Terrain disappears or crashes

yubgipenguin

15-04-2010 09:21:32

I just have uncommected terrain creating lines from PCZTestApp.

If I remove buildingNode->translate(buildingTranslate, Node::TS_LOCAL); from MoveCamera from PCZTestApp it doesn't crash when I try to go down below the second terrain through itself. Also it crashes when an Entity is hitting the middle of second terrain.

But if I remove it, while it doesn't crash, it sometimes makes second or third, never the first one, terrain disappear when I'm at near the second terrain while looking at certain point. (try yourself) And it doesn't show bounding boxes correctly on second terrain.(rays doesn't hit)

vid :) http://www.youtube.com/watch?v=KqFc_XE8Guc) - terrain disappears without buildingNode->translate
vid2 http://www.youtube.com/watch?v=faXY85Mhr9o- crashes with buildingNode->translate

I just don't understand what's happening.

Any ideas?


PS. Oh and also I made a little modification to the zone to create ETM+PCZSM... but it still crashes or terrains disappears when I use fresh source codes from Ogre1.7.0 source code
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=57022

yubgipenguin

16-04-2010 05:00:28

can anyone test it for me to see if it happens to you too or just me with modified code...

Lf3THn4D

16-04-2010 06:02:17

Does it only happen on the middle terrain? I'm guessing it's due to some portal setup to invalid space.

Either way, the AABB portal wasn't really designed for such use. It was mostly designed for huge sparse scene structure like planetary type scenes where each AABB encompasses a planet. This allows the rid of octree culling while retaining some form of broad phase culling.

I would very much suggest that you use the octree zone and slap your terrain in them without the use of AABB portals. Personally, AABB portals are pretty useless in most cases. The recommended way to use PCZ in a typical scene is to have the base octree zone for outdoor and default zones for indoor. The reason behind this is that for the most part, indoor levels don't have much entities to handle hence the octree is only a nuisance of ram space more than actually helping in culling.

yubgipenguin

16-04-2010 07:06:25

It happens anywhere on the second terrain...

and it crashes at random points
first it was at OgreOctreeZone.cpp:line 497(something about thread lock with stack overflow)
and then it was at OgrePCZSceneNode.cpp:line 278(something about bad string pointer while comparing two strings, one of them was bad pointer)

it crashed with stack overflow when return mZoneData[zone->getName()]; or piend = mPortals.end(); is used.

I really don't understand why it crashes with seems unrelated buildingNode->translate line and why it won't crash and not show a terrain without buildNode->translate line.

With buildingNode->translate it shows terrain correctly.

So I think it's definately a memory corruption problem... somewhere.



Does it happen to you too? Or is it just me? I'd like to know if there's something wrong with my source code tree or it's a bug in Ogre source code...
I tried using prebuilt SDK and it still happens..


I would very much suggest that you use the octree zone and slap your terrain in them without the use of AABB portals. Personally, AABB portals are pretty useless in most cases. The recommended way to use PCZ in a typical scene is to have the base octree zone for outdoor and default zones for indoor. The reason behind this is that for the most part, indoor levels don't have much entities to handle hence the octree is only a nuisance of ram space more than actually helping in culling.
I'd like to use your suggestion but I don't know how to slap a terrain in octree zone... is there an example code?

Lf3THn4D

16-04-2010 07:48:24

I've been using PCZ with no issues in terms of portal traversal code. I'm suspecting you probably missed some part that needs commenting out due to certain bad hard wired code. The sample code is more of a test scene to test features than a proper sample. I had intended to fix this to provide a proper scene sample however I don't have the time to work on that right now.

For octree zone terrain stuff, you simply create your octree zone type and use it directly by assigning all your terrain scene nodes to the octree zone. The octree zone will then automatically use it's internal octree culling implementation to do proper frustum culling. That is all there is to it.

yubgipenguin

16-04-2010 08:56:09

