Added DataVariance enum and set/get fields to osg::Object to help identify
which objects have values that vary over the lifetime of the object (DYNAMIC) and ones that do not vary (STATIC). Removed the equivalent code in osg::Transform, StateSet and StateAttribute, as these are now encompassed by the new DataVariance field. Removed MatrixMode enum from Matrix, and associated fields/parameters from osg::Transfrom and osg::NodeVisitor, since MatrixMode was not providing any useful functionality, but made the interface more complex (MatrixMode was an experimental API) Added ReferenceFrame field to osg::Transform which allows users to specify transforms that are relative to their parents (the default, and previous behavior) or absolute reference frame, which can be used for HUD's, camera relative light sources etc etc. Note, the view frustum culling for absolute Transform are disabled, and all their parents up to the root are also automatically have view frustum culling disabled. However, once passed an absolute Transform node culling will return to its default state of on, so you can still cull underneath an absolute transform, its only the culling above which is disabled.
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
#include <math.h>
|
||||
#include <osg/Group>
|
||||
#include <osg/BoundingBox>
|
||||
#include <osg/Transform>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define square(x) ((x)*(x))
|
||||
|
||||
using namespace osg;
|
||||
|
||||
Group::Group()
|
||||
@@ -202,6 +201,10 @@ const bool Group::computeBound() const
|
||||
_bsphere.init();
|
||||
if (_children.empty()) return false;
|
||||
|
||||
// note, special handling of the case when a child is an Transform,
|
||||
// such that only Transforms which are relative to their parents coordinates frame (i.e this group)
|
||||
// are handled, Transform relative to and absolute reference frame are ignored.
|
||||
|
||||
BoundingBox bb;
|
||||
bb.init();
|
||||
ChildList::const_iterator itr;
|
||||
@@ -209,7 +212,11 @@ const bool Group::computeBound() const
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
bb.expandBy((*itr)->getBound());
|
||||
const osg::Transform* transform = dynamic_cast<const osg::Transform*>(itr->get());
|
||||
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_TO_PARENTS)
|
||||
{
|
||||
bb.expandBy((*itr)->getBound());
|
||||
}
|
||||
}
|
||||
|
||||
if (!bb.isValid()) return false;
|
||||
@@ -220,7 +227,11 @@ const bool Group::computeBound() const
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
_bsphere.expandRadiusBy((*itr)->getBound());
|
||||
const osg::Transform* transform = dynamic_cast<const osg::Transform*>(itr->get());
|
||||
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_TO_PARENTS)
|
||||
{
|
||||
_bsphere.expandRadiusBy((*itr)->getBound());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user