|
|
|
@ -29,8 +29,6 @@ Objects::Objects(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Gro
|
|
|
|
|
|
|
|
|
|
Objects::~Objects()
|
|
|
|
|
{
|
|
|
|
|
for(PtrAnimationMap::iterator iter = mObjects.begin();iter != mObjects.end();++iter)
|
|
|
|
|
delete iter->second;
|
|
|
|
|
mObjects.clear();
|
|
|
|
|
|
|
|
|
|
for (CellMap::iterator iter = mCellSceneNodes.begin(); iter != mCellSceneNodes.end(); ++iter)
|
|
|
|
@ -74,9 +72,9 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool
|
|
|
|
|
{
|
|
|
|
|
insertBegin(ptr);
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, animated, allowLight));
|
|
|
|
|
osg::ref_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, animated, allowLight));
|
|
|
|
|
|
|
|
|
|
mObjects.insert(std::make_pair(ptr, anim.release()));
|
|
|
|
|
mObjects.insert(std::make_pair(ptr, anim));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, bool weaponsShields)
|
|
|
|
@ -85,16 +83,16 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b
|
|
|
|
|
ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor);
|
|
|
|
|
|
|
|
|
|
// CreatureAnimation
|
|
|
|
|
std::auto_ptr<Animation> anim;
|
|
|
|
|
osg::ref_ptr<Animation> anim;
|
|
|
|
|
|
|
|
|
|
if (weaponsShields)
|
|
|
|
|
anim.reset(new CreatureWeaponAnimation(ptr, mesh, mResourceSystem));
|
|
|
|
|
anim = new CreatureWeaponAnimation(ptr, mesh, mResourceSystem);
|
|
|
|
|
else
|
|
|
|
|
anim.reset(new CreatureAnimation(ptr, mesh, mResourceSystem));
|
|
|
|
|
anim = new CreatureAnimation(ptr, mesh, mResourceSystem);
|
|
|
|
|
|
|
|
|
|
ptr.getClass().getContainerStore(ptr).setContListener(static_cast<ActorAnimation*>(anim.get()));
|
|
|
|
|
|
|
|
|
|
mObjects.insert(std::make_pair(ptr, anim.release()));
|
|
|
|
|
mObjects.insert(std::make_pair(ptr, anim));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
|
|
|
@ -102,12 +100,12 @@ void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
|
|
|
|
insertBegin(ptr);
|
|
|
|
|
ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor);
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem));
|
|
|
|
|
osg::ref_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem));
|
|
|
|
|
|
|
|
|
|
ptr.getClass().getInventoryStore(ptr).setInvListener(anim.get(), ptr);
|
|
|
|
|
ptr.getClass().getInventoryStore(ptr).setContListener(anim.get());
|
|
|
|
|
|
|
|
|
|
mObjects.insert(std::make_pair(ptr, anim.release()));
|
|
|
|
|
mObjects.insert(std::make_pair(ptr, anim));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Objects::removeObject (const MWWorld::Ptr& ptr)
|
|
|
|
@ -119,9 +117,8 @@ bool Objects::removeObject (const MWWorld::Ptr& ptr)
|
|
|
|
|
if(iter != mObjects.end())
|
|
|
|
|
{
|
|
|
|
|
if (mUnrefQueue.get())
|
|
|
|
|
mUnrefQueue->push(iter->second->getObjectRoot());
|
|
|
|
|
mUnrefQueue->push(iter->second);
|
|
|
|
|
|
|
|
|
|
delete iter->second;
|
|
|
|
|
mObjects.erase(iter);
|
|
|
|
|
|
|
|
|
|
if (ptr.getClass().isNpc())
|
|
|
|
@ -148,7 +145,7 @@ void Objects::removeCell(const MWWorld::CellStore* store)
|
|
|
|
|
if(ptr.getCell() == store)
|
|
|
|
|
{
|
|
|
|
|
if (mUnrefQueue.get())
|
|
|
|
|
mUnrefQueue->push(iter->second->getObjectRoot());
|
|
|
|
|
mUnrefQueue->push(iter->second);
|
|
|
|
|
|
|
|
|
|
if (ptr.getClass().isNpc() && ptr.getRefData().getCustomData())
|
|
|
|
|
{
|
|
|
|
@ -157,7 +154,6 @@ void Objects::removeCell(const MWWorld::CellStore* store)
|
|
|
|
|
store.setContListener(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete iter->second;
|
|
|
|
|
mObjects.erase(iter++);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|