For octree zone terrain stuff, you simply create your octree zone type and use it directly by assigning all your terrain scene nodes to the octree zone. The octree zone will then automatically use it's internal octree culling implementation to do proper frustum culling. That is all there is to it.
You mean I create terrain with ZoneType_Terrain and move all the nodes to the zone created with ZoneType_Octree?

Can you give me a code snippit? :)

Lf3THn4D

16-04-2010 09:33:56

ZoneType_Octree does not support terrains. You need ZoneType_Terrain. ZoneType_Terrain is in itself an octree zone. So just using it directly should be good enough. My suggestion on using ZoneType_Octree was on the assumption that you are using ETM. Hope this help. ;-)

yubgipenguin

16-04-2010 10:03:04

Oh. Yeah well I modified TerrainZone to make a zone named *ZoneType_TerrainETM*. It's same thing as ZoneType_Terrain but with deform function(I just copied deform related function codes from ETM). You can't use ETM with PCZSM without that modification.. at least I don't think so....(since you can't use two scene managers: http://www.ogre3d.org/mantis/view.php?id=130)

And also it crashes without my modification.


So it means I can't use multiple terrains with PCZSM? I mean, it crashes. I tested it with fresh pre-built Ogre1.7.0 SDK and, from that SDK, PCZTestApp and same thing still happens.

Just try uncommenting createTerrain lines from PCZTestApp and make two terrains and when you hit second terrain it bombs.(follow my second vid if you don't understand this, use Shift Key to move around faster)

Maybe it's something wrong with something else... so I'd really like to know same thing happens to someone else too...

yubgipenguin

16-04-2010 13:18:46

I just found out it crashes on PythonOgre too.....

Same as C++ version, if I remove self.app.buildingNode.translate(self.buildingTranslate, ogre.Node.TS_LOCAL) line it won't crash but terrain will disappear.


And how do I use terrain without AABB portals? When I removed AABB portals from terrain, terrains weren't visible at all...

Lf3THn4D

16-04-2010 17:22:05

ETM is a scene manager? I always thought ETM is just a MovableObject so it doesn't really care. Maybe what I'm referring to is ETM2.

When using terrain as I had suggested, you need to use the terrain zone as a whole. That means to have the full scene terrain in the terrain zone. If you're doing paging, I don't think the default ogre terrain is a good place to start. You could simulate paging through ETM2 i think. Not so sure about ETM. I haven't been looking at them for a long time. However, Ogre has recently created a new paging terrain system. It should be possible to use that with PCZ without much issue.

As for the removal of translating building node, I've no clue what the problem really is. It could probably be a bug in the way terrain was handled. Unfortunately I can't compile the PCZ test case right now since ogre moved to a new sample framework. The PCZ sample needs to be ported over first.

yubgipenguin

17-04-2010 07:26:30

ETM is a scene manager? I always thought ETM is just a MovableObject so it doesn't really care. Maybe what I'm referring to is ETM2.

As for the removal of translating building node, I've no clue what the problem really is. It could probably be a bug in the way terrain was handled. Unfortunately I can't compile the PCZ test case right now since ogre moved to a new sample framework. The PCZ sample needs to be ported over first.


Yeah I'm using ETM2 and it's not a scene manager...
Actually I modified TerrainZone to make ETM zone because if you use ETM2 directly you can't make more than one terrain.
I thought even though ETM is not a scene manager it USES scene manager so I thought it is only compatible with OctreeSceneMAnager but only code it uses was creating a node... so you could probably modify ETM2 to make multiple terrains I guess.. but it was easier to make ETM zone than to do that. :)

I didn't know you could use new terrain with PCZ! If then I don't have to struggle with PCZ with multiple terrain... I just could use new terrain paging for multiple terrain and portals to make indoors or even TARDIS! :)

About a crash I've got no clue. It crashes at totally unrelated random points. So my first thought is corruption in the memory somewhere...

Lf3THn4D

17-04-2010 16:56:44

