mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-14 22:26:41 +00:00
Ensure RigGeometry child geometries have sensible bounds without actually computing them.
This commit is contained in:
parent
586ac2d12d
commit
6286f5a1d4
2 changed files with 24 additions and 0 deletions
|
@ -41,6 +41,8 @@ void RigGeometry::setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeometry)
|
||||||
to.setSupportsDisplayList(false);
|
to.setSupportsDisplayList(false);
|
||||||
to.setUseVertexBufferObjects(true);
|
to.setUseVertexBufferObjects(true);
|
||||||
to.setCullingActive(false); // make sure to disable culling since that's handled by this class
|
to.setCullingActive(false); // make sure to disable culling since that's handled by this class
|
||||||
|
to.setComputeBoundingBoxCallback(new CopyBoundingBoxCallback());
|
||||||
|
to.setComputeBoundingSphereCallback(new CopyBoundingSphereCallback());
|
||||||
|
|
||||||
// vertices and normals are modified every frame, so we need to deep copy them.
|
// vertices and normals are modified every frame, so we need to deep copy them.
|
||||||
// assign a dedicated VBO to make sure that modifications don't interfere with source geometry's VBO.
|
// assign a dedicated VBO to make sure that modifications don't interfere with source geometry's VBO.
|
||||||
|
@ -273,6 +275,14 @@ void RigGeometry::updateBounds(osg::NodeVisitor *nv)
|
||||||
_boundingSphereComputed = true;
|
_boundingSphereComputed = true;
|
||||||
for (unsigned int i=0; i<getNumParents(); ++i)
|
for (unsigned int i=0; i<getNumParents(); ++i)
|
||||||
getParent(i)->dirtyBound();
|
getParent(i)->dirtyBound();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
osg::Geometry& geom = *mGeometry[i];
|
||||||
|
static_cast<CopyBoundingBoxCallback*>(geom.getComputeBoundingBoxCallback())->boundingBox = _boundingBox;
|
||||||
|
static_cast<CopyBoundingSphereCallback*>(geom.getComputeBoundingSphereCallback())->boundingSphere = _boundingSphere;
|
||||||
|
geom.dirtyBound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,20 @@ namespace SceneUtil
|
||||||
virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
|
virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
|
||||||
virtual void accept(osg::PrimitiveFunctor&) const;
|
virtual void accept(osg::PrimitiveFunctor&) const;
|
||||||
|
|
||||||
|
struct CopyBoundingBoxCallback : osg::Drawable::ComputeBoundingBoxCallback
|
||||||
|
{
|
||||||
|
osg::BoundingBox boundingBox;
|
||||||
|
|
||||||
|
virtual osg::BoundingBox computeBound(const osg::Drawable&) const override { return boundingBox; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CopyBoundingSphereCallback : osg::Node::ComputeBoundingSphereCallback
|
||||||
|
{
|
||||||
|
osg::BoundingSphere boundingSphere;
|
||||||
|
|
||||||
|
virtual osg::BoundingSphere computeBound(const osg::Node&) const override { return boundingSphere; }
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cull(osg::NodeVisitor* nv);
|
void cull(osg::NodeVisitor* nv);
|
||||||
void updateBounds(osg::NodeVisitor* nv);
|
void updateBounds(osg::NodeVisitor* nv);
|
||||||
|
|
Loading…
Reference in a new issue