From 22482b7eece985f55866b9ede84353cfd0506816 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 19:04:02 +0100 Subject: [PATCH] Don't use xmesh.nif over mesh.nif for classes that don't make use of the separated keyframes --- apps/openmw/mwclass/activator.cpp | 6 +++++- apps/openmw/mwclass/activator.hpp | 3 +++ apps/openmw/mwclass/actor.cpp | 6 +++++- apps/openmw/mwclass/actor.hpp | 2 ++ apps/openmw/mwclass/container.cpp | 6 +++++- apps/openmw/mwclass/container.hpp | 2 ++ apps/openmw/mwclass/door.cpp | 5 ++++- apps/openmw/mwclass/door.hpp | 2 ++ apps/openmw/mwclass/light.cpp | 5 ++++- apps/openmw/mwclass/light.hpp | 2 ++ apps/openmw/mwworld/class.cpp | 5 +++++ apps/openmw/mwworld/class.hpp | 3 +++ apps/openmw/mwworld/scene.cpp | 10 +++++++++- 13 files changed, 51 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index b3747f916..3e0ec366f 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -38,7 +38,6 @@ namespace MWClass { if(!model.empty()) physics.addObject(ptr, model); - MWBase::Environment::get().getMechanicsManager()->add(ptr); } std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const @@ -52,6 +51,11 @@ namespace MWClass return ""; } + bool Activator::useAnim() const + { + return true; + } + std::string Activator::getName (const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index e90620cea..4fe4dda7e 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -39,6 +39,9 @@ namespace MWClass static void registerSelf(); virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; + + virtual bool useAnim() const; + ///< Whether or not to use animated variant of model (default false) }; } diff --git a/apps/openmw/mwclass/actor.cpp b/apps/openmw/mwclass/actor.cpp index d46729c1d..ecf089b35 100644 --- a/apps/openmw/mwclass/actor.cpp +++ b/apps/openmw/mwclass/actor.cpp @@ -34,7 +34,11 @@ namespace MWClass if (getCreatureStats(ptr).isDead()) MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false); } - MWBase::Environment::get().getMechanicsManager()->add(ptr); + } + + bool Actor::useAnim() const + { + return true; } void Actor::block(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/actor.hpp b/apps/openmw/mwclass/actor.hpp index 84b8f4ad8..c3720050c 100644 --- a/apps/openmw/mwclass/actor.hpp +++ b/apps/openmw/mwclass/actor.hpp @@ -26,6 +26,8 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool useAnim() const; + virtual void block(const MWWorld::Ptr &ptr) const; virtual osg::Vec3f getRotationVector(const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 47e24f0d6..b0d3ca791 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -100,7 +100,6 @@ namespace MWClass { if(!model.empty()) physics.addObject(ptr, model); - MWBase::Environment::get().getMechanicsManager()->add(ptr); } std::string Container::getModel(const MWWorld::ConstPtr &ptr) const @@ -114,6 +113,11 @@ namespace MWClass return ""; } + bool Container::useAnim() const + { + return true; + } + boost::shared_ptr Container::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 3add65a7e..04223f264 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -70,6 +70,8 @@ namespace MWClass virtual void restock (const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; + + virtual bool useAnim() const; }; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 830ba258b..21e191931 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -74,8 +74,11 @@ namespace MWClass MWBase::Environment::get().getWorld()->activateDoor(ptr, customData.mDoorState); } } + } - MWBase::Environment::get().getMechanicsManager()->add(ptr); + bool Door::useAnim() const + { + return true; } std::string Door::getModel(const MWWorld::ConstPtr &ptr) const diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index 906b18511..3760f59c4 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -20,6 +20,8 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool useAnim() const; + virtual std::string getName (const MWWorld::ConstPtr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 689419f44..e74b9da88 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -51,8 +51,11 @@ namespace MWClass MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop); + } - MWBase::Environment::get().getMechanicsManager()->add(ptr); + bool Light::useAnim() const + { + return true; } std::string Light::getModel(const MWWorld::ConstPtr &ptr) const diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 68fd2d2c7..284a7d817 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -16,6 +16,8 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool useAnim() const; + virtual std::string getName (const MWWorld::ConstPtr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 7832c1066..72696e209 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -304,6 +304,11 @@ namespace MWWorld return ""; } + bool Class::useAnim() const + { + return false; + } + void Class::getModelsToPreload(const Ptr &ptr, std::vector &models) const { std::string model = getModel(ptr); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 0b6c5e038..3b1ddb647 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -271,6 +271,9 @@ namespace MWWorld virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; + virtual bool useAnim() const; + ///< Whether or not to use animated variant of model (default false) + virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector& models) const; ///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel(). diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 0e8a1fecb..8c3fc771d 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -53,15 +53,23 @@ namespace void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, MWRender::RenderingManager& rendering) { - std::string model = Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getModel(ptr), rendering.getResourceSystem()->getVFS()); + bool useAnim = ptr.getClass().useAnim(); + std::string model = ptr.getClass().getModel(ptr); + if (useAnim) + model = Misc::ResourceHelpers::correctActorModelPath(model, rendering.getResourceSystem()->getVFS()); + std::string id = ptr.getCellRef().getRefId(); if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker") model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player + ptr.getClass().insertObjectRendering(ptr, model, rendering); setNodeRotation(ptr, rendering, false); ptr.getClass().insertObject (ptr, model, physics); + if (useAnim) + MWBase::Environment::get().getMechanicsManager()->add(ptr); + if (ptr.getClass().isActor()) rendering.addWaterRippleEmitter(ptr); }