Phys engines & PLSM without "LoadNow" option

RB

16-10-2006 14:51:37

Hi,

currently i am writing an interface to combine PLSM and ODE physics engine for the YAKE project.
My previous code work just fine and terrain geometry was loaded quickly with relative small terrain
( about 512x512) but then i tried to load larger terrain an execution of SetOption("LoadNow") takes a large amount of time ( ~40 seconds)

I' am wrote an algo which is now loading only necessary tiles,
i.e. only tiles which is participate in collision on the current step.
Then the time to collision comes, it is manually loading this tile and process RenderableManager::executeRenderableLoading(..).

Due to testing and debugging this algo I encountered an assertions of tiles been loaded.
Since i manually loading the tiles those checks is unnecessary.

Please take a look at this patch, it's also contain some fixes for building PLSM on Linux with gcc 4.2


Index: PlugIns/PagingLandScape2/include/OgrePagingLandScapeData2D_HeightField.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeData2D_HeightField.h,v
retrieving revision 1.23
diff -u -p -r1.23 OgrePagingLandScapeData2D_HeightField.h
--- PlugIns/PagingLandScape2/include/OgrePagingLandScapeData2D_HeightField.h 5 Sep 2006 09:14:00 -0000 1.23
+++ PlugIns/PagingLandScape2/include/OgrePagingLandScapeData2D_HeightField.h 6 Oct 2006 10:40:55 -0000
@@ -50,8 +50,8 @@ protected:
virtual void _unload(void);

private:
- Real PagingLandScapeData2D_HeightField::getScale() const;
- Real PagingLandScapeData2D_HeightField::getInvScale() const;
+ Real getScale() const;
+ Real getInvScale() const;

Image* mImage;
Image* mBase;
Index: PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h,v
retrieving revision 1.29
diff -u -p -r1.29 OgrePagingLandScapeRenderable.h
--- PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h 19 May 2006 13:53:32 -0000 1.29
+++ PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderable.h 6 Oct 2006 10:40:55 -0000
@@ -95,7 +95,7 @@ namespace Ogre
return (mBounds.getMaximum()).y;
};

- inline void PagingLandScapeRenderable::setInUse (bool InUse)
+ inline void setInUse (bool InUse)
{
mInUse = InUse;
}
@@ -163,7 +163,7 @@ namespace Ogre

IndexData* getRawIndexData(const int renderlevel);
void getRawVertexData(Vector3* pVerts);
- const unsigned int PagingLandScapeRenderable::getVertexCount();
+ const unsigned int getVertexCount();

