How do you use Ghost Objects?

GameQ
Posts: 8
Joined: Fri Aug 14, 2009 8:44 pm

Re: How do you use Ghost Objects?

Post by GameQ »

Compiler settings for the loss:

struct member alignment: 4-bytes

apparently that will screw you in the butt!

~GameQ
edouard
Posts: 8
Joined: Fri Sep 25, 2009 2:08 pm

Re: How do you use Ghost Objects?

Post by edouard »

Hi everyone,

I just have a quick question about ghost object, are dynamic object suppose to collide with them? I want to create a trigger with a ghost object and just want to know if an object is within the limit of my ghost. My ghost object seems to trigger a collision with the dynamic object.

here is how I create my ghost object

Code: Select all

btPairCachingGhostObject* myGhost = new btPairCachingGhostObject();
myGhost->setCollisionShape(pConvexCastShape);
m_discreteWorld->addCollisionObject(myGhost,btBroadphaseProxy::DefaultFilter, btBroadphaseProxy::AllFilter);
m_discreteWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
I tried putting the collision the collision flag to CF_NO_CONTACT_RESPONSE and it does not collide anymore but it doesn't seem to register the collision in the overlapping pair array. So can I use a ghost object to make a trigger or I need to create a simple rigidBody with no collision and iterate all the manifold to get the revelant collision

Thanks
edouard
Posts: 8
Joined: Fri Sep 25, 2009 2:08 pm

Re: How do you use Ghost Objects?

Post by edouard »

I made some research and found out that if I put CF_NO_CONTACT_RESPONSE I still get contact point for dynamic object and not from static object. Since my ghost object is moving along one of my rigid body collision with static object are frequent. It stills puzle me has to why the collision is not registered in the overlappingpair
Verbo
Posts: 39
Joined: Fri May 08, 2009 9:27 pm

Re: How do you use Ghost Objects?

Post by Verbo »

Interesting,

I have been running in the exact same problem lately, and I am still trying to find out the cause.

Actually, I also noticed that when the ghost object collide with objects that are dynamics but with a mass of zero, I encounter the same problem. And on the other hand, if I set the mass to INFINITE on dynamic objects, the the ghost objects is happy and give us the proper results.

It very problematic, because we cannot just stop using the static objects.

Has anyone noticed something similar and found a solution? I really need to fix this as soon as possible, any help will be more than appreciated :)

Thanks!

Verbo
rrck
Posts: 26
Joined: Mon Sep 21, 2009 7:30 am

Re: How do you use Ghost Objects?

Post by rrck »

If I correctly understand the problem is that ghost objects are not colliding with static objects? (Sorry maybe I not correctly understand the problem.)

May be reason is that with default collision filter static objects don't collide with other static objects?
As I understand btCollisionObject(and btGhostObject) is static by default.
Verbo
Posts: 39
Joined: Fri May 08, 2009 9:27 pm

Re: How do you use Ghost Objects?

Post by Verbo »

Hi,

Yes, that`s it, but in my specific case, our ghost object collision flag is set to CF_NO_CONTACT_RESPONSE because we only want to use the ghost object as a wheel sensor to detect the wheel contacts with static(concave or convex) or dynamic objects. So in this perspective, the collision filter flag are not really an issue because my ghost objects are using the default collision group and collision mask.

This problem could also be experimented if I wanted to use the ghost object as moving triggers.

What I also noticed is that when my ghost object collide with a static object, I only see 3 overlapping pairs in the cache list, and when I use the algorithm pointer to get the manifold result for each pair, I get nothing. It is as if the overlapping pairs were not valid. However, if I collide with the same object that is now dynamic, I get 8 overlapping pairs and then I can get valid manifold results from the algorithm.

I even tried to derive the ghost object class and give my new class a CO_RIGID_BODY internal type, but I still get the same problem.

Verbo
rrck
Posts: 26
Joined: Mon Sep 21, 2009 7:30 am

Re: How do you use Ghost Objects?

Post by rrck »

Hello,
Yes, that`s it, but in my specific case, our ghost object collision flag is set to CF_NO_CONTACT_RESPONSE because we only want to use the ghost object as a wheel sensor to detect the wheel contacts with static(concave or convex) or dynamic objects. So in this perspective, the collision filter flag are not really an issue because my ghost objects are using the default collision group and collision mask.
As I know CF_NO_CONTACT_RESPONSE flag don't connected to collision filters flags. And it seems that when default collision group and collision filter are set, then static objects doesn't collide with other statics. May be you can try to change collision filter and group or try to debug addOverlappingPair function in btOverlappingPairCache to be sure that objects are not filtered out.
Verbo
Posts: 39
Joined: Fri May 08, 2009 9:27 pm

Re: How do you use Ghost Objects?

Post by Verbo »

Hi,

Thanks, We finally fixed our problem. We were accidentally overwritting the collision flag to CF_NO_CONTACT_RESPONSE instead of adding it to the actual mask value. This was causing IsStaticObject() to return false in the check in btCollisionWorld::updateSingleAabb() which resulted in setting our ghost object's activation flag to DISABLE_SIMULATION.

On the other hand, we don`t see any problem with using the default collision filter group and mask. It all works pretty well now, it is totally underperformant on the Wii(we are not very surprised...), but it works. :)

Thanks!

Verbo
CodeWarrior
Posts: 3
Joined: Fri Dec 11, 2009 10:00 am

Re: How do you use Ghost Objects?

Post by CodeWarrior »

Hello,

I am new to bullet: I created a ghost object, added it into the world, but the ghost object only collided with dynamic rigid bodies, not with static. I was searching the API Reference, forum, but I couldn't figure out why is this happening. Behold, the API Reference states addCollisionObject function is declared as follows:

addCollisionObject (btCollisionObject *collisionObject, short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, short int collisionFilterMask=btBroadphaseProxy::AllFilter)

However, the funcion in btDiscreteDynamicsWorld has different default parameters:

addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter)

Of course, API reference points only to the former. Trust no one.
jchen114
Posts: 12
Joined: Wed Jun 08, 2016 1:39 am

Re: How do you use Ghost Objects?

Post by jchen114 »

So which flags/mask pair do you have to set to have ghost objects collide with static objects?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland

Re: How do you use Ghost Objects?

Post by benelot »

Is anybody of you interested in implementing the case including the issue into an example of the bullet example browser? By doing this, you usually do not only reduce the causes of errors because you minimize the example but also you make the issue accessible for others to tinker with. It usually makes it easier to fix an issue.