Merge pull request #5 from greye/cross-cell

fix and unify object cell change update in mwrender
actorid
ChrisKCat 12 years ago
commit aab7cf137b

@ -149,10 +149,10 @@ Animation* Actors::getAnimation(const MWWorld::Ptr &ptr)
return NULL;
}
void Actors::updateObjectCell(const MWWorld::Ptr &ptr)
void Actors::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
{
Ogre::SceneNode *node;
MWWorld::CellStore *newCell = ptr.getCell();
MWWorld::CellStore *newCell = cur.getCell();
CellSceneNodeMap::const_iterator celliter = mCellSceneNodes.find(newCell);
if(celliter != mCellSceneNodes.end())
@ -162,15 +162,15 @@ void Actors::updateObjectCell(const MWWorld::Ptr &ptr)
node = mMwRoot->createChildSceneNode();
mCellSceneNodes[newCell] = node;
}
node->addChild(ptr.getRefData().getBaseNode());
node->addChild(cur.getRefData().getBaseNode());
PtrAnimationMap::iterator iter = mAllActors.find(ptr);
PtrAnimationMap::iterator iter = mAllActors.find(old);
if(iter != mAllActors.end())
{
Animation *anim = iter->second;
mAllActors.erase(iter);
anim->updatePtr(ptr);
mAllActors[ptr] = anim;
anim->updatePtr(cur);
mAllActors[cur] = anim;
}
}

@ -42,7 +42,7 @@ namespace MWRender
void update (float duration);
/// Updates containing cell for object rendering data
void updateObjectCell(const MWWorld::Ptr &ptr);
void updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur);
Animation* getAnimation(const MWWorld::Ptr &ptr);
};

@ -533,10 +533,10 @@ void Objects::rebuildStaticGeometry()
}
}
void Objects::updateObjectCell(const MWWorld::Ptr &ptr)
void Objects::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
{
Ogre::SceneNode *node;
MWWorld::CellStore *newCell = ptr.getCell();
MWWorld::CellStore *newCell = cur.getCell();
if(mCellSceneNodes.find(newCell) == mCellSceneNodes.end()) {
node = mMwRoot->createChildSceneNode();
@ -544,6 +544,6 @@ void Objects::updateObjectCell(const MWWorld::Ptr &ptr)
} else {
node = mCellSceneNodes[newCell];
}
node->addChild(ptr.getRefData().getBaseNode());
node->addChild(cur.getRefData().getBaseNode());
}

@ -95,7 +95,7 @@ public:
void rebuildStaticGeometry();
/// Updates containing cell for object rendering data
void updateObjectCell(const MWWorld::Ptr &ptr);
void updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur);
};
}
#endif

@ -302,23 +302,19 @@ bool RenderingManager::rotateObject( const MWWorld::Ptr &ptr, Ogre::Vector3 &rot
}
void
RenderingManager::moveObjectToCell(
const MWWorld::Ptr& ptr,
const Ogre::Vector3& pos,
MWWorld::CellStore *store)
RenderingManager::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
{
Ogre::SceneNode *child =
mRendering.getScene()->getSceneNode(ptr.getRefData().getHandle());
mRendering.getScene()->getSceneNode(old.getRefData().getHandle());
Ogre::SceneNode *parent = child->getParentSceneNode();
parent->removeChild(child);
if (MWWorld::Class::get(ptr).isActor()) {
mActors.updateObjectCell(ptr);
if (MWWorld::Class::get(old).isActor()) {
mActors.updateObjectCell(old, cur);
} else {
mObjects.updateObjectCell(ptr);
mObjects.updateObjectCell(old, cur);
}
child->setPosition(pos);
}
void RenderingManager::update (float duration, bool paused)

@ -123,9 +123,10 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
void setWaterHeight(const float height);
void toggleWater();
/// Moves object rendering part to proper container
/// \param store Cell the object was in previously (\a ptr has already been updated to the new cell).
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store);
/// Updates object rendering after cell change
/// \param old Object reference in previous cell
/// \param cur Object reference in new cell
void updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur);
void update (float duration, bool paused);

@ -770,7 +770,8 @@ namespace MWWorld
MWWorld::Ptr copy =
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
mRendering->moveObjectToCell(copy, vec, currCell);
mRendering->updateObjectCell(ptr, copy);
MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager();
mechMgr->updateCell(copy);

Loading…
Cancel
Save