mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-19 20:19:50 +02:00
Quake 4 integrated with DoomRTX
This commit is contained in:
+226
-120
@@ -2,9 +2,9 @@
|
||||
===========================================================================
|
||||
|
||||
IceTech GPL Source Code
|
||||
Copyright (C) 2026 Justin Marshall
|
||||
Copyright (C) 2026 Justin Marshall
|
||||
|
||||
This file is part of the IceTech GPL Source Code (?IceTech Source Code?).
|
||||
This file is part of the IceTech GPL Source Code (?IceTech Source Code?).
|
||||
|
||||
IceTech Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -40,24 +40,45 @@ If you have questions concerning this license or the applicable additional terms
|
||||
template< class type >
|
||||
class idInterpolate {
|
||||
public:
|
||||
idInterpolate();
|
||||
idInterpolate();
|
||||
|
||||
void Init( const float startTime, const float duration, const type &startValue, const type &endValue );
|
||||
void SetStartTime( float time ) { this->startTime = time; }
|
||||
void SetDuration( float duration ) { this->duration = duration; }
|
||||
void SetStartValue( const type &startValue ) { this->startValue = startValue; }
|
||||
void SetEndValue( const type &endValue ) { this->endValue = endValue; }
|
||||
#ifdef QUAKE4
|
||||
virtual ~idInterpolate() {}
|
||||
#endif
|
||||
|
||||
type GetCurrentValue( float time ) const;
|
||||
bool IsDone( float time ) const { return ( time >= startTime + duration ); }
|
||||
void Init(const float startTime, const float duration, const type& startValue, const type& endValue);
|
||||
void SetStartTime(float time) { this->startTime = time; }
|
||||
void SetDuration(float duration) { this->duration = duration; }
|
||||
void SetStartValue(const type& startValue) { this->startValue = startValue; }
|
||||
void SetEndValue(const type& endValue) { this->endValue = endValue; }
|
||||
|
||||
float GetStartTime( void ) const { return startTime; }
|
||||
float GetEndTime( void ) const { return startTime + duration; }
|
||||
float GetDuration( void ) const { return duration; }
|
||||
const type & GetStartValue( void ) const { return startValue; }
|
||||
const type & GetEndValue( void ) const { return endValue; }
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// abahr: made virtual
|
||||
virtual type GetCurrentValue(float time) const;
|
||||
virtual type GetDeltaValue(float startTime, float endTime) const;
|
||||
// RAVEN END
|
||||
#else
|
||||
type GetCurrentValue(float time) const;
|
||||
#endif
|
||||
|
||||
bool IsDone(float time) const { return (time >= startTime + duration); }
|
||||
|
||||
float GetStartTime(void) const { return startTime; }
|
||||
float GetEndTime(void) const { return startTime + duration; }
|
||||
float GetDuration(void) const { return duration; }
|
||||
const type& GetStartValue(void) const { return startValue; }
|
||||
const type& GetEndValue(void) const { return endValue; }
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// abahr: changed to protected
|
||||
protected:
|
||||
// RAVEN END
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
|
||||
float startTime;
|
||||
float duration;
|
||||
type startValue;
|
||||
@@ -74,7 +95,7 @@ idInterpolate::idInterpolate
|
||||
template< class type >
|
||||
ID_INLINE idInterpolate<type>::idInterpolate() {
|
||||
currentTime = startTime = duration = 0;
|
||||
memset( ¤tValue, 0, sizeof( currentValue ) );
|
||||
memset(¤tValue, 0, sizeof(currentValue));
|
||||
startValue = endValue = currentValue;
|
||||
}
|
||||
|
||||
@@ -84,7 +105,7 @@ idInterpolate::Init
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolate<type>::Init( const float startTime, const float duration, const type &startValue, const type &endValue ) {
|
||||
ID_INLINE void idInterpolate<type>::Init(const float startTime, const float duration, const type& startValue, const type& endValue) {
|
||||
this->startTime = startTime;
|
||||
this->duration = duration;
|
||||
this->startValue = startValue;
|
||||
@@ -99,23 +120,100 @@ idInterpolate::GetCurrentValue
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE type idInterpolate<type>::GetCurrentValue( float time ) const {
|
||||
ID_INLINE type idInterpolate<type>::GetCurrentValue(float time) const {
|
||||
float deltaTime;
|
||||
|
||||
deltaTime = time - startTime;
|
||||
if ( time != currentTime ) {
|
||||
if (time != currentTime) {
|
||||
currentTime = time;
|
||||
if ( deltaTime <= 0 ) {
|
||||
if (deltaTime <= 0) {
|
||||
currentValue = startValue;
|
||||
} else if ( deltaTime >= duration ) {
|
||||
}
|
||||
else if (deltaTime >= duration) {
|
||||
currentValue = endValue;
|
||||
} else {
|
||||
currentValue = startValue + ( endValue - startValue ) * ( (float) deltaTime / duration );
|
||||
}
|
||||
else {
|
||||
currentValue = startValue + (endValue - startValue) * ((float)deltaTime / duration);
|
||||
}
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// abahr
|
||||
/*
|
||||
====================
|
||||
idInterpolate::GetDeltaValue
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE type idInterpolate<type>::GetDeltaValue(float startTime, float endTime) const {
|
||||
return GetCurrentValue(endTime) - GetCurrentValue(startTime);
|
||||
}
|
||||
|
||||
ID_INLINE float Linear(float frac) {
|
||||
return frac;
|
||||
}
|
||||
|
||||
ID_INLINE float SinusoidalMidPoint(float frac) {
|
||||
return idMath::Sin(DEG2RAD(idMath::MidPointLerp(0.0f, 60.0f, 90.0f, frac)));
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================================
|
||||
|
||||
Spherical interpolation.
|
||||
|
||||
==============================================================================================
|
||||
*/
|
||||
|
||||
typedef float (*TimeManipFunc)(float);
|
||||
|
||||
class rvSphericalInterpolate : public idInterpolate<idQuat> {
|
||||
public:
|
||||
rvSphericalInterpolate();
|
||||
|
||||
virtual idQuat GetCurrentValue(float time) const;
|
||||
|
||||
void SetTimeFunction(TimeManipFunc func) { timeFunc = func; }
|
||||
|
||||
protected:
|
||||
TimeManipFunc timeFunc;
|
||||
};
|
||||
|
||||
/*
|
||||
====================
|
||||
rvSphericalInterpolate::rvSphericalInterpolate
|
||||
====================
|
||||
*/
|
||||
ID_INLINE rvSphericalInterpolate::rvSphericalInterpolate() :
|
||||
idInterpolate<idQuat>() {
|
||||
SetTimeFunction(SinusoidalMidPoint);
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
rvSphericalInterpolate::GetCurrentValue
|
||||
====================
|
||||
*/
|
||||
ID_INLINE idQuat rvSphericalInterpolate::GetCurrentValue(float time) const {
|
||||
float deltaTime;
|
||||
|
||||
deltaTime = time - startTime;
|
||||
if (time != currentTime) {
|
||||
currentTime = time;
|
||||
if (duration == 0.0f) {
|
||||
currentValue = endValue;
|
||||
}
|
||||
else {
|
||||
currentValue.Slerp(startValue, endValue, timeFunc((float)deltaTime / duration));
|
||||
}
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
// RAVEN END
|
||||
#endif
|
||||
|
||||
/*
|
||||
==============================================================================================
|
||||
@@ -127,26 +225,26 @@ ID_INLINE type idInterpolate<type>::GetCurrentValue( float time ) const {
|
||||
*/
|
||||
|
||||
template< class type >
|
||||
class idInterpolateAccelDecelLinear {
|
||||
class idInterpolateAccelDecelLinear {
|
||||
public:
|
||||
idInterpolateAccelDecelLinear();
|
||||
idInterpolateAccelDecelLinear();
|
||||
|
||||
void Init( const float startTime, const float accelTime, const float decelTime, const float duration, const type &startValue, const type &endValue );
|
||||
void SetStartTime( float time ) { startTime = time; Invalidate(); }
|
||||
void SetStartValue( const type &startValue ) { this->startValue = startValue; Invalidate(); }
|
||||
void SetEndValue( const type &endValue ) { this->endValue = endValue; Invalidate(); }
|
||||
void Init(const float startTime, const float accelTime, const float decelTime, const float duration, const type& startValue, const type& endValue);
|
||||
void SetStartTime(float time) { startTime = time; Invalidate(); }
|
||||
void SetStartValue(const type& startValue) { this->startValue = startValue; Invalidate(); }
|
||||
void SetEndValue(const type& endValue) { this->endValue = endValue; Invalidate(); }
|
||||
|
||||
type GetCurrentValue( float time ) const;
|
||||
type GetCurrentSpeed( float time ) const;
|
||||
bool IsDone( float time ) const { return ( time >= startTime + accelTime + linearTime + decelTime ); }
|
||||
type GetCurrentValue(float time) const;
|
||||
type GetCurrentSpeed(float time) const;
|
||||
bool IsDone(float time) const { return (time >= startTime + accelTime + linearTime + decelTime); }
|
||||
|
||||
float GetStartTime( void ) const { return startTime; }
|
||||
float GetEndTime( void ) const { return startTime + accelTime + linearTime + decelTime; }
|
||||
float GetDuration( void ) const { return accelTime + linearTime + decelTime; }
|
||||
float GetAcceleration( void ) const { return accelTime; }
|
||||
float GetDeceleration( void ) const { return decelTime; }
|
||||
const type & GetStartValue( void ) const { return startValue; }
|
||||
const type & GetEndValue( void ) const { return endValue; }
|
||||
float GetStartTime(void) const { return startTime; }
|
||||
float GetEndTime(void) const { return startTime + accelTime + linearTime + decelTime; }
|
||||
float GetDuration(void) const { return accelTime + linearTime + decelTime; }
|
||||
float GetAcceleration(void) const { return accelTime; }
|
||||
float GetDeceleration(void) const { return decelTime; }
|
||||
const type& GetStartValue(void) const { return startValue; }
|
||||
const type& GetEndValue(void) const { return endValue; }
|
||||
|
||||
private:
|
||||
float startTime;
|
||||
@@ -157,8 +255,8 @@ private:
|
||||
type endValue;
|
||||
mutable idExtrapolate<type> extrapolate;
|
||||
|
||||
void Invalidate( void );
|
||||
void SetPhase( float time ) const;
|
||||
void Invalidate(void);
|
||||
void SetPhase(float time) const;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -169,7 +267,7 @@ idInterpolateAccelDecelLinear::idInterpolateAccelDecelLinear
|
||||
template< class type >
|
||||
ID_INLINE idInterpolateAccelDecelLinear<type>::idInterpolateAccelDecelLinear() {
|
||||
startTime = accelTime = linearTime = decelTime = 0;
|
||||
memset( &startValue, 0, sizeof( startValue ) );
|
||||
memset(&startValue, 0, sizeof(startValue));
|
||||
endValue = startValue;
|
||||
}
|
||||
|
||||
@@ -179,7 +277,7 @@ idInterpolateAccelDecelLinear::Init
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolateAccelDecelLinear<type>::Init( const float startTime, const float accelTime, const float decelTime, const float duration, const type &startValue, const type &endValue ) {
|
||||
ID_INLINE void idInterpolateAccelDecelLinear<type>::Init(const float startTime, const float accelTime, const float decelTime, const float duration, const type& startValue, const type& endValue) {
|
||||
type speed;
|
||||
|
||||
this->startTime = startTime;
|
||||
@@ -188,23 +286,25 @@ ID_INLINE void idInterpolateAccelDecelLinear<type>::Init( const float startTime,
|
||||
this->startValue = startValue;
|
||||
this->endValue = endValue;
|
||||
|
||||
if ( duration <= 0.0f ) {
|
||||
if (duration <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this->accelTime + this->decelTime > duration ) {
|
||||
this->accelTime = this->accelTime * duration / ( this->accelTime + this->decelTime );
|
||||
if (this->accelTime + this->decelTime > duration) {
|
||||
this->accelTime = this->accelTime * duration / (this->accelTime + this->decelTime);
|
||||
this->decelTime = duration - this->accelTime;
|
||||
}
|
||||
this->linearTime = duration - this->accelTime - this->decelTime;
|
||||
speed = ( endValue - startValue ) * ( 1000.0f / ( (float) this->linearTime + ( this->accelTime + this->decelTime ) * 0.5f ) );
|
||||
speed = (endValue - startValue) * (1000.0f / ((float)this->linearTime + (this->accelTime + this->decelTime) * 0.5f));
|
||||
|
||||
if ( this->accelTime ) {
|
||||
extrapolate.Init( startTime, this->accelTime, startValue, ( startValue - startValue ), speed, EXTRAPOLATION_ACCELLINEAR );
|
||||
} else if ( this->linearTime ) {
|
||||
extrapolate.Init( startTime, this->linearTime, startValue, ( startValue - startValue ), speed, EXTRAPOLATION_LINEAR );
|
||||
} else {
|
||||
extrapolate.Init( startTime, this->decelTime, startValue, ( startValue - startValue ), speed, EXTRAPOLATION_DECELLINEAR );
|
||||
if (this->accelTime) {
|
||||
extrapolate.Init(startTime, this->accelTime, startValue, (startValue - startValue), speed, EXTRAPOLATION_ACCELLINEAR);
|
||||
}
|
||||
else if (this->linearTime) {
|
||||
extrapolate.Init(startTime, this->linearTime, startValue, (startValue - startValue), speed, EXTRAPOLATION_LINEAR);
|
||||
}
|
||||
else {
|
||||
extrapolate.Init(startTime, this->decelTime, startValue, (startValue - startValue), speed, EXTRAPOLATION_DECELLINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +314,8 @@ idInterpolateAccelDecelLinear::Invalidate
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolateAccelDecelLinear<type>::Invalidate( void ) {
|
||||
extrapolate.Init( 0, 0, extrapolate.GetStartValue(), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_NONE );
|
||||
ID_INLINE void idInterpolateAccelDecelLinear<type>::Invalidate(void) {
|
||||
extrapolate.Init(0, 0, extrapolate.GetStartValue(), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -224,21 +324,23 @@ idInterpolateAccelDecelLinear::SetPhase
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolateAccelDecelLinear<type>::SetPhase( float time ) const {
|
||||
ID_INLINE void idInterpolateAccelDecelLinear<type>::SetPhase(float time) const {
|
||||
float deltaTime;
|
||||
|
||||
deltaTime = time - startTime;
|
||||
if ( deltaTime < accelTime ) {
|
||||
if ( extrapolate.GetExtrapolationType() != EXTRAPOLATION_ACCELLINEAR ) {
|
||||
extrapolate.Init( startTime, accelTime, startValue, extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_ACCELLINEAR );
|
||||
if (deltaTime < accelTime) {
|
||||
if (extrapolate.GetExtrapolationType() != EXTRAPOLATION_ACCELLINEAR) {
|
||||
extrapolate.Init(startTime, accelTime, startValue, extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_ACCELLINEAR);
|
||||
}
|
||||
} else if ( deltaTime < accelTime + linearTime ) {
|
||||
if ( extrapolate.GetExtrapolationType() != EXTRAPOLATION_LINEAR ) {
|
||||
extrapolate.Init( startTime + accelTime, linearTime, startValue + extrapolate.GetSpeed() * ( accelTime * 0.001f * 0.5f ), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_LINEAR );
|
||||
}
|
||||
else if (deltaTime < accelTime + linearTime) {
|
||||
if (extrapolate.GetExtrapolationType() != EXTRAPOLATION_LINEAR) {
|
||||
extrapolate.Init(startTime + accelTime, linearTime, startValue + extrapolate.GetSpeed() * (accelTime * 0.001f * 0.5f), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_LINEAR);
|
||||
}
|
||||
} else {
|
||||
if ( extrapolate.GetExtrapolationType() != EXTRAPOLATION_DECELLINEAR ) {
|
||||
extrapolate.Init( startTime + accelTime + linearTime, decelTime, endValue - ( extrapolate.GetSpeed() * ( decelTime * 0.001f * 0.5f ) ), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_DECELLINEAR );
|
||||
}
|
||||
else {
|
||||
if (extrapolate.GetExtrapolationType() != EXTRAPOLATION_DECELLINEAR) {
|
||||
extrapolate.Init(startTime + accelTime + linearTime, decelTime, endValue - (extrapolate.GetSpeed() * (decelTime * 0.001f * 0.5f)), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_DECELLINEAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,9 +351,9 @@ idInterpolateAccelDecelLinear::GetCurrentValue
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE type idInterpolateAccelDecelLinear<type>::GetCurrentValue( float time ) const {
|
||||
SetPhase( time );
|
||||
return extrapolate.GetCurrentValue( time );
|
||||
ID_INLINE type idInterpolateAccelDecelLinear<type>::GetCurrentValue(float time) const {
|
||||
SetPhase(time);
|
||||
return extrapolate.GetCurrentValue(time);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -260,9 +362,9 @@ idInterpolateAccelDecelLinear::GetCurrentSpeed
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE type idInterpolateAccelDecelLinear<type>::GetCurrentSpeed( float time ) const {
|
||||
SetPhase( time );
|
||||
return extrapolate.GetCurrentSpeed( time );
|
||||
ID_INLINE type idInterpolateAccelDecelLinear<type>::GetCurrentSpeed(float time) const {
|
||||
SetPhase(time);
|
||||
return extrapolate.GetCurrentSpeed(time);
|
||||
}
|
||||
|
||||
|
||||
@@ -276,26 +378,26 @@ ID_INLINE type idInterpolateAccelDecelLinear<type>::GetCurrentSpeed( float time
|
||||
*/
|
||||
|
||||
template< class type >
|
||||
class idInterpolateAccelDecelSine {
|
||||
class idInterpolateAccelDecelSine {
|
||||
public:
|
||||
idInterpolateAccelDecelSine();
|
||||
idInterpolateAccelDecelSine();
|
||||
|
||||
void Init( const float startTime, const float accelTime, const float decelTime, const float duration, const type &startValue, const type &endValue );
|
||||
void SetStartTime( float time ) { startTime = time; Invalidate(); }
|
||||
void SetStartValue( const type &startValue ) { this->startValue = startValue; Invalidate(); }
|
||||
void SetEndValue( const type &endValue ) { this->endValue = endValue; Invalidate(); }
|
||||
void Init(const float startTime, const float accelTime, const float decelTime, const float duration, const type& startValue, const type& endValue);
|
||||
void SetStartTime(float time) { startTime = time; Invalidate(); }
|
||||
void SetStartValue(const type& startValue) { this->startValue = startValue; Invalidate(); }
|
||||
void SetEndValue(const type& endValue) { this->endValue = endValue; Invalidate(); }
|
||||
|
||||
type GetCurrentValue( float time ) const;
|
||||
type GetCurrentSpeed( float time ) const;
|
||||
bool IsDone( float time ) const { return ( time >= startTime + accelTime + linearTime + decelTime ); }
|
||||
type GetCurrentValue(float time) const;
|
||||
type GetCurrentSpeed(float time) const;
|
||||
bool IsDone(float time) const { return (time >= startTime + accelTime + linearTime + decelTime); }
|
||||
|
||||
float GetStartTime( void ) const { return startTime; }
|
||||
float GetEndTime( void ) const { return startTime + accelTime + linearTime + decelTime; }
|
||||
float GetDuration( void ) const { return accelTime + linearTime + decelTime; }
|
||||
float GetAcceleration( void ) const { return accelTime; }
|
||||
float GetDeceleration( void ) const { return decelTime; }
|
||||
const type & GetStartValue( void ) const { return startValue; }
|
||||
const type & GetEndValue( void ) const { return endValue; }
|
||||
float GetStartTime(void) const { return startTime; }
|
||||
float GetEndTime(void) const { return startTime + accelTime + linearTime + decelTime; }
|
||||
float GetDuration(void) const { return accelTime + linearTime + decelTime; }
|
||||
float GetAcceleration(void) const { return accelTime; }
|
||||
float GetDeceleration(void) const { return decelTime; }
|
||||
const type& GetStartValue(void) const { return startValue; }
|
||||
const type& GetEndValue(void) const { return endValue; }
|
||||
|
||||
private:
|
||||
float startTime;
|
||||
@@ -306,8 +408,8 @@ private:
|
||||
type endValue;
|
||||
mutable idExtrapolate<type> extrapolate;
|
||||
|
||||
void Invalidate( void );
|
||||
void SetPhase( float time ) const;
|
||||
void Invalidate(void);
|
||||
void SetPhase(float time) const;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -318,7 +420,7 @@ idInterpolateAccelDecelSine::idInterpolateAccelDecelSine
|
||||
template< class type >
|
||||
ID_INLINE idInterpolateAccelDecelSine<type>::idInterpolateAccelDecelSine() {
|
||||
startTime = accelTime = linearTime = decelTime = 0;
|
||||
memset( &startValue, 0, sizeof( startValue ) );
|
||||
memset(&startValue, 0, sizeof(startValue));
|
||||
endValue = startValue;
|
||||
}
|
||||
|
||||
@@ -328,7 +430,7 @@ idInterpolateAccelDecelSine::Init
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolateAccelDecelSine<type>::Init( const float startTime, const float accelTime, const float decelTime, const float duration, const type &startValue, const type &endValue ) {
|
||||
ID_INLINE void idInterpolateAccelDecelSine<type>::Init(const float startTime, const float accelTime, const float decelTime, const float duration, const type& startValue, const type& endValue) {
|
||||
type speed;
|
||||
|
||||
this->startTime = startTime;
|
||||
@@ -337,23 +439,25 @@ ID_INLINE void idInterpolateAccelDecelSine<type>::Init( const float startTime, c
|
||||
this->startValue = startValue;
|
||||
this->endValue = endValue;
|
||||
|
||||
if ( duration <= 0.0f ) {
|
||||
if (duration <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this->accelTime + this->decelTime > duration ) {
|
||||
this->accelTime = this->accelTime * duration / ( this->accelTime + this->decelTime );
|
||||
if (this->accelTime + this->decelTime > duration) {
|
||||
this->accelTime = this->accelTime * duration / (this->accelTime + this->decelTime);
|
||||
this->decelTime = duration - this->accelTime;
|
||||
}
|
||||
this->linearTime = duration - this->accelTime - this->decelTime;
|
||||
speed = ( endValue - startValue ) * ( 1000.0f / ( (float) this->linearTime + ( this->accelTime + this->decelTime ) * idMath::SQRT_1OVER2 ) );
|
||||
speed = (endValue - startValue) * (1000.0f / ((float)this->linearTime + (this->accelTime + this->decelTime) * idMath::SQRT_1OVER2));
|
||||
|
||||
if ( this->accelTime ) {
|
||||
extrapolate.Init( startTime, this->accelTime, startValue, ( startValue - startValue ), speed, EXTRAPOLATION_ACCELSINE );
|
||||
} else if ( this->linearTime ) {
|
||||
extrapolate.Init( startTime, this->linearTime, startValue, ( startValue - startValue ), speed, EXTRAPOLATION_LINEAR );
|
||||
} else {
|
||||
extrapolate.Init( startTime, this->decelTime, startValue, ( startValue - startValue ), speed, EXTRAPOLATION_DECELSINE );
|
||||
if (this->accelTime) {
|
||||
extrapolate.Init(startTime, this->accelTime, startValue, (startValue - startValue), speed, EXTRAPOLATION_ACCELSINE);
|
||||
}
|
||||
else if (this->linearTime) {
|
||||
extrapolate.Init(startTime, this->linearTime, startValue, (startValue - startValue), speed, EXTRAPOLATION_LINEAR);
|
||||
}
|
||||
else {
|
||||
extrapolate.Init(startTime, this->decelTime, startValue, (startValue - startValue), speed, EXTRAPOLATION_DECELSINE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,8 +467,8 @@ idInterpolateAccelDecelSine::Invalidate
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolateAccelDecelSine<type>::Invalidate( void ) {
|
||||
extrapolate.Init( 0, 0, extrapolate.GetStartValue(), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_NONE );
|
||||
ID_INLINE void idInterpolateAccelDecelSine<type>::Invalidate(void) {
|
||||
extrapolate.Init(0, 0, extrapolate.GetStartValue(), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -373,21 +477,23 @@ idInterpolateAccelDecelSine::SetPhase
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE void idInterpolateAccelDecelSine<type>::SetPhase( float time ) const {
|
||||
ID_INLINE void idInterpolateAccelDecelSine<type>::SetPhase(float time) const {
|
||||
float deltaTime;
|
||||
|
||||
deltaTime = time - startTime;
|
||||
if ( deltaTime < accelTime ) {
|
||||
if ( extrapolate.GetExtrapolationType() != EXTRAPOLATION_ACCELSINE ) {
|
||||
extrapolate.Init( startTime, accelTime, startValue, extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_ACCELSINE );
|
||||
if (deltaTime < accelTime) {
|
||||
if (extrapolate.GetExtrapolationType() != EXTRAPOLATION_ACCELSINE) {
|
||||
extrapolate.Init(startTime, accelTime, startValue, extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_ACCELSINE);
|
||||
}
|
||||
} else if ( deltaTime < accelTime + linearTime ) {
|
||||
if ( extrapolate.GetExtrapolationType() != EXTRAPOLATION_LINEAR ) {
|
||||
extrapolate.Init( startTime + accelTime, linearTime, startValue + extrapolate.GetSpeed() * ( accelTime * 0.001f * idMath::SQRT_1OVER2 ), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_LINEAR );
|
||||
}
|
||||
else if (deltaTime < accelTime + linearTime) {
|
||||
if (extrapolate.GetExtrapolationType() != EXTRAPOLATION_LINEAR) {
|
||||
extrapolate.Init(startTime + accelTime, linearTime, startValue + extrapolate.GetSpeed() * (accelTime * 0.001f * idMath::SQRT_1OVER2), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_LINEAR);
|
||||
}
|
||||
} else {
|
||||
if ( extrapolate.GetExtrapolationType() != EXTRAPOLATION_DECELSINE ) {
|
||||
extrapolate.Init( startTime + accelTime + linearTime, decelTime, endValue - ( extrapolate.GetSpeed() * ( decelTime * 0.001f * idMath::SQRT_1OVER2 ) ), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_DECELSINE );
|
||||
}
|
||||
else {
|
||||
if (extrapolate.GetExtrapolationType() != EXTRAPOLATION_DECELSINE) {
|
||||
extrapolate.Init(startTime + accelTime + linearTime, decelTime, endValue - (extrapolate.GetSpeed() * (decelTime * 0.001f * idMath::SQRT_1OVER2)), extrapolate.GetBaseSpeed(), extrapolate.GetSpeed(), EXTRAPOLATION_DECELSINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,9 +504,9 @@ idInterpolateAccelDecelSine::GetCurrentValue
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE type idInterpolateAccelDecelSine<type>::GetCurrentValue( float time ) const {
|
||||
SetPhase( time );
|
||||
return extrapolate.GetCurrentValue( time );
|
||||
ID_INLINE type idInterpolateAccelDecelSine<type>::GetCurrentValue(float time) const {
|
||||
SetPhase(time);
|
||||
return extrapolate.GetCurrentValue(time);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -409,9 +515,9 @@ idInterpolateAccelDecelSine::GetCurrentSpeed
|
||||
====================
|
||||
*/
|
||||
template< class type >
|
||||
ID_INLINE type idInterpolateAccelDecelSine<type>::GetCurrentSpeed( float time ) const {
|
||||
SetPhase( time );
|
||||
return extrapolate.GetCurrentSpeed( time );
|
||||
ID_INLINE type idInterpolateAccelDecelSine<type>::GetCurrentSpeed(float time) const {
|
||||
SetPhase(time);
|
||||
return extrapolate.GetCurrentSpeed(time);
|
||||
}
|
||||
|
||||
#endif /* !__MATH_INTERPOLATE_H__ */
|
||||
#endif /* !__MATH_INTERPOLATE_H__ */
|
||||
Reference in New Issue
Block a user