What are you simple tricks and optimize rules.

Hey everyone. I been woundering what are some key details that a programer should keep in mind when dealing with larger projects and 3d worlds?

For example, you wouldn’t want to load everything at once, but “cube” load what is needed around the player and then preload what the user may go into nexts.

One thing I do whenever I create a task or bit of code that needs to repeat is ask myself if this task really needs to repeat every frame, or can I get away with running it every 0.1 seconds for example. If so the task would run 10 times per second instead of 60, giving a six-fold performance gain on that task.
Then I see if I can take it one step further, for example if this task that now updates every 6 frames (at 60fps) is looping over many objects, I’ll set the task to run every frame but only loop over 1/6th of the objects, which will help keep the frame rate smooth instead of having a little performance spike every 0.1 seconds.

It is also important when optimizing to measure what parts of the code are taking the most time and focus on those parts. Don’t waste time reducing something that takes 0.02ms down to 0.01ms per frame, unless you really have nothing better to do.

What is the best way to do this in Panda? Thanks!

instead of this

taskMgr.add(myfunc, 'myfunc-task')

use something like this

taskMgr.doMethodLater(0.1, myfunc, 'myfunc-task')

that causes it to run every (0.1) seconds
[/code]

dont forget that a task that returns:

return task.cont

will run every frame from that moment on.

return task.again

task.again however will make it repeat the same interval as defined before.

For the original question, use LODs and terrain paging youtube.com/watch?v=qIE5_pltbzQ

One way of doing LOD is setting it up in an egg file and having premade “LOD levels”.

Another approach could be to have 2 cameras, one rendering things close to you from some point in high LOD and another camera rendering things farther from some point but in their lower LOD level.

Geomipterrain can do LODing of terrains in realtime (no need to model each LOD level), BUT this is only for terrain geometry generated from a heightmap image.

Thank you!

Is it possible to use fuzzy LOD distances?
Lets say i have 3 LODs for model, high,med and low.
And then make player able to input distances for switching LODs (via python variable)?

EDIT1: I would have all LODs in one egg file per model.

You have complete control over the LOD switching distances via the LODNode interface.

David