Re: [osg-users] GL Error vulnerability in OSG 3.4.0 (invalid enum)

2016-07-19 Thread Rick Irons
Hi Robert,

Sorry for the delay in responding.  Thanks for the info below.

I will investigate if the GL_MAX_3D_TEXTURE_SIZE and 
GL_MAX_ARRAY_TEXTURE_LAYERS_EXT enumerations have GLES counterparts that need 
to be considered.

In regards to the fallback, wouldn’t the existing initialization of the two 
values to zero be sufficient?

We encountered this issue of unexpected GL errors in some tests that exercise 
Microsoft’s OpenGL 1.1 software implementation.  We use this version of OpenGL 
as a fallback when issues with hardware graphics OpenGL are encountered.

Thanks,
Rick

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Thursday, June 30, 2016 11:39 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] GL Error vulnerability in OSG 3.4.0 (invalid enum)

Hi Rick,
If we need to protect the testing of certain features for certain drivers then 
glVersion number probably isn't sufficient as we have GL and GLES versions to 
consider.
Another thing we'd need to do is provide a fallback in case we don't set the 
associated values.
BTW, what platform and GL versions are you seeing issus with?

Robert.

On 30 June 2016 at 16:34, Rick Irons 
<rick.ir...@mathworks.com<mailto:rick.ir...@mathworks.com>> wrote:
Hi,

openscenegraph/src/osg/GLExtensions.cpp should probably be checking the OpenGL 
version prior to using the GL_MAX_3D_TEXTURE_SIZE and 
GL_MAX_ARRAY_TEXTURE_LAYERS_EXT enums (see change below).  Otherwise, such 
calls will generate GL errors when using older versions of OpenGL.  Any 
concerns with such a change?

Thanks,
Rick
[cid:image001.png@01D1E1B0.3CFA8600]

___
osg-users mailing list
osg-users@lists.openscenegraph.org<mailto: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] GL Error vulnerability in OSG 3.4.0 (invalid enum)

2016-06-30 Thread Rick Irons
Hi,

openscenegraph/src/osg/GLExtensions.cpp should probably be checking the OpenGL 
version prior to using the GL_MAX_3D_TEXTURE_SIZE and 
GL_MAX_ARRAY_TEXTURE_LAYERS_EXT enums (see change below).  Otherwise, such 
calls will generate GL errors when using older versions of OpenGL.  Any 
concerns with such a change?

Thanks,
Rick
[cid:image001.png@01D1D2C2.771617C0]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OpenThreads build error (OSG 3.4.0)

2016-06-21 Thread Rick Irons
Hi Robert,

Thanks for the response.  I will wait to hear what others have to say.

Thanks,
Rick

-Original Message-
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Tuesday, June 21, 2016 10:49 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] OpenThreads build error (OSG 3.4.0)

Hi Rick,

On 21 June 2016 at 15:33, Rick Irons <rick.ir...@mathworks.com> wrote:
> Any thoughts on this issue?
>
> We are trying out option #2 below (Define WIN32_IE to 0x0600 in the 
> Open Thread cmake list file) since it is the more conservative of the 
> approaches.
> No issues so far.

I don't have Windows expertise to comment on specifics like this so have to 
defer to members of the community that have Windows knowledge like yourself.

One thing that is a bit curious though is why you are seeing build problems 
with 3.4.0 when others using Windows didn't report problems during the 3.4.0 
release testing cycle.  I have a Windows 7 dual boot on this system that I 
occasionally boot into and haven't seen problems, I think I have VS2013 
installed as well.

Robert.
___
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] OpenThreads build error (OSG 3.4.0)

2016-06-21 Thread Rick Irons
Hi all,

Any thoughts on this issue?

We are trying out option #2 below (Define WIN32_IE to 0x0600 in the Open Thread 
cmake list 
file<https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/OpenThreads/win32/CMakeLists.txt>)
 since it is the more conservative of the approaches.  No issues so far.

