From 79f1714730db5275c9ff0623a33911b943fe70f8 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Wed, 30 Nov 2011 21:42:04 -0800 Subject: [PATCH] Fixes for plGLight errors. --- .../Plasma/PubUtilLib/plGLight/plLightInfo.cpp | 10 +++++++--- .../PubUtilLib/plGLight/plPerspDirSlave.cpp | 15 ++++++++++----- .../Plasma/PubUtilLib/plGLight/plShadowMaster.cpp | 6 ++++-- .../Plasma/PubUtilLib/plGLight/plShadowSlave.cpp | 9 +++++++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp index 737549d9..e2a3b8ff 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp @@ -763,7 +763,8 @@ void plOmniLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& str // Volume - Want to base this on the closest point on the bounds, instead of just the center. const hsPoint3& pos = bnd.GetCenter(); - hsScalar dist = hsVector3(&pos, &GetWorldPosition()).MagnitudeSquared(); + hsPoint3 wpos = GetWorldPosition(); + hsScalar dist = hsVector3(&pos, &wpos).MagnitudeSquared(); dist = 1.f / hsFastMath::InvSqrtAppr(dist); if( fAttenQuadratic > 0 ) { @@ -833,7 +834,9 @@ void plOmniLightInfo::IRefresh() hsVector3 plOmniLightInfo::GetNegativeWorldDirection(const hsPoint3& pos) const { - return hsFastMath::NormalizeAppr(hsVector3(&GetWorldPosition(), &pos)); + hsPoint3 wpos = GetWorldPosition(); + hsVector3 tmp(&wpos, &pos); + return hsFastMath::NormalizeAppr(tmp); } void plOmniLightInfo::Read(hsStream* s, hsResMgr* mgr) @@ -903,7 +906,8 @@ void plSpotLightInfo::GetStrengthAndScale(const hsBounds3Ext& bnd, hsScalar& str const hsPoint3& pos = bnd.GetCenter(); hsVector3 del; - del.Set(&pos, &GetWorldPosition()); + hsPoint3 wpos = GetWorldPosition(); + del.Set(&pos, &wpos); hsScalar invDist = del.MagnitudeSquared(); invDist = hsFastMath::InvSqrtAppr(invDist); diff --git a/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp b/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp index a3a26fc2..97e2e318 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp @@ -48,6 +48,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plPerspDirSlave.h" #include +#include + +#ifndef isnan +#define isnan _isnan +#endif void plPerspDirSlave::Init() { @@ -183,9 +188,9 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe) // is probably data-side. I take full responsibility for this // hack-around breaking the entire system, loosing data, causing // unauthorized credit card transactions, etc. - if (_isnan(bnd.GetMins().fX) || _isnan(bnd.GetMins().fY)) + if (isnan(bnd.GetMins().fX) || isnan(bnd.GetMins().fY)) return false; - if (_isnan(bnd.GetMaxs().fX) || _isnan(bnd.GetMaxs().fY)) + if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY)) return false; // THIS IS EVEN MORE WRONG @@ -244,9 +249,9 @@ bool plPerspDirSlave::SetupViewTransform(plPipeline* pipe) // is probably data-side. I take full responsibility for this // hack-around breaking the entire system, loosing data, causing // unauthorized credit card transactions, etc. - if (_isnan(bnd.GetMins().fX) || _isnan(bnd.GetMins().fY)) + if (isnan(bnd.GetMins().fX) || isnan(bnd.GetMins().fY)) return false; - if (_isnan(bnd.GetMaxs().fX) || _isnan(bnd.GetMaxs().fY)) + if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY)) return false; plConst(hsScalar) kMinMinZ(1.f); @@ -385,4 +390,4 @@ void plPerspDirSlave::IComputeCamNDCToLight(const hsPoint3& from, const hsPoint3 camNDC2Li = w2light; li2CamNDC = light2w; -} \ No newline at end of file +} diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp index b535bc75..c6b68fa3 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp @@ -402,10 +402,12 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha wBnd.TestPlane(castMsg->Pipeline()->GetViewDirWorld(), depth); hsScalar eyeDist = castMsg->Pipeline()->GetViewDirWorld().InnerProduct(castMsg->Pipeline()->GetViewPositionWorld()); #else - hsVector3 dir(&wBnd.GetCenter(), &castMsg->Pipeline()->GetViewPositionWorld()); + hsPoint3 centre = wBnd.GetCenter(); + hsPoint3 vpos = castMsg->Pipeline()->GetViewPositionWorld(); + hsVector3 dir(¢re, &vpos); hsFastMath::NormalizeAppr(dir); wBnd.TestPlane(dir, depth); - hsScalar eyeDist = dir.InnerProduct(castMsg->Pipeline()->GetViewPositionWorld()); + hsScalar eyeDist = dir.InnerProduct(vpos); #endif hsScalar dist = depth.fX - eyeDist; diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp index a059193e..a5755f31 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp @@ -46,6 +46,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plTweak.h" #include +#include + +#ifndef isnan +#define isnan _isnan +#endif static const hsScalar kMinMinZ = 1.f; // totally random arbitrary number (has to be > 0). @@ -132,9 +137,9 @@ bool plShadowSlave::ISetupPerspViewTransform() // is probably data-side. I take full responsibility for this // hack-around breaking the entire system, loosing data, causing // unauthorized credit card transactions, etc. - if (_isnan(bnd.GetMins().fX) || _isnan(bnd.GetMins().fY)) + if (isnan(bnd.GetMins().fX) || isnan(bnd.GetMins().fY)) return false; - if (_isnan(bnd.GetMaxs().fX) || _isnan(bnd.GetMaxs().fY)) + if (isnan(bnd.GetMaxs().fX) || isnan(bnd.GetMaxs().fY)) return false; hsScalar cotX, cotY;