Explorar o código

bullet: prevent softbody with AABB out of bounds from asserting

See #357
rdb %!s(int64=7) %!d(string=hai) anos
pai
achega
5fe294a467
Modificáronse 1 ficheiros con 9 adicións e 2 borrados
  1. 9 2
      panda/src/bullet/bulletSoftBodyNode.cxx

+ 9 - 2
panda/src/bullet/bulletSoftBodyNode.cxx

@@ -276,8 +276,15 @@ do_sync_b2p() {
 
 
   // Update the synchronized transform with the current approximate center of
   // Update the synchronized transform with the current approximate center of
   // the soft body
   // the soft body
-  LVecBase3 pos = this->do_get_aabb().get_approx_center();
-  CPT(TransformState) ts = TransformState::make_pos(pos);
+  btVector3 pMin, pMax;
+  _soft->getAabb(pMin, pMax);
+  LPoint3 pos = (btVector3_to_LPoint3(pMin) + btVector3_to_LPoint3(pMax)) * 0.5;
+  CPT(TransformState) ts;
+  if (!pos.is_nan()) {
+    ts = TransformState::make_pos(pos);
+  } else {
+    ts = TransformState::make_identity();
+  }
 
 
   NodePath np = NodePath::any_path((PandaNode *)this);
   NodePath np = NodePath::any_path((PandaNode *)this);
   LVecBase3 scale = np.get_net_transform()->get_scale();
   LVecBase3 scale = np.get_net_transform()->get_scale();