Files
test2/source/blender
Philipp Oeser 566a38ffee Fix: Crash rendering of rigid body setup without baking dynamics first
When rendering animation without baking dynamics first, rigid body
objects/shapes might be set up for the fist time (see
`rigidbody_update_simulation`).

Here is my take on what happens when we run into the reported crash:

In `rigidbody_validate_sim_object`, `rigidbody_validate_sim_shape` can
be called (which -- amongst other things -- can call `RB_shape_delete`).
It does not set `RBO_FLAG_NEEDS_RESHAPE` nor calls
`RB_body_set_collision_shape`. It only sets `rbo->shared->physics_shape`
(which only seems to to update the "blender side of things", but not the
"bullet side of things").

Then later (still in `rigidbody_validate_sim_object`),
`RB_dworld_add_body`/ `btDiscreteDynamicsWorld::addRigidBody`>
`btCollisionWorld::addCollisionObject` > collisionObject->getCollisionShape()
 is called, but confused because we called `RB_shape_delete` before.

Also see the TODO(Sybren) comment from 98a0bcd425 (which might even be
removed with this PR, but not I havent verified "collision shape being
created twice" is now not happening anymore).

One might think that flagging `RBO_FLAG_NEEDS_RESHAPE` might be enough,
but reacting on that only happens later in `rigidbody_update_simulation`
(so not early enough to not run into the issues of `RB_dworld_add_body`
above).

So to resolve, call `RB_body_set_collision_shape` in
`rigidbody_validate_sim_shape` if we actually made a new one.

Fixes #130991

Pull Request: https://projects.blender.org/blender/blender/pulls/131039
2024-12-06 17:14:49 +01:00
..
2024-11-22 09:40:51 -05:00
2024-09-20 13:14:57 +10:00
2024-10-04 11:33:21 +02:00
2024-10-23 13:14:37 +11:00