Changes to getHeightAt and getRealWorldSlope

DrPain

02-12-2005 21:35:39

Tuan, when I had originally written getHeightAt and getRealWorldSlope, I included a mechanism to load data if it wasn't already loaded.
I did this because I need this information in my world server, which is a 2D app with no cameras. I know I've read other people need this capability as well.

Now, in getInterpolatedWorldHeight (getHeightAt is gone?), if the data is not loaded, zero is returned. Same in getRealWorldSlope. This breaks my server. :(

What do you suggest as a solution? Is there a way to force the entire heightmap to be loaded into memory? Memory is less an issue than speed.

(BTW, I'm using CVS Head, updated today).

DrPain

02-12-2005 22:24:02

I figured I'd try to manually load all the pages, so I tried the following (just loads one page for now):


Vector3 currentPage3;
Vector2 currentPage2;

currentPage3.x = 0;
currentPage3.z = 0;
global->sceneMgr->getOption("GlobalToPage", &currentPage3);
currentPage2.x = currentPage3.x;
currentPage2.y = currentPage3.z;
global->sceneMgr->setOption("PageUpdate", &currentPage2);


However, this loads the terrain textures as well as the 2D data, which is not good for my server.
Is there a way (in the config file maybe?) to disable all textures for the map?

And if this does eventually work, how do I determine how many pages to step through? Is it the "Width" and "Height" settings in the config file?

(Apologies for not just playing with the config file, but I'm about to go out for the evening and wanted to post this before leaving) :)

tuan kuranes

03-12-2005 12:46:32

Change MaxPreloadedPage in the config files to fit all page possible (put the max of widht and height pages).
All Data page will be available.

Other things would break paging.

DrPain

03-12-2005 14:24:52

Thanks Tuan, I'll experiment with that.

The texturing is still an issue however. Is there a way to tell the engine to not texture at all?
I tried commenting out all TextureFormat lines in the cfg file, but that didn't work.

The problem is that I don't create a Renderer, so there's no root TextureManager available.

tuan kuranes

03-12-2005 14:28:14

You could create an empty TextureMode in plsm2, which would be a paginglandscapetexture derivated class but with empty method instead of virtual methods. Then register it in texturemanager constructor.

DrPain

03-12-2005 17:11:42

Ok, I think I've got that working. Do you want me to submit it as a patch?
I named the texture type "None".

Now, I'm not so sure that MaxPreloadedPages is working. In my config file, I've got:

Width=4
Height=4
MaxPreloadedPages=16

But the data doesn't get loaded. Do I need to call some function in code to load the data?

I tried the code I mentioned above, and the getSlopeAt function works, because getRealWorldSlope calls getData2D, which returns good data.
However, getHeightAt fails because getInterpolatedWorldHeight tests page->isPreLoaded(), which returns false.
What does preloaded mean as opposed to loaded? And how do I get around that?

tuan kuranes

03-12-2005 18:12:14

yes send me a patch.

about MaxPreloadedPages, does preload is not working, or getheight ?
(check what is preloaded with the pagepreloaded event)

DrPain

03-12-2005 21:03:23

If I don't make the setOption("PageUpdate") call, then PagingLandScapeData2D::load(), PagingLandScapeData2D::load() nor PagingLandScapePage::load() ever get called.

Perhaps I should take a step back and show you exactly what I'm doing. Maybe you'll see a step I've missed.


global->root = new Root("PluginsServer.cfg", "Ogre.cfg", "Ogre_Server.log");
SetupOgreResources();
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

global->root->restoreConfig();
global->root->initialise(false);

global->sceneMgr = (PagingLandScapeSceneManager *)global->root->getSceneManager(ST_EXTERIOR_REAL_FAR);
hardwareBufferManager = new Ogre::DefaultHardwareBufferManager();
global->sceneMgr->setWorldGeometry("paginglandscape2.cfg");
global->sceneMgr->getWorldSize(&global->worldSizeX, &global->worldSizeZ);

#if 0
Vector3 currentPage3;
Vector2 currentPage2;

currentPage3.x = 0;
currentPage3.z = 0;
global->sceneMgr->getOption("GlobalToPage", &currentPage3);
currentPage2.x = currentPage3.x;
currentPage2.y = currentPage3.z;
global->sceneMgr->setOption("PageUpdate", &currentPage2);
#endif

float testHeight = global->sceneMgr->getHeightAt(0, 0);
float testSlope = global->sceneMgr->getSlopeAt(0, 0);


With this code, both getHeightAt() and getSlopeAt() return zeroes, because the heightfield data is not loaded.
MaxPreloadedPages is set to 16, with Width=4 and Height=4.

tuan kuranes

05-12-2005 09:14:14

So you're not using a camera at all ?
Is that impossible without renderer ?
That was my solution one camera per client, making paging still effective...

If not possible and paging not mandatory (not too big world or powerful enough server) :

Best solution would be detecting the fact that we want to preload all pages by comparing the MaxPreloadedPages to worldwidth and worldheight and preloading them directly in Data2dmanager::Load().

patch welcome ;)

DrPain

05-12-2005 11:50:41

Ok, I'll make that change.
Do you think it's better to test that in Load(), or should there be a seperate call you can make to manually force a load?

tuan kuranes

05-12-2005 12:16:39

Load() seems the best place to me.

DrPain

05-12-2005 20:49:51

Well, I've got all that working.

However, after fixing the load problem, I saw that the getSlopeAt() function wasn't always working correctly. I took a look at your getInterpolatedWorldHeight() function and saw how complex it was. Rather than repeat that monstrosity for a slope function, I added a slope parameter (pointer to Real) to the existing getInterpolatedWorldHeight, which defaults to NULL, so as to not affect existing code.

I'll submit a patch with all these changes, but I wanted to alert you to this situation to see if you had any comment on it.

tuan kuranes

06-12-2005 13:23:58

I'm thinking about making a getSlope like method. It's on my todo list, and it will be working like in ogre Refapplication. It's about returning a list of planes bouding the region around the point.

DrPain

06-12-2005 16:59:57

Well, that sounds like it might be useful to someone.

However, I'd like to request you keep in the current getSlopeAt function, which simply returns a float from 0 to 1. I've got a LOT of functionality that depends on this. I don't need any of them thar fancy planes. ;)

I've submitted the patch for all the changes mentioned in this thread here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1374609&group_id=2997&atid=302997

tuan kuranes

06-12-2005 17:24:40

thanks for the patch.

I'm also in the process of cleaning export symbols...
Apart from getSlopeAt, which can be easily turned in a scenemanager::getOption form, is there other that you needs to turn in a getoption ?

DrPain

06-12-2005 19:44:58

At the moment, I'm good to go.

That getOption kinda worries me though. Doesn't it do a lot of string compares just to identify which function to call?

tuan kuranes

06-12-2005 20:17:30

agree. Note that sinbad is all for a rayscene query struct member containing a normal. maybe some lobbying would help to put that on top of todo.

Or We could optimize:

make the order more optimized, depending on a ratio of call numbers and cpu uses of calls.

uses multiple hashes, all set*, all get*, each in a separate hash...

Or find a way to use delegates (harder and no that user friendly).

I'm thinking of the hash thing for a while but didn't find time to.

tuan kuranes

07-12-2005 14:29:27

mmmh. finally the preload thing in Data2dmanager breaks the 'no loads' before first frame, which make use cannot "Listen" to preload event as he has now way to register it before.
So it may end in a setOption() when I'll apply the patch.

DrPain

07-12-2005 16:29:35

Ah, ok. That works fine for me as well.

tuan kuranes

16-12-2005 14:27:02

ok it's :
scenemanager::setOption("LoadNow"):