Browse Source

updated to new collision API

Joe Shochet 21 years ago
parent
commit
ab4011179c

+ 2 - 2
direct/src/directtools/DirectCameraControl.py

@@ -299,7 +299,7 @@ class DirectCameraControl(PandaObject):
             nodePath = entry.getIntoNodePath()
             if direct.camera not in nodePath.getAncestry():
                 # Compute new hit point
-                hitPt = entry.getFromIntersectionPoint()
+                hitPt = entry.getSurfacePoint(entry.getFromNodePath())
                 # Move coa marker to new point
                 self.updateCoa(hitPt, ref = self.coaMarkerRef)
             else:
@@ -319,7 +319,7 @@ class DirectCameraControl(PandaObject):
         elif entry:
             # Got a hit point (hit point is in camera coordinates)
             # Set center of action
-            hitPt = entry.getFromIntersectionPoint()
+            hitPt = entry.getSurfacePoint(entry.getFromNodePath())
             hitPtDist = Vec3(hitPt).length()
             coa.assign(hitPt)
             # Handle case of bad coa point (too close or too far)

+ 3 - 3
direct/src/directtools/DirectManipulation.py

@@ -44,7 +44,7 @@ class DirectManipulationControl(PandaObject):
         # Did we hit a widget?
         if entry:
             # Yes!
-            self.hitPt.assign(entry.getFromIntersectionPoint())
+            self.hitPt.assign(entry.getSurfacePoint(entry.getFromNodePath()))
             self.hitPtDist = Vec3(self.hitPt).length()
             # Constraint determined by nodes name
             self.constraint = entry.getIntoNodePath().getName()
@@ -93,7 +93,7 @@ class DirectManipulationControl(PandaObject):
             entry = direct.iRay.pickGeom(skipFlags = skipFlags)
             if entry:
                 # Record hit point information
-                self.hitPt.assign(entry.getFromIntersectionPoint())
+                self.hitPt.assign(entry.getSurfacePoint(entry.getFromNodePath()))
                 self.hitPtDist = Vec3(self.hitPt).length()
                 # Select it
                 direct.select(entry.getIntoNodePath(), direct.fShift)
@@ -494,7 +494,7 @@ class DirectManipulationControl(PandaObject):
             direct.selected.getWrtAll()
             # Move selected
             direct.widget.setPos(
-                direct.camera,entry.getFromIntersectionPoint())
+                direct.camera,entry.getSurfacePoint(entry.getFromNodePath()))
             # Move all the selected objects with widget
             # Move the objects with the widget
             direct.selected.moveWrtWidgetAll()

+ 8 - 6
direct/src/directtools/DirectSelection.py

@@ -490,12 +490,13 @@ class SelectionQueue(CollisionHandlerQueue):
         # If dot product of collision point surface normal and
         # ray from camera to collision point is positive, we are
         # looking at the backface of the polygon
-        if not entry.hasFromSurfaceNormal():
+        if not entry.hasSurfaceNormal():
             # Well, no way to tell.  Assume we're not backfacing.
             return 0
-        
-        v = Vec3(entry.getFromIntersectionPoint())
-        n = entry.getFromSurfaceNormal()
+
+        fromNodePath = entry.getFromNodePath()
+        v = Vec3(entry.getSurfacePoint(fromNodePath))
+        n = entry.getSurfaceNormal(fromNodePath)
         # Convert to camera space for backfacing test
         if self.collisionNodePath.getParent() != base.cam:
             # Problem: assumes base.cam is the camera in question
@@ -687,9 +688,10 @@ class SelectionSphere(SelectionQueue):
         # If dot product of collision point surface normal and
         # ray from sphere origin to collision point is positive, 
         # center is on the backside of the polygon
-        v = Vec3(entry.getFromIntersectionPoint() -
+        fromNodePath = entry.getFromNodePath()
+        v = Vec3(entry.getSurfacePoint(fromNodePath) -
                  entry.getFrom().getCenter())
-        n = entry.getFromSurfaceNormal()
+        n = entry.getSurfaceNormal(fromNodePath)
         # If points almost on top of each other, reject face
         # (treat as backfacing)
         if v.length() < 0.05: