Preloading Areas

Jules Robichaud Gagnon

27-07-2008 00:52:53

Hello everyone,

I made a special request to JohnJ about preloading a large area to avoid hiccup when moving fast in a massive forest.

He created those two methods:

In PagedGeometry.h

/**
\brief Preloads a region of geometry (loads once and never loads again)
\param area A rectangular area of the world that needs to be preloaded

You can use this function to preload entire areas of geometry. Doing this
will basically turn off dynamic paging for the given region, since all the
pages effecting it will stay loaded forever (until you delete the PagedGeometry
object, or if using infinite mode, until you move away from the region).

\note The rectangular bounds value you supply does not indicate a
rectangular area to preload, but instead a rectangular area in which you need
the camera to be able to freely move around without having to dynamically load
any pages. In other words, this function will preload all geometry within
viewing range of the given bounds area.
*/
void preloadGeometry(const TBounds & area);


/**
\brief Releases geometry preloaded with preloadGeometry() to be unloaded if necessary

When you call preloadGeometry() to preload region(s) of geometry, it makes those
regions un-unloadable; in other words, they will never be unloaded automatically
by PagedGeometry (except for some cases in infinite mode). This way you can load
a region of your world once and never have to load it again (optimally).

This function allows you to undo all this by allowing all the geometry to be
unloaded once again when necessary. It won't unload anything, but it will
allow geometry to unload that previously was not allowed.
*/
void resetPreloadedGeometry();



I added this method for lazy people who wants to convert an AAB ( such as the AAB of a Page in PLSM2 ) to input it into PagedGeometry:


/**
\brief Convert an Ogre::AxisAlignedBox to a TBounds coplanar to the plane defined by the UP axis.
*/
TBounds convertAABToTBounds( const Ogre::AxisAlignedBox & aab ) const;


In the same time I also did some cleanup in the ctors, added a few const and removed white spaces.


Thanks JohnJ!

Jules Robichaud Gagnon

27-07-2008 20:01:37

I just fixed an infinite loop when loading a GrassPage without GrassLayer added when using preloadGeometry.