Change time type from float to double in osgAnimation
This commit is contained in:
parent
fe5527f332
commit
35fa541350
@ -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 <osg/Object>
|
||||
#include <osgAnimation/Export>
|
||||
@ -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;
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
* Michael Platings <mplatings@pixelpower.com>
|
||||
*/
|
||||
|
||||
#ifndef OSGANIMATION_CHANNEL_H
|
||||
#define OSGANIMATION_CHANNEL_H
|
||||
#ifndef OSGANIMATION_CHANNEL
|
||||
#define OSGANIMATION_CHANNEL 1
|
||||
|
||||
#include <osgAnimation/Export>
|
||||
#include <osgAnimation/Sampler>
|
||||
@ -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<TargetType> _target;
|
||||
|
@ -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;
|
||||
|
@ -16,8 +16,8 @@
|
||||
* Michael Platings <mplatings@pixelpower.com>
|
||||
*/
|
||||
|
||||
#ifndef OSGANIMATION_SAMPLER_H
|
||||
#define OSGANIMATION_SAMPLER_H
|
||||
#ifndef OSGANIMATION_SAMPLER
|
||||
#define OSGANIMATION_SAMPLER 1
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
@ -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);
|
||||
}
|
||||
|
@ -13,8 +13,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OSGANIMATION_TARGET_H
|
||||
#define OSGANIMATION_TARGET_H
|
||||
#ifndef OSGANIMATION_TARGET
|
||||
#define OSGANIMATION_TARGET 1
|
||||
|
||||
#include <vector>
|
||||
#include <osg/Quat>
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user