Ah.. ok. So I was right that ETM doesn't bother about scene managers. From what I understood, the new terrain does the same thing except that it uses the paging feature and generates better terrain blend shaders. So yes, you should be able to use it with PCZ. I would guess that it might even be possible to use the new paging system for paging Zones in and out of the scene.

At anyrate, you might be right about the memory corruption some where. I'm guessing it's most likely the AABB portal traversal bug. I've never used it since portal/antiportal planes are the only thing that is useful to my scenario. Truth be told, I can't find any proper justification to use AABB portals. Either way, this is how it is now. I suggest you avoid using AABB portals for now unless really necessary. As far as I can tell, nobody actually use them aside from probably Chaster who is the author of this plugin.

yubgipenguin

29-04-2010 01:31:46

Yup... works great with Quad Portals...

I'm gonna be using PCZ instead of new terrain paging only because it's a lot faster on my Gforce FX 5500 machine. :D

yubgipenguin

30-04-2010 04:02:10

At anyrate, you might be right about the memory corruption some where. I'm guessing it's most likely the AABB portal traversal bug. I've never used it since portal/antiportal planes are the only thing that is useful to my scenario. Truth be told, I can't find any proper justification to use AABB portals. Either way, this is how it is now. I suggest you avoid using AABB portals for now unless really necessary. As far as I can tell, nobody actually use them aside from probably Chaster who is the author of this plugin.

I don't know what I'm doing wrong but I changed portals to Quad Portals and thought it worked great but when I hit terrain it crashed again.

So I don't think it's about AABB I think maybe I'm doing something wrong since it works for you? Or maybe you never hit the terrain yourself.....

It crashes whether it's camera or an Entity. So if I put an entity and entity hits terrain it crashes.


Maybe you can post working example code for portals....
And here's what I did for portals for reference.


portalName = Ogre::String("_PortalFrom"+zoneName+"ToDefault_Zone1_");
p = ((PCZSceneManager*)mSceneMgr)->createPortal(portalName);
float height = 30.0f;
p->setCorner(0, Vector3(0.0f, height, 0.0f));
p->setCorner(1, Vector3(0.0f, height, 1500.0f));
p->setCorner(2, Vector3(1500.0f, height, 1500.0f));
p->setCorner(3, Vector3(1500.0f, height, 0.0f));
p->setNode(terrainZone->getEnclosureNode());
terrainZone->_addPortal(p);
p->updateDerivedValues();

portalName = Ogre::String("_PortalTo"+zoneName);
p5 = ((PCZSceneManager*)mSceneMgr)->createPortal(portalName);
p5->setCorner(0, Vector3(0.0f, height, 0.0f));
p5->setCorner(1, Vector3(0.0f, height, 1500.0f));
p5->setCorner(2, Vector3(1500.0f, height, 1500.0f));
p5->setCorner(3, Vector3(1500.0f, height, 0.0f));
p5->setNode(((PCZSceneManager*)mSceneMgr)->getDefaultZone()->getEnclosureNode());
((PCZSceneManager*)mSceneMgr)->getDefaultZone()->_addPortal(p5);
p5->updateDerivedValues();

p->setTargetZone(((PCZSceneManager*)mSceneMgr)->getDefaultZone());
p->setTargetPortal(p5);
p5->setTargetZone(terrainZone);
p5->setTargetPortal(p);

Fish

30-04-2010 14:32:05

I would suggest going back to basics. Revert back to the original PCZSM code and example program. Maybe even go back to Ogre 1.6.5 temporarily. Make sure that everything works as expected and then start making modifications, but only one modification at a time in some logical progression.

-Fish

yubgipenguin

07-05-2010 17:24:55

I would suggest going back to basics. Revert back to the original PCZSM code and example program. Maybe even go back to Ogre 1.6.5 temporarily. Make sure that everything works as expected and then start making modifications, but only one modification at a time in some logical progression.

-Fish


You nailed it! 1.6.5 doesn't crash. Now we know where to look...