mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-05 15:55:45 +00:00
Move makeOsgVec3f() to settingsutils.hpp
Remove all other makeOsgVec3f() implementations
This commit is contained in:
parent
fe23acdd14
commit
3872d7476b
@ -469,7 +469,7 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence)
|
||||
for (std::vector<ESM::AiSequence::AiPackageContainer>::const_iterator it = sequence.mPackages.begin();
|
||||
it != sequence.mPackages.end(); ++it)
|
||||
{
|
||||
std::unique_ptr<MWMechanics::AiPackage> package (nullptr);
|
||||
std::unique_ptr<MWMechanics::AiPackage> package;
|
||||
switch (it->mType)
|
||||
{
|
||||
case ESM::AiSequence::Ai_Wander:
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
#include <components/resource/bulletshape.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "convert.hpp"
|
||||
#include "collisiontype.hpp"
|
||||
|
||||
namespace MWPhysics
|
||||
@ -62,7 +62,7 @@ Actor::Actor(const MWWorld::Ptr& ptr, osg::ref_ptr<const Resource::BulletShape>
|
||||
}
|
||||
else
|
||||
{
|
||||
mShape.reset(new btBoxShape(toBullet(mHalfExtents)));
|
||||
mShape.reset(new btBoxShape(Misc::Convert::toBullet(mHalfExtents)));
|
||||
mRotationallyInvariant = false;
|
||||
}
|
||||
|
||||
@ -138,13 +138,13 @@ void Actor::updateCollisionObjectPosition()
|
||||
btTransform tr = mCollisionObject->getWorldTransform();
|
||||
osg::Vec3f scaledTranslation = mRotation * osg::componentMultiply(mMeshTranslation, mScale);
|
||||
osg::Vec3f newPosition = scaledTranslation + mPosition;
|
||||
tr.setOrigin(toBullet(newPosition));
|
||||
tr.setOrigin(Misc::Convert::toBullet(newPosition));
|
||||
mCollisionObject->setWorldTransform(tr);
|
||||
}
|
||||
|
||||
osg::Vec3f Actor::getCollisionObjectPosition() const
|
||||
{
|
||||
return toOsg(mCollisionObject->getWorldTransform().getOrigin());
|
||||
return Misc::Convert::toOsg(mCollisionObject->getWorldTransform().getOrigin());
|
||||
}
|
||||
|
||||
void Actor::setPosition(const osg::Vec3f &position)
|
||||
@ -169,7 +169,7 @@ void Actor::updateRotation ()
|
||||
{
|
||||
btTransform tr = mCollisionObject->getWorldTransform();
|
||||
mRotation = mPtr.getRefData().getBaseNode()->getAttitude();
|
||||
tr.setRotation(toBullet(mRotation));
|
||||
tr.setRotation(Misc::Convert::toBullet(mRotation));
|
||||
mCollisionObject->setWorldTransform(tr);
|
||||
|
||||
updateCollisionObjectPosition();
|
||||
@ -187,7 +187,7 @@ void Actor::updateScale()
|
||||
|
||||
mPtr.getClass().adjustScale(mPtr, scaleVec, false);
|
||||
mScale = scaleVec;
|
||||
mShape->setLocalScaling(toBullet(mScale));
|
||||
mShape->setLocalScaling(Misc::Convert::toBullet(mScale));
|
||||
|
||||
scaleVec = osg::Vec3f(scale,scale,scale);
|
||||
mPtr.getClass().adjustScale(mPtr, scaleVec, true);
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "object.hpp"
|
||||
#include "convert.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/nifosg/particle.hpp>
|
||||
#include <components/resource/bulletshape.hpp>
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
||||
@ -26,7 +26,7 @@ namespace MWPhysics
|
||||
mCollisionObject->setUserPointer(static_cast<PtrHolder*>(this));
|
||||
|
||||
setScale(ptr.getCellRef().getScale());
|
||||
setRotation(toBullet(ptr.getRefData().getBaseNode()->getAttitude()));
|
||||
setRotation(Misc::Convert::toBullet(ptr.getRefData().getBaseNode()->getAttitude()));
|
||||
const float* pos = ptr.getRefData().getPosition().pos;
|
||||
setOrigin(btVector3(pos[0], pos[1], pos[2]));
|
||||
}
|
||||
@ -112,7 +112,7 @@ namespace MWPhysics
|
||||
matrix.orthoNormalize(matrix);
|
||||
|
||||
btTransform transform;
|
||||
transform.setOrigin(toBullet(matrix.getTrans()) * compound->getLocalScaling());
|
||||
transform.setOrigin(Misc::Convert::toBullet(matrix.getTrans()) * compound->getLocalScaling());
|
||||
for (int i=0; i<3; ++i)
|
||||
for (int j=0; j<3; ++j)
|
||||
transform.getBasis()[i][j] = matrix(j,i); // NB column/row major difference
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <components/misc/constants.hpp>
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
#include <components/sceneutil/unrefqueue.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <components/nifosg/particle.hpp> // FindRecIndexVisitor
|
||||
|
||||
@ -40,7 +41,6 @@
|
||||
|
||||
#include "collisiontype.hpp"
|
||||
#include "actor.hpp"
|
||||
#include "convert.hpp"
|
||||
#include "trace.h"
|
||||
#include "object.hpp"
|
||||
#include "heightfield.hpp"
|
||||
@ -243,7 +243,7 @@ namespace MWPhysics
|
||||
// Check if we actually found a valid spawn point (use an infinitely thin ray this time).
|
||||
// Required for some broken door destinations in Morrowind.esm, where the spawn point
|
||||
// intersects with other geometry if the actor's base is taken into account
|
||||
btVector3 from = toBullet(position);
|
||||
btVector3 from = Misc::Convert::toBullet(position);
|
||||
btVector3 to = from - btVector3(0,0,maxHeight);
|
||||
|
||||
btCollisionWorld::ClosestRayResultCallback resultCallback1(from, to);
|
||||
@ -253,11 +253,11 @@ namespace MWPhysics
|
||||
collisionWorld->rayTest(from, to, resultCallback1);
|
||||
|
||||
if (resultCallback1.hasHit() &&
|
||||
( (toOsg(resultCallback1.m_hitPointWorld) - (tracer.mEndPos-offset)).length2() > 35*35
|
||||
( (Misc::Convert::toOsg(resultCallback1.m_hitPointWorld) - (tracer.mEndPos-offset)).length2() > 35*35
|
||||
|| !isWalkableSlope(tracer.mPlaneNormal)))
|
||||
{
|
||||
actor->setOnSlope(!isWalkableSlope(resultCallback1.m_hitNormalWorld));
|
||||
return toOsg(resultCallback1.m_hitPointWorld) + osg::Vec3f(0.f, 0.f, sGroundOffset);
|
||||
return Misc::Convert::toOsg(resultCallback1.m_hitPointWorld) + osg::Vec3f(0.f, 0.f, sGroundOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -696,7 +696,7 @@ namespace MWPhysics
|
||||
|
||||
btCollisionObject object;
|
||||
object.setCollisionShape(&shape);
|
||||
object.setWorldTransform(btTransform(toBullet(orient), toBullet(center)));
|
||||
object.setWorldTransform(btTransform(Misc::Convert::toBullet(orient), Misc::Convert::toBullet(center)));
|
||||
|
||||
const btCollisionObject* me = nullptr;
|
||||
std::vector<const btCollisionObject*> targetCollisionObjects;
|
||||
@ -715,7 +715,7 @@ namespace MWPhysics
|
||||
}
|
||||
}
|
||||
|
||||
DeepestNotMeContactTestResultCallback resultCallback(me, targetCollisionObjects, toBullet(origin));
|
||||
DeepestNotMeContactTestResultCallback resultCallback(me, targetCollisionObjects, Misc::Convert::toBullet(origin));
|
||||
resultCallback.m_collisionFilterGroup = CollisionType_Actor;
|
||||
resultCallback.m_collisionFilterMask = CollisionType_World | CollisionType_Door | CollisionType_HeightMap | CollisionType_Actor;
|
||||
mCollisionWorld->contactTest(&object, resultCallback);
|
||||
@ -724,7 +724,7 @@ namespace MWPhysics
|
||||
{
|
||||
PtrHolder* holder = static_cast<PtrHolder*>(resultCallback.mObject->getUserPointer());
|
||||
if (holder)
|
||||
return std::make_pair(holder->getPtr(), toOsg(resultCallback.mContactPoint));
|
||||
return std::make_pair(holder->getPtr(), Misc::Convert::toOsg(resultCallback.mContactPoint));
|
||||
}
|
||||
return std::make_pair(MWWorld::Ptr(), osg::Vec3f());
|
||||
}
|
||||
@ -740,7 +740,7 @@ namespace MWPhysics
|
||||
|
||||
btTransform rayFrom;
|
||||
rayFrom.setIdentity();
|
||||
rayFrom.setOrigin(toBullet(point));
|
||||
rayFrom.setOrigin(Misc::Convert::toBullet(point));
|
||||
|
||||
// target the collision object's world origin, this should be the center of the collision object
|
||||
btTransform rayTo;
|
||||
@ -756,7 +756,7 @@ namespace MWPhysics
|
||||
return 0.f;
|
||||
}
|
||||
else
|
||||
return (point - toOsg(cb.m_hitPointWorld)).length();
|
||||
return (point - Misc::Convert::toOsg(cb.m_hitPointWorld)).length();
|
||||
}
|
||||
|
||||
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
|
||||
@ -790,8 +790,8 @@ namespace MWPhysics
|
||||
|
||||
PhysicsSystem::RayResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore, std::vector<MWWorld::Ptr> targets, int mask, int group) const
|
||||
{
|
||||
btVector3 btFrom = toBullet(from);
|
||||
btVector3 btTo = toBullet(to);
|
||||
btVector3 btFrom = Misc::Convert::toBullet(from);
|
||||
btVector3 btTo = Misc::Convert::toBullet(to);
|
||||
|
||||
const btCollisionObject* me = nullptr;
|
||||
std::vector<const btCollisionObject*> targetCollisionObjects;
|
||||
@ -829,8 +829,8 @@ namespace MWPhysics
|
||||
result.mHit = resultCallback.hasHit();
|
||||
if (resultCallback.hasHit())
|
||||
{
|
||||
result.mHitPos = toOsg(resultCallback.m_hitPointWorld);
|
||||
result.mHitNormal = toOsg(resultCallback.m_hitNormalWorld);
|
||||
result.mHitPos = Misc::Convert::toOsg(resultCallback.m_hitPointWorld);
|
||||
result.mHitNormal = Misc::Convert::toOsg(resultCallback.m_hitNormalWorld);
|
||||
if (PtrHolder* ptrHolder = static_cast<PtrHolder*>(resultCallback.m_collisionObject->getUserPointer()))
|
||||
result.mHitObject = ptrHolder->getPtr();
|
||||
}
|
||||
@ -839,15 +839,15 @@ namespace MWPhysics
|
||||
|
||||
PhysicsSystem::RayResult PhysicsSystem::castSphere(const osg::Vec3f &from, const osg::Vec3f &to, float radius)
|
||||
{
|
||||
btCollisionWorld::ClosestConvexResultCallback callback(toBullet(from), toBullet(to));
|
||||
btCollisionWorld::ClosestConvexResultCallback callback(Misc::Convert::toBullet(from), Misc::Convert::toBullet(to));
|
||||
callback.m_collisionFilterGroup = 0xff;
|
||||
callback.m_collisionFilterMask = CollisionType_World|CollisionType_HeightMap|CollisionType_Door;
|
||||
|
||||
btSphereShape shape(radius);
|
||||
const btQuaternion btrot = btQuaternion::getIdentity();
|
||||
|
||||
btTransform from_ (btrot, toBullet(from));
|
||||
btTransform to_ (btrot, toBullet(to));
|
||||
btTransform from_ (btrot, Misc::Convert::toBullet(from));
|
||||
btTransform to_ (btrot, Misc::Convert::toBullet(to));
|
||||
|
||||
mCollisionWorld->convexSweepTest(&shape, from_, to_, callback);
|
||||
|
||||
@ -855,8 +855,8 @@ namespace MWPhysics
|
||||
result.mHit = callback.hasHit();
|
||||
if (result.mHit)
|
||||
{
|
||||
result.mHitPos = toOsg(callback.m_hitPointWorld);
|
||||
result.mHitNormal = toOsg(callback.m_hitNormalWorld);
|
||||
result.mHitPos = Misc::Convert::toOsg(callback.m_hitPointWorld);
|
||||
result.mHitNormal = Misc::Convert::toOsg(callback.m_hitNormalWorld);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -1131,7 +1131,7 @@ namespace MWPhysics
|
||||
ObjectMap::iterator found = mObjects.find(ptr);
|
||||
if (found != mObjects.end())
|
||||
{
|
||||
found->second->setRotation(toBullet(ptr.getRefData().getBaseNode()->getAttitude()));
|
||||
found->second->setRotation(Misc::Convert::toBullet(ptr.getRefData().getBaseNode()->getAttitude()));
|
||||
mCollisionWorld->updateSingleAabb(found->second->getCollisionObject());
|
||||
return;
|
||||
}
|
||||
@ -1152,7 +1152,7 @@ namespace MWPhysics
|
||||
ObjectMap::iterator found = mObjects.find(ptr);
|
||||
if (found != mObjects.end())
|
||||
{
|
||||
found->second->setOrigin(toBullet(ptr.getRefData().getPosition().asVec3()));
|
||||
found->second->setOrigin(Misc::Convert::toBullet(ptr.getRefData().getPosition().asVec3()));
|
||||
mCollisionWorld->updateSingleAabb(found->second->getCollisionObject());
|
||||
return;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include "trace.h"
|
||||
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
|
||||
#include <BulletCollision/CollisionShapes/btConvexShape.h>
|
||||
|
||||
#include "collisiontype.hpp"
|
||||
#include "actor.hpp"
|
||||
#include "convert.hpp"
|
||||
|
||||
namespace MWPhysics
|
||||
{
|
||||
@ -49,8 +50,8 @@ protected:
|
||||
|
||||
void ActorTracer::doTrace(const btCollisionObject *actor, const osg::Vec3f& start, const osg::Vec3f& end, const btCollisionWorld* world)
|
||||
{
|
||||
const btVector3 btstart = toBullet(start);
|
||||
const btVector3 btend = toBullet(end);
|
||||
const btVector3 btstart = Misc::Convert::toBullet(start);
|
||||
const btVector3 btend = Misc::Convert::toBullet(end);
|
||||
|
||||
const btTransform &trans = actor->getWorldTransform();
|
||||
btTransform from(trans);
|
||||
@ -75,7 +76,7 @@ void ActorTracer::doTrace(const btCollisionObject *actor, const osg::Vec3f& star
|
||||
mFraction = newTraceCallback.m_closestHitFraction;
|
||||
mPlaneNormal = osg::Vec3f(tracehitnormal.x(), tracehitnormal.y(), tracehitnormal.z());
|
||||
mEndPos = (end-start)*mFraction + start;
|
||||
mHitPoint = toOsg(newTraceCallback.m_hitPointWorld);
|
||||
mHitPoint = Misc::Convert::toOsg(newTraceCallback.m_hitPointWorld);
|
||||
mHitObject = newTraceCallback.m_hitCollisionObject;
|
||||
}
|
||||
else
|
||||
|
@ -87,9 +87,9 @@ namespace MWScript
|
||||
else
|
||||
{
|
||||
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage61}");
|
||||
Misc::StringUtils::replace(msgBox, "%d", std::to_string(count).c_str(), 2);
|
||||
::Misc::StringUtils::replace(msgBox, "%d", std::to_string(count).c_str(), 2);
|
||||
}
|
||||
Misc::StringUtils::replace(msgBox, "%s", itemName.c_str(), 2);
|
||||
::Misc::StringUtils::replace(msgBox, "%s", itemName.c_str(), 2);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
|
||||
}
|
||||
}
|
||||
@ -171,13 +171,13 @@ namespace MWScript
|
||||
if (numRemoved > 1)
|
||||
{
|
||||
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage63}");
|
||||
Misc::StringUtils::replace(msgBox, "%d", std::to_string(numRemoved).c_str(), 2);
|
||||
::Misc::StringUtils::replace(msgBox, "%d", std::to_string(numRemoved).c_str(), 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage62}");
|
||||
}
|
||||
Misc::StringUtils::replace(msgBox, "%s", itemName.c_str(), 2);
|
||||
::Misc::StringUtils::replace(msgBox, "%s", itemName.c_str(), 2);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <components/resource/bulletshape.hpp>
|
||||
#include <components/detournavigator/navigator.hpp>
|
||||
#include <components/detournavigator/debug.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
@ -28,7 +29,6 @@
|
||||
#include "../mwphysics/actor.hpp"
|
||||
#include "../mwphysics/object.hpp"
|
||||
#include "../mwphysics/heightfield.hpp"
|
||||
#include "../mwphysics/convert.hpp"
|
||||
|
||||
#include "player.hpp"
|
||||
#include "localscripts.hpp"
|
||||
@ -135,16 +135,16 @@ namespace
|
||||
|
||||
const auto& transform = object->getCollisionObject()->getWorldTransform();
|
||||
const btTransform closedDoorTransform(
|
||||
MWPhysics::toBullet(makeObjectOsgQuat(ptr.getCellRef().getPosition())),
|
||||
Misc::Convert::toBullet(makeObjectOsgQuat(ptr.getCellRef().getPosition())),
|
||||
transform.getOrigin()
|
||||
);
|
||||
|
||||
const auto start = DetourNavigator::makeOsgVec3f(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 = DetourNavigator::makeOsgVec3f(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);
|
||||
const auto connectionEnd = endPoint.mHit ? endPoint.mHitPos : end;
|
||||
|
@ -125,7 +125,7 @@ namespace DetourNavigator
|
||||
{
|
||||
// Stop at Off-Mesh link or when point is further than slop away.
|
||||
if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
|
||||
!inRange(makeOsgVec3f(&steerPath[ns * 3]), startPos, minTargetDist, 1000.0f))
|
||||
!inRange(Misc::Convert::makeOsgVec3f(&steerPath[ns * 3]), startPos, minTargetDist, 1000.0f))
|
||||
break;
|
||||
ns++;
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include <LinearMath/btVector3.h>
|
||||
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
@ -26,16 +28,6 @@ namespace DetourNavigator
|
||||
{
|
||||
struct Settings;
|
||||
|
||||
inline osg::Vec3f makeOsgVec3f(const float* values)
|
||||
{
|
||||
return osg::Vec3f(values[0], values[1], values[2]);
|
||||
}
|
||||
|
||||
inline osg::Vec3f makeOsgVec3f(const btVector3& value)
|
||||
{
|
||||
return osg::Vec3f(value.x(), value.y(), value.z());
|
||||
}
|
||||
|
||||
inline bool inRange(const osg::Vec3f& v1, const osg::Vec3f& v2, const float r, const float h)
|
||||
{
|
||||
const auto d = v2 - v1;
|
||||
|
@ -5,17 +5,14 @@
|
||||
#include "settingsutils.hpp"
|
||||
#include "tileposition.hpp"
|
||||
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
inline osg::Vec3f makeOsgVec3f(const btVector3& value)
|
||||
{
|
||||
return osg::Vec3f(value.x(), value.y(), value.z());
|
||||
}
|
||||
|
||||
template <class Callback>
|
||||
void getTilesPositions(const osg::Vec3f& aabbMin, const osg::Vec3f& aabbMax,
|
||||
const Settings& settings, Callback&& callback)
|
||||
@ -49,7 +46,7 @@ namespace DetourNavigator
|
||||
btVector3 aabbMax;
|
||||
shape.getAabb(transform, aabbMin, aabbMax);
|
||||
|
||||
getTilesPositions(makeOsgVec3f(aabbMin), makeOsgVec3f(aabbMax), settings, std::forward<Callback>(callback));
|
||||
getTilesPositions(Misc::Convert::makeOsgVec3f(aabbMin), Misc::Convert::makeOsgVec3f(aabbMax), settings, std::forward<Callback>(callback));
|
||||
}
|
||||
|
||||
template <class Callback>
|
||||
@ -66,7 +63,7 @@ namespace DetourNavigator
|
||||
aabbMax.setX(std::max(aabbMin.x(), aabbMax.x()));
|
||||
aabbMax.setY(std::max(aabbMin.y(), aabbMax.y()));
|
||||
|
||||
getTilesPositions(makeOsgVec3f(aabbMin), makeOsgVec3f(aabbMax), settings, std::forward<Callback>(callback));
|
||||
getTilesPositions(Misc::Convert::makeOsgVec3f(aabbMin), Misc::Convert::makeOsgVec3f(aabbMax), settings, std::forward<Callback>(callback));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "flags.hpp"
|
||||
#include "navmeshtilescache.hpp"
|
||||
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <DetourNavMesh.h>
|
||||
#include <DetourNavMeshBuilder.h>
|
||||
#include <Recast.h>
|
||||
@ -44,11 +46,6 @@ namespace
|
||||
|
||||
using PolyMeshDetailStackPtr = std::unique_ptr<rcPolyMeshDetail, PolyMeshDetailStackDeleter>;
|
||||
|
||||
osg::Vec3f makeOsgVec3f(const btVector3& value)
|
||||
{
|
||||
return osg::Vec3f(value.x(), value.y(), value.z());
|
||||
}
|
||||
|
||||
struct WaterBounds
|
||||
{
|
||||
osg::Vec3f mMin;
|
||||
@ -61,8 +58,8 @@ namespace
|
||||
if (water.mCellSize == std::numeric_limits<int>::max())
|
||||
{
|
||||
const auto transform = getSwimLevelTransform(settings, water.mTransform, agentHalfExtents.z());
|
||||
const auto min = toNavMeshCoordinates(settings, makeOsgVec3f(transform(btVector3(-1, -1, 0))));
|
||||
const auto max = toNavMeshCoordinates(settings, makeOsgVec3f(transform(btVector3(1, 1, 0))));
|
||||
const auto min = toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(-1, -1, 0))));
|
||||
const auto max = toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(1, 1, 0))));
|
||||
return WaterBounds {
|
||||
osg::Vec3f(-std::numeric_limits<float>::max(), min.y(), -std::numeric_limits<float>::max()),
|
||||
osg::Vec3f(std::numeric_limits<float>::max(), max.y(), std::numeric_limits<float>::max())
|
||||
@ -73,8 +70,8 @@ namespace
|
||||
const auto transform = getSwimLevelTransform(settings, water.mTransform, agentHalfExtents.z());
|
||||
const auto halfCellSize = water.mCellSize / 2.0f;
|
||||
return WaterBounds {
|
||||
toNavMeshCoordinates(settings, makeOsgVec3f(transform(btVector3(-halfCellSize, -halfCellSize, 0)))),
|
||||
toNavMeshCoordinates(settings, makeOsgVec3f(transform(btVector3(halfCellSize, halfCellSize, 0))))
|
||||
toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(-halfCellSize, -halfCellSize, 0)))),
|
||||
toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(halfCellSize, halfCellSize, 0))))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "exceptions.hpp"
|
||||
|
||||
#include <components/bullethelpers/processtrianglecallback.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
||||
@ -15,14 +16,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
osg::Vec3f makeOsgVec3f(const btVector3& value)
|
||||
{
|
||||
return osg::Vec3f(value.x(), value.y(), value.z());
|
||||
}
|
||||
}
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
using BulletHelpers::makeProcessTriangleCallback;
|
||||
@ -175,7 +168,7 @@ namespace DetourNavigator
|
||||
|
||||
void RecastMeshBuilder::addVertex(const btVector3& worldPosition)
|
||||
{
|
||||
const auto navMeshPosition = toNavMeshCoordinates(mSettings, makeOsgVec3f(worldPosition));
|
||||
const auto navMeshPosition = toNavMeshCoordinates(mSettings, Misc::Convert::makeOsgVec3f(worldPosition));
|
||||
mVertices.push_back(navMeshPosition.x());
|
||||
mVertices.push_back(navMeshPosition.y());
|
||||
mVertices.push_back(navMeshPosition.z());
|
||||
|
@ -1,14 +1,25 @@
|
||||
#ifndef OPENMW_MWPHYSICS_CONVERT_H
|
||||
#define OPENMW_MWPHYSICS_CONVERT_H
|
||||
#ifndef OPENMW_COMPONENTS_MISC_CONVERT_H
|
||||
#define OPENMW_COMPONENTS_MISC_CONVERT_H
|
||||
|
||||
#include <LinearMath/btTransform.h>
|
||||
#include <LinearMath/btVector3.h>
|
||||
#include <LinearMath/btQuaternion.h>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
#include <osg/Quat>
|
||||
|
||||
namespace MWPhysics
|
||||
namespace Misc
|
||||
{
|
||||
namespace Convert
|
||||
{
|
||||
inline osg::Vec3f makeOsgVec3f(const float* values)
|
||||
{
|
||||
return osg::Vec3f(values[0], values[1], values[2]);
|
||||
}
|
||||
|
||||
inline osg::Vec3f makeOsgVec3f(const btVector3& value)
|
||||
{
|
||||
return osg::Vec3f(value.x(), value.y(), value.z());
|
||||
}
|
||||
|
||||
inline btVector3 toBullet(const osg::Vec3f& vec)
|
||||
{
|
||||
@ -29,7 +40,7 @@ namespace MWPhysics
|
||||
{
|
||||
return osg::Quat(quat.x(), quat.y(), quat.z(), quat.w());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef OPENMW_COMPONENTS_SCENEUTIL_DETOURDEBUGDRAW_H
|
||||
#define OPENMW_COMPONENTS_SCENEUTIL_DETOURDEBUGDRAW_H
|
||||
|
||||
#include <DebugDraw.h>
|
||||
|
||||
#include <osg/Geometry>
|
||||
@ -48,3 +51,5 @@ namespace SceneUtil
|
||||
void addColor(osg::Vec4f&& value);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user