libraries/animation: cppcheck fixes

* Fix for potential bug in AnimLoop due to _maxFrameIndexHint being uninitialized.
* made more single argument constructors explicit.
This commit is contained in:
Anthony Thibault 2016-03-13 17:17:34 -07:00
parent 11fcf00b2a
commit 9f30556084
9 changed files with 14 additions and 21 deletions

View file

@ -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} {}

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -38,7 +38,7 @@ protected:
virtual QSharedPointer<Resource> createResource(const QUrl& url,
const QSharedPointer<Resource>& 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; }

View file

@ -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())
{

View file

@ -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);

View file

@ -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);

View file

@ -83,6 +83,7 @@ public:
Hover
};
Rig() {}
virtual ~Rig() {}
void destroyAnimGraph();