コード例 #1
0
void TestArraySorting2(void)
{
	CArrayInt	cInts;

	cInts.Init();
	cInts.Add(4);
	cInts.Add(3);
	cInts.Add(2);
	cInts.Add(1);

	cInts.QuickSort();

	AssertInt(1, cInts.GetValue(0));
	AssertInt(2, cInts.GetValue(1));
	AssertInt(3, cInts.GetValue(2));
	AssertInt(4, cInts.GetValue(3));

	cInts.Kill();

	cInts.Init();
	cInts.Add(4);
	cInts.Add(3);
	cInts.Add(2);
	cInts.Add(1);

	cInts.BubbleSort();

	AssertInt(1, cInts.GetValue(0));
	AssertInt(2, cInts.GetValue(1));
	AssertInt(3, cInts.GetValue(2));
	AssertInt(4, cInts.GetValue(3));

	cInts.Kill();
}
コード例 #2
0
BOOL CPolygon::UnionPosition(SFloat3* psPosition)
{
	CArrayInt	cIndices;
	int			iInsertionIndex;
	int			i;
	int			iIndex;
	
	if (mbConvex)
	{
		if (On(psPosition))
		{
			if (!Contains(psPosition))
			{
				if (HasPositionPtr(psPosition))
				{
					return TRUE;
				}

				cIndices.Init(4);
				FindIndicesOfVisibleHalfSpaces(psPosition, &cIndices);
				if (cIndices.NumElements() == 0)
				{
					//Something went wrong.
					return FALSE;
				}

				iInsertionIndex = cIndices.GetValue(1);  //End index of the first visible line.

				for (i = 2; i < cIndices.NumElements(); i+= 2)
				{
					iIndex = cIndices.GetValue(i);
					mapsPositions.RemoveAt(iIndex);
					if (iIndex < iInsertionIndex)
					{
						iInsertionIndex--;
					}
				}

				mapsPositions.InsertAt(&psPosition, iInsertionIndex);
				cIndices.Kill();
			}
			return TRUE;
		}
		return FALSE;
	}
	return FALSE;
}
コード例 #3
0
void CMeshSmoothGroups::GenerateSmoothingFromAngles(CMeshEditor* pcMeshEditor)
{
	int				i;
	int				iNumPolygons;
	CMeshPolygon*	pcPolygon;
	CArrayFloat3	asNormals;
	CArrayInt		aiAdjPolys;
	SFloat3*		psThisNormal;
	SFloat3*		psOtherNormal;
	int				j;
	int				iOtherGon;
	float			fDot;
	float			fResult;

	fDot = Deg2Dot(mfSharpAngle);

	asNormals.Init();
	pcMeshEditor->mcPolygons.GetNormals(&asNormals, &pcMeshEditor->mpcMesh->mcNormals);

	mcSmoothingGroups.SetArrayValues(0);

	iNumPolygons = pcMeshEditor->mcPolygons.mcPolygons.NumElements();
	for (i = 0; i < iNumPolygons; i++)
	{
		psThisNormal = asNormals.Get(i);
		pcPolygon = pcMeshEditor->mcPolygons.Get(i);
		aiAdjPolys.Init();
		pcMeshEditor->mcPolygons.GetAdjacentPolygons(pcMeshEditor->mpcMesh->GetConnectivity(), i, &aiAdjPolys);

		for (j = 0; j < aiAdjPolys.NumElements(); j++)
		{
			iOtherGon = aiAdjPolys.GetValue(j);
			psOtherNormal = asNormals.Get(iOtherGon);

			fResult = Float3Dot(psThisNormal, psOtherNormal);
			if (fResult >= fDot)
			{
				//Smooth!
			}
		}

		aiAdjPolys.Kill();
	}

	asNormals.Kill();
}
コード例 #4
0
void CConvexHull::GetVertices(CArrayBlock* pasPositions, SFloat3* psPoints, int iStride)
{
	CArrayInt	aiIndices;
	int			i;
	int			iIndex;
	SFloat3*	psPosition;

	aiIndices.Init(mcPolygons.NumElements()+1);
	GetIndices(&aiIndices, psPoints, iStride);

	for (i = 0; i < aiIndices.NumElements(); i++)
	{
		iIndex = aiIndices.GetValue(i);
		psPosition = GetPosition(psPoints, iStride, iIndex);
		pasPositions->Add(psPosition);
	}

	aiIndices.Kill();
}