[SOLVED] PStats

hello,

I’ve had a look at my pstats to try and figure out why I am getting only 6-10 fps with my terrain geometry - that saying I am creating my own terrain and not using the panda class heightmap classes.

I am though not entirely sure how pstats can help me finding out about bottlenecks - maybe I am missing something fundamental here ?

anyone can tell me more ?

It looks like “cull” is surprisingly high in your time breakdown, which suggests you might have too many nodes in your scene graph. Have you considered using flattenStrong() to reduce the node count of your terrain?

Also, all of the “munge” time is a little worrisome. Are you sure you have converted your terrain as a static model, and not as an animatable model by mistake?

BTW, the piano roll chart isn’t particularly useful to solve questions like this; that’s mainly needed when you want to answer questions about the order in which things happen during the frame.

David

ok here now with flatten_strong on my terrain node

Uploaded with ImageShack.us

framerate seems to have gone up a bit but still pretty poor 17fps.

Not sure what you mean with

Egg files can store two different kinds of models–static models, which are most efficient to render, and animatable models, which can be loaded as Actors. They both look the same when you render them, but animatable models are more expensive.

You have to know when you convert it from whatever modeling package you use whether you intend it to be animatable or not. Each converter has its own way of specifying whether you want a static or an animatable model.

I don’t know which modeling package or converter you have used, but one easy way to check is to look at your egg files in a text editor and see if you see the “dart” flag. This will only be present in an animatable model.

Also, what does the scene graph look like if you type render.ls()?

David

ah I understand what you mean - my geometry is not created via a 3rd party software, its generated from a 512x512 heightmap via my own code ( I dont use the native panda heightmap class ). The big texture gets split into 16x16 geom corrisponding what would be 32x32 heightmaps.

I have left the geometry as “dynamic” though, could that have something to do with it ?

oh and here my “ls()” output

Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
wclass is WinGraphicsWindow0, title is + Panda3D Test Viewer
Type AWTerrainPath was unregistered!
PandaNode render S:(CullFaceAttrib RescaleNormalAttrib ShadeModelAttrib)
  PandaNode camera_group
    Camera camera ( PerspectiveLens )
      PerspectiveLens fov = 39.3201 30
  PandaNode The World
    PandaNode FocusNode T:(hpr -45 -45 0)
      Camera BaseCamera ( PerspectiveLens ) T:(pos 0 -1000 0)
        PerspectiveLens fov = 67 52.8009
        CollisionNode MousePicker (1 solids) (hidden)
    PandaNode Test Sector
      PandaNode AWTerrainNode
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))
        AWTerrainPath AWTerrainPatch (1 geoms: S:(ShaderAttrib TextureAttrib))

I never noticed this

I think it should say “AWTerrainPatch” it’s misspelled - I’ll try and see why that is.

EDIT :
I’ve fixed the spell mistake - but it still says
Type AWTerrainPatch was unregistered!

the AWTerrainPatch is a class derived of GeomNode which holds the geometry for that part of the terrain.

Oh, hmm, that kind of looks like trouble. Panda’s going to have to visit each one of the AWTerrainPatch nodes every frame and ask it for the geometry to render, then it’s going to have to munge whatever the answer is into a form that the backend renderer can handle.

This is potentially going to be very expensive, unless you have taken a lot of care to make the AWTerrainPatch class extremely efficient. How have you implemented this class? Is it a subclass of GeomNode, or is it something else? Does it rebuild its geometry every frame? What exactly happens in cull_callback()?

David

my class is derived of GeomNode - I haven’t overriden any of the geom node methods.

class cAWTerrainPatch : public GeomNode
{
public:
	cAWTerrainPatch(unsigned int x, unsigned int y);
	virtual ~cAWTerrainPatch();

	inline bool IsLoaded()const { return mbLoaded; }

	void CreateMesh(cAWTerrain* pTerrain);

protected:
	friend class cAWTerrain;
	cFileObject* mpFileObject;
private:
	unsigned int mCoordX;
	unsigned int mCoordY;
	bool mbLoaded;
	

public:
	static TypeHandle get_class_type() { return _type_handle; }
	static void init_type() { GeomNode::init_type(); register_type(_type_handle, "AWTerrainPatch", GeomNode::get_class_type()); }
	virtual TypeHandle get_type() const { return get_class_type(); }
	virtual TypeHandle force_init_type() { init_type(); return get_class_type(); }
private:
	static TypeHandle _type_handle;
};

and here the implementation of the create function

