1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +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,7 +74,7 @@ public:
bool GotHit() { return fDist != FLT_MAX; }
plKey GetObj() { return fHitObj; }
hsScalar GetDistance() { return fDist; }
float GetDistance() { return fDist; }
const hsVector3& GetNormal() { return fNormal; }
const hsPoint3& GetPoint() { return fPoint; }
void ResetHitObj(){fHitObj=nil;}
@ -153,7 +153,7 @@ private:
plKey fHitObj;
hsVector3 fNormal;
hsPoint3 fPoint;
hsScalar fDist;
float fDist;
} gMyReport;
plLOSDispatch::plLOSDispatch()
@ -213,7 +213,7 @@ hsBool plLOSDispatch::MsgReceive(plMessage* msg)
gMyReport.InitCast(requestMsg->GetRequestType(), requestMsg->GetTestType());
hsVector3 norm = hsVector3(at - from);
hsScalar dist = norm.Magnitude();
float dist = norm.Magnitude();
norm.Normalize();
NxRay worldRay;
@ -238,7 +238,7 @@ hsBool plLOSDispatch::MsgReceive(plMessage* msg)
// If we have a cull db, adjust the length of the raycast to be from the
// original point to the object we hit. If we find anything from the cull
// db in there, the cast fails.
hsScalar dist = gMyReport.GetDistance();
float dist = gMyReport.GetDistance();
if(dist!=0.0)
{
gMyReport.InitCast(requestMsg->GetCullDB(), plLOSRequestMsg::kTestAny);

View File

@ -212,7 +212,7 @@ static void MakeBoxFromHull(NxConvexMesh* convexMesh, NxBoxShapeDesc& box)
NxConvexMeshDesc desc;
convexMesh->saveToDesc(desc);
hsScalar minX, minY, minZ, maxX, maxY, maxZ;
float minX, minY, minZ, maxX, maxY, maxZ;
minX = minY = minZ = FLT_MAX;
maxX = maxY = maxZ = -FLT_MAX;
@ -1071,7 +1071,7 @@ void plPXPhysical::Read(hsStream* stream, hsResMgr* mgr)
hsAssert(!fProxyGen, "Already have proxy gen, double read?");
hsColorRGBA physColor;
hsScalar opac = 1.0f;
float opac = 1.0f;
if (fGroup == plSimDefs::kGroupAvatar)
{

View File

@ -74,9 +74,9 @@ class PhysRecipe
public:
PhysRecipe();
hsScalar mass;
hsScalar friction;
hsScalar restitution;
float mass;
float friction;
float restitution;
plSimDefs::Bounds bounds;
plSimDefs::Group group;
uint32_t reportsOn;
@ -91,7 +91,7 @@ public:
NxTriangleMesh* triMesh;
// For spheres only
hsScalar radius;
float radius;
hsPoint3 offset;
// For Boxes
@ -191,7 +191,7 @@ public:
//this partially for exclude regions vs avatar capsule
virtual hsBool OverlapWithCapsule(NxCapsule& cap);
virtual hsScalar GetMass() {return fMass;}
virtual float GetMass() {return fMass;}
protected:
void IGetPositionSim(hsPoint3& pos) const;
void IGetRotationSim(hsQuat& rot) const;
@ -259,7 +259,7 @@ protected:
void ISetHullToWorldWTriangles();
inline hsBool ITestPlane(const hsPoint3 &pos, const hsPlane3 &plane)
{
hsScalar dis = plane.fN.InnerProduct(pos);
float dis = plane.fN.InnerProduct(pos);
dis += plane.fD;
if (dis == 0.f)
return false;

View File

@ -99,7 +99,7 @@ public:
plPXPhysicalControllerCore* ac = plPXPhysicalControllerCore::FindController(hit.controller);
NxActor& actor = hit.shape->getActor();
plPXPhysical* phys = (plPXPhysical*)actor.userData;
static hsScalar SlopeLimit = kSLOPELIMIT;
static float SlopeLimit = kSLOPELIMIT;
hsVector3 normal = plPXConvert::Vector(hit.worldNormal);
ac->fMovementInterface->IAddContactNormals(normal);
#ifndef PLASMA_EXTERNAL_RELEASE
@ -127,9 +127,9 @@ public:
// If the avatar hit a movable physical, apply some force to it.
hsVector3 dir = plPXConvert::Vector(hit.dir);
float dirdotup=dir.fZ;
hsPoint3 pos((hsScalar)hit.worldPos.x, (hsScalar)hit.worldPos.y, (hsScalar)hit.worldPos.z);
hsPoint3 pos((float)hit.worldPos.x, (float)hit.worldPos.y, (float)hit.worldPos.z);
NxExtendedVec3 controllerPos=hit.controller->getPosition();
hsVector3 bottomOfTheCapsule((hsScalar)controllerPos.x,(hsScalar)controllerPos.y,(hsScalar)controllerPos.z);
hsVector3 bottomOfTheCapsule((float)controllerPos.x,(float)controllerPos.y,(float)controllerPos.z);
bottomOfTheCapsule.fZ=bottomOfTheCapsule.fZ-(ac->fHeight/2.0f + ac->fRadius);
if (actor.isDynamic() )
{
@ -167,10 +167,10 @@ public:
hsVector3 vel=ac->GetLinearVelocity()- plPXConvert::Vector( actor.getLinearVelocity());
if(dirdotup>=0)vel.fZ=0.001f;
else vel.fZ=0.0f;
static hsScalar kAvieMass = 140.f/32.f;
static float kAvieMass = 140.f/32.f;
if (!vel.IsEmpty())
{
static hsScalar kForceScale = 140.0f;
static float kForceScale = 140.0f;
NxF32 coeff;
NxExtendedVec3 norm2=hit.controller->getPosition();
norm2.x=hit.worldPos.x-bottomOfTheCapsule.fX;
@ -195,9 +195,9 @@ public:
float proj=(float)(norm2.x*dir.fX+dir.fY*norm2.y+dir.fZ*norm2.z);
coeff =abs(proj*kForceScale*vel.Magnitude());
vel.fZ=(hsScalar)norm2.z;
vel.fY=(hsScalar)norm2.y;
vel.fX=(hsScalar)norm2.x;
vel.fZ=(float)norm2.z;
vel.fY=(float)norm2.y;
vel.fX=(float)norm2.x;
phys->SetHitForce(vel*coeff, pos);
}
}
@ -223,13 +223,13 @@ public:
} gMyReport;
plPhysicalControllerCore* plPhysicalControllerCore::Create(plKey ownerSO, hsScalar height, hsScalar width)
plPhysicalControllerCore* plPhysicalControllerCore::Create(plKey ownerSO, float height, float width)
{
// Test to see how many controller there already is
if ( !plPXPhysicalControllerCore::fPXControllersMax || plPXPhysicalControllerCore::NumControllers() < plPXPhysicalControllerCore::fPXControllersMax )
{
hsScalar radius = width / 2.f;
hsScalar realHeight = height - width + kPhysicalHeightFudge;
float radius = width / 2.f;
float realHeight = height - width + kPhysicalHeightFudge;
return TRACKED_NEW plPXPhysicalControllerCore(ownerSO, realHeight,radius);
}
return nil;
@ -326,7 +326,7 @@ int plPXPhysicalControllerCore::GetNumberOfControllersInThisSubWorld(plKey world
return i;
}
//
plPXPhysicalControllerCore::plPXPhysicalControllerCore(plKey ownerSO, hsScalar height, hsScalar radius)
plPXPhysicalControllerCore::plPXPhysicalControllerCore(plKey ownerSO, float height, float radius)
: plPhysicalControllerCore(ownerSO,height,radius)
, fController(nil)
, fProxyGen(nil)
@ -499,12 +499,12 @@ void plPXPhysicalControllerCore::IGetPositionSim(hsPoint3& pos) const
if(this->fBehavingLikeAnimatedPhys)
{
const NxExtendedVec3& nxPos = fController->getPosition();
pos.Set(hsScalar(nxPos.x), hsScalar(nxPos.y), hsScalar(nxPos.z) - kPhysZOffset);
pos.Set(float(nxPos.x), float(nxPos.y), float(nxPos.z) - kPhysZOffset);
}
else
{
NxVec3 Pos = fKinematicActor->getGlobalPosition();
pos.Set(hsScalar(Pos.x), hsScalar(Pos.y), hsScalar(Pos.z) - kPhysZOffset);
pos.Set(float(Pos.x), float(Pos.y), float(Pos.z) - kPhysZOffset);
}
}
void plPXPhysicalControllerCore::ICreateController()
@ -568,7 +568,7 @@ NxScene* scene = plSimulationMgr::GetInstance()->GetScene(fWorldKey);
//hsAssert(!fProxyGen, "Already have proxy gen, double read?");
hsColorRGBA physColor;
hsScalar opac = 1.0f;
float opac = 1.0f;
// local avatar is light purple and transparent
physColor.Set(.2f, .1f, .2f, 1.f);
@ -638,7 +638,7 @@ void plPXPhysicalControllerCore::ICreateController(const hsPoint3& pos)
//hsAssert(!fProxyGen, "Already have proxy gen, double read?");
hsColorRGBA physColor;
hsScalar opac = 1.0f;
float opac = 1.0f;
// local avatar is light purple and transparent
physColor.Set(.2f, .1f, .2f, 1.f);
@ -809,7 +809,7 @@ void plPXPhysicalControllerCore::GetState(hsPoint3& pos, float& zRot)
fLocalRotation.GetAngleAxis(&zRot, (hsVector3*)&pos);
if (pos.fZ < 0)
zRot = (2 * hsScalarPI) - zRot; // axis is backwards, so reverse the angle too
zRot = (2 * M_PI) - zRot; // axis is backwards, so reverse the angle too
pos = fLocalPosition;
@ -870,10 +870,10 @@ void plPXPhysicalControllerCore::GetKinematicPosition(hsPoint3& pos)
if ( fKinematicActor )
{
NxVec3 klPos = fKinematicActor->getGlobalPosition();
pos.Set(hsScalar(klPos.x), hsScalar(klPos.y), hsScalar(klPos.z) - kPhysZOffset);
pos.Set(float(klPos.x), float(klPos.y), float(klPos.z) - kPhysZOffset);
}
}
void plPXPhysicalControllerCore::UpdatePoststep( hsScalar delSecs)
void plPXPhysicalControllerCore::UpdatePoststep( float delSecs)
{
// Apparently the user data field of the controllers is broken
// uint32_t count = gControllerMgr.getNbControllers();
@ -901,7 +901,7 @@ void plPXPhysicalControllerCore::UpdatePoststep( hsScalar delSecs)
}
}
}
void plPXPhysicalControllerCore::UpdatePrestep(hsScalar delSecs)
void plPXPhysicalControllerCore::UpdatePrestep(float delSecs)
{
for (int i = 0; i < gControllers.size(); i++)
{
@ -928,7 +928,7 @@ void plPXPhysicalControllerCore::UpdatePrestep(hsScalar delSecs)
}
gRebuildCache = false;
}
void plPXPhysicalControllerCore::UpdatePostSimStep(hsScalar delSecs)
void plPXPhysicalControllerCore::UpdatePostSimStep(float delSecs)
{
for (int i = 0; i < gControllers.size(); i++)
{
@ -1011,7 +1011,7 @@ void plPXPhysicalControllerCore::IHandleResize()
// delete[] response;
}
void plPXPhysicalControllerCore::SetControllerDimensions(hsScalar radius, hsScalar height)
void plPXPhysicalControllerCore::SetControllerDimensions(float radius, float height)
{
fNeedsResize=false;
if(fRadius!=radius)
@ -1129,7 +1129,7 @@ void plPXPhysicalControllerCore::SetLinearVelocity(const hsVector3& linearVel)
fKinematicActor->setLinearVelocity(vel);
}
}
void plPXPhysicalControllerCore::SetAngularVelocity(const hsScalar angvel)
void plPXPhysicalControllerCore::SetAngularVelocity(const float angvel)
{
plPhysicalControllerCore::SetAngularVelocity(angvel);
if(fKinematicActor && !fBehavingLikeAnimatedPhys)
@ -1138,7 +1138,7 @@ void plPXPhysicalControllerCore::SetAngularVelocity(const hsScalar angvel)
fKinematicActor->setAngularVelocity(vel);
}
}
void plPXPhysicalControllerCore::SetVelocities(const hsVector3& linearVel, hsScalar angVel)
void plPXPhysicalControllerCore::SetVelocities(const hsVector3& linearVel, float angVel)
{
SetLinearVelocity(linearVel);
SetAngularVelocity(angVel);
@ -1212,7 +1212,7 @@ void plPXPhysicalControllerCore::IDrawDebugDisplay()
{
hsVector3 normal = fDbgCollisionInfo[i].fNormal;
char *overlapStr = fDbgCollisionInfo[i].fOverlap ? "yes" : "no";
hsScalar angle = hsScalarRadToDeg(hsACosine(normal * hsVector3(0, 0, 1)));
float angle = hsRadiansToDegrees(acos(normal * hsVector3(0, 0, 1)));
sprintf(strBuf, " Obj: %s, Normal: (%.2f, %.2f, %.2f), Angle(%.1f), Overlap(%3s)",
fDbgCollisionInfo[i].fSO->GetKeyName(),
normal.fX, normal.fY, normal.fZ, angle, overlapStr);

View File

@ -68,7 +68,7 @@ class plPXPhysicalControllerCore: public plPhysicalControllerCore
{
friend class PXControllerHitReportWalk;
public:
plPXPhysicalControllerCore(plKey ownerSO, hsScalar height, hsScalar radius);
plPXPhysicalControllerCore(plKey ownerSO, float height, float radius);
~plPXPhysicalControllerCore();
//should actually be a 3 vector but everywhere else it is assumed to be just around Z
@ -98,7 +98,7 @@ public:
virtual void GetPositionSim(hsPoint3& pos){IGetPositionSim(pos);}
virtual void MoveKinematicToController(hsPoint3& pos);
virtual const hsPoint3& GetLocalPosition(){return fLocalPosition;}
virtual void SetControllerDimensions(hsScalar radius, hsScalar height);
virtual void SetControllerDimensions(float radius, float height);
virtual void LeaveAge();
virtual void UpdateControllerAndPhysicalRep();
@ -113,9 +113,9 @@ public:
static int GetControllersInThisSubWorld(plKey world, int maxToReturn,
plPXPhysicalControllerCore** bufferout);
static int GetNumberOfControllersInThisSubWorld(plKey world);
static void UpdatePrestep(hsScalar delSecs);
static void UpdatePoststep(hsScalar delSecs);
static void UpdatePostSimStep(hsScalar delSecs);
static void UpdatePrestep(float delSecs);
static void UpdatePoststep(float delSecs);
static void UpdatePostSimStep(float delSecs);
virtual plDrawableSpans* CreateProxy(hsGMaterial* mat, hsTArray<uint32_t>& idx, plDrawableSpans* addTo);
#ifndef PLASMA_EXTERNAL_RELEASE
static hsBool fDebugDisplay;
@ -129,8 +129,8 @@ public:
virtual void SetLinearVelocity(const hsVector3& linearVel);
//should actually be a 3 vector but everywhere else it is assumed to be just around Z
virtual void SetAngularVelocity(const hsScalar angvel);
virtual void SetVelocities(const hsVector3& linearVel, hsScalar angVel);
virtual void SetAngularVelocity(const float angvel);
virtual void SetVelocities(const hsVector3& linearVel, float angVel);
protected:
friend class PXControllerHitReport;
@ -151,8 +151,8 @@ protected:
void IDrawDebugDisplay();
#endif
void IHandleResize();
hsScalar fPreferedRadius;
hsScalar fPreferedHeight;
float fPreferedRadius;
float fPreferedHeight;
// The global position and rotation of the avatar last time we set it (so we
// can detect if someone else moves him)
plPhysicalProxy* fProxyGen;

View File

@ -468,7 +468,7 @@ NxScene* plSimulationMgr::GetScene(plKey world)
if (!scene)
{
uint32_t maxSteps = (uint32_t)hsCeil(fMaxDelta / fStepSize);
uint32_t maxSteps = (uint32_t)ceil(fMaxDelta / fStepSize);
NxSceneDesc sceneDesc;
sceneDesc.gravity.set(0, 0, -32.174049f);
@ -802,7 +802,7 @@ int plSimulationMgr::GetStepsPerSecond()
return (int)((1.0 / fStepSize) + 0.5f); // round to nearest int
}
int plSimulationMgr::GetMaterialIdx(NxScene* scene, hsScalar friction, hsScalar restitution)
int plSimulationMgr::GetMaterialIdx(NxScene* scene, float friction, float restitution)
{
if (friction == 0.5f && restitution == 0.5f)
return 0;

View File

@ -97,7 +97,7 @@ public:
// the scene
void ReleaseScene(plKey world);
int GetMaterialIdx(NxScene* scene, hsScalar friction, hsScalar restitution);
int GetMaterialIdx(NxScene* scene, float friction, float restitution);
// PHYSX FIXME - walk thru all the convex hull detector regions to see if we are in any... we're either coming or going
void UpdateDetectorsInScene(plKey world, plKey avatar, hsPoint3& pos, bool entering);