![]() |
#1
|
|||
|
|||
Intersect vs collision
Is it more efficient framewise to detect collisions with viz.intersect()
or physics collide callbacks? |
#2
|
|||
|
|||
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) In general it is more efficient to handle collision callbacks than to manually query for intersections every frame. |
#3
|
|||
|
|||
line touching cylinder
I am trying to detect when an on the fly line is in contact
with a cylinder. Which method would be most efficient? |
#4
|
|||
|
|||
In this case collision callbacks won't work, so you need to manually call the intersect function yourself.
|
#5
|
|||
|
|||
FYI the collision callback method does work with an on-the-fly line if you
specify .collideBox(). It doesn't work with .collideMesh(). |
#6
|
|||
|
|||
Why? Will the collision callbacks work while dragging something with the HD? That's what I'm trying to do....
|
#7
|
|||
|
|||
Yes, the callbacks will still work when you are dragging an object. Like I mentioned above, you will need to explicitly enable collision notifications on an object for a callback to be triggered.
|
#8
|
|||
|
|||
Quote:
made a bunch of screws and said this for each one: Code:
screw.collideCapsule() screw.enable(viz.COLLIDE_NOTIFY) Code:
currentBox.collideMesh() #make a collision mesh so we know when screws hit it currentBox.enable(viz.COLLIDE_NOTIFY) Code:
def onCollide(e): print "collision!" global allM1Screws, allM2Screws #Did a screw hit the box? if ((e.obj2 in allM1Screws) or (e.obj2 in allM2Screws)): #Change color of box e.obj1.color( random.choice( [viz.RED,viz.GREEN,viz.SKYBLUE,viz.YELLOW,viz.ORANGE,viz.PURPLE] ) ) viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide ) viz.collision(viz.ON) Last edited by mjabon; 07-16-2007 at 02:28 PM. Reason: forgot something |
#9
|
|||
|
|||
try doing this
currentBox.collideMesh() currentBox.enable(viz.COLLIDE_NOTIFY) currentBox.enable(viz.CONTACTS) hope that was helpfull ![]() |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|