It seems to me that com.unity.physics does not respect the TransformUsageFlags principles.
For instance, if I understand well, transform parent relationships should only be kept after baking if some behavior declares a DYNAMIC transform usage. However, in a very simple case with two authoring game objects Collider and Sub_Collider where both only have a Box Collider authoring component and Sub_Collider is child of Collider, as shown in the screenshot, the parent relationship is preserved after baking. (And also they have both LocalTransform and LocalToWorld which seems unnecessary?)
#Built-in Physics Authoring and Transforms
1 messages · Page 1 of 1 (latest)
Shouldn't you check the static box at the top of the inspector to make the baking system not set the dynamic flag ?
I somewhat considered this; though it seems that it does a lot of stuff, and in particular, it seems to enable light baking which is not what I am after.
Also I would still think a component should only add the Dynamic flag if it moves the object which is not the case for the collider. (I mean if the presence of the component implies the movement of the entity)
It would be very interesting to have the take of someone from the Unity.Physics team on this matter 😊
If you throw a static optimise entity on here does it still add dynamic
I tested with static optimise entity, and I think remembering that the issue was that this implied that any child of the entity are also then considered static.
Indeed, in IBaker.IsStatic(GameObject gameObject):
gameObject.GetComponentInParent<StaticOptimizeEntity>(gameObject)
That is correct but now I'm confused
Your colliders are static as they have no body so why does that matter?
There could be a dynamic child without a collider for instance.
And for a dynamic child with a collider, it would ideally be unparented during baking (as I think it already is the case?)
Is this a prefab or a root scene object?
It would be for prefabs (I know they are always dynamic, but I modified the entities package to prevent that); but I guess it could also apply to scene objects
Haha yeah I also have a fork that does that
But anyway physics declares a dynamic transform flag because it expects anything not marked static explicitly to be dynamic
It's kind of using the transforms flags as expected?
Maybe I just misunderstood what you're trying to do
I would not agree that it is using transform flags as expected.
My understanding from is that the authoring component implying the runtime movement should be the one setting the flags as dynamic.
But after looking at the physics baking code, I think they might do it this way to ensure that physic entities always have a LocalTransform component (which if I am not mistaken is not guaranteed by default).
Yes dynamic flag is how localtransform is added and if you aren't marked static, what physics uses for position