Re: [osg-users] trouble with flattening static transforms

2008-02-14 Thread Robert Osfield
Hi Terry,

A glatten static transforms that have duplicates shared subgraphs
would be a useful addition to osgUtil::Optimizer so if you are willing
to tidy up and submit it'd be appreciated.

Cheers,
Robert.

On Thu, Jan 31, 2008 at 9:56 PM, Terry Welsh [EMAIL PROTECTED] wrote:
 I went ahead and wrote a visitor that really does remove all static
  transforms.  If nodes underneath transforms have multiple parents, it
  makes copies so that each child subgraph can be properly transformed.
  On my big test case, I remove 911 out of 911 transforms, my model
  takes up 10x the memory, and it runs 25-30% faster.  It's a good
  tradeoff for the app I'm working on.

  There's probably plenty of refinement necessary for corner cases since
  I have only tested with 2 models, but if this sounds worthwhile to
  anyone else I can fix up a few things and submit it.
  - Terry
  
   Message: 16
   Date: Tue, 29 Jan 2008 19:28:24 +
   From: Robert Osfield [EMAIL PROTECTED]
   Subject: Re: [osg-users] trouble with flattening static transforms
   To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
   Message-ID:
   [EMAIL PROTECTED]
   Content-Type: text/plain; charset=ISO-8859-1
  
   Hi Terry,
  
   You can't flatten a static transform when anything it its subgraph is
   shared with other transforms, if you do flatten it the the object is
   the trying to be in two places at one time, something it can't do,
   what happens to these objects is undefined, in fact quite rightly
   disallowed until you hacked away at it...
  
   The only way to flatten these objects shared beneath multiple
   transforms is to duplicate the subgraph so that each transform has its
   own unique subgraph.  This itself has its own penalties in terms of
   performance.
  
   Robert.
  
   On Jan 29, 2008 7:14 PM, Terry Welsh [EMAIL PROTECTED] wrote:
So I have a big city database that I built in Creator with lots of
external models loaded under transform nodes.  I assumed that
Optimizer could flatten this out for me with
FLATTEN_STATIC_TRANSFORMS.  Unfortunately, I only end up flattening 35
out of 911 transforms.
   
Tracing through the code, I find that line 804 of Optimizer.cpp is
where things go bad for me:
   
if (_firstMatrix!=matrix) _moreThanOneMatrixRequired=true;
   
This line rejects most of my flattening because later on
_moreThanOneMatrixRequired seems to be used to decide whether or not
to flatten.  If I comment this line out, then all but the first
instance of each model disappears from my scene.
   
Understanding all the logic in Optimizer.cpp could take me a long
time.  Is there some fundamental reason why having more than one
matrix makes it impossible to flatten a model, or is this just
incomplete code that I could extend to give me a more thorough
flattening?  Any tips on how to try and extend it would be great
too
--
Terry Welsh - mogumbo 'at' gmail.com
www.reallyslick.com  |  www.mogumbo.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
   
  
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] trouble with flattening static transforms

2008-01-29 Thread Robert Osfield
Hi Terry,

You can't flatten a static transform when anything it its subgraph is
shared with other transforms, if you do flatten it the the object is
the trying to be in two places at one time, something it can't do,
what happens to these objects is undefined, in fact quite rightly
disallowed until you hacked away at it...

The only way to flatten these objects shared beneath multiple
transforms is to duplicate the subgraph so that each transform has its
own unique subgraph.  This itself has its own penalties in terms of
performance.

Robert.

On Jan 29, 2008 7:14 PM, Terry Welsh [EMAIL PROTECTED] wrote:
 So I have a big city database that I built in Creator with lots of
 external models loaded under transform nodes.  I assumed that
 Optimizer could flatten this out for me with
 FLATTEN_STATIC_TRANSFORMS.  Unfortunately, I only end up flattening 35
 out of 911 transforms.

 Tracing through the code, I find that line 804 of Optimizer.cpp is
 where things go bad for me:

 if (_firstMatrix!=matrix) _moreThanOneMatrixRequired=true;

 This line rejects most of my flattening because later on
 _moreThanOneMatrixRequired seems to be used to decide whether or not
 to flatten.  If I comment this line out, then all but the first
 instance of each model disappears from my scene.

 Understanding all the logic in Optimizer.cpp could take me a long
 time.  Is there some fundamental reason why having more than one
 matrix makes it impossible to flatten a model, or is this just
 incomplete code that I could extend to give me a more thorough
 flattening?  Any tips on how to try and extend it would be great
 too
 --
 Terry Welsh - mogumbo 'at' gmail.com
 www.reallyslick.com  |  www.mogumbo.com
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] trouble with flattening static transforms

2008-01-29 Thread Bradford, Chase

If you have a transform tree, with the following:
A: translate (0, 10, 0)
|
---B: translate( 0, 5, 0 )
|  |
|  --- Model 1
|
---C: translate( 0, 20, 0 )
   |
   --- Model 2

Then A cannot be flatten with B and C, because B != C.  If A, B, and C
were flattened into a single transform, then Model 1 or Model 2 would
end up in the wrong place.

If you really want them flattened, then you could translate all vertices
in Model 2's geometry by 15 along the Y to account for the difference in
C.  However, doing this in general could introduce numeric error if your
models span a wide area.

It's sort of a balancing act, where you try to group nearby models,
modify their geometries to share a common origin, and apply a single
transform to all of them.  However, because that action requires
knowledge of the lower scene graph, an optimizer can't do it for you.
Also, this wouldn't work with paged children without saving out the
modified geometry, and you'd have to apply different techniques to make
it work on non-geometry drawables.

Hope that helps,
Chase



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:osg-users-
 [EMAIL PROTECTED] On Behalf Of Terry Welsh
 Sent: Tuesday, January 29, 2008 11:14 AM
 To: osg-users@lists.openscenegraph.org
 Subject: [osg-users] trouble with flattening static transforms
 
 So I have a big city database that I built in Creator with lots of
 external models loaded under transform nodes.  I assumed that
 Optimizer could flatten this out for me with
 FLATTEN_STATIC_TRANSFORMS.  Unfortunately, I only end up flattening 35
 out of 911 transforms.
 
 Tracing through the code, I find that line 804 of Optimizer.cpp is
 where things go bad for me:
 
 if (_firstMatrix!=matrix) _moreThanOneMatrixRequired=true;
 
 This line rejects most of my flattening because later on
 _moreThanOneMatrixRequired seems to be used to decide whether or not
 to flatten.  If I comment this line out, then all but the first
 instance of each model disappears from my scene.
 
 Understanding all the logic in Optimizer.cpp could take me a long
 time.  Is there some fundamental reason why having more than one
 matrix makes it impossible to flatten a model, or is this just
 incomplete code that I could extend to give me a more thorough
 flattening?  Any tips on how to try and extend it would be great
 too
 --
 Terry Welsh - mogumbo 'at' gmail.com
 www.reallyslick.com  |  www.mogumbo.com
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org