PagedGeometry and Terrain Paging

Etty

28-03-2013 15:24:07

Hello,

I'm now adding pagedGeometry to my application with terrain paging. However I met some issue and I was wondering how you, PagedGeometry users, are dealing with the kind of problem I encounter.

With TreeLoader3D:
When I try to get the heightAtWorldPosition where the terrain isn't loaded it returns 0 and then all my trees appear under the terrain.

With TreeLoader2D and GrassLoader: (With the height function I used for TreeLoader3D provided.)
At my start position everything is under the terrain but if I move, new grass/tress will be correct.
If I move far enough to unload the misplaced ones and come back, they will be correctly replaced.

I assume this is happening because the terrain is loaded after PagedGeometry. So I did the following thing :

In my dummyPageProvider, when a terrain chunk is being prepared, I'm filling a list of entities that will be placed on that terrain area.
When a terrain is loading, I sleep the thread until the terrain is fully loaded and then place the pending entities.

This is working pretty well for TreeLoader3D but now I'm doubt about GrassLoader since it place the grass itself when boundaries are provided.

So I'm adding a grasslayer per terrain with corresponding boundaries.
But still a problem, there are no grass where camera spawn ( and not even under terrain ) until I move and come back for it to reload.

I think I am close to what I want. But I'm absolutely not sure of how effective is the way I did all that stuff.

If you have any advice about PagedGeometry and terrain paging component I'd really appreciate it, thanks !

Edit : Oh yeah I forgot. I was first using that trick in my frameListener :

if ( mTerrainGroup->getTerrain(0,0) != NULL && mTerrainGroup->getTerrain(0,0)->isLoaded()){
trees->update(); // Using TreeLoader2D, wouldn't help with TreeLoader3D
grass->update();
}

In that case i was spawning on terrain 0 0. This would have been replaced by any terrain near camera.
That worked perfectly but somehow I'd prefer avoid that method and procedurally place entities.

Etty

29-03-2013 10:46:48

I fixed that grass problem by calling grass->reloadGeometry();
With every terrain having its layer of grass added to the grassLoader.

Since this reload function seems "heavy" I will only call it situationally (spawn, teleport, something like that).

I'm not sure about the efficiency of what I did since the beginning and I'm still curious about how you guys do.