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

Eliminate hsScalar and hsFixed

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

View File

@ -74,8 +74,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// heinous
#include "plNetClient/plNetClientMgr.h"
#include "pnMessage/plEnableMsg.h"
static hsScalar kMaxYon = 1000.f;
static hsScalar kMinHither = 1.f;
static float kMaxYon = 1000.f;
static float kMinHither = 1.f;
#include "plLightProxy.h"
@ -141,9 +141,9 @@ void plLightInfo::IRefresh()
void plLightInfo::ICheckMaxStrength()
{
hsScalar r = GetDiffuse().r >= 0 ? GetDiffuse().r : -GetDiffuse().r;
hsScalar g = GetDiffuse().g >= 0 ? GetDiffuse().g : -GetDiffuse().g;
hsScalar b = GetDiffuse().b >= 0 ? GetDiffuse().b : -GetDiffuse().b;
float r = GetDiffuse().r >= 0 ? GetDiffuse().r : -GetDiffuse().r;
float g = GetDiffuse().g >= 0 ? GetDiffuse().g : -GetDiffuse().g;
float b = GetDiffuse().b >= 0 ? GetDiffuse().b : -GetDiffuse().b;
fMaxStrength =
r > g
? (
@ -157,11 +157,11 @@ void plLightInfo::ICheckMaxStrength()
: b
);
const hsScalar kMinMaxStrength = 1.e-2f;
const float kMinMaxStrength = 1.e-2f;
SetZero(fMaxStrength < kMinMaxStrength);
}
void plLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const
void plLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const
{
if( IsIdle() )
{
@ -592,7 +592,7 @@ plDirectionalLightInfo::~plDirectionalLightInfo()
{
}
void plDirectionalLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const
void plDirectionalLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const
{
plLightInfo::GetStrengthAndScale(bnd, strength, scale);
}
@ -637,8 +637,8 @@ void plLimitedDirLightInfo::IRefresh()
hsMatrix44 l2ndc;
l2ndc.Reset();
hsScalar width = fWidth;
hsScalar height = fHeight;
float width = fWidth;
float height = fHeight;
l2ndc.fMap[0][0] = 1.f / width;
l2ndc.fMap[0][3] = 0.5f;
@ -658,7 +658,7 @@ void plLimitedDirLightInfo::IRefresh()
}
}
void plLimitedDirLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const
void plLimitedDirLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const
{
// If we haven't culled the object, return that we're full strength.
plLightInfo::GetStrengthAndScale(bnd, strength, scale);
@ -691,8 +691,8 @@ void plLimitedDirLightInfo::IMakeIsect()
hsPoint3 p0, p1;
hsScalar width = fWidth;
hsScalar height = fHeight;
float width = fWidth;
float height = fHeight;
p0.Set(-width*0.5f, 0, 0);
p1.Set(width*0.5f, 0, 0);
fParPlanes->SetPlane(0, p0, p1);
@ -756,7 +756,7 @@ void plOmniLightInfo::IMakeIsect()
fSphere->SetTransform(fLightToWorld, fWorldToLight);
}
void plOmniLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const
void plOmniLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const
{
plLightInfo::GetStrengthAndScale(bnd, strength, scale);
@ -764,7 +764,7 @@ void plOmniLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& str
const hsPoint3& pos = bnd.GetCenter();
hsPoint3 wpos = GetWorldPosition();
hsScalar dist = hsVector3(&pos, &wpos).MagnitudeSquared();
float dist = hsVector3(&pos, &wpos).MagnitudeSquared();
dist = 1.f / hsFastMath::InvSqrtAppr(dist);
if( fAttenQuadratic > 0 )
{
@ -785,16 +785,16 @@ void plOmniLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& str
}
}
hsScalar plOmniLightInfo::GetRadius() const
float plOmniLightInfo::GetRadius() const
{
hsScalar radius = 0;
float radius = 0;
if( fAttenQuadratic > 0 )
{
hsScalar mult = fDiffuse.a >= 0 ? fDiffuse.a : -fDiffuse.a;
hsScalar det = fAttenLinear*fAttenLinear - 4.f * fAttenQuadratic * fAttenConst * (1.f - mult * plSillyLightKonstants::GetFarPowerKonst());
float mult = fDiffuse.a >= 0 ? fDiffuse.a : -fDiffuse.a;
float det = fAttenLinear*fAttenLinear - 4.f * fAttenQuadratic * fAttenConst * (1.f - mult * plSillyLightKonstants::GetFarPowerKonst());
if( det > 0 )
{
det = hsSquareRoot(det);
det = sqrt(det);
radius = -fAttenLinear + det;
radius /= fAttenQuadratic * 2.f;
@ -804,7 +804,7 @@ hsScalar plOmniLightInfo::GetRadius() const
}
else if( fAttenLinear > 0 )
{
hsScalar mult = fDiffuse.a >= 0 ? fDiffuse.a : -fDiffuse.a;
float mult = fDiffuse.a >= 0 ? fDiffuse.a : -fDiffuse.a;
radius = (mult * plSillyLightKonstants::GetFarPowerKonst() - 1.f ) * fAttenConst / fAttenLinear;
}
else if( fAttenCutoff > 0 )
@ -887,8 +887,8 @@ plDrawableSpans* plOmniLightInfo::CreateProxy(hsGMaterial* mat, hsTArray<uint32_
// Spot
plSpotLightInfo::plSpotLightInfo()
: fFalloff(1.f),
fSpotInner(hsScalarPI * 0.125f),
fSpotOuter(hsScalarPI * 0.25f),
fSpotInner(M_PI * 0.125f),
fSpotOuter(M_PI * 0.25f),
fCone(nil)
{
}
@ -898,7 +898,7 @@ plSpotLightInfo::~plSpotLightInfo()
delete fCone;
}
void plSpotLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const
void plSpotLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const
{
plOmniLightInfo::GetStrengthAndScale(bnd, strength, scale);
@ -908,13 +908,13 @@ void plSpotLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& str
hsVector3 del;
hsPoint3 wpos = GetWorldPosition();
del.Set(&pos, &wpos);
hsScalar invDist = del.MagnitudeSquared();
float invDist = del.MagnitudeSquared();
invDist = hsFastMath::InvSqrtAppr(invDist);
hsScalar dot = del.InnerProduct(GetWorldDirection());
float dot = del.InnerProduct(GetWorldDirection());
dot *= invDist;
hsScalar cosInner, cosOuter, t;
float cosInner, cosOuter, t;
hsFastMath::SinCosInRangeAppr(fSpotInner, t, cosInner);
hsFastMath::SinCosInRangeAppr(fSpotOuter, t, cosOuter);
if( dot < cosOuter )
@ -936,7 +936,7 @@ void plSpotLightInfo::IRefresh()
if( !fCone )
IMakeIsect();
hsScalar effFOV = fSpotOuter;
float effFOV = fSpotOuter;
fCone->SetAngle(effFOV);
@ -948,12 +948,12 @@ void plSpotLightInfo::IRefresh()
if( GetProjection() )
{
hsScalar yon = GetRadius();
float yon = GetRadius();
if( yon < kMinHither )
yon = kMaxYon;
hsScalar hither = hsMinimum(kMinHither, yon * 0.5f);
float hither = hsMinimum(kMinHither, yon * 0.5f);
hsScalar sinFOV, cosFOV;
float sinFOV, cosFOV;
hsFastMath::SinCos(effFOV, sinFOV, cosFOV);
hsMatrix44 l2ndc;

View File

@ -136,7 +136,7 @@ protected:
plSoftVolume* fSoftVolume;
hsScalar fMaxStrength;
float fMaxStrength;
hsBool fRegisteredForRenderMsg;
@ -183,7 +183,7 @@ public:
void SetShadowCaster(hsBool on) { SetProperty(kLPCastShadows, on); }
void Refresh() { if( IsDirty() ) { IRefresh(); SetDirty(false); } }
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const;
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const;
hsBool AffectsBound(const hsBounds3Ext& bnd) { return IGetIsect() ? IGetIsect()->Test(bnd) != kVolumeCulled : true; }
void GetAffectedForced(const plSpaceTree* space, hsBitVector& list, hsBool charac);
@ -256,7 +256,7 @@ public:
CLASSNAME_REGISTER( plDirectionalLightInfo );
GETINTERFACE_ANY( plDirectionalLightInfo, plLightInfo );
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const;
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const;
hsVector3 GetWorldDirection() const;
virtual hsVector3 GetNegativeWorldDirection(const hsPoint3& pos) const { return -GetWorldDirection(); }
@ -270,9 +270,9 @@ class plLimitedDirLightInfo : public plDirectionalLightInfo
{
protected:
hsScalar fWidth;
hsScalar fHeight;
hsScalar fDepth;
float fWidth;
float fHeight;
float fDepth;
plParallelIsect* fParPlanes;
@ -288,15 +288,15 @@ public:
CLASSNAME_REGISTER( plLimitedDirLightInfo );
GETINTERFACE_ANY( plLimitedDirLightInfo, plDirectionalLightInfo );
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const;
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const;
hsScalar GetWidth() const { return fWidth; }
hsScalar GetHeight() const { return fHeight; }
hsScalar GetDepth() const { return fDepth; }
float GetWidth() const { return fWidth; }
float GetHeight() const { return fHeight; }
float GetDepth() const { return fDepth; }
void SetWidth(hsScalar w) { fWidth = w; }
void SetHeight(hsScalar h) { fHeight = h; }
void SetDepth(hsScalar d) { fDepth = d; }
void SetWidth(float w) { fWidth = w; }
void SetHeight(float h) { fHeight = h; }
void SetDepth(float d) { fDepth = d; }
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
@ -309,10 +309,10 @@ class plOmniLightInfo : public plLightInfo
{
protected:
// Omni and spot
hsScalar fAttenConst;
hsScalar fAttenLinear;
hsScalar fAttenQuadratic;
hsScalar fAttenCutoff; // Only for attenuate-but-not-really mode, 0 otherwise
float fAttenConst;
float fAttenLinear;
float fAttenQuadratic;
float fAttenCutoff; // Only for attenuate-but-not-really mode, 0 otherwise
plSphereIsect* fSphere;
@ -329,23 +329,23 @@ public:
CLASSNAME_REGISTER( plOmniLightInfo );
GETINTERFACE_ANY( plOmniLightInfo, plLightInfo );
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const;
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const;
virtual hsVector3 GetNegativeWorldDirection(const hsPoint3& pos) const;
hsBool IsAttenuated() const { return (fAttenLinear != 0)||(fAttenQuadratic != 0) || ( fAttenCutoff != 0 ); }
hsScalar GetRadius() const;
float GetRadius() const;
hsScalar GetConstantAttenuation() const { return fAttenConst; }
hsScalar GetLinearAttenuation() const { return fAttenLinear; }
hsScalar GetQuadraticAttenuation() const { return fAttenQuadratic; }
hsScalar GetCutoffAttenuation() const { return fAttenCutoff; }
float GetConstantAttenuation() const { return fAttenConst; }
float GetLinearAttenuation() const { return fAttenLinear; }
float GetQuadraticAttenuation() const { return fAttenQuadratic; }
float GetCutoffAttenuation() const { return fAttenCutoff; }
hsPoint3 GetWorldPosition() const { return fLightToWorld.GetTranslate(); }
void SetConstantAttenuation(hsScalar a) { fAttenConst = a; SetDirty(true); }
void SetLinearAttenuation(hsScalar a) { fAttenLinear = a; SetDirty(true); }
void SetQuadraticAttenuation(hsScalar a) { fAttenQuadratic = a; SetDirty(true); }
void SetCutoffAttenuation( hsScalar a ) { fAttenCutoff = a; SetDirty( true ); }
void SetConstantAttenuation(float a) { fAttenConst = a; SetDirty(true); }
void SetLinearAttenuation(float a) { fAttenLinear = a; SetDirty(true); }
void SetQuadraticAttenuation(float a) { fAttenQuadratic = a; SetDirty(true); }
void SetCutoffAttenuation( float a ) { fAttenCutoff = a; SetDirty( true ); }
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
@ -359,13 +359,13 @@ class plSpotLightInfo : public plOmniLightInfo
{
protected:
// Valid only for spot
hsScalar fFalloff;
float fFalloff;
// Note - these are half angles, D3D wants whole angles, so fSpotInner*2 etc.
hsScalar fSpotInner;
hsScalar fSpotOuter;
float fSpotInner;
float fSpotOuter;
hsScalar fEffectiveFOV;
float fEffectiveFOV;
plConeIsect* fCone;
@ -381,18 +381,18 @@ public:
CLASSNAME_REGISTER( plSpotLightInfo );
GETINTERFACE_ANY( plSpotLightInfo, plOmniLightInfo );
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& strength, hsScalar& scale) const;
virtual void GetStrengthAndScale(const hsBounds3Ext& bnd, float& strength, float& scale) const;
hsVector3 GetWorldDirection() const;
virtual hsVector3 GetNegativeWorldDirection(const hsPoint3& pos) const { return -GetWorldDirection(); }
void SetFalloff(hsScalar f) { fFalloff = f; SetDirty(true); }
void SetSpotInner(hsScalar rads) { fSpotInner = rads; SetDirty(true); }
void SetSpotOuter(hsScalar rads) { fSpotOuter = rads; SetDirty(true); }
void SetFalloff(float f) { fFalloff = f; SetDirty(true); }
void SetSpotInner(float rads) { fSpotInner = rads; SetDirty(true); }
void SetSpotOuter(float rads) { fSpotOuter = rads; SetDirty(true); }
hsScalar GetFalloff() const { return fFalloff; }
hsScalar GetSpotInner() const { return fSpotInner; }
hsScalar GetSpotOuter() const { return fSpotOuter; }
float GetFalloff() const { return fFalloff; }
float GetSpotInner() const { return fSpotInner; }
float GetSpotOuter() const { return fSpotOuter; }
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);

View File

@ -62,7 +62,7 @@ public:
CLASSNAME_REGISTER( plLightSpace );
GETINTERFACE_ANY( plLightSpace, plMultiModifier );
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty) { return false; }
virtual hsBool IEval(double secs, float del, uint32_t dirty) { return false; }
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);

View File

@ -60,7 +60,7 @@ void plPerspDirSlave::Init()
fFlags |= kCastInCameraSpace;
}
hsPoint3 plPerspDirSlave::IProject(const hsMatrix44& world2NDC, const hsPoint3& pos, hsScalar w) const
hsPoint3 plPerspDirSlave::IProject(const hsMatrix44& world2NDC, const hsPoint3& pos, float w) const
{
hsPoint3 retVal;
retVal.fX = world2NDC.fMap[0][0] * pos.fX
@ -78,7 +78,7 @@ hsPoint3 plPerspDirSlave::IProject(const hsMatrix44& world2NDC, const hsPoint3&
+ world2NDC.fMap[2][2] * pos.fZ
+ world2NDC.fMap[2][3] * w;
hsScalar invW = 1.f / (
float invW = 1.f / (
world2NDC.fMap[3][0] * pos.fX
+ world2NDC.fMap[3][1] * pos.fY
+ world2NDC.fMap[3][2] * pos.fZ
@ -125,8 +125,8 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
{
plViewTransform pipeView = pipe->GetViewTransform();
plConst(hsScalar) kYon(100.f);
plConst(hsScalar) kHither(30.f);
plConst(float) kYon(100.f);
plConst(float) kHither(30.f);
pipeView.SetHither(kHither);
pipeView.SetYon(kYon);
@ -153,7 +153,7 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
}
else if( kUseFrustCenter )
{
plConst(hsScalar) kDist(50.f);
plConst(float) kDist(50.f);
hsPoint3 camFrustCenter(0.f, 0.f, kDist);
lookAt = IProject(cam2NDC, camFrustCenter);
}
@ -167,8 +167,8 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
hsMatrix44 li2CamNDC;
IComputeCamNDCToLight(perspLiPos, lookAt, camNDC2Li, li2CamNDC);
hsScalar minZ, maxZ;
hsScalar cotX, cotY;
float minZ, maxZ;
float cotX, cotY;
plConst(hsBool) kFixedPersp(true);
if( !kFixedPersp )
@ -197,13 +197,13 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
plConst(hsBool) kFakeDepth(false);
if( kFakeDepth )
{
plConst(hsScalar) kMin(1.f);
plConst(hsScalar) kMax(30.f);
plConst(float) kMin(1.f);
plConst(float) kMax(30.f);
minZ = kMin;
maxZ = kMax;
}
plConst(hsScalar) kMinMinZ(1.f);
plConst(float) kMinMinZ(1.f);
if( minZ < kMinMinZ )
minZ = kMinMinZ;
@ -231,7 +231,7 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
}
else
{
plConst(hsScalar) kHi(1.f);
plConst(float) kHi(1.f);
hsBounds3Ext bnd;
const hsPoint3 lo(-1.f, -1.f, 0.f);
const hsPoint3 hi(1.f, 1.f, kHi);
@ -254,7 +254,7 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY))
return false;
plConst(hsScalar) kMinMinZ(1.f);
plConst(float) kMinMinZ(1.f);
if( minZ < kMinMinZ )
minZ = kMinMinZ;
@ -320,8 +320,8 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe)
cotX -= cotX / (fWidth * 0.5f);
cotY -= cotY / (fHeight * 0.5f);
hsScalar tanX = 1.f / cotX;
hsScalar tanY = 1.f / cotY;
float tanX = 1.f / cotX;
float tanY = 1.f / cotY;
fView.SetScreenSize((uint16_t)fWidth, (uint16_t)fHeight);
fView.SetCameraTransform(pipe->GetViewTransform().GetWorldToCamera(), pipe->GetViewTransform().GetCameraToWorld());
fView.SetPerspective(true);
@ -368,10 +368,10 @@ void plPerspDirSlave::IComputeCamNDCToLight(const hsPoint3& from, const hsPoint3
{
hsVector3 atToFrom(&from, &at);
hsScalar distSq = atToFrom.MagnitudeSquared();
float distSq = atToFrom.MagnitudeSquared();
atToFrom *= hsFastMath::InvSqrtAppr(distSq);
const hsScalar kMinMag = 0.5f;
const float kMinMag = 0.5f;
hsVector3 up(0,0,1.f);
if( CrossProd(up, (at - from)).MagnitudeSquared() < kMinMag )
{

View File

@ -49,7 +49,7 @@ class plPerspDirSlave : public plShadowSlave
{
protected:
hsBounds3Ext IGetPerspCasterBound(const hsMatrix44& world2NDC) const;
hsPoint3 IProject(const hsMatrix44& world2NDC, const hsPoint3& pos, hsScalar w=1.f) const;
hsPoint3 IProject(const hsMatrix44& world2NDC, const hsPoint3& pos, float w=1.f) const;
void IComputeCamNDCToLight(const hsPoint3& from, const hsPoint3& at, hsMatrix44& camNDC2Li, hsMatrix44& li2CamNDC);
public:

View File

@ -53,11 +53,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsBounds.h"
#include "hsFastMath.h"
static const hsScalar kMinMinZ = 1.f; // totally random arbitrary number (has to be > 0).
static const float kMinMinZ = 1.f; // totally random arbitrary number (has to be > 0).
static inline void QuickNorm( hsVector3& a, hsScalar& b )
static inline void QuickNorm( hsVector3& a, float& b )
{
hsScalar len = hsFastMath::InvSqrtAppr((a).MagnitudeSquared());
float len = hsFastMath::InvSqrtAppr((a).MagnitudeSquared());
a *= len;
b *= len;
}
@ -119,22 +119,22 @@ void plPointShadowMaster::IBeginRender()
void plPointShadowMaster::IComputeWorldToLight(const hsBounds3Ext& bnd, plShadowSlave* slave) const
{
const hsScalar kMinMag = 0.5f;
const float kMinMag = 0.5f;
hsPoint3 from = fLightInfo->GetLightToWorld().GetTranslate();
hsPoint3 at = bnd.GetCenter();
hsVector3 atToFrom(&from, &at);
hsScalar distSq = atToFrom.MagnitudeSquared();
float distSq = atToFrom.MagnitudeSquared();
atToFrom *= hsFastMath::InvSqrtAppr(distSq);
hsPoint2 depth;
bnd.TestPlane(atToFrom, depth);
hsScalar fromDepth = atToFrom.InnerProduct(from);
float fromDepth = atToFrom.InnerProduct(from);
hsScalar dist = fromDepth - depth.fY;
float dist = fromDepth - depth.fY;
static hsScalar kMinDist = 3.f;
static float kMinDist = 3.f;
if( dist < kMinDist )
{
atToFrom *= kMinDist - dist;
@ -199,10 +199,10 @@ void plPointShadowMaster::IComputeBounds(const hsBounds3Ext& wBnd, plShadowSlave
hsBounds3Ext bnd = sBnd;
hsScalar dist = sBnd.GetCenter().fZ;
float dist = sBnd.GetCenter().fZ;
dist += slave->fAttenDist;
hsScalar minZ = sBnd.GetMaxs().fZ;
float minZ = sBnd.GetMaxs().fZ;
hsPoint3 p(sBnd.GetMins().fX * dist / minZ, sBnd.GetMins().fY * dist / minZ, dist);
bnd.Union(&p);

View File

@ -87,12 +87,12 @@ protected:
// to be network synced.
uint8_t fCastFlags;
hsScalar fBoost;
hsScalar fAttenScale;
hsScalar fBlurScale;
float fBoost;
float fAttenScale;
float fBlurScale;
// Casting attributes calculated each frame.
hsScalar fMaxOpacity;
float fMaxOpacity;
hsTArray<DrawSpan> fSpans;
friend class plShadowMaster;
@ -110,14 +110,14 @@ public:
CLASSNAME_REGISTER( plShadowCaster );
GETINTERFACE_ANY( plShadowCaster, plMultiModifier );
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty) { return true; }
virtual hsBool IEval(double secs, float del, uint32_t dirty) { return true; }
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
hsScalar MaxOpacity() const { return fMaxOpacity; }
float MaxOpacity() const { return fMaxOpacity; }
const hsTArray<DrawSpan>& Spans() const { return fSpans; }
hsBool GetSelfShadow() const { return 0 != (fCastFlags & kSelfShadow); }
@ -129,14 +129,14 @@ public:
hsBool GetLimitRes() const { return 0 != (fCastFlags & kLimitRes); }
void SetLimitRes(hsBool on) { if(on) fCastFlags |= kLimitRes; else fCastFlags &= ~kLimitRes; }
hsScalar GetAttenScale() const { return fAttenScale; }
void SetAttenScale(hsScalar s) { fAttenScale = s; }
float GetAttenScale() const { return fAttenScale; }
void SetAttenScale(float s) { fAttenScale = s; }
hsScalar GetBlurScale() const { return fBlurScale; }
void SetBlurScale(hsScalar s) { fBlurScale = s; }
float GetBlurScale() const { return fBlurScale; }
void SetBlurScale(float s) { fBlurScale = s; }
hsScalar GetBoost() const { return fBoost; }
void SetBoost(hsScalar s) { fBoost = s; }
float GetBoost() const { return fBoost; }
void SetBoost(float s) { fBoost = s; }
// These are usually handled internally, activating on read and deactivating
// on destruct. Made public in case they need to be manually handled, like

View File

@ -63,11 +63,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plTweak.h"
uint32_t plShadowMaster::fGlobalMaxSize = 512;
hsScalar plShadowMaster::fGlobalMaxDist = 160.f; // PERSPTEST
// hsScalar plShadowMaster::fGlobalMaxDist = 100000.f; // PERSPTEST
hsScalar plShadowMaster::fGlobalVisParm = 1.f;
float plShadowMaster::fGlobalMaxDist = 160.f; // PERSPTEST
// float plShadowMaster::fGlobalMaxDist = 100000.f; // PERSPTEST
float plShadowMaster::fGlobalVisParm = 1.f;
void plShadowMaster::SetGlobalShadowQuality(hsScalar s)
void plShadowMaster::SetGlobalShadowQuality(float s)
{
if( s < 0 )
s = 0;
@ -166,7 +166,7 @@ void plShadowMaster::Deactivate() const
plgDispatch::Dispatch()->UnRegisterForExactType(plRenderMsg::Index(), GetKey());
}
void plShadowMaster::SetMaxDist(hsScalar f)
void plShadowMaster::SetMaxDist(float f)
{
fMaxDist = f;
fMinDist = f * 0.75f;
@ -227,11 +227,11 @@ hsBool plShadowMaster::IOnCastMsg(plShadowCastMsg* castMsg)
hsBounds3Ext casterBnd;
IComputeCasterBounds(caster, casterBnd);
hsScalar power = IComputePower(caster, casterBnd);
float power = IComputePower(caster, casterBnd);
static hsScalar kVisShadowPower = 1.e-1f;
static hsScalar kMinShadowPower = 2.e-1f;
static hsScalar kKneeShadowPower = 3.e-1f;
static float kVisShadowPower = 1.e-1f;
static float kMinShadowPower = 2.e-1f;
static float kKneeShadowPower = 3.e-1f;
if( power < kMinShadowPower )
return false;
if( power < kKneeShadowPower )
@ -318,7 +318,7 @@ plShadowSlave* plShadowMaster::INextSlave(const plShadowCaster* caster)
return slave;
}
plShadowSlave* plShadowMaster::ICreateShadowSlave(plShadowCastMsg* castMsg, const hsBounds3Ext& casterBnd, hsScalar power)
plShadowSlave* plShadowMaster::ICreateShadowSlave(plShadowCastMsg* castMsg, const hsBounds3Ext& casterBnd, float power)
{
const plShadowCaster* caster = castMsg->Caster();
@ -371,13 +371,13 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha
if( !castMsg->Pipeline()->TestVisibleWorld(wBnd) )
return IRecycleSlave(slave);
hsScalar maxDist = fMaxDist > 0
float maxDist = fMaxDist > 0
? (fGlobalMaxDist > 0
? hsMinimum(fMaxDist, fGlobalMaxDist)
: fMaxDist)
: fGlobalMaxDist;
plConst(hsScalar) kMinFrac(0.6f);
plConst(float) kMinFrac(0.6f);
maxDist *= kMinFrac + GetGlobalShadowQuality() * (1.f - kMinFrac);
// If we haven't got a max distance at which the shadow stays visible
@ -385,10 +385,10 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha
if( maxDist <= 0 )
return slave;
plConst(hsScalar) kMinFadeFrac(0.90f);
plConst(hsScalar) kMaxFadeFrac(0.75f);
const hsScalar fadeFrac = kMinFadeFrac + GetGlobalShadowQuality() * (kMaxFadeFrac - kMinFadeFrac);
hsScalar minDist = maxDist * fadeFrac;
plConst(float) kMinFadeFrac(0.90f);
plConst(float) kMaxFadeFrac(0.75f);
const float fadeFrac = kMinFadeFrac + GetGlobalShadowQuality() * (kMaxFadeFrac - kMinFadeFrac);
float minDist = maxDist * fadeFrac;
// So we want to fade out the shadow as it gets farther away, hopefully
// pitching it in the distance when we couldn't see it anyway.
@ -400,16 +400,16 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha
// but at least nothing will change when you swing the camera around.
#if 0
wBnd.TestPlane(castMsg->Pipeline()->GetViewDirWorld(), depth);
hsScalar eyeDist = castMsg->Pipeline()->GetViewDirWorld().InnerProduct(castMsg->Pipeline()->GetViewPositionWorld());
float eyeDist = castMsg->Pipeline()->GetViewDirWorld().InnerProduct(castMsg->Pipeline()->GetViewPositionWorld());
#else
hsPoint3 centre = wBnd.GetCenter();
hsPoint3 vpos = castMsg->Pipeline()->GetViewPositionWorld();
hsVector3 dir(&centre, &vpos);
hsFastMath::NormalizeAppr(dir);
wBnd.TestPlane(dir, depth);
hsScalar eyeDist = dir.InnerProduct(vpos);
float eyeDist = dir.InnerProduct(vpos);
#endif
hsScalar dist = depth.fX - eyeDist;
float dist = depth.fX - eyeDist;
// If it's not far enough to be fading, just go with it as is.
dist -= minDist;
@ -429,13 +429,13 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha
}
// compute ShadowSlave power influenced by SoftRegion, current light intensity, and ShadowCaster.fMaxOpacity;
hsScalar plShadowMaster::IComputePower(const plShadowCaster* caster, const hsBounds3Ext& casterBnd) const
float plShadowMaster::IComputePower(const plShadowCaster* caster, const hsBounds3Ext& casterBnd) const
{
hsScalar power = 0;
float power = 0;
if( fLightInfo && !fLightInfo->IsIdle() )
{
power = caster->fMaxOpacity;
hsScalar strength, scale;
float strength, scale;
fLightInfo->GetStrengthAndScale(casterBnd, strength, scale);
power *= strength;
}
@ -465,15 +465,15 @@ void plShadowMaster::IComputeWidthAndHeight(plShadowCastMsg* castMsg, plShadowSl
hsPoint2 depth;
wBnd.TestPlane(castMsg->Pipeline()->GetViewDirWorld(), depth);
hsScalar eyeDist = castMsg->Pipeline()->GetViewDirWorld().InnerProduct(castMsg->Pipeline()->GetViewPositionWorld());
hsScalar dist = depth.fX - eyeDist;
float eyeDist = castMsg->Pipeline()->GetViewDirWorld().InnerProduct(castMsg->Pipeline()->GetViewPositionWorld());
float dist = depth.fX - eyeDist;
if( dist < 0 )
dist = 0;
slave->fPriority = dist; // Might want to boost the local players priority.
plConst(hsScalar) kShiftDist = 50.f; // PERSPTEST
// plConst(hsScalar) kShiftDist = 5000.f; // PERSPTEST
plConst(float) kShiftDist = 50.f; // PERSPTEST
// plConst(float) kShiftDist = 5000.f; // PERSPTEST
int iShift = int(dist / kShiftDist);
slave->fWidth >>= iShift;
slave->fHeight >>= iShift;
@ -507,8 +507,8 @@ void plShadowMaster::IComputeLUT(plShadowCastMsg* castMsg, plShadowSlave* slave)
hsBounds3Ext bnd = slave->fCasterWorldBounds;
bnd.Transform(&slave->fWorldToLight);
hsScalar farthest = bnd.GetCenter().fZ + slave->fAttenDist;
hsScalar closest = bnd.GetMins().fZ;
float farthest = bnd.GetCenter().fZ + slave->fAttenDist;
float closest = bnd.GetMins().fZ;
// Shouldn't this always be negated?
static hsMatrix44 lightToLut; // Static ensures initialized to all zeros.
@ -524,8 +524,8 @@ void plShadowMaster::IComputeLUT(plShadowCastMsg* castMsg, plShadowSlave* slave)
// bias to ShadowSlave.LUTXfm.fMap[0][3]. Bias magnitude would probably be at
// least 0.5f/256.f to compensate for quantization.
plConst(hsScalar) kSelfBias = 2.f / 256.f;
plConst(hsScalar) kOtherBias = -0.5 / 256.f;
plConst(float) kSelfBias = 2.f / 256.f;
plConst(float) kOtherBias = -0.5 / 256.f;
#if 0 // MF_NOSELF
lightToLut.fMap[0][3] += slave->HasFlag(plShadowSlave::kSelfShadow) ? kSelfBias : kOtherBias;
#else // MF_NOSELF
@ -722,7 +722,7 @@ protected:
hsTArray<plDrawSpan> fSpans;
hsBounds3Ext fTotalWorldBounds;
hsScalar fMaxOpacity;
float fMaxOpacity;
On RenderMsg
@ -741,7 +741,7 @@ protected:
//find max opacity of all spans
//clear shadowBits of all spans
hsScalar fMaxOpacity = 0.f;
float fMaxOpacity = 0.f;
int i;
for( i = 0; i < fSpans.GetCount(); i++ )
{
@ -803,7 +803,7 @@ public:
CLASSNAME_REGISTER( plShadowCaster );
GETINTERFACE_ANY( plShadowCaster, plMultiModifier );
virtual hsBool IEval(double secs, hsScalar del, uint32_t dirty) {}
virtual hsBool IEval(double secs, float del, uint32_t dirty) {}
virtual hsBool MsgReceive(plMessage* msg);
@ -818,7 +818,7 @@ protected:
plVolumeIsect* fIsect;
hsScalar fAttenDist;
float fAttenDist;
plSoftVolume* fSoftVolume;
@ -831,7 +831,7 @@ protected:
// Override if you want to attenuate (e.g. dist for omni, cone angle for spot).
// But make sure you factor in base class power.
virtual hsScalar IComputePower(const plShadowCaster* caster);
virtual float IComputePower(const plShadowCaster* caster);
public:
plVolumeIsect* GetIsect() const { return fIsect; }
@ -853,7 +853,7 @@ public:
}
}
virtual void CreateShadowSlave(const hsBounds3Ext& bnd, hsScalar power)
virtual void CreateShadowSlave(const hsBounds3Ext& bnd, float power)
{
int iSlave = fSlavePool.GetCount();
fSlavePool.ExpandAndZero(iSlave+1);
@ -883,9 +883,9 @@ public:
};
// compute ShadowSlave power influenced by SoftRegion and ShadowCaster.fMaxOpacity;
hsScalar plShadowMaster::ComputePower(const plShadowCaster* caster)
float plShadowMaster::ComputePower(const plShadowCaster* caster)
{
hsScalar power = caster->fMaxOpacity;
float power = caster->fMaxOpacity;
if( fSoftVolume )
{
power *= fSoftVolume->GetStrength(caster->fTotalWorldBounds.GetCenter());
@ -928,13 +928,13 @@ void plOmniShadowMaster::IComputeProjections(const hsBounds3Ext& wBnd, plShadowS
hsBounds3Ext bnd = wBnd;
bnd.Transform(slave->fWorldToLight);
hsScalar minZ = bnd.GetMins().fZ;
hsScalar maxZ = bnd.GetCenter().fZ + fAttenDist;
float minZ = bnd.GetMins().fZ;
float maxZ = bnd.GetCenter().fZ + fAttenDist;
if( minZ < kMinMinZ )
minZ = kMinMinZ;
hsScalar cotX, cotY;
float cotX, cotY;
if( -bnd.GetMins().fX > bnd.GetMaxs().fX )
{
hsAssert(bnd.GetMins().fX < 0, "Empty shadow caster bounds?");
@ -1011,7 +1011,7 @@ public:
hsMatrix44 fCastLUT;
hsMatrix44 fRcvLUT;
hsScalar fPower;
float fPower;
plVolumeIsect* fISect;
@ -1038,7 +1038,7 @@ Harvest
if( !ShadowMaster.CanSee(ShadowCaster.fTotalWorldBounds) )
forget it;
hsScalar power = ComputePower(ShadowCaster);
float power = ComputePower(ShadowCaster);
if( power == 0 )
forget it;

View File

@ -72,18 +72,18 @@ public:
protected:
// Global clamp on shadow map size and stuff
static uint32_t fGlobalMaxSize;
static hsScalar fGlobalMaxDist;
static hsScalar fGlobalVisParm;
static float fGlobalMaxDist;
static float fGlobalVisParm;
// Constant parameter(s) for this master.
hsScalar fAttenDist;
hsScalar fMaxDist;
hsScalar fMinDist;
float fAttenDist;
float fMaxDist;
float fMinDist;
uint32_t fMaxSize;
uint32_t fMinSize;
hsScalar fPower;
float fPower;
// Temp data used for one frame and recycled.
hsTArray<plShadowSlave*> fSlavePool;
@ -102,11 +102,11 @@ protected:
virtual void IComputeCasterBounds(const plShadowCaster* caster, hsBounds3Ext& casterBnd);
virtual void IComputeWidthAndHeight(plShadowCastMsg* castMsg, plShadowSlave* slave) const;
virtual void IComputeLUT(plShadowCastMsg* castMsg, plShadowSlave* slave) const;
virtual hsScalar IComputePower(const plShadowCaster* caster, const hsBounds3Ext& casterBnd) const;
virtual float IComputePower(const plShadowCaster* caster, const hsBounds3Ext& casterBnd) const;
virtual plShadowSlave* ILastChanceToBail(plShadowCastMsg* castMsg, plShadowSlave* slave);
virtual plShadowSlave* ICreateShadowSlave(plShadowCastMsg* castMsg, const hsBounds3Ext& casterBnd, hsScalar power);
virtual plShadowSlave* ICreateShadowSlave(plShadowCastMsg* castMsg, const hsBounds3Ext& casterBnd, float power);
virtual plShadowSlave* INewSlave(const plShadowCaster* caster) = 0;
virtual plShadowSlave* INextSlave(const plShadowCaster* caster);
@ -140,29 +140,29 @@ public:
void Activate() const;
// These should only be useful on scene conversion.
hsScalar GetAttenDist() const { return fAttenDist; }
void SetAttenDist(hsScalar d) { fAttenDist = d; }
float GetAttenDist() const { return fAttenDist; }
void SetAttenDist(float d) { fAttenDist = d; }
hsScalar GetMaxDist() const { return fMaxDist; }
hsScalar GetMinDist() const { return fMinDist; }
void SetMaxDist(hsScalar m);
float GetMaxDist() const { return fMaxDist; }
float GetMinDist() const { return fMinDist; }
void SetMaxDist(float m);
uint32_t GetMaxSize() const { return fMaxSize; }
uint32_t GetMinSize() const { return fMinSize; }
void SetMaxSize(uint32_t s) { fMaxSize = s; }
void SetMinSize(uint32_t s) { fMinSize = s; }
hsScalar GetPower() const { return fPower; }
void SetPower(hsScalar f) { fPower = f; }
float GetPower() const { return fPower; }
void SetPower(float f) { fPower = f; }
static void SetGlobalMaxSize(uint32_t s) ;
static uint32_t GetGlobalMaxSize() { return fGlobalMaxSize; }
static void SetGlobalMaxDist(hsScalar s) { fGlobalMaxDist = s; }
static hsScalar GetGlobalMaxDist() { return fGlobalMaxDist; }
static void SetGlobalMaxDist(float s) { fGlobalMaxDist = s; }
static float GetGlobalMaxDist() { return fGlobalMaxDist; }
static void SetGlobalShadowQuality(hsScalar s);
static hsScalar GetGlobalShadowQuality() { return fGlobalVisParm; }
static void SetGlobalShadowQuality(float s);
static float GetGlobalShadowQuality() { return fGlobalVisParm; }
};

View File

@ -52,7 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define isnan _isnan
#endif
static const hsScalar kMinMinZ = 1.f; // totally random arbitrary number (has to be > 0).
static const float kMinMinZ = 1.f; // totally random arbitrary number (has to be > 0).
bool plShadowSlave::ISetupOrthoViewTransform()
{
@ -60,14 +60,14 @@ bool plShadowSlave::ISetupOrthoViewTransform()
bnd.Transform(&fWorldToLight);
hsScalar minZ = bnd.GetMins().fZ;
hsScalar maxZ = bnd.GetCenter().fZ + fAttenDist;
float minZ = bnd.GetMins().fZ;
float maxZ = bnd.GetCenter().fZ + fAttenDist;
hsScalar minX = bnd.GetMins().fX;
hsScalar maxX = bnd.GetMaxs().fX;
float minX = bnd.GetMins().fX;
float maxX = bnd.GetMaxs().fX;
hsScalar minY = bnd.GetMins().fY;
hsScalar maxY = bnd.GetMaxs().fY;
float minY = bnd.GetMins().fY;
float maxY = bnd.GetMaxs().fY;
hsMatrix44 proj;
@ -82,7 +82,7 @@ bool plShadowSlave::ISetupOrthoViewTransform()
// and an offset of zero works great. This could be a driver bug, or
// hardware "dependency" (read IHV bug), but whatever, zero is working
// now. Might need to adjust for new drivers or other hardware.
const hsScalar kAdjustBias = 0.0f;
const float kAdjustBias = 0.0f;
proj.fMap[0][0] = 1.f / (maxX - minX);
proj.fMap[0][3] = -minX / (maxX - minX) + kAdjustBias / fWidth;
proj.fMap[1][1] = -1.f / (maxY - minY);
@ -98,10 +98,10 @@ bool plShadowSlave::ISetupOrthoViewTransform()
// Like the adjust bias above, this part is correct in theory, but only
// screws things up (increases Z-acne).
#if 0
hsScalar delX = maxX - minX;
float delX = maxX - minX;
minX += delX / (fWidth * 0.5f);
maxX -= delX / (fWidth * 0.5f);
hsScalar delY = maxY - minY;
float delY = maxY - minY;
minY += delY / (fHeight * 0.5f);
maxY -= delY / (fHeight * 0.5f);
#endif
@ -111,7 +111,7 @@ bool plShadowSlave::ISetupOrthoViewTransform()
fView.SetScreenSize((uint16_t)fWidth, (uint16_t)fHeight);
fView.SetCameraTransform(fWorldToLight, fLightToWorld);
fView.SetPerspective(false);
fView.SetViewPort(0, 0, hsScalar(fWidth), hsScalar(fHeight), false);
fView.SetViewPort(0, 0, float(fWidth), float(fHeight), false);
fLightDir = fLightToWorld.GetAxis(hsMatrix44::kUp);
SetFlag(kPositional, false);
@ -126,8 +126,8 @@ bool plShadowSlave::ISetupPerspViewTransform()
bnd.Transform(&fWorldToLight);
hsScalar minZ = bnd.GetMins().fZ;
hsScalar maxZ = bnd.GetCenter().fZ + fAttenDist;
float minZ = bnd.GetMins().fZ;
float maxZ = bnd.GetCenter().fZ + fAttenDist;
if( minZ < kMinMinZ )
minZ = kMinMinZ;
@ -142,7 +142,7 @@ bool plShadowSlave::ISetupPerspViewTransform()
if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY))
return false;
hsScalar cotX, cotY;
float cotX, cotY;
if( -bnd.GetMins().fX > bnd.GetMaxs().fX )
{
hsAssert(bnd.GetMins().fX < 0, "Empty shadow caster bounds?");
@ -180,11 +180,11 @@ bool plShadowSlave::ISetupPerspViewTransform()
proj.fMap[1][1] = cotY * 0.5f;
proj.fMap[1][2] = -0.5f * (1.f + 0.5f/fHeight);
#else
plConst(hsScalar) kBiasScale(1.f);
plConst(hsScalar) kBiasTrans(1.f);
proj.fMap[0][0] = cotX * 0.5f * ( hsScalar(fWidth-2.f) / hsScalar(fWidth) ) * kBiasScale;
plConst(float) kBiasScale(1.f);
plConst(float) kBiasTrans(1.f);
proj.fMap[0][0] = cotX * 0.5f * ( float(fWidth-2.f) / float(fWidth) ) * kBiasScale;
proj.fMap[0][2] = 0.5f * (1.f - kBiasTrans * 0.5f/fWidth);
proj.fMap[1][1] = -cotY * 0.5f * ( hsScalar(fHeight-2.f) / hsScalar(fHeight) ) * kBiasScale;
proj.fMap[1][1] = -cotY * 0.5f * ( float(fHeight-2.f) / float(fHeight) ) * kBiasScale;
proj.fMap[1][2] = 0.5f * (1.f - kBiasTrans * 0.5f/fHeight);
#endif
@ -206,13 +206,13 @@ bool plShadowSlave::ISetupPerspViewTransform()
cotX -= cotX / (fWidth * 0.5f);
cotY -= cotY / (fHeight * 0.5f);
hsScalar tanX = 1.f / cotX;
hsScalar tanY = 1.f / cotY;
float tanX = 1.f / cotX;
float tanY = 1.f / cotY;
fView.SetView(hsPoint3(-tanX, -tanY, minZ), hsPoint3(tanX, tanY, maxZ));
fView.SetScreenSize((uint16_t)fWidth, (uint16_t)fHeight);
fView.SetCameraTransform(fWorldToLight, fLightToWorld);
fView.SetPerspective(true);
fView.SetViewPort(0, 0, hsScalar(fWidth), hsScalar(fHeight), false);
fView.SetViewPort(0, 0, float(fWidth), float(fHeight), false);
fLightPos = fLightToWorld.GetTranslate();
SetFlag(kPositional, true);

View File

@ -70,8 +70,8 @@ public:
plViewTransform fView;
hsScalar fPower;
hsScalar fBlurScale;
float fPower;
float fBlurScale;
hsBounds3Ext fCasterWorldBounds;
hsBounds3Ext fWorldBounds;
@ -81,9 +81,9 @@ public:
uint32_t fWidth;
uint32_t fHeight;
hsScalar fAttenDist;
float fAttenDist;
hsScalar fPriority;
float fPriority;
uint32_t fFlags;