updated to new collision API

This commit is contained in:
Joe Shochet 2004-06-14 19:31:47 +00:00
parent 99d24b226b
commit ab4011179c
3 changed files with 13 additions and 11 deletions

View File

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

View File

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

View File

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