Thanks,
Rick

From: Rick Irons
Sent: Friday, June 17, 2016 1:08 PM
To: 'osg-users@lists.openscenegraph.org' <osg-users@lists.openscenegraph.org>
Subject: OpenThreads build error (OSG 3.4.0)

Hi,

Our internal development environment was just recently updated and we are now 
encountering an OpenThreads build error on Windows with OSG 3.4.0.  The build 
error is included in the following Visual Studios 2013 build output...

1>-- Rebuild All started: Project: OpenThreads, Configuration: Debug x64 
--
2>-- Skipped Rebuild All: Project: uninstall, Configuration: Debug x64 
--
2>Project not selected to build for this solution configuration
1>  WIN32Condition.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Win32Mutex.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Win32Thread.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Win32ThreadBarrier.cpp
1>  Version.cpp
1>  Atomic.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Generating Code...
3>-- Rebuild All started: Project: osg, Configuration: Debug x64 --
3>  AlphaFunc.cpp
3>  AnimationPath.cpp
3>  ApplicationUsage.cpp
3>  ArgumentParser.cpp

The source of the issue appears to be the following line in sdkddkver.h

#if ((_WIN32_WINNT < _WIN32_WINNT_WIN2K) && (_WIN32_IE > _WIN32_IE_IE60SP1))

...where WIN32_WINNT is 0x0400 (per Open Thread 
definition<https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/OpenThreads/win32/CMakeLists.txt>),
 WIN32_WINNT_WIN2K is 
0x0500<https://msdn.microsoft.com/en-us/library/6sehtctf.aspx>, WIN32_IE is 
0x0700 (new default in our dev environment), and WIN32_IE_IE60SP1 is 
0x0601<https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx>.
  What appears to now be tripping the error is that the default value of 
WIN32_IE has changed in our dev environment from 0x0600 to 0x0700.

I am interested in feedback regarding how to properly address this issue.  
Possible options include...


1.)Changing WIN32_WINNT to 0x0500 in the Open Thread cmake list 
file<https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/OpenThreads/win32/CMakeLists.txt>.



2.)Define WIN32_IE to 0x0600 in the Open Thread cmake list 
file<https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/OpenThreads/win32/CMakeLists.txt>.

Thank you.

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


[osg-users] OpenThreads build error (OSG 3.4.0)

2016-06-17 Thread Rick Irons
Hi,

Our internal development environment was just recently updated and we are now 
encountering an OpenThreads build error on Windows with OSG 3.4.0.  The build 
error is included in the following Visual Studios 2013 build output...

1>-- Rebuild All started: Project: OpenThreads, Configuration: Debug x64 
--
2>-- Skipped Rebuild All: Project: uninstall, Configuration: Debug x64 
--
2>Project not selected to build for this solution configuration
1>  WIN32Condition.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Win32Mutex.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Win32Thread.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Win32ThreadBarrier.cpp
1>  Version.cpp
1>  Atomic.cpp
1>c:\program files (x86)\windows kits\8.1\include\shared\sdkddkver.h(272): 
fatal error C1189: #error :  _WIN32_WINNT settings conflicts with _WIN32_IE 
setting
1>  Generating Code...
3>-- Rebuild All started: Project: osg, Configuration: Debug x64 --
3>  AlphaFunc.cpp
3>  AnimationPath.cpp
3>  ApplicationUsage.cpp
3>  ArgumentParser.cpp

The source of the issue appears to be the following line in sdkddkver.h

#if ((_WIN32_WINNT < _WIN32_WINNT_WIN2K) && (_WIN32_IE > _WIN32_IE_IE60SP1))

...where WIN32_WINNT is 0x0400 (per Open Thread 
definition),
 WIN32_WINNT_WIN2K is 
0x0500, WIN32_IE is 
0x0700 (new default in our dev environment), and WIN32_IE_IE60SP1 is 
0x0601.
  What appears to now be tripping the error is that the default value of 
