GhostObject ignorig triangle mesh

Post Reply
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

GhostObject ignorig triangle mesh

Post by Tau »

Hi, im working on a submarine game and im using btGhostObject for torpedos.

Code: Select all

////init
	m_ghostBody = new btPairCachingGhostObject();
	m_ghostBody->setCollisionShape(in_sm->m_pGame->go_ammoCtrl.m_colShape);
	m_ghostBody->setCollisionFlags(m_ghostBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);

	btTransform tr;
	tr.setFromDirectXMatrix(mWorld.m);
	m_ghostBody->setWorldTransform(tr);
	in_sm->m_pGame->dynamicsWorld->addCollisionObject(m_ghostBody);


////collision check
		test_trans.setFromDirectXMatrix(v_torpWSimple[i].mWorld.m);
		v_torpWSimple[i].m_ghostBody->setWorldTransform(test_trans);
		{
			btAlignedObjectArray<btCollisionObject*>& overlappingObjects = v_torpWSimple[i].m_ghostBody->getOverlappingPairs();
			WCHAR wt[50];
			if (overlappingObjects.size())
			{
				if (overlappingObjects[0]!=v_torpWSimple[i].sender->m_body)
				{
					swprintf(wt, L"size %d", overlappingObjects.size());
					m_pGame->add_text(wt, fTime);
					v_to_delete.push_back(i);
				}
				else
					m_pGame->add_text(L"dmg self", fTime);
			}
		}

Problem is that btGhostObject detects collision only with standard shapes, but im using btHeightfieldTerrainShape and btBvhTriangleMeshShape for map and objects on map.
What should i do if i want btGhostObject to detect collision with these too?
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Re: GhostObject ignorig triangle mesh

Post by Tau »

bump
How should i set btGhostObject to collide with trianglemesh?
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: GhostObject ignorig triangle mesh

Post by xexuxjy »

You say that ghost objects only collide with standard shapes (presumably box,sphere,capsule?) ? trying to remember but can't recall any fixed restrictions like that in the code. At what level are the collisions being ignored? broad/narrow phase?

also a bit hard to see in your example but you're setting the transform of the ghost object directly and then trying to get the values from the overlapping pair cache. I would have thought that as a simulation step hadn't been run in between then the system would not have been able to re-calculate collisions based on your change?
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Re: GhostObject ignorig triangle mesh

Post by Tau »

Collision only with standard meshes - yes, player and NPCs have btCompoundShape build from boxes, spheres, ...
Not sure but i HOPE its narrow (i could check broad without bullet).
Actually its not setting world transform its update. Torpedos position its updated without bullet, then ghost objects world transform is adjusted to this new position. This update happens every game cycle.

Now i know whats wrong. Ghost objects are static, that's why they ignore other static objects.
Nvm, solved it with contactTest.
Post Reply