- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

int leaves = 0;

size_t numnodes = getNumNodes();

for (size_t i = 0; i < numnodes ; i++) {

const int nodeID = id2offset(i);

const Node& n = node(nodes, nodeID);

if (n.child[0] < 0)

++leaves;

if (n.child[1] < 0)

++leaves;

}

The actual numbers computed by getNumNodes and getNumLeaves are:

nodes = 18935

leaves = 18936

The numbers I come up by going through the nodes array:

nodes=18935

leaves=15121

What am I doing wrong here?

thanks,

vf

Link Copied

4 Replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Some nodes in these arrays are not used as multiple threads take blocks of nodes out of this array. Some blocks at the end might end up partly filled.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Thanks for your reply. I realized that last night when I started printing the nodes and seeing all these empty ones. I thought the following piece of code is getting rid of the unused space:

/*! free temporary memory again */

bvh->nodes

= (BVH2

* sizeof(BVH2

So the above instruction removes the unused blocks, but there are still unused space withing the currently used blocks? Could you please clarify this?

thanks,

vf

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Got it.

Thanks again for your help.

best,

vf

Thanks again for your help.

best,

vf

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page