Hooks for game logic

lvella

09-06-2009 21:34:53

Are there any hooks that I can plug in order to be informed when nodes where added and removed from the render queue by the PCZSM? If no, are they difficult to implement?
I want to activate physics and AI on my game based on which zone the player character is in, so only the "neighborhood" consumes processor cycles.

Lf3THn4D

17-07-2009 08:03:41

Unfortunately, no. The way PCZ works is to do zone <-> portal traversal for every render. This means it doesn't bother about when a node gets "removed" from the render queue. You can however do the checking yourself by getting the last visible frame from PCZSceneNode. Match it with Ogre::Root::getNextFrameNumber().

Something like this pseudo code here:

unsigned long nextFrame = Ogre::Root::getSingleton().getNextFrameNumber();
foreach (node in nodeList)
{
if (node->getLastVisibleFrame() < nextFrame)
{
// Node not visible.
}
}


As for what's visible, one just need to get it from the mVisible NodeList of PCZSceneManager. However, it's not exposed right now. Maybe we should expose it. That name is rather ambiguous too. Will need to rename it. Either way, it isn't very efficient. But I think this is as best as we can do for now.

Anyways, I would think what you really want is getting a list of nodes within an enclosed area closed to the given camera no? Else it'll be extremely funny to see objects freezing whenever camera is not looking.