diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index 5b8f451556..2180cdf8c1 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/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()