Public Group

#### Archived

This topic is now archived and is closed to further replies.

This topic is 5284 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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:
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.

##### Share on other sites
In C++, every non-zero value evaluates to true (including negitives). So if(triangleCount) will return true if it isn''t 0.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011702
• ### Who's Online (See full list)

There are no registered users currently online

×