mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Manage the player's NpcAnimation object in the RenderingManager
It may be more appropriate to manage it in MWRender::Actors with the other Animation-based objects, but that will need some (minor) interface changes.
This commit is contained in:
parent
ba3a67f84b
commit
bb8277920b
4 changed files with 34 additions and 24 deletions
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace MWRender
|
||||
{
|
||||
Player::Player (Ogre::Camera *camera, Ogre::SceneNode* node)
|
||||
Player::Player (Ogre::Camera *camera)
|
||||
: mCamera(camera),
|
||||
mCameraNode(NULL),
|
||||
mFirstPersonView(true),
|
||||
|
@ -35,7 +35,6 @@ namespace MWRender
|
|||
|
||||
Player::~Player()
|
||||
{
|
||||
delete mAnimation;
|
||||
}
|
||||
|
||||
void Player::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
|
||||
|
@ -273,11 +272,13 @@ namespace MWRender
|
|||
|
||||
void Player::setAnimation(NpcAnimation *anim)
|
||||
{
|
||||
anim->setViewMode((mVanity.enabled || mPreviewMode || !mFirstPersonView) ?
|
||||
NpcAnimation::VM_Normal : NpcAnimation::VM_FirstPerson);
|
||||
|
||||
delete mAnimation;
|
||||
// If we're switching to a new NpcAnimation, ensure the old one is
|
||||
// using a normal view mode
|
||||
if(mAnimation && mAnimation != anim)
|
||||
mAnimation->setViewMode(NpcAnimation::VM_Normal);
|
||||
mAnimation = anim;
|
||||
mAnimation->setViewMode((mVanity.enabled || mPreviewMode || !mFirstPersonView) ?
|
||||
NpcAnimation::VM_Normal : NpcAnimation::VM_FirstPerson);
|
||||
}
|
||||
|
||||
void Player::setHeight(float height)
|
||||
|
|
|
@ -49,8 +49,7 @@ namespace MWRender
|
|||
void setLowHeight(bool low = true);
|
||||
|
||||
public:
|
||||
|
||||
Player (Ogre::Camera *camera, Ogre::SceneNode* mNode);
|
||||
Player(Ogre::Camera *camera);
|
||||
~Player();
|
||||
|
||||
/// Set where the player is looking at. Uses Morrowind (euler) angles
|
||||
|
@ -89,8 +88,6 @@ namespace MWRender
|
|||
void setCameraDistance();
|
||||
|
||||
void setAnimation(NpcAnimation *anim);
|
||||
NpcAnimation *getAnimation() const
|
||||
{ return mAnimation; }
|
||||
|
||||
void setHeight(float height);
|
||||
float getHeight();
|
||||
|
|
|
@ -53,8 +53,9 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,MWWorld::Fallback* fallback)
|
||||
: mRendering(_rend)
|
||||
, mFallback(fallback)
|
||||
, mObjects(mRendering,mFallback)
|
||||
, mObjects(mRendering, mFallback)
|
||||
, mActors(mRendering, this)
|
||||
, mPlayerAnimation(NULL)
|
||||
, mAmbientMode(0)
|
||||
, mSunEnabled(0)
|
||||
, mPhysicsEngine(engine)
|
||||
|
@ -148,14 +149,13 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
|
||||
applyCompositors();
|
||||
|
||||
SceneNode *rt = mRendering.getScene()->getRootSceneNode();
|
||||
mRootNode = rt;
|
||||
mRootNode = mRendering.getScene()->getRootSceneNode();
|
||||
mRootNode->createChildSceneNode("player");
|
||||
|
||||
mObjects.setRootNode(mRootNode);
|
||||
mActors.setRootNode(mRootNode);
|
||||
|
||||
Ogre::SceneNode *playerNode = mRootNode->createChildSceneNode ("player");
|
||||
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
|
||||
mPlayer = new MWRender::Player(mRendering.getCamera());
|
||||
|
||||
mShadows = new Shadows(&mRendering);
|
||||
|
||||
|
@ -183,6 +183,7 @@ RenderingManager::~RenderingManager ()
|
|||
mRendering.getWindow()->removeListener(this);
|
||||
mRendering.removeWindowEventListener(this);
|
||||
|
||||
delete mPlayerAnimation;
|
||||
delete mPlayer;
|
||||
delete mSkyManager;
|
||||
delete mDebugging;
|
||||
|
@ -866,14 +867,23 @@ void RenderingManager::setupPlayer(const MWWorld::Ptr &ptr)
|
|||
|
||||
void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
MWRender::NpcAnimation *anim =
|
||||
new MWRender::NpcAnimation(
|
||||
ptr, ptr.getRefData ().getBaseNode (),
|
||||
MWWorld::Class::get(ptr).getInventoryStore(ptr), RV_Actors
|
||||
);
|
||||
mPlayer->setAnimation(anim);
|
||||
mWater->removeEmitter (ptr);
|
||||
mWater->addEmitter (ptr);
|
||||
if(!mPlayerAnimation)
|
||||
{
|
||||
mPlayerAnimation = new NpcAnimation(ptr, ptr.getRefData().getBaseNode(),
|
||||
MWWorld::Class::get(ptr).getInventoryStore(ptr),
|
||||
RV_Actors);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reconstruct the NpcAnimation in-place
|
||||
mPlayerAnimation->~NpcAnimation();
|
||||
new(mPlayerAnimation) NpcAnimation(ptr, ptr.getRefData().getBaseNode(),
|
||||
MWWorld::Class::get(ptr).getInventoryStore(ptr),
|
||||
RV_Actors);
|
||||
}
|
||||
mPlayer->setAnimation(mPlayerAnimation);
|
||||
mWater->removeEmitter(ptr);
|
||||
mWater->addEmitter(ptr);
|
||||
// apply race height
|
||||
MWBase::Environment::get().getWorld()->scaleObject(ptr, 1.f);
|
||||
}
|
||||
|
@ -914,7 +924,7 @@ Animation* RenderingManager::getAnimation(const MWWorld::Ptr &ptr)
|
|||
{
|
||||
Animation *anim = mActors.getAnimation(ptr);
|
||||
if(!anim && ptr.getRefData().getHandle() == "player")
|
||||
anim = mPlayer->getAnimation();
|
||||
anim = mPlayerAnimation;
|
||||
return anim;
|
||||
}
|
||||
|
||||
|
|
|
@ -238,6 +238,8 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
|||
MWRender::Objects mObjects;
|
||||
MWRender::Actors mActors;
|
||||
|
||||
MWRender::NpcAnimation *mPlayerAnimation;
|
||||
|
||||
// 0 normal, 1 more bright, 2 max
|
||||
int mAmbientMode;
|
||||
|
||||
|
|
Loading…
Reference in a new issue