Change time type from float to double in osgAnimation

This commit is contained in:
Cedric Pinson 2010-03-25 17:50:29 +00:00
parent fe5527f332
commit 35fa541350
6 changed files with 34 additions and 34 deletions

View File

@ -12,8 +12,8 @@
* OpenSceneGraph Public License for more details. * OpenSceneGraph Public License for more details.
*/ */
#ifndef OSGANIMATION_ANIMATION_H #ifndef OSGANIMATION_ANIMATION
#define OSGANIMATION_ANIMATION_H #define OSGANIMATION_ANIMATION 1
#include <osg/Object> #include <osg/Object>
#include <osgAnimation/Export> #include <osgAnimation/Export>
@ -65,20 +65,20 @@ namespace osgAnimation
*/ */
void computeDuration(); void computeDuration();
float getDuration() const; double getDuration() const;
void setWeight (float weight); void setWeight (float weight);
float getWeight() const; float getWeight() const;
bool update (float time, int priority = 0); bool update (double time, int priority = 0);
void resetTargets(); void resetTargets();
void setPlaymode (PlayMode mode) { _playmode = mode; } void setPlaymode (PlayMode mode) { _playmode = mode; }
PlayMode getPlayMode() const { return _playmode; } PlayMode getPlayMode() const { return _playmode; }
void setStartTime(float time) { _startTime = time;} void setStartTime(double time) { _startTime = time;}
float getStartTime() const { return _startTime;} double getStartTime() const { return _startTime;}
protected: protected:
@ -89,7 +89,7 @@ namespace osgAnimation
double _duration; double _duration;
double _originalDuration; double _originalDuration;
float _weight; float _weight;
float _startTime; double _startTime;
PlayMode _playmode; PlayMode _playmode;
ChannelList _channels; ChannelList _channels;

View File

