Browse Source

Fixed buggy scaling for multi-shape bodies.

enn0x 12 years ago
parent
commit
0f22583ba5
1 changed files with 5 additions and 7 deletions
  1. 5 7
      panda/src/bullet/bulletRigidBodyNode.cxx

+ 5 - 7
panda/src/bullet/bulletRigidBodyNode.cxx

@@ -288,15 +288,13 @@ transform_changed() {
   }
 
   // Rescale all shapes, but only if the new transform state
-  // has a scale
+  // has a scale, and this scale differes from the current scale.
   if (ts->has_scale()) {
-    LVecBase3 scale = ts->get_scale();
-    if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
-      for (int i=0; i<get_num_shapes(); i++) {
-        PT(BulletShape) shape = _shapes[i];
-        shape->set_local_scale(scale);
-      }
+    btVector3 new_scale = LVecBase3_to_btVector3(ts->get_scale());
+    btVector3 current_scale = _shape->getLocalScaling();
 
+    if (new_scale != current_scale) {
+      _shape->setLocalScaling(new_scale);
       shape_changed();
     }
   }