Re: [Plib-users] <<code review>> Bounding sphere of a branch node
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-02-29 06:31:18
|
Rahul Choudhury wrote: > The current ssg code marks a branch node's bouding > sphere empty as and when an entity is added to the > branch or removed from it. But the bounding sphere of > the branch node really does not get updated. The > places where it does get updated are in flatten() of > ssgOptimiser or the constructor of ssgLeaf (which in > turn calls the recalcBSphere of ssgBranch). > > But think about a scenario where a Branch group has a > leaf ssgRahulLeaf which is derived from ssgLeaf and > has a different constrcutor which does not invoke > recalcBSphere in it. Also imagine that the user of the > ssg API did not call flatten on the scene graph before > renedering it. Will the bounding spheres of the branch > nodes be updated in this case ? > > Is this better to update the bounding sphere of a > branch node right when an entity is added to or > removed from it ? I don't exactly mark the sphere 'empty' - I mark it 'dirty' (ie invalid) - and SSG will recompute it only when something asks for the value of the bsphere. The thing to bear in mind is that dirtying a bounding sphere also dirties the spheres above it in the scene graph. What SSG does is to only recompute a bsphere when it's actually needed. That gives you LARGE speedups when a lot of leaf nodes are dirtied between each update because the higher up nodes are not repeatedly recomputed. In general, bspheres will get recomputed a minimal number of times in the CullAndDraw routine - or the next isect request or whatever. Clever - eh! One of the keys to fast scene graph API's is 'lazy evaluation'. > Let me know your views. I think I dodged *that* bullet :-) -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |