From 8745ec7d69a4edb25d47b6cc071e902cb7b35e80 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 6 Jan 2009 19:09:50 +0000 Subject: [PATCH] Removed the usage of assert to prevent associated compile warnings and to clean up code --- .../osganimationskinning/osganimationskinning.cpp | 1 - include/osgAnimation/Assert | 4 ++-- include/osgAnimation/Channel | 5 ++--- include/osgAnimation/Interpolator | 11 ++--------- include/osgAnimation/Sampler | 3 --- include/osgAnimation/Skinning | 3 --- src/osgAnimation/AnimationManager.cpp | 7 ++++--- src/osgAnimation/AnimationManagerBase.cpp | 1 - src/osgAnimation/BasicAnimationManager.cpp | 7 ++++--- 9 files changed, 14 insertions(+), 28 deletions(-) diff --git a/examples/osganimationskinning/osganimationskinning.cpp b/examples/osganimationskinning/osganimationskinning.cpp index b22814a80..320a9e16d 100644 --- a/examples/osganimationskinning/osganimationskinning.cpp +++ b/examples/osganimationskinning/osganimationskinning.cpp @@ -247,7 +247,6 @@ int main (int argc, char* argv[]) osg::ref_ptr src = dynamic_cast(geom->getVertexArray()); geom->getOrCreateStateSet()->setMode(GL_LIGHTING, false); geom->setDataVariance(osg::Object::DYNAMIC); - OSGANIMATION_ASSERT(src); initVertexMap(root.get(), right0.get(), right1.get(), geom, src.get()); diff --git a/include/osgAnimation/Assert b/include/osgAnimation/Assert index 3b4f1e31d..21e3976c3 100644 --- a/include/osgAnimation/Assert +++ b/include/osgAnimation/Assert @@ -40,10 +40,10 @@ namespace osgAnimation } #ifdef OSGANIMATION_ASSERT_THROW -#define OSGANIMATION_ASSERT(a) if (!(a)) throw osgAnimation::ThrowAssert(std::string(#a),__FILE__,__LINE__); +//#define OSGANIMATION_ASSERT(a) if (!(a)) throw osgAnimation::ThrowAssert(std::string(#a),__FILE__,__LINE__); #else -#define OSGANIMATION_ASSERT(a) {if (!(a)) *((int*)0) = 0;} +//#define OSGANIMATION_ASSERT(a) {if (!(a)) *((int*)0) = 0;} #endif #endif diff --git a/include/osgAnimation/Channel b/include/osgAnimation/Channel index 06ae1aa56..c2ebf79d4 100644 --- a/include/osgAnimation/Channel +++ b/include/osgAnimation/Channel @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -107,8 +106,8 @@ namespace osgAnimation TargetType* getTargetTyped() { return _target.get(); } void setTarget(TargetType* target) { _target = target; } - virtual float getStartTime() const { OSGANIMATION_ASSERT(_sampler.valid() && "no sampler attached to channel"); return _sampler->getStartTime(); } - virtual float getEndTime() const { OSGANIMATION_ASSERT(_sampler.valid() && "no sampler attached to channel"); return _sampler->getEndTime(); } + virtual float getStartTime() const { return _sampler->getStartTime(); } + virtual float getEndTime() const { return _sampler->getEndTime(); } protected: osg::ref_ptr _target; diff --git a/include/osgAnimation/Interpolator b/include/osgAnimation/Interpolator index 79157b0c9..bdf172fe1 100644 --- a/include/osgAnimation/Interpolator +++ b/include/osgAnimation/Interpolator @@ -15,7 +15,6 @@ #ifndef OSGANIMATION_INTERPOLATOR_H #define OSGANIMATION_INTERPOLATOR_H -#include #include #include @@ -37,9 +36,6 @@ namespace osgAnimation void reset() { _lastKeyAccess = -1; } int getKeyIndexFromTime(const TemplateKeyframeContainer& keys, float time) const { - OSGANIMATION_ASSERT(!keys.empty() && "no keys"); - OSGANIMATION_ASSERT(time >= keys.front().getTime() && time <= keys.back().getTime() && "bad range"); - // todo use a cache int key_size = keys.size(); const TemplateKeyframe* keysVector = &keys.front(); @@ -47,10 +43,7 @@ namespace osgAnimation { float time0 = keysVector[i].getTime(); float time1 = keysVector[i+1].getTime(); -#ifndef OSGANIMATION_NO_EXTRA_CHECK - if ( time0>time1 ) - OSGANIMATION_ASSERT(0 && "invalid input data"); -#endif + if ( time >= time0 && time < time1 ) { _lastKeyAccess = i; @@ -59,7 +52,7 @@ namespace osgAnimation } std::cout << time << " first key " << keysVector[0].getTime() << " last key " << keysVector[key_size-1].getTime() << std::endl; *((int *)0) = 0; - OSGANIMATION_ASSERT(0 && "impossible has happened"); + return -1; } }; diff --git a/include/osgAnimation/Sampler b/include/osgAnimation/Sampler index 510d5ecd8..bad4a928b 100644 --- a/include/osgAnimation/Sampler +++ b/include/osgAnimation/Sampler @@ -21,7 +21,6 @@ #include #include #include -#include namespace osgAnimation { @@ -65,13 +64,11 @@ namespace osgAnimation float getStartTime() const { - OSGANIMATION_ASSERT(_keyframes.valid() && !_keyframes->empty() && "no keyframes"); return _keyframes->front().getTime(); } float getEndTime() const { - OSGANIMATION_ASSERT(_keyframes.valid() && !_keyframes->empty() && "no keyframes"); return _keyframes->back().getTime(); } diff --git a/include/osgAnimation/Skinning b/include/osgAnimation/Skinning index 7be9bcf88..528053c6b 100644 --- a/include/osgAnimation/Skinning +++ b/include/osgAnimation/Skinning @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -163,7 +162,6 @@ namespace osgAnimation template void compute(const V* src, V* dst) { - OSGANIMATION_ASSERT(src != dst); int size = _boneSetVertexSet.size(); for (int i = 0; i < size; i++) { @@ -183,7 +181,6 @@ namespace osgAnimation template void compute(const MatrixType& transform, const MatrixType& invTransform, const V* src, V* dst) { - OSGANIMATION_ASSERT(src != dst); int size = _boneSetVertexSet.size(); for (int i = 0; i < size; i++) { diff --git a/src/osgAnimation/AnimationManager.cpp b/src/osgAnimation/AnimationManager.cpp index d0f008917..4329aff8b 100644 --- a/src/osgAnimation/AnimationManager.cpp +++ b/src/osgAnimation/AnimationManager.cpp @@ -14,7 +14,6 @@ #include #include -#include using namespace osgAnimation; @@ -40,8 +39,10 @@ AnimationManager::AnimationManager() } void AnimationManager::playAnimation(Animation* pAnimation, int priority, float weight) { - bool r = findAnimation(pAnimation); - OSGANIMATION_ASSERT(r && "This animation is not registered"); + if (!findAnimation(pAnimation)) + { + return; + } if ( isPlaying(pAnimation) ) stopAnimation(pAnimation); diff --git a/src/osgAnimation/AnimationManagerBase.cpp b/src/osgAnimation/AnimationManagerBase.cpp index 28c9536f9..6bb3f5443 100644 --- a/src/osgAnimation/AnimationManagerBase.cpp +++ b/src/osgAnimation/AnimationManagerBase.cpp @@ -14,7 +14,6 @@ #include #include -#include using namespace osgAnimation; diff --git a/src/osgAnimation/BasicAnimationManager.cpp b/src/osgAnimation/BasicAnimationManager.cpp index b3f78a0f4..99c1003a3 100644 --- a/src/osgAnimation/BasicAnimationManager.cpp +++ b/src/osgAnimation/BasicAnimationManager.cpp @@ -14,7 +14,6 @@ #include #include -#include using namespace osgAnimation; @@ -38,8 +37,10 @@ BasicAnimationManager::BasicAnimationManager() } void BasicAnimationManager::playAnimation(Animation* pAnimation, int priority, float weight) { - bool r = findAnimation(pAnimation); - OSGANIMATION_ASSERT(r && "This animation is not registered"); + if (!findAnimation(pAnimation)) + { + return; + } if ( isPlaying(pAnimation) ) stopAnimation(pAnimation);