Simplify code and allow any actor as parent.

This commit is contained in:
Menotdan
2023-12-09 17:56:09 -05:00
parent 4e54e945ef
commit 2f50042523

View File

@@ -8,20 +8,15 @@ namespace FlaxEngine
public override void OnActorSpawned()
{
base.OnActorSpawned();
if (Parent is StaticModel model)
{
Vector3 modelScale = model.Scale;
Vector3 modelSize = model.Box.Size;
Vector3 modelCenter = model.Box.Center - model.Position;
Vector3 colliderSize = modelSize / modelScale;
Vector3 colliderCenter = modelCenter / modelScale;
Vector3 parentScale = Parent.Scale;
Vector3 parentSize = Parent.Box.Size;
Vector3 parentCenter = Parent.Box.Center - Parent.Position;
Size = colliderSize;
Center = colliderCenter;
Size = parentSize / parentScale;
Center = parentCenter / parentScale;
// Undo Rotation
Orientation *= Quaternion.Invert(Orientation);
}
// Undo Rotation
Orientation *= Quaternion.Invert(Orientation);
}
}
}