From Luc Frauciel, "You'll find attached a new option that allow, when using LOD in USER_DEFINED_CENTER mode to expand the radius of the node by the radius of loaded objets.
Motivation ; When using PagedLODs, you don't always know the real size of loaded children, If it occurs that they are out of predefined bounds, picking on the parts that are out of bound will fail They also can be culled out too soon. The problem often occurs with long object (roads). I've modified LOD and ProxyNode to include this option." and later email: "Attached the UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED version There are impacts on some serializers (dae, osgWrapper). I haven't modified deprecated osg, since it's deprecated"
This commit is contained in:
@@ -90,6 +90,14 @@ BoundingSphere LOD::computeBound() const
|
||||
{
|
||||
return BoundingSphere(_userDefinedCenter,_radius);
|
||||
}
|
||||
else if (_centerMode==UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED && _radius>=0.0f)
|
||||
{
|
||||
BoundingSphere bs = BoundingSphere(_userDefinedCenter,_radius);
|
||||
bs.expandBy(Group::computeBound());
|
||||
//alternative (used in TxpPagedLOD)
|
||||
// bs.expandRadiusBy(Group::computeBound());
|
||||
return bs;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Group::computeBound();
|
||||
|
||||
@@ -110,6 +110,14 @@ BoundingSphere ProxyNode::computeBound() const
|
||||
{
|
||||
return BoundingSphere(_userDefinedCenter,_radius);
|
||||
}
|
||||
else if (_centerMode==UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED && _radius>=0.0f)
|
||||
{
|
||||
BoundingSphere bs = BoundingSphere(_userDefinedCenter,_radius);
|
||||
bs.expandBy(Group::computeBound());
|
||||
//alternative (used in TxpPagedLOD)
|
||||
// bs.expandRadiusBy(Group::computeBound());
|
||||
return bs;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Group::computeBound();
|
||||
|
||||
@@ -289,7 +289,7 @@ void daeWriter::apply( osg::LOD &node )
|
||||
domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
|
||||
teq->setProfile( "OpenSceneGraph" );
|
||||
|
||||
if (node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER)
|
||||
if ((node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER)||(node.getCenterMode()==osg::LOD::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED))
|
||||
{
|
||||
domAny *center = (domAny*)teq->add("Center");
|
||||
center->setValue(toString(node.getCenter()).c_str());
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// _userDefinedCenter, _radius
|
||||
static bool checkUserCenter( const osg::LOD& node )
|
||||
{
|
||||
return node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER;
|
||||
return (node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER)||(node.getCenterMode()==osg::LOD::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED);
|
||||
}
|
||||
|
||||
static bool readUserCenter( osgDB::InputStream& is, osg::LOD& node )
|
||||
@@ -63,6 +63,7 @@ REGISTER_OBJECT_WRAPPER( LOD,
|
||||
BEGIN_ENUM_SERIALIZER( CenterMode, USE_BOUNDING_SPHERE_CENTER );
|
||||
ADD_ENUM_VALUE( USE_BOUNDING_SPHERE_CENTER );
|
||||
ADD_ENUM_VALUE( USER_DEFINED_CENTER );
|
||||
ADD_ENUM_VALUE( UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED );
|
||||
END_ENUM_SERIALIZER(); // _centerMode
|
||||
|
||||
ADD_USER_SERIALIZER( UserCenter ); // _userDefinedCenter, _radius
|
||||
|
||||
@@ -80,7 +80,7 @@ static bool writeChildren( osgDB::OutputStream& os, const osg::ProxyNode& node )
|
||||
// _userDefinedCenter, _radius
|
||||
static bool checkUserCenter( const osg::ProxyNode& node )
|
||||
{
|
||||
return node.getCenterMode()==osg::ProxyNode::USER_DEFINED_CENTER;
|
||||
return (node.getCenterMode()==osg::ProxyNode::USER_DEFINED_CENTER)||(node.getCenterMode()==osg::ProxyNode::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED);
|
||||
}
|
||||
|
||||
static bool readUserCenter( osgDB::InputStream& is, osg::ProxyNode& node )
|
||||
@@ -117,6 +117,7 @@ REGISTER_OBJECT_WRAPPER( ProxyNode,
|
||||
BEGIN_ENUM_SERIALIZER( CenterMode, USE_BOUNDING_SPHERE_CENTER );
|
||||
ADD_ENUM_VALUE( USE_BOUNDING_SPHERE_CENTER );
|
||||
ADD_ENUM_VALUE( USER_DEFINED_CENTER );
|
||||
ADD_ENUM_VALUE( UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED );
|
||||
END_ENUM_SERIALIZER(); // _centerMode
|
||||
|
||||
ADD_USER_SERIALIZER( UserCenter ); // _userDefinedCenter, _radius
|
||||
|
||||
Reference in New Issue
Block a user