Use the Werewolf field of view override (Fixes #3064)

Need to re-run the settings importer for the feature to work.
pull/849/head
scrawl 9 years ago
parent 9d4af59860
commit 136a425cec

@ -638,6 +638,9 @@ MwIniImporter::MwIniImporter()
"Blood:Texture Name 1",
"Blood:Texture Name 2",
// werewolf (Bloodmoon)
"General:Werewolf FOV",
0
};

@ -136,6 +136,8 @@ namespace MWRender
, mUnderwaterFog(0.f)
, mUnderwaterIndoorFog(fallback->getFallbackFloat("Water_UnderwaterIndoorFog"))
, mNightEyeFactor(0.f)
, mFieldOfViewOverride(0.f)
, mFieldOfViewOverridden(false)
{
resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem);
@ -769,7 +771,10 @@ namespace MWRender
void RenderingManager::updateProjectionMatrix()
{
double aspect = mViewer->getCamera()->getViewport()->aspectRatio();
mViewer->getCamera()->setProjectionMatrixAsPerspective(mFieldOfView, aspect, mNearClip, mViewDistance);
float fov = mFieldOfView;
if (mFieldOfViewOverridden)
fov = mFieldOfViewOverride;
mViewer->getCamera()->setProjectionMatrixAsPerspective(fov, aspect, mNearClip, mViewDistance);
}
void RenderingManager::updateTextureFiltering()
@ -912,4 +917,23 @@ namespace MWRender
mCamera->setCameraDistance(-factor/120.f*10, true, true);
}
void RenderingManager::overrideFieldOfView(float val)
{
if (mFieldOfViewOverridden != true || mFieldOfViewOverride != val)
{
mFieldOfViewOverridden = true;
mFieldOfViewOverride = val;
updateProjectionMatrix();
}
}
void RenderingManager::resetFieldOfView()
{
if (mFieldOfViewOverridden == true)
{
mFieldOfViewOverridden = false;
updateProjectionMatrix();
}
}
}

@ -170,6 +170,11 @@ namespace MWRender
void togglePlayerLooking(bool enable);
void changeVanityModeScale(float factor);
/// temporarily override the field of view with given value.
void overrideFieldOfView(float val);
/// reset a previous overrideFieldOfView() call, i.e. revert to field of view specified in the settings file.
void resetFieldOfView();
private:
void updateProjectionMatrix();
void updateTextureFiltering();
@ -208,6 +213,8 @@ namespace MWRender
float mNearClip;
float mViewDistance;
float mFieldOfViewOverride;
bool mFieldOfViewOverridden;
float mFieldOfView;
void operator = (const RenderingManager&);

@ -1565,8 +1565,20 @@ namespace MWWorld
mPlayer->setLastKnownExteriorPosition(pos.asVec3());
}
if (player.getClass().getNpcStats(player).isWerewolf())
MWBase::Environment::get().getWindowManager()->setWerewolfOverlay(mRendering->getCamera()->isFirstPerson());
bool isWerewolf = player.getClass().getNpcStats(player).isWerewolf();
bool isFirstPerson = mRendering->getCamera()->isFirstPerson();
if (isWerewolf && isFirstPerson)
{
float werewolfFov = mFallback.getFallbackFloat("General_Werewolf_FOV");
if (werewolfFov != 0)
mRendering->overrideFieldOfView(werewolfFov);
MWBase::Environment::get().getWindowManager()->setWerewolfOverlay(true);
}
else
{
mRendering->resetFieldOfView();
MWBase::Environment::get().getWindowManager()->setWerewolfOverlay(false);
}
// Sink the camera while sneaking
bool sneaking = player.getClass().getCreatureStats(getPlayerPtr()).getStance(MWMechanics::CreatureStats::Stance_Sneak);

Loading…
Cancel
Save