WIN32_IE has changed in our dev environment from 0x0600 to 0x0700.

I am interested in feedback regarding how to properly address this issue.  
Possible options include...


1.)Changing WIN32_WINNT to 0x0500 in the Open Thread cmake list 
file.



2.)Define WIN32_IE to 0x0600 in the Open Thread cmake list 
file.

Thank you.

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


Re: [osg-users] Drawable getBoundingBox() question

2016-06-14 Thread Rick Irons
Hi Robert,

Sounds good.  Thanks for the update. 

I believe I should just be able to switch to using _boundingShereComputed.

Rick

-Original Message-
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Tuesday, June 14, 2016 11:49 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] Drawable getBoundingBox() question

Hi Rick,

I've just begun a review of the code and I currently feel that 
_boundingBoxComputed is no longer required and should be removed to avoid 
confusion.  I will need to do another review now to double check that 
everything should work without it.

Robert.

On 13 June 2016 at 15:29, Rick Irons <rick.ir...@mathworks.com> wrote:
> Hi Robert,
>
>
>
> Thank you for the response.
>
>
>
> I am still a little puzzled...shouldn't the code you refer to below 
> set '_boundingBoxComputed' to true in addition to the current behavior 
> of setting ‘_boundingSphereComputed’ to true?  When I compare the OSG 
> 3.0.1 version of the method to the 3.4.0 version the setting of 
> ‘_boundingBoxComputed’ to true has been removed while the setting of 
> ‘_boundingSphereComputed’ to true has been added.  It seems that both 
> are necessary.
>
>
>
> Thanks,
>
> Rick
>
>
>
>
>
> -Original Message-
> From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On 
> Behalf Of Robert Osfield
> Sent: Saturday, June 11, 2016 3:07 AM
> To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
> Subject: Re: [osg-users] Drawable getBoundingBox() question
>
>
>
> On 10 June 2016 at 23:02, Rick Irons <rick.ir...@mathworks.com> wrote:
>
>> Shouldn’t the inlined getBoundingBox() method in include/osg/Drawable
>
>> set _boundingBoxComputed to ‘true’ or am I missing something?
>
>
>
> The later :-)
>
>
>
> From git master:
>
>
>
> /** Get BoundingBox of Drawable.
>
>   * If the BoundingBox is not up to date then its updated via 
> an internal call to computeBond().
>
>   */
>
> inline const BoundingBox& getBoundingBox() const
>
> {
>
> if(!_boundingSphereComputed)
>
> {
>
> _boundingBox = _initialBound;
>
>
>
> if (_computeBoundCallback.valid())
>
>
>
> _boundingBox.expandBy(_computeBoundCallback->computeBound(*this));
>
> else
>
> _boundingBox.expandBy(computeBoundingBox());
>
>
>
> if(_boundingBox.valid()){
>
> _boundingSphere.set(_boundingBox.center(),
>
> _boundingBox.radius());
>
> } else {
>
> _boundingSphere.init();
>
> }
>
>
>
> _boundingSphereComputed = true;
>
> }
>
>
>
> return _boundingBox;
>
> }
>
> ___
>
> 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
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Drawable getBoundingBox() question

2016-06-13 Thread Rick Irons
Hi Robert,



Thank you for the response.



I am still a little puzzled...shouldn't the code you refer to below set 
'_boundingBoxComputed' to true in addition to the current behavior of setting 
‘_boundingSphereComputed’ to true?  When I compare the OSG 3.0.1 version of the 
method to the 3.4.0 version the setting of ‘_boundingBoxComputed’ to true has 
been removed while the setting of ‘_boundingSphereComputed’ to true has been 
added.  It seems that both are necessary.



Thanks,

Rick





-Original Message-
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Saturday, June 11, 2016 3:07 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] Drawable getBoundingBox() question



On 10 June 2016 at 23:02, Rick Irons 
<rick.ir...@mathworks.com<mailto:rick.ir...@mathworks.com>> wrote:

> Shouldn’t the inlined getBoundingBox() method in include/osg/Drawable

> set _boundingBoxComputed to ‘true’ or am I missing something?



The later :-)



From git master:



/** Get BoundingBox of Drawable.

  * If the BoundingBox is not up to date then its updated via an 
internal call to computeBond().

  */

inline const BoundingBox& getBoundingBox() const

{

if(!_boundingSphereComputed)

{

_boundingBox = _initialBound;



if (_computeBoundCallback.valid())



_boundingBox.expandBy(_computeBoundCallback->computeBound(*this));

else

_boundingBox.expandBy(computeBoundingBox());



if(_boundingBox.valid()){

_boundingSphere.set(_boundingBox.center(),

_boundingBox.radius());

} else {

_boundingSphere.init();

}



_boundingSphereComputed = true;

}



return _boundingBox;

}

___

osg-users mailing list

osg-users@lists.openscenegraph.org<mailto: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] Drawable getBoundingBox() question

2016-06-10 Thread Rick Irons
Hi,

Shouldn't the inlined getBoundingBox() method in include/osg/Drawable set 
_boundingBoxComputed to 'true' or am I missing something?

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


Re: [osg-users] Use of getCameraContainingPosition in OSG 3.4.0 (deprecated?)

2016-06-09 Thread Rick Irons
Hi Robert,

Thank you for the clarifications.

Regards,
Rick

-Original Message-
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Wednesday, June 8, 2016 10:54 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Cc: Xing Gao <xing@mathworks.com>
Subject: Re: [osg-users] Use of getCameraContainingPosition in OSG 3.4.0 
(deprecated?)

Hi Rick.

I deprecated the function as the interpretation of how it should behave is 
ambiguous for certain combinations of viewer Camera set up - it simply can't 
guarantee to give the correct camera and x,y location that you might be 
expecting as the interface doesn't provide enough information for the function 
to work correctly in all cases as it has to make assumptions for this missing 
data.  For simple viewers you won't hit up against this but as you add more 
complex set ups set as multiple overlapping cameras/distortion correction etc. 
exactly how a mouse coordinate maps can varying widely.

The resolve the task of where a mouse coordinate maps osgGA::GUEventAdapter now 
"has a" stack of  PointerData that hold how the coordinate maps to the 
successive camera's in the stake.  If you look at View you'll now see 
computeIntersections(..) methods that take the GUIEventAdapter object directly 
rather than the orphaned x,y mouse cooridnates.  This extra information enables 
the intersection traversal correctly.

The PonterData holds the Camera information, if you look at the
View::computeIntersections(..) methods you'll see how it's used:

bool View::computeIntersections(const osgGA::GUIEventAdapter& ea, 
osgUtil::LineSegmentIntersector::Intersections&
intersections,osg::Node::NodeMask traversalMask) { #if 1
if (ea.getNumPointerData()>=1)
{
const osgGA::PointerData* pd =
ea.getPointerData(ea.getNumPointerData()-1);
const osg::Camera* camera = pd->object.valid() ?
pd->object->asCamera() : 0;
if (camera)
{
return computeIntersections(camera, 
osgUtil::Intersector::PROJECTION, pd->getXnormalized(),
pd->getYnormalized(), intersections, traversalMask);
}
}
#endif
return computeIntersections(ea.getX(), ea.getY(), intersections, 
traversalMask); }

The old code is still there as a fallback, the new bit is in the #if 1 #endif 
block.

I realise this will seem like an extra level of complexity, but for most users 
they shouldn't be using the getCameraContainingPosition() method directly and 
won't need to look at the PointerData either.
What the PointerData gives you is a robust way of getting the mouse position 
relative to the active cameras.

Robert.







Robert.

