Collision Detection Problem | Chain Links

Hey everyone,

I am new to Panda3d and am currently trying to solve some problems regarding a physics simulation I want to code using Panda3d ( and Bullet). The simulation features around multiple link components which are linked together (see picture). The tricky part is that the linkages (consisting of two parts) are all actors as they are animated (using blender 2.7) to expand and contract, making the chain longer and shorter.

I managed to implement the links in my program, but am struggling to find the right way to add collision detection to it.
I tried using the collide game property in blender and adding a bitmask with the models geometry, but it doesn’t seem to work as an actor (only as a model). Otherwise adding 4 collision solids boxes and form in the model with it seem like an awful complicated solution?
As there are many different ways that collision detection can be done in Panda3d what is the best way for this problem?

I hope I could outline my problem clearly and hope that anyone can help me with it :slight_smile:

I don’t know of one “best” way, but do have a thought or two:

Primarily, is it important that the chain-links interact with each other physically, or that their collision be especially accurate?

If not, I’d suggest just using one box or capsule per link–that should be reasonably simple, and reasonably accurate. Furthermore, while I don’t know about Bullet’s capsules, I do recall that Panda’s capsules can have their extents changed on the fly, allowing for such colliders to adjust to your expanding-and-contracting chain.

(If physical interaction between links is important, then does Blender-made animation not conflict with such physics?)

Yes, the interaction between the links is important, but doesn’t need to be especially accurate. The links are required to have contact (mostly on the end bits) while expanding, through a force that is applied at either end.

Do u think it might be easier to just cut the link in half and import it as a model, while creating the animation in my code using interval positioning? Therefore, the use of bitmask could resolve the problem of collision detection.

Ah, I see. In that case, either two or four boxes per link (depending on whether the sides of the links are required) isn’t a bad way of modelling it, I think.

I’m more thinking that non-physics-based animation might not respect the physical interactions. That is, if you have an animation that moves the links through each other, it’s not going to stop because there was a physics collision.

I would expect much the same when using intervals, I think.

Something more code-driven, a frame-to-frame simulation of their movement, might be more reliable.

[edit]
All that said, if you move away from Actor-based animation then your original models might just work. Just be careful to not make their polygon counts too high, or to use a lower-detail copy for the collision!

Thank you for highlighting that! I didn’t think of that at all. Therefore, a model-based approach seems much more reasonable and less complicated.

Would the frame to frame animation then simply be an adjustment of all link positions per each frame using the setPos command or can that be done more efficiently?

It’s my pleasure. :slight_smile:

That’s probably what I’d do, indeed. I don’t know whether there’s a more efficient way, but I’d expect it to work for most purposes.