Implement transformBoundingSphere for both sphere types (bug #6579)

C++20
Alexei Dobrohotov 3 years ago
parent 406e950052
commit aaea2bc0f6

@ -100,6 +100,7 @@
Bug #6519: Effects tooltips for ingredients work incorrectly
Bug #6523: Disintegrate Weapon is resisted by Resist Magicka instead of Sanctuary
Bug #6544: Far from world origin objects jitter when camera is still
Bug #6579: OpenMW compilation error when using OSG doubles for BoundingSphere
Feature #890: OpenMW-CS: Column filtering
Feature #1465: "Reset" argument for AI functions
Feature #2554: Modifying an object triggers the instances table to scroll to the corresponding record

@ -188,37 +188,6 @@ private:
osg::ref_ptr<osg::FrameBufferObject> mMsaaFbo;
};
void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphere& bsphere)
{
osg::BoundingSphere::vec_type xdash = bsphere._center;
xdash.x() += bsphere._radius;
xdash = xdash*matrix;
osg::BoundingSphere::vec_type ydash = bsphere._center;
ydash.y() += bsphere._radius;
ydash = ydash*matrix;
osg::BoundingSphere::vec_type zdash = bsphere._center;
zdash.z() += bsphere._radius;
zdash = zdash*matrix;
bsphere._center = bsphere._center*matrix;
xdash -= bsphere._center;
osg::BoundingSphere::value_type sqrlen_xdash = xdash.length2();
ydash -= bsphere._center;
osg::BoundingSphere::value_type sqrlen_ydash = ydash.length2();
zdash -= bsphere._center;
osg::BoundingSphere::value_type sqrlen_zdash = zdash.length2();
bsphere._radius = sqrlen_xdash;
if (bsphere._radius<sqrlen_ydash) bsphere._radius = sqrlen_ydash;
if (bsphere._radius<sqrlen_zdash) bsphere._radius = sqrlen_zdash;
bsphere._radius = sqrtf(bsphere._radius);
}
osg::Vec4f colourFromRGB(unsigned int clr)
{
osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f,

@ -49,7 +49,37 @@ namespace SceneUtil
// Transform a bounding sphere by a matrix
// based off private code in osg::Transform
// TODO: patch osg to make public
void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphere& bsphere);
template<typename VT>
inline void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphereImpl<VT>& bsphere)
{
VT xdash = bsphere._center;
xdash.x() += bsphere._radius;
xdash = xdash*matrix;
VT ydash = bsphere._center;
ydash.y() += bsphere._radius;
ydash = ydash*matrix;
VT zdash = bsphere._center;
zdash.z() += bsphere._radius;
zdash = zdash*matrix;
bsphere._center = bsphere._center*matrix;
xdash -= bsphere._center;
typename VT::value_type sqrlen_xdash = xdash.length2();
ydash -= bsphere._center;
typename VT::value_type sqrlen_ydash = ydash.length2();
zdash -= bsphere._center;
typename VT::value_type sqrlen_zdash = zdash.length2();
bsphere._radius = sqrlen_xdash;
if (bsphere._radius<sqrlen_ydash) bsphere._radius = sqrlen_ydash;
if (bsphere._radius<sqrlen_zdash) bsphere._radius = sqrlen_zdash;
bsphere._radius = sqrtf(bsphere._radius);
}
osg::Vec4f colourFromRGB (unsigned int clr);

Loading…
Cancel
Save