mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Merge branch 'enable'
This commit is contained in:
commit
173820d29b
@ -81,24 +81,15 @@ namespace MWClass
|
|||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||||
ptr.get<ESM::Creature>();
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
assert (ref->base != NULL);
|
||||||
if(!model.empty()){
|
if(!model.empty()){
|
||||||
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Creature::enable (const MWWorld::Ptr& ptr) const
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::disable (const MWWorld::Ptr& ptr) const
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->removeActor (ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||||
|
@ -22,12 +22,6 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
|
|
||||||
virtual void enable (const MWWorld::Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part
|
|
||||||
|
|
||||||
virtual void disable (const MWWorld::Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part
|
|
||||||
|
|
||||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
@ -55,12 +55,6 @@ namespace MWClass
|
|||||||
if(!model.empty()){
|
if(!model.empty()){
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Light::enable (const MWWorld::Ptr& ptr) const
|
|
||||||
{
|
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
|
||||||
ptr.get<ESM::Light>();
|
|
||||||
|
|
||||||
if (!ref->base->sound.empty())
|
if (!ref->base->sound.empty())
|
||||||
{
|
{
|
||||||
|
@ -14,11 +14,6 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
|
|
||||||
virtual void enable (const MWWorld::Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part
|
|
||||||
/// \attention This is not the same as the script instruction with the same name. References
|
|
||||||
/// should only be enabled while in an active cell.
|
|
||||||
|
|
||||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
@ -110,44 +110,27 @@ namespace MWClass
|
|||||||
|
|
||||||
void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr));
|
renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
assert (ref->base != NULL);
|
||||||
std::string headID = ref->base->head;
|
std::string headID = ref->base->head;
|
||||||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||||
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
||||||
|
|
||||||
|
|
||||||
std::string smodel = "meshes\\base_anim.nif";
|
std::string smodel = "meshes\\base_anim.nif";
|
||||||
if(beast)
|
if(beast)
|
||||||
smodel = "meshes\\base_animkna.nif";
|
smodel = "meshes\\base_animkna.nif";
|
||||||
physics.insertActorPhysics(ptr, smodel);
|
physics.insertActorPhysics(ptr, smodel);
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Npc::enable (const MWWorld::Ptr& ptr) const
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::disable (const MWWorld::Ptr& ptr) const
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->removeActor (ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||||
|
@ -19,12 +19,6 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
|
|
||||||
virtual void enable (const MWWorld::Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part
|
|
||||||
|
|
||||||
virtual void disable (const MWWorld::Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part
|
|
||||||
|
|
||||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
@ -71,7 +71,10 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
mActors.erase (ptr);
|
std::set<MWWorld::Ptr>::iterator iter = mActors.find (ptr);
|
||||||
|
|
||||||
|
if (iter!=mActors.end())
|
||||||
|
mActors.erase (iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
void Actors::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
||||||
|
@ -32,6 +32,8 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void removeActor (const MWWorld::Ptr& ptr);
|
void removeActor (const MWWorld::Ptr& ptr);
|
||||||
///< Deregister an actor for stats management
|
///< Deregister an actor for stats management
|
||||||
|
///
|
||||||
|
/// \note Ignored, if \a ptr is not a registered actor.
|
||||||
|
|
||||||
void dropActors (const MWWorld::Ptr::CellStore *cellStore);
|
void dropActors (const MWWorld::Ptr::CellStore *cellStore);
|
||||||
///< Deregister all actors in the given cell.
|
///< Deregister all actors in the given cell.
|
||||||
|
@ -32,16 +32,6 @@ namespace MWWorld
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::enable (const Ptr& ptr) const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Class::disable (const Ptr& ptr) const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||||
{
|
{
|
||||||
throw std::runtime_error ("class does not have creature stats");
|
throw std::runtime_error ("class does not have creature stats");
|
||||||
|
@ -68,16 +68,6 @@ namespace MWWorld
|
|||||||
virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
||||||
|
|
||||||
virtual void enable (const Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part (default implementation: ignore)
|
|
||||||
/// \attention This is not the same as the script instruction with the same name. References
|
|
||||||
/// should only be enabled while in an active cell.
|
|
||||||
|
|
||||||
virtual void disable (const Ptr& ptr) const;
|
|
||||||
///< Enable reference; only does the non-rendering part (default implementation: ignore)
|
|
||||||
/// \attention This is not the same as the script instruction with the same name. References
|
|
||||||
/// should only be enabled while in an active cell.
|
|
||||||
|
|
||||||
virtual std::string getName (const Ptr& ptr) const = 0;
|
virtual std::string getName (const Ptr& ptr) const = 0;
|
||||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
@ -41,7 +41,6 @@ namespace
|
|||||||
{
|
{
|
||||||
rendering.addObject(ptr);
|
rendering.addObject(ptr);
|
||||||
class_.insertObject(ptr, physics);
|
class_.insertObject(ptr, physics);
|
||||||
class_.enable (ptr);
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
@ -459,8 +458,20 @@ namespace MWWorld
|
|||||||
|
|
||||||
mRendering.addObject(newPtr);
|
mRendering.addObject(newPtr);
|
||||||
MWWorld::Class::get(newPtr).insertObject(newPtr, *mPhysics);
|
MWWorld::Class::get(newPtr).insertObject(newPtr, *mPhysics);
|
||||||
MWWorld::Class::get(newPtr).enable(newPtr);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::addObjectToScene (const Ptr& ptr)
|
||||||
|
{
|
||||||
|
mRendering.addObject (ptr);
|
||||||
|
MWWorld::Class::get (ptr).insertObject (ptr, *mPhysics);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::removeObjectFromScene (const Ptr& ptr)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->removeActor (ptr);
|
||||||
|
MWBase::Environment::get().getSoundManager()->stopSound3D (ptr);
|
||||||
|
mPhysics->removeObject (ptr.getRefData().getHandle());
|
||||||
|
mRendering.removeObject (ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,12 @@ namespace MWWorld
|
|||||||
void insertObject(MWWorld::Ptr object, Ptr::CellStore* cell);
|
void insertObject(MWWorld::Ptr object, Ptr::CellStore* cell);
|
||||||
|
|
||||||
void update (float duration);
|
void update (float duration);
|
||||||
|
|
||||||
|
void addObjectToScene (const Ptr& ptr);
|
||||||
|
///< Add an object that already exists in the world model to the scene.
|
||||||
|
|
||||||
|
void removeObjectFromScene (const Ptr& ptr);
|
||||||
|
///< Remove an object from the scene, but not from the world model.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,12 +357,8 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
reference.getRefData().enable();
|
reference.getRefData().enable();
|
||||||
|
|
||||||
|
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
|
||||||
//render->enable (reference.getRefData().getHandle());
|
mWorldScene->addObjectToScene (reference);
|
||||||
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end())
|
|
||||||
Class::get (reference).enable (reference);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,14 +368,8 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
reference.getRefData().disable();
|
reference.getRefData().disable();
|
||||||
|
|
||||||
|
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount())
|
||||||
//render->disable (reference.getRefData().getHandle());
|
mWorldScene->removeObjectFromScene (reference);
|
||||||
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){
|
|
||||||
Class::get (reference).disable (reference);
|
|
||||||
MWBase::Environment::get().getSoundManager()->stopSound3D (reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,16 +543,12 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
ptr.getRefData().setCount (0);
|
ptr.getRefData().setCount (0);
|
||||||
|
|
||||||
|
if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end() &&
|
||||||
if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){
|
ptr.getRefData().isEnabled())
|
||||||
// Class::get (ptr).disable (ptr, mEnvironment); /// \todo this line needs to be removed
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->stopSound3D (ptr);
|
mWorldScene->removeObjectFromScene (ptr);
|
||||||
|
mLocalScripts.remove (ptr);
|
||||||
mPhysics->removeObject (ptr.getRefData().getHandle());
|
}
|
||||||
mRendering->removeObject(ptr);
|
|
||||||
|
|
||||||
mLocalScripts.remove (ptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user