Merge pull request #141 from OpenMW/master

Add OpenMW commits up to 5 Feb 2017
coverity_scan^2
David Cernat 8 years ago committed by GitHub
commit 3a29b2d41d

@ -67,20 +67,30 @@ namespace MWGui
void ItemWidget::setIcon(const std::string &icon) void ItemWidget::setIcon(const std::string &icon)
{ {
if (mItemShadow) if (mCurrentIcon != icon)
mItemShadow->setImageTexture(icon); {
if (mItem) mCurrentIcon = icon;
mItem->setImageTexture(icon);
if (mItemShadow)
mItemShadow->setImageTexture(icon);
if (mItem)
mItem->setImageTexture(icon);
}
} }
void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord) void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord)
{ {
if (mFrame) if (mFrame)
{ {
mFrame->setImageTexture(frame);
mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug? mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug?
mFrame->setImageCoord(coord); mFrame->setImageCoord(coord);
} }
if (mCurrentFrame != frame)
{
mCurrentFrame = frame;
mFrame->setImageTexture(frame);
}
} }
void ItemWidget::setIcon(const MWWorld::Ptr &ptr) void ItemWidget::setIcon(const MWWorld::Ptr &ptr)
@ -105,6 +115,8 @@ namespace MWGui
mItemShadow->setImageTexture(""); mItemShadow->setImageTexture("");
mItem->setImageTexture(""); mItem->setImageTexture("");
mText->setCaption(""); mText->setCaption("");
mCurrentIcon.clear();
mCurrentFrame.clear();
return; return;
} }

@ -47,6 +47,9 @@ namespace MWGui
MyGUI::ImageBox* mItemShadow; MyGUI::ImageBox* mItemShadow;
MyGUI::ImageBox* mFrame; MyGUI::ImageBox* mFrame;
MyGUI::TextBox* mText; MyGUI::TextBox* mText;
std::string mCurrentIcon;
std::string mCurrentFrame;
}; };
} }

@ -401,7 +401,6 @@ namespace MWMechanics
{ {
updateDrowning(ptr, duration); updateDrowning(ptr, duration);
calculateNpcStatModifiers(ptr, duration); calculateNpcStatModifiers(ptr, duration);
updateEquippedLight(ptr, duration);
} }
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature) void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
@ -738,11 +737,19 @@ namespace MWMechanics
} }
} }
UpdateSummonedCreatures updateSummonedCreatures(ptr); bool hasSummonEffect = false;
creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures); for (MagicEffects::Collection::const_iterator it = effects.begin(); it != effects.end(); ++it)
if (ptr.getClass().hasInventoryStore(ptr)) if (it->first.mId >= ESM::MagicEffect::SummonScamp && it->first.mId <= ESM::MagicEffect::SummonStormAtronach)
ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures); hasSummonEffect = true;
updateSummonedCreatures.process();
if (!creatureStats.getSummonedCreatureMap().empty() || !creatureStats.getSummonedCreatureGraveyard().empty() || hasSummonEffect)
{
UpdateSummonedCreatures updateSummonedCreatures(ptr);
creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures);
if (ptr.getClass().hasInventoryStore(ptr))
ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures);
updateSummonedCreatures.process();
}
} }
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration) void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration)
@ -1027,10 +1034,13 @@ namespace MWMechanics
{ {
static float timerUpdateAITargets = 0; static float timerUpdateAITargets = 0;
static float timerUpdateHeadTrack = 0; static float timerUpdateHeadTrack = 0;
static float timerUpdateEquippedLight = 0;
const float updateEquippedLightInterval = 1.0f;
// target lists get updated once every 1.0 sec // target lists get updated once every 1.0 sec
if (timerUpdateAITargets >= 1.0f) timerUpdateAITargets = 0; if (timerUpdateAITargets >= 1.0f) timerUpdateAITargets = 0;
if (timerUpdateHeadTrack >= 0.3f) timerUpdateHeadTrack = 0; if (timerUpdateHeadTrack >= 0.3f) timerUpdateHeadTrack = 0;
if (timerUpdateEquippedLight >= updateEquippedLightInterval) timerUpdateEquippedLight = 0;
MWWorld::Ptr player = getPlayer(); MWWorld::Ptr player = getPlayer();
@ -1116,7 +1126,12 @@ namespace MWMechanics
} }
if(iter->first.getTypeName() == typeid(ESM::NPC).name()) if(iter->first.getTypeName() == typeid(ESM::NPC).name())
{
updateNpc(iter->first, duration); updateNpc(iter->first, duration);
if (timerUpdateEquippedLight == 0)
updateEquippedLight(iter->first, updateEquippedLightInterval);
}
} }
} }

