PagingGeometry doesn't seem to improve the performance

Dugi

01-08-2013 11:26:17

I changed the name of this topic, because I was helped with this, but a new issue came, see bellow. Original name was Help! Segfault in PagedGeometry::Update().

I was trying to place some trees using PagedGeometry accordingly to the first tutorial, but I came to a problem I could not figure out. Until I came to the trees->update() part, everything was fine (nothing displayed, not sure if wasn't supposed to display something after using trees->setPageLoader(treeLoader) even without using ->update).

It caused crashes even if I placed there no objects, or just one on zero coordinates. It seems to crash in the same way even if I don't assign it a PageLoader. Here's the code:
Forests::PagedGeometry *trees = new Forests::PagedGeometry();
trees->setCamera(mCamera);
trees->setPageSize(50);
trees->setInfinite();
trees->addDetailLevel<Forests::BatchPage>(150, 30);
trees->addDetailLevel<Forests::ImpostorPage>(400, 50);
Forests::TreeLoader3D *treeLoader = new Forests::TreeLoader3D(trees, Forests::TBounds(0, 0, 1500, 1500));
Ogre::Entity *myEntity = mSceneMgr->createEntity("Tree", "tree-forest-1.mesh");
Ogre::Vector3 position;
Ogre::Radian yaw;
Ogre::Real scale;
//...
position = Ogre::Vector3(0,0,0);
yaw = Ogre::Degree(0);
scale = Ogre::Real(4);
treeLoader->addTree(myEntity, position, yaw, scale);
//...
trees->setPageLoader(treeLoader);
//So far, no segfaults occurred.
//...
//In frameRenderingQueued
trees->update();
//Caused a segfault

Regarding the rest of code, it was based on the classical TutorialApplication and BaseApplication from clean project, adding a terrain and some other entities, but they had different names and it was pretty basic.

I tried to use valgrind on it, and this is what it told about the crash:
==6869== Process terminating with default action of signal 11 (SIGSEGV)
==6869== General Protection Fault
==6869== at 0x4FD27D7: Ogre::Camera::getDerivedPosition() const (OgreCamera.cpp:524)
==6869== by 0x43EBC2: Forests::PagedGeometry::update() (in /home/dugi/Documents/Informa/clean_ogre_cmake_project/dist/bin/OgreApp)
==6869== by 0x42664C: TutorialApplication::frameRenderingQueued(Ogre::FrameEvent const&) (TutorialApplication.cpp:339)
==6869== by 0x5169CEC: Ogre::Root::_fireFrameRenderingQueued(Ogre::FrameEvent&) (OgreRoot.cpp:841)
==6869== by 0x516A17F: Ogre::Root::_fireFrameRenderingQueued() (OgreRoot.cpp:896)
==6869== by 0x516A1B1: Ogre::Root::_updateAllRenderTargets() (OgreRoot.cpp:1395)
==6869== by 0x516A26F: Ogre::Root::renderOneFrame() (OgreRoot.cpp:978)
==6869== by 0x516A2B4: Ogre::Root::startRendering() (OgreRoot.cpp:968)
==6869== by 0x41B7D8: BaseApplication::go() (BaseApplication.cpp:205)
==6869== by 0x41B357: main (TutorialApplication.cpp:364)


I am using ogre-paged-1.1.4, with Ogre 1.8.1, compiled on Linux Ubuntu 12.10, building with cmake version 2.8.9, using Qt but the error comes also without using it at all, video card ATI HD5470 if that matters.

Sorry if it is noobish question.

Dugi

12-08-2013 11:53:37

I tried to use it on Ogre 1.9.0 (the patched version), but it segfaulted on trees->update() as well. :(

tod

21-08-2013 08:05:04

i think the camera may be invalid, from the call stack.

Dugi

23-08-2013 12:24:57

I assumed that something might be wrong with the camera as well and experimented with it, but with no success. The camera was working properly without PagedGeometry.

I tried it using a different code (using AdvancedOgreFramework from Tutorial instead of TutorialFramework) that has the camera defined differently, with only one tree, and still, segfault on trees->update(), this time without specifying that it was related to the camera.

If I could get a link to a working 1.9.0 ogre project using PagedGeometry, I might be able to figure out what difference makes it segfault, but I haven't found anything so far. Even the examples are failing to compile (except the first one, but that one crashes even before that, reporting that World geometry is not supported by the generic SceneManager.).

Dugi

27-09-2013 08:14:03

To make it easier to spot the error, I am pasting the lines that seem to cause it:
In OgreCamera.cpp, it crashes on updateView() (looks like if something was set up wrongly there)
const Vector3& Camera::getDerivedPosition(void) const
{
updateView();
return mDerivedPosition;
}

In PagedGeometry.cpp, the code above is called from this:
//Get camera position and speed
Vector3 camPos = _convertToLocal(sceneCam->getDerivedPosition());
Vector3 camSpeed; //Speed in units-per-millisecond

I am not sure what is wrong there, but updateView does this:
void Frustum::updateView(void) const
{
if (isViewOutOfDate())
{
updateViewImpl();
}
}

and updateViewImpl() does this (so it probably segfaults somewhere here, note that it segfaults only if there is at least one object on PagedGeometry, without problem if it is empty):
void Frustum::updateViewImpl(void) const
{
// ----------------------
// Update the view matrix
// ----------------------

// Get orientation from quaternion

if (!mCustomViewMatrix)
{
Matrix3 rot;
const Quaternion& orientation = getOrientationForViewUpdate();
const Vector3& position = getPositionForViewUpdate();

mViewMatrix = Math::makeViewMatrix(position, orientation, mReflect? &mReflectMatrix : 0);
}

mRecalcView = false;

// Signal to update frustum clipping planes
mRecalcFrustumPlanes = true;
// Signal to update world space corners
mRecalcWorldSpaceCorners = true;
// Signal to update frustum if oblique plane enabled,
// since plane needs to be in view space
if (mObliqueDepthProjection)
{
mRecalcFrustum = true;
}
}

dermont

30-09-2013 09:22:35

Why not zip up and upload your source project instead of just repeating the errors you are encountering.

Have you checked there is not a mismatch between the versions of Ogre you are build against and the Example loadPlugin loads the correct version of plugins?

You should be able to run Example1-10 by updating Example1 to say load from a plugin.cfg file and:


Root *root = new Ogre::Root("plugins.cfg");
/* //Load appropriate plugins
.....
*/

//Load the terrain
//sceneMgr->setWorldGeometry("terrain.cfg");


Commenting out the query mask in HeightFunction.h:


void initialize(SceneManager *sceneMgr){
if (!initialized){
initialized = true;
updateRay.setOrigin(Vector3::ZERO);
updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y);
raySceneQuery = sceneMgr->createRayQuery(updateRay);
raySceneQuery->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK);
//raySceneQuery->setWorldFragmentType(Ogre::SceneQuery::WFT_SINGLE_INTERSECTION);
raySceneQueryListener = new MyRaySceneQueryListener;
}
}

