I’ve been trying to make some test cases to gain an understanding of collision detection in Panda3d. After reading through the manual and collision tutorials, I decided to try to make the following test case:
Have stationary ball3 get hit by moving ball5 and then throw an event flag.
I’m fairly certain this code should produce a collision. What am I missing?
So I got collision detection working. I am unable to use a loaded egg model with more than 1 collision object at a time though.
For example if I want to use a model called ball.egg for collision objects balla and ballb, they end up passing through each other. On the other hand, if I make a copy of the physical egg file and name it ball1. I can set balla to ball and ballb to ball1 and they correctly collide.
How can i get around this so I can use the same model for both balla and ballb?
It turns out that there’s an optimization deep within the collision system, to avoid testing an object for collisions against itself. This is often a good idea: if an object detects a collision with itself, it is likely to detect that collision every frame, and erroneous behavior can result.
In this case, you don’t, precisely, have an object testing against collisions with itself–you have two different instances of an object testing for collisions with each other. That should be legitimate, but the self-test is short-circuiting that incorrectly.
This is arguably a bug. It may be easy to fix, but the fix might introduce unintended side-effects. We will have to investigate this carefully.
In the meantime, one possible workaround is to rename the egg file, as you have discovered. Another possibility is to put “noCache = True” on the loader.loadModel() call for one or both models–this will force it to re-read the egg file from disk, instead of sharing some content with the egg file previously returned.