From 3872d7476b3006b3087edaa7baba0c81a8e6734e Mon Sep 17 00:00:00 2001 From: Grigory Latyshev Date: Thu, 28 Feb 2019 20:03:42 +0000 Subject: [PATCH] Move makeOsgVec3f() to settingsutils.hpp Remove all other makeOsgVec3f() implementations --- apps/openmw/mwmechanics/aisequence.cpp | 2 +- apps/openmw/mwphysics/actor.cpp | 12 +++--- apps/openmw/mwphysics/object.cpp | 6 +-- apps/openmw/mwphysics/physicssystem.cpp | 40 +++++++++---------- apps/openmw/mwphysics/trace.cpp | 9 +++-- apps/openmw/mwscript/containerextensions.cpp | 8 ++-- apps/openmw/mwworld/scene.cpp | 8 ++-- components/detournavigator/findsmoothpath.cpp | 2 +- components/detournavigator/findsmoothpath.hpp | 12 +----- .../detournavigator/gettilespositions.hpp | 11 ++--- components/detournavigator/makenavmesh.cpp | 15 +++---- .../detournavigator/recastmeshbuilder.cpp | 11 +---- .../mwphysics => components/misc}/convert.hpp | 23 ++++++++--- components/sceneutil/detourdebugdraw.hpp | 5 +++ 14 files changed, 80 insertions(+), 84 deletions(-) rename {apps/openmw/mwphysics => components/misc}/convert.hpp (59%) diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index e337c6349..13f34058c 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -469,7 +469,7 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence) for (std::vector::const_iterator it = sequence.mPackages.begin(); it != sequence.mPackages.end(); ++it) { - std::unique_ptr package (nullptr); + std::unique_ptr package; switch (it->mType) { case ESM::AiSequence::Ai_Wander: diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index b55c20455..632d32c26 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -7,10 +7,10 @@ #include #include #include +#include #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 } 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); diff --git a/apps/openmw/mwphysics/object.cpp b/apps/openmw/mwphysics/object.cpp index 549b450a9..950630141 100644 --- a/apps/openmw/mwphysics/object.cpp +++ b/apps/openmw/mwphysics/object.cpp @@ -1,10 +1,10 @@ #include "object.hpp" -#include "convert.hpp" #include #include #include #include +#include #include #include @@ -26,7 +26,7 @@ namespace MWPhysics mCollisionObject->setUserPointer(static_cast(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 diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index f6f7aac39..d12f7fe6c 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include // 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 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(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 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 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(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; } diff --git a/apps/openmw/mwphysics/trace.cpp b/apps/openmw/mwphysics/trace.cpp index 07465ada0..57b0a8368 100644 --- a/apps/openmw/mwphysics/trace.cpp +++ b/apps/openmw/mwphysics/trace.cpp @@ -1,11 +1,12 @@ #include "trace.h" +#include + #include #include #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 diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 47c46d65e..db50ff621 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -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); } } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index a8f573ac3..1e8418893 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #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; diff --git a/components/detournavigator/findsmoothpath.cpp b/components/detournavigator/findsmoothpath.cpp index e59b80114..ef0341d72 100644 --- a/components/detournavigator/findsmoothpath.cpp +++ b/components/detournavigator/findsmoothpath.cpp @@ -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++; } diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index c02e3315b..ce5febebe 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -14,6 +14,8 @@ #include +#include + #include #include @@ -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; diff --git a/components/detournavigator/gettilespositions.hpp b/components/detournavigator/gettilespositions.hpp index 86ce77402..e233795e6 100644 --- a/components/detournavigator/gettilespositions.hpp +++ b/components/detournavigator/gettilespositions.hpp @@ -5,17 +5,14 @@ #include "settingsutils.hpp" #include "tileposition.hpp" +#include + #include #include namespace DetourNavigator { - inline osg::Vec3f makeOsgVec3f(const btVector3& value) - { - return osg::Vec3f(value.x(), value.y(), value.z()); - } - template 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)); + getTilesPositions(Misc::Convert::makeOsgVec3f(aabbMin), Misc::Convert::makeOsgVec3f(aabbMax), settings, std::forward(callback)); } template @@ -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)); + getTilesPositions(Misc::Convert::makeOsgVec3f(aabbMin), Misc::Convert::makeOsgVec3f(aabbMax), settings, std::forward(callback)); } } diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index 7bd2fee77..f1f6205c7 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -10,6 +10,8 @@ #include "flags.hpp" #include "navmeshtilescache.hpp" +#include + #include #include #include @@ -44,11 +46,6 @@ namespace using PolyMeshDetailStackPtr = std::unique_ptr; - 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::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::max(), min.y(), -std::numeric_limits::max()), osg::Vec3f(std::numeric_limits::max(), max.y(), std::numeric_limits::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)))) }; } } diff --git a/components/detournavigator/recastmeshbuilder.cpp b/components/detournavigator/recastmeshbuilder.cpp index e325b7eaf..71c4f0405 100644 --- a/components/detournavigator/recastmeshbuilder.cpp +++ b/components/detournavigator/recastmeshbuilder.cpp @@ -6,6 +6,7 @@ #include "exceptions.hpp" #include +#include #include #include @@ -15,14 +16,6 @@ #include -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()); diff --git a/apps/openmw/mwphysics/convert.hpp b/components/misc/convert.hpp similarity index 59% rename from apps/openmw/mwphysics/convert.hpp rename to components/misc/convert.hpp index c5075a2c3..c5671f016 100644 --- a/apps/openmw/mwphysics/convert.hpp +++ b/components/misc/convert.hpp @@ -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 #include #include - #include #include -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 \ No newline at end of file diff --git a/components/sceneutil/detourdebugdraw.hpp b/components/sceneutil/detourdebugdraw.hpp index bb170e7ba..9b6a28ace 100644 --- a/components/sceneutil/detourdebugdraw.hpp +++ b/components/sceneutil/detourdebugdraw.hpp @@ -1,3 +1,6 @@ +#ifndef OPENMW_COMPONENTS_SCENEUTIL_DETOURDEBUGDRAW_H +#define OPENMW_COMPONENTS_SCENEUTIL_DETOURDEBUGDRAW_H + #include #include @@ -48,3 +51,5 @@ namespace SceneUtil void addColor(osg::Vec4f&& value); }; } + +#endif \ No newline at end of file