Ejemplo n.º 1
0
bool MeshMender::SharesEdgeRespectSplits(	Triangle* triA,
									Triangle* triB,
				std::vector< Vertex >& theVerts)
{
	assert(triA && triB && "invalid data passed to SharesEdgeNoSplit");
	//here we want to compare based solely on indices.

	size_t a1 = triA->indices[0];
	size_t b1 = triA->indices[1];
	size_t c1 = triA->indices[2];

	size_t a2 = triB->indices[0];
	size_t b2 = triB->indices[1];
	size_t c2 = triB->indices[2];

	//edge B1->A1
	if( TriHasEdge(b1,a1,a2,b2,c2)  )
		return true;

	//edge A1->C1
	if( TriHasEdge(a1,c1,a2,b2,c2)  )
		return true;

	//edge C1->B1
	if( TriHasEdge(c1,b1,a2,b2,c2)  )
		return true;

	return false;
}
static void GetTriIndicesUsingEdge(const int32 Edge0, const int32 Edge1, const TArray<int32> TriData, int32& Tri0Index, int32& Tri1Index)
{
	Tri0Index = INDEX_NONE;
	Tri1Index = INDEX_NONE;

	const int32 NumTris = TriData.Num()/3;

	// Iterate over triangles, looking for ones that contain this edge.
	for(int32 i=0; i<NumTris; i++)
	{
		if( TriHasEdge(TriData[(i*3)+0], TriData[(i*3)+1], TriData[(i*3)+2], Edge0, Edge1) )
		{
			if(Tri0Index == INDEX_NONE)
			{
				Tri0Index = i;
			}
			else if(Tri1Index == INDEX_NONE)
			{
				Tri1Index = i;
			}
			else
			{
				UE_LOG(LogPhysics, Log,  TEXT("GetTriIndicesUsingEdge : 3 tris share an edge.") );
			}
		}
	}
}
Ejemplo n.º 3
0
bool MeshMender::SharesEdge(Triangle* triA,
				Triangle* triB,
				std::vector< Vertex >& theVerts)
{
	assert(triA && triB && "invalid data passed to SharesEdge");

	//check based on position not on indices, because there may be splits
	//we don't care about. unless the user has told us they care about those
	//splits
	if(m_RespectExistingSplits == RESPECT_SPLITS)
	{
		return SharesEdgeRespectSplits(triA, triB, theVerts);
	}

	D3DXVECTOR3 a1 = theVerts[ triA->indices[0] ].pos;
	D3DXVECTOR3 b1 = theVerts[ triA->indices[1] ].pos;
	D3DXVECTOR3 c1 = theVerts[ triA->indices[2] ].pos;

	D3DXVECTOR3 a2 = theVerts[ triB->indices[0] ].pos;
	D3DXVECTOR3 b2 = theVerts[ triB->indices[1] ].pos;
	D3DXVECTOR3 c2 = theVerts[ triB->indices[2] ].pos;

	//edge B1->A1
	if( TriHasEdge(b1,a1,a2,b2,c2)  )
		return true;

	//edge A1->C1
	if( TriHasEdge(a1,c1,a2,b2,c2)  )
		return true;

	//edge C1->B1
	if( TriHasEdge(c1,b1,a2,b2,c2)  )
		return true;

	return false;
}