Dugi

02-10-2013 09:42:05

Yes, I have checked that it isn't a version mismatch, I had issues with that before, but now, it should not happen. I have compiled PagedGeometry with Ogre 1.9 (before also with Ogre 1.8, result was the same) and using it with Ogre 1.9.

I wasn't even able to compile some examples, so the position of plugins file does not matter, but height function could not compile even if I separated it, so commenting that particular line might do the trick, I'll try that.

And okay, I am posting a project where I encounter the problem. I've made it by minimalistically fusing the AdvancedOgreFramework with the code from tutorial. For some reasons, sometimes it does not segfault, but nothing from the objects in PagedGeometry appears (never seen this behaviour before, but it looks like if it accidentally entered an unrelated part of the memory the program has instead of entering a part of memory the program does not have, failing to do its job in both cases).

dermont

02-10-2013 12:42:28

Haven't looked through all of your demo but the segfault may be due to the fact you are letting your PagedGeometry go out of scope in GameState:createScene and then trying to update it later.


GameState:createScene {
.....
Forests::PagedGeometry *trees = new Forests::PagedGeometry(m_pCamera);
}
GameState::update {
trees->update();
}


I'm not sure how the AdvancedFramework is supposed to work but you probably need something like the following and then deleting when the GameState exits.

GameState::GameState()
{
....
<edit>
//Forests::PagedGeometry *trees = 0;
trees = 0;
</edit>
}
GameState:createScene {
.....
trees = new Forests::PagedGeometry(m_pCamera);
}