@ -1882,10 +1882,14 @@ void CharacterController::update(float duration)
{ {
if(mHitState != CharState_KnockDown && mHitState != CharState_KnockOut) if(mHitState != CharState_KnockDown && mHitState != CharState_KnockOut)
{ {
world->rotateObject(mPtr, rot.x(), rot.y(), rot.z(), true); if (rot != osg::Vec3f())
world->rotateObject(mPtr, rot.x(), rot.y(), rot.z(), true);
} }
else //avoid z-rotating for knockdown else //avoid z-rotating for knockdown
world->rotateObject(mPtr, rot.x(), rot.y(), 0.0f, true); {
if (rot.x() != 0 && rot.y() != 0)
world->rotateObject(mPtr, rot.x(), rot.y(), 0.0f, true);
}
if (!mMovementAnimationControlled) if (!mMovementAnimationControlled)
world->queueMovement(mPtr, vec); world->queueMovement(mPtr, vec);

@ -575,6 +575,8 @@ namespace MWRender
mAccumCtrl = NULL; mAccumCtrl = NULL;
mAnimSources.clear(); mAnimSources.clear();
mAnimVelocities.clear();
} }
bool Animation::hasAnimation(const std::string &anim) const bool Animation::hasAnimation(const std::string &anim) const
@ -952,6 +954,10 @@ namespace MWRender
if (!mAccumRoot) if (!mAccumRoot)
return 0.0f; return 0.0f;
std::map<std::string, float>::const_iterator found = mAnimVelocities.find(groupname);
if (found != mAnimVelocities.end())
return found->second;
// Look in reverse; last-inserted source has priority. // Look in reverse; last-inserted source has priority.
AnimSourceList::const_reverse_iterator animsrc(mAnimSources.rbegin()); AnimSourceList::const_reverse_iterator animsrc(mAnimSources.rbegin());
for(;animsrc != mAnimSources.rend();++animsrc) for(;animsrc != mAnimSources.rend();++animsrc)
@ -999,6 +1005,8 @@ namespace MWRender
} }
} }
mAnimVelocities.insert(std::make_pair(groupname, velocity));
return velocity; return velocity;
} }

@ -274,6 +274,8 @@ protected:
float mAlpha; float mAlpha;
mutable std::map<std::string, float> mAnimVelocities;
osg::ref_ptr<SceneUtil::LightListCallback> mLightListCallback; osg::ref_ptr<SceneUtil::LightListCallback> mLightListCallback;
const NodeMap& getNodeMap() const; const NodeMap& getNodeMap() const;

