mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
bullet: workaround for deadlock adding shape to scaled body (#689)
This commit is contained in:
parent
24d48d8cb0
commit
c54f964a3b
@ -353,9 +353,17 @@ do_add_shape(BulletShape *bullet_shape, const TransformState *ts) {
|
|||||||
|
|
||||||
// Reset the shape scaling before we add a shape, and remember the current
|
// Reset the shape scaling before we add a shape, and remember the current
|
||||||
// Scale so we can restore it later...
|
// Scale so we can restore it later...
|
||||||
NodePath np = NodePath::any_path((PandaNode *)this);
|
CPT(TransformState) prev_transform = get_transform();
|
||||||
LVector3 scale = np.get_scale();
|
bool scale_changed = false;
|
||||||
np.set_scale(1.0);
|
if (!prev_transform->is_identity() && prev_transform->get_scale() != LVecBase3(1.0, 1.0, 1.0)) {
|
||||||
|
// As a hack, temporarily release the lock, since transform_changed will
|
||||||
|
// otherwise deadlock trying to grab it again. See GitHub issue #689.
|
||||||
|
LightMutex &lock = BulletWorld::get_global_lock();
|
||||||
|
lock.release();
|
||||||
|
set_transform(prev_transform->set_scale(LVecBase3(1.0, 1.0, 1.0)));
|
||||||
|
lock.acquire();
|
||||||
|
scale_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Root shape
|
// Root shape
|
||||||
btCollisionShape *previous = get_object()->getCollisionShape();
|
btCollisionShape *previous = get_object()->getCollisionShape();
|
||||||
@ -417,7 +425,13 @@ do_add_shape(BulletShape *bullet_shape, const TransformState *ts) {
|
|||||||
_shapes.push_back(bullet_shape);
|
_shapes.push_back(bullet_shape);
|
||||||
|
|
||||||
// Restore the local scaling again
|
// Restore the local scaling again
|
||||||
np.set_scale(scale);
|
if (scale_changed) {
|
||||||
|
CPT(TransformState) transform = get_transform()->set_scale(prev_transform->get_scale());
|
||||||
|
LightMutex &lock = BulletWorld::get_global_lock();
|
||||||
|
lock.release();
|
||||||
|
set_transform(std::move(transform));
|
||||||
|
lock.acquire();
|
||||||
|
}
|
||||||
|
|
||||||
do_shape_changed();
|
do_shape_changed();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user