On 8 June 2016 at 15:34, Rick Irons <rick.ir...@mathworks.com> wrote:
> Hi,
>
>
>
> We are working on updating an application from OSG 3.0.1 to 3.4.0.  We 
> have previously relied on getCameraContainingPosition() for selection, 
> but now we are noticing that the function is marked as deprecated.  
> Can someone identify the deprecation plan for this API?  Is it still 
> safe to use with the understanding that it will not be available in a 
> future release?  Or, should we stop using the function now?  Our 
> efforts to locate information on the deprecation of this API have not been 
> successful.
>
>
>
> I am asking since the function is not behaving as expected following 
> our update.  It is not clear if this behavior is due to the function 
> no longer being supported or if some changes on our end are necessary 
> to use the 3.4.0 version of the API.
>
>
>
> Thanks for any help you can offer.
>
>
>
> Rick
>
>
> ___
> 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


[osg-users] Use of getCameraContainingPosition in OSG 3.4.0 (deprecated?)

2016-06-08 Thread Rick Irons
Hi,

We are working on updating an application from OSG 3.0.1 to 3.4.0.  We have 
previously relied on getCameraContainingPosition() for selection, but now we 
are noticing that the function is marked as deprecated.  Can someone  identify 
the deprecation plan for this API?  Is it still safe to use with the 
understanding that it will not be available in a future release?  Or, should we 
stop using the function now?  Our efforts to locate information on the 
deprecation of this API have not been successful.

I am asking since the function is not behaving as expected following our 
update.  It is not clear if this behavior is due to the function no longer 
being supported or if some changes on our end are necessary to use the 3.4.0 
version of the API.

Thanks for any help you can offer.

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


Re: [osg-users] CullVisitor object not getting properly deleted

2016-05-27 Thread Rick Irons
Hi Robert,

Your most recent changes addressed the crash we were encountering.  Thanks for 
looking into this issue.

Rick

-Original Message-
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Friday, May 27, 2016 4:50 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] CullVisitor object not getting properly deleted

Hi Rick,

Just tried, static_cast<> isn't usable in this instance thank to the use of 
virtual inheritance.

So the solution I have gone for is refactor the RenderStageCache so that it 
uses a map<Referenced*, ref_ptr> in place of map<CullVisitor*, 
ref_ptr>, this means the cast happens when the map is set up and 
no dynamic_cast<> need be done anywhere.

The changes are:

diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 
d198b78..3112cdf 100644
--- a/src/osgUtil/CullVisitor.cpp
+++ b/src/osgUtil/CullVisitor.cpp
@@ -1368,7 +1368,7 @@ class RenderStageCache : public osg::Object, public 
osg::Observer  {
 public:

-typedef std::map<CullVisitor*, osg::ref_ptr >
RenderStageMap;
+typedef std::map<osg::Referenced*, osg::ref_ptr
> RenderStageMap;

 RenderStageCache() {}
 RenderStageCache(const RenderStageCache&, const osg::CopyOp&) {} @@ 
-1387,18 +1387,17 @@ class RenderStageCache : public osg::Object, public 
osg::Observer
 virtual void objectDeleted(void* object)
 {
 osg::Referenced* ref = reinterpret_cast<osg::Referenced*>(object);
-osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*>(ref);

 OpenThreads::ScopedLock lock(_mutex);

-RenderStageMap::iterator itr = _renderStageMap.find(cv);
+RenderStageMap::iterator itr = _renderStageMap.find(ref);
 if (itr!=_renderStageMap.end())
 {
 _renderStageMap.erase(itr);
 }
 }

-void setRenderStage(CullVisitor* cv, RenderStage* rs)
+void setRenderStage(osg::Referenced* cv, RenderStage* rs)
 {
 OpenThreads::ScopedLock lock(_mutex);
 RenderStageMap::iterator itr = _renderStageMap.find(cv); @@ 
-1414,7 +1413,7 @@ class RenderStageCache : public osg::Object, public 
osg::Observer

 }

-RenderStage* getRenderStage(osgUtil::CullVisitor* cv)
+RenderStage* getRenderStage(osg::Referenced* cv)
 {
 OpenThreads::ScopedLock lock(_mutex);
 RenderStageMap::iterator itr = _renderStageMap.find(cv);


I have checked this fix into OSG master and 3.4 branch.  Commit is
110cf56..31592d2

Could you let me know how this works out, if it fails I'm afraid I'll need a 
small test example to reproduce it as the osgoi and osgprerender examples I'm 
using are working 100% OK.

Robert.

On 27 May 2016 at 09:01, Robert Osfield <robert.osfi...@gmail.com> wrote:
> Hi Rick,
>
> As general note, use of a C pointer to scene graph objects include the 
> CullVisitor should generally be avoided, it's only safe for small 
> blocks of code where you know that the objects will remain in memory 
> at all times during the block.  Instead you should use ref_ptr<> to 
> make sure it's lifetime is correct - if in doubt use ref_ptr<>.
>
> I will have a look at the use of dynamic_cast<> again.  I had to keep 
> it in there because the pointer to the Referenced base class isn't 
> castable directly to a CullVsititor as CullVisitor uses virtual 
> inheritance.
>
> Robert.
>
>
> On 26 May 2016 at 22:04, Rick Irons <rick.ir...@mathworks.com> wrote:
>> Hi Robert,
>>
>>
>>
>> Unfortunately the fix didn't address the crash I am encountering.  
>> The issue of the dynamic cast in objectDeleted()
>> (\openscenegraph\src\osgUtil\CullVisitor.cpp) failing remains...
>>
>>
>>
>> virtual void objectDeleted(void* object)
>>
>> {
>>
>> osg::Referenced* ref =
>> reinterpret_cast<osg::Referenced*>(object);
>>
>> osgUtil::CullVisitor* cv = 
>> dynamic_cast<osgUtil::CullVisitor*>(ref);
>>
>>
>>
>> OpenThreads::ScopedLock lock(_mutex);
>>
>>
>>
>> RenderStageMap::iterator itr = _renderStageMap.find(cv);
>>
>> if (itr!=_renderStageMap.end())
>>
>> {
>>
>> _renderStageMap.erase(itr);
>>
>> }
>>
>> }
>>
>>
>>
>> I was going to define our object that inherits from the CullVisitor 
>> as an osg::ref_ptr.  Perhaps doing so will delay the freeing of the 
>> CullVisitor object 

Re: [osg-users] CullVisitor object not getting properly deleted

2016-05-26 Thread Rick Irons
Hi Robert,



Unfortunately the fix didn't address the crash I am encountering.  The issue of 
the dynamic cast in objectDeleted() 
(\openscenegraph\src\osgUtil\CullVisitor.cpp) failing remains...



virtual void objectDeleted(void* object)

{

osg::Referenced* ref = reinterpret_cast<osg::Referenced*>(object);

osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(ref);



OpenThreads::ScopedLock lock(_mutex);



RenderStageMap::iterator itr = _renderStageMap.find(cv);

if (itr!=_renderStageMap.end())

{

_renderStageMap.erase(itr);

}

}



I was going to define our object that inherits from the CullVisitor as an 
osg::ref_ptr.  Perhaps doing so will delay the freeing of the CullVisitor 
object long enough within the CullVisitor destructor so that the problematic 
dynamic cast will succeed.  I am open to any other suggestions as well.  I may 
have to resort to just creating a small example program that reproduces the 
issue.



Thanks,

Rick



-Original Message-
From: Rick Irons
Sent: Wednesday, May 25, 2016 5:56 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] CullVisitor object not getting properly deleted



Hi Robert,



Thanks for the update.   I will try out the fix.



Rick



> On May 24, 2016, at 3:53 PM, Robert Osfield 
> <robert.osfi...@gmail.com<mailto:robert.osfi...@gmail.com>> wrote:

>

> Hi Rick,

>

> After a preplexing day looking at how the osgUtiil::CullVisitor,

> osg::Camera and RenderStageCache were all interacting via the

> osg::Observer system I finally fixed the problem with the crash that

> I've see with the osgoit and osgprerender examples.   As the crash

> looks similar to what you saw there is reasonable chance that the

> changes should work for you too.

>

> I have checked my fix into master and OpenSceneGraph-3.4.

>

> Robert.

> ___

> osg-users mailing list

> osg-users@lists.openscenegraph.org<mailto: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] CullVisitor object not getting properly deleted

