ODE collisions

OdeUtil.collide(geom1,geom2) returns an OdeCollisionEntry. But in order to create an OdeContactJoint(OdeWorld,OdeContact) i need an OdeContact.
How do i get the OdeContact.

From PyODE i see that:

    # Check if the objects do collide
    contacts = ode.collide(geom1, geom2)

    # Create contact joints
    world,contactgroup = args
    for c in contacts:
        j = ode.ContactJoint(world, contactgroup, c)
        j.attach(geom1.getBody(), geom2.getBody())

So the ode.collide seems to return a list of contacts.

So how do i contsruct a OdeContactJoint(OdeWorld,OdeContact) ?

Its a bit of a pain to do what you intend to be honest, though it is doable. You basically have to construct each OdeContact manually - all the information is there to be extracted from the OdeCollisionEntry. Well, the geom is extractable, the surface (Friction parameters etc.) you have to provide yourself (But would have to be provided somewhere else anyway.) and the friction direction can be calculated from the velocities of the bodies and the collision surface normal in the geom.

My advice would be to find another way of doing it though - preferably by using the automatic collision detection joint creation provided. (I’ld be surprised if you can’t, even if it does involve a creative use of masks, spaces etc.) I don’t know why you want to do the above, but if your following a tutorial/example then that is not the way Panda ode does it; if on the other hand you have a good reason to do this I could work out the code easily enough.

i have no trouble using autocollide, the problem is it does too much, so i need less, coz my heart will bleed if i know i calculate somthing i dont need. I dont either have problems by creating different spaces and masks to get the exact collision checks i need.

What i need is that ODE would not create too complex contacts, like, i dont need the objects to be simulated with all the fancy physics: mu, damp, bounce and so on . All i need is collision check and that the objects would not penetrate each other/or would penetrate in some cases.
Also i dont want the rigid body effect, meaning no rolling of objects(maybe i can do it by somehow disabling the angualrforce/velo or torque)

Well, if you create OdeContacts manually, you still need to provide that information. ODE needs to know what to do when objects do penetrate.
I suggest just set the mu and bounce to 0 or so. You won’t have any friction then, though.

Having to callback to Python on every collision will be a lot slower than keeping the collide callback in C++, by using the autoCollide system.

The way I disable rotation btw is to simply reset the rotation after every time step - it works, though I suspect it is responsible for some instabilities I’m seeing. It is the recommended technique in the ODE manual however.

Just be careful about having no friction - your system will need to lose energy, otherwise it could explode. Make sure you add some kind of damping to it.

I was hoping for somthing like that :
autoCollide(tag,tag,tag) so i could modify the tags to make autocollide to a more simplified checking and contactjoint creating.

This is exactly what i would like to skip. I don’t want to reset something every frame that i don’t need, i would rather prefer to disable certain parameters while the contactjoints are generated and physics are calculated.
And i really find it strange that this is the suggested solution in the ODE manual, as it seems logical to me to have always the possibility to do less.

As long as i would use spheres i do not care about the roll as i don’t have to pass the quaterninon to the panda model, but the moment i use cube or capsule i will see some bumping wile moving.

One more thing on the subject:
If i would like to create gost objects, that only detect collision but dont react to them, would i need to just change their bitmasks to something else before calling quickstep? and changing them back after the quickstep? Or should i put these object into a different space and not make that space autoCollidable? Like doing the collision check with all spaces but doing the physics for only specific spaces? Any ideas?

Well, I think you should talk to the ODE developers about adding that functionality.
I don’t see how autoCollide could be simplified, as it just creates a couple of contact joints containing the given surface parameters and the contact geoms from odeUtil.collide.

It doesn’t really make sense to do rigid body dynamics without rotation and with rotation at the same time, as without rotation is physically impossible and requires different assumption, so its not surprising they don’t support it. However, if this really matters to you this much you could consider writting your own physics engine modelling everything as an infinitely small point, so no rotation, but continue to use ODE for the collision detection. Considering your simplifications what your after will take less than a hundred lines of python and only the most basic of mechanics.

For ghost objects I just call collide between a space, converted to a body using the util method, and a geom that isn’t in any space every single frame… and then not add any contact constraints! (So, similar to your original approach.)

I dont really need rigid body dynamics.
What i would like to have/do:
detect collisions
tag collision meshes with ghost/solid
tag bodies/collision meshes with dynamic/rigid body(dynamic means no rotation, rigid body means do all the fancyness of physics you can)

Only part i cant currently solidly cover is the dynamic part, as i dont know how to efficiently downgrade the “rigid body”. I can cover it by resetting the rotation every frame, but its not my dreamsolution but i will use it if i cant find any better alternatives.

Yes i would like to have a system where based on collisionentrys only new positions are calculated.
From collisionentry i can get geoms and contact point(s) but how do i get the penetration depth?

If i would have the depth i could move objects back by depth/2 along the contactpoint vector or along the vector from obj1 center to obj2 center.

Well, then why are you using a physics engine?

Penetration depth is OdeContactGeom.getDepth().

The getContactGeom method of OdeCollisionEntry returns a OdeContactGeom - its all in there.

Edit: Seems that pro-rsoft got here first. Note that you might want to also consider the surface normal of the impact.

Coz pandas collision system is slow(but very stable), for example i can have 640 collision spheres that collide into each other in pand at 30fps.
In ode i can have over 1000 spheres with 60 fps.(maybe even a lot more, didnt test with bigger numbers)

In panda i can have 50 shperes colliding into a 4000 vert terrain(octtreed) mesh at 30 fps
In ode i can have 500 spheres colliding into 4000 vert terrain mesh at 60 fps.

All i really needed was a good collision detection system and i simply hoped maybe i can use somthing from the physics as well from ode.

And thank you both for the OdeContactGeom.

Wait wait wait, when you say ODE, you mean ODE -in- Panda3D? I am currently playing with ODE, and with just 100 spheres and a really simple terrain mesh my fps drops to 30fps.

Do you really get 60fps with 500 spheres in Panda3D? Then I must be doing something really wrong!