Browse Source

Fixes for plGLight errors.

Darryl Pogue 13 years ago
parent
commit
79f1714730
  1. 10
      Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp
  2. 15
      Sources/Plasma/PubUtilLib/plGLight/plPerspDirSlave.cpp
  3. 6
      Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp
  4. 9
      Sources/Plasma/PubUtilLib/plGLight/plShadowSlave.cpp

10
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);

15
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 <float.h>
#include <math.h>
#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;
}
}

6
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(&centre, &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;

9
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 <float.h>
#include <math.h>
#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;

Loading…
Cancel
Save