Browse Source

don't introduce matrix errors from the pusher

David Rose 22 years ago
parent
commit
ea1b5a99f6
1 changed files with 15 additions and 3 deletions
  1. 15 3
      panda/src/collide/collisionHandlerPusher.cxx

+ 15 - 3
panda/src/collide/collisionHandlerPusher.cxx

@@ -252,9 +252,21 @@ handle_entries() {
           }
 #endif
           
-          LMatrix4f mat;
-          def.get_mat(mat);
-          def.set_mat(LMatrix4f::translate_mat(net_shove) * mat);
+          if (def._node != (PandaNode *)NULL) {
+            // If we are adjusting a plain PandaNode, get the
+            // transform and adjust just the position to preserve
+            // maximum precision.
+            CPT(TransformState) trans = def._node->get_transform();
+            LVecBase3f pos = trans->get_pos();
+            pos += net_shove * trans->get_mat();
+            def._node->set_transform(trans->set_pos(pos));
+          } else {          
+            // Otherwise, go ahead and do the matrix math to do things
+            // the old and clumsy way.
+            LMatrix4f mat;
+            def.get_mat(mat);
+            def.set_mat(LMatrix4f::translate_mat(net_shove) * mat);
+          }
         }
       }
     }