Exemple #1
0
//////////////////////////////////////////////////////////////////////////
// classify
MaAABB::eClassify MaAABB::classify( const MaAABB& AABB ) const
{
	BcU32 PointsInside = 0;
	for( BcU32 i = 0; i < 8; ++i )
	{
		MaVec3d Point = AABB.corner( i );
		if( ( Point.x() >= Min_.x() && Point.x() <= Max_.x() ) &&
			( Point.y() >= Min_.y() && Point.y() <= Max_.y() ) &&
			( Point.z() >= Min_.z() && Point.z() <= Max_.z() ) )
		{
			PointsInside++;
		}
	}

	if( PointsInside == 8 )
	{
		return bcBC_INSIDE;
	}

	if( PointsInside > 0 )
	{
		return bcBC_SPANNING;
	}

	return bcBC_OUTSIDE;
}
//////////////////////////////////////////////////////////////////////////
// drawAABB
void ScnDebugRenderComponent::drawAABB( const MaAABB& AABB, const RsColour& Colour, BcU32 Layer )
{
	drawLine( AABB.corner( 0 ), AABB.corner( 1 ), Colour, Layer );
	drawLine( AABB.corner( 1 ), AABB.corner( 3 ), Colour, Layer );
	drawLine( AABB.corner( 2 ), AABB.corner( 0 ), Colour, Layer );
	drawLine( AABB.corner( 3 ), AABB.corner( 2 ), Colour, Layer );

	drawLine( AABB.corner( 4 ), AABB.corner( 5 ), Colour, Layer );
	drawLine( AABB.corner( 5 ), AABB.corner( 7 ), Colour, Layer );
	drawLine( AABB.corner( 6 ), AABB.corner( 4 ), Colour, Layer );
	drawLine( AABB.corner( 7 ), AABB.corner( 6 ), Colour, Layer );

	drawLine( AABB.corner( 0 ), AABB.corner( 4 ), Colour, Layer );
	drawLine( AABB.corner( 1 ), AABB.corner( 5 ), Colour, Layer );
	drawLine( AABB.corner( 2 ), AABB.corner( 6 ), Colour, Layer );
	drawLine( AABB.corner( 3 ), AABB.corner( 7 ), Colour, Layer );
}