From 038f682510e0dc12ddbf5d15a75d6c68774cb78b Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Nov 2015 01:06:51 +0100 Subject: [PATCH 1/5] Fix SoundManager::isPlaying to consider multiple entries with the same Ptr/id Now it returns true if *any* sounds matching the given Ptr and id are playing. The previous behaviour was causing problems with "zombie" sounds (sounds that have finished playing, but weren't removed from the map yet) making the isPlaying method return false even though there's another legitimately playing sound in the map. --- apps/openmw/mwsound/soundmanagerimp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index bc97f1601..6e309e28e 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -168,8 +168,8 @@ namespace MWSound SoundMap::const_iterator snditer = mActiveSounds.begin(); while(snditer != mActiveSounds.end()) { - if(snditer->second.first == ptr && snditer->second.second == id) - return snditer->first->isPlaying(); + if(snditer->second.first == ptr && snditer->second.second == id && snditer->first->isPlaying()) + return true; ++snditer; } return false; From 966737f891d013d3ece6a6de35900399baf322fa Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Nov 2015 15:49:42 +0100 Subject: [PATCH 2/5] Set the particle scaleReferenceFrame to local space --- components/nifosg/nifloader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 3e7f47b6f..6a536d7af 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -843,6 +843,8 @@ namespace NifOsg partsys->getOrCreateUserDataContainer()->addDescription("worldspace"); } + partsys->setParticleScaleReferenceFrame(osgParticle::ParticleSystem::LOCAL_COORDINATES); + handleParticleInitialState(nifNode, partsys, partctrl); partsys->setQuota(partctrl->numParticles); From 622573f494af36af9c923e26acae7ca56226754f Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Nov 2015 15:57:12 +0100 Subject: [PATCH 3/5] Set the object node scale before inserting model This fixes initWorldSpaceParticles not taking object scale into account. Still not taking into account object rotation or node animations. Ideally the initWorldSpaceParticles needs to run in an updateCallback. --- apps/openmw/mwrender/objects.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 9f4fe2de2..40cbb6511 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -125,6 +125,11 @@ void Objects::insertBegin(const MWWorld::Ptr& ptr) insert->setPosition(osg::Vec3(f[0], f[1], f[2])); + const float scale = ptr.getCellRef().getScale(); + osg::Vec3f scaleVec(scale, scale, scale); + ptr.getClass().adjustScale(ptr, scaleVec, true); + insert->setScale(scaleVec); + ptr.getRefData().setBaseNode(insert); } From e5ce3f62b7db6e46ed8a4648fa0b04ca07410309 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 20 Nov 2015 03:22:35 +0100 Subject: [PATCH 4/5] Fix lighting incontinuity at nightfall and sunrise --- apps/openmw/mwworld/weather.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 24b45fcea..e4fdd62de 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -680,7 +680,7 @@ void WeatherManager::update(float duration, bool paused) if ( !is_night ) { theta = M_PI * (adjustedHour - mSunriseTime) / dayDuration; } else { - theta = M_PI * (adjustedHour - adjustedNightStart) / nightDuration; + theta = M_PI * (1.f - (adjustedHour - adjustedNightStart) / nightDuration); } osg::Vec3f final( From b2746c8c01794c3241bddcbb16d24efdf996e495 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 20 Nov 2015 03:29:58 +0100 Subject: [PATCH 5/5] Fix the collision shape not updating when scaling an object via script --- apps/openmw/mwphysics/physicssystem.cpp | 2 +- apps/openmw/mwworld/scene.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 55144afe7..0a687d93f 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -1062,9 +1062,9 @@ namespace MWPhysics void PhysicsSystem::updateScale(const MWWorld::Ptr &ptr) { ObjectMap::iterator found = mObjects.find(ptr); - float scale = ptr.getCellRef().getScale(); if (found != mObjects.end()) { + float scale = ptr.getCellRef().getScale(); found->second->setScale(scale); mCollisionWorld->updateSingleAabb(found->second->getCollisionObject()); return; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 1ba17a967..5598598d0 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -73,6 +73,8 @@ namespace osg::Vec3f scaleVec (scale, scale, scale); ptr.getClass().adjustScale(ptr, scaleVec, true); rendering.scaleObject(ptr, scaleVec); + + physics.updateScale(ptr); } } @@ -114,7 +116,6 @@ namespace { addObject(ptr, mPhysics, mRendering); updateObjectRotation(ptr, mPhysics, mRendering, false); - updateObjectScale(ptr, mPhysics, mRendering); ptr.getClass().adjustPosition (ptr, false); } catch (const std::exception& e)