From Pjotr Svetachov, "have added some missing serializers for RigGeomery. Withouth them I
ran into two issues. At first you get a bunch of warnings that osg::ComputeBoundCallback and osg::UpdateCallback were unsupported wrapper classes when converting fbx models with skeletal animation to osg(t/b). The second issue was that when reading, the readers fail to read the ComputeBoundCallback and UpdateCallback and set them to NULL which messes up the RigGeometry. Because a RigGeometry makes his own classes in the constructor it might be preferable to not write them at all, because now those classes are being made two times when reading a RigGeometry. But after thinking about this that would place too much limits on them (you won't be able to share or name them and save that information or make a new inherited class from them and write that one) So I ended up thinking the best way was to just write the files. "
This commit is contained in:
@@ -21,43 +21,34 @@
|
||||
using namespace osgAnimation;
|
||||
|
||||
// The idea is to compute a bounding box with a factor x of the first step we compute the bounding box
|
||||
class RigComputeBoundingBoxCallback : public osg::Drawable::ComputeBoundingBoxCallback
|
||||
osg::BoundingBox RigComputeBoundingBoxCallback::computeBound(const osg::Drawable& drawable) const
|
||||
{
|
||||
public:
|
||||
RigComputeBoundingBoxCallback(double factor = 2.0) : _computed(false), _factor(factor) {}
|
||||
void reset() { _computed = false; }
|
||||
virtual osg::BoundingBox computeBound(const osg::Drawable& drawable) const
|
||||
{
|
||||
const osgAnimation::RigGeometry& rig = dynamic_cast<const osgAnimation::RigGeometry&>(drawable);
|
||||
const osgAnimation::RigGeometry& rig = dynamic_cast<const osgAnimation::RigGeometry&>(drawable);
|
||||
|
||||
// if a valid inital bounding box is set we use it without asking more
|
||||
if (rig.getInitialBound().valid())
|
||||
return rig.getInitialBound();
|
||||
// if a valid inital bounding box is set we use it without asking more
|
||||
if (rig.getInitialBound().valid())
|
||||
return rig.getInitialBound();
|
||||
|
||||
if (_computed)
|
||||
return _boundingBox;
|
||||
|
||||
// if the computing of bb is invalid (like no geometry inside)
|
||||
// then dont tag the bounding box as computed
|
||||
osg::BoundingBox bb = rig.computeBound();
|
||||
if (!bb.valid())
|
||||
return bb;
|
||||
|
||||
|
||||
_boundingBox.expandBy(bb);
|
||||
osg::Vec3 center = _boundingBox.center();
|
||||
osg::Vec3 vec = (_boundingBox._max-center)*_factor;
|
||||
_boundingBox.expandBy(center + vec);
|
||||
_boundingBox.expandBy(center - vec);
|
||||
_computed = true;
|
||||
// OSG_NOTICE << "build the bounding box for RigGeometry " << rig.getName() << " " << _boundingBox._min << " " << _boundingBox._max << std::endl;
|
||||
if (_computed)
|
||||
return _boundingBox;
|
||||
}
|
||||
protected:
|
||||
mutable bool _computed;
|
||||
double _factor;
|
||||
mutable osg::BoundingBox _boundingBox;
|
||||
};
|
||||
|
||||
// if the computing of bb is invalid (like no geometry inside)
|
||||
// then dont tag the bounding box as computed
|
||||
osg::BoundingBox bb = rig.computeBound();
|
||||
if (!bb.valid())
|
||||
return bb;
|
||||
|
||||
|
||||
_boundingBox.expandBy(bb);
|
||||
osg::Vec3 center = _boundingBox.center();
|
||||
osg::Vec3 vec = (_boundingBox._max-center)*_factor;
|
||||
_boundingBox.expandBy(center + vec);
|
||||
_boundingBox.expandBy(center - vec);
|
||||
_computed = true;
|
||||
// OSG_NOTICE << "build the bounding box for RigGeometry " << rig.getName() << " " << _boundingBox._min << " " << _boundingBox._max << std::endl;
|
||||
return _boundingBox;
|
||||
}
|
||||
|
||||
|
||||
RigGeometry::RigGeometry()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user