OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Problems flattening static transforms


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Paul Martz
Guest





PostPosted: Fri Oct 24, 2008 7:24 pm    Post subject:
Problems flattening static transforms
Reply with quote

Hi all -- I have a scene graph containing multiple static transforms. My application runs the osgUtil::Optimizer on this scene graph. This should flatten all the static transforms. Unfortunately, the result is that all the transforms flatten _except_ for the top level transform. If I do an osgconv on this same scene graph, all the static transforms flatten -- they are converted to Group nodes, and their transformations are folded into the geometry. Clearly, the issue isn't with the scene graph itself, but it's something my app is doing wrong when it invokes the Optimizer. My dilemma: why doesn't this work properly for osgconv, but not for my app?

I have dug into this for quite some time now, trying to uncover the difference between osgconv (which works) and my code (which doesn't work). Here's what I know so far:

* I've written a small test app to try to reproduce the problem. It loads the scene graph, runs the Optimizer, and writes the scene graph back out. Unfortunately, it works properly, just like osgconv. It flattens all the transforms. I'm unable to reproduce the problem in anything other than my (larger) application. This must be a bug in my code, I must be doing something wrong.

* I have verified that the problem is not non-STATIC transforms, multiple parents, or ProxyNodes. The same scene graph works fine in osgconv and my little test app, so it isn't a scene graph issue. I believe my app handles the scene graph the same as in these other two apps, which work.

* Yes I'm invoking the Optimizer the same way, with no flags. I'm sure that the OSG_OPTIMIZER variable is not set in the environment. I get the same behavior if I just pass the FLATTEN_STATIC_TRANSFORMS flag (top level node fails to flatten). If I set OSG_OPTIMIZER=FLATTEN_STATIC_TRANSFORMS and run osgconv, it still works properly and flattens all transforms.

* ObjectStruct has a Boolean called _moreThanOneMatrixRequired. In my app, this gets set to true at Optimizer.cpp line 826. This doesn't happen when running osgconv or my small test code. This seems to be part of the problem, but the root cause that triggers this event is still unknown to me.

I'll attach the scene graph in question, though I doubt it will do anyone much good, because it works fine in osgconv and my simple test app. It only fails in my larger app. Note the top level Node named "CenterOfMassOffset"; this is the transform that refuses to flatten.

I'm wondering if anyone has encountered the same issue before, has any info on how to resolve the issue, or might know how to proceed with debugging it. Notify level DEBUG_INFO does not produce any enlightening information.

I admit I'm stumped on this one. It's extremely out of the ordinary when OSG doesn't just do what I expect it to. I appreciate any info.

Thanks,

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

------------------
Post generated by Mail2Forum
Back to top
Robert Osfield
Guest





PostPosted: Fri Oct 24, 2008 7:35 pm    Post subject:
Problems flattening static transforms
Reply with quote

Hi Paul,

I'm just online briefly so I'll give you my first thought as what is
amiss. Optimizer::optimize() method takes a reference to the scene
graph to optimize, this means that it can't change it's type, so it
can't flatten it. If you place a Group above it and then optimize
it'll be able to optimize the node away.

One could possibly write an additional method that takes a pointer to
a scene graph node and then return the new scene graph with
potentially a new root node. For compatibility we'd need to keep the
present one.

Robert.

On Fri, Oct 24, 2008 at 8:24 PM, Paul Martz <> wrote:
Quote:
Hi all -- I have a scene graph containing multiple static transforms. My
application runs the osgUtil::Optimizer on this scene graph. This should
flatten all the static transforms. Unfortunately, the result is that all the
transforms flatten _except_ for the top level transform. If I do an osgconv
on this same scene graph, all the static transforms flatten -- they are
converted to Group nodes, and their transformations are folded into the
geometry. Clearly, the issue isn't with the scene graph itself, but it's
something my app is doing wrong when it invokes the Optimizer. My dilemma:
why doesn't this work properly for osgconv, but not for my app?

I have dug into thisu for quite some time now, trying to uncover the
difference between osgconv (which works) and my code (which doesn't work).
Here's what I know so far:

* I've written a small test app to try to reproduce the problem. It loads
the scene graph, runs the Optimizer, and writes the scene graph back out.
Unfortunately, it works properly, just like osgconv. It flattens all the
transforms. I'm unable to reproduce the problem in anything other than my
(larger) application. This must be a bug in my code, I must be doing
something wrong.

* I have verified that the problem is not non-STATIC transforms, multiple
parents, or ProxyNodes. The same scene graph works fine in osgconv and my
little test app, so it isn't a scene graph issue. I believe my app handles
the scene graph the same as in these other two apps, which work.

* Yes I'm invoking the Optimizer the same way, with no flags. I'm sure that
the OSG_OPTIMIZER variable is not set in the environment. I get the same
behavior if I just pass the FLATTEN_STATIC_TRANSFORMS flag (top level node
fails to flatten). If I set OSG_OPTIMIZER=FLATTEN_STATIC_TRANSFORMS and run
osgconv, it still works properly and flattens all transforms.

* ObjectStruct has a Boolean called _moreThanOneMatrixRequired. In my app,
this gets set to true at Optimizer.cpp line 826. This doesn't happen when
running osgconv or my small test code. This seems to be part of the problem,
but the root cause that triggers this event is still unknown to me.

I'll attach the scene graph in question, though I doubt it will do anyone
much good, because it works fine in osgconv and my simple test app. It only
fails in my larger app. Note the top level Node named "CenterOfMassOffset";
this is the transform that refuses to flatten.

I'm wondering if anyone has encountered the same issue before, has any info
on how to resolve the issue, or might know how to proceed with debugging it.
Notify level DEBUG_INFO does not produce any enlightening information.

I admit I'm stumped on this one. It's extremely out of the ordinary when OSG
doesn't just do what I expect it to. I appreciate any info.

Thanks,

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466






------------------
Post generated by Mail2Forum
Back to top
Paul Martz
Guest





PostPosted: Fri Oct 24, 2008 7:53 pm    Post subject:
Problems flattening static transforms
Reply with quote

Thanks for the quick reply, Robert.

It's really the flattening that I require, and not necessarily the type
change.

For example, I see that osgconv doesn't change the type of the top level
Transform node, but it does flatten it so that its transform is the
identity. In my app, however, this top level transform is simply not
flattened; the matrix is still non-identity.

To be pedantic, I added a top level Group above my (previous) top level
Transform. In my app, this Transform remains unflattened.

My app maintains other ref_ptrs into this scene graph, could this be the
problem? To check, I set a breakpoint in Referenced::referenceCount() just
before calling optimize(). Aside from the explicit calls in
FSTV::apply(Geode&) for the vertex and normal arrays, FSTV does not appear
to query the referenceCount of any Node. So I suspect this is not the issue.

So I'm really quite stumped. I know it's difficult to debug remotely, but
this app is rather large and impractical to share. Guidance on debugging
would be appreciated.
-Paul


Quote:
-----Original Message-----
From:
[mailto:] On Behalf
Of Robert Osfield
Sent: Friday, October 24, 2008 1:35 PM
To: OpenSceneGraph Users
Subject: Re: Problems flattening static transforms

Hi Paul,

I'm just online briefly so I'll give you my first thought as
what is amiss. Optimizer::optimize() method takes a
reference to the scene graph to optimize, this means that it
can't change it's type, so it can't flatten it. If you place
a Group above it and then optimize it'll be able to optimize
the node away.

One could possibly write an additional method that takes a
pointer to a scene graph node and then return the new scene
graph with potentially a new root node. For compatibility
we'd need to keep the present one.

Robert.

On Fri, Oct 24, 2008 at 8:24 PM, Paul Martz
<> wrote:
Quote:
Hi all -- I have a scene graph containing multiple static
transforms.
Quote:
My application runs the osgUtil::Optimizer on this scene
graph. This
Quote:
should flatten all the static transforms. Unfortunately,
the result is
Quote:
that all the transforms flatten _except_ for the top level
transform.
Quote:
If I do an osgconv on this same scene graph, all the static
transforms
Quote:
flatten -- they are converted to Group nodes, and their
transformations are folded into the geometry. Clearly, the
issue isn't
Quote:
with the scene graph itself, but it's something my app is
doing wrong when it invokes the Optimizer. My dilemma:
Quote:
why doesn't this work properly for osgconv, but not for my app?

I have dug into thisu for quite some time now, trying to
uncover the
Quote:
difference between osgconv (which works) and my code (which
doesn't work).
Quote:
Here's what I know so far:

* I've written a small test app to try to reproduce the problem. It
loads the scene graph, runs the Optimizer, and writes the
scene graph back out.
Quote:
Unfortunately, it works properly, just like osgconv. It
flattens all
Quote:
the transforms. I'm unable to reproduce the problem in
anything other
Quote:
than my
(larger) application. This must be a bug in my code, I must
be doing
Quote:
something wrong.

* I have verified that the problem is not non-STATIC transforms,
multiple parents, or ProxyNodes. The same scene graph works fine in
osgconv and my little test app, so it isn't a scene graph issue. I
believe my app handles the scene graph the same as in these
other two apps, which work.
Quote:

* Yes I'm invoking the Optimizer the same way, with no
flags. I'm sure
Quote:
that the OSG_OPTIMIZER variable is not set in the
environment. I get
Quote:
the same behavior if I just pass the FLATTEN_STATIC_TRANSFORMS flag
(top level node fails to flatten). If I set
OSG_OPTIMIZER=FLATTEN_STATIC_TRANSFORMS and run osgconv, it
still works properly and flattens all transforms.
Quote:

* ObjectStruct has a Boolean called
_moreThanOneMatrixRequired. In my
Quote:
app, this gets set to true at Optimizer.cpp line 826. This doesn't
happen when running osgconv or my small test code. This seems to be
part of the problem, but the root cause that triggers this
event is still unknown to me.
Quote:

I'll attach the scene graph in question, though I doubt it will do
anyone much good, because it works fine in osgconv and my
simple test
Quote:
app. It only fails in my larger app. Note the top level Node named
"CenterOfMassOffset"; this is the transform that refuses to flatten.

I'm wondering if anyone has encountered the same issue
before, has any
Quote:
info on how to resolve the issue, or might know how to
proceed with debugging it.
Quote:
Notify level DEBUG_INFO does not produce any enlightening
information.
Quote:

I admit I'm stumped on this one. It's extremely out of the ordinary
when OSG doesn't just do what I expect it to. I appreciate any info.

Thanks,

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

_______________________________________________
osg-users mailing list


http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
Quote:
org



negraph.org



------------------
Post generated by Mail2Forum
Back to top
Paul Martz
Guest





PostPosted: Fri Oct 24, 2008 8:32 pm    Post subject:
Problems flattening static transforms
Reply with quote

Interesting... Multiple references _does_ seem to be the cause!

I modified my simple test app to make a second ref_ptr to the loaded scene
graph. So the pseudocode is:

Load scene graph into first ref_ptr.
Create a second ref_ptr and make it reference the first ref_ptr's child 0.
Run the Optimizer
Write the scene graph

(Code attached. Run it with my previous "opt1.osg" file to reproduce the
problem.)

With the second ref_ptr pointing to the child of the top level Transform,
the top level Transform does not flatten.

Is this a bug? Why does the Optimizer (apparently) not flatten a transform
if it has a child with reference count greater than 1?
-Paul


Quote:
Thanks for the quick reply, Robert.

It's really the flattening that I require, and not
necessarily the type change.

For example, I see that osgconv doesn't change the type of
the top level Transform node, but it does flatten it so that
its transform is the identity. In my app, however, this top
level transform is simply not flattened; the matrix is still
non-identity.

To be pedantic, I added a top level Group above my (previous)
top level Transform. In my app, this Transform remains unflattened.

My app maintains other ref_ptrs into this scene graph, could
this be the problem? To check, I set a breakpoint in
Referenced::referenceCount() just before calling optimize().
Aside from the explicit calls in
FSTV::apply(Geode&) for the vertex and normal arrays, FSTV
does not appear to query the referenceCount of any Node. So I
suspect this is not the issue.

So I'm really quite stumped. I know it's difficult to debug
remotely, but this app is rather large and impractical to
share. Guidance on debugging would be appreciated.
-Paul


Quote:
-----Original Message-----
From:
[mailto:] On Behalf Of
Robert Osfield
Sent: Friday, October 24, 2008 1:35 PM
To: OpenSceneGraph Users
Subject: Re: Problems flattening static transforms

Hi Paul,

I'm just online briefly so I'll give you my first thought
as what is
Quote:
amiss. Optimizer::optimize() method takes a reference to the scene
graph to optimize, this means that it can't change it's type, so it
can't flatten it. If you place a Group above it and then optimize
it'll be able to optimize the node away.

One could possibly write an additional method that takes a
pointer to
Quote:
a scene graph node and then return the new scene graph with
potentially a new root node. For compatibility we'd need
to keep the
Quote:
present one.

Robert.

On Fri, Oct 24, 2008 at 8:24 PM, Paul Martz
<>
Quote:
wrote:
Quote:
Hi all -- I have a scene graph containing multiple static
transforms.
Quote:
My application runs the osgUtil::Optimizer on this scene
graph. This
Quote:
should flatten all the static transforms. Unfortunately,
the result is
Quote:
that all the transforms flatten _except_ for the top level
transform.
Quote:
If I do an osgconv on this same scene graph, all the static
transforms
Quote:
flatten -- they are converted to Group nodes, and their
transformations are folded into the geometry. Clearly, the
issue isn't
Quote:
with the scene graph itself, but it's something my app is
doing wrong when it invokes the Optimizer. My dilemma:
Quote:
why doesn't this work properly for osgconv, but not for my app?

I have dug into thisu for quite some time now, trying to
uncover the
Quote:
difference between osgconv (which works) and my code (which
doesn't work).
Quote:
Here's what I know so far:

* I've written a small test app to try to reproduce the
problem. It
Quote:
Quote:
loads the scene graph, runs the Optimizer, and writes the
scene graph back out.
Quote:
Unfortunately, it works properly, just like osgconv. It
flattens all
Quote:
the transforms. I'm unable to reproduce the problem in
anything other
Quote:
than my
(larger) application. This must be a bug in my code, I must
be doing
Quote:
something wrong.

* I have verified that the problem is not non-STATIC transforms,
multiple parents, or ProxyNodes. The same scene graph
works fine in
Quote:
Quote:
osgconv and my little test app, so it isn't a scene graph
issue. I
Quote:
Quote:
believe my app handles the scene graph the same as in these
other two apps, which work.
Quote:

* Yes I'm invoking the Optimizer the same way, with no
flags. I'm sure
Quote:
that the OSG_OPTIMIZER variable is not set in the
environment. I get
Quote:
the same behavior if I just pass the
FLATTEN_STATIC_TRANSFORMS flag
Quote:
Quote:
(top level node fails to flatten). If I set
OSG_OPTIMIZER=FLATTEN_STATIC_TRANSFORMS and run osgconv, it
still works properly and flattens all transforms.
Quote:

* ObjectStruct has a Boolean called
_moreThanOneMatrixRequired. In my
Quote:
app, this gets set to true at Optimizer.cpp line 826.
This doesn't
Quote:
Quote:
happen when running osgconv or my small test code. This
seems to be
Quote:
Quote:
part of the problem, but the root cause that triggers this
event is still unknown to me.
Quote:

I'll attach the scene graph in question, though I doubt
it will do
Quote:
Quote:
anyone much good, because it works fine in osgconv and my
simple test
Quote:
app. It only fails in my larger app. Note the top level
Node named
Quote:
Quote:
"CenterOfMassOffset"; this is the transform that refuses
to flatten.
Quote:
Quote:

I'm wondering if anyone has encountered the same issue
before, has any
Quote:
info on how to resolve the issue, or might know how to
proceed with debugging it.
Quote:
Notify level DEBUG_INFO does not produce any enlightening
information.
Quote:

I admit I'm stumped on this one. It's extremely out of
the ordinary
Quote:
Quote:
when OSG doesn't just do what I expect it to. I
appreciate any info.
Quote:
Quote:

Thanks,

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

_______________________________________________
osg-users mailing list



http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
Quote:
Quote:
org



negraph.org


negraph.org



------------------
Post generated by Mail2Forum
Back to top
Jolley, Thomas P
Guest





PostPosted: Fri Oct 24, 2008 9:09 pm    Post subject:
Problems flattening static transforms
Reply with quote

Hi Paul,

I'm not sure it's a bug. I think the Optimizer is playing it safe when
there are two scene graphs sharing a common graph. You have two scene
graphs sharing a graph even though one graph doesn't have a parent as in
your second ref_ptr. The result would be optimize one graph and the
other graph changes when it shouldn't.

If you don't think the above is correct and the decision to optimize
should be based on whether there is more than one parent, create a
custom Optimizer. I think what you will find is the second ref_ptr
which was pointing to a graph with lots of geometry may end up as an
empty group node. Something that might be unexpected if it was the top
node of something you're rendering. That may not be a problem in your
application.


Quote:
-----Original Message-----
From: Paul Martz [mailto:]
Sent: Friday, October 24, 2008 3:32 PM
To: 'OpenSceneGraph Users'
Subject: Re: Problems flattening static transforms

Interesting... Multiple references _does_ seem to be the cause!

I modified my simple test app to make a second ref_ptr to the
loaded scene graph. So the pseudocode is:

Load scene graph into first ref_ptr.
Create a second ref_ptr and make it reference the first
ref_ptr's child 0.
Run the Optimizer
Write the scene graph

(Code attached. Run it with my previous "opt1.osg" file to
reproduce the
problem.)

With the second ref_ptr pointing to the child of the top
level Transform, the top level Transform does not flatten.

Is this a bug? Why does the Optimizer (apparently) not
flatten a transform if it has a child with reference count
greater than 1?
-Paul



------------------
Post generated by Mail2Forum
Back to top
Paul Martz
Guest





PostPosted: Fri Oct 24, 2008 9:55 pm    Post subject:
Problems flattening static transforms
Reply with quote

Thanks, I see the light now.

I wrote my own FlattenStaticTransforms NodeVisitor to just fold the
transform into the geometry and set the transformation to identity; It works
great as long as all Transforms are MatrixTransforms.

(It'd be nice if there were a virtual osg::Transform::setIdentity() method
to easily allow code to set any Transform Node to the identity. For example,
see Optimizer.cpp starting at line 1080. It makes sense for PATs and
DOFTransforms, but maybe not for Camera...)
-Paul


Quote:
-----Original Message-----
From:
[mailto:] On Behalf
Of Jolley, Thomas P
Sent: Friday, October 24, 2008 3:09 PM
To: OpenSceneGraph Users
Subject: Re: Problems flattening static transforms

Hi Paul,

I'm not sure it's a bug. I think the Optimizer is playing it
safe when there are two scene graphs sharing a common graph.
You have two scene graphs sharing a graph even though one
graph doesn't have a parent as in your second ref_ptr. The
result would be optimize one graph and the other graph
changes when it shouldn't.

If you don't think the above is correct and the decision to
optimize should be based on whether there is more than one
parent, create a custom Optimizer. I think what you will
find is the second ref_ptr which was pointing to a graph with
lots of geometry may end up as an empty group node.
Something that might be unexpected if it was the top node of
something you're rendering. That may not be a problem in
your application.


Quote:
-----Original Message-----
From: Paul Martz [mailto:]
Sent: Friday, October 24, 2008 3:32 PM
To: 'OpenSceneGraph Users'
Subject: Re: Problems flattening static transforms

Interesting... Multiple references _does_ seem to be the cause!

I modified my simple test app to make a second ref_ptr to
the loaded
Quote:
scene graph. So the pseudocode is:

Load scene graph into first ref_ptr.
Create a second ref_ptr and make it reference the first ref_ptr's
child 0.
Run the Optimizer
Write the scene graph

(Code attached. Run it with my previous "opt1.osg" file to
reproduce
Quote:
the
problem.)

With the second ref_ptr pointing to the child of the top level
Transform, the top level Transform does not flatten.

Is this a bug? Why does the Optimizer (apparently) not flatten a
transform if it has a child with reference count greater than 1?
-Paul


negraph.org



------------------
Post generated by Mail2Forum
Back to top
Terry Welsh
Guest





PostPosted: Fri Oct 24, 2008 10:56 pm    Post subject:
Problems flattening static transforms
Reply with quote

Hi Paul,
I ran into this dillemna recently while working on an app and then
again while working on the code for
FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS. My solution
was the same as Robert's: place your graph under a temporary Group
node, then flatten it, then retrieve the child of the Group node
whatever it may be.

Just setting the root Transform node to identity didn't appeal to me.
The point of the optimization in all cases I have seen is to remove
transforms from the modelview stack since they can cause a big
performance hit in sufficient numbers. Even if the matrix is identity
you would still have the performance hit unless OSG is smart enough to
treat such a Transform like a Group.

I hope this is useful, but it sounds like your situation might be more
complicated than mine.
- Terry
Quote:

Message: 14
Date: Fri, 24 Oct 2008 15:53:47 -0600
From: "Paul Martz" <>
Subject: Re: Problems flattening static transforms
To: "'OpenSceneGraph Users'" <>
Message-ID: <2BC450067F9540B4A41004AC6C1086EE@Supreme>
Content-Type: text/plain; charset="US-ASCII"

Thanks, I see the light now.

I wrote my own FlattenStaticTransforms NodeVisitor to just fold the
transform into the geometry and set the transformation to identity; It works
great as long as all Transforms are MatrixTransforms.

(It'd be nice if there were a virtual osg::Transform::setIdentity() method
to easily allow code to set any Transform Node to the identity. For example,
see Optimizer.cpp starting at line 1080. It makes sense for PATs and
DOFTransforms, but maybe not for Camera...)
-Paul



------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Optimizer FLATTEN_STATIC_TRANSFORMS n... Sergey Lukashev General 3 Wed Apr 24, 2019 8:17 pm View latest post
No new posts Problems with dae plugin John Richardson Plugins [osgPlugins] 0 Thu Apr 11, 2019 5:00 pm View latest post
No new posts [PARTIALLY SOLVED] Problems with dae ... Nikkitta Plugins [osgPlugins] 4 Mon Apr 08, 2019 3:51 pm View latest post
No new posts Particular Build Problems with OSG. Zachary1234 Build system [build] 5 Wed Mar 27, 2019 7:12 am View latest post
No new posts OSG static v 3.6.3 CMake 3.12.4 + Vis... Serathin Build system [build] 0 Fri Feb 01, 2019 8:19 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP