questions about broadphase and phantom

questions about broadphase and phantom

Hi.

I implemente my "shift coordinate system" with reference to "SlidingWorldDemo".
First I copied almost demo code and added a phantom to the world. (The original SlidingWorldDemo has not a phantom.)

Compile ended successfully and I think it works good.But after moving coordinate system(= after moving broadphase), my phantoms are sink downward without collision and rigid bodies are disappeared.
I wonder why this problem was happened.

pseudo code is below. (Almost same asSlidingWorldDemo)

world->broadphase->shiftAllObject();

for all island type
for all rigidbody
shift disitance

for all rigidbody
if (rb->getWorld() == HK_NULL)
shift distance

for all rigidbody
if (rb is in new broadphase's aabb)
world->addEntity

And some screenshots are here.

1. Big Plate (= Fixed rigidbody) and 1 Phantom and 200 RigidBodies

2. Move Phantom and some rigidbodies are scattered by it.

3. Move coordinate system. After this, red bounding box that outside of broadphase are disappeared.

4. Restore coordinate, but some lines are extended from broadphase border. And rigidbodies which moved by phantom are disappear and phantom always sink to downward.

Should I add some code for phantom?
I really appreciate if you solve this problem.
Thanks!

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I solve this problem, but I don't know how (and why) it does works.
First I blocked a line, which check "rb->getWorld() == HK_NULL" and add a line remove rigidbody explicitly.
I think hkpWorld remove there rigidbody "silently", so rigidbody's m_world is not refreshed.

Should I add a listener to the world?
If it is needed what kind of listener should I add to?

void SlidingWorld::addBodiesNewlyInsideSimulationAreaToSimulation()
{
	//.... blahblah

	for (int i = 0; i < m_rigidbodies.getSize(); i++)
	{
		hkpRigidBody* rb = m_rigidbodies[i];
		//if ( rb->getWorld() == HK_NULL ) ////////// I blocked this line
		{		
			hkAabb rbAabb;
			rb->getCollidable()->getShape()->getAabb(rb->getTransform(), 0, rbAabb);

			if (broadphaseAabb.contains(rbAabb)) 
			{
				m_world->removeEntity( rb ); /////////// I added it
				m_world->addEntity( rb );
				//...
			}
		}
	}
	//.... blah
}

Best Reply

Hey sanybyme,

I think the missing piece here is the customSlidingWorldBroadphaseBorder class. It has a maxPositionExceededCallback() that's removing the entities from the world (thus setting their world to null) as they leave the broadphase. Take a look at the SlidingWorldBroadphaseBorder class and make sure you have a similar system set up. Also make sure you're calling m_world->setBroadPhaseBorder() with your custom BroadphaseBorder class just like the SlidingWorld demo does.

Let me know if this helps!

Pete Developer Support Engineer Havok www.havok.com

Quoting - havokpete

Hey sanybyme,

I think the missing piece here is the customSlidingWorldBroadphaseBorder class. It has a maxPositionExceededCallback() that's removing the entities from the world (thus setting their world to null) as they leave the broadphase. Take a look at the SlidingWorldBroadphaseBorder class and make sure you have a similar system set up. Also make sure you're calling m_world->setBroadPhaseBorder() with your custom BroadphaseBorder class just like the SlidingWorld demo does.

Let me know if this helps!

Thanks for reply, pete!
It works very well.

Login to leave a comment.