mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 16:09:43 +00:00
Add separate function to handle NiGeometry node
To force use a single source of data. All fields of Nif::Node are available in NiGeometry.
This commit is contained in:
parent
56eef691a8
commit
4ac83f4c39
2 changed files with 12 additions and 4 deletions
|
@ -336,7 +336,12 @@ void BulletNifLoader::handleNiTriShape(const Nif::Node& nifNode, int flags, cons
|
||||||
if ((flags & 0x800))
|
if ((flags & 0x800))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Nif::NiGeometry& niGeometry = static_cast<const Nif::NiGeometry&>(nifNode);
|
handleNiTriShape(static_cast<const Nif::NiGeometry&>(nifNode), transform, isAnimated, avoid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const osg::Matrixf &transform,
|
||||||
|
bool isAnimated, bool avoid)
|
||||||
|
{
|
||||||
if (niGeometry.data.empty() || niGeometry.data->vertices.empty())
|
if (niGeometry.data.empty() || niGeometry.data->vertices.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -377,8 +382,8 @@ void BulletNifLoader::handleNiTriShape(const Nif::Node& nifNode, int flags, cons
|
||||||
std::unique_ptr<Resource::TriangleMeshShape> childShape(new Resource::TriangleMeshShape(childMesh.get(), true));
|
std::unique_ptr<Resource::TriangleMeshShape> childShape(new Resource::TriangleMeshShape(childMesh.get(), true));
|
||||||
childMesh.release();
|
childMesh.release();
|
||||||
|
|
||||||
float scale = nifNode.trafo.scale;
|
float scale = niGeometry.trafo.scale;
|
||||||
for (const Nif::Node* parent = nifNode.parent; parent != nullptr; parent = parent->parent)
|
for (const Nif::Node* parent = niGeometry.parent; parent != nullptr; parent = parent->parent)
|
||||||
scale *= parent->trafo.scale;
|
scale *= parent->trafo.scale;
|
||||||
osg::Quat q = transform.getRotate();
|
osg::Quat q = transform.getRotate();
|
||||||
osg::Vec3f v = transform.getTrans();
|
osg::Vec3f v = transform.getTrans();
|
||||||
|
@ -386,7 +391,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::Node& nifNode, int flags, cons
|
||||||
|
|
||||||
btTransform trans(btQuaternion(q.x(), q.y(), q.z(), q.w()), btVector3(v.x(), v.y(), v.z()));
|
btTransform trans(btQuaternion(q.x(), q.y(), q.z(), q.w()), btVector3(v.x(), v.y(), v.z()));
|
||||||
|
|
||||||
mShape->mAnimatedShapes.emplace(nifNode.recIndex, mCompoundShape->getNumChildShapes());
|
mShape->mAnimatedShapes.emplace(niGeometry.recIndex, mCompoundShape->getNumChildShapes());
|
||||||
|
|
||||||
mCompoundShape->addChildShape(trans, childShape.get());
|
mCompoundShape->addChildShape(trans, childShape.get());
|
||||||
childShape.release();
|
childShape.release();
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace Nif
|
||||||
struct Transformation;
|
struct Transformation;
|
||||||
struct NiTriShape;
|
struct NiTriShape;
|
||||||
struct NiTriStrips;
|
struct NiTriStrips;
|
||||||
|
struct NiGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace NifBullet
|
namespace NifBullet
|
||||||
|
@ -61,6 +62,8 @@ private:
|
||||||
|
|
||||||
void handleNiTriShape(const Nif::Node& nifNode, int flags, const osg::Matrixf& transform, bool isAnimated, bool avoid);
|
void handleNiTriShape(const Nif::Node& nifNode, int flags, const osg::Matrixf& transform, bool isAnimated, bool avoid);
|
||||||
|
|
||||||
|
void handleNiTriShape(const Nif::NiGeometry& nifNode, const osg::Matrixf& transform, bool isAnimated, bool avoid);
|
||||||
|
|
||||||
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mCompoundShape;
|
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mCompoundShape;
|
||||||
|
|
||||||
std::unique_ptr<btTriangleMesh> mStaticMesh;
|
std::unique_ptr<btTriangleMesh> mStaticMesh;
|
||||||
|
|
Loading…
Reference in a new issue