void cAWTerrainPatch::CreateMesh(cAWTerrain* pTerrain)
{
	PT(GeomVertexArrayFormat) array = new GeomVertexArrayFormat();
	array->add_column(InternalName::make("vertex"), 3, Geom::NT_float32, Geom::C_point);
	array->add_column(InternalName::make("normal"), 3, Geom::NT_float32, Geom::C_point);
	array->add_column(InternalName::make("alphaUV"), 2, Geom::NT_float32, Geom::C_texcoord);
	array->add_column(InternalName::make("colorUV"), 2, Geom::NT_float32, Geom::C_texcoord);

	PT(GeomVertexFormat )unregistered_format = new GeomVertexFormat();
	unregistered_format->add_array(array);

	CPT(GeomVertexFormat) format = GeomVertexFormat::register_format(unregistered_format);

	PT(GeomVertexData) vData = new GeomVertexData("AWTerrainPatch", format, Geom::UH_dynamic);
	GeomVertexRewriter vertices = GeomVertexRewriter(vData, "vertex");
	GeomVertexRewriter normals = GeomVertexRewriter(vData, "normal");
	GeomVertexRewriter alphaUV = GeomVertexRewriter(vData, "alphaUV");
	GeomVertexRewriter colorUV = GeomVertexRewriter(vData, "colorUV");

	PT(Geom) polyGeom = new Geom(vData);


	float factor = TILES_PER_TERRAIN_X / 10.0f;

	for(int y = static_cast<int>(mCoordY * (TILES_PER_PATCH_Y - 1)), y0 = 0; y <= static_cast<int>(mCoordY + 1) * (TILES_PER_PATCH_Y - 1); y++, y0++)
	{
		for(int x = static_cast<int>(mCoordX * (TILES_PER_PATCH_X - 1)), x0 = 0; x <= static_cast<int>(mCoordX + 1) * (TILES_PER_PATCH_X - 1); x++, x0++)
		{
			cAWTerrainTile* pTile = pTerrain->GetTile(x, y);
			LVector3f pos = LVector3f(x, y, pTile->mHeight);
			float a_x = static_cast<float>(x) / static_cast<float>(pTerrain->Size().get_x());
			float a_y = static_cast<float>(y) / static_cast<float>(pTerrain->Size().get_y());
			LVector2f vAlphaUV = LVector2f(a_x, a_y); //Alpha UV : [0, 1)
			LVector2f vColorUV = vAlphaUV * factor;   //Color UV : Repeat once every 10 tiles 


			vertices.add_data3f(pos);
			normals.add_data3f(pTerrain->GetNormal(x,y));
			alphaUV.add_data2f(vAlphaUV);
			colorUV.add_data2f(vColorUV);
		}
	}

	PT(GeomTriangles) prim = new GeomTriangles(Geom::UH_dynamic);

	for(unsigned int y = mCoordY * (TILES_PER_PATCH_Y - 1), y0 = 0; y < (mCoordY + 1) * (TILES_PER_PATCH_Y - 1); y++, y0++)
	{
		for(unsigned int x = mCoordX * (TILES_PER_PATCH_X - 1), x0 = 0; x < (mCoordX + 1) * (TILES_PER_PATCH_X - 1); x++, x0++)
		{
			//Triangle 1
			prim->add_vertex(y0   * ((TILES_PER_PATCH_X - 1) + 1 ) + x0);
			prim->add_vertex(y0   * ((TILES_PER_PATCH_X - 1) + 1) + x0 + 1);
			prim->add_vertex((y0+1) * ((TILES_PER_PATCH_X - 1) + 1) + x0);
			//Triangle 2
			prim->add_vertex((y0+1) * ((TILES_PER_PATCH_X - 1) + 1) + x0);
			prim->add_vertex(y0   * ((TILES_PER_PATCH_X - 1) + 1) + x0 + 1);
			prim->add_vertex((y0+1) * ((TILES_PER_PATCH_X -1) + 1) + x0 + 1);
		}
	}

	prim->close_primitive();
	polyGeom->add_primitive(prim); 
	add_geom(polyGeom);

}

this function is not called every frame, but only once.

OK, so that’s not too bad; but still you’ve got problems because you’ve subclassed GeomNode, which prevents flatten_strong() from flattening the different nodes together (it can’t, because it doesn’t know what your subclass might need to do specially), and that means you have 256 separate nodes where maybe one would do.

You could improve this by creating a series of standalone GeomNodes instead, and then flatten_strong() could reduce them into only one or a handful of nodes. Or, you could somehow combine the logic of all of these separate nodes into a single node that generates one big mesh instead of lots of little meshes.

Incidentally, the “unregistered type” problem means that you’ve never called AWTerrainPatch::init_type().

David

Are the panda nodes not meant to be derived from ? Because that was what I thought the correct approach would be.

Also you suggest I don’t derive from GeomNode but create a geomnode in my CreateMesh method but store a NodePath to the GeomNode in my class instead ?

I don’t really wanted to generate a single big mesh because it is all meant to stream at some point, but that’s a different story.

I have actually created various custom “debug” classes deriving from geomNode - it never occured to me that that would be wrong.

