oid COctree::CreateNewNode(CPoly *pPoly, vector<bool> pList, int numberOfVerts,
CVector3 vCenter, float width, int triangleCount, int nodeID)
{
if(triangleCount)
{
CPoly *pNodeVertices = new CPoly [triangleCount];
int index = 0;
for(int i = 0; i < numberOfVerts; i++)
{
if(pList[i])
{
pNodeVertices[index] = pPoly[i];
index++;
}
}
m_pOctreeNodes[nodeID] = new COctree;
CVector3 vNodeCenter = GetNewNodeCenter(vCenter, width, nodeID);
g_CurrentSubdivision++;
m_pOctreeNodes[nodeID]->CreateNode(pNodeVertices, triangleCount, vNodeCenter, width / 2);
g_CurrentSubdivision--;
delete [] pNodeVertices;
}
}
What does the first if statement actually prove true for? It seems a bit weird to me because I would have thought it only returns true for triangleCount = 1, but he seems to act like it works for values above 1 as well. triangleCount is the intended amount of triangles to put into one node.
Quick question about if's
Ok this question specifically concerns DigiBen''s Octree class (gametutorials.com octree2 program). In his program when he creates a new node, the function looks like this:
In C++, every non-zero value evaluates to true (including negitives). So if(triangleCount) will return true if it isn''t 0.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement