首先对于山洞类型的shape(一般是CollectionShape),重载接口getCollisionFilterInfo
例如:
hkUint32 getCollisionFilterInfo( hkpShapeKey key ) const
{
// look up whether there is a hole at x/z using the bitmask
int x = getXFromShapeKey(key) >> m_iTileSamplesX;
int y = getZFromShapeKey(key) >> m_iTileSamplesY;
bool bIsHole = m_TileHoleMask.IsBitSet(x+y*m_iStrideX);
return bIsHole ? m_iNonCollide : m_iCollide;
}
对于射线查询,可以通过hkpShapeRayCastCollectorOutput,这个的属性m_extraInfo,获得对应的shapekey
获得对应的shape后就可以通过getCollisonFilterInfo()来知道碰撞的shape是否为山洞了
例如:
if( col && col->getCollisionFilterInfo( hitInfo.m_extraInfo )
== hkpGroupFilter::calcFilterInfo( TERRAIN_HOLE_BITMASK ) )
{
return;
}