1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 19:29:09 +00:00

Eliminate hsScalar and hsFixed

Modern CPUs support floats just fine... hsFixed was crazy.
This commit is contained in:
2012-01-21 02:03:37 -05:00
parent 5027b5a4ac
commit e020651e4b
584 changed files with 5401 additions and 6399 deletions

View File

@ -50,12 +50,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// linear interpolation
///////////////////////////////////////////////////////
//
void hsInterp::LinInterp(hsScalar k1, hsScalar k2, hsScalar t, hsScalar* result)
void hsInterp::LinInterp(float k1, float k2, float t, float* result)
{
*result = k1 + t * (k2 - k1);
}
void hsInterp::LinInterp(const hsScalarTriple* k1, const hsScalarTriple* k2, hsScalar t,
void hsInterp::LinInterp(const hsScalarTriple* k1, const hsScalarTriple* k2, float t,
hsScalarTriple* result)
{
if (t==0.0)
@ -71,7 +71,7 @@ void hsInterp::LinInterp(const hsScalarTriple* k1, const hsScalarTriple* k2, hsS
}
}
void hsInterp::LinInterp(const hsColorRGBA* k1, const hsColorRGBA* k2, hsScalar t,
void hsInterp::LinInterp(const hsColorRGBA* k1, const hsColorRGBA* k2, float t,
hsColorRGBA* result, uint32_t flags)
{
if (t==0.0)
@ -102,7 +102,7 @@ void hsInterp::LinInterp(const hsColorRGBA* k1, const hsColorRGBA* k2, hsScalar
LinInterp(k1->a, k2->a, t, &result->a);
}
void hsInterp::LinInterp(const hsMatrix33* k1, const hsMatrix33* k2, hsScalar t,
void hsInterp::LinInterp(const hsMatrix33* k1, const hsMatrix33* k2, float t,
hsMatrix33* result, uint32_t flags)
{
if (t==0.0)
@ -162,7 +162,7 @@ void hsInterp::LinInterp(const hsMatrix33* k1, const hsMatrix33* k2, hsScalar t,
//
//
void hsInterp::LinInterp(const hsMatrix44* mat1, const hsMatrix44* mat2, hsScalar t,
void hsInterp::LinInterp(const hsMatrix44* mat1, const hsMatrix44* mat2, float t,
hsMatrix44* out, uint32_t flags)
{
if (flags == 0)
@ -173,7 +173,7 @@ void hsInterp::LinInterp(const hsMatrix44* mat1, const hsMatrix44* mat2, hsScala
return;
}
if( hsScalar1 == t )
if( 1.f == t )
{
*out = *mat2;
return;
@ -234,7 +234,7 @@ void hsInterp::LinInterp(const hsMatrix44* mat1, const hsMatrix44* mat2, hsScala
}
}
void hsInterp::LinInterp(const hsQuat* k1, const hsQuat* k2, hsScalar t, hsQuat* result)
void hsInterp::LinInterp(const hsQuat* k1, const hsQuat* k2, float t, hsQuat* result)
{
if (t==0.0)
*result = *k1;
@ -247,14 +247,14 @@ void hsInterp::LinInterp(const hsQuat* k1, const hsQuat* k2, hsScalar t, hsQuat*
}
}
void hsInterp::LinInterp(const hsScaleValue* k1, const hsScaleValue* k2, hsScalar t,
void hsInterp::LinInterp(const hsScaleValue* k1, const hsScaleValue* k2, float t,
hsScaleValue* result)
{
LinInterp(&k1->fS, &k2->fS, t, &result->fS); // Stretch rotation
LinInterp(&k1->fQ, &k2->fQ, t, &result->fQ); // Stretch factor
}
void hsInterp::LinInterp(const hsAffineParts* k1, const hsAffineParts* k2, hsScalar t,
void hsInterp::LinInterp(const hsAffineParts* k1, const hsAffineParts* k2, float t,
hsAffineParts* result, uint32_t flags)
{
if (t==0.0)
@ -329,28 +329,28 @@ void hsInterp::LinInterp(const hsAffineParts* k1, const hsAffineParts* k2, hsSca
///////////////////////////////////////////////////////
//
void hsInterp::BezScalarEval(const hsScalar value1, const hsScalar outTan,
const hsScalar value2, const hsScalar inTan,
const hsScalar t, const hsScalar tanScale, hsScalar *result)
void hsInterp::BezScalarEval(const float value1, const float outTan,
const float value2, const float inTan,
const float t, const float tanScale, float *result)
{
#if 0
// If the tangents were what you'd expect them to be... Hermite splines, than this code
// would make sense. But no, Max likes to store them in a scaled form based on the
// time of each frame. If we ever optimize this further, we could do the scaling on export,
// but I need this to work right now before all the artists hate me too much.
const hsScalar t2 = t * t;
const hsScalar t3 = t2 * t;
const float t2 = t * t;
const float t3 = t2 * t;
const hsScalar term1 = 2 * t3 - 3 * t2;
const float term1 = 2 * t3 - 3 * t2;
*result = ((term1 + 1) * value1) +
(-term1 * value2) +
((t3 - 2 * t2 + 1) * outTan) +
((t3 - t2) * inTan);
#else
const hsScalar oneMinusT = (1.0f - t);
const hsScalar tSq = t * t;
const hsScalar oneMinusTSq = oneMinusT * oneMinusT;
const float oneMinusT = (1.0f - t);
const float tSq = t * t;
const float oneMinusTSq = oneMinusT * oneMinusT;
*result = (oneMinusT * oneMinusTSq * value1) +
(3.f * t * oneMinusTSq * (value1 + outTan * tanScale)) +
@ -359,23 +359,23 @@ void hsInterp::BezScalarEval(const hsScalar value1, const hsScalar outTan,
#endif
}
void hsInterp::BezInterp(const hsBezPoint3Key* k1, const hsBezPoint3Key* k2, const hsScalar t, hsScalarTriple* result)
void hsInterp::BezInterp(const hsBezPoint3Key* k1, const hsBezPoint3Key* k2, const float t, hsScalarTriple* result)
{
hsScalar scale = (k2->fFrame - k1->fFrame) * MAX_TICKS_PER_FRAME / 3.f;
float scale = (k2->fFrame - k1->fFrame) * MAX_TICKS_PER_FRAME / 3.f;
BezScalarEval(k1->fValue.fX, k1->fOutTan.fX, k2->fValue.fX, k2->fInTan.fX, t, scale, &result->fX);
BezScalarEval(k1->fValue.fY, k1->fOutTan.fY, k2->fValue.fY, k2->fInTan.fY, t, scale, &result->fY);
BezScalarEval(k1->fValue.fZ, k1->fOutTan.fZ, k2->fValue.fZ, k2->fInTan.fZ, t, scale, &result->fZ);
}
void hsInterp::BezInterp(const hsBezScalarKey* k1, const hsBezScalarKey* k2, const hsScalar t, hsScalar* result)
void hsInterp::BezInterp(const hsBezScalarKey* k1, const hsBezScalarKey* k2, const float t, float* result)
{
hsScalar scale = (k2->fFrame - k1->fFrame) * MAX_TICKS_PER_FRAME / 3.f;
float scale = (k2->fFrame - k1->fFrame) * MAX_TICKS_PER_FRAME / 3.f;
BezScalarEval(k1->fValue, k1->fOutTan, k2->fValue, k2->fInTan, t, scale, result);
}
void hsInterp::BezInterp(const hsBezScaleKey* k1, const hsBezScaleKey* k2, const hsScalar t, hsScaleValue* result)
void hsInterp::BezInterp(const hsBezScaleKey* k1, const hsBezScaleKey* k2, const float t, hsScaleValue* result)
{
hsScalar scale = (k2->fFrame - k1->fFrame) * MAX_TICKS_PER_FRAME / 3.f;
float scale = (k2->fFrame - k1->fFrame) * MAX_TICKS_PER_FRAME / 3.f;
BezScalarEval(k1->fValue.fS.fX, k1->fOutTan.fX, k2->fValue.fS.fX, k2->fInTan.fX, t, scale, &result->fS.fX);
BezScalarEval(k1->fValue.fS.fY, k1->fOutTan.fY, k2->fValue.fS.fY, k2->fInTan.fY, t, scale, &result->fS.fY);
BezScalarEval(k1->fValue.fS.fZ, k1->fOutTan.fZ, k2->fValue.fS.fZ, k2->fInTan.fZ, t, scale, &result->fS.fZ);
@ -399,8 +399,8 @@ static inline hsKeyFrame* GetKey(int32_t i, void *keys, int32_t size)
// Returns the index of the first key which can be passed in as a hint (lastKeyIdx)
// for the next search.
//
void hsInterp::GetBoundaryKeyFrames(hsScalar time, uint32_t numKeys, void *keys, uint32_t size,
hsKeyFrame **kF1, hsKeyFrame **kF2, uint32_t *lastKeyIdx, hsScalar *p, hsBool forwards)
void hsInterp::GetBoundaryKeyFrames(float time, uint32_t numKeys, void *keys, uint32_t size,
hsKeyFrame **kF1, hsKeyFrame **kF2, uint32_t *lastKeyIdx, float *p, hsBool forwards)
{
hsAssert(numKeys>1, "Must have more than 1 keyframe");
int k1, k2;

View File

@ -68,26 +68,26 @@ public:
kPreservePartsScale = 0x40 // result gets the scale of key1
};
static void BezScalarEval(const hsScalar value1, const hsScalar outTan,
const hsScalar value2, const hsScalar inTan,
const hsScalar t, const hsScalar scale, hsScalar *result);
static void BezInterp(const hsBezPoint3Key *k1, const hsBezPoint3Key *k2, const hsScalar t, hsScalarTriple *result);
static void BezInterp(const hsBezScalarKey *k1, const hsBezScalarKey *k2, const hsScalar t, hsScalar *result);
static void BezInterp(const hsBezScaleKey *k1, const hsBezScaleKey *k2, const hsScalar t, hsScaleValue *result);
static void BezScalarEval(const float value1, const float outTan,
const float value2, const float inTan,
const float t, const float scale, float *result);
static void BezInterp(const hsBezPoint3Key *k1, const hsBezPoint3Key *k2, const float t, hsScalarTriple *result);
static void BezInterp(const hsBezScalarKey *k1, const hsBezScalarKey *k2, const float t, float *result);
static void BezInterp(const hsBezScaleKey *k1, const hsBezScaleKey *k2, const float t, hsScaleValue *result);
// simple linear interpolation
static void LinInterp(const hsScalar k1, const hsScalar k2, const hsScalar t, hsScalar *result);
static void LinInterp(const hsScalarTriple *k1, const hsScalarTriple *k2, const hsScalar t, hsScalarTriple *result);
static void LinInterp(const hsColorRGBA *k1, const hsColorRGBA *k2, const hsScalar t, hsColorRGBA *result, uint32_t ignoreFlags=0);
static void LinInterp(const hsMatrix33 *k1, const hsMatrix33 *k2, const hsScalar t, hsMatrix33 *result, uint32_t ignoreFlags=0);
static void LinInterp(const hsMatrix44 *mat1, const hsMatrix44 *mat2, const hsScalar t, hsMatrix44 *out, uint32_t ignoreFlags=0);
static void LinInterp(const hsQuat *k1, const hsQuat *k2, const hsScalar t, hsQuat *result);
static void LinInterp(const hsScaleValue *k1, const hsScaleValue *k2, const hsScalar t, hsScaleValue *result);
static void LinInterp(const hsAffineParts *k1, const hsAffineParts *k2, const hsScalar t, hsAffineParts *result, uint32_t ignoreFlags=0);
static void LinInterp(const float k1, const float k2, const float t, float *result);
static void LinInterp(const hsScalarTriple *k1, const hsScalarTriple *k2, const float t, hsScalarTriple *result);
static void LinInterp(const hsColorRGBA *k1, const hsColorRGBA *k2, const float t, hsColorRGBA *result, uint32_t ignoreFlags=0);
static void LinInterp(const hsMatrix33 *k1, const hsMatrix33 *k2, const float t, hsMatrix33 *result, uint32_t ignoreFlags=0);
static void LinInterp(const hsMatrix44 *mat1, const hsMatrix44 *mat2, const float t, hsMatrix44 *out, uint32_t ignoreFlags=0);
static void LinInterp(const hsQuat *k1, const hsQuat *k2, const float t, hsQuat *result);
static void LinInterp(const hsScaleValue *k1, const hsScaleValue *k2, const float t, hsScaleValue *result);
static void LinInterp(const hsAffineParts *k1, const hsAffineParts *k2, const float t, hsAffineParts *result, uint32_t ignoreFlags=0);
// Given a time value, find the enclosing keyframes and normalize time (0-1)
static void GetBoundaryKeyFrames(hsScalar time, uint32_t numKeys, void *keys,
uint32_t keySize, hsKeyFrame **kF1, hsKeyFrame **kF2, uint32_t *lastKeyIdx, hsScalar *p, hsBool forwards);
static void GetBoundaryKeyFrames(float time, uint32_t numKeys, void *keys,
uint32_t keySize, hsKeyFrame **kF1, hsKeyFrame **kF2, uint32_t *lastKeyIdx, float *p, hsBool forwards);
};

View File

@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "hsKeys.h"
#include "hsStream.h"
#include <math.h>
const int hsKeyFrame::kMaxFrameNumber = 65535;
@ -149,8 +150,8 @@ hsBool hsQuatKey::CompareValue(hsQuatKey *key)
//////////////////////////////////////////////////////////////////////////////
const hsScalar hsCompressedQuatKey32::kOneOverRootTwo = 0.70710678;
const hsScalar hsCompressedQuatKey32::k10BitScaleRange = 1023 / (2 * kOneOverRootTwo);
const float hsCompressedQuatKey32::kOneOverRootTwo = 0.70710678;
const float hsCompressedQuatKey32::k10BitScaleRange = 1023 / (2 * kOneOverRootTwo);
void hsCompressedQuatKey32::Read(hsStream *stream)
{
@ -178,7 +179,7 @@ void hsCompressedQuatKey32::SetQuat(hsQuat &q)
{
q.Normalize();
uint32_t maxElement = kCompQuatNukeX;
hsScalar maxVal = hsABS(q.fX);
float maxVal = hsABS(q.fX);
if (hsABS(q.fY) > maxVal)
{
maxElement = kCompQuatNukeY;
@ -256,7 +257,7 @@ void hsCompressedQuatKey32::GetQuat(hsQuat &q)
q.fY = (fData >> 20 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fZ = (fData >> 10 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fW = (fData & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fX = hsSquareRoot(1 - q.fY * q.fY - q.fZ * q.fZ - q.fW *q.fW);
q.fX = sqrt(1 - q.fY * q.fY - q.fZ * q.fZ - q.fW *q.fW);
break;
}
case kCompQuatNukeY:
@ -264,7 +265,7 @@ void hsCompressedQuatKey32::GetQuat(hsQuat &q)
q.fX = (fData >> 20 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fZ = (fData >> 10 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fW = (fData & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fY = hsSquareRoot(1 - q.fX * q.fX - q.fZ * q.fZ - q.fW *q.fW);
q.fY = sqrt(1 - q.fX * q.fX - q.fZ * q.fZ - q.fW *q.fW);
break;
}
case kCompQuatNukeZ:
@ -272,7 +273,7 @@ void hsCompressedQuatKey32::GetQuat(hsQuat &q)
q.fX = (fData >> 20 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fY = (fData >> 10 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fW = (fData & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fZ = hsSquareRoot(1 - q.fX * q.fX - q.fY * q.fY - q.fW *q.fW);
q.fZ = sqrt(1 - q.fX * q.fX - q.fY * q.fY - q.fW *q.fW);
break;
}
case kCompQuatNukeW:
@ -281,7 +282,7 @@ void hsCompressedQuatKey32::GetQuat(hsQuat &q)
q.fX = (fData >> 20 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fY = (fData >> 10 & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fZ = (fData & 0x000003ff) / k10BitScaleRange - kOneOverRootTwo;
q.fW = hsSquareRoot(1 - q.fX * q.fX - q.fY * q.fY - q.fZ * q.fZ);
q.fW = sqrt(1 - q.fX * q.fX - q.fY * q.fY - q.fZ * q.fZ);
break;
}
}
@ -289,9 +290,9 @@ void hsCompressedQuatKey32::GetQuat(hsQuat &q)
/////////////////////////////////////////////////////////////////////////////
const hsScalar hsCompressedQuatKey64::kOneOverRootTwo = 0.70710678;
const hsScalar hsCompressedQuatKey64::k20BitScaleRange = 1048575 / (2 * kOneOverRootTwo);
const hsScalar hsCompressedQuatKey64::k21BitScaleRange = 2097151 / (2 * kOneOverRootTwo);
const float hsCompressedQuatKey64::kOneOverRootTwo = 0.70710678;
const float hsCompressedQuatKey64::k20BitScaleRange = 1048575 / (2 * kOneOverRootTwo);
const float hsCompressedQuatKey64::k21BitScaleRange = 2097151 / (2 * kOneOverRootTwo);
void hsCompressedQuatKey64::Read(hsStream *stream)
{
@ -321,7 +322,7 @@ void hsCompressedQuatKey64::SetQuat(hsQuat &q)
{
q.Normalize();
uint32_t maxElement = kCompQuatNukeX;
hsScalar maxVal = hsABS(q.fX);
float maxVal = hsABS(q.fX);
if (hsABS(q.fY) > maxVal)
{
maxElement = kCompQuatNukeY;
@ -407,7 +408,7 @@ void hsCompressedQuatKey64::GetQuat(hsQuat &q)
q.fY = ((fData[0] >> 10) & 0x000fffff) / k20BitScaleRange - kOneOverRootTwo;
q.fZ = (((fData[0] & 0x000003ff) << 11) | (fData[1] >> 21)) / k21BitScaleRange - kOneOverRootTwo;
q.fW = (fData[1] & 0x001fffff) / k21BitScaleRange - kOneOverRootTwo;
q.fX = hsSquareRoot(1 - q.fY * q.fY - q.fZ * q.fZ - q.fW *q.fW);
q.fX = sqrt(1 - q.fY * q.fY - q.fZ * q.fZ - q.fW *q.fW);
break;
}
case kCompQuatNukeY:
@ -415,7 +416,7 @@ void hsCompressedQuatKey64::GetQuat(hsQuat &q)
q.fX = ((fData[0] >> 10) & 0x000fffff) / k20BitScaleRange - kOneOverRootTwo;
q.fZ = (((fData[0] & 0x000003ff) << 11) | (fData[1] >> 21)) / k21BitScaleRange - kOneOverRootTwo;
q.fW = (fData[1] & 0x001fffff) / k21BitScaleRange - kOneOverRootTwo;
q.fY = hsSquareRoot(1 - q.fX * q.fX - q.fZ * q.fZ - q.fW *q.fW);
q.fY = sqrt(1 - q.fX * q.fX - q.fZ * q.fZ - q.fW *q.fW);
break;
}
case kCompQuatNukeZ:
@ -423,7 +424,7 @@ void hsCompressedQuatKey64::GetQuat(hsQuat &q)
q.fX = ((fData[0] >> 10) & 0x000fffff) / k20BitScaleRange - kOneOverRootTwo;
q.fY = (((fData[0] & 0x000003ff) << 11) | (fData[1] >> 21)) / k21BitScaleRange - kOneOverRootTwo;
q.fW = (fData[1] & 0x001fffff) / k21BitScaleRange - kOneOverRootTwo;
q.fZ = hsSquareRoot(1 - q.fX * q.fX - q.fY * q.fY - q.fW *q.fW);
q.fZ = sqrt(1 - q.fX * q.fX - q.fY * q.fY - q.fW *q.fW);
break;
}
case kCompQuatNukeW:
@ -432,7 +433,7 @@ void hsCompressedQuatKey64::GetQuat(hsQuat &q)
q.fX = ((fData[0] >> 10) & 0x000fffff) / k20BitScaleRange - kOneOverRootTwo;
q.fY = (((fData[0] & 0x000003ff) << 11) | (fData[1] >> 21)) / k21BitScaleRange - kOneOverRootTwo;
q.fZ = (fData[1] & 0x001fffff) / k21BitScaleRange - kOneOverRootTwo;
q.fW = hsSquareRoot(1 - q.fX * q.fX - q.fY * q.fY - q.fZ * q.fZ);
q.fW = sqrt(1 - q.fX * q.fX - q.fY * q.fY - q.fZ * q.fZ);
break;
}
}

View File

@ -98,7 +98,7 @@ struct hsBezPoint3Key : public hsKeyFrame
struct hsScalarKey : public hsKeyFrame
{
hsScalar fValue;
float fValue;
void Read(hsStream *stream);
void Write(hsStream *stream);
@ -108,9 +108,9 @@ struct hsScalarKey : public hsKeyFrame
struct hsBezScalarKey : public hsKeyFrame
{
hsScalar fInTan;
hsScalar fOutTan;
hsScalar fValue;
float fInTan;
float fOutTan;
float fValue;
void Read(hsStream *stream);
void Write(hsStream *stream);
@ -138,8 +138,8 @@ struct hsCompressedQuatKey32 : public hsKeyFrame
kCompQuatNukeW,
};
static const hsScalar kOneOverRootTwo;
static const hsScalar k10BitScaleRange;
static const float kOneOverRootTwo;
static const float k10BitScaleRange;
void SetQuat(hsQuat &q);
void GetQuat(hsQuat &q);
@ -163,9 +163,9 @@ struct hsCompressedQuatKey64 : public hsKeyFrame
kCompQuatNukeW,
};
static const hsScalar kOneOverRootTwo;
static const hsScalar k20BitScaleRange;
static const hsScalar k21BitScaleRange;
static const float kOneOverRootTwo;
static const float k20BitScaleRange;
static const float k21BitScaleRange;
void SetQuat(hsQuat &q);
void GetQuat(hsQuat &q);

View File

@ -54,8 +54,8 @@ public:
};
protected:
uint32_t fFlags;
hsScalar fDuration;
hsScalar fStartTime;
float fDuration;
float fStartTime;
T fValue;
T fGoal;
@ -67,8 +67,8 @@ public:
uint32_t GetFlags() { return fFlags; }
void SetDuration(hsScalar duration);
hsScalar GetDuration() const { return fDuration; }
void SetDuration(float duration);
float GetDuration() const { return fDuration; }
hsBool32 operator==(const hsTimedValue<T>& v);
hsTimedValue<T>& operator=(const T& v) { SetValue(v); return *this; }
@ -83,22 +83,22 @@ public:
void Reset() { fFlags |= (kIdle | kInstant); }
void StartClock(hsScalar s);
hsScalar GetStartTime() const { return fStartTime; }
void StartClock(float s);
float GetStartTime() const { return fStartTime; }
const T& GetFrom() const { return fFrom; }
void Update(hsScalar s);
void Update(float s);
void WriteScalar(hsStream* s, hsScalar currSecs);
void Write(hsStream* s, hsScalar currSecs);
void WriteScalar(hsStream* s, float currSecs);
void Write(hsStream* s, float currSecs);
void ReadScalar(hsStream* s, hsScalar currSecs);
void Read(hsStream* s, hsScalar currSecs);
void ReadScalar(hsStream* s, float currSecs);
void Read(hsStream* s, float currSecs);
};
template <class T>
void hsTimedValue<T>::WriteScalar(hsStream* s, hsScalar currSecs)
void hsTimedValue<T>::WriteScalar(hsStream* s, float currSecs)
{
s->WriteLE32(fFlags);
@ -115,7 +115,7 @@ void hsTimedValue<T>::WriteScalar(hsStream* s, hsScalar currSecs)
}
template <class T>
void hsTimedValue<T>::Write(hsStream* s, hsScalar currSecs)
void hsTimedValue<T>::Write(hsStream* s, float currSecs)
{
s->WriteLE32(fFlags);
@ -132,7 +132,7 @@ void hsTimedValue<T>::Write(hsStream* s, hsScalar currSecs)
}
template <class T>
void hsTimedValue<T>::ReadScalar(hsStream* s, hsScalar currSecs)
void hsTimedValue<T>::ReadScalar(hsStream* s, float currSecs)
{
fFlags = s->ReadLE32();
@ -149,7 +149,7 @@ void hsTimedValue<T>::ReadScalar(hsStream* s, hsScalar currSecs)
}
template <class T>
void hsTimedValue<T>::Read(hsStream* s, hsScalar currSecs)
void hsTimedValue<T>::Read(hsStream* s, float currSecs)
{
fFlags = s->ReadLE32();
@ -166,7 +166,7 @@ void hsTimedValue<T>::Read(hsStream* s, hsScalar currSecs)
}
template <class T>
void hsTimedValue<T>::SetDuration(hsScalar duration)
void hsTimedValue<T>::SetDuration(float duration)
{
fDuration = duration;
if( fDuration > 0 )
@ -192,7 +192,7 @@ hsBool32 hsTimedValue<T>::operator==(const hsTimedValue<T>& v)
}
template <class T>
void hsTimedValue<T>::StartClock(hsScalar s)
void hsTimedValue<T>::StartClock(float s)
{
fStartTime = s;
@ -212,19 +212,19 @@ void hsTimedValue<T>::StartClock(hsScalar s)
}
template <class T>
void hsTimedValue<T>::Update(hsScalar s)
void hsTimedValue<T>::Update(float s)
{
if( fFlags & kIdle )
return;
hsAssert(fDuration > 0, "Instant should always be idle");
hsScalar interp = (s - fStartTime) / fDuration;
float interp = (s - fStartTime) / fDuration;
if( interp >= hsScalar1 )
if( interp >= 1.f )
{
fValue = fGoal;
interp = hsScalar1;
interp = 1.f;
fFlags |= kIdle;
}
else

View File

@ -44,8 +44,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
///////////////////////////////////////////////////////////////////////////////////////////////
plATCEaseCurve *plATCEaseCurve::CreateEaseCurve(uint8_t type, hsScalar minLength, hsScalar maxLength, hsScalar length,
hsScalar startSpeed, hsScalar goalSpeed)
plATCEaseCurve *plATCEaseCurve::CreateEaseCurve(uint8_t type, float minLength, float maxLength, float length,
float startSpeed, float goalSpeed)
{
if (type == plAnimEaseTypes::kConstAccel)
return TRACKED_NEW plConstAccelEaseCurve(minLength, maxLength, length, startSpeed, goalSpeed);
@ -55,9 +55,9 @@ plATCEaseCurve *plATCEaseCurve::CreateEaseCurve(uint8_t type, hsScalar minLength
return nil;
}
void plATCEaseCurve::RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, hsBool preserveRate /* = false */)
void plATCEaseCurve::RecalcToSpeed(float startSpeed, float goalSpeed, hsBool preserveRate /* = false */)
{
hsScalar rate = 1;
float rate = 1;
if (fSpeed == goalSpeed && fStartSpeed == startSpeed) // already there, no need to do anything
return;
@ -72,45 +72,45 @@ void plATCEaseCurve::RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, hsBo
SetLengthOnRate(rate);
}
void plATCEaseCurve::SetLengthOnRate(hsScalar rate)
void plATCEaseCurve::SetLengthOnRate(float rate)
{
fLength = (fSpeed - fStartSpeed) / rate;
if (fLength < 0)
fLength = -fLength;
}
hsScalar plATCEaseCurve::GetMinDistance()
float plATCEaseCurve::GetMinDistance()
{
if (fMinLength == 0)
return 0;
hsScalar oldLength = fLength;
float oldLength = fLength;
fLength = fMinLength;
hsScalar result = PositionGivenTime(fMinLength);
float result = PositionGivenTime(fMinLength);
fLength = oldLength;
return result;
}
hsScalar plATCEaseCurve::GetMaxDistance()
float plATCEaseCurve::GetMaxDistance()
{
if (fMaxLength == 0)
return 0;
hsScalar oldLength = fLength;
float oldLength = fLength;
fLength = fMaxLength;
hsScalar result = PositionGivenTime(fMaxLength);
float result = PositionGivenTime(fMaxLength);
fLength = oldLength;
return result;
}
hsScalar plATCEaseCurve::GetNormDistance()
float plATCEaseCurve::GetNormDistance()
{
if (fNormLength == 0)
return 0;
hsScalar oldLength = fLength;
float oldLength = fLength;
fLength = fNormLength;
hsScalar result = PositionGivenTime(fNormLength);
float result = PositionGivenTime(fNormLength);
fLength = oldLength;
return result;
}
@ -149,8 +149,8 @@ plConstAccelEaseCurve::plConstAccelEaseCurve()
RecalcToSpeed(0, 1);
}
plConstAccelEaseCurve::plConstAccelEaseCurve(hsScalar minLength, hsScalar maxLength, hsScalar length,
hsScalar startSpeed, hsScalar goalSpeed)
plConstAccelEaseCurve::plConstAccelEaseCurve(float minLength, float maxLength, float length,
float startSpeed, float goalSpeed)
{
fMinLength = minLength;
fMaxLength = maxLength;
@ -174,22 +174,22 @@ plATCEaseCurve *plConstAccelEaseCurve::Clone() const
return curve;
}
void plConstAccelEaseCurve::SetLengthOnDistance(hsScalar dist)
void plConstAccelEaseCurve::SetLengthOnDistance(float dist)
{
fLength = 2 * dist / (fSpeed + fStartSpeed);
}
hsScalar plConstAccelEaseCurve::PositionGivenTime(hsScalar time) const
float plConstAccelEaseCurve::PositionGivenTime(float time) const
{
return (hsScalar)(fStartSpeed * time + (0.5 * (fSpeed - fStartSpeed) / fLength) * time * time);
return (float)(fStartSpeed * time + (0.5 * (fSpeed - fStartSpeed) / fLength) * time * time);
}
hsScalar plConstAccelEaseCurve::VelocityGivenTime(hsScalar time) const
float plConstAccelEaseCurve::VelocityGivenTime(float time) const
{
return fStartSpeed + ((fSpeed - fStartSpeed) / fLength) * time;
}
hsScalar plConstAccelEaseCurve::TimeGivenVelocity(hsScalar velocity) const
float plConstAccelEaseCurve::TimeGivenVelocity(float velocity) const
{
return (velocity - fStartSpeed) / ((fSpeed - fStartSpeed) / fLength);
}
@ -204,8 +204,8 @@ plSplineEaseCurve::plSplineEaseCurve()
RecalcToSpeed(0, 1);
}
plSplineEaseCurve::plSplineEaseCurve(hsScalar minLength, hsScalar maxLength, hsScalar length,
hsScalar startSpeed, hsScalar goalSpeed)
plSplineEaseCurve::plSplineEaseCurve(float minLength, float maxLength, float length,
float startSpeed, float goalSpeed)
{
fMinLength = minLength;
fMaxLength = maxLength;
@ -233,7 +233,7 @@ plATCEaseCurve *plSplineEaseCurve::Clone() const
return curve;
}
void plSplineEaseCurve::RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, hsBool preserveRate /* = false */)
void plSplineEaseCurve::RecalcToSpeed(float startSpeed, float goalSpeed, hsBool preserveRate /* = false */)
{
plATCEaseCurve::RecalcToSpeed(startSpeed, goalSpeed, preserveRate);
@ -241,7 +241,7 @@ void plSplineEaseCurve::RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, h
// Note: "b" is always zero for the ease splines we're currently doing (and will remain that way
// so long as the initial acceleration is zero. Can optimize a bit of the eval math to take
// advantage of this.
hsScalar a, b, c, d;
float a, b, c, d;
a = fStartSpeed;
b = 0;
@ -254,16 +254,16 @@ void plSplineEaseCurve::RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, h
fCoef[3] = d;
}
void plSplineEaseCurve::SetLengthOnDistance(hsScalar dist)
void plSplineEaseCurve::SetLengthOnDistance(float dist)
{
hsScalar curDist = PositionGivenTime(fLength);
float curDist = PositionGivenTime(fLength);
fLength = fLength * dist / curDist;
}
hsScalar plSplineEaseCurve::PositionGivenTime(hsScalar time) const
float plSplineEaseCurve::PositionGivenTime(float time) const
{
hsScalar t1, t2, t3, t4;
float t1, t2, t3, t4;
t1 = time / fLength;
t2 = t1 * t1;
t3 = t2 * t1;
@ -272,53 +272,53 @@ hsScalar plSplineEaseCurve::PositionGivenTime(hsScalar time) const
return fLength * (fCoef[0] * t1 + fCoef[1] * t2 / 2 + fCoef[2] * t3 / 3 + fCoef[3] * t4 / 4);
}
hsScalar plSplineEaseCurve::VelocityGivenTime(hsScalar time) const
float plSplineEaseCurve::VelocityGivenTime(float time) const
{
hsScalar t1, t2, t3;
float t1, t2, t3;
t1 = time / fLength;
t2 = t1 * t1;
t3 = t2 * t1;
return fCoef[0] + fCoef[1] * t1 + fCoef[2] * t2 + fCoef[3] * t3;
}
hsScalar plSplineEaseCurve::TimeGivenVelocity(hsScalar velocity) const
float plSplineEaseCurve::TimeGivenVelocity(float velocity) const
{
// Code based off of Graphics Gems V, pp 11-12 and
// http://www.worldserver.com/turk/opensource/FindCubicRoots.c.txt
// Solving the equation: fCoef[0] + fCoef[1] * t + fCoef[2] * t^2 + fCoef[3] * t^3 - velocity = 0
hsScalar root;
hsScalar a = (fCoef[0] - velocity) / fCoef[3];
hsScalar b = fCoef[1] / fCoef[3];
hsScalar c = fCoef[2] / fCoef[3];
float root;
float a = (fCoef[0] - velocity) / fCoef[3];
float b = fCoef[1] / fCoef[3];
float c = fCoef[2] / fCoef[3];
hsScalar Q = (c * c - 3 * b) / 9;
hsScalar R = (2 * c * c * c - 9 * c * b + 27 * a) / 54;
hsScalar Q3 = Q * Q * Q;
hsScalar D = Q3 - R * R;
float Q = (c * c - 3 * b) / 9;
float R = (2 * c * c * c - 9 * c * b + 27 * a) / 54;
float Q3 = Q * Q * Q;
float D = Q3 - R * R;
if (D >= 0)
{
// 3 roots, find the one in the range [0, 1]
const hsScalar pi = 3.14159;
const float pi = 3.14159;
double theta = acos(R / sqrt(Q3));
double sqrtQ = sqrt(Q);
root = (hsScalar)(-2 * sqrtQ * cos((theta + 4 * pi) / 3) - c / 3); // Middle root, most likely to match
root = (float)(-2 * sqrtQ * cos((theta + 4 * pi) / 3) - c / 3); // Middle root, most likely to match
if (root < 0.f || root > 1.f)
{
root = (hsScalar)(-2 * sqrtQ * cos((theta + 2 * pi) / 3) - c / 3); // Lower root
root = (float)(-2 * sqrtQ * cos((theta + 2 * pi) / 3) - c / 3); // Lower root
if (root < 0.f || root > 1.f)
{
root = (hsScalar)(-2 * sqrtQ * cos(theta / 3) - c / 3); // Upper root
root = (float)(-2 * sqrtQ * cos(theta / 3) - c / 3); // Upper root
}
}
}
else // One root to the equation (I don't expect this to happen for ease splines, but JIC)
{
double E = sqrt(-D) + pow(fabs(R), 1.f / 3.f);
root = (hsScalar)((E + Q / E) - c / 3);
root = (float)((E + Q / E) - c / 3);
if (R > 0)
root = -root;
}
@ -328,10 +328,10 @@ hsScalar plSplineEaseCurve::TimeGivenVelocity(hsScalar velocity) const
hsAssert(false, "No valid root found while solving animation spline");
// Either a bug, or a rare case of floating-point inaccuracy. Either way, guess
// the proper root as either the start or end of the curve based on the velocity.
hsScalar dStart = velocity - fStartSpeed;
float dStart = velocity - fStartSpeed;
if (dStart < 0)
dStart = -dStart;
hsScalar dEnd = velocity - fSpeed;
float dEnd = velocity - fSpeed;
if (dEnd < 0)
dEnd = -dEnd;

View File

@ -45,11 +45,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plController.h"
#include "hsFastMath.h"
#include "hsResMgr.h"
#include <math.h>
const hsScalar kSmallDelTime = 1.e-2f;
const hsScalar kInvSmallDelTime = 1.f / kSmallDelTime;
const hsScalar kTerminateDelTime = 1.e-3f;
const hsScalar kTerminateDelDistSq = .1f;
const float kSmallDelTime = 1.e-2f;
const float kInvSmallDelTime = 1.f / kSmallDelTime;
const float kTerminateDelTime = 1.e-3f;
const float kTerminateDelDistSq = .1f;
plAnimPath::plAnimPath()
: fController(nil), fLength(0), fMinDistSq(0),
@ -70,7 +71,7 @@ void plAnimPath::Reset()
SetCurTime(0);
}
void plAnimPath::SetCurTime(hsScalar t, uint32_t calcFlags)
void plAnimPath::SetCurTime(float t, uint32_t calcFlags)
{
fTime = t;
if( !fController )
@ -82,7 +83,7 @@ void plAnimPath::SetCurTime(hsScalar t, uint32_t calcFlags)
return;
}
hsScalar t0, t1, t2;
float t0, t1, t2;
if( t < kSmallDelTime )
{
@ -144,7 +145,7 @@ void plAnimPath::ICalcBounds()
int i;
hsPoint3 pos;
hsTArray<hsScalar> keyTimes;
hsTArray<float> keyTimes;
pc->GetKeyTimes(keyTimes);
fCenter.Set(0,0,0);
for( i = 0; i < keyTimes.GetCount() ; i++ )
@ -152,19 +153,19 @@ void plAnimPath::ICalcBounds()
pc->Interp(keyTimes[i], &pos);
fCenter += pos;
}
fCenter *= hsScalarInvert((hsScalar)keyTimes.GetCount());
fCenter *= hsInvert((float)keyTimes.GetCount());
fRadius = 0;
for( i = 0; i < keyTimes.GetCount(); i++ )
{
pc->Interp(keyTimes[i], &pos);
hsScalar rad = (pos - fCenter).Magnitude();
float rad = (pos - fCenter).Magnitude();
if( rad > fRadius )
fRadius = rad;
}
}
hsScalar plAnimPath::ICalcTotalLength()
float plAnimPath::ICalcTotalLength()
{
if( !(fController && fController->GetPosController()) )
return 0;
@ -183,6 +184,11 @@ void plAnimPath::SetController(plCompoundController* tmc)
ICalcBounds();
}
float plAnimPath::GetMinDistance() const
{
return sqrt(fMinDistSq);
}
void plAnimPath::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
{
fLocalToWorld = l2w;
@ -224,15 +230,15 @@ void plAnimPath::Write(hsStream* stream, hsResMgr* mgr)
stream->WriteLEScalar(fMinDistSq);
}
hsBool plAnimPath::OutOfRange(hsPoint3 &worldPt, hsScalar range) const
hsBool plAnimPath::OutOfRange(hsPoint3 &worldPt, float range) const
{
hsPoint3 pt = fWorldToLocal * worldPt;
hsScalar radius = (pt - fCenter).Magnitude() - fRadius;
float radius = (pt - fCenter).Magnitude() - fRadius;
return( radius > range );
}
hsScalar plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const
float plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const
{
if( !fController )
return 0;
@ -241,18 +247,18 @@ hsScalar plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const
plController *pc = fController->GetPosController();
hsScalar minDistSq = 1.e33f;
hsScalar minTime = 0, delTime = 0;
float minDistSq = 1.e33f;
float minTime = 0, delTime = 0;
// start search by using the time of the closest ctrl point
int i;
hsTArray<hsScalar> keyTimes;
hsTArray<float> keyTimes;
pc->GetKeyTimes(keyTimes);
for( i = 0; i < keyTimes.GetCount(); i++ )
{
hsScalar t = keyTimes[i];
float t = keyTimes[i];
hsPoint3 pos;
pc->Interp(t, &pos); // handles easing
hsScalar distSq = (pt - pos).MagnitudeSquared();
float distSq = (pt - pos).MagnitudeSquared();
if( distSq < minDistSq )
{
minDistSq = distSq;
@ -263,8 +269,8 @@ hsScalar plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const
delTime = t - keyTimes[i - 1];
else
{
hsScalar fore = keyTimes[i + 1] - t;
hsScalar back = t - keyTimes[i - 1];
float fore = keyTimes[i + 1] - t;
float back = t - keyTimes[i - 1];
delTime = hsMaximum(fore, back);
}
}
@ -273,7 +279,7 @@ hsScalar plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const
return GetExtremePoint(minTime, delTime, worldPt);
}
hsScalar plAnimPath::GetExtremePoint(hsScalar lastTime, hsScalar delTime, hsPoint3 &worldPt) const
float plAnimPath::GetExtremePoint(float lastTime, float delTime, hsPoint3 &worldPt) const
{
if( !fController )
return 0;
@ -284,7 +290,7 @@ hsScalar plAnimPath::GetExtremePoint(hsScalar lastTime, hsScalar delTime, hsPoin
return ICheckInterval(pt);
}
hsScalar plAnimPath::ICheckInterval(hsPoint3 &pt) const
float plAnimPath::ICheckInterval(hsPoint3 &pt) const
{
if( fDelTime <= kTerminateDelTime &&
hsVector3(&fCurPos, &fPrevPos).MagnitudeSquared() < kTerminateDelDistSq)
@ -331,7 +337,7 @@ hsScalar plAnimPath::ICheckInterval(hsPoint3 &pt) const
return 0;
}
void plAnimPath::IInitInterval(hsScalar time, hsScalar delTime, hsPoint3 &pt) const
void plAnimPath::IInitInterval(float time, float delTime, hsPoint3 &pt) const
{
plController* pc = fController->GetPosController();
@ -395,7 +401,7 @@ void plAnimPath::IInitInterval(hsScalar time, hsScalar delTime, hsPoint3 &pt) co
}
}
hsScalar plAnimPath::ISubDivBack(hsPoint3 &pt) const
float plAnimPath::ISubDivBack(hsPoint3 &pt) const
{
fNextTime = fThisTime;
fNextDistSq = fThisDistSq;
@ -419,7 +425,7 @@ hsScalar plAnimPath::ISubDivBack(hsPoint3 &pt) const
return ICheckInterval(pt);
}
hsScalar plAnimPath::ISubDivFore(hsPoint3 &pt) const
float plAnimPath::ISubDivFore(hsPoint3 &pt) const
{
fLastTime = fThisTime;
fLastDistSq = fThisDistSq;
@ -443,7 +449,7 @@ hsScalar plAnimPath::ISubDivFore(hsPoint3 &pt) const
return ICheckInterval(pt);
}
hsScalar plAnimPath::IShiftBack(hsPoint3 &pt) const
float plAnimPath::IShiftBack(hsPoint3 &pt) const
{
if( !GetWrap() && (fLastTime <= 0) )
return ISubDivBack(pt);
@ -470,7 +476,7 @@ hsScalar plAnimPath::IShiftBack(hsPoint3 &pt) const
return ICheckInterval(pt);
}
hsScalar plAnimPath::IShiftFore(hsPoint3 &pt) const
float plAnimPath::IShiftFore(hsPoint3 &pt) const
{
if( !GetWrap() &&(fNextTime >= fLength) )
return ISubDivFore(pt);
@ -509,10 +515,10 @@ void plAnimPath::IMakeSegment(hsTArray<uint16_t>& idx, hsTArray<hsPoint3>& pos,
hsVector3 up;
up.Set(0,0,1.f);
const hsScalar kOutLength = 0.25f;
const float kOutLength = 0.25f;
hsVector3 a = del % up;
hsScalar magSq = a.MagnitudeSquared();
float magSq = a.MagnitudeSquared();
if( magSq < 1.e-3f )
{
a.Set(kOutLength, 0, 0);
@ -585,12 +591,12 @@ void plAnimPath::MakeDrawList(hsTArray<uint16_t>& idx, hsTArray<hsPoint3>& pos)
ident.Reset();
SetTransform(ident, ident);
hsScalar numSegs = fRadius; // crude estimate of arclength
float numSegs = fRadius; // crude estimate of arclength
if (numSegs>100)
numSegs=100;
hsScalar animLen = GetLength();
hsScalar timeInc = animLen/numSegs;
hsScalar time=0;
float animLen = GetLength();
float timeInc = animLen/numSegs;
float time=0;
hsPoint3 p1, p2;
SetCurTime(0, kCalcPosOnly);
@ -631,9 +637,9 @@ void plAnimPath::ComputeArcLenDeltas(int32_t numSamples)
// compute arc len deltas
fArcLenDeltas.Reset();
fArcLenDeltas.SetCount(numSamples);
hsScalar animLen = GetLength();
hsScalar timeInc = animLen/(numSamples-1); // use num-1 since we'll create the zeroth entry by hand
hsScalar time=0;
float animLen = GetLength();
float timeInc = animLen/(numSamples-1); // use num-1 since we'll create the zeroth entry by hand
float time=0;
hsPoint3 p1, p2;
int32_t cnt=0;
@ -671,7 +677,7 @@ void plAnimPath::ComputeArcLenDeltas(int32_t numSamples)
// Returns time of point (at least) arcLength units away from point at startTime.
// Also sets strtSrchIdx for incremental searching.
//
hsScalar plAnimPath::GetLookAheadTime(hsScalar startTime, hsScalar arcLengthIn, hsBool bwd,
float plAnimPath::GetLookAheadTime(float startTime, float arcLengthIn, hsBool bwd,
int32_t* startSrchIdx)
{
if (arcLengthIn==0)
@ -685,7 +691,7 @@ hsScalar plAnimPath::GetLookAheadTime(hsScalar startTime, hsScalar arcLengthIn,
hsAssert(startSrchIdx, "nil var for startSrchIdx");
hsScalar oldTime=fTime;
float oldTime=fTime;
ComputeArcLenDeltas(); // precompute first time only
@ -736,14 +742,14 @@ hsScalar plAnimPath::GetLookAheadTime(hsScalar startTime, hsScalar arcLengthIn,
GetPosition(&pos); // startTime position
hsPoint3 pos2;
hsScalar endTime = fArcLenDeltas[nearestIdx].fT;
float endTime = fArcLenDeltas[nearestIdx].fT;
SetCurTime(endTime, kCalcPosOnly);
GetPosition(&pos2); // position at nearest sample point
hsScalar curArcLen = hsVector3(&pos2, &pos).Magnitude();
hsScalar curTime=0;
float curArcLen = hsVector3(&pos2, &pos).Magnitude();
float curTime=0;
hsBool quit=false;
hsScalar timeOut = 0;
float timeOut = 0;
int32_t inc = bwd ? -1 : 1;
// now sum distance deltas until we exceed the desired arcLen
if (curArcLen<arcLengthIn)
@ -777,7 +783,7 @@ hsScalar plAnimPath::GetLookAheadTime(hsScalar startTime, hsScalar arcLengthIn,
// interp remaining interval
// 1. compute necessary distToGoal
hsScalar distToGoal = arcLengthIn-curArcLen;
float distToGoal = arcLengthIn-curArcLen;
hsAssert(distToGoal, "0 length distToGoal?");
// 2. compute % of dist interval which gives distToGoal
@ -787,8 +793,8 @@ hsScalar plAnimPath::GetLookAheadTime(hsScalar startTime, hsScalar arcLengthIn,
SetCurTime(endTime, kCalcPosOnly);
GetPosition(&pos2);
hsScalar distInterval = hsVector3(&pos2, &pos).Magnitude();
hsScalar percent = distToGoal/distInterval;
float distInterval = hsVector3(&pos2, &pos).Magnitude();
float percent = distToGoal/distInterval;
hsAssert(percent>=0 && percent<=1, "illegal percent value");
// 3. compute interpolated time value using percent

View File

@ -70,12 +70,12 @@ protected:
hsPoint3 fPos;
hsVector3 fVel;
hsVector3 fAccel;
hsScalar fTime; // presumably seconds
float fTime; // presumably seconds
// The paramters (and options) for this curve.
uint32_t fAnimPathFlags; // currently set at runtime only
hsScalar fMinDistSq;
hsScalar fLength; // presumably seconds
float fMinDistSq;
float fLength; // presumably seconds
// Controller stuff only works in local space.
hsMatrix44 fLocalToWorld;
@ -83,31 +83,31 @@ protected:
// Bounding sphere available for ignoring out of range
hsPoint3 fCenter;
hsScalar fRadius;
float fRadius;
plCompoundController* fController;
hsAffineParts fParts;
// These are temps during a search. They're here to avoid recalc.
mutable hsScalar fLastTime;
mutable hsScalar fLastDistSq;
mutable hsScalar fThisTime;
mutable hsScalar fThisDistSq;
mutable hsScalar fNextTime;
mutable hsScalar fNextDistSq;
mutable hsScalar fDelTime;
mutable float fLastTime;
mutable float fLastDistSq;
mutable float fThisTime;
mutable float fThisDistSq;
mutable float fNextTime;
mutable float fNextDistSq;
mutable float fDelTime;
mutable hsPoint3 fPrevPos, fCurPos;
void ICalcBounds();
hsScalar ICalcTotalLength();
hsScalar IShiftFore(hsPoint3 &pt) const;
hsScalar IShiftBack(hsPoint3 &pt) const;
hsScalar ISubDivFore(hsPoint3 &pt) const;
hsScalar ISubDivBack(hsPoint3 &pt) const;
void IInitInterval(hsScalar time, hsScalar delTime, hsPoint3 &pt) const;
hsScalar ICheckInterval(hsPoint3 &pt) const;
hsScalar IBestTime() const { return fLastDistSq < fThisDistSq
float ICalcTotalLength();
float IShiftFore(hsPoint3 &pt) const;
float IShiftBack(hsPoint3 &pt) const;
float ISubDivFore(hsPoint3 &pt) const;
float ISubDivBack(hsPoint3 &pt) const;
void IInitInterval(float time, float delTime, hsPoint3 &pt) const;
float ICheckInterval(hsPoint3 &pt) const;
float IBestTime() const { return fLastDistSq < fThisDistSq
? (fLastDistSq < fNextDistSq
? fLastTime
: fNextTime)
@ -122,9 +122,9 @@ protected:
// For computing arclen
struct ArcLenDeltaInfo
{
hsScalar fT;
hsScalar fArcLenDelta; // arc len distance from prev sample point (array entry)
ArcLenDeltaInfo(hsScalar t, hsScalar del) : fT(t),fArcLenDelta(del) {}
float fT;
float fArcLenDelta; // arc len distance from prev sample point (array entry)
ArcLenDeltaInfo(float t, float del) : fT(t),fArcLenDelta(del) {}
ArcLenDeltaInfo() : fT(0),fArcLenDelta(0) {}
};
hsTArray<ArcLenDeltaInfo> fArcLenDeltas;
@ -153,15 +153,15 @@ public:
void SetFarthest(hsBool on) { if(on)fAnimPathFlags |= kFarthest; else fAnimPathFlags &= ~kFarthest; }
hsBool GetFarthest() const { return 0 != (fAnimPathFlags & kFarthest); }
void SetCurTime(hsScalar t, uint32_t calcFlags=0);
hsScalar GetCurTime() const { return fTime; }
void SetCurTime(float t, uint32_t calcFlags=0);
float GetCurTime() const { return fTime; }
void SetController(plCompoundController* tmc);
plCompoundController* GetController() const { return fController; }
hsScalar GetLength() const { return fLength; } // seconds
float GetLength() const { return fLength; } // seconds
void SetMinDistance(hsScalar d) { fMinDistSq = d*d; }
hsScalar GetMinDistance() const { return hsSquareRoot(fMinDistSq); }
void SetMinDistance(float d) { fMinDistSq = d*d; }
float GetMinDistance() const;
hsMatrix44* GetMatrix44(hsMatrix44* xOut) const { *xOut = fXform; return xOut; }
hsPoint3* GetPosition(hsPoint3* pOut) const { *pOut = fPos; return pOut; }
@ -170,16 +170,16 @@ public:
hsVector3* GetUp(hsVector3* uOut) const { uOut->Set(fXform.fMap[0][1], fXform.fMap[1][1], fXform.fMap[2][1]); return uOut; }
hsVector3* GetAcceleration(hsVector3* aOut) const { *aOut = fAccel; return aOut; }
hsBool OutOfRange(hsPoint3 &pt, hsScalar range) const;
hsBool OutOfRange(hsPoint3 &pt, float range) const;
const hsAffineParts* Parts() const { return &fParts; }
void InitParts(const hsAffineParts& p) { fParts = p; }
hsScalar GetExtremePoint(hsPoint3 &worldPt) const; // Exhaustive search
hsScalar GetExtremePoint(hsScalar lastTime, hsScalar delTime, hsPoint3 &worldPt) const; // Incremental search
float GetExtremePoint(hsPoint3 &worldPt) const; // Exhaustive search
float GetExtremePoint(float lastTime, float delTime, hsPoint3 &worldPt) const; // Incremental search
// for arclen usage
void ComputeArcLenDeltas(int32_t numSamples=256);
hsScalar GetLookAheadTime(hsScalar startTime, hsScalar arcLength, hsBool bwd, int32_t* startSrchIdx);
float GetLookAheadTime(float startTime, float arcLength, hsBool bwd, int32_t* startSrchIdx);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);

View File

@ -212,7 +212,7 @@ void plAnimTimeConvert::ResetWrap()
fFlags &= (~kWrap & ~kNeedsReset);
}
hsScalar plAnimTimeConvert::ICalcEaseTime(const plATCEaseCurve *curve, double start, double end)
float plAnimTimeConvert::ICalcEaseTime(const plATCEaseCurve *curve, double start, double end)
{
start -= curve->fBeginWorldTime;
end -= curve->fBeginWorldTime;
@ -224,12 +224,12 @@ hsScalar plAnimTimeConvert::ICalcEaseTime(const plATCEaseCurve *curve, double st
end = curve->fLength;
hsScalar delSecs = 0;
float delSecs = 0;
if (start < curve->fLength)
{
// Redundant eval... but only when easing.
delSecs = curve->PositionGivenTime((hsScalar)end) - curve->PositionGivenTime((hsScalar)start);
delSecs = curve->PositionGivenTime((float)end) - curve->PositionGivenTime((float)start);
}
return delSecs;
}
@ -244,7 +244,7 @@ void plAnimTimeConvert::IClearSpeedEase()
fSpeedEaseCurve = nil;
}
void plAnimTimeConvert::ICheckTimeCallbacks(hsScalar frameStart, hsScalar frameStop)
void plAnimTimeConvert::ICheckTimeCallbacks(float frameStart, float frameStop)
{
int i;
for( i = fCallbackMsgs.GetCount()-1; i >= 0; --i )
@ -262,7 +262,7 @@ void plAnimTimeConvert::ICheckTimeCallbacks(hsScalar frameStart, hsScalar frameS
}
}
hsBool plAnimTimeConvert::ITimeInFrame(hsScalar secs, hsScalar start, hsScalar stop)
hsBool plAnimTimeConvert::ITimeInFrame(float secs, float start, float stop)
{
if (secs == start && secs == stop)
return true;
@ -328,7 +328,7 @@ void plAnimTimeConvert::ISendCallback(int i)
}
}
plAnimTimeConvert& plAnimTimeConvert::IStop(double time, hsScalar animTime)
plAnimTimeConvert& plAnimTimeConvert::IStop(double time, float animTime)
{
if( IsStopped() )
return *this;
@ -352,7 +352,7 @@ plAnimTimeConvert& plAnimTimeConvert::IStop(double time, hsScalar animTime)
return *this;
}
plAnimTimeConvert& plAnimTimeConvert::IProcessStateChange(double worldTime, hsScalar animTime /* = -1 */)
plAnimTimeConvert& plAnimTimeConvert::IProcessStateChange(double worldTime, float animTime /* = -1 */)
{
if (fStates.size() > 0 && worldTime < fStates.front()->fStartWorldTime)
return *this; // Sorry... state saves only work in the forward direction
@ -468,11 +468,11 @@ hsBool plAnimTimeConvert::IsStoppedAt(double wSecs) const
return IIsStoppedAt(wSecs, state->fFlags, state->fEaseCurve);
}
hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
float plAnimTimeConvert::WorldToAnimTime(double wSecs)
{
//hsAssert(wSecs >= fLastEvalWorldTime, "Tried to eval a time that's earlier than the last eval time.");
double d = wSecs - fLastEvalWorldTime;
hsScalar f = fCurrentAnimTime;
float f = fCurrentAnimTime;
if (wSecs < fLastStateChange)
{
@ -505,8 +505,8 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
return fCurrentAnimTime;
}
hsScalar note = fCurrentAnimTime - f;
hsScalar secs = 0, delSecs = 0;
float note = fCurrentAnimTime - f;
float secs = 0, delSecs = 0;
if (fCurrentEaseCurve != nil)
{
@ -514,7 +514,7 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
if (wSecs > fCurrentEaseCurve->GetEndWorldTime())
{
if (fFlags & kEasingIn)
delSecs += hsScalar(wSecs - fCurrentEaseCurve->GetEndWorldTime()) * fSpeed;
delSecs += float(wSecs - fCurrentEaseCurve->GetEndWorldTime()) * fSpeed;
IClearSpeedEase();
@ -524,7 +524,7 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
else
{
// The easy case... playing the animation at a constant speed.
delSecs = hsScalar(wSecs - fLastEvalWorldTime) * fSpeed;
delSecs = float(wSecs - fLastEvalWorldTime) * fSpeed;
}
if (fFlags & kBackwards)
@ -617,12 +617,12 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
return fCurrentAnimTime = secs;
}
hsScalar plAnimTimeConvert::WorldToAnimTimeNoUpdate(double wSecs) const
float plAnimTimeConvert::WorldToAnimTimeNoUpdate(double wSecs) const
{
return IWorldToAnimTimeNoUpdate(wSecs, IGetState(wSecs));
}
hsScalar plAnimTimeConvert::IWorldToAnimTimeNoUpdate(double wSecs, plATCState *state)
float plAnimTimeConvert::IWorldToAnimTimeNoUpdate(double wSecs, plATCState *state)
{
//hsAssert(wSecs >= fLastEvalWorldTime, "Tried to eval a time that's earlier than the last eval time.");
if (state == nil)
@ -631,7 +631,7 @@ hsScalar plAnimTimeConvert::IWorldToAnimTimeNoUpdate(double wSecs, plATCState *s
if (state->fFlags & kStopped)
return state->fStartAnimTime;
hsScalar secs = 0, delSecs = 0;
float secs = 0, delSecs = 0;
if (state->fEaseCurve != nil)
{
@ -639,13 +639,13 @@ hsScalar plAnimTimeConvert::IWorldToAnimTimeNoUpdate(double wSecs, plATCState *s
if (wSecs > state->fEaseCurve->GetEndWorldTime())
{
if (state->fFlags & kEasingIn)
delSecs += hsScalar(wSecs - state->fEaseCurve->GetEndWorldTime()) * state->fSpeed;
delSecs += float(wSecs - state->fEaseCurve->GetEndWorldTime()) * state->fSpeed;
}
}
else
{
// The easy case... playing the animation at a constant speed.
delSecs = hsScalar(wSecs - state->fStartWorldTime) * state->fSpeed;
delSecs = float(wSecs - state->fStartWorldTime) * state->fSpeed;
}
if (state->fFlags & kBackwards)
@ -720,12 +720,12 @@ hsScalar plAnimTimeConvert::IWorldToAnimTimeNoUpdate(double wSecs, plATCState *s
return secs;
}
hsScalar plAnimTimeConvert::IWorldToAnimTimeBeforeState(double wSecs) const
float plAnimTimeConvert::IWorldToAnimTimeBeforeState(double wSecs) const
{
return IWorldToAnimTimeNoUpdate(wSecs, IGetState(wSecs));
}
void plAnimTimeConvert::SetCurrentAnimTime(hsScalar s, hsBool jump /* = false */)
void plAnimTimeConvert::SetCurrentAnimTime(float s, hsBool jump /* = false */)
{
// We're setting the anim value for whenever we last evaluated.
fFlags |= kForcedMove;
@ -743,7 +743,7 @@ void plAnimTimeConvert::SetCurrentAnimTime(hsScalar s, hsBool jump /* = false */
IProcessStateChange(hsTimer::GetSysSeconds(), fCurrentAnimTime);
}
void plAnimTimeConvert::SetEase(hsBool easeIn, uint8_t type, hsScalar minLength, hsScalar maxLength, hsScalar normLength)
void plAnimTimeConvert::SetEase(hsBool easeIn, uint8_t type, float minLength, float maxLength, float normLength)
{
if (easeIn)
{
@ -759,24 +759,24 @@ void plAnimTimeConvert::SetEase(hsBool easeIn, uint8_t type, hsScalar minLength,
hsScalar plAnimTimeConvert::GetBestStopDist(hsScalar min, hsScalar max, hsScalar norm, hsScalar time) const
float plAnimTimeConvert::GetBestStopDist(float min, float max, float norm, float time) const
{
hsScalar bestTime = -1;
hsScalar bestDist = -1;
float bestTime = -1;
float bestDist = -1;
if (fStopPoints.GetCount() == 0)
return norm;
hsScalar curTime;
hsScalar curDist;
float curTime;
float curDist;
int i;
for (i = 0; i < fStopPoints.GetCount(); i++)
{
hsScalar stop = fStopPoints.Get(i);
float stop = fStopPoints.Get(i);
if (IsLooped())
{
hsScalar loopDist;
float loopDist;
if (IsBackwards())
{
if ((time >= fLoopBegin && stop < fLoopBegin) ||
@ -841,9 +841,9 @@ hsScalar plAnimTimeConvert::GetBestStopDist(hsScalar min, hsScalar max, hsScalar
}
// Passing in a rate of zero specifies an immediate change.
void plAnimTimeConvert::SetSpeed(hsScalar goal, hsScalar rate /* = 0 */)
void plAnimTimeConvert::SetSpeed(float goal, float rate /* = 0 */)
{
hsScalar curSpeed = fSpeed;
float curSpeed = fSpeed;
fSpeed = goal;
@ -860,7 +860,7 @@ void plAnimTimeConvert::SetSpeed(hsScalar goal, hsScalar rate /* = 0 */)
if (fCurrentEaseCurve != nil)
{
double easeTime = curTime - fCurrentEaseCurve->fBeginWorldTime;
curSpeed = fCurrentEaseCurve->VelocityGivenTime((hsScalar)easeTime);
curSpeed = fCurrentEaseCurve->VelocityGivenTime((float)easeTime);
}
if (fSpeedEaseCurve != nil)
{
@ -869,7 +869,7 @@ void plAnimTimeConvert::SetSpeed(hsScalar goal, hsScalar rate /* = 0 */)
}
else
{
hsScalar length;
float length;
length = (goal - curSpeed) / rate;
if (length < 0)
length = -length;
@ -975,7 +975,7 @@ plAnimTimeConvert& plAnimTimeConvert::Stop(double stopTime)
if (stopTime < 0)
stopTime = hsTimer::GetSysSeconds();
hsScalar stopAnimTime = WorldToAnimTimeNoUpdate(stopTime);
float stopAnimTime = WorldToAnimTimeNoUpdate(stopTime);
SetFlag(kEasingIn, false);
@ -984,11 +984,11 @@ plAnimTimeConvert& plAnimTimeConvert::Stop(double stopTime)
return IStop(stopTime, fCurrentAnimTime);
}
hsScalar currSpeed;
float currSpeed;
if (fCurrentEaseCurve == nil || stopTime >= fCurrentEaseCurve->GetEndWorldTime())
currSpeed = fSpeed;
else
currSpeed = fCurrentEaseCurve->VelocityGivenTime((hsScalar)(stopTime - fCurrentEaseCurve->fBeginWorldTime));
currSpeed = fCurrentEaseCurve->VelocityGivenTime((float)(stopTime - fCurrentEaseCurve->fBeginWorldTime));
fEaseOutCurve->RecalcToSpeed(currSpeed > fSpeed ? currSpeed : fSpeed, 0);
fEaseOutCurve->SetLengthOnDistance(GetBestStopDist(fEaseOutCurve->GetMinDistance(), fEaseOutCurve->GetMaxDistance(),
@ -1013,11 +1013,11 @@ plAnimTimeConvert& plAnimTimeConvert::Start(double startTime)
if (fEaseInCurve != nil)
{
hsScalar currSpeed;
float currSpeed;
if (fCurrentEaseCurve == nil || startTime >= fCurrentEaseCurve->GetEndWorldTime())
currSpeed = 0;
else
currSpeed = fCurrentEaseCurve->VelocityGivenTime((hsScalar)(startTime - fCurrentEaseCurve->fBeginWorldTime));
currSpeed = fCurrentEaseCurve->VelocityGivenTime((float)(startTime - fCurrentEaseCurve->fBeginWorldTime));
if (currSpeed <= fSpeed)
{
@ -1119,7 +1119,7 @@ plAnimTimeConvert& plAnimTimeConvert::Loop(hsBool on)
return *this;
}
plAnimTimeConvert& plAnimTimeConvert::PlayToTime(hsScalar time)
plAnimTimeConvert& plAnimTimeConvert::PlayToTime(float time)
{
fFlags |= kNeedsReset;
if (fCurrentAnimTime > time)
@ -1144,7 +1144,7 @@ plAnimTimeConvert& plAnimTimeConvert::PlayToTime(hsScalar time)
return *this;
}
plAnimTimeConvert& plAnimTimeConvert::PlayToPercentage(hsScalar percent)
plAnimTimeConvert& plAnimTimeConvert::PlayToPercentage(float percent)
{
return PlayToTime(fBegin + (fEnd - fBegin) * percent);
}
@ -1280,7 +1280,7 @@ hsBool plAnimTimeConvert::HandleCmd(plAnimCmdMsg* modMsg)
if (fCurrentAnimTime == fEnd)
return true;
double currTime = hsTimer::GetSysSeconds();
hsScalar newTime = fCurrentAnimTime + hsTimer::GetDelSysSeconds();
float newTime = fCurrentAnimTime + hsTimer::GetDelSysSeconds();
if (newTime > fEnd)
{
newTime = fEnd;
@ -1293,7 +1293,7 @@ hsBool plAnimTimeConvert::HandleCmd(plAnimCmdMsg* modMsg)
if (fCurrentAnimTime == fBegin)
return true;
double currTime = hsTimer::GetSysSeconds();
hsScalar newTime = fCurrentAnimTime - hsTimer::GetDelSysSeconds();
float newTime = fCurrentAnimTime - hsTimer::GetDelSysSeconds();
if (newTime < fBegin)
{
newTime = fBegin;

View File

@ -64,13 +64,13 @@ class plAnimTimeConvert : public plCreatable
protected:
uint16_t fFlags;
hsScalar fBegin;
hsScalar fEnd;
hsScalar fLoopEnd;
hsScalar fLoopBegin;
hsScalar fSpeed;
hsScalar fCurrentAnimTime;
hsScalar fWrapTime;
float fBegin;
float fEnd;
float fLoopEnd;
float fLoopBegin;
float fSpeed;
float fCurrentAnimTime;
float fWrapTime;
double fLastEvalWorldTime;
// Do not change fLastEvalWorldTime anywhere except WorldToAnimTime()
@ -80,7 +80,7 @@ protected:
typedef std::list<plATCState *> plATCStateList;
plATCStateList fStates;
hsTArray<hsScalar> fStopPoints;
hsTArray<float> fStopPoints;
hsTArray<plEventCallbackMsg*> fCallbackMsgs;
/////////////////////////
@ -94,19 +94,19 @@ protected:
//
/////////////////////////
hsScalar fInitialBegin;
hsScalar fInitialEnd;
float fInitialBegin;
float fInitialEnd;
static hsScalar ICalcEaseTime(const plATCEaseCurve *curve, double start, double end);
static float ICalcEaseTime(const plATCEaseCurve *curve, double start, double end);
void IClearSpeedEase();
void ICheckTimeCallbacks(hsScalar frameStart, hsScalar frameStop);
hsBool ITimeInFrame(hsScalar secs, hsScalar start, hsScalar stop);
void ICheckTimeCallbacks(float frameStart, float frameStop);
hsBool ITimeInFrame(float secs, float start, float stop);
void ISendCallback(int i);
plAnimTimeConvert& IStop(double time, hsScalar animTime);
plAnimTimeConvert& IStop(double time, float animTime);
hsBool IIsStoppedAt(const double &wSecs, const uint32_t &flags, const plATCEaseCurve *curve) const;
plAnimTimeConvert& IProcessStateChange(double worldTime, hsScalar animTime = -1);
plAnimTimeConvert& IProcessStateChange(double worldTime, float animTime = -1);
void IFlushOldStates();
void IClearAllStates();
plATCState *IGetState(double wSecs) const;
@ -128,30 +128,30 @@ public:
// ALL WorldToAnimTime functions are only valid if called with a time >= fLastEvalWorldTime.
hsBool IsStoppedAt(double wSecs) const;
hsScalar WorldToAnimTime(double wSecs);
hsScalar WorldToAnimTimeNoUpdate(double wSecs) const; // convert time but don't fire triggers or set state
float WorldToAnimTime(double wSecs);
float WorldToAnimTimeNoUpdate(double wSecs) const; // convert time but don't fire triggers or set state
protected:
static hsScalar IWorldToAnimTimeNoUpdate(double wSecs, plATCState *state);
hsScalar IWorldToAnimTimeBeforeState(double wSecs) const;
static float IWorldToAnimTimeNoUpdate(double wSecs, plATCState *state);
float IWorldToAnimTimeBeforeState(double wSecs) const;
public:
void SetBegin(hsScalar s) { fBegin = s; }
void SetEnd(hsScalar s) { fEnd = s; }
void SetSpeed(hsScalar goal, hsScalar rate = 0);
void SetLoopPoints(hsScalar begin, hsScalar end) { SetLoopBegin(begin); SetLoopEnd(end); }
void SetLoopBegin(hsScalar s) { fLoopBegin = s; }
void SetLoopEnd(hsScalar s) { fLoopEnd = s; }
void SetEase(hsBool easeIn, uint8_t inType, hsScalar minLength, hsScalar maxLength, hsScalar inLength);
void SetBegin(float s) { fBegin = s; }
void SetEnd(float s) { fEnd = s; }
void SetSpeed(float goal, float rate = 0);
void SetLoopPoints(float begin, float end) { SetLoopBegin(begin); SetLoopEnd(end); }
void SetLoopBegin(float s) { fLoopBegin = s; }
void SetLoopEnd(float s) { fLoopEnd = s; }
void SetEase(hsBool easeIn, uint8_t inType, float minLength, float maxLength, float inLength);
void SetCurrentEaseCurve(int x); // 0=nil, 1=easeIn, 2=easeOut, 3=speed
hsScalar GetBegin() const { return fBegin; }
hsScalar GetEnd() const { return fEnd; }
hsScalar GetLoopBegin() const { return fLoopBegin; }
hsScalar GetLoopEnd() const { return fLoopEnd; }
hsScalar GetSpeed() const { return fSpeed; }
hsTArray<hsScalar> &GetStopPoints() { return fStopPoints; }
hsScalar GetBestStopDist(hsScalar min, hsScalar max, hsScalar norm, hsScalar time) const;
float GetBegin() const { return fBegin; }
float GetEnd() const { return fEnd; }
float GetLoopBegin() const { return fLoopBegin; }
float GetLoopEnd() const { return fLoopEnd; }
float GetSpeed() const { return fSpeed; }
hsTArray<float> &GetStopPoints() { return fStopPoints; }
float GetBestStopDist(float min, float max, float norm, float time) const;
int GetCurrentEaseCurve() const; // returns 0=nil, 1=easeIn, 2=easeOut, 3=speed
void ResizeStates(int cnt);
@ -164,8 +164,8 @@ public:
plAnimTimeConvert& Stop(hsBool on);
plAnimTimeConvert& Stop(double s = -1.0);
plAnimTimeConvert& Start(double s = -1.0);
plAnimTimeConvert& PlayToTime(hsScalar time);
plAnimTimeConvert& PlayToPercentage(hsScalar percent); // zero to one.
plAnimTimeConvert& PlayToTime(float time);
plAnimTimeConvert& PlayToPercentage(float percent); // zero to one.
plAnimTimeConvert& Loop(hsBool on);
plAnimTimeConvert& Loop() { return Loop(true); }
@ -181,8 +181,8 @@ public:
hsBool IsForewards() const { return !(fFlags & kBackwards); }
double LastEvalWorldTime() const { return fLastEvalWorldTime; }
hsScalar CurrentAnimTime() const { return fCurrentAnimTime; }
void SetCurrentAnimTime(hsScalar s, hsBool jump = false);
float CurrentAnimTime() const { return fCurrentAnimTime; }
void SetCurrentAnimTime(float s, hsBool jump = false);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
@ -224,21 +224,21 @@ public:
class plATCEaseCurve : public plCreatable
{
protected:
hsScalar fStartSpeed;
hsScalar fMinLength;
hsScalar fMaxLength;
hsScalar fNormLength;
float fStartSpeed;
float fMinLength;
float fMaxLength;
float fNormLength;
public:
CLASSNAME_REGISTER( plATCEaseCurve );
GETINTERFACE_ANY( plATCEaseCurve, plCreatable );
double fBeginWorldTime;
hsScalar fLength;
hsScalar fSpeed; // The anim's target ("full") speed.
float fLength;
float fSpeed; // The anim's target ("full") speed.
static plATCEaseCurve *CreateEaseCurve(uint8_t type, hsScalar minLength, hsScalar maxLength, hsScalar normLength,
hsScalar startSpeed, hsScalar goalSpeed);
static plATCEaseCurve *CreateEaseCurve(uint8_t type, float minLength, float maxLength, float normLength,
float startSpeed, float goalSpeed);
double GetEndWorldTime() const { return fBeginWorldTime + fLength; }
@ -246,40 +246,40 @@ public:
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
virtual void RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, hsBool preserveRate = false);
virtual void SetLengthOnRate(hsScalar rate);
virtual void SetLengthOnDistance(hsScalar dist) = 0;
virtual hsScalar PositionGivenTime(hsScalar time) const = 0;
virtual hsScalar VelocityGivenTime(hsScalar time) const = 0;
virtual hsScalar TimeGivenVelocity(hsScalar velocity) const = 0;
virtual hsScalar GetMinDistance();
virtual hsScalar GetMaxDistance();
virtual hsScalar GetNormDistance();
virtual void RecalcToSpeed(float startSpeed, float goalSpeed, hsBool preserveRate = false);
virtual void SetLengthOnRate(float rate);
virtual void SetLengthOnDistance(float dist) = 0;
virtual float PositionGivenTime(float time) const = 0;
virtual float VelocityGivenTime(float time) const = 0;
virtual float TimeGivenVelocity(float velocity) const = 0;
virtual float GetMinDistance();
virtual float GetMaxDistance();
virtual float GetNormDistance();
};
class plConstAccelEaseCurve : public plATCEaseCurve
{
public:
plConstAccelEaseCurve();
plConstAccelEaseCurve(hsScalar minLength, hsScalar maxLength, hsScalar length,
hsScalar startSpeed, hsScalar goalSpeed);
plConstAccelEaseCurve(float minLength, float maxLength, float length,
float startSpeed, float goalSpeed);
CLASSNAME_REGISTER( plConstAccelEaseCurve );
GETINTERFACE_ANY( plConstAccelEaseCurve, plATCEaseCurve );
virtual plATCEaseCurve *Clone() const;
virtual void SetLengthOnDistance(hsScalar dist);
virtual hsScalar PositionGivenTime(hsScalar time) const;
virtual hsScalar VelocityGivenTime(hsScalar time) const;
virtual hsScalar TimeGivenVelocity(hsScalar velocity) const;
virtual void SetLengthOnDistance(float dist);
virtual float PositionGivenTime(float time) const;
virtual float VelocityGivenTime(float time) const;
virtual float TimeGivenVelocity(float velocity) const;
};
class plSplineEaseCurve : public plATCEaseCurve
{
public:
plSplineEaseCurve();
plSplineEaseCurve(hsScalar minLength, hsScalar maxLength, hsScalar length,
hsScalar startSpeed, hsScalar goalSpeed);
plSplineEaseCurve(float minLength, float maxLength, float length,
float startSpeed, float goalSpeed);
CLASSNAME_REGISTER( plSplineEaseCurve );
GETINTERFACE_ANY( plSplineEaseCurve, plATCEaseCurve );
@ -288,13 +288,13 @@ public:
virtual void Write(hsStream *s, hsResMgr *mgr);
virtual plATCEaseCurve *Clone() const;
virtual void RecalcToSpeed(hsScalar startSpeed, hsScalar goalSpeed, hsBool preserveRate = false);
virtual void SetLengthOnDistance(hsScalar dist);
virtual hsScalar PositionGivenTime(hsScalar time) const;
virtual hsScalar VelocityGivenTime(hsScalar time) const;
virtual hsScalar TimeGivenVelocity(hsScalar velocity) const;
virtual void RecalcToSpeed(float startSpeed, float goalSpeed, hsBool preserveRate = false);
virtual void SetLengthOnDistance(float dist);
virtual float PositionGivenTime(float time) const;
virtual float VelocityGivenTime(float time) const;
virtual float TimeGivenVelocity(float velocity) const;
hsScalar fCoef[4];
float fCoef[4];
};
class plATCState
@ -307,15 +307,15 @@ public:
void Write(hsStream *s, hsResMgr *mgr);
double fStartWorldTime;
hsScalar fStartAnimTime;
float fStartAnimTime;
uint8_t fFlags;
hsScalar fBegin;
hsScalar fEnd;
hsScalar fLoopBegin;
hsScalar fLoopEnd;
hsScalar fSpeed;
hsScalar fWrapTime;
float fBegin;
float fEnd;
float fLoopBegin;
float fLoopEnd;
float fSpeed;
float fWrapTime;
plATCEaseCurve *fEaseCurve;
};

View File

@ -79,7 +79,7 @@ plLeafController::~plLeafController()
delete[] fKeys;
}
void plLeafController::Interp(hsScalar time, hsScalar* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, float* result, plControllerCacheInfo *cache) const
{
hsAssert(fType == hsKeyFrame::kScalarKeyFrame || fType == hsKeyFrame::kBezScalarKeyFrame, kInvalidInterpString);
@ -87,7 +87,7 @@ void plLeafController::Interp(hsScalar time, hsScalar* result, plControllerCache
if (fType == hsKeyFrame::kScalarKeyFrame)
{
hsScalarKey *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsScalarKey), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::LinInterp(k1->fValue, k2->fValue, t, result);
@ -95,14 +95,14 @@ void plLeafController::Interp(hsScalar time, hsScalar* result, plControllerCache
else
{
hsBezScalarKey *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsBezScalarKey), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::BezInterp(k1, k2, t, result);
}
}
void plLeafController::Interp(hsScalar time, hsScalarTriple* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, hsScalarTriple* result, plControllerCacheInfo *cache) const
{
hsAssert(fType == hsKeyFrame::kPoint3KeyFrame || fType == hsKeyFrame::kBezPoint3KeyFrame, kInvalidInterpString);
@ -110,7 +110,7 @@ void plLeafController::Interp(hsScalar time, hsScalarTriple* result, plControlle
if (fType == hsKeyFrame::kPoint3KeyFrame)
{
hsPoint3Key *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsPoint3Key), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::LinInterp(&k1->fValue, &k2->fValue, t, result);
@ -118,14 +118,14 @@ void plLeafController::Interp(hsScalar time, hsScalarTriple* result, plControlle
else
{
hsBezPoint3Key *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsBezPoint3Key), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::BezInterp(k1, k2, t, result);
}
}
void plLeafController::Interp(hsScalar time, hsScaleValue* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, hsScaleValue* result, plControllerCacheInfo *cache) const
{
hsAssert(fType == hsKeyFrame::kScaleKeyFrame || fType == hsKeyFrame::kBezScaleKeyFrame, kInvalidInterpString);
@ -133,7 +133,7 @@ void plLeafController::Interp(hsScalar time, hsScaleValue* result, plControllerC
if (fType == hsKeyFrame::kScaleKeyFrame)
{
hsScaleKey *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsScaleKey), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::LinInterp(&k1->fValue, &k2->fValue, t, result);
@ -141,14 +141,14 @@ void plLeafController::Interp(hsScalar time, hsScaleValue* result, plControllerC
else
{
hsBezScaleKey *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsBezScaleKey), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::BezInterp(k1, k2, t, result);
}
}
void plLeafController::Interp(hsScalar time, hsQuat* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, hsQuat* result, plControllerCacheInfo *cache) const
{
hsAssert(fType == hsKeyFrame::kQuatKeyFrame ||
fType == hsKeyFrame::kCompressedQuatKeyFrame32 ||
@ -158,7 +158,7 @@ void plLeafController::Interp(hsScalar time, hsQuat* result, plControllerCacheIn
if (fType == hsKeyFrame::kQuatKeyFrame)
{
hsQuatKey *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsQuatKey), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::LinInterp(&k1->fValue, &k2->fValue, t, result);
@ -166,7 +166,7 @@ void plLeafController::Interp(hsScalar time, hsQuat* result, plControllerCacheIn
else if (fType == hsKeyFrame::kCompressedQuatKeyFrame32)
{
hsCompressedQuatKey32 *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsCompressedQuatKey32), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
@ -178,7 +178,7 @@ void plLeafController::Interp(hsScalar time, hsQuat* result, plControllerCacheIn
else // (fType == hsKeyFrame::kCompressedQuatKeyFrame64)
{
hsCompressedQuatKey64 *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsCompressedQuatKey64), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
@ -189,31 +189,31 @@ void plLeafController::Interp(hsScalar time, hsQuat* result, plControllerCacheIn
}
}
void plLeafController::Interp(hsScalar time, hsMatrix33* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, hsMatrix33* result, plControllerCacheInfo *cache) const
{
hsAssert(fType == hsKeyFrame::kMatrix33KeyFrame, kInvalidInterpString);
hsBool tryForward = (cache? cache->fAtc->IsForewards() : true);
hsMatrix33Key *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsMatrix33Key), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::LinInterp(&k1->fValue, &k2->fValue, t, result);
}
void plLeafController::Interp(hsScalar time, hsMatrix44* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, hsMatrix44* result, plControllerCacheInfo *cache) const
{
hsAssert(fType == hsKeyFrame::kMatrix44KeyFrame, kInvalidInterpString);
hsBool tryForward = (cache? cache->fAtc->IsForewards() : true);
hsMatrix44Key *k1, *k2;
hsScalar t;
float t;
uint32_t *idxStore = (cache ? &cache->fKeyIndex : &fLastKeyIdx);
hsInterp::GetBoundaryKeyFrames(time, fNumKeys, fKeys, sizeof(hsMatrix44Key), (hsKeyFrame**)&k1, (hsKeyFrame**)&k2, idxStore, &t, tryForward);
hsInterp::LinInterp(&k1->fValue, &k2->fValue, t, result);
}
void plLeafController::Interp(hsScalar time, hsColorRGBA* result, plControllerCacheInfo *cache) const
void plLeafController::Interp(float time, hsColorRGBA* result, plControllerCacheInfo *cache) const
{
hsPoint3 value;
Interp(time, &value, cache);
@ -229,7 +229,7 @@ plControllerCacheInfo *plLeafController::CreateCache() const
return cache;
}
hsScalar plLeafController::GetLength() const
float plLeafController::GetLength() const
{
uint32_t stride = GetStride();
if (stride == 0 || fNumKeys == 0)
@ -369,7 +369,7 @@ hsMatrix44Key *plLeafController::GetMatrix44Key(uint32_t i) const
return (hsMatrix44Key *)((uint8_t *)fKeys + i * sizeof(hsMatrix44Key));
}
void plLeafController::GetKeyTimes(hsTArray<hsScalar> &keyTimes) const
void plLeafController::GetKeyTimes(hsTArray<float> &keyTimes) const
{
int cIdx;
int kIdx;
@ -377,8 +377,8 @@ void plLeafController::GetKeyTimes(hsTArray<hsScalar> &keyTimes) const
uint8_t *keyPtr = (uint8_t *)fKeys;
for (cIdx = 0, kIdx = 0; cIdx < fNumKeys, kIdx < keyTimes.GetCount();)
{
hsScalar kTime = keyTimes[kIdx];
hsScalar cTime = ((hsKeyFrame*)(keyPtr + cIdx * stride))->fFrame / MAX_FRAMES_PER_SEC;
float kTime = keyTimes[kIdx];
float cTime = ((hsKeyFrame*)(keyPtr + cIdx * stride))->fFrame / MAX_FRAMES_PER_SEC;
if (cTime < kTime)
{
keyTimes.InsertAtIndex(kIdx, cTime);
@ -399,7 +399,7 @@ void plLeafController::GetKeyTimes(hsTArray<hsScalar> &keyTimes) const
// All remaining times in the controller are later than the original keyTimes set
for (; cIdx < fNumKeys; cIdx++)
{
hsScalar cTime = ((hsKeyFrame*)(keyPtr + cIdx * stride))->fFrame / MAX_FRAMES_PER_SEC;
float cTime = ((hsKeyFrame*)(keyPtr + cIdx * stride))->fFrame / MAX_FRAMES_PER_SEC;
keyTimes.Append(cTime);
}
}
@ -467,7 +467,7 @@ void plLeafController::AllocKeys(uint32_t numKeys, uint8_t type)
}
}
void plLeafController::QuickScalarController(int numKeys, hsScalar* times, hsScalar* values, uint32_t valueStrides)
void plLeafController::QuickScalarController(int numKeys, float* times, float* values, uint32_t valueStrides)
{
AllocKeys(numKeys, hsKeyFrame::kScalarKeyFrame);
int i;
@ -475,7 +475,7 @@ void plLeafController::QuickScalarController(int numKeys, hsScalar* times, hsSca
{
((hsScalarKey*)fKeys)[i].fFrame = (uint16_t)(*times++ * MAX_FRAMES_PER_SEC);
((hsScalarKey*)fKeys)[i].fValue = *values;
values = (hsScalar *)((uint8_t *)values + valueStrides);
values = (float *)((uint8_t *)values + valueStrides);
}
}
@ -764,7 +764,7 @@ plCompoundController::~plCompoundController()
delete fZController;
}
void plCompoundController::Interp(hsScalar time, hsScalarTriple* result, plControllerCacheInfo *cache) const
void plCompoundController::Interp(float time, hsScalarTriple* result, plControllerCacheInfo *cache) const
{
if (fXController)
fXController->Interp(time, &result->fX, (cache ? cache->fSubControllers[0] : nil));
@ -774,7 +774,7 @@ void plCompoundController::Interp(hsScalar time, hsScalarTriple* result, plContr
fZController->Interp(time, &result->fZ, (cache ? cache->fSubControllers[2] : nil));
}
void plCompoundController::Interp(hsScalar time, hsQuat* result, plControllerCacheInfo *cache) const
void plCompoundController::Interp(float time, hsQuat* result, plControllerCacheInfo *cache) const
{
hsEuler eul(0,0,0,EulOrdXYZs);
@ -785,7 +785,7 @@ void plCompoundController::Interp(hsScalar time, hsQuat* result, plControllerCac
eul.GetQuat(result);
}
void plCompoundController::Interp(hsScalar time, hsAffineParts* parts, plControllerCacheInfo *cache) const
void plCompoundController::Interp(float time, hsAffineParts* parts, plControllerCacheInfo *cache) const
{
if (fXController)
fXController->Interp(time, &parts->fT, (cache ? cache->fSubControllers[0] : nil));
@ -802,16 +802,16 @@ void plCompoundController::Interp(hsScalar time, hsAffineParts* parts, plControl
}
}
void plCompoundController::Interp(hsScalar time, hsColorRGBA* result, plControllerCacheInfo *cache) const
void plCompoundController::Interp(float time, hsColorRGBA* result, plControllerCacheInfo *cache) const
{
fXController->Interp(time, &result->r, (cache ? cache->fSubControllers[0] : nil));
fYController->Interp(time, &result->g, (cache ? cache->fSubControllers[1] : nil));
fZController->Interp(time, &result->b, (cache ? cache->fSubControllers[2] : nil));
}
hsScalar plCompoundController::GetLength() const
float plCompoundController::GetLength() const
{
hsScalar len=0;
float len=0;
int i;
for(i=0; i<3; i++)
{
@ -821,7 +821,7 @@ hsScalar plCompoundController::GetLength() const
return len;
}
void plCompoundController::GetKeyTimes(hsTArray<hsScalar> &keyTimes) const
void plCompoundController::GetKeyTimes(hsTArray<float> &keyTimes) const
{
if (fXController)
fXController->GetKeyTimes(keyTimes);

View File

@ -98,18 +98,18 @@ public:
CLASSNAME_REGISTER( plController );
GETINTERFACE_ANY( plController, plCreatable );
virtual void Interp(hsScalar time, hsScalar* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsScalarTriple* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsScaleValue* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsQuat* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsMatrix33* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsMatrix44* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsColorRGBA* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(hsScalar time, hsAffineParts* parts, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, float* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsScalarTriple* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsScaleValue* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsQuat* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsMatrix33* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsMatrix44* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsColorRGBA* result, plControllerCacheInfo *cache = nil) const {}
virtual void Interp(float time, hsAffineParts* parts, plControllerCacheInfo *cache = nil) const {}
virtual plControllerCacheInfo* CreateCache() const { return nil; } // Caller must handle deleting the pointer.
virtual hsScalar GetLength() const = 0;
virtual void GetKeyTimes(hsTArray<hsScalar> &keyTimes) const = 0;
virtual float GetLength() const = 0;
virtual void GetKeyTimes(hsTArray<float> &keyTimes) const = 0;
virtual hsBool AllKeysMatch() const = 0;
// Checks each of our subcontrollers (if we have any) and deletes any that
@ -138,16 +138,16 @@ public:
CLASSNAME_REGISTER( plLeafController );
GETINTERFACE_ANY( plLeafController, plController );
void Interp(hsScalar time, hsScalar* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsScalarTriple* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsScaleValue* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsQuat* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsMatrix33* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsMatrix44* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsColorRGBA* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, float* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsScalarTriple* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsScaleValue* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsQuat* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsMatrix33* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsMatrix44* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsColorRGBA* result, plControllerCacheInfo *cache = nil) const;
virtual plControllerCacheInfo* CreateCache() const;
hsScalar GetLength() const;
float GetLength() const;
uint32_t GetStride() const;
hsPoint3Key *GetPoint3Key(uint32_t i) const;
@ -166,9 +166,9 @@ public:
uint8_t GetType() const { return fType; }
uint32_t GetNumKeys() const { return fNumKeys; }
void *GetKeyBuffer() const { return fKeys; }
void GetKeyTimes(hsTArray<hsScalar> &keyTimes) const;
void GetKeyTimes(hsTArray<float> &keyTimes) const;
void AllocKeys(uint32_t n, uint8_t type);
void QuickScalarController(int numKeys, hsScalar* times, hsScalar* values, uint32_t valueStrides);
void QuickScalarController(int numKeys, float* times, float* values, uint32_t valueStrides);
hsBool AllKeysMatch() const;
hsBool PurgeRedundantSubcontrollers();
@ -196,10 +196,10 @@ public:
CLASSNAME_REGISTER( plCompoundController );
GETINTERFACE_ANY( plCompoundController, plController );
void Interp(hsScalar time, hsQuat* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsScalarTriple* result, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsAffineParts* parts, plControllerCacheInfo *cache = nil) const;
void Interp(hsScalar time, hsColorRGBA* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsQuat* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsScalarTriple* result, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsAffineParts* parts, plControllerCacheInfo *cache = nil) const;
void Interp(float time, hsColorRGBA* result, plControllerCacheInfo *cache = nil) const;
plControllerCacheInfo* CreateCache() const;
plController *GetXController() const { return fXController; }
@ -209,8 +209,8 @@ public:
plController *GetRotController() const { return fYController; }
plController *GetScaleController() const { return fZController; }
plController *GetController(int32_t i) const;
hsScalar GetLength() const;
void GetKeyTimes(hsTArray<hsScalar> &keyTimes) const;
float GetLength() const;
void GetKeyTimes(hsTArray<float> &keyTimes) const;
hsBool AllKeysMatch() const;
hsBool PurgeRedundantSubcontrollers();

View File

@ -76,18 +76,18 @@ void plModulator::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
}
// Volume - Want to base this on the closest point on the bounds, instead of just the center.
hsScalar plModulator::Modulation(const hsBounds3Ext& bnd) const
float plModulator::Modulation(const hsBounds3Ext& bnd) const
{
return Modulation(bnd.GetCenter());
}
hsScalar plModulator::Modulation(const hsPoint3& pos) const
float plModulator::Modulation(const hsPoint3& pos) const
{
hsAssert(fVolume, "Modulator with no Volume is pretty useless");
hsScalar dist = fVolume->Test(pos);
float dist = fVolume->Test(pos);
hsScalar retVal;
float retVal;
if( dist > 0 )
{
if( dist < fSoftDist )

View File

@ -54,7 +54,7 @@ class plModulator : public plCreatable
{
protected:
plVolumeIsect* fVolume;
hsScalar fSoftDist;
float fSoftDist;
public:
plModulator();
@ -66,13 +66,13 @@ public:
const plVolumeIsect* GetVolume() const { return fVolume; }
void SetVolume(plVolumeIsect* vol); // Takes ownership, so don't delete after handing it in.
hsScalar Modulation(const hsPoint3& pos) const;
hsScalar Modulation(const hsBounds3Ext& bnd) const;
float Modulation(const hsPoint3& pos) const;
float Modulation(const hsBounds3Ext& bnd) const;
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
hsScalar GetSoftDist() const { return fSoftDist; }
void SetSoftDist(hsScalar s) { fSoftDist = s; }
float GetSoftDist() const { return fSoftDist; }
void SetSoftDist(float s) { fSoftDist = s; }
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);