Procházet zdrojové kódy

back out changes, they is broken

cxgeorge před 24 roky
rodič
revize
cdcf5913f1

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

@@ -172,28 +172,19 @@ handle_entries() {
           }
           }
         }
         }
 
 
-        LMatrix4f mat;
-        def.get_mat(mat);
-
-        // def.set_mat(LMatrix4f::translate_mat(net_shove) * mat);
-
-        mat(3,0) += net_shove[0];
-        mat(3,1) += net_shove[1];
-
-        if (!_horizontal) {
-          mat(3,2) += net_shove[2];
+        if (_horizontal) {
+          net_shove[2] = 0.0;
         }
         }
 
 
-        def.set_mat(mat);
-
         if (collide_cat.is_debug()) {
         if (collide_cat.is_debug()) {
-          if (_horizontal)
-             net_shove[2] = 0.0;
-
           collide_cat.debug()
           collide_cat.debug()
             << "Net shove on " << *from_node << " is: "
             << "Net shove on " << *from_node << " is: "
             << net_shove << "\n";
             << net_shove << "\n";
         }
         }
+
+        LMatrix4f mat;
+        def.get_mat(mat);
+        def.set_mat(LMatrix4f::translate_mat(net_shove) * mat);
       }
       }
     }
     }
   }
   }

+ 4 - 10
panda/src/collide/collisionPlane.cxx

@@ -125,17 +125,11 @@ test_intersection_from_sphere(CollisionHandler *record,
   DCAST_INTO_R(sphere, entry.get_from(), 0);
   DCAST_INTO_R(sphere, entry.get_from(), 0);
 
 
   LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
   LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
-  float dist = dist_to_plane(from_center);
-//  LVector3f from_radius_v =
-//    LVector3f(sphere->get_radius(), 0.0f, 0.0f) * entry.get_wrt_space();
-//  float from_radius = length(from_radius_v);
-
-  const LMatrix4f *pMat = &entry.get_wrt_space();
-  float from_radius = sphere->get_radius() *
-                      sqrtf((*pMat)(0,0)*(*pMat)(0,0) + 
-                            (*pMat)(0,1)*(*pMat)(0,1) + 
-                            (*pMat)(0,2)*(*pMat)(0,2));
+  LVector3f from_radius_v =
+    LVector3f(sphere->get_radius(), 0.0f, 0.0f) * entry.get_wrt_space();
+  float from_radius = length(from_radius_v);
 
 
+  float dist = dist_to_plane(from_center);
   if (dist > from_radius) {
   if (dist > from_radius) {
     // No intersection.
     // No intersection.
     return 0;
     return 0;

+ 5 - 15
panda/src/collide/collisionPolygon.cxx

@@ -239,20 +239,12 @@ test_intersection_from_sphere(CollisionHandler *record,
   DCAST_INTO_R(sphere, entry.get_from(), 0);
   DCAST_INTO_R(sphere, entry.get_from(), 0);
 
 
   LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
   LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
-  float dist = dist_to_plane(from_center);
-
-//  LVector3f from_radius_v =
-//    LVector3f(sphere->get_radius(), 0.0f, 0.0f) * entry.get_wrt_space();
-//  float from_radius = length(from_radius_v);
-
-  const LMatrix4f *pMat = &entry.get_wrt_space();
-  float from_radius = sphere->get_radius() *
-                      sqrtf((*pMat)(0,0)*(*pMat)(0,0) + 
-                            (*pMat)(0,1)*(*pMat)(0,1) + 
-                            (*pMat)(0,2)*(*pMat)(0,2));
+  LVector3f from_radius_v =
+    LVector3f(sphere->get_radius(), 0.0f, 0.0f) * entry.get_wrt_space();
+  float from_radius = length(from_radius_v);
 
 
-//  if (dist > from_radius || dist < -from_radius) {
-  if (fabs(dist) > from_radius) {
+  float dist = dist_to_plane(from_center);
+  if (dist > from_radius || dist < -from_radius) {
     // No intersection.
     // No intersection.
     return 0;
     return 0;
   }
   }
@@ -265,9 +257,7 @@ test_intersection_from_sphere(CollisionHandler *record,
   bool really_intersects =
   bool really_intersects =
     get_plane().intersects_line(plane_point,
     get_plane().intersects_line(plane_point,
                                 from_center, from_center + get_normal());
                                 from_center, from_center + get_normal());
-#ifdef _DEBUG
   nassertr(really_intersects, 0);
   nassertr(really_intersects, 0);
-#endif
 
 
   LPoint2f p = to_2d(plane_point);
   LPoint2f p = to_2d(plane_point);
 
 

+ 9 - 14
panda/src/collide/collisionSphere.cxx

@@ -123,22 +123,17 @@ test_intersection_from_sphere(CollisionHandler *record,
   const CollisionSphere *sphere;
   const CollisionSphere *sphere;
   DCAST_INTO_R(sphere, entry.get_from(), 0);
   DCAST_INTO_R(sphere, entry.get_from(), 0);
 
 
- //from_radius_v = LVector3f(sphere->get_radius(), 0.0, 0.0) * entry.get_wrt_space();
- //float from_radius = length(from_radius_v);
-
-  const LMatrix4f *pMat = &entry.get_wrt_space();
-  float from_radius = sphere->get_radius() *
-                      sqrtf((*pMat)(0,0)*(*pMat)(0,0) + 
-                            (*pMat)(0,1)*(*pMat)(0,1) + 
-                            (*pMat)(0,2)*(*pMat)(0,2));
-
   LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
   LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
-  LVector3f vec = from_center - _center;
+  LVector3f from_radius_v =
+    LVector3f(sphere->get_radius(), 0.0, 0.0) * entry.get_wrt_space();
+  float from_radius = length(from_radius_v);
 
 
-  float dist2 = dot(vec, vec);
-  float total_radius = _radius + from_radius;
+  LPoint3f into_center = _center;
+  float into_radius = _radius;
 
 
-  if (dist2 > total_radius * total_radius) {
+  LVector3f vec = from_center - into_center;
+  float dist2 = dot(vec, vec);
+  if (dist2 > (into_radius + from_radius) * (into_radius + from_radius)) {
     // No intersection.
     // No intersection.
     return 0;
     return 0;
   }
   }
@@ -153,7 +148,7 @@ test_intersection_from_sphere(CollisionHandler *record,
   float dist = sqrtf(dist2);
   float dist = sqrtf(dist2);
   LVector3f into_normal = normalize(vec);
   LVector3f into_normal = normalize(vec);
   LPoint3f into_intersection_point = into_normal * (dist - from_radius);
   LPoint3f into_intersection_point = into_normal * (dist - from_radius);
-  float into_depth = total_radius - dist;
+  float into_depth = into_radius + from_radius - dist;
 
 
   new_entry->set_into_surface_normal(into_normal * entry.get_inv_wrt_space());
   new_entry->set_into_surface_normal(into_normal * entry.get_inv_wrt_space());
   new_entry->set_into_intersection_point(into_intersection_point * entry.get_inv_wrt_space());
   new_entry->set_into_intersection_point(into_intersection_point * entry.get_inv_wrt_space());