I understand both methods clears the array so which should I use?
Thanks.
set_used(0); vs clear(); - Which is better to use? (array)
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Re: set_used(0); vs clear(); - Which is better to use? (arra
You may want to revisit your understanding.MasterGod wrote:I understand both methods clears the array so which should I use?
Code: Select all
void set_used(u32 usedNow)
{
if (allocated < usedNow)
reallocate(usedNow);
used = usedNow;
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Re: set_used(0); vs clear(); - Which is better to use? (arra
So what can it be used for? (I've seen it in the smgr->drawAll() method..) - What's the purpose of it..rogerborg wrote:You may want to revisit your understanding.MasterGod wrote:I understand both methods clears the array so which should I use?
set_used(0) does not destroy any objects or free any memory.Code: Select all
void set_used(u32 usedNow) { if (allocated < usedNow) reallocate(usedNow); used = usedNow; }
Re: set_used(0); vs clear(); - Which is better to use? (arra
If I recall, that was answered in your last topic where you specifically asked about what set_used(0) was used for.MasterGod wrote:So what can it be used for? (I've seen it in the smgr->drawAll() method..) - What's the purpose of it..rogerborg wrote:You may want to revisit your understanding.MasterGod wrote:I understand both methods clears the array so which should I use?
set_used(0) does not destroy any objects or free any memory.Code: Select all
void set_used(u32 usedNow) { if (allocated < usedNow) reallocate(usedNow); used = usedNow; }
And if you feel too lazy to search for it, I did it myself:
vitek wrote: OnRegisterSceneNode() is called for every scene node in the scene graph. That function will be called regardless of what the contents of the other render queues look like.
That is just the way it is written. Scene nodes register themselves every render in OnRegisterSceneNode(). If they didn't do it that way, then they would need to register themselves for rendering when they are added to the scene graph, and they would have to be removed from the render queues when they were removed from the scene graph.
If you don't clear the array before/after each render, but you continue to call OnRegisterSceneNode(), the render queue will have many pointers to the same nodes.
Travis
TheQuestion = 2B || !2B
It's cleared in CSceneManager's destructor.
Try this code yourself, try different values for size, put some real timers around them if it runs too fast for you to be able to see anything.
Try this code yourself, try different values for size, put some real timers around them if it runs too fast for you to be able to see anything.
Code: Select all
core::array<s32> Numbers1;
core::array<s32> Numbers2;
s32 i, j, size = 5000;
cout << "Test 1 start\n";
// test 1-
for (j=0; j < size; ++j)
{
Numbers1.clear();
for (i=0; i < size; ++i)
Numbers1.push_back(i);
}
cout << "Test 2 start\n";
// test 2-
for (j=0; j < size; ++j)
{
Numbers2.set_used(0);
for (i=0; i < size; ++i)
Numbers2.push_back(i);
}
cout << "Test 2 end";