Skip to content

Commit

Permalink
fix: bone processing in RemoveMeshInBoxProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Feb 5, 2023
1 parent 82ba212 commit b2fea4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Editor/Processors/SkinnedMeshes/MeshInfo2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private Vertex(Vertex vertex)

public Vertex Clone() => new Vertex(this);

public Vector3 ComputeActualPosition(MeshInfo2 meshInfo2)
public Vector3 ComputeActualPosition(MeshInfo2 meshInfo2, Matrix4x4 rendererWorldToLocalMatrix)
{
var position = Position;

Expand All @@ -449,7 +449,9 @@ public Vector3 ComputeActualPosition(MeshInfo2 meshInfo2)
var boneMat = transformMat * bone.Bindpose;
MulAdd(ref matrix, boneMat, weight);
}
return matrix * position;

matrix = rendererWorldToLocalMatrix * matrix;
return matrix * new Vector4(position.x, position.y, position.z, 1f);
}

// UnityEngine doesn't provide Matrix4x4 + Matrix4x4 and Matrix4x4 * float.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override void Process(OptimizerSession session, MeshInfo2 target, MeshInf
// Vertex.AdditionalTemporal: 0 if in box, 1 if out of box
foreach (var vertex in target.Vertices)
{
Vector3 actualPosition = Target.transform.worldToLocalMatrix * vertex.ComputeActualPosition(target);
var actualPosition = vertex.ComputeActualPosition(target, Target.transform.worldToLocalMatrix);
vertex.AdditionalTemporal = Component.boxes.Any(x => x.ContainsVertex(actualPosition)) ? 0 : 1;
}

Expand Down

0 comments on commit b2fea4f

Please sign in to comment.