Skip to content

Commit

Permalink
Merge branch 'vfs_normalized_path_21' into 'master'
Browse files Browse the repository at this point in the history
Use normalized path for Class::getCorrectedModel (#8138)

See merge request OpenMW/openmw!4461
  • Loading branch information
Capostrophic committed Nov 19, 2024
2 parents 4a911a6 + 6cd76fb commit b6a1461
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 19 deletions.
3 changes: 1 addition & 2 deletions apps/navmeshtool/worldspacedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ namespace NavMeshTool
osg::ref_ptr<const Resource::BulletShape> shape = [&] {
try
{
return bulletShapeManager.getShape(
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(model)));
return bulletShapeManager.getShape(Misc::ResourceHelpers::correctMeshPath(model));
}
catch (const std::exception& e)
{
Expand Down
1 change: 0 additions & 1 deletion apps/openmw/mwclass/classmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../mwworld/livecellref.hpp"
#include "../mwworld/ptr.hpp"

#include <string>
#include <string_view>

namespace MWClass
Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwclass/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,15 @@ namespace MWClass
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 ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(ref->mBase->mRace);
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
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/npc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace MWClass

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;

Expand Down
5 changes: 2 additions & 3 deletions apps/openmw/mwphysics/physicssystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ namespace MWPhysics
{
if (animationMesh != mesh)
{
shape = mShapeManager->getShape(VFS::Path::toNormalized(mesh));
shape = mShapeManager->getShape(mesh);
}
}

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

Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/mwscript/miscextensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,8 @@ namespace MWScript
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl;
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const VFS::Path::Normalized model = ::Misc::ResourceHelpers::correctActorModelPath(
VFS::Path::toNormalized(ptr.getClass().getCorrectedModel(ptr)), vfs);
const VFS::Path::Normalized model
= ::Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getCorrectedModel(ptr), vfs);
msg << "Model: " << model.value() << std::endl;
if (!model.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwworld/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ namespace MWWorld
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);
if (!model.empty())
Expand Down
3 changes: 2 additions & 1 deletion apps/openmw/mwworld/class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <components/esm/refid.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/vfs/pathutil.hpp>

namespace ESM
{
Expand Down Expand Up @@ -277,7 +278,7 @@ namespace MWWorld

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;
///< Whether or not to use animated variant of model (default false)
Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwworld/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace
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()))
return {};
Expand All @@ -115,7 +115,7 @@ namespace
return;
}

std::string model = getModel(ptr);
const VFS::Path::Normalized model = getModel(ptr);
const auto rotation = makeDirectNodeRotation(ptr);

ESM::RefNum refnum = ptr.getCellRef().getRefNum();
Expand Down Expand Up @@ -706,7 +706,7 @@ namespace MWWorld
ptr.mRef->mData.mPhysicsPostponed = false;
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())
{
const auto rotation = makeNodeRotation(ptr, RotationOrder::direct);
Expand Down
3 changes: 1 addition & 2 deletions apps/openmw/mwworld/worldimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2325,8 +2325,7 @@ namespace MWWorld
MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr());

mPhysics->remove(getPlayerPtr());
mPhysics->addActor(
getPlayerPtr(), VFS::Path::toNormalized(getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr())));
mPhysics->addActor(getPlayerPtr(), getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr()));

applyLoopingParticles(player);

Expand Down
4 changes: 4 additions & 0 deletions components/vfs/pathutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ namespace VFS::Path
{
return Normalized(std::forward<T>(value));
}

Normalized toNormalized(NormalizedView value) = delete;

Normalized toNormalized(Normalized value) = delete;
}

#endif

0 comments on commit b6a1461

Please sign in to comment.