Skip to content

Apply transform of first LOD to MeshAsset Instances#726

Draft
aidandavey wants to merge 6 commits intoTokisanGames:mainfrom
aidandavey:Apply-MA-Transforms
Draft

Apply transform of first LOD to MeshAsset Instances#726
aidandavey wants to merge 6 commits intoTokisanGames:mainfrom
aidandavey:Apply-MA-Transforms

Conversation

@aidandavey
Copy link
Copy Markdown
Contributor

@aidandavey aidandavey commented Jun 19, 2025

As discussed on previous PR #724, applying transforms from the first LOD mesh in the MeshAsset file while painting instances.

@aidandavey aidandavey marked this pull request as ready for review June 19, 2025 20:47
@TokisanGames TokisanGames added the enhancement New feature or request label Jun 27, 2025
@TokisanGames TokisanGames added this to the 1.1 milestone Jun 27, 2025
@TokisanGames TokisanGames self-assigned this Jun 28, 2025
@TokisanGames TokisanGames force-pushed the Apply-MA-Transforms branch from 035737d to 7f57fa6 Compare July 11, 2025 15:50
@TokisanGames
Copy link
Copy Markdown
Owner

TokisanGames commented Jul 11, 2025

Thanks for the start on this. I've rebased it and started to review it, thinking about what we should be doing with this corrective feature.

Background

The LODs in the example are setup how they often will be coming in from an artist with a bunch of LODs underneath a Blender Empty node. The root node might be setup as a static body. Below that will often be a parent node for all of the meshes, either a Node3D as here, or a Blender Armature or Skeleton3D node. Or the mesh lods might just be dumped under the root. Then a collision node will be under the root.
{BA59D943-2519-4F54-B301-611B61F52CB1}

I don't want to encourage poor behavior by accommodating and fixing every artist created problems, especially if it's a lot of code for us. I do want to facilitate convenience, so if it's a minor thing for great convenience, then fine.

So now the question is, where in this tree might there be transforms, and why?

  1. LOD misalignment where LOD0, LOD1, LOD2+ have different transforms. This is a messy asset that we should not accommodate by handling every LOD transform. This needs to be fixed in blender by the artist.
  2. Import/export issues. Sometimes transferring assets between UE/Unity/Blender/DCC have different coordinate systems so the incoming asset is 90 degrees off on one axis. Sometimes transforms haven't been applied properly, or are baked into the animations where the root/mesh parent node is scaled to 0.01 but the meshes and baked animations are scaled to 100 (though we won't have animations on instanced nodes), and they can't be fixed in the DCC. These are very annoying, and easier to fix in the scene with a rotation/scale on the root/mesh parent. We can accommodate this.
  3. The origin / scale is off on the mesh parent/root node. It's an artist issue, that should be fixed in Blender, but it can be provided for free by fixing the above issue.

Review

In this PR, you've captured the LOD0 local transform. But we should capture the root / mesh parent transform, or get the LOD0 global transform (not available), or all of the transforms between LOD0 and the scene root.

I swapped example LOD0/1. Then transformed the mesh parent to affect all LODs simultaneously to rotate it as follows. However, placing this on the terrain it still appears flat because there are no transforms on LOD0:

{13A3F30B-958F-4164-A349-2C4C528FFDAE}

Accumulating the transforms from LOD0 to scene root allows this to work:

{D1722D35-D31F-402D-8573-0C3396EDEED0}

Because the mesh asset transform is intended to be corrective (moving a transform to 0 or resetting rotation to neutral), I also think the mesh asset transform needs to be applied before the instancer applied transforms which are for variation. This is a bit more complicated, so I'll address it in another commit and comment.

@aidandavey
Copy link
Copy Markdown
Contributor Author

Thinking on this, baking the LOD transform into the instance data might not be what we want to do. It doesn't allow for modification afterwards, and causes an issue with my instance collision PR since I need the shape positions, not the LOD.

In fact baking the variation transforms might already be an issue there.

I'm thinking the instancer data could hold the instance_origin, and a variation transform.

The LOD transform, and CollisionShape transform, will remain in the MA data and can be applied in update_mmis and/or update_instance_collision, in the proper order region->instance->correction->variation

This also sets us up to support an instance transform brush, so you can paint alternative variation.

@TokisanGames TokisanGames marked this pull request as draft November 10, 2025 00:49
@TokisanGames TokisanGames modified the milestones: 1.1, 1.2 Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants