From 9f305560841f5ccf77ad293edbef8350d4b82cc2 Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Sun, 13 Mar 2016 17:17:34 -0700 Subject: [PATCH] libraries/animation: cppcheck fixes * Fix for potential bug in AnimLoop due to _maxFrameIndexHint being uninitialized. * made more single argument constructors explicit. --- libraries/animation/src/AnimExpression.h | 8 ++++---- libraries/animation/src/AnimInverseKinematics.h | 2 +- libraries/animation/src/AnimNodeLoader.h | 2 +- libraries/animation/src/AnimStateMachine.h | 2 +- libraries/animation/src/AnimationCache.h | 4 ++-- libraries/animation/src/AnimationLoop.cpp | 2 ++ libraries/animation/src/AnimationLoop.h | 2 +- libraries/animation/src/Rig.cpp | 12 +----------- libraries/animation/src/Rig.h | 1 + 9 files changed, 14 insertions(+), 21 deletions(-) diff --git a/libraries/animation/src/AnimExpression.h b/libraries/animation/src/AnimExpression.h index 468217f5b3..87fb3ca20c 100644 --- a/libraries/animation/src/AnimExpression.h +++ b/libraries/animation/src/AnimExpression.h @@ -21,7 +21,7 @@ class AnimExpression { public: friend class AnimTests; - AnimExpression(const QString& str); + explicit AnimExpression(const QString& str); protected: struct Token { enum Type { @@ -49,8 +49,8 @@ protected: Comma, Error }; - Token(Type type) : type {type} {} - Token(const QStringRef& strRef) : type {Type::Identifier}, strVal {strRef.toString()} {} + explicit Token(Type type) : type {type} {} + explicit Token(const QStringRef& strRef) : type {Type::Identifier}, strVal {strRef.toString()} {} explicit Token(int val) : type {Type::Int}, intVal {val} {} explicit Token(bool val) : type {Type::Bool}, intVal {val} {} explicit Token(float val) : type {Type::Float}, floatVal {val} {} @@ -82,7 +82,7 @@ protected: Modulus, UnaryMinus }; - OpCode(Type type) : type {type} {} + explicit OpCode(Type type) : type {type} {} explicit OpCode(const QStringRef& strRef) : type {Type::Identifier}, strVal {strRef.toString()} {} explicit OpCode(const QString& str) : type {Type::Identifier}, strVal {str} {} explicit OpCode(int val) : type {Type::Int}, intVal {val} {} diff --git a/libraries/animation/src/AnimInverseKinematics.h b/libraries/animation/src/AnimInverseKinematics.h index aeb718668a..182e7b3492 100644 --- a/libraries/animation/src/AnimInverseKinematics.h +++ b/libraries/animation/src/AnimInverseKinematics.h @@ -25,7 +25,7 @@ class RotationConstraint; class AnimInverseKinematics : public AnimNode { public: - AnimInverseKinematics(const QString& id); + explicit AnimInverseKinematics(const QString& id); virtual ~AnimInverseKinematics() override; void loadDefaultPoses(const AnimPoseVec& poses); diff --git a/libraries/animation/src/AnimNodeLoader.h b/libraries/animation/src/AnimNodeLoader.h index bc7d574c39..27b94f81bb 100644 --- a/libraries/animation/src/AnimNodeLoader.h +++ b/libraries/animation/src/AnimNodeLoader.h @@ -25,7 +25,7 @@ class AnimNodeLoader : public QObject { Q_OBJECT public: - AnimNodeLoader(const QUrl& url); + explicit AnimNodeLoader(const QUrl& url); signals: void success(AnimNode::Pointer node); diff --git a/libraries/animation/src/AnimStateMachine.h b/libraries/animation/src/AnimStateMachine.h index 6a28ef1825..d92b94d1b5 100644 --- a/libraries/animation/src/AnimStateMachine.h +++ b/libraries/animation/src/AnimStateMachine.h @@ -110,7 +110,7 @@ protected: public: - AnimStateMachine(const QString& id); + explicit AnimStateMachine(const QString& id); virtual ~AnimStateMachine() override; virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; diff --git a/libraries/animation/src/AnimationCache.h b/libraries/animation/src/AnimationCache.h index 6143d9b42e..e6a795c864 100644 --- a/libraries/animation/src/AnimationCache.h +++ b/libraries/animation/src/AnimationCache.h @@ -38,7 +38,7 @@ protected: virtual QSharedPointer createResource(const QUrl& url, const QSharedPointer& fallback, bool delayLoad, const void* extra); private: - AnimationCache(QObject* parent = NULL); + explicit AnimationCache(QObject* parent = NULL); virtual ~AnimationCache() { } }; @@ -51,7 +51,7 @@ class Animation : public Resource { public: - Animation(const QUrl& url); + explicit Animation(const QUrl& url); const FBXGeometry& getGeometry() const { return *_geometry; } diff --git a/libraries/animation/src/AnimationLoop.cpp b/libraries/animation/src/AnimationLoop.cpp index f6a2877966..3d7bca863f 100644 --- a/libraries/animation/src/AnimationLoop.cpp +++ b/libraries/animation/src/AnimationLoop.cpp @@ -40,6 +40,7 @@ AnimationLoop::AnimationLoop(const AnimationDetails& animationDetails) : _lastFrame(animationDetails.lastFrame), _running(animationDetails.running), _currentFrame(animationDetails.currentFrame), + _maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME), _resetOnRunning(true), _lastSimulated(usecTimestampNow()) { @@ -55,6 +56,7 @@ AnimationLoop::AnimationLoop(float fps, bool loop, bool hold, bool startAutomati _lastFrame(lastFrame), _running(running), _currentFrame(currentFrame), + _maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME), _resetOnRunning(true), _lastSimulated(usecTimestampNow()) { diff --git a/libraries/animation/src/AnimationLoop.h b/libraries/animation/src/AnimationLoop.h index 10664c47e7..6adfbf35e2 100644 --- a/libraries/animation/src/AnimationLoop.h +++ b/libraries/animation/src/AnimationLoop.h @@ -19,7 +19,7 @@ public: static const float MAXIMUM_POSSIBLE_FRAME; AnimationLoop(); - AnimationLoop(const AnimationDetails& animationDetails); + explicit AnimationLoop(const AnimationDetails& animationDetails); AnimationLoop(float fps, bool loop, bool hold, bool startAutomatically, float firstFrame, float lastFrame, bool running, float currentFrame); diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index bca90b242a..ae9adc71c2 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -37,17 +37,7 @@ static bool isEqual(const glm::quat& p, const glm::quat& q) { return 1.0f - fabsf(glm::dot(p, q)) <= EPSILON; } -#ifdef NDEBUG -#define ASSERT(cond) -#else -#define ASSERT(cond) \ - do { \ - if (!(cond)) { \ - int* ptr = nullptr; \ - *ptr = 10; \ - } \ - } while (0) -#endif +#define ASSERT(cond) assert(cond) // 2 meter tall dude const glm::vec3 DEFAULT_RIGHT_EYE_POS(-0.3f, 0.9f, 0.0f); diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index 50313d10e7..1f9a02d8ab 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -83,6 +83,7 @@ public: Hover }; + Rig() {} virtual ~Rig() {} void destroyAnimGraph();