Browse Source

don't introduce matrix errors from the lifter

David Rose 22 years ago
parent
commit
f55e4d2e1e
1 changed files with 17 additions and 4 deletions
  1. 17 4
      panda/src/collide/collisionHandlerFloor.cxx

+ 17 - 4
panda/src/collide/collisionHandlerFloor.cxx

@@ -125,10 +125,23 @@ handle_entries() {
             adjust = max(adjust, -max_adjust);
           }
           
-          LMatrix4f mat;
-          def.get_mat(mat);
-          mat(3, 2) += adjust;
-          def.set_mat(mat);
+          if (def._node != (PandaNode *)NULL) {
+            // If we are adjusting a plain PandaNode, get the
+            // transform and adjust just the Z value to preserve
+            // maximum precision.
+            CPT(TransformState) trans = def._node->get_transform();
+            LVecBase3f pos = trans->get_pos();
+            pos[2] += adjust;
+            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);
+            mat(3, 2) += adjust;
+            def.set_mat(mat);
+          }
         } else {
           if (collide_cat.is_spam()) {
             collide_cat.spam()