@ -32,6 +32,26 @@
namespace namespace
{ {
void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, bool inverseRotationOrder)
{
if (!ptr.getRefData().getBaseNode())
return;
osg::Quat worldRotQuat(ptr.getRefData().getPosition().rot[2], osg::Vec3(0,0,-1));
if (!ptr.getClass().isActor())
{
float xr = ptr.getRefData().getPosition().rot[0];
float yr = ptr.getRefData().getPosition().rot[1];
if (!inverseRotationOrder)
worldRotQuat = worldRotQuat * osg::Quat(yr, osg::Vec3(0,-1,0)) *
osg::Quat(xr, osg::Vec3(-1,0,0));
else
worldRotQuat = osg::Quat(xr, osg::Vec3(-1,0,0)) * osg::Quat(yr, osg::Vec3(0,-1,0)) * worldRotQuat;
}
rendering.rotateObject(ptr, worldRotQuat);
}
void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
MWRender::RenderingManager& rendering) MWRender::RenderingManager& rendering)
{ {
@ -40,6 +60,8 @@ namespace
if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker") if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker")
model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player
ptr.getClass().insertObjectRendering(ptr, model, rendering); ptr.getClass().insertObjectRendering(ptr, model, rendering);
setNodeRotation(ptr, rendering, false);
ptr.getClass().insertObject (ptr, model, physics); ptr.getClass().insertObject (ptr, model, physics);
if (ptr.getClass().isActor()) if (ptr.getClass().isActor())
@ -49,23 +71,8 @@ namespace
void updateObjectRotation (const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, void updateObjectRotation (const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
MWRender::RenderingManager& rendering, bool inverseRotationOrder) MWRender::RenderingManager& rendering, bool inverseRotationOrder)
{ {
if (ptr.getRefData().getBaseNode() != NULL) setNodeRotation(ptr, rendering, inverseRotationOrder);
{ physics.updateRotation(ptr);
osg::Quat worldRotQuat(ptr.getRefData().getPosition().rot[2], osg::Vec3(0,0,-1));
if (!ptr.getClass().isActor())
{
float xr = ptr.getRefData().getPosition().rot[0];
float yr = ptr.getRefData().getPosition().rot[1];
if (!inverseRotationOrder)
worldRotQuat = worldRotQuat * osg::Quat(yr, osg::Vec3(0,-1,0)) *
osg::Quat(xr, osg::Vec3(-1,0,0));
else
worldRotQuat = osg::Quat(xr, osg::Vec3(-1,0,0)) * osg::Quat(yr, osg::Vec3(0,-1,0)) * worldRotQuat;
}
rendering.rotateObject(ptr, worldRotQuat);
physics.updateRotation(ptr);
}
} }
void updateObjectScale(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, void updateObjectScale(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
@ -133,7 +140,6 @@ namespace
try try
{ {
addObject(ptr, mPhysics, mRendering); addObject(ptr, mPhysics, mRendering);
updateObjectRotation(ptr, mPhysics, mRendering, false);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
@ -629,7 +635,6 @@ namespace MWWorld
try try
{ {
addObject(ptr, *mPhysics, mRendering); addObject(ptr, *mPhysics, mRendering);
updateObjectRotation(ptr, false);
MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().getScale()); MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().getScale());
} }
catch (std::exception& e) catch (std::exception& e)

@ -61,14 +61,14 @@
<Resource type="ResourceSkin" name="MW_EnergyBar_Magic" size="64 12"> <Resource type="ResourceSkin" name="MW_EnergyBar_Magic" size="64 12">
<Property key="TrackSkin" value="MW_BarTrack_Magic"/> <Property key="TrackSkin" value="MW_BarTrack_Magic"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_EnergyBar_Weapon" size="64 12"> <Resource type="ResourceSkin" name="MW_EnergyBar_Weapon" size="64 12">
<Property key="TrackSkin" value="MW_BarTrack_Weapon"/> <Property key="TrackSkin" value="MW_BarTrack_Weapon"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -76,7 +76,7 @@
<Resource type="ResourceSkin" name="MW_EnergyBar_Red" size="64 12"> <Resource type="ResourceSkin" name="MW_EnergyBar_Red" size="64 12">
<Property key="TrackSkin" value="MW_BarTrack_Red"/> <Property key="TrackSkin" value="MW_BarTrack_Red"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -84,7 +84,7 @@
<Resource type="ResourceSkin" name="MW_EnergyBar_Green" size="64 12"> <Resource type="ResourceSkin" name="MW_EnergyBar_Green" size="64 12">
<Property key="TrackSkin" value="MW_BarTrack_Green"/> <Property key="TrackSkin" value="MW_BarTrack_Green"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -92,7 +92,7 @@
<Resource type="ResourceSkin" name="MW_EnergyBar_Blue" size="64 12"> <Resource type="ResourceSkin" name="MW_EnergyBar_Blue" size="64 12">
<Property key="TrackSkin" value="MW_BarTrack_Blue"/> <Property key="TrackSkin" value="MW_BarTrack_Blue"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -100,7 +100,7 @@
<Resource type="ResourceSkin" name="MW_EnergyBar_Yellow" size="64 12"> <Resource type="ResourceSkin" name="MW_EnergyBar_Yellow" size="64 12">
<Property key="TrackSkin" value="MW_BarTrack_Yellow"/> <Property key="TrackSkin" value="MW_BarTrack_Yellow"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>

@ -9,6 +9,7 @@
<Property key="MinTrackSize" value="14"/> <Property key="MinTrackSize" value="14"/>
<Property key="VerticalAlignment" value="false"/> <Property key="VerticalAlignment" value="false"/>
<Property key="MoveToClick" value="true"/> <Property key="MoveToClick" value="true"/>
<Property key="TrackFill" value="1"/>
<Property key="WheelPage" value="36"/> <Property key="WheelPage" value="36"/>
<Property key="ViewPage" value="36"/> <Property key="ViewPage" value="36"/>
@ -50,6 +51,7 @@
<Property key="TrackRangeMargins" value="20 19"/> <Property key="TrackRangeMargins" value="20 19"/>
<Property key="MinTrackSize" value="14"/> <Property key="MinTrackSize" value="14"/>
<Property key="MoveToClick" value="true"/> <Property key="MoveToClick" value="true"/>
<Property key="TrackFill" value="1"/>
<Property key="WheelPage" value="36"/> <Property key="WheelPage" value="36"/>
<Property key="ViewPage" value="36"/> <Property key="ViewPage" value="36"/>

@ -54,7 +54,7 @@
<Resource type="ResourceSkin" name="MW_Progress_Red" size="64 12"> <Resource type="ResourceSkin" name="MW_Progress_Red" size="64 12">
<Property key="TrackSkin" value="MW_Track_Red"/> <Property key="TrackSkin" value="MW_Track_Red"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -62,7 +62,7 @@
<Resource type="ResourceSkin" name="MW_Progress_Green" size="64 12"> <Resource type="ResourceSkin" name="MW_Progress_Green" size="64 12">
<Property key="TrackSkin" value="MW_Track_Green"/> <Property key="TrackSkin" value="MW_Track_Green"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -70,7 +70,7 @@
<Resource type="ResourceSkin" name="MW_Progress_Blue" size="64 12"> <Resource type="ResourceSkin" name="MW_Progress_Blue" size="64 12">
<Property key="TrackSkin" value="MW_Track_Blue"/> <Property key="TrackSkin" value="MW_Track_Blue"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
@ -78,18 +78,19 @@
<Resource type="ResourceSkin" name="MW_Progress_LightBlue" size="64 6"> <Resource type="ResourceSkin" name="MW_Progress_LightBlue" size="64 6">
<Property key="TrackSkin" value="MW_BigTrack_Progress_Blue_Small"/> <Property key="TrackSkin" value="MW_BigTrack_Progress_Blue_Small"/>
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 6" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 64 6" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 2" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 2" align="Stretch" name="Client"/>
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_Progress_Drowning" size="64 6"> <Resource type="ResourceSkin" name="MW_Progress_Drowning" size="64 6">
<Child type="Widget" skin="MW_BigTrack_Progress_Red_Small" offset="0 0 64 6" align="Stretch"/> <Property key="TrackSkin" value="MW_BigTrack_Progress_Red_Small"/>
<Property key="TrackFill" value="1"/>
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_ProgressScroll_Loading" size="64 6"> <Resource type="ResourceSkin" name="MW_ProgressScroll_Loading" size="64 6">
<Property key="TrackWidth" value="1"/> <Property key="TrackFill" value="1"/>
<Property key="TrackRangeMargins" value="0 0"/> <Property key="TrackRangeMargins" value="0 0"/>
<Property key="MinTrackSize" value="1"/> <Property key="MinTrackSize" value="1"/>
<Property key="VerticalAlignment" value="false"/> <Property key="VerticalAlignment" value="false"/>

Loading…
Cancel
Save