mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-11 01:13:23 +00:00
Implement transformBoundingSphere for both sphere types (bug #6579)
This commit is contained in:
parent
406e950052
commit
aaea2bc0f6
@ -100,6 +100,7 @@
|
|||||||
Bug #6519: Effects tooltips for ingredients work incorrectly
|
Bug #6519: Effects tooltips for ingredients work incorrectly
|
||||||
Bug #6523: Disintegrate Weapon is resisted by Resist Magicka instead of Sanctuary
|
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 #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 #890: OpenMW-CS: Column filtering
|
||||||
Feature #1465: "Reset" argument for AI functions
|
Feature #1465: "Reset" argument for AI functions
|
||||||
Feature #2554: Modifying an object triggers the instances table to scroll to the corresponding record
|
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;
|
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 colourFromRGB(unsigned int clr)
|
||||||
{
|
{
|
||||||
osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f,
|
osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f,
|
||||||
|
@ -49,7 +49,37 @@ namespace SceneUtil
|
|||||||
// Transform a bounding sphere by a matrix
|
// Transform a bounding sphere by a matrix
|
||||||
// based off private code in osg::Transform
|
// based off private code in osg::Transform
|
||||||
// TODO: patch osg to make public
|
// 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);
|
osg::Vec4f colourFromRGB (unsigned int clr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user