Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,32 +66,30 @@ public static Bounds CalculateLocalRenderBounds(GameObject parent)
{
if (r == null) continue;

Bounds srcLocal;
Bounds transformed;

if (r is SkinnedMeshRenderer smr)
{
// In smr local space
srcLocal = smr.localBounds;
// Transform bounds center and extents to new AABB in parent local space
transformed = TransformBoundsAABB(smr.bounds, parentWorldToLocal);
}
else if (r is MeshRenderer mr)
{
var mf = mr.GetComponent<MeshFilter>();
if (mf == null || mf.sharedMesh == null) continue;

// In mesh local space (same as MeshFilter transform local space)
srcLocal = mf.sharedMesh.bounds;
var srcLocal = mf.sharedMesh.bounds;
// Map from renderer local -> world -> parent local
Matrix4x4 toParentLocal = parentWorldToLocal * r.transform.localToWorldMatrix;
// Transform bounds center and extents to new AABB in parent local space
transformed = TransformBoundsAABB(srcLocal, toParentLocal);
}
else
{
continue; // ignore other renderer types for now
}

// Map from renderer local -> world -> parent local
Matrix4x4 toParentLocal = parentWorldToLocal * r.transform.localToWorldMatrix;

// Transform bounds center and extents to new AABB in parent local space
Bounds transformed = TransformBoundsAABB(srcLocal, toParentLocal);

if (!hasAny)
{
accum = transformed;
Expand Down