void WorldLinearCastMultithreadedDemo::displayRootCdPoint( hkpWorld* world, const hkpRootCdPoint& cp ) { displayRootCdBody( world, cp.m_rootCollidableB, cp.m_shapeKeyB ); // Display contact point HK_DISPLAY_ARROW( cp.m_contact.getPosition(), cp.m_contact.getNormal(), hkColor::YELLOW ); }
void ShapeQueryDemo::worldGetPenetrations( hkpWorld* world, hkReal time, hkArray<QueryObject>& queryObjects ) { hkpAllCdBodyPairCollector collector[10]; // Next we batch query the system (that is ask for the penetrations N times before processing the results). // This follows our usual core loop: for ( int i = 0; i < queryObjects.getSize(); i++ ) { QueryObject& qo = queryObjects[i]; // create a new position: all objects move in a circle hkReal t = time + HK_REAL_PI * 2 * i / queryObjects.getSize(); hkVector4 pos( hkMath::sin( t ) * 10.0f, 0.0f, hkMath::cos( t ) * 10.0f ); qo.m_transform->setTranslation(pos); // // Query for intersecting objects // for (int j = 0; j < NUM_ITER; j++ ) { MY_TIMER_BEGIN(i); collector[i].reset(); world->getPenetrations( qo.m_collidable, *world->getCollisionInput(), collector[i] ); MY_TIMER_END(); } } // Next up is the display update, first we highlight any overlapping triangles or objects: { for ( int i = 0; i < queryObjects.getSize(); i++ ) { // iterate over each individual hit for (int j = 0; j < collector[i].getHits().getSize(); j++ ) { displayRootCdBody( world, collector[i].getHits()[j].m_rootCollidableB, collector[i].getHits()[j].m_shapeKeyB ); } } } // Followed by a geometry update for our QO: { for ( int i = 0; i < queryObjects.getSize(); i++ ) { QueryObject& qo = queryObjects[i]; hkDebugDisplay::getInstance().updateGeometry( qo.m_collidable->getTransform(), (hkUlong)qo.m_collidable, 0); } } }
void ShapeQueryDemo::displayRayHit( hkpWorld* world, const hkpWorldRayCastInput& in, const hkpWorldRayCastOutput& out ) { // Display hit shape // This demo has a hardcoded knowledge of the shape hierarchy. It could be more generalized // by using the hkpShapeContainer interface. int key = out.m_shapeKeys[0]; for(int i = 0; out.m_shapeKeys[i] != HK_INVALID_SHAPE_KEY; ++i ) { key = out.m_shapeKeys[i]; } displayRootCdBody( world, out.m_rootCollidable, key ); // Display contact point { hkVector4 pos; pos.setInterpolate4( in.m_from, in.m_to, out.m_hitFraction ); HK_DISPLAY_ARROW( pos, out.m_normal, hkColor::YELLOW); } }