Make better use of osg::BoundingSpheref in the NIF loader

macos_ci_fix
Alexei Kotov 1 year ago
parent 0154bb78df
commit fd3b24e2e6

@ -46,8 +46,7 @@ namespace Nif
}
}
nif->read(mCenter);
nif->read(mRadius);
nif->read(mBoundingSphere);
bool hasColors;
nif->read(hasColors);
@ -373,7 +372,7 @@ namespace Nif
nif->read(bi.mTransform.rotation);
nif->read(bi.mTransform.pos);
nif->read(bi.mTransform.scale);
bi.mBoundSphere = osg::BoundingSpheref(nif->get<osg::Vec3f>(), nif->get<float>());
nif->read(bi.mBoundSphere);
uint16_t numVertices;
nif->read(numVertices);
@ -574,8 +573,7 @@ namespace Nif
void BSMultiBoundSphere::read(NIFStream* nif)
{
nif->read(mCenter);
nif->read(mRadius);
nif->read(mSphere);
}
} // Namespace

@ -51,8 +51,7 @@ namespace Nif
uint16_t mDataFlags{ 0 };
uint32_t mMaterialHash;
std::vector<osg::Vec3f> mNormals, mTangents, mBitangents;
osg::Vec3f mCenter;
float mRadius;
osg::BoundingSpheref mBoundingSphere;
std::vector<osg::Vec4f> mColors;
std::vector<std::vector<osg::Vec2f>> mUVList;
uint16_t mConsistencyType;
@ -402,8 +401,7 @@ namespace Nif
struct BSMultiBoundSphere : public BSMultiBoundData
{
osg::Vec3f mCenter;
float mRadius;
osg::BoundingSpheref mSphere;
void read(NIFStream* nif) override;
};

@ -122,6 +122,13 @@ namespace Nif
quat.z() = data[3];
}
template <>
void NIFStream::read<osg::BoundingSpheref>(osg::BoundingSpheref& sphere)
{
read(sphere.center());
read(sphere.radius());
}
template <>
void NIFStream::read<Transformation>(Transformation& t)
{
@ -178,6 +185,12 @@ namespace Nif
readRange(*this, dest, size);
}
template <>
void NIFStream::read<osg::BoundingSpheref>(osg::BoundingSpheref* dest, size_t size)
{
readRange(*this, dest, size);
}
template <>
void NIFStream::read<Transformation>(Transformation* dest, size_t size)
{

@ -15,6 +15,7 @@
#include <components/misc/endianness.hpp>
#include <components/misc/float16.hpp>
#include <osg/BoundingSphere>
#include <osg/Quat>
#include <osg/Vec3f>
#include <osg/Vec4f>
@ -174,6 +175,8 @@ namespace Nif
template <>
void NIFStream::read<osg::Quat>(osg::Quat& quat);
template <>
void NIFStream::read<osg::BoundingSpheref>(osg::BoundingSpheref& sphere);
template <>
void NIFStream::read<Transformation>(Transformation& t);
template <>
void NIFStream::read<bool>(bool& data);
@ -191,6 +194,8 @@ namespace Nif
template <>
void NIFStream::read<osg::Quat>(osg::Quat* dest, size_t size);
template <>
void NIFStream::read<osg::BoundingSpheref>(osg::BoundingSpheref* dest, size_t size);
template <>
void NIFStream::read<Transformation>(Transformation* dest, size_t size);
template <>
void NIFStream::read<bool>(bool* dest, size_t size);

@ -19,7 +19,7 @@ namespace Nif
break;
case SPHERE_BV:
{
sphere.read(nif);
nif->read(sphere);
break;
}
case BOX_BV:
@ -336,7 +336,7 @@ namespace Nif
void BSTriShape::read(NIFStream* nif)
{
Node::read(nif);
mBoundingSphere.read(nif);
nif->read(mBoundingSphere);
if (nif->getBethVersion() == NIFFile::BethVersion::BETHVER_F76)
{
@ -412,12 +412,6 @@ namespace Nif
mFlags = (data & 0xFFF00000000000) >> 0x2C;
}
void NiBoundingVolume::NiSphereBV::read(NIFStream* nif)
{
nif->read(center);
nif->read(radius);
}
void BSVertexData::read(NIFStream* nif, uint16_t flags)
{
uint16_t vertexFlag = flags & BSVertexDesc::VertexAttribute::Vertex;

@ -26,13 +26,6 @@ namespace Nif
HALFSPACE_BV = 5
};
struct NiSphereBV
{
osg::Vec3f center;
float radius{ 0.f };
void read(NIFStream* nif);
};
struct NiBoxBV
{
osg::Vec3f center;
@ -59,7 +52,7 @@ namespace Nif
};
unsigned int type;
NiSphereBV sphere;
osg::BoundingSpheref sphere;
NiBoxBV box;
NiCapsuleBV capsule;
NiLozengeBV lozenge;
@ -355,7 +348,7 @@ namespace Nif
struct BSTriShape : Node
{
NiBoundingVolume::NiSphereBV mBoundingSphere;
osg::BoundingSpheref mBoundingSphere;
std::array<float, 6> mBoundMinMax;
NiSkinInstancePtr mSkin;

@ -1173,7 +1173,7 @@ namespace NifOsg
}
// radius may be used to force a larger bounding box
box.expandBy(osg::BoundingSphere(osg::Vec3(0, 0, 0), particledata->mRadius));
box.expandBy(osg::BoundingSphere(osg::Vec3(0, 0, 0), particledata->mBoundingSphere.radius()));
partsys->setInitialBound(box);
}

Loading…
Cancel
Save