mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-29 14:34:29 +00:00
Add btVector3 -> osg::Vec3f helper
This commit is contained in:
parent
b845e07ad6
commit
1caac90e93
5 changed files with 13 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "../nif/node.hpp"
|
||||
|
||||
#include <components/bullethelpers/processtrianglecallback.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
#include <components/nif/data.hpp>
|
||||
#include <components/nif/extra.hpp>
|
||||
#include <components/nif/node.hpp>
|
||||
|
|
@ -300,8 +301,7 @@ namespace
|
|||
|
||||
void copy(const btTransform& src, Nif::NiTransform& dst)
|
||||
{
|
||||
dst.mTranslation = osg::Vec3f(static_cast<float>(src.getOrigin().x()), static_cast<float>(src.getOrigin().y()),
|
||||
static_cast<float>(src.getOrigin().z()));
|
||||
dst.mTranslation = Misc::Convert::makeOsgVec3f(src.getOrigin());
|
||||
for (int row = 0; row < 3; ++row)
|
||||
for (int column = 0; column < 3; ++column)
|
||||
dst.mRotation.mValues[row][column] = static_cast<float>(src.getBasis().getRow(row)[column]);
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ namespace MWWorld
|
|||
assert(target != caster);
|
||||
|
||||
MWMechanics::CastSpell cast(caster, target);
|
||||
cast.mHitPosition = !active ? Misc::Convert::toOsg(projectile->getHitPosition()) : pos;
|
||||
cast.mHitPosition = !active ? Misc::Convert::makeOsgVec3f(projectile->getHitPosition()) : pos;
|
||||
cast.mId = magicBoltState.mSpellId;
|
||||
cast.mSourceName = magicBoltState.mSourceName;
|
||||
cast.mItem = magicBoltState.mItem;
|
||||
|
|
|
|||
|
|
@ -178,13 +178,13 @@ namespace
|
|||
const btTransform closedDoorTransform(
|
||||
Misc::Convert::makeBulletQuaternion(ptr.getCellRef().getPosition()), transform.getOrigin());
|
||||
|
||||
const auto start = Misc::Convert::toOsg(closedDoorTransform(center + toPoint));
|
||||
const auto start = Misc::Convert::makeOsgVec3f(closedDoorTransform(center + toPoint));
|
||||
const auto startPoint = physics.castRay(start, start - osg::Vec3f(0, 0, 1000), { ptr }, {},
|
||||
MWPhysics::CollisionType_World | MWPhysics::CollisionType_HeightMap
|
||||
| MWPhysics::CollisionType_Water);
|
||||
const auto connectionStart = startPoint.mHit ? startPoint.mHitPos : start;
|
||||
|
||||
const auto end = Misc::Convert::toOsg(closedDoorTransform(center - toPoint));
|
||||
const auto end = Misc::Convert::makeOsgVec3f(closedDoorTransform(center - toPoint));
|
||||
const auto endPoint = physics.castRay(end, end - osg::Vec3f(0, 0, 1000), { ptr }, {},
|
||||
MWPhysics::CollisionType_World | MWPhysics::CollisionType_HeightMap
|
||||
| MWPhysics::CollisionType_Water);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ namespace Misc::Convert
|
|||
return osg::Vec3d(vec.x(), vec.y(), vec.z());
|
||||
}
|
||||
|
||||
inline osg::Vec3f makeOsgVec3f(const btVector3& vec)
|
||||
{
|
||||
return toOsg(vec);
|
||||
}
|
||||
|
||||
inline osg::Quat toOsg(const btQuaternion& quat)
|
||||
{
|
||||
return osg::Quat(quat.x(), quat.y(), quat.z(), quat.w());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <BulletCollision/CollisionShapes/btTriangleMesh.h>
|
||||
|
||||
#include <components/misc/convert.hpp>
|
||||
#include <components/misc/osguservalues.hpp>
|
||||
#include <components/misc/pathhelpers.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
|
|
@ -37,14 +38,12 @@ namespace Resource
|
|||
|
||||
void setMatrix(const osg::Matrixf& matrix) { mMatrix = matrix; }
|
||||
|
||||
inline btVector3 toBullet(const osg::Vec3f& vec) { return btVector3(vec.x(), vec.y(), vec.z()); }
|
||||
|
||||
void inline operator()(const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3,
|
||||
bool /*temp*/ = false) // Note: unused temp argument left here for OSG versions less than 3.5.6
|
||||
{
|
||||
if (mTriMesh)
|
||||
mTriMesh->addTriangle(
|
||||
toBullet(mMatrix.preMult(v1)), toBullet(mMatrix.preMult(v2)), toBullet(mMatrix.preMult(v3)));
|
||||
mTriMesh->addTriangle(Misc::Convert::toBullet(mMatrix.preMult(v1)),
|
||||
Misc::Convert::toBullet(mMatrix.preMult(v2)), Misc::Convert::toBullet(mMatrix.preMult(v3)));
|
||||
}
|
||||
|
||||
btTriangleMesh* mTriMesh;
|
||||
|
|
|
|||
Loading…
Reference in a new issue