GameState::update {...
...
<edit>
if (trees)
</edit>
trees->update();
....
}


Attached is Example1 (built agains 1.4.4) and modified to remove references to terrain. Update the CMakeList.txt file to point to your PagedGeometry lib/includes, remove boost_system if your not building against later versions of boost.

Copy across media and update your plugins.cfg file to point to your own install.

Dugi

02-10-2013 16:35:59

built agains 1.4.4According to this, linked by the wiki, the latest version is 1.1.4 and not 1.4.4. So I downloaded 1.1.4, patched it with the patch that should handle the differences of Ogre 1.9, and somehow it compiled with Ogre 1.9. So I believe that my problem is that I have an obsolete version of PagedGeometry, but I could not find anything newer. I found one link, but it was dead. Any ideas where I might get it?

EDIT: Found some precompiled windows binaries for PagedGeometry 1.1.1, it looked nice, but the performance wasn't great, but I blame Wine for it.

dermont

02-10-2013 16:53:55

built agains 1.4.4According to this, linked by the wiki, the latest version is 1.1.4 and not 1.4.4. So I downloaded 1.1.4, patched it with the patch that should handle the differences of Ogre 1.9, and somehow it compiled with Ogre 1.9. So I believe that my problem is that I have an obsolete version of PagedGeometry, but I could not find anything newer. I found one link, but it was dead. Any ideas where I might get it?

Sorry, typo, should be 1.1.4.

As I said the problem with the demo you posted, PagedGeometryCrashing.rar, is in your code. What is the problem you are currently encountering?

AFAIK with 1.9 Examples1-10 won't run without either disabling the old terrain code or build the old terrain manager yourself. Example11 should run with the new terrain system.

There is also ogre-paged-latest which is just 1.1.4 patched with some(not all) ofthe differences you mentioned above.

viewtopic.php?f=14&t=29997

Dugi

02-10-2013 17:35:07

What is the problem you are currently encountering?It either does absolutely nothing (not a single object appears), or it segfaults on trees->update(). I assume that when it does nothing, it is the same error, just jumping into a wrong address that happens not to be outside the space given to the program.

the segfault may be due to the fact you are letting your PagedGeometry go out of scope in GameState:createScene and then trying to update it later.I don't understand what do you mean with going out of scope. Nothing related to PagedGeometry was done outside the lines I posted in the initial post, there is just the creation and update. I have tried it also on TutorialApplicationFramework, but it did the same.

AFAIK with 1.9 Examples1-10 won't run without either disabling the old terrain code or build the old terrain manager yourself. Example11 should run with the new terrain system.Example11 cannot compile neither. And I don't think that my skill is good enough to port the old terrain format for the new terrain format.

dermont

02-10-2013 18:24:35

What is the problem you are currently encountering?It either does absolutely nothing (not a single object appears), or it segfaults on trees->update(). I assume that when it does nothing, it is the same error, just jumping into a wrong address that happens not to be outside the space given to the program.


As I've already said, to me, the problem looks to be with your code. Attached is the modified GameState.cpp.

Dugi

02-10-2013 19:23:03

It works now. Meshes are visible and replaced by impostors. A big thanks to you. I should have tried to test if it is uninitialised at that point. And I should not have assumed that AdvancedOgreFramework will not run update() before createScene().

However, I haven't noticed any visible performance improvement. I have created 2000 ogreheads, and looking at any of them decreased my framerate from 500 to 5, although some of them were actually replaced by 2D impostors. I moved far away enough to make them all get replaced by impostors, and the information said that there was 3.000.000 triangles, and framerate was at 5 frames per second again (1500 triangles per ogrehead, that isn't much like a 2D object). Example 10 (I found a precompiled Windows version) had quite an odd framerate and many triangles as well, so it might be caused by my computer somehow. It isn't doing what I assume it does or I have set up some properties incorrectly? EDIT: No, I was wrong here.