@ -16,8 +16,8 @@
* Michael Platings <mplatings@pixelpower.com> * Michael Platings <mplatings@pixelpower.com>
*/ */
#ifndef OSGANIMATION_CHANNEL_H #ifndef OSGANIMATION_CHANNEL
#define OSGANIMATION_CHANNEL_H #define OSGANIMATION_CHANNEL 1
#include <osgAnimation/Export> #include <osgAnimation/Export>
#include <osgAnimation/Sampler> #include <osgAnimation/Sampler>
@ -37,7 +37,7 @@ namespace osgAnimation
virtual ~Channel(); virtual ~Channel();
virtual Channel* clone() const = 0; 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 void reset() = 0;
virtual Target* getTarget() = 0; virtual Target* getTarget() = 0;
virtual bool setTarget(Target*) = 0; virtual bool setTarget(Target*) = 0;
@ -45,8 +45,8 @@ namespace osgAnimation
const std::string& getName() const; const std::string& getName() const;
void setName(const std::string& name); void setName(const std::string& name);
virtual float getStartTime() const = 0; virtual double getStartTime() const = 0;
virtual float getEndTime() const = 0; virtual double getEndTime() const = 0;
const std::string& getTargetName() const; const std::string& getTargetName() const;
void setTargetName(const std::string& name); void setTargetName(const std::string& name);
@ -113,7 +113,7 @@ namespace osgAnimation
} }
virtual ~TemplateChannel() {} virtual ~TemplateChannel() {}
virtual void update(float time, float weight, int priority) virtual void update(double time, float weight, int priority)
{ {
// skip if weight == 0 // skip if weight == 0
if (weight < 1e-4) if (weight < 1e-4)
@ -148,8 +148,8 @@ namespace osgAnimation
const TargetType* getTargetTyped() const { return _target.get(); } const TargetType* getTargetTyped() const { return _target.get(); }
void setTarget(TargetType* target) { _target = target; } void setTarget(TargetType* target) { _target = target; }
virtual float getStartTime() const { return _sampler->getStartTime(); } virtual double getStartTime() const { return _sampler->getStartTime(); }
virtual float getEndTime() const { return _sampler->getEndTime(); } virtual double getEndTime() const { return _sampler->getEndTime(); }
protected: protected:
osg::ref_ptr<TargetType> _target; osg::ref_ptr<TargetType> _target;

View File

@ -31,11 +31,11 @@ namespace osgAnimation
class Keyframe class Keyframe
{ {
public: public:
float getTime() const { return _time; } double getTime() const { return _time; }
void setTime(float time) { _time = time; } void setTime(double time) { _time = time; }
protected: protected:
float _time; double _time;
}; };
@ -48,7 +48,7 @@ namespace osgAnimation
TemplateKeyframe () {} TemplateKeyframe () {}
~TemplateKeyframe () {} ~TemplateKeyframe () {}
TemplateKeyframe (float time, const T& value) TemplateKeyframe (double time, const T& value)
{ {
_time = time; _time = time;
_value = value; _value = value;

View File

@ -16,8 +16,8 @@
* Michael Platings <mplatings@pixelpower.com> * Michael Platings <mplatings@pixelpower.com>
*/ */
#ifndef OSGANIMATION_SAMPLER_H #ifndef OSGANIMATION_SAMPLER
#define OSGANIMATION_SAMPLER_H #define OSGANIMATION_SAMPLER 1
#include <vector> #include <vector>
#include <iostream> #include <iostream>
@ -50,7 +50,7 @@ namespace osgAnimation
TemplateSampler() {} TemplateSampler() {}
~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;} void setKeyframeContainer(KeyframeContainerType* kf) { _keyframes = kf;}
virtual KeyframeContainer* getKeyframeContainer() { return _keyframes.get(); } virtual KeyframeContainer* getKeyframeContainer() { return _keyframes.get(); }
@ -66,17 +66,17 @@ namespace osgAnimation
return _keyframes.get(); return _keyframes.get();
} }
float getStartTime() const double getStartTime() const
{ {
if (!_keyframes) if (!_keyframes)
return 0.0f; return 0.0;
return _keyframes->front().getTime(); return _keyframes->front().getTime();
} }
float getEndTime() const double getEndTime() const
{ {
if (!_keyframes) if (!_keyframes)
return 0.0f; return 0.0;
return _keyframes->back().getTime(); 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); _time.getValueAt(time, newtime);
_value.getValueAt(newtime, result); _value.getValueAt(newtime, result);
} }

View File

@ -13,8 +13,8 @@
*/ */
#ifndef OSGANIMATION_TARGET_H #ifndef OSGANIMATION_TARGET
#define OSGANIMATION_TARGET_H #define OSGANIMATION_TARGET 1
#include <vector> #include <vector>
#include <osg/Quat> #include <osg/Quat>

View File

@ -80,7 +80,7 @@ void Animation::setDuration(double duration)
_duration = duration; _duration = duration;
} }
float Animation::getDuration() const double Animation::getDuration() const
{ {
return _duration; return _duration;
} }
@ -95,14 +95,14 @@ void Animation::setWeight (float weight)
_weight = 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 if (!_duration) // if not initialized then do it
computeDuration(); computeDuration();
double ratio = _originalDuration / _duration; double ratio = _originalDuration / _duration;
float t = (time - _startTime) * ratio; double t = (time - _startTime) * ratio;
switch (_playmode) switch (_playmode)
{ {
case ONCE: case ONCE:
@ -117,7 +117,7 @@ bool Animation::update (float time, int priority)
if (!_duration) if (!_duration)
t = _startTime; t = _startTime;
else if (t > _duration) else if (t > _duration)
t = fmod(t, (float)_duration); t = fmod(t, _duration);
// std::cout << "t " << t << " duration " << _duration << std::endl; // std::cout << "t " << t << " duration " << _duration << std::endl;
break; break;
case PPONG: case PPONG: