mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-03 05:41:31 +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,
|
void Activator::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||||
MWPhysics::PhysicsSystem& physics) const
|
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
|
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,
|
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||||
MWPhysics::PhysicsSystem& physics) const
|
MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
physics.addActor(ptr, model);
|
physics.addActor(ptr, VFS::Path::toNormalized(model));
|
||||||
if (getCreatureStats(ptr).isDead() && getCreatureStats(ptr).isDeathAnimationFinished())
|
if (getCreatureStats(ptr).isDead() && getCreatureStats(ptr).isDeathAnimationFinished())
|
||||||
MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false);
|
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,
|
void Container::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||||
MWPhysics::PhysicsSystem& physics) const
|
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
|
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,
|
void Door::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||||
MWPhysics::PhysicsSystem& physics) const
|
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
|
bool Door::isDoor() const
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace MWClass
|
||||||
void ESM4Impl::insertObjectPhysics(
|
void ESM4Impl::insertObjectPhysics(
|
||||||
const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics)
|
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)
|
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
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
if ((ptr.get<ESM::Light>()->mBase->mData.mFlags & ESM::Light::Carry) == 0)
|
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
|
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,
|
void Static::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||||
MWPhysics::PhysicsSystem& physics) const
|
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
|
std::string_view Static::getModel(const MWWorld::ConstPtr& ptr) const
|
||||||
|
|
|
@ -407,14 +407,15 @@ namespace MWPhysics
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::addObject(
|
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)
|
if (ptr.mRef->mData.mPhysicsPostponed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const VFS::Path::Normalized animationMesh = ptr.getClass().useAnim()
|
const VFS::Path::Normalized animationMesh = ptr.getClass().useAnim()
|
||||||
? Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS())
|
? VFS::Path::toNormalized(
|
||||||
: mesh;
|
Misc::ResourceHelpers::correctActorModelPath(mesh.value(), mResourceSystem->getVFS()))
|
||||||
|
: VFS::Path::Normalized(mesh);
|
||||||
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(animationMesh);
|
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(animationMesh);
|
||||||
if (!shapeInstance || !shapeInstance->mCollisionShape)
|
if (!shapeInstance || !shapeInstance->mCollisionShape)
|
||||||
return;
|
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
|
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);
|
osg::ref_ptr<const Resource::BulletShape> shape = mShapeManager->getShape(animationMesh);
|
||||||
|
|
||||||
// Try to get shape from basic model as fallback for creatures
|
// Try to get shape from basic model as fallback for creatures
|
||||||
|
@ -589,7 +590,7 @@ namespace MWPhysics
|
||||||
}
|
}
|
||||||
|
|
||||||
int PhysicsSystem::addProjectile(
|
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
|
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance
|
||||||
= mShapeManager->getInstance(VFS::Path::toNormalized(mesh));
|
= mShapeManager->getInstance(VFS::Path::toNormalized(mesh));
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <osg/Timer>
|
#include <osg/Timer>
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
|
#include <components/vfs/pathutil.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include "collisiontype.hpp"
|
#include "collisiontype.hpp"
|
||||||
|
@ -159,12 +161,12 @@ namespace MWPhysics
|
||||||
void setWaterHeight(float height);
|
void setWaterHeight(float height);
|
||||||
void disableWater();
|
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);
|
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(
|
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 setCaster(int projectileId, const MWWorld::Ptr& caster);
|
||||||
void removeProjectile(const int projectileId);
|
void removeProjectile(const int projectileId);
|
||||||
|
|
||||||
|
|
|
@ -2331,7 +2331,8 @@ namespace MWWorld
|
||||||
MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr());
|
MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr());
|
||||||
|
|
||||||
mPhysics->remove(getPlayerPtr());
|
mPhysics->remove(getPlayerPtr());
|
||||||
mPhysics->addActor(getPlayerPtr(), getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr()));
|
mPhysics->addActor(
|
||||||
|
getPlayerPtr(), VFS::Path::toNormalized(getPlayerPtr().getClass().getCorrectedModel(getPlayerPtr())));
|
||||||
|
|
||||||
applyLoopingParticles(player);
|
applyLoopingParticles(player);
|
||||||
|
|
||||||
|
|
|
@ -154,9 +154,9 @@ std::string Misc::ResourceHelpers::correctBookartPath(
|
||||||
return image;
|
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("/\\");
|
std::string::size_type p = mdlname.find_last_of("/\\");
|
||||||
if (p != std::string::npos)
|
if (p != std::string::npos)
|
||||||
mdlname.insert(mdlname.begin() + p + 1, 'x');
|
mdlname.insert(mdlname.begin() + p + 1, 'x');
|
||||||
|
@ -168,7 +168,7 @@ std::string Misc::ResourceHelpers::correctActorModelPath(const std::string& resP
|
||||||
|
|
||||||
if (!vfs->exists(kfname))
|
if (!vfs->exists(kfname))
|
||||||
{
|
{
|
||||||
return resPath;
|
return std::string(resPath);
|
||||||
}
|
}
|
||||||
return mdlname;
|
return mdlname;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Misc
|
||||||
std::string correctBookartPath(std::string_view resPath, int width, int height, const VFS::Manager* vfs);
|
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
|
/// 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". :(
|
/// 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);
|
std::string correctMaterialPath(std::string_view resPath, const VFS::Manager* vfs);
|
||||||
|
|
||||||
// Adds "meshes\\".
|
// Adds "meshes\\".
|
||||||
|
|
Loading…
Reference in a new issue