Application is slow after deformation


17-02-2009 12:31:00

Hello World
I'm using ETL with wxOgre ( ) and I'm getting trouble. In fact the problem is very simple but I have absolutely no idea of how I can solve it, and why I have this problem. When I load a heightmap terrain, or a plane terrain, if I move the camera, everything works well. But now if I deform a part of the terrain, and try to move the camera again, it moves slowly, and it's laggy. You can have a look at the code here and at a video showing the issue here :
Do you have an idea of what is causing that, and how to solve it ? Do you need more precisions ?
Thanks for your help


17-02-2009 14:30:08

Sorry, no idea. Once deformation is done, it shouldn't affect performance (unless of course the new terrain state needs higher level of detail. but judging from your video, that is unlikely).
Maybe you're not correctly stopping the deformation? What kind of computer do you have (CPU, graphics card)?


17-02-2009 15:07:32

I have a Core2 Duo 2.53Ghz, 4Go of Ram and a Nvidia Quadro NVS 160M. I have also tested the program on another configuration : a Pentium4 3Ghz, 2Go of Ram and a Nvidia 9800. It should be sufficient...
What do you mean by "stopping correctly the deformation" ?


17-02-2009 15:33:38

I mean that you don't stop to deform the terrain even though no mouse button is pressed.
Does the ETL demo show the same behaviour?


17-02-2009 17:01:18

No, the demo works properly. A difference between my program and the demo is that I use wxOgre so the main loop is owned by wxApp class. So I make the program deform the terrain at each mouse event. I have set a maximum of 30 fps to the viewports. Can it be the source of the problem ?


17-02-2009 18:40:45

It has to be, though precisely how I can't tell you. Something apparently happens when you start a deformation which isn't reset properly (else it wouldn't influence performance *after* the deformation).


20-02-2009 10:04:59

To avoid doing deforms every mouse event have the mouse down event toggle some "mouse button down" flags in your app class (and mouseup toggle the flags back to false). Then do the actual deformation in your onIdle event handler. Ex.

mouse event handler
onMouseEvents(wxMouseEvent &evt)
if (recievedLeftMouseDown)
m_bLMBDown = true;

else if (recievedLeftMouseUp)
m_bLMBDown = false;

// ... etc for other mouse btns

onIdle event handler
onIdle(wxIdleEvent& evt)
if (m_bLMBDown)
// Get the mouse position on terrain and do the deform