1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-07 01:15:36 +00:00

Merge branch 'vfs_normalized_path_21' into 'master'

Use normalized path for Class::getCorrectedModel (#8138)

See merge request OpenMW/openmw!4461
This commit is contained in:
Alexei Kotov 2024-11-19 22:13:38 +00:00
commit b6a1461141
11 changed files with 20 additions and 19 deletions

View file

@ -131,8 +131,7 @@ namespace NavMeshTool
osg::ref_ptr<const Resource::BulletShape> shape = [&] { osg::ref_ptr<const Resource::BulletShape> shape = [&] {
try try
{ {
return bulletShapeManager.getShape( return bulletShapeManager.getShape(Misc::ResourceHelpers::correctMeshPath(model));
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(model)));
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {

View file

@ -4,7 +4,6 @@
#include "../mwworld/livecellref.hpp" #include "../mwworld/livecellref.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include <string>
#include <string_view> #include <string_view>
namespace MWClass namespace MWClass

View file

@ -441,15 +441,15 @@ namespace MWClass
return model.substr(prefix.size()); return model.substr(prefix.size());
} }
std::string Npc::getCorrectedModel(const MWWorld::ConstPtr& ptr) const VFS::Path::Normalized Npc::getCorrectedModel(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>(); const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(ref->mBase->mRace); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(ref->mBase->mRace);
if (race->mData.mFlags & ESM::Race::Beast) if (race->mData.mFlags & ESM::Race::Beast)
return Settings::models().mBaseanimkna.get().value(); return Settings::models().mBaseanimkna.get();
return Settings::models().mBaseanim.get().value(); return Settings::models().mBaseanim.get();
} }
void Npc::getModelsToPreload(const MWWorld::ConstPtr& ptr, std::vector<std::string_view>& models) const void Npc::getModelsToPreload(const MWWorld::ConstPtr& ptr, std::vector<std::string_view>& models) const

View file

@ -133,7 +133,7 @@ namespace MWClass
std::string_view getModel(const MWWorld::ConstPtr& ptr) const override; std::string_view getModel(const MWWorld::ConstPtr& ptr) const override;
std::string getCorrectedModel(const MWWorld::ConstPtr& ptr) const override; VFS::Path::Normalized getCorrectedModel(const MWWorld::ConstPtr& ptr) const override;
float getSkill(const MWWorld::Ptr& ptr, ESM::RefId id) const override; float getSkill(const MWWorld::Ptr& ptr, ESM::RefId id) const override;

View file

@ -571,7 +571,7 @@ namespace MWPhysics
{ {
if (animationMesh != mesh) if (animationMesh != mesh)
{ {
shape = mShapeManager->getShape(VFS::Path::toNormalized(mesh)); shape = mShapeManager->getShape(mesh);
} }
} }
@ -591,8 +591,7 @@ namespace MWPhysics
int PhysicsSystem::addProjectile( int PhysicsSystem::addProjectile(
const MWWorld::Ptr& caster, const osg::Vec3f& position, VFS::Path::NormalizedView mesh, bool computeRadius) const MWWorld::Ptr& caster, const osg::Vec3f& position, VFS::Path::NormalizedView mesh, bool computeRadius)
{ {
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(mesh);
= mShapeManager->getInstance(VFS::Path::toNormalized(mesh));
assert(shapeInstance); assert(shapeInstance);
float radius = computeRadius ? shapeInstance->mCollisionBox.mExtents.length() / 2.f : 1.f; float radius = computeRadius ? shapeInstance->mCollisionBox.mExtents.length() / 2.f : 1.f;

View file

@ -1437,8 +1437,8 @@ namespace MWScript
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3()); osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl; msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl;
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const VFS::Path::Normalized model = ::Misc::ResourceHelpers::correctActorModelPath( const VFS::Path::Normalized model
VFS::Path::toNormalized(ptr.getClass().getCorrectedModel(ptr)), vfs); = ::Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getCorrectedModel(ptr), vfs);
msg << "Model: " << model.value() << std::endl; msg << "Model: " << model.value() << std::endl;
if (!model.empty()) if (!model.empty())
{ {

View file

@ -311,7 +311,7 @@ namespace MWWorld
return {}; return {};
} }
std::string Class::getCorrectedModel(const MWWorld::ConstPtr& ptr) const VFS::Path::Normalized Class::getCorrectedModel(const MWWorld::ConstPtr& ptr) const
{ {
std::string_view model = getModel(ptr); std::string_view model = getModel(ptr);
if (!model.empty()) if (!model.empty())

View file

@ -17,6 +17,7 @@
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include <components/esm3/loadskil.hpp> #include <components/esm3/loadskil.hpp>
#include <components/vfs/pathutil.hpp>
namespace ESM namespace ESM
{ {
@ -277,7 +278,7 @@ namespace MWWorld
virtual std::string_view getModel(const MWWorld::ConstPtr& ptr) const; virtual std::string_view getModel(const MWWorld::ConstPtr& ptr) const;
virtual std::string getCorrectedModel(const MWWorld::ConstPtr& ptr) const; virtual VFS::Path::Normalized getCorrectedModel(const MWWorld::ConstPtr& ptr) const;
virtual bool useAnim() const; virtual bool useAnim() const;
///< Whether or not to use animated variant of model (default false) ///< Whether or not to use animated variant of model (default false)

View file

@ -95,7 +95,7 @@ namespace
rendering.rotateObject(ptr, rotation); rendering.rotateObject(ptr, rotation);
} }
std::string getModel(const MWWorld::Ptr& ptr) VFS::Path::Normalized getModel(const MWWorld::Ptr& ptr)
{ {
if (Misc::ResourceHelpers::isHiddenMarker(ptr.getCellRef().getRefId())) if (Misc::ResourceHelpers::isHiddenMarker(ptr.getCellRef().getRefId()))
return {}; return {};
@ -115,7 +115,7 @@ namespace
return; return;
} }
std::string model = getModel(ptr); const VFS::Path::Normalized model = getModel(ptr);
const auto rotation = makeDirectNodeRotation(ptr); const auto rotation = makeDirectNodeRotation(ptr);
ESM::RefNum refnum = ptr.getCellRef().getRefNum(); ESM::RefNum refnum = ptr.getCellRef().getRefNum();
@ -706,7 +706,7 @@ namespace MWWorld
ptr.mRef->mData.mPhysicsPostponed = false; ptr.mRef->mData.mPhysicsPostponed = false;
if (ptr.mRef->mData.isEnabled() && ptr.mRef->mRef.getCount() > 0) if (ptr.mRef->mData.isEnabled() && ptr.mRef->mRef.getCount() > 0)
{ {
std::string model = getModel(ptr); const VFS::Path::Normalized model = getModel(ptr);
if (!model.empty()) if (!model.empty())
{ {
const auto rotation = makeNodeRotation(ptr, RotationOrder::direct); const auto rotation = makeNodeRotation(ptr, RotationOrder::direct);

View file

@ -2325,8 +2325,7 @@ namespace MWWorld
MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr()); MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr());
mPhysics->remove(getPlayerPtr()); mPhysics->remove(getPlayerPtr());
mPhysics->addActor( mPhysics->addActor(getPlayerPtr(), getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr()));
getPlayerPtr(), VFS::Path::toNormalized(getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr())));
applyLoopingParticles(player); applyLoopingParticles(player);

View file

@ -297,6 +297,10 @@ namespace VFS::Path
{ {
return Normalized(std::forward<T>(value)); return Normalized(std::forward<T>(value));
} }
Normalized toNormalized(NormalizedView value) = delete;
Normalized toNormalized(Normalized value) = delete;
} }
#endif #endif