예제 #1
0
void GetTriangleOverlap(neCollisionResult & result, s32 i, TConvex & convexA, TConvex & convexB)
{
	const Pair * pair = &tc.GetPairs()[i];

	IceMaths::Point * vertsA = convexA.as.opcodeMesh.vertices;

	IndexedTriangle * trisA = convexA.as.opcodeMesh.triIndices;

	IceMaths::Point * vertsB = convexB.as.opcodeMesh.vertices;

	IndexedTriangle * trisB = convexB.as.opcodeMesh.triIndices;

	IceMaths::Point V0 = worldA * vertsA[trisA[pair->id0].mVRef[0]];

	IceMaths::Point V1 = worldA * vertsA[trisA[pair->id0].mVRef[1]];

	IceMaths::Point V2 = worldA * vertsA[trisA[pair->id0].mVRef[2]];

	IceMaths::Point U0 = worldB * vertsB[trisB[pair->id1].mVRef[0]];

	IceMaths::Point U1 = worldB * vertsB[trisB[pair->id1].mVRef[1]];

	IceMaths::Point U2 = worldB * vertsB[trisB[pair->id1].mVRef[2]];

	if (tc.TriTriOverlap(V0, V1, V2, U0, U1, U2))
	{

	}
}
예제 #2
0
bool DTIFilterROI::matches(DTIPathway *pathway)
{
#ifdef USE_RAPID
	CollModel *pathwayModel = pathway->getCollisionModel();
	RAPID_Collide (_rotation_matrix, _position, _model.get(),
		ZERO_ROTATION, ZERO_TRANSLATION, pathwayModel, RAPID_FIRST_CONTACT);
	return RAPID_num_contacts > 0 ? true:false;
#else
	Opcode::Model *pathwayModel = pathway->getCollisionModel();
	Opcode::AABBTreeCollider TC;
	TC.SetFirstContact(true);
	Opcode::BVTCache cache;
	cache.Model0 = pathway->getCollisionModel();
	cache.Model1 = this->_model.get();

	TC.Collide(cache);

	return TC.GetContactStatus();
#endif
}
예제 #3
0
void Opcode2OpcodeTest(neCollisionResult & result, TConvex & convexA, neT3 & transA, TConvex & convexB, neT3 & transB)
{
	tc.SetFirstContact(false);
	tc.SetFullBoxBoxTest(true);
	tc.SetFullPrimBoxTest(true);
	tc.SetTemporalCoherence(false);

	tc.SetPointers0(convexA.as.opcodeMesh.triIndices, convexA.as.opcodeMesh.vertices);
	tc.SetPointers1(convexB.as.opcodeMesh.triIndices, convexB.as.opcodeMesh.vertices);

	// Setup cache
	
	ColCache.Model0 = convexA.as.opcodeMesh.opmodel;
	ColCache.Model1 = convexB.as.opcodeMesh.opmodel;
	
	transA.AssignIceMatrix(worldA);
	transB.AssignIceMatrix(worldB);
	// Collision query

	bool IsOk = tc.Collide(ColCache, &worldA, &worldB);

	if (tc.GetContactStatus() == false)
	{
		result.penetrate = false;
		return;
	}

	u32 npairs = tc.GetNbPairs();

	result.penetrate = true;

	result.depth = 0.0f;

	for (u32 i = 0; i < npairs; i++)
	{
		GetTriangleOverlap(result, i, convexA, convexB);
	}
}