Browse Source

Eliminate hsScalar and hsFixed

Modern CPUs support floats just fine... hsFixed was crazy.
Adam Johnson 13 years ago
parent
commit
e020651e4b
  1. 14
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 6
      Sources/Plasma/Apps/plClient/plClient.h
  3. 2
      Sources/Plasma/CoreLib/CMakeLists.txt
  4. 61
      Sources/Plasma/CoreLib/HS_POINT2.inc
  5. 1
      Sources/Plasma/CoreLib/HeadSpin.cpp
  6. 414
      Sources/Plasma/CoreLib/hsBounds.cpp
  7. 26
      Sources/Plasma/CoreLib/hsBounds.h
  8. 27
      Sources/Plasma/CoreLib/hsColorRGBA.h
  9. 10
      Sources/Plasma/CoreLib/hsConfig.h
  10. 19
      Sources/Plasma/CoreLib/hsFastMath.cpp
  11. 52
      Sources/Plasma/CoreLib/hsFastMath.h
  12. 120
      Sources/Plasma/CoreLib/hsFixedTypes.h
  13. 34
      Sources/Plasma/CoreLib/hsGeometry3.cpp
  14. 164
      Sources/Plasma/CoreLib/hsGeometry3.h
  15. 2
      Sources/Plasma/CoreLib/hsMatrix33.h
  16. 215
      Sources/Plasma/CoreLib/hsMatrix44.cpp
  17. 50
      Sources/Plasma/CoreLib/hsMatrix44.h
  18. 162
      Sources/Plasma/CoreLib/hsPoint2.h
  19. 82
      Sources/Plasma/CoreLib/hsQuat.cpp
  20. 32
      Sources/Plasma/CoreLib/hsQuat.h
  21. 200
      Sources/Plasma/CoreLib/hsScalar.h
  22. 120
      Sources/Plasma/CoreLib/hsStream.cpp
  23. 28
      Sources/Plasma/CoreLib/hsStream.h
  24. 20
      Sources/Plasma/CoreLib/hsTypes.h
  25. 17
      Sources/Plasma/CoreLib/hsUtils.cpp
  26. 12
      Sources/Plasma/CoreLib/hsUtils.h
  27. 8
      Sources/Plasma/CoreLib/hsWide.cpp
  28. 29
      Sources/Plasma/CoreLib/hsWide.h
  29. 30
      Sources/Plasma/CoreLib/plViewTransform.cpp
  30. 54
      Sources/Plasma/CoreLib/plViewTransform.h
  31. 8
      Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.cpp
  32. 2
      Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.h
  33. 46
      Sources/Plasma/FeatureLib/pfAnimation/plBlower.cpp
  34. 54
      Sources/Plasma/FeatureLib/pfAnimation/plBlower.h
  35. 2
      Sources/Plasma/FeatureLib/pfAnimation/plFilterCoordInterface.cpp
  36. 2
      Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp
  37. 2
      Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.h
  38. 18
      Sources/Plasma/FeatureLib/pfAnimation/plLightModifier.cpp
  39. 8
      Sources/Plasma/FeatureLib/pfAnimation/plLightModifier.h
  40. 38
      Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp
  41. 34
      Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.h
  42. 12
      Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp
  43. 18
      Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.h
  44. 14
      Sources/Plasma/FeatureLib/pfAnimation/plStereizer.cpp
  45. 34
      Sources/Plasma/FeatureLib/pfAnimation/plStereizer.h
  46. 8
      Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp
  47. 2
      Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.h
  48. 2
      Sources/Plasma/FeatureLib/pfAudio/plListener.cpp
  49. 4
      Sources/Plasma/FeatureLib/pfAudio/plListener.h
  50. 10
      Sources/Plasma/FeatureLib/pfAudio/plRandomSoundMod.cpp
  51. 2
      Sources/Plasma/FeatureLib/pfAudio/plRandomSoundMod.h
  52. 104
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
  53. 134
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.h
  54. 18
      Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp
  55. 26
      Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.h
  56. 6
      Sources/Plasma/FeatureLib/pfCamera/plInterestingModifier.cpp
  57. 16
      Sources/Plasma/FeatureLib/pfCamera/plInterestingModifier.h
  58. 62
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  59. 46
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h
  60. 2
      Sources/Plasma/FeatureLib/pfCharacter/pfMarkerMgr.cpp
  61. 50
      Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp
  62. 28
      Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h
  63. 2
      Sources/Plasma/FeatureLib/pfConditional/plAnimationEventConditionalObject.cpp
  64. 2
      Sources/Plasma/FeatureLib/pfConditional/plAnimationEventConditionalObject.h
  65. 4
      Sources/Plasma/FeatureLib/pfConditional/plFacingConditionalObject.cpp
  66. 4
      Sources/Plasma/FeatureLib/pfConditional/plFacingConditionalObject.h
  67. 2
      Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp
  68. 68
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  69. 4
      Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
  70. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp
  71. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h
  72. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp
  73. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h
  74. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIClickMapCtrl.cpp
  75. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIClickMapCtrl.h
  76. 22
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp
  77. 8
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.h
  78. 4
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp
  79. 12
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.cpp
  80. 8
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.h
  81. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDragBarCtrl.cpp
  82. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDragBarCtrl.h
  83. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDraggableMod.cpp
  84. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDraggableMod.h
  85. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDynDisplayCtrl.cpp
  86. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDynDisplayCtrl.h
  87. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp
  88. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h
  89. 22
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp
  90. 10
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h
  91. 12
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.cpp
  92. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.h
  93. 10
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp
  94. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.h
  95. 10
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp
  96. 8
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.h
  97. 22
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp
  98. 8
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h
  99. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIRadioGroupCtrl.cpp
  100. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIRadioGroupCtrl.h
  101. Some files were not shown because too many files have changed in this diff Show More

14
Sources/Plasma/Apps/plClient/plClient.cpp

@ -164,7 +164,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define MSG_LOADING_BAR #define MSG_LOADING_BAR
// static hsVector3 gAbsDown(0,0,-hsScalar1); // static hsVector3 gAbsDown(0,0,-1.f);
static plDispatchBase* gDisp = nil; static plDispatchBase* gDisp = nil;
static plTimerCallbackManager* gTimerMgr = nil; static plTimerCallbackManager* gTimerMgr = nil;
@ -571,7 +571,7 @@ hsBool plClient::InitPipeline()
float yon = 500.0f; float yon = 500.0f;
pipe->SetFOV( 60.f, hsIntToScalar( 60.f * pipe->Height() / pipe->Width() ) ); pipe->SetFOV( 60.f, int32_t( 60.f * pipe->Height() / pipe->Width() ) );
pipe->SetDepth( 0.3f, yon ); pipe->SetDepth( 0.3f, yon );
hsMatrix44 id; hsMatrix44 id;
@ -1296,7 +1296,7 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress)
} }
//============================================================================ //============================================================================
void plClient::IIncProgress (hsScalar byHowMuch, const char * text) void plClient::IIncProgress (float byHowMuch, const char * text)
{ {
if (fProgressBar) { if (fProgressBar) {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1307,7 +1307,7 @@ void plClient::IIncProgress (hsScalar byHowMuch, const char * text)
} }
//============================================================================ //============================================================================
void plClient::IStartProgress( const char *title, hsScalar len ) void plClient::IStartProgress( const char *title, float len )
{ {
if (fProgressBar) if (fProgressBar)
{ {
@ -1519,7 +1519,7 @@ hsBool plClient::StartInit()
plgAudioSys::Activate(true); plgAudioSys::Activate(true);
plConst(hsScalar) delay(2.f); plConst(float) delay(2.f);
//commenting out publisher splash for MORE //commenting out publisher splash for MORE
//IPlayIntroBink("avi/intro0.bik", delay, 0.f, 0.f, 1.f, 1.f, 0.75); //IPlayIntroBink("avi/intro0.bik", delay, 0.f, 0.f, 1.f, 1.f, 0.75);
//if( GetDone() ) return false; //if( GetDone() ) return false;
@ -1731,7 +1731,7 @@ hsBool plClient::IUpdate()
// Time may have been clamped in IncSysSeconds, depending on hsTimer's current mode. // Time may have been clamped in IncSysSeconds, depending on hsTimer's current mode.
double currTime = hsTimer::GetSysSeconds(); double currTime = hsTimer::GetSysSeconds();
hsScalar delSecs = hsTimer::GetDelSysSeconds(); float delSecs = hsTimer::GetDelSysSeconds();
// do not change this ordering // do not change this ordering
@ -1971,7 +1971,7 @@ void plClient::IKillMovies()
fMovies.Reset(); fMovies.Reset();
} }
hsBool plClient::IPlayIntroBink(const char* movieName, hsScalar endDelay, hsScalar posX, hsScalar posY, hsScalar scaleX, hsScalar scaleY, hsScalar volume /* = 1.0 */) hsBool plClient::IPlayIntroBink(const char* movieName, float endDelay, float posX, float posY, float scaleX, float scaleY, float volume /* = 1.0 */)
{ {
SetQuitIntro(false); SetQuitIntro(false);
plBinkPlayer player; plBinkPlayer player;

6
Sources/Plasma/Apps/plClient/plClient.h

@ -189,13 +189,13 @@ protected:
void IProcessRenderRequests(hsTArray<plRenderRequest*>& reqs); void IProcessRenderRequests(hsTArray<plRenderRequest*>& reqs);
void IAddRenderRequest(plRenderRequest* req); void IAddRenderRequest(plRenderRequest* req);
hsBool IPlayIntroBink(const char* movieName, hsScalar endDelay, hsScalar posX, hsScalar posY, hsScalar scaleX, hsScalar scaleY, hsScalar volume = 1.0); hsBool IPlayIntroBink(const char* movieName, float endDelay, float posX, float posY, float scaleX, float scaleY, float volume = 1.0);
hsBool IHandleMovieMsg(plMovieMsg* mov); hsBool IHandleMovieMsg(plMovieMsg* mov);
void IKillMovies(); void IKillMovies();
void IServiceMovies(); void IServiceMovies();
void IStartProgress( const char *title, hsScalar len ); void IStartProgress( const char *title, float len );
void IIncProgress( hsScalar byHowMuch, const char *text ); void IIncProgress( float byHowMuch, const char *text );
void IStopProgress( void ); void IStopProgress( void );
static void IDispatchMsgReceiveCallback(); static void IDispatchMsgReceiveCallback();

2
Sources/Plasma/CoreLib/CMakeLists.txt

@ -51,7 +51,6 @@ set(CoreLib_HEADERS
hsCritSect.h hsCritSect.h
hsExceptions.h hsExceptions.h
hsFastMath.h hsFastMath.h
hsFixedTypes.h
hsGeometry3.h hsGeometry3.h
hsHashTable.h hsHashTable.h
hsMalloc.h hsMalloc.h
@ -63,7 +62,6 @@ set(CoreLib_HEADERS
hsQueue.h hsQueue.h
hsRefCnt.h hsRefCnt.h
hsSafeRefCnt.h hsSafeRefCnt.h
hsScalar.h
hsStlSortUtils.h hsStlSortUtils.h
hsSTLStream.h hsSTLStream.h
hsStlUtils.h hsStlUtils.h

61
Sources/Plasma/CoreLib/HS_POINT2.inc

@ -1,61 +0,0 @@
struct HS_POINT2_NAME {
HS_POINT2_TYPE fX, fY;
HS_POINT2_NAME& Set(HS_POINT2_TYPE x, HS_POINT2_TYPE y)
{
fX = x;
fY = y;
return *this;
}
HS_POINT2_NAME& operator+=(const HS_POINT2_NAME& s)
{
this->fX += s.fX;
this->fY += s.fY;
return *this;
}
HS_POINT2_NAME& operator-=(const HS_POINT2_NAME& s)
{
this->fX -= s.fX;
this->fY -= s.fY;
return *this;
}
#if 0 // Havok reeks
friend int operator==(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
return (s.fX == t.fX && s.fY == t.fY);
}
friend int operator!=(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
return !(s == t);
}
#else // Havok reeks
int operator==(const HS_POINT2_NAME& ss) const
{
return (ss.fX == fX && ss.fY == fY);
}
int operator!=(const HS_POINT2_NAME& ss)
{
return !(ss == *this);
}
#endif // Havok reeks
friend HS_POINT2_NAME operator+(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
HS_POINT2_NAME result;
result.Set(s.fX + t.fX, s.fY + t.fY);
return result;
}
friend HS_POINT2_NAME operator-(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
HS_POINT2_NAME result;
result.Set(s.fX - t.fX, s.fY - t.fY);
return result;
}
friend HS_POINT2_NAME operator-(const HS_POINT2_NAME& s)
{
HS_POINT2_NAME result = { -s.fX, -s.fY };
return result;
}
#undef HS_POINT2_NAME
#undef HS_POINT2_TYPE

1
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsUtils.h" #include "hsUtils.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "hsExceptions.h" #include "hsExceptions.h"
#include <math.h>
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32

414
Sources/Plasma/CoreLib/hsBounds.cpp

File diff suppressed because it is too large Load Diff

26
Sources/Plasma/CoreLib/hsBounds.h

@ -68,7 +68,7 @@ class hsBounds
protected: protected:
hsBoundsType fType; hsBoundsType fType;
public: public:
static const hsScalar kRealSmall; static const float kRealSmall;
hsBounds() : fType(kBoundsUninitialized) { }; hsBounds() : fType(kBoundsUninitialized) { };
@ -130,7 +130,7 @@ public:
virtual void GetCorners(hsPoint3 *b) const; virtual void GetCorners(hsPoint3 *b) const;
const hsPoint3& GetMins() const; const hsPoint3& GetMins() const;
const hsPoint3& GetMaxs() const; const hsPoint3& GetMaxs() const;
hsScalar GetMaxDim() const; // Computes the answer float GetMaxDim() const; // Computes the answer
const hsPoint3& GetCenter() const; // Computes the answer if not already there const hsPoint3& GetCenter() const; // Computes the answer if not already there
virtual hsBool IsInside(const hsPoint3* pos) const; // ok for full/empty virtual hsBool IsInside(const hsPoint3* pos) const; // ok for full/empty
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const; virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
@ -141,8 +141,8 @@ public:
// neg, pos, zero == disjoint, I contain other, overlap // neg, pos, zero == disjoint, I contain other, overlap
virtual int32_t TestBound(const hsBounds3& other) const; virtual int32_t TestBound(const hsBounds3& other) const;
static hsScalar ClosestPointToLine(const hsPoint3 *p, const hsPoint3 *v0, const hsPoint3 *v1, hsPoint3 *out); static float ClosestPointToLine(const hsPoint3 *p, const hsPoint3 *v0, const hsPoint3 *v1, hsPoint3 *out);
static hsScalar ClosestPointToInfiniteLine(const hsPoint3* p, const hsVector3* v, hsPoint3* out); static float ClosestPointToInfiniteLine(const hsPoint3* p, const hsVector3* v, hsPoint3* out);
virtual void Read(hsStream*); virtual void Read(hsStream*);
virtual void Write(hsStream*); virtual void Write(hsStream*);
@ -183,7 +183,7 @@ inline const hsPoint3& hsBounds3::GetCenter() const
return fCenter; return fCenter;
} }
inline hsScalar hsBounds3::GetMaxDim() const inline float hsBounds3::GetMaxDim() const
{ {
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim"); hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim");
return hsMaximum(hsMaximum(fMaxs.fX-fMins.fX, fMaxs.fY-fMins.fY), fMaxs.fZ-fMins.fZ); return hsMaximum(hsMaximum(fMaxs.fX-fMins.fX, fMaxs.fY-fMins.fY), fMaxs.fZ-fMins.fZ);
@ -245,7 +245,7 @@ protected:
hsPoint3 fCorner; hsPoint3 fCorner;
hsVector3 fAxes[3]; hsVector3 fAxes[3];
mutable hsPoint2 fDists[3]; mutable hsPoint2 fDists[3];
mutable hsScalar fRadius; mutable float fRadius;
hsBool IAxisIsZero(uint32_t i) const { return (fExtFlags & (1 << (20+i))) != 0; }; hsBool IAxisIsZero(uint32_t i) const { return (fExtFlags & (1 << (20+i))) != 0; };
void IMakeSphere() const; void IMakeSphere() const;
@ -276,7 +276,7 @@ public:
virtual void Transform(const hsMatrix44 *m); virtual void Transform(const hsMatrix44 *m);
virtual void Translate(const hsVector3 &v); virtual void Translate(const hsVector3 &v);
virtual hsScalar GetRadius() const; virtual float GetRadius() const;
virtual void GetAxes(hsVector3 *fAxis0, hsVector3 *fAxis1, hsVector3 *fAxis2) const; virtual void GetAxes(hsVector3 *fAxis0, hsVector3 *fAxis1, hsVector3 *fAxis2) const;
virtual hsPoint3 *GetCorner(hsPoint3 *c) const { *c = (fExtFlags & kAxisAligned ? fMins : fCorner); return c; } virtual hsPoint3 *GetCorner(hsPoint3 *c) const { *c = (fExtFlags & kAxisAligned ? fMins : fCorner); return c; }
virtual void GetCorners(hsPoint3 *b) const; virtual void GetCorners(hsPoint3 *b) const;
@ -300,21 +300,21 @@ public:
virtual hsBool ISectBS(const hsBounds3Ext &other, const hsVector3 &myVel) const; virtual hsBool ISectBS(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual int32_t IClosestISect(const hsBounds3Ext& other, const hsVector3& myVel, virtual int32_t IClosestISect(const hsBounds3Ext& other, const hsVector3& myVel,
hsScalar* tClose, hsScalar* tImpact) const; float* tClose, float* tImpact) const;
virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const; virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectBSBox(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const; virtual hsBool ISectBSBox(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel) const; virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBSBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const; virtual hsBool ISectBSBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectLine(const hsPoint3* from, const hsPoint3* to) const; virtual hsBool ISectLine(const hsPoint3* from, const hsPoint3* to) const;
virtual hsBool ISectCone(const hsPoint3* from, const hsPoint3* to, hsScalar radius) const; virtual hsBool ISectCone(const hsPoint3* from, const hsPoint3* to, float radius) const;
virtual hsBool ISectRayBS(const hsPoint3& from, const hsPoint3& to, hsPoint3& at) const; virtual hsBool ISectRayBS(const hsPoint3& from, const hsPoint3& to, hsPoint3& at) const;
virtual void Read(hsStream *s); virtual void Read(hsStream *s);
virtual void Write(hsStream *s); virtual void Write(hsStream *s);
}; };
inline hsScalar hsBounds3Ext::GetRadius() const inline float hsBounds3Ext::GetRadius() const
{ {
if( !(fExtFlags & kSphereSet) ) if( !(fExtFlags & kSphereSet) )
IMakeSphere(); IMakeSphere();
@ -323,7 +323,7 @@ inline hsScalar hsBounds3Ext::GetRadius() const
class hsHitInfoExt { class hsHitInfoExt {
public: public:
hsScalar fDepth; float fDepth;
hsVector3 fNormal; hsVector3 fNormal;
hsVector3 fDelPos; hsVector3 fDelPos;
@ -333,9 +333,9 @@ public:
hsHitInfoExt(const hsPoint3 *ctr, const hsVector3& offset) { fRootCenter=ctr; fDelPos=offset; }; hsHitInfoExt(const hsPoint3 *ctr, const hsVector3& offset) { fRootCenter=ctr; fDelPos=offset; };
void Set(const hsBounds3Ext *m, const hsVector3* n, hsScalar d) void Set(const hsBounds3Ext *m, const hsVector3* n, float d)
{ fDepth = d; fBoxBnd = m; fNormal = *n; fOtherBoxBnd = nil; } { fDepth = d; fBoxBnd = m; fNormal = *n; fOtherBoxBnd = nil; }
void Set(const hsBounds3Ext *m, const hsBounds3Ext *o, const hsVector3 &norm, hsScalar d) void Set(const hsBounds3Ext *m, const hsBounds3Ext *o, const hsVector3 &norm, float d)
{ fDepth = d; fBoxBnd = m, fOtherBoxBnd = o; fNormal = norm; } { fDepth = d; fBoxBnd = m, fOtherBoxBnd = o; fNormal = norm; }
}; };
#endif // hsBounds_inc #endif // hsBounds_inc

27
Sources/Plasma/CoreLib/hsColorRGBA.h

@ -43,15 +43,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef hsColorRGBA_inc #ifndef hsColorRGBA_inc
#define hsColorRGBA_inc #define hsColorRGBA_inc
#include "hsScalar.h"
#include "hsStream.h" #include "hsStream.h"
struct hsColorRGBA { struct hsColorRGBA {
hsScalar r,g,b,a; float r,g,b,a;
hsRGBAColor32 ToRGBA32() const; hsRGBAColor32 ToRGBA32() const;
hsColorRGBA& Set(hsScalar red, hsScalar grn, hsScalar blu, hsScalar alp) { r = red; g = grn; b = blu; a = alp; return *this; } hsColorRGBA& Set(float red, float grn, float blu, float alp) { r = red; g = grn; b = blu; a = alp; return *this; }
hsBool operator==(const hsColorRGBA&c) const { return (r==c.r)&&(g==c.g)&&(b==c.b)&&(a==c.a); } hsBool operator==(const hsColorRGBA&c) const { return (r==c.r)&&(g==c.g)&&(b==c.b)&&(a==c.a); }
hsBool operator!=(const hsColorRGBA&c) const { return !(c == *this); } hsBool operator!=(const hsColorRGBA&c) const { return !(c == *this); }
@ -65,9 +64,9 @@ struct hsColorRGBA {
friend inline hsColorRGBA operator-(const hsColorRGBA& s, const hsColorRGBA& t); friend inline hsColorRGBA operator-(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator-=(const hsColorRGBA& s); hsColorRGBA& operator-=(const hsColorRGBA& s);
friend inline hsColorRGBA operator*(const hsColorRGBA& c, const hsScalar s); friend inline hsColorRGBA operator*(const hsColorRGBA& c, const float s);
friend inline hsColorRGBA operator*(const hsScalar s, const hsColorRGBA& c); friend inline hsColorRGBA operator*(const float s, const hsColorRGBA& c);
hsColorRGBA& operator*=(const hsScalar s); hsColorRGBA& operator*=(const float s);
hsColorRGBA& FromARGB32(uint32_t c); hsColorRGBA& FromARGB32(uint32_t c);
uint32_t ToARGB32() const; uint32_t ToARGB32() const;
@ -93,11 +92,11 @@ inline void hsColorRGBA::Write(hsStream *s) const
inline hsColorRGBA& hsColorRGBA::FromARGB32(uint32_t c) inline hsColorRGBA& hsColorRGBA::FromARGB32(uint32_t c)
{ {
const hsScalar oo255 = 1.f / 255.f; const float oo255 = 1.f / 255.f;
a = hsScalar((c >> 24) & 0xff) * oo255; a = float((c >> 24) & 0xff) * oo255;
r = hsScalar((c >> 16) & 0xff) * oo255; r = float((c >> 16) & 0xff) * oo255;
g = hsScalar((c >> 8) & 0xff) * oo255; g = float((c >> 8) & 0xff) * oo255;
b = hsScalar((c >> 0) & 0xff) * oo255; b = float((c >> 0) & 0xff) * oo255;
return *this; return *this;
} }
@ -151,16 +150,16 @@ inline hsColorRGBA& hsColorRGBA::operator-=(const hsColorRGBA& s)
return *this; return *this;
} }
inline hsColorRGBA operator*(const hsColorRGBA& t, const hsScalar s) inline hsColorRGBA operator*(const hsColorRGBA& t, const float s)
{ {
hsColorRGBA res; hsColorRGBA res;
return res.Set(s * t.r, s * t.g, s * t.b, s * t.a); return res.Set(s * t.r, s * t.g, s * t.b, s * t.a);
} }
inline hsColorRGBA operator*(const hsScalar s, const hsColorRGBA&t) inline hsColorRGBA operator*(const float s, const hsColorRGBA&t)
{ {
return t * s; return t * s;
} }
inline hsColorRGBA& hsColorRGBA::operator*=(const hsScalar s) inline hsColorRGBA& hsColorRGBA::operator*=(const float s)
{ {
r *= s; r *= s;
g *= s; g *= s;

10
Sources/Plasma/CoreLib/hsConfig.h

@ -52,9 +52,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//////////////////// Change the 1s and 0s ////////////////////// //////////////////// Change the 1s and 0s //////////////////////
#define HS_CAN_USE_FLOAT 1
#define HS_SCALAR_IS_FLOAT 1
#define HS_PIN_MATH_OVERFLOW 0 // This forces hsWide versions of FixMath routines #define HS_PIN_MATH_OVERFLOW 0 // This forces hsWide versions of FixMath routines
#define HS_DEBUG_MATH_OVERFLOW 0 // This calls hsDebugMessage on k[Pos,Neg]Infinity #define HS_DEBUG_MATH_OVERFLOW 0 // This calls hsDebugMessage on k[Pos,Neg]Infinity
@ -68,13 +65,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define HS_BUILD_FOR_UNIX 1 #define HS_BUILD_FOR_UNIX 1
#endif #endif
#define HS_SCALAR_IS_FIXED !(HS_SCALAR_IS_FLOAT)
#define HS_NEVER_USE_FLOAT !(HS_CAN_USE_FLOAT)
#if HS_DEBUG_MATH_OVERFLOW && !(HS_PIN_MATH_OVERFLOW)
#error "Can't debug overflow unless HS_PIN_MATH_OVERFLOW is ON"
#endif
///////////////////////Windows Specific Defines ///////////////////////////// ///////////////////////Windows Specific Defines /////////////////////////////

19
Sources/Plasma/CoreLib/hsFastMath.cpp

@ -41,13 +41,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "hsTypes.h" #include "hsTypes.h"
#include "hsScalar.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "hsFastMath.h" #include "hsFastMath.h"
const hsScalar hsFastMath::kSqrtTwo = hsSquareRoot(2.f); const float hsFastMath::kSqrtTwo = sqrt(2.f);
const hsScalar hsFastMath::kInvSqrtTwo = hsScalarInvert(hsFastMath::kSqrtTwo); const float hsFastMath::kInvSqrtTwo = hsInvert(hsFastMath::kSqrtTwo);
const hsScalar hsFastMath::kTwoPI = hsScalarPI * 2.f; const float hsFastMath::kTwoPI = M_PI * 2.f;
hsPoint2 statCosSinTable[9] = // must match length in inline hsPoint2 statCosSinTable[9] = // must match length in inline
{ {
@ -579,11 +578,11 @@ unsigned char statSeedTable[] = {
0x6a 0x6a
}; };
hsScalar hsFastMath::IATan2OverTwoPi(hsScalar y, hsScalar x) float hsFastMath::IATan2OverTwoPi(float y, float x)
{ {
const int tabSize = 16; // pad with one extra because hi can go hi const int tabSize = 16; // pad with one extra because hi can go hi
const int tabMax = tabSize-1; const int tabMax = tabSize-1;
static hsScalar tab[tabSize+1] = { static float tab[tabSize+1] = {
0.f, 0.f,
0.0105947f, 0.0105947f,
0.0210962f, 0.0210962f,
@ -609,14 +608,14 @@ hsScalar hsFastMath::IATan2OverTwoPi(hsScalar y, hsScalar x)
if((yNeg = (y < 0)))y = -y; if((yNeg = (y < 0)))y = -y;
if((xNeg = (x < 0)))x = -x; if((xNeg = (x < 0)))x = -x;
hsBool yBigger = y >= x; hsBool yBigger = y >= x;
hsScalar div = yBigger ? x / y : y / x; float div = yBigger ? x / y : y / x;
hsScalar fInd = div * tabMax; float fInd = div * tabMax;
int lo = int(fInd); int lo = int(fInd);
int hi = lo+1; int hi = lo+1;
hsScalar frac = fInd - lo; float frac = fInd - lo;
hsScalar res = tab[lo]; float res = tab[lo];
res += frac * (tab[hi] - res); res += frac * (tab[hi] - res);
// now move to proper half quadrant // now move to proper half quadrant

52
Sources/Plasma/CoreLib/hsFastMath.h

@ -51,27 +51,27 @@ protected:
static const hsPoint2* fCosSinTable; static const hsPoint2* fCosSinTable;
public: public:
static const hsScalar kSqrtTwo; static const float kSqrtTwo;
static const hsScalar kInvSqrtTwo; static const float kInvSqrtTwo;
static const hsScalar kTwoPI; static const float kTwoPI;
static hsScalar IATan2OverTwoPi(hsScalar y, hsScalar x); static float IATan2OverTwoPi(float y, float x);
static inline hsScalar InvSqrtAppr(hsScalar x); static inline float InvSqrtAppr(float x);
static inline hsScalar InvSqrt(hsScalar x); static inline float InvSqrt(float x);
static inline hsVector3& Normalize(hsVector3& v) { return (v *= InvSqrt(v.MagnitudeSquared())); } static inline hsVector3& Normalize(hsVector3& v) { return (v *= InvSqrt(v.MagnitudeSquared())); }
static inline hsVector3& NormalizeAppr(hsVector3& v) { return (v *= InvSqrtAppr(v.MagnitudeSquared())); } static inline hsVector3& NormalizeAppr(hsVector3& v) { return (v *= InvSqrtAppr(v.MagnitudeSquared())); }
static inline void SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads); static inline void SinCosAppr(float rads, float& sinRads, float& cosRads);
static inline void SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads); static inline void SinCosInRangeAppr(float rads, float& sinRads, float& cosRads);
static inline void SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads); static inline void SinCos(float rads, float& sinRads, float& cosRads);
static inline void SinCosInRange(hsScalar ang, hsScalar& sinRads, hsScalar& cosRads); static inline void SinCosInRange(float ang, float& sinRads, float& cosRads);
static inline hsScalar Sin(hsScalar rads); static inline float Sin(float rads);
static inline hsScalar Cos(hsScalar rads); static inline float Cos(float rads);
static inline hsScalar SinInRange(hsScalar rads); static inline float SinInRange(float rads);
static inline hsScalar CosInRange(hsScalar rads); static inline float CosInRange(float rads);
}; };
@ -104,7 +104,7 @@ public:
#define SET_MANTSEED(a) (((unsigned long) (a)) << SEED_POS) #define SET_MANTSEED(a) (((unsigned long) (a)) << SEED_POS)
inline hsScalar hsFastMath::InvSqrtAppr(hsScalar x) inline float hsFastMath::InvSqrtAppr(float x)
{ {
register unsigned long a = *(long*)&x; register unsigned long a = *(long*)&x;
register float arg = x; register float arg = x;
@ -131,7 +131,7 @@ inline hsScalar hsFastMath::InvSqrtAppr(hsScalar x)
return r; return r;
} }
inline hsScalar hsFastMath::InvSqrt(hsScalar x) inline float hsFastMath::InvSqrt(float x)
{ {
register unsigned long a = *(long*)&x; register unsigned long a = *(long*)&x;
register float arg = x; register float arg = x;
@ -155,7 +155,7 @@ inline hsScalar hsFastMath::InvSqrt(hsScalar x)
} }
inline void hsFastMath::SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads) inline void hsFastMath::SinCosAppr(float rads, float& sinRads, float& cosRads)
{ {
rads = fmodf(rads, kTwoPI); rads = fmodf(rads, kTwoPI);
if( rads < 0 ) if( rads < 0 )
@ -163,11 +163,11 @@ inline void hsFastMath::SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& c
SinCosInRangeAppr(rads, sinRads, cosRads); SinCosInRangeAppr(rads, sinRads, cosRads);
} }
inline void hsFastMath::SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads) inline void hsFastMath::SinCosInRangeAppr(float rads, float& sinRads, float& cosRads)
{ {
const int kNumSinCosEntries = 8; const int kNumSinCosEntries = 8;
const hsScalar kNumEntriesOverTwoPI = kNumSinCosEntries * 0.5f / hsScalarPI; const float kNumEntriesOverTwoPI = kNumSinCosEntries * 0.5f / M_PI;
hsScalar t = rads * kNumEntriesOverTwoPI; float t = rads * kNumEntriesOverTwoPI;
int iLo = (int)t; int iLo = (int)t;
t -= iLo; t -= iLo;
@ -184,7 +184,7 @@ inline void hsFastMath::SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsSc
} }
inline hsScalar hsFastMath::Sin(hsScalar rads) inline float hsFastMath::Sin(float rads)
{ {
rads = fmodf(rads, kTwoPI); rads = fmodf(rads, kTwoPI);
if( rads < 0 ) if( rads < 0 )
@ -193,7 +193,7 @@ inline hsScalar hsFastMath::Sin(hsScalar rads)
return SinInRange(rads); return SinInRange(rads);
} }
inline hsScalar hsFastMath::Cos(hsScalar rads) inline float hsFastMath::Cos(float rads)
{ {
rads = fmodf(rads, kTwoPI); rads = fmodf(rads, kTwoPI);
if( rads < 0 ) if( rads < 0 )
@ -202,7 +202,7 @@ inline hsScalar hsFastMath::Cos(hsScalar rads)
return CosInRange(rads); return CosInRange(rads);
} }
inline hsScalar hsFastMath::SinInRange(hsScalar ang) inline float hsFastMath::SinInRange(float ang)
{ {
float sgn = 1.f; float sgn = 1.f;
@ -217,7 +217,7 @@ inline hsScalar hsFastMath::SinInRange(hsScalar ang)
return (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn; return (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
} }
inline hsScalar hsFastMath::CosInRange(hsScalar ang) inline float hsFastMath::CosInRange(float ang)
{ {
float sgn = 1.f; float sgn = 1.f;
@ -232,7 +232,7 @@ inline hsScalar hsFastMath::CosInRange(hsScalar ang)
return (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn; return (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
} }
inline void hsFastMath::SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads) inline void hsFastMath::SinCos(float rads, float& sinRads, float& cosRads)
{ {
rads = fmodf(rads, kTwoPI); rads = fmodf(rads, kTwoPI);
if( rads < 0 ) if( rads < 0 )
@ -240,7 +240,7 @@ inline void hsFastMath::SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRa
SinCosInRange(rads, sinRads, cosRads); SinCosInRange(rads, sinRads, cosRads);
} }
inline void hsFastMath::SinCosInRange(hsScalar ang, hsScalar& sinRads, hsScalar& cosRads) inline void hsFastMath::SinCosInRange(float ang, float& sinRads, float& cosRads)
{ {
float sgn = 1.f; float sgn = 1.f;

120
Sources/Plasma/CoreLib/hsFixedTypes.h

@ -1,120 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef hsFixedTypesDefined
#define hsFixedTypesDefined
#include "hsTypes.h"
#ifdef __cplusplus
extern "C" {
#endif
#define hsIntToFixed(x) ((hsFixed)(x) << 16)
#define hsFixedToInt(x) ((x) >> 16)
#define hsFixedRound(x) (((x) + 0x8000) >> 16)
#define hsFixed1 hsIntToFixed(1)
#define hsFixedPI (0x3243F)
#define hsFixedPiOver2 (0x1921F)
#define hsFixedToFract(x) ((hsFract)(x) << 14)
#define hsFractToFixed(x) ((hsFixed)(x) >> 14)
#define hsFract1 hsFixedToFract(hsFixed1)
#define hsFractPiOver2 (0x6487ED34) /* needs some work */
#define hsFixFloor(x) \
(hsFixed)((x) < 0 ? -(hsFixed)((-(x) + 0xFFFF) & 0xFFFF0000) : (x) & 0xFFFF0000)
#define hsFixedToFloorInt(x) \
(int)((x) < 0 ? -(int)((-(x) + 0xFFFF) >> 16) : ((x) >> 16))
#define hsFixCeiling(x) \
(hsFixed)((x) < 0 ? -(hsFixed)(-(x) & 0xFFFF0000) : ((x) + 0xFFFF) & 0xFFFF0000)
#define hsFixedToCeilingInt(x) \
(int)((x) < 0 ? -(int)(-(x) >> 16) : (((x) + 0xFFFF) >> 16))
#if HS_CAN_USE_FLOAT
#define hsFixedToFloat(x) ((x) / float(hsFixed1))
#define hsFloatToFixed(x) hsFixed((x) * hsFixed1)
#define hsFractToFloat(x) ((x) / float(hsFract1))
#define hsFloatToFract(x) hsFract((x) * hsFract1)
#endif
hsFixed hsFixMul(hsFixed a, hsFixed b);
hsFract hsFixDiv(hsFixed a, hsFixed b);
hsFract hsFracMul(hsFract a, hsFract b);
hsFract hsFracDiv(hsFract a, hsFract b);
hsFract hsFracSqrt(hsFract value);
#define hsFixSqrt(value) (hsFracSqrt(value) >> 7)
hsFract hsFracCubeRoot(hsFract value);
hsFixed hsFixedSin(hsFixed s);
hsFixed hsFixedCos(hsFixed s);
hsFixed hsFixedASin(hsFixed s);
hsFixed hsFixedACos(hsFixed s);
uint16_t hsSqrt32(uint32_t value);
uint16_t hsCubeRoot32(uint32_t value);
int32_t hsMulDiv32(int32_t numer1, int32_t numer2, int32_t denom);
int32_t hsMagnitude32(int32_t x, int32_t y);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
struct hsFixedPlane {
hsFixed fA, fB, fC;
void Set(hsFixed a, hsFixed b, hsFixed c) { fA = a; fB = b; fC = c; }
hsFixed FixEval(hsFixed x, hsFixed y) const { return hsFixMul(fA, x) + hsFixMul(fB, y) + fC; }
int32_t IntEval(int32_t x, int32_t y) const { return fA * x + fB * y + fC; }
void ShiftDown(uint32_t i) { fA >>= i; fB >>= i; fC >>= i;}
};
#endif
#endif

34
Sources/Plasma/CoreLib/hsGeometry3.cpp

@ -41,14 +41,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "hsStream.h" #include "hsStream.h"
#include <math.h>
hsVector3 operator%(const hsVector3& t, const hsVector3& s) hsVector3 operator%(const hsVector3& t, const hsVector3& s)
{ {
hsVector3 result; hsVector3 result;
return *result.Set( hsScalarMul(t.fY, s.fZ) - hsScalarMul(s.fY, t.fZ), return *result.Set((t.fY * s.fZ) - (s.fY * t.fZ),
-hsScalarMul(t.fX, s.fZ) + hsScalarMul(s.fX, t.fZ), -(t.fX * s.fZ) + (s.fX * t.fZ),
hsScalarMul(t.fX, s.fY) - hsScalarMul(s.fX, t.fY)); (t.fX * s.fY) - (s.fX * t.fY));
} }
@ -56,33 +57,10 @@ hsVector3 operator%(const hsVector3& t, const hsVector3& s)
////////////////////////////////// //////////////////////////////////
///////////////////////////////// /////////////////////////////////
#if HS_SCALAR_IS_FIXED float hsScalarTriple::Magnitude() const
hsScalar hsScalarTriple::Magnitude() const
{ {
hsWide result, temp; return sqrt(MagnitudeSquared());
result.Mul(fCoord[0], fCoord[0]);
temp.Mul(fCoord[1], fCoord[1]);
result.Add(&temp);
temp.Mul(fCoord[2], fCoord[2]);
result.Add(&temp);
return result.Sqrt();
}
hsScalar hsScalarTriple::MagnitudeSquared() const
{
hsWide result, temp;
result.Mul(fCoord[0], fCoord[0]);
temp.Mul(fCoord[1], fCoord[1]);
result.Add(&temp);
temp.Mul(fCoord[2], fCoord[2]);
result.Add(&temp);
return result.AsFixed();
} }
#endif
void hsScalarTriple::Read(hsStream *stream) void hsScalarTriple::Read(hsStream *stream)
{ {

164
Sources/Plasma/CoreLib/hsGeometry3.h

@ -42,26 +42,27 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef hsGGeometry3Defined #ifndef hsGGeometry3Defined
#define hsGGeometry3Defined #define hsGGeometry3Defined
#include "hsTypes.h" #include "HeadSpin.h"
#include "hsUtils.h"
struct hsVector3; struct hsVector3;
struct hsPoint3; struct hsPoint3;
struct hsScalarTriple; struct hsScalarTriple;
class hsStream; class hsStream;
/* /*
If value is already close to hsScalar1, then this is a good approx. of 1/sqrt(value) If value is already close to 1.f, then this is a good approx. of 1/sqrt(value)
*/ */
static inline hsScalar hsInvSqrt(hsScalar value) static inline float hsInvSqrt(float value)
{ {
hsScalar guess; float guess;
hsScalar threeOverTwo = hsScalar1 + hsScalarHalf; float threeOverTwo = 1.5f;
value = hsScalarDiv2(value); value /= 2.f;
guess = threeOverTwo - value; // with initial guess = 1.0 guess = threeOverTwo - value; // with initial guess = 1.0
// repeat this line for better approx // repeat this line for better approx
guess = hsScalarMul(guess, threeOverTwo - hsScalarMul(hsScalarMul(value, guess), guess)); guess = (guess * threeOverTwo - ((value * guess) * guess));
guess = hsScalarMul(guess, threeOverTwo - hsScalarMul(hsScalarMul(value, guess), guess)); guess = (guess * threeOverTwo - ((value * guess) * guess));
return guess; return guess;
} }
@ -71,12 +72,12 @@ struct hsScalarTriple
{ {
//protected: //protected:
// hsScalarTriple() : fX(privateData[0]), fY(privateData[1]), fZ(privateData[2]) {} // hsScalarTriple() : fX(privateData[0]), fY(privateData[1]), fZ(privateData[2]) {}
// hsScalarTriple(hsScalar x, hsScalar y, hsScalar z) // hsScalarTriple(float x, float y, float z)
// : fX(privateData[0]), fY(privateData[1]), fZ(privateData[2]) { fX = x, fY = y, fZ = z; } // : fX(privateData[0]), fY(privateData[1]), fZ(privateData[2]) { fX = x, fY = y, fZ = z; }
// //
// union { // union {
// u_long128 privateTemp; // u_long128 privateTemp;
// hsScalar privateData[4]; // float privateData[4];
// }; // };
//public: //public:
// //
@ -84,34 +85,29 @@ struct hsScalarTriple
// hsScalarTriple(const hsScalarTriple& o) : fX(privateData[0]), fY(privateData[1]), fZ(privateData[2]) // hsScalarTriple(const hsScalarTriple& o) : fX(privateData[0]), fY(privateData[1]), fZ(privateData[2])
// { *this = o; } // { *this = o; }
// //
// hsScalar& fX; // float& fX;
// hsScalar& fY; // float& fY;
// hsScalar& fZ; // float& fZ;
protected: protected:
hsScalarTriple() {} hsScalarTriple() {}
hsScalarTriple(hsScalar x, hsScalar y, hsScalar z) : fX(x), fY(y), fZ(z) {} hsScalarTriple(float x, float y, float z) : fX(x), fY(y), fZ(z) {}
public: public:
hsScalar fX, fY, fZ; float fX, fY, fZ;
hsScalarTriple* Set(hsScalar x, hsScalar y, hsScalar z) { fX= x; fY = y; fZ = z; return this;} hsScalarTriple* Set(float x, float y, float z) { fX= x; fY = y; fZ = z; return this;}
hsScalarTriple* Set(const hsScalarTriple *p) { fX = p->fX; fY = p->fY; fZ = p->fZ; return this;} hsScalarTriple* Set(const hsScalarTriple *p) { fX = p->fX; fY = p->fY; fZ = p->fZ; return this;}
hsScalar InnerProduct(const hsScalarTriple &p) const; float InnerProduct(const hsScalarTriple &p) const;
hsScalar InnerProduct(const hsScalarTriple *p) const; float InnerProduct(const hsScalarTriple *p) const;
// hsScalarTriple LERP(hsScalarTriple &other, hsScalar t); // hsScalarTriple LERP(hsScalarTriple &other, float t);
#if HS_SCALAR_IS_FIXED float Magnitude() const;
hsScalar Magnitude() const; float MagnitudeSquared() const { return (fX * fX + fY * fY + fZ * fZ); }
hsScalar MagnitudeSquared() const;
#else
hsScalar Magnitude() const { return hsSquareRoot(MagnitudeSquared()); }
hsScalar MagnitudeSquared() const { return (fX * fX + fY * fY + fZ * fZ); }
#endif
hsBool IsEmpty() const { return fX == 0 && fY == 0 && fZ == 0; } hsBool IsEmpty() const { return fX == 0 && fY == 0 && fZ == 0; }
hsScalar operator[](int i) const; float operator[](int i) const;
hsScalar& operator[](int i); float& operator[](int i);
void Read(hsStream *stream); void Read(hsStream *stream);
void Write(hsStream *stream) const; void Write(hsStream *stream) const;
@ -120,32 +116,32 @@ public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
inline hsScalar& hsScalarTriple::operator[] (int i) inline float& hsScalarTriple::operator[] (int i)
{ {
hsAssert(i >=0 && i <3, "Bad index for hsScalarTriple::operator[]"); hsAssert(i >=0 && i <3, "Bad index for hsScalarTriple::operator[]");
return *(&fX + i); return *(&fX + i);
} }
inline hsScalar hsScalarTriple::operator[] (int i) const inline float hsScalarTriple::operator[] (int i) const
{ {
hsAssert(i >=0 && i <3, "Bad index for hsScalarTriple::operator[]"); hsAssert(i >=0 && i <3, "Bad index for hsScalarTriple::operator[]");
return *(&fX + i); return *(&fX + i);
} }
inline hsScalar hsScalarTriple::InnerProduct(const hsScalarTriple &p) const inline float hsScalarTriple::InnerProduct(const hsScalarTriple &p) const
{ {
hsScalar tmp = fX*p.fX; float tmp = fX*p.fX;
tmp += fY*p.fY; tmp += fY*p.fY;
tmp += fZ*p.fZ; tmp += fZ*p.fZ;
return tmp; return tmp;
} }
inline hsScalar hsScalarTriple::InnerProduct(const hsScalarTriple *p) const inline float hsScalarTriple::InnerProduct(const hsScalarTriple *p) const
{ {
hsScalar tmp = fX*p->fX; float tmp = fX*p->fX;
tmp += fY*p->fY; tmp += fY*p->fY;
tmp += fZ*p->fZ; tmp += fZ*p->fZ;
return tmp; return tmp;
} }
//inline hsScalarTriple hsScalarTriple::LERP(hsScalarTriple &other, hsScalar t) //inline hsScalarTriple hsScalarTriple::LERP(hsScalarTriple &other, float t)
//{ //{
// hsScalarTriple p = other - this; // hsScalarTriple p = other - this;
// p = p / t; // p = p / t;
@ -157,26 +153,26 @@ inline hsScalar hsScalarTriple::InnerProduct(const hsScalarTriple *p) const
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
struct hsPoint3 : public hsScalarTriple { struct hsPoint3 : public hsScalarTriple {
hsPoint3() {}; hsPoint3() {};
hsPoint3(hsScalar x, hsScalar y, hsScalar z) : hsScalarTriple(x,y,z) {} hsPoint3(float x, float y, float z) : hsScalarTriple(x,y,z) {}
explicit hsPoint3(const hsScalarTriple& p) : hsScalarTriple(p) {} explicit hsPoint3(const hsScalarTriple& p) : hsScalarTriple(p) {}
hsPoint3* Set(hsScalar x, hsScalar y, hsScalar z) { return (hsPoint3*)this->hsScalarTriple::Set(x,y,z);} hsPoint3* Set(float x, float y, float z) { return (hsPoint3*)this->hsScalarTriple::Set(x,y,z);}
hsPoint3* Set(const hsScalarTriple* p) { return (hsPoint3*)this->hsScalarTriple::Set(p) ;} hsPoint3* Set(const hsScalarTriple* p) { return (hsPoint3*)this->hsScalarTriple::Set(p) ;}
friend inline hsPoint3 operator+(const hsPoint3& s, const hsPoint3& t); friend inline hsPoint3 operator+(const hsPoint3& s, const hsPoint3& t);
friend inline hsPoint3 operator+(const hsPoint3& s, const hsVector3& t); friend inline hsPoint3 operator+(const hsPoint3& s, const hsVector3& t);
friend inline hsPoint3 operator-(const hsPoint3& s, const hsPoint3& t); friend inline hsPoint3 operator-(const hsPoint3& s, const hsPoint3& t);
friend inline hsPoint3 operator-(const hsPoint3& s); friend inline hsPoint3 operator-(const hsPoint3& s);
friend inline hsPoint3 operator*(const hsScalar& s, const hsPoint3& t); friend inline hsPoint3 operator*(const float& s, const hsPoint3& t);
friend inline hsPoint3 operator*(const hsPoint3& t, const hsScalar& s); friend inline hsPoint3 operator*(const hsPoint3& t, const float& s);
friend inline hsPoint3 operator/(const hsPoint3& t, const hsScalar& s); friend inline hsPoint3 operator/(const hsPoint3& t, const float& s);
hsBool operator==(const hsPoint3& ss) const hsBool operator==(const hsPoint3& ss) const
{ {
return (ss.fX == fX && ss.fY == fY && ss.fZ == fZ); return (ss.fX == fX && ss.fY == fY && ss.fZ == fZ);
} }
hsBool operator!=(const hsPoint3& ss) const { return !(*this == ss); } hsBool operator!=(const hsPoint3& ss) const { return !(*this == ss); }
hsPoint3 &operator+=(const hsScalarTriple &s) { fX += s.fX; fY += s.fY; fZ += s.fZ; return *this; } hsPoint3 &operator+=(const hsScalarTriple &s) { fX += s.fX; fY += s.fY; fZ += s.fZ; return *this; }
hsPoint3 &operator*=(const hsScalar s) { fX *= s; fY *= s; fZ *= s; return *this; } hsPoint3 &operator*=(const float s) { fX *= s; fY *= s; fZ *= s; return *this; }
}; };
@ -185,38 +181,38 @@ struct hsPoint3 : public hsScalarTriple {
struct hsVector3 : public hsScalarTriple { struct hsVector3 : public hsScalarTriple {
hsVector3() {}; hsVector3() {};
hsVector3(hsScalar x, hsScalar y, hsScalar z) : hsScalarTriple(x,y,z) {} hsVector3(float x, float y, float z) : hsScalarTriple(x,y,z) {}
explicit hsVector3(const hsScalarTriple& p) : hsScalarTriple(p) { } explicit hsVector3(const hsScalarTriple& p) : hsScalarTriple(p) { }
hsVector3(const hsPoint3 *p1, const hsPoint3 *p2) { hsVector3(const hsPoint3 *p1, const hsPoint3 *p2) {
fX = p1->fX - p2->fX, fY= p1->fY - p2->fY, fZ = p1->fZ - p2->fZ; } fX = p1->fX - p2->fX, fY= p1->fY - p2->fY, fZ = p1->fZ - p2->fZ; }
hsVector3* Set(hsScalar x, hsScalar y, hsScalar z) { return (hsVector3*)hsScalarTriple::Set(x,y,z); } hsVector3* Set(float x, float y, float z) { return (hsVector3*)hsScalarTriple::Set(x,y,z); }
hsVector3* Set(const hsScalarTriple* p) { return (hsVector3*)hsScalarTriple::Set(p) ;} hsVector3* Set(const hsScalarTriple* p) { return (hsVector3*)hsScalarTriple::Set(p) ;}
hsVector3* Set(const hsScalarTriple* p1, const hsScalarTriple* p2) { return Set(p1->fX-p2->fX,p1->fY-p2->fY,p1->fZ-p2->fZ);} hsVector3* Set(const hsScalarTriple* p1, const hsScalarTriple* p2) { return Set(p1->fX-p2->fX,p1->fY-p2->fY,p1->fZ-p2->fZ);}
void Normalize() void Normalize()
{ {
hsScalar length = this->Magnitude(); float length = this->Magnitude();
// hsIfDebugMessage(length == 0, "Err: Normalizing hsVector3 of length 0", 0); // hsIfDebugMessage(length == 0, "Err: Normalizing hsVector3 of length 0", 0);
if (length == 0) if (length == 0)
return; return;
hsScalar invMag = hsScalarInvert(length); float invMag = hsInvert(length);
fX = hsScalarMul(fX, invMag); fX = (fX * invMag);
fY = hsScalarMul(fY, invMag); fY = (fY * invMag);
fZ = hsScalarMul(fZ, invMag); fZ = (fZ * invMag);
} }
inline void Renormalize() // if the vector is already close to unit length inline void Renormalize() // if the vector is already close to unit length
{ {
hsScalar mag2 = *this * *this; float mag2 = *this * *this;
hsIfDebugMessage(mag2 == 0, "Err: Renormalizing hsVector3 of length 0", 0); hsIfDebugMessage(mag2 == 0, "Err: Renormalizing hsVector3 of length 0", 0);
if (mag2 == 0) if (mag2 == 0)
return; return;
hsScalar invMag = hsInvSqrt(mag2); float invMag = hsInvSqrt(mag2);
fX = hsScalarMul(fX, invMag); fX = (fX * invMag);
fY = hsScalarMul(fY, invMag); fY = (fY * invMag);
fZ = hsScalarMul(fZ, invMag); fZ = (fZ * invMag);
} }
// hsVector3 &Sub(const hsPoint3& s, const hsPoint3& t) // hsVector3 &Sub(const hsPoint3& s, const hsPoint3& t)
@ -225,10 +221,10 @@ struct hsVector3 : public hsScalarTriple {
friend inline hsVector3 operator+(const hsVector3& s, const hsVector3& t); friend inline hsVector3 operator+(const hsVector3& s, const hsVector3& t);
friend inline hsVector3 operator-(const hsVector3& s, const hsVector3& t); friend inline hsVector3 operator-(const hsVector3& s, const hsVector3& t);
friend inline hsVector3 operator-(const hsVector3& s); friend inline hsVector3 operator-(const hsVector3& s);
friend inline hsVector3 operator*(const hsScalar& s, const hsVector3& t); friend inline hsVector3 operator*(const float& s, const hsVector3& t);
friend inline hsVector3 operator*(const hsVector3& t, const hsScalar& s); friend inline hsVector3 operator*(const hsVector3& t, const float& s);
friend inline hsVector3 operator/(const hsVector3& t, const hsScalar& s); friend inline hsVector3 operator/(const hsVector3& t, const float& s);
friend inline hsScalar operator*(const hsVector3& t, const hsVector3& s); friend inline float operator*(const hsVector3& t, const hsVector3& s);
friend hsVector3 operator%(const hsVector3& t, const hsVector3& s); friend hsVector3 operator%(const hsVector3& t, const hsVector3& s);
#if 0 // Havok reeks #if 0 // Havok reeks
friend hsBool32 operator==(const hsVector3& s, const hsVector3& t) friend hsBool32 operator==(const hsVector3& s, const hsVector3& t)
@ -243,20 +239,20 @@ struct hsVector3 : public hsScalarTriple {
#endif // Havok reeks #endif // Havok reeks
hsVector3 &operator+=(const hsScalarTriple &s) { fX += s.fX; fY += s.fY; fZ += s.fZ; return *this; } hsVector3 &operator+=(const hsScalarTriple &s) { fX += s.fX; fY += s.fY; fZ += s.fZ; return *this; }
hsVector3 &operator-=(const hsScalarTriple &s) { fX -= s.fX; fY -= s.fY; fZ -= s.fZ; return *this; } hsVector3 &operator-=(const hsScalarTriple &s) { fX -= s.fX; fY -= s.fY; fZ -= s.fZ; return *this; }
hsVector3 &operator*=(const hsScalar s) { fX *= s; fY *= s; fZ *= s; return *this; } hsVector3 &operator*=(const float s) { fX *= s; fY *= s; fZ *= s; return *this; }
hsVector3 &operator/=(const hsScalar s) { fX /= s; fY /= s; fZ /= s; return *this; } hsVector3 &operator/=(const float s) { fX /= s; fY /= s; fZ /= s; return *this; }
}; };
struct hsPoint4 { struct hsPoint4 {
hsScalar fX, fY, fZ, fW; float fX, fY, fZ, fW;
hsPoint4() {} hsPoint4() {}
hsPoint4(hsScalar x, hsScalar y, hsScalar z, hsScalar w) : fX(x), fY(y), fZ(z), fW(w) {} hsPoint4(float x, float y, float z, float w) : fX(x), fY(y), fZ(z), fW(w) {}
hsScalar& operator[](int i); float& operator[](int i);
hsScalar operator[](int i) const; float operator[](int i) const;
hsPoint4& operator=(const hsPoint3&p) { Set(p.fX, p.fY, p.fZ, hsScalar1); return *this; } hsPoint4& operator=(const hsPoint3&p) { Set(p.fX, p.fY, p.fZ, 1.f); return *this; }
hsPoint4* Set(hsScalar x, hsScalar y, hsScalar z, hsScalar w) hsPoint4* Set(float x, float y, float z, float w)
{ fX = x; fY = y; fZ = z; fW = w; return this; } { fX = x; fY = y; fZ = z; fW = w; return this; }
}; };
@ -282,28 +278,28 @@ inline hsVector3 operator-(const hsVector3& s)
return *result.Set(-s.fX, -s.fY, -s.fZ); return *result.Set(-s.fX, -s.fY, -s.fZ);
} }
inline hsVector3 operator*(const hsVector3& s, const hsScalar& t) inline hsVector3 operator*(const hsVector3& s, const float& t)
{ {
hsVector3 result; hsVector3 result;
return *result.Set(hsScalarMul(s.fX, t), hsScalarMul(s.fY, t), hsScalarMul(s.fZ, t)); return *result.Set(s.fX * t, s.fY * t, s.fZ * t);
} }
inline hsVector3 operator/(const hsVector3& s, const hsScalar& t) inline hsVector3 operator/(const hsVector3& s, const float& t)
{ {
hsVector3 result; hsVector3 result;
return *result.Set(hsScalarDiv(s.fX, t), hsScalarDiv(s.fY, t), hsScalarDiv(s.fZ, t)); return *result.Set(s.fX / t, s.fY / t, s.fZ / t);
} }
inline hsVector3 operator*(const hsScalar& t, const hsVector3& s) inline hsVector3 operator*(const float& t, const hsVector3& s)
{ {
hsVector3 result; hsVector3 result;
return *result.Set(hsScalarMul(s.fX, t), hsScalarMul(s.fY, t), hsScalarMul(s.fZ, t)); return *result.Set(s.fX * t, s.fY * t, s.fZ * t);
} }
inline hsScalar operator*(const hsVector3& t, const hsVector3& s) inline float operator*(const hsVector3& t, const hsVector3& s)
{ {
return hsScalarMul(t.fX, s.fX) + hsScalarMul(t.fY, s.fY) + hsScalarMul(t.fZ, s.fZ); return (t.fX * s.fX) + (t.fY * s.fY) + (t.fZ * s.fZ);
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -343,32 +339,32 @@ inline hsPoint3 operator-(const hsPoint3& s, const hsVector3& t)
return *result.Set(s.fX - t.fX, s.fY - t.fY, s.fZ - t.fZ); return *result.Set(s.fX - t.fX, s.fY - t.fY, s.fZ - t.fZ);
} }
inline hsPoint3 operator*(const hsPoint3& s, const hsScalar& t) inline hsPoint3 operator*(const hsPoint3& s, const float& t)
{ {
hsPoint3 result; hsPoint3 result;
return *result.Set(hsScalarMul(s.fX, t), hsScalarMul(s.fY, t), hsScalarMul(s.fZ, t)); return *result.Set((s.fX * t), (s.fY * t), (s.fZ * t));
} }
inline hsPoint3 operator/(const hsPoint3& s, const hsScalar& t) inline hsPoint3 operator/(const hsPoint3& s, const float& t)
{ {
hsPoint3 result; hsPoint3 result;
return *result.Set(hsScalarDiv(s.fX, t), hsScalarDiv(s.fY, t), hsScalarDiv(s.fZ, t)); return *result.Set((s.fX / t), (s.fY / t), (s.fZ / t));
} }
inline hsPoint3 operator*(const hsScalar& t, const hsPoint3& s) inline hsPoint3 operator*(const float& t, const hsPoint3& s)
{ {
hsPoint3 result; hsPoint3 result;
return *result.Set(hsScalarMul(s.fX, t), hsScalarMul(s.fY, t), hsScalarMul(s.fZ, t)); return *result.Set((s.fX * t), (s.fY * t), (s.fZ * t));
} }
inline hsScalar hsPoint4::operator[] (int i) const inline float hsPoint4::operator[] (int i) const
{ {
hsAssert(i >=0 && i <4, "Bad index for hsPoint4::operator[]"); hsAssert(i >=0 && i <4, "Bad index for hsPoint4::operator[]");
return *(&fX + i); return *(&fX + i);
} }
inline hsScalar& hsPoint4::operator[] (int i) inline float& hsPoint4::operator[] (int i)
{ {
hsAssert(i >=0 && i <4, "Bad index for hsPoint4::operator[]"); hsAssert(i >=0 && i <4, "Bad index for hsPoint4::operator[]");
return *(&fX + i); return *(&fX + i);
@ -389,10 +385,10 @@ struct hsPointNorm {
struct hsPlane3 { struct hsPlane3 {
hsVector3 fN; hsVector3 fN;
hsScalar fD; float fD;
hsPlane3() { } hsPlane3() { }
hsPlane3(const hsVector3* nrml, hsScalar d) hsPlane3(const hsVector3* nrml, float d)
{ fN = *nrml; fD=d; } { fN = *nrml; fD=d; }
hsPlane3(const hsPoint3* pt, const hsVector3* nrml) hsPlane3(const hsPoint3* pt, const hsVector3* nrml)
{ fN = *nrml; fD = -pt->InnerProduct(nrml); } { fN = *nrml; fD = -pt->InnerProduct(nrml); }

2
Sources/Plasma/CoreLib/hsMatrix33.h

@ -47,7 +47,7 @@ class hsStream;
struct hsMatrix33 struct hsMatrix33
{ {
hsScalar fMap[3][3]; float fMap[3][3];
hsMatrix33* Reset(); hsMatrix33* Reset();

215
Sources/Plasma/CoreLib/hsMatrix44.cpp

@ -34,7 +34,8 @@ work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at: or by snail mail at:
Cyan Worlds, Inc. Cyan Worlds, I
nc.
14617 N Newport Hwy 14617 N Newport Hwy
Mead, WA 99021 Mead, WA 99021
@ -44,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsQuat.h" #include "hsQuat.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "hsStream.h" #include "hsStream.h"
#include <math.h>
static hsMatrix44 myIdent = hsMatrix44().Reset(); static hsMatrix44 myIdent = hsMatrix44().Reset();
const hsMatrix44& hsMatrix44::IdentityMatrix() { return myIdent; } const hsMatrix44& hsMatrix44::IdentityMatrix() { return myIdent; }
@ -91,75 +93,6 @@ void hsMatrix44::DecompRigid(hsScalarTriple &translate, hsQuat &rotate) const
} }
#if 0
hsMatrix44& hsMatrix44::Reset()
{
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
fMap[i][j] = (i==j) ? hsScalar1 : 0;
}
}
return *this;
}
#endif
#if 0 // Havok reeks
hsMatrix44 operator*(const hsMatrix44& a, const hsMatrix44& b)
{
hsMatrix44 c;
if( a.fFlags & b.fFlags & hsMatrix44::kIsIdent )
{
c.Reset();
return c;
}
if( a.fFlags & hsMatrix44::kIsIdent )
return b;
if( b.fFlags & hsMatrix44::kIsIdent )
return a;
c.fMap[0][0] = hsScalarMul(a.fMap[0][0], b.fMap[0][0]) + hsScalarMul(a.fMap[0][1], b.fMap[1][0]) + hsScalarMul(a.fMap[0][2], b.fMap[2][0]) + hsScalarMul(a.fMap[0][3], b.fMap[3][0]);
c.fMap[0][1] = hsScalarMul(a.fMap[0][0], b.fMap[0][1]) + hsScalarMul(a.fMap[0][1], b.fMap[1][1]) + hsScalarMul(a.fMap[0][2], b.fMap[2][1]) + hsScalarMul(a.fMap[0][3], b.fMap[3][1]);
c.fMap[0][2] = hsScalarMul(a.fMap[0][0], b.fMap[0][2]) + hsScalarMul(a.fMap[0][1], b.fMap[1][2]) + hsScalarMul(a.fMap[0][2], b.fMap[2][2]) + hsScalarMul(a.fMap[0][3], b.fMap[3][2]);
c.fMap[0][3] = hsScalarMul(a.fMap[0][0], b.fMap[0][3]) + hsScalarMul(a.fMap[0][1], b.fMap[1][3]) + hsScalarMul(a.fMap[0][2], b.fMap[2][3]) + hsScalarMul(a.fMap[0][3], b.fMap[3][3]);
c.fMap[1][0] = hsScalarMul(a.fMap[1][0], b.fMap[0][0]) + hsScalarMul(a.fMap[1][1], b.fMap[1][0]) + hsScalarMul(a.fMap[1][2], b.fMap[2][0]) + hsScalarMul(a.fMap[1][3], b.fMap[3][0]);
c.fMap[1][1] = hsScalarMul(a.fMap[1][0], b.fMap[0][1]) + hsScalarMul(a.fMap[1][1], b.fMap[1][1]) + hsScalarMul(a.fMap[1][2], b.fMap[2][1]) + hsScalarMul(a.fMap[1][3], b.fMap[3][1]);
c.fMap[1][2] = hsScalarMul(a.fMap[1][0], b.fMap[0][2]) + hsScalarMul(a.fMap[1][1], b.fMap[1][2]) + hsScalarMul(a.fMap[1][2], b.fMap[2][2]) + hsScalarMul(a.fMap[1][3], b.fMap[3][2]);
c.fMap[1][3] = hsScalarMul(a.fMap[1][0], b.fMap[0][3]) + hsScalarMul(a.fMap[1][1], b.fMap[1][3]) + hsScalarMul(a.fMap[1][2], b.fMap[2][3]) + hsScalarMul(a.fMap[1][3], b.fMap[3][3]);
c.fMap[2][0] = hsScalarMul(a.fMap[2][0], b.fMap[0][0]) + hsScalarMul(a.fMap[2][1], b.fMap[1][0]) + hsScalarMul(a.fMap[2][2], b.fMap[2][0]) + hsScalarMul(a.fMap[2][3], b.fMap[3][0]);
c.fMap[2][1] = hsScalarMul(a.fMap[2][0], b.fMap[0][1]) + hsScalarMul(a.fMap[2][1], b.fMap[1][1]) + hsScalarMul(a.fMap[2][2], b.fMap[2][1]) + hsScalarMul(a.fMap[2][3], b.fMap[3][1]);
c.fMap[2][2] = hsScalarMul(a.fMap[2][0], b.fMap[0][2]) + hsScalarMul(a.fMap[2][1], b.fMap[1][2]) + hsScalarMul(a.fMap[2][2], b.fMap[2][2]) + hsScalarMul(a.fMap[2][3], b.fMap[3][2]);
c.fMap[2][3] = hsScalarMul(a.fMap[2][0], b.fMap[0][3]) + hsScalarMul(a.fMap[2][1], b.fMap[1][3]) + hsScalarMul(a.fMap[2][2], b.fMap[2][3]) + hsScalarMul(a.fMap[2][3], b.fMap[3][3]);
c.fMap[3][0] = hsScalarMul(a.fMap[3][0], b.fMap[0][0]) + hsScalarMul(a.fMap[3][1], b.fMap[1][0]) + hsScalarMul(a.fMap[3][2], b.fMap[2][0]) + hsScalarMul(a.fMap[3][3], b.fMap[3][0]);
c.fMap[3][1] = hsScalarMul(a.fMap[3][0], b.fMap[0][1]) + hsScalarMul(a.fMap[3][1], b.fMap[1][1]) + hsScalarMul(a.fMap[3][2], b.fMap[2][1]) + hsScalarMul(a.fMap[3][3], b.fMap[3][1]);
c.fMap[3][2] = hsScalarMul(a.fMap[3][0], b.fMap[0][2]) + hsScalarMul(a.fMap[3][1], b.fMap[1][2]) + hsScalarMul(a.fMap[3][2], b.fMap[2][2]) + hsScalarMul(a.fMap[3][3], b.fMap[3][2]);
c.fMap[3][3] = hsScalarMul(a.fMap[3][0], b.fMap[0][3]) + hsScalarMul(a.fMap[3][1], b.fMap[1][3]) + hsScalarMul(a.fMap[3][2], b.fMap[2][3]) + hsScalarMul(a.fMap[3][3], b.fMap[3][3]);
return c;
}
hsVector3 operator*(const hsMatrix44& m, const hsVector3& p)
{
if( m.fFlags & hsMatrix44::kIsIdent )
return p;
hsVector3 rVal;
rVal.fX = hsScalarMul(p.fX, m.fMap[0][0]) + hsScalarMul(p.fY, m.fMap[0][1]) + hsScalarMul(p.fZ, m.fMap[0][2]);
rVal.fY = hsScalarMul(p.fX, m.fMap[1][0]) + hsScalarMul(p.fY, m.fMap[1][1]) + hsScalarMul(p.fZ, m.fMap[1][2]);
rVal.fZ = hsScalarMul(p.fX, m.fMap[2][0]) + hsScalarMul(p.fY, m.fMap[2][1]) + hsScalarMul(p.fZ, m.fMap[2][2]);
return rVal;
}
#else // Havok reeks
hsMatrix44 hsMatrix44::operator*(const hsMatrix44& b) const hsMatrix44 hsMatrix44::operator*(const hsMatrix44& b) const
{ {
hsMatrix44 c; hsMatrix44 c;
@ -175,25 +108,25 @@ hsMatrix44 hsMatrix44::operator*(const hsMatrix44& b) const
if( b.fFlags & hsMatrix44::kIsIdent ) if( b.fFlags & hsMatrix44::kIsIdent )
return *this; return *this;
c.fMap[0][0] = hsScalarMul(fMap[0][0], b.fMap[0][0]) + hsScalarMul(fMap[0][1], b.fMap[1][0]) + hsScalarMul(fMap[0][2], b.fMap[2][0]) + hsScalarMul(fMap[0][3], b.fMap[3][0]); c.fMap[0][0] = (fMap[0][0] * b.fMap[0][0]) + (fMap[0][1] * b.fMap[1][0]) + (fMap[0][2] * b.fMap[2][0]) + (fMap[0][3] * b.fMap[3][0]);
c.fMap[0][1] = hsScalarMul(fMap[0][0], b.fMap[0][1]) + hsScalarMul(fMap[0][1], b.fMap[1][1]) + hsScalarMul(fMap[0][2], b.fMap[2][1]) + hsScalarMul(fMap[0][3], b.fMap[3][1]); c.fMap[0][1] = (fMap[0][0] * b.fMap[0][1]) + (fMap[0][1] * b.fMap[1][1]) + (fMap[0][2] * b.fMap[2][1]) + (fMap[0][3] * b.fMap[3][1]);
c.fMap[0][2] = hsScalarMul(fMap[0][0], b.fMap[0][2]) + hsScalarMul(fMap[0][1], b.fMap[1][2]) + hsScalarMul(fMap[0][2], b.fMap[2][2]) + hsScalarMul(fMap[0][3], b.fMap[3][2]); c.fMap[0][2] = (fMap[0][0] * b.fMap[0][2]) + (fMap[0][1] * b.fMap[1][2]) + (fMap[0][2] * b.fMap[2][2]) + (fMap[0][3] * b.fMap[3][2]);
c.fMap[0][3] = hsScalarMul(fMap[0][0], b.fMap[0][3]) + hsScalarMul(fMap[0][1], b.fMap[1][3]) + hsScalarMul(fMap[0][2], b.fMap[2][3]) + hsScalarMul(fMap[0][3], b.fMap[3][3]); c.fMap[0][3] = (fMap[0][0] * b.fMap[0][3]) + (fMap[0][1] * b.fMap[1][3]) + (fMap[0][2] * b.fMap[2][3]) + (fMap[0][3] * b.fMap[3][3]);
c.fMap[1][0] = hsScalarMul(fMap[1][0], b.fMap[0][0]) + hsScalarMul(fMap[1][1], b.fMap[1][0]) + hsScalarMul(fMap[1][2], b.fMap[2][0]) + hsScalarMul(fMap[1][3], b.fMap[3][0]); c.fMap[1][0] = (fMap[1][0] * b.fMap[0][0]) + (fMap[1][1] * b.fMap[1][0]) + (fMap[1][2] * b.fMap[2][0]) + (fMap[1][3] * b.fMap[3][0]);
c.fMap[1][1] = hsScalarMul(fMap[1][0], b.fMap[0][1]) + hsScalarMul(fMap[1][1], b.fMap[1][1]) + hsScalarMul(fMap[1][2], b.fMap[2][1]) + hsScalarMul(fMap[1][3], b.fMap[3][1]); c.fMap[1][1] = (fMap[1][0] * b.fMap[0][1]) + (fMap[1][1] * b.fMap[1][1]) + (fMap[1][2] * b.fMap[2][1]) + (fMap[1][3] * b.fMap[3][1]);
c.fMap[1][2] = hsScalarMul(fMap[1][0], b.fMap[0][2]) + hsScalarMul(fMap[1][1], b.fMap[1][2]) + hsScalarMul(fMap[1][2], b.fMap[2][2]) + hsScalarMul(fMap[1][3], b.fMap[3][2]); c.fMap[1][2] = (fMap[1][0] * b.fMap[0][2]) + (fMap[1][1] * b.fMap[1][2]) + (fMap[1][2] * b.fMap[2][2]) + (fMap[1][3] * b.fMap[3][2]);
c.fMap[1][3] = hsScalarMul(fMap[1][0], b.fMap[0][3]) + hsScalarMul(fMap[1][1], b.fMap[1][3]) + hsScalarMul(fMap[1][2], b.fMap[2][3]) + hsScalarMul(fMap[1][3], b.fMap[3][3]); c.fMap[1][3] = (fMap[1][0] * b.fMap[0][3]) + (fMap[1][1] * b.fMap[1][3]) + (fMap[1][2] * b.fMap[2][3]) + (fMap[1][3] * b.fMap[3][3]);
c.fMap[2][0] = hsScalarMul(fMap[2][0], b.fMap[0][0]) + hsScalarMul(fMap[2][1], b.fMap[1][0]) + hsScalarMul(fMap[2][2], b.fMap[2][0]) + hsScalarMul(fMap[2][3], b.fMap[3][0]); c.fMap[2][0] = (fMap[2][0] * b.fMap[0][0]) + (fMap[2][1] * b.fMap[1][0]) + (fMap[2][2] * b.fMap[2][0]) + (fMap[2][3] * b.fMap[3][0]);
c.fMap[2][1] = hsScalarMul(fMap[2][0], b.fMap[0][1]) + hsScalarMul(fMap[2][1], b.fMap[1][1]) + hsScalarMul(fMap[2][2], b.fMap[2][1]) + hsScalarMul(fMap[2][3], b.fMap[3][1]); c.fMap[2][1] = (fMap[2][0] * b.fMap[0][1]) + (fMap[2][1] * b.fMap[1][1]) + (fMap[2][2] * b.fMap[2][1]) + (fMap[2][3] * b.fMap[3][1]);
c.fMap[2][2] = hsScalarMul(fMap[2][0], b.fMap[0][2]) + hsScalarMul(fMap[2][1], b.fMap[1][2]) + hsScalarMul(fMap[2][2], b.fMap[2][2]) + hsScalarMul(fMap[2][3], b.fMap[3][2]); c.fMap[2][2] = (fMap[2][0] * b.fMap[0][2]) + (fMap[2][1] * b.fMap[1][2]) + (fMap[2][2] * b.fMap[2][2]) + (fMap[2][3] * b.fMap[3][2]);
c.fMap[2][3] = hsScalarMul(fMap[2][0], b.fMap[0][3]) + hsScalarMul(fMap[2][1], b.fMap[1][3]) + hsScalarMul(fMap[2][2], b.fMap[2][3]) + hsScalarMul(fMap[2][3], b.fMap[3][3]); c.fMap[2][3] = (fMap[2][0] * b.fMap[0][3]) + (fMap[2][1] * b.fMap[1][3]) + (fMap[2][2] * b.fMap[2][3]) + (fMap[2][3] * b.fMap[3][3]);
c.fMap[3][0] = hsScalarMul(fMap[3][0], b.fMap[0][0]) + hsScalarMul(fMap[3][1], b.fMap[1][0]) + hsScalarMul(fMap[3][2], b.fMap[2][0]) + hsScalarMul(fMap[3][3], b.fMap[3][0]); c.fMap[3][0] = (fMap[3][0] * b.fMap[0][0]) + (fMap[3][1] * b.fMap[1][0]) + (fMap[3][2] * b.fMap[2][0]) + (fMap[3][3] * b.fMap[3][0]);
c.fMap[3][1] = hsScalarMul(fMap[3][0], b.fMap[0][1]) + hsScalarMul(fMap[3][1], b.fMap[1][1]) + hsScalarMul(fMap[3][2], b.fMap[2][1]) + hsScalarMul(fMap[3][3], b.fMap[3][1]); c.fMap[3][1] = (fMap[3][0] * b.fMap[0][1]) + (fMap[3][1] * b.fMap[1][1]) + (fMap[3][2] * b.fMap[2][1]) + (fMap[3][3] * b.fMap[3][1]);
c.fMap[3][2] = hsScalarMul(fMap[3][0], b.fMap[0][2]) + hsScalarMul(fMap[3][1], b.fMap[1][2]) + hsScalarMul(fMap[3][2], b.fMap[2][2]) + hsScalarMul(fMap[3][3], b.fMap[3][2]); c.fMap[3][2] = (fMap[3][0] * b.fMap[0][2]) + (fMap[3][1] * b.fMap[1][2]) + (fMap[3][2] * b.fMap[2][2]) + (fMap[3][3] * b.fMap[3][2]);
c.fMap[3][3] = hsScalarMul(fMap[3][0], b.fMap[0][3]) + hsScalarMul(fMap[3][1], b.fMap[1][3]) + hsScalarMul(fMap[3][2], b.fMap[2][3]) + hsScalarMul(fMap[3][3], b.fMap[3][3]); c.fMap[3][3] = (fMap[3][0] * b.fMap[0][3]) + (fMap[3][1] * b.fMap[1][3]) + (fMap[3][2] * b.fMap[2][3]) + (fMap[3][3] * b.fMap[3][3]);
return c; return c;
} }
@ -205,34 +138,13 @@ hsVector3 hsMatrix44::operator*(const hsVector3& p) const
hsVector3 rVal; hsVector3 rVal;
rVal.fX = hsScalarMul(p.fX, fMap[0][0]) + hsScalarMul(p.fY, fMap[0][1]) + hsScalarMul(p.fZ, fMap[0][2]); rVal.fX = (p.fX * fMap[0][0]) + (p.fY * fMap[0][1]) + (p.fZ * fMap[0][2]);
rVal.fY = hsScalarMul(p.fX, fMap[1][0]) + hsScalarMul(p.fY, fMap[1][1]) + hsScalarMul(p.fZ, fMap[1][2]); rVal.fY = (p.fX * fMap[1][0]) + (p.fY * fMap[1][1]) + (p.fZ * fMap[1][2]);
rVal.fZ = hsScalarMul(p.fX, fMap[2][0]) + hsScalarMul(p.fY, fMap[2][1]) + hsScalarMul(p.fZ, fMap[2][2]); rVal.fZ = (p.fX * fMap[2][0]) + (p.fY * fMap[2][1]) + (p.fZ * fMap[2][2]);
return rVal; return rVal;
} }
#endif // Havok reeks
#if 0 // Havok reeks
int operator==(const hsMatrix44& s, const hsMatrix44& t)
{
if( s.fFlags & t.fFlags & hsMatrix44::kIsIdent )
{
return true;
}
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
if (s.fMap[i][j] != t.fMap[i][j])
return false;
}
}
return true;
}
#else // Havok reeks
int hsMatrix44::operator==(const hsMatrix44& ss) const int hsMatrix44::operator==(const hsMatrix44& ss) const
{ {
if( ss.fFlags & fFlags & hsMatrix44::kIsIdent ) if( ss.fFlags & fFlags & hsMatrix44::kIsIdent )
@ -251,7 +163,6 @@ int hsMatrix44::operator==(const hsMatrix44& ss) const
return true; return true;
} }
#endif // Havok reeks
hsMatrix44& hsMatrix44::Scale(const hsVector3* scale) hsMatrix44& hsMatrix44::Scale(const hsVector3* scale)
{ {
@ -315,7 +226,7 @@ hsMatrix44& hsMatrix44::SetTranslate(const hsScalarTriple* pt)
NotIdentity(); NotIdentity();
return *this; return *this;
} }
hsMatrix44& hsMatrix44::MakeRotateMat(int axis, hsScalar radians) hsMatrix44& hsMatrix44::MakeRotateMat(int axis, float radians)
{ {
Reset(); Reset();
SetRotate(axis, radians); SetRotate(axis, radians);
@ -323,7 +234,7 @@ hsMatrix44& hsMatrix44::MakeRotateMat(int axis, hsScalar radians)
return *this; return *this;
} }
hsMatrix44& hsMatrix44::Rotate(int axis, hsScalar radians) hsMatrix44& hsMatrix44::Rotate(int axis, float radians)
{ {
hsMatrix44 rMat; hsMatrix44 rMat;
rMat.MakeRotateMat(axis, radians); rMat.MakeRotateMat(axis, radians);
@ -331,10 +242,10 @@ hsMatrix44& hsMatrix44::Rotate(int axis, hsScalar radians)
return *this; return *this;
} }
hsMatrix44& hsMatrix44::SetRotate(int axis, hsScalar radians) hsMatrix44& hsMatrix44::SetRotate(int axis, float radians)
{ {
hsScalar s = hsSine(radians); float s = sin(radians);
hsScalar c = hsCosine(radians); float c = cos(radians);
int c1,c2; int c1,c2;
switch (axis) switch (axis)
{ {
@ -361,11 +272,11 @@ hsMatrix44& hsMatrix44::SetRotate(int axis, hsScalar radians)
return *this; return *this;
} }
void hsMatrix44::MakeXRotation(hsScalar radians) void hsMatrix44::MakeXRotation(float radians)
{ {
Reset(); Reset();
hsScalar s = hsSine(radians); float s = sin(radians);
hsScalar c = hsCosine(radians); float c = cos(radians);
fMap[1][1] = c; fMap[1][1] = c;
fMap[2][2] = c; fMap[2][2] = c;
@ -374,11 +285,11 @@ void hsMatrix44::MakeXRotation(hsScalar radians)
NotIdentity(); NotIdentity();
} }
void hsMatrix44::MakeYRotation(hsScalar radians) void hsMatrix44::MakeYRotation(float radians)
{ {
Reset(); Reset();
hsScalar s = hsSine(radians); float s = sin(radians);
hsScalar c = hsCosine(radians); float c = cos(radians);
fMap[0][0] = c; fMap[0][0] = c;
fMap[2][2] = c; fMap[2][2] = c;
fMap[0][2] = -s; fMap[0][2] = -s;
@ -386,11 +297,11 @@ void hsMatrix44::MakeYRotation(hsScalar radians)
NotIdentity(); NotIdentity();
} }
void hsMatrix44::MakeZRotation(hsScalar radians) void hsMatrix44::MakeZRotation(float radians)
{ {
Reset(); Reset();
hsScalar s = hsSine(radians); float s = sin(radians);
hsScalar c = hsCosine(radians); float c = cos(radians);
fMap[0][0] = c; fMap[0][0] = c;
fMap[1][1] = c; fMap[1][1] = c;
fMap[0][1] = s; fMap[0][1] = s;
@ -630,14 +541,14 @@ hsMatrix44& hsMatrix44::MakeCameraUpPreserving(const hsPoint3* from, const hsPoi
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
static hsScalar GetDeterminant33(const hsMatrix44* mat) static float GetDeterminant33(const hsMatrix44* mat)
{ {
return hsScalarMul(hsScalarMul(mat->fMap[0][0], mat->fMap[1][1]), mat->fMap[2][2]) + return ((mat->fMap[0][0] * mat->fMap[1][1]) * mat->fMap[2][2]) +
hsScalarMul(hsScalarMul(mat->fMap[0][1], mat->fMap[1][2]), mat->fMap[2][0]) + ((mat->fMap[0][1] * mat->fMap[1][2]) * mat->fMap[2][0]) +
hsScalarMul(hsScalarMul(mat->fMap[0][2], mat->fMap[1][0]), mat->fMap[2][1]) - ((mat->fMap[0][2] * mat->fMap[1][0]) * mat->fMap[2][1]) -
hsScalarMul(hsScalarMul(mat->fMap[0][2], mat->fMap[1][1]), mat->fMap[2][0]) - ((mat->fMap[0][2] * mat->fMap[1][1]) * mat->fMap[2][0]) -
hsScalarMul(hsScalarMul(mat->fMap[0][1], mat->fMap[1][0]), mat->fMap[2][2]) - ((mat->fMap[0][1] * mat->fMap[1][0]) * mat->fMap[2][2]) -
hsScalarMul(hsScalarMul(mat->fMap[0][0], mat->fMap[1][2]), mat->fMap[2][1]); ((mat->fMap[0][0] * mat->fMap[1][2]) * mat->fMap[2][1]);
} }
hsMatrix44* hsMatrix44::GetTranspose(hsMatrix44* transp) const hsMatrix44* hsMatrix44::GetTranspose(hsMatrix44* transp) const
@ -649,21 +560,21 @@ hsMatrix44* hsMatrix44::GetTranspose(hsMatrix44* transp) const
} }
static inline hsScalar Determinant2(hsScalar a, hsScalar b,hsScalar c, hsScalar d) static inline float Determinant2(float a, float b,float c, float d)
{ {
return hsScalarMul(a,d) - hsScalarMul(c,b); return (a * d) - (c * b);
} }
static inline hsScalar Determinant3(hsScalar a, hsScalar b, hsScalar c, static inline float Determinant3(float a, float b, float c,
hsScalar d, hsScalar e, hsScalar f, float d, float e, float f,
hsScalar g, hsScalar h, hsScalar i) float g, float h, float i)
{ {
return hsScalarMul(a, Determinant2(e, f, h, i)) return (a * Determinant2(e, f, h, i))
- hsScalarMul(b, Determinant2(d, f, g, i)) - (b * Determinant2(d, f, g, i))
+ hsScalarMul(c, Determinant2(d, e, g, h)); + (c * Determinant2(d, e, g, h));
} }
hsScalar hsMatrix44::GetDeterminant() const float hsMatrix44::GetDeterminant() const
{ {
return (fMap[0][0]*Determinant3(fMap[1][1], fMap[2][1], fMap[3][1], return (fMap[0][0]*Determinant3(fMap[1][1], fMap[2][1], fMap[3][1],
fMap[1][2], fMap[2][2], fMap[3][2], fMap[1][2], fMap[2][2], fMap[3][2],
@ -753,7 +664,7 @@ hsMatrix44 *hsMatrix44::GetAdjoint(hsMatrix44 *adj) const
hsMatrix44* hsMatrix44::GetInverse(hsMatrix44* inverse) const hsMatrix44* hsMatrix44::GetInverse(hsMatrix44* inverse) const
{ {
hsScalar det = GetDeterminant(); float det = GetDeterminant();
int i,j; int i,j;
if (det == 0.0f) if (det == 0.0f)
@ -762,7 +673,7 @@ hsMatrix44* hsMatrix44::GetInverse(hsMatrix44* inverse) const
return inverse; return inverse;
} }
det = hsScalarInvert(det); det = hsInvert(det);
GetAdjoint(inverse); GetAdjoint(inverse);
for (i=0; i<4; i++) for (i=0; i<4; i++)
@ -840,7 +751,7 @@ hsBool hsMatrix44::IsIdentity(void)
#if 0 // IDENTITY_CRISIS #if 0 // IDENTITY_CRISIS
if( i == j) if( i == j)
{ {
if (fMap[i][j] != hsScalar1) if (fMap[i][j] != 1.f)
{ {
NotIdentity(); NotIdentity();
retVal = false; retVal = false;
@ -855,17 +766,17 @@ hsBool hsMatrix44::IsIdentity(void)
} }
} }
#else // IDENTITY_CRISIS #else // IDENTITY_CRISIS
const hsScalar kEPS = 1.e-5f; const float kEPS = 1.e-5f;
if( i == j) if( i == j)
{ {
if( (fMap[i][j] < hsScalar1-kEPS) || (fMap[i][j] > hsScalar1+kEPS) ) if( (fMap[i][j] < 1.f-kEPS) || (fMap[i][j] > 1.f+kEPS) )
{ {
NotIdentity(); NotIdentity();
retVal = false; retVal = false;
} }
else else
{ {
fMap[i][j] = hsScalar1; fMap[i][j] = 1.f;
} }
} }
else else
@ -909,12 +820,7 @@ void hsMatrix44::Read(hsStream *stream)
int i,j; int i,j;
for(i=0; i<4; i++) for(i=0; i<4; i++)
for(j=0; j<4; j++) for(j=0; j<4; j++)
#if HS_SCALAR_IS_FIXED
fMap[i][j] = stream->ReadLE32();
#endif
#if HS_SCALAR_IS_FLOAT
fMap[i][j] = stream->ReadLEFloat(); fMap[i][j] = stream->ReadLEFloat();
#endif
IsIdentity(); IsIdentity();
} }
else else
@ -930,11 +836,6 @@ void hsMatrix44::Write(hsStream *stream)
int i,j; int i,j;
for(i=0; i<4; i++) for(i=0; i<4; i++)
for(j=0; j<4; j++) for(j=0; j<4; j++)
#if HS_SCALAR_IS_FIXED
stream->WriteLE32(fMap[i][j]);
#endif
#if HS_SCALAR_IS_FLOAT
stream->WriteLEFloat(fMap[i][j]); stream->WriteLEFloat(fMap[i][j]);
#endif
} }
} }

50
Sources/Plasma/CoreLib/hsMatrix44.h

@ -59,7 +59,7 @@ struct hsMatrix44 {
kUp, kUp,
kView kView
}; };
hsScalar fMap[4][4]; float fMap[4][4];
uint32_t fFlags; uint32_t fFlags;
hsMatrix44() : fFlags(0) {} hsMatrix44() : fFlags(0) {}
@ -76,7 +76,7 @@ struct hsMatrix44 {
// Concat transform // Concat transform
hsMatrix44& Translate(const hsVector3 *); hsMatrix44& Translate(const hsVector3 *);
hsMatrix44& Scale(const hsVector3 *); hsMatrix44& Scale(const hsVector3 *);
hsMatrix44& Rotate(int axis, hsScalar radians); hsMatrix44& Rotate(int axis, float radians);
hsMatrix44& Reset(hsBool asIdent=true) hsMatrix44& Reset(hsBool asIdent=true)
{ {
@ -92,7 +92,7 @@ struct hsMatrix44 {
// Create matrix from scratch // Create matrix from scratch
hsMatrix44& MakeTranslateMat(const hsVector3 *trans); hsMatrix44& MakeTranslateMat(const hsVector3 *trans);
hsMatrix44& MakeScaleMat(const hsVector3 *scale); hsMatrix44& MakeScaleMat(const hsVector3 *scale);
hsMatrix44& MakeRotateMat(int axis, hsScalar radians); hsMatrix44& MakeRotateMat(int axis, float radians);
hsMatrix44& Make(const hsPoint3* from, const hsPoint3* at, hsMatrix44& Make(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up); // Not a camera matrix const hsVector3* up); // Not a camera matrix
hsMatrix44& MakeUpPreserving(const hsPoint3* from, const hsPoint3* at, hsMatrix44& MakeUpPreserving(const hsPoint3* from, const hsPoint3* at,
@ -104,7 +104,7 @@ struct hsMatrix44 {
const hsVector3* up); const hsVector3* up);
hsBool GetParity() const; hsBool GetParity() const;
hsScalar GetDeterminant() const; float GetDeterminant() const;
hsMatrix44* GetInverse(hsMatrix44* inverse) const; hsMatrix44* GetInverse(hsMatrix44* inverse) const;
hsMatrix44* GetTranspose(hsMatrix44* inverse) const; hsMatrix44* GetTranspose(hsMatrix44* inverse) const;
hsMatrix44* GetAdjoint(hsMatrix44* adjoint) const; hsMatrix44* GetAdjoint(hsMatrix44* adjoint) const;
@ -120,67 +120,39 @@ struct hsMatrix44 {
// Change component of matrix // Change component of matrix
hsMatrix44& SetTranslate(const hsScalarTriple *); hsMatrix44& SetTranslate(const hsScalarTriple *);
hsMatrix44& SetScale(const hsVector3 *); hsMatrix44& SetScale(const hsVector3 *);
hsMatrix44& SetRotate(int axis, hsScalar radians); hsMatrix44& SetRotate(int axis, float radians);
hsVector3 RemoveScale(); // returns old scale hsVector3 RemoveScale(); // returns old scale
void MakeXRotation(hsScalar radians); void MakeXRotation(float radians);
void MakeYRotation(hsScalar radians); void MakeYRotation(float radians);
void MakeZRotation(hsScalar radians); void MakeZRotation(float radians);
#if 0 // Havok reeks
friend hsPoint3 operator*(const hsMatrix44& m, const hsPoint3& p)
{
if( m.fFlags & hsMatrix44::kIsIdent )
return p;
hsPoint3 rVal;
rVal.fX = hsScalarMul(p.fX, m.fMap[0][0]) + hsScalarMul(p.fY, m.fMap[0][1]) + hsScalarMul(p.fZ, m.fMap[0][2]) + m.fMap[0][3];
rVal.fY = hsScalarMul(p.fX, m.fMap[1][0]) + hsScalarMul(p.fY, m.fMap[1][1]) + hsScalarMul(p.fZ, m.fMap[1][2]) + m.fMap[1][3];
rVal.fZ = hsScalarMul(p.fX, m.fMap[2][0]) + hsScalarMul(p.fY, m.fMap[2][1]) + hsScalarMul(p.fZ, m.fMap[2][2]) + m.fMap[2][3];
return rVal;
}
friend hsVector3 operator*(const hsMatrix44& m, const hsVector3& p);
friend hsMatrix44 operator*(const hsMatrix44& a, const hsMatrix44& b);
#else // Havok reeks
hsPoint3 operator*(const hsPoint3& p) const hsPoint3 operator*(const hsPoint3& p) const
{ {
if( fFlags & hsMatrix44::kIsIdent ) if( fFlags & hsMatrix44::kIsIdent )
return p; return p;
hsPoint3 rVal; hsPoint3 rVal;
rVal.fX = hsScalarMul(p.fX, fMap[0][0]) + hsScalarMul(p.fY, fMap[0][1]) + hsScalarMul(p.fZ, fMap[0][2]) + fMap[0][3]; rVal.fX = (p.fX * fMap[0][0]) + (p.fY * fMap[0][1]) + (p.fZ * fMap[0][2]) + fMap[0][3];
rVal.fY = hsScalarMul(p.fX, fMap[1][0]) + hsScalarMul(p.fY, fMap[1][1]) + hsScalarMul(p.fZ, fMap[1][2]) + fMap[1][3]; rVal.fY = (p.fX * fMap[1][0]) + (p.fY * fMap[1][1]) + (p.fZ * fMap[1][2]) + fMap[1][3];
rVal.fZ = hsScalarMul(p.fX, fMap[2][0]) + hsScalarMul(p.fY, fMap[2][1]) + hsScalarMul(p.fZ, fMap[2][2]) + fMap[2][3]; rVal.fZ = (p.fX * fMap[2][0]) + (p.fY * fMap[2][1]) + (p.fZ * fMap[2][2]) + fMap[2][3];
return rVal; return rVal;
} }
hsVector3 operator*(const hsVector3& p) const; hsVector3 operator*(const hsVector3& p) const;
hsMatrix44 operator*(const hsMatrix44& b) const; hsMatrix44 operator*(const hsMatrix44& b) const;
#endif // Havok reeks
hsPoint3* MapPoints(long count, hsPoint3 points[]) const; hsPoint3* MapPoints(long count, hsPoint3 points[]) const;
hsBool IsIdentity(void); hsBool IsIdentity(void);
void NotIdentity() { fFlags &= ~kIsIdent; } void NotIdentity() { fFlags &= ~kIsIdent; }
#if 0 // Havok reeks
friend int operator==(const hsMatrix44& s, const hsMatrix44& t);
friend int operator!=(const hsMatrix44& s, const hsMatrix44& t);
#else // Havok reeks
hsBool operator==(const hsMatrix44& ss) const; hsBool operator==(const hsMatrix44& ss) const;
hsBool operator!=(const hsMatrix44& ss) const { return !(ss == *this); } hsBool operator!=(const hsMatrix44& ss) const { return !(ss == *this); }
#endif // Havok reeks
void Read(hsStream *stream); void Read(hsStream *stream);
void Write(hsStream *stream); void Write(hsStream *stream);
}; };
#if 0 // Havok reeks
inline int operator!=(const hsMatrix44& s, const hsMatrix44& t)
{
return (!(s==t));
}
#endif // Havok reeks
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#endif #endif

162
Sources/Plasma/CoreLib/hsPoint2.h

@ -42,90 +42,92 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef hsPoint2_Defined #ifndef hsPoint2_Defined
#define hsPoint2_Defined #define hsPoint2_Defined
#include "hsScalar.h" #include <cmath>
#define HS_POINT2_NAME hsIntPoint2 struct hsPolar {
#define HS_POINT2_TYPE int32_t float fRadius;
#include "HS_POINT2.inc" float fAngle;
}; };
#define HS_POINT2_NAME hsFixedPoint2 struct hsPoint2 {
#define HS_POINT2_TYPE hsFixed float fX, fY;
#include "HS_POINT2.inc"
hsPoint2& Set(float x, float y)
hsFixedPoint2& operator=(const hsIntPoint2& src) {
{ fX = x;
this->fX = hsIntToFixed(src.fX); fY = y;
this->fY = hsIntToFixed(src.fY); return *this;
return *this; }
} hsPoint2& operator+=(const hsPoint2& s)
{
hsFixed Magnitude() const { return hsMagnitude32(fX, fY); } this->fX += s.fX;
this->fY += s.fY;
static hsFixed Magnitude(hsFixed x, hsFixed y) return *this;
{ }
return hsMagnitude32(x, y); hsPoint2& operator-=(const hsPoint2& s)
} {
static hsFixed Distance(const hsFixedPoint2& p1, const hsFixedPoint2& p2) this->fX -= s.fX;
{ this->fY -= s.fY;
return hsMagnitude32(p2.fX - p1.fX, p2.fY - p1.fY); return *this;
} }
int operator==(const hsPoint2& ss) const
{
return (ss.fX == fX && ss.fY == fY);
}
int operator!=(const hsPoint2& ss)
{
return !(ss == *this);
}
friend hsPoint2 operator+(const hsPoint2& s, const hsPoint2& t)
{
hsPoint2 result;
result.Set(s.fX + t.fX, s.fY + t.fY);
return result;
}
friend hsPoint2 operator-(const hsPoint2& s, const hsPoint2& t)
{
hsPoint2 result;
result.Set(s.fX - t.fX, s.fY - t.fY);
return result;
}
friend hsPoint2 operator-(const hsPoint2& s)
{
hsPoint2 result = { -s.fX, -s.fY };
return result;
}
friend hsPoint2 operator*(const hsPoint2& s, float t)
{
hsPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
friend hsPoint2 operator*(float t, const hsPoint2& s)
{
hsPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
hsPoint2* Grid(float period);
hsBool CloseEnough(const hsPoint2* p, float tolerance) const;
float MagnitudeSquared() const { return fX * fX + fY * fY; }
float Magnitude() const { return Magnitude(fX, fY); }
hsPolar* ToPolar(hsPolar* polar) const;
static float Magnitude(float x, float y) { return sqrt(x * x + y * y); }
static float Distance(const hsPoint2& p1, const hsPoint2& p2);
static hsPoint2 Average(const hsPoint2& a, const hsPoint2& b)
{
hsPoint2 result;
result.Set((a.fX + b.fX) * float(0.5), (a.fY + b.fY) * float(0.5));
return result;
}
static float ComputeAngle(const hsPoint2& a, const hsPoint2& b, const hsPoint2& c);
}; };
#if HS_CAN_USE_FLOAT
struct hsPolar {
float fRadius;
float fAngle;
};
#define HS_POINT2_NAME hsFloatPoint2
#define HS_POINT2_TYPE float
#include "HS_POINT2.inc"
hsFloatPoint2& operator=(const hsIntPoint2& src)
{
this->fX = float(src.fX);
this->fY = float(src.fY);
return *this;
}
friend hsFloatPoint2 operator*(const hsFloatPoint2& s, float t)
{
hsFloatPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
friend hsFloatPoint2 operator*(float t, const hsFloatPoint2& s)
{
hsFloatPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
hsFloatPoint2* Grid(float period);
hsBool CloseEnough(const hsFloatPoint2* p, float tolerance) const;
float Magnitude() const { return hsFloatPoint2::Magnitude(fX, fY); }
float MagnitudeSquared() const { return fX * fX + fY * fY; }
hsPolar* ToPolar(hsPolar* polar) const;
static float Magnitude(float x, float y) { return hsSquareRoot(x * x + y * y); }
static hsScalar Distance(const hsFloatPoint2& p1, const hsFloatPoint2& p2);
static hsFloatPoint2 Average(const hsFloatPoint2& a, const hsFloatPoint2& b)
{
hsFloatPoint2 result;
result.Set((a.fX + b.fX) * float(0.5), (a.fY + b.fY) * float(0.5));
return result;
}
static hsScalar ComputeAngle(const hsFloatPoint2& a, const hsFloatPoint2& b, const hsFloatPoint2& c);
};
#endif
#if HS_SCALAR_IS_FIXED
typedef hsFixedPoint2 hsPoint2;
#else
typedef hsFloatPoint2 hsPoint2;
#endif
#endif // hsPoint2_Defined #endif // hsPoint2_Defined

82
Sources/Plasma/CoreLib/hsQuat.cpp

@ -53,13 +53,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
// Construct quat from angle (in radians) and axis of rotation // Construct quat from angle (in radians) and axis of rotation
// //
hsQuat::hsQuat(hsScalar rad, const hsVector3* axis) hsQuat::hsQuat(float rad, const hsVector3* axis)
{ {
// hsAssert(rad >= -hsScalarPI && rad <= hsScalarPI, "Quat: Angle should be between -PI and PI"); // hsAssert(rad >= -M_PI && rad <= M_PI, "Quat: Angle should be between -PI and PI");
fW = hsCosine(rad*0.5f); fW = cos(rad*0.5f);
hsScalar s = hsSine(rad*0.5f); float s = sin(rad*0.5f);
fX = axis->fX*s; fX = axis->fX*s;
fY = axis->fY*s; fY = axis->fY*s;
fZ = axis->fZ*s; fZ = axis->fZ*s;
@ -68,7 +68,7 @@ hsQuat::hsQuat(hsScalar rad, const hsVector3* axis)
hsQuat hsQuat::Inverse() hsQuat hsQuat::Inverse()
{ {
hsQuat q2 = Conjugate(); hsQuat q2 = Conjugate();
hsScalar msInv = 1.0f/q2.MagnitudeSquared(); float msInv = 1.0f/q2.MagnitudeSquared();
return (q2 * msInv); return (q2 * msInv);
} }
@ -82,11 +82,11 @@ hsPoint3 hsQuat::Rotate(const hsScalarTriple* v)
return hsPoint3(res.fX, res.fY, res.fZ); return hsPoint3(res.fX, res.fY, res.fZ);
} }
void hsQuat::SetAngleAxis(const hsScalar rad, const hsVector3 &axis) void hsQuat::SetAngleAxis(const float rad, const hsVector3 &axis)
{ {
fW = hsCosine(rad*0.5f); fW = cos(rad*0.5f);
hsScalar s = hsSine(rad*0.5f); float s = sin(rad*0.5f);
fX = axis.fX*s; fX = axis.fX*s;
fY = axis.fY*s; fY = axis.fY*s;
fZ = axis.fZ*s; fZ = axis.fZ*s;
@ -95,16 +95,16 @@ void hsQuat::SetAngleAxis(const hsScalar rad, const hsVector3 &axis)
// //
// Might want to Normalize before calling this // Might want to Normalize before calling this
// //
void hsQuat::GetAngleAxis(hsScalar *rad, hsVector3 *axis) const void hsQuat::GetAngleAxis(float *rad, hsVector3 *axis) const
{ {
hsAssert((fW >= -1) && (fW <= 1), "Invalid acos argument"); hsAssert((fW >= -1) && (fW <= 1), "Invalid acos argument");
hsScalar ac = hsACosine(fW); float ac = acos(fW);
*rad = 2.0f * ac; *rad = 2.0f * ac;
hsScalar s = hsSine(ac); float s = sin(ac);
if (s != 0.0f) if (s != 0.0f)
{ {
hsScalar invS = 1.0f/s; float invS = 1.0f/s;
axis->Set(fX*invS, fY*invS, fZ*invS); axis->Set(fX*invS, fY*invS, fZ*invS);
} }
else else
@ -114,7 +114,7 @@ void hsQuat::GetAngleAxis(hsScalar *rad, hsVector3 *axis) const
// //
// //
// //
hsScalar hsQuat::MagnitudeSquared() float hsQuat::MagnitudeSquared()
{ {
return (fX*fX + fY*fY + fZ*fZ + fW*fW); return (fX*fX + fY*fY + fZ*fZ + fW*fW);
} }
@ -122,9 +122,9 @@ hsScalar hsQuat::MagnitudeSquared()
// //
// //
// //
hsScalar hsQuat::Magnitude() float hsQuat::Magnitude()
{ {
return hsSquareRoot(MagnitudeSquared()); return sqrt(MagnitudeSquared());
} }
// //
@ -132,7 +132,7 @@ hsScalar hsQuat::Magnitude()
// //
void hsQuat::Normalize() void hsQuat::Normalize()
{ {
hsScalar invMag = 1.0f/Magnitude(); float invMag = 1.0f/Magnitude();
fX *= invMag; fX *= invMag;
fY *= invMag; fY *= invMag;
fZ *= invMag; fZ *= invMag;
@ -145,11 +145,11 @@ void hsQuat::Normalize()
void hsQuat::NormalizeIfNeeded() void hsQuat::NormalizeIfNeeded()
{ {
hsScalar magSquared = MagnitudeSquared(); float magSquared = MagnitudeSquared();
if (magSquared == 1.0f) if (magSquared == 1.0f)
return; return;
hsScalar invMag = 1.0f/hsSquareRoot(magSquared); float invMag = 1.0f/sqrt(magSquared);
fX *= invMag; fX *= invMag;
fY *= invMag; fY *= invMag;
fZ *= invMag; fZ *= invMag;
@ -259,17 +259,17 @@ void hsQuat::Write(hsStream *stream)
// //
// Interpolate on a sphere. // Interpolate on a sphere.
// //
void hsQuat::SetFromSlerp(hsQuat *q1, hsQuat *q2, hsScalar t) void hsQuat::SetFromSlerp(hsQuat *q1, hsQuat *q2, float t)
{ {
hsAssert(t>=0.0 && t<= 1.0, "Quat slerp param must be between 0 an 1"); hsAssert(t>=0.0 && t<= 1.0, "Quat slerp param must be between 0 an 1");
hsScalar theta = hsACosine(q1->Dot(*q2)); float theta = acos(q1->Dot(*q2));
hsScalar st = hsSine(theta); float st = sin(theta);
assert(st != 0.0); assert(st != 0.0);
hsScalar s1 = hsSine(1.0-t)*theta / st; float s1 = sin(1.0-t)*theta / st;
hsScalar s2 = hsSine(t)*theta / st; float s2 = sin(t)*theta / st;
*this = (*q1) * s1 + (*q2) * s2; *this = (*q1) * s1 + (*q2) * s2;
} }
@ -280,15 +280,15 @@ void hsQuat::SetFromSlerp(hsQuat *q1, hsQuat *q2, hsScalar t)
#define EPSILON 1.0E-6 /* a tiny number */ #define EPSILON 1.0E-6 /* a tiny number */
void hsQuat::SetFromSlerp(const hsQuat &a, const hsQuat &b, hsScalar alpha, int spin) void hsQuat::SetFromSlerp(const hsQuat &a, const hsQuat &b, float alpha, int spin)
// double alpha; /* interpolation parameter (0 to 1) */ // double alpha; /* interpolation parameter (0 to 1) */
// Quaternion *a, *b; /* start and end unit quaternions */ // Quaternion *a, *b; /* start and end unit quaternions */
// int spin; /* number of extra spin rotations */ // int spin; /* number of extra spin rotations */
{ {
hsScalar beta; /* complementary interp parameter */ float beta; /* complementary interp parameter */
hsScalar theta; /* angle between A and B */ float theta; /* angle between A and B */
hsScalar sin_t, cos_t; /* sine, cosine of theta */ float sin_t, cos_t; /* sine, cosine of theta */
hsScalar phi; /* theta plus spins */ float phi; /* theta plus spins */
int bflip; /* use negation of B? */ int bflip; /* use negation of B? */
/* cosine theta = dot product of A and B */ /* cosine theta = dot product of A and B */
@ -313,12 +313,12 @@ void hsQuat::SetFromSlerp(const hsQuat &a, const hsQuat &b, hsScalar alpha, int
} else } else
{ /* normal case */ { /* normal case */
// hsAssert((cos_t >= -1) && (cos_t <= 1), "Invalid acos argument"); // hsAssert((cos_t >= -1) && (cos_t <= 1), "Invalid acos argument");
theta = hsACosine(cos_t); theta = acos(cos_t);
phi = theta + spin * hsScalarPI; phi = theta + spin * M_PI;
sin_t = hsSine(theta); sin_t = sin(theta);
hsAssert(sin_t != 0.0, "Invalid sin value in quat slerp"); hsAssert(sin_t != 0.0, "Invalid sin value in quat slerp");
beta = hsSine(theta - alpha*phi) / sin_t; beta = sin(theta - alpha*phi) / sin_t;
alpha = hsSine(alpha*phi) / sin_t; alpha = sin(alpha*phi) / sin_t;
} }
if (bflip) if (bflip)
@ -337,11 +337,11 @@ void hsQuat::SetFromSlerp(const hsQuat &a, const hsQuat &b, hsScalar alpha, int
// //
void hsQuat::SetFromMatrix(const hsMatrix44* mat) void hsQuat::SetFromMatrix(const hsMatrix44* mat)
{ {
hsScalar wSq = 0.25f*(1 + mat->fMap[0][0] + mat->fMap[1][1] + mat->fMap[2][2]); float wSq = 0.25f*(1 + mat->fMap[0][0] + mat->fMap[1][1] + mat->fMap[2][2]);
if (wSq > EPSILON) if (wSq > EPSILON)
{ {
fW = hsSquareRoot(wSq); fW = sqrt(wSq);
hsScalar iw4 = 1.0f/(4.0f*fW); float iw4 = 1.0f/(4.0f*fW);
fX = (mat->fMap[2][1] - mat->fMap[1][2]) * iw4; fX = (mat->fMap[2][1] - mat->fMap[1][2]) * iw4;
fY = (mat->fMap[0][2] - mat->fMap[2][0]) * iw4; fY = (mat->fMap[0][2] - mat->fMap[2][0]) * iw4;
fZ = (mat->fMap[1][0] - mat->fMap[0][1]) * iw4; fZ = (mat->fMap[1][0] - mat->fMap[0][1]) * iw4;
@ -349,21 +349,21 @@ void hsQuat::SetFromMatrix(const hsMatrix44* mat)
} }
fW = 0; fW = 0;
hsScalar xSq = -0.5f*(mat->fMap[1][1] + mat->fMap[2][2]); float xSq = -0.5f*(mat->fMap[1][1] + mat->fMap[2][2]);
if (xSq > EPSILON) if (xSq > EPSILON)
{ {
fX = hsSquareRoot(xSq); fX = sqrt(xSq);
hsScalar ix2 = 1.0f/(2.0f*fX); float ix2 = 1.0f/(2.0f*fX);
fY = mat->fMap[1][0] * ix2; fY = mat->fMap[1][0] * ix2;
fZ = mat->fMap[2][0] * ix2; fZ = mat->fMap[2][0] * ix2;
return; return;
} }
fX = 0; fX = 0;
hsScalar ySq = 0.5f * (1 - mat->fMap[2][2]); float ySq = 0.5f * (1 - mat->fMap[2][2]);
if (ySq > EPSILON) if (ySq > EPSILON)
{ {
fY = hsSquareRoot(ySq); fY = sqrt(ySq);
fZ = mat->fMap[2][1] / (2.0f*fY); fZ = mat->fMap[2][1] / (2.0f*fY);
return; return;
} }

32
Sources/Plasma/CoreLib/hsQuat.h

@ -53,29 +53,29 @@ struct hsMatrix44;
class hsQuat { class hsQuat {
public: public:
hsScalar fX,fY,fZ,fW; float fX,fY,fZ,fW;
// Constructors // Constructors
hsQuat(){} hsQuat(){}
hsQuat(hsScalar X, hsScalar Y, hsScalar Z, hsScalar W) : hsQuat(float X, float Y, float Z, float W) :
fX(X), fY(Y), fZ(Z), fW(W) {} fX(X), fY(Y), fZ(Z), fW(W) {}
hsQuat(const hsQuat& a) { fX = a.fX; fY = a.fY; fZ = a.fZ; fW = a.fW; } hsQuat(const hsQuat& a) { fX = a.fX; fY = a.fY; fZ = a.fZ; fW = a.fW; }
hsQuat(hsScalar af[4]) { fX = af[0]; fY = af[1]; fZ = af[2]; fW = af[3]; } hsQuat(float af[4]) { fX = af[0]; fY = af[1]; fZ = af[2]; fW = af[3]; }
hsQuat(hsScalar rad, const hsVector3* axis); hsQuat(float rad, const hsVector3* axis);
static hsQuat QuatFromMatrix44(const hsMatrix44& mat); static hsQuat QuatFromMatrix44(const hsMatrix44& mat);
hsQuat& SetFromMatrix44(const hsMatrix44& mat); hsQuat& SetFromMatrix44(const hsMatrix44& mat);
void SetFromMatrix(const hsMatrix44 *mat); void SetFromMatrix(const hsMatrix44 *mat);
void SetFromSlerp(const hsQuat &q1, const hsQuat &q2, hsScalar t, int spin=0); void SetFromSlerp(const hsQuat &q1, const hsQuat &q2, float t, int spin=0);
void Set(hsScalar X, hsScalar Y, hsScalar Z, hsScalar W) void Set(float X, float Y, float Z, float W)
{ fX = X; fY = Y; fZ = Z; fW = W; } { fX = X; fY = Y; fZ = Z; fW = W; }
void GetAngleAxis(hsScalar *rad, hsVector3 *axis) const; void GetAngleAxis(float *rad, hsVector3 *axis) const;
void SetAngleAxis(const hsScalar rad, const hsVector3 &axis); void SetAngleAxis(const float rad, const hsVector3 &axis);
hsPoint3 Rotate(const hsScalarTriple* v); hsPoint3 Rotate(const hsScalarTriple* v);
// Access operators // Access operators
hsScalar& operator[](int i) { return (&fX)[i]; } float& operator[](int i) { return (&fX)[i]; }
const hsScalar& operator[](int i) const { return (&fX)[i]; } const float& operator[](int i) const { return (&fX)[i]; }
// Unary operators // Unary operators
hsQuat operator-() const { return(hsQuat(-fX,-fY,-fZ,-fW)); } hsQuat operator-() const { return(hsQuat(-fX,-fY,-fZ,-fW)); }
@ -84,14 +84,14 @@ public:
// Comparison // Comparison
int operator==(const hsQuat& a) const int operator==(const hsQuat& a) const
{ return (fX==a.fX && fY==a.fY && fZ==a.fZ && fW==a.fW); } { return (fX==a.fX && fY==a.fY && fZ==a.fZ && fW==a.fW); }
void Identity() { fX = fY = fZ = (hsScalar)0.0; fW = (hsScalar) 1.0; } void Identity() { fX = fY = fZ = (float)0.0; fW = (float) 1.0; }
int IsIdentity() const int IsIdentity() const
{ return (fX==0.0 && fY==0.0 && fZ==0.0 && fW==1.0); } { return (fX==0.0 && fY==0.0 && fZ==0.0 && fW==1.0); }
void Normalize(); void Normalize();
void NormalizeIfNeeded(); void NormalizeIfNeeded();
void MakeMatrix(hsMatrix44 *mat) const; void MakeMatrix(hsMatrix44 *mat) const;
hsScalar Magnitude(); float Magnitude();
hsScalar MagnitudeSquared(); float MagnitudeSquared();
hsQuat Conjugate() const hsQuat Conjugate() const
{ return hsQuat(-fX,-fY,-fZ,fW); } { return hsQuat(-fX,-fY,-fZ,fW); }
hsQuat Inverse(); hsQuat Inverse();
@ -99,13 +99,13 @@ public:
hsQuat operator-(const hsQuat&) const; hsQuat operator-(const hsQuat&) const;
hsQuat operator+(const hsQuat&) const; hsQuat operator+(const hsQuat&) const;
hsQuat operator*(const hsQuat&) const; hsQuat operator*(const hsQuat&) const;
hsQuat operator*(hsScalar f) const hsQuat operator*(float f) const
{ return hsQuat(fX*f,fY*f,fZ*f,fW*f); } { return hsQuat(fX*f,fY*f,fZ*f,fW*f); }
hsQuat operator/(hsScalar f) const hsQuat operator/(float f) const
{ return hsQuat(fX/f,fY/f,fZ/f,fW/f); } { return hsQuat(fX/f,fY/f,fZ/f,fW/f); }
hsQuat operator/(const hsQuat&) const; hsQuat operator/(const hsQuat&) const;
hsScalar Dot(const hsQuat &q2) const float Dot(const hsQuat &q2) const
{ return (fX*q2.fX + fY*q2.fY + fZ*q2.fZ + fW*q2.fW); } { return (fX*q2.fX + fY*q2.fY + fZ*q2.fZ + fW*q2.fW); }
// I/O // I/O

200
Sources/Plasma/CoreLib/hsScalar.h

@ -1,200 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef hsScalarMacrosDefined
#define hsScalarMacrosDefined
#include "hsFixedTypes.h"
#ifndef HS_SCALAR_IS_FLOAT
#define HS_SCALAR_IS_FIXED 0
#define HS_SCALAR_IS_FLOAT 1
#define HS_NEVER_USE_FLOAT 0
#endif
#if HS_SCALAR_IS_FLOAT && HS_NEVER_USE_FLOAT
#error "can't define HS_SCALAR_IS_FLOAT and HS_NEVER_USE_FLOAT"
#endif
#if HS_SCALAR_IS_FLOAT
#include <math.h>
#endif
#define hsScalarDegToRad(deg) hsScalarMul(deg, hsScalarPI / 180)
#define hsScalarRadToDeg(rad) hsScalarMul(rad, 180 / hsScalarPI)
#if HS_SCALAR_IS_FIXED
typedef hsFixed hsScalar;
#define hsScalar1 hsFixed1
#define hsScalarHalf (hsFixed1 >> 1)
#define hsScalarPI (hsFixedPI)
#define hsScalarMax (0x7fffffff)
#if HS_CAN_USE_FLOAT
#define hsFloatToScalar(x) hsFixed((x) * float(hsFixed1))
#define hsScalarToFloat(x) ((x) / float(hsFixed1))
#endif
#define hsIntToScalar(x) hsIntToFixed(x)
#define hsScalarToInt(x) hsFixedToInt(x)
#define hsScalarRound(x) hsFixedRound(x)
#define hsFixedToScalar(x) (x)
#define hsScalarToFixed(x) (x)
#define hsFractToScalar(x) hsFractToFixed(x)
#define hsScalarToFract(x) hsFixedToFract(x)
#define hsScalarMul(a, b) hsFixMul(a, b)
#define hsScalarMul2(a) ((a) << 1)
#define hsScalarDiv(a, b) hsFixDiv(a, b)
#define hsScalarDiv2(a) ((a) >> 1)
#define hsScalarInvert(a) hsFixDiv(hsFixed1, a)
#define hsScalarMod(a,b) ((a) % (b))
#define hsScalarMulDiv(n1, n2, d) hsMulDiv32(n1, n2, d)
#define hsScalarMulAdd(a, b, c) (hsFixMul(a, b) + (c))
#define hsSquareRoot(scalar) hsFixSqrt(scalar)
#define hsSine(angle) hsFixedSin(angle)
#define hsCosine(angle) hsFixedCos(angle)
#define hsTan(angle) (hsSine(angle)/hsCosine(angle))
#define hsASine(value) hsFixedASin(value)
#define hsACosine(value) hsFixedACos(value)
#ifdef __cplusplus
inline hsScalar hsScalarAverage(hsScalar a, hsScalar b) { return a + b >> 1; }
inline hsScalar hsScalarAverage(hsScalar a, hsScalar b, hsScalar t)
{
return a + hsFixMul(t, b - a);
}
#if HS_CAN_USE_FLOAT
inline hsScalar hsPow(hsScalar base, hsScalar exponent)
{
return hsFloatToScalar(powf(hsScalarToFloat(base), hsScalarToFloat(exponent)));
}
inline hsScalar hsATan2(hsScalar y, hsScalar x)
{
return hsFloatToScalar(atan2f(hsScalarToFloat(y), hsScalarToFloat(x)));
}
#endif
inline hsScalar hsCeil(hsScalar x) { return (x + 0xFFFF) & 0xFFFF0000; }
inline hsScalar hsFloor(hsScalar x) { return x & 0xFFFF0000; }
#endif
#endif
#if HS_SCALAR_IS_FLOAT
typedef float hsScalar;
#define hsScalar1 float(1)
#define hsScalarHalf float(0.5)
#define hsScalarPI float(HS_PI)
#define hsScalarMax float(3.402823466e+38F)
#define hsFloatToScalar(x) float(x)
#define hsScalarToFloat(x) float(x)
#define hsIntToScalar(x) float(x)
#define hsScalarToInt(x) int32_t(x)
#define hsFixedToScalar(x) ((hsScalar)(x) / float(hsFixed1))
#define hsScalarToFixed(x) hsFixed((x) * float(hsFixed1))
#define hsFractToScalar(x) ((x) / float(hsFract1))
#define hsScalarToFract(x) hsFract((x) * float(hsFract1))
#ifdef __cplusplus
#define hsScalarMod(a,b) fmodf(a, b)
#define hsScalarMulAdd(a, b, c) ((a) * (b) + (c))
#define hsScalarMul(a,b) ((a) * (b))
#define hsScalarMul2(a) ((a) * 2)
#define hsScalarDiv(a,b) ((a) / (b))
#define hsScalarDiv2(a) ((a) * float(0.5))
#define hsScalarInvert(a) (float(1) / (a))
#define hsScalarMulDiv(n1,n2,d) ((n1) * (n2) / (d))
#ifndef HS_DEBUGGING /* mf horse testing defines vs inlines for VC++5.0 performance */
#define hsScalarRound(x) int32_t((x) + ((x) < 0 ? -hsScalarHalf : hsScalarHalf))
#else /* HS_DEBUGGING - use inlines for type-checking etc...and all */
inline int32_t hsScalarRound(float x)
{
float half = hsScalarHalf;
if (x < 0)
half = -half;
return int32_t(x + half);
}
#endif /* HS_DEBUGGING - use inlines for type-checking etc...and all */
inline float hsScalarAverage(float a, float b) { return (a + b) * float(0.5); }
inline float hsScalarAverage(float a, float b, float t) { return a + t * (b - a); }
inline hsScalar hsSquareRoot(hsScalar scalar) { return sqrtf(scalar); }
inline hsScalar hsSine(hsScalar angle) { return sinf(angle); }
inline hsScalar hsCosine(hsScalar angle) { return cosf(angle); }
inline hsScalar hsTan(hsScalar rads) { return tanf(rads); }
inline hsScalar hsASine(hsScalar value) { return asinf(value); }
inline hsScalar hsACosine(hsScalar value) { return acosf(value); }
inline hsScalar hsPow(hsScalar base, hsScalar exponent) { return powf(base, exponent); }
inline hsScalar hsATan2(hsScalar y, hsScalar x) { return atan2f(y, x); }
inline hsScalar hsCeil(hsScalar x) { return ceilf(x); }
inline hsScalar hsFloor(hsScalar x) { return floorf(x); }
#endif /* HS_SCALAR_IS_FLOAT */
#endif /* __CPLUSPLUS */
//
// Macros for enabling double precision math ops
// require #include <float.h>
//
#if HS_BUILD_FOR_WIN32
#define hsDoublePrecBegin \
unsigned int fpc=_controlfp( 0, 0); \
_controlfp( _PC_64, MCW_PC );
#define hsDoublePrecEnd \
_controlfp( fpc, 0xfffff );
#else
#define hsDoublePrecBegin
#define hsDoublePrecEnd
#endif
#endif

120
Sources/Plasma/CoreLib/hsStream.cpp

@ -526,46 +526,44 @@ uint32_t hsStream::ReadBE32()
return value; return value;
} }
#if HS_CAN_USE_FLOAT double hsStream::ReadLEDouble()
double hsStream::ReadLEDouble() {
{ double value;
double value; Read8Bytes(&value);
Read8Bytes(&value); value = hsToLEDouble(value);
value = hsToLEDouble(value); return value;
return value; }
}
void hsStream::ReadLEDouble(int count, double values[]) void hsStream::ReadLEDouble(int count, double values[])
{ {
this->Read(count * sizeof(double), values); this->Read(count * sizeof(double), values);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
values[i] = hsToLEDouble(values[i]); values[i] = hsToLEDouble(values[i]);
} }
float hsStream::ReadLEFloat() float hsStream::ReadLEFloat()
{ {
float value; float value;
Read4Bytes(&value); Read4Bytes(&value);
value = hsToLEFloat(value); value = hsToLEFloat(value);
return value; return value;
} }
void hsStream::ReadLEFloat(int count, float values[]) void hsStream::ReadLEFloat(int count, float values[])
{ {
this->Read(count * sizeof(float), values); this->Read(count * sizeof(float), values);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
values[i] = hsToLEFloat(values[i]); values[i] = hsToLEFloat(values[i]);
} }
float hsStream::ReadBEFloat() float hsStream::ReadBEFloat()
{ {
float value; float value;
this->Read(sizeof(float), &value); this->Read(sizeof(float), &value);
value = hsToBEFloat(value); value = hsToBEFloat(value);
return value; return value;
} }
#endif
void hsStream::WriteBool(hsBool value) void hsStream::WriteBool(hsBool value)
@ -631,37 +629,35 @@ void hsStream::WriteBE32(uint32_t value)
this->Write(sizeof(int32_t), &value); this->Write(sizeof(int32_t), &value);
} }
#if HS_CAN_USE_FLOAT void hsStream::WriteLEDouble(double value)
void hsStream::WriteLEDouble(double value) {
{ value = hsToLEDouble(value);
value = hsToLEDouble(value); this->Write(sizeof(double), &value);
this->Write(sizeof(double), &value); }
}
void hsStream::WriteLEDouble(int count, const double values[]) void hsStream::WriteLEDouble(int count, const double values[])
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
this->WriteLEDouble(values[i]); this->WriteLEDouble(values[i]);
} }
void hsStream::WriteLEFloat(float value) void hsStream::WriteLEFloat(float value)
{ {
value = hsToLEFloat(value); value = hsToLEFloat(value);
this->Write(sizeof(float), &value); this->Write(sizeof(float), &value);
} }
void hsStream::WriteLEFloat(int count, const float values[]) void hsStream::WriteLEFloat(int count, const float values[])
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
this->WriteLEFloat(values[i]); this->WriteLEFloat(values[i]);
} }
void hsStream::WriteBEFloat(float value) void hsStream::WriteBEFloat(float value)
{ {
value = hsToBEFloat(value); value = hsToBEFloat(value);
this->Write(sizeof(float), &value); this->Write(sizeof(float), &value);
} }
#endif
void hsStream::WriteLEAtom(uint32_t tag, uint32_t size) void hsStream::WriteLEAtom(uint32_t tag, uint32_t size)
{ {

28
Sources/Plasma/CoreLib/hsStream.h

@ -225,7 +225,6 @@ public:
/* Overloaded End */ /* Overloaded End */
#if HS_CAN_USE_FLOAT
float ReadLEFloat(); float ReadLEFloat();
void ReadLEFloat(int count, float values[]); void ReadLEFloat(int count, float values[]);
double ReadLEDouble(); double ReadLEDouble();
@ -256,33 +255,7 @@ public:
void WriteLE(double value) { WriteLEDouble(value); } void WriteLE(double value) { WriteLEDouble(value); }
void WriteLE(int count, const double values[]) { WriteLEDouble(count, values); } void WriteLE(int count, const double values[]) { WriteLEDouble(count, values); }
/* Overloaded End */ /* Overloaded End */
#endif
#if HS_SCALAR_IS_FIXED
hsFixed ReadLEScalar() { return (hsFixed)this->ReadLE32(); }
void ReadLEScalar(int count, hsFixed values[])
{
this->ReadLE32(count, (uint32_t*)values);
}
hsFixed ReadBEScalar() { return (hsFixed)this->ReadBE32(); }
void WriteLEScalar(hsFixed value) { this->WriteLE32(value); }
void WriteLEScalar(int count, const hsFixed values[])
{
this->WriteLE32(count, (uint32_t*)values);
}
void WriteBEScalar(hsFixed value) { this->WriteBE32(value); }
/* Overloaded Begin (Scalar) */
void ReadLE(hsFixed* value) { this->ReadLE((uint32_t*)value); }
void ReadLE(int count, hsFixed values[]) { this->ReadLE(count, (uint32_t*)values); }
void WriteLE(hsFixed value) { this->WriteLE((uint32_t)value); }
void WriteLE(int count, const hsFixed values[]) { this->WriteLE(count, (uint32_t*)values); }
/* Overloaded End */
#else
float ReadLEScalar() { return (float)this->ReadLEFloat(); } float ReadLEScalar() { return (float)this->ReadLEFloat(); }
void ReadLEScalar(int count, float values[]) void ReadLEScalar(int count, float values[])
{ {
@ -295,7 +268,6 @@ public:
this->WriteLEFloat(count, (float*)values); this->WriteLEFloat(count, (float*)values);
} }
void WriteBEScalar(float value) { this->WriteBEFloat(value); } void WriteBEScalar(float value) { this->WriteBEFloat(value); }
#endif
void WriteLEAtom(uint32_t tag, uint32_t size); void WriteLEAtom(uint32_t tag, uint32_t size);
uint32_t ReadLEAtom(uint32_t* size); uint32_t ReadLEAtom(uint32_t* size);

20
Sources/Plasma/CoreLib/hsTypes.h

@ -48,10 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/************************** Other Includes *****************************/ /************************** Other Includes *****************************/
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#if HS_CAN_USE_FLOAT
#include <math.h>
#endif
/************************** Basic Macros *****************************/ /************************** Basic Macros *****************************/
@ -83,9 +79,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define kPosInfinity32 (0x7fffffff) #define kPosInfinity32 (0x7fffffff)
#define kNegInfinity32 (0x80000000) #define kNegInfinity32 (0x80000000)
#ifndef M_PI
typedef int32_t hsFixed; # define M_PI 3.14159265358979323846
typedef int32_t hsFract; #endif
#ifdef __cplusplus #ifdef __cplusplus
@ -93,12 +89,6 @@ typedef int hsBool;
#endif #endif
#include "hsScalar.h"
#if HS_CAN_USE_FLOAT
#define HS_PI 3.1415927
#endif
#ifndef nil #ifndef nil
#define nil (0) #define nil (0)
#endif #endif
@ -148,7 +138,6 @@ typedef uint32_t hsGSeedValue;
((value & 0x00ff000000000000) >> 40) | ((value & 0x00ff000000000000) >> 40) |
((value) >> 56); ((value) >> 56);
} }
#if HS_CAN_USE_FLOAT
inline float hsSwapEndianFloat(float fvalue) inline float hsSwapEndianFloat(float fvalue)
{ {
uint32_t value = *(uint32_t*)&fvalue; uint32_t value = *(uint32_t*)&fvalue;
@ -161,7 +150,6 @@ typedef uint32_t hsGSeedValue;
value = hsSwapEndian64(value); value = hsSwapEndian64(value);
return *(double*)&value; return *(double*)&value;
} }
#endif
#if LITTLE_ENDIAN #if LITTLE_ENDIAN
#define hsToBE16(n) hsSwapEndian16(n) #define hsToBE16(n) hsSwapEndian16(n)
@ -201,14 +189,12 @@ typedef uint32_t hsGSeedValue;
b = c; b = c;
} }
#if HS_CAN_USE_FLOAT
inline void hsSwap(float& a, float& b) inline void hsSwap(float& a, float& b)
{ {
float c = a; float c = a;
a = b; a = b;
b = c; b = c;
} }
#endif
#endif #endif
/************************** Color32 Type *****************************/ /************************** Color32 Type *****************************/

17
Sources/Plasma/CoreLib/hsUtils.cpp

@ -55,6 +55,7 @@ extern "C" {
#endif #endif
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include <math.h>
char * hsFormatStr(const char * fmt, ...) char * hsFormatStr(const char * fmt, ...)
@ -75,16 +76,9 @@ char * hsFormatStrV(const char * fmt, va_list args)
static char hsStrBuf[100]; static char hsStrBuf[100];
char *hsScalarToStr(hsScalar s) char *hsScalarToStr(float s)
{ {
if (s == hsIntToScalar(hsScalarToInt(s))) sprintf(hsStrBuf, "%f", s);
sprintf(hsStrBuf, "%d", hsScalarToInt(s));
else
#if HS_CAN_USE_FLOAT
sprintf(hsStrBuf, "%f", hsScalarToFloat(s));
#else
sprintf(hsStrBuf, "%d:%lu", hsFixedToInt(s), (uint16_t)s);
#endif
return hsStrBuf; return hsStrBuf;
} }
@ -216,6 +210,11 @@ int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int
#endif #endif
} }
inline hsBool hsCompare(float a, float b, float delta)
{
return (fabs(a - b) < delta);
}
/* Generic psuedo RNG used in ANSI C. */ /* Generic psuedo RNG used in ANSI C. */
static unsigned long SEED = 1; static unsigned long SEED = 1;

12
Sources/Plasma/CoreLib/hsUtils.h

@ -53,7 +53,7 @@ char* hsStrcpy(char dstOrNil[], const char src[]);
void hsStrcat(char dst[], const char src[]); void hsStrcat(char dst[], const char src[]);
hsBool hsStrEQ(const char s1[], const char s2[]); hsBool hsStrEQ(const char s1[], const char s2[]);
hsBool hsStrCaseEQ(const char* s1, const char* s2); hsBool hsStrCaseEQ(const char* s1, const char* s2);
char* hsScalarToStr(hsScalar); char* hsScalarToStr(float);
int hsRemove(const char* filename); int hsRemove(const char* filename);
void hsCPathToMacPath(char* dst, char* fname); void hsCPathToMacPath(char* dst, char* fname);
void hsStrLower(char *s); void hsStrLower(char *s);
@ -127,10 +127,7 @@ int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int
int hsMessageBoxWithOwner(void* owner, const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk); int hsMessageBoxWithOwner(void* owner, const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk);
int hsMessageBoxWithOwner(void* owner, const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk); int hsMessageBoxWithOwner(void* owner, const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk);
inline hsBool hsCompare(hsScalar a, hsScalar b, hsScalar delta=0.0001) inline hsBool hsCompare(float a, float b, float delta=0.0001);
{
return (fabs(a - b) < delta);
}
// flag testing / clearing // flag testing / clearing
#define hsCheckBits(f,c) ((f & c)==c) #define hsCheckBits(f,c) ((f & c)==c)
@ -167,6 +164,11 @@ inline hsBool hsCompare(hsScalar a, hsScalar b, hsScalar delta=0.0001)
# define hsWFopen(name, mode) fopen(hsWStringToString(name), hsWStringToString(mode)) # define hsWFopen(name, mode) fopen(hsWStringToString(name), hsWStringToString(mode))
#endif #endif
// Useful floating point utilities
inline float hsDegreesToRadians(float deg) { return float(deg * (M_PI / 180)); }
inline float hsRadiansToDegrees(float rad) { return float(rad * (180 / M_PI)); }
#define hsInvert(a) (1 / (a))
///////////////////////////// /////////////////////////////
// Physical memory functions // Physical memory functions

8
Sources/Plasma/CoreLib/hsWide.cpp

@ -240,7 +240,7 @@ inline int MaxLeftShift(const hsWide* w)
} }
} }
hsFixed hsWide::FixDiv(const hsWide* denom) const int32_t hsWide::FixDiv(const hsWide* denom) const
{ {
hsWide num = *this; hsWide num = *this;
hsWide den = *denom; hsWide den = *denom;
@ -256,7 +256,7 @@ hsFixed hsWide::FixDiv(const hsWide* denom) const
return num.Div(&den)->AsLong(); return num.Div(&den)->AsLong();
} }
hsFract hsWide::FracDiv(const hsWide* denom) const int32_t hsWide::FracDiv(const hsWide* denom) const
{ {
hsWide num = *this; hsWide num = *this;
hsWide den = *denom; hsWide den = *denom;
@ -297,10 +297,6 @@ int32_t hsWide::Sqrt() const
} }
} while (--bits); } while (--bits);
#if HS_PIN_MATH_OVERFLOW
if ((int32_t)root < 0)
return kPosInfinity32;
#endif
return (int32_t)root; return (int32_t)root;
} }

29
Sources/Plasma/CoreLib/hsWide.h

@ -73,21 +73,20 @@ struct hsWide {
inline hsWide* RoundRight(unsigned shift); inline hsWide* RoundRight(unsigned shift);
inline int32_t AsLong() const; // return bits 31-0, checking for over/under flow inline int32_t AsLong() const; // return bits 31-0, checking for over/under flow
inline hsFixed AsFixed() const; // return bits 47-16, checking for over/under flow inline int32_t AsFixed() const; // return bits 47-16, checking for over/under flow
inline hsFract AsFract() const; // return bits 61-30, checking for over/under flow inline int32_t AsFract() const; // return bits 61-30, checking for over/under flow
hsWide* Mul(int32_t a); // this updates the wide hsWide* Mul(int32_t a); // this updates the wide
hsWide* Mul(int32_t a, int32_t b); // this sets the wide hsWide* Mul(int32_t a, int32_t b); // this sets the wide
hsWide* Div(int32_t denom); // this updates the wide hsWide* Div(int32_t denom); // this updates the wide
hsWide* Div(const hsWide* denom); // this updates the wide hsWide* Div(const hsWide* denom); // this updates the wide
hsFixed FixDiv(const hsWide* denom) const; int32_t FixDiv(const hsWide* denom) const;
hsFract FracDiv(const hsWide* denom) const; int32_t FracDiv(const hsWide* denom) const;
int32_t Sqrt() const; int32_t Sqrt() const;
int32_t CubeRoot() const; int32_t CubeRoot() const;
#if HS_CAN_USE_FLOAT
double AsDouble() const { return fHi * double(65536) * double(65536) + fLo; } double AsDouble() const { return fHi * double(65536) * double(65536) + fLo; }
hsWide* Set(double d) hsWide* Set(double d)
{ {
@ -95,7 +94,6 @@ struct hsWide {
int32_t lo = int32_t(d - double(hi)); int32_t lo = int32_t(d - double(hi));
return Set(hi, lo); return Set(hi, lo);
} }
#endif
}; };
@ -107,13 +105,8 @@ const hsWide kNegInfinity64 = { kNegInfinity32, 0 };
#define TOP2BITS(n) (uint32_t(n) >> 30) #define TOP2BITS(n) (uint32_t(n) >> 30)
#define TOP3BITS(n) (uint32_t(n) >> 29) #define TOP3BITS(n) (uint32_t(n) >> 29)
#if HS_PIN_MATH_OVERFLOW && HS_DEBUG_MATH_OVERFLOW
#define hsSignalMathOverflow() hsDebugMessage("Math overflow", 0)
#define hsSignalMathUnderflow() hsDebugMessage("Math underflow", 0)
#else
#define hsSignalMathOverflow() #define hsSignalMathOverflow()
#define hsSignalMathUnderflow() #define hsSignalMathUnderflow()
#endif
#define WIDE_ISNEG(hi, lo) (int32_t(hi) < 0) #define WIDE_ISNEG(hi, lo) (int32_t(hi) < 0)
#define WIDE_LESSTHAN(hi, lo, hi2, lo2) ((hi) < (hi2) || (hi) == (hi2) && (lo) < (lo2)) #define WIDE_LESSTHAN(hi, lo, hi2, lo2) ((hi) < (hi2) || (hi) == (hi2) && (lo) < (lo2))
@ -186,16 +179,6 @@ inline hsWide* hsWide::RoundRight(unsigned shift)
inline int32_t hsWide::AsLong() const inline int32_t hsWide::AsLong() const
{ {
#if HS_PIN_MATH_OVERFLOW
if (fHi > 0 || (fHi == 0 && (int32_t)fLo < 0))
{ hsSignalMathOverflow();
return kPosInfinity32;
}
if (fHi < -1L || (fHi == -1L && (int32_t)fLo >= 0))
{ hsSignalMathOverflow();
return kNegInfinity32;
}
#endif
return (int32_t)fLo; return (int32_t)fLo;
} }
@ -204,14 +187,14 @@ inline hsBool hsWide::IsWide() const
return (fHi > 0 || (fHi == 0 && (int32_t)fLo < 0)) || (fHi < -1L || (fHi == -1L && (int32_t)fLo >= 0)); return (fHi > 0 || (fHi == 0 && (int32_t)fLo < 0)) || (fHi < -1L || (fHi == -1L && (int32_t)fLo >= 0));
} }
inline hsFixed hsWide::AsFixed() const inline int32_t hsWide::AsFixed() const
{ {
hsWide tmp = *this; hsWide tmp = *this;
return tmp.RoundRight(16)->AsLong(); return tmp.RoundRight(16)->AsLong();
} }
inline hsFract hsWide::AsFract() const inline int32_t hsWide::AsFract() const
{ {
hsWide tmp = *this; hsWide tmp = *this;

30
Sources/Plasma/CoreLib/plViewTransform.cpp

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "plViewTransform.h" #include "plViewTransform.h"
const hsScalar plViewTransform::kMinHither = 0.25f; const float plViewTransform::kMinHither = 0.25f;
plViewTransform::plViewTransform() plViewTransform::plViewTransform()
: fFlags(kViewPortRelative), : fFlags(kViewPortRelative),
@ -81,15 +81,15 @@ void plViewTransform::ISetCameraToNDC() const
{ {
hsPoint3 worldSizeInv; hsPoint3 worldSizeInv;
worldSizeInv.fX = hsScalarInvert( fMax.fX - fMin.fX ) * 2.f; worldSizeInv.fX = hsInvert( fMax.fX - fMin.fX ) * 2.f;
worldSizeInv.fY = hsScalarInvert( fMax.fY - fMin.fY ) * 2.f; worldSizeInv.fY = hsInvert( fMax.fY - fMin.fY ) * 2.f;
worldSizeInv.fZ = hsScalarInvert( fMax.fZ - fMin.fZ ); worldSizeInv.fZ = hsInvert( fMax.fZ - fMin.fZ );
fCameraToNDC.fMap[0][0] = worldSizeInv.fX; fCameraToNDC.fMap[0][0] = worldSizeInv.fX;
fCameraToNDC.fMap[0][3] = -fMin.fX * worldSizeInv.fX - hsScalar1; fCameraToNDC.fMap[0][3] = -fMin.fX * worldSizeInv.fX - 1.f;
fCameraToNDC.fMap[1][1] = worldSizeInv.fY; fCameraToNDC.fMap[1][1] = worldSizeInv.fY;
fCameraToNDC.fMap[1][3] = -fMin.fY * worldSizeInv.fY - hsScalar1; fCameraToNDC.fMap[1][3] = -fMin.fY * worldSizeInv.fY - 1.f;
// Map Screen Z to range 0 (at hither) to 1 (at yon) // Map Screen Z to range 0 (at hither) to 1 (at yon)
fCameraToNDC.fMap[2][2] = worldSizeInv.fZ; fCameraToNDC.fMap[2][2] = worldSizeInv.fZ;
@ -152,7 +152,7 @@ hsScalarTriple plViewTransform::NDCToScreen(const hsScalarTriple& ndc) const
hsScalarTriple plViewTransform::NDCToCamera(const hsScalarTriple& ndc) const hsScalarTriple plViewTransform::NDCToCamera(const hsScalarTriple& ndc) const
{ {
hsPoint3 camP; hsPoint3 camP;
hsScalar w = ndc.fZ; float w = ndc.fZ;
const hsMatrix44& c2NDC = GetCameraToNDC(); const hsMatrix44& c2NDC = GetCameraToNDC();
@ -188,7 +188,7 @@ hsScalarTriple plViewTransform::CameraToNDC(const hsScalarTriple& camP) const
} }
else else
{ {
hsScalar invW = 1.f / camP.fZ; float invW = 1.f / camP.fZ;
ndc.fX = c2NDC.fMap[0][0] * camP.fX * invW ndc.fX = c2NDC.fMap[0][0] * camP.fX * invW
+ c2NDC.fMap[0][2]; + c2NDC.fMap[0][2];
@ -203,7 +203,7 @@ hsScalarTriple plViewTransform::CameraToNDC(const hsScalarTriple& camP) const
hsPoint3 ndc = c2NDC * hsPoint3(camP); hsPoint3 ndc = c2NDC * hsPoint3(camP);
if( !GetOrthogonal() ) if( !GetOrthogonal() )
{ {
hsScalar invW = 1.f / camP.fZ; float invW = 1.f / camP.fZ;
ndc *= invW; ndc *= invW;
} }
#endif // MF_FLIP_SPARSE #endif // MF_FLIP_SPARSE
@ -299,18 +299,18 @@ hsBool plViewTransform::Union(const plViewTransform& view)
return true; return true;
} }
hsScalar plViewTransform::GetFovX() const float plViewTransform::GetFovX() const
{ {
hsScalar minAng = hsATan2(fMin.fX, 1.f); float minAng = atan2(fMin.fX, 1.f);
hsScalar maxAng = hsATan2(fMax.fX, 1.f); float maxAng = atan2(fMax.fX, 1.f);
return maxAng - minAng; return maxAng - minAng;
} }
hsScalar plViewTransform::GetFovY() const float plViewTransform::GetFovY() const
{ {
hsScalar minAng = hsATan2(fMin.fY, 1.f); float minAng = atan2(fMin.fY, 1.f);
hsScalar maxAng = hsATan2(fMax.fY, 1.f); float maxAng = atan2(fMax.fY, 1.f);
return maxAng - minAng; return maxAng - minAng;
} }

54
Sources/Plasma/CoreLib/plViewTransform.h

@ -130,15 +130,15 @@ public:
hsPoint3 GetMapMax() const { return fMapMax; } hsPoint3 GetMapMax() const { return fMapMax; }
void GetMapping(hsPoint3& mapMin, hsPoint3& mapMax) const { mapMin = fMapMin; mapMax = fMapMax; } void GetMapping(hsPoint3& mapMin, hsPoint3& mapMax) const { mapMin = fMapMin; mapMax = fMapMax; }
hsScalar GetFovX() const; float GetFovX() const;
hsScalar GetFovY() const; float GetFovY() const;
hsScalar GetFovXDeg() const { return hsScalarRadToDeg(GetFovX()); } float GetFovXDeg() const { return hsRadiansToDegrees(GetFovX()); }
hsScalar GetFovYDeg() const { return hsScalarRadToDeg(GetFovY()); } float GetFovYDeg() const { return hsRadiansToDegrees(GetFovY()); }
hsScalar GetOrthoWidth() const { return fMax.fX - fMin.fX; } float GetOrthoWidth() const { return fMax.fX - fMin.fX; }
hsScalar GetOrthoHeight() const { return fMax.fY - fMin.fY; } float GetOrthoHeight() const { return fMax.fY - fMin.fY; }
hsScalar GetHither() const { return fMin.fZ; } float GetHither() const { return fMin.fZ; }
hsScalar GetYon() const { return fMax.fZ; } float GetYon() const { return fMax.fZ; }
void GetDepth(hsScalar& hither, hsScalar& yon) const { hither = GetHither(); yon = GetYon(); } void GetDepth(float& hither, float& yon) const { hither = GetHither(); yon = GetYon(); }
// Setup. // Setup.
// First, our world to camera and back again. // First, our world to camera and back again.
@ -158,7 +158,7 @@ public:
// Defaults to 0,0,width,height (i.e. the whole screen). // Defaults to 0,0,width,height (i.e. the whole screen).
void SetViewPort(const hsPoint2& mins, const hsPoint2& maxs, hsBool relative=true); void SetViewPort(const hsPoint2& mins, const hsPoint2& maxs, hsBool relative=true);
void SetViewPort(float loX, float loY, float hiX, float hiY, hsBool relative=true) { SetViewPort(hsPoint2().Set(loX, loY), hsPoint2().Set(hiX, hiY), relative); } void SetViewPort(float loX, float loY, float hiX, float hiY, hsBool relative=true) { SetViewPort(hsPoint2().Set(loX, loY), hsPoint2().Set(hiX, hiY), relative); }
void SetViewPort(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) { SetViewPort(hsScalar(left), hsScalar(top), hsScalar(right), hsScalar(bottom), false); } void SetViewPort(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) { SetViewPort(float(left), float(top), float(right), float(bottom), false); }
void SetMapping(const hsPoint3& mins, const hsPoint3& maxs) { SetMapMin(mins); SetMapMax(maxs); } void SetMapping(const hsPoint3& mins, const hsPoint3& maxs) { SetMapMin(mins); SetMapMax(maxs); }
void SetMapMin(const hsPoint3& mins) { fMapMin = mins; } void SetMapMin(const hsPoint3& mins) { fMapMin = mins; }
@ -166,35 +166,35 @@ public:
// Next, variants on setting up our projection matrix. // Next, variants on setting up our projection matrix.
// Depth is pretty uniform. // Depth is pretty uniform.
void SetDepth(hsScalar hither, hsScalar yon) { fMin.fZ = hither; fMax.fZ = yon; InvalidateTransforms(); } void SetDepth(float hither, float yon) { fMin.fZ = hither; fMax.fZ = yon; InvalidateTransforms(); }
void SetDepth(const hsPoint2& d) { SetDepth(d.fX, d.fY); } void SetDepth(const hsPoint2& d) { SetDepth(d.fX, d.fY); }
void SetHither(hsScalar hither) { fMin.fZ = hither; InvalidateTransforms(); } void SetHither(float hither) { fMin.fZ = hither; InvalidateTransforms(); }
void SetYon(hsScalar yon) { fMax.fZ = yon; InvalidateTransforms(); } void SetYon(float yon) { fMax.fZ = yon; InvalidateTransforms(); }
// Garden variety symmetric fov uses either of this first batch. Unless you're doing some funky projection, you don't even // Garden variety symmetric fov uses either of this first batch. Unless you're doing some funky projection, you don't even
// need to look through the rest. // need to look through the rest.
// Degrees - all are full angles, < 180 degrees // Degrees - all are full angles, < 180 degrees
void SetFovDeg(const hsPoint2& deg) { SetFovDeg(deg.fX, deg.fY); } void SetFovDeg(const hsPoint2& deg) { SetFovDeg(deg.fX, deg.fY); }
void SetFovDeg(hsScalar degX, hsScalar degY) { SetFovXDeg(degX); SetFovYDeg(degY); } void SetFovDeg(float degX, float degY) { SetFovXDeg(degX); SetFovYDeg(degY); }
void SetFovXDeg(hsScalar deg) { SetFovX(hsScalarDegToRad(deg)); } void SetFovXDeg(float deg) { SetFovX(hsDegreesToRadians(deg)); }
void SetFovYDeg(hsScalar deg) { SetFovY(hsScalarDegToRad(deg)); } void SetFovYDeg(float deg) { SetFovY(hsDegreesToRadians(deg)); }
// Radians - all are full angles, < PI // Radians - all are full angles, < PI
void SetFov(const hsPoint2& rad) { SetFov(rad.fX, rad.fY); } void SetFov(const hsPoint2& rad) { SetFov(rad.fX, rad.fY); }
void SetFov(hsScalar radX, hsScalar radY) { SetFovX(radX); SetFovY(radY); } void SetFov(float radX, float radY) { SetFovX(radX); SetFovY(radY); }
void SetFovX(hsScalar rad) { SetHalfWidth(hsTan(rad * 0.5f)); } void SetFovX(float rad) { SetHalfWidth(tan(rad * 0.5f)); }
void SetFovY(hsScalar rad) { SetHalfHeight(hsTan(rad * 0.5f)); } void SetFovY(float rad) { SetHalfHeight(tan(rad * 0.5f)); }
// For orthogonal projection, don't call SetWidth(hsTan(fovRads)), because hsTan(f)/2 != hsTan(f/2) // For orthogonal projection, don't call SetWidth(tan(fovRads)), because tan(f)/2 != tan(f/2)
// For non-centered, call SetWidths/Heights() directly. // For non-centered, call SetWidths/Heights() directly.
void SetWidth(hsScalar w) { SetHalfWidth(w * 0.5f); } void SetWidth(float w) { SetHalfWidth(w * 0.5f); }
void SetHeight(hsScalar h) { SetHalfHeight(h * 0.5f); } void SetHeight(float h) { SetHalfHeight(h * 0.5f); }
// The rest do no interpretation, just stuff the values passed in. // The rest do no interpretation, just stuff the values passed in.
void SetHalfWidth(hsScalar hw) { SetWidths(-hw, hw); } void SetHalfWidth(float hw) { SetWidths(-hw, hw); }
void SetHalfHeight(hsScalar hh) { SetHeights(-hh, hh); } void SetHalfHeight(float hh) { SetHeights(-hh, hh); }
void SetWidths(hsScalar minW, hsScalar maxW) { fMin.fX = minW; fMax.fX = maxW; InvalidateTransforms(); } void SetWidths(float minW, float maxW) { fMin.fX = minW; fMax.fX = maxW; InvalidateTransforms(); }
void SetHeights(hsScalar minH, hsScalar maxH) { fMin.fY = minH; fMax.fY = maxH; InvalidateTransforms(); } void SetHeights(float minH, float maxH) { fMin.fY = minH; fMax.fY = maxH; InvalidateTransforms(); }
void SetWidths(const hsPoint2& w) { SetWidths(w.fX, w.fY); } void SetWidths(const hsPoint2& w) { SetWidths(w.fX, w.fY); }
void SetHeights(const hsPoint2& h) { SetHeights(h.fX, h.fY); } void SetHeights(const hsPoint2& h) { SetHeights(h.fX, h.fY); }
void SetView(const hsPoint3& mins, const hsPoint3& maxs) { fMax = maxs; fMin = mins; InvalidateTransforms(); } void SetView(const hsPoint3& mins, const hsPoint3& maxs) { fMax = maxs; fMin = mins; InvalidateTransforms(); }
@ -319,7 +319,7 @@ protected:
mutable hsMatrix44 fWorldToNDC; mutable hsMatrix44 fWorldToNDC;
// Have to set a limit here on the smallest the hither plane can be. // Have to set a limit here on the smallest the hither plane can be.
static const hsScalar kMinHither; static const float kMinHither;
void ISetCameraToNDC() const; void ISetCameraToNDC() const;
hsBool ICameraToNDCSet() const { return IHasFlag(kCameraToNDCSet); } hsBool ICameraToNDCSet() const { return IHasFlag(kCameraToNDCSet); }

8
Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.cpp

@ -949,9 +949,9 @@ hsBool pfObjectFlocker::MsgReceive(plMessage* msg)
plKey newKey = cloneMsg->GetCloneKey(); plKey newKey = cloneMsg->GetCloneKey();
cloneMsg->Send(); cloneMsg->Send();
hsScalar xAdjust = (2 * RAND()) - 1; // produces a random number between -1 and 1 float xAdjust = (2 * RAND()) - 1; // produces a random number between -1 and 1
hsScalar yAdjust = (2 * RAND()) - 1; float yAdjust = (2 * RAND()) - 1;
hsScalar zAdjust = (2 * RAND()) - 1; float zAdjust = (2 * RAND()) - 1;
hsPoint3 boidPos(pos.fX + xAdjust, pos.fY + yAdjust, pos.fZ + zAdjust); hsPoint3 boidPos(pos.fX + xAdjust, pos.fY + yAdjust, pos.fZ + zAdjust);
fFlock.AddBoid(this, newKey, boidPos); fFlock.AddBoid(this, newKey, boidPos);
} }
@ -979,7 +979,7 @@ hsBool pfObjectFlocker::MsgReceive(plMessage* msg)
return plSingleModifier::MsgReceive(msg); return plSingleModifier::MsgReceive(msg);
} }
hsBool pfObjectFlocker::IEval(double secs, hsScalar del, uint32_t dirty) hsBool pfObjectFlocker::IEval(double secs, float del, uint32_t dirty)
{ {
fFlock.Update(fTarget, del); fFlock.Update(fTarget, del);

2
Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.h

@ -448,7 +448,7 @@ protected:
hsBool fUseTargetRotation; hsBool fUseTargetRotation;
hsBool fRandomizeAnimationStart; hsBool fRandomizeAnimationStart;
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
}; };
#endif #endif

46
Sources/Plasma/FeatureLib/pfAnimation/plBlower.cpp

@ -51,13 +51,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
plRandom plBlower::fRandom; plRandom plBlower::fRandom;
static const hsScalar kDefaultMasterPower = 20.f; static const float kDefaultMasterPower = 20.f;
static const hsScalar kDefaultMasterFrequency = 2.f; static const float kDefaultMasterFrequency = 2.f;
static const hsScalar kDefaultDirectRate = 1.f; static const float kDefaultDirectRate = 1.f;
static const hsScalar kDefaultImpulseRate = 1.e2f; static const float kDefaultImpulseRate = 1.e2f;
static const hsScalar kDefaultSpringKonst = 20.f; static const float kDefaultSpringKonst = 20.f;
static const hsScalar kDefaultBias = 0.25f; static const float kDefaultBias = 0.25f;
static const hsScalar kInitialMaxOffDist = 1.f; static const float kInitialMaxOffDist = 1.f;
plBlower::plBlower() plBlower::plBlower()
: :
@ -82,7 +82,7 @@ plBlower::~plBlower()
{ {
} }
void plBlower::IBlow(double secs, hsScalar delSecs) void plBlower::IBlow(double secs, float delSecs)
{ {
hsPoint3 worldPos = fTarget->GetLocalToWorld().GetTranslate(); hsPoint3 worldPos = fTarget->GetLocalToWorld().GetTranslate();
hsPoint3 localPos = fTarget->GetLocalToParent().GetTranslate(); hsPoint3 localPos = fTarget->GetLocalToParent().GetTranslate();
@ -93,13 +93,13 @@ void plBlower::IBlow(double secs, hsScalar delSecs)
// Strength = Strength + rnd01 * (MaxStrength - Strength) // Strength = Strength + rnd01 * (MaxStrength - Strength)
hsScalar t = (fAccumTime += delSecs); float t = (fAccumTime += delSecs);
hsScalar strength = 0; float strength = 0;
int i; int i;
for( i = 0; i < fOscillators.GetCount(); i++ ) for( i = 0; i < fOscillators.GetCount(); i++ )
{ {
hsScalar c, s; float c, s;
t *= fOscillators[i].fFrequency * fMasterFrequency; t *= fOscillators[i].fFrequency * fMasterFrequency;
t += fOscillators[i].fPhase; t += fOscillators[i].fPhase;
hsFastMath::SinCosAppr(t, s, c); hsFastMath::SinCosAppr(t, s, c);
@ -116,25 +116,25 @@ void plBlower::IBlow(double secs, hsScalar delSecs)
hsFastMath::NormalizeAppr(fDirection); hsFastMath::NormalizeAppr(fDirection);
hsScalar offDist = hsVector3(&fRestPos, &worldPos).Magnitude(); float offDist = hsVector3(&fRestPos, &worldPos).Magnitude();
if( offDist > fMaxOffsetDist ) if( offDist > fMaxOffsetDist )
fMaxOffsetDist = offDist; fMaxOffsetDist = offDist;
hsVector3 force = fDirection * strength; hsVector3 force = fDirection * strength;
static hsScalar kOffsetDistFrac = 0.5f; // make me const static float kOffsetDistFrac = 0.5f; // make me const
if( offDist > fMaxOffsetDist * kOffsetDistFrac ) if( offDist > fMaxOffsetDist * kOffsetDistFrac )
{ {
offDist /= fMaxOffsetDist; offDist /= fMaxOffsetDist;
offDist *= fMasterPower; offDist *= fMasterPower;
hsScalar impulse = offDist * delSecs * fImpulseRate; float impulse = offDist * delSecs * fImpulseRate;
force.fX += impulse * fRandom.RandMinusOneToOne(); force.fX += impulse * fRandom.RandMinusOneToOne();
force.fY += impulse * fRandom.RandMinusOneToOne(); force.fY += impulse * fRandom.RandMinusOneToOne();
force.fZ += impulse * fRandom.RandMinusOneToOne(); force.fZ += impulse * fRandom.RandMinusOneToOne();
} }
const hsScalar kOffsetDistDecay = 0.999f; const float kOffsetDistDecay = 0.999f;
fMaxOffsetDist *= kOffsetDistDecay; fMaxOffsetDist *= kOffsetDistDecay;
hsVector3 accel = force; hsVector3 accel = force;
@ -145,9 +145,9 @@ void plBlower::IBlow(double secs, hsScalar delSecs)
fCurrDel = del; fCurrDel = del;
} }
hsBool plBlower::IEval(double secs, hsScalar delSecs, uint32_t dirty) hsBool plBlower::IEval(double secs, float delSecs, uint32_t dirty)
{ {
const hsScalar kMaxDelSecs = 0.1f; const float kMaxDelSecs = 0.1f;
if( delSecs > kMaxDelSecs ) if( delSecs > kMaxDelSecs )
delSecs = kMaxDelSecs; delSecs = kMaxDelSecs;
IBlow(secs, delSecs); IBlow(secs, delSecs);
@ -212,20 +212,20 @@ void plBlower::Write(hsStream* s, hsResMgr* mgr)
void plBlower::IInitOscillators() void plBlower::IInitOscillators()
{ {
const hsScalar kBasePower = 5.f; const float kBasePower = 5.f;
fOscillators.SetCount(5); fOscillators.SetCount(5);
int i; int i;
for( i = 0; i < fOscillators.GetCount(); i++ ) for( i = 0; i < fOscillators.GetCount(); i++ )
{ {
hsScalar fi = hsScalar(i+1); float fi = float(i+1);
fOscillators[i].fFrequency = fi / hsScalarPI * fRandom.RandRangeF(0.75f, 1.25f); fOscillators[i].fFrequency = fi / M_PI * fRandom.RandRangeF(0.75f, 1.25f);
// fOscillators[i].fFrequency = 1.f / hsScalarPI * fRandom.RandRangeF(0.5f, 1.5f); // fOscillators[i].fFrequency = 1.f / M_PI * fRandom.RandRangeF(0.5f, 1.5f);
fOscillators[i].fPhase = fRandom.RandZeroToOne(); fOscillators[i].fPhase = fRandom.RandZeroToOne();
fOscillators[i].fPower = kBasePower * fRandom.RandRangeF(0.75f, 1.25f); fOscillators[i].fPower = kBasePower * fRandom.RandRangeF(0.75f, 1.25f);
} }
} }
void plBlower::SetConstancy(hsScalar f) void plBlower::SetConstancy(float f)
{ {
if( f < 0 ) if( f < 0 )
f = 0; f = 0;
@ -235,7 +235,7 @@ void plBlower::SetConstancy(hsScalar f)
fBias = f; fBias = f;
} }
hsScalar plBlower::GetConstancy() const float plBlower::GetConstancy() const
{ {
return fBias; return fBias;
} }

54
Sources/Plasma/FeatureLib/pfAnimation/plBlower.h

@ -58,21 +58,21 @@ protected:
class Oscillator class Oscillator
{ {
public: public:
hsScalar fFrequency; float fFrequency;
hsScalar fPhase; float fPhase;
hsScalar fPower; float fPower;
}; };
static plRandom fRandom; static plRandom fRandom;
// Parameters // Parameters
hsScalar fMasterPower; float fMasterPower;
hsScalar fMasterFrequency; float fMasterFrequency;
hsScalar fDirectRate; float fDirectRate;
hsScalar fImpulseRate; float fImpulseRate;
hsScalar fSpringKonst; float fSpringKonst;
hsScalar fBias; float fBias;
hsScalar fAccumTime; float fAccumTime;
hsTArray<Oscillator> fOscillators; hsTArray<Oscillator> fOscillators;
// CurrentState // CurrentState
@ -80,13 +80,13 @@ protected:
hsPoint3 fRestPos; hsPoint3 fRestPos;
hsPoint3 fLocalRestPos; hsPoint3 fLocalRestPos;
hsVector3 fCurrDel; hsVector3 fCurrDel;
hsScalar fMaxOffsetDist; float fMaxOffsetDist;
void IInitOscillators(); void IInitOscillators();
void ISetTargetTransform(); void ISetTargetTransform();
void IBlow(double secs, hsScalar delSecs); void IBlow(double secs, float delSecs);
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
public: public:
~plBlower(); ~plBlower();
plBlower(); plBlower();
@ -99,19 +99,19 @@ public:
virtual void Read(hsStream* stream, hsResMgr* mgr); virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr); virtual void Write(hsStream* stream, hsResMgr* mgr);
void SetMasterPower(hsScalar f) { fMasterPower = f; } void SetMasterPower(float f) { fMasterPower = f; }
void SetMasterFrequency(hsScalar f) { fMasterFrequency = f; } void SetMasterFrequency(float f) { fMasterFrequency = f; }
void SetDirectRate(hsScalar f) { fDirectRate = f; } void SetDirectRate(float f) { fDirectRate = f; }
void SetImpulseRate(hsScalar f) { fImpulseRate = f; } void SetImpulseRate(float f) { fImpulseRate = f; }
void SetSpringKonst(hsScalar f) { fSpringKonst = f; } void SetSpringKonst(float f) { fSpringKonst = f; }
void SetConstancy(hsScalar f); void SetConstancy(float f);
hsScalar GetMasterPower() const { return fMasterPower; } float GetMasterPower() const { return fMasterPower; }
hsScalar GetMasterFrequency() const { return fMasterFrequency; } float GetMasterFrequency() const { return fMasterFrequency; }
hsScalar GetDirectRate() const { return fDirectRate; } float GetDirectRate() const { return fDirectRate; }
hsScalar GetImpulseRate() const { return fImpulseRate; } float GetImpulseRate() const { return fImpulseRate; }
hsScalar GetSpringKonst() const { return fSpringKonst; } float GetSpringKonst() const { return fSpringKonst; }
hsScalar GetConstancy() const; float GetConstancy() const;
}; };
#endif // plBlower_inc #endif // plBlower_inc

2
Sources/Plasma/FeatureLib/pfAnimation/plFilterCoordInterface.cpp

@ -50,7 +50,7 @@ static hsMatrix44* InvTRS(const hsMatrix44& trs, hsMatrix44& inv)
{ {
inv.NotIdentity(); inv.NotIdentity();
hsScalar invSSq[3]; float invSSq[3];
invSSq[0] = 1.f / (trs.fMap[0][0] * trs.fMap[0][0] + trs.fMap[1][0] * trs.fMap[1][0] + trs.fMap[2][0] * trs.fMap[2][0]); invSSq[0] = 1.f / (trs.fMap[0][0] * trs.fMap[0][0] + trs.fMap[1][0] * trs.fMap[1][0] + trs.fMap[2][0] * trs.fMap[2][0]);
invSSq[1] = 1.f / (trs.fMap[0][1] * trs.fMap[0][1] + trs.fMap[1][1] * trs.fMap[1][1] + trs.fMap[2][1] * trs.fMap[2][1]); invSSq[1] = 1.f / (trs.fMap[0][1] * trs.fMap[0][1] + trs.fMap[1][1] * trs.fMap[1][1] + trs.fMap[2][1] * trs.fMap[2][1]);
invSSq[2] = 1.f / (trs.fMap[0][2] * trs.fMap[0][2] + trs.fMap[1][2] * trs.fMap[1][2] + trs.fMap[2][2] * trs.fMap[2][2]); invSSq[2] = 1.f / (trs.fMap[0][2] * trs.fMap[0][2] + trs.fMap[1][2] * trs.fMap[1][2] + trs.fMap[2][2] * trs.fMap[2][2]);

2
Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp

@ -218,7 +218,7 @@ void plFollowMod::IMoveTarget()
GetTarget()->SetTransform(l2w, w2l); GetTarget()->SetTransform(l2w, w2l);
} }
hsBool plFollowMod::IEval(double secs, hsScalar del, uint32_t dirty) hsBool plFollowMod::IEval(double secs, float del, uint32_t dirty)
{ {
if( ICheckLeader() ) if( ICheckLeader() )
IMoveTarget(); IMoveTarget();

2
Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.h

@ -87,7 +87,7 @@ protected:
hsBool ICheckLeader(); hsBool ICheckLeader();
void IMoveTarget(); void IMoveTarget();
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
public: public:
plFollowMod(); plFollowMod();

18
Sources/Plasma/FeatureLib/pfAnimation/plLightModifier.cpp

@ -141,7 +141,7 @@ void plLightModifier::IApplyDynamic()
void plLightModifier::DefaultAnimation() void plLightModifier::DefaultAnimation()
{ {
hsScalar len = MaxAnimLength(0); float len = MaxAnimLength(0);
fTimeConvert.SetBegin(0); fTimeConvert.SetBegin(0);
fTimeConvert.SetEnd(len); fTimeConvert.SetEnd(len);
fTimeConvert.SetLoopPoints(0, len); fTimeConvert.SetLoopPoints(0, len);
@ -149,7 +149,7 @@ void plLightModifier::DefaultAnimation()
fTimeConvert.Start(); fTimeConvert.Start();
} }
hsScalar plLightModifier::MaxAnimLength(hsScalar len) const float plLightModifier::MaxAnimLength(float len) const
{ {
if( fColorCtl && (fColorCtl->GetLength() > len) ) if( fColorCtl && (fColorCtl->GetLength() > len) )
len = fColorCtl->GetLength(); len = fColorCtl->GetLength();
@ -229,7 +229,7 @@ void plOmniModifier::IApplyDynamic()
} }
} }
hsScalar plOmniModifier::MaxAnimLength(hsScalar len) const float plOmniModifier::MaxAnimLength(float len) const
{ {
len = plLightModifier::MaxAnimLength(len); len = plLightModifier::MaxAnimLength(len);
if( fAttenCtl && (fAttenCtl->GetLength() > len) ) if( fAttenCtl && (fAttenCtl->GetLength() > len) )
@ -302,20 +302,20 @@ void plSpotModifier::IApplyDynamic()
{ {
plOmniModifier::IApplyDynamic(); plOmniModifier::IApplyDynamic();
hsScalar f; float f;
if( fInnerCtl ) if( fInnerCtl )
{ {
fInnerCtl->Interp(fCurrentTime, &f); fInnerCtl->Interp(fCurrentTime, &f);
fSpot->SetSpotInner(hsScalarDegToRad(f)*0.5f); fSpot->SetSpotInner(hsDegreesToRadians(f)*0.5f);
} }
if( fOuterCtl ) if( fOuterCtl )
{ {
fOuterCtl->Interp(fCurrentTime, &f); fOuterCtl->Interp(fCurrentTime, &f);
fSpot->SetSpotOuter(hsScalarDegToRad(f)*0.5f); fSpot->SetSpotOuter(hsDegreesToRadians(f)*0.5f);
} }
} }
hsScalar plSpotModifier::MaxAnimLength(hsScalar len) const float plSpotModifier::MaxAnimLength(float len) const
{ {
len = plOmniModifier::MaxAnimLength(len); len = plOmniModifier::MaxAnimLength(len);
if( fInnerCtl && (fInnerCtl->GetLength() > len) ) if( fInnerCtl && (fInnerCtl->GetLength() > len) )
@ -397,7 +397,7 @@ void plLtdDirModifier::IApplyDynamic()
{ {
plLightModifier::IApplyDynamic(); plLightModifier::IApplyDynamic();
hsScalar f; float f;
if( fWidthCtl ) if( fWidthCtl )
{ {
fWidthCtl->Interp(fCurrentTime, &f); fWidthCtl->Interp(fCurrentTime, &f);
@ -415,7 +415,7 @@ void plLtdDirModifier::IApplyDynamic()
} }
} }
hsScalar plLtdDirModifier::MaxAnimLength(hsScalar len) const float plLtdDirModifier::MaxAnimLength(float len) const
{ {
len = plLightModifier::MaxAnimLength(len); len = plLightModifier::MaxAnimLength(len);
if( fWidthCtl && (fWidthCtl->GetLength() > len) ) if( fWidthCtl && (fWidthCtl->GetLength() > len) )

8
Sources/Plasma/FeatureLib/pfAnimation/plLightModifier.h

@ -87,7 +87,7 @@ public:
void SetSpecularCtl(plController* ctl) { fSpecularCtl = ctl; } void SetSpecularCtl(plController* ctl) { fSpecularCtl = ctl; }
virtual void DefaultAnimation(); virtual void DefaultAnimation();
virtual hsScalar MaxAnimLength(hsScalar len) const; virtual float MaxAnimLength(float len) const;
}; };
class plOmniModifier : public plLightModifier class plOmniModifier : public plLightModifier
@ -121,7 +121,7 @@ public:
void SetAttenCtl(plController* ctl) { fAttenCtl = ctl; } void SetAttenCtl(plController* ctl) { fAttenCtl = ctl; }
void SetInitAtten(const hsPoint3& p) { fInitAtten = p; } void SetInitAtten(const hsPoint3& p) { fInitAtten = p; }
virtual hsScalar MaxAnimLength(hsScalar len) const; virtual float MaxAnimLength(float len) const;
}; };
class plSpotModifier : public plOmniModifier class plSpotModifier : public plOmniModifier
@ -155,7 +155,7 @@ public:
void SetInnerCtl(plController* ctl) { fInnerCtl = ctl; } void SetInnerCtl(plController* ctl) { fInnerCtl = ctl; }
void SetOuterCtl(plController* ctl) { fOuterCtl = ctl; } void SetOuterCtl(plController* ctl) { fOuterCtl = ctl; }
virtual hsScalar MaxAnimLength(hsScalar len) const; virtual float MaxAnimLength(float len) const;
}; };
class plLtdDirModifier : public plLightModifier class plLtdDirModifier : public plLightModifier
@ -191,7 +191,7 @@ public:
void SetHeightCtl(plController* ctl) { fHeightCtl = ctl; } void SetHeightCtl(plController* ctl) { fHeightCtl = ctl; }
void SetDepthCtl(plController* ctl) { fDepthCtl = ctl; } void SetDepthCtl(plController* ctl) { fDepthCtl = ctl; }
virtual hsScalar MaxAnimLength(hsScalar len) const; virtual float MaxAnimLength(float len) const;
}; };
#endif // plLightModifier_inc #endif // plLightModifier_inc

38
Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp

@ -79,7 +79,7 @@ plLineFollowMod::~plLineFollowMod()
delete fPath; delete fPath;
} }
void plLineFollowMod::SetSpeedClamp(hsScalar fps) void plLineFollowMod::SetSpeedClamp(float fps)
{ {
fSpeedClamp = fps; fSpeedClamp = fps;
if( fSpeedClamp > 0 ) if( fSpeedClamp > 0 )
@ -93,7 +93,7 @@ void plLineFollowMod::SetSpeedClamp(hsScalar fps)
} }
void plLineFollowMod::SetOffsetFeet(hsScalar f) void plLineFollowMod::SetOffsetFeet(float f)
{ {
fOffset = f; fOffset = f;
if( fOffset != 0 ) if( fOffset != 0 )
@ -115,9 +115,9 @@ void plLineFollowMod::SetForceToLine(hsBool on)
fFollowFlags &= ~kForceToLine; fFollowFlags &= ~kForceToLine;
} }
void plLineFollowMod::SetOffsetDegrees(hsScalar f) void plLineFollowMod::SetOffsetDegrees(float f)
{ {
fOffset = hsScalarDegToRad(f); fOffset = hsDegreesToRadians(f);
if( fOffset != 0 ) if( fOffset != 0 )
{ {
fFollowFlags &= ~kOffsetFeet; fFollowFlags &= ~kOffsetFeet;
@ -130,7 +130,7 @@ void plLineFollowMod::SetOffsetDegrees(hsScalar f)
} }
} }
void plLineFollowMod::SetOffsetClamp(hsScalar f) void plLineFollowMod::SetOffsetClamp(float f)
{ {
fOffsetClamp = f; fOffsetClamp = f;
if( fOffsetClamp > 0 ) if( fOffsetClamp > 0 )
@ -337,7 +337,7 @@ void plLineFollowMod::IRegister()
} }
} }
hsBool plLineFollowMod::IEval(double secs, hsScalar del, uint32_t dirty) hsBool plLineFollowMod::IEval(double secs, float del, uint32_t dirty)
{ {
if( !fPath ) if( !fPath )
return false; return false;
@ -366,7 +366,7 @@ hsBool plLineFollowMod::IOffsetTargetTransform(hsMatrix44& tgtXfm)
hsPoint3 tgtPos = tgtXfm.GetTranslate(); hsPoint3 tgtPos = tgtXfm.GetTranslate();
hsVector3 tgt2src(&fSearchPos, &tgtPos); hsVector3 tgt2src(&fSearchPos, &tgtPos);
hsScalar t2sLen = tgt2src.Magnitude(); float t2sLen = tgt2src.Magnitude();
hsFastMath::NormalizeAppr(tgt2src); hsFastMath::NormalizeAppr(tgt2src);
hsVector3 out; hsVector3 out;
@ -374,7 +374,7 @@ hsBool plLineFollowMod::IOffsetTargetTransform(hsMatrix44& tgtXfm)
if( fFollowFlags & kOffsetAng ) if( fFollowFlags & kOffsetAng )
{ {
hsScalar del = t2sLen * fTanOffset; float del = t2sLen * fTanOffset;
if( fFollowFlags & kOffsetClamp ) if( fFollowFlags & kOffsetClamp )
{ {
if( del > fOffsetClamp ) if( del > fOffsetClamp )
@ -409,7 +409,7 @@ hsBool plLineFollowMod::IOffsetTargetTransform(hsMatrix44& tgtXfm)
hsBool plLineFollowMod::IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tgtXfm) hsBool plLineFollowMod::IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tgtXfm)
{ {
hsScalar t = fPath->GetExtremePoint(searchPos); float t = fPath->GetExtremePoint(searchPos);
if( fFollowFlags & kFullMatrix ) if( fFollowFlags & kFullMatrix )
{ {
fPath->SetCurTime(t, plAnimPath::kNone); fPath->SetCurTime(t, plAnimPath::kNone);
@ -441,12 +441,12 @@ void plLineFollowMod::ICheckForPop(const hsPoint3& oldPos, const hsPoint3& newPo
{ {
hsVector3 del(&oldPos, &newPos); hsVector3 del(&oldPos, &newPos);
hsScalar elapsed = hsTimer::GetDelSysSeconds(); float elapsed = hsTimer::GetDelSysSeconds();
hsScalar speedSq = 0.f; float speedSq = 0.f;
if (elapsed > 0.f) if (elapsed > 0.f)
speedSq = del.MagnitudeSquared() / elapsed; speedSq = del.MagnitudeSquared() / elapsed;
const hsScalar kMaxSpeedSq = 30.f * 30.f; // (feet per sec)^2 const float kMaxSpeedSq = 30.f * 30.f; // (feet per sec)^2
if( speedSq > kMaxSpeedSq ) if( speedSq > kMaxSpeedSq )
fFollowFlags |= kSearchPosPop; fFollowFlags |= kSearchPosPop;
else else
@ -497,7 +497,7 @@ hsBool plLineFollowMod::IGetSearchPos()
return true; return true;
} }
hsMatrix44 plLineFollowMod::IInterpMatrices(const hsMatrix44& m0, const hsMatrix44& m1, hsScalar parm) hsMatrix44 plLineFollowMod::IInterpMatrices(const hsMatrix44& m0, const hsMatrix44& m1, float parm)
{ {
hsMatrix44 retVal; hsMatrix44 retVal;
int i, j; int i, j;
@ -524,14 +524,14 @@ hsMatrix44 plLineFollowMod::ISpeedClamp(plCoordinateInterface* ci, const hsMatri
const hsPoint3 oldPos = currL2W.GetTranslate(); const hsPoint3 oldPos = currL2W.GetTranslate();
const hsPoint3 newPos = unclTgtXfm.GetTranslate(); const hsPoint3 newPos = unclTgtXfm.GetTranslate();
const hsVector3 del(&newPos, &oldPos); const hsVector3 del(&newPos, &oldPos);
hsScalar elapsed = hsTimer::GetDelSysSeconds(); float elapsed = hsTimer::GetDelSysSeconds();
hsScalar speed = 0.f; float speed = 0.f;
if (elapsed > 0.f) if (elapsed > 0.f)
speed = del.Magnitude() / elapsed; speed = del.Magnitude() / elapsed;
if( speed > fSpeedClamp ) if( speed > fSpeedClamp )
{ {
hsScalar parm = fSpeedClamp / speed; float parm = fSpeedClamp / speed;
hsMatrix44 clTgtXfm = IInterpMatrices(currL2W, unclTgtXfm, parm); hsMatrix44 clTgtXfm = IInterpMatrices(currL2W, unclTgtXfm, parm);
@ -658,9 +658,9 @@ hsBool plRailCameraMod::IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tg
return true; return true;
} }
hsPoint3 plRailCameraMod::GetGoal(double secs, hsScalar speed) hsPoint3 plRailCameraMod::GetGoal(double secs, float speed)
{ {
hsScalar delTime; float delTime;
int dir; int dir;
if (fTargetTime == fCurrentTime) if (fTargetTime == fCurrentTime)
return fGoal; return fGoal;
@ -681,7 +681,7 @@ hsPoint3 plRailCameraMod::GetGoal(double secs, hsScalar speed)
if (delTime <= (secs * speed)) if (delTime <= (secs * speed))
fCurrentTime = fTargetTime; fCurrentTime = fTargetTime;
else else
fCurrentTime += (hsScalar)((secs * speed) * dir); fCurrentTime += (float)((secs * speed) * dir);
if (fPath->GetWrap()) if (fPath->GetWrap())
{ {

34
Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.h

@ -92,12 +92,12 @@ protected:
hsTArray<plStereizer*> fStereizers; hsTArray<plStereizer*> fStereizers;
hsScalar fTanOffset; float fTanOffset;
hsScalar fOffset; float fOffset;
hsScalar fOffsetClamp; float fOffsetClamp;
hsScalar fSpeedClamp; float fSpeedClamp;
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
virtual hsBool IGetSearchPos(); virtual hsBool IGetSearchPos();
virtual void ISetTargetTransform(int iTarg, const hsMatrix44& tgtXfm); virtual void ISetTargetTransform(int iTarg, const hsMatrix44& tgtXfm);
@ -106,7 +106,7 @@ protected:
virtual hsBool IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tgtXfm); virtual hsBool IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tgtXfm);
virtual hsBool IOffsetTargetTransform(hsMatrix44& tgtXfm); virtual hsBool IOffsetTargetTransform(hsMatrix44& tgtXfm);
virtual hsMatrix44 ISpeedClamp(plCoordinateInterface* ci, const hsMatrix44& unclTgtXfm); virtual hsMatrix44 ISpeedClamp(plCoordinateInterface* ci, const hsMatrix44& unclTgtXfm);
hsMatrix44 IInterpMatrices(const hsMatrix44& m0, const hsMatrix44& m1, hsScalar parm); hsMatrix44 IInterpMatrices(const hsMatrix44& m0, const hsMatrix44& m1, float parm);
void ICheckForPop(const hsPoint3& oldPos, const hsPoint3& newPos); void ICheckForPop(const hsPoint3& oldPos, const hsPoint3& newPos);
void ISetupStereizers(const plListenerMsg* listMsg); void ISetupStereizers(const plListenerMsg* listMsg);
@ -138,20 +138,20 @@ public:
hsBool HasOffsetClamp() const { return 0 != (fFollowFlags & kOffsetClamp); } hsBool HasOffsetClamp() const { return 0 != (fFollowFlags & kOffsetClamp); }
hsBool HasSpeedClamp() const { return 0 != (fFollowFlags & kSpeedClamp); } hsBool HasSpeedClamp() const { return 0 != (fFollowFlags & kSpeedClamp); }
void SetOffsetFeet(hsScalar f); void SetOffsetFeet(float f);
hsScalar GetOffsetFeet() const { return fOffset; } float GetOffsetFeet() const { return fOffset; }
void SetOffsetDegrees(hsScalar f); void SetOffsetDegrees(float f);
hsScalar GetOffsetDegrees() const { return hsScalarRadToDeg(fOffset); } float GetOffsetDegrees() const { return hsRadiansToDegrees(fOffset); }
void SetOffsetClamp(hsScalar f); void SetOffsetClamp(float f);
hsScalar GetOffsetClamp() const { return fOffsetClamp; } float GetOffsetClamp() const { return fOffsetClamp; }
void SetForceToLine(hsBool on); void SetForceToLine(hsBool on);
hsBool GetForceToLine() const { return 0 != (fFollowFlags & kForceToLine); } hsBool GetForceToLine() const { return 0 != (fFollowFlags & kForceToLine); }
void SetSpeedClamp(hsScalar feetPerSec); void SetSpeedClamp(float feetPerSec);
hsScalar GetSpeedClamp() const { return fSpeedClamp; } float GetSpeedClamp() const { return fSpeedClamp; }
hsBool MsgReceive(plMessage* msg); hsBool MsgReceive(plMessage* msg);
@ -175,7 +175,7 @@ public:
GETINTERFACE_ANY( plRailCameraMod, plLineFollowMod ); GETINTERFACE_ANY( plRailCameraMod, plLineFollowMod );
void Init() { fCurrentTime = -1; } // twiddle ourselves so we get ready to go... void Init() { fCurrentTime = -1; } // twiddle ourselves so we get ready to go...
hsPoint3 GetGoal(double secs, hsScalar speed); hsPoint3 GetGoal(double secs, float speed);
protected: protected:
@ -183,8 +183,8 @@ protected:
virtual hsBool IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tgtXfm); virtual hsBool IGetTargetTransform(hsPoint3& searchPos, hsMatrix44& tgtXfm);
hsMatrix44 fDesiredMatrix; hsMatrix44 fDesiredMatrix;
hsScalar fCurrentTime; float fCurrentTime;
hsScalar fTargetTime; float fTargetTime;
hsPoint3 fGoal; hsPoint3 fGoal;
hsBool fFarthest; hsBool fFarthest;
}; };

12
Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp

@ -51,7 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h" #include "hsTimer.h"
#include "hsUtils.h" #include "hsUtils.h"
static const hsScalar kRandNormalize = 1.f / 32767.f; static const float kRandNormalize = 1.f / 32767.f;
plRandomCommandMod::plRandomCommandMod() plRandomCommandMod::plRandomCommandMod()
{ {
@ -126,11 +126,11 @@ int plRandomCommandMod::IExcludeSelections(int ncmds)
return ncmds; return ncmds;
} }
hsScalar plRandomCommandMod::IGetDelay(hsScalar len) const float plRandomCommandMod::IGetDelay(float len) const
{ {
hsScalar r = float(hsRand() * kRandNormalize); float r = float(hsRand() * kRandNormalize);
hsScalar delay = fMinDelay + (fMaxDelay - fMinDelay) * r; float delay = fMinDelay + (fMaxDelay - fMinDelay) * r;
if( fMode & kDelayFromEnd ) if( fMode & kDelayFromEnd )
delay += len; delay += len;
@ -156,7 +156,7 @@ hsBool plRandomCommandMod::ISelectNext(int ncmds)
} }
return true; return true;
} }
hsScalar r = float(hsRand() * kRandNormalize); float r = float(hsRand() * kRandNormalize);
int nSelect = ncmds; int nSelect = ncmds;
@ -294,7 +294,7 @@ void plRandomCommandMod::Write(hsStream* s, hsResMgr* mgr)
s->WriteLEScalar(fMaxDelay); s->WriteLEScalar(fMaxDelay);
} }
void plRandomCommandMod::IRetry(hsScalar secs) void plRandomCommandMod::IRetry(float secs)
{ {
IStop(); IStop();

18
Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.h

@ -73,18 +73,18 @@ protected:
uint8_t fMode; // static, if it becomes dynamic, move to SynchedValue uint8_t fMode; // static, if it becomes dynamic, move to SynchedValue
hsTArray<double> fEndTimes; hsTArray<double> fEndTimes;
hsScalar fMinDelay; float fMinDelay;
hsScalar fMaxDelay; float fMaxDelay;
void IStart(); void IStart();
virtual void IStop(); virtual void IStop();
hsBool IStopped() const; hsBool IStopped() const;
void IRetry(hsScalar secs); void IRetry(float secs);
virtual void IPlayNextIfMaster(); virtual void IPlayNextIfMaster();
void IReset(); void IReset();
hsScalar IGetDelay(hsScalar len) const; float IGetDelay(float len) const;
int IExcludeSelections(int ncmds); int IExcludeSelections(int ncmds);
hsBool ISelectNext(int nAnim); // return false if we should stop, else set fCurrent to next index hsBool ISelectNext(int nAnim); // return false if we should stop, else set fCurrent to next index
@ -94,7 +94,7 @@ protected:
virtual void IPlayNext() = 0; virtual void IPlayNext() = 0;
// We only act in response to messages. // We only act in response to messages.
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty) { return false; } virtual hsBool IEval(double secs, float del, uint32_t dirty) { return false; }
public: public:
plRandomCommandMod(); plRandomCommandMod();
@ -115,11 +115,11 @@ public:
void SetState(uint8_t s) { fState = s; } void SetState(uint8_t s) { fState = s; }
uint8_t GetState() const { return fState; } uint8_t GetState() const { return fState; }
void SetMinDelay(hsScalar f) { fMinDelay = f; } void SetMinDelay(float f) { fMinDelay = f; }
hsScalar GetMinDelay() const { return fMinDelay; } float GetMinDelay() const { return fMinDelay; }
void SetMaxDelay(hsScalar f) { fMaxDelay = f; } void SetMaxDelay(float f) { fMaxDelay = f; }
hsScalar GetMaxDelay() const { return fMaxDelay; } float GetMaxDelay() const { return fMaxDelay; }
}; };

14
Sources/Plasma/FeatureLib/pfAnimation/plStereizer.cpp

@ -119,7 +119,7 @@ hsBool plStereizer::MsgReceive(plMessage* msg)
return plSingleModifier::MsgReceive(msg); return plSingleModifier::MsgReceive(msg);
} }
hsBool plStereizer::IEval(double secs, hsScalar del, uint32_t dirty) hsBool plStereizer::IEval(double secs, float del, uint32_t dirty)
{ {
return false; return false;
} }
@ -135,7 +135,7 @@ hsBool plStereizer::Stereize()
// Find distance to listener // Find distance to listener
hsPoint3 pos = IGetUnStereoPos(); hsPoint3 pos = IGetUnStereoPos();
hsVector3 posToList(&fListPos, &pos); hsVector3 posToList(&fListPos, &pos);
hsScalar dist = posToList.Magnitude(); float dist = posToList.Magnitude();
// If distance less than ambient distance // If distance less than ambient distance
// setup as pure ambient // setup as pure ambient
@ -210,14 +210,14 @@ hsPoint3 plStereizer::IGetAmbientPos() const
return pos; return pos;
} }
hsPoint3 plStereizer::IGetLocalizedPos(const hsVector3& posToList, hsScalar distToList) const hsPoint3 plStereizer::IGetLocalizedPos(const hsVector3& posToList, float distToList) const
{ {
hsPoint3 pos = IGetUnStereoPos(); hsPoint3 pos = IGetUnStereoPos();
hsVector3 axOut(-posToList.fY, posToList.fX, 0); hsVector3 axOut(-posToList.fY, posToList.fX, 0);
hsFastMath::NormalizeAppr(axOut); hsFastMath::NormalizeAppr(axOut);
hsScalar distOut = distToList * fTanAng; float distOut = distToList * fTanAng;
if( distOut > fMaxSepDist ) if( distOut > fMaxSepDist )
distOut = fMaxSepDist; distOut = fMaxSepDist;
else if( distOut < fMinSepDist ) else if( distOut < fMinSepDist )
@ -232,12 +232,12 @@ hsPoint3 plStereizer::IGetLocalizedPos(const hsVector3& posToList, hsScalar dist
return pos; return pos;
} }
void plStereizer::SetSepAngle(hsScalar rads) void plStereizer::SetSepAngle(float rads)
{ {
fTanAng = hsScalar(tan(rads)); fTanAng = float(tan(rads));
} }
hsScalar plStereizer::GetSepAngle() const float plStereizer::GetSepAngle() const
{ {
return atan(fTanAng); return atan(fTanAng);
} }

34
Sources/Plasma/FeatureLib/pfAnimation/plStereizer.h

@ -67,13 +67,13 @@ protected:
}; };
// Static properties // Static properties
hsScalar fAmbientDist; float fAmbientDist;
hsScalar fTransition; float fTransition;
hsScalar fMaxSepDist; float fMaxSepDist;
hsScalar fMinSepDist; float fMinSepDist;
hsScalar fTanAng; float fTanAng;
hsPoint3 fInitPos; hsPoint3 fInitPos;
@ -82,9 +82,9 @@ protected:
hsVector3 fListDirection; hsVector3 fListDirection;
hsVector3 fListUp; hsVector3 fListUp;
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
hsPoint3 IGetLocalizedPos(const hsVector3& posToList, hsScalar distToList) const; hsPoint3 IGetLocalizedPos(const hsVector3& posToList, float distToList) const;
hsPoint3 IGetAmbientPos() const; hsPoint3 IGetAmbientPos() const;
void ISetNewPos(const hsPoint3& newPos); void ISetNewPos(const hsPoint3& newPos);
@ -109,20 +109,20 @@ public:
hsBool Stereize(); hsBool Stereize();
void SetFromListenerMsg(const plListenerMsg* listMsg); void SetFromListenerMsg(const plListenerMsg* listMsg);
void SetAmbientDist(hsScalar d) { fAmbientDist = d; } void SetAmbientDist(float d) { fAmbientDist = d; }
hsScalar GetAmbientDist() const { return fAmbientDist; } float GetAmbientDist() const { return fAmbientDist; }
void SetTransition(hsScalar d) { fTransition = d; } void SetTransition(float d) { fTransition = d; }
hsScalar GetTransition() const { return fTransition; } float GetTransition() const { return fTransition; }
void SetMaxSepDist(hsScalar d) { fMaxSepDist = d; } void SetMaxSepDist(float d) { fMaxSepDist = d; }
hsScalar GetMaxSepDist() const { return fMaxSepDist; } float GetMaxSepDist() const { return fMaxSepDist; }
void SetMinSepDist(hsScalar d) { fMinSepDist = d; } void SetMinSepDist(float d) { fMinSepDist = d; }
hsScalar GetMinSepDist() const { return fMinSepDist; } float GetMinSepDist() const { return fMinSepDist; }
void SetSepAngle(hsScalar rads); void SetSepAngle(float rads);
hsScalar GetSepAngle() const; float GetSepAngle() const;
void SetAsLeftChannel(hsBool on) { if(on)SetFlag(kLeftChannel); else ClearFlag(kLeftChannel); } void SetAsLeftChannel(hsBool on) { if(on)SetFlag(kLeftChannel); else ClearFlag(kLeftChannel); }
hsBool IsLeftChannel() const { return HasFlag(kLeftChannel); } hsBool IsLeftChannel() const { return HasFlag(kLeftChannel); }

8
Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp

@ -129,7 +129,7 @@ void plViewFaceModifier::SetTarget(plSceneObject* so)
plgDispatch::Dispatch()->RegisterForExactType(plArmatureUpdateMsg::Index(), GetKey()); plgDispatch::Dispatch()->RegisterForExactType(plArmatureUpdateMsg::Index(), GetKey());
} }
hsBool plViewFaceModifier::IEval(double secs, hsScalar del, uint32_t dirty) hsBool plViewFaceModifier::IEval(double secs, float del, uint32_t dirty)
{ {
return false; return false;
} }
@ -157,7 +157,7 @@ hsBool plViewFaceModifier::IFacePoint(plPipeline* pipe, const hsPoint3& at)
} }
hsPoint3 localAt = worldToLocal * at; hsPoint3 localAt = worldToLocal * at;
hsScalar len = localAt.MagnitudeSquared(); float len = localAt.MagnitudeSquared();
if( len <= 0 ) if( len <= 0 )
return false; return false;
len = -hsFastMath::InvSqrtAppr(len); len = -hsFastMath::InvSqrtAppr(len);
@ -220,7 +220,7 @@ hsBool plViewFaceModifier::IFacePoint(plPipeline* pipe, const hsPoint3& at)
x.fMap[3][0] = x.fMap[3][1] = x.fMap[3][2] = 0; x.fMap[3][0] = x.fMap[3][1] = x.fMap[3][2] = 0;
xInv.fMap[0][3] = xInv.fMap[1][3] = xInv.fMap[2][3] = 0; xInv.fMap[0][3] = xInv.fMap[1][3] = xInv.fMap[2][3] = 0;
xInv.fMap[3][3] = x.fMap[3][3] = hsScalar1; xInv.fMap[3][3] = x.fMap[3][3] = 1.f;
x.NotIdentity(); x.NotIdentity();
xInv.NotIdentity(); xInv.NotIdentity();
@ -239,7 +239,7 @@ hsBool plViewFaceModifier::IFacePoint(plPipeline* pipe, const hsPoint3& at)
x.fMap[2][1] *= fScale.fZ; x.fMap[2][1] *= fScale.fZ;
x.fMap[2][2] *= fScale.fZ; x.fMap[2][2] *= fScale.fZ;
hsScalar inv = 1.f / fScale.fX; float inv = 1.f / fScale.fX;
xInv.fMap[0][0] *= inv; xInv.fMap[0][0] *= inv;
xInv.fMap[1][0] *= inv; xInv.fMap[1][0] *= inv;
xInv.fMap[2][0] *= inv; xInv.fMap[2][0] *= inv;

2
Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.h

@ -84,7 +84,7 @@ protected:
hsBounds3Ext fMaxBounds; hsBounds3Ext fMaxBounds;
virtual hsBool IFacePoint(plPipeline* pipe, const hsPoint3& at); virtual hsBool IFacePoint(plPipeline* pipe, const hsPoint3& at);
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
enum RefType enum RefType
{ {

2
Sources/Plasma/FeatureLib/pfAudio/plListener.cpp

@ -61,7 +61,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
hsBool plListener::fPrintDbgInfo = false; hsBool plListener::fPrintDbgInfo = false;
hsBool plListener::IEval(double secs, hsScalar del, uint32_t dirty) hsBool plListener::IEval(double secs, float del, uint32_t dirty)
{ {
// if (!plgAudioSys::Active()) // if (!plgAudioSys::Active())
// return true; // return true;

4
Sources/Plasma/FeatureLib/pfAudio/plListener.h

@ -83,12 +83,12 @@ protected:
plVirtualCam1* fVCam; plVirtualCam1* fVCam;
hsScalar fPosRatio, fFacingRatio, fVelRatio; // 0 is vCam, 1 is refObject float fPosRatio, fFacingRatio, fVelRatio; // 0 is vCam, 1 is refObject
hsBool fInitMe; hsBool fInitMe;
static hsBool fPrintDbgInfo; static hsBool fPrintDbgInfo;
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
void ISetRef( const plKey &ref, hsBool binding, int type ); void ISetRef( const plKey &ref, hsBool binding, int type );
void ICheckAudio( void ) const; void ICheckAudio( void ) const;

10
Sources/Plasma/FeatureLib/pfAudio/plRandomSoundMod.cpp

@ -185,7 +185,7 @@ void plRandomSoundMod::IPlayNext()
fFirstTimePlay = false; fFirstTimePlay = false;
if( !(fMode & kOneCmd) ) if( !(fMode & kOneCmd) )
{ {
hsScalar delay = IGetDelay(0); float delay = IGetDelay(0);
double t = hsTimer::GetSysSeconds() + delay; double t = hsTimer::GetSysSeconds() + delay;
plAnimCmdMsg* anim = TRACKED_NEW plAnimCmdMsg(GetKey(), GetKey(), &t); plAnimCmdMsg* anim = TRACKED_NEW plAnimCmdMsg(GetKey(), GetKey(), &t);
@ -203,7 +203,7 @@ void plRandomSoundMod::IPlayNext()
// We don't want random sounds to synch, since we don't synch the randomness. So force this next // We don't want random sounds to synch, since we don't synch the randomness. So force this next
// sound to not synch // sound to not synch
hsScalar currLen; float currLen;
if( fGroups != nil && fGroups[ fCurrentGroup ].fGroupedIdx != -1 ) if( fGroups != nil && fGroups[ fCurrentGroup ].fGroupedIdx != -1 )
{ {
currentSndIdx = fGroups[ fCurrentGroup ].fIndices[ fCurrent ]; currentSndIdx = fGroups[ fCurrentGroup ].fIndices[ fCurrent ];
@ -245,7 +245,7 @@ void plRandomSoundMod::IPlayNext()
} }
if (ai->GetSound(currentSndIdx)) if (ai->GetSound(currentSndIdx))
currLen = (hsScalar)(ai->GetSound(currentSndIdx)->GetLength()); currLen = (float)(ai->GetSound(currentSndIdx)->GetLength());
else else
currLen = 0; currLen = 0;
} }
@ -262,7 +262,7 @@ void plRandomSoundMod::IPlayNext()
if( !(fMode & kOneCmd) ) if( !(fMode & kOneCmd) )
{ {
hsScalar delay = IGetDelay(currLen); float delay = IGetDelay(currLen);
double t = hsTimer::GetSysSeconds() + delay; double t = hsTimer::GetSysSeconds() + delay;
@ -386,7 +386,7 @@ hsBool plRandomSoundMod::MsgReceive(plMessage* msg)
return plRandomCommandMod::MsgReceive(msg); return plRandomCommandMod::MsgReceive(msg);
} }
void plRandomSoundMod::ISetVolume(hsScalar volume) void plRandomSoundMod::ISetVolume(float volume)
{ {
plSound *pSound = nil; plSound *pSound = nil;

2
Sources/Plasma/FeatureLib/pfAudio/plRandomSoundMod.h

@ -77,7 +77,7 @@ protected:
virtual void IPlayNext(); virtual void IPlayNext();
virtual void IPlayNextIfMaster(); virtual void IPlayNextIfMaster();
virtual void IStop(); virtual void IStop();
void ISetVolume(hsScalar volume); void ISetVolume(float volume);
void ISetPosition(hsPoint3); void ISetPosition(hsPoint3);
plSound *IGetSoundPtr(); plSound *IGetSoundPtr();

104
Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp

@ -73,12 +73,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetClient/plNetClientMgr.h" #include "plNetClient/plNetClientMgr.h"
hsBool plCameraBrain1_FirstPerson::fDontFade = false; hsBool plCameraBrain1_FirstPerson::fDontFade = false;
hsScalar plCameraBrain1::fFallAccel = 20.0f; float plCameraBrain1::fFallAccel = 20.0f;
hsScalar plCameraBrain1::fFallDecel = 5.0f; float plCameraBrain1::fFallDecel = 5.0f;
hsScalar plCameraBrain1::fFallVelocity = 50.0f; float plCameraBrain1::fFallVelocity = 50.0f;
hsScalar plCameraBrain1::fFallPOAAccel = 10.0f; float plCameraBrain1::fFallPOAAccel = 10.0f;
hsScalar plCameraBrain1::fFallPOADecel = 10.0f; float plCameraBrain1::fFallPOADecel = 10.0f;
hsScalar plCameraBrain1::fFallPOAVelocity = 50.0f; float plCameraBrain1::fFallPOAVelocity = 50.0f;
// basic camera brain now is a fixed brain by default. // basic camera brain now is a fixed brain by default.
// if it doesn't have a subject (an object) it will just look straight ahead. // if it doesn't have a subject (an object) it will just look straight ahead.
@ -176,13 +176,13 @@ void plCameraBrain1::Pop()
} }
// set the goal to which we want to animate the fov // set the goal to which we want to animate the fov
void plCameraBrain1::SetFOVGoal(hsScalar h, double t) void plCameraBrain1::SetFOVGoal(float h, double t)
{ {
if (fFOVGoal == h || h == fCamera->GetFOVh()) if (fFOVGoal == h || h == fCamera->GetFOVh())
return; return;
hsScalar dif = h - fCamera->GetFOVh(); float dif = h - fCamera->GetFOVh();
fFOVAnimRate = dif / ((hsScalar)t); fFOVAnimRate = dif / ((float)t);
fFOVGoal = h; fFOVGoal = h;
fFOVStartTime = hsTimer::GetSysSeconds(); fFOVStartTime = hsTimer::GetSysSeconds();
@ -192,7 +192,7 @@ void plCameraBrain1::SetFOVGoal(hsScalar h, double t)
} }
// set parameters for how this camera zooms FOV based on user input (mostly for telescopes) // set parameters for how this camera zooms FOV based on user input (mostly for telescopes)
void plCameraBrain1::SetZoomParams(hsScalar max, hsScalar min, hsScalar rate) void plCameraBrain1::SetZoomParams(float max, float min, float rate)
{ {
fZoomRate = rate; fZoomRate = rate;
fZoomMax = max; fZoomMax = max;
@ -240,7 +240,7 @@ void plCameraBrain1::Update(hsBool forced)
// adjust FOV based on elapsed time // adjust FOV based on elapsed time
void plCameraBrain1::IAnimateFOV(double time) void plCameraBrain1::IAnimateFOV(double time)
{ {
hsScalar dH = fFOVAnimRate * hsTimer::GetDelSysSeconds(); float dH = fFOVAnimRate * hsTimer::GetDelSysSeconds();
dH += fCamera->GetFOVh(); dH += fCamera->GetFOVh();
@ -251,7 +251,7 @@ void plCameraBrain1::IAnimateFOV(double time)
dH = fFOVGoal; dH = fFOVGoal;
} }
fCamera->SetFOVw( (hsScalar)(dH * plVirtualCam1::Instance()->GetAspectRatio()) ); fCamera->SetFOVw( (float)(dH * plVirtualCam1::Instance()->GetAspectRatio()) );
fCamera->SetFOVh( dH ); fCamera->SetFOVh( dH );
} }
@ -274,13 +274,13 @@ void plCameraBrain1::IMoveTowardGoal(double elapsedTime)
return; return;
} }
hsVector3 dir(fGoal - fCamera->GetTargetPos()); hsVector3 dir(fGoal - fCamera->GetTargetPos());
hsScalar distToGoal=dir.Magnitude(); float distToGoal=dir.Magnitude();
//smooth out stoppage... //smooth out stoppage...
hsScalar adjMaxVel = fVelocity; float adjMaxVel = fVelocity;
if (distToGoal <= 5.0f && distToGoal > 0.1f) if (distToGoal <= 5.0f && distToGoal > 0.1f)
{ {
hsScalar mult = (distToGoal - 5.0f)*0.1f; float mult = (distToGoal - 5.0f)*0.1f;
adjMaxVel = fVelocity - hsABS(fVelocity*mult); adjMaxVel = fVelocity - hsABS(fVelocity*mult);
} }
@ -306,7 +306,7 @@ void plCameraBrain1::IMoveTowardGoal(double elapsedTime)
fCurCamSpeed = vel.Magnitude(); fCurCamSpeed = vel.Magnitude();
hsScalar distMoved; float distMoved;
if (fFlags.IsBitSet(kPanicVelocity)) if (fFlags.IsBitSet(kPanicVelocity))
distMoved = IClampVelocity(&vel, 1000.0f, elapsedTime); distMoved = IClampVelocity(&vel, 1000.0f, elapsedTime);
else else
@ -350,16 +350,16 @@ void plCameraBrain1::IPointTowardGoal(double elapsedTime)
hsVector3 dir(fPOAGoal - fCamera->GetTargetPOA()); hsVector3 dir(fPOAGoal - fCamera->GetTargetPOA());
hsScalar distToGoal=dir.Magnitude(); float distToGoal=dir.Magnitude();
if (distToGoal > 0.0f) if (distToGoal > 0.0f)
dir.Normalize(); dir.Normalize();
// smooth out stoppage // smooth out stoppage
hsScalar adjMaxVel = fPOAVelocity; float adjMaxVel = fPOAVelocity;
if (distToGoal <= 5.0f && distToGoal > 0.1f) if (distToGoal <= 5.0f && distToGoal > 0.1f)
{ {
hsScalar mult = (distToGoal - 5.0f)*0.1f; float mult = (distToGoal - 5.0f)*0.1f;
adjMaxVel = fPOAVelocity - hsABS(fPOAVelocity*mult); adjMaxVel = fPOAVelocity - hsABS(fPOAVelocity*mult);
} }
@ -382,7 +382,7 @@ void plCameraBrain1::IPointTowardGoal(double elapsedTime)
fCurViewSpeed = vel.Magnitude(); fCurViewSpeed = vel.Magnitude();
hsScalar distMoved; float distMoved;
if (fFlags.IsBitSet(kPanicVelocity)) if (fFlags.IsBitSet(kPanicVelocity))
distMoved = IClampVelocity(&vel, 1000.0f, elapsedTime); distMoved = IClampVelocity(&vel, 1000.0f, elapsedTime);
else else
@ -402,15 +402,15 @@ void plCameraBrain1::IPointTowardGoal(double elapsedTime)
} }
void plCameraBrain1::IAdjustVelocity(hsScalar adjAccelRate, hsScalar adjDecelRate, void plCameraBrain1::IAdjustVelocity(float adjAccelRate, float adjDecelRate,
hsVector3* dir, hsVector3* vel, hsScalar maxSpeed, hsVector3* dir, hsVector3* vel, float maxSpeed,
hsScalar distToGoal, double elapsedTime) float distToGoal, double elapsedTime)
{ {
hsScalar speed = vel->Magnitude(); // save current speed float speed = vel->Magnitude(); // save current speed
*vel = *dir * speed; // change vel to correct dir *vel = *dir * speed; // change vel to correct dir
// compute accel/decel // compute accel/decel
hsScalar finalAccelRate; float finalAccelRate;
if (IShouldDecelerate(adjDecelRate, speed, distToGoal)) if (IShouldDecelerate(adjDecelRate, speed, distToGoal))
{ {
@ -425,7 +425,7 @@ void plCameraBrain1::IAdjustVelocity(hsScalar adjAccelRate, hsScalar adjDecelRat
{ {
// compute accel vector in the direction of the goal // compute accel vector in the direction of the goal
hsVector3 accelVec = *dir * finalAccelRate; hsVector3 accelVec = *dir * finalAccelRate;
accelVec = accelVec * (hsScalar)elapsedTime; accelVec = accelVec * (float)elapsedTime;
// add acceleration to velocity // add acceleration to velocity
*vel = *vel + accelVec; *vel = *vel + accelVec;
@ -436,13 +436,13 @@ void plCameraBrain1::IAdjustVelocity(hsScalar adjAccelRate, hsScalar adjDecelRat
} }
} }
hsScalar plCameraBrain1::IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime) float plCameraBrain1::IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime)
{ {
*vel = *vel * (hsScalar)elapsedTime; *vel = *vel * (float)elapsedTime;
maxSpeed *= (hsScalar)elapsedTime; maxSpeed *= (float)elapsedTime;
// clamp speed (clamp if going negative?) // clamp speed (clamp if going negative?)
hsScalar distMoved = vel->Magnitude(); float distMoved = vel->Magnitude();
if (distMoved > maxSpeed) if (distMoved > maxSpeed)
{ {
vel->Normalize(); vel->Normalize();
@ -452,16 +452,16 @@ hsScalar plCameraBrain1::IClampVelocity(hsVector3* vel, hsScalar maxSpeed, doubl
return distMoved; return distMoved;
} }
hsBool plCameraBrain1::IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal) hsBool plCameraBrain1::IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal)
{ {
if (decelSpeed == 0) if (decelSpeed == 0)
// no deceleration // no deceleration
return false; return false;
// compute distance required to stop, given decel speed (in units/sec sq) // compute distance required to stop, given decel speed (in units/sec sq)
hsScalar stopTime = curSpeed / decelSpeed; float stopTime = curSpeed / decelSpeed;
hsScalar avgSpeed = curSpeed * .5f; float avgSpeed = curSpeed * .5f;
hsScalar stopDist = avgSpeed * stopTime; float stopDist = avgSpeed * stopTime;
return (hsABS(distToGoal) <= hsABS(stopDist)); // stopDist+avgSpeed? return (hsABS(distToGoal) <= hsABS(stopDist)); // stopDist+avgSpeed?
} }
@ -476,7 +476,7 @@ void plCameraBrain1::AdjustForInput(double secs)
if (fOffsetPct < 1.0f) if (fOffsetPct < 1.0f)
{ {
hsVector3 v(fPOAGoal - fGoal); hsVector3 v(fPOAGoal - fGoal);
hsScalar len = v.Magnitude(); float len = v.Magnitude();
len = len - (len * fOffsetPct); len = len - (len * fOffsetPct);
v.Normalize(); v.Normalize();
fGoal = fGoal + (v * len); fGoal = fGoal + (v * len);
@ -710,10 +710,10 @@ void plCameraBrain1::SetSubject(plSceneObject* sub)
// //
hsScalar plCameraBrain1_Drive::fTurnRate = 100.0f; float plCameraBrain1_Drive::fTurnRate = 100.0f;
hsScalar plCameraBrain1_Drive::fAcceleration = 200.0f; float plCameraBrain1_Drive::fAcceleration = 200.0f;
hsScalar plCameraBrain1_Drive::fDeceleration = 200.0f; float plCameraBrain1_Drive::fDeceleration = 200.0f;
hsScalar plCameraBrain1_Drive::fMaxVelocity = 100.0f; float plCameraBrain1_Drive::fMaxVelocity = 100.0f;
// constructor // constructor
@ -764,7 +764,7 @@ void plCameraBrain1_Drive::Update(hsBool forced)
// update our desired position: // update our desired position:
double time = hsTimer::GetSeconds(); double time = hsTimer::GetSeconds();
hsScalar eTime = (hsScalar)(time-fLastTime); float eTime = (float)(time-fLastTime);
if(eTime > 0.01f) if(eTime > 0.01f)
eTime = 0.01f; eTime = 0.01f;
fLastTime = time; fLastTime = time;
@ -772,7 +772,7 @@ void plCameraBrain1_Drive::Update(hsBool forced)
hsVector3 view, up, right; hsVector3 view, up, right;
fTargetMatrix.GetAxis(&view,&up,&right); fTargetMatrix.GetAxis(&view,&up,&right);
hsScalar delta = 5.0f * eTime; float delta = 5.0f * eTime;
// adjust speed // adjust speed
if (HasMovementFlag(B_CAMERA_DRIVE_SPEED_UP)) if (HasMovementFlag(B_CAMERA_DRIVE_SPEED_UP))
@ -805,8 +805,8 @@ void plCameraBrain1_Drive::Update(hsBool forced)
fMaxVelocity = plVirtualCam1::Instance()->fVel; fMaxVelocity = plVirtualCam1::Instance()->fVel;
} }
hsScalar speed = fMaxVelocity; float speed = fMaxVelocity;
hsScalar turn = 1.0f; float turn = 1.0f;
if (HasMovementFlag(B_CONTROL_MODIFIER_FAST)) if (HasMovementFlag(B_CONTROL_MODIFIER_FAST))
{ {
@ -1583,7 +1583,7 @@ hsBool plCameraBrain1_Fixed::MsgReceive(plMessage* msg)
// //
// //
// circle camera crap // circle camera crap
static const hsScalar kTwoPI = 2.0f*hsScalarPI; static const float kTwoPI = 2.0f*M_PI;
plCameraBrain1_Circle::plCameraBrain1_Circle() : plCameraBrain1_Fixed() plCameraBrain1_Circle::plCameraBrain1_Circle() : plCameraBrain1_Fixed()
{ {
@ -1656,17 +1656,17 @@ hsPoint3 plCameraBrain1_Circle::MoveTowardsFromGoal(const hsPoint3* fromGoal, do
if (fCurRad != fGoalRad) if (fCurRad != fGoalRad)
{ {
hsScalar dist = hsABS(fGoalRad-fCurRad); float dist = hsABS(fGoalRad-fCurRad);
hsAssert(dist>=0 && dist<=kTwoPI, "illegal radian diff"); hsAssert(dist>=0 && dist<=kTwoPI, "illegal radian diff");
hsBool mustWrap = (dist > hsScalarPI); // go opposite direction for shortcut and wrap hsBool mustWrap = (dist > M_PI); // go opposite direction for shortcut and wrap
// compute speed // compute speed
hsScalar speed; float speed;
if (warp) if (warp)
speed = (hsScalar)(kTwoPI * 100 * secs); speed = (float)(kTwoPI * 100 * secs);
else else
speed = (hsScalar)(kTwoPI * fCirPerSec * secs); speed = (float)(kTwoPI * fCirPerSec * secs);
// move towards goalRad // move towards goalRad
hsAssert(fCurRad>=0 && fCurRad<=kTwoPI, "illegal radian value"); hsAssert(fCurRad>=0 && fCurRad<=kTwoPI, "illegal radian value");
@ -1717,7 +1717,7 @@ hsPoint3 plCameraBrain1_Circle::MoveTowardsFromGoal(const hsPoint3* fromGoal, do
hsAssert(fCurRad>=0 && fCurRad<=kTwoPI, "illegal radian value"); hsAssert(fCurRad>=0 && fCurRad<=kTwoPI, "illegal radian value");
hsPoint3 x; hsPoint3 x;
x = GetCenterPoint() + hsVector3((hsScalar)hsCosine(fCurRad)*fRadius, (hsScalar)hsSine(fCurRad)*fRadius, 0.0f); x = GetCenterPoint() + hsVector3((float)cos(fCurRad)*fRadius, (float)sin(fCurRad)*fRadius, 0.0f);
x.fZ = fCamera->GetTargetPos().fZ; x.fZ = fCamera->GetTargetPos().fZ;
return x; return x;
} }
@ -1737,8 +1737,8 @@ hsPoint3 plCameraBrain1_Circle::IGetClosestPointOnCircle(const hsPoint3* toThis)
v = hsVector3(&center, &p); v = hsVector3(&center, &p);
} }
v.Normalize(); v.Normalize();
fGoalRad = (hsScalar)atan2(v.fY, v.fX); // -pi to pi fGoalRad = (float)atan2(v.fY, v.fX); // -pi to pi
hsAssert(fGoalRad>=-hsScalarPI && fGoalRad<=hsScalarPI, "Illegal atan2 val"); hsAssert(fGoalRad>=-M_PI && fGoalRad<=M_PI, "Illegal atan2 val");
if (fGoalRad<0) if (fGoalRad<0)
fGoalRad = kTwoPI + fGoalRad; // 0 to 2pi fGoalRad = kTwoPI + fGoalRad; // 0 to 2pi
hsAssert(fGoalRad>=0 && fGoalRad<=kTwoPI, "Illegal atan2 val"); hsAssert(fGoalRad>=0 && fGoalRad<=kTwoPI, "Illegal atan2 val");

134
Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.h

@ -94,12 +94,12 @@ public:
void SetCamera(plCameraModifier1* pMod) { fCamera = pMod; } void SetCamera(plCameraModifier1* pMod) { fCamera = pMod; }
void SetAccel (hsScalar f) { fAccel = f; } void SetAccel (float f) { fAccel = f; }
void SetDecel (hsScalar f) { fDecel = f; } void SetDecel (float f) { fDecel = f; }
void SetVelocity (hsScalar f) { fVelocity = f; } void SetVelocity (float f) { fVelocity = f; }
void SetPOAAccel (hsScalar f) { fPOAAccel = f; } void SetPOAAccel (float f) { fPOAAccel = f; }
void SetPOADecel (hsScalar f) { fPOADecel = f; } void SetPOADecel (float f) { fPOADecel = f; }
void SetPOAVelocity (hsScalar f) { fPOAVelocity = f; } void SetPOAVelocity (float f) { fPOAVelocity = f; }
const plCameraModifier1* GetCamera() { return fCamera; } const plCameraModifier1* GetCamera() { return fCamera; }
@ -128,13 +128,13 @@ public:
void SetGoal(hsPoint3 pt) { fGoal = pt; } void SetGoal(hsPoint3 pt) { fGoal = pt; }
void SetPOAGoal(hsPoint3 pt) { fPOAGoal = pt; } void SetPOAGoal(hsPoint3 pt) { fPOAGoal = pt; }
void SetFOVGoal(hsScalar h, double t); void SetFOVGoal(float h, double t);
void SetZoomParams(hsScalar max, hsScalar min, hsScalar rate); void SetZoomParams(float max, float min, float rate);
void SetXPanLimit(hsScalar x) {fXPanLimit = x;} void SetXPanLimit(float x) {fXPanLimit = x;}
void SetZPanLimit(hsScalar y) {fZPanLimit = y;} void SetZPanLimit(float y) {fZPanLimit = y;}
hsScalar GetXPanLimit() {return fXPanLimit;} float GetXPanLimit() {return fXPanLimit;}
hsScalar GetZPanLimit() {return fZPanLimit;} float GetZPanLimit() {return fZPanLimit;}
void SetRail(plRailCameraMod* m) { fRail = m; } void SetRail(plRailCameraMod* m) { fRail = m; }
@ -144,28 +144,28 @@ public:
virtual void Push(hsBool recenter = true); virtual void Push(hsBool recenter = true);
virtual void Pop(); virtual void Pop();
hsScalar GetVelocity() { return fVelocity; } float GetVelocity() { return fVelocity; }
hsScalar GetAccel() { return fAccel; } float GetAccel() { return fAccel; }
hsScalar GetDecel() { return fDecel; } float GetDecel() { return fDecel; }
hsScalar GetPOAAccel() { return fPOAAccel; } float GetPOAAccel() { return fPOAAccel; }
hsScalar GetPOAVelocity() { return fPOAVelocity; } float GetPOAVelocity() { return fPOAVelocity; }
hsScalar GetPOADecel() { return fPOADecel; } float GetPOADecel() { return fPOADecel; }
hsScalar GetCurrentCamSpeed() { return fCurCamSpeed; } float GetCurrentCamSpeed() { return fCurCamSpeed; }
hsScalar GetCurrentViewSpeed() { return fCurViewSpeed; } float GetCurrentViewSpeed() { return fCurViewSpeed; }
void SetCurrentCamSpeed(hsScalar s) { fCurCamSpeed = s; } void SetCurrentCamSpeed(float s) { fCurCamSpeed = s; }
void SetCurrentViewSpeed(hsScalar s) { fCurViewSpeed = s; } void SetCurrentViewSpeed(float s) { fCurViewSpeed = s; }
hsMatrix44 GetTargetMatrix() { return fTargetMatrix; } hsMatrix44 GetTargetMatrix() { return fTargetMatrix; }
static hsScalar fFallVelocity; static float fFallVelocity;
static hsScalar fFallAccel; static float fFallAccel;
static hsScalar fFallDecel; static float fFallDecel;
static hsScalar fFallPOAVelocity; static float fFallPOAVelocity;
static hsScalar fFallPOAAccel; static float fFallPOAAccel;
static hsScalar fFallPOADecel; static float fFallPOADecel;
protected: protected:
@ -173,48 +173,48 @@ protected:
void IMoveTowardGoal(double time); void IMoveTowardGoal(double time);
void IPointTowardGoal(double time); void IPointTowardGoal(double time);
void IAnimateFOV(double time); void IAnimateFOV(double time);
void IAdjustVelocity(hsScalar adjAccelRate, void IAdjustVelocity(float adjAccelRate,
hsScalar adjDecelRate, float adjDecelRate,
hsVector3* dir, hsVector3* dir,
hsVector3* vel, hsVector3* vel,
hsScalar maxSpeed, float maxSpeed,
hsScalar distToGoal, float distToGoal,
double elapsedTime); double elapsedTime);
hsScalar IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime); float IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime);
hsBool IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal); hsBool IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal);
plCameraModifier1* fCamera; plCameraModifier1* fCamera;
plKey fSubjectKey; plKey fSubjectKey;
plRailCameraMod* fRail; plRailCameraMod* fRail;
hsScalar fCurCamSpeed; float fCurCamSpeed;
hsScalar fCurViewSpeed; float fCurViewSpeed;
double fLastTime; double fLastTime;
hsScalar fVelocity; float fVelocity;
hsScalar fAccel; float fAccel;
hsScalar fDecel; float fDecel;
hsScalar fPOAVelocity; float fPOAVelocity;
hsScalar fPOAAccel; float fPOAAccel;
hsScalar fPOADecel; float fPOADecel;
hsVector3 fPOAOffset; hsVector3 fPOAOffset;
hsPoint3 fGoal; hsPoint3 fGoal;
hsPoint3 fPOAGoal; hsPoint3 fPOAGoal;
hsScalar fXPanLimit; float fXPanLimit;
hsScalar fZPanLimit; float fZPanLimit;
hsScalar fPanSpeed; float fPanSpeed;
hsScalar fFOVGoal; float fFOVGoal;
double fFOVStartTime; double fFOVStartTime;
double fFOVEndTime; double fFOVEndTime;
hsScalar fFOVAnimRate; float fFOVAnimRate;
hsScalar fZoomRate; float fZoomRate;
hsScalar fZoomMax; float fZoomMax;
hsScalar fZoomMin; float fZoomMin;
hsBitVector fMoveFlags; hsBitVector fMoveFlags;
hsBitVector fFlags; hsBitVector fFlags;
hsMatrix44 fTargetMatrix; hsMatrix44 fTargetMatrix;
hsScalar fOffsetLength; float fOffsetLength;
hsScalar fOffsetPct; float fOffsetPct;
double fFallTimer; double fFallTimer;
}; };
@ -226,8 +226,8 @@ protected:
hsPoint3 fDesiredPosition; hsPoint3 fDesiredPosition;
hsPoint3 fFacingTarget; hsPoint3 fFacingTarget;
hsBool bUseDesiredFacing; hsBool bUseDesiredFacing;
hsScalar deltaX; float deltaX;
hsScalar deltaY; float deltaY;
hsBool bDisregardY; // these are here to prevent hsBool bDisregardY; // these are here to prevent
hsBool bDisregardX; // the camera from jumping when the mouse cursor recenters / wraps around. hsBool bDisregardX; // the camera from jumping when the mouse cursor recenters / wraps around.
hsVector3 fUp; hsVector3 fUp;
@ -238,7 +238,7 @@ public:
plCameraBrain1_Drive(plCameraModifier1* pMod); plCameraBrain1_Drive(plCameraModifier1* pMod);
~plCameraBrain1_Drive(); ~plCameraBrain1_Drive();
static void SetSensitivity(hsScalar f) { fTurnRate = f; } static void SetSensitivity(float f) { fTurnRate = f; }
CLASSNAME_REGISTER( plCameraBrain1_Drive ); CLASSNAME_REGISTER( plCameraBrain1_Drive );
GETINTERFACE_ANY( plCameraBrain1_Drive, plCameraBrain1 ); GETINTERFACE_ANY( plCameraBrain1_Drive, plCameraBrain1 );
@ -248,10 +248,10 @@ public:
virtual void Push(hsBool recenter = true); virtual void Push(hsBool recenter = true);
virtual void Pop(); virtual void Pop();
static hsScalar fAcceleration; static float fAcceleration;
static hsScalar fDeceleration; static float fDeceleration;
static hsScalar fMaxVelocity; static float fMaxVelocity;
static hsScalar fTurnRate; static float fTurnRate;
}; };
@ -365,10 +365,10 @@ protected:
uint32_t fCircleFlags; uint32_t fCircleFlags;
hsPoint3 fCenter; hsPoint3 fCenter;
plSceneObject* fCenterObject; // optional, use instead of fCenter plSceneObject* fCenterObject; // optional, use instead of fCenter
hsScalar fRadius; float fRadius;
hsScalar fCurRad, fGoalRad; // Radians float fCurRad, fGoalRad; // Radians
plSceneObject* fPOAObj; // in this case the subject is who we stay close to/away from plSceneObject* fPOAObj; // in this case the subject is who we stay close to/away from
hsScalar fCirPerSec; float fCirPerSec;
hsPoint3 IGetClosestPointOnCircle(const hsPoint3* toThisPt); hsPoint3 IGetClosestPointOnCircle(const hsPoint3* toThisPt);
public: public:
@ -389,13 +389,13 @@ public:
uint32_t GetCircleFlags() { return fCircleFlags; } uint32_t GetCircleFlags() { return fCircleFlags; }
hsPoint3* GetCenter() { return &fCenter; } // use GetCenterPoint hsPoint3* GetCenter() { return &fCenter; } // use GetCenterPoint
hsPoint3 GetCenterPoint(); hsPoint3 GetCenterPoint();
hsScalar GetRadius() { return fRadius; } float GetRadius() { return fRadius; }
plSceneObject* GetCenterObject() { return fCenterObject; } plSceneObject* GetCenterObject() { return fCenterObject; }
void SetCircumferencePerSec(hsScalar h) { fCirPerSec = h; } void SetCircumferencePerSec(float h) { fCirPerSec = h; }
void SetCircleFlags(uint32_t f) { fCircleFlags|=f; } void SetCircleFlags(uint32_t f) { fCircleFlags|=f; }
void SetCenter(hsPoint3* ctr) { fCenter = *ctr; } // Circle lies in the plane z = ctr->z void SetCenter(hsPoint3* ctr) { fCenter = *ctr; } // Circle lies in the plane z = ctr->z
void SetRadius(hsScalar radius) { fRadius = radius; } void SetRadius(float radius) { fRadius = radius; }
void SetFarCircleCam(hsBool farType) { if (farType) fCircleFlags |= kFarthest; else fCircleFlags &= ~kFarthest; } void SetFarCircleCam(hsBool farType) { if (farType) fCircleFlags |= kFarthest; else fCircleFlags &= ~kFarthest; }
void SetCenterObjectKey(plKey k); void SetCenterObjectKey(plKey k);
void SetPOAObject(plSceneObject* pObj) { fPOAObj = pObj; } void SetPOAObject(plSceneObject* pObj) { fPOAObj = pObj; }

18
Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp

@ -137,14 +137,14 @@ plSceneObject* plCameraModifier1::GetSubject()
return fSubObj; return fSubObj;
} }
void plCameraModifier1::SetFOVw(hsScalar f, hsBool fUpdateVCam) void plCameraModifier1::SetFOVw(float f, hsBool fUpdateVCam)
{ {
fFOVw = f; fFOVw = f;
if (plVirtualCam1::Instance() && fUpdateVCam) if (plVirtualCam1::Instance() && fUpdateVCam)
plVirtualCam1::SetFOV(fFOVw, fFOVh, this); plVirtualCam1::SetFOV(fFOVw, fFOVh, this);
} }
void plCameraModifier1::SetFOVh(hsScalar f, hsBool fUpdateVCam) void plCameraModifier1::SetFOVh(float f, hsBool fUpdateVCam)
{ {
fFOVh = f; fFOVh = f;
if (plVirtualCam1::Instance() && fUpdateVCam) if (plVirtualCam1::Instance() && fUpdateVCam)
@ -191,7 +191,7 @@ hsBool plCameraModifier1::MsgReceive(plMessage* msg)
double time = (double)fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fAccel; double time = (double)fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fAccel;
double time2 = (double)pEventMsg->fEventTime; double time2 = (double)pEventMsg->fEventTime;
time = hsABS(time - time2); time = hsABS(time - time2);
hsScalar h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh; float h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh;
if (GetBrain()) if (GetBrain())
GetBrain()->SetFOVGoal(h, time); GetBrain()->SetFOVGoal(h, time);
} }
@ -333,12 +333,12 @@ void plCameraModifier1::Read(hsStream* stream, hsResMgr* mgr)
hsBool cutpos = stream->ReadBool(); hsBool cutpos = stream->ReadBool();
hsBool cutpoa = stream->ReadBool(); hsBool cutpoa = stream->ReadBool();
hsBool ignore = stream->ReadBool(); hsBool ignore = stream->ReadBool();
hsScalar v = stream->ReadLEScalar(); float v = stream->ReadLEScalar();
hsScalar a = stream->ReadLEScalar(); float a = stream->ReadLEScalar();
hsScalar d = stream->ReadLEScalar(); float d = stream->ReadLEScalar();
hsScalar pV = stream->ReadLEScalar(); float pV = stream->ReadLEScalar();
hsScalar pA = stream->ReadLEScalar(); float pA = stream->ReadLEScalar();
hsScalar pD = stream->ReadLEScalar(); float pD = stream->ReadLEScalar();
CamTrans* camTrans = TRACKED_NEW CamTrans(key); CamTrans* camTrans = TRACKED_NEW CamTrans(key);
camTrans->fAccel = a; camTrans->fAccel = a;

26
Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.h

@ -75,12 +75,12 @@ struct CamTrans
hsBool fCutPos; hsBool fCutPos;
hsBool fCutPOA; hsBool fCutPOA;
hsBool fIgnore; hsBool fIgnore;
hsScalar fAccel; float fAccel;
hsScalar fDecel; float fDecel;
hsScalar fVelocity; float fVelocity;
hsScalar fPOAAccel; float fPOAAccel;
hsScalar fPOADecel; float fPOADecel;
hsScalar fPOAVelocity; float fPOAVelocity;
}; };
@ -96,7 +96,7 @@ class plCameraModifier1 : public plSingleModifier
protected: protected:
void Output(); void Output();
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty) { return true; } virtual hsBool IEval(double secs, float del, uint32_t dirty) { return true; }
public: public:
@ -128,10 +128,10 @@ public:
void SetTargetPOA(hsPoint3 pos) { fAt = pos; } void SetTargetPOA(hsPoint3 pos) { fAt = pos; }
void SetSubworldPos(hsPoint3 pos) { fLastSubPos = pos; } void SetSubworldPos(hsPoint3 pos) { fLastSubPos = pos; }
void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; } void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; }
hsScalar GetFOVw() { return fFOVw; } float GetFOVw() { return fFOVw; }
hsScalar GetFOVh() { return fFOVh; } float GetFOVh() { return fFOVh; }
void SetFOVw(hsScalar f, hsBool fUpdateVCam = true); void SetFOVw(float f, hsBool fUpdateVCam = true);
void SetFOVh(hsScalar f, hsBool fUpdateVCam = true); void SetFOVh(float f, hsBool fUpdateVCam = true);
hsBool GetInSubworld() { return fInSubLastUpdate; } hsBool GetInSubworld() { return fInSubLastUpdate; }
void InSubworld(hsBool b) { fInSubLastUpdate = b; } void InSubworld(hsBool b) { fInSubLastUpdate = b; }
virtual void Read(hsStream* stream, hsResMgr* mgr); virtual void Read(hsStream* stream, hsResMgr* mgr);
@ -157,8 +157,8 @@ private:
plCameraBrain1* fBrain; // the 'logic' portion of the camera plCameraBrain1* fBrain; // the 'logic' portion of the camera
hsTArray<CamTrans*> fTrans; hsTArray<CamTrans*> fTrans;
plSceneObject* fSubObj; plSceneObject* fSubObj;
hsScalar fFOVw; float fFOVw;
hsScalar fFOVh; float fFOVh;
hsTArray<plMessage*> fMessageQueue; hsTArray<plMessage*> fMessageQueue;
hsTArray<plCameraMsg*> fFOVInstructions; hsTArray<plCameraMsg*> fFOVInstructions;
hsBool fAnimated, fStartAnimOnPush, fStopAnimOnPop, fResetAnimOnPop; hsBool fAnimated, fStartAnimOnPush, fStopAnimOnPop, fResetAnimOnPop;

6
Sources/Plasma/FeatureLib/pfCamera/plInterestingModifier.cpp

@ -52,11 +52,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
hsScalar plInterestingModifier::fInterestRadius = 100.0f; float plInterestingModifier::fInterestRadius = 100.0f;
hsScalar plInterestingModifier::fInterestWeight = 1.0f; float plInterestingModifier::fInterestWeight = 1.0f;
hsBool plInterestingModifier::IEval(double secs, hsScalar del, uint32_t dirty) hsBool plInterestingModifier::IEval(double secs, float del, uint32_t dirty)
{ {
for (int i=0; i < GetNumTargets(); i++) for (int i=0; i < GetNumTargets(); i++)
{ {

16
Sources/Plasma/FeatureLib/pfCamera/plInterestingModifier.h

@ -62,12 +62,12 @@ protected:
}; };
uint8_t fType; uint8_t fType;
hsScalar fView; float fView;
static hsScalar fInterestRadius; static float fInterestRadius;
static hsScalar fInterestWeight; static float fInterestWeight;
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); virtual hsBool IEval(double secs, float del, uint32_t dirty);
public: public:
plInterestingModifier(){ fType = kTypeInteresting;} plInterestingModifier(){ fType = kTypeInteresting;}
@ -78,11 +78,11 @@ public:
CLASSNAME_REGISTER( plInterestingModifier ); CLASSNAME_REGISTER( plInterestingModifier );
GETINTERFACE_ANY( plInterestingModifier, plSingleModifier ); GETINTERFACE_ANY( plInterestingModifier, plSingleModifier );
hsScalar GetInterestWeight() { return fInterestWeight; } float GetInterestWeight() { return fInterestWeight; }
hsScalar GetInterestRadius() { return fInterestRadius; } float GetInterestRadius() { return fInterestRadius; }
void SetInterestWeight(hsScalar _InterestRadius) { fInterestWeight =_InterestRadius; } void SetInterestWeight(float _InterestRadius) { fInterestWeight =_InterestRadius; }
void SetInterestRadius(hsScalar _InterestWeight) { fInterestRadius =_InterestWeight; } void SetInterestRadius(float _InterestWeight) { fInterestRadius =_InterestWeight; }
virtual void AddTarget(plSceneObject* so); virtual void AddTarget(plSceneObject* so);

62
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp

@ -86,21 +86,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsConfig.h" #include "hsConfig.h"
#include "hsQuat.h" #include "hsQuat.h"
hsScalar plVirtualCam1::fFOVw = 45.0f; float plVirtualCam1::fFOVw = 45.0f;
hsScalar plVirtualCam1::fFOVh = 33.75f; float plVirtualCam1::fFOVh = 33.75f;
hsScalar plVirtualCam1::fHither = 0.3f; float plVirtualCam1::fHither = 0.3f;
hsScalar plVirtualCam1::fYon = 500.0f; float plVirtualCam1::fYon = 500.0f;
hsBool plVirtualCam1::printFOV = false; hsBool plVirtualCam1::printFOV = false;
hsBool plVirtualCam1::fUseAccelOverride = 1; hsBool plVirtualCam1::fUseAccelOverride = 1;
hsBool plVirtualCam1::freeze = 0; hsBool plVirtualCam1::freeze = 0;
//hsScalar plVirtualCam1::fAccel = 5.0f; //float plVirtualCam1::fAccel = 5.0f;
//hsScalar plVirtualCam1::fDecel = 5.0f; //float plVirtualCam1::fDecel = 5.0f;
//hsScalar plVirtualCam1::fVel = 10.0f; //float plVirtualCam1::fVel = 10.0f;
hsScalar plVirtualCam1::fAccel = 50.0f; float plVirtualCam1::fAccel = 50.0f;
hsScalar plVirtualCam1::fDecel = 50.0f; float plVirtualCam1::fDecel = 50.0f;
hsScalar plVirtualCam1::fVel = 100.0f; float plVirtualCam1::fVel = 100.0f;
hsScalar plVirtualCam1::fPanResponseTime = 3.0f; float plVirtualCam1::fPanResponseTime = 3.0f;
hsScalar plVirtualCam1::fFallTimerDelay = 0.25f; float plVirtualCam1::fFallTimerDelay = 0.25f;
hsBool plVirtualCam1::alwaysCutForColin = false; hsBool plVirtualCam1::alwaysCutForColin = false;
hsBool plVirtualCam1::WalkPan3rdPerson = false; hsBool plVirtualCam1::WalkPan3rdPerson = false;
hsBool plVirtualCam1::StayInFirstPersonForever = false; hsBool plVirtualCam1::StayInFirstPersonForever = false;
@ -287,7 +287,7 @@ void plVirtualCam1::SetOffset(float x, float y, float z)
} }
// static function // static function
void plVirtualCam1::SetFOV(hsScalar x, hsScalar y) void plVirtualCam1::SetFOV(float x, float y)
{ {
float fovW = y * fAspectRatio; float fovW = y * fAspectRatio;
@ -307,12 +307,12 @@ if (printFOV)
} }
// static function // static function
void plVirtualCam1::SetFOV(hsScalar x, hsScalar y, plCameraModifier1* pCam) void plVirtualCam1::SetFOV(float x, float y, plCameraModifier1* pCam)
{ {
if (plVirtualCam1::Instance()->GetCurrentCamera() != pCam) if (plVirtualCam1::Instance()->GetCurrentCamera() != pCam)
return; return;
hsScalar diff = hsABS(fFOVw - x); float diff = hsABS(fFOVw - x);
if (diff > 10.0f) if (diff > 10.0f)
{ {
#ifdef STATUS_LOG #ifdef STATUS_LOG
@ -339,7 +339,7 @@ void plVirtualCam1::SetFOV(hsScalar x, hsScalar y, plCameraModifier1* pCam)
// static function // static function
void plVirtualCam1::SetDepth(hsScalar h, hsScalar y) void plVirtualCam1::SetDepth(float h, float y)
{ {
return; return;
fHither = h; fHither = h;
@ -684,17 +684,17 @@ void plVirtualCam1::AdjustForInput()
UnPanIfNeeded(); UnPanIfNeeded();
hsScalar panSpeed = 0.5f; float panSpeed = 0.5f;
double secs = hsTimer::GetDelSysSeconds(); double secs = hsTimer::GetDelSysSeconds();
if (HasMovementFlag(B_CAMERA_PAN_UP)) if (HasMovementFlag(B_CAMERA_PAN_UP))
fY -= (hsScalar)(panSpeed * secs); fY -= (float)(panSpeed * secs);
if (HasMovementFlag(B_CAMERA_PAN_DOWN)) if (HasMovementFlag(B_CAMERA_PAN_DOWN))
fY += (hsScalar)(panSpeed * secs); fY += (float)(panSpeed * secs);
if (HasMovementFlag(B_CAMERA_PAN_LEFT)) if (HasMovementFlag(B_CAMERA_PAN_LEFT))
fX -= (hsScalar)(panSpeed * secs); fX -= (float)(panSpeed * secs);
if (HasMovementFlag(B_CAMERA_PAN_RIGHT)) if (HasMovementFlag(B_CAMERA_PAN_RIGHT))
fX += (hsScalar)(panSpeed * secs); fX += (float)(panSpeed * secs);
} }
if ((fY == 0.5f && fX == 0.5f) && if ((fY == 0.5f && fX == 0.5f) &&
fFirstPersonOverride == nil) fFirstPersonOverride == nil)
@ -725,17 +725,17 @@ void plVirtualCam1::AdjustForInput()
// scale maximum angle by % mouse input // scale maximum angle by % mouse input
hsScalar scaledX; float scaledX;
if (fFirstPersonOverride) if (fFirstPersonOverride)
scaledX = 3.14159; scaledX = 3.14159;
else else
scaledX = (hsScalar)(3.14159 - (fXPanLimit * ( (fX - 0.5f) / 0.5f))); scaledX = (float)(3.14159 - (fXPanLimit * ( (fX - 0.5f) / 0.5f)));
hsScalar scaledZ; float scaledZ;
if (fFirstPersonOverride) if (fFirstPersonOverride)
scaledZ = (hsScalar)(3.14159 - (0.872f * ( (fY - 0.5f) / 0.5f))); scaledZ = (float)(3.14159 - (0.872f * ( (fY - 0.5f) / 0.5f)));
else else
scaledZ = (hsScalar)(3.14159 - (fZPanLimit * ( (fY - 0.5f) / 0.5f))); scaledZ = (float)(3.14159 - (fZPanLimit * ( (fY - 0.5f) / 0.5f)));
hsMatrix44 mX; hsMatrix44 mX;
hsMatrix44 mZ; hsMatrix44 mZ;
@ -1068,8 +1068,8 @@ hsBool plVirtualCam1::MsgReceive(plMessage* msg)
{ {
if (!HasFlags(kFalling)) if (!HasFlags(kFalling))
{ {
hsScalar dX = pMouseMsg->GetDX(); float dX = pMouseMsg->GetDX();
hsScalar dY = pMouseMsg->GetDY(); float dY = pMouseMsg->GetDY();
if (plMouseDevice::GetInverted()) if (plMouseDevice::GetInverted())
{ {
dX *= -1.f; dX *= -1.f;
@ -1906,7 +1906,7 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
curVec.fZ = transVec.fZ = 0; curVec.fZ = transVec.fZ = 0;
transVec.Normalize(); transVec.Normalize();
curVec.Normalize(); curVec.Normalize();
hsScalar dot = curVec * transVec; float dot = curVec * transVec;
if (dot <= 0.5f || transVec.MagnitudeSquared() != 0.0f) if (dot <= 0.5f || transVec.MagnitudeSquared() != 0.0f)
{ {
pBrain->SetPOAAccel(100); pBrain->SetPOAAccel(100);
@ -1973,7 +1973,7 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
pBrain->SetCamera(fTransitionCamera); pBrain->SetCamera(fTransitionCamera);
// deal with FOV - // deal with FOV -
hsScalar diffH = hsABS(pCam->GetFOVh() - fPrevCam->GetFOVh()); float diffH = hsABS(pCam->GetFOVh() - fPrevCam->GetFOVh());
if ( diffH ) if ( diffH )
{ {
double time = 0; double time = 0;
@ -2029,7 +2029,7 @@ void plVirtualCam1::RunTransition()
plCameraBrain1_Avatar* pAvBr = plCameraBrain1_Avatar::ConvertNoRef(pBrain); plCameraBrain1_Avatar* pAvBr = plCameraBrain1_Avatar::ConvertNoRef(pBrain);
if (pAvBr) if (pAvBr)
{ {
hsScalar off = pAvBr->GetOffset().MagnitudeSquared(); float off = pAvBr->GetOffset().MagnitudeSquared();
hsVector3 dist(pToCam->GetTargetPos() - fTransitionCamera->GetTargetPos()); hsVector3 dist(pToCam->GetTargetPos() - fTransitionCamera->GetTargetPos());
if (dist.MagnitudeSquared() > off) if (dist.MagnitudeSquared() > off)
fTransitionCamera->GetBrain()->SetFlags(plCameraBrain1::kPanicVelocity); fTransitionCamera->GetBrain()->SetFlags(plCameraBrain1::kPanicVelocity);

46
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h

@ -120,13 +120,13 @@ public:
void Init(); void Init();
virtual hsBool MsgReceive(plMessage* msg); virtual hsBool MsgReceive(plMessage* msg);
static void SetFOV(hsScalar w, hsScalar h); static void SetFOV(float w, float h);
static void SetFOV(hsScalar w, hsScalar h, plCameraModifier1* pCam); static void SetFOV(float w, float h, plCameraModifier1* pCam);
static void SetDepth(hsScalar h, hsScalar y); static void SetDepth(float h, float y);
static hsScalar GetFOVw() { return fFOVw; } static float GetFOVw() { return fFOVw; }
static hsScalar GetFOVh() { return fFOVh; } static float GetFOVh() { return fFOVh; }
static hsScalar GetHither() { return fHither; } static float GetHither() { return fHither; }
static hsScalar GetYon() { return fYon; } static float GetYon() { return fYon; }
static void SetOffset(float x, float y, float z); static void SetOffset(float x, float y, float z);
static void SetAspectRatio(float aspect) { fAspectRatio = aspect; } static void SetAspectRatio(float aspect) { fAspectRatio = aspect; }
static float GetAspectRatio() { return fAspectRatio; } static float GetAspectRatio() { return fAspectRatio; }
@ -174,8 +174,8 @@ public:
void StartUnPan(); void StartUnPan();
// these are for console access // these are for console access
static hsBool fUseAccelOverride, freeze, alwaysCutForColin, WalkPan3rdPerson,StayInFirstPersonForever; static hsBool fUseAccelOverride, freeze, alwaysCutForColin, WalkPan3rdPerson,StayInFirstPersonForever;
static hsScalar fDecel, fAccel, fVel; static float fDecel, fAccel, fVel;
static hsScalar fFallTimerDelay; static float fFallTimerDelay;
private: private:
@ -215,19 +215,19 @@ private:
hsBitVector fFlags; hsBitVector fFlags;
hsTArray<plSceneObject*> fCamerasLoaded; hsTArray<plSceneObject*> fCamerasLoaded;
hsBitVector fMoveFlags; hsBitVector fMoveFlags;
hsScalar fX; float fX;
hsScalar fY; float fY;
hsScalar fXPanLimit; float fXPanLimit;
hsScalar fZPanLimit; float fZPanLimit;
hsScalar fXPanLimitGoal; float fXPanLimitGoal;
hsScalar fZPanLimitGoal; float fZPanLimitGoal;
hsScalar fXUnPanRate; float fXUnPanRate;
hsScalar fZUnPanRate; float fZUnPanRate;
hsScalar fXPanInterpRate; float fXPanInterpRate;
hsScalar fZPanInterpRate; float fZPanInterpRate;
double fUnPanEndTime; double fUnPanEndTime;
double fInterpPanLimitTime; double fInterpPanLimitTime;
hsScalar fRetainedFY; float fRetainedFY;
// built-in cameras // built-in cameras
plCameraModifier1* fDriveCamera; // for driving around plCameraModifier1* fDriveCamera; // for driving around
@ -237,11 +237,11 @@ private:
plCameraModifier1* fPrevCam; // the last camera we were displaying plCameraModifier1* fPrevCam; // the last camera we were displaying
plCameraModifier1* fThirdPersonCam; // built in third person cam for ccr's when they jump about plCameraModifier1* fThirdPersonCam; // built in third person cam for ccr's when they jump about
static hsScalar fFOVh, fFOVw; static float fFOVh, fFOVw;
static hsScalar fHither, fYon; static float fHither, fYon;
static plVirtualCam1* fInstance; static plVirtualCam1* fInstance;
static hsBool printFOV; static hsBool printFOV;
static hsScalar fPanResponseTime; static float fPanResponseTime;
static float fAspectRatio; static float fAspectRatio;
hsBool fForceCutOnce; hsBool fForceCutOnce;

2
Sources/Plasma/FeatureLib/pfCharacter/pfMarkerMgr.cpp

@ -168,7 +168,7 @@ void pfMarkerMgr::AddMarker(double x, double y, double z, uint32_t id, bool just
DEL(fMarkers[id]); DEL(fMarkers[id]);
} }
hsPoint3 pos((hsScalar)x, (hsScalar)y, (hsScalar)z); hsPoint3 pos((float)x, (float)y, (float)z);
fMarkers[id] = TRACKED_NEW pfMarkerInfo(pos, justCreated); fMarkers[id] = TRACKED_NEW pfMarkerInfo(pos, justCreated);
fMarkers[id]->Spawn(pfMarkerInfo::kMarkerOpen); fMarkers[id]->Spawn(pfMarkerInfo::kMarkerOpen);
} }

50
Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.cpp

@ -77,10 +77,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
//#include "../plHavok1/plHKPhysical.h" //#include "../plHavok1/plHKPhysical.h"
// //
//hsScalar plPlayerModifier::fTurnRate = 1.0f; //float plPlayerModifier::fTurnRate = 1.0f;
//hsScalar plPlayerModifier::fAcceleration = 80.0f; //float plPlayerModifier::fAcceleration = 80.0f;
//hsScalar plPlayerModifier::fDeceleration = 80.0f; //float plPlayerModifier::fDeceleration = 80.0f;
//hsScalar plPlayerModifier::fMaxVelocity = 200.0f; //float plPlayerModifier::fMaxVelocity = 200.0f;
// //
//plPlayerModifier::plPlayerModifier() : //plPlayerModifier::plPlayerModifier() :
//bUseDesiredFacing(false), //bUseDesiredFacing(false),
@ -277,7 +277,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//hsPoint3 forceRight(-200,0,0); //hsPoint3 forceRight(-200,0,0);
//hsPoint3 forceUp(0,0,15); //hsPoint3 forceUp(0,0,15);
// //
//hsBool plPlayerModifier::IEval(double secs, hsScalar del, uint32_t dirty) //hsBool plPlayerModifier::IEval(double secs, float del, uint32_t dirty)
//{ //{
// // setup for local player if necessary // // setup for local player if necessary
// if (HasFlag(kNeedsLocalSetup)) // if (HasFlag(kNeedsLocalSetup))
@ -371,8 +371,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// return true; // return true;
// //
// // update our desired position: // // update our desired position:
//// hsScalar eTime = secs - fLastTime; //// float eTime = secs - fLastTime;
// hsScalar eTime = hsTimer::GetDelSysSeconds(); // float eTime = hsTimer::GetDelSysSeconds();
// //
// hsPoint3 newLinearForce(0,0,0); // hsPoint3 newLinearForce(0,0,0);
// //
@ -385,8 +385,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// hsVector3 view, up, right; // hsVector3 view, up, right;
// targetMatrix.GetAxis(&view, &up, &right); // targetMatrix.GetAxis(&view, &up, &right);
// //
// hsScalar speed = fMaxVelocity; // float speed = fMaxVelocity;
// hsScalar turn = fTurnRate; // float turn = fTurnRate;
// //
// if (HasMovementFlag(B_CONTROL_MODIFIER_FAST)) // if (HasMovementFlag(B_CONTROL_MODIFIER_FAST))
// { // {
@ -437,7 +437,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// hsPoint3 newPos; // hsPoint3 newPos;
// //
// hsVector3 dir(fDesiredPosition - curPos); // hsVector3 dir(fDesiredPosition - curPos);
// hsScalar distToGoal=dir.Magnitude(); // float distToGoal=dir.Magnitude();
// //
// if (dir.MagnitudeSquared() > 0.0f) // if (dir.MagnitudeSquared() > 0.0f)
// dir.Normalize(); // dir.Normalize();
@ -447,7 +447,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// IAdjustVelocity(fAcceleration, fDeceleration, &dir, &vel, fMaxVelocity, distToGoal, eTime); // IAdjustVelocity(fAcceleration, fDeceleration, &dir, &vel, fMaxVelocity, distToGoal, eTime);
// fCurSpeed = vel.Magnitude(); // fCurSpeed = vel.Magnitude();
// //
// hsScalar distMoved = IClampVelocity(&vel, fMaxVelocity, eTime); // float distMoved = IClampVelocity(&vel, fMaxVelocity, eTime);
// //
// // compute final pos // // compute final pos
// if (distMoved > distToGoal) // if (distMoved > distToGoal)
@ -471,8 +471,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
// // compute degrees needed to turn left/right // // compute degrees needed to turn left/right
// hsVector3 cross = fPlayerViewGoal % view; // hsVector3 cross = fPlayerViewGoal % view;
// hsScalar dot = fPlayerViewGoal * view; // float dot = fPlayerViewGoal * view;
// hsScalar rad = hsACosine(dot); // float rad = acos(dot);
// fRotationScalar = 1.0f; // fRotationScalar = 1.0f;
// //
// if (cross.fZ<0) // if (cross.fZ<0)
@ -491,7 +491,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// } // }
// } // }
// //
// hsScalar angle = 0; // float angle = 0;
// //
// if ( HasMovementFlag( B_CONTROL_ROTATE_RIGHT ) ) // if ( HasMovementFlag( B_CONTROL_ROTATE_RIGHT ) )
// { // {
@ -561,15 +561,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//// ////
//// vector version. dir vector should be normalized //// vector version. dir vector should be normalized
//// ////
//void plPlayerModifier::IAdjustVelocity(hsScalar adjAccelRate, hsScalar adjDecelRate, //void plPlayerModifier::IAdjustVelocity(float adjAccelRate, float adjDecelRate,
// hsVector3* dir, hsVector3* vel, hsScalar maxSpeed, // hsVector3* dir, hsVector3* vel, float maxSpeed,
// hsScalar distToGoal, double elapsedTime) // float distToGoal, double elapsedTime)
//{ //{
// hsScalar speed = vel->Magnitude(); // save current speed // float speed = vel->Magnitude(); // save current speed
// *vel = *dir * speed; // change vel to correct dir // *vel = *dir * speed; // change vel to correct dir
// //
// // compute accel/decel // // compute accel/decel
// hsScalar finalAccelRate; // float finalAccelRate;
// if (IShouldDecelerate(adjDecelRate, speed, distToGoal)) // if (IShouldDecelerate(adjDecelRate, speed, distToGoal))
// { // {
// finalAccelRate = -adjDecelRate; // finalAccelRate = -adjDecelRate;
@ -594,13 +594,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// } // }
//} //}
// //
//hsScalar plPlayerModifier::IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime) //float plPlayerModifier::IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime)
//{ //{
// *vel = *vel * elapsedTime; // *vel = *vel * elapsedTime;
// maxSpeed *= elapsedTime; // maxSpeed *= elapsedTime;
// //
// // clamp speed (clamp if going negative?) // // clamp speed (clamp if going negative?)
// hsScalar distMoved = vel->Magnitude(); // float distMoved = vel->Magnitude();
// if (distMoved > maxSpeed) // if (distMoved > maxSpeed)
// { // {
// vel->Normalize(); // vel->Normalize();
@ -610,16 +610,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// return distMoved; // return distMoved;
//} //}
// //
//hsBool32 plPlayerModifier::IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal) //hsBool32 plPlayerModifier::IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal)
//{ //{
// if (decelSpeed == 0) // if (decelSpeed == 0)
// // no deceleration // // no deceleration
// return false; // return false;
// //
// // compute distance required to stop, given decel speed (in units/sec sq) // // compute distance required to stop, given decel speed (in units/sec sq)
// hsScalar stopTime = curSpeed / decelSpeed; // float stopTime = curSpeed / decelSpeed;
// hsScalar avgSpeed = curSpeed * .5f; // float avgSpeed = curSpeed * .5f;
// hsScalar stopDist = avgSpeed * stopTime; // float stopDist = avgSpeed * stopTime;
// //
// return (hsABS(distToGoal) <= hsABS(stopDist)); // stopDist+avgSpeed? // return (hsABS(distToGoal) <= hsABS(stopDist)); // stopDist+avgSpeed?
//} //}

28
Sources/Plasma/FeatureLib/pfCharacter/plPlayerModifier.h

@ -68,15 +68,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// struct spawnPt // struct spawnPt
// { // {
// hsPoint3 pt; // hsPoint3 pt;
// hsScalar dist; // float dist;
// }; // };
// //
// static hsScalar fTurnRate; // static float fTurnRate;
// //
// static hsScalar fAcceleration; // static float fAcceleration;
// static hsScalar fDeceleration; // static float fDeceleration;
// static hsScalar fMaxVelocity; // static float fMaxVelocity;
// hsScalar fCurSpeed; // float fCurSpeed;
// //
// //
// double fLastTime; // double fLastTime;
@ -88,19 +88,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// bool bUseDesiredMatrix; // bool bUseDesiredMatrix;
// bool bIgnoreDesiredMatrix; // bool bIgnoreDesiredMatrix;
// //
// hsScalar fRotationScalar; // float fRotationScalar;
// hsTArray<spawnPt*> fSpawnPoints; // hsTArray<spawnPt*> fSpawnPoints;
// //
// void IAdjustVelocity(hsScalar adjAccelRate, // void IAdjustVelocity(float adjAccelRate,
// hsScalar adjDecelRate, // float adjDecelRate,
// hsVector3* dir, // hsVector3* dir,
// hsVector3* vel, // hsVector3* vel,
// hsScalar maxSpeed, // float maxSpeed,
// hsScalar distToGoal, // float distToGoal,
// double elapsedTime); // double elapsedTime);
// //
// hsScalar IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime); // float IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime);
// hsBool32 IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal); // hsBool32 IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal);
// //
// hsBool HasMovementFlag(int f) const { return fMoveFlags.IsBitSet(f); } // hsBool HasMovementFlag(int f) const { return fMoveFlags.IsBitSet(f); }
// void SetMovementFlag(int f) { fMoveFlags.SetBit(f); } // void SetMovementFlag(int f) { fMoveFlags.SetBit(f); }
@ -129,7 +129,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// virtual void RemoveTarget(plSceneObject* so); // virtual void RemoveTarget(plSceneObject* so);
// //
// hsBool HandleControlInput(plControlEventMsg* pMsg); // hsBool HandleControlInput(plControlEventMsg* pMsg);
// virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty); // virtual hsBool IEval(double secs, float del, uint32_t dirty);
// //
// void SetMoving(hsBool b); // void SetMoving(hsBool b);
// hsBool IsMoving() { return bMoving; } // hsBool IsMoving() { return bMoving; }

2
Sources/Plasma/FeatureLib/pfConditional/plAnimationEventConditionalObject.cpp

@ -67,7 +67,7 @@ hsBool plAnimationEventConditionalObject::MsgReceive(plMessage* msg)
} }
void plAnimationEventConditionalObject::SetEvent(const CallbackEvent b, hsScalar time) void plAnimationEventConditionalObject::SetEvent(const CallbackEvent b, float time)
{ {
plAnimCmdMsg* pMsg = TRACKED_NEW plAnimCmdMsg; plAnimCmdMsg* pMsg = TRACKED_NEW plAnimCmdMsg;
pMsg->AddReceiver(fTarget); pMsg->AddReceiver(fTarget);

2
Sources/Plasma/FeatureLib/pfConditional/plAnimationEventConditionalObject.h

@ -71,7 +71,7 @@ public:
void Evaluate(){;} void Evaluate(){;}
void Reset() { SetSatisfied(false); } void Reset() { SetSatisfied(false); }
void SetEvent(const CallbackEvent b, hsScalar time = 0.0f); void SetEvent(const CallbackEvent b, float time = 0.0f);
}; };

4
Sources/Plasma/FeatureLib/pfConditional/plFacingConditionalObject.cpp

@ -96,7 +96,7 @@ hsBool plFacingConditionalObject::Verify(plMessage* msg)
ourView = v; ourView = v;
ourView.Normalize(); ourView.Normalize();
} }
hsScalar dot = playerView * ourView; float dot = playerView * ourView;
if (dot >= fTolerance) if (dot >= fTolerance)
{ {
fLogicMod->GetNotify()->AddFacingEvent( pActivateMsg->fHitterObj, fLogicMod->GetTarget()->GetKey(), dot, true); fLogicMod->GetNotify()->AddFacingEvent( pActivateMsg->fHitterObj, fLogicMod->GetTarget()->GetKey(), dot, true);
@ -129,7 +129,7 @@ hsBool plFacingConditionalObject::Verify(plMessage* msg)
ourView.fZ = playerView.fZ; ourView.fZ = playerView.fZ;
ourView.Normalize(); ourView.Normalize();
} }
hsScalar dot = playerView * ourView; float dot = playerView * ourView;
if (dot >= fTolerance) if (dot >= fTolerance)
{ {
return true; return true;

4
Sources/Plasma/FeatureLib/pfConditional/plFacingConditionalObject.h

@ -50,7 +50,7 @@ class plSceneObject;
class plFacingConditionalObject : public plConditionalObject class plFacingConditionalObject : public plConditionalObject
{ {
protected: protected:
hsScalar fTolerance; float fTolerance;
hsBool fDirectional; hsBool fDirectional;
public: public:
@ -63,7 +63,7 @@ public:
hsBool MsgReceive(plMessage* msg); hsBool MsgReceive(plMessage* msg);
void SetTolerance(hsScalar d) { fTolerance = d; } void SetTolerance(float d) { fTolerance = d; }
void SetDirectional(hsBool d) { fDirectional = d; } void SetDirectional(hsBool d) { fDirectional = d; }
virtual hsBool Verify(plMessage* msg); virtual hsBool Verify(plMessage* msg);

2
Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp

@ -502,7 +502,7 @@ PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpo
plKey targetKey = seekTarget->GetKey(); plKey targetKey = seekTarget->GetKey();
plKey avKey = avatar->GetKey(); plKey avKey = avatar->GetKey();
hsScalar unused = 0.0f; float unused = 0.0f;
plAvSeekMsg *msg = TRACKED_NEW plAvSeekMsg(nil, avKey, targetKey, unused, false); plAvSeekMsg *msg = TRACKED_NEW plAvSeekMsg(nil, avKey, targetKey, unused, false);
plgDispatch::MsgSend(msg); plgDispatch::MsgSend(msg);

68
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -1237,10 +1237,10 @@ PF_CONSOLE_CMD( Graphics_Shadow,
"...", "...",
"Max shadowmap blur size." ) "Max shadowmap blur size." )
{ {
extern hsScalar blurScale; extern float blurScale;
if( numParams > 0 ) if( numParams > 0 )
{ {
blurScale = (hsScalar)atof( params[ 0 ] ); blurScale = (float)atof( params[ 0 ] );
} }
else else
{ {
@ -1317,7 +1317,7 @@ PF_CONSOLE_CMD( Graphics_Renderer, Gamma, "float g, ...", "Set gamma value (g or
{ {
hsAssert( pfConsole::GetPipeline() != nil, "Cannot use this command before pipeline initialization" ); hsAssert( pfConsole::GetPipeline() != nil, "Cannot use this command before pipeline initialization" );
hsScalar g = params[0]; float g = params[0];
if( numParams == 1 ) if( numParams == 1 )
{ {
@ -1329,9 +1329,9 @@ PF_CONSOLE_CMD( Graphics_Renderer, Gamma, "float g, ...", "Set gamma value (g or
} }
else else
{ {
hsScalar eR = g; float eR = g;
hsScalar eG = g; float eG = g;
hsScalar eB = g; float eB = g;
if( numParams > 2 ) if( numParams > 2 )
eB = params[2]; eB = params[2];
@ -1352,21 +1352,21 @@ PF_CONSOLE_CMD( Graphics_Renderer, Gamma2, "float g", "Set gamma value (alternat
hsTArray<uint16_t> ramp; hsTArray<uint16_t> ramp;
ramp.SetCount(256); ramp.SetCount(256);
hsScalar g = params[0]; float g = params[0];
int i; int i;
for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
{ {
hsScalar t = hsScalar(i) / 255.f; float t = float(i) / 255.f;
hsScalar sinT = sin(t * hsScalarPI / 2.f); float sinT = sin(t * M_PI / 2.f);
hsScalar remap = t + (sinT - t) * g; float remap = t + (sinT - t) * g;
if( remap < 0 ) if( remap < 0 )
remap = 0; remap = 0;
else if( remap > 1.f ) else if( remap > 1.f )
remap = 1.f; remap = 1.f;
ramp[i] = uint16_t(remap * hsScalar(uint16_t(-1)) + 0.5f); ramp[i] = uint16_t(remap * float(uint16_t(-1)) + 0.5f);
} }
pfConsole::GetPipeline()->SetGamma(ramp.AcquireArray()); pfConsole::GetPipeline()->SetGamma(ramp.AcquireArray());
@ -1405,7 +1405,7 @@ PF_CONSOLE_CMD( Graphics_Renderer, SetYon, "float yon, ...", "Sets the view yon"
{ {
hsAssert( pfConsole::GetPipeline() != nil, "Cannot use this command before pipeline initialization" ); hsAssert( pfConsole::GetPipeline() != nil, "Cannot use this command before pipeline initialization" );
hsScalar hither, yon; float hither, yon;
pfConsole::GetPipeline()->GetDepth( hither, yon ); pfConsole::GetPipeline()->GetDepth( hither, yon );
@ -1424,7 +1424,7 @@ PF_CONSOLE_CMD( Graphics_Renderer, TweakZBiasScale, "float deltaScale", "Adjusts
{ {
hsAssert( pfConsole::GetPipeline() != nil, "Cannot use this command before pipeline initialization" ); hsAssert( pfConsole::GetPipeline() != nil, "Cannot use this command before pipeline initialization" );
hsScalar scale; float scale;
scale = pfConsole::GetPipeline()->GetZBiasScale(); scale = pfConsole::GetPipeline()->GetZBiasScale();
scale += (float)params[ 0 ]; scale += (float)params[ 0 ];
@ -2862,7 +2862,7 @@ PF_CONSOLE_CMD( Camera, AvatarVisible1stPerson, "bool b", "turn avatar visibilit
PF_CONSOLE_CMD( Camera, FallTimerDelay, "float b", "fall timer delay") PF_CONSOLE_CMD( Camera, FallTimerDelay, "float b", "fall timer delay")
{ {
hsScalar f = params[0]; float f = params[0];
plVirtualCam1::fFallTimerDelay = f; plVirtualCam1::fFallTimerDelay = f;
} }
@ -3380,7 +3380,7 @@ PF_CONSOLE_CMD( Audio, SetAllChannelVolumes, "float soundFX, float music, float
for( i = 0; i < 5; i++ ) for( i = 0; i < 5; i++ )
{ {
hsScalar vol = (hsScalar)(float)params[ i ]; float vol = (float)(float)params[ i ];
if( vol > 1.f ) if( vol > 1.f )
vol = 1.f; vol = 1.f;
else if( vol < 0.f ) else if( vol < 0.f )
@ -3414,7 +3414,7 @@ Valid channels are: SoundFX, BgndMusic, Voice, GUI, NPCVoice and Ambience.")
return; return;
} }
hsScalar vol = (hsScalar)(float)params[ 1 ]; float vol = (float)(float)params[ 1 ];
if( vol > 1.f ) if( vol > 1.f )
vol = 1.f; vol = 1.f;
else if( vol < 0.f ) else if( vol < 0.f )
@ -3438,7 +3438,7 @@ Valid channels are: SoundFX, BgndMusic, Voice, GUI, NPCVoice and Ambience.")
PF_CONSOLE_CMD( Audio, Set2D3DBias, "float bias", "Sets the 2D/3D bias when not using hardware acceleration.") PF_CONSOLE_CMD( Audio, Set2D3DBias, "float bias", "Sets the 2D/3D bias when not using hardware acceleration.")
{ {
hsScalar bias = (hsScalar)(float)params[ 0 ]; float bias = (float)(float)params[ 0 ];
plgAudioSys::Set2D3DBias( bias ); plgAudioSys::Set2D3DBias( bias );
} }
@ -4735,8 +4735,8 @@ PF_CONSOLE_CMD( Access,
#include "plMessage/plBulletMsg.h" #include "plMessage/plBulletMsg.h"
plSceneObject* gunObj = nil; plSceneObject* gunObj = nil;
hsScalar gunRadius = 1.f; float gunRadius = 1.f;
hsScalar gunRange = 5000.f; float gunRange = 5000.f;
PF_CONSOLE_CMD( Access, PF_CONSOLE_CMD( Access,
Gun, Gun,
@ -4778,9 +4778,9 @@ PF_CONSOLE_CMD( Access,
dir.Normalize(); dir.Normalize();
hsPoint3 pos = l2w.GetTranslate(); hsPoint3 pos = l2w.GetTranslate();
hsScalar radius = gunRadius; float radius = gunRadius;
hsScalar range = gunRange; float range = gunRange;
plBulletMsg* bull = TRACKED_NEW plBulletMsg(nil, nil, nil); plBulletMsg* bull = TRACKED_NEW plBulletMsg(nil, nil, nil);
bull->FireShot(pos, dir, radius, range); bull->FireShot(pos, dir, radius, range);
@ -4807,9 +4807,9 @@ PF_CONSOLE_CMD( Access,
dir.Normalize(); dir.Normalize();
hsPoint3 pos = l2w.GetTranslate(); hsPoint3 pos = l2w.GetTranslate();
hsScalar radius = gunRadius; float radius = gunRadius;
hsScalar range = gunRange; float range = gunRange;
plBulletMsg* bull = TRACKED_NEW plBulletMsg(nil, nil, nil); plBulletMsg* bull = TRACKED_NEW plBulletMsg(nil, nil, nil);
bull->FireShot(pos, dir, radius, range); bull->FireShot(pos, dir, radius, range);
@ -4898,11 +4898,11 @@ namespace plWaveCmd {
typedef void PrintFunk(const char* str); typedef void PrintFunk(const char* str);
static inline hsScalar FracToPercent(hsScalar f) { return (hsScalar)(1.e2 * f); } static inline float FracToPercent(float f) { return (float)(1.e2 * f); }
static inline hsScalar PercentToFrac(hsScalar f) { return (hsScalar)(1.e-2 * f); } static inline float PercentToFrac(float f) { return (float)(1.e-2 * f); }
static inline hsScalar RadToDeg(hsScalar r) { return r * 180.f / hsScalarPI; } static inline float RadToDeg(float r) { return r * 180.f / M_PI; }
static inline hsScalar DegToRad(hsScalar d) { return d * hsScalarPI / 180.f; } static inline float DegToRad(float d) { return d * M_PI / 180.f; }
static void IDisplayWaveVal(PrintFunk PrintString, plWaveSet7* wave, plWaveCmd::Cmd cmd) static void IDisplayWaveVal(PrintFunk PrintString, plWaveSet7* wave, plWaveCmd::Cmd cmd)
{ {
@ -5062,7 +5062,7 @@ static plWaveSet7* ICheckWaveParams(PrintFunk PrintString, const char* name, int
return waveSet; return waveSet;
} }
static hsScalar LimitVal(hsScalar val, hsScalar lo, hsScalar hi, PrintFunk PrintString) static float LimitVal(float val, float lo, float hi, PrintFunk PrintString)
{ {
if( val < lo ) if( val < lo )
{ {
@ -5091,7 +5091,7 @@ static bool ISendWaveCmd1f(PrintFunk PrintString, pfConsoleCmdParam* params, int
float val = params[1]; float val = params[1];
hsScalar secs = ( numParams > 2 ) ? params[2] : 0.f; float secs = ( numParams > 2 ) ? params[2] : 0.f;
switch( cmd ) switch( cmd )
{ {
@ -5168,7 +5168,7 @@ static bool ISendWaveCmd2f(PrintFunk PrintString, pfConsoleCmdParam* params, int
using namespace plWaveCmd; using namespace plWaveCmd;
hsScalar secs = ( numParams > 3 ) ? params[3] : 0.f; float secs = ( numParams > 3 ) ? params[3] : 0.f;
hsVector3 vec; hsVector3 vec;
plFixedWaterState7 state = wave->State(); plFixedWaterState7 state = wave->State();
@ -5217,7 +5217,7 @@ static bool ISendWaveCmd3f(PrintFunk PrintString, pfConsoleCmdParam* params, int
hsVector3 vec(x, y, z); hsVector3 vec(x, y, z);
hsPoint3 pos(x, y, z); hsPoint3 pos(x, y, z);
hsScalar secs = ( numParams > 4 ) ? params[4] : 0.f; float secs = ( numParams > 4 ) ? params[4] : 0.f;
switch( cmd ) switch( cmd )
{ {
@ -5253,7 +5253,7 @@ static bool ISendWaveCmd4c(PrintFunk PrintString, pfConsoleCmdParam* params, int
float g = params[2]; float g = params[2];
float b = params[3]; float b = params[3];
hsScalar secs = ( numParams > 4 ) ? params[4] : 0.f; float secs = ( numParams > 4 ) ? params[4] : 0.f;
hsColorRGBA col; hsColorRGBA col;
col.Set(r / 255.f, g / 255.f, b / 255.f, 1.f); col.Set(r / 255.f, g / 255.f, b / 255.f, 1.f);
@ -6034,7 +6034,7 @@ PF_CONSOLE_CMD( Mouse, UnInvert, nil, "un-invert the mouse")
PF_CONSOLE_CMD( Mouse, SetDeadZone, "float zone", "Sets the dead zone for the mouse - range is from 0.0 to 1.0") PF_CONSOLE_CMD( Mouse, SetDeadZone, "float zone", "Sets the dead zone for the mouse - range is from 0.0 to 1.0")
{ {
hsScalar f = params[0]; float f = params[0];
} }
PF_CONSOLE_CMD( Mouse, Enable, nil, "Enable mouse input") PF_CONSOLE_CMD( Mouse, Enable, nil, "Enable mouse input")
@ -6238,7 +6238,7 @@ PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set t
PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group
void UpdateParticleParam(char *objName, int32_t paramID, hsScalar value, void (*PrintString)(const char *)) void UpdateParticleParam(char *objName, int32_t paramID, float value, void (*PrintString)(const char *))
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(objName, nil, str); plKey key = FindSceneObjectByName(objName, nil, str);

4
Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp

@ -119,8 +119,8 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, in
// it's an include list and we didn't find it // it's an include list and we didn't find it
return; return;
static hsScalar lastTime=0; static float lastTime=0;
hsScalar curTime = (hsScalar)hsTimer::GetSysSeconds(); float curTime = (float)hsTimer::GetSysSeconds();
if (lastTime!=curTime) if (lastTime!=curTime)
{ {

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp

@ -169,7 +169,7 @@ pfGUIButtonMod::~pfGUIButtonMod()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIButtonMod::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIButtonMod::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h

@ -76,7 +76,7 @@ class pfGUIButtonMod : public pfGUIControlMod
int32_t fNotifyType; int32_t fNotifyType;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp

@ -79,7 +79,7 @@ pfGUICheckBoxCtrl::~pfGUICheckBoxCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUICheckBoxCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUICheckBoxCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h

@ -65,7 +65,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod
hsBool fChecked; hsBool fChecked;
hsBool fPlaySound; hsBool fPlaySound;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIClickMapCtrl.cpp

@ -72,7 +72,7 @@ pfGUIClickMapCtrl::~pfGUIClickMapCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIClickMapCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIClickMapCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIClickMapCtrl.h

@ -60,7 +60,7 @@ class pfGUIClickMapCtrl : public pfGUIControlMod
hsBool fTracking; hsBool fTracking;
int32_t fCustomCursor; int32_t fCustomCursor;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h

22
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp

@ -180,7 +180,7 @@ pfGUIControlMod::~pfGUIControlMod()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIControlMod::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIControlMod::IEval( double secs, float del, uint32_t dirty )
{ {
// UpdateBounds(); // UpdateBounds();
return false; return false;
@ -205,13 +205,13 @@ void pfGUIControlMod::SetTransform( const hsMatrix44 &l2w, const hsMatrix44 &
//// GetVectorAngle ////////////////////////////////////////////////////////// //// GetVectorAngle //////////////////////////////////////////////////////////
static hsScalar GetVectorAngle( const hsPoint3 &basePt, const hsPoint3 &pointA, const hsPoint3 &pointB ) static float GetVectorAngle( const hsPoint3 &basePt, const hsPoint3 &pointA, const hsPoint3 &pointB )
{ {
hsVector3 vectorA( &pointA, &basePt ), vectorB( &pointB, &basePt ); hsVector3 vectorA( &pointA, &basePt ), vectorB( &pointB, &basePt );
hsScalar dot = vectorA * vectorB; float dot = vectorA * vectorB;
hsVector3 cross = vectorA % vectorB; hsVector3 cross = vectorA % vectorB;
hsScalar crossLen = cross.fZ; float crossLen = cross.fZ;
return atan2( crossLen, dot ); return atan2( crossLen, dot );
} }
@ -225,7 +225,7 @@ static hsScalar GetVectorAngle( const hsPoint3 &basePt, const hsPoint3 &pointA,
static hsBool CreateConvexHull( hsPoint3 *inPoints, int &numPoints ) static hsBool CreateConvexHull( hsPoint3 *inPoints, int &numPoints )
{ {
int i, j, pointA, pointB, pointC; int i, j, pointA, pointB, pointC;
hsScalar *angles; float *angles;
if( numPoints < 3 ) if( numPoints < 3 )
return false; return false;
@ -246,7 +246,7 @@ static hsBool CreateConvexHull( hsPoint3 *inPoints, int &numPoints )
// Step 2: Sort all the in points by the angle to the X axis (vector <1,0>). // Step 2: Sort all the in points by the angle to the X axis (vector <1,0>).
// Step A: Calculate all the angles // Step A: Calculate all the angles
angles = TRACKED_NEW hsScalar[ numPoints ]; angles = TRACKED_NEW float[ numPoints ];
hsPoint3 xAxisPoint( avgPoint.fX + 1, avgPoint.fY, avgPoint.fZ ); hsPoint3 xAxisPoint( avgPoint.fX + 1, avgPoint.fY, avgPoint.fZ );
for( i = 0; i < numPoints; i++ ) for( i = 0; i < numPoints; i++ )
angles[ i ] = GetVectorAngle( avgPoint, inPoints[ i ], xAxisPoint ); angles[ i ] = GetVectorAngle( avgPoint, inPoints[ i ], xAxisPoint );
@ -258,7 +258,7 @@ static hsBool CreateConvexHull( hsPoint3 *inPoints, int &numPoints )
{ {
if( angles[ j ] < angles[ i ] ) if( angles[ j ] < angles[ i ] )
{ {
hsScalar tempAngle = angles[ j ]; float tempAngle = angles[ j ];
angles[ j ] = angles[ i ]; angles[ j ] = angles[ i ];
angles[ i ] = tempAngle; angles[ i ] = tempAngle;
@ -283,12 +283,12 @@ static hsBool CreateConvexHull( hsPoint3 *inPoints, int &numPoints )
pointB += numPoints; pointB += numPoints;
// For points A, B, and C, find the interior angle between them // For points A, B, and C, find the interior angle between them
hsScalar angle = GetVectorAngle( inPoints[ pointB ], inPoints[ pointA ], inPoints[ pointC ] ); float angle = GetVectorAngle( inPoints[ pointB ], inPoints[ pointA ], inPoints[ pointC ] );
// If the angle is < 180, then it's a good angle and we can advance all our points by 1... // If the angle is < 180, then it's a good angle and we can advance all our points by 1...
// Note: we have a tolerance so that we don't get points that form edges that are pretty darned close... // Note: we have a tolerance so that we don't get points that form edges that are pretty darned close...
const hsScalar tolerance = hsScalarPI / 90.f; const float tolerance = M_PI / 90.f;
if( angle > tolerance && angle < hsScalarPI - tolerance ) if( angle > tolerance && angle < M_PI - tolerance )
{ {
pointA++; pointA++;
pointB++; pointB++;
@ -526,7 +526,7 @@ void pfGUIControlMod::UpdateBounds( hsMatrix44 *invXformMatrix, hsBool force
// Given the x/y coordinates in 0..1 space, recalcs the sceneObject position // Given the x/y coordinates in 0..1 space, recalcs the sceneObject position
// and moves the object to match, retaining the stored fCenterZ coordinate // and moves the object to match, retaining the stored fCenterZ coordinate
void pfGUIControlMod::SetObjectCenter( hsScalar x, hsScalar y ) void pfGUIControlMod::SetObjectCenter( float x, float y )
{ {
hsMatrix44 xformMatrix, l2p, p2l; hsMatrix44 xformMatrix, l2p, p2l;
hsPoint3 center, corners[ 8 ]; hsPoint3 center, corners[ 8 ];

8
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.h

@ -119,7 +119,7 @@ class pfGUIControlMod : public plSingleModifier
pfGUIDialogMod *fDialog; pfGUIDialogMod *fDialog;
hsBounds3 fBounds, fInitialBounds; // Z component is 0-1 hsBounds3 fBounds, fInitialBounds; // Z component is 0-1
hsScalar fScreenMinZ; // Closest Z coordinate in screen space float fScreenMinZ; // Closest Z coordinate in screen space
hsPoint3 fScreenCenter; hsPoint3 fScreenCenter;
hsBool fBoundsValid, fCenterValid; hsBool fBoundsValid, fCenterValid;
hsMatrix44 fXformMatrix; // Only used for doing drag work, etc. hsMatrix44 fXformMatrix; // Only used for doing drag work, etc.
@ -144,7 +144,7 @@ class pfGUIControlMod : public plSingleModifier
virtual void IPostSetUpDynTextMap( void ) {} virtual void IPostSetUpDynTextMap( void ) {}
virtual void IGrowDTMDimsToDesiredSize( uint16_t &width, uint16_t &height ) { } virtual void IGrowDTMDimsToDesiredSize( uint16_t &width, uint16_t &height ) { }
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
void ISetDialog( pfGUIDialogMod *mod ) { fDialog = mod; } void ISetDialog( pfGUIDialogMod *mod ) { fDialog = mod; }
void IScreenToLocalPt( hsPoint3 &pt ); void IScreenToLocalPt( hsPoint3 &pt );
@ -190,9 +190,9 @@ class pfGUIControlMod : public plSingleModifier
virtual void Refresh( void ); virtual void Refresh( void );
virtual void UpdateBounds( hsMatrix44 *invXformMatrix = nil, hsBool force = false ); virtual void UpdateBounds( hsMatrix44 *invXformMatrix = nil, hsBool force = false );
void SetObjectCenter( hsScalar x, hsScalar y ); void SetObjectCenter( float x, float y );
virtual hsPoint3 GetObjectCenter() { return fScreenCenter; } virtual hsPoint3 GetObjectCenter() { return fScreenCenter; }
hsScalar GetScreenMinZ( void ) { return fScreenMinZ; } float GetScreenMinZ( void ) { return fScreenMinZ; }
void CalcInitialBounds( void ); void CalcInitialBounds( void );
const hsBounds3 &GetBounds( void ); const hsBounds3 &GetBounds( void );

4
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp

@ -466,8 +466,8 @@ pfGUIDialogMod *pfGUICtrlGenerator::IGenerateDialog( const char *name, float sc
fovX = atan( scrnWidth / ( 2.f * 100.f ) ) * 2.f; fovX = atan( scrnWidth / ( 2.f * 100.f ) ) * 2.f;
fovY = fovX;// * 3.f / 4.f; fovY = fovX;// * 3.f / 4.f;
renderMod->SetFovX( fovX * 180.f / hsScalarPI ); renderMod->SetFovX( fovX * 180.f / M_PI );
renderMod->SetFovY( fovY * 180.f / hsScalarPI ); renderMod->SetFovY( fovY * 180.f / M_PI );
// Create the sceneNode to go with it // Create the sceneNode to go with it
node = TRACKED_NEW plSceneNode; node = TRACKED_NEW plSceneNode;

12
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.cpp

@ -117,7 +117,7 @@ pfGUIDialogMod::~pfGUIDialogMod()
// Sometimes it just sucks not having access to the pipeline at just the // Sometimes it just sucks not having access to the pipeline at just the
// right time. // right time.
void pfGUIDialogMod::ScreenToWorldPoint( hsScalar x, hsScalar y, hsScalar z, hsPoint3 &outPt ) void pfGUIDialogMod::ScreenToWorldPoint( float x, float y, float z, hsPoint3 &outPt )
{ {
plViewTransform view = fRenderMod->GetViewTransform(); plViewTransform view = fRenderMod->GetViewTransform();
view.SetScreenSize( 1, 1 ); view.SetScreenSize( 1, 1 );
@ -141,7 +141,7 @@ hsPoint3 pfGUIDialogMod::WorldToScreenPoint( const hsPoint3 &inPt )
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIDialogMod::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIDialogMod::IEval( double secs, float del, uint32_t dirty )
{ {
return false; return false;
} }
@ -364,7 +364,7 @@ plKey pfGUIDialogMod::GetSceneNodeKey( void )
// Really. We go through and make sure every control marked as interesting // Really. We go through and make sure every control marked as interesting
// still has the mouse inside it and vice versa. // still has the mouse inside it and vice versa.
void pfGUIDialogMod::UpdateInterestingThings( hsScalar mouseX, hsScalar mouseY, uint8_t modifiers, hsBool modalPreset ) void pfGUIDialogMod::UpdateInterestingThings( float mouseX, float mouseY, uint8_t modifiers, hsBool modalPreset )
{ {
int i; int i;
hsPoint3 mousePoint; hsPoint3 mousePoint;
@ -405,14 +405,14 @@ void pfGUIDialogMod::UpdateInterestingThings( hsScalar mouseX, hsScalar mouse
#include "plPipeline/plDebugText.h" #include "plPipeline/plDebugText.h"
#endif #endif
hsBool pfGUIDialogMod::HandleMouseEvent( pfGameGUIMgr::EventType event, hsScalar mouseX, hsScalar mouseY, hsBool pfGUIDialogMod::HandleMouseEvent( pfGameGUIMgr::EventType event, float mouseX, float mouseY,
uint8_t modifiers ) uint8_t modifiers )
{ {
hsPoint3 mousePoint; hsPoint3 mousePoint;
uint32_t i; uint32_t i;
pfGUIControlMod *oldInterestingCtrl = nil; pfGUIControlMod *oldInterestingCtrl = nil;
hsScalar smallestZ; float smallestZ;
#ifdef HS_DEBUGGING // Debugging bounds rects #ifdef HS_DEBUGGING // Debugging bounds rects
static bool showBounds = false; static bool showBounds = false;
@ -787,7 +787,7 @@ void pfGUIDialogMod::EnterDragMode( pfGUIControlMod *source )
void pfGUIDialogMod::IHandleDrag( hsPoint3 &mousePoint, pfGameGUIMgr::EventType event, uint8_t modifiers ) void pfGUIDialogMod::IHandleDrag( hsPoint3 &mousePoint, pfGameGUIMgr::EventType event, uint8_t modifiers )
{ {
int i; int i;
hsScalar smallestZ; float smallestZ;
// First, see if our target control has changed // First, see if our target control has changed

8
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.h

@ -91,7 +91,7 @@ class pfGUIDialogMod : public plSingleModifier
plKey fSceneNodeKey; plKey fSceneNodeKey;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
void IHandleDrag( hsPoint3 &mousePt, pfGameGUIMgr::EventType event, uint8_t modifiers ); void IHandleDrag( hsPoint3 &mousePt, pfGameGUIMgr::EventType event, uint8_t modifiers );
@ -130,13 +130,13 @@ class pfGUIDialogMod : public plSingleModifier
const char *GetName( void ) { return fName; } const char *GetName( void ) { return fName; }
void ScreenToWorldPoint( hsScalar x, hsScalar y, hsScalar z, hsPoint3 &outPt ); void ScreenToWorldPoint( float x, float y, float z, hsPoint3 &outPt );
hsPoint3 WorldToScreenPoint( const hsPoint3 &inPt ); hsPoint3 WorldToScreenPoint( const hsPoint3 &inPt );
virtual hsBool HandleMouseEvent( pfGameGUIMgr::EventType event, hsScalar mouseX, hsScalar mouseY, uint8_t modifiers ); virtual hsBool HandleMouseEvent( pfGameGUIMgr::EventType event, float mouseX, float mouseY, uint8_t modifiers );
hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, uint8_t modifiers ); hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, uint8_t modifiers );
hsBool HandleKeyPress( wchar_t key, uint8_t modifiers ); hsBool HandleKeyPress( wchar_t key, uint8_t modifiers );
void UpdateInterestingThings( hsScalar mouseX, hsScalar mouseY, uint8_t modifiers, hsBool modalPreset ); void UpdateInterestingThings( float mouseX, float mouseY, uint8_t modifiers, hsBool modalPreset );
void SetControlOfInterest( pfGUIControlMod *c ); void SetControlOfInterest( pfGUIControlMod *c );
pfGUIControlMod *GetControlOfInterest( void ) const { return fControlOfInterest; } pfGUIControlMod *GetControlOfInterest( void ) const { return fControlOfInterest; }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDragBarCtrl.cpp

@ -78,7 +78,7 @@ pfGUIDragBarCtrl::~pfGUIDragBarCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIDragBarCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIDragBarCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDragBarCtrl.h

@ -60,7 +60,7 @@ class pfGUIDragBarCtrl : public pfGUIControlMod
hsBool fDragging; hsBool fDragging;
hsBool fAnchored; hsBool fAnchored;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDraggableMod.cpp

@ -72,7 +72,7 @@ pfGUIDraggableMod::~pfGUIDraggableMod()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIDraggableMod::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIDraggableMod::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDraggableMod.h

@ -61,7 +61,7 @@ class pfGUIDraggableMod : public pfGUIControlMod
hsBool fDragging; hsBool fDragging;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDynDisplayCtrl.cpp

@ -72,7 +72,7 @@ pfGUIDynDisplayCtrl::~pfGUIDynDisplayCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIDynDisplayCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIDynDisplayCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDynDisplayCtrl.h

@ -79,7 +79,7 @@ class pfGUIDynDisplayCtrl : public pfGUIControlMod
hsTArray<hsGMaterial *> fMaterials; hsTArray<hsGMaterial *> fMaterials;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
public: public:

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp

@ -86,7 +86,7 @@ pfGUIEditBoxMod::~pfGUIEditBoxMod()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIEditBoxMod::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIEditBoxMod::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.h

@ -74,7 +74,7 @@ class pfGUIEditBoxMod : public pfGUIControlMod
plKeyDef fSavedKey; plKeyDef fSavedKey;
uint8_t fSavedModifiers; uint8_t fSavedModifiers;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual void IPostSetUpDynTextMap( void ); virtual void IPostSetUpDynTextMap( void );
virtual void IUpdate( void ); virtual void IUpdate( void );

22
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp

@ -90,7 +90,7 @@ pfGUIKnobCtrl::~pfGUIKnobCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIKnobCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIKnobCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIValueCtrl::IEval( secs, del, dirty ); return pfGUIValueCtrl::IEval( secs, del, dirty );
} }
@ -210,7 +210,7 @@ void pfGUIKnobCtrl::HandleMouseUp( hsPoint3 &mousePt, uint8_t modifiers )
void pfGUIKnobCtrl::HandleMouseDrag( hsPoint3 &mousePt, uint8_t modifiers ) void pfGUIKnobCtrl::HandleMouseDrag( hsPoint3 &mousePt, uint8_t modifiers )
{ {
hsScalar oldValue = fValue, newValue = fDragValue; float oldValue = fValue, newValue = fDragValue;
if( fDragRangeMin != -1 ) if( fDragRangeMin != -1 )
{ {
@ -242,7 +242,7 @@ void pfGUIKnobCtrl::HandleMouseDrag( hsPoint3 &mousePt, uint8_t modifiers )
} }
else else
{ {
hsScalar diff; float diff;
if( HasFlag( kLeftRightOrientation ) ) if( HasFlag( kLeftRightOrientation ) )
diff = ( mousePt.fX - fDragStart.fX ) * 20.f; diff = ( mousePt.fX - fDragStart.fX ) * 20.f;
else else
@ -284,7 +284,7 @@ hsBool pfGUIKnobCtrl::ICalcAnimTimes( void )
if( fAnimTimesCalced ) if( fAnimTimesCalced )
return true; return true;
hsScalar tBegin = 1e30, tEnd = -1e30; float tBegin = 1e30, tEnd = -1e30;
bool foundOne = false; bool foundOne = false;
for( int i = 0; i < fAnimationKeys.GetCount(); i++ ) for( int i = 0; i < fAnimationKeys.GetCount(); i++ )
@ -295,8 +295,8 @@ hsBool pfGUIKnobCtrl::ICalcAnimTimes( void )
{ {
for( int j = 0; j < mod->GetNumAnimations(); j++ ) for( int j = 0; j < mod->GetNumAnimations(); j++ )
{ {
hsScalar begin = mod->GetAnimInstance( j )->GetTimeConvert()->GetBegin(); float begin = mod->GetAnimInstance( j )->GetTimeConvert()->GetBegin();
hsScalar end = mod->GetAnimInstance( j )->GetTimeConvert()->GetEnd(); float end = mod->GetAnimInstance( j )->GetTimeConvert()->GetEnd();
if( begin < tBegin ) if( begin < tBegin )
tBegin = begin; tBegin = begin;
if( end > tEnd ) if( end > tEnd )
@ -308,8 +308,8 @@ hsBool pfGUIKnobCtrl::ICalcAnimTimes( void )
plLayerAnimation *layer = plLayerAnimation::ConvertNoRef( fAnimationKeys[ i ]->ObjectIsLoaded() ); plLayerAnimation *layer = plLayerAnimation::ConvertNoRef( fAnimationKeys[ i ]->ObjectIsLoaded() );
if( layer != nil ) if( layer != nil )
{ {
hsScalar begin = layer->GetTimeConvert().GetBegin(); float begin = layer->GetTimeConvert().GetBegin();
hsScalar end = layer->GetTimeConvert().GetEnd(); float end = layer->GetTimeConvert().GetEnd();
if( begin < tBegin ) if( begin < tBegin )
tBegin = begin; tBegin = begin;
if( end > tEnd ) if( end > tEnd )
@ -331,7 +331,7 @@ hsBool pfGUIKnobCtrl::ICalcAnimTimes( void )
//// SetCurrValue //////////////////////////////////////////////////////////// //// SetCurrValue ////////////////////////////////////////////////////////////
void pfGUIKnobCtrl::SetCurrValue( hsScalar v ) void pfGUIKnobCtrl::SetCurrValue( float v )
{ {
int old = (int)fValue; int old = (int)fValue;
pfGUIValueCtrl::SetCurrValue( v ); pfGUIValueCtrl::SetCurrValue( v );
@ -343,8 +343,8 @@ void pfGUIKnobCtrl::SetCurrValue( hsScalar v )
{ {
ICalcAnimTimes(); ICalcAnimTimes();
hsScalar tLength = fAnimEnd - fAnimBegin; float tLength = fAnimEnd - fAnimBegin;
hsScalar newTime = fMin; float newTime = fMin;
if (fMin != fMax) // Protect against div by zero if (fMin != fMax) // Protect against div by zero
{ {

10
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h

@ -61,17 +61,17 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl
char *fAnimName; char *fAnimName;
hsPoint3 fDragStart; hsPoint3 fDragStart;
hsScalar fDragValue; float fDragValue;
hsBool fDragging; hsBool fDragging;
hsPoint3 fAnimStartPos, fAnimEndPos; // Calculated at export time for kMapToScreenRange hsPoint3 fAnimStartPos, fAnimEndPos; // Calculated at export time for kMapToScreenRange
hsScalar fDragRangeMin, fDragRangeMax; float fDragRangeMin, fDragRangeMax;
// Computed once, once an anim is loaded that we can compute this with // Computed once, once an anim is loaded that we can compute this with
hsScalar fAnimBegin, fAnimEnd; float fAnimBegin, fAnimEnd;
hsBool fAnimTimesCalced; hsBool fAnimTimesCalced;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h virtual uint32_t IGetDesiredCursor( void ) const; // As specified in plInputInterface.h
@ -106,7 +106,7 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl
virtual void UpdateBounds( hsMatrix44 *invXformMatrix = nil, hsBool force = false ); virtual void UpdateBounds( hsMatrix44 *invXformMatrix = nil, hsBool force = false );
virtual void SetCurrValue( hsScalar v ); virtual void SetCurrValue( float v );
// Export only // Export only
void SetAnimationKeys( hsTArray<plKey> &keys, const char *name ); void SetAnimationKeys( hsTArray<plKey> &keys, const char *name );

12
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.cpp

@ -140,7 +140,7 @@ pfGUIListBoxMod::~pfGUIListBoxMod()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIListBoxMod::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIListBoxMod::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }
@ -242,7 +242,7 @@ void pfGUIListBoxMod::IUpdate( void )
{ {
// Shit. Move the scrollPos up to this item at the very least // Shit. Move the scrollPos up to this item at the very least
fScrollPos = j; fScrollPos = j;
fScrollControl->SetCurrValue( (hsScalar)( (int)fScrollControl->GetMax() - fScrollPos ) ); fScrollControl->SetCurrValue( (float)( (int)fScrollControl->GetMax() - fScrollPos ) );
fCheckScroll = false; fCheckScroll = false;
break; break;
} }
@ -345,7 +345,7 @@ void pfGUIListBoxMod::IUpdate( void )
if( anySelected ) if( anySelected )
{ {
fScrollPos = j; fScrollPos = j;
fScrollControl->SetCurrValue( (hsScalar)( (int)fScrollControl->GetMax() - fScrollPos ) ); fScrollControl->SetCurrValue( (float)( (int)fScrollControl->GetMax() - fScrollPos ) );
IUpdate(); // Gotta update again, since we just changed the scrollPos after the fact IUpdate(); // Gotta update again, since we just changed the scrollPos after the fact
return; return;
} }
@ -495,9 +495,9 @@ void pfGUIListBoxMod::ICalcScrollRange( void )
// Smaller than the viewing area, so we don't scroll at all // Smaller than the viewing area, so we don't scroll at all
fScrollControl->SetRange( 0.f, 0.f ); fScrollControl->SetRange( 0.f, 0.f );
else else
fScrollControl->SetRange( 0.f, (hsScalar)( i + 1 ) ); fScrollControl->SetRange( 0.f, (float)( i + 1 ) );
fScrollControl->SetCurrValue( (hsScalar)( (int)fScrollControl->GetMax() - fScrollPos ) ); fScrollControl->SetCurrValue( (float)( (int)fScrollControl->GetMax() - fScrollPos ) );
} }
} }
@ -1044,7 +1044,7 @@ void pfGUIListBoxMod::SetScrollPos( int32_t pos )
{ {
if ( pos >= (int)fScrollControl->GetMin() && pos <= (int)fScrollControl->GetMax() ) if ( pos >= (int)fScrollControl->GetMin() && pos <= (int)fScrollControl->GetMax() )
{ {
fScrollControl->SetCurrValue( (hsScalar)pos ); fScrollControl->SetCurrValue( (float)pos );
fScrollPos = (int)fScrollControl->GetMax() - pos; fScrollPos = (int)fScrollControl->GetMax() - pos;
} }
IUpdate(); IUpdate();

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.h

@ -89,7 +89,7 @@ class pfGUIListBoxMod : public pfGUIControlMod
hsTArray<int16_t> fWrapStartIdxs; hsTArray<int16_t> fWrapStartIdxs;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
void ICalcScrollRange( void ); void ICalcScrollRange( void );
void ICalcWrapStarts( void ); void ICalcWrapStarts( void );

10
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp

@ -189,7 +189,7 @@ pfGUIMultiLineEditCtrl::~pfGUIMultiLineEditCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIMultiLineEditCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIMultiLineEditCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }
@ -240,7 +240,7 @@ void pfGUIMultiLineEditCtrl::SetScrollPosition( int32_t topLine )
if( fScrollControl != nil ) if( fScrollControl != nil )
// Scroll control values are reversed // Scroll control values are reversed
fScrollControl->SetCurrValue( fScrollControl->GetMax() - (hsScalar)fScrollPos ); fScrollControl->SetCurrValue( fScrollControl->GetMax() - (float)fScrollPos );
HandleExtendedEvent( pfGUIMultiLineEditCtrl::kScrollPosChanged ); HandleExtendedEvent( pfGUIMultiLineEditCtrl::kScrollPosChanged );
@ -267,16 +267,16 @@ void pfGUIMultiLineEditCtrl::IUpdateScrollRange( void )
{ {
// +1 here because the last visible line is only a partial, but we want to be able to view // +1 here because the last visible line is only a partial, but we want to be able to view
// full lines all the way to the end. // full lines all the way to the end.
hsScalar newMax = (hsScalar)( fLineStarts.GetCount() - ICalcNumVisibleLines() + 1 ); float newMax = (float)( fLineStarts.GetCount() - ICalcNumVisibleLines() + 1 );
if( newMax != fScrollControl->GetMax() ) if( newMax != fScrollControl->GetMax() )
{ {
fScrollControl->SetRange( 0, (hsScalar)(fLineStarts.GetCount() - ICalcNumVisibleLines() + 1) ); fScrollControl->SetRange( 0, (float)(fLineStarts.GetCount() - ICalcNumVisibleLines() + 1) );
fScrollControl->SetEnabled( true ); fScrollControl->SetEnabled( true );
if( fScrollPos > fLineStarts.GetCount() - ICalcNumVisibleLines() + 1 ) if( fScrollPos > fLineStarts.GetCount() - ICalcNumVisibleLines() + 1 )
{ {
fScrollPos = fLineStarts.GetCount() - ICalcNumVisibleLines() + 1; fScrollPos = fLineStarts.GetCount() - ICalcNumVisibleLines() + 1;
fScrollControl->SetCurrValue( fScrollControl->GetMax() - (hsScalar)fScrollPos ); fScrollControl->SetCurrValue( fScrollControl->GetMax() - (float)fScrollPos );
} }
// All bets are off on scrolling, so refresh the whole area // All bets are off on scrolling, so refresh the whole area

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.h

@ -111,7 +111,7 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
static wchar_t fColorCodeChar, fStyleCodeChar; static wchar_t fColorCodeChar, fStyleCodeChar;
static uint32_t fColorCodeSize, fStyleCodeSize; static uint32_t fColorCodeSize, fStyleCodeSize;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
virtual void IPostSetUpDynTextMap( void ); virtual void IPostSetUpDynTextMap( void );
virtual void IUpdate( void ); virtual void IUpdate( void );

10
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp

@ -336,7 +336,7 @@ void pfGUIPopUpMenu::SetEnabled( hsBool e )
pfGUIDialogMod::SetEnabled( e ); pfGUIDialogMod::SetEnabled( e );
} }
void pfGUIPopUpMenu::Show( hsScalar x, hsScalar y ) void pfGUIPopUpMenu::Show( float x, float y )
{ {
fOriginX = x; fOriginX = x;
fOriginY = y; fOriginY = y;
@ -622,7 +622,7 @@ void pfGUIPopUpMenu::ITearDownMenu( void )
//// HandleMouseEvent //////////////////////////////////////////////////////// //// HandleMouseEvent ////////////////////////////////////////////////////////
hsBool pfGUIPopUpMenu::HandleMouseEvent( pfGameGUIMgr::EventType event, hsScalar mouseX, hsScalar mouseY, hsBool pfGUIPopUpMenu::HandleMouseEvent( pfGameGUIMgr::EventType event, float mouseX, float mouseY,
uint8_t modifiers ) uint8_t modifiers )
{ {
hsBool r = pfGUIDialogMod::HandleMouseEvent( event, mouseX, mouseY, modifiers ); hsBool r = pfGUIDialogMod::HandleMouseEvent( event, mouseX, mouseY, modifiers );
@ -733,7 +733,7 @@ hsGMaterial *pfGUIPopUpMenu::ICreateDynMaterial( void )
#include "plJPEG/plJPEG.h" #include "plJPEG/plJPEG.h"
pfGUIPopUpMenu *pfGUIPopUpMenu::Build( const char *name, pfGUIDialogMod *parent, hsScalar x, hsScalar y, const plLocation &destLoc ) pfGUIPopUpMenu *pfGUIPopUpMenu::Build( const char *name, pfGUIDialogMod *parent, float x, float y, const plLocation &destLoc )
{ {
float fovX, fovY; float fovX, fovY;
@ -778,8 +778,8 @@ pfGUIPopUpMenu *pfGUIPopUpMenu::Build( const char *name, pfGUIDialogMod *parent
fovX = atan( scrnWidth / ( 2.f * 100.f ) ) * 2.f; fovX = atan( scrnWidth / ( 2.f * 100.f ) ) * 2.f;
fovY = fovX;// * 3.f / 4.f; fovY = fovX;// * 3.f / 4.f;
renderMod->SetFovX( fovX * 180.f / hsScalarPI ); renderMod->SetFovX( fovX * 180.f / M_PI );
renderMod->SetFovY( fovY * 180.f / hsScalarPI ); renderMod->SetFovY( fovY * 180.f / M_PI );
// Create the sceneNode to go with it // Create the sceneNode to go with it
menu->fParentNode= TRACKED_NEW plSceneNode; menu->fParentNode= TRACKED_NEW plSceneNode;

8
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.h

@ -100,7 +100,7 @@ class pfGUIPopUpMenu : public pfGUIDialogMod
// Array of info to rebuild our menu from. Note that this is ONLY used when rebuilding // Array of info to rebuild our menu from. Note that this is ONLY used when rebuilding
hsBool fNeedsRebuilding, fWaitingForSkin; hsBool fNeedsRebuilding, fWaitingForSkin;
hsScalar fOriginX, fOriginY; float fOriginX, fOriginY;
uint16_t fMargin; uint16_t fMargin;
hsTArray<pfMenuItem> fMenuItems; hsTArray<pfMenuItem> fMenuItems;
int32_t fSubMenuOpen; int32_t fSubMenuOpen;
@ -153,9 +153,9 @@ class pfGUIPopUpMenu : public pfGUIDialogMod
virtual void Write( hsStream* s, hsResMgr* mgr ); virtual void Write( hsStream* s, hsResMgr* mgr );
virtual void SetEnabled( hsBool e ); virtual void SetEnabled( hsBool e );
virtual hsBool HandleMouseEvent( pfGameGUIMgr::EventType event, hsScalar mouseX, hsScalar mouseY, uint8_t modifiers ); virtual hsBool HandleMouseEvent( pfGameGUIMgr::EventType event, float mouseX, float mouseY, uint8_t modifiers );
void Show( hsScalar x, hsScalar y ); void Show( float x, float y );
void SetOriginAnchor( plSceneObject *anchor, pfGUIDialogMod *context ); void SetOriginAnchor( plSceneObject *anchor, pfGUIDialogMod *context );
void SetAlignment( Alignment a ) { fAlignment = a; } void SetAlignment( Alignment a ) { fAlignment = a; }
@ -164,7 +164,7 @@ class pfGUIPopUpMenu : public pfGUIDialogMod
void AddItem( const wchar_t *name, pfGUICtrlProcObject *handler, pfGUIPopUpMenu *subMenu = nil ); void AddItem( const wchar_t *name, pfGUICtrlProcObject *handler, pfGUIPopUpMenu *subMenu = nil );
void SetSkin( pfGUISkin *skin ); void SetSkin( pfGUISkin *skin );
static pfGUIPopUpMenu *Build( const char *name, pfGUIDialogMod *parent, hsScalar x, hsScalar y, const plLocation &destLoc = plLocation::kGlobalFixedLoc ); static pfGUIPopUpMenu *Build( const char *name, pfGUIDialogMod *parent, float x, float y, const plLocation &destLoc = plLocation::kGlobalFixedLoc );
}; };

22
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp

@ -83,7 +83,7 @@ pfGUIProgressCtrl::~pfGUIProgressCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIProgressCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIProgressCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIValueCtrl::IEval( secs, del, dirty ); return pfGUIValueCtrl::IEval( secs, del, dirty );
} }
@ -163,7 +163,7 @@ hsBool pfGUIProgressCtrl::ICalcAnimTimes( void )
if( fAnimTimesCalced ) if( fAnimTimesCalced )
return true; return true;
hsScalar tBegin = 1e30, tEnd = -1e30; float tBegin = 1e30, tEnd = -1e30;
bool foundOne = false; bool foundOne = false;
for( int i = 0; i < fAnimationKeys.GetCount(); i++ ) for( int i = 0; i < fAnimationKeys.GetCount(); i++ )
@ -174,8 +174,8 @@ hsBool pfGUIProgressCtrl::ICalcAnimTimes( void )
{ {
for( int j = 0; j < mod->GetNumAnimations(); j++ ) for( int j = 0; j < mod->GetNumAnimations(); j++ )
{ {
hsScalar begin = mod->GetAnimInstance( j )->GetTimeConvert()->GetBegin(); float begin = mod->GetAnimInstance( j )->GetTimeConvert()->GetBegin();
hsScalar end = mod->GetAnimInstance( j )->GetTimeConvert()->GetEnd(); float end = mod->GetAnimInstance( j )->GetTimeConvert()->GetEnd();
if( begin < tBegin ) if( begin < tBegin )
tBegin = begin; tBegin = begin;
if( end > tEnd ) if( end > tEnd )
@ -187,8 +187,8 @@ hsBool pfGUIProgressCtrl::ICalcAnimTimes( void )
plLayerAnimation *layer = plLayerAnimation::ConvertNoRef( fAnimationKeys[ i ]->ObjectIsLoaded() ); plLayerAnimation *layer = plLayerAnimation::ConvertNoRef( fAnimationKeys[ i ]->ObjectIsLoaded() );
if( layer != nil ) if( layer != nil )
{ {
hsScalar begin = layer->GetTimeConvert().GetBegin(); float begin = layer->GetTimeConvert().GetBegin();
hsScalar end = layer->GetTimeConvert().GetEnd(); float end = layer->GetTimeConvert().GetEnd();
if( begin < tBegin ) if( begin < tBegin )
tBegin = begin; tBegin = begin;
if( end > tEnd ) if( end > tEnd )
@ -210,7 +210,7 @@ hsBool pfGUIProgressCtrl::ICalcAnimTimes( void )
//// SetCurrValue //////////////////////////////////////////////////////////// //// SetCurrValue ////////////////////////////////////////////////////////////
void pfGUIProgressCtrl::SetCurrValue( hsScalar v ) void pfGUIProgressCtrl::SetCurrValue( float v )
{ {
int old = (int)fValue; int old = (int)fValue;
@ -223,8 +223,8 @@ void pfGUIProgressCtrl::SetCurrValue( hsScalar v )
{ {
ICalcAnimTimes(); ICalcAnimTimes();
hsScalar tLength = fAnimEnd - fAnimBegin; float tLength = fAnimEnd - fAnimBegin;
hsScalar newTime; float newTime;
if( HasFlag( kReverseValues ) ) if( HasFlag( kReverseValues ) )
newTime = ( ( fMax - fValue ) / ( fMax - fMin ) ) * tLength + fAnimBegin; newTime = ( ( fMax - fValue ) / ( fMax - fMin ) ) * tLength + fAnimBegin;
@ -240,7 +240,7 @@ void pfGUIProgressCtrl::SetCurrValue( hsScalar v )
} }
} }
void pfGUIProgressCtrl::AnimateToPercentage( hsScalar percent ) void pfGUIProgressCtrl::AnimateToPercentage( float percent )
{ {
// percent should be a value in range 0.0 to 1.0 // percent should be a value in range 0.0 to 1.0
if (percent >= 0.0f && percent <= 1.0f) if (percent >= 0.0f && percent <= 1.0f)
@ -262,7 +262,7 @@ void pfGUIProgressCtrl::AnimateToPercentage( hsScalar percent )
PlaySound(kAnimateSound, true); PlaySound(kAnimateSound, true);
// setup a timer to call back when we finish animating // setup a timer to call back when we finish animating
hsScalar elapsedTime = (fAnimEnd - fAnimBegin) * percent; float elapsedTime = (fAnimEnd - fAnimBegin) * percent;
plTimerCallbackMsg *timerMsg = TRACKED_NEW plTimerCallbackMsg(GetKey(), fStopSoundTimer); plTimerCallbackMsg *timerMsg = TRACKED_NEW plTimerCallbackMsg(GetKey(), fStopSoundTimer);
plgTimerCallbackMgr::NewTimer(elapsedTime, timerMsg); plgTimerCallbackMgr::NewTimer(elapsedTime, timerMsg);
} }

8
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h

@ -61,11 +61,11 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl
char *fAnimName; char *fAnimName;
// Computed once, once an anim is loaded that we can compute this with // Computed once, once an anim is loaded that we can compute this with
hsScalar fAnimBegin, fAnimEnd; float fAnimBegin, fAnimEnd;
hsBool fAnimTimesCalced; hsBool fAnimTimesCalced;
hsBool fPlaySound; hsBool fPlaySound;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
hsBool ICalcAnimTimes( void ); hsBool ICalcAnimTimes( void );
@ -92,8 +92,8 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl
virtual void UpdateBounds( hsMatrix44 *invXformMatrix = nil, hsBool force = false ); virtual void UpdateBounds( hsMatrix44 *invXformMatrix = nil, hsBool force = false );
virtual void SetCurrValue( hsScalar v ); virtual void SetCurrValue( float v );
virtual void AnimateToPercentage( hsScalar percent ); virtual void AnimateToPercentage( float percent );
enum SoundEvents enum SoundEvents
{ {

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIRadioGroupCtrl.cpp

@ -137,7 +137,7 @@ pfGUIRadioGroupCtrl::~pfGUIRadioGroupCtrl()
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIRadioGroupCtrl::IEval( double secs, hsScalar del, uint32_t dirty ) hsBool pfGUIRadioGroupCtrl::IEval( double secs, float del, uint32_t dirty )
{ {
return pfGUIControlMod::IEval( secs, del, dirty ); return pfGUIControlMod::IEval( secs, del, dirty );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIRadioGroupCtrl.h

@ -72,7 +72,7 @@ class pfGUIRadioGroupCtrl : public pfGUIControlMod
int32_t fValue, fDefaultValue; int32_t fValue, fDefaultValue;
virtual hsBool IEval( double secs, hsScalar del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
public: public:

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save