I have a hierarchy of Unity objects, and each object in the hierarchy has a (non-uniform) scale and rotation.
For example, my hierarchy may be A->B->C.
I’m trying to write a script to “bake” the scale of these objects into the meshes in the hierarchy, so from the point of view of the rendering engine, all objects will have a scale of (1,1,1). This will allow batching to work more reliably, and more importantly, should avoid huge spikes I’m getting due to lots of calls to BakeScaledMeshCollisionData. The object hierarchies in question will be used as runtime-prefabs. I’ve verified this solution works for my needs using simple un-parented objects.
What I need help with, is figuring out how to do this in a hierarchy of objects. In other words - given the hierarchy above, how do I determine for each object what scale to apply?
Basically - how do I recreate the effects of the transforms of all the objects in the hierarchy into a single matrix, that I can then use to transform the verts of the mesh, while setting the localscale of each object in the hierachy to 1.0, to get the same effect?