2016-05-25 Thread Rick Irons
Hi Robert,

Thanks for the update.   I will try out the fix.

Rick

> On May 24, 2016, at 3:53 PM, Robert Osfield  wrote:
> 
> Hi Rick,
> 
> After a preplexing day looking at how the osgUtiil::CullVisitor,
> osg::Camera and RenderStageCache were all interacting via the
> osg::Observer system I finally fixed the problem with the crash that
> I've see with the osgoit and osgprerender examples.   As the crash
> looks similar to what you saw there is reasonable chance that the
> changes should work for you too.
> 
> I have checked my fix into master and OpenSceneGraph-3.4.
> 
> Robert.
> ___
> 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] CullVisitor object not getting properly deleted

2016-05-24 Thread Rick Irons
Hi Robert,

Thanks for the update.

Rick

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Tuesday, May 24, 2016 5:11 AM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] CullVisitor object not getting properly deleted

Hi Rick,

On 23 May 2016 at 20:33, Rick Irons 
<rick.ir...@mathworks.com<mailto:rick.ir...@mathworks.com>> wrote:
The code where the static cast is failing is OSG code 
(openscenegraph\src\osgUtil\CullVisitor.cpp).  I believe it is fairly recent 
code that was added just prior to the release of 3.4.0.  Here is the OSG 3.5.1 
version of the change… 
http://trac.openscenegraph.org/projects/osg/changeset/14578#file0

Thanks for pin pointing the change.  The code in question was written to 
address a bug in clean up, so it looks like it's inadvertently introduced it's 
own one.

In testing I've foind the osgoit example crashes in the same manor as you've 
found.  I'm currently looking at resolving this.
Robert.

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


Re: [osg-users] CullVisitor object not getting properly deleted

2016-05-23 Thread Rick Irons
Hi Robert,

The code where the static cast is failing is OSG code 
(openscenegraph\src\osgUtil\CullVisitor.cpp).  I believe it is fairly recent 
code that was added just prior to the release of 3.4.0.  Here is the OSG 3.5.1 
version of the change… 
http://trac.openscenegraph.org/projects/osg/changeset/14578#file0

Thanks,
Rick

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Monday, May 23, 2016 2:02 PM
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] CullVisitor object not getting properly deleted

Hi Rick,
The Object that your observer is trying to dynamic_cast<> on is in the throws 
of being destructed - have a look at the stack trace, I'm not surprised this 
fails.
Try removing the use of the dynamic_cast<>, replacing it with a static_cast<>.  
As long as you don't dereference and just use it to double check other arrays 
the it things should be OK.
As a general note though, it's kind odd bit of code.  What does you 
_renderStageMap contain?  Just raw C pointers?
I suspect the code should probably be redesigned to avoid trying to do tricks 
like using an custom Observer to do house keeping.

Robert.


On 23 May 2016 at 17:45, Rick Irons 
<rick.ir...@mathworks.com<mailto:rick.ir...@mathworks.com>> wrote:
Hi all,

I am encountering an issue with a CullVisitor object not being properly deleted 
in version 3.4.0.  I am encountering this issue when updating from version 
3.0.1.

The source of the problem is a failed Referenced to CullVisitor dynamic cast 
that occurs in the code below…

