Octree question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Octree question

Post by ikslm »

Hey all.

I have a scene (level) where i create ~~7000 unique ISceneNodes each with its own custom geometry (auto generated, not loaded from a file). At any moment i can remove/modify any of them.

So every frame, the engine has to check every node if it is in the frustum? That makes a lot of checking...?

Is there a way to throw all this nodes into octree? (nodes are "static" they don't change position and the bbox is constant). I've been looking at the addOctTreeSceneNode and it only receives the Mesh param, not the ISceneNodes...
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Post by aanderse »

No such class exists in irrlicht. Ogre has that type of octree, but no dice for irrlicht.

You could make one though :-) You wouldn't even have to do it from scratch. I saw someone had made a Quadtree Scene Node for irrlicht. If you didn't need fully 3 dimensional you could use the Quadtree scene node, but if you needed to cull based on all 3 dimensions you would have to modify it to make it an octree.

http://br.geocities.com/paulo_cmv/
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Post by ikslm »

Yes, in my case the quadtree would be better. I guess i'll have to make it myself. But i guess something like that would be a nice addition to the engine.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

It would be much better if all your objects were in one scene node and you rendered them all at once rather than individually. If you're removing them at any time then that might not make that easy or even possible though...
Image Image Image
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Post by ikslm »

.... and usually only 10% are visible per frame. so, quadtree ;)

or i could make a BIG (1 or more, since we have the 65xxx buffer size limit) vertex and index list, and then erase/add/modify vertices/indices when needed.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

ikslm wrote:Yes, in my case the quadtree would be better. I guess i'll have to make it myself. But i guess something like that would be a nice addition to the engine.
It's do-able, but non-trivial. We'd have to deal with shifting objects around the oct-tree as they move / rotate / scale, as well as taking into account the descendants of the oct tree's scene node children (including when nodes get reparented), so it's not a lunchtime job. ;)

That said, patches are always very welcome, particularly if they come with test apps. I'm still working through the bug backlog, but do intend to get around to the feature requests after 1.5 is cut.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Post by ikslm »

Well for my scenario the things are simpler:

1. i would use quadtree
2. i'd use quadtree only for static objects (by static i mean that they have constant position and bbox), so this quadtree would receive a vector of nodes it should contain and some quadtree params
3. for other objects (animated, movable... in my case there are ~~ 100 of them) i'd use normal frustum culling
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Post by ikslm »

Anyway, i'm woking on the quadtree for my purpose. I'll report the speed increase when i finish.
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Post by ikslm »

simple question.

how can i do a "bounding box in current view frustum" test?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Swipe the culling code from source/Irrlicht/CSceneManager::isCulled().
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
ikslm
Posts: 7
Joined: Mon Nov 10, 2008 11:51 am

Post by ikslm »

Ok, done. I'm happy with the result. I got a 4x-6x boost of FPS. Gone from 60FPS to 400FPS. Thanks for the help.
blizuke
Posts: 8
Joined: Sun Jul 18, 2010 9:51 am

Anyone have code like this to share?

Post by blizuke »

Has anyone implemented anything like this, that they have already shared or are willing to share, please?

It would be very helpful.
Post Reply