bool mQueued;
PagingLandScapeTile *mParentTile;
Index: PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderableManager.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderableManager.h,v
retrieving revision 1.20
diff -u -p -r1.20 OgrePagingLandScapeRenderableManager.h
--- PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderableManager.h 19 May 2006 13:53:32 -0000 1.20
+++ PlugIns/PagingLandScape2/include/OgrePagingLandScapeRenderableManager.h 6 Oct 2006 10:40:55 -0000
@@ -37,7 +37,7 @@ namespace Ogre
{
public:

- PagingLandScapeRenderableSet::PagingLandScapeRenderableSet();
+ PagingLandScapeRenderableSet();
void setRenderableManager (PagingLandScapeRenderableManager *rMgr)
{
mRenderableManager = rMgr;
Index: PlugIns/PagingLandScape2/include/OgrePagingLandScapeTile.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/include/OgrePagingLandScapeTile.h,v
retrieving revision 1.20
diff -u -p -r1.20 OgrePagingLandScapeTile.h
--- PlugIns/PagingLandScape2/include/OgrePagingLandScapeTile.h 19 May 2006 13:53:32 -0000 1.20
+++ PlugIns/PagingLandScape2/include/OgrePagingLandScapeTile.h 6 Oct 2006 10:40:55 -0000
@@ -100,7 +100,7 @@ public:
mLoading = value;
};

- void PagingLandScapeTile::setInUse (bool InUse)
+ void setInUse (bool InUse)
{
assert (mInit);
if (mRenderable)
Index: PlugIns/PagingLandScape2/src/OgrePagingLandScapePageManager.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapePageManager.cpp,v
retrieving revision 1.62
diff -u -p -r1.62 OgrePagingLandScapePageManager.cpp
--- PlugIns/PagingLandScape2/src/OgrePagingLandScapePageManager.cpp 4 Sep 2006 16:16:25 -0000 1.62
+++ PlugIns/PagingLandScape2/src/OgrePagingLandScapePageManager.cpp 6 Oct 2006 10:40:57 -0000
@@ -586,7 +599,7 @@ namespace Ogre
}
for (itq = mPageLoadQueue.begin (); itq != mPageLoadQueue.end ();)
{
- assert (!(*itq)->isLoaded());
+// this assert is preventing manual page loading
+// assert (!(*itq)->isLoaded());
assert ((*itq)->mIsLoading && !(*itq)->mIsTextureLoading && !(*itq)->mIsPreLoading);
if ((*itq)->touched ())
{
@@ -620,7 +633,7 @@ namespace Ogre
{
// We to Load nearest page in non-empty queue
PagingLandScapePage *p = mPageLoadQueue.find_nearest (pos);
- assert (p && !p->isLoaded ());
+// this assert is preventing manual page loading
+// assert (p && !p->isLoaded ());
assert (!p->mIsTextureLoading && !p->mIsPreLoading);
p->load ();

Index: PlugIns/PagingLandScape3/src/OgrePagingLandScapeRenderableManager.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/OgrePagingLandScapeRenderableManager.cpp,v
retrieving revision 1.30
diff -u -p -r1.30 OgrePagingLandScapeRenderableManager.cpp
--- PlugIns/PagingLandScape2/src/OgrePagingLandScapeRenderableManager.cpp 4 Sep 2006 16:16:25 -0000 1.30
+++ PlugIns/PagingLandScape2/src/OgrePagingLandScapeRenderableManager.cpp 6 Oct 2006 10:40:58 -0000
@@ -159,7 +160,7 @@ namespace Ogre
assert (tile->getRenderable ()->mQueued);

assert (tile->isLoaded ());
- assert (!tile->getRenderable ()->isLoaded ());
+// those asserts is preventing manual page loading
+// assert (!tile->getRenderable ()->isLoaded ());
//assert (!tile->getRenderable ()->isInUse ());

//
@@ -208,18 +209,17 @@ namespace Ogre
+// I didn't understend there mLoadInterval could bee increased
+// if (mLoadInterval-- < 0)
{
const size_t queueSize = mTilesLoadRenderableQueue.getSize () ;
mTilesLoadRenderableQueue.sortNearest(Cameraposition);
const size_t k = mNumRenderableLoading > queueSize ? queueSize : mNumRenderableLoading;
for (size_t i = 0; i < k; i++)
{
-
PagingLandScapeTile * const tile = mTilesLoadRenderableQueue.pop ();
// no more in queues.
assert (tile != 0);
@@ -234,7 +234,6 @@ namespace Ogre
SceneNode * const tileSceneNode = tile->getSceneNode ();
assert (tileSceneNode != 0);

-
// if renderable can be loaded
if (rend->load ())
{
Index: PlugIns/PagingLandScape2/src/filetutils.cpp
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/PlugIns/PagingLandScape2/src/filetutils.cpp,v
retrieving revision 1.4
diff -u -p -r1.4 filetutils.cpp
--- PlugIns/PagingLandScape2/src/filetutils.cpp 4 Sep 2006 16:16:25 -0000 1.4
+++ PlugIns/PagingLandScape2/src/filetutils.cpp 6 Oct 2006 10:41:02 -0000
@@ -7,9 +7,9 @@
* *
***************************************************************************/

-#include "OgrePagingLandScapePrecompiledHeaders.h"
+#include <OgrePagingLandScapePrecompiledHeaders.h>

-#include "OgreNoMemoryMacros.h"
+#include <OgreNoMemoryMacros.h>


#include <sys/types.h>
Index: Samples/Common/include/PagingLandScape2Overlay.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/Samples/Common/include/PagingLandScape2Overlay.h,v
retrieving revision 1.2
diff -u -p -r1.2 PagingLandScape2Overlay.h
--- Samples/Common/include/PagingLandScape2Overlay.h 22 Aug 2006 09:54:27 -0000 1.2
+++ Samples/Common/include/PagingLandScape2Overlay.h 6 Oct 2006 10:41:03 -0000
@@ -1,6 +1,7 @@
#ifndef CursorOverlayElement_H
#define CursorOverlayElement_H

+#include "OgrePrerequisites.h"

class CursorOverlayElement : public PanelOverlayElement
{
Index: Tools/MapSplitter/include/MapSplatter.h
===================================================================
RCS file: /cvsroot/ogre/ogreaddons/paginglandscape/Tools/MapSplitter/include/MapSplatter.h,v
retrieving revision 1.6
diff -u -p -r1.6 MapSplatter.h
--- Tools/MapSplitter/include/MapSplatter.h 13 Jun 2006 14:39:02 -0000 1.6
+++ Tools/MapSplitter/include/MapSplatter.h 6 Oct 2006 10:41:58 -0000
@@ -68,7 +68,7 @@ public:
* \return pointer to image containing Alpha Map that
* splats a particular Map
*/
- Image *MapSplatter::getAlphaMap(uint i);
+ Image * getAlphaMap(uint i);

/**
* \return pointer to image containing RGB Map that

tuan kuranes

16-10-2006 17:57:12

applied and in cvs (next time please you should patch against PLSM2 cvs)

RB

17-10-2006 12:06:41

Thanks for the lightspeed replay!

(next time please you should patch against PLSM2 cvs)

Yes of course :)

:idea: If someone interested, here the implementation of the algo:

http://www.upload2.net/page/download/GccfgDL5S7cKMDT/terra_nova.tar.bz2.html

this sample is written for the YAKE project, but it could be ported to another platform easily.