Automatic scene partitioning in Panda3D ?

Hi, I’m new here. I’m thinking about using Panda3D and I have a question about it. I’ve been looking everywhere to find the answer, but could not find it. I even tried looking at Panda3D’s source code, but its just too big and I had no idea where to start. :confused:

My question is this: Does Panda3D do automatic scene partitioning to optimize frustum culling, collision detections and other tasks using scene discovery ? Just to be clear about what I mean by this, here is an example: Lets say I create lots of scene nodes at the root of the scene graph. Will Panda3D automatically organize these scene nodes in some structure (like an ocTree, a kdTree, a BSP, etc.) to optimize scene discovery (to find which scene nodes are inside the view frustum for example) ?

My question is not about the performance issues related to the number of scene nodes that need to be rendered in the view frustum. I already know about these issues.

Thank you very much for your help. :slight_smile:

hi, welcome to panda.

long answer short. no.

panda will not do that automatically. though you can do it manually if you want to. best thing (better than all automated processes) would be to set up your scene so culling it most efficient to start with.

there are some scripts here on the forum to create octrees.for visual stuff aswell as collisions.

Thank you for your answer. So, in other words, unless I sort my scene myself, view frustum culling and collision detection will be of O(N) and O(N^2) complexity (where N is the number of root scene nodes). How many root scene nodes can there be before Panda3D’s performance starts to choke because of this ?

depends what you understand with choke. at a fps would it mean all under 40 fps, at a simulation peoples are happy with 1 fps. but i tested it now, at my computer with 1800 texture planes, i got a framerate around 25 fps. but there is nothing which interact with this nodes, just displaying it. to reach more objects displayed you need to use instances.

with full interaction, means distance calculation and lot of other calculations (bouncing, fraction, gravity, mouse interaction (all self written, so no physic engine or collision detection in use)). i reach 12 fps. ok thats not easy to reach that, im using therefor a very smart method. which is nearly not possible to optimize more, i think (on a single cpu).

panda’s really fast at frustum checks. they are so fast they almost dont matter. (at least not for visible geometry with sane ammount of nodes).

far more important is the number of nodes which remain (you already mentioned you know about this one). during tests i had no problem with thousands of individual objects outside the frustum. if you are interested in how much time it exactly takes to do culling launch pstats. it can draw nice graphs of your simulation with detailed performance analysis. including culling.

@krid. in you’r case i’m almost perfectly sure you hit the “too many visible nodes choking your gpu” not the “culling takes too long” problem.

:smiley: oh of course just visible nodes. so take it that way, with 1000 visible nodes you are in a save state. but at invisble nodes :smiley: you can have so many you want, then its just related how you reload them. so then is my answer a endless count. :wink:

Thanks a lot for the information. :slight_smile: I’ll use pstats to determine if this is a problem should performance start to choke. If that’s the case, I guess I could take a look at those scripts to build octrees you mentioned earlier.

no! thomas is quite wrong. you can have so many nodes as you want. not just tousands. :wink: but you at visible nodes you are save with around 1000. sorry thomas. but really i dont see a point where it should stop. ok there is a point. as long panda is running on computers you can display new nodes.

Please, don’t start an argument because of me. :wink:

Just to clarify something, in case I was misunderstood. When I asked if Panda3D would automatically partition my scene in a structure (a tree or something else), I did not mean that the nodes of this structure would be visible to my Python script in the scene graph and that my scene nodes would be re-parented to them. I meant that this structure would only be used internally by Panda3D to optimize node discovery and would not be visible in the scene graph from my scripts (the scene graph, as seen by the Python script, would still be “flat”). I hope I’m being understandable here. This is a bit hard to explain.

we wont! :wink:

the first thing you need to know, never use a node if you dont need one. and you only need a node when its getting visible. you can store your data on a different and more faster way. and assign this data to a node only when its get visible. why you wanna have this bunch of possibilities of a node all the time at the back if you dont need it? like you already know a node costs performance. for all the datas you need, use vector arrays and multidimsional array. then assign this data on a clever way that you dont feel it while assigning. with geometry is it a bit more tricky. at interactions and moving out side the visible area, make extrapolation for. try to be for that such framerate indipend. and loop over this something like this:

while(game) {
x++;
if (x > n){
x=0}
//here you interaction loop
for (y=x;y<objectCOUNT;y++) {
id += n-1;
objectARRAY[id](extrapolation);
}
}

this decrease your framerate alot :wink:

and try to raster as much you can.

I’m sorry, I don’t understand what you mean by “for all the datas you need, use vector arrays and multidimsional array. then assign this data on a clever way that you dont feel it while assigning.”. Please remember that you are talking to a Panda3D newbie here. :confused: You need to put me in context a bit more please.

Doum, i would be very very very surprised that your bottle neck is going to be in partitioning for frustum culling. You can use Pstats to find all performance problems is a fantastic tool.

Quick overview on cases of low fps, first look at: pixel shaders, overdraw, 300+ batch count, vertex count…

Ok now collision detections might require some work, I have written a script (search the forums) that can generate collision octrees that are really fast from geometry. I think you are covered on that front.

AI - panda3d uses nav mesh, i am not sure how its optimized, yet i had not seen any performance complains yet.