From f14db21745e1e149e03ad029ce9a3e96208d979d Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Sun, 17 May 2020 19:52:23 +1200 Subject: [PATCH 01/28] Make disableShadowsForStateSet a no-op when shadows are disabled Otherwise the GPU has to do useless shadow comparisons when shadows are disabled. --- components/sceneutil/shadow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index a1cd1d660..8c564f224 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -69,6 +69,9 @@ namespace SceneUtil void ShadowManager::disableShadowsForStateSet(osg::ref_ptr stateset) { + if (!Settings::Manager::getBool("enable shadows", "Shadows")) + return; + int numberOfShadowMapsPerLight = Settings::Manager::getInt("number of shadow maps", "Shadows"); numberOfShadowMapsPerLight = std::max(1, std::min(numberOfShadowMapsPerLight, 8)); From e5fa457fe7bcd4d346b8d10c33e4ee6601bac37b Mon Sep 17 00:00:00 2001 From: fredzio Date: Sun, 1 Nov 2020 17:14:59 +0100 Subject: [PATCH 02/28] Properly account for interleaved move of actors. Before this change, if an actor position was changed while the physics simulation was running, the simulation result would be discarded. It is fine in case of one off event such as teleport, but in the case of scripts making use of this functionality to make lifts or conveyor (such as Sotha Sil Expanded mod) it broke actor movement. To alleviate this issue, at the end of the simulation, the position of the Actor in the world is compared to the position it had at the beginning of the simulation. A difference indicate a force move occured. In this case, the Actor mPosition and mPreviousPosition are translated by the difference of position. Since the Actor position will be really set while the next simulation runs, we save it in the mNextPosition field. --- apps/openmw/mwphysics/actor.cpp | 90 ++++++++----------- apps/openmw/mwphysics/actor.hpp | 19 ++-- apps/openmw/mwphysics/mtphysics.cpp | 53 +++++------ apps/openmw/mwphysics/mtphysics.hpp | 1 - apps/openmw/mwphysics/physicssystem.cpp | 7 +- apps/openmw/mwphysics/physicssystem.hpp | 3 +- .../mwscript/transformationextensions.cpp | 6 +- apps/openmw/mwworld/worldimp.cpp | 6 +- 8 files changed, 91 insertions(+), 94 deletions(-) diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 5caaba5c9..760e21cce 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -75,9 +75,10 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic updateRotation(); updateScale(); updatePosition(); + setPosition(mWorldPosition, true); addCollisionMask(getCollisionMask()); - commitPositionChange(); + updateCollisionObjectPosition(); } Actor::~Actor() @@ -122,88 +123,77 @@ int Actor::getCollisionMask() const void Actor::updatePosition() { - std::unique_lock lock(mPositionMutex); - osg::Vec3f position = mPtr.getRefData().getPosition().asVec3(); + std::scoped_lock lock(mPositionMutex); + mWorldPosition = mPtr.getRefData().getPosition().asVec3(); +} - mPosition = position; - mPreviousPosition = position; +osg::Vec3f Actor::getWorldPosition() const +{ + std::scoped_lock lock(mPositionMutex); + return mWorldPosition; +} - mTransformUpdatePending = true; - updateCollisionObjectPosition(); +void Actor::setNextPosition(const osg::Vec3f& position) +{ + mNextPosition = position; +} + +osg::Vec3f Actor::getNextPosition() const +{ + return mNextPosition; } void Actor::updateCollisionObjectPosition() { + std::scoped_lock lock(mPositionMutex); + mShape->setLocalScaling(Misc::Convert::toBullet(mScale)); osg::Vec3f scaledTranslation = mRotation * osg::componentMultiply(mMeshTranslation, mScale); osg::Vec3f newPosition = scaledTranslation + mPosition; mLocalTransform.setOrigin(Misc::Convert::toBullet(newPosition)); mLocalTransform.setRotation(Misc::Convert::toBullet(mRotation)); - -} - -void Actor::commitPositionChange() -{ - std::unique_lock lock(mPositionMutex); - if (mScaleUpdatePending) - { - mShape->setLocalScaling(Misc::Convert::toBullet(mScale)); - mScaleUpdatePending = false; - } - if (mTransformUpdatePending) - { - mCollisionObject->setWorldTransform(mLocalTransform); - mTransformUpdatePending = false; - } + mCollisionObject->setWorldTransform(mLocalTransform); } osg::Vec3f Actor::getCollisionObjectPosition() const { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); return Misc::Convert::toOsg(mLocalTransform.getOrigin()); } -void Actor::setPosition(const osg::Vec3f &position, bool updateCollisionObject) +void Actor::setPosition(const osg::Vec3f& position, bool reset) { - std::unique_lock lock(mPositionMutex); - if (mTransformUpdatePending) + if (reset) { - mCollisionObject->setWorldTransform(mLocalTransform); - mTransformUpdatePending = false; + mPreviousPosition = position; + mNextPosition = position; } else - { mPreviousPosition = mPosition; + mPosition = position; +} - mPosition = position; - if (updateCollisionObject) - { - updateCollisionObjectPosition(); - mCollisionObject->setWorldTransform(mLocalTransform); - } - } +void Actor::adjustPosition(const osg::Vec3f& offset) +{ + mPosition += offset; + mPreviousPosition += offset; } osg::Vec3f Actor::getPosition() const { - std::unique_lock lock(mPositionMutex); return mPosition; } osg::Vec3f Actor::getPreviousPosition() const { - std::unique_lock lock(mPositionMutex); return mPreviousPosition; } void Actor::updateRotation () { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); if (mRotation == mPtr.getRefData().getBaseNode()->getAttitude()) return; mRotation = mPtr.getRefData().getBaseNode()->getAttitude(); - - mTransformUpdatePending = true; - updateCollisionObjectPosition(); } bool Actor::isRotationallyInvariant() const @@ -213,37 +203,33 @@ bool Actor::isRotationallyInvariant() const void Actor::updateScale() { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); float scale = mPtr.getCellRef().getScale(); osg::Vec3f scaleVec(scale,scale,scale); mPtr.getClass().adjustScale(mPtr, scaleVec, false); mScale = scaleVec; - mScaleUpdatePending = true; scaleVec = osg::Vec3f(scale,scale,scale); mPtr.getClass().adjustScale(mPtr, scaleVec, true); mRenderingScale = scaleVec; - - mTransformUpdatePending = true; - updateCollisionObjectPosition(); } osg::Vec3f Actor::getHalfExtents() const { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); return osg::componentMultiply(mHalfExtents, mScale); } osg::Vec3f Actor::getOriginalHalfExtents() const { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); return mHalfExtents; } osg::Vec3f Actor::getRenderingHalfExtents() const { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); return osg::componentMultiply(mHalfExtents, mRenderingScale); } @@ -274,7 +260,7 @@ void Actor::setWalkingOnWater(bool walkingOnWater) void Actor::setCanWaterWalk(bool waterWalk) { - std::unique_lock lock(mPositionMutex); + std::scoped_lock lock(mPositionMutex); if (waterWalk != mCanWaterWalk) { mCanWaterWalk = waterWalk; diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index ef7b368b9..00ba162af 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -57,13 +57,20 @@ namespace MWPhysics bool isRotationallyInvariant() const; /** - * Set mPosition and mPreviousPosition to the position in the Ptr's RefData. This should be used + * Set mWorldPosition to the position in the Ptr's RefData. This is used by the physics simulation to account for * when an object is "instantly" moved/teleported as opposed to being moved by the physics simulation. */ void updatePosition(); + osg::Vec3f getWorldPosition() const; + + /** + * Used by the physics simulation to store the simulation result. Used in conjunction with mWorldPosition + * to account for e.g. scripted movements + */ + void setNextPosition(const osg::Vec3f& position); + osg::Vec3f getNextPosition() const; void updateCollisionObjectPosition(); - void commitPositionChange(); /** * Returns the half extents of the collision body (scaled according to collision scale) @@ -83,9 +90,9 @@ namespace MWPhysics /** * Store the current position into mPreviousPosition, then move to this position. - * Optionally, inform the physics engine about the change of position. */ - void setPosition(const osg::Vec3f& position, bool updateCollisionObject=true); + void setPosition(const osg::Vec3f& position, bool reset=false); + void adjustPosition(const osg::Vec3f& offset); osg::Vec3f getPosition() const; @@ -159,11 +166,11 @@ namespace MWPhysics osg::Vec3f mScale; osg::Vec3f mRenderingScale; + osg::Vec3f mWorldPosition; + osg::Vec3f mNextPosition; osg::Vec3f mPosition; osg::Vec3f mPreviousPosition; btTransform mLocalTransform; - bool mScaleUpdatePending; - bool mTransformUpdatePending; mutable std::mutex mPositionMutex; osg::Vec3f mForce; diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index f105efce5..1b99b4c3f 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -102,9 +102,18 @@ namespace stats.addToFallHeight(-actorData.mFallHeight); } - osg::Vec3f interpolateMovements(const MWPhysics::ActorFrameData& actorData, float timeAccum, float physicsDt) + osg::Vec3f interpolateMovements(MWPhysics::ActorFrameData& actorData, float timeAccum, float physicsDt) { const float interpolationFactor = timeAccum / physicsDt; + + // account for force change of actor's position in the main thread + const auto correction = actorData.mActorRaw->getWorldPosition() - actorData.mOrigin; + if (correction.length() != 0) + { + actorData.mActorRaw->adjustPosition(correction); + actorData.mPosition = actorData.mActorRaw->getPosition(); + } + return actorData.mPosition * interpolationFactor + actorData.mActorRaw->getPreviousPosition() * (1.f - interpolationFactor); } @@ -182,7 +191,6 @@ namespace MWPhysics mPostSimBarrier = std::make_unique(mNumThreads, [&]() { - udpateActorsAabbs(); mNewFrame = false; if (mLOSCacheExpiry >= 0) { @@ -229,6 +237,9 @@ namespace MWPhysics updateMechanics(data); if (mAdvanceSimulation) updateStandingCollision(data, standingCollisions); + + if (mMovementResults.find(data.mPtr) != mMovementResults.end()) + data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); } } @@ -245,10 +256,6 @@ namespace MWPhysics if (mAdvanceSimulation) mWorldFrameData = std::make_unique(); - // update each actor position based on latest data - for (auto& data : mActorsFrameData) - data.updatePosition(); - // we are asked to skip the simulation (load a savegame for instance) // just return the actors' reference position without applying the movements if (skipSimulation) @@ -256,7 +263,10 @@ namespace MWPhysics standingCollisions.clear(); mMovementResults.clear(); for (const auto& m : mActorsFrameData) - mMovementResults[m.mPtr] = m.mPosition; + { + m.mActorRaw->setPosition(m.mActorRaw->getWorldPosition(), true); + mMovementResults[m.mPtr] = m.mActorRaw->getWorldPosition(); + } return mMovementResults; } @@ -271,6 +281,11 @@ namespace MWPhysics for (auto& data : mActorsFrameData) updateStandingCollision(data, standingCollisions); } + for (auto& data : mActorsFrameData) + { + if (mMovementResults.find(data.mPtr) != mMovementResults.end()) + data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); + } return mMovementResults; } @@ -427,7 +442,7 @@ namespace MWPhysics { if (const auto actor = std::dynamic_pointer_cast(p)) { - actor->commitPositionChange(); + actor->updateCollisionObjectPosition(); mCollisionWorld->updateSingleAabb(actor->getCollisionObject()); } else if (const auto object = std::dynamic_pointer_cast(p)) @@ -485,28 +500,17 @@ namespace MWPhysics { if(const auto actor = actorData.mActor.lock()) { - if (actorData.mPosition == actor->getPosition()) - actor->setPosition(actorData.mPosition, false); // update previous position to make sure interpolation is correct - else + bool positionChanged = actorData.mPosition != actorData.mActorRaw->getPosition(); + actorData.mActorRaw->setPosition(actorData.mPosition); + if (positionChanged) { - actorData.mPositionChanged = true; - actor->setPosition(actorData.mPosition); + actor->updateCollisionObjectPosition(); + mCollisionWorld->updateSingleAabb(actor->getCollisionObject()); } } } } - void PhysicsTaskScheduler::udpateActorsAabbs() - { - std::unique_lock lock(mCollisionWorldMutex); - for (const auto& actorData : mActorsFrameData) - if (actorData.mPositionChanged) - { - if(const auto actor = actorData.mActor.lock()) - mCollisionWorld->updateSingleAabb(actor->getCollisionObject()); - } - } - bool PhysicsTaskScheduler::hasLineOfSight(const Actor* actor1, const Actor* actor2) { btVector3 pos1 = Misc::Convert::toBullet(actor1->getCollisionObjectPosition() + osg::Vec3f(0,0,actor1->getHalfExtents().z() * 0.9)); // eye level @@ -538,6 +542,5 @@ namespace MWPhysics mMovementResults[actorData.mPtr] = interpolateMovements(actorData, mTimeAccum, mPhysicsDt); updateMechanics(actorData); } - udpateActorsAabbs(); } } diff --git a/apps/openmw/mwphysics/mtphysics.hpp b/apps/openmw/mwphysics/mtphysics.hpp index 100e71a90..84ea93c08 100644 --- a/apps/openmw/mwphysics/mtphysics.hpp +++ b/apps/openmw/mwphysics/mtphysics.hpp @@ -49,7 +49,6 @@ namespace MWPhysics void syncComputation(); void worker(); void updateActorsPositions(); - void udpateActorsAabbs(); bool hasLineOfSight(const Actor* actor1, const Actor* actor2); void refreshLOSCache(); void updateAabbs(); diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 9a777bd45..6b94ef43b 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -883,7 +883,7 @@ namespace MWPhysics ActorFrameData::ActorFrameData(const std::shared_ptr& actor, const MWWorld::Ptr character, const MWWorld::Ptr standingOn, bool moveToWaterSurface, osg::Vec3f movement, float slowFall, float waterlevel) : mActor(actor), mActorRaw(actor.get()), mStandingOn(standingOn), - mPositionChanged(false), mDidJump(false), mNeedLand(false), mMoveToWaterSurface(moveToWaterSurface), + mDidJump(false), mNeedLand(false), mMoveToWaterSurface(moveToWaterSurface), mWaterlevel(waterlevel), mSlowFall(slowFall), mOldHeight(0), mFallHeight(0), mMovement(movement), mPosition(), mRefpos() { const MWBase::World *world = MWBase::Environment::get().getWorld(); @@ -893,10 +893,9 @@ namespace MWPhysics mWantJump = mPtr.getClass().getMovementSettings(mPtr).mPosition[2] != 0; mIsDead = mPtr.getClass().getCreatureStats(mPtr).isDead(); mWasOnGround = actor->getOnGround(); - } - void ActorFrameData::updatePosition() - { + mActorRaw->updatePosition(); + mOrigin = mActorRaw->getNextPosition(); mPosition = mActorRaw->getPosition(); if (mMoveToWaterSurface) { diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 36ef762d3..4844b5e8e 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -78,14 +78,12 @@ namespace MWPhysics struct ActorFrameData { ActorFrameData(const std::shared_ptr& actor, const MWWorld::Ptr character, const MWWorld::Ptr standingOn, bool moveToWaterSurface, osg::Vec3f movement, float slowFall, float waterlevel); - void updatePosition(); std::weak_ptr mActor; Actor* mActorRaw; MWWorld::Ptr mPtr; MWWorld::Ptr mStandingOn; bool mFlying; bool mSwimming; - bool mPositionChanged; bool mWasOnGround; bool mWantJump; bool mDidJump; @@ -97,6 +95,7 @@ namespace MWPhysics float mOldHeight; float mFallHeight; osg::Vec3f mMovement; + osg::Vec3f mOrigin; osg::Vec3f mPosition; ESM::Position mRefpos; }; diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 41df1870c..ce45729b3 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -32,7 +32,11 @@ namespace MWScript std::vector actors; MWBase::Environment::get().getWorld()->getActorsStandingOn (ptr, actors); for (auto& actor : actors) - MWBase::Environment::get().getWorld()->queueMovement(actor, diff); + { + osg::Vec3f actorPos(actor.getRefData().getPosition().asVec3()); + actorPos += diff; + MWBase::Environment::get().getWorld()->moveObject(actor, actorPos.x(), actorPos.y(), actorPos.z()); + } } template diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index be32765ad..ad6c33790 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1504,11 +1504,11 @@ namespace MWWorld const auto results = mPhysics->applyQueuedMovement(duration, mDiscardMovements); mDiscardMovements = false; - for(const auto& result : results) + for(const auto& [actor, position]: results) { // Handle player last, in case a cell transition occurs - if(result.first != getPlayerPtr()) - moveObjectImp(result.first, result.second.x(), result.second.y(), result.second.z(), false); + if(actor != getPlayerPtr()) + moveObjectImp(actor, position.x(), position.y(), position.z(), false); } const auto player = results.find(getPlayerPtr()); From d64ed6cf53f9d35edfd9dddc5521939db89cb4f5 Mon Sep 17 00:00:00 2001 From: fredzio Date: Sat, 7 Nov 2020 18:30:52 +0100 Subject: [PATCH 03/28] Get rid of the StandingActorsMap. Just embed the necessary info into Actor class. --- apps/openmw/mwphysics/actor.cpp | 14 ++++++- apps/openmw/mwphysics/actor.hpp | 4 ++ apps/openmw/mwphysics/mtphysics.cpp | 25 +++--------- apps/openmw/mwphysics/mtphysics.hpp | 2 +- apps/openmw/mwphysics/physicssystem.cpp | 51 +++++++++---------------- apps/openmw/mwphysics/physicssystem.hpp | 8 ---- 6 files changed, 40 insertions(+), 64 deletions(-) diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 760e21cce..0f3d69d21 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -19,7 +19,7 @@ namespace MWPhysics Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler) - : mCanWaterWalk(false), mWalkingOnWater(false) + : mStandingOnPtr(nullptr), mCanWaterWalk(false), mWalkingOnWater(false) , mCollisionObject(nullptr), mMeshTranslation(shape->mCollisionBoxTranslate), mHalfExtents(shape->mCollisionBoxHalfExtents) , mForce(0.f, 0.f, 0.f), mOnGround(true), mOnSlope(false) , mInternalCollisionMode(true) @@ -268,4 +268,16 @@ void Actor::setCanWaterWalk(bool waterWalk) } } +MWWorld::Ptr Actor::getStandingOnPtr() const +{ + std::scoped_lock lock(mPositionMutex); + return mStandingOnPtr; +} + +void Actor::setStandingOnPtr(const MWWorld::Ptr& ptr) +{ + std::scoped_lock lock(mPositionMutex); + mStandingOnPtr = ptr; +} + } diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index 00ba162af..6b23b31d3 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -144,7 +144,11 @@ namespace MWPhysics void setWalkingOnWater(bool walkingOnWater); bool isWalkingOnWater() const; + MWWorld::Ptr getStandingOnPtr() const; + void setStandingOnPtr(const MWWorld::Ptr& ptr); + private: + MWWorld::Ptr mStandingOnPtr; /// Removes then re-adds the collision object to the dynamics world void updateCollisionMask(); void addCollisionMask(int collisionMask); diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 1b99b4c3f..ff676413b 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -82,14 +82,6 @@ namespace ptr.getClass().getMovementSettings(ptr).mPosition[2] = 0; } - void updateStandingCollision(MWPhysics::ActorFrameData& actorData, MWPhysics::CollisionMap& standingCollisions) - { - if (!actorData.mStandingOn.isEmpty()) - standingCollisions[actorData.mPtr] = actorData.mStandingOn; - else - standingCollisions.erase(actorData.mPtr); - } - void updateMechanics(MWPhysics::ActorFrameData& actorData) { if (actorData.mDidJump) @@ -215,7 +207,7 @@ namespace MWPhysics thread.join(); } - const PtrPositionList& PhysicsTaskScheduler::moveActors(int numSteps, float timeAccum, std::vector&& actorsData, CollisionMap& standingCollisions, bool skipSimulation) + const PtrPositionList& PhysicsTaskScheduler::moveActors(int numSteps, float timeAccum, std::vector&& actorsData, bool skipSimulation) { // This function run in the main thread. // While the mSimulationMutex is held, background physics threads can't run. @@ -225,9 +217,6 @@ namespace MWPhysics // start by finishing previous background computation if (mNumThreads != 0) { - if (mAdvanceSimulation) - standingCollisions.clear(); - for (auto& data : mActorsFrameData) { // Ignore actors that were deleted while the background thread was running @@ -236,7 +225,7 @@ namespace MWPhysics updateMechanics(data); if (mAdvanceSimulation) - updateStandingCollision(data, standingCollisions); + data.mActorRaw->setStandingOnPtr(data.mStandingOn); if (mMovementResults.find(data.mPtr) != mMovementResults.end()) data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); @@ -260,10 +249,10 @@ namespace MWPhysics // just return the actors' reference position without applying the movements if (skipSimulation) { - standingCollisions.clear(); mMovementResults.clear(); for (const auto& m : mActorsFrameData) { + m.mActorRaw->setStandingOnPtr(nullptr); m.mActorRaw->setPosition(m.mActorRaw->getWorldPosition(), true); mMovementResults[m.mPtr] = m.mActorRaw->getWorldPosition(); } @@ -275,14 +264,10 @@ namespace MWPhysics mMovementResults.clear(); syncComputation(); - if (mAdvanceSimulation) - { - standingCollisions.clear(); - for (auto& data : mActorsFrameData) - updateStandingCollision(data, standingCollisions); - } for (auto& data : mActorsFrameData) { + if (mAdvanceSimulation) + data.mActorRaw->setStandingOnPtr(data.mStandingOn); if (mMovementResults.find(data.mPtr) != mMovementResults.end()) data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); } diff --git a/apps/openmw/mwphysics/mtphysics.hpp b/apps/openmw/mwphysics/mtphysics.hpp index 84ea93c08..ef1c90b87 100644 --- a/apps/openmw/mwphysics/mtphysics.hpp +++ b/apps/openmw/mwphysics/mtphysics.hpp @@ -30,7 +30,7 @@ namespace MWPhysics /// @param timeAccum accumulated time from previous run to interpolate movements /// @param actorsData per actor data needed to compute new positions /// @return new position of each actor - const PtrPositionList& moveActors(int numSteps, float timeAccum, std::vector&& actorsData, CollisionMap& standingCollisions, bool skip); + const PtrPositionList& moveActors(int numSteps, float timeAccum, std::vector&& actorsData, bool skip); // Thread safe wrappers void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const; diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 6b94ef43b..5de26fdfc 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -148,11 +148,11 @@ namespace MWPhysics if (!physactor || !physactor->getOnGround()) return false; - CollisionMap::const_iterator found = mStandingCollisions.find(actor); - if (found == mStandingCollisions.end()) + const auto obj = physactor->getStandingOnPtr(); + if (obj.isEmpty()) return true; // assume standing on terrain (which is a non-object, so not collision tracked) - ObjectMap::const_iterator foundObj = mObjects.find(found->second); + ObjectMap::const_iterator foundObj = mObjects.find(obj); if (foundObj == mObjects.end()) return false; @@ -501,22 +501,6 @@ namespace MWPhysics } } - void PhysicsSystem::updateCollisionMapPtr(CollisionMap& map, const MWWorld::Ptr &old, const MWWorld::Ptr &updated) - { - CollisionMap::iterator found = map.find(old); - if (found != map.end()) - { - map[updated] = found->second; - map.erase(found); - } - - for (auto& collision : map) - { - if (collision.second == old) - collision.second = updated; - } - } - void PhysicsSystem::updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &updated) { ObjectMap::iterator found = mObjects.find(old); @@ -537,7 +521,11 @@ namespace MWPhysics mActors.emplace(updated, std::move(actor)); } - updateCollisionMapPtr(mStandingCollisions, old, updated); + for (auto& [_, actor] : mActors) + { + if (actor->getStandingOnPtr() == old) + actor->setStandingOnPtr(updated); + } } Actor *PhysicsSystem::getActor(const MWWorld::Ptr &ptr) @@ -675,7 +663,6 @@ namespace MWPhysics void PhysicsSystem::clearQueuedMovement() { mMovementQueue.clear(); - mStandingCollisions.clear(); } const PtrPositionList& PhysicsSystem::applyQueuedMovement(float dt, bool skipSimulation) @@ -688,7 +675,7 @@ namespace MWPhysics mTimeAccum -= numSteps * mPhysicsDt; - return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), mStandingCollisions, skipSimulation); + return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), skipSimulation); } std::vector PhysicsSystem::prepareFrameData(int numSteps) @@ -700,10 +687,8 @@ namespace MWPhysics { const auto foundActor = mActors.find(character); if (foundActor == mActors.end()) // actor was already removed from the scene - { - mStandingCollisions.erase(character); continue; - } + auto physicActor = foundActor->second; float waterlevel = -std::numeric_limits::max(); @@ -734,7 +719,7 @@ namespace MWPhysics // Ue current value only if we don't advance the simulation. Otherwise we might get a stale value. MWWorld::Ptr standingOn; if (numSteps == 0) - standingOn = mStandingCollisions[character]; + standingOn = physicActor->getStandingOnPtr(); actorsFrameData.emplace_back(std::move(physicActor), character, standingOn, moveToWaterSurface, movement, slowFall, waterlevel); } @@ -774,20 +759,18 @@ namespace MWPhysics bool PhysicsSystem::isActorStandingOn(const MWWorld::Ptr &actor, const MWWorld::ConstPtr &object) const { - for (const auto& standingActor : mStandingCollisions) - { - if (standingActor.first == actor && standingActor.second == object) - return true; - } + const auto physActor = mActors.find(actor); + if (physActor != mActors.end()) + return physActor->second->getStandingOnPtr() == object; return false; } void PhysicsSystem::getActorsStandingOn(const MWWorld::ConstPtr &object, std::vector &out) const { - for (const auto& standingActor : mStandingCollisions) + for (const auto& [_, actor] : mActors) { - if (standingActor.second == object) - out.push_back(standingActor.first); + if (actor->getStandingOnPtr() == object) + out.emplace_back(actor->getPtr()); } } diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 4844b5e8e..ccfca5422 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -50,7 +50,6 @@ class btVector3; namespace MWPhysics { using PtrPositionList = std::map; - using CollisionMap = std::map; class HeightField; class Object; @@ -272,13 +271,6 @@ namespace MWPhysics bool mDebugDrawEnabled; - // Tracks standing collisions happening during a single frame. - // This will detect standing on an object, but won't detect running e.g. against a wall. - CollisionMap mStandingCollisions; - - // replaces all occurrences of 'old' in the map by 'updated', no matter if it's a key or value - void updateCollisionMapPtr(CollisionMap& map, const MWWorld::Ptr &old, const MWWorld::Ptr &updated); - using PtrVelocityList = std::vector>; PtrVelocityList mMovementQueue; From bb5213670c41634c666dd705e196832c74b8aa52 Mon Sep 17 00:00:00 2001 From: Frederic Chardon Date: Mon, 16 Nov 2020 11:09:08 +0100 Subject: [PATCH 04/28] Use bigger hammer to set Actor's position after teleporting. Otherwise traceDown() would use old collision object transform and gives incorrect results, making the Actor "fall" in the new position. --- apps/openmw/mwphysics/actor.cpp | 24 ++++++++++++------------ apps/openmw/mwphysics/actor.hpp | 3 ++- apps/openmw/mwphysics/mtphysics.cpp | 2 +- apps/openmw/mwphysics/physicssystem.cpp | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 0f3d69d21..430bd4dee 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -74,11 +74,8 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic updateRotation(); updateScale(); - updatePosition(); - setPosition(mWorldPosition, true); - + resetPosition(); addCollisionMask(getCollisionMask()); - updateCollisionObjectPosition(); } Actor::~Actor() @@ -160,15 +157,9 @@ osg::Vec3f Actor::getCollisionObjectPosition() const return Misc::Convert::toOsg(mLocalTransform.getOrigin()); } -void Actor::setPosition(const osg::Vec3f& position, bool reset) +void Actor::setPosition(const osg::Vec3f& position) { - if (reset) - { - mPreviousPosition = position; - mNextPosition = position; - } - else - mPreviousPosition = mPosition; + mPreviousPosition = mPosition; mPosition = position; } @@ -178,6 +169,15 @@ void Actor::adjustPosition(const osg::Vec3f& offset) mPreviousPosition += offset; } +void Actor::resetPosition() +{ + updatePosition(); + mPreviousPosition = mWorldPosition; + mPosition = mWorldPosition; + mNextPosition = mWorldPosition; + updateCollisionObjectPosition(); +} + osg::Vec3f Actor::getPosition() const { return mPosition; diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index 6b23b31d3..3d6f93ae0 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -91,7 +91,8 @@ namespace MWPhysics /** * Store the current position into mPreviousPosition, then move to this position. */ - void setPosition(const osg::Vec3f& position, bool reset=false); + void setPosition(const osg::Vec3f& position); + void resetPosition(); void adjustPosition(const osg::Vec3f& offset); osg::Vec3f getPosition() const; diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index ff676413b..dbb714fac 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -253,7 +253,7 @@ namespace MWPhysics for (const auto& m : mActorsFrameData) { m.mActorRaw->setStandingOnPtr(nullptr); - m.mActorRaw->setPosition(m.mActorRaw->getWorldPosition(), true); + m.mActorRaw->resetPosition(); mMovementResults[m.mPtr] = m.mActorRaw->getWorldPosition(); } return mMovementResults; diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 5de26fdfc..42ead3606 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -433,8 +433,8 @@ namespace MWPhysics ActorMap::iterator found = mActors.find(ptr); if (found == mActors.end()) return ptr.getRefData().getPosition().asVec3(); - else - return MovementSolver::traceDown(ptr, position, found->second.get(), mCollisionWorld.get(), maxHeight); + found->second->resetPosition(); + return MovementSolver::traceDown(ptr, position, found->second.get(), mCollisionWorld.get(), maxHeight); } void PhysicsSystem::addHeightField (const float* heights, int x, int y, float triSize, float sqrtVerts, float minH, float maxH, const osg::Object* holdObject) From 7768556ce64c240bdcf361910e6520b2e32b224f Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Mon, 16 Nov 2020 21:01:20 +0000 Subject: [PATCH 05/28] Set dummy state when disabling shadows indoors As we don't reconfigure all shaders without shadows when we disable them indoors (as it'd probably add a hitch to transitioning in and out) we need to set up dummy state so the shaders don't do anything illegal. This hadn't had symptoms for most objects as when indoors, nearly everything would be drawn first in one of the water RTTs, which had dummy state to disable shadows already. This wasn't true of the water plane itself, though, yet somehow it took until just now for anyone to report that. This resolves vtastek's issue where the water would be invisible indoors --- components/sceneutil/mwshadowtechnique.cpp | 26 +++++++++++++++++++++- components/sceneutil/mwshadowtechnique.hpp | 3 ++- components/sceneutil/shadow.cpp | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index 0411dbc43..c49a14777 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -820,9 +820,10 @@ void MWShadowTechnique::enableShadows() _enableShadows = true; } -void MWShadowTechnique::disableShadows() +void MWShadowTechnique::disableShadows(bool setDummyState) { _enableShadows = false; + mSetDummyStateWhenDisabled = setDummyState; } void SceneUtil::MWShadowTechnique::enableDebugHUD() @@ -914,7 +915,28 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) { if (!_enableShadows) { + if (mSetDummyStateWhenDisabled) + { + osg::ref_ptr dummyState = new osg::StateSet(); + + ShadowSettings* settings = getShadowedScene()->getShadowSettings(); + int baseUnit = settings->getBaseShadowTextureUnit(); + int endUnit = baseUnit + settings->getNumShadowMapsPerLight(); + for (int i = baseUnit; i < endUnit; ++i) + { + dummyState->setTextureAttributeAndModes(i, _fallbackShadowMapTexture, osg::StateAttribute::ON); + dummyState->addUniform(new osg::Uniform(("shadowTexture" + std::to_string(i - baseUnit)).c_str(), i)); + dummyState->addUniform(new osg::Uniform(("shadowTextureUnit" + std::to_string(i - baseUnit)).c_str(), i)); + } + + cv.pushStateSet(dummyState); + } + _shadowedScene->osg::Group::traverse(cv); + + if (mSetDummyStateWhenDisabled) + cv.popStateSet(); + return; } @@ -1577,6 +1599,8 @@ void MWShadowTechnique::createShaders() _fallbackShadowMapTexture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT); _fallbackShadowMapTexture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); _fallbackShadowMapTexture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); + _fallbackShadowMapTexture->setShadowComparison(true); + _fallbackShadowMapTexture->setShadowCompareFunc(osg::Texture::ShadowCompareFunc::ALWAYS); } diff --git a/components/sceneutil/mwshadowtechnique.hpp b/components/sceneutil/mwshadowtechnique.hpp index a7208cfa6..5125247dd 100644 --- a/components/sceneutil/mwshadowtechnique.hpp +++ b/components/sceneutil/mwshadowtechnique.hpp @@ -67,7 +67,7 @@ namespace SceneUtil { virtual void enableShadows(); - virtual void disableShadows(); + virtual void disableShadows(bool setDummyState = false); virtual void enableDebugHUD(); @@ -252,6 +252,7 @@ namespace SceneUtil { osg::ref_ptr _program; bool _enableShadows; + bool mSetDummyStateWhenDisabled; double _splitPointUniformLogRatio = 0.5; double _splitPointDeltaBias = 0.0; diff --git a/components/sceneutil/shadow.cpp b/components/sceneutil/shadow.cpp index 1e14fbbb1..35646b834 100644 --- a/components/sceneutil/shadow.cpp +++ b/components/sceneutil/shadow.cpp @@ -168,7 +168,7 @@ namespace SceneUtil if (Settings::Manager::getBool("enable indoor shadows", "Shadows")) mShadowSettings->setCastsShadowTraversalMask(mIndoorShadowCastingMask); else - mShadowTechnique->disableShadows(); + mShadowTechnique->disableShadows(true); } void ShadowManager::enableOutdoorMode() From 06ae2a0536274b45fc04d0b1a1a3585fda25ac3a Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Mon, 16 Nov 2020 21:07:30 +0000 Subject: [PATCH 06/28] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f19783ef..51babd907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Bug #5644: Summon effects running on the player during game initialization cause crashes Bug #5656: Sneaking characters block hits while standing Bug #5661: Region sounds don't play at the right interval + Bug #5688: Water shader broken indoors with enable indoor shadows = false Feature #390: 3rd person look "over the shoulder" Feature #2386: Distant Statics in the form of Object Paging Feature #2404: Levelled List can not be placed into a container From 211894a178481ff4ae5434840e4da1bbacf32247 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 17 Nov 2020 16:14:05 +0000 Subject: [PATCH 07/28] Fix extraction with 7z 9.10 This is still used in the wild as lots of people install 7zip and never update it because it works. We can't check the version and abort if it's too old as the changelog doesn't make it clear which version fixed the behaviour. --- CI/before_script.msvc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index 2a0db9c91..0ef67f47e 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -913,7 +913,7 @@ printf "LZ4 1.9.2... " printf "Exists. " elif [ -z $SKIP_EXTRACT ]; then rm -rf LZ4_1.9.2 - eval 7z x -y lz4_win${BITS}_v1_9_2.7z -o./LZ4_1.9.2 $STRIP + eval 7z x -y lz4_win${BITS}_v1_9_2.7z -o$(real_pwd)/LZ4_1.9.2 $STRIP fi export LZ4DIR="$(real_pwd)/LZ4_1.9.2" add_cmake_opts -DLZ4_INCLUDE_DIR="${LZ4DIR}/include" \ From 48ea9960b92c2e31c6888e04775aae8aaab4981a Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 17 Nov 2020 16:45:13 +0000 Subject: [PATCH 08/28] Fix Debian GCC timeout on forks --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25a04d536..810e23d38 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,8 @@ Debian_GCC: CC: gcc CXX: g++ CCACHE_SIZE: 3G + # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. + timeout: 2h Debian_GCC_tests: extends: .Debian From 06d1e70aacba6b18a9751e99db5625dc4a7e39ff Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 18 Nov 2020 15:34:21 +0000 Subject: [PATCH 09/28] Make Bullet DebugDrawer's default state match the physics system --- apps/openmw/mwphysics/physicssystem.cpp | 2 +- apps/openmw/mwrender/bulletdebugdraw.cpp | 8 +++----- apps/openmw/mwrender/bulletdebugdraw.hpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 42ead3606..8a58919ca 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -93,7 +93,7 @@ namespace MWPhysics } mTaskScheduler = std::make_unique(mPhysicsDt, mCollisionWorld); - mDebugDrawer = std::make_unique(mParentNode, mCollisionWorld.get()); + mDebugDrawer = std::make_unique(mParentNode, mCollisionWorld.get(), mDebugDrawEnabled); } PhysicsSystem::~PhysicsSystem() diff --git a/apps/openmw/mwrender/bulletdebugdraw.cpp b/apps/openmw/mwrender/bulletdebugdraw.cpp index 61570be45..00529ef80 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.cpp +++ b/apps/openmw/mwrender/bulletdebugdraw.cpp @@ -14,13 +14,11 @@ namespace MWRender { -DebugDrawer::DebugDrawer(osg::ref_ptr parentNode, btCollisionWorld *world) +DebugDrawer::DebugDrawer(osg::ref_ptr parentNode, btCollisionWorld *world, int debugMode) : mParentNode(parentNode), - mWorld(world), - mDebugOn(true) + mWorld(world) { - - createGeometry(); + setDebugMode(debugMode); } void DebugDrawer::createGeometry() diff --git a/apps/openmw/mwrender/bulletdebugdraw.hpp b/apps/openmw/mwrender/bulletdebugdraw.hpp index f07ce2e2e..ec421bd74 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.hpp +++ b/apps/openmw/mwrender/bulletdebugdraw.hpp @@ -48,7 +48,7 @@ protected: public: - DebugDrawer(osg::ref_ptr parentNode, btCollisionWorld *world); + DebugDrawer(osg::ref_ptr parentNode, btCollisionWorld *world, int debugMode = 1); ~DebugDrawer(); void step(); From c126d8801f938c6b188d8ab4bd708a9f4e48ba82 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 18 Nov 2020 17:28:09 +0100 Subject: [PATCH 10/28] Fix #5689 --- apps/openmw/mwstate/statemanagerimp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index e409e5b3b..72e4b1ae0 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -48,8 +48,8 @@ void MWState::StateManager::cleanup (bool force) MWBase::Environment::get().getDialogueManager()->clear(); MWBase::Environment::get().getJournal()->clear(); MWBase::Environment::get().getScriptManager()->clear(); - MWBase::Environment::get().getWorld()->clear(); MWBase::Environment::get().getWindowManager()->clear(); + MWBase::Environment::get().getWorld()->clear(); MWBase::Environment::get().getInputManager()->clear(); MWBase::Environment::get().getMechanicsManager()->clear(); From 9363bc2d4825705fcf8c60f42b150828b3ba332b Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 18 Nov 2020 18:03:29 +0100 Subject: [PATCH 11/28] Update recastnavigation to 6624e7aef5e15df11cb2f5673574df8e4c96af6a --- extern/recastnavigation/.id | 2 +- extern/recastnavigation/CMakeLists.txt | 6 ++++++ .../DebugUtils/CMakeLists.txt | 19 ++++++++++--------- extern/recastnavigation/Detour/CMakeLists.txt | 19 ++++++++++--------- .../DetourCrowd/CMakeLists.txt | 19 ++++++++++--------- .../DetourCrowd/Source/DetourCrowd.cpp | 8 +++++--- .../DetourTileCache/CMakeLists.txt | 19 ++++++++++--------- extern/recastnavigation/Recast/CMakeLists.txt | 19 ++++++++++--------- 8 files changed, 62 insertions(+), 49 deletions(-) diff --git a/extern/recastnavigation/.id b/extern/recastnavigation/.id index 81e564671..b53727263 100644 --- a/extern/recastnavigation/.id +++ b/extern/recastnavigation/.id @@ -1 +1 @@ -57610fa6ef31b39020231906f8c5d40eaa8294ae +6624e7aef5e15df11cb2f5673574df8e4c96af6a diff --git a/extern/recastnavigation/CMakeLists.txt b/extern/recastnavigation/CMakeLists.txt index 0d31c2e36..cf35af1e8 100644 --- a/extern/recastnavigation/CMakeLists.txt +++ b/extern/recastnavigation/CMakeLists.txt @@ -13,6 +13,12 @@ SET(VERSION 1.0.0) option(RECASTNAVIGATION_STATIC "Build static libraries" ON) +if(MSVC AND BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + +include(GNUInstallDirs) + add_subdirectory(DebugUtils) add_subdirectory(Detour) add_subdirectory(DetourCrowd) diff --git a/extern/recastnavigation/DebugUtils/CMakeLists.txt b/extern/recastnavigation/DebugUtils/CMakeLists.txt index 8b6a3fcf6..21d8f8f9d 100644 --- a/extern/recastnavigation/DebugUtils/CMakeLists.txt +++ b/extern/recastnavigation/DebugUtils/CMakeLists.txt @@ -1,12 +1,8 @@ file(GLOB SOURCES Source/*.cpp) - -if (RECASTNAVIGATION_STATIC) - add_library(DebugUtils STATIC ${SOURCES}) -else() - add_library(DebugUtils SHARED ${SOURCES}) -endif() +add_library(DebugUtils ${SOURCES}) add_library(RecastNavigation::DebugUtils ALIAS DebugUtils) +set_target_properties(DebugUtils PROPERTIES DEBUG_POSTFIX -d) set(DebugUtils_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include") @@ -23,13 +19,18 @@ target_link_libraries(DebugUtils set_target_properties(DebugUtils PROPERTIES SOVERSION ${SOVERSION} VERSION ${VERSION} + COMPILE_PDB_OUTPUT_DIRECTORY . + COMPILE_PDB_NAME "DebugUtils-d" ) install(TARGETS DebugUtils - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) file(GLOB INCLUDES Include/*.h) -install(FILES ${INCLUDES} DESTINATION include) +install(FILES ${INCLUDES} DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation) +install(FILES "$/DebugUtils-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib") diff --git a/extern/recastnavigation/Detour/CMakeLists.txt b/extern/recastnavigation/Detour/CMakeLists.txt index de88111d5..5cb47ec0e 100644 --- a/extern/recastnavigation/Detour/CMakeLists.txt +++ b/extern/recastnavigation/Detour/CMakeLists.txt @@ -1,12 +1,8 @@ file(GLOB SOURCES Source/*.cpp) - -if(RECASTNAVIGATION_STATIC) - add_library(Detour STATIC ${SOURCES}) -else() - add_library(Detour SHARED ${SOURCES}) -endif() +add_library(Detour ${SOURCES}) add_library(RecastNavigation::Detour ALIAS Detour) +set_target_properties(Detour PROPERTIES DEBUG_POSTFIX -d) set(Detour_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include") @@ -17,13 +13,18 @@ target_include_directories(Detour PUBLIC set_target_properties(Detour PROPERTIES SOVERSION ${SOVERSION} VERSION ${VERSION} + COMPILE_PDB_OUTPUT_DIRECTORY . + COMPILE_PDB_NAME "Detour-d" ) install(TARGETS Detour - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) file(GLOB INCLUDES Include/*.h) -install(FILES ${INCLUDES} DESTINATION include) +install(FILES ${INCLUDES} DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation) +install(FILES "$/Detour-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib") diff --git a/extern/recastnavigation/DetourCrowd/CMakeLists.txt b/extern/recastnavigation/DetourCrowd/CMakeLists.txt index 73cdf7ce8..d0e186be0 100644 --- a/extern/recastnavigation/DetourCrowd/CMakeLists.txt +++ b/extern/recastnavigation/DetourCrowd/CMakeLists.txt @@ -1,12 +1,8 @@ file(GLOB SOURCES Source/*.cpp) - -if (RECASTNAVIGATION_STATIC) - add_library(DetourCrowd STATIC ${SOURCES}) -else () - add_library(DetourCrowd SHARED ${SOURCES}) -endif () +add_library(DetourCrowd ${SOURCES}) add_library(RecastNavigation::DetourCrowd ALIAS DetourCrowd) +set_target_properties(DetourCrowd PROPERTIES DEBUG_POSTFIX -d) set(DetourCrowd_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include") @@ -21,13 +17,18 @@ target_link_libraries(DetourCrowd set_target_properties(DetourCrowd PROPERTIES SOVERSION ${SOVERSION} VERSION ${VERSION} + COMPILE_PDB_OUTPUT_DIRECTORY . + COMPILE_PDB_NAME "DetourCrowd-d" ) install(TARGETS DetourCrowd - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) file(GLOB INCLUDES Include/*.h) -install(FILES ${INCLUDES} DESTINATION include) +install(FILES ${INCLUDES} DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation) +install(FILES "$/DetourCrowd-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib") diff --git a/extern/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp b/extern/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp index 1e76e40ce..3f0311f7f 100644 --- a/extern/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp +++ b/extern/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp @@ -1409,12 +1409,14 @@ void dtCrowd::update(const float dt, dtCrowdAgentDebugInfo* debug) } // Update agents using off-mesh connection. - for (int i = 0; i < m_maxAgents; ++i) + for (int i = 0; i < nagents; ++i) { - dtCrowdAgentAnimation* anim = &m_agentAnims[i]; + dtCrowdAgent* ag = agents[i]; + const int idx = (int)(ag - m_agents); + dtCrowdAgentAnimation* anim = &m_agentAnims[idx]; if (!anim->active) continue; - dtCrowdAgent* ag = agents[i]; + anim->t += dt; if (anim->t > anim->tmax) diff --git a/extern/recastnavigation/DetourTileCache/CMakeLists.txt b/extern/recastnavigation/DetourTileCache/CMakeLists.txt index 121b8edcc..3703ebb92 100644 --- a/extern/recastnavigation/DetourTileCache/CMakeLists.txt +++ b/extern/recastnavigation/DetourTileCache/CMakeLists.txt @@ -1,12 +1,8 @@ file(GLOB SOURCES Source/*.cpp) - -if (RECASTNAVIGATION_STATIC) - add_library(DetourTileCache STATIC ${SOURCES}) -else () - add_library(DetourTileCache SHARED ${SOURCES}) -endif () +add_library(DetourTileCache ${SOURCES}) add_library(RecastNavigation::DetourTileCache ALIAS DetourTileCache) +set_target_properties(DetourTileCache PROPERTIES DEBUG_POSTFIX -d) set(DetourTileCache_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include") @@ -21,14 +17,19 @@ target_link_libraries(DetourTileCache set_target_properties(DetourTileCache PROPERTIES SOVERSION ${SOVERSION} VERSION ${VERSION} + COMPILE_PDB_OUTPUT_DIRECTORY . + COMPILE_PDB_NAME "DetourTileCache-d" ) install(TARGETS DetourTileCache - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) file(GLOB INCLUDES Include/*.h) -install(FILES ${INCLUDES} DESTINATION include) +install(FILES ${INCLUDES} DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation) +install(FILES "$/DetourTileCache-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib") diff --git a/extern/recastnavigation/Recast/CMakeLists.txt b/extern/recastnavigation/Recast/CMakeLists.txt index 5e843762e..360654464 100644 --- a/extern/recastnavigation/Recast/CMakeLists.txt +++ b/extern/recastnavigation/Recast/CMakeLists.txt @@ -1,12 +1,8 @@ file(GLOB SOURCES Source/*.cpp) - -if (RECASTNAVIGATION_STATIC) - add_library(Recast STATIC ${SOURCES}) -else () - add_library(Recast SHARED ${SOURCES}) -endif () +add_library(Recast ${SOURCES}) add_library(RecastNavigation::Recast ALIAS Recast) +set_target_properties(Recast PROPERTIES DEBUG_POSTFIX -d) set(Recast_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include") @@ -17,13 +13,18 @@ target_include_directories(Recast PUBLIC set_target_properties(Recast PROPERTIES SOVERSION ${SOVERSION} VERSION ${VERSION} + COMPILE_PDB_OUTPUT_DIRECTORY . + COMPILE_PDB_NAME "Recast-d" ) install(TARGETS Recast - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) file(GLOB INCLUDES Include/*.h) -install(FILES ${INCLUDES} DESTINATION include) +install(FILES ${INCLUDES} DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/recastnavigation) +install(FILES "$/Recast-d.pdb" CONFIGURATIONS "Debug" DESTINATION "lib") From 9b11b8a27b42782ea528b1b2f5e2f884352bdb13 Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 18 Nov 2020 18:52:00 +0100 Subject: [PATCH 12/28] Fix boundary check --- components/detournavigator/chunkytrimesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/detournavigator/chunkytrimesh.cpp b/components/detournavigator/chunkytrimesh.cpp index 3a8fc3480..ffd39d0a9 100644 --- a/components/detournavigator/chunkytrimesh.cpp +++ b/components/detournavigator/chunkytrimesh.cpp @@ -51,7 +51,7 @@ namespace DetourNavigator const auto inum = imax - imin; const auto icur = curNode; - if (curNode > nodes.size()) + if (curNode >= nodes.size()) return; ChunkyTriMeshNode& node = nodes[curNode++]; From f78a5d795c0395c48d441989ddaeaffb6eae02d4 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Wed, 18 Nov 2020 22:48:47 +0200 Subject: [PATCH 13/28] Separate keyframes logic to provide basis for osgAnimation integration. --- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwmechanics/character.hpp | 2 +- apps/openmw/mwrender/animation.cpp | 43 ++++++------ apps/openmw/mwrender/animation.hpp | 20 +++--- apps/openmw/mwrender/npcanimation.cpp | 5 +- components/nifosg/controller.cpp | 3 +- components/nifosg/controller.hpp | 6 +- components/nifosg/nifloader.cpp | 18 ++--- components/nifosg/nifloader.hpp | 38 +---------- components/resource/keyframemanager.cpp | 53 +++++++++++++-- components/resource/keyframemanager.hpp | 10 ++- components/resource/resourcesystem.cpp | 2 +- components/sceneutil/keyframe.hpp | 68 +++++++++++++++++++ .../{nifosg => sceneutil}/textkeymap.hpp | 6 +- 14 files changed, 174 insertions(+), 102 deletions(-) create mode 100644 components/sceneutil/keyframe.hpp rename components/{nifosg => sceneutil}/textkeymap.hpp (94%) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 657f2e2ec..9b3c8576e 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -936,7 +936,7 @@ void split(const std::string &s, char delim, std::vector &elems) { } } -void CharacterController::handleTextKey(const std::string &groupname, NifOsg::TextKeyMap::ConstIterator key, const NifOsg::TextKeyMap& map) +void CharacterController::handleTextKey(const std::string &groupname, SceneUtil::TextKeyMap::ConstIterator key, const SceneUtil::TextKeyMap& map) { const std::string &evt = key->second; diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index 949affcfd..2308ba971 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -241,7 +241,7 @@ public: CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim); virtual ~CharacterController(); - void handleTextKey(const std::string &groupname, NifOsg::TextKeyMap::ConstIterator key, const NifOsg::TextKeyMap& map) override; + void handleTextKey(const std::string &groupname, SceneUtil::TextKeyMap::ConstIterator key, const SceneUtil::TextKeyMap& map) override; // Be careful when to call this, see comment in Actors void updateContinuousVfx(); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 10a6b2be4..f8ff3780d 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -20,8 +20,7 @@ #include #include -#include // KeyframeHolder -#include +#include #include @@ -148,7 +147,7 @@ namespace } }; - float calcAnimVelocity(const NifOsg::TextKeyMap& keys, NifOsg::KeyframeController *nonaccumctrl, + float calcAnimVelocity(const SceneUtil::TextKeyMap& keys, SceneUtil::KeyframeController *nonaccumctrl, const osg::Vec3f& accum, const std::string &groupname) { const std::string start = groupname+": start"; @@ -530,13 +529,13 @@ namespace MWRender struct Animation::AnimSource { - osg::ref_ptr mKeyframes; + osg::ref_ptr mKeyframes; - typedef std::map > ControllerMap; + typedef std::map > ControllerMap; ControllerMap mControllerMap[Animation::sNumBlendMasks]; - const NifOsg::TextKeyMap& getTextKeys() const; + const SceneUtil::TextKeyMap& getTextKeys() const; }; void UpdateVfxCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) @@ -688,7 +687,7 @@ namespace MWRender return 0; } - const NifOsg::TextKeyMap &Animation::AnimSource::getTextKeys() const + const SceneUtil::TextKeyMap &Animation::AnimSource::getTextKeys() const { return mKeyframes->mTextKeys; } @@ -729,8 +728,6 @@ namespace MWRender if(kfname.size() > 4 && kfname.compare(kfname.size()-4, 4, ".nif") == 0) kfname.replace(kfname.size()-4, 4, ".kf"); - else - return; addSingleAnimSource(kfname, baseModel); @@ -753,7 +750,7 @@ namespace MWRender const NodeMap& nodeMap = getNodeMap(); - for (NifOsg::KeyframeHolder::KeyframeControllerMap::const_iterator it = animsrc->mKeyframes->mKeyframeControllers.begin(); + for (SceneUtil::KeyframeHolder::KeyframeControllerMap::const_iterator it = animsrc->mKeyframes->mKeyframeControllers.begin(); it != animsrc->mKeyframes->mKeyframeControllers.end(); ++it) { std::string bonename = Misc::StringUtils::lowerCase(it->first); @@ -769,7 +766,7 @@ namespace MWRender size_t blendMask = detectBlendMask(node); // clone the controller, because each Animation needs its own ControllerSource - osg::ref_ptr cloned = new NifOsg::KeyframeController(*it->second, osg::CopyOp::SHALLOW_COPY); + osg::ref_ptr cloned = osg::clone(it->second.get(), osg::CopyOp::SHALLOW_COPY); cloned->setSource(mAnimationTimePtr[blendMask]); animsrc->mControllerMap[blendMask].insert(std::make_pair(bonename, cloned)); @@ -810,7 +807,7 @@ namespace MWRender AnimSourceList::const_iterator iter(mAnimSources.begin()); for(;iter != mAnimSources.end();++iter) { - const NifOsg::TextKeyMap &keys = (*iter)->getTextKeys(); + const SceneUtil::TextKeyMap &keys = (*iter)->getTextKeys(); if (keys.hasGroupStart(anim)) return true; } @@ -822,7 +819,7 @@ namespace MWRender { for(AnimSourceList::const_reverse_iterator iter(mAnimSources.rbegin()); iter != mAnimSources.rend(); ++iter) { - const NifOsg::TextKeyMap &keys = (*iter)->getTextKeys(); + const SceneUtil::TextKeyMap &keys = (*iter)->getTextKeys(); const auto found = keys.findGroupStart(groupname); if(found != keys.end()) @@ -835,7 +832,7 @@ namespace MWRender { for(AnimSourceList::const_reverse_iterator iter(mAnimSources.rbegin()); iter != mAnimSources.rend(); ++iter) { - const NifOsg::TextKeyMap &keys = (*iter)->getTextKeys(); + const SceneUtil::TextKeyMap &keys = (*iter)->getTextKeys(); for(auto iterKey = keys.begin(); iterKey != keys.end(); ++iterKey) { @@ -847,8 +844,8 @@ namespace MWRender return -1.f; } - void Animation::handleTextKey(AnimState &state, const std::string &groupname, NifOsg::TextKeyMap::ConstIterator key, - const NifOsg::TextKeyMap& map) + void Animation::handleTextKey(AnimState &state, const std::string &groupname, SceneUtil::TextKeyMap::ConstIterator key, + const SceneUtil::TextKeyMap& map) { const std::string &evt = key->second; @@ -911,7 +908,7 @@ namespace MWRender AnimSourceList::reverse_iterator iter(mAnimSources.rbegin()); for(;iter != mAnimSources.rend();++iter) { - const NifOsg::TextKeyMap &textkeys = (*iter)->getTextKeys(); + const SceneUtil::TextKeyMap &textkeys = (*iter)->getTextKeys(); if(reset(state, textkeys, groupname, start, stop, startpoint, loopfallback)) { state.mSource = *iter; @@ -956,7 +953,7 @@ namespace MWRender resetActiveGroups(); } - bool Animation::reset(AnimState &state, const NifOsg::TextKeyMap &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, bool loopfallback) + bool Animation::reset(AnimState &state, const SceneUtil::TextKeyMap &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, bool loopfallback) { // Look for text keys in reverse. This normally wouldn't matter, but for some reason undeadwolf_2.nif has two // separate walkforward keys, and the last one is supposed to be used. @@ -1186,7 +1183,7 @@ namespace MWRender AnimSourceList::const_reverse_iterator animsrc(mAnimSources.rbegin()); for(;animsrc != mAnimSources.rend();++animsrc) { - const NifOsg::TextKeyMap &keys = (*animsrc)->getTextKeys(); + const SceneUtil::TextKeyMap &keys = (*animsrc)->getTextKeys(); if (keys.hasGroupStart(groupname)) break; } @@ -1194,7 +1191,7 @@ namespace MWRender return 0.0f; float velocity = 0.0f; - const NifOsg::TextKeyMap &keys = (*animsrc)->getTextKeys(); + const SceneUtil::TextKeyMap &keys = (*animsrc)->getTextKeys(); const AnimSource::ControllerMap& ctrls = (*animsrc)->mControllerMap[0]; for (AnimSource::ControllerMap::const_iterator it = ctrls.begin(); it != ctrls.end(); ++it) @@ -1215,7 +1212,7 @@ namespace MWRender while(!(velocity > 1.0f) && ++animiter != mAnimSources.rend()) { - const NifOsg::TextKeyMap &keys2 = (*animiter)->getTextKeys(); + const SceneUtil::TextKeyMap &keys2 = (*animiter)->getTextKeys(); const AnimSource::ControllerMap& ctrls2 = (*animiter)->mControllerMap[0]; for (AnimSource::ControllerMap::const_iterator it = ctrls2.begin(); it != ctrls2.end(); ++it) @@ -1265,7 +1262,7 @@ namespace MWRender continue; } - const NifOsg::TextKeyMap &textkeys = state.mSource->getTextKeys(); + const SceneUtil::TextKeyMap &textkeys = state.mSource->getTextKeys(); auto textkey = textkeys.upperBound(state.getTime()); float timepassed = duration * state.mSpeedMult; @@ -1839,7 +1836,7 @@ namespace MWRender osg::Callback* cb = node->getUpdateCallback(); while (cb) { - if (dynamic_cast(cb)) + if (dynamic_cast(cb)) { foundKeyframeCtrl = true; break; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 9d03831be..ebfe8a2e5 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -4,8 +4,8 @@ #include "../mwworld/ptr.hpp" #include +#include #include -#include #include @@ -20,14 +20,10 @@ namespace Resource class ResourceSystem; } -namespace NifOsg +namespace SceneUtil { class KeyframeHolder; class KeyframeController; -} - -namespace SceneUtil -{ class LightSource; class LightListCallback; class Skeleton; @@ -150,8 +146,8 @@ public: class TextKeyListener { public: - virtual void handleTextKey(const std::string &groupname, NifOsg::TextKeyMap::ConstIterator key, - const NifOsg::TextKeyMap& map) = 0; + virtual void handleTextKey(const std::string &groupname, SceneUtil::TextKeyMap::ConstIterator key, + const SceneUtil::TextKeyMap& map) = 0; virtual ~TextKeyListener() = default; }; @@ -242,7 +238,7 @@ protected: osg::ref_ptr mAccumRoot; // The controller animating that node. - osg::ref_ptr mAccumCtrl; + osg::ref_ptr mAccumCtrl; // Used to reset the position of the accumulation root every frame - the movement should be applied to the physics system osg::ref_ptr mResetAccumRootCallback; @@ -306,12 +302,12 @@ protected: * the marker is not found, or if the markers are the same, it returns * false. */ - bool reset(AnimState &state, const NifOsg::TextKeyMap &keys, + bool reset(AnimState &state, const SceneUtil::TextKeyMap &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, bool loopfallback); - void handleTextKey(AnimState &state, const std::string &groupname, NifOsg::TextKeyMap::ConstIterator key, - const NifOsg::TextKeyMap& map); + void handleTextKey(AnimState &state, const std::string &groupname, SceneUtil::TextKeyMap::ConstIterator key, + const SceneUtil::TextKeyMap& map); /** Sets the root model of the object. * diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 36213fc96..d97e57115 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -19,11 +19,10 @@ #include #include #include +#include #include -#include // TextKeyMapHolder - #include #include "../mwworld/esmstore.hpp" @@ -864,7 +863,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g for (unsigned int i=0; igetUserDataContainer()->getNumUserObjects(); ++i) { osg::Object* obj = node->getUserDataContainer()->getUserObject(i); - if (NifOsg::TextKeyMapHolder* keys = dynamic_cast(obj)) + if (SceneUtil::TextKeyMapHolder* keys = dynamic_cast(obj)) { for (const auto &key : keys->mTextKeys) { diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index 64e9f7de6..31fd92b43 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -71,8 +71,7 @@ KeyframeController::KeyframeController() } KeyframeController::KeyframeController(const KeyframeController ©, const osg::CopyOp ©op) - : osg::NodeCallback(copy, copyop) - , Controller(copy) + : SceneUtil::KeyframeController(copy, copyop) , mRotations(copy.mRotations) , mXRotations(copy.mXRotations) , mYRotations(copy.mYRotations) diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index 996e4ef97..0063b2ec0 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -226,7 +226,7 @@ namespace NifOsg std::vector mKeyFrames; }; - class KeyframeController : public osg::NodeCallback, public SceneUtil::Controller + class KeyframeController : public SceneUtil::KeyframeController { public: // This is used if there's no interpolator but there is data (Morrowind meshes). @@ -242,7 +242,7 @@ namespace NifOsg META_Object(NifOsg, KeyframeController) - virtual osg::Vec3f getTranslation(float time) const; + osg::Vec3f getTranslation(float time) const override; void operator() (osg::Node*, osg::NodeVisitor*) override; diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index a5a61b317..751bdb51f 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -139,7 +139,7 @@ namespace } }; - void extractTextKeys(const Nif::NiTextKeyExtraData *tk, NifOsg::TextKeyMap &textkeys) + void extractTextKeys(const Nif::NiTextKeyExtraData *tk, SceneUtil::TextKeyMap &textkeys) { for(size_t i = 0;i < tk->list.size();i++) { @@ -234,7 +234,7 @@ namespace NifOsg // This is used to queue emitters that weren't attached to their node yet. std::vector>> mEmitterQueue; - static void loadKf(Nif::NIFFilePtr nif, KeyframeHolder& target) + static void loadKf(Nif::NIFFilePtr nif, SceneUtil::KeyframeHolder& target) { const Nif::NiSequenceStreamHelper *seq = nullptr; const size_t numRoots = nif->numRoots(); @@ -284,7 +284,7 @@ namespace NifOsg if (key->data.empty() && key->interpolator.empty()) continue; - osg::ref_ptr callback(handleKeyframeController(key)); + osg::ref_ptr callback(handleKeyframeController(key)); callback->setFunction(std::shared_ptr(new NifOsg::ControllerFunction(key))); if (!target.mKeyframeControllers.emplace(strdata->string, callback).second) @@ -305,7 +305,7 @@ namespace NifOsg if (!nifNode) nif->fail("Found no root nodes"); - osg::ref_ptr textkeys (new TextKeyMapHolder); + osg::ref_ptr textkeys (new SceneUtil::TextKeyMapHolder); osg::ref_ptr created = handleNode(nifNode, nullptr, imageManager, std::vector(), 0, false, false, false, &textkeys->mTextKeys); @@ -353,10 +353,10 @@ namespace NifOsg else if (props[i].getPtr()->recType == Nif::RC_NiTexturingProperty) { if (props[i].getPtr()->recIndex == mFirstRootTextureIndex) - applyTo->setUserValue("overrideFx", 1); + applyTo->setUserValue("overrideFx", 1); } handleProperty(props[i].getPtr(), applyTo, composite, imageManager, boundTextures, animflags); - } + } } } @@ -514,7 +514,7 @@ namespace NifOsg } osg::ref_ptr handleNode(const Nif::Node* nifNode, osg::Group* parentNode, Resource::ImageManager* imageManager, - std::vector boundTextures, int animflags, bool skipMeshes, bool hasMarkers, bool hasAnimatedParents, TextKeyMap* textKeys, osg::Node* rootNode=nullptr) + std::vector boundTextures, int animflags, bool skipMeshes, bool hasMarkers, bool hasAnimatedParents, SceneUtil::TextKeyMap* textKeys, osg::Node* rootNode=nullptr) { if (rootNode != nullptr && Misc::StringUtils::ciEqual(nifNode->name, "Bounding Box")) return nullptr; @@ -1197,7 +1197,7 @@ namespace NifOsg for (const auto& strip : data->strips) { if (strip.size() >= 3) - geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, strip.size(), + geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, strip.size(), (unsigned short*)strip.data())); } } @@ -1929,7 +1929,7 @@ namespace NifOsg return impl.load(file, imageManager); } - void Loader::loadKf(Nif::NIFFilePtr kf, KeyframeHolder& target) + void Loader::loadKf(Nif::NIFFilePtr kf, SceneUtil::KeyframeHolder& target) { LoaderImpl impl(kf->getFilename(), kf->getVersion(), kf->getUserVersion(), kf->getBethVersion()); impl.loadKf(kf, target); diff --git a/components/nifosg/nifloader.hpp b/components/nifosg/nifloader.hpp index 49a78ad5f..8ee6b4167 100644 --- a/components/nifosg/nifloader.hpp +++ b/components/nifosg/nifloader.hpp @@ -2,12 +2,13 @@ #define OPENMW_COMPONENTS_NIFOSG_LOADER #include +#include +#include #include #include #include "controller.hpp" -#include "textkeymap.hpp" namespace osg { @@ -21,39 +22,6 @@ namespace Resource namespace NifOsg { - struct TextKeyMapHolder : public osg::Object - { - public: - TextKeyMapHolder() {} - TextKeyMapHolder(const TextKeyMapHolder& copy, const osg::CopyOp& copyop) - : osg::Object(copy, copyop) - , mTextKeys(copy.mTextKeys) - {} - - TextKeyMap mTextKeys; - - META_Object(NifOsg, TextKeyMapHolder) - - }; - - class KeyframeHolder : public osg::Object - { - public: - KeyframeHolder() {} - KeyframeHolder(const KeyframeHolder& copy, const osg::CopyOp& copyop) - : mTextKeys(copy.mTextKeys) - , mKeyframeControllers(copy.mKeyframeControllers) - { - } - - TextKeyMap mTextKeys; - - META_Object(OpenMW, KeyframeHolder) - - typedef std::map > KeyframeControllerMap; - KeyframeControllerMap mKeyframeControllers; - }; - /// The main class responsible for loading NIF files into an OSG-Scenegraph. /// @par This scene graph is self-contained and can be cloned using osg::clone if desired. Particle emitters /// and programs hold a pointer to their ParticleSystem, which would need to be manually updated when cloning. @@ -64,7 +32,7 @@ namespace NifOsg static osg::ref_ptr load(Nif::NIFFilePtr file, Resource::ImageManager* imageManager); /// Load keyframe controllers from the given kf file. - static void loadKf(Nif::NIFFilePtr kf, KeyframeHolder& target); + static void loadKf(Nif::NIFFilePtr kf, SceneUtil::KeyframeHolder& target); /// Set whether or not nodes marked as "MRK" should be shown. /// These should be hidden ingame, but visible in the editor. diff --git a/components/resource/keyframemanager.cpp b/components/resource/keyframemanager.cpp index 8c5c50adc..ef6339adb 100644 --- a/components/resource/keyframemanager.cpp +++ b/components/resource/keyframemanager.cpp @@ -2,13 +2,45 @@ #include +#include + #include "objectcache.hpp" +#include "scenemanager.hpp" + +namespace +{ + class RetrieveAnimationsVisitor : public osg::NodeVisitor + { + public: + RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), mTarget(target) {} + + + virtual void apply(osg::Node& node) + { + if (node.libraryName() == std::string("osgAnimation")) + std::cout << "found an " << node.className() << std::endl; + traverse(node); + } + + private: + SceneUtil::KeyframeHolder& mTarget; + }; + + std::string getFileExtension(const std::string& file) + { + size_t extPos = file.find_last_of('.'); + if (extPos != std::string::npos && extPos+1 < file.size()) + return file.substr(extPos+1); + return std::string(); + } +} namespace Resource { - KeyframeManager::KeyframeManager(const VFS::Manager* vfs) + KeyframeManager::KeyframeManager(const VFS::Manager* vfs, SceneManager* sceneManager) : ResourceManager(vfs) + , mSceneManager(sceneManager) { } @@ -16,19 +48,28 @@ namespace Resource { } - osg::ref_ptr KeyframeManager::get(const std::string &name) + osg::ref_ptr KeyframeManager::get(const std::string &name) { std::string normalized = name; mVFS->normalizeFilename(normalized); osg::ref_ptr obj = mCache->getRefFromObjectCache(normalized); if (obj) - return osg::ref_ptr(static_cast(obj.get())); + return osg::ref_ptr(static_cast(obj.get())); else { - osg::ref_ptr loaded (new NifOsg::KeyframeHolder); - NifOsg::Loader::loadKf(Nif::NIFFilePtr(new Nif::NIFFile(mVFS->getNormalized(normalized), normalized)), *loaded.get()); - + osg::ref_ptr loaded (new SceneUtil::KeyframeHolder); + std::string ext = getFileExtension(normalized); + if (ext == "kf") + { + NifOsg::Loader::loadKf(Nif::NIFFilePtr(new Nif::NIFFile(mVFS->getNormalized(normalized), normalized)), *loaded.get()); + } + else + { + osg::ref_ptr scene = mSceneManager->getTemplate(normalized); + RetrieveAnimationsVisitor rav(*loaded.get()); + const_cast(scene.get())->accept(rav); // const_cast required because there is no const version of osg::NodeVisitor + } mCache->addEntryToObjectCache(normalized, loaded); return loaded; } diff --git a/components/resource/keyframemanager.hpp b/components/resource/keyframemanager.hpp index fe1c4014e..e186e2783 100644 --- a/components/resource/keyframemanager.hpp +++ b/components/resource/keyframemanager.hpp @@ -4,26 +4,30 @@ #include #include -#include +#include #include "resourcemanager.hpp" namespace Resource { + class SceneManager; + /// @brief Managing of keyframe resources /// @note May be used from any thread. class KeyframeManager : public ResourceManager { public: - KeyframeManager(const VFS::Manager* vfs); + KeyframeManager(const VFS::Manager* vfs, SceneManager* sceneManager); ~KeyframeManager(); /// Retrieve a read-only keyframe resource by name (case-insensitive). /// @note Throws an exception if the resource is not found. - osg::ref_ptr get(const std::string& name); + osg::ref_ptr get(const std::string& name); void reportStats(unsigned int frameNumber, osg::Stats* stats) const override; + private: + SceneManager* mSceneManager; }; } diff --git a/components/resource/resourcesystem.cpp b/components/resource/resourcesystem.cpp index 2015ba874..ab9d0aba2 100644 --- a/components/resource/resourcesystem.cpp +++ b/components/resource/resourcesystem.cpp @@ -14,9 +14,9 @@ namespace Resource : mVFS(vfs) { mNifFileManager.reset(new NifFileManager(vfs)); - mKeyframeManager.reset(new KeyframeManager(vfs)); mImageManager.reset(new ImageManager(vfs)); mSceneManager.reset(new SceneManager(vfs, mImageManager.get(), mNifFileManager.get())); + mKeyframeManager.reset(new KeyframeManager(vfs, mSceneManager.get())); addResourceManager(mNifFileManager.get()); addResourceManager(mKeyframeManager.get()); diff --git a/components/sceneutil/keyframe.hpp b/components/sceneutil/keyframe.hpp new file mode 100644 index 000000000..c993c7b7c --- /dev/null +++ b/components/sceneutil/keyframe.hpp @@ -0,0 +1,68 @@ +#ifndef OPENMW_COMPONENTS_SCENEUTIL_KEYFRAME_HPP +#define OPENMW_COMPONENTS_SCENEUTIL_KEYFRAME_HPP + +#include + +#include + +#include +#include + +namespace SceneUtil +{ + + class KeyframeController : public osg::NodeCallback, public SceneUtil::Controller + { + public: + KeyframeController() {} + + KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop) + : osg::NodeCallback(copy, copyop) + , SceneUtil::Controller(copy) + {} + META_Object(SceneUtil, KeyframeController) + + virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); } + + virtual void operator() (osg::Node* node, osg::NodeVisitor* nodeVisitor) { traverse(node, nodeVisitor); } + }; + + /// Wrapper object containing an animation track as a ref-countable osg::Object. + struct TextKeyMapHolder : public osg::Object + { + public: + TextKeyMapHolder() {} + TextKeyMapHolder(const TextKeyMapHolder& copy, const osg::CopyOp& copyop) + : osg::Object(copy, copyop) + , mTextKeys(copy.mTextKeys) + {} + + TextKeyMap mTextKeys; + + META_Object(SceneUtil, TextKeyMapHolder) + + }; + + /// Wrapper object containing the animation track and its KeyframeControllers. + class KeyframeHolder : public osg::Object + { + public: + KeyframeHolder() {} + KeyframeHolder(const KeyframeHolder& copy, const osg::CopyOp& copyop) + : mTextKeys(copy.mTextKeys) + , mKeyframeControllers(copy.mKeyframeControllers) + { + } + + TextKeyMap mTextKeys; + + META_Object(SceneUtil, KeyframeHolder) + + /// Controllers mapped to node name. + typedef std::map > KeyframeControllerMap; + KeyframeControllerMap mKeyframeControllers; + }; + +} + +#endif diff --git a/components/nifosg/textkeymap.hpp b/components/sceneutil/textkeymap.hpp similarity index 94% rename from components/nifosg/textkeymap.hpp rename to components/sceneutil/textkeymap.hpp index 49e1e461e..ee58bc72a 100644 --- a/components/nifosg/textkeymap.hpp +++ b/components/sceneutil/textkeymap.hpp @@ -1,12 +1,12 @@ -#ifndef OPENMW_COMPONENTS_NIFOSG_TEXTKEYMAP -#define OPENMW_COMPONENTS_NIFOSG_TEXTKEYMAP +#ifndef OPENMW_COMPONENTS_SCENEUTIL_TEXTKEYMAP +#define OPENMW_COMPONENTS_SCENEUTIL_TEXTKEYMAP #include #include #include #include -namespace NifOsg +namespace SceneUtil { class TextKeyMap { From 6e77ad1f6a77cd31bd7fbf8ed7007015899013e9 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Thu, 19 Nov 2020 01:11:56 +0200 Subject: [PATCH 14/28] OSG-Collada animation support --- CMakeLists.txt | 2 +- apps/openmw/mwrender/animation.cpp | 2 + components/CMakeLists.txt | 5 +- components/resource/animation.cpp | 40 +++++ components/resource/animation.hpp | 39 +++++ components/resource/keyframemanager.cpp | 94 +++++++++--- components/resource/keyframemanager.hpp | 20 +++ components/resource/scenemanager.cpp | 2 +- components/sceneutil/clone.cpp | 12 +- components/sceneutil/keyframe.hpp | 13 ++ components/sceneutil/osgacontroller.cpp | 195 ++++++++++++++++++++++++ components/sceneutil/osgacontroller.hpp | 70 +++++++++ 12 files changed, 471 insertions(+), 23 deletions(-) create mode 100644 components/resource/animation.cpp create mode 100644 components/resource/animation.hpp create mode 100644 components/sceneutil/osgacontroller.cpp create mode 100644 components/sceneutil/osgacontroller.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 37696f44c..76764fbd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,7 +259,7 @@ if(NOT HAVE_STDINT_H) endif() -find_package(OpenSceneGraph 3.3.4 REQUIRED osgDB osgViewer osgText osgGA osgParticle osgUtil osgFX osgShadow) +find_package(OpenSceneGraph 3.3.4 REQUIRED osgDB osgViewer osgText osgGA osgParticle osgUtil osgFX osgShadow osgAnimation) include_directories(SYSTEM ${OPENSCENEGRAPH_INCLUDE_DIRS}) set(USED_OSG_PLUGINS diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index f8ff3780d..8c9f5f493 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -782,6 +782,8 @@ namespace MWRender NodeMap::const_iterator found = nodeMap.find("bip01"); if (found == nodeMap.end()) found = nodeMap.find("root bone"); + if (found == nodeMap.end()) + found = nodeMap.find("root"); if (found != nodeMap.end()) mAccumRoot = found->second; diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 08f183f5e..3c1899037 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -41,7 +41,8 @@ add_component_dir (vfs ) add_component_dir (resource - scenemanager keyframemanager imagemanager bulletshapemanager bulletshape niffilemanager objectcache multiobjectcache resourcesystem resourcemanager stats + scenemanager keyframemanager imagemanager bulletshapemanager bulletshape niffilemanager objectcache multiobjectcache resourcesystem + resourcemanager stats animation ) add_component_dir (shader @@ -51,7 +52,7 @@ add_component_dir (shader add_component_dir (sceneutil clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller lightmanager lightutil positionattitudetransform workqueue unrefqueue pathgridutil waterutil writescene serialize optimizer - actorutil detourdebugdraw navmesh agentpath shadow mwshadowtechnique recastmesh shadowsbin + actorutil detourdebugdraw navmesh agentpath shadow mwshadowtechnique recastmesh shadowsbin osgacontroller ) add_component_dir (nif diff --git a/components/resource/animation.cpp b/components/resource/animation.cpp new file mode 100644 index 000000000..34ae162ee --- /dev/null +++ b/components/resource/animation.cpp @@ -0,0 +1,40 @@ +#include + +#include +#include + +namespace Resource +{ + Animation::Animation(const Animation& anim, const osg::CopyOp& copyop): osg::Object(anim, copyop), + mDuration(0.0f), + mStartTime(0.0f) + { + const osgAnimation::ChannelList& channels = anim.getChannels(); + for (const osg::ref_ptr channel: channels) + addChannel(channel.get()->clone()); + } + + void Animation::addChannel(osg::ref_ptr pChannel) + { + mChannels.push_back(pChannel); + } + + std::vector>& Animation::getChannels() + { + return mChannels; + } + + const std::vector>& Animation::getChannels() const + { + return mChannels; + } + + bool Animation::update (double time) + { + for (const osg::ref_ptr channel: mChannels) + { + channel->update(time, 1.0f, 0); + } + return true; + } +} diff --git a/components/resource/animation.hpp b/components/resource/animation.hpp new file mode 100644 index 000000000..885394747 --- /dev/null +++ b/components/resource/animation.hpp @@ -0,0 +1,39 @@ +#ifndef OPENMW_COMPONENTS_RESOURCE_ANIMATION_HPP +#define OPENMW_COMPONENTS_RESOURCE_ANIMATION_HPP + +#include + +#include +#include +#include + +namespace Resource +{ + /// Stripped down class of osgAnimation::Animation, only needed for OSG's plugin formats like dae + class Animation : public osg::Object + { + public: + META_Object(Resource, Animation) + + Animation() : + mDuration(0.0), mStartTime(0) {} + + Animation(const Animation&, const osg::CopyOp&); + ~Animation() {} + + void addChannel (osg::ref_ptr pChannel); + + std::vector>& getChannels(); + + const std::vector>& getChannels() const; + + bool update (double time); + + protected: + double mDuration; + double mStartTime; + std::vector> mChannels; + }; +} + +#endif diff --git a/components/resource/keyframemanager.cpp b/components/resource/keyframemanager.cpp index ef6339adb..6cda9728c 100644 --- a/components/resource/keyframemanager.cpp +++ b/components/resource/keyframemanager.cpp @@ -2,29 +2,86 @@ #include -#include +#include +#include +#include +#include +#include +#include + +#include "animation.hpp" #include "objectcache.hpp" #include "scenemanager.hpp" -namespace +namespace OsgAOpenMW { - class RetrieveAnimationsVisitor : public osg::NodeVisitor + + RetrieveAnimationsVisitor::RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr animationManager) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), mTarget(target), mAnimationManager(animationManager) {} + + void RetrieveAnimationsVisitor::apply(osg::Node& node) { - public: - RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), mTarget(target) {} + if (node.libraryName() == std::string("osgAnimation") && node.className() == std::string("Bone") && node.getName() == std::string("root")) + { + if (!mAnimationManager) + { + traverse(node); + return; + } + osg::ref_ptr callback = new OsgaController::KeyframeController(); - virtual void apply(osg::Node& node) - { - if (node.libraryName() == std::string("osgAnimation")) - std::cout << "found an " << node.className() << std::endl; - traverse(node); - } + std::vector emulatedAnimations; - private: - SceneUtil::KeyframeHolder& mTarget; - }; + for (auto animation : mAnimationManager->getAnimationList()) + { + if (animation) + { + if (animation->getName() == "Default") //"Default" is osg dae plugin's default naming scheme for unnamed animations + { + animation->setName(std::string("idle")); // animation naming scheme "idle: start" and "idle: stop" is the default idle animation that OpenMW seems to want to play + } + + osg::ref_ptr mergedAnimationTrack = new Resource::Animation; + std::string animationName = animation->getName(); + std::string start = animationName + std::string(": start"); + std::string stop = animationName + std::string(": stop"); + std::string loopstart = animationName + std::string(": loop start"); + std::string loopstop = animationName + std::string(": loop stop"); + + const osgAnimation::ChannelList& channels = animation->getChannels(); + for (const osg::ref_ptr channel: channels) + { + mergedAnimationTrack->addChannel(channel.get()->clone()); // is ->clone needed? + } + mergedAnimationTrack->setName(animation->getName()); + callback->addMergedAnimationTrack(mergedAnimationTrack); + + float startTime = animation->getStartTime(); + float stopTime = startTime + animation->getDuration(); + + // mTextKeys is a nif-thing, used by OpenMW's animation system + // Format is likely "AnimationName: [Keyword_optional] [Start OR Stop]" + // AnimationNames are keywords like idle2, idle3... AiPackages and various mechanics control which animations are played + // Keywords can be stuff like Loop, Equip, Unequip, Block, InventoryHandtoHand, InventoryWeaponOneHand, PickProbe, Slash, Thrust, Chop... even "Slash Small Follow" + mTarget.mTextKeys.emplace(startTime, std::move(start)); + mTarget.mTextKeys.emplace(stopTime, std::move(stop)); + mTarget.mTextKeys.emplace(startTime, std::move(loopstart)); + mTarget.mTextKeys.emplace(stopTime, std::move(loopstop)); + + SceneUtil::EmulatedAnimation emulatedAnimation; + emulatedAnimation.mStartTime = startTime; + emulatedAnimation.mStopTime = stopTime; + emulatedAnimation.mName = animationName; + emulatedAnimations.emplace_back(emulatedAnimation); + } + } + callback->setEmulatedAnimations(emulatedAnimations); + mTarget.mKeyframeControllers.emplace(node.getName(), callback); + } + + traverse(node); + } std::string getFileExtension(const std::string& file) { @@ -59,16 +116,17 @@ namespace Resource else { osg::ref_ptr loaded (new SceneUtil::KeyframeHolder); - std::string ext = getFileExtension(normalized); + std::string ext = OsgAOpenMW::getFileExtension(normalized); if (ext == "kf") { NifOsg::Loader::loadKf(Nif::NIFFilePtr(new Nif::NIFFile(mVFS->getNormalized(normalized), normalized)), *loaded.get()); } else { - osg::ref_ptr scene = mSceneManager->getTemplate(normalized); - RetrieveAnimationsVisitor rav(*loaded.get()); - const_cast(scene.get())->accept(rav); // const_cast required because there is no const version of osg::NodeVisitor + osg::ref_ptr scene = const_cast ( mSceneManager->getTemplate(normalized).get() ); + osg::ref_ptr bam = dynamic_cast (scene->getUpdateCallback()); + OsgAOpenMW::RetrieveAnimationsVisitor rav(*loaded.get(), bam); + scene->accept(rav); } mCache->addEntryToObjectCache(normalized, loaded); return loaded; diff --git a/components/resource/keyframemanager.hpp b/components/resource/keyframemanager.hpp index e186e2783..4f83196f3 100644 --- a/components/resource/keyframemanager.hpp +++ b/components/resource/keyframemanager.hpp @@ -2,12 +2,32 @@ #define OPENMW_COMPONENTS_KEYFRAMEMANAGER_H #include +#include #include #include #include "resourcemanager.hpp" +namespace OsgAOpenMW +{ + /// @brief extract animations to OpenMW's animation system + class RetrieveAnimationsVisitor : public osg::NodeVisitor + { + public: + RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr animationManager); + + virtual void apply(osg::Node& node); + + private: + SceneUtil::KeyframeHolder& mTarget; + osg::ref_ptr mAnimationManager; + + }; + + std::string getFileExtension(const std::string& file); +} + namespace Resource { diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 44ba7e687..e99003b74 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -492,7 +492,7 @@ namespace Resource } catch (std::exception& e) { - static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2" }; + static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", "dae" }; for (unsigned int i=0; i +#include +#include +#include +#include + #include #include #include @@ -30,6 +35,11 @@ namespace SceneUtil mUpdaterToOldPs[cloned] = updater->getParticleSystem(0); return cloned; } + + if (dynamic_cast(node) || dynamic_cast(node)) + { + return osg::clone(node, *this); + } return osg::CopyOp::operator()(node); } @@ -38,7 +48,7 @@ namespace SceneUtil if (const osgParticle::ParticleSystem* partsys = dynamic_cast(drawable)) return operator()(partsys); - if (dynamic_cast(drawable) || dynamic_cast(drawable)) + if (dynamic_cast(drawable) || dynamic_cast(drawable) || dynamic_cast(drawable) || dynamic_cast(drawable)) { return static_cast(drawable->clone(*this)); } diff --git a/components/sceneutil/keyframe.hpp b/components/sceneutil/keyframe.hpp index c993c7b7c..5a0435469 100644 --- a/components/sceneutil/keyframe.hpp +++ b/components/sceneutil/keyframe.hpp @@ -7,9 +7,16 @@ #include #include +#include namespace SceneUtil { + struct EmulatedAnimation + { + float mStartTime; + float mStopTime; + std::string mName; + }; class KeyframeController : public osg::NodeCallback, public SceneUtil::Controller { @@ -19,12 +26,18 @@ namespace SceneUtil KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop) : osg::NodeCallback(copy, copyop) , SceneUtil::Controller(copy) + , mMergedAnimationTracks(copy.mMergedAnimationTracks) + , mEmulatedAnimations(copy.mEmulatedAnimations) {} META_Object(SceneUtil, KeyframeController) virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); } virtual void operator() (osg::Node* node, osg::NodeVisitor* nodeVisitor) { traverse(node, nodeVisitor); } + + protected: + std::vector> mMergedAnimationTracks; // Used only by osgAnimation-based formats (e.g. dae) + std::vector mEmulatedAnimations; }; /// Wrapper object containing an animation track as a ref-countable osg::Object. diff --git a/components/sceneutil/osgacontroller.cpp b/components/sceneutil/osgacontroller.cpp new file mode 100644 index 000000000..6b635d4ea --- /dev/null +++ b/components/sceneutil/osgacontroller.cpp @@ -0,0 +1,195 @@ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace OsgaController +{ + LinkVisitor::LinkVisitor() : osg::NodeVisitor( TRAVERSE_ALL_CHILDREN ) + { + mAnimation = nullptr; + } + + void LinkVisitor::link(osgAnimation::UpdateMatrixTransform* umt) + { + const osgAnimation::ChannelList& channels = mAnimation->getChannels(); + for (const osg::ref_ptr channel: channels) + { + const std::string& channelName = channel->getName(); + const std::string& channelTargetName = channel->getTargetName(); + + if (channelTargetName != umt->getName()) continue; + + // check if we can link a StackedTransformElement to the current Channel + for (auto stackedTransform : umt->getStackedTransforms()) + { + osgAnimation::StackedTransformElement* element = stackedTransform.get(); + if (element && !element->getName().empty() && channelName == element->getName()) + { + osgAnimation::Target* target = element->getOrCreateTarget(); + if (target) + { + channel->setTarget(target); + } + } + } + } + } + + void LinkVisitor::handle_stateset(osg::StateSet* stateset) + { + if (!stateset) + return; + const osg::StateSet::AttributeList& attributeList = stateset->getAttributeList(); + for (auto attribute : attributeList) + { + osg::StateAttribute* sattr = attribute.second.first.get(); + osgAnimation::UpdateMatrixTransform* umt = dynamic_cast(sattr->getUpdateCallback()); //Can this even be in sa? + if (umt) link(umt); + } + } + + void LinkVisitor::setAnimation(Resource::Animation* animation) + { + mAnimation = animation; + } + + void LinkVisitor::apply(osg::Node& node) + { + osg::StateSet* st = node.getStateSet(); + if (st) + handle_stateset(st); + + osg::Callback* cb = node.getUpdateCallback(); + while (cb) + { + osgAnimation::UpdateMatrixTransform* umt = dynamic_cast(cb); + if (umt) + if (node.getName() != "root") link(umt); + cb = cb->getNestedCallback(); + } + + traverse( node ); + } + + void LinkVisitor::apply(osg::Geode& node) + { + for (unsigned int i = 0; i < node.getNumDrawables(); i++) + { + osg::Drawable* drawable = node.getDrawable(i); + if (drawable && drawable->getStateSet()) + handle_stateset(drawable->getStateSet()); + } + apply(static_cast(node)); + } + + KeyframeController::KeyframeController(const KeyframeController ©, const osg::CopyOp ©op) : SceneUtil::KeyframeController(copy, copyop) + { + mLinker = nullptr; + } + + osg::Vec3f KeyframeController::getTranslation(float time) const + { + osg::Vec3f translationValue; + std::string animationName; + float newTime = time; + + //Find the correct animation based on time + for (auto emulatedAnimation : mEmulatedAnimations) + { + if (time > emulatedAnimation.mStartTime && time < emulatedAnimation.mStopTime) + { + newTime = time - emulatedAnimation.mStartTime; + animationName = emulatedAnimation.mName; + } + } + + //Find the root transform track in animation + for (auto mergedAnimationTrack : mMergedAnimationTracks) + { + if (mergedAnimationTrack->getName() != animationName) continue; + + const osgAnimation::ChannelList& channels = mergedAnimationTrack->getChannels(); + + for (const osg::ref_ptr channel: channels) + { + if (channel->getTargetName() != "root" || channel->getName() != "transform") continue; + + if ( osgAnimation::MatrixLinearSampler* templateSampler = dynamic_cast (channel->getSampler()) ) + { + osg::Matrixf matrix; + templateSampler->getValueAt(newTime, matrix); + translationValue = matrix.getTrans(); + return osg::Vec3f(translationValue[0], translationValue[1], translationValue[2]); + } + } + } + + return osg::Vec3f(); + } + + void KeyframeController::update(float time, std::string animationName) + { + for (auto mergedAnimationTrack : mMergedAnimationTracks) + { + if (mergedAnimationTrack->getName() == animationName) mergedAnimationTrack->update(time); + } + } + + void KeyframeController::operator() (osg::Node* node, osg::NodeVisitor* nv) + { + if (hasInput()) + { + if (mNeedToLink) + { + for (auto mergedAnimationTrack : mMergedAnimationTracks) + { + if (!mLinker.valid()) mLinker = new LinkVisitor(); + mLinker->setAnimation(mergedAnimationTrack); + node->accept(*mLinker); + } + mNeedToLink = false; + } + + float time = getInputValue(nv); + + for (auto emulatedAnimation : mEmulatedAnimations) + { + if (time > emulatedAnimation.mStartTime && time < emulatedAnimation.mStopTime) + { + update(time - emulatedAnimation.mStartTime, emulatedAnimation.mName); + } + } + } + + traverse(node, nv); + } + + void KeyframeController::setEmulatedAnimations(std::vector emulatedAnimations) + { + mEmulatedAnimations = emulatedAnimations; + } + + void KeyframeController::addMergedAnimationTrack(osg::ref_ptr animationTrack) + { + mMergedAnimationTracks.emplace_back(animationTrack); + } +} diff --git a/components/sceneutil/osgacontroller.hpp b/components/sceneutil/osgacontroller.hpp new file mode 100644 index 000000000..4ae122199 --- /dev/null +++ b/components/sceneutil/osgacontroller.hpp @@ -0,0 +1,70 @@ +#ifndef OPENMW_COMPONENTS_SCENEUTIL_OSGACONTROLLER_HPP +#define OPENMW_COMPONENTS_SCENEUTIL_OSGACONTROLLER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace OsgaController +{ + class LinkVisitor : public osg::NodeVisitor + { + public: + LinkVisitor(); + + virtual void link(osgAnimation::UpdateMatrixTransform* umt); + + virtual void handle_stateset(osg::StateSet* stateset); + + virtual void setAnimation(Resource::Animation* animation); + + virtual void apply(osg::Node& node); + + virtual void apply(osg::Geode& node); + + protected: + Resource::Animation* mAnimation; + }; + + class KeyframeController : public SceneUtil::KeyframeController + { + public: + /// @brief Handles the animation for osgAnimation formats + KeyframeController() {}; + + KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop); + + META_Object(OsgaController, KeyframeController) + + /// @brief Handles the location of the instance + osg::Vec3f getTranslation(float time) const override; + + /// @brief Calls animation track update() + void update(float time, std::string animationName); + + /// @brief Called every frame for osgAnimation + void operator() (osg::Node*, osg::NodeVisitor*) override; + + /// @brief Sets details of the animations + void setEmulatedAnimations(std::vector emulatedAnimations); + + /// @brief Adds an animation track to a model + void addMergedAnimationTrack(osg::ref_ptr animationTrack); + private: + bool mNeedToLink = true; + osg::ref_ptr mLinker; + }; +} + +#endif From 2413de38b52d6c6184f5b393f800d20086345b37 Mon Sep 17 00:00:00 2001 From: jefetienne Date: Tue, 17 Nov 2020 19:47:56 -0500 Subject: [PATCH 15/28] Extend spell/item search to search by magic effect name --- apps/openmw/mwgui/spellmodel.cpp | 46 +++++++++++++++++++++++++++++--- apps/openmw/mwgui/spellmodel.hpp | 3 +++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/spellmodel.cpp b/apps/openmw/mwgui/spellmodel.cpp index 1dedfa10b..2ae92e33f 100644 --- a/apps/openmw/mwgui/spellmodel.cpp +++ b/apps/openmw/mwgui/spellmodel.cpp @@ -42,6 +42,44 @@ namespace MWGui { } + bool SpellModel::matchingEffectExists(std::string filter, const ESM::EffectList &effects) + { + auto wm = MWBase::Environment::get().getWindowManager(); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + for (unsigned int i = 0; i < effects.mList.size(); ++i) + { + short effectId = effects.mList[i].mEffectID; + const ESM::MagicEffect *magicEffect = + store.get().search(effectId); + + if (effectId != -1) + { + std::string effectIDStr = ESM::MagicEffect::effectIdToString(effectId); + std::string fullEffectName = wm->getGameSettingString(effectIDStr, ""); + + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill && effects.mList[i].mSkill != -1) + { + fullEffectName += " " + wm->getGameSettingString(ESM::Skill::sSkillNameIds[effects.mList[i].mSkill], ""); + } + + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute && effects.mList[i].mAttribute != -1) + { + fullEffectName += " " + wm->getGameSettingString(ESM::Attribute::sGmstAttributeIds[effects.mList[i].mAttribute], ""); + } + + std::string convert = Misc::StringUtils::lowerCaseUtf8(fullEffectName); + if (convert.find(filter) != std::string::npos) + { + return true; + } + } + } + + return false; + } + void SpellModel::update() { mSpells.clear(); @@ -61,8 +99,9 @@ namespace MWGui continue; std::string name = Misc::StringUtils::lowerCaseUtf8(spell->mName); - - if (name.find(filter) == std::string::npos) + + if (name.find(filter) == std::string::npos + && !matchingEffectExists(filter, spell->mEffects)) continue; Spell newSpell; @@ -103,7 +142,8 @@ namespace MWGui std::string name = Misc::StringUtils::lowerCaseUtf8(item.getClass().getName(item)); - if (name.find(filter) == std::string::npos) + if (name.find(filter) == std::string::npos + && !matchingEffectExists(filter, enchant->mEffects)) continue; Spell newSpell; diff --git a/apps/openmw/mwgui/spellmodel.hpp b/apps/openmw/mwgui/spellmodel.hpp index d191cba0e..2404610bf 100644 --- a/apps/openmw/mwgui/spellmodel.hpp +++ b/apps/openmw/mwgui/spellmodel.hpp @@ -2,6 +2,7 @@ #define OPENMW_GUI_SPELLMODEL_H #include "../mwworld/ptr.hpp" +#include namespace MWGui { @@ -57,6 +58,8 @@ namespace MWGui std::vector mSpells; std::string mFilter; + + bool matchingEffectExists(std::string filter, const ESM::EffectList &effects); }; } From bc6f46465f9d3bf09aebbd44689898673998efe4 Mon Sep 17 00:00:00 2001 From: jefetienne Date: Wed, 18 Nov 2020 14:30:41 -0500 Subject: [PATCH 16/28] Add to changelog, authors. Move variable declaration inside block --- AUTHORS.md | 1 + CHANGELOG.md | 1 + apps/openmw/mwgui/spellmodel.cpp | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 25004078e..09ab78412 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -96,6 +96,7 @@ Programmers Jan Borsodi (am0s) Jason Hooks (jhooks) jeaye + jefetienne Jeffrey Haines (Jyby) Jengerer Jiří KuneÅ¡ (kunesj) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51babd907..8f909a19f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ Feature #5642: Ability to attach arrows to actor skeleton instead of bow mesh Feature #5649: Skyrim SE compressed BSA format support Feature #5672: Make stretch menu background configuration more accessible + Feature #5692: Improve spell/magic item search to factor in magic effect names Task #5480: Drop Qt4 support Task #5520: Improve cell name autocompleter implementation diff --git a/apps/openmw/mwgui/spellmodel.cpp b/apps/openmw/mwgui/spellmodel.cpp index 2ae92e33f..136547c4c 100644 --- a/apps/openmw/mwgui/spellmodel.cpp +++ b/apps/openmw/mwgui/spellmodel.cpp @@ -51,11 +51,11 @@ namespace MWGui for (unsigned int i = 0; i < effects.mList.size(); ++i) { short effectId = effects.mList[i].mEffectID; - const ESM::MagicEffect *magicEffect = - store.get().search(effectId); if (effectId != -1) { + const ESM::MagicEffect *magicEffect = + store.get().search(effectId); std::string effectIDStr = ESM::MagicEffect::effectIdToString(effectId); std::string fullEffectName = wm->getGameSettingString(effectIDStr, ""); From 32d4344803702efb99d435b0732a4c883c4c360a Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Fri, 20 Nov 2020 19:38:29 +0200 Subject: [PATCH 17/28] Don't copy osga-data in base class keyframecontroller, fix warnings. --- components/resource/keyframemanager.cpp | 4 ++-- components/resource/keyframemanager.hpp | 2 +- components/sceneutil/keyframe.hpp | 15 +-------------- components/sceneutil/osgacontroller.cpp | 4 +++- components/sceneutil/osgacontroller.hpp | 16 +++++++++++++--- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/components/resource/keyframemanager.cpp b/components/resource/keyframemanager.cpp index 6cda9728c..d084d6a08 100644 --- a/components/resource/keyframemanager.cpp +++ b/components/resource/keyframemanager.cpp @@ -31,7 +31,7 @@ namespace OsgAOpenMW osg::ref_ptr callback = new OsgaController::KeyframeController(); - std::vector emulatedAnimations; + std::vector emulatedAnimations; for (auto animation : mAnimationManager->getAnimationList()) { @@ -69,7 +69,7 @@ namespace OsgAOpenMW mTarget.mTextKeys.emplace(startTime, std::move(loopstart)); mTarget.mTextKeys.emplace(stopTime, std::move(loopstop)); - SceneUtil::EmulatedAnimation emulatedAnimation; + OsgaController::EmulatedAnimation emulatedAnimation; emulatedAnimation.mStartTime = startTime; emulatedAnimation.mStopTime = stopTime; emulatedAnimation.mName = animationName; diff --git a/components/resource/keyframemanager.hpp b/components/resource/keyframemanager.hpp index 4f83196f3..778b4bc9a 100644 --- a/components/resource/keyframemanager.hpp +++ b/components/resource/keyframemanager.hpp @@ -17,7 +17,7 @@ namespace OsgAOpenMW public: RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr animationManager); - virtual void apply(osg::Node& node); + virtual void apply(osg::Node& node) override; private: SceneUtil::KeyframeHolder& mTarget; diff --git a/components/sceneutil/keyframe.hpp b/components/sceneutil/keyframe.hpp index 5a0435469..e09541cb9 100644 --- a/components/sceneutil/keyframe.hpp +++ b/components/sceneutil/keyframe.hpp @@ -11,13 +11,6 @@ namespace SceneUtil { - struct EmulatedAnimation - { - float mStartTime; - float mStopTime; - std::string mName; - }; - class KeyframeController : public osg::NodeCallback, public SceneUtil::Controller { public: @@ -26,18 +19,12 @@ namespace SceneUtil KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop) : osg::NodeCallback(copy, copyop) , SceneUtil::Controller(copy) - , mMergedAnimationTracks(copy.mMergedAnimationTracks) - , mEmulatedAnimations(copy.mEmulatedAnimations) {} META_Object(SceneUtil, KeyframeController) virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); } - virtual void operator() (osg::Node* node, osg::NodeVisitor* nodeVisitor) { traverse(node, nodeVisitor); } - - protected: - std::vector> mMergedAnimationTracks; // Used only by osgAnimation-based formats (e.g. dae) - std::vector mEmulatedAnimations; + virtual void operator() (osg::Node* node, osg::NodeVisitor* nodeVisitor) override { traverse(node, nodeVisitor); } }; /// Wrapper object containing an animation track as a ref-countable osg::Object. diff --git a/components/sceneutil/osgacontroller.cpp b/components/sceneutil/osgacontroller.cpp index 6b635d4ea..e20ecb5b8 100644 --- a/components/sceneutil/osgacontroller.cpp +++ b/components/sceneutil/osgacontroller.cpp @@ -102,6 +102,8 @@ namespace OsgaController } KeyframeController::KeyframeController(const KeyframeController ©, const osg::CopyOp ©op) : SceneUtil::KeyframeController(copy, copyop) + , mMergedAnimationTracks(copy.mMergedAnimationTracks) + , mEmulatedAnimations(copy.mEmulatedAnimations) { mLinker = nullptr; } @@ -183,7 +185,7 @@ namespace OsgaController traverse(node, nv); } - void KeyframeController::setEmulatedAnimations(std::vector emulatedAnimations) + void KeyframeController::setEmulatedAnimations(std::vector emulatedAnimations) { mEmulatedAnimations = emulatedAnimations; } diff --git a/components/sceneutil/osgacontroller.hpp b/components/sceneutil/osgacontroller.hpp index 4ae122199..a3072088a 100644 --- a/components/sceneutil/osgacontroller.hpp +++ b/components/sceneutil/osgacontroller.hpp @@ -18,6 +18,13 @@ namespace OsgaController { + struct EmulatedAnimation + { + float mStartTime; + float mStopTime; + std::string mName; + }; + class LinkVisitor : public osg::NodeVisitor { public: @@ -29,9 +36,9 @@ namespace OsgaController virtual void setAnimation(Resource::Animation* animation); - virtual void apply(osg::Node& node); + virtual void apply(osg::Node& node) override; - virtual void apply(osg::Geode& node); + virtual void apply(osg::Geode& node) override; protected: Resource::Animation* mAnimation; @@ -57,13 +64,16 @@ namespace OsgaController void operator() (osg::Node*, osg::NodeVisitor*) override; /// @brief Sets details of the animations - void setEmulatedAnimations(std::vector emulatedAnimations); + void setEmulatedAnimations(std::vector emulatedAnimations); /// @brief Adds an animation track to a model void addMergedAnimationTrack(osg::ref_ptr animationTrack); + private: bool mNeedToLink = true; osg::ref_ptr mLinker; + std::vector> mMergedAnimationTracks; // Used only by osgAnimation-based formats (e.g. dae) + std::vector mEmulatedAnimations; }; } From 3232faa703bfe5963895c35a69534def1c283e21 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Fri, 20 Nov 2020 19:41:01 +0200 Subject: [PATCH 18/28] Use const ref instead of value --- components/sceneutil/osgacontroller.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/sceneutil/osgacontroller.cpp b/components/sceneutil/osgacontroller.cpp index e20ecb5b8..503d9cf02 100644 --- a/components/sceneutil/osgacontroller.cpp +++ b/components/sceneutil/osgacontroller.cpp @@ -115,7 +115,7 @@ namespace OsgaController float newTime = time; //Find the correct animation based on time - for (auto emulatedAnimation : mEmulatedAnimations) + for (const EmulatedAnimation& emulatedAnimation : mEmulatedAnimations) { if (time > emulatedAnimation.mStartTime && time < emulatedAnimation.mStopTime) { @@ -125,7 +125,7 @@ namespace OsgaController } //Find the root transform track in animation - for (auto mergedAnimationTrack : mMergedAnimationTracks) + for (const osg::ref_ptr mergedAnimationTrack : mMergedAnimationTracks) { if (mergedAnimationTrack->getName() != animationName) continue; @@ -150,7 +150,7 @@ namespace OsgaController void KeyframeController::update(float time, std::string animationName) { - for (auto mergedAnimationTrack : mMergedAnimationTracks) + for (const osg::ref_ptr mergedAnimationTrack : mMergedAnimationTracks) { if (mergedAnimationTrack->getName() == animationName) mergedAnimationTrack->update(time); } @@ -162,7 +162,7 @@ namespace OsgaController { if (mNeedToLink) { - for (auto mergedAnimationTrack : mMergedAnimationTracks) + for (const osg::ref_ptr mergedAnimationTrack : mMergedAnimationTracks) { if (!mLinker.valid()) mLinker = new LinkVisitor(); mLinker->setAnimation(mergedAnimationTrack); @@ -173,7 +173,7 @@ namespace OsgaController float time = getInputValue(nv); - for (auto emulatedAnimation : mEmulatedAnimations) + for (const EmulatedAnimation& emulatedAnimation : mEmulatedAnimations) { if (time > emulatedAnimation.mStartTime && time < emulatedAnimation.mStopTime) { From 08dcbe30b37cb266bebf3c8171e9130e5bea9d5d Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Fri, 20 Nov 2020 19:46:08 +0200 Subject: [PATCH 19/28] Earlier nullptr check --- components/resource/keyframemanager.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/components/resource/keyframemanager.cpp b/components/resource/keyframemanager.cpp index d084d6a08..421b0ddf7 100644 --- a/components/resource/keyframemanager.cpp +++ b/components/resource/keyframemanager.cpp @@ -23,12 +23,6 @@ namespace OsgAOpenMW { if (node.libraryName() == std::string("osgAnimation") && node.className() == std::string("Bone") && node.getName() == std::string("root")) { - if (!mAnimationManager) - { - traverse(node); - return; - } - osg::ref_ptr callback = new OsgaController::KeyframeController(); std::vector emulatedAnimations; @@ -125,8 +119,11 @@ namespace Resource { osg::ref_ptr scene = const_cast ( mSceneManager->getTemplate(normalized).get() ); osg::ref_ptr bam = dynamic_cast (scene->getUpdateCallback()); - OsgAOpenMW::RetrieveAnimationsVisitor rav(*loaded.get(), bam); - scene->accept(rav); + if (bam) + { + OsgAOpenMW::RetrieveAnimationsVisitor rav(*loaded.get(), bam); + scene->accept(rav); + } } mCache->addEntryToObjectCache(normalized, loaded); return loaded; From 9aba55a21a0d7423b91a40ae9234144e3b823ec2 Mon Sep 17 00:00:00 2001 From: Frederic Chardon Date: Fri, 20 Nov 2020 13:11:53 +0100 Subject: [PATCH 20/28] Add the async physics worker to the profiler overlay. --- apps/openmw/engine.cpp | 10 +++++++++- apps/openmw/mwbase/world.hpp | 4 +++- apps/openmw/mwphysics/mtphysics.cpp | 17 ++++++++++++++++- apps/openmw/mwphysics/mtphysics.hpp | 10 +++++++++- apps/openmw/mwphysics/physicssystem.cpp | 5 +++-- apps/openmw/mwphysics/physicssystem.hpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 9 +++++---- apps/openmw/mwworld/worldimp.hpp | 4 ++-- 8 files changed, 49 insertions(+), 13 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 49a4b4059..0bfd67dd7 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -94,6 +94,7 @@ namespace Script, Mechanics, Physics, + PhysicsWorker, World, Gui, @@ -124,6 +125,9 @@ namespace template <> const UserStats UserStatsValue::sValue {"Phys", "physics"}; + template <> + const UserStats UserStatsValue::sValue {" -Async", "physicsworker"}; + template <> const UserStats UserStatsValue::sValue {"World", "world"}; @@ -203,6 +207,10 @@ namespace profiler.addUserStatsLine(v.mLabel, textColor, barColor, v.mTaken, multiplier, average, averageInInverseSpace, v.mBegin, v.mEnd, maxValue); }); + // the forEachUserStatsValue loop is "run" at compile time, hence the settings manager is not available. + // Unconditionnally add the async physics stats, and then remove it at runtime if necessary + if (Settings::Manager::getInt("async num threads", "Physics") == 0) + profiler.removeUserStatsLine(" -Async"); } } @@ -318,7 +326,7 @@ bool OMW::Engine::frame(float frametime) if (mEnvironment.getStateManager()->getState() != MWBase::StateManager::State_NoGame) { - mEnvironment.getWorld()->updatePhysics(frametime, guiActive); + mEnvironment.getWorld()->updatePhysics(frametime, guiActive, frameStart, frameNumber, *stats); } } diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index f9cbc8972..49bc76a76 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -10,6 +10,8 @@ #include +#include + #include "../mwworld/ptr.hpp" #include "../mwworld/doorstate.hpp" @@ -391,7 +393,7 @@ namespace MWBase /// \return pointer to created record virtual void update (float duration, bool paused) = 0; - virtual void updatePhysics (float duration, bool paused) = 0; + virtual void updatePhysics (float duration, bool paused, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) = 0; virtual void updateWindowManager () = 0; diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index dbb714fac..8c06e0140 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -1,6 +1,8 @@ #include #include +#include + #include "components/debug/debuglog.hpp" #include #include "components/misc/convert.hpp" @@ -154,6 +156,8 @@ namespace MWPhysics , mQuit(false) , mNextJob(0) , mNextLOS(0) + , mFrameNumber(0) + , mTimer(osg::Timer::instance()) { mNumThreads = Config::computeNumThreads(mThreadSafeBullet); @@ -192,6 +196,7 @@ namespace MWPhysics [](const LOSRequest& req) { return req.mStale; }), mLOSCache.end()); } + mTimeEnd = mTimer->tick(); }); } @@ -207,7 +212,7 @@ namespace MWPhysics thread.join(); } - const PtrPositionList& PhysicsTaskScheduler::moveActors(int numSteps, float timeAccum, std::vector&& actorsData, bool skipSimulation) + const PtrPositionList& PhysicsTaskScheduler::moveActors(int numSteps, float timeAccum, std::vector&& actorsData, bool skipSimulation, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) { // This function run in the main thread. // While the mSimulationMutex is held, background physics threads can't run. @@ -230,6 +235,16 @@ namespace MWPhysics if (mMovementResults.find(data.mPtr) != mMovementResults.end()) data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); } + + if (mFrameNumber == frameNumber - 1) + { + stats.setAttribute(mFrameNumber, "physicsworker_time_begin", mTimer->delta_s(mFrameStart, mTimeBegin)); + stats.setAttribute(mFrameNumber, "physicsworker_time_taken", mTimer->delta_s(mTimeBegin, mTimeEnd)); + stats.setAttribute(mFrameNumber, "physicsworker_time_end", mTimer->delta_s(mFrameStart, mTimeEnd)); + } + mFrameStart = frameStart; + mTimeBegin = mTimer->tick(); + mFrameNumber = frameNumber; } // init diff --git a/apps/openmw/mwphysics/mtphysics.hpp b/apps/openmw/mwphysics/mtphysics.hpp index ef1c90b87..c061fe01d 100644 --- a/apps/openmw/mwphysics/mtphysics.hpp +++ b/apps/openmw/mwphysics/mtphysics.hpp @@ -9,6 +9,8 @@ #include +#include + #include "physicssystem.hpp" #include "ptrholder.hpp" @@ -30,7 +32,7 @@ namespace MWPhysics /// @param timeAccum accumulated time from previous run to interpolate movements /// @param actorsData per actor data needed to compute new positions /// @return new position of each actor - const PtrPositionList& moveActors(int numSteps, float timeAccum, std::vector&& actorsData, bool skip); + const PtrPositionList& moveActors(int numSteps, float timeAccum, std::vector&& actorsData, bool skip, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats); // Thread safe wrappers void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const; @@ -87,6 +89,12 @@ namespace MWPhysics mutable std::shared_mutex mLOSCacheMutex; mutable std::mutex mUpdateAabbMutex; std::condition_variable_any mHasJob; + + unsigned int mFrameNumber; + const osg::Timer* mTimer; + osg::Timer_t mTimeBegin; + osg::Timer_t mTimeEnd; + osg::Timer_t mFrameStart; }; } diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 8a58919ca..1ceba2f31 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -665,7 +666,7 @@ namespace MWPhysics mMovementQueue.clear(); } - const PtrPositionList& PhysicsSystem::applyQueuedMovement(float dt, bool skipSimulation) + const PtrPositionList& PhysicsSystem::applyQueuedMovement(float dt, bool skipSimulation, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) { mTimeAccum += dt; @@ -675,7 +676,7 @@ namespace MWPhysics mTimeAccum -= numSteps * mPhysicsDt; - return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), skipSimulation); + return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), skipSimulation, frameStart, frameNumber, stats); } std::vector PhysicsSystem::prepareFrameData(int numSteps) diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index ccfca5422..379aea1dd 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "../mwworld/ptr.hpp" @@ -200,7 +201,7 @@ namespace MWPhysics void queueObjectMovement(const MWWorld::Ptr &ptr, const osg::Vec3f &velocity); /// Apply all queued movements, then clear the list. - const PtrPositionList& applyQueuedMovement(float dt, bool skipSimulation); + const PtrPositionList& applyQueuedMovement(float dt, bool skipSimulation, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats); /// Clear the queued movements list without applying. void clearQueuedMovement(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index ad6c33790..54b94833e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -1494,14 +1495,14 @@ namespace MWWorld mPhysics->updateAnimatedCollisionShape(ptr); } - void World::doPhysics(float duration) + void World::doPhysics(float duration, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) { mPhysics->stepSimulation(); processDoors(duration); mProjectileManager->update(duration); - const auto results = mPhysics->applyQueuedMovement(duration, mDiscardMovements); + const auto results = mPhysics->applyQueuedMovement(duration, mDiscardMovements, frameStart, frameNumber, stats); mDiscardMovements = false; for(const auto& [actor, position]: results) @@ -1830,11 +1831,11 @@ namespace MWWorld } } - void World::updatePhysics (float duration, bool paused) + void World::updatePhysics (float duration, bool paused, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) { if (!paused) { - doPhysics (duration); + doPhysics (duration, frameStart, frameNumber, stats); } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 909ac1d41..41ab9cf2c 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -157,7 +157,7 @@ namespace MWWorld void processDoors(float duration); ///< Run physics simulation and modify \a world accordingly. - void doPhysics(float duration); + void doPhysics(float duration, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats); ///< Run physics simulation and modify \a world accordingly. void updateNavigator(); @@ -493,7 +493,7 @@ namespace MWWorld /// \return pointer to created record void update (float duration, bool paused) override; - void updatePhysics (float duration, bool paused) override; + void updatePhysics (float duration, bool paused, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) override; void updateWindowManager () override; From 96e22bd44e58e69487456759ffc0a11125ecc7b7 Mon Sep 17 00:00:00 2001 From: psi29a Date: Mon, 23 Nov 2020 06:05:45 +0000 Subject: [PATCH 21/28] Merge branch 'fastforwardpos' into 'master' Discard physics simulation results after fast forward See merge request OpenMW/openmw!423 (cherry picked from commit ff2d7695698341ef059c75707aa092cef48deea4) 03a37433 In case of time fast forward (resting, jail), force reset of positions --- apps/openmw/mwworld/worldimp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 54b94833e..20ee7625b 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -890,6 +890,7 @@ namespace MWWorld { mRendering->notifyWorldSpaceChanged(); mProjectileManager->clear(); + mDiscardMovements = true; } } From 4acd910b3768f0f0d3e941d318dad8480d15e0f0 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 13 Nov 2020 10:36:26 +0400 Subject: [PATCH 22/28] Rework file error messages handling --- components/files/lowlevelfile.cpp | 100 +++++++++++++++++++----------- 1 file changed, 65 insertions(+), 35 deletions(-) diff --git a/components/files/lowlevelfile.cpp b/components/files/lowlevelfile.cpp index 424527b9d..07915abba 100644 --- a/components/files/lowlevelfile.cpp +++ b/components/files/lowlevelfile.cpp @@ -4,6 +4,11 @@ #include #include +#if FILE_API == FILE_API_STDIO +#include +#include +#endif + #if FILE_API == FILE_API_POSIX #include #include @@ -39,7 +44,7 @@ void LowLevelFile::open (char const * filename) if (mHandle == nullptr) { std::ostringstream os; - os << "Failed to open '" << filename << "' for reading."; + os << "Failed to open '" << filename << "' for reading: " << strerror(errno); throw std::runtime_error (os.str ()); } } @@ -58,42 +63,63 @@ size_t LowLevelFile::size () assert (mHandle != nullptr); long oldPosition = ftell (mHandle); - if (oldPosition == -1) - throw std::runtime_error ("A query operation on a file failed."); + { + std::ostringstream os; + os << "An ftell() call failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } if (fseek (mHandle, 0, SEEK_END) != 0) - throw std::runtime_error ("A query operation on a file failed."); + { + std::ostringstream os; + os << "An fseek() call failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } - long Size = ftell (mHandle); - - if (Size == -1) - throw std::runtime_error ("A query operation on a file failed."); + long size = ftell (mHandle); + if (size == -1) + { + std::ostringstream os; + os << "An ftell() call failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } if (fseek (mHandle, oldPosition, SEEK_SET) != 0) - throw std::runtime_error ("A query operation on a file failed."); + { + std::ostringstream os; + os << "An fseek() call failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } - return size_t (Size); + return size_t (size); } -void LowLevelFile::seek (size_t Position) +void LowLevelFile::seek (size_t position) { assert (mHandle != nullptr); - if (fseek (mHandle, Position, SEEK_SET) != 0) - throw std::runtime_error ("A seek operation on a file failed."); + if (fseek (mHandle, position, SEEK_SET) != 0) + { + std::ostringstream os; + os << "An fseek() call failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } } size_t LowLevelFile::tell () { assert (mHandle != nullptr); - long Position = ftell (mHandle); + long position = ftell (mHandle); + if (position == -1) + { + std::ostringstream os; + os << "An ftell() call failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } - if (Position == -1) - throw std::runtime_error ("A query operation on a file failed."); - - return size_t (Position); + return size_t (position); } size_t LowLevelFile::read (void * data, size_t size) @@ -103,7 +129,11 @@ size_t LowLevelFile::read (void * data, size_t size) int amount = fread (data, 1, size, mHandle); if (amount == 0 && ferror (mHandle)) - throw std::runtime_error ("A read operation on a file failed."); + { + std::ostringstream os; + os << "An attempt to read " << size << " bytes failed: " << strerror(errno); + throw std::runtime_error (os.str ()); + } return amount; } @@ -164,37 +194,37 @@ size_t LowLevelFile::size () if (oldPosition == size_t (-1)) { std::ostringstream os; - os << "An lseek() call failed:" << strerror(errno); + os << "An lseek() call failed: " << strerror(errno); throw std::runtime_error (os.str ()); } - size_t Size = ::lseek (mHandle, 0, SEEK_END); + size_t size = ::lseek (mHandle, 0, SEEK_END); - if (Size == size_t (-1)) + if (size == size_t (-1)) { std::ostringstream os; - os << "An lseek() call failed:" << strerror(errno); + os << "An lseek() call failed: " << strerror(errno); throw std::runtime_error (os.str ()); } if (lseek (mHandle, oldPosition, SEEK_SET) == -1) { std::ostringstream os; - os << "An lseek() call failed:" << strerror(errno); + os << "An lseek() call failed: " << strerror(errno); throw std::runtime_error (os.str ()); } - return Size; + return size; } -void LowLevelFile::seek (size_t Position) +void LowLevelFile::seek (size_t position) { assert (mHandle != -1); - if (::lseek (mHandle, Position, SEEK_SET) == -1) + if (::lseek (mHandle, position, SEEK_SET) == -1) { std::ostringstream os; - os << "An lseek() call failed:" << strerror(errno); + os << "An lseek() call failed: " << strerror(errno); throw std::runtime_error (os.str ()); } } @@ -203,16 +233,16 @@ size_t LowLevelFile::tell () { assert (mHandle != -1); - size_t Position = ::lseek (mHandle, 0, SEEK_CUR); + size_t position = ::lseek (mHandle, 0, SEEK_CUR); - if (Position == size_t (-1)) + if (position == size_t (-1)) { std::ostringstream os; - os << "An lseek() call failed:" << strerror(errno); + os << "An lseek() call failed: " << strerror(errno); throw std::runtime_error (os.str ()); } - return Position; + return position; } size_t LowLevelFile::read (void * data, size_t size) @@ -224,7 +254,7 @@ size_t LowLevelFile::read (void * data, size_t size) if (amount == -1) { std::ostringstream os; - os << "An attempt to read " << size << "bytes failed:" << strerror(errno); + os << "An attempt to read " << size << " bytes failed: " << strerror(errno); throw std::runtime_error (os.str ()); } @@ -292,11 +322,11 @@ size_t LowLevelFile::size () return info.nFileSizeLow; } -void LowLevelFile::seek (size_t Position) +void LowLevelFile::seek (size_t position) { assert (mHandle != INVALID_HANDLE_VALUE); - if (SetFilePointer (mHandle, Position, nullptr, SEEK_SET) == INVALID_SET_FILE_POINTER) + if (SetFilePointer (mHandle, position, nullptr, SEEK_SET) == INVALID_SET_FILE_POINTER) if (GetLastError () != NO_ERROR) throw std::runtime_error ("A seek operation on a file failed."); } From 5b6377b061b1814b25e81d5927285acce8f70825 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Sat, 28 Nov 2020 13:12:30 +0300 Subject: [PATCH 23/28] Handle multiple root nodes (bug #5604) --- CHANGELOG.md | 1 + components/nifbullet/bulletnifloader.cpp | 95 +++++++++++++----------- components/nifosg/nifloader.cpp | 53 +++++++------ 3 files changed, 81 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f909a19f..7257e2338 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ Bug #5557: Diagonal movement is noticeably slower with analogue stick Bug #5588: Randomly clicking on the journal's right-side page when it's empty shows random topics Bug #5603: Setting constant effect cast style doesn't correct effects view + Bug #5604: Only one valid NIF root node is loaded from a single file Bug #5611: Usable items with "0 Uses" should be used only once Bug #5622: Can't properly interact with the console when in pause menu Bug #5633: Damage Spells in effect before god mode is enabled continue to hurt the player character and can kill them diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index b1461e536..db9d5ae43 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -123,73 +123,79 @@ osg::ref_ptr BulletNifLoader::load(const Nif::File& nif) mStaticMesh.reset(); mAvoidStaticMesh.reset(); - Nif::Node* node = nullptr; const size_t numRoots = nif.numRoots(); + std::vector roots; for (size_t i = 0; i < numRoots; ++i) { Nif::Record* r = nif.getRoot(i); assert(r != nullptr); + Nif::Node* node = nullptr; if ((node = dynamic_cast(r))) - break; + roots.emplace_back(node); } const std::string filename = nif.getFilename(); - if (!node) + if (roots.empty()) { warn("Found no root nodes in NIF file " + filename); return mShape; } - if (findBoundingBox(node, filename)) + // Try to find a valid bounding box first. If one's found for any root node, use that. + for (const Nif::Node* node : roots) { - const btVector3 halfExtents = Misc::Convert::toBullet(mShape->mCollisionBoxHalfExtents); - const btVector3 origin = Misc::Convert::toBullet(mShape->mCollisionBoxTranslate); - std::unique_ptr compound (new btCompoundShape); - std::unique_ptr boxShape(new btBoxShape(halfExtents)); - btTransform transform = btTransform::getIdentity(); - transform.setOrigin(origin); - compound->addChildShape(transform, boxShape.get()); - boxShape.release(); + if (findBoundingBox(node, filename)) + { + const btVector3 halfExtents = Misc::Convert::toBullet(mShape->mCollisionBoxHalfExtents); + const btVector3 origin = Misc::Convert::toBullet(mShape->mCollisionBoxTranslate); + std::unique_ptr compound (new btCompoundShape); + std::unique_ptr boxShape(new btBoxShape(halfExtents)); + btTransform transform = btTransform::getIdentity(); + transform.setOrigin(origin); + compound->addChildShape(transform, boxShape.get()); + boxShape.release(); - mShape->mCollisionShape = compound.release(); - return mShape; + mShape->mCollisionShape = compound.release(); + return mShape; + } } - else + // files with the name convention xmodel.nif usually have keyframes stored in a separate file xmodel.kf (see Animation::addAnimSource). + // assume all nodes in the file will be animated + const bool isAnimated = pathFileNameStartsWithX(filename); + + // If there's no bounding box, we'll have to generate a Bullet collision shape + // from the collision data present in every root node. + for (const Nif::Node* node : roots) { bool autogenerated = hasAutoGeneratedCollision(node); - - // files with the name convention xmodel.nif usually have keyframes stored in a separate file xmodel.kf (see Animation::addAnimSource). - // assume all nodes in the file will be animated - const bool isAnimated = pathFileNameStartsWithX(filename); - handleNode(filename, node, 0, autogenerated, isAnimated, autogenerated); + } - if (mCompoundShape) + if (mCompoundShape) + { + if (mStaticMesh) { - if (mStaticMesh) - { - btTransform trans; - trans.setIdentity(); - std::unique_ptr child(new Resource::TriangleMeshShape(mStaticMesh.get(), true)); - mCompoundShape->addChildShape(trans, child.get()); - child.release(); - mStaticMesh.release(); - } - mShape->mCollisionShape = mCompoundShape.release(); - } - else if (mStaticMesh) - { - mShape->mCollisionShape = new Resource::TriangleMeshShape(mStaticMesh.get(), true); + btTransform trans; + trans.setIdentity(); + std::unique_ptr child(new Resource::TriangleMeshShape(mStaticMesh.get(), true)); + mCompoundShape->addChildShape(trans, child.get()); + child.release(); mStaticMesh.release(); } - - if (mAvoidStaticMesh) - { - mShape->mAvoidCollisionShape = new Resource::TriangleMeshShape(mAvoidStaticMesh.get(), false); - mAvoidStaticMesh.release(); - } - - return mShape; + mShape->mCollisionShape = mCompoundShape.release(); } + else if (mStaticMesh) + { + mShape->mCollisionShape = new Resource::TriangleMeshShape(mStaticMesh.get(), true); + mStaticMesh.release(); + } + + if (mAvoidStaticMesh) + { + mShape->mAvoidCollisionShape = new Resource::TriangleMeshShape(mAvoidStaticMesh.get(), false); + mAvoidStaticMesh.release(); + } + + return mShape; } // Find a boundingBox in the node hierarchy. @@ -228,8 +234,7 @@ bool BulletNifLoader::findBoundingBox(const Nif::Node* node, const std::string& { if(!list[i].empty()) { - bool found = findBoundingBox (list[i].getPtr(), filename); - if (found) + if (findBoundingBox(list[i].getPtr(), filename)) return true; } } diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index a5a61b317..815f1aef2 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -231,6 +231,9 @@ namespace NifOsg size_t mFirstRootTextureIndex = -1; bool mFoundFirstRootTexturingProperty = false; + bool mHasNightDayLabel = false; + bool mHasHerbalismLabel = false; + // This is used to queue emitters that weren't attached to their node yet. std::vector>> mEmitterQueue; @@ -294,20 +297,31 @@ namespace NifOsg osg::ref_ptr load(Nif::NIFFilePtr nif, Resource::ImageManager* imageManager) { - const Nif::Node* nifNode = nullptr; const size_t numRoots = nif->numRoots(); + std::vector roots; for (size_t i = 0; i < numRoots; ++i) { const Nif::Record* r = nif->getRoot(i); + const Nif::Node* nifNode = nullptr; if ((nifNode = dynamic_cast(r))) - break; + roots.emplace_back(nifNode); } - if (!nifNode) + if (roots.empty()) nif->fail("Found no root nodes"); osg::ref_ptr textkeys (new TextKeyMapHolder); - osg::ref_ptr created = handleNode(nifNode, nullptr, imageManager, std::vector(), 0, false, false, false, &textkeys->mTextKeys); + osg::ref_ptr created(new osg::Group); + created->setDataVariance(osg::Object::STATIC); + for (const Nif::Node* root : roots) + { + auto node = handleNode(root, nullptr, imageManager, std::vector(), 0, false, false, false, &textkeys->mTextKeys); + created->addChild(node); + } + if (mHasNightDayLabel) + created->getOrCreateUserDataContainer()->addDescription(Constants::NightDayLabel); + if (mHasHerbalismLabel) + created->getOrCreateUserDataContainer()->addDescription(Constants::HerbalismLabel); // Attach particle emitters to their nodes which should all be loaded by now. handleQueuedParticleEmitters(created, nif); @@ -315,18 +329,11 @@ namespace NifOsg if (nif->getUseSkinning()) { osg::ref_ptr skel = new SceneUtil::Skeleton; - - osg::Group* root = created->asGroup(); - if (root && root->getDataVariance() == osg::Object::STATIC && !root->asTransform()) - { - skel->setStateSet(root->getStateSet()); - skel->setName(root->getName()); - for (unsigned int i=0; igetNumChildren(); ++i) - skel->addChild(root->getChild(i)); - root->removeChildren(0, root->getNumChildren()); - } - else - skel->addChild(created); + skel->setStateSet(created->getStateSet()); + skel->setName(created->getName()); + for (unsigned int i=0; i < created->getNumChildren(); ++i) + skel->addChild(created->getChild(i)); + created->removeChildren(0, created->getNumChildren()); created = skel; } @@ -632,7 +639,7 @@ namespace NifOsg } if(nifNode->recType == Nif::RC_NiAutoNormalParticles || nifNode->recType == Nif::RC_NiRotatingParticles) - handleParticleSystem(nifNode, node, composite, animflags, rootNode); + handleParticleSystem(nifNode, node, composite, animflags); if (composite->getNumControllers() > 0) { @@ -662,10 +669,10 @@ namespace NifOsg const Nif::NiSwitchNode* niSwitchNode = static_cast(nifNode); osg::ref_ptr switchNode = handleSwitchNode(niSwitchNode); node->addChild(switchNode); - if (niSwitchNode->name == Constants::NightDayLabel && !SceneUtil::hasUserDescription(rootNode, Constants::NightDayLabel)) - rootNode->getOrCreateUserDataContainer()->addDescription(Constants::NightDayLabel); - else if (niSwitchNode->name == Constants::HerbalismLabel && !SceneUtil::hasUserDescription(rootNode, Constants::HerbalismLabel)) - rootNode->getOrCreateUserDataContainer()->addDescription(Constants::HerbalismLabel); + if (niSwitchNode->name == Constants::NightDayLabel) + mHasNightDayLabel = true; + else if (niSwitchNode->name == Constants::HerbalismLabel) + mHasHerbalismLabel = true; currentNode = switchNode; } @@ -1023,7 +1030,7 @@ namespace NifOsg return emitter; } - void handleQueuedParticleEmitters(osg::Node* rootNode, Nif::NIFFilePtr nif) + void handleQueuedParticleEmitters(osg::Group* rootNode, Nif::NIFFilePtr nif) { for (const auto& emitterPair : mEmitterQueue) { @@ -1044,7 +1051,7 @@ namespace NifOsg mEmitterQueue.clear(); } - void handleParticleSystem(const Nif::Node *nifNode, osg::Group *parentNode, SceneUtil::CompositeStateSetUpdater* composite, int animflags, osg::Node* rootNode) + void handleParticleSystem(const Nif::Node *nifNode, osg::Group *parentNode, SceneUtil::CompositeStateSetUpdater* composite, int animflags) { osg::ref_ptr partsys (new ParticleSystem); partsys->setSortMode(osgParticle::ParticleSystem::SORT_BACK_TO_FRONT); From 55dcc6582a7b5024994368fbdf07a998b1394cbd Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sat, 28 Nov 2020 15:03:10 +0200 Subject: [PATCH 24/28] Don't duplicate getFileExtension, use OpenMW's namespaces --- components/resource/keyframemanager.cpp | 20 ++++++-------------- components/resource/keyframemanager.hpp | 4 +--- components/resource/scenemanager.cpp | 17 ++++++++--------- components/resource/scenemanager.hpp | 1 + components/sceneutil/osgacontroller.cpp | 14 +++++++------- components/sceneutil/osgacontroller.hpp | 10 +++++----- 6 files changed, 28 insertions(+), 38 deletions(-) diff --git a/components/resource/keyframemanager.cpp b/components/resource/keyframemanager.cpp index 421b0ddf7..af0f365ee 100644 --- a/components/resource/keyframemanager.cpp +++ b/components/resource/keyframemanager.cpp @@ -14,7 +14,7 @@ #include "objectcache.hpp" #include "scenemanager.hpp" -namespace OsgAOpenMW +namespace Resource { RetrieveAnimationsVisitor::RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr animationManager) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), mTarget(target), mAnimationManager(animationManager) {} @@ -23,9 +23,9 @@ namespace OsgAOpenMW { if (node.libraryName() == std::string("osgAnimation") && node.className() == std::string("Bone") && node.getName() == std::string("root")) { - osg::ref_ptr callback = new OsgaController::KeyframeController(); + osg::ref_ptr callback = new SceneUtil::OsgAnimationController(); - std::vector emulatedAnimations; + std::vector emulatedAnimations; for (auto animation : mAnimationManager->getAnimationList()) { @@ -63,7 +63,7 @@ namespace OsgAOpenMW mTarget.mTextKeys.emplace(startTime, std::move(loopstart)); mTarget.mTextKeys.emplace(stopTime, std::move(loopstop)); - OsgaController::EmulatedAnimation emulatedAnimation; + SceneUtil::EmulatedAnimation emulatedAnimation; emulatedAnimation.mStartTime = startTime; emulatedAnimation.mStopTime = stopTime; emulatedAnimation.mName = animationName; @@ -76,14 +76,6 @@ namespace OsgAOpenMW traverse(node); } - - std::string getFileExtension(const std::string& file) - { - size_t extPos = file.find_last_of('.'); - if (extPos != std::string::npos && extPos+1 < file.size()) - return file.substr(extPos+1); - return std::string(); - } } namespace Resource @@ -110,7 +102,7 @@ namespace Resource else { osg::ref_ptr loaded (new SceneUtil::KeyframeHolder); - std::string ext = OsgAOpenMW::getFileExtension(normalized); + std::string ext = Resource::getFileExtension(normalized); if (ext == "kf") { NifOsg::Loader::loadKf(Nif::NIFFilePtr(new Nif::NIFFile(mVFS->getNormalized(normalized), normalized)), *loaded.get()); @@ -121,7 +113,7 @@ namespace Resource osg::ref_ptr bam = dynamic_cast (scene->getUpdateCallback()); if (bam) { - OsgAOpenMW::RetrieveAnimationsVisitor rav(*loaded.get(), bam); + Resource::RetrieveAnimationsVisitor rav(*loaded.get(), bam); scene->accept(rav); } } diff --git a/components/resource/keyframemanager.hpp b/components/resource/keyframemanager.hpp index 778b4bc9a..3e992ac5e 100644 --- a/components/resource/keyframemanager.hpp +++ b/components/resource/keyframemanager.hpp @@ -9,7 +9,7 @@ #include "resourcemanager.hpp" -namespace OsgAOpenMW +namespace Resource { /// @brief extract animations to OpenMW's animation system class RetrieveAnimationsVisitor : public osg::NodeVisitor @@ -24,8 +24,6 @@ namespace OsgAOpenMW osg::ref_ptr mAnimationManager; }; - - std::string getFileExtension(const std::string& file); } namespace Resource diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index e99003b74..2630cd453 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -338,17 +338,9 @@ namespace Resource Resource::ImageManager* mImageManager; }; - std::string getFileExtension(const std::string& file) - { - size_t extPos = file.find_last_of('.'); - if (extPos != std::string::npos && extPos+1 < file.size()) - return file.substr(extPos+1); - return std::string(); - } - osg::ref_ptr load (Files::IStreamPtr file, const std::string& normalizedFilename, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager) { - std::string ext = getFileExtension(normalizedFilename); + std::string ext = Resource::getFileExtension(normalizedFilename); if (ext == "nif") return NifOsg::Loader::load(nifFileManager->get(normalizedFilename), imageManager); else @@ -780,4 +772,11 @@ namespace Resource return shaderVisitor; } + std::string getFileExtension(const std::string& file) + { + size_t extPos = file.find_last_of('.'); + if (extPos != std::string::npos && extPos+1 < file.size()) + return file.substr(extPos+1); + return std::string(); + } } diff --git a/components/resource/scenemanager.hpp b/components/resource/scenemanager.hpp index 8df556158..fd75070a1 100644 --- a/components/resource/scenemanager.hpp +++ b/components/resource/scenemanager.hpp @@ -181,6 +181,7 @@ namespace Resource void operator = (const SceneManager&); }; + std::string getFileExtension(const std::string& file); } #endif diff --git a/components/sceneutil/osgacontroller.cpp b/components/sceneutil/osgacontroller.cpp index 503d9cf02..87e6f02fe 100644 --- a/components/sceneutil/osgacontroller.cpp +++ b/components/sceneutil/osgacontroller.cpp @@ -21,7 +21,7 @@ #include #include -namespace OsgaController +namespace SceneUtil { LinkVisitor::LinkVisitor() : osg::NodeVisitor( TRAVERSE_ALL_CHILDREN ) { @@ -101,14 +101,14 @@ namespace OsgaController apply(static_cast(node)); } - KeyframeController::KeyframeController(const KeyframeController ©, const osg::CopyOp ©op) : SceneUtil::KeyframeController(copy, copyop) + OsgAnimationController::OsgAnimationController(const OsgAnimationController ©, const osg::CopyOp ©op) : SceneUtil::KeyframeController(copy, copyop) , mMergedAnimationTracks(copy.mMergedAnimationTracks) , mEmulatedAnimations(copy.mEmulatedAnimations) { mLinker = nullptr; } - osg::Vec3f KeyframeController::getTranslation(float time) const + osg::Vec3f OsgAnimationController::getTranslation(float time) const { osg::Vec3f translationValue; std::string animationName; @@ -148,7 +148,7 @@ namespace OsgaController return osg::Vec3f(); } - void KeyframeController::update(float time, std::string animationName) + void OsgAnimationController::update(float time, std::string animationName) { for (const osg::ref_ptr mergedAnimationTrack : mMergedAnimationTracks) { @@ -156,7 +156,7 @@ namespace OsgaController } } - void KeyframeController::operator() (osg::Node* node, osg::NodeVisitor* nv) + void OsgAnimationController::operator() (osg::Node* node, osg::NodeVisitor* nv) { if (hasInput()) { @@ -185,12 +185,12 @@ namespace OsgaController traverse(node, nv); } - void KeyframeController::setEmulatedAnimations(std::vector emulatedAnimations) + void OsgAnimationController::setEmulatedAnimations(std::vector emulatedAnimations) { mEmulatedAnimations = emulatedAnimations; } - void KeyframeController::addMergedAnimationTrack(osg::ref_ptr animationTrack) + void OsgAnimationController::addMergedAnimationTrack(osg::ref_ptr animationTrack) { mMergedAnimationTracks.emplace_back(animationTrack); } diff --git a/components/sceneutil/osgacontroller.hpp b/components/sceneutil/osgacontroller.hpp index a3072088a..f1c1584c2 100644 --- a/components/sceneutil/osgacontroller.hpp +++ b/components/sceneutil/osgacontroller.hpp @@ -16,7 +16,7 @@ #include #include -namespace OsgaController +namespace SceneUtil { struct EmulatedAnimation { @@ -44,15 +44,15 @@ namespace OsgaController Resource::Animation* mAnimation; }; - class KeyframeController : public SceneUtil::KeyframeController + class OsgAnimationController : public SceneUtil::KeyframeController { public: /// @brief Handles the animation for osgAnimation formats - KeyframeController() {}; + OsgAnimationController() {}; - KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop); + OsgAnimationController(const OsgAnimationController& copy, const osg::CopyOp& copyop); - META_Object(OsgaController, KeyframeController) + META_Object(SceneUtil, OsgAnimationController) /// @brief Handles the location of the instance osg::Vec3f getTranslation(float time) const override; From ea2ba27084c38485ee3ad5fb2fa27e370e9e0e82 Mon Sep 17 00:00:00 2001 From: fredzio Date: Sat, 28 Nov 2020 20:45:23 +0100 Subject: [PATCH 25/28] Move the moment when the actor origin is saved before simulation so to be sure the simulation is over. Otherwise, if the simulation is too slow the position is wrong, and the actors would jump back and forth between old and new position instead of actually moving. --- apps/openmw/mwphysics/actor.cpp | 33 +++++++++++++++++-------- apps/openmw/mwphysics/actor.hpp | 8 +++--- apps/openmw/mwphysics/mtphysics.cpp | 7 ++++-- apps/openmw/mwphysics/physicssystem.cpp | 5 +++- apps/openmw/mwphysics/physicssystem.hpp | 1 + 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 430bd4dee..0e557378d 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -118,10 +118,15 @@ int Actor::getCollisionMask() const return collisionMask; } +void Actor::updatePositionUnsafe() +{ + mWorldPosition = mPtr.getRefData().getPosition().asVec3(); +} + void Actor::updatePosition() { std::scoped_lock lock(mPositionMutex); - mWorldPosition = mPtr.getRefData().getPosition().asVec3(); + updatePositionUnsafe(); } osg::Vec3f Actor::getWorldPosition() const @@ -130,19 +135,18 @@ osg::Vec3f Actor::getWorldPosition() const return mWorldPosition; } -void Actor::setNextPosition(const osg::Vec3f& position) +void Actor::setSimulationPosition(const osg::Vec3f& position) { - mNextPosition = position; + mSimulationPosition = position; } -osg::Vec3f Actor::getNextPosition() const +osg::Vec3f Actor::getSimulationPosition() const { - return mNextPosition; + return mSimulationPosition; } -void Actor::updateCollisionObjectPosition() +void Actor::updateCollisionObjectPositionUnsafe() { - std::scoped_lock lock(mPositionMutex); mShape->setLocalScaling(Misc::Convert::toBullet(mScale)); osg::Vec3f scaledTranslation = mRotation * osg::componentMultiply(mMeshTranslation, mScale); osg::Vec3f newPosition = scaledTranslation + mPosition; @@ -151,6 +155,12 @@ void Actor::updateCollisionObjectPosition() mCollisionObject->setWorldTransform(mLocalTransform); } +void Actor::updateCollisionObjectPosition() +{ + std::scoped_lock lock(mPositionMutex); + updateCollisionObjectPositionUnsafe(); +} + osg::Vec3f Actor::getCollisionObjectPosition() const { std::scoped_lock lock(mPositionMutex); @@ -159,23 +169,26 @@ osg::Vec3f Actor::getCollisionObjectPosition() const void Actor::setPosition(const osg::Vec3f& position) { + std::scoped_lock lock(mPositionMutex); mPreviousPosition = mPosition; mPosition = position; } void Actor::adjustPosition(const osg::Vec3f& offset) { + std::scoped_lock lock(mPositionMutex); mPosition += offset; mPreviousPosition += offset; } void Actor::resetPosition() { - updatePosition(); + std::scoped_lock lock(mPositionMutex); + updatePositionUnsafe(); mPreviousPosition = mWorldPosition; mPosition = mWorldPosition; - mNextPosition = mWorldPosition; - updateCollisionObjectPosition(); + mSimulationPosition = mWorldPosition; + updateCollisionObjectPositionUnsafe(); } osg::Vec3f Actor::getPosition() const diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index 3d6f93ae0..07a9bebd2 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -67,8 +67,8 @@ namespace MWPhysics * Used by the physics simulation to store the simulation result. Used in conjunction with mWorldPosition * to account for e.g. scripted movements */ - void setNextPosition(const osg::Vec3f& position); - osg::Vec3f getNextPosition() const; + void setSimulationPosition(const osg::Vec3f& position); + osg::Vec3f getSimulationPosition() const; void updateCollisionObjectPosition(); @@ -154,6 +154,8 @@ namespace MWPhysics void updateCollisionMask(); void addCollisionMask(int collisionMask); int getCollisionMask() const; + void updateCollisionObjectPositionUnsafe(); + void updatePositionUnsafe(); bool mCanWaterWalk; std::atomic mWalkingOnWater; @@ -172,7 +174,7 @@ namespace MWPhysics osg::Vec3f mScale; osg::Vec3f mRenderingScale; osg::Vec3f mWorldPosition; - osg::Vec3f mNextPosition; + osg::Vec3f mSimulationPosition; osg::Vec3f mPosition; osg::Vec3f mPreviousPosition; btTransform mLocalTransform; diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 8c06e0140..2d4009e7d 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -219,6 +219,9 @@ namespace MWPhysics std::unique_lock lock(mSimulationMutex); + for (auto& data : actorsData) + data.updatePosition(); + // start by finishing previous background computation if (mNumThreads != 0) { @@ -233,7 +236,7 @@ namespace MWPhysics data.mActorRaw->setStandingOnPtr(data.mStandingOn); if (mMovementResults.find(data.mPtr) != mMovementResults.end()) - data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); + data.mActorRaw->setSimulationPosition(mMovementResults[data.mPtr]); } if (mFrameNumber == frameNumber - 1) @@ -284,7 +287,7 @@ namespace MWPhysics if (mAdvanceSimulation) data.mActorRaw->setStandingOnPtr(data.mStandingOn); if (mMovementResults.find(data.mPtr) != mMovementResults.end()) - data.mActorRaw->setNextPosition(mMovementResults[data.mPtr]); + data.mActorRaw->setSimulationPosition(mMovementResults[data.mPtr]); } return mMovementResults; } diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 1ceba2f31..7aa1f5914 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -877,9 +877,12 @@ namespace MWPhysics mWantJump = mPtr.getClass().getMovementSettings(mPtr).mPosition[2] != 0; mIsDead = mPtr.getClass().getCreatureStats(mPtr).isDead(); mWasOnGround = actor->getOnGround(); + } + void ActorFrameData::updatePosition() + { mActorRaw->updatePosition(); - mOrigin = mActorRaw->getNextPosition(); + mOrigin = mActorRaw->getSimulationPosition(); mPosition = mActorRaw->getPosition(); if (mMoveToWaterSurface) { diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 379aea1dd..03ae78993 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -78,6 +78,7 @@ namespace MWPhysics struct ActorFrameData { ActorFrameData(const std::shared_ptr& actor, const MWWorld::Ptr character, const MWWorld::Ptr standingOn, bool moveToWaterSurface, osg::Vec3f movement, float slowFall, float waterlevel); + void updatePosition(); std::weak_ptr mActor; Actor* mActorRaw; MWWorld::Ptr mPtr; From 8084a336b52f0d0a1938f1d22732f91baf21a3e3 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 13 Nov 2020 11:39:47 +0400 Subject: [PATCH 26/28] Replace zeroes and nulls by nullptrs --- apps/launcher/advancedpage.hpp | 2 +- apps/launcher/datafilespage.hpp | 2 +- apps/launcher/graphicspage.hpp | 2 +- apps/launcher/maindialog.hpp | 2 +- apps/launcher/playpage.hpp | 2 +- apps/launcher/settingspage.hpp | 2 +- apps/launcher/utils/lineedit.hpp | 2 +- apps/launcher/utils/profilescombobox.cpp | 2 +- apps/launcher/utils/profilescombobox.hpp | 4 +- apps/launcher/utils/textinputdialog.cpp | 2 +- apps/launcher/utils/textinputdialog.hpp | 2 +- apps/opencs/model/doc/operationholder.hpp | 2 +- apps/opencs/model/doc/runner.cpp | 8 +- apps/opencs/model/prefs/boolsetting.cpp | 4 +- apps/opencs/model/prefs/coloursetting.cpp | 2 +- apps/opencs/model/prefs/doublesetting.cpp | 2 +- apps/opencs/model/prefs/enumsetting.cpp | 2 +- apps/opencs/model/prefs/intsetting.cpp | 2 +- apps/opencs/model/prefs/modifiersetting.cpp | 2 +- apps/opencs/model/prefs/shortcut.cpp | 8 +- apps/opencs/model/prefs/shortcutmanager.cpp | 2 +- apps/opencs/model/prefs/shortcutsetting.cpp | 2 +- apps/opencs/model/prefs/state.cpp | 4 +- apps/opencs/model/tools/mergestages.cpp | 2 +- apps/opencs/model/tools/mergestages.hpp | 2 +- apps/opencs/model/tools/scriptcheck.cpp | 6 +- apps/opencs/model/tools/searchstage.cpp | 2 +- apps/opencs/model/tools/tools.cpp | 6 +- apps/opencs/model/world/columnimp.hpp | 8 +- apps/opencs/model/world/commanddispatcher.hpp | 2 +- apps/opencs/model/world/commands.cpp | 4 +- apps/opencs/model/world/commands.hpp | 18 ++--- apps/opencs/model/world/data.cpp | 18 ++--- apps/opencs/model/world/idtableproxymodel.hpp | 2 +- .../model/world/infotableproxymodel.hpp | 2 +- apps/opencs/model/world/record.hpp | 2 +- apps/opencs/model/world/refidcollection.cpp | 2 +- apps/opencs/model/world/resources.hpp | 4 +- apps/opencs/view/doc/adjusterwidget.hpp | 2 +- apps/opencs/view/doc/filedialog.cpp | 2 +- apps/opencs/view/doc/filedialog.hpp | 2 +- apps/opencs/view/doc/filewidget.hpp | 2 +- .../view/doc/globaldebugprofilemenu.cpp | 4 +- .../view/doc/globaldebugprofilemenu.hpp | 2 +- apps/opencs/view/doc/loader.cpp | 2 +- apps/opencs/view/doc/sizehint.hpp | 2 +- apps/opencs/view/doc/view.cpp | 2 +- apps/opencs/view/doc/viewmanager.hpp | 2 +- apps/opencs/view/filter/editwidget.hpp | 2 +- apps/opencs/view/filter/filterbox.hpp | 2 +- apps/opencs/view/filter/recordfilterbox.hpp | 2 +- apps/opencs/view/prefs/keybindingpage.cpp | 6 +- apps/opencs/view/render/cell.cpp | 4 +- apps/opencs/view/render/cellwater.cpp | 8 +- apps/opencs/view/render/editmode.hpp | 2 +- apps/opencs/view/render/instancemode.cpp | 6 +- apps/opencs/view/render/instancemode.hpp | 2 +- apps/opencs/view/render/instancemovemode.hpp | 2 +- apps/opencs/view/render/lighting.hpp | 2 +- apps/opencs/view/render/object.cpp | 2 +- apps/opencs/view/render/orbitcameramode.cpp | 4 +- .../view/render/pagedworldspacewidget.cpp | 2 +- apps/opencs/view/render/pathgrid.cpp | 12 +-- apps/opencs/view/render/pathgridmode.cpp | 6 +- apps/opencs/view/render/pathgridmode.hpp | 2 +- apps/opencs/view/render/previewwidget.hpp | 2 +- apps/opencs/view/render/scenewidget.cpp | 4 +- apps/opencs/view/render/terrainshapemode.cpp | 16 ++-- .../opencs/view/render/terraintexturemode.cpp | 18 ++--- apps/opencs/view/render/worldspacewidget.cpp | 10 +-- apps/opencs/view/render/worldspacewidget.hpp | 2 +- apps/opencs/view/tools/merge.cpp | 4 +- apps/opencs/view/tools/merge.hpp | 2 +- apps/opencs/view/tools/reporttable.cpp | 6 +- apps/opencs/view/tools/reporttable.hpp | 2 +- apps/opencs/view/tools/searchbox.hpp | 2 +- apps/opencs/view/tools/searchsubview.cpp | 2 +- apps/opencs/view/widget/coloreditor.hpp | 6 +- apps/opencs/view/widget/completerpopup.hpp | 2 +- apps/opencs/view/widget/droplineedit.hpp | 2 +- apps/opencs/view/widget/modebutton.hpp | 2 +- apps/opencs/view/widget/pushbutton.hpp | 4 +- apps/opencs/view/widget/scenetoolbar.hpp | 4 +- apps/opencs/view/widget/scenetoolmode.cpp | 4 +- .../view/widget/scenetoolshapebrush.hpp | 2 +- .../view/widget/scenetooltexturebrush.hpp | 2 +- apps/opencs/view/widget/scenetooltoggle.cpp | 2 +- apps/opencs/view/widget/scenetooltoggle2.cpp | 2 +- apps/opencs/view/world/creator.cpp | 2 +- apps/opencs/view/world/dialoguespinbox.hpp | 4 +- apps/opencs/view/world/dialoguesubview.cpp | 12 +-- apps/opencs/view/world/dialoguesubview.hpp | 4 +- apps/opencs/view/world/enumdelegate.cpp | 2 +- .../world/extendedcommandconfigurator.hpp | 2 +- apps/opencs/view/world/genericcreator.cpp | 8 +- .../view/world/idcompletiondelegate.cpp | 2 +- apps/opencs/view/world/idvalidator.hpp | 2 +- apps/opencs/view/world/recordbuttonbar.hpp | 4 +- .../view/world/recordstatusdelegate.hpp | 2 +- apps/opencs/view/world/regionmap.hpp | 2 +- apps/opencs/view/world/scriptedit.cpp | 4 +- apps/opencs/view/world/scripterrortable.hpp | 2 +- apps/opencs/view/world/scriptsubview.cpp | 4 +- apps/opencs/view/world/tablebottombox.hpp | 2 +- apps/opencs/view/world/tableeditidaction.hpp | 2 +- apps/opencs/view/world/util.cpp | 8 +- apps/openmw/engine.cpp | 2 +- apps/openmw/mwbase/environment.cpp | 26 +++---- apps/openmw/mwbase/statemanager.hpp | 2 +- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwgui/bookpage.cpp | 6 +- apps/openmw/mwgui/charactercreation.cpp | 54 +++++++------- apps/openmw/mwgui/class.cpp | 16 ++-- apps/openmw/mwgui/console.cpp | 2 +- apps/openmw/mwgui/draganddrop.cpp | 2 +- apps/openmw/mwgui/mainmenu.cpp | 2 +- apps/openmw/mwgui/mapwindow.cpp | 2 +- apps/openmw/mwgui/quickkeysmenu.cpp | 6 +- apps/openmw/mwgui/review.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.cpp | 8 +- apps/openmw/mwgui/tooltips.cpp | 4 +- apps/openmw/mwgui/widgets.cpp | 4 +- apps/openmw/mwgui/windowmanagerimp.cpp | 2 +- apps/openmw/mwinput/mousemanager.cpp | 2 +- apps/openmw/mwmechanics/alchemy.cpp | 2 +- .../mwscript/transformationextensions.cpp | 4 +- apps/openmw/mwsound/ffmpeg_decoder.cpp | 2 +- apps/openmw/mwsound/openal_output.cpp | 24 +++--- apps/openmw/mwsound/sound_buffer.hpp | 2 +- apps/openmw/mwsound/soundmanagerimp.cpp | 4 +- apps/openmw/mwstate/character.cpp | 4 +- apps/openmw/mwstate/charactermanager.cpp | 2 +- apps/openmw/mwstate/statemanagerimp.hpp | 2 +- apps/openmw/mwworld/cells.cpp | 6 +- apps/openmw/mwworld/cellstore.cpp | 2 +- apps/openmw/mwworld/containerstore.cpp | 28 +++---- apps/openmw/mwworld/esmstore.cpp | 4 +- apps/openmw/mwworld/esmstore.hpp | 6 +- apps/openmw/mwworld/manualref.cpp | 2 +- apps/openmw/mwworld/player.cpp | 8 +- apps/openmw/mwworld/ptr.cpp | 4 +- apps/openmw/mwworld/ptr.hpp | 24 +++--- apps/openmw/mwworld/refdata.cpp | 18 ++--- apps/openmw/mwworld/scene.cpp | 4 +- apps/openmw/mwworld/store.cpp | 34 ++++----- apps/openmw/mwworld/store.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 12 +-- apps/openmw/mwworld/worldimp.hpp | 2 +- apps/wizard/mainwizard.hpp | 2 +- apps/wizard/unshield/unshieldworker.hpp | 2 +- apps/wizard/utils/componentlistwidget.hpp | 2 +- components/compiler/context.hpp | 4 +- .../contentselector/model/contentmodel.cpp | 6 +- components/contentselector/model/esmfile.hpp | 2 +- .../contentselector/model/modelitem.hpp | 2 +- components/contentselector/view/combobox.cpp | 2 +- components/contentselector/view/combobox.hpp | 2 +- .../contentselector/view/contentselector.hpp | 2 +- components/crashcatcher/crashcatcher.cpp | 2 +- components/detournavigator/findsmoothpath.cpp | 4 +- components/detournavigator/findsmoothpath.hpp | 4 +- components/esm/loadcell.hpp | 2 +- components/esm/variant.cpp | 14 ++-- components/esm/variantimp.hpp | 6 +- components/esmterrain/storage.cpp | 14 ++-- components/files/constrainedfilestream.cpp | 6 +- components/interpreter/runtime.cpp | 6 +- .../myguiplatform/myguirendermanager.cpp | 2 +- components/nifosg/particle.cpp | 2 +- components/resource/imagemanager.cpp | 2 +- components/resource/objectcache.hpp | 2 +- components/sceneutil/lightmanager.cpp | 4 +- components/sdlutil/sdlcursormanager.cpp | 4 +- components/sdlutil/sdlgraphicswindow.cpp | 6 +- components/sdlutil/sdlgraphicswindow.hpp | 2 +- components/terrain/quadtreenode.cpp | 2 +- components/widgets/box.cpp | 8 +- components/widgets/list.cpp | 8 +- .../osg-ffmpeg-videoplayer/audiodecoder.cpp | 8 +- extern/osg-ffmpeg-videoplayer/videoplayer.cpp | 6 +- extern/osg-ffmpeg-videoplayer/videostate.cpp | 74 +++++++++---------- extern/osg-ffmpeg-videoplayer/videostate.hpp | 2 +- 183 files changed, 483 insertions(+), 483 deletions(-) diff --git a/apps/launcher/advancedpage.hpp b/apps/launcher/advancedpage.hpp index bdf5af0c8..ef2f4740f 100644 --- a/apps/launcher/advancedpage.hpp +++ b/apps/launcher/advancedpage.hpp @@ -20,7 +20,7 @@ namespace Launcher public: AdvancedPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, - Settings::Manager &engineSettings, QWidget *parent = 0); + Settings::Manager &engineSettings, QWidget *parent = nullptr); bool loadSettings(); void saveSettings(); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index af54fe75e..92984847e 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -32,7 +32,7 @@ namespace Launcher public: explicit DataFilesPage (Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, - Config::LauncherSettings &launcherSettings, QWidget *parent = 0); + Config::LauncherSettings &launcherSettings, QWidget *parent = nullptr); QAbstractItemModel* profilesModel() const; diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index 3b03a72bd..55178e0d7 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -20,7 +20,7 @@ namespace Launcher Q_OBJECT public: - GraphicsPage(Files::ConfigurationManager &cfg, Settings::Manager &engineSettings, QWidget *parent = 0); + GraphicsPage(Files::ConfigurationManager &cfg, Settings::Manager &engineSettings, QWidget *parent = nullptr); void saveSettings(); bool loadSettings(); diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 214d31dd4..de7423330 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -48,7 +48,7 @@ namespace Launcher Q_OBJECT public: - explicit MainDialog(QWidget *parent = 0); + explicit MainDialog(QWidget *parent = nullptr); ~MainDialog(); FirstRunDialogResult showFirstRunDialog(); diff --git a/apps/launcher/playpage.hpp b/apps/launcher/playpage.hpp index 1dc5bb0fe..b0bd3ee27 100644 --- a/apps/launcher/playpage.hpp +++ b/apps/launcher/playpage.hpp @@ -16,7 +16,7 @@ namespace Launcher Q_OBJECT public: - PlayPage(QWidget *parent = 0); + PlayPage(QWidget *parent = nullptr); void setProfilesModel(QAbstractItemModel *model); signals: diff --git a/apps/launcher/settingspage.hpp b/apps/launcher/settingspage.hpp index ccc2061dd..97b099dd6 100644 --- a/apps/launcher/settingspage.hpp +++ b/apps/launcher/settingspage.hpp @@ -24,7 +24,7 @@ namespace Launcher public: SettingsPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, - Config::LauncherSettings &launcherSettings, MainDialog *parent = 0); + Config::LauncherSettings &launcherSettings, MainDialog *parent = nullptr); ~SettingsPage(); void saveSettings(); diff --git a/apps/launcher/utils/lineedit.hpp b/apps/launcher/utils/lineedit.hpp index 50da73045..da28e858c 100644 --- a/apps/launcher/utils/lineedit.hpp +++ b/apps/launcher/utils/lineedit.hpp @@ -24,7 +24,7 @@ class LineEdit : public QLineEdit QString mPlaceholderText; public: - LineEdit(QWidget *parent = 0); + LineEdit(QWidget *parent = nullptr); protected: void resizeEvent(QResizeEvent *) override; diff --git a/apps/launcher/utils/profilescombobox.cpp b/apps/launcher/utils/profilescombobox.cpp index 7df89098e..462c2ebc2 100644 --- a/apps/launcher/utils/profilescombobox.cpp +++ b/apps/launcher/utils/profilescombobox.cpp @@ -33,7 +33,7 @@ void ProfilesComboBox::setEditEnabled(bool editable) ComboBoxLineEdit *edit = new ComboBoxLineEdit(this); setLineEdit(edit); - setCompleter(0); + setCompleter(nullptr); connect(lineEdit(), SIGNAL(editingFinished()), this, SLOT(slotEditingFinished())); diff --git a/apps/launcher/utils/profilescombobox.hpp b/apps/launcher/utils/profilescombobox.hpp index 7b83c41b2..065682f3d 100644 --- a/apps/launcher/utils/profilescombobox.hpp +++ b/apps/launcher/utils/profilescombobox.hpp @@ -16,12 +16,12 @@ public: class ComboBoxLineEdit : public LineEdit { public: - explicit ComboBoxLineEdit (QWidget *parent = 0); + explicit ComboBoxLineEdit (QWidget *parent = nullptr); }; public: - explicit ProfilesComboBox(QWidget *parent = 0); + explicit ProfilesComboBox(QWidget *parent = nullptr); void setEditEnabled(bool editable); void setCurrentProfile(int index) { diff --git a/apps/launcher/utils/textinputdialog.cpp b/apps/launcher/utils/textinputdialog.cpp index 385d086fd..70b827596 100644 --- a/apps/launcher/utils/textinputdialog.cpp +++ b/apps/launcher/utils/textinputdialog.cpp @@ -23,7 +23,7 @@ Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString & QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore mLineEdit = new LineEdit(this); mLineEdit->setValidator(validator); - mLineEdit->setCompleter(0); + mLineEdit->setCompleter(nullptr); QVBoxLayout *dialogLayout = new QVBoxLayout(this); dialogLayout->addWidget(label); diff --git a/apps/launcher/utils/textinputdialog.hpp b/apps/launcher/utils/textinputdialog.hpp index a9353956a..de0659963 100644 --- a/apps/launcher/utils/textinputdialog.hpp +++ b/apps/launcher/utils/textinputdialog.hpp @@ -15,7 +15,7 @@ namespace Launcher public: - explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0); + explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = nullptr); ~TextInputDialog (); inline LineEdit *lineEdit() { return mLineEdit; } diff --git a/apps/opencs/model/doc/operationholder.hpp b/apps/opencs/model/doc/operationholder.hpp index b73d61dab..69af6ed66 100644 --- a/apps/opencs/model/doc/operationholder.hpp +++ b/apps/opencs/model/doc/operationholder.hpp @@ -25,7 +25,7 @@ namespace CSMDoc public: - OperationHolder (Operation *operation = 0); + OperationHolder (Operation *operation = nullptr); void setOperation (Operation *operation); diff --git a/apps/opencs/model/doc/runner.cpp b/apps/opencs/model/doc/runner.cpp index 84bc61a9a..ccdff1444 100644 --- a/apps/opencs/model/doc/runner.cpp +++ b/apps/opencs/model/doc/runner.cpp @@ -8,7 +8,7 @@ #include "operationholder.hpp" CSMDoc::Runner::Runner (const boost::filesystem::path& projectPath) -: mRunning (false), mStartup (0), mProjectPath (projectPath) +: mRunning (false), mStartup (nullptr), mProjectPath (projectPath) { connect (&mProcess, SIGNAL (finished (int, QProcess::ExitStatus)), this, SLOT (finished (int, QProcess::ExitStatus))); @@ -25,7 +25,7 @@ CSMDoc::Runner::~Runner() { if (mRunning) { - disconnect (&mProcess, 0, this, 0); + disconnect (&mProcess, nullptr, this, nullptr); mProcess.kill(); mProcess.waitForFinished(); } @@ -36,7 +36,7 @@ void CSMDoc::Runner::start (bool delayed) if (mStartup) { delete mStartup; - mStartup = 0; + mStartup = nullptr; } if (!delayed) @@ -102,7 +102,7 @@ void CSMDoc::Runner::start (bool delayed) void CSMDoc::Runner::stop() { delete mStartup; - mStartup = 0; + mStartup = nullptr; if (mProcess.state()==QProcess::NotRunning) { diff --git a/apps/opencs/model/prefs/boolsetting.cpp b/apps/opencs/model/prefs/boolsetting.cpp index 6431dc6af..005875349 100644 --- a/apps/opencs/model/prefs/boolsetting.cpp +++ b/apps/opencs/model/prefs/boolsetting.cpp @@ -11,7 +11,7 @@ CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, bool default_) -: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0) +: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr) {} CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip) @@ -33,7 +33,7 @@ std::pair CSMPrefs::BoolSetting::makeWidgets (QWidget *par connect (mWidget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int))); - return std::make_pair (static_cast (0), mWidget); + return std::make_pair (static_cast (nullptr), mWidget); } void CSMPrefs::BoolSetting::updateWidget() diff --git a/apps/opencs/model/prefs/coloursetting.cpp b/apps/opencs/model/prefs/coloursetting.cpp index 1a41621da..e676ad91c 100644 --- a/apps/opencs/model/prefs/coloursetting.cpp +++ b/apps/opencs/model/prefs/coloursetting.cpp @@ -14,7 +14,7 @@ CSMPrefs::ColourSetting::ColourSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, QColor default_) -: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0) +: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr) {} CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip (const std::string& tooltip) diff --git a/apps/opencs/model/prefs/doublesetting.cpp b/apps/opencs/model/prefs/doublesetting.cpp index 8ae6f4818..757b67389 100644 --- a/apps/opencs/model/prefs/doublesetting.cpp +++ b/apps/opencs/model/prefs/doublesetting.cpp @@ -16,7 +16,7 @@ CSMPrefs::DoubleSetting::DoubleSetting (Category *parent, Settings::Manager *val QMutex *mutex, const std::string& key, const std::string& label, double default_) : Setting (parent, values, mutex, key, label), mPrecision(2), mMin (0), mMax (std::numeric_limits::max()), - mDefault (default_), mWidget(0) + mDefault (default_), mWidget(nullptr) {} CSMPrefs::DoubleSetting& CSMPrefs::DoubleSetting::setPrecision(int precision) diff --git a/apps/opencs/model/prefs/enumsetting.cpp b/apps/opencs/model/prefs/enumsetting.cpp index 62cac062a..ec3fca328 100644 --- a/apps/opencs/model/prefs/enumsetting.cpp +++ b/apps/opencs/model/prefs/enumsetting.cpp @@ -42,7 +42,7 @@ CSMPrefs::EnumValues& CSMPrefs::EnumValues::add (const std::string& value, const CSMPrefs::EnumSetting::EnumSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, const EnumValue& default_) -: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0) +: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr) {} CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::setTooltip (const std::string& tooltip) diff --git a/apps/opencs/model/prefs/intsetting.cpp b/apps/opencs/model/prefs/intsetting.cpp index 25dbf78c2..407ed11f0 100644 --- a/apps/opencs/model/prefs/intsetting.cpp +++ b/apps/opencs/model/prefs/intsetting.cpp @@ -15,7 +15,7 @@ CSMPrefs::IntSetting::IntSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, int default_) : Setting (parent, values, mutex, key, label), mMin (0), mMax (std::numeric_limits::max()), - mDefault (default_), mWidget(0) + mDefault (default_), mWidget(nullptr) {} CSMPrefs::IntSetting& CSMPrefs::IntSetting::setRange (int min, int max) diff --git a/apps/opencs/model/prefs/modifiersetting.cpp b/apps/opencs/model/prefs/modifiersetting.cpp index da6b2ccdd..288926d00 100644 --- a/apps/opencs/model/prefs/modifiersetting.cpp +++ b/apps/opencs/model/prefs/modifiersetting.cpp @@ -15,7 +15,7 @@ namespace CSMPrefs ModifierSetting::ModifierSetting(Category* parent, Settings::Manager* values, QMutex* mutex, const std::string& key, const std::string& label) : Setting(parent, values, mutex, key, label) - , mButton(0) + , mButton(nullptr) , mEditorActive(false) { } diff --git a/apps/opencs/model/prefs/shortcut.cpp b/apps/opencs/model/prefs/shortcut.cpp index 924b9535e..ff7b949a4 100644 --- a/apps/opencs/model/prefs/shortcut.cpp +++ b/apps/opencs/model/prefs/shortcut.cpp @@ -23,7 +23,7 @@ namespace CSMPrefs , mLastPos(0) , mActivationStatus(AS_Inactive) , mModifierStatus(false) - , mAction(0) + , mAction(nullptr) { assert (parent); @@ -42,7 +42,7 @@ namespace CSMPrefs , mLastPos(0) , mActivationStatus(AS_Inactive) , mModifierStatus(false) - , mAction(0) + , mAction(nullptr) { assert (parent); @@ -62,7 +62,7 @@ namespace CSMPrefs , mLastPos(0) , mActivationStatus(AS_Inactive) , mModifierStatus(false) - , mAction(0) + , mAction(nullptr) { assert (parent); @@ -218,6 +218,6 @@ namespace CSMPrefs void Shortcut::actionDeleted() { - mAction = 0; + mAction = nullptr; } } diff --git a/apps/opencs/model/prefs/shortcutmanager.cpp b/apps/opencs/model/prefs/shortcutmanager.cpp index f39492c6c..781ad4de3 100644 --- a/apps/opencs/model/prefs/shortcutmanager.cpp +++ b/apps/opencs/model/prefs/shortcutmanager.cpp @@ -781,7 +781,7 @@ namespace CSMPrefs std::make_pair((int)Qt::Key_LastNumberRedial , "LastNumberRedial"), std::make_pair((int)Qt::Key_Camera , "Camera"), std::make_pair((int)Qt::Key_CameraFocus , "CameraFocus"), - std::make_pair(0 , (const char*) 0) + std::make_pair(0 , (const char*) nullptr) }; } diff --git a/apps/opencs/model/prefs/shortcutsetting.cpp b/apps/opencs/model/prefs/shortcutsetting.cpp index de495b9fc..1c065f7da 100644 --- a/apps/opencs/model/prefs/shortcutsetting.cpp +++ b/apps/opencs/model/prefs/shortcutsetting.cpp @@ -18,7 +18,7 @@ namespace CSMPrefs ShortcutSetting::ShortcutSetting(Category* parent, Settings::Manager* values, QMutex* mutex, const std::string& key, const std::string& label) : Setting(parent, values, mutex, key, label) - , mButton(0) + , mButton(nullptr) , mEditorActive(false) , mEditorPos(0) { diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index abd1ddfc8..39aae48bd 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -12,7 +12,7 @@ #include "shortcutsetting.hpp" #include "modifiersetting.hpp" -CSMPrefs::State *CSMPrefs::State::sThis = 0; +CSMPrefs::State *CSMPrefs::State::sThis = nullptr; void CSMPrefs::State::load() { @@ -599,7 +599,7 @@ CSMPrefs::State::State (const Files::ConfigurationManager& configurationManager) CSMPrefs::State::~State() { - sThis = 0; + sThis = nullptr; } void CSMPrefs::State::save() diff --git a/apps/opencs/model/tools/mergestages.cpp b/apps/opencs/model/tools/mergestages.cpp index 897c3329c..016e2da39 100644 --- a/apps/opencs/model/tools/mergestages.cpp +++ b/apps/opencs/model/tools/mergestages.cpp @@ -104,7 +104,7 @@ void CSMTools::MergeReferencesStage::perform (int stage, CSMDoc::Messages& messa ref.mNew = false; CSMWorld::Record newRecord ( - CSMWorld::RecordBase::State_ModifiedOnly, 0, &ref); + CSMWorld::RecordBase::State_ModifiedOnly, nullptr, &ref); mState.mTarget->getData().getReferences().appendRecord (newRecord); } diff --git a/apps/opencs/model/tools/mergestages.hpp b/apps/opencs/model/tools/mergestages.hpp index bcb3fe2ad..a6b6de58f 100644 --- a/apps/opencs/model/tools/mergestages.hpp +++ b/apps/opencs/model/tools/mergestages.hpp @@ -82,7 +82,7 @@ namespace CSMTools const CSMWorld::Record& record = source.getRecord (stage); if (!record.isDeleted()) - target.appendRecord (CSMWorld::Record (CSMWorld::RecordBase::State_ModifiedOnly, 0, &record.get())); + target.appendRecord (CSMWorld::Record (CSMWorld::RecordBase::State_ModifiedOnly, nullptr, &record.get())); } class MergeRefIdsStage : public CSMDoc::Stage diff --git a/apps/opencs/model/tools/scriptcheck.cpp b/apps/opencs/model/tools/scriptcheck.cpp index 952127edf..46a74362b 100644 --- a/apps/opencs/model/tools/scriptcheck.cpp +++ b/apps/opencs/model/tools/scriptcheck.cpp @@ -50,7 +50,7 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, Type type) } CSMTools::ScriptCheckStage::ScriptCheckStage (const CSMDoc::Document& document) -: mDocument (document), mContext (document.getData()), mMessages (0), mWarningMode (Mode_Ignore) +: mDocument (document), mContext (document.getData()), mMessages (nullptr), mWarningMode (Mode_Ignore) { /// \todo add an option to configure warning mode setWarningsMode (0); @@ -73,7 +73,7 @@ int CSMTools::ScriptCheckStage::setup() mWarningMode = Mode_Strict; mContext.clear(); - mMessages = 0; + mMessages = nullptr; mId.clear(); Compiler::ErrorHandler::reset(); @@ -130,5 +130,5 @@ void CSMTools::ScriptCheckStage::perform (int stage, CSMDoc::Messages& messages) messages.add (id, stream.str(), "", CSMDoc::Message::Severity_SeriousError); } - mMessages = 0; + mMessages = nullptr; } diff --git a/apps/opencs/model/tools/searchstage.cpp b/apps/opencs/model/tools/searchstage.cpp index 3db10b0c3..7cd3f4924 100644 --- a/apps/opencs/model/tools/searchstage.cpp +++ b/apps/opencs/model/tools/searchstage.cpp @@ -5,7 +5,7 @@ #include "searchoperation.hpp" CSMTools::SearchStage::SearchStage (const CSMWorld::IdTableBase *model) -: mModel (model), mOperation (0) +: mModel (model), mOperation (nullptr) {} int CSMTools::SearchStage::setup() diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 07a721e8e..a3d7db497 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -43,7 +43,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::get (int type) case CSMDoc::State_Merging: return &mMerge; } - return 0; + return nullptr; } const CSMDoc::OperationHolder *CSMTools::Tools::get (int type) const @@ -138,8 +138,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() } CSMTools::Tools::Tools (CSMDoc::Document& document, ToUTF8::FromType encoding) -: mDocument (document), mData (document.getData()), mVerifierOperation (0), - mSearchOperation (0), mMergeOperation (0), mNextReportNumber (0), mEncoding (encoding) +: mDocument (document), mData (document.getData()), mVerifierOperation (nullptr), + mSearchOperation (nullptr), mMergeOperation (nullptr), mNextReportNumber (0), mEncoding (encoding) { // index 0: load error log mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel)); diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index c69ca1d84..17518937c 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -2254,7 +2254,7 @@ namespace CSMWorld QVariant get (const Record& record) const override { - const std::string *string = 0; + const std::string *string = nullptr; switch (this->mColumnId) { @@ -2272,7 +2272,7 @@ namespace CSMWorld void set (Record& record, const QVariant& data) override { - std::string *string = 0; + std::string *string = nullptr; ESXRecordT record2 = record.get(); @@ -2312,7 +2312,7 @@ namespace CSMWorld QVariant get (const Record& record) const override { - const std::string *string = 0; + const std::string *string = nullptr; switch (this->mColumnId) { @@ -2330,7 +2330,7 @@ namespace CSMWorld void set (Record& record, const QVariant& data) override { - std::string *string = 0; + std::string *string = nullptr; ESXRecordT record2 = record.get(); diff --git a/apps/opencs/model/world/commanddispatcher.hpp b/apps/opencs/model/world/commanddispatcher.hpp index 1d29e48c1..538fd7f18 100644 --- a/apps/opencs/model/world/commanddispatcher.hpp +++ b/apps/opencs/model/world/commanddispatcher.hpp @@ -34,7 +34,7 @@ namespace CSMWorld public: CommandDispatcher (CSMDoc::Document& document, const CSMWorld::UniversalId& id, - QObject *parent = 0); + QObject *parent = nullptr); ///< \param id ID of the table the commands should operate on primarily. void setEditLock (bool locked); diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index e9682d7c9..e33be1139 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -290,7 +290,7 @@ void CSMWorld::CreateCommand::undo() } CSMWorld::RevertCommand::RevertCommand (IdTable& model, const std::string& id, QUndoCommand* parent) -: QUndoCommand (parent), mModel (model), mId (id), mOld (0) +: QUndoCommand (parent), mModel (model), mId (id), mOld (nullptr) { setText (("Revert record " + id).c_str()); @@ -326,7 +326,7 @@ void CSMWorld::RevertCommand::undo() CSMWorld::DeleteCommand::DeleteCommand (IdTable& model, const std::string& id, CSMWorld::UniversalId::Type type, QUndoCommand* parent) -: QUndoCommand (parent), mModel (model), mId (id), mOld (0), mType(type) +: QUndoCommand (parent), mModel (model), mId (id), mOld (nullptr), mType(type) { setText (("Delete record " + id).c_str()); diff --git a/apps/opencs/model/world/commands.hpp b/apps/opencs/model/world/commands.hpp index 88af32636..5776cae36 100644 --- a/apps/opencs/model/world/commands.hpp +++ b/apps/opencs/model/world/commands.hpp @@ -140,7 +140,7 @@ namespace CSMWorld public: ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_, - QUndoCommand *parent = 0); + QUndoCommand *parent = nullptr); void redo() override; @@ -167,7 +167,7 @@ namespace CSMWorld public: - CreateCommand (IdTable& model, const std::string& id, QUndoCommand *parent = 0); + CreateCommand (IdTable& model, const std::string& id, QUndoCommand *parent = nullptr); void setType (UniversalId::Type type); @@ -189,7 +189,7 @@ namespace CSMWorld CloneCommand (IdTable& model, const std::string& idOrigin, const std::string& IdDestination, const UniversalId::Type type, - QUndoCommand* parent = 0); + QUndoCommand* parent = nullptr); void redo() override; @@ -208,7 +208,7 @@ namespace CSMWorld public: - RevertCommand (IdTable& model, const std::string& id, QUndoCommand *parent = 0); + RevertCommand (IdTable& model, const std::string& id, QUndoCommand *parent = nullptr); virtual ~RevertCommand(); @@ -231,7 +231,7 @@ namespace CSMWorld public: DeleteCommand (IdTable& model, const std::string& id, - UniversalId::Type type = UniversalId::Type_None, QUndoCommand *parent = 0); + UniversalId::Type type = UniversalId::Type_None, QUndoCommand *parent = nullptr); virtual ~DeleteCommand(); @@ -259,7 +259,7 @@ namespace CSMWorld { public: - CreatePathgridCommand(IdTable& model, const std::string& id, QUndoCommand *parent = 0); + CreatePathgridCommand(IdTable& model, const std::string& id, QUndoCommand *parent = nullptr); void redo() override; }; @@ -279,7 +279,7 @@ namespace CSMWorld public: - UpdateCellCommand (IdTable& model, int row, QUndoCommand *parent = 0); + UpdateCellCommand (IdTable& model, int row, QUndoCommand *parent = nullptr); void redo() override; @@ -316,7 +316,7 @@ namespace CSMWorld public: - DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0); + DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = nullptr); void redo() override; @@ -338,7 +338,7 @@ namespace CSMWorld public: - AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0); + AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = nullptr); void redo() override; diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 23720a99a..70c496e3f 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -68,7 +68,7 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, const std::vector& archives, const boost::filesystem::path& resDir) : mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), - mReader (0), mDialogue (0), mReaderIndex(1), + mReader (nullptr), mDialogue (nullptr), mReaderIndex(1), mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives) { mVFS.reset(new VFS::Manager(mFsStrict)); @@ -916,7 +916,7 @@ const CSMWorld::MetaData& CSMWorld::Data::getMetaData() const void CSMWorld::Data::setMetaData (const MetaData& metaData) { - Record record (RecordBase::State_ModifiedOnly, 0, &metaData); + Record record (RecordBase::State_ModifiedOnly, nullptr, &metaData); mMetaData.setRecord (0, record); } @@ -932,7 +932,7 @@ QAbstractItemModel *CSMWorld::Data::getTableModel (const CSMWorld::UniversalId& // construction of the ESX data where no update signals are available. if (id.getType()==UniversalId::Type_RegionMap) { - RegionMap *table = 0; + RegionMap *table = nullptr; addModel (table = new RegionMap (*this), UniversalId::Type_RegionMap, false); return table; } @@ -962,9 +962,9 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base // Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading std::shared_ptr ptr(mReader); mReaders.push_back(ptr); - mReader = 0; + mReader = nullptr; - mDialogue = 0; + mDialogue = nullptr; mReader = new ESM::ESMReader; mReader->setEncoder (&mEncoder); @@ -982,7 +982,7 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base metaData.mId = "sys::meta"; metaData.load (*mReader); - mMetaData.setRecord (0, Record (RecordBase::State_ModifiedOnly, 0, &metaData)); + mMetaData.setRecord (0, Record (RecordBase::State_ModifiedOnly, nullptr, &metaData)); } // Fix uninitialized master data index @@ -1064,9 +1064,9 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages) else delete mReader; - mReader = 0; + mReader = nullptr; - mDialogue = 0; + mDialogue = nullptr; loadFallbackEntries(); @@ -1151,7 +1151,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages) if (isDeleted) { // record vector can be shuffled around which would make pointer to record invalid - mDialogue = 0; + mDialogue = nullptr; if (mJournals.tryDelete (record.mId)) { diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index 14d705792..7e0563834 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -35,7 +35,7 @@ namespace CSMWorld public: - IdTableProxyModel (QObject *parent = 0); + IdTableProxyModel (QObject *parent = nullptr); virtual QModelIndex getModelIndex (const std::string& id, int column) const; diff --git a/apps/opencs/model/world/infotableproxymodel.hpp b/apps/opencs/model/world/infotableproxymodel.hpp index 6a8e66b4f..92afdabdc 100644 --- a/apps/opencs/model/world/infotableproxymodel.hpp +++ b/apps/opencs/model/world/infotableproxymodel.hpp @@ -28,7 +28,7 @@ namespace CSMWorld ///< \a currentRow is a row of the source model. public: - InfoTableProxyModel(UniversalId::Type type, QObject *parent = 0); + InfoTableProxyModel(UniversalId::Type type, QObject *parent = nullptr); void setSourceModel(QAbstractItemModel *sourceModel) override; diff --git a/apps/opencs/model/world/record.hpp b/apps/opencs/model/world/record.hpp index 82f2abe77..5f67a93b1 100644 --- a/apps/opencs/model/world/record.hpp +++ b/apps/opencs/model/world/record.hpp @@ -87,7 +87,7 @@ namespace CSMWorld template RecordBase *Record::modifiedCopy() const { - return new Record (State_ModifiedOnly, 0, &(this->get())); + return new Record (State_ModifiedOnly, nullptr, &(this->get())); } template diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 535a31ddd..cd2dd89df 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -350,7 +350,7 @@ CSMWorld::RefIdCollection::RefIdCollection() }; // for re-use in NPC records - const RefIdColumn *essential = 0; + const RefIdColumn *essential = nullptr; for (int i=0; sCreatureFlagTable[i].mName!=-1; ++i) { diff --git a/apps/opencs/model/world/resources.hpp b/apps/opencs/model/world/resources.hpp index 5e9872ea8..c217b793d 100644 --- a/apps/opencs/model/world/resources.hpp +++ b/apps/opencs/model/world/resources.hpp @@ -25,9 +25,9 @@ namespace CSMWorld /// \param type Type of resources in this table. Resources (const VFS::Manager* vfs, const std::string& baseDirectory, UniversalId::Type type, - const char * const *extensions = 0); + const char * const *extensions = nullptr); - void recreate(const VFS::Manager* vfs, const char * const *extensions = 0); + void recreate(const VFS::Manager* vfs, const char * const *extensions = nullptr); int getSize() const; diff --git a/apps/opencs/view/doc/adjusterwidget.hpp b/apps/opencs/view/doc/adjusterwidget.hpp index 91e308236..cec9ca229 100644 --- a/apps/opencs/view/doc/adjusterwidget.hpp +++ b/apps/opencs/view/doc/adjusterwidget.hpp @@ -32,7 +32,7 @@ namespace CSVDoc public: - AdjusterWidget (QWidget *parent = 0); + AdjusterWidget (QWidget *parent = nullptr); void setLocalData (const boost::filesystem::path& localData); void setAction (ContentAction action); diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 7a3fe398f..69490edca 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -18,7 +18,7 @@ #include "adjusterwidget.hpp" CSVDoc::FileDialog::FileDialog(QWidget *parent) : - QDialog(parent), mSelector (0), mAction(ContentAction_Undefined), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false) + QDialog(parent), mSelector (nullptr), mAction(ContentAction_Undefined), mFileWidget (nullptr), mAdjusterWidget (nullptr), mDialogBuilt(false) { ui.setupUi (this); resize(400, 400); diff --git a/apps/opencs/view/doc/filedialog.hpp b/apps/opencs/view/doc/filedialog.hpp index bec2c6869..6c48fa78b 100644 --- a/apps/opencs/view/doc/filedialog.hpp +++ b/apps/opencs/view/doc/filedialog.hpp @@ -42,7 +42,7 @@ namespace CSVDoc public: - explicit FileDialog(QWidget *parent = 0); + explicit FileDialog(QWidget *parent = nullptr); void showDialog (ContentAction action); void addFiles (const QString &path); diff --git a/apps/opencs/view/doc/filewidget.hpp b/apps/opencs/view/doc/filewidget.hpp index ab06f37f1..626b8d77d 100644 --- a/apps/opencs/view/doc/filewidget.hpp +++ b/apps/opencs/view/doc/filewidget.hpp @@ -23,7 +23,7 @@ namespace CSVDoc public: - FileWidget (QWidget *parent = 0); + FileWidget (QWidget *parent = nullptr); void setType (bool addon); diff --git a/apps/opencs/view/doc/globaldebugprofilemenu.cpp b/apps/opencs/view/doc/globaldebugprofilemenu.cpp index f0d9655dd..c898b819c 100644 --- a/apps/opencs/view/doc/globaldebugprofilemenu.cpp +++ b/apps/opencs/view/doc/globaldebugprofilemenu.cpp @@ -13,7 +13,7 @@ void CSVDoc::GlobalDebugProfileMenu::rebuild() clear(); delete mActions; - mActions = 0; + mActions = nullptr; int idColumn = mDebugProfiles->findColumnIndex (CSMWorld::Columns::ColumnId_Id); int stateColumn = mDebugProfiles->findColumnIndex (CSMWorld::Columns::ColumnId_Modification); @@ -48,7 +48,7 @@ void CSVDoc::GlobalDebugProfileMenu::rebuild() CSVDoc::GlobalDebugProfileMenu::GlobalDebugProfileMenu (CSMWorld::IdTable *debugProfiles, QWidget *parent) -: QMenu (parent), mDebugProfiles (debugProfiles), mActions (0) +: QMenu (parent), mDebugProfiles (debugProfiles), mActions (nullptr) { rebuild(); diff --git a/apps/opencs/view/doc/globaldebugprofilemenu.hpp b/apps/opencs/view/doc/globaldebugprofilemenu.hpp index 0d7906cce..e12ee306a 100644 --- a/apps/opencs/view/doc/globaldebugprofilemenu.hpp +++ b/apps/opencs/view/doc/globaldebugprofilemenu.hpp @@ -26,7 +26,7 @@ namespace CSVDoc public: - GlobalDebugProfileMenu (CSMWorld::IdTable *debugProfiles, QWidget *parent = 0); + GlobalDebugProfileMenu (CSMWorld::IdTable *debugProfiles, QWidget *parent = nullptr); void updateActions (bool running); diff --git a/apps/opencs/view/doc/loader.cpp b/apps/opencs/view/doc/loader.cpp index 49a53e179..1cdfc0173 100644 --- a/apps/opencs/view/doc/loader.cpp +++ b/apps/opencs/view/doc/loader.cpp @@ -17,7 +17,7 @@ void CSVDoc::LoadingDocument::closeEvent (QCloseEvent *event) } CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document) -: mDocument (document), mAborted (false), mMessages (0), mTotalRecords (0) +: mDocument (document), mAborted (false), mMessages (nullptr), mTotalRecords (0) { setWindowTitle (QString::fromUtf8((std::string("Opening ") + document->getSavePath().filename().string()).c_str())); diff --git a/apps/opencs/view/doc/sizehint.hpp b/apps/opencs/view/doc/sizehint.hpp index 1b3c52eb8..14ec7b186 100644 --- a/apps/opencs/view/doc/sizehint.hpp +++ b/apps/opencs/view/doc/sizehint.hpp @@ -11,7 +11,7 @@ namespace CSVDoc QSize mSize; public: - SizeHintWidget(QWidget *parent = 0); + SizeHintWidget(QWidget *parent = nullptr); ~SizeHintWidget(); QSize sizeHint() const override; diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index ac7c8ebf9..be3fe5142 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -733,7 +733,7 @@ void CSVDoc::View::infoAbout() #endif // Get current year - time_t now = time(NULL); + time_t now = time(nullptr); struct tm tstruct; char copyrightInfo[40]; tstruct = *localtime(&now); diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 70431107f..8424be6f8 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -43,7 +43,7 @@ namespace CSVDoc ViewManager& operator= (const ViewManager&); void updateIndices(); - bool notifySaveOnClose (View *view = 0); + bool notifySaveOnClose (View *view = nullptr); bool showModifiedDocumentMessageBox (View *view); bool showSaveInProgressMessageBox (View *view); bool removeDocument(View *view); diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index b47a884a3..f933ec92e 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -30,7 +30,7 @@ namespace CSVFilter public: - EditWidget (CSMWorld::Data& data, QWidget *parent = 0); + EditWidget (CSMWorld::Data& data, QWidget *parent = nullptr); void createFilterRequest(std::vector > >& filterSource, Qt::DropAction action); diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index 94aa80b84..94b5fced3 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -25,7 +25,7 @@ namespace CSVFilter RecordFilterBox *mRecordFilterBox; public: - FilterBox (CSMWorld::Data& data, QWidget *parent = 0); + FilterBox (CSMWorld::Data& data, QWidget *parent = nullptr); void setRecordFilter (const std::string& filter); diff --git a/apps/opencs/view/filter/recordfilterbox.hpp b/apps/opencs/view/filter/recordfilterbox.hpp index 77a07c92b..3bcd7c57b 100644 --- a/apps/opencs/view/filter/recordfilterbox.hpp +++ b/apps/opencs/view/filter/recordfilterbox.hpp @@ -25,7 +25,7 @@ namespace CSVFilter public: - RecordFilterBox (CSMWorld::Data& data, QWidget *parent = 0); + RecordFilterBox (CSMWorld::Data& data, QWidget *parent = nullptr); void setFilter (const std::string& filter); diff --git a/apps/opencs/view/prefs/keybindingpage.cpp b/apps/opencs/view/prefs/keybindingpage.cpp index eed5c0eb8..39c9f78ec 100644 --- a/apps/opencs/view/prefs/keybindingpage.cpp +++ b/apps/opencs/view/prefs/keybindingpage.cpp @@ -16,9 +16,9 @@ namespace CSVPrefs { KeyBindingPage::KeyBindingPage(CSMPrefs::Category& category, QWidget* parent) : PageBase(category, parent) - , mStackedLayout(0) - , mPageLayout(0) - , mPageSelector(0) + , mStackedLayout(nullptr) + , mPageLayout(nullptr) + , mPageSelector(nullptr) { // Need one widget for scroll area QWidget* topWidget = new QWidget(); diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 23b5aa91e..75d83cf63 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -504,12 +504,12 @@ void CSVRender::Cell::setCellArrows (int mask) bool enable = mask & direction; - if (enable!=(mCellArrows[i].get()!=0)) + if (enable!=(mCellArrows[i].get()!=nullptr)) { if (enable) mCellArrows[i].reset (new CellArrow (mCellNode, direction, mCoordinates)); else - mCellArrows[i].reset (0); + mCellArrows[i].reset (nullptr); } } } diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index 435178860..f8857c3af 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -27,9 +27,9 @@ namespace CSVRender : mData(data) , mId(id) , mParentNode(cellNode) - , mWaterTransform(0) - , mWaterNode(0) - , mWaterGeometry(0) + , mWaterTransform(nullptr) + , mWaterNode(nullptr) + , mWaterGeometry(nullptr) , mDeleted(false) , mExterior(false) , mHasWater(false) @@ -137,7 +137,7 @@ namespace CSVRender if (mWaterGeometry) { mWaterNode->removeDrawable(mWaterGeometry); - mWaterGeometry = 0; + mWaterGeometry = nullptr; } if (mDeleted || !mHasWater) diff --git a/apps/opencs/view/render/editmode.hpp b/apps/opencs/view/render/editmode.hpp index c0482c81a..52c35811d 100644 --- a/apps/opencs/view/render/editmode.hpp +++ b/apps/opencs/view/render/editmode.hpp @@ -30,7 +30,7 @@ namespace CSVRender public: EditMode (WorldspaceWidget *worldspaceWidget, const QIcon& icon, unsigned int mask, - const QString& tooltip = "", QWidget *parent = 0); + const QString& tooltip = "", QWidget *parent = nullptr); unsigned int getInteractionMask() const; diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 987dea437..19018fae6 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -98,7 +98,7 @@ osg::Vec3f CSVRender::InstanceMode::getScreenCoords(const osg::Vec3f& pos) CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, osg::ref_ptr parentNode, QWidget *parent) : EditMode (worldspaceWidget, QIcon (":scenetoolbar/editing-instance"), Mask_Reference | Mask_Terrain, "Instance editing", - parent), mSubMode (0), mSubModeId ("move"), mSelectionMode (0), mDragMode (DragMode_None), + parent), mSubMode (nullptr), mSubModeId ("move"), mSelectionMode (nullptr), mDragMode (DragMode_None), mDragAxis (-1), mLocked (false), mUnitScaleDist(1), mParentNode (parentNode) { connect(this, SIGNAL(requestFocus(const std::string&)), @@ -169,14 +169,14 @@ void CSVRender::InstanceMode::deactivate (CSVWidget::SceneToolbar *toolbar) { toolbar->removeTool (mSelectionMode); delete mSelectionMode; - mSelectionMode = 0; + mSelectionMode = nullptr; } if (mSubMode) { toolbar->removeTool (mSubMode); delete mSubMode; - mSubMode = 0; + mSubMode = nullptr; } EditMode::deactivate (toolbar); diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index 29955feef..32dd4ac67 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -62,7 +62,7 @@ namespace CSVRender public: - InstanceMode (WorldspaceWidget *worldspaceWidget, osg::ref_ptr parentNode, QWidget *parent = 0); + InstanceMode (WorldspaceWidget *worldspaceWidget, osg::ref_ptr parentNode, QWidget *parent = nullptr); void activate (CSVWidget::SceneToolbar *toolbar) override; diff --git a/apps/opencs/view/render/instancemovemode.hpp b/apps/opencs/view/render/instancemovemode.hpp index bd0e28dac..62e6b6a1f 100644 --- a/apps/opencs/view/render/instancemovemode.hpp +++ b/apps/opencs/view/render/instancemovemode.hpp @@ -11,7 +11,7 @@ namespace CSVRender public: - InstanceMoveMode (QWidget *parent = 0); + InstanceMoveMode (QWidget *parent = nullptr); }; } diff --git a/apps/opencs/view/render/lighting.hpp b/apps/opencs/view/render/lighting.hpp index 66b0eec00..d9d90767f 100644 --- a/apps/opencs/view/render/lighting.hpp +++ b/apps/opencs/view/render/lighting.hpp @@ -16,7 +16,7 @@ namespace CSVRender { public: - Lighting() : mRootNode(0) {} + Lighting() : mRootNode(nullptr) {} virtual ~Lighting(); virtual void activate (osg::Group* rootNode, bool isExterior) = 0; diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index f9d2c8872..2bb537d74 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -413,7 +413,7 @@ osg::Vec3f CSVRender::Object::getMarkerPosition (float x, float y, float z, int CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode, const std::string& id, bool referenceable, bool forceBaseToZero) -: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero), +: mData (data), mBaseNode(nullptr), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero), mScaleOverride (1), mOverrideFlags (0), mSubMode (-1), mMarkerTransparency(0.5f) { mRootNode = new osg::PositionAttitudeTransform; diff --git a/apps/opencs/view/render/orbitcameramode.cpp b/apps/opencs/view/render/orbitcameramode.cpp index ba25beaba..79ac0167a 100644 --- a/apps/opencs/view/render/orbitcameramode.cpp +++ b/apps/opencs/view/render/orbitcameramode.cpp @@ -13,7 +13,7 @@ namespace CSVRender QWidget* parent) : ModeButton(icon, tooltip, parent) , mWorldspaceWidget(worldspaceWidget) - , mCenterOnSelection(0) + , mCenterOnSelection(nullptr) { mCenterShortcut = new CSMPrefs::Shortcut("orbit-center-selection", worldspaceWidget); mCenterShortcut->enable(false); @@ -35,7 +35,7 @@ namespace CSVRender void OrbitCameraMode::deactivate(CSVWidget::SceneToolbar* toolbar) { - mCenterShortcut->associateAction(0); + mCenterShortcut->associateAction(nullptr); mCenterShortcut->enable(false); } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index b5d9234e4..dca5549af 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -787,7 +787,7 @@ CSVRender::Cell* CSVRender::PagedWorldspaceWidget::getCell(const osg::Vec3d& poi if (searchResult != mCells.end()) return searchResult->second; else - return 0; + return nullptr; } CSVRender::Cell* CSVRender::PagedWorldspaceWidget::getCell(const CSMWorld::CellCoordinates& coords) const diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index 7f0454d8f..470a3d092 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -60,8 +60,8 @@ namespace CSVRender , mRemoveGeometry(false) , mUseOffset(true) , mParent(parent) - , mPathgridGeometry(0) - , mDragGeometry(0) + , mPathgridGeometry(nullptr) + , mDragGeometry(nullptr) , mTag(new PathgridTag(this)) { const float CoordScalar = ESM::Land::REAL_SIZE; @@ -219,7 +219,7 @@ namespace CSVRender mMoveOffset.set(0, 0, 0); mPathgridGeode->removeDrawable(mDragGeometry); - mDragGeometry = 0; + mDragGeometry = nullptr; } void Pathgrid::applyPoint(CSMWorld::CommandMacro& commands, const osg::Vec3d& worldPos) @@ -557,7 +557,7 @@ namespace CSVRender if (mPathgridGeometry) { mPathgridGeode->removeDrawable(mPathgridGeometry); - mPathgridGeometry = 0; + mPathgridGeometry = nullptr; } } @@ -566,7 +566,7 @@ namespace CSVRender if (mSelectedGeometry) { mPathgridGeode->removeDrawable(mSelectedGeometry); - mSelectedGeometry = 0; + mSelectedGeometry = nullptr; } } @@ -612,7 +612,7 @@ namespace CSVRender return &mPathgridCollection.getRecord(index).get(); } - return 0; + return nullptr; } int Pathgrid::edgeExists(const CSMWorld::Pathgrid& source, unsigned short node1, unsigned short node2) diff --git a/apps/opencs/view/render/pathgridmode.cpp b/apps/opencs/view/render/pathgridmode.cpp index 8863ad235..7a3fc8ecf 100644 --- a/apps/opencs/view/render/pathgridmode.cpp +++ b/apps/opencs/view/render/pathgridmode.cpp @@ -27,7 +27,7 @@ namespace CSVRender getTooltip(), parent) , mDragMode(DragMode_None) , mFromNode(0) - , mSelectionMode(0) + , mSelectionMode(nullptr) { } @@ -59,7 +59,7 @@ namespace CSVRender { toolbar->removeTool (mSelectionMode); delete mSelectionMode; - mSelectionMode = 0; + mSelectionMode = nullptr; } } @@ -214,7 +214,7 @@ namespace CSVRender Cell* cell = getWorldspaceWidget().getCell(hit.worldPos); if (cell && cell->getPathgrid()) { - PathgridTag* tag = 0; + PathgridTag* tag = nullptr; if (hit.tag && (tag = dynamic_cast(hit.tag.get())) && tag->getPathgrid()->getId() == mEdgeId) { unsigned short node = SceneUtil::getPathgridNode(static_cast(hit.index0)); diff --git a/apps/opencs/view/render/pathgridmode.hpp b/apps/opencs/view/render/pathgridmode.hpp index 6d8f96e8c..cc61dfe9b 100644 --- a/apps/opencs/view/render/pathgridmode.hpp +++ b/apps/opencs/view/render/pathgridmode.hpp @@ -15,7 +15,7 @@ namespace CSVRender public: - PathgridMode(WorldspaceWidget* worldspace, QWidget* parent=0); + PathgridMode(WorldspaceWidget* worldspace, QWidget* parent=nullptr); void activate(CSVWidget::SceneToolbar* toolbar) override; diff --git a/apps/opencs/view/render/previewwidget.hpp b/apps/opencs/view/render/previewwidget.hpp index 630ccf293..a8d73729a 100644 --- a/apps/opencs/view/render/previewwidget.hpp +++ b/apps/opencs/view/render/previewwidget.hpp @@ -29,7 +29,7 @@ namespace CSVRender public: PreviewWidget (CSMWorld::Data& data, const std::string& id, bool referenceable, - QWidget *parent = 0); + QWidget *parent = nullptr); signals: diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index f3186e76a..3abc01d2e 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -36,7 +36,7 @@ namespace CSVRender RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) - , mRootNode(0) + , mRootNode(nullptr) { osgViewer::CompositeViewer& viewer = CompositeViewer::get(); @@ -257,7 +257,7 @@ void SceneWidget::setLighting(Lighting *lighting) mLighting = lighting; mLighting->activate (mRootNode, mIsExterior); - osg::Vec4f ambient = mLighting->getAmbientColour(mHasDefaultAmbient ? &mDefaultAmbient : 0); + osg::Vec4f ambient = mLighting->getAmbientColour(mHasDefaultAmbient ? &mDefaultAmbient : nullptr); setAmbient(ambient); flagAsModified(); diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index 5664378ca..e495d2355 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -99,7 +99,7 @@ void CSVRender::TerrainShapeMode::primaryOpenPressed (const WorldspaceHitResult& void CSVRender::TerrainShapeMode::primaryEditPressed(const WorldspaceHitResult& hit) { - if (hit.hit && hit.tag == 0) + if (hit.hit && hit.tag == nullptr) { if (mShapeEditTool == ShapeEditTool_Flatten) setFlattenToolTargetHeight(hit); @@ -124,7 +124,7 @@ void CSVRender::TerrainShapeMode::primaryEditPressed(const WorldspaceHitResult& void CSVRender::TerrainShapeMode::primarySelectPressed(const WorldspaceHitResult& hit) { - if(hit.hit && hit.tag == 0) + if(hit.hit && hit.tag == nullptr) { selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 0, false); } @@ -132,7 +132,7 @@ void CSVRender::TerrainShapeMode::primarySelectPressed(const WorldspaceHitResult void CSVRender::TerrainShapeMode::secondarySelectPressed(const WorldspaceHitResult& hit) { - if(hit.hit && hit.tag == 0) + if(hit.hit && hit.tag == nullptr) { selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 1, false); } @@ -144,7 +144,7 @@ bool CSVRender::TerrainShapeMode::primaryEditStartDrag (const QPoint& pos) mDragMode = InteractionType_PrimaryEdit; - if (hit.hit && hit.tag == 0) + if (hit.hit && hit.tag == nullptr) { mEditingPos = hit.worldPos; mIsEditing = true; @@ -164,7 +164,7 @@ bool CSVRender::TerrainShapeMode::primarySelectStartDrag (const QPoint& pos) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); mDragMode = InteractionType_PrimarySelect; - if (!hit.hit || hit.tag != 0) + if (!hit.hit || hit.tag != nullptr) { mDragMode = InteractionType_None; return false; @@ -177,7 +177,7 @@ bool CSVRender::TerrainShapeMode::secondarySelectStartDrag (const QPoint& pos) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); mDragMode = InteractionType_SecondarySelect; - if (!hit.hit || hit.tag != 0) + if (!hit.hit || hit.tag != nullptr) { mDragMode = InteractionType_None; return false; @@ -202,13 +202,13 @@ void CSVRender::TerrainShapeMode::drag (const QPoint& pos, int diffX, int diffY, if (mDragMode == InteractionType_PrimarySelect) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); - if (hit.hit && hit.tag == 0) selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 0, true); + if (hit.hit && hit.tag == nullptr) selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 0, true); } if (mDragMode == InteractionType_SecondarySelect) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); - if (hit.hit && hit.tag == 0) selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 1, true); + if (hit.hit && hit.tag == nullptr) selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 1, true); } } diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index ae5711881..c8d63f32e 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -119,7 +119,7 @@ void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult CSMWorld::IdCollection& landtexturesCollection = document.getData().getLandTextures(); int index = landtexturesCollection.searchId(mBrushTexture); - if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == 0) + if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == nullptr) { undoStack.beginMacro ("Edit texture records"); if(allowLandTextureEditing(mCellId)) @@ -133,7 +133,7 @@ void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResult& hit) { - if(hit.hit && hit.tag == 0) + if(hit.hit && hit.tag == nullptr) { selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 0, false); } @@ -141,7 +141,7 @@ void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResu void CSVRender::TerrainTextureMode::secondarySelectPressed(const WorldspaceHitResult& hit) { - if(hit.hit && hit.tag == 0) + if(hit.hit && hit.tag == nullptr) { selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 1, false); } @@ -166,7 +166,7 @@ bool CSVRender::TerrainTextureMode::primaryEditStartDrag (const QPoint& pos) CSMWorld::IdCollection& landtexturesCollection = document.getData().getLandTextures(); int index = landtexturesCollection.searchId(mBrushTexture); - if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == 0) + if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == nullptr) { undoStack.beginMacro ("Edit texture records"); mIsEditing = true; @@ -189,7 +189,7 @@ bool CSVRender::TerrainTextureMode::primarySelectStartDrag (const QPoint& pos) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); mDragMode = InteractionType_PrimarySelect; - if (!hit.hit || hit.tag != 0) + if (!hit.hit || hit.tag != nullptr) { mDragMode = InteractionType_None; return false; @@ -202,7 +202,7 @@ bool CSVRender::TerrainTextureMode::secondarySelectStartDrag (const QPoint& pos) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); mDragMode = InteractionType_SecondarySelect; - if (!hit.hit || hit.tag != 0) + if (!hit.hit || hit.tag != nullptr) { mDragMode = InteractionType_None; return false; @@ -222,7 +222,7 @@ void CSVRender::TerrainTextureMode::drag (const QPoint& pos, int diffX, int diff CSMWorld::IdCollection& landtexturesCollection = document.getData().getLandTextures(); int index = landtexturesCollection.searchId(mBrushTexture); - if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == 0) + if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == nullptr) { editTerrainTextureGrid(hit); } @@ -231,13 +231,13 @@ void CSVRender::TerrainTextureMode::drag (const QPoint& pos, int diffX, int diff if (mDragMode == InteractionType_PrimarySelect) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); - if (hit.hit && hit.tag == 0) selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 0, true); + if (hit.hit && hit.tag == nullptr) selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 0, true); } if (mDragMode == InteractionType_SecondarySelect) { WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask()); - if (hit.hit && hit.tag == 0) selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 1, true); + if (hit.hit && hit.tag == nullptr) selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 1, true); } } diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 4535b5e8a..82a1459f2 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -34,11 +34,11 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) : SceneWidget (document.getData().getResourceSystem(), parent, Qt::WindowFlags(), false) - , mSceneElements(0) - , mRun(0) + , mSceneElements(nullptr) + , mRun(nullptr) , mDocument(document) , mInteractionMask (0) - , mEditMode (0) + , mEditMode (nullptr) , mLocked (false) , mDragMode(InteractionType_None) , mDragging (false) @@ -435,7 +435,7 @@ CSVRender::WorldspaceHitResult CSVRender::WorldspaceWidget::mousePick (const QPo } // Something untagged, probably terrain - WorldspaceHitResult hit = { true, 0, 0, 0, 0, intersection.getWorldIntersectPoint() }; + WorldspaceHitResult hit = { true, nullptr, 0, 0, 0, intersection.getWorldIntersectPoint() }; if (intersection.indexList.size() >= 3) { hit.index0 = intersection.indexList[0]; @@ -449,7 +449,7 @@ CSVRender::WorldspaceHitResult CSVRender::WorldspaceWidget::mousePick (const QPo direction.normalize(); direction *= CSMPrefs::get()["3D Scene Editing"]["distance"].toInt(); - WorldspaceHitResult hit = { false, 0, 0, 0, 0, start + direction }; + WorldspaceHitResult hit = { false, nullptr, 0, 0, 0, start + direction }; return hit; } diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 5ed3d01b3..3b8cf70c2 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -96,7 +96,7 @@ namespace CSVRender InteractionType_None }; - WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0); + WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = nullptr); ~WorldspaceWidget (); CSVWidget::SceneToolMode *makeNavigationSelector (CSVWidget::SceneToolbar *parent); diff --git a/apps/opencs/view/tools/merge.cpp b/apps/opencs/view/tools/merge.cpp index c49044ccd..f50a85f2f 100644 --- a/apps/opencs/view/tools/merge.cpp +++ b/apps/opencs/view/tools/merge.cpp @@ -27,7 +27,7 @@ void CSVTools::Merge::keyPressEvent (QKeyEvent *event) } CSVTools::Merge::Merge (CSMDoc::DocumentManager& documentManager, QWidget *parent) -: QWidget (parent), mDocument (0), mDocumentManager (documentManager) +: QWidget (parent), mDocument (nullptr), mDocumentManager (documentManager) { setWindowTitle ("Merge Content Files into a new Game File"); @@ -117,7 +117,7 @@ CSMDoc::Document *CSVTools::Merge::getDocument() const void CSVTools::Merge::cancel() { - mDocument = 0; + mDocument = nullptr; hide(); } diff --git a/apps/opencs/view/tools/merge.hpp b/apps/opencs/view/tools/merge.hpp index c82feba14..d394a431e 100644 --- a/apps/opencs/view/tools/merge.hpp +++ b/apps/opencs/view/tools/merge.hpp @@ -39,7 +39,7 @@ namespace CSVTools public: - Merge (CSMDoc::DocumentManager& documentManager, QWidget *parent = 0); + Merge (CSMDoc::DocumentManager& documentManager, QWidget *parent = nullptr); /// Configure dialogue for a new merge void configure (CSMDoc::Document *document); diff --git a/apps/opencs/view/tools/reporttable.cpp b/apps/opencs/view/tools/reporttable.cpp index 7b28f2b0f..c1297d475 100644 --- a/apps/opencs/view/tools/reporttable.cpp +++ b/apps/opencs/view/tools/reporttable.cpp @@ -25,7 +25,7 @@ namespace CSVTools { public: - RichTextDelegate (QObject *parent = 0); + RichTextDelegate (QObject *parent = nullptr); void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; @@ -142,7 +142,7 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id, bool richTextDescription, int refreshState, QWidget *parent) : CSVWorld::DragRecordTable (document, parent), mModel (document.getReport (id)), - mRefreshAction (0), mRefreshState (refreshState) + mRefreshAction (nullptr), mRefreshState (refreshState) { horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive); horizontalHeader()->setStretchLastSection (true); @@ -159,7 +159,7 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document, setModel (mProxyModel); setColumnHidden (2, true); - mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (0, + mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (nullptr, mDocument, this); setItemDelegateForColumn (0, mIdTypeDelegate); diff --git a/apps/opencs/view/tools/reporttable.hpp b/apps/opencs/view/tools/reporttable.hpp index 4c169a986..f39dd6f85 100644 --- a/apps/opencs/view/tools/reporttable.hpp +++ b/apps/opencs/view/tools/reporttable.hpp @@ -62,7 +62,7 @@ namespace CSVTools /// 0 no refresh function exists. If the document current has the specified state /// the refresh function is disabled. ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id, - bool richTextDescription, int refreshState = 0, QWidget *parent = 0); + bool richTextDescription, int refreshState = 0, QWidget *parent = nullptr); std::vector getDraggedRecords() const override; diff --git a/apps/opencs/view/tools/searchbox.hpp b/apps/opencs/view/tools/searchbox.hpp index eff5296b4..cbeb150d8 100644 --- a/apps/opencs/view/tools/searchbox.hpp +++ b/apps/opencs/view/tools/searchbox.hpp @@ -41,7 +41,7 @@ namespace CSVTools public: - SearchBox (QWidget *parent = 0); + SearchBox (QWidget *parent = nullptr); void setSearchMode (bool enabled); diff --git a/apps/opencs/view/tools/searchsubview.cpp b/apps/opencs/view/tools/searchsubview.cpp index 9bada22af..07ba7907e 100644 --- a/apps/opencs/view/tools/searchsubview.cpp +++ b/apps/opencs/view/tools/searchsubview.cpp @@ -30,7 +30,7 @@ void CSVTools::SearchSubView::replace (bool selection) bool autoDelete = CSMPrefs::get()["Search & Replace"]["auto-delete"].isTrue(); CSMTools::Search search (mSearch); - CSMWorld::IdTableBase *currentTable = 0; + CSMWorld::IdTableBase *currentTable = nullptr; // We are running through the indices in reverse order to avoid messing up multiple results // in a single string. diff --git a/apps/opencs/view/widget/coloreditor.hpp b/apps/opencs/view/widget/coloreditor.hpp index d4a802ca2..aa746da68 100644 --- a/apps/opencs/view/widget/coloreditor.hpp +++ b/apps/opencs/view/widget/coloreditor.hpp @@ -22,8 +22,8 @@ namespace CSVWidget QPoint calculatePopupPosition(); public: - ColorEditor(const QColor &color, QWidget *parent = 0, const bool popupOnStart = false); - ColorEditor(const int colorInt, QWidget *parent = 0, const bool popupOnStart = false); + ColorEditor(const QColor &color, QWidget *parent = nullptr, const bool popupOnStart = false); + ColorEditor(const int colorInt, QWidget *parent = nullptr, const bool popupOnStart = false); QColor color() const; @@ -41,7 +41,7 @@ namespace CSVWidget void showEvent(QShowEvent *event) override; private: - ColorEditor(QWidget *parent = 0, const bool popupOnStart = false); + ColorEditor(QWidget *parent = nullptr, const bool popupOnStart = false); private slots: void showPicker(); diff --git a/apps/opencs/view/widget/completerpopup.hpp b/apps/opencs/view/widget/completerpopup.hpp index 62fdf5388..96675f56f 100644 --- a/apps/opencs/view/widget/completerpopup.hpp +++ b/apps/opencs/view/widget/completerpopup.hpp @@ -8,7 +8,7 @@ namespace CSVWidget class CompleterPopup : public QListView { public: - CompleterPopup(QWidget *parent = 0); + CompleterPopup(QWidget *parent = nullptr); int sizeHintForRow(int row) const override; }; diff --git a/apps/opencs/view/widget/droplineedit.hpp b/apps/opencs/view/widget/droplineedit.hpp index ed991af0d..911051873 100644 --- a/apps/opencs/view/widget/droplineedit.hpp +++ b/apps/opencs/view/widget/droplineedit.hpp @@ -26,7 +26,7 @@ namespace CSVWidget ///< The accepted Display type for this LineEdit. public: - DropLineEdit(CSMWorld::ColumnBase::Display type, QWidget *parent = 0); + DropLineEdit(CSMWorld::ColumnBase::Display type, QWidget *parent = nullptr); protected: void dragEnterEvent(QDragEnterEvent *event) override; diff --git a/apps/opencs/view/widget/modebutton.hpp b/apps/opencs/view/widget/modebutton.hpp index 1615ff298..f59596923 100644 --- a/apps/opencs/view/widget/modebutton.hpp +++ b/apps/opencs/view/widget/modebutton.hpp @@ -17,7 +17,7 @@ namespace CSVWidget public: ModeButton (const QIcon& icon, const QString& tooltip = "", - QWidget *parent = 0); + QWidget *parent = nullptr); /// Default-Implementation: do nothing virtual void activate (SceneToolbar *toolbar); diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 5522cd74f..b3aaaebef 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -48,11 +48,11 @@ namespace CSVWidget /// \param push Do not maintain a toggle state PushButton (const QIcon& icon, Type type, const QString& tooltip = "", - QWidget *parent = 0); + QWidget *parent = nullptr); /// \param push Do not maintain a toggle state PushButton (Type type, const QString& tooltip = "", - QWidget *parent = 0); + QWidget *parent = nullptr); bool hasKeepOpen() const; diff --git a/apps/opencs/view/widget/scenetoolbar.hpp b/apps/opencs/view/widget/scenetoolbar.hpp index d9998eefc..70f580765 100644 --- a/apps/opencs/view/widget/scenetoolbar.hpp +++ b/apps/opencs/view/widget/scenetoolbar.hpp @@ -23,11 +23,11 @@ namespace CSVWidget public: - SceneToolbar (int buttonSize, QWidget *parent = 0); + SceneToolbar (int buttonSize, QWidget *parent = nullptr); /// If insertPoint==0, insert \a tool at the end of the scrollbar. Otherwise /// insert tool after \a insertPoint. - void addTool (SceneTool *tool, SceneTool *insertPoint = 0); + void addTool (SceneTool *tool, SceneTool *insertPoint = nullptr); void removeTool (SceneTool *tool); diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 7b2ff64db..3aec44f1b 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -33,7 +33,7 @@ void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode) toolTip += "

(left click to change mode)"; - if (createContextMenu (0)) + if (createContextMenu (nullptr)) toolTip += "
(right click to access context menu)"; setToolTip (toolTip); @@ -62,7 +62,7 @@ void CSVWidget::SceneToolMode::setButton (std::map::i CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip) : SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()), - mToolTip (toolTip), mFirst (0), mCurrent (0), mToolbar (parent) + mToolTip (toolTip), mFirst (nullptr), mCurrent (nullptr), mToolbar (parent) { mPanel = new QFrame (this, Qt::Popup); diff --git a/apps/opencs/view/widget/scenetoolshapebrush.hpp b/apps/opencs/view/widget/scenetoolshapebrush.hpp index 76c0dfa04..3afd7f8b3 100644 --- a/apps/opencs/view/widget/scenetoolshapebrush.hpp +++ b/apps/opencs/view/widget/scenetoolshapebrush.hpp @@ -54,7 +54,7 @@ namespace CSVWidget public: - ShapeBrushWindow(CSMDoc::Document& document, QWidget *parent = 0); + ShapeBrushWindow(CSMDoc::Document& document, QWidget *parent = nullptr); void configureButtonInitialSettings(QPushButton *button); const QString toolTipPoint = "Paint single point"; diff --git a/apps/opencs/view/widget/scenetooltexturebrush.hpp b/apps/opencs/view/widget/scenetooltexturebrush.hpp index c6f0b5e52..5f42800cb 100644 --- a/apps/opencs/view/widget/scenetooltexturebrush.hpp +++ b/apps/opencs/view/widget/scenetooltexturebrush.hpp @@ -57,7 +57,7 @@ namespace CSVWidget Q_OBJECT public: - TextureBrushWindow(CSMDoc::Document& document, QWidget *parent = 0); + TextureBrushWindow(CSMDoc::Document& document, QWidget *parent = nullptr); void configureButtonInitialSettings(QPushButton *button); const QString toolTipPoint = "Paint single point"; diff --git a/apps/opencs/view/widget/scenetooltoggle.cpp b/apps/opencs/view/widget/scenetooltoggle.cpp index 5919a280a..fa0be3155 100644 --- a/apps/opencs/view/widget/scenetooltoggle.cpp +++ b/apps/opencs/view/widget/scenetooltoggle.cpp @@ -115,7 +115,7 @@ QRect CSVWidget::SceneToolToggle::getIconBox (int index) const CSVWidget::SceneToolToggle::SceneToolToggle (SceneToolbar *parent, const QString& toolTip, const std::string& emptyIcon) : SceneTool (parent), mEmptyIcon (emptyIcon), mButtonSize (parent->getButtonSize()), - mIconSize (parent->getIconSize()), mToolTip (toolTip), mFirst (0) + mIconSize (parent->getIconSize()), mToolTip (toolTip), mFirst (nullptr) { mPanel = new QFrame (this, Qt::Popup); diff --git a/apps/opencs/view/widget/scenetooltoggle2.cpp b/apps/opencs/view/widget/scenetooltoggle2.cpp index 720da6a96..cf9bfe349 100644 --- a/apps/opencs/view/widget/scenetooltoggle2.cpp +++ b/apps/opencs/view/widget/scenetooltoggle2.cpp @@ -57,7 +57,7 @@ CSVWidget::SceneToolToggle2::SceneToolToggle2 (SceneToolbar *parent, const QStri const std::string& compositeIcon, const std::string& singleIcon) : SceneTool (parent), mCompositeIcon (compositeIcon), mSingleIcon (singleIcon), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()), mToolTip (toolTip), - mFirst (0) + mFirst (nullptr) { mPanel = new QFrame (this, Qt::Popup); diff --git a/apps/opencs/view/world/creator.cpp b/apps/opencs/view/world/creator.cpp index 7a93339c5..53664c186 100644 --- a/apps/opencs/view/world/creator.cpp +++ b/apps/opencs/view/world/creator.cpp @@ -17,5 +17,5 @@ CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {} CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const { - return 0; + return nullptr; } diff --git a/apps/opencs/view/world/dialoguespinbox.hpp b/apps/opencs/view/world/dialoguespinbox.hpp index b7c4889a5..90fe8d20c 100644 --- a/apps/opencs/view/world/dialoguespinbox.hpp +++ b/apps/opencs/view/world/dialoguespinbox.hpp @@ -12,7 +12,7 @@ namespace CSVWorld public: - DialogueSpinBox (QWidget *parent = 0); + DialogueSpinBox (QWidget *parent = nullptr); protected: @@ -27,7 +27,7 @@ namespace CSVWorld public: - DialogueDoubleSpinBox (QWidget *parent = 0); + DialogueDoubleSpinBox (QWidget *parent = nullptr); protected: diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index e29fcb779..3d3b3cdbe 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -498,7 +498,7 @@ void CSVWorld::EditWidget::remake(int row) if (mDispatcher) delete mDispatcher; - mDispatcher = new DialogueDelegateDispatcher(0/*this*/, mTable, mCommandDispatcher, mDocument); + mDispatcher = new DialogueDelegateDispatcher(nullptr/*this*/, mTable, mCommandDispatcher, mDocument); if (mNestedTableDispatcher) delete mNestedTableDispatcher; @@ -648,7 +648,7 @@ void CSVWorld::EditWidget::remake(int row) mNestedTableMapper->setModel(tree); // FIXME: lack MIME support? mNestedTableDispatcher = - new DialogueDelegateDispatcher (0/*this*/, mTable, mCommandDispatcher, mDocument, tree); + new DialogueDelegateDispatcher (nullptr/*this*/, mTable, mCommandDispatcher, mDocument, tree); mNestedTableMapper->setRootIndex (tree->index(row, i)); mNestedTableMapper->setItemDelegate(mNestedTableDispatcher); @@ -732,7 +732,7 @@ bool CSVWorld::SimpleDialogueSubView::isLocked() const CSVWorld::SimpleDialogueSubView::SimpleDialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id), - mEditWidget(0), + mEditWidget(nullptr), mMainLayout(nullptr), mTable(dynamic_cast(document.getData().getTableModel(id))), mLocked(false), @@ -834,7 +834,7 @@ void CSVWorld::SimpleDialogueSubView::rowsAboutToBeRemoved(const QModelIndex &pa if(mEditWidget) { delete mEditWidget; - mEditWidget = 0; + mEditWidget = nullptr; } emit closeRequest(this); } @@ -869,7 +869,7 @@ void CSVWorld::DialogueSubView::addButtonBar() CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting) -: SimpleDialogueSubView (id, document), mButtons (0) +: SimpleDialogueSubView (id, document), mButtons (nullptr) { // bottom box mBottom = new TableBottomBox (creatorFactory, document, id, this); @@ -905,7 +905,7 @@ void CSVWorld::DialogueSubView::settingChanged (const CSMPrefs::Setting *setting { getMainLayout().removeWidget (mButtons); delete mButtons; - mButtons = 0; + mButtons = nullptr; } } } diff --git a/apps/opencs/view/world/dialoguesubview.hpp b/apps/opencs/view/world/dialoguesubview.hpp index eb14efa8e..2cf05f711 100644 --- a/apps/opencs/view/world/dialoguesubview.hpp +++ b/apps/opencs/view/world/dialoguesubview.hpp @@ -50,7 +50,7 @@ namespace CSVWorld const CSMWorld::IdTable* mTable; public: NotEditableSubDelegate(const CSMWorld::IdTable* table, - QObject * parent = 0); + QObject * parent = nullptr); void setEditorData (QWidget* editor, const QModelIndex& index) const override; @@ -126,7 +126,7 @@ namespace CSVWorld CSMWorld::IdTable* table, CSMWorld::CommandDispatcher& commandDispatcher, CSMDoc::Document& document, - QAbstractItemModel* model = 0); + QAbstractItemModel* model = nullptr); ~DialogueDelegateDispatcher(); diff --git a/apps/opencs/view/world/enumdelegate.cpp b/apps/opencs/view/world/enumdelegate.cpp index 3140adc48..65ded46c7 100644 --- a/apps/opencs/view/world/enumdelegate.cpp +++ b/apps/opencs/view/world/enumdelegate.cpp @@ -71,7 +71,7 @@ QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QStyleOptio const QModelIndex& index, CSMWorld::ColumnBase::Display display) const { if (!index.data(Qt::EditRole).isValid() && !index.data(Qt::DisplayRole).isValid()) - return 0; + return nullptr; QComboBox *comboBox = new QComboBox (parent); diff --git a/apps/opencs/view/world/extendedcommandconfigurator.hpp b/apps/opencs/view/world/extendedcommandconfigurator.hpp index 42573924a..85862ac49 100644 --- a/apps/opencs/view/world/extendedcommandconfigurator.hpp +++ b/apps/opencs/view/world/extendedcommandconfigurator.hpp @@ -57,7 +57,7 @@ namespace CSVWorld public: ExtendedCommandConfigurator(CSMDoc::Document &document, const CSMWorld::UniversalId &id, - QWidget *parent = 0); + QWidget *parent = nullptr); void configure(Mode mode, const std::vector &selectedIds); void setEditLock(bool locked); diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index 5e2118e9b..23813f806 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -148,8 +148,8 @@ void CSVWorld::GenericCreator::addScope (const QString& name, CSMWorld::Scope sc CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, bool relaxedIdRules) : mData (data), mUndoStack (undoStack), mListId (id), mLocked (false), - mClonedType (CSMWorld::UniversalId::Type_None), mScopes (CSMWorld::Scope_Content), mScope (0), - mScopeLabel (0), mCloneMode (false) + mClonedType (CSMWorld::UniversalId::Type_None), mScopes (CSMWorld::Scope_Content), mScope (nullptr), + mScopeLabel (nullptr), mCloneMode (false) { // If the collection ID has a parent type, use it instead. // It will change IDs with Record/SubRecord class (used for creators in Dialogue subviews) @@ -322,10 +322,10 @@ void CSVWorld::GenericCreator::setScope (unsigned int scope) else { delete mScope; - mScope = 0; + mScope = nullptr; delete mScopeLabel; - mScopeLabel = 0; + mScopeLabel = nullptr; } updateNamespace(); diff --git a/apps/opencs/view/world/idcompletiondelegate.cpp b/apps/opencs/view/world/idcompletiondelegate.cpp index 4ff850b9f..447bcc25d 100644 --- a/apps/opencs/view/world/idcompletiondelegate.cpp +++ b/apps/opencs/view/world/idcompletiondelegate.cpp @@ -74,7 +74,7 @@ QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, { return new CSVWidget::DropLineEdit(display, parent); } - default: return 0; // The rest of them can't be edited anyway + default: return nullptr; // The rest of them can't be edited anyway } } diff --git a/apps/opencs/view/world/idvalidator.hpp b/apps/opencs/view/world/idvalidator.hpp index 17624a243..278335a65 100644 --- a/apps/opencs/view/world/idvalidator.hpp +++ b/apps/opencs/view/world/idvalidator.hpp @@ -19,7 +19,7 @@ namespace CSVWorld public: - IdValidator (bool relaxed = false, QObject *parent = 0); + IdValidator (bool relaxed = false, QObject *parent = nullptr); ///< \param relaxed Relaxed rules for IDs that also functino as user visible text State validate (QString& input, int& pos) const override; diff --git a/apps/opencs/view/world/recordbuttonbar.hpp b/apps/opencs/view/world/recordbuttonbar.hpp index fbee066ce..aca3211f8 100644 --- a/apps/opencs/view/world/recordbuttonbar.hpp +++ b/apps/opencs/view/world/recordbuttonbar.hpp @@ -58,8 +58,8 @@ namespace CSVWorld public: RecordButtonBar (const CSMWorld::UniversalId& id, - CSMWorld::IdTable& table, TableBottomBox *bottomBox = 0, - CSMWorld::CommandDispatcher *commandDispatcher = 0, QWidget *parent = 0); + CSMWorld::IdTable& table, TableBottomBox *bottomBox = nullptr, + CSMWorld::CommandDispatcher *commandDispatcher = nullptr, QWidget *parent = nullptr); void setEditLock (bool locked); diff --git a/apps/opencs/view/world/recordstatusdelegate.hpp b/apps/opencs/view/world/recordstatusdelegate.hpp index 6ec8c37bd..38f066862 100644 --- a/apps/opencs/view/world/recordstatusdelegate.hpp +++ b/apps/opencs/view/world/recordstatusdelegate.hpp @@ -19,7 +19,7 @@ namespace CSVWorld RecordStatusDelegate (const ValueList& values, const IconList& icons, CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, - QObject *parent = 0); + QObject *parent = nullptr); }; class RecordStatusDelegateFactory : public DataDisplayDelegateFactory diff --git a/apps/opencs/view/world/regionmap.hpp b/apps/opencs/view/world/regionmap.hpp index b1f7cdc67..443de9ce3 100644 --- a/apps/opencs/view/world/regionmap.hpp +++ b/apps/opencs/view/world/regionmap.hpp @@ -61,7 +61,7 @@ namespace CSVWorld public: RegionMap (const CSMWorld::UniversalId& universalId, CSMDoc::Document& document, - QWidget *parent = 0); + QWidget *parent = nullptr); std::vector getDraggedRecords() const override; diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 9083359d2..743df9c76 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -47,7 +47,7 @@ CSVWorld::ScriptEdit::ScriptEdit( ) : QPlainTextEdit(parent), mChangeLocked(0), mShowLineNum(false), - mLineNumberArea(0), + mLineNumberArea(nullptr), mDefaultFont(font()), mMonoFont(QFont("Monospace")), mTabCharCount(4), @@ -314,7 +314,7 @@ void CSVWorld::ScriptEdit::markOccurrences() // prevent infinite recursion with cursor.select(), // which ends up calling this function again // could be fixed with blockSignals, but mDocument is const - disconnect(this, SIGNAL(cursorPositionChanged()), this, 0); + disconnect(this, SIGNAL(cursorPositionChanged()), this, nullptr); cursor.select(QTextCursor::WordUnderCursor); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(markOccurrences())); diff --git a/apps/opencs/view/world/scripterrortable.hpp b/apps/opencs/view/world/scripterrortable.hpp index ad287707d..7165d0fc6 100644 --- a/apps/opencs/view/world/scripterrortable.hpp +++ b/apps/opencs/view/world/scripterrortable.hpp @@ -41,7 +41,7 @@ namespace CSVWorld public: - ScriptErrorTable (const CSMDoc::Document& document, QWidget *parent = 0); + ScriptErrorTable (const CSMDoc::Document& document, QWidget *parent = nullptr); void update (const std::string& source); diff --git a/apps/opencs/view/world/scriptsubview.cpp b/apps/opencs/view/world/scriptsubview.cpp index 58ad09451..096fc8a9e 100644 --- a/apps/opencs/view/world/scriptsubview.cpp +++ b/apps/opencs/view/world/scriptsubview.cpp @@ -88,7 +88,7 @@ void CSVWorld::ScriptSubView::adjustSplitter() } CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) -: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mButtons (0), +: SubView (id), mDocument (document), mColumn (-1), mBottom(nullptr), mButtons (nullptr), mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType())), mErrorHeight (CSMPrefs::get()["Scripts"]["error-height"].toInt()) { @@ -177,7 +177,7 @@ void CSVWorld::ScriptSubView::settingChanged (const CSMPrefs::Setting *setting) { mLayout.removeWidget (mButtons); delete mButtons; - mButtons = 0; + mButtons = nullptr; } } else if (*setting=="Scripts/compile-delay") diff --git a/apps/opencs/view/world/tablebottombox.hpp b/apps/opencs/view/world/tablebottombox.hpp index 50d61150f..6ad2dbd82 100644 --- a/apps/opencs/view/world/tablebottombox.hpp +++ b/apps/opencs/view/world/tablebottombox.hpp @@ -59,7 +59,7 @@ namespace CSVWorld TableBottomBox (const CreatorFactoryBase& creatorFactory, CSMDoc::Document& document, const CSMWorld::UniversalId& id, - QWidget *parent = 0); + QWidget *parent = nullptr); virtual ~TableBottomBox(); diff --git a/apps/opencs/view/world/tableeditidaction.hpp b/apps/opencs/view/world/tableeditidaction.hpp index f2cf0b7bd..9fe41b0de 100644 --- a/apps/opencs/view/world/tableeditidaction.hpp +++ b/apps/opencs/view/world/tableeditidaction.hpp @@ -19,7 +19,7 @@ namespace CSVWorld CellData getCellData(int row, int column) const; public: - TableEditIdAction(const QTableView &table, QWidget *parent = 0); + TableEditIdAction(const QTableView &table, QWidget *parent = nullptr); void setCell(int row, int column); diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index 5a4503362..ba9f40847 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -57,7 +57,7 @@ QVariant CSVWorld::NastyTableModelHack::getData() const CSVWorld::CommandDelegateFactory::~CommandDelegateFactory() {} -CSVWorld::CommandDelegateFactoryCollection *CSVWorld::CommandDelegateFactoryCollection::sThis = 0; +CSVWorld::CommandDelegateFactoryCollection *CSVWorld::CommandDelegateFactoryCollection::sThis = nullptr; CSVWorld::CommandDelegateFactoryCollection::CommandDelegateFactoryCollection() { @@ -69,7 +69,7 @@ CSVWorld::CommandDelegateFactoryCollection::CommandDelegateFactoryCollection() CSVWorld::CommandDelegateFactoryCollection::~CommandDelegateFactoryCollection() { - sThis = 0; + sThis = nullptr; for (std::map::iterator iter ( mFactories.begin()); @@ -193,7 +193,7 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO variant = index.data(Qt::DisplayRole); if (!variant.isValid()) { - return 0; + return nullptr; } } @@ -362,7 +362,7 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde if (!n.isEmpty()) { if (!variant.isValid()) - variant = QVariant(editor->property(n).userType(), (const void *)0); + variant = QVariant(editor->property(n).userType(), (const void *)nullptr); editor->setProperty(n, variant); } diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 0bfd67dd7..8092bb770 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -380,7 +380,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mGrab(true) , mExportFonts(false) , mRandomSeed(0) - , mScriptContext (0) + , mScriptContext (nullptr) , mFSStrict (false) , mScriptBlacklistUse (true) , mNewGame (false) diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 764a07ec9..aca2685e0 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -14,11 +14,11 @@ #include "windowmanager.hpp" #include "statemanager.hpp" -MWBase::Environment *MWBase::Environment::sThis = 0; +MWBase::Environment *MWBase::Environment::sThis = nullptr; MWBase::Environment::Environment() -: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mStateManager (0), +: mWorld (nullptr), mSoundManager (nullptr), mScriptManager (nullptr), mWindowManager (nullptr), + mMechanicsManager (nullptr), mDialogueManager (nullptr), mJournal (nullptr), mInputManager (nullptr), mStateManager (nullptr), mFrameDuration (0), mFrameRateLimit(0.f) { assert (!sThis); @@ -28,7 +28,7 @@ MWBase::Environment::Environment() MWBase::Environment::~Environment() { cleanup(); - sThis = 0; + sThis = nullptr; } void MWBase::Environment::setWorld (World *world) @@ -166,31 +166,31 @@ float MWBase::Environment::getFrameDuration() const void MWBase::Environment::cleanup() { delete mMechanicsManager; - mMechanicsManager = 0; + mMechanicsManager = nullptr; delete mDialogueManager; - mDialogueManager = 0; + mDialogueManager = nullptr; delete mJournal; - mJournal = 0; + mJournal = nullptr; delete mScriptManager; - mScriptManager = 0; + mScriptManager = nullptr; delete mWindowManager; - mWindowManager = 0; + mWindowManager = nullptr; delete mWorld; - mWorld = 0; + mWorld = nullptr; delete mSoundManager; - mSoundManager = 0; + mSoundManager = nullptr; delete mInputManager; - mInputManager = 0; + mInputManager = nullptr; delete mStateManager; - mStateManager = 0; + mStateManager = nullptr; } const MWBase::Environment& MWBase::Environment::get() diff --git a/apps/openmw/mwbase/statemanager.hpp b/apps/openmw/mwbase/statemanager.hpp index 643695c37..157833a0e 100644 --- a/apps/openmw/mwbase/statemanager.hpp +++ b/apps/openmw/mwbase/statemanager.hpp @@ -59,7 +59,7 @@ namespace MWBase virtual void deleteGame (const MWState::Character *character, const MWState::Slot *slot) = 0; - virtual void saveGame (const std::string& description, const MWState::Slot *slot = 0) = 0; + virtual void saveGame (const std::string& description, const MWState::Slot *slot = nullptr) = 0; ///< Write a saved game to \a slot or create a new slot if \a slot == 0. /// /// \note Slot must belong to the current character. diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 49bc76a76..d4f1d2f8a 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -180,7 +180,7 @@ namespace MWBase virtual char getGlobalVariableType (const std::string& name) const = 0; ///< Return ' ', if there is no global variable with this name. - virtual std::string getCellName (const MWWorld::CellStore *cell = 0) const = 0; + virtual std::string getCellName (const MWWorld::CellStore *cell = nullptr) const = 0; ///< Return name of the cell. /// /// \note If cell==0, the cell the player is currently in will be used instead to diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index c51eab513..31341db73 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -69,7 +69,7 @@ namespace MWClass return *this; } - CreatureCustomData() : mContainerStore(0) {} + CreatureCustomData() : mContainerStore(nullptr) {} virtual ~CreatureCustomData() { delete mContainerStore; } }; diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 8a6ec998d..c70783f39 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -925,7 +925,7 @@ public: void dirtyFocusItem () { - if (mFocusItem != 0) + if (mFocusItem != nullptr) { MyGUI::IFont* Font = mBook->affectedFont (mFocusItem); @@ -946,7 +946,7 @@ public: dirtyFocusItem (); - mFocusItem = 0; + mFocusItem = nullptr; mItemActive = false; } @@ -976,7 +976,7 @@ public: } } else - if (mFocusItem != 0) + if (mFocusItem != nullptr) { bool newItemActive = hit == mFocusItem; diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 31fe3afb0..827f87c7d 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -87,15 +87,15 @@ namespace MWGui CharacterCreation::CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem) : mParent(parent) , mResourceSystem(resourceSystem) - , mNameDialog(0) - , mRaceDialog(0) - , mClassChoiceDialog(0) - , mGenerateClassQuestionDialog(0) - , mGenerateClassResultDialog(0) - , mPickClassDialog(0) - , mCreateClassDialog(0) - , mBirthSignDialog(0) - , mReviewDialog(0) + , mNameDialog(nullptr) + , mRaceDialog(nullptr) + , mClassChoiceDialog(nullptr) + , mGenerateClassQuestionDialog(nullptr) + , mGenerateClassResultDialog(nullptr) + , mPickClassDialog(nullptr) + , mCreateClassDialog(nullptr) + , mBirthSignDialog(nullptr) + , mReviewDialog(nullptr) , mGenerateClassStep(0) { mCreationStage = CSE_NotStarted; @@ -184,7 +184,7 @@ namespace MWGui { case GM_Name: MWBase::Environment::get().getWindowManager()->removeDialog(mNameDialog); - mNameDialog = 0; + mNameDialog = nullptr; mNameDialog = new TextInputDialog(); mNameDialog->setTextLabel(MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", "Name")); mNameDialog->setTextInput(mPlayerName); @@ -195,7 +195,7 @@ namespace MWGui case GM_Race: MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog); - mRaceDialog = 0; + mRaceDialog = nullptr; mRaceDialog = new RaceDialog(mParent, mResourceSystem); mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen); mRaceDialog->setRaceId(mPlayerRaceId); @@ -208,7 +208,7 @@ namespace MWGui case GM_Class: MWBase::Environment::get().getWindowManager()->removeDialog(mClassChoiceDialog); - mClassChoiceDialog = 0; + mClassChoiceDialog = nullptr; mClassChoiceDialog = new ClassChoiceDialog(); mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice); mClassChoiceDialog->setVisible(true); @@ -218,7 +218,7 @@ namespace MWGui case GM_ClassPick: MWBase::Environment::get().getWindowManager()->removeDialog(mPickClassDialog); - mPickClassDialog = 0; + mPickClassDialog = nullptr; mPickClassDialog = new PickClassDialog(); mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen); mPickClassDialog->setClassId(mPlayerClass.mId); @@ -231,7 +231,7 @@ namespace MWGui case GM_Birth: MWBase::Environment::get().getWindowManager()->removeDialog(mBirthSignDialog); - mBirthSignDialog = 0; + mBirthSignDialog = nullptr; mBirthSignDialog = new BirthDialog(); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); mBirthSignDialog->setBirthId(mPlayerBirthSignId); @@ -266,7 +266,7 @@ namespace MWGui break; case GM_Review: MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog); - mReviewDialog = 0; + mReviewDialog = nullptr; mReviewDialog = new ReviewDialog(); MWBase::World *world = MWBase::Environment::get().getWorld(); @@ -316,7 +316,7 @@ namespace MWGui void CharacterCreation::onReviewDialogDone(WindowBase* parWindow) { MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog); - mReviewDialog = 0; + mReviewDialog = nullptr; MWBase::Environment::get().getWindowManager()->popGuiMode(); } @@ -324,7 +324,7 @@ namespace MWGui void CharacterCreation::onReviewDialogBack() { MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog); - mReviewDialog = 0; + mReviewDialog = nullptr; mCreationStage = CSE_ReviewBack; MWBase::Environment::get().getWindowManager()->popGuiMode(); @@ -334,7 +334,7 @@ namespace MWGui void CharacterCreation::onReviewActivateDialog(int parDialog) { MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog); - mReviewDialog = 0; + mReviewDialog = nullptr; mCreationStage = CSE_ReviewNext; MWBase::Environment::get().getWindowManager()->popGuiMode(); @@ -370,7 +370,7 @@ namespace MWGui mPlayerClass = *klass; } MWBase::Environment::get().getWindowManager()->removeDialog(mPickClassDialog); - mPickClassDialog = 0; + mPickClassDialog = nullptr; } updatePlayerHealth(); @@ -394,7 +394,7 @@ namespace MWGui void CharacterCreation::onClassChoice(int _index) { MWBase::Environment::get().getWindowManager()->removeDialog(mClassChoiceDialog); - mClassChoiceDialog = 0; + mClassChoiceDialog = nullptr; MWBase::Environment::get().getWindowManager()->popGuiMode(); @@ -423,7 +423,7 @@ namespace MWGui mPlayerName = mNameDialog->getTextInput(); MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName); MWBase::Environment::get().getWindowManager()->removeDialog(mNameDialog); - mNameDialog = 0; + mNameDialog = nullptr; } handleDialogDone(CSE_NameChosen, GM_Race); @@ -446,7 +446,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar(); MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog); - mRaceDialog = 0; + mRaceDialog = nullptr; } updatePlayerHealth(); @@ -475,7 +475,7 @@ namespace MWGui if (!mPlayerBirthSignId.empty()) MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId); MWBase::Environment::get().getWindowManager()->removeDialog(mBirthSignDialog); - mBirthSignDialog = 0; + mBirthSignDialog = nullptr; } updatePlayerHealth(); @@ -551,7 +551,7 @@ namespace MWGui MWBase::Environment::get().getSoundManager()->stopSay(); MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassQuestionDialog); - mGenerateClassQuestionDialog = 0; + mGenerateClassQuestionDialog = nullptr; if (_index < 0 || _index >= 3) { @@ -669,7 +669,7 @@ namespace MWGui } MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog); - mGenerateClassResultDialog = 0; + mGenerateClassResultDialog = nullptr; mGenerateClassResultDialog = new GenerateClassResultDialog(); mGenerateClassResultDialog->setClassId(mGenerateClass); @@ -687,7 +687,7 @@ namespace MWGui } MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassQuestionDialog); - mGenerateClassQuestionDialog = 0; + mGenerateClassQuestionDialog = nullptr; mGenerateClassQuestionDialog = new InfoBoxDialog(); @@ -711,7 +711,7 @@ namespace MWGui void CharacterCreation::selectGeneratedClass() { MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog); - mGenerateClassResultDialog = 0; + mGenerateClassResultDialog = nullptr; MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index cfbf5e5fb..ee5fe5939 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -550,16 +550,16 @@ namespace MWGui void CreateClassDialog::onDialogCancel() { MWBase::Environment::get().getWindowManager()->removeDialog(mSpecDialog); - mSpecDialog = 0; + mSpecDialog = nullptr; MWBase::Environment::get().getWindowManager()->removeDialog(mAttribDialog); - mAttribDialog = 0; + mAttribDialog = nullptr; MWBase::Environment::get().getWindowManager()->removeDialog(mSkillDialog); - mSkillDialog = 0; + mSkillDialog = nullptr; MWBase::Environment::get().getWindowManager()->removeDialog(mDescDialog); - mDescDialog = 0; + mDescDialog = nullptr; } void CreateClassDialog::onSpecializationClicked(MyGUI::Widget* _sender) @@ -577,7 +577,7 @@ namespace MWGui setSpecialization(mSpecializationId); MWBase::Environment::get().getWindowManager()->removeDialog(mSpecDialog); - mSpecDialog = 0; + mSpecDialog = nullptr; } void CreateClassDialog::setSpecialization(int id) @@ -618,7 +618,7 @@ namespace MWGui } mAffectedAttribute->setAttributeId(id); MWBase::Environment::get().getWindowManager()->removeDialog(mAttribDialog); - mAttribDialog = 0; + mAttribDialog = nullptr; update(); } @@ -651,7 +651,7 @@ namespace MWGui mAffectedSkill->setSkillId(mSkillDialog->getSkillId()); MWBase::Environment::get().getWindowManager()->removeDialog(mSkillDialog); - mSkillDialog = 0; + mSkillDialog = nullptr; update(); } @@ -667,7 +667,7 @@ namespace MWGui { mDescription = mDescDialog->getTextInput(); MWBase::Environment::get().getWindowManager()->removeDialog(mDescDialog); - mDescDialog = 0; + mDescDialog = nullptr; } void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index e56cd170c..89ba5d388 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -36,7 +36,7 @@ namespace MWGui ConsoleInterpreterContext::ConsoleInterpreterContext (Console& console, MWWorld::Ptr reference) : MWScript::InterpreterContext ( - reference.isEmpty() ? 0 : &reference.getRefData().getLocals(), reference), + reference.isEmpty() ? nullptr : &reference.getRefData().getLocals(), reference), mConsole (console) {} diff --git a/apps/openmw/mwgui/draganddrop.cpp b/apps/openmw/mwgui/draganddrop.cpp index daf9f6636..cfe60db5d 100644 --- a/apps/openmw/mwgui/draganddrop.cpp +++ b/apps/openmw/mwgui/draganddrop.cpp @@ -135,7 +135,7 @@ void DragAndDrop::finish() MWBase::Environment::get().getWindowManager()->getInventoryWindow()->updateItemView(); MyGUI::Gui::getInstance().destroyWidget(mDraggedWidget); - mDraggedWidget = 0; + mDraggedWidget = nullptr; MWBase::Environment::get().getWindowManager()->setDragDrop(false); } diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index a5d8f7344..4e695710f 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -24,7 +24,7 @@ namespace MWGui MainMenu::MainMenu(int w, int h, const VFS::Manager* vfs, const std::string& versionDescription) : WindowBase("openmw_mainmenu.layout") , mWidth (w), mHeight (h) - , mVFS(vfs), mButtonBox(0) + , mVFS(vfs), mButtonBox(nullptr) , mBackground(nullptr) , mVideoBackground(nullptr) , mVideo(nullptr) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index acf131926..6e8804a43 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -644,7 +644,7 @@ namespace MWGui : WindowPinnableBase("openmw_map_window.layout") , LocalMapBase(customMarkers, localMapRender) , NoDrop(drag, mMainWidget) - , mGlobalMap(0) + , mGlobalMap(nullptr) , mGlobalMapImage(nullptr) , mGlobalMapOverlay(nullptr) , mGlobal(Settings::Manager::getBool("global", "Map")) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 214e52942..a6bfac2a4 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -37,9 +37,9 @@ namespace MWGui , mKey(std::vector(10)) , mSelected(nullptr) , mActivated(nullptr) - , mAssignDialog(0) - , mItemSelectionDialog(0) - , mMagicSelectionDialog(0) + , mAssignDialog(nullptr) + , mItemSelectionDialog(nullptr) + , mMagicSelectionDialog(nullptr) { getWidget(mOkButton, "OKButton"); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index e76cbe770..101b6956d 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -86,7 +86,7 @@ namespace MWGui for (int i = 0; i < ESM::Skill::Length; ++i) { mSkillValues.insert(std::make_pair(i, MWMechanics::SkillValue())); - mSkillWidgetMap.insert(std::make_pair(i, static_cast (0))); + mSkillWidgetMap.insert(std::make_pair(i, static_cast (nullptr))); } MyGUI::Button* backButton; diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 1f086507f..f9de469e2 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -587,7 +587,7 @@ namespace MWGui mAddEffectDialog.newEffect(effect); mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId()); MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog); - mSelectAttributeDialog = 0; + mSelectAttributeDialog = nullptr; } void EffectEditorBase::onSelectSkill () @@ -598,7 +598,7 @@ namespace MWGui mAddEffectDialog.newEffect(effect); mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId()); MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog); - mSelectSkillDialog = 0; + mSelectSkillDialog = nullptr; } void EffectEditorBase::onAttributeOrSkillCancel () @@ -608,8 +608,8 @@ namespace MWGui if (mSelectAttributeDialog) MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog); - mSelectSkillDialog = 0; - mSelectAttributeDialog = 0; + mSelectSkillDialog = nullptr; + mSelectAttributeDialog = nullptr; } void EffectEditorBase::onAvailableEffectClicked (MyGUI::Widget* sender) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index c0db57b1b..e0a8e4d3e 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -153,7 +153,7 @@ namespace MWGui return; MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getMouseFocusWidget(); - if (focus == 0) + if (focus == nullptr) return; MyGUI::IntSize tooltipSize; @@ -410,7 +410,7 @@ namespace MWGui if (text.size() > 0 && text[0] == '\n') text.erase(0, 1); - const ESM::Enchantment* enchant = 0; + const ESM::Enchantment* enchant = nullptr; const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (info.enchant != "") { diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 74076641a..fb8521f06 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -101,7 +101,7 @@ namespace MWGui button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked); } - button = 0; + button = nullptr; assignWidget(button, "StatValueButton"); if (button) { @@ -192,7 +192,7 @@ namespace MWGui button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked); } - button = 0; + button = nullptr; assignWidget(button, "StatValueButton"); if (button) { diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 840f0f9cf..bfce90810 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1957,7 +1957,7 @@ namespace MWGui { if (_type != "Text") return; - char* text=0; + char* text=nullptr; text = SDL_GetClipboardText(); if (text) _data = MyGUI::TextIterator::toTagsString(text); diff --git a/apps/openmw/mwinput/mousemanager.cpp b/apps/openmw/mwinput/mousemanager.cpp index ac30d4487..4816470ff 100644 --- a/apps/openmw/mwinput/mousemanager.cpp +++ b/apps/openmw/mwinput/mousemanager.cpp @@ -154,7 +154,7 @@ namespace MWInput { guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); guiMode = MyGUI::InputManager::getInstance().injectMousePress(static_cast(mGuiCursorX), static_cast(mGuiCursorY), sdlButtonToMyGUI(id)) && guiMode; - if (MyGUI::InputManager::getInstance().getMouseFocusWidget () != 0) + if (MyGUI::InputManager::getInstance().getMouseFocusWidget () != nullptr) { MyGUI::Button* b = MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType(false); if (b && b->getEnabled() && id == SDL_BUTTON_LEFT) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 116937fcd..6d06724f0 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -255,7 +255,7 @@ const ESM::Potion *MWMechanics::Alchemy::getRecord(const ESM::Potion& toFind) co return &(*iter); } - return 0; + return nullptr; } void MWMechanics::Alchemy::removeIngredients() diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index ce45729b3..a908940ed 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -368,7 +368,7 @@ namespace MWScript std::string cellID = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - MWWorld::CellStore* store = 0; + MWWorld::CellStore* store = nullptr; try { store = MWBase::Environment::get().getWorld()->getInterior(cellID); @@ -481,7 +481,7 @@ namespace MWScript Interpreter::Type_Float zRotDegrees = runtime[0].mFloat; runtime.pop(); - MWWorld::CellStore* store = 0; + MWWorld::CellStore* store = nullptr; try { store = MWBase::Environment::get().getWorld()->getInterior(cellID); diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 6c334978c..95ed9eeed 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -437,7 +437,7 @@ FFmpeg_Decoder::FFmpeg_Decoder(const VFS::Manager* vfs) , mFrameSize(0) , mFramePos(0) , mNextPts(0.0) - , mSwr(0) + , mSwr(nullptr) , mOutputSampleFormat(AV_SAMPLE_FMT_NONE) , mOutputChannelLayout(0) , mDataBuf(nullptr) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index a7be5a743..67b52309d 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -624,7 +624,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname attrs.reserve(15); if(ALC.SOFT_HRTF) { - LPALCGETSTRINGISOFT alcGetStringiSOFT = 0; + LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; getALCFunc(alcGetStringiSOFT, mDevice, "alcGetStringiSOFT"); attrs.push_back(ALC_HRTF_SOFT); @@ -850,13 +850,13 @@ void OpenAL_Output::deinit() alDeleteFilters(1, &mWaterFilter); mWaterFilter = 0; - alcMakeContextCurrent(0); + alcMakeContextCurrent(nullptr); if(mContext) alcDestroyContext(mContext); - mContext = 0; + mContext = nullptr; if(mDevice) alcCloseDevice(mDevice); - mDevice = 0; + mDevice = nullptr; mInitialized = false; } @@ -869,7 +869,7 @@ std::vector OpenAL_Output::enumerateHrtf() if(!mDevice || !ALC.SOFT_HRTF) return ret; - LPALCGETSTRINGISOFT alcGetStringiSOFT = 0; + LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; getALCFunc(alcGetStringiSOFT, mDevice, "alcGetStringiSOFT"); ALCint num_hrtf; @@ -892,10 +892,10 @@ void OpenAL_Output::setHrtf(const std::string &hrtfname, HrtfMode hrtfmode) return; } - LPALCGETSTRINGISOFT alcGetStringiSOFT = 0; + LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; getALCFunc(alcGetStringiSOFT, mDevice, "alcGetStringiSOFT"); - LPALCRESETDEVICESOFT alcResetDeviceSOFT = 0; + LPALCRESETDEVICESOFT alcResetDeviceSOFT = nullptr; getALCFunc(alcResetDeviceSOFT, mDevice, "alcResetDeviceSOFT"); std::vector attrs; @@ -1213,7 +1213,7 @@ void OpenAL_Output::finishSound(Sound *sound) { if(!sound->mHandle) return; ALuint source = GET_PTRID(sound->mHandle); - sound->mHandle = 0; + sound->mHandle = nullptr; // Rewind the stream to put the source back into an AL_INITIAL state, for // the next time it's used. @@ -1316,7 +1316,7 @@ void OpenAL_Output::finishStream(Stream *sound) OpenAL_SoundStream *stream = reinterpret_cast(sound->mHandle); ALuint source = stream->mSource; - sound->mHandle = 0; + sound->mHandle = nullptr; mStreamThread->remove(stream); // Rewind the stream to put the source back into an AL_INITIAL state, for @@ -1462,7 +1462,7 @@ void OpenAL_Output::pauseActiveDevice() if(alcIsExtensionPresent(mDevice, "ALC_SOFT_PAUSE_DEVICE")) { - LPALCDEVICEPAUSESOFT alcDevicePauseSOFT = 0; + LPALCDEVICEPAUSESOFT alcDevicePauseSOFT = nullptr; getALCFunc(alcDevicePauseSOFT, mDevice, "alcDevicePauseSOFT"); alcDevicePauseSOFT(mDevice); getALCError(mDevice); @@ -1478,7 +1478,7 @@ void OpenAL_Output::resumeActiveDevice() if(alcIsExtensionPresent(mDevice, "ALC_SOFT_PAUSE_DEVICE")) { - LPALCDEVICERESUMESOFT alcDeviceResumeSOFT = 0; + LPALCDEVICERESUMESOFT alcDeviceResumeSOFT = nullptr; getALCFunc(alcDeviceResumeSOFT, mDevice, "alcDeviceResumeSOFT"); alcDeviceResumeSOFT(mDevice); getALCError(mDevice); @@ -1513,7 +1513,7 @@ void OpenAL_Output::resumeSounds(int types) OpenAL_Output::OpenAL_Output(SoundManager &mgr) : Sound_Output(mgr) - , mDevice(0), mContext(0) + , mDevice(nullptr), mContext(nullptr) , mListenerPos(0.0f, 0.0f, 0.0f), mListenerEnv(Env_Normal) , mWaterFilter(0), mWaterEffect(0), mDefaultEffect(0), mEffectSlot(0) , mStreamThread(new StreamThread) diff --git a/apps/openmw/mwsound/sound_buffer.hpp b/apps/openmw/mwsound/sound_buffer.hpp index 5ca3a45da..83b08d6be 100644 --- a/apps/openmw/mwsound/sound_buffer.hpp +++ b/apps/openmw/mwsound/sound_buffer.hpp @@ -20,7 +20,7 @@ namespace MWSound size_t mUses; Sound_Buffer(std::string resname, float volume, float mindist, float maxdist) - : mResourceName(resname), mVolume(volume), mMinDist(mindist), mMaxDist(maxdist), mHandle(0), mUses(0) + : mResourceName(resname), mVolume(volume), mMinDist(mindist), mMaxDist(maxdist), mHandle(nullptr), mUses(0) { } }; } diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 1a90dceed..37ba80820 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -120,7 +120,7 @@ namespace MWSound { if(sfx.mHandle) mOutput->unloadSound(sfx.mHandle); - sfx.mHandle = 0; + sfx.mHandle = nullptr; } mUnusedBuffers.clear(); mOutput.reset(); @@ -229,7 +229,7 @@ namespace MWSound size = mOutput->unloadSound(unused->mHandle); mBufferCacheSize -= size; - unused->mHandle = 0; + unused->mHandle = nullptr; mUnusedBuffers.pop_back(); } while(mBufferCacheSize > mBufferCacheMin); diff --git a/apps/openmw/mwstate/character.cpp b/apps/openmw/mwstate/character.cpp index 3c5c4f8b2..df1ab1bdf 100644 --- a/apps/openmw/mwstate/character.cpp +++ b/apps/openmw/mwstate/character.cpp @@ -64,7 +64,7 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile) } slot.mProfile = profile; - slot.mTimeStamp = std::time (0); + slot.mTimeStamp = std::time (nullptr); mSlots.push_back (slot); } @@ -143,7 +143,7 @@ const MWState::Slot *MWState::Character::updateSlot (const Slot *slot, const ESM Slot newSlot = *slot; newSlot.mProfile = profile; - newSlot.mTimeStamp = std::time (0); + newSlot.mTimeStamp = std::time (nullptr); mSlots.erase (mSlots.begin()+index); diff --git a/apps/openmw/mwstate/charactermanager.cpp b/apps/openmw/mwstate/charactermanager.cpp index b5868c3e5..a324dfe0f 100644 --- a/apps/openmw/mwstate/charactermanager.cpp +++ b/apps/openmw/mwstate/charactermanager.cpp @@ -7,7 +7,7 @@ MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves, const std::string& game) -: mPath (saves), mCurrent (0), mGame (game) +: mPath (saves), mCurrent (nullptr), mGame (game) { if (!boost::filesystem::is_directory (mPath)) { diff --git a/apps/openmw/mwstate/statemanagerimp.hpp b/apps/openmw/mwstate/statemanagerimp.hpp index 11984b7f5..3534dabf2 100644 --- a/apps/openmw/mwstate/statemanagerimp.hpp +++ b/apps/openmw/mwstate/statemanagerimp.hpp @@ -53,7 +53,7 @@ namespace MWState void deleteGame (const MWState::Character *character, const MWState::Slot *slot) override; ///< Delete a saved game slot from this character. If all save slots are deleted, the character will be deleted too. - void saveGame (const std::string& description, const Slot *slot = 0) override; + void saveGame (const std::string& description, const Slot *slot = nullptr) override; ///< Write a saved game to \a slot or create a new slot if \a slot == 0. /// /// \note Slot must belong to the current character. diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 94c78b433..15c1b46ba 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -94,7 +94,7 @@ void MWWorld::Cells::clear() { mInteriors.clear(); mExteriors.clear(); - std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair("", (MWWorld::CellStore*)0)); + std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair("", (MWWorld::CellStore*)nullptr)); mIdCacheIndex = 0; } @@ -132,7 +132,7 @@ void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const MWWorld::Cells::Cells (const MWWorld::ESMStore& store, std::vector& reader) : mStore (store), mReader (reader), - mIdCache (Settings::Manager::getInt("pointers cache size", "Cells"), std::pair ("", (CellStore*)0)), + mIdCache (Settings::Manager::getInt("pointers cache size", "Cells"), std::pair ("", (CellStore*)nullptr)), mIdCacheIndex (0) {} @@ -449,7 +449,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type, ESM::CellState state; state.mId.load (reader); - CellStore *cellStore = 0; + CellStore *cellStore = nullptr; try { diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 14b96b27c..b48fe74a6 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -37,7 +37,7 @@ namespace for (typename MWWorld::CellRefList::List::iterator iter (containerList.mList.begin()); iter!=containerList.mList.end(); ++iter) { - MWWorld::Ptr container (&*iter, 0); + MWWorld::Ptr container (&*iter, nullptr); if (container.getRefData().getCustomData() == nullptr) continue; diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 6fad42926..17c35489f 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -67,7 +67,7 @@ namespace { if (Misc::StringUtils::ciEqual(iter->mBase->mId, id2) && iter->mData.getCount()) { - MWWorld::Ptr ptr (&*iter, 0); + MWWorld::Ptr ptr (&*iter, nullptr); ptr.setContainerStore (store); return ptr; } @@ -326,7 +326,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr if (actorPtr == player) { // Items in player's inventory have cell set to 0, so their scripts will never be removed - item.mCell = 0; + item.mCell = nullptr; } else { @@ -1138,18 +1138,18 @@ PtrType MWWorld::ContainerStoreIteratorBase::operator*() const switch (mType) { - case ContainerStore::Type_Potion: ptr = PtrType (&*mPotion, 0); break; - case ContainerStore::Type_Apparatus: ptr = PtrType (&*mApparatus, 0); break; - case ContainerStore::Type_Armor: ptr = PtrType (&*mArmor, 0); break; - case ContainerStore::Type_Book: ptr = PtrType (&*mBook, 0); break; - case ContainerStore::Type_Clothing: ptr = PtrType (&*mClothing, 0); break; - case ContainerStore::Type_Ingredient: ptr = PtrType (&*mIngredient, 0); break; - case ContainerStore::Type_Light: ptr = PtrType (&*mLight, 0); break; - case ContainerStore::Type_Lockpick: ptr = PtrType (&*mLockpick, 0); break; - case ContainerStore::Type_Miscellaneous: ptr = PtrType (&*mMiscellaneous, 0); break; - case ContainerStore::Type_Probe: ptr = PtrType (&*mProbe, 0); break; - case ContainerStore::Type_Repair: ptr = PtrType (&*mRepair, 0); break; - case ContainerStore::Type_Weapon: ptr = PtrType (&*mWeapon, 0); break; + case ContainerStore::Type_Potion: ptr = PtrType (&*mPotion, nullptr); break; + case ContainerStore::Type_Apparatus: ptr = PtrType (&*mApparatus, nullptr); break; + case ContainerStore::Type_Armor: ptr = PtrType (&*mArmor, nullptr); break; + case ContainerStore::Type_Book: ptr = PtrType (&*mBook, nullptr); break; + case ContainerStore::Type_Clothing: ptr = PtrType (&*mClothing, nullptr); break; + case ContainerStore::Type_Ingredient: ptr = PtrType (&*mIngredient, nullptr); break; + case ContainerStore::Type_Light: ptr = PtrType (&*mLight, nullptr); break; + case ContainerStore::Type_Lockpick: ptr = PtrType (&*mLockpick, nullptr); break; + case ContainerStore::Type_Miscellaneous: ptr = PtrType (&*mMiscellaneous, nullptr); break; + case ContainerStore::Type_Probe: ptr = PtrType (&*mProbe, nullptr); break; + case ContainerStore::Type_Repair: ptr = PtrType (&*mRepair, nullptr); break; + case ContainerStore::Type_Weapon: ptr = PtrType (&*mWeapon, nullptr); break; } if (ptr.isEmpty()) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 942d5feeb..90bc80b48 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -71,7 +71,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener) { listener->setProgressRange(1000); - ESM::Dialogue *dialogue = 0; + ESM::Dialogue *dialogue = nullptr; // Land texture loading needs to use a separate internal store for each plugin. // We set the number of plugins here to avoid continual resizes during loading, @@ -153,7 +153,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener) if (n.intval==ESM::REC_DIAL) { dialogue = const_cast(mDialogs.find(id.mId)); } else { - dialogue = 0; + dialogue = nullptr; } } listener->setProgress(static_cast(esm.getFileOffset() / (float)esm.getFileSize() * 1000)); diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 99db96ac1..d69c56d8c 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -196,7 +196,7 @@ namespace MWWorld const std::string id = "$dynamic" + std::to_string(mDynamicCount++); Store &store = const_cast &>(get()); - if (store.search(id) != 0) + if (store.search(id) != nullptr) { const std::string msg = "Try to override existing record '" + id + "'"; throw std::runtime_error(msg); @@ -234,7 +234,7 @@ namespace MWWorld const std::string id = "$dynamic" + std::to_string(mDynamicCount++); Store &store = const_cast &>(get()); - if (store.search(id) != 0) + if (store.search(id) != nullptr) { const std::string msg = "Try to override existing record '" + id + "'"; throw std::runtime_error(msg); @@ -286,7 +286,7 @@ namespace MWWorld { return mNpcs.insert(npc); } - else if (mNpcs.search(id) != 0) + else if (mNpcs.search(id) != nullptr) { const std::string msg = "Try to override existing record '" + id + "'"; throw std::runtime_error(msg); diff --git a/apps/openmw/mwworld/manualref.cpp b/apps/openmw/mwworld/manualref.cpp index 48270d224..7f7fd6033 100644 --- a/apps/openmw/mwworld/manualref.cpp +++ b/apps/openmw/mwworld/manualref.cpp @@ -26,7 +26,7 @@ namespace MWWorld::LiveCellRef ref(cellRef, base); refValue = ref; - ptrValue = MWWorld::Ptr(&boost::any_cast&>(refValue), 0); + ptrValue = MWWorld::Ptr(&boost::any_cast&>(refValue), nullptr); } } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 66ae4e319..d8e2fb2f0 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -29,7 +29,7 @@ namespace MWWorld { Player::Player (const ESM::NPC *player) - : mCellStore(0), + : mCellStore(nullptr), mLastKnownExteriorPosition(0,0,0), mMarkedPosition(ESM::Position()), mMarkedCell(nullptr), @@ -299,9 +299,9 @@ namespace MWWorld void Player::clear() { - mCellStore = 0; + mCellStore = nullptr; mSign.clear(); - mMarkedCell = 0; + mMarkedCell = nullptr; mAutoMove = false; mForwardBackward = 0; mTeleported = false; @@ -448,7 +448,7 @@ namespace MWWorld } else { - mMarkedCell = 0; + mMarkedCell = nullptr; } mForwardBackward = 0; diff --git a/apps/openmw/mwworld/ptr.cpp b/apps/openmw/mwworld/ptr.cpp index 12c44b0b3..e16a19629 100644 --- a/apps/openmw/mwworld/ptr.cpp +++ b/apps/openmw/mwworld/ptr.cpp @@ -8,7 +8,7 @@ const std::string& MWWorld::Ptr::getTypeName() const { - if(mRef != 0) + if(mRef != nullptr) return mRef->mClass->getTypeName(); throw std::runtime_error("Can't get type name from an empty object."); } @@ -57,7 +57,7 @@ MWWorld::Ptr::operator const void *() const std::string &MWWorld::ConstPtr::getTypeName() const { - if(mRef != 0) + if(mRef != nullptr) return mRef->mClass->getTypeName(); throw std::runtime_error("Can't get type name from an empty object."); } diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index d7c170e45..9ab18d7f4 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -25,21 +25,21 @@ namespace MWWorld ContainerStore *mContainerStore; public: - Ptr(MWWorld::LiveCellRefBase *liveCellRef=0, CellStore *cell=0) - : mRef(liveCellRef), mCell(cell), mContainerStore(0) + Ptr(MWWorld::LiveCellRefBase *liveCellRef=nullptr, CellStore *cell=nullptr) + : mRef(liveCellRef), mCell(cell), mContainerStore(nullptr) { } bool isEmpty() const { - return mRef == 0; + return mRef == nullptr; } const std::string& getTypeName() const; const Class& getClass() const { - if(mRef != 0) + if(mRef != nullptr) return *(mRef->mClass); throw std::runtime_error("Cannot get class of an empty object"); } @@ -52,7 +52,7 @@ namespace MWWorld std::stringstream str; str<< "Bad LiveCellRef cast to "<mClass); throw std::runtime_error("Cannot get class of an empty object"); } @@ -128,7 +128,7 @@ namespace MWWorld std::stringstream str; str<< "Bad LiveCellRef cast to "<clone() : 0; + mCustomData = refData.mCustomData ? refData.mCustomData->clone() : nullptr; } void RefData::cleanup() { - mBaseNode = 0; + mBaseNode = nullptr; delete mCustomData; - mCustomData = 0; + mCustomData = nullptr; } RefData::RefData() - : mBaseNode(0), mDeletedByContentFile(false), mEnabled (true), mCount (1), mCustomData (0), mChanged(false), mFlags(0) + : mBaseNode(nullptr), mDeletedByContentFile(false), mEnabled (true), mCount (1), mCustomData (nullptr), mChanged(false), mFlags(0) { for (int i=0; i<3; ++i) { @@ -56,20 +56,20 @@ namespace MWWorld } RefData::RefData (const ESM::CellRef& cellRef) - : mBaseNode(0), mDeletedByContentFile(false), mEnabled (true), + : mBaseNode(nullptr), mDeletedByContentFile(false), mEnabled (true), mCount (1), mPosition (cellRef.mPos), - mCustomData (0), + mCustomData (nullptr), mChanged(false), mFlags(0) // Loading from ESM/ESP files -> assume unchanged { } RefData::RefData (const ESM::ObjectState& objectState, bool deletedByContentFile) - : mBaseNode(0), mDeletedByContentFile(deletedByContentFile), + : mBaseNode(nullptr), mDeletedByContentFile(deletedByContentFile), mEnabled (objectState.mEnabled != 0), mCount (objectState.mCount), mPosition (objectState.mPosition), mAnimationState(objectState.mAnimationState), - mCustomData (0), + mCustomData (nullptr), mChanged(true), mFlags(objectState.mFlags) // Loading from a savegame -> assume changed { // "Note that the ActivationFlag_UseEnabled is saved to the reference, @@ -79,7 +79,7 @@ namespace MWWorld } RefData::RefData (const RefData& refData) - : mBaseNode(0), mCustomData (0) + : mBaseNode(nullptr), mCustomData (nullptr) { try { diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index d01cc741c..47b62862f 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -397,7 +397,7 @@ namespace MWWorld if (!test && cell->getCell()->isExterior()) { osg::ref_ptr land = mRendering.getLandManager()->getLand(cellX, cellY); - const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VHGT) : 0; + const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VHGT) : nullptr; if (data) { mPhysics->addHeightField (data->mHeights, cellX, cellY, worldsize / (verts-1), verts, data->mMinHeight, data->mMaxHeight, land.get()); @@ -755,7 +755,7 @@ namespace MWWorld Scene::Scene (MWRender::RenderingManager& rendering, MWPhysics::PhysicsSystem *physics, DetourNavigator::Navigator& navigator) - : mCurrentCell (0), mCellChanged (false), mPhysics(physics), mRendering(rendering), mNavigator(navigator) + : mCurrentCell (nullptr), mCellChanged (false), mPhysics(physics), mRendering(rendering), mNavigator(navigator) , mCellLoadingThreshold(1024.f) , mPreloadDistance(Settings::Manager::getInt("preload distance", "Cells")) , mPreloadEnabled(Settings::Manager::getBool("preload enabled", "Cells")) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index f8ec8c7c2..69ca1f8c2 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -101,7 +101,7 @@ namespace MWWorld const T *IndexedStore::find(int index) const { const T *ptr = search(index); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = T::getRecordType() + " with index " + std::to_string(index) + " not found"; throw std::runtime_error(msg); @@ -146,7 +146,7 @@ namespace MWWorld if (it != mStatic.end()) return &(it->second); - return 0; + return nullptr; } template const T *Store::searchStatic(const std::string &id) const @@ -156,7 +156,7 @@ namespace MWWorld if (it != mStatic.end()) return &(it->second); - return 0; + return nullptr; } template @@ -178,7 +178,7 @@ namespace MWWorld const T *Store::find(const std::string &id) const { const T *ptr = search(id); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = T::getRecordType() + " '" + id + "' not found"; throw std::runtime_error(msg); @@ -189,7 +189,7 @@ namespace MWWorld const T *Store::findRandom(const std::string &id) const { const T *ptr = searchRandom(id); - if(ptr == 0) + if(ptr == nullptr) { const std::string msg = T::getRecordType() + " starting with '" + id + "' not found"; throw std::runtime_error(msg); @@ -370,7 +370,7 @@ namespace MWWorld const ESM::LandTexture *Store::find(size_t index, size_t plugin) const { const ESM::LandTexture *ptr = search(index, plugin); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = "Land texture with index " + std::to_string(index) + " not found"; throw std::runtime_error(msg); @@ -471,12 +471,12 @@ namespace MWWorld if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) { return *it; } - return 0; + return nullptr; } const ESM::Land *Store::find(int x, int y) const { const ESM::Land *ptr = search(x, y); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = "Land at (" + std::to_string(x) + ", " + std::to_string(y) + ") not found"; throw std::runtime_error(msg); @@ -570,7 +570,7 @@ namespace MWWorld return &dit->second; } - return 0; + return nullptr; } const ESM::Cell *Store::search(int x, int y) const { @@ -588,7 +588,7 @@ namespace MWWorld return &dit->second; } - return 0; + return nullptr; } const ESM::Cell *Store::searchStatic(int x, int y) const { @@ -600,7 +600,7 @@ namespace MWWorld if (it != mExt.end()) { return &(it->second); } - return 0; + return nullptr; } const ESM::Cell *Store::searchOrCreate(int x, int y) { @@ -628,7 +628,7 @@ namespace MWWorld const ESM::Cell *Store::find(const std::string &id) const { const ESM::Cell *ptr = search(id); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = "Cell '" + id + "' not found"; throw std::runtime_error(msg); @@ -638,7 +638,7 @@ namespace MWWorld const ESM::Cell *Store::find(int x, int y) const { const ESM::Cell *ptr = search(x, y); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = "Exterior at (" + std::to_string(x) + ", " + std::to_string(y) + ") not found"; throw std::runtime_error(msg); @@ -781,7 +781,7 @@ namespace MWWorld { if (Misc::StringUtils::ciEqual(sharedCell->mName, id)) { - if (cell == 0 || + if (cell == nullptr || (sharedCell->mData.mX > cell->mData.mX) || (sharedCell->mData.mX == cell->mData.mX && sharedCell->mData.mY > cell->mData.mY)) { @@ -831,7 +831,7 @@ namespace MWWorld } ESM::Cell *Store::insert(const ESM::Cell &cell) { - if (search(cell) != 0) + if (search(cell) != nullptr) { const std::string cellType = (cell.isExterior()) ? "exterior" : "interior"; throw std::runtime_error("Failed to create " + cellType + " cell"); @@ -1032,7 +1032,7 @@ namespace MWWorld const ESM::Attribute *Store::search(size_t index) const { if (index >= mStatic.size()) { - return 0; + return nullptr; } return &mStatic.at(index); } @@ -1040,7 +1040,7 @@ namespace MWWorld const ESM::Attribute *Store::find(size_t index) const { const ESM::Attribute *ptr = search(index); - if (ptr == 0) + if (ptr == nullptr) { const std::string msg = "Attribute with index " + std::to_string(index) + " not found"; throw std::runtime_error(msg); diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index d2406b602..cb9f4f1e0 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -412,7 +412,7 @@ namespace MWWorld const ESM::WeaponType *search(const int id) const; const ESM::WeaponType *find(const int id) const; - RecordId load(ESM::ESMReader &esm) override { return RecordId(0, false); } + RecordId load(ESM::ESMReader &esm) override { return RecordId(nullptr, false); } ESM::WeaponType* insert(const ESM::WeaponType &weaponType); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 20ee7625b..224925dd5 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -302,7 +302,7 @@ namespace MWWorld if (mPlayer) { mPlayer->clear(); - mPlayer->setCell(0); + mPlayer->setCell(nullptr); mPlayer->getPlayer().getRefData() = RefData(); mPlayer->set(mStore.get().find ("player")); } @@ -1010,7 +1010,7 @@ namespace MWWorld if (!facedObject.isEmpty() && !facedObject.getClass().allowTelekinesis(facedObject) && mDistanceToFacedObject > getMaxActivationDistance() && !MWBase::Environment::get().getWindowManager()->isGuiMode()) - return 0; + return nullptr; } return facedObject; } @@ -1180,7 +1180,7 @@ namespace MWWorld haveToMove = false; newPtr = currCell->moveTo(ptr, newCell); - newPtr.getRefData().setBaseNode(0); + newPtr.getRefData().setBaseNode(nullptr); } else if (!currCellActive && !newCellActive) newPtr = currCell->moveTo(ptr, newCell); @@ -1263,7 +1263,7 @@ namespace MWWorld mWorldScene->removeFromPagedRefs(ptr); } - if(ptr.getRefData().getBaseNode() != 0) + if(ptr.getRefData().getBaseNode() != nullptr) mWorldScene->updateObjectScale(ptr); if (mPhysics->getActor(ptr)) @@ -1311,7 +1311,7 @@ namespace MWWorld mRendering->pagingBlacklistObject(mStore.find(ptr.getCellRef().getRefId()), ptr); mWorldScene->removeFromPagedRefs(ptr); - if(ptr.getRefData().getBaseNode() != 0) + if(ptr.getRefData().getBaseNode() != nullptr) { const auto order = flags & MWBase::RotationFlag_inverseOrder ? RotationOrder::inverse : RotationOrder::direct; @@ -1396,7 +1396,7 @@ namespace MWWorld void World::rotateWorldObject (const Ptr& ptr, osg::Quat rotate) { - if(ptr.getRefData().getBaseNode() != 0) + if(ptr.getRefData().getBaseNode() != nullptr) { mRendering->pagingBlacklistObject(mStore.find(ptr.getCellRef().getRefId()), ptr); mWorldScene->removeFromPagedRefs(ptr); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 41ab9cf2c..1fc5ebc20 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -275,7 +275,7 @@ namespace MWWorld char getGlobalVariableType (const std::string& name) const override; ///< Return ' ', if there is no global variable with this name. - std::string getCellName (const MWWorld::CellStore *cell = 0) const override; + std::string getCellName (const MWWorld::CellStore *cell = nullptr) const override; ///< Return name of the cell. /// /// \note If cell==0, the cell the player is currently in will be used instead to diff --git a/apps/wizard/mainwizard.hpp b/apps/wizard/mainwizard.hpp index 8d9623baa..4c221635e 100644 --- a/apps/wizard/mainwizard.hpp +++ b/apps/wizard/mainwizard.hpp @@ -41,7 +41,7 @@ namespace Wizard Page_Conclusion }; - MainWizard(QWidget *parent = 0); + MainWizard(QWidget *parent = nullptr); ~MainWizard(); bool findFiles(const QString &name, const QString &path); diff --git a/apps/wizard/unshield/unshieldworker.hpp b/apps/wizard/unshield/unshieldworker.hpp index 3f922ad78..2553d1bef 100644 --- a/apps/wizard/unshield/unshieldworker.hpp +++ b/apps/wizard/unshield/unshieldworker.hpp @@ -26,7 +26,7 @@ namespace Wizard Q_OBJECT public: - UnshieldWorker(QObject *parent = 0); + UnshieldWorker(QObject *parent = nullptr); ~UnshieldWorker(); void stopWorker(); diff --git a/apps/wizard/utils/componentlistwidget.hpp b/apps/wizard/utils/componentlistwidget.hpp index 23965f8a6..be15ea49f 100644 --- a/apps/wizard/utils/componentlistwidget.hpp +++ b/apps/wizard/utils/componentlistwidget.hpp @@ -10,7 +10,7 @@ class ComponentListWidget : public QListWidget Q_PROPERTY(QStringList mCheckedItems READ checkedItems) public: - ComponentListWidget(QWidget *parent = 0); + ComponentListWidget(QWidget *parent = nullptr); QStringList mCheckedItems; QStringList checkedItems(); diff --git a/components/compiler/context.hpp b/components/compiler/context.hpp index 2d6af0e45..399e8125b 100644 --- a/components/compiler/context.hpp +++ b/components/compiler/context.hpp @@ -13,14 +13,14 @@ namespace Compiler public: - Context() : mExtensions (0) {} + Context() : mExtensions (nullptr) {} virtual ~Context() = default; virtual bool canDeclareLocals() const = 0; ///< Is the compiler allowed to declare local variables? - void setExtensions (const Extensions *extensions = 0) + void setExtensions (const Extensions *extensions = nullptr) { mExtensions = extensions; } diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 86208d7af..e51c1809a 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -53,7 +53,7 @@ const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(in if (row >= 0 && row < mFiles.size()) return mFiles.at(row); - return 0; + return nullptr; } ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(int row) @@ -61,7 +61,7 @@ ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(int row) if (row >= 0 && row < mFiles.count()) return mFiles.at(row); - return 0; + return nullptr; } const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(const QString &name) const { @@ -75,7 +75,7 @@ const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(co if (name.compare(file->fileProperty (fp).toString(), Qt::CaseInsensitive) == 0) return file; } - return 0; + return nullptr; } QModelIndex ContentSelectorModel::ContentModel::indexFromItem(const EsmFile *item) const diff --git a/components/contentselector/model/esmfile.hpp b/components/contentselector/model/esmfile.hpp index 614eee298..66863d7c6 100644 --- a/components/contentselector/model/esmfile.hpp +++ b/components/contentselector/model/esmfile.hpp @@ -28,7 +28,7 @@ namespace ContentSelectorModel FileProperty_GameFile = 6 }; - EsmFile(QString fileName = QString(), ModelItem *parent = 0); + EsmFile(QString fileName = QString(), ModelItem *parent = nullptr); // EsmFile(const EsmFile &); ~EsmFile() diff --git a/components/contentselector/model/modelitem.hpp b/components/contentselector/model/modelitem.hpp index e4ea7acc6..a860b1891 100644 --- a/components/contentselector/model/modelitem.hpp +++ b/components/contentselector/model/modelitem.hpp @@ -11,7 +11,7 @@ namespace ContentSelectorModel Q_OBJECT public: - ModelItem(ModelItem *parent = 0); + ModelItem(ModelItem *parent = nullptr); //ModelItem(const ModelItem *parent = 0); ~ModelItem(); diff --git a/components/contentselector/view/combobox.cpp b/components/contentselector/view/combobox.cpp index 1ef9f9bd7..742e236b3 100644 --- a/components/contentselector/view/combobox.cpp +++ b/components/contentselector/view/combobox.cpp @@ -9,7 +9,7 @@ ContentSelectorView::ComboBox::ComboBox(QWidget *parent) : mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore setValidator(mValidator); setEditable(true); - setCompleter(0); + setCompleter(nullptr); setEnabled (true); setInsertPolicy(QComboBox::NoInsert); diff --git a/components/contentselector/view/combobox.hpp b/components/contentselector/view/combobox.hpp index c57a5f116..9af3c83af 100644 --- a/components/contentselector/view/combobox.hpp +++ b/components/contentselector/view/combobox.hpp @@ -14,7 +14,7 @@ namespace ContentSelectorView Q_OBJECT public: - explicit ComboBox (QWidget *parent = 0); + explicit ComboBox (QWidget *parent = nullptr); void setPlaceholderText(const QString &text); diff --git a/components/contentselector/view/contentselector.hpp b/components/contentselector/view/contentselector.hpp index f1058d510..1b50f1e5e 100644 --- a/components/contentselector/view/contentselector.hpp +++ b/components/contentselector/view/contentselector.hpp @@ -23,7 +23,7 @@ namespace ContentSelectorView public: - explicit ContentSelector(QWidget *parent = 0); + explicit ContentSelector(QWidget *parent = nullptr); QString currentFile() const; diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index 307c08d95..4ad856548 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -451,7 +451,7 @@ static void getExecPath(char **argv) if(argv[0][0] == '/') snprintf(argv0, sizeof(argv0), "%s", argv[0]); - else if (getcwd(argv0, sizeof(argv0)) != NULL) + else if (getcwd(argv0, sizeof(argv0)) != nullptr) { cwdlen = strlen(argv0); snprintf(argv0+cwdlen, sizeof(argv0)-cwdlen, "/%s", argv[0]); diff --git a/components/detournavigator/findsmoothpath.cpp b/components/detournavigator/findsmoothpath.cpp index 8e443def9..a13b83abd 100644 --- a/components/detournavigator/findsmoothpath.cpp +++ b/components/detournavigator/findsmoothpath.cpp @@ -58,8 +58,8 @@ namespace DetourNavigator return path; // Get connected polygons - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = nullptr; + const dtPoly* poly = nullptr; if (dtStatusFailed(navQuery.getAttachedNavMesh()->getTileAndPolyByRef(path[0], &tile, &poly))) return path; diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index dcdddce8a..a351f8279 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -158,10 +158,10 @@ namespace DetourNavigator { // Iterate over the path to find smooth path on the detail mesh surface. osg::Vec3f iterPos; - navMeshQuery.closestPointOnPoly(polygonPath.front(), start.ptr(), iterPos.ptr(), 0); + navMeshQuery.closestPointOnPoly(polygonPath.front(), start.ptr(), iterPos.ptr(), nullptr); osg::Vec3f targetPos; - navMeshQuery.closestPointOnPoly(polygonPath.back(), end.ptr(), targetPos.ptr(), 0); + navMeshQuery.closestPointOnPoly(polygonPath.back(), end.ptr(), targetPos.ptr(), nullptr); const float SLOP = 0.01f; diff --git a/components/esm/loadcell.hpp b/components/esm/loadcell.hpp index 132c869ad..d06b509c5 100644 --- a/components/esm/loadcell.hpp +++ b/components/esm/loadcell.hpp @@ -185,7 +185,7 @@ struct Cell CellRef &ref, bool &isDeleted, bool ignoreMoves = false, - MovedCellRef *mref = 0); + MovedCellRef *mref = nullptr); /* This fetches an MVRF record, which is used to track moved references. * Since they are comparably rare, we use a separate method for this. diff --git a/components/esm/variant.cpp b/components/esm/variant.cpp index c65eed5e0..6ff31dc44 100644 --- a/components/esm/variant.cpp +++ b/components/esm/variant.cpp @@ -16,11 +16,11 @@ namespace const uint32_t STTV = ESM::FourCC<'S','T','T','V'>::value; } -ESM::Variant::Variant() : mType (VT_None), mData (0) {} +ESM::Variant::Variant() : mType (VT_None), mData (nullptr) {} ESM::Variant::Variant(const std::string &value) { - mData = 0; + mData = nullptr; mType = VT_None; setType(VT_String); setString(value); @@ -28,7 +28,7 @@ ESM::Variant::Variant(const std::string &value) ESM::Variant::Variant(int value) { - mData = 0; + mData = nullptr; mType = VT_None; setType(VT_Long); setInteger(value); @@ -36,7 +36,7 @@ ESM::Variant::Variant(int value) ESM::Variant::Variant(float value) { - mData = 0; + mData = nullptr; mType = VT_None; setType(VT_Float); setFloat(value); @@ -51,7 +51,7 @@ ESM::Variant& ESM::Variant::operator= (const Variant& variant) { if (&variant!=this) { - VariantDataBase *newData = variant.mData ? variant.mData->clone() : 0; + VariantDataBase *newData = variant.mData ? variant.mData->clone() : nullptr; delete mData; @@ -63,7 +63,7 @@ ESM::Variant& ESM::Variant::operator= (const Variant& variant) } ESM::Variant::Variant (const Variant& variant) -: mType (variant.mType), mData (variant.mData ? variant.mData->clone() : 0) +: mType (variant.mType), mData (variant.mData ? variant.mData->clone() : nullptr) {} ESM::VarType ESM::Variant::getType() const @@ -254,7 +254,7 @@ void ESM::Variant::setType (VarType type) { if (type!=mType) { - VariantDataBase *newData = 0; + VariantDataBase *newData = nullptr; switch (type) { diff --git a/components/esm/variantimp.hpp b/components/esm/variantimp.hpp index e7ac722b1..c1203ddf8 100644 --- a/components/esm/variantimp.hpp +++ b/components/esm/variantimp.hpp @@ -71,7 +71,7 @@ namespace ESM public: - VariantStringData (const VariantDataBase *data = 0); + VariantStringData (const VariantDataBase *data = nullptr); ///< Calling the constructor with an incompatible data type will result in a silent /// default initialisation. @@ -103,7 +103,7 @@ namespace ESM public: - VariantIntegerData (const VariantDataBase *data = 0); + VariantIntegerData (const VariantDataBase *data = nullptr); ///< Calling the constructor with an incompatible data type will result in a silent /// default initialisation. @@ -142,7 +142,7 @@ namespace ESM public: - VariantFloatData (const VariantDataBase *data = 0); + VariantFloatData (const VariantDataBase *data = nullptr); ///< Calling the constructor with an incompatible data type will result in a silent /// default initialisation. diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index cf27b7128..4d3f3c305 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -71,7 +71,7 @@ namespace ESMTerrain int endColumn = startColumn + size * (ESM::Land::LAND_SIZE-1) + 1; osg::ref_ptr land = getLand (cellX, cellY); - const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VHGT) : 0; + const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VHGT) : nullptr; if (data) { min = std::numeric_limits::max(); @@ -119,7 +119,7 @@ namespace ESMTerrain } const LandObject* land = getLand(cellX, cellY, cache); - const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VNML) : 0; + const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VNML) : nullptr; if (data) { normal.x() = data->mNormals[col*ESM::Land::LAND_SIZE*3+row*3]; @@ -156,7 +156,7 @@ namespace ESMTerrain } const LandObject* land = getLand(cellX, cellY, cache); - const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VCLR) : 0; + const ESM::Land::LandData* data = land ? land->getData(ESM::Land::DATA_VCLR) : nullptr; if (data) { color.r() = data->mColours[col*ESM::Land::LAND_SIZE*3+row*3]; @@ -207,9 +207,9 @@ namespace ESMTerrain for (int cellX = startCellX; cellX < startCellX + std::ceil(size); ++cellX) { const LandObject* land = getLand(cellX, cellY, cache); - const ESM::Land::LandData *heightData = 0; - const ESM::Land::LandData *normalData = 0; - const ESM::Land::LandData *colourData = 0; + const ESM::Land::LandData *heightData = nullptr; + const ESM::Land::LandData *normalData = nullptr; + const ESM::Land::LandData *colourData = nullptr; if (land) { heightData = land->getData(ESM::Land::DATA_VHGT); @@ -341,7 +341,7 @@ namespace ESMTerrain const LandObject* land = getLand(cellX, cellY, cache); - const ESM::Land::LandData *data = land ? land->getData(ESM::Land::DATA_VTEX) : 0; + const ESM::Land::LandData *data = land ? land->getData(ESM::Land::DATA_VTEX) : nullptr; if (data) { int tex = data->mTextures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; diff --git a/components/files/constrainedfilestream.cpp b/components/files/constrainedfilestream.cpp index d2802218f..baab1b081 100644 --- a/components/files/constrainedfilestream.cpp +++ b/components/files/constrainedfilestream.cpp @@ -32,7 +32,7 @@ namespace Files if (start != 0) mFile.seek(start); - setg(0,0,0); + setg(nullptr,nullptr,nullptr); mOrigin = start; } @@ -81,7 +81,7 @@ namespace Files mFile.seek(mOrigin+newPos); // Clear read pointers so underflow() gets called on the next read attempt. - setg(0, 0, 0); + setg(nullptr, nullptr, nullptr); return newPos; } @@ -97,7 +97,7 @@ namespace Files mFile.seek(mOrigin + pos); // Clear read pointers so underflow() gets called on the next read attempt. - setg(0, 0, 0); + setg(nullptr, nullptr, nullptr); return pos; } diff --git a/components/interpreter/runtime.cpp b/components/interpreter/runtime.cpp index a90bda94b..35ad93a8a 100644 --- a/components/interpreter/runtime.cpp +++ b/components/interpreter/runtime.cpp @@ -6,7 +6,7 @@ namespace Interpreter { - Runtime::Runtime() : mContext (0), mCode (0), mCodeSize(0), mPC (0) {} + Runtime::Runtime() : mContext (nullptr), mCode (nullptr), mCodeSize(0), mPC (0) {} int Runtime::getPC() const { @@ -65,8 +65,8 @@ namespace Interpreter void Runtime::clear() { - mContext = 0; - mCode = 0; + mContext = nullptr; + mCode = nullptr; mCodeSize = 0; mStack.clear(); } diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index bba7df702..dc771f11f 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -127,7 +127,7 @@ public: if(texture) state->applyTextureAttribute(0, texture); - osg::GLBufferObject* bufferobject = state->isVertexBufferObjectSupported() ? vbo->getOrCreateGLBufferObject(state->getContextID()) : 0; + osg::GLBufferObject* bufferobject = state->isVertexBufferObjectSupported() ? vbo->getOrCreateGLBufferObject(state->getContextID()) : nullptr; if (bufferobject) { state->bindVertexBufferObject(bufferobject); diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 2cb0ffc62..e2e1f92cf 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -344,7 +344,7 @@ void Emitter::emitParticles(double dt) for (int i=0; icreateParticle(0); + osgParticle::Particle* P = getParticleSystem()->createParticle(nullptr); if (P) { mPlacer->place(P); diff --git a/components/resource/imagemanager.cpp b/components/resource/imagemanager.cpp index ff6fb04a6..dd34ed1a1 100644 --- a/components/resource/imagemanager.cpp +++ b/components/resource/imagemanager.cpp @@ -151,7 +151,7 @@ namespace Resource image->setFileName(normalized); if (!checkSupported(image, filename)) { - static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != 0); + static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != nullptr); if (!uncompress) { Log(Debug::Error) << "Error loading " << filename << ": no S3TC texture compression support installed"; diff --git a/components/resource/objectcache.hpp b/components/resource/objectcache.hpp index 6e309a7f7..5c4b511f0 100644 --- a/components/resource/objectcache.hpp +++ b/components/resource/objectcache.hpp @@ -119,7 +119,7 @@ class GenericObjectCache : public osg::Referenced typename ObjectCacheMap::iterator itr = _objectCache.find(key); if (itr!=_objectCache.end()) return itr->second.first; - else return 0; + else return nullptr; } /** Check if an object is in the cache, and if it is, update its usage time stamp. */ diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 673e01f33..2ebce241d 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -111,11 +111,11 @@ namespace SceneUtil { public: CollectLightCallback() - : mLightManager(0) { } + : mLightManager(nullptr) { } CollectLightCallback(const CollectLightCallback& copy, const osg::CopyOp& copyop) : osg::NodeCallback(copy, copyop) - , mLightManager(0) { } + , mLightManager(nullptr) { } META_Object(SceneUtil, SceneUtil::CollectLightCallback) diff --git a/components/sdlutil/sdlcursormanager.cpp b/components/sdlutil/sdlcursormanager.cpp index 82854cb2f..56225868e 100644 --- a/components/sdlutil/sdlcursormanager.cpp +++ b/components/sdlutil/sdlcursormanager.cpp @@ -50,7 +50,7 @@ namespace CursorDecompression traits->alpha = 8; traits->windowDecoration = false; traits->doubleBuffer = false; - traits->sharedContext = 0; + traits->sharedContext = nullptr; traits->pbuffer = true; osg::GraphicsContext::ScreenIdentifier si; @@ -267,7 +267,7 @@ namespace SDLUtil if (mCursorMap.find(name) != mCursorMap.end()) return; - static bool forceSoftwareDecompression = (getenv("OPENMW_DECOMPRESS_TEXTURES") != 0); + static bool forceSoftwareDecompression = (getenv("OPENMW_DECOMPRESS_TEXTURES") != nullptr); SurfaceUniquePtr (*decompressionFunction)(osg::ref_ptr, float); if (forceSoftwareDecompression || CursorDecompression::DXTCSupported) { diff --git a/components/sdlutil/sdlgraphicswindow.cpp b/components/sdlutil/sdlgraphicswindow.cpp index 0a1951700..ad7ecd9ae 100644 --- a/components/sdlutil/sdlgraphicswindow.cpp +++ b/components/sdlutil/sdlgraphicswindow.cpp @@ -11,8 +11,8 @@ GraphicsWindowSDL2::~GraphicsWindowSDL2() } GraphicsWindowSDL2::GraphicsWindowSDL2(osg::GraphicsContext::Traits *traits) - : mWindow(0) - , mContext(0) + : mWindow(nullptr) + , mContext(nullptr) , mValid(false) , mRealized(false) , mOwnsWindow(false) @@ -79,7 +79,7 @@ void GraphicsWindowSDL2::init() WindowData *inheritedWindowData = dynamic_cast(_traits->inheritedWindowData.get()); mWindow = inheritedWindowData ? inheritedWindowData->mWindow : nullptr; - mOwnsWindow = (mWindow == 0); + mOwnsWindow = (mWindow == nullptr); if(mOwnsWindow) { OSG_FATAL<<"Error: No SDL window provided."<(object)!=0; } + bool isSameKindAs(const Object* object) const override { return dynamic_cast(object)!=nullptr; } const char* libraryName() const override { return "osgViewer"; } const char* className() const override { return "GraphicsWindowSDL2"; } diff --git a/components/terrain/quadtreenode.cpp b/components/terrain/quadtreenode.cpp index 7baea45c8..c113a629c 100644 --- a/components/terrain/quadtreenode.cpp +++ b/components/terrain/quadtreenode.cpp @@ -63,7 +63,7 @@ QuadTreeNode::QuadTreeNode(QuadTreeNode* parent, ChildDirection direction, float , mCenter(center) { for (unsigned int i=0; i<4; ++i) - mNeighbours[i] = 0; + mNeighbours[i] = nullptr; } QuadTreeNode::~QuadTreeNode() diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index 1db193320..23a108ee9 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -8,7 +8,7 @@ namespace Gui void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w) { MyGUI::Widget * parent = w->getParent(); - if (parent != 0) + if (parent != nullptr) { if (mExpandDirection.isLeft()) { @@ -17,7 +17,7 @@ namespace Gui } w->setSize(getRequestedSize ()); - while (parent != 0) + while (parent != nullptr) { Box * b = dynamic_cast(parent); if (b) @@ -280,7 +280,7 @@ namespace Gui void HBox::initialiseOverride() { Base::initialiseOverride(); - MyGUI::Widget* client = 0; + MyGUI::Widget* client = nullptr; assignWidget(client, "Client"); setWidgetClient(client); } @@ -435,7 +435,7 @@ namespace Gui void VBox::initialiseOverride() { Base::initialiseOverride(); - MyGUI::Widget* client = 0; + MyGUI::Widget* client = nullptr; assignWidget(client, "Client"); setWidgetClient(client); } diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index bf24acf7e..73ca94929 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -7,9 +7,9 @@ namespace Gui { - MWList::MWList() : - mScrollView(0) - ,mClient(0) + MWList::MWList() + : mScrollView(nullptr) + , mClient(nullptr) , mItemHeight(0) { } @@ -19,7 +19,7 @@ namespace Gui Base::initialiseOverride(); assignWidget(mClient, "Client"); - if (mClient == 0) + if (mClient == nullptr) mClient = this; mScrollView = mClient->createWidgetReal( diff --git a/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp b/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp index 0c314ec7d..337382679 100644 --- a/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp +++ b/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp @@ -30,7 +30,7 @@ namespace Video struct AudioResampler { AudioResampler() - : mSwr(NULL) + : mSwr(nullptr) { } @@ -51,8 +51,8 @@ MovieAudioDecoder::MovieAudioDecoder(VideoState* videoState) , mFramePos(0) , mFrameSize(0) , mAudioClock(0.0) - , mDataBuf(NULL) - , mFrameData(NULL) + , mDataBuf(nullptr) + , mFrameData(nullptr) , mDataBufLen(0) , mFrame(av_frame_alloc()) , mGetNextPacket(true) @@ -125,7 +125,7 @@ void MovieAudioDecoder::setupFormat() inputSampleFormat, inputSampleRate, 0, // logging level offset - NULL); // log context + nullptr); // log context if(!mAudioResampler->mSwr) fail(std::string("Couldn't allocate SwrContext")); if(swr_init(mAudioResampler->mSwr) < 0) diff --git a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp index c6544de9c..28ac3b36c 100644 --- a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp +++ b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp @@ -11,7 +11,7 @@ namespace Video { VideoPlayer::VideoPlayer() - : mState(NULL) + : mState(nullptr) { } @@ -87,13 +87,13 @@ void VideoPlayer::close() mState->deinit(); delete mState; - mState = NULL; + mState = nullptr; } } bool VideoPlayer::hasAudioStream() { - return mState && mState->audio_st != NULL; + return mState && mState->audio_st != nullptr; } void VideoPlayer::play() diff --git a/extern/osg-ffmpeg-videoplayer/videostate.cpp b/extern/osg-ffmpeg-videoplayer/videostate.cpp index c176fe0f2..5858d985a 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.cpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.cpp @@ -42,14 +42,14 @@ namespace Video { VideoState::VideoState() - : mAudioFactory(NULL) - , format_ctx(NULL) - , video_ctx(NULL) - , audio_ctx(NULL) + : mAudioFactory(nullptr) + , format_ctx(nullptr) + , video_ctx(nullptr) + , audio_ctx(nullptr) , av_sync_type(AV_SYNC_DEFAULT) - , audio_st(NULL) - , video_st(NULL), frame_last_pts(0.0) - , video_clock(0.0), sws_context(NULL), rgbaFrame(NULL), pictq_size(0) + , audio_st(nullptr) + , video_st(nullptr), frame_last_pts(0.0) + , video_clock(0.0), sws_context(nullptr), rgbaFrame(nullptr), pictq_size(0) , pictq_rindex(0), pictq_windex(0) , mSeekRequested(false) , mSeekPos(0) @@ -86,7 +86,7 @@ void PacketQueue::put(AVPacket *pkt) throw std::runtime_error("Failed to duplicate packet"); pkt1->pkt = *pkt; - pkt1->next = NULL; + pkt1->next = nullptr; this->mutex.lock (); @@ -112,7 +112,7 @@ int PacketQueue::get(AVPacket *pkt, VideoState *is) { this->first_pkt = pkt1->next; if(!this->first_pkt) - this->last_pkt = NULL; + this->last_pkt = nullptr; this->nb_packets--; this->size -= pkt1->pkt.size; @@ -141,15 +141,15 @@ void PacketQueue::clear() AVPacketList *pkt, *pkt1; this->mutex.lock(); - for(pkt = this->first_pkt; pkt != NULL; pkt = pkt1) + for(pkt = this->first_pkt; pkt != nullptr; pkt = pkt1) { pkt1 = pkt->next; if (pkt->pkt.data != flush_pkt.data) av_packet_unref(&pkt->pkt); av_freep(&pkt); } - this->last_pkt = NULL; - this->first_pkt = NULL; + this->last_pkt = nullptr; + this->first_pkt = nullptr; this->nb_packets = 0; this->size = 0; this->mutex.unlock (); @@ -296,14 +296,14 @@ int VideoState::queue_picture(AVFrame *pFrame, double pts) // Convert the image into RGBA format // TODO: we could do this in a pixel shader instead, if the source format // matches a commonly used format (ie YUV420P) - if(this->sws_context == NULL) + if(this->sws_context == nullptr) { int w = this->video_ctx->width; int h = this->video_ctx->height; this->sws_context = sws_getContext(w, h, this->video_ctx->pix_fmt, w, h, AV_PIX_FMT_RGBA, SWS_BICUBIC, - NULL, NULL, NULL); - if(this->sws_context == NULL) + nullptr, nullptr, nullptr); + if(this->sws_context == nullptr) throw std::runtime_error("Cannot initialize the conversion context!\n"); } @@ -587,7 +587,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) av_codec_set_pkt_timebase(this->audio_ctx, pFormatCtx->streams[stream_index]->time_base); #endif - if (avcodec_open2(this->audio_ctx, codec, NULL) < 0) + if (avcodec_open2(this->audio_ctx, codec, nullptr) < 0) { fprintf(stderr, "Unsupported codec!\n"); return -1; @@ -597,7 +597,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) { std::cerr << "No audio factory registered, can not play audio stream" << std::endl; avcodec_free_context(&this->audio_ctx); - this->audio_st = NULL; + this->audio_st = nullptr; return -1; } @@ -606,7 +606,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) { std::cerr << "Failed to create audio decoder, can not play audio stream" << std::endl; avcodec_free_context(&this->audio_ctx); - this->audio_st = NULL; + this->audio_st = nullptr; return -1; } mAudioDecoder->setupFormat(); @@ -624,7 +624,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) av_codec_set_pkt_timebase(this->video_ctx, pFormatCtx->streams[stream_index]->time_base); #endif - if (avcodec_open2(this->video_ctx, codec, NULL) < 0) + if (avcodec_open2(this->video_ctx, codec, nullptr) < 0) { fprintf(stderr, "Unsupported codec!\n"); return -1; @@ -653,7 +653,7 @@ void VideoState::init(std::shared_ptr inputstream, const std::stri if(!this->stream.get()) throw std::runtime_error("Failed to open video resource"); - AVIOContext *ioCtx = avio_alloc_context(NULL, 0, 0, this, istream_read, istream_write, istream_seek); + AVIOContext *ioCtx = avio_alloc_context(nullptr, 0, 0, this, istream_read, istream_write, istream_seek); if(!ioCtx) throw std::runtime_error("Failed to allocate AVIOContext"); this->format_ctx = avformat_alloc_context(); @@ -667,27 +667,27 @@ void VideoState::init(std::shared_ptr inputstream, const std::stri /// /// https://trac.ffmpeg.org/ticket/1357 /// - if(!this->format_ctx || avformat_open_input(&this->format_ctx, name.c_str(), NULL, NULL)) + if(!this->format_ctx || avformat_open_input(&this->format_ctx, name.c_str(), nullptr, nullptr)) { - if (this->format_ctx != NULL) + if (this->format_ctx != nullptr) { - if (this->format_ctx->pb != NULL) + if (this->format_ctx->pb != nullptr) { av_free(this->format_ctx->pb->buffer); - this->format_ctx->pb->buffer = NULL; + this->format_ctx->pb->buffer = nullptr; av_free(this->format_ctx->pb); - this->format_ctx->pb = NULL; + this->format_ctx->pb = nullptr; } } // "Note that a user-supplied AVFormatContext will be freed on failure." - this->format_ctx = NULL; + this->format_ctx = nullptr; av_free(ioCtx); throw std::runtime_error("Failed to open video input"); } // Retrieve stream information - if(avformat_find_stream_info(this->format_ctx, NULL) < 0) + if(avformat_find_stream_info(this->format_ctx, nullptr) < 0) throw std::runtime_error("Failed to retrieve stream information"); // Dump information about file onto standard error @@ -735,16 +735,16 @@ void VideoState::deinit() if(this->audio_ctx) avcodec_free_context(&this->audio_ctx); - this->audio_st = NULL; - this->audio_ctx = NULL; + this->audio_st = nullptr; + this->audio_ctx = nullptr; if(this->video_ctx) avcodec_free_context(&this->video_ctx); - this->video_st = NULL; - this->video_ctx = NULL; + this->video_st = nullptr; + this->video_ctx = nullptr; if(this->sws_context) sws_freeContext(this->sws_context); - this->sws_context = NULL; + this->sws_context = nullptr; if(this->format_ctx) { @@ -754,13 +754,13 @@ void VideoState::deinit() /// /// https://trac.ffmpeg.org/ticket/1357 /// - if (this->format_ctx->pb != NULL) + if (this->format_ctx->pb != nullptr) { av_free(this->format_ctx->pb->buffer); - this->format_ctx->pb->buffer = NULL; + this->format_ctx->pb->buffer = nullptr; av_free(this->format_ctx->pb); - this->format_ctx->pb = NULL; + this->format_ctx->pb = nullptr; } avformat_close_input(&this->format_ctx); } @@ -768,8 +768,8 @@ void VideoState::deinit() if (mTexture) { // reset Image separately, it's pointing to *this and there might still be outside references to mTexture - mTexture->setImage(NULL); - mTexture = NULL; + mTexture->setImage(nullptr); + mTexture = nullptr; } } diff --git a/extern/osg-ffmpeg-videoplayer/videostate.hpp b/extern/osg-ffmpeg-videoplayer/videostate.hpp index 984050cd6..641fce04b 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.hpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.hpp @@ -71,7 +71,7 @@ struct ExternalClock struct PacketQueue { PacketQueue() - : first_pkt(NULL), last_pkt(NULL), flushing(false), nb_packets(0), size(0) + : first_pkt(nullptr), last_pkt(nullptr), flushing(false), nb_packets(0), size(0) { } ~PacketQueue() { clear(); } From b0e3bd6ff931dd0c68e9de622b86d59333ce3744 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sun, 29 Nov 2020 23:25:34 +0200 Subject: [PATCH 27/28] Fix crash caused by QStatusBar --- apps/opencs/view/world/tablebottombox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/tablebottombox.cpp b/apps/opencs/view/world/tablebottombox.cpp index f6b060a8f..1b065da49 100644 --- a/apps/opencs/view/world/tablebottombox.cpp +++ b/apps/opencs/view/world/tablebottombox.cpp @@ -95,7 +95,7 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto mStatus = new QLabel; - mStatusBar = new QStatusBar; + mStatusBar = new QStatusBar(this); mStatusBar->addWidget (mStatus); From db9c174ca848b7d7297150ca58498019f3f5d7c0 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Thu, 26 Nov 2020 21:04:56 +0300 Subject: [PATCH 28/28] Make NIF particle node handling more generic --- components/nif/data.cpp | 4 ++-- components/nif/data.hpp | 4 ++-- components/nif/niffile.cpp | 10 ++++++---- components/nif/node.hpp | 27 +++++---------------------- components/nif/record.hpp | 7 +++---- components/nif/recordptr.hpp | 6 ++---- components/nifosg/nifloader.cpp | 12 +++++------- 7 files changed, 25 insertions(+), 45 deletions(-) diff --git a/components/nif/data.cpp b/components/nif/data.cpp index 235825e4a..415a013b3 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -184,7 +184,7 @@ void NiLinesData::read(NIFStream *nif) } } -void NiAutoNormalParticlesData::read(NIFStream *nif) +void NiParticlesData::read(NIFStream *nif) { NiGeometryData::read(nif); @@ -216,7 +216,7 @@ void NiAutoNormalParticlesData::read(NIFStream *nif) void NiRotatingParticlesData::read(NIFStream *nif) { - NiAutoNormalParticlesData::read(nif); + NiParticlesData::read(nif); if (nif->getVersion() <= NIFStream::generateVersion(4,2,2,0) && nif->getBoolean()) nif->getQuaternions(rotations, vertices.size()); diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 35f329573..908313f50 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -70,7 +70,7 @@ struct NiLinesData : public NiGeometryData void read(NIFStream *nif) override; }; -class NiAutoNormalParticlesData : public NiGeometryData +class NiParticlesData : public NiGeometryData { public: int numParticles{0}; @@ -84,7 +84,7 @@ public: void read(NIFStream *nif) override; }; -class NiRotatingParticlesData : public NiAutoNormalParticlesData +class NiRotatingParticlesData : public NiParticlesData { public: void read(NIFStream *nif) override; diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 7915908d1..67c864f47 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -47,8 +47,9 @@ static std::map makeFactory() factory["NiTriShape"] = {&construct , RC_NiTriShape }; factory["NiTriStrips"] = {&construct , RC_NiTriStrips }; factory["NiLines"] = {&construct , RC_NiLines }; - factory["NiRotatingParticles"] = {&construct , RC_NiRotatingParticles }; - factory["NiAutoNormalParticles"] = {&construct , RC_NiAutoNormalParticles }; + factory["NiParticles"] = {&construct , RC_NiParticles }; + factory["NiRotatingParticles"] = {&construct , RC_NiParticles }; + factory["NiAutoNormalParticles"] = {&construct , RC_NiParticles }; factory["NiCamera"] = {&construct , RC_NiCamera }; factory["RootCollisionNode"] = {&construct , RC_RootCollisionNode }; factory["NiTexturingProperty"] = {&construct , RC_NiTexturingProperty }; @@ -99,8 +100,9 @@ static std::map makeFactory() factory["NiSkinData"] = {&construct , RC_NiSkinData }; factory["NiUVData"] = {&construct , RC_NiUVData }; factory["NiPosData"] = {&construct , RC_NiPosData }; - factory["NiRotatingParticlesData"] = {&construct , RC_NiRotatingParticlesData }; - factory["NiAutoNormalParticlesData"] = {&construct , RC_NiAutoNormalParticlesData }; + factory["NiParticlesData"] = {&construct , RC_NiParticlesData }; + factory["NiRotatingParticlesData"] = {&construct , RC_NiParticlesData }; + factory["NiAutoNormalParticlesData"] = {&construct , RC_NiParticlesData }; factory["NiSequenceStreamHelper"] = {&construct , RC_NiSequenceStreamHelper }; factory["NiSourceTexture"] = {&construct , RC_NiSourceTexture }; factory["NiSkinInstance"] = {&construct , RC_NiSkinInstance }; diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 0b958d2c2..58397bdca 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -401,39 +401,22 @@ struct NiCamera : Node } }; -struct NiAutoNormalParticles : Node +struct NiParticles : NiGeometry { - NiAutoNormalParticlesDataPtr data; - + NiParticlesDataPtr data; void read(NIFStream *nif) override { Node::read(nif); data.read(nif); - nif->getInt(); // -1 - } - - void post(NIFFile *nif) override - { - Node::post(nif); - data.post(nif); - } -}; - -struct NiRotatingParticles : Node -{ - NiRotatingParticlesDataPtr data; - - void read(NIFStream *nif) override - { - Node::read(nif); - data.read(nif); - nif->getInt(); // -1 + skin.read(nif); + materialData.read(nif); } void post(NIFFile *nif) override { Node::post(nif); data.post(nif); + skin.post(nif); } }; diff --git a/components/nif/record.hpp b/components/nif/record.hpp index c5773643a..2217c588e 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -44,8 +44,7 @@ enum RecordType RC_NiTriShape, RC_NiTriStrips, RC_NiLines, - RC_NiRotatingParticles, - RC_NiAutoNormalParticles, + RC_NiParticles, RC_NiBSParticleNode, RC_NiCamera, RC_NiTexturingProperty, @@ -94,7 +93,7 @@ enum RecordType RC_NiUVData, RC_NiPosData, RC_NiRotatingParticlesData, - RC_NiAutoNormalParticlesData, + RC_NiParticlesData, RC_NiSequenceStreamHelper, RC_NiSourceTexture, RC_NiSkinInstance, @@ -119,7 +118,7 @@ enum RecordType RC_NiFloatInterpolator, RC_NiPoint3Interpolator, RC_NiBoolInterpolator, - RC_NiTransformInterpolator, + RC_NiTransformInterpolator }; /// Base class for all records diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index b40a17583..ed8f7ef6b 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -138,8 +138,7 @@ class NiTriShapeData; class NiTriStripsData; class NiSkinInstance; class NiSourceTexture; -class NiRotatingParticlesData; -class NiAutoNormalParticlesData; +class NiParticlesData; class NiPalette; struct NiParticleModifier; struct NiLinesData; @@ -167,8 +166,7 @@ using NiTriStripsDataPtr = RecordPtrT; using NiLinesDataPtr = RecordPtrT; using NiSkinInstancePtr = RecordPtrT; using NiSourceTexturePtr = RecordPtrT; -using NiRotatingParticlesDataPtr = RecordPtrT; -using NiAutoNormalParticlesDataPtr = RecordPtrT; +using NiParticlesDataPtr = RecordPtrT; using NiPalettePtr = RecordPtrT; using NiParticleModifierPtr = RecordPtrT; using NiBoolDataPtr = RecordPtrT; diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 4bc48637c..0db15237e 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -638,7 +638,7 @@ namespace NifOsg } } - if(nifNode->recType == Nif::RC_NiAutoNormalParticles || nifNode->recType == Nif::RC_NiRotatingParticles) + if (nifNode->recType == Nif::RC_NiParticles) handleParticleSystem(nifNode, node, composite, animflags); if (composite->getNumControllers() > 0) @@ -946,14 +946,12 @@ namespace NifOsg // Load the initial state of the particle system, i.e. the initial particles and their positions, velocity and colors. void handleParticleInitialState(const Nif::Node* nifNode, osgParticle::ParticleSystem* partsys, const Nif::NiParticleSystemController* partctrl) { - const Nif::NiAutoNormalParticlesData *particledata = nullptr; - if(nifNode->recType == Nif::RC_NiAutoNormalParticles) - particledata = static_cast(nifNode)->data.getPtr(); - else if(nifNode->recType == Nif::RC_NiRotatingParticles) - particledata = static_cast(nifNode)->data.getPtr(); - else + const auto particleNode = static_cast(nifNode); + if (particleNode->data.empty()) return; + const Nif::NiParticlesData* particledata = particleNode->data.getPtr(); + osg::BoundingBox box; int i=0;