virtual void objectDeleted(void* object)
{
osg::Referenced* ref = reinterpret_cast<osg::Referenced*>(object);
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(ref);
OpenThreads::ScopedLock lock(_mutex);
RenderStageMap::iterator itr = _renderStageMap.find(cv);
if (itr!=_renderStageMap.end())
{
_renderStageMap.erase(cv);
}
}

The call stack at the time of the failed cast is the following…

[cid:image001.png@01D1B505.D7E68DD0]

The cv pointer is NULL following the cast.  My suspicion is that the dynamic 
cast is failing because we are in the destructor of our own object that 
inherits the OSG CullVisitor object.  I tested this suspicion by confirming 
that the same dynamic cast will succeed in application code if done immediately 
before invoking the destructor of our version of the CullVisitor.  This issue 
is blocking our update to 3.4.0 since it causes numerous unit test failures.

Any suggestions on how to address this issue?

I created the hack below to temporary bypass the problem…

virtual void objectDeleted(void* object)
{
osg::Referenced* ref = reinterpret_cast<osg::Referenced*>(object);
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(ref);
OpenThreads::ScopedLock lock(_mutex);
if (cv != NULL)
{
RenderStageMap::iterator itr = _renderStageMap.find(cv);
if (itr!=_renderStageMap.end())
{
_renderStageMap.erase(cv);
}
}
else
{
   for(RenderStageMap::iterator itr = _renderStageMap.begin();
   itr != _renderStageMap.end();
   ++itr)
   {
   osg::Referenced* tmpRef = 
dynamic_cast<osg::Referenced*>(itr->first);
   if (ref==tmpRef)
   {
cv = itr->first;
   _renderStageMap.erase(cv);
   break;
   }
   }
}
}

Thanks,
Rick

___
osg-users mailing list
osg-users@lists.openscenegraph.org<mailto: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] CullVisitor object not getting properly deleted

2016-05-23 Thread Rick Irons
Hi all,

I am encountering an issue with a CullVisitor object not being properly deleted 
in version 3.4.0.  I am encountering this issue when updating from version 
3.0.1.

The source of the problem is a failed Referenced to CullVisitor dynamic cast 
that occurs in the code below...

virtual void objectDeleted(void* object)
{
osg::Referenced* ref = reinterpret_cast(object);
osgUtil::CullVisitor* cv = dynamic_cast(ref);
OpenThreads::ScopedLock lock(_mutex);
RenderStageMap::iterator itr = _renderStageMap.find(cv);
if (itr!=_renderStageMap.end())
{
_renderStageMap.erase(cv);
}
}

The call stack at the time of the failed cast is the following...

[cid:image001.png@01D1B4EE.430210C0]

The cv pointer is NULL following the cast.  My suspicion is that the dynamic 
cast is failing because we are in the destructor of our own object that 
inherits the OSG CullVisitor object.  I tested this suspicion by confirming 
that the same dynamic cast will succeed in application code if done immediately 
before invoking the destructor of our version of the CullVisitor.  This issue 
is blocking our update to 3.4.0 since it causes numerous unit test failures.

Any suggestions on how to address this issue?

I created the hack below to temporary bypass the problem...

virtual void objectDeleted(void* object)
{
osg::Referenced* ref = reinterpret_cast(object);
osgUtil::CullVisitor* cv = dynamic_cast(ref);
OpenThreads::ScopedLock lock(_mutex);
if (cv != NULL)
{
RenderStageMap::iterator itr = _renderStageMap.find(cv);
if (itr!=_renderStageMap.end())
{
_renderStageMap.erase(cv);
}
}
else
{
   for(RenderStageMap::iterator itr = _renderStageMap.begin();
   itr != _renderStageMap.end();
   ++itr)
   {
   osg::Referenced* tmpRef = 
dynamic_cast(itr->first);
   if (ref==tmpRef)
   {
cv = itr->first;
   _renderStageMap.erase(cv);
   break;
   }
   }
}
}

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