View Single Post
  #2  
Old 10-11-2006, 04:04 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
viz.intersect() is different from physics collision callbacks. viz.intersect() returns collisions over a line. The physics callbacks are triggered when two objects collide. So it depends on what you need.

If you need line intersection tests, then viz.phys.intersectLine() will be much faster than viz.intersect. However, viz.phys.intersectLine() only returns results for objects that are part of the physics simulation. So you must define a collision volume for each node that should take part in the intersection test.

If you want know when two objects are colliding then you have two options. Use the physics collision callbacks. You must explicitly enable collision notifications for each object that you are interested in:
Code:
node.enable(viz.COLLIDE_NOTIFY)
Look at the duckcourt script for an example. The other option is to use the viz.phys.intersectNode command. This will return a list of all the nodes an object is colliding with. However, similar to the viz.phys.intersectLine() command, it only checks for collisions with objects that are part of the physics simulation.

In general it is more efficient to handle collision callbacks than to manually query for intersections every frame.
Reply With Quote