mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 00:09:41 +00:00
Use normalized path in PhysicsSystem
This commit is contained in:
parent
bac0018a09
commit
d2ab366233
12 changed files with 25 additions and 21 deletions
|
@ -59,7 +59,7 @@ namespace MWClass
|
|||
void Activator::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
physics.addObject(ptr, VFS::Path::toNormalized(model), rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
std::string_view Activator::getModel(const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace MWClass
|
|||
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addActor(ptr, model);
|
||||
physics.addActor(ptr, VFS::Path::toNormalized(model));
|
||||
if (getCreatureStats(ptr).isDead() && getCreatureStats(ptr).isDeathAnimationFinished())
|
||||
MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace MWClass
|
|||
void Container::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
physics.addObject(ptr, VFS::Path::toNormalized(model), rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
std::string_view Container::getModel(const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace MWClass
|
|||
void Door::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_Door);
|
||||
physics.addObject(ptr, VFS::Path::toNormalized(model), rotation, MWPhysics::CollisionType_Door);
|
||||
}
|
||||
|
||||
bool Door::isDoor() const
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace MWClass
|
|||
void ESM4Impl::insertObjectPhysics(
|
||||
const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics)
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
physics.addObject(ptr, VFS::Path::toNormalized(model), rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
MWGui::ToolTipInfo ESM4Impl::getToolTipInfo(std::string_view name, int count)
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MWClass
|
|||
{
|
||||
// TODO: add option somewhere to enable collision for placeable objects
|
||||
if ((ptr.get<ESM::Light>()->mBase->mData.mFlags & ESM::Light::Carry) == 0)
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
physics.addObject(ptr, VFS::Path::toNormalized(model), rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
bool Light::useAnim() const
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace MWClass
|
|||
void Static::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
physics.addObject(ptr, VFS::Path::toNormalized(model), rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
std::string_view Static::getModel(const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -407,14 +407,15 @@ namespace MWPhysics
|
|||
}
|
||||
|
||||
void PhysicsSystem::addObject(
|
||||
const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation, int collisionType)
|
||||
const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh, osg::Quat rotation, int collisionType)
|
||||
{
|
||||
if (ptr.mRef->mData.mPhysicsPostponed)
|
||||
return;
|
||||
|
||||
const VFS::Path::Normalized animationMesh = ptr.getClass().useAnim()
|
||||
? Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS())
|
||||
: mesh;
|
||||
? VFS::Path::toNormalized(
|
||||
Misc::ResourceHelpers::correctActorModelPath(mesh.value(), mResourceSystem->getVFS()))
|
||||
: VFS::Path::Normalized(mesh);
|
||||
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(animationMesh);
|
||||
if (!shapeInstance || !shapeInstance->mCollisionShape)
|
||||
return;
|
||||
|
@ -560,10 +561,10 @@ namespace MWPhysics
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsSystem::addActor(const MWWorld::Ptr& ptr, const std::string& mesh)
|
||||
void PhysicsSystem::addActor(const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh)
|
||||
{
|
||||
const VFS::Path::Normalized animationMesh
|
||||
= Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS());
|
||||
= Misc::ResourceHelpers::correctActorModelPath(mesh.value(), mResourceSystem->getVFS());
|
||||
osg::ref_ptr<const Resource::BulletShape> shape = mShapeManager->getShape(animationMesh);
|
||||
|
||||
// Try to get shape from basic model as fallback for creatures
|
||||
|
@ -589,7 +590,7 @@ namespace MWPhysics
|
|||
}
|
||||
|
||||
int PhysicsSystem::addProjectile(
|
||||
const MWWorld::Ptr& caster, const osg::Vec3f& position, const std::string& mesh, bool computeRadius)
|
||||
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));
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <osg/Timer>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <components/vfs/pathutil.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "collisiontype.hpp"
|
||||
|
@ -159,12 +161,12 @@ namespace MWPhysics
|
|||
void setWaterHeight(float height);
|
||||
void disableWater();
|
||||
|
||||
void addObject(const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation,
|
||||
void addObject(const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh, osg::Quat rotation,
|
||||
int collisionType = CollisionType_World);
|
||||
void addActor(const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
void addActor(const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh);
|
||||
|
||||
int addProjectile(
|
||||
const MWWorld::Ptr& caster, const osg::Vec3f& position, const std::string& mesh, bool computeRadius);
|
||||
const MWWorld::Ptr& caster, const osg::Vec3f& position, VFS::Path::NormalizedView mesh, bool computeRadius);
|
||||
void setCaster(int projectileId, const MWWorld::Ptr& caster);
|
||||
void removeProjectile(const int projectileId);
|
||||
|
||||
|
|
|
@ -2331,7 +2331,8 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr());
|
||||
|
||||
mPhysics->remove(getPlayerPtr());
|
||||
mPhysics->addActor(getPlayerPtr(), getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr()));
|
||||
mPhysics->addActor(
|
||||
getPlayerPtr(), VFS::Path::toNormalized(getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr())));
|
||||
|
||||
applyLoopingParticles(player);
|
||||
|
||||
|
|
|
@ -154,9 +154,9 @@ std::string Misc::ResourceHelpers::correctBookartPath(
|
|||
return image;
|
||||
}
|
||||
|
||||
std::string Misc::ResourceHelpers::correctActorModelPath(const std::string& resPath, const VFS::Manager* vfs)
|
||||
std::string Misc::ResourceHelpers::correctActorModelPath(std::string_view resPath, const VFS::Manager* vfs)
|
||||
{
|
||||
std::string mdlname = resPath;
|
||||
std::string mdlname(resPath);
|
||||
std::string::size_type p = mdlname.find_last_of("/\\");
|
||||
if (p != std::string::npos)
|
||||
mdlname.insert(mdlname.begin() + p + 1, 'x');
|
||||
|
@ -168,7 +168,7 @@ std::string Misc::ResourceHelpers::correctActorModelPath(const std::string& resP
|
|||
|
||||
if (!vfs->exists(kfname))
|
||||
{
|
||||
return resPath;
|
||||
return std::string(resPath);
|
||||
}
|
||||
return mdlname;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Misc
|
|||
std::string correctBookartPath(std::string_view resPath, int width, int height, const VFS::Manager* vfs);
|
||||
/// Use "xfoo.nif" instead of "foo.nif" if "xfoo.kf" is available
|
||||
/// Note that if "xfoo.nif" is actually unavailable, we can't fall back to "foo.nif". :(
|
||||
std::string correctActorModelPath(const std::string& resPath, const VFS::Manager* vfs);
|
||||
std::string correctActorModelPath(std::string_view resPath, const VFS::Manager* vfs);
|
||||
std::string correctMaterialPath(std::string_view resPath, const VFS::Manager* vfs);
|
||||
|
||||
// Adds "meshes\\".
|
||||
|
|
Loading…
Reference in a new issue