From 35fa541350b89af9e7b89d6350a4c11daa33d8ef Mon Sep 17 00:00:00 2001 From: Cedric Pinson Date: Thu, 25 Mar 2010 17:50:29 +0000 Subject: [PATCH] Change time type from float to double in osgAnimation --- include/osgAnimation/Animation | 14 +++++++------- include/osgAnimation/Channel | 16 ++++++++-------- include/osgAnimation/Keyframe | 8 ++++---- include/osgAnimation/Sampler | 18 +++++++++--------- include/osgAnimation/Target | 4 ++-- src/osgAnimation/Animation.cpp | 8 ++++---- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/osgAnimation/Animation b/include/osgAnimation/Animation index 2d50372b8..c5311340a 100644 --- a/include/osgAnimation/Animation +++ b/include/osgAnimation/Animation @@ -12,8 +12,8 @@ * OpenSceneGraph Public License for more details. */ -#ifndef OSGANIMATION_ANIMATION_H -#define OSGANIMATION_ANIMATION_H +#ifndef OSGANIMATION_ANIMATION +#define OSGANIMATION_ANIMATION 1 #include #include @@ -65,20 +65,20 @@ namespace osgAnimation */ void computeDuration(); - float getDuration() const; + double getDuration() const; void setWeight (float weight); float getWeight() const; - bool update (float time, int priority = 0); + bool update (double time, int priority = 0); void resetTargets(); void setPlaymode (PlayMode mode) { _playmode = mode; } PlayMode getPlayMode() const { return _playmode; } - void setStartTime(float time) { _startTime = time;} - float getStartTime() const { return _startTime;} + void setStartTime(double time) { _startTime = time;} + double getStartTime() const { return _startTime;} protected: @@ -89,7 +89,7 @@ namespace osgAnimation double _duration; double _originalDuration; float _weight; - float _startTime; + double _startTime; PlayMode _playmode; ChannelList _channels; diff --git a/include/osgAnimation/Channel b/include/osgAnimation/Channel index a91316406..a3139bf0c 100644 --- a/include/osgAnimation/Channel +++ b/include/osgAnimation/Channel @@ -16,8 +16,8 @@ * Michael Platings */ -#ifndef OSGANIMATION_CHANNEL_H -#define OSGANIMATION_CHANNEL_H +#ifndef OSGANIMATION_CHANNEL +#define OSGANIMATION_CHANNEL 1 #include #include @@ -37,7 +37,7 @@ namespace osgAnimation virtual ~Channel(); virtual Channel* clone() const = 0; - virtual void update(float time, float weight, int priority) = 0; + virtual void update(double time, float weight, int priority) = 0; virtual void reset() = 0; virtual Target* getTarget() = 0; virtual bool setTarget(Target*) = 0; @@ -45,8 +45,8 @@ namespace osgAnimation const std::string& getName() const; void setName(const std::string& name); - virtual float getStartTime() const = 0; - virtual float getEndTime() const = 0; + virtual double getStartTime() const = 0; + virtual double getEndTime() const = 0; const std::string& getTargetName() const; void setTargetName(const std::string& name); @@ -113,7 +113,7 @@ namespace osgAnimation } virtual ~TemplateChannel() {} - virtual void update(float time, float weight, int priority) + virtual void update(double time, float weight, int priority) { // skip if weight == 0 if (weight < 1e-4) @@ -148,8 +148,8 @@ namespace osgAnimation const TargetType* getTargetTyped() const { return _target.get(); } void setTarget(TargetType* target) { _target = target; } - virtual float getStartTime() const { return _sampler->getStartTime(); } - virtual float getEndTime() const { return _sampler->getEndTime(); } + virtual double getStartTime() const { return _sampler->getStartTime(); } + virtual double getEndTime() const { return _sampler->getEndTime(); } protected: osg::ref_ptr _target; diff --git a/include/osgAnimation/Keyframe b/include/osgAnimation/Keyframe index c83c31746..7c10640cb 100644 --- a/include/osgAnimation/Keyframe +++ b/include/osgAnimation/Keyframe @@ -31,11 +31,11 @@ namespace osgAnimation class Keyframe { public: - float getTime() const { return _time; } - void setTime(float time) { _time = time; } + double getTime() const { return _time; } + void setTime(double time) { _time = time; } protected: - float _time; + double _time; }; @@ -48,7 +48,7 @@ namespace osgAnimation TemplateKeyframe () {} ~TemplateKeyframe () {} - TemplateKeyframe (float time, const T& value) + TemplateKeyframe (double time, const T& value) { _time = time; _value = value; diff --git a/include/osgAnimation/Sampler b/include/osgAnimation/Sampler index cda31b982..e1600f703 100644 --- a/include/osgAnimation/Sampler +++ b/include/osgAnimation/Sampler @@ -16,8 +16,8 @@ * Michael Platings */ -#ifndef OSGANIMATION_SAMPLER_H -#define OSGANIMATION_SAMPLER_H +#ifndef OSGANIMATION_SAMPLER +#define OSGANIMATION_SAMPLER 1 #include #include @@ -50,7 +50,7 @@ namespace osgAnimation TemplateSampler() {} ~TemplateSampler() {} - void getValueAt(float time, UsingType& result) const { _functor.getValue(*_keyframes, time, result);} + void getValueAt(double time, UsingType& result) const { _functor.getValue(*_keyframes, time, result);} void setKeyframeContainer(KeyframeContainerType* kf) { _keyframes = kf;} virtual KeyframeContainer* getKeyframeContainer() { return _keyframes.get(); } @@ -66,17 +66,17 @@ namespace osgAnimation return _keyframes.get(); } - float getStartTime() const + double getStartTime() const { if (!_keyframes) - return 0.0f; + return 0.0; return _keyframes->front().getTime(); } - float getEndTime() const + double getEndTime() const { if (!_keyframes) - return 0.0f; + return 0.0; return _keyframes->back().getTime(); } @@ -101,9 +101,9 @@ namespace osgAnimation { } - void getValueAt(float time, typename VALUESAMPLERTYPE::FunctorType::UsingType& result) + void getValueAt(double time, typename VALUESAMPLERTYPE::FunctorType::UsingType& result) { - float newtime; + double newtime; _time.getValueAt(time, newtime); _value.getValueAt(newtime, result); } diff --git a/include/osgAnimation/Target b/include/osgAnimation/Target index 4e519c01e..4303150bb 100644 --- a/include/osgAnimation/Target +++ b/include/osgAnimation/Target @@ -13,8 +13,8 @@ */ -#ifndef OSGANIMATION_TARGET_H -#define OSGANIMATION_TARGET_H +#ifndef OSGANIMATION_TARGET +#define OSGANIMATION_TARGET 1 #include #include diff --git a/src/osgAnimation/Animation.cpp b/src/osgAnimation/Animation.cpp index 948d94c36..cd1a4258e 100644 --- a/src/osgAnimation/Animation.cpp +++ b/src/osgAnimation/Animation.cpp @@ -80,7 +80,7 @@ void Animation::setDuration(double duration) _duration = duration; } -float Animation::getDuration() const +double Animation::getDuration() const { return _duration; } @@ -95,14 +95,14 @@ void Animation::setWeight (float weight) _weight = weight; } -bool Animation::update (float time, int priority) +bool Animation::update (double time, int priority) { if (!_duration) // if not initialized then do it computeDuration(); double ratio = _originalDuration / _duration; - float t = (time - _startTime) * ratio; + double t = (time - _startTime) * ratio; switch (_playmode) { case ONCE: @@ -117,7 +117,7 @@ bool Animation::update (float time, int priority) if (!_duration) t = _startTime; else if (t > _duration) - t = fmod(t, (float)_duration); + t = fmod(t, _duration); // std::cout << "t " << t << " duration " << _duration << std::endl; break; case PPONG: