Skip to main content
gamedev.net
🔒 Locked

why last?

Started by luasitdown 3 replies 750+ views
Original Post
luasitdown
luasitdown
I see a code . /** Set true by camera if the node is visible in this frame. */ void setRenderedInLastFrame( bool enabled ); why care about last frame?
kmccusker
kmccusker
Most programmers tend to name their functions and variables something descriptive. A name that will give a hint to its purpose, or maybe how its used.

Looking at this function, the name tells me that its a function to check whether or not the node was rendered in the previous(last) frame.
Sneftel
Sneftel
I don't know why they care. Why don't you see where that value is actually used? Chances are that that function simply sets a boolean variable in the class... search through the source code for where that variable is used.

Offtopic: do you realize that you've posted EIGHT topics today? Just out of curiosity, what do you do to try to answer your own questions before posting them here?
JY
JY
Absolutely, we should all solve our own problems and not post anything here. ;)
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
JohnBolton
JohnBolton
It's for optimization. You would use it something like this:
    // If the object was rendered last frame, then it will probably be visible    // this frame too, so just draw it. Otherwise, test if it is visible before drawing.        if ( getRenderedInLastFrame()    {        Draw();    }    else    {        // Test if the object is visible. If it is, then draw it.                bool visible;        visible = ExpensiveTestToDetermineVisibility();        if ( visible )        {            Draw();        }    } 
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.