ok, I’ve changed my code to not derive of GeomNode anymore and store the nodepath in my class instead. The fps is now around 150 again.

my questions above remain though :slight_smile:

It’s not “wrong” per se to derive from GeomNode, but you have to understand the consequences of doing so. In this case, it interferes with the ability of Panda to automatically coalesce multiple small GeomNodes into a single large one, which is usually an important optimization.

GeomNode is particularly tricky thing to subclass because it is so critical to the low-level rendering performance–it is the fundamental geometry type. It would be possible to subclass GeomNode in a way that didn’t interfere with Panda’s optimization features, but it would take a bit more effort. In this case, it’s probably better not to subclass GeomNode.

This is the fundamental distinction between “has-a” and “is-a” in object-oriented programming. In general, there’s no reason to be afraid of “has-a”, especially when it makes some things easier. :wink:

David

okay makes sense,

I have re-organised my geometry and terrain classes now and a total of 1.477milion triangles are contained in a mere 15 geoms (most of which are not terrain related but other stuff).

The problem I have got now is that everytime I perform a mouse click which executes this code - I get a massive spike.

	// This gives up the screen coordinates of the mouse.   
	const LPoint2f& mpos =GetMouseWatcher()->get_mouse();

	// This makes the ray's origin the camera and makes the ray point    
	// to the screen coordinates of the mouse.
	PT(Camera) pCamera = Camera()->Object();
	GetCollisionRay()->set_from_lens(pCamera, mpos.get_x(), mpos.get_y());
	GetCollisionTraverser()->traverse(TheWorldNode());
	PT(CollisionHandlerQueue) collisionHQ = GetCollisionHQ();

	if(collisionHQ->get_num_entries() > 0)
	{
		collisionHQ->sort_entries();

		NodePath pickedObj = collisionHQ->get_entry(0)->get_into_node_path();
		pickedObj = pickedObj.find_net_tag("Selectable");

		if(!pickedObj.is_empty() && !pickedObj.is_hidden())
		{
			SetSelectedNode(pickedObj.node());
		}
	}

        WindowFramework* pWindow = GameWindow();
	NodePath render2D = pWindow->get_render_2d();
	
	DisplayRegion* pDisplay2D = pWindow->get_display_region_2d();
	NodePath cam2D = pDisplay2D->get_camera();

	PT(Camera) pCamera2D = DCAST(Camera, cam2D.node());
	Lens* pLens2D = pCamera2D->get_lens(); 

	GetCollisionRay2D()->set_from_lens(pCamera2D, mpos.get_x(), mpos.get_y());

	GetCollisionTraverser2D()->traverse(render2D);
	PT(CollisionHandlerQueue) collisionHQ2D = GetCollisionHQ2D();

	if(collisionHQ2D->get_num_entries() > 0)
	{
		collisionHQ2D->sort_entries();

		NodePath pickedObj = collisionHQ2D->get_entry(0)->get_into_node_path();
		pickedObj = pickedObj.find_net_tag("Selectable");

		if(!pickedObj.is_empty() && !pickedObj.is_hidden())
		{
			SetSelectedNode2D(pickedObj.node());
		}
	}

(I have simplified the code a bit to try and make it easier to read).
This code gets executed everytime a mouse click happens - the aim for this code is to find what “selectable” 3D items have been clicked and what “selectable” 2D GUI items have been clicked (my GUI items are actually 3d models).

I guess I need to perform some magic here as well to get more performance out of it ?

any suggestions ?

Well, now you’re asking the collision system to visit each of 1.477 million triangles and determine whether each one is the one within the mouse pointer. Obviously that’s going to be an expensive operation no matter how you slice it.

So, you have two choices:

(1) reconstruct your scene with a better bounding volume structure so that the collision system doesn’t have to visit all 1.477 million triangles, but can easily reject several of them based on their early bounding volumes. That is, put the terrain within an octree structure.

Of course, the octree structure which is optimal for collisions is very suboptimal for rendering, so it means you will want to have two copies of your terrain, one for collision tests and one for rendering. You probably want this anyway, because the copy for collision tests can be made with CollisionNodes instead of GeomNodes, and it can have far fewer vertices.

Or, you can:
(2) don’t use collisions at all, but simply use a custom intersection algorithm to determine where the user is clicking on the terrain. If nothing else, you could use a simple planar equation to calculate where on the X-Y plane the user clicked, and then extrapolate to the point on the terrain above that. This will work best if the terrain is not terribly hilly. If your terrain is very steep, you might need to do a different algorithm.

David

I am aware that traversing a list of 1.x milion polys isnt a trivial task , I was hopeing there was some panda stuff that would allow me to subdivide geom nodes into a quadtree or that there was some physics stuff to help with it.

but thanks anyway that answered my questions :slight_smile: