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

Merge remote-tracking branch 'origin/master' into plString

Conflicts:
	Sources/Plasma/CoreLib/hsStream.h
	Sources/Plasma/FeatureLib/pfAudio/plListener.cpp
	Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
	Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
	Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
	Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
	Sources/Plasma/FeatureLib/pfPython/cyMisc.h
	Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp
	Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
	Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h
	Sources/Plasma/FeatureLib/pfPython/pyImage.cpp
	Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp
	Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h
	Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp
	Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp
	Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp
	Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h
	Sources/Plasma/NucleusLib/pnMessage/plMessage.h
	Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
	Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp
	Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp
	Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp
	Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp
	Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h
	Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
	Sources/Plasma/PubUtilLib/plNetCommon/plClientGuid.h
	Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp
	Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.h
	Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h
	Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp
	Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp
	Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp
	Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp
	Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h
	Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp
	Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h
	Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.cpp
	Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.h
	Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp
This commit is contained in:
2012-01-28 17:20:01 -08:00
1722 changed files with 24149 additions and 27599 deletions

View File

@ -69,7 +69,7 @@ public:
CLASSNAME_REGISTER( plBoundInterface );
GETINTERFACE_ANY( plBoundInterface, plObjInterface );
virtual Int32 GetNumProperties() const { return kNumProps; }
virtual int32_t GetNumProperties() const { return kNumProps; }
virtual void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
virtual void Read(hsStream* stream, hsResMgr* mgr);

View File

@ -39,7 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "HeadSpin.h"
#include "hsGeometry3.h"
#include "hsMatrix44.h"
#include "plConvexVolume.h"
@ -79,9 +79,9 @@ hsBool plConvexVolume::AddPlane(const hsPlane3 &plane)
}
fNumPlanes++;
//delete [] fFlags;
//fFlags = TRACKED_NEW UInt32[fNumPlanes];
//fFlags = new uint32_t[fNumPlanes];
hsPlane3 *tempPlanes = TRACKED_NEW hsPlane3[fNumPlanes];
hsPlane3 *tempPlanes = new hsPlane3[fNumPlanes];
for (i = 0; i < fNumPlanes - 1; i++)
{
tempPlanes[i] = fLocalPlanes[i];
@ -91,7 +91,7 @@ hsBool plConvexVolume::AddPlane(const hsPlane3 &plane)
delete [] fLocalPlanes;
fLocalPlanes = tempPlanes;
delete [] fWorldPlanes;
fWorldPlanes = TRACKED_NEW hsPlane3[fNumPlanes];
fWorldPlanes = new hsPlane3[fNumPlanes];
return true;
}
@ -110,16 +110,16 @@ void plConvexVolume::Update(const hsMatrix44 &l2w)
}
}
void plConvexVolume::SetNumPlanesAndClear(const UInt32 num)
void plConvexVolume::SetNumPlanesAndClear(const uint32_t num)
{
IClear();
//fFlags = TRACKED_NEW UInt32[num];
fLocalPlanes = TRACKED_NEW hsPlane3[num];
fWorldPlanes = TRACKED_NEW hsPlane3[num];
//fFlags = new uint32_t[num];
fLocalPlanes = new hsPlane3[num];
fWorldPlanes = new hsPlane3[num];
fNumPlanes = num;
}
void plConvexVolume::SetPlane(const hsPlane3 &plane, const UInt32 index)
void plConvexVolume::SetPlane(const hsPlane3 &plane, const uint32_t index)
{
fLocalPlanes[index] = plane;
}
@ -138,10 +138,10 @@ hsBool plConvexVolume::IsInside(const hsPoint3 &pos) const
hsBool plConvexVolume::ResolvePoint(hsPoint3 &pos) const
{
hsScalar minDist = 1.e33f;
Int32 minIndex = -1;
float minDist = 1.e33f;
int32_t minIndex = -1;
hsScalar currDist;
float currDist;
int i;
for (i = 0; i < fNumPlanes; i++)
{
@ -159,12 +159,12 @@ hsBool plConvexVolume::ResolvePoint(hsPoint3 &pos) const
return true;
}
hsBool plConvexVolume::BouncePoint(hsPoint3 &pos, hsVector3 &velocity, hsScalar bounce, hsScalar friction) const
hsBool plConvexVolume::BouncePoint(hsPoint3 &pos, hsVector3 &velocity, float bounce, float friction) const
{
hsScalar minDist = 1.e33f;
Int32 minIndex = -1;
float minDist = 1.e33f;
int32_t minIndex = -1;
hsScalar currDist;
float currDist;
int i;
for (i = 0; i < fNumPlanes; i++)
{

View File

@ -64,8 +64,8 @@ public:
void Update(const hsMatrix44 &l2w);
hsBool AddPlane(const hsPlane3 &plane);
void SetNumPlanesAndClear(const UInt32 num);
void SetPlane(const hsPlane3 &plane, const UInt32 index);
void SetNumPlanesAndClear(const uint32_t num);
void SetPlane(const hsPlane3 &plane, const uint32_t index);
// If you only care about the test, call this. Otherwise call ResolvePoint.
hsBool IsInside(const hsPoint3 &pos) const;
@ -75,7 +75,7 @@ public:
// returns true if the point was inside and pos and velocity updated to bounce off offending plane.
// input bounce==1.f for perfect bounce, bounce==0 to slide.
hsBool BouncePoint(hsPoint3 &pos, hsVector3 &velocity, hsScalar bounce, hsScalar friction) const;
hsBool BouncePoint(hsPoint3 &pos, hsVector3 &velocity, float bounce, float friction) const;
inline hsBool TestPlane(const hsPoint3 &pos, const hsPlane3 &plane) const; // Is the point inside the plane?
virtual void Read(hsStream* s, hsResMgr *mgr);
@ -87,12 +87,12 @@ protected:
hsPlane3 *fLocalPlanes;
hsPlane3 *fWorldPlanes;
UInt32 fNumPlanes;
uint32_t fNumPlanes;
};
inline hsBool plConvexVolume::TestPlane(const hsPoint3 &pos, const hsPlane3 &plane) const
{
hsScalar dis = plane.fN.InnerProduct(pos);
float dis = plane.fN.InnerProduct(pos);
dis += plane.fD;
if( dis >= 0.f )
return false;

View File

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plEffectTargetInfo_inc
#define plEffectTargetInfo_inc
#include "hsTypes.h"
#include "HeadSpin.h"
struct hsPoint3;
class plPipeline;
@ -58,7 +58,7 @@ public:
plPipeline* fPipeline;
plParticleSystem* fSystem;
double fSecs;
hsScalar fDelSecs;
float fDelSecs;
};
@ -68,27 +68,27 @@ public:
class plEffectTargetInfo
{
public:
// Byte arrays. Declared as type UInt8 so that adding the stride to the pointer is guaranteed to advance
// uint8_t arrays. Declared as type uint8_t so that adding the stride to the pointer is guaranteed to advance
// the exact number of bytes.
UInt8 *fPos;
UInt8 *fVelocity;
UInt8 *fInvMass;
UInt8 *fAcceleration;
UInt8 *fColor;
UInt8 *fRadsPerSec;
UInt8 *fMiscFlags;
uint8_t *fPos;
uint8_t *fVelocity;
uint8_t *fInvMass;
uint8_t *fAcceleration;
uint8_t *fColor;
uint8_t *fRadsPerSec;
uint8_t *fMiscFlags;
UInt32 fPosStride;
UInt32 fVelocityStride;
UInt32 fInvMassStride;
UInt32 fAccelerationStride;
UInt32 fColorStride;
UInt32 fRadsPerSecStride;
UInt32 fMiscFlagsStride;
uint32_t fPosStride;
uint32_t fVelocityStride;
uint32_t fInvMassStride;
uint32_t fAccelerationStride;
uint32_t fColorStride;
uint32_t fRadsPerSecStride;
uint32_t fMiscFlagsStride;
plParticleContext fContext;
UInt32 fNumValidParticles;
UInt32 fFirstNewParticle;
uint32_t fNumValidParticles;
uint32_t fFirstNewParticle;
// We're going to need some sort of connectivity data for constraint satisfaction, but at least we have
// a system that allows that to be added in smoothly when it's needed, so for now, let's get the main

View File

@ -82,10 +82,10 @@ class plParticleCore
{
public:
hsPoint3 fPos;
UInt32 fColor; // Particle opacity goes into the color's alpha.
uint32_t fColor; // Particle opacity goes into the color's alpha.
hsPoint3 fOrientation; // fMiscFlags determines how this should be used.
hsVector3 fNormal;
hsScalar fHSize, fVSize; // distance from the heart of the particle to the borders of its poly.
float fHSize, fVSize; // distance from the heart of the particle to the borders of its poly.
hsPoint3 fUVCoords[4];
};
@ -94,20 +94,20 @@ class plParticleExt
public:
//hsPoint3 fOldPos;
hsVector3 fVelocity;
hsScalar fInvMass; // The inverse (1 / mass) is what we actually need for calculations. Storing it this
float fInvMass; // The inverse (1 / mass) is what we actually need for calculations. Storing it this
// way allows us to make an object immovable with an inverse mass of 0 (and save a divide).
hsVector3 fAcceleration; // Accumulated from multiple forces.
hsScalar fLife; // how many seconds before we recycle this? (My particle has more of a life than I do...)
hsScalar fStartLife;
hsScalar fScale;
hsScalar fRadsPerSec;
//UInt32 fOrigColor;
float fLife; // how many seconds before we recycle this? (My particle has more of a life than I do...)
float fStartLife;
float fScale;
float fRadsPerSec;
//uint32_t fOrigColor;
enum // Miscellaneous flags for particles
{
kImmortal = 0x00000001,
};
UInt32 fMiscFlags; // I know... 32 bits for a single flag...
uint32_t fMiscFlags; // I know... 32 bits for a single flag...
// Feel free to change this if you've got something to pack it against.
};

View File

@ -51,7 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
plParticleGenerator *plParticleApplicator::IGetParticleGen(plSceneObject *so)
{
UInt32 numMods = so->GetNumModifiers();
uint32_t numMods = so->GetNumModifiers();
int i;
for (i = 0; i < numMods; i++)
{
@ -88,7 +88,7 @@ void plParticleAngleApplicator::IApply(const plAGModifier *mod, double time)
{
plScalarChannel *chan = plScalarChannel::ConvertNoRef(fChannel);
IGetParticleGen(mod->GetTarget(0))->UpdateParam(plParticleUpdateMsg::kParamInitPitchRange,
(hsScalar)(chan->Value(time) * PI / 180.f));
(float)(chan->Value(time) * PI / 180.f));
}
void plParticleVelMinApplicator::IApply(const plAGModifier *mod, double time)

View File

@ -39,7 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "HeadSpin.h"
#include "hsGeometry3.h"
#include "plParticle.h"
#include "plParticleEffect.h"
@ -98,7 +98,7 @@ void plParticleCollisionEffect::Read(hsStream *s, hsResMgr *mgr)
hsKeyedObject::Read(s, mgr);
plGenRefMsg* msg;
msg = TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, 0); // SceneObject
msg = new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, 0); // SceneObject
mgr->ReadKeyNotifyMe(s, msg, plRefFlags::kActiveRef);
fBounds = nil;
}
@ -118,7 +118,7 @@ plParticleCollisionEffectBeat::plParticleCollisionEffectBeat()
{
}
hsBool plParticleCollisionEffectBeat::ApplyEffect(const plEffectTargetInfo &target, Int32 i)
hsBool plParticleCollisionEffectBeat::ApplyEffect(const plEffectTargetInfo &target, int32_t i)
{
hsAssert(i >= 0, "Use of default argument doesn't make sense for plParticleCollisionEffect");
@ -137,7 +137,7 @@ plParticleCollisionEffectDie::plParticleCollisionEffectDie()
{
}
hsBool plParticleCollisionEffectDie::ApplyEffect(const plEffectTargetInfo &target, Int32 i)
hsBool plParticleCollisionEffectDie::ApplyEffect(const plEffectTargetInfo &target, int32_t i)
{
hsAssert(i >= 0, "Use of default argument doesn't make sense for plParticleCollisionEffect");
@ -156,7 +156,7 @@ plParticleCollisionEffectBounce::plParticleCollisionEffectBounce()
{
}
hsBool plParticleCollisionEffectBounce::ApplyEffect(const plEffectTargetInfo &target, Int32 i)
hsBool plParticleCollisionEffectBounce::ApplyEffect(const plEffectTargetInfo &target, int32_t i)
{
hsAssert(i >= 0, "Use of default argument doesn't make sense for plParticleCollisionEffect");
@ -234,9 +234,9 @@ plParticleFadeVolumeEffect::~plParticleFadeVolumeEffect()
// The shorter the distance, the more noticable the fade out.
// Note the wierdness between the fractions, because kFadeFrac is fraction
// of fLength, but kFadeParm and kInvFadeFrac are fraction of 2.f*fLength. Sorry.
const hsScalar kFadeFrac = 0.5f;
const hsScalar kFadeParm = 1.f - kFadeFrac * 0.5f;
const hsScalar kInvFadeFrac = 1.f / (kFadeFrac * 0.5f);
const float kFadeFrac = 0.5f;
const float kFadeParm = 1.f - kFadeFrac * 0.5f;
const float kInvFadeFrac = 1.f / (kFadeFrac * 0.5f);
void plParticleFadeVolumeEffect::PrepareEffect(const plEffectTargetInfo &target)
{
@ -265,13 +265,13 @@ void plParticleFadeVolumeEffect::PrepareEffect(const plEffectTargetInfo &target)
fNorm.fZ = 1.f / (fMax.fZ - fMin.fZ);
}
hsBool plParticleFadeVolumeEffect::ApplyEffect(const plEffectTargetInfo& target, Int32 i)
hsBool plParticleFadeVolumeEffect::ApplyEffect(const plEffectTargetInfo& target, int32_t i)
{
hsPoint3 *currPos = (hsPoint3 *)(target.fPos + i * target.fPosStride);
hsScalar parm;
float parm;
hsScalar fade = 1.f;
float fade = 1.f;
parm = (currPos->fX - fMin.fX) * fNorm.fX;
if( parm < 0 )
@ -338,8 +338,8 @@ hsBool plParticleFadeVolumeEffect::ApplyEffect(const plEffectTargetInfo& target,
if( fade < 1.f )
{
UInt32 *color = (UInt32 *)(target.fColor + i * target.fColorStride);
UInt32 alpha = (UInt32)((*color >> 24) * fade);
uint32_t *color = (uint32_t *)(target.fColor + i * target.fColorStride);
uint32_t alpha = (uint32_t)((*color >> 24) * fade);
*color = (*color & 0x00ffffff) | (alpha << 24);
}
@ -409,7 +409,7 @@ void plParticleWindEffect::Write(hsStream *s, hsResMgr *mgr)
void plParticleWindEffect::SetRefDirection(const hsVector3& v)
{
fRefDir = v;
hsScalar lenSq = fRefDir.MagnitudeSquared();
float lenSq = fRefDir.MagnitudeSquared();
if( lenSq > 1.e-1f )
{
fDir = fRefDir * hsFastMath::InvSqrtAppr(lenSq);
@ -484,12 +484,12 @@ void plParticleLocalWind::PrepareEffect(const plEffectTargetInfo& target)
}
hsBool plParticleLocalWind::ApplyEffect(const plEffectTargetInfo& target, Int32 i)
hsBool plParticleLocalWind::ApplyEffect(const plEffectTargetInfo& target, int32_t i)
{
const hsPoint3& pos = *(hsPoint3 *)(target.fPos + i * target.fPosStride);
hsVector3& vel = *(hsVector3*)(target.fVelocity + i * target.fVelocityStride);
const hsScalar kMinToBother = 0;
const float kMinToBother = 0;
float strength = 1.f / ( (1.f + fConstancy) * (1.f + fConstancy) );
float s, c, t;
@ -516,7 +516,7 @@ hsBool plParticleLocalWind::ApplyEffect(const plEffectTargetInfo& target, Int32
strength *= c;
#endif
const hsScalar& invMass = *(hsScalar*)(target.fInvMass + i * target.fInvMassStride);
const float& invMass = *(float*)(target.fInvMass + i * target.fInvMassStride);
strength *= invMass;
vel += fWindVec * strength;
@ -569,9 +569,9 @@ void plParticleUniformWind::Write(hsStream *s, hsResMgr *mgr)
s->WriteLEScalar(fFreqRate);
}
void plParticleUniformWind::SetFrequencyRange(hsScalar minSecsPerCycle, hsScalar maxSecsPerCycle)
void plParticleUniformWind::SetFrequencyRange(float minSecsPerCycle, float maxSecsPerCycle)
{
const hsScalar kMinSecsPerCycle = 1.f;
const float kMinSecsPerCycle = 1.f;
if( minSecsPerCycle < kMinSecsPerCycle )
minSecsPerCycle = kMinSecsPerCycle;
if( minSecsPerCycle < kMinSecsPerCycle )
@ -589,9 +589,9 @@ void plParticleUniformWind::SetFrequencyRange(hsScalar minSecsPerCycle, hsScalar
}
}
void plParticleUniformWind::SetFrequencyRate(hsScalar secsPerCycle)
void plParticleUniformWind::SetFrequencyRate(float secsPerCycle)
{
const hsScalar kMinSecsPerCycle = 1.f;
const float kMinSecsPerCycle = 1.f;
if( secsPerCycle < kMinSecsPerCycle )
secsPerCycle = kMinSecsPerCycle;
fFreqRate = 1.f / secsPerCycle;
@ -606,9 +606,9 @@ void plParticleUniformWind::PrepareEffect(const plEffectTargetInfo& target)
{
static plRandom random;
const double kTwoPi = hsScalarPI * 2.0;
const double kTwoPi = M_PI * 2.0;
double t0 = fFreqCurr * fLastFreqSecs + fCurrPhase;
hsScalar t1 = (hsScalar)fmod(t0, kTwoPi);
float t1 = (float)fmod(t0, kTwoPi);
fCurrPhase -= t0 - t1;
fFreqCurr += fFreqRate * target.fContext.fDelSecs * random.RandZeroToOne();
@ -624,11 +624,11 @@ void plParticleUniformWind::PrepareEffect(const plEffectTargetInfo& target)
fFreqRate = -fFreqRate;
}
hsScalar phaseDel = (hsScalar)(t1 - (fFreqCurr * fLastFreqSecs + fCurrPhase));
float phaseDel = (float)(t1 - (fFreqCurr * fLastFreqSecs + fCurrPhase));
fCurrPhase += phaseDel;
hsScalar t = hsScalar(fFreqCurr * target.fContext.fSecs + fCurrPhase);
hsScalar s;
float t = float(fFreqCurr * target.fContext.fSecs + fCurrPhase);
float s;
hsFastMath::SinCosAppr(t, s, fCurrentStrength);
fCurrentStrength += fConstancy;
fCurrentStrength /= (1.f + fConstancy);
@ -641,11 +641,11 @@ void plParticleUniformWind::PrepareEffect(const plEffectTargetInfo& target)
}
hsBool plParticleUniformWind::ApplyEffect(const plEffectTargetInfo& target, Int32 i)
hsBool plParticleUniformWind::ApplyEffect(const plEffectTargetInfo& target, int32_t i)
{
hsVector3& vel = *(hsVector3*)(target.fVelocity + i * target.fVelocityStride);
const hsScalar& invMass = *(hsScalar*)(target.fInvMass + i * target.fInvMassStride);
const float& invMass = *(float*)(target.fInvMass + i * target.fInvMassStride);
vel += fWindVec * (invMass * fCurrentStrength);
@ -729,9 +729,9 @@ void plParticleFlockEffect::IUpdateInfluences(const plEffectTargetInfo &target)
}
if (numAvg > 0)
fInfluences[i].fAvgVel /= (hsScalar)numAvg;
fInfluences[i].fAvgVel /= (float)numAvg;
if (numRep > 0)
fInfluences[i].fRepDir /= (hsScalar)numRep;
fInfluences[i].fRepDir /= (float)numRep;
}
}
@ -743,7 +743,7 @@ void plParticleFlockEffect::PrepareEffect(const plEffectTargetInfo& target)
// Some of this is the same for every particle and should be cached in PrepareEffect().
// Holding off on that until I like the behavior.
hsBool plParticleFlockEffect::ApplyEffect(const plEffectTargetInfo& target, Int32 i)
hsBool plParticleFlockEffect::ApplyEffect(const plEffectTargetInfo& target, int32_t i)
{
if (i >= fMaxParticles)
return false; // Don't have the memory to deal with you. Good luck kid...
@ -751,9 +751,9 @@ hsBool plParticleFlockEffect::ApplyEffect(const plEffectTargetInfo& target, Int3
const hsPoint3 &pos = *(hsPoint3*)(target.fPos + i * target.fPosStride);
hsVector3 &vel = *(hsVector3*)(target.fVelocity + i * target.fVelocityStride);
hsScalar curSpeed = vel.Magnitude();
float curSpeed = vel.Magnitude();
hsPoint3 goal;
if (*(UInt32*)(target.fMiscFlags + i * target.fMiscFlagsStride) & plParticleExt::kImmortal)
if (*(uint32_t*)(target.fMiscFlags + i * target.fMiscFlagsStride) & plParticleExt::kImmortal)
goal = target.fContext.fSystem->GetTarget(0)->GetLocalToWorld().GetTranslate() + fTargetOffset;
else
goal = fDissenterTarget;
@ -761,13 +761,13 @@ hsBool plParticleFlockEffect::ApplyEffect(const plEffectTargetInfo& target, Int3
hsVector3 goalDir;
hsPoint3 tmp = goal - pos;
goalDir.Set(&tmp);
hsScalar distSq = goalDir.MagnitudeSquared();
float distSq = goalDir.MagnitudeSquared();
goalDir.Normalize();
hsScalar goalStr;
hsScalar maxSpeed;
hsScalar maxSpeedSq;
float goalStr;
float maxSpeed;
float maxSpeedSq;
if (distSq <= fGoalDistSq)
{
goalStr = fGoalOrbitStr;
@ -785,7 +785,7 @@ hsBool plParticleFlockEffect::ApplyEffect(const plEffectTargetInfo& target, Int3
}
else
{
hsScalar pct = (distSq - fGoalDistSq) / (fFullChaseDistSq - fGoalDistSq);
float pct = (distSq - fGoalDistSq) / (fFullChaseDistSq - fGoalDistSq);
goalStr = fGoalOrbitStr + (fGoalChaseStr - fGoalOrbitStr) * pct;
maxSpeed = fMaxOrbitSpeed + (fMaxChaseSpeed - fMaxOrbitSpeed) * pct;
}
@ -804,7 +804,7 @@ hsBool plParticleFlockEffect::ApplyEffect(const plEffectTargetInfo& target, Int3
return false;
}
void plParticleFlockEffect::SetMaxParticles(const UInt16 num)
void plParticleFlockEffect::SetMaxParticles(const uint16_t num)
{
delete [] fDistSq;
delete [] fInfluences;
@ -812,8 +812,8 @@ void plParticleFlockEffect::SetMaxParticles(const UInt16 num)
if (num > 0)
{
fDistSq = TRACKED_NEW hsScalar[num * num];
fInfluences = TRACKED_NEW plParticleInfluenceInfo[num];
fDistSq = new float[num * num];
fInfluences = new plParticleInfluenceInfo[num];
}
}
@ -833,7 +833,7 @@ void plParticleFlockEffect::Read(hsStream *s, hsResMgr *mgr)
fGoalChaseStr = s->ReadLEScalar();
SetMaxOrbitSpeed(s->ReadLEScalar());
SetMaxChaseSpeed(s->ReadLEScalar());
SetMaxParticles((UInt16)s->ReadLEScalar());
SetMaxParticles((uint16_t)s->ReadLEScalar());
}
void plParticleFlockEffect::Write(hsStream *s, hsResMgr *mgr)
@ -889,7 +889,7 @@ void plParticleFollowSystemEffect::PrepareEffect(const plEffectTargetInfo& targe
fEvalThisFrame = (fOldW2L != target.fContext.fSystem->GetTarget(0)->GetWorldToLocal());
}
hsBool plParticleFollowSystemEffect::ApplyEffect(const plEffectTargetInfo& target, Int32 i)
hsBool plParticleFollowSystemEffect::ApplyEffect(const plEffectTargetInfo& target, int32_t i)
{
if (fEvalThisFrame)
{

View File

@ -67,7 +67,7 @@ public:
// context (invalidating anything cached).
// Defaults for Prepare and End are no-ops.
virtual void PrepareEffect(const plEffectTargetInfo& target) {}
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i) = 0;
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i) = 0;
virtual void EndEffect(const plEffectTargetInfo& target) {}
};
@ -102,7 +102,7 @@ public:
CLASSNAME_REGISTER( plParticleCollisionEffectBeat );
GETINTERFACE_ANY( plParticleCollisionEffectBeat, plParticleCollisionEffect );
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
};
// This particle blocker just kills any particles that hit it.
@ -114,30 +114,30 @@ public:
CLASSNAME_REGISTER( plParticleCollisionEffectDie );
GETINTERFACE_ANY( plParticleCollisionEffectDie, plParticleCollisionEffect );
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
};
class plParticleCollisionEffectBounce : public plParticleCollisionEffect
{
protected:
hsScalar fBounce;
hsScalar fFriction;
float fBounce;
float fFriction;
public:
plParticleCollisionEffectBounce();
CLASSNAME_REGISTER( plParticleCollisionEffectBounce );
GETINTERFACE_ANY( plParticleCollisionEffectBounce, plParticleCollisionEffect );
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
void SetBounce(hsScalar b) { fBounce = b; }
hsScalar GetBounce() const { return fBounce; }
void SetBounce(float b) { fBounce = b; }
float GetBounce() const { return fBounce; }
void SetFriction(hsScalar f) { fFriction = f; }
hsScalar GetFriction() const { return fFriction; }
void SetFriction(float f) { fFriction = f; }
float GetFriction() const { return fFriction; }
};
class plParticleFadeVolumeEffect : public plParticleEffect
@ -157,13 +157,13 @@ public:
GETINTERFACE_ANY( plParticleFadeVolumeEffect, plParticleEffect );
virtual void PrepareEffect(const plEffectTargetInfo& target);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
//virtual hsBool MsgReceive(plMessage *msg);
hsScalar fLength;
float fLength;
hsBool fIgnoreZ;
};
@ -171,9 +171,9 @@ class plParticleWindEffect : public plParticleEffect
{
protected:
// The properties that define the wind. These might/should be animatable.
hsScalar fStrength;
hsScalar fConstancy;
hsScalar fSwirl;
float fStrength;
float fConstancy;
float fSwirl;
hsBool fHorizontal;
hsVector3 fRefDir;
@ -193,19 +193,19 @@ public:
GETINTERFACE_ANY( plParticleWindEffect, plParticleEffect );
virtual void PrepareEffect(const plEffectTargetInfo& target);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i) = 0;
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i) = 0;
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
void SetStrength(hsScalar v) { fStrength = v; }
hsScalar GetStrength() const { return fStrength; }
void SetStrength(float v) { fStrength = v; }
float GetStrength() const { return fStrength; }
void SetConstancy(hsScalar c) { fConstancy = c; }
hsScalar GetConstancy() const { return fConstancy; }
void SetConstancy(float c) { fConstancy = c; }
float GetConstancy() const { return fConstancy; }
void SetSwirl(hsScalar s) { fSwirl = s; }
hsScalar GetSwirl() const { return fSwirl; }
void SetSwirl(float s) { fSwirl = s; }
float GetSwirl() const { return fSwirl; }
void SetHorizontal(hsBool on) { fHorizontal = on; }
hsBool GetHorizontal() const { return fHorizontal; }
@ -218,7 +218,7 @@ class plParticleLocalWind : public plParticleWindEffect
{
protected:
hsVector3 fScale;
hsScalar fSpeed;
float fSpeed;
hsVector3 fPhase;
hsVector3 fInvScale;
@ -232,13 +232,13 @@ public:
GETINTERFACE_ANY( plParticleLocalWind, plParticleWindEffect );
virtual void PrepareEffect(const plEffectTargetInfo& target);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
void SetScale(const hsVector3& v) { fScale = v; }
const hsVector3& GetScale() const { return fScale; }
void SetSpeed(hsScalar v) { fSpeed = v; }
hsScalar GetSpeed() const { return fSpeed; }
void SetSpeed(float v) { fSpeed = v; }
float GetSpeed() const { return fSpeed; }
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
@ -249,15 +249,15 @@ class plParticleUniformWind : public plParticleWindEffect
{
protected:
hsScalar fFreqMin;
hsScalar fFreqMax;
hsScalar fFreqCurr;
hsScalar fFreqRate;
float fFreqMin;
float fFreqMax;
float fFreqCurr;
float fFreqRate;
double fCurrPhase;
double fLastFreqSecs;
hsScalar fCurrentStrength;
float fCurrentStrength;
public:
plParticleUniformWind();
~plParticleUniformWind();
@ -266,10 +266,10 @@ public:
GETINTERFACE_ANY( plParticleUniformWind, plParticleWindEffect );
virtual void PrepareEffect(const plEffectTargetInfo& target);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
void SetFrequencyRange(hsScalar minSecsPerCycle, hsScalar maxSecsPerCycle);
void SetFrequencyRate(hsScalar secsPerCycle);
void SetFrequencyRange(float minSecsPerCycle, float maxSecsPerCycle);
void SetFrequencyRate(float secsPerCycle);
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
@ -289,19 +289,19 @@ class plParticleFlockEffect : public plParticleEffect
protected:
hsPoint3 fTargetOffset; // Worldspace offset from our target to get the true goal
hsPoint3 fDissenterTarget; // Where to particles go when they get scared and leave us?
hsScalar fInfAvgRadSq; // Square of the radius of influence for average velocity matching.
hsScalar fInfRepRadSq; // Same, for repelling from neighbors.
hsScalar fAvgVelStr; // How strongly are we influenced by average dir?
hsScalar fRepDirStr; // Same for repelling
hsScalar fGoalOrbitStr; // Same for the goal (when we're within the desired distance)
hsScalar fGoalChaseStr; // Same for the goal (when we're too far away, and chasing it)
hsScalar fGoalDistSq;
hsScalar fFullChaseDistSq;
hsScalar fMaxOrbitSpeed;
hsScalar fMaxChaseSpeed;
float fInfAvgRadSq; // Square of the radius of influence for average velocity matching.
float fInfRepRadSq; // Same, for repelling from neighbors.
float fAvgVelStr; // How strongly are we influenced by average dir?
float fRepDirStr; // Same for repelling
float fGoalOrbitStr; // Same for the goal (when we're within the desired distance)
float fGoalChaseStr; // Same for the goal (when we're too far away, and chasing it)
float fGoalDistSq;
float fFullChaseDistSq;
float fMaxOrbitSpeed;
float fMaxChaseSpeed;
UInt16 fMaxParticles;
hsScalar *fDistSq; // Table of distances from particle to particle
uint16_t fMaxParticles;
float *fDistSq; // Table of distances from particle to particle
plParticleInfluenceInfo *fInfluences;
void IUpdateDistances(const plEffectTargetInfo &target);
@ -315,21 +315,21 @@ public:
GETINTERFACE_ANY( plParticleFlockEffect, plParticleEffect );
virtual void PrepareEffect(const plEffectTargetInfo& target);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
void SetTargetOffset(const hsPoint3 &offset) { fTargetOffset = offset; }
void SetDissenterTarget(const hsPoint3 &target) { fDissenterTarget = target; }
void SetInfluenceAvgRadius(hsScalar val) { fInfAvgRadSq = val * val; }
void SetInfluenceRepelRadius(hsScalar val) { fInfRepRadSq = val * val; }
void SetGoalRadius(hsScalar val) { fGoalDistSq = val * val; }
void SetFullChaseRadius(hsScalar val) { fFullChaseDistSq = val * val; }
void SetConformStr(hsScalar val) { fAvgVelStr = val; }
void SetRepelStr(hsScalar val) { fRepDirStr = val; }
void SetGoalOrbitStr(hsScalar val) { fGoalOrbitStr = val; }
void SetGoalChaseStr(hsScalar val) { fGoalChaseStr = val; }
void SetMaxOrbitSpeed(hsScalar val) { fMaxOrbitSpeed = val; }
void SetMaxChaseSpeed(hsScalar val) { fMaxChaseSpeed = val; }
void SetMaxParticles(UInt16 num);
void SetInfluenceAvgRadius(float val) { fInfAvgRadSq = val * val; }
void SetInfluenceRepelRadius(float val) { fInfRepRadSq = val * val; }
void SetGoalRadius(float val) { fGoalDistSq = val * val; }
void SetFullChaseRadius(float val) { fFullChaseDistSq = val * val; }
void SetConformStr(float val) { fAvgVelStr = val; }
void SetRepelStr(float val) { fRepDirStr = val; }
void SetGoalOrbitStr(float val) { fGoalOrbitStr = val; }
void SetGoalChaseStr(float val) { fGoalChaseStr = val; }
void SetMaxOrbitSpeed(float val) { fMaxOrbitSpeed = val; }
void SetMaxChaseSpeed(float val) { fMaxChaseSpeed = val; }
void SetMaxParticles(uint16_t num);
virtual void Read(hsStream *s, hsResMgr *mgr);
virtual void Write(hsStream *s, hsResMgr *mgr);
@ -345,7 +345,7 @@ public:
plParticleFollowSystemEffect();
virtual void PrepareEffect(const plEffectTargetInfo& target);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, Int32 i);
virtual hsBool ApplyEffect(const plEffectTargetInfo& target, int32_t i);
virtual void EndEffect(const plEffectTargetInfo& target);
protected:

View File

@ -39,8 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "hsUtils.h"
#include "HeadSpin.h"
#include "hsResMgr.h"
#include "pnMessage/plRefMsg.h"
#include "plMessage/plParticleUpdateMsg.h"
@ -68,7 +68,7 @@ plParticleEmitter::plParticleEmitter()
fTimeToLive = 0;
}
void plParticleEmitter::Init(plParticleSystem *system, UInt32 maxParticles, UInt32 spanIndex, UInt32 miscFlags,
void plParticleEmitter::Init(plParticleSystem *system, uint32_t maxParticles, uint32_t spanIndex, uint32_t miscFlags,
plParticleGenerator *gen /* = nil */)
{
IClear();
@ -93,7 +93,7 @@ void plParticleEmitter::Init(plParticleSystem *system, UInt32 maxParticles, UInt
ISetupParticleMem();
}
void plParticleEmitter::Clone(plParticleEmitter* src, UInt32 spanIndex)
void plParticleEmitter::Clone(plParticleEmitter* src, uint32_t spanIndex)
{
Init(src->fSystem,
src->fMaxParticles,
@ -131,18 +131,18 @@ void plParticleEmitter::ISetupParticleMem()
{
fNumValidParticles = 0;
fParticleCores = TRACKED_NEW plParticleCore[fMaxParticles];
fParticleExts = TRACKED_NEW plParticleExt[fMaxParticles];
fParticleCores = new plParticleCore[fMaxParticles];
fParticleExts = new plParticleExt[fMaxParticles];
fTargetInfo.fPos = (UInt8 *)fParticleCores;
fTargetInfo.fColor = (UInt8 *)fParticleCores + sizeof(hsPoint3);
fTargetInfo.fPos = (uint8_t *)fParticleCores;
fTargetInfo.fColor = (uint8_t *)fParticleCores + sizeof(hsPoint3);
fTargetInfo.fPosStride = fTargetInfo.fColorStride = sizeof(plParticleCore);
fTargetInfo.fVelocity = (UInt8 *)fParticleExts;
fTargetInfo.fVelocity = (uint8_t *)fParticleExts;
fTargetInfo.fInvMass = fTargetInfo.fVelocity + sizeof(hsVector3);
fTargetInfo.fAcceleration = fTargetInfo.fInvMass + sizeof(hsScalar);
fTargetInfo.fMiscFlags = (UInt8 *)&(fParticleExts[0].fMiscFlags);
fTargetInfo.fRadsPerSec = (UInt8 *)&(fParticleExts[0].fRadsPerSec);
fTargetInfo.fAcceleration = fTargetInfo.fInvMass + sizeof(float);
fTargetInfo.fMiscFlags = (uint8_t *)&(fParticleExts[0].fMiscFlags);
fTargetInfo.fRadsPerSec = (uint8_t *)&(fParticleExts[0].fRadsPerSec);
fTargetInfo.fVelocityStride
= fTargetInfo.fInvMassStride
= fTargetInfo.fAccelerationStride
@ -151,7 +151,7 @@ void plParticleEmitter::ISetupParticleMem()
= sizeof(plParticleExt);
}
UInt32 plParticleEmitter::GetNumTiles() const
uint32_t plParticleEmitter::GetNumTiles() const
{
return fSystem->GetNumTiles();
}
@ -161,13 +161,13 @@ const hsMatrix44 &plParticleEmitter::GetLocalToWorld() const
return fMiscFlags & kOverrideLocalToWorld ? fLocalToWorld : fSystem->GetLocalToWorld();
}
void plParticleEmitter::AddParticle(hsPoint3 &pos, hsVector3 &velocity, UInt32 tileIndex,
hsScalar hSize, hsScalar vSize, hsScalar scale, hsScalar invMass, hsScalar life,
hsPoint3 &orientation, UInt32 miscFlags, hsScalar radsPerSec)
void plParticleEmitter::AddParticle(hsPoint3 &pos, hsVector3 &velocity, uint32_t tileIndex,
float hSize, float vSize, float scale, float invMass, float life,
hsPoint3 &orientation, uint32_t miscFlags, float radsPerSec)
{
plParticleCore *core;
plParticleExt *ext;
UInt32 currParticle;
uint32_t currParticle;
if (fNumValidParticles == fMaxParticles)
return; // No more room... you lose!
@ -185,8 +185,8 @@ void plParticleEmitter::AddParticle(hsPoint3 &pos, hsVector3 &velocity, UInt32 t
//if (core->fMiscFlags & kNormalUp != 0)
core->fNormal.Set(0, 0, 1);
hsScalar xOff = (tileIndex % fSystem->fXTiles) / (float)fSystem->fXTiles;
hsScalar yOff = (tileIndex / fSystem->fXTiles) / (float)fSystem->fYTiles;
float xOff = (tileIndex % fSystem->fXTiles) / (float)fSystem->fXTiles;
float yOff = (tileIndex / fSystem->fXTiles) / (float)fSystem->fYTiles;
core->fUVCoords[0].fX = xOff;
core->fUVCoords[0].fY = yOff + 1.0f / fSystem->fYTiles;
@ -220,7 +220,7 @@ void plParticleEmitter::WipeExistingParticles()
}
// This method is called from a network received message. Don't trust the args without checking.
void plParticleEmitter::KillParticles(hsScalar num, hsScalar timeToDie, UInt8 flags)
void plParticleEmitter::KillParticles(float num, float timeToDie, uint8_t flags)
{
if (flags & plParticleKillMsg::kParticleKillPercentage)
{
@ -252,16 +252,16 @@ void plParticleEmitter::KillParticles(hsScalar num, hsScalar timeToDie, UInt8 fl
}
}
void plParticleEmitter::UpdateGenerator(UInt32 paramID, hsScalar paramValue)
void plParticleEmitter::UpdateGenerator(uint32_t paramID, float paramValue)
{
if (fGenerator != nil)
fGenerator->UpdateParam(paramID, paramValue);
}
UInt16 plParticleEmitter::StealParticlesFrom(plParticleEmitter *victim, UInt16 num)
uint16_t plParticleEmitter::StealParticlesFrom(plParticleEmitter *victim, uint16_t num)
{
UInt16 spaceAvail = (UInt16)(fMaxParticles - fNumValidParticles);
UInt16 numToCopy = (UInt16)(hsMinimum(num, (victim ? victim->fNumValidParticles : 0)));
uint16_t spaceAvail = (uint16_t)(fMaxParticles - fNumValidParticles);
uint16_t numToCopy = (uint16_t)(hsMinimum(num, (victim ? victim->fNumValidParticles : 0)));
if (spaceAvail < numToCopy)
numToCopy = spaceAvail;
@ -285,7 +285,7 @@ void plParticleEmitter::TranslateAllParticles(hsPoint3 &amount)
fParticleCores[i].fPos += amount;
}
hsBool plParticleEmitter::IUpdate(hsScalar delta)
hsBool plParticleEmitter::IUpdate(float delta)
{
if (fMiscFlags & kNeedsUpdate)
{
@ -303,7 +303,7 @@ hsBool plParticleEmitter::IUpdate(hsScalar delta)
return true;
}
void plParticleEmitter::IUpdateParticles(hsScalar delta)
void plParticleEmitter::IUpdateParticles(float delta)
{
int i, j;
@ -343,7 +343,7 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta)
hsVector3 *currVelocity;
hsVector3 *currAccel;
hsPoint3 color(fColor.r, fColor.g, fColor.b);
hsScalar alpha = fColor.a;
float alpha = fColor.a;
plController *colorCtl;
// Allow effects a chance to cache any upfront calculations
@ -365,7 +365,7 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta)
{
if (!( fParticleExts[i].fMiscFlags & plParticleExt::kImmortal ))
{
hsScalar percent = (1.0f - fParticleExts[i].fLife / fParticleExts[i].fStartLife);
float percent = (1.0f - fParticleExts[i].fLife / fParticleExts[i].fStartLife);
colorCtl = (fMiscFlags & kMatIsEmissive ? fSystem->fAmbientCtl : fSystem->fDiffuseCtl);
if (colorCtl != nil)
colorCtl->Interp(colorCtl->GetLength() * percent, &color);
@ -417,8 +417,8 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta)
}
else if( fParticleExts[i].fRadsPerSec != 0 )
{
hsScalar sinX, cosX;
hsFastMath::SinCos(fParticleExts[i].fLife * fParticleExts[i].fRadsPerSec * 2.f * hsScalarPI, sinX, cosX);
float sinX, cosX;
hsFastMath::SinCos(fParticleExts[i].fLife * fParticleExts[i].fRadsPerSec * 2.f * M_PI, sinX, cosX);
fParticleCores[i].fOrientation.Set(sinX, -cosX, 0);
}
@ -431,7 +431,7 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta)
// V = V + -k*(V * delta)
// V *= (1 + -k * delta)
// Giving the change in velocity.
hsScalar drag = 1.f + fSystem->fDrag * delta;
float drag = 1.f + fSystem->fDrag * delta;
// Clamp it at 0. Drag should never cause a reversal in velocity direction.
if( drag < 0.f )
drag = 0.f;
@ -478,7 +478,7 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta)
plProfile_CreateTimer("Bound", "Particles", ParticleBound);
plProfile_CreateTimer("Normal", "Particles", ParticleNormal);
void plParticleEmitter::IUpdateBoundsAndNormals(hsScalar delta)
void plParticleEmitter::IUpdateBoundsAndNormals(float delta)
{
plProfile_BeginTiming(ParticleBound);
fBoundBox.MakeEmpty();
@ -526,7 +526,7 @@ void plParticleEmitter::IUpdateBoundsAndNormals(hsScalar delta)
plProfile_EndTiming(ParticleNormal);
}
void plParticleEmitter::IRemoveParticle(UInt32 index)
void plParticleEmitter::IRemoveParticle(uint32_t index)
{
hsAssert(index < fNumValidParticles, "Trying to remove an invalid particle");
@ -571,19 +571,19 @@ void plParticleEmitter::Write(hsStream *s, hsResMgr *mgr)
fColor.Write(s);
}
UInt32 plParticleEmitter::CreateHexColor(const hsColorRGBA &color)
uint32_t plParticleEmitter::CreateHexColor(const hsColorRGBA &color)
{
return CreateHexColor(color.r, color.g, color.b, color.a);
}
UInt32 plParticleEmitter::CreateHexColor(const hsScalar r, const hsScalar g, const hsScalar b, const hsScalar a)
uint32_t plParticleEmitter::CreateHexColor(const float r, const float g, const float b, const float a)
{
UInt32 ru, gu, bu, au;
uint32_t ru, gu, bu, au;
au = (UInt32)(a * 255.0f);
ru = (UInt32)(r * 255.0f);
gu = (UInt32)(g * 255.0f);
bu = (UInt32)(b * 255.0f);
au = (uint32_t)(a * 255.0f);
ru = (uint32_t)(r * 255.0f);
gu = (uint32_t)(g * 255.0f);
bu = (uint32_t)(b * 255.0f);
return ( au << 24 ) | ( ru << 16 ) | ( gu << 8 ) | ( bu );
}

View File

@ -67,34 +67,34 @@ class plParticleEmitter : public plCreatable
public:
plParticleEmitter();
~plParticleEmitter();
void Init(plParticleSystem *system, UInt32 maxParticles, UInt32 spanIndex, UInt32 miscFlags,
void Init(plParticleSystem *system, uint32_t maxParticles, uint32_t spanIndex, uint32_t miscFlags,
plParticleGenerator *gen = nil);
void Clone(plParticleEmitter* src, UInt32 spanIndex);
void Clone(plParticleEmitter* src, uint32_t spanIndex);
plParticleCore *GetParticleArray() const { return fParticleCores; }
UInt32 GetParticleCount() const { return fNumValidParticles; }
UInt32 GetNumTiles() const;
uint32_t GetParticleCount() const { return fNumValidParticles; }
uint32_t GetNumTiles() const;
const hsBounds3Ext &GetBoundingBox() const { return fBoundBox; }
UInt32 GetSpanIndex() const { return fSpanIndex; }
uint32_t GetSpanIndex() const { return fSpanIndex; }
const hsMatrix44 &GetLocalToWorld() const;
void AddParticle(hsPoint3 &pos, hsVector3 &velocity, UInt32 tileIndex,
hsScalar hSize, hsScalar vSize, hsScalar scale, hsScalar invMass, hsScalar life,
hsPoint3 &orientation, UInt32 miscFlags, hsScalar radsPerSec=0);
void AddParticle(hsPoint3 &pos, hsVector3 &velocity, uint32_t tileIndex,
float hSize, float vSize, float scale, float invMass, float life,
hsPoint3 &orientation, uint32_t miscFlags, float radsPerSec=0);
void WipeExistingParticles();
void KillParticles(hsScalar num, hsScalar timeToDie, UInt8 flags);
UInt16 StealParticlesFrom(plParticleEmitter *victim, UInt16 num); // returns the number actually stolen
void KillParticles(float num, float timeToDie, uint8_t flags);
uint16_t StealParticlesFrom(plParticleEmitter *victim, uint16_t num); // returns the number actually stolen
void TranslateAllParticles(hsPoint3 &amount); // Used to recenter the system when linking between ages.
void UpdateGenerator(UInt32 paramID, hsScalar paramValue);
void UpdateGenerator(uint32_t paramID, float paramValue);
static UInt32 CreateHexColor(const hsColorRGBA &color);
static UInt32 CreateHexColor(const hsScalar r, const hsScalar g, const hsScalar b, const hsScalar a);
static uint32_t CreateHexColor(const hsColorRGBA &color);
static uint32_t CreateHexColor(const float r, const float g, const float b, const float a);
void OverrideLocalToWorld(const hsMatrix44& l2w);
void UnOverrideLocalToWorld() { fMiscFlags &= ~kOverrideLocalToWorld; }
hsBool LocalToWorldOverridden() const { return 0 != (fMiscFlags & kOverrideLocalToWorld); }
void SetTimeToLive(hsScalar dt) { fTimeToLive = dt; }
hsScalar GetTimeToLive() const { return fTimeToLive; } // 0 time to live is never turn off.
void SetTimeToLive(float dt) { fTimeToLive = dt; }
float GetTimeToLive() const { return fTimeToLive; } // 0 time to live is never turn off.
CLASSNAME_REGISTER( plParticleEmitter );
GETINTERFACE_ANY( plParticleEmitter, plCreatable);
@ -127,7 +127,7 @@ public:
kOrientationVelocityMask = kOrientationVelocityBased | kOrientationVelocityStretch | kOrientationVelocityFlow, // Velocity dependent
kOrientationMask = kOrientationUp | kOrientationVelocityMask,
};
UInt32 fMiscFlags;
uint32_t fMiscFlags;
protected:
@ -137,23 +137,23 @@ protected:
// doesn't need.
plParticleGenerator *fGenerator; // Optional auto generator (have this be nil if you don't want auto-generation)
UInt32 fSpanIndex; // Index of the span that this emitter uses.
UInt32 fNumValidParticles;
UInt32 fMaxParticles;
uint32_t fSpanIndex; // Index of the span that this emitter uses.
uint32_t fNumValidParticles;
uint32_t fMaxParticles;
hsBounds3Ext fBoundBox;
plEffectTargetInfo fTargetInfo; // A collection of pointers and strides that plParticleEffects will manipulate.
hsColorRGBA fColor;
hsMatrix44 fLocalToWorld;
hsScalar fTimeToLive;
float fTimeToLive;
void IClear();
void ISetupParticleMem();
void ISetSystem(plParticleSystem *sys) { fSystem = sys; }
hsBool IUpdate(hsScalar delta);
void IUpdateParticles(hsScalar delta);
void IUpdateBoundsAndNormals(hsScalar delta);
void IRemoveParticle(UInt32 index);
hsBool IUpdate(float delta);
void IUpdateParticles(float delta);
void IUpdateBoundsAndNormals(float delta);
void IRemoveParticle(uint32_t index);
};
#endif

View File

@ -39,11 +39,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "HeadSpin.h"
#include "hsGeometry3.h"
#include "hsStream.h"
#include "hsFastMath.h"
#include "hsUtils.h"
#include "plParticle.h"
#include "plParticleSystem.h"
#include "plParticleEmitter.h"
@ -54,14 +54,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsResMgr.h"
#include "plMath/plRandom.h"
static const hsScalar DEFAULT_INVERSE_MASS = 1.f;
static const float DEFAULT_INVERSE_MASS = 1.f;
static plRandom sRandom;
const void plParticleGenerator::ComputeDirection(float pitch, float yaw, hsVector3 &direction)
{
hsScalar cosPitch, sinPitch;
hsScalar cosYaw, sinYaw;
float cosPitch, sinPitch;
float cosYaw, sinYaw;
hsFastMath::SinCos(pitch, sinPitch, cosPitch);
hsFastMath::SinCos(yaw, sinYaw, cosYaw);
@ -101,13 +101,13 @@ plSimpleParticleGenerator::~plSimpleParticleGenerator()
delete [] fInitYaw;
}
void plSimpleParticleGenerator::Init(hsScalar genLife, hsScalar partLifeMin, hsScalar partLifeMax,
hsScalar particlesPerSecond, UInt32 numSources, hsPoint3 *initPos,
hsScalar *initPitch, hsScalar *initYaw, hsScalar angleRange,
hsScalar initVelMin, hsScalar initVelMax,
hsScalar xSize, hsScalar ySize,
hsScalar scaleMin, hsScalar scaleMax,
hsScalar massRange, hsScalar radsPerSecRange)
void plSimpleParticleGenerator::Init(float genLife, float partLifeMin, float partLifeMax,
float particlesPerSecond, uint32_t numSources, hsPoint3 *initPos,
float *initPitch, float *initYaw, float angleRange,
float initVelMin, float initVelMax,
float xSize, float ySize,
float scaleMin, float scaleMax,
float massRange, float radsPerSecRange)
{
fGenLife = genLife;
fPartLifeMin = partLifeMin;
@ -135,9 +135,9 @@ void plSimpleParticleGenerator::Init(hsScalar genLife, hsScalar partLifeMin, hsS
if (fGenLife < 0) fMiscFlags |= kImmortal;
}
hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, float dt, UInt32 numForced /* = 0 */)
hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, float dt, uint32_t numForced /* = 0 */)
{
Int32 numNewParticles;
int32_t numNewParticles;
if (numForced == 0)
{
@ -146,7 +146,7 @@ hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, f
return true; // Leave it around so that a message can bring it back to life.
fParticleSum += fParticlesPerSecond * dt;
numNewParticles = (Int32)fParticleSum;
numNewParticles = (int32_t)fParticleSum;
if (numNewParticles <= 0 || fParticlesPerSecond == 0)
return true;
@ -156,27 +156,27 @@ hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, f
numNewParticles = numForced;
}
UInt32 miscFlags = 0;
uint32_t miscFlags = 0;
hsPoint3 currStart;
fParticleSum -= numNewParticles;
hsPoint3 orientation;
hsVector3 initDirection;
hsScalar vel = (fVelMax + fVelMin) * 0.5f;
hsScalar velRange = vel - fVelMin;
hsScalar initVelocity;
hsScalar initLife;
hsScalar life = (fPartLifeMax + fPartLifeMin) * 0.5f;
hsScalar lifeRange = life - fPartLifeMin;
hsScalar currSizeVar;
hsScalar scale = (fScaleMax + fScaleMin) * 0.5f;
hsScalar scaleRange = scale - fScaleMin;
hsScalar radsPerSec = 0;
UInt32 tile;
UInt32 sourceIndex;
float vel = (fVelMax + fVelMin) * 0.5f;
float velRange = vel - fVelMin;
float initVelocity;
float initLife;
float life = (fPartLifeMax + fPartLifeMin) * 0.5f;
float lifeRange = life - fPartLifeMin;
float currSizeVar;
float scale = (fScaleMax + fScaleMin) * 0.5f;
float scaleRange = scale - fScaleMin;
float radsPerSec = 0;
uint32_t tile;
uint32_t sourceIndex;
const hsScalar lifeDiff = dt / numNewParticles;
hsScalar lifeSoFar;
const float lifeDiff = dt / numNewParticles;
float lifeSoFar;
int i;
for (i = 0, lifeSoFar = 0; i < numNewParticles; i++, lifeSoFar += lifeDiff)
{
@ -189,7 +189,7 @@ hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, f
if (initLife <= 0 && initLife + lifeSoFar >= 0)
continue;
sourceIndex = (UInt32)(sRandom.RandZeroToOne() * fNumSources);
sourceIndex = (uint32_t)(sRandom.RandZeroToOne() * fNumSources);
ComputeDirection(fInitPitch[sourceIndex] + fAngleRange * sRandom.RandMinusOneToOne(),
fInitYaw[sourceIndex] + fAngleRange * sRandom.RandMinusOneToOne(), initDirection);
@ -205,10 +205,10 @@ hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, f
else
orientation.Set(&initDirection);
tile = (UInt32)(sRandom.RandZeroToOne() * emitter->GetNumTiles());
tile = (uint32_t)(sRandom.RandZeroToOne() * emitter->GetNumTiles());
currSizeVar = scale + scaleRange * sRandom.RandMinusOneToOne();
hsScalar invMass = fPartInvMassMin;
float invMass = fPartInvMassMin;
// Might be faster to just do the math instead of checking for zero...
if( fPartInvMassRange > 0 )
invMass += fPartInvMassRange * sRandom.RandZeroToOne();
@ -224,7 +224,7 @@ hsBool plSimpleParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, f
return true;
}
void plSimpleParticleGenerator::UpdateParam(UInt32 paramID, hsScalar paramValue)
void plSimpleParticleGenerator::UpdateParam(uint32_t paramID, float paramValue)
{
switch (paramID)
{
@ -296,14 +296,14 @@ void plSimpleParticleGenerator::UpdateParam(UInt32 paramID, hsScalar paramValue)
void plSimpleParticleGenerator::Read(hsStream* s, hsResMgr *mgr)
{
hsScalar genLife = s->ReadLEScalar();
hsScalar partLifeMin = s->ReadLEScalar();
hsScalar partLifeMax = s->ReadLEScalar();
hsScalar pps = s->ReadLEScalar();
UInt32 numSources = s->ReadLE32();
hsPoint3 *pos = TRACKED_NEW hsPoint3[numSources];
hsScalar *pitch = TRACKED_NEW hsScalar[numSources];
hsScalar *yaw = TRACKED_NEW hsScalar[numSources];
float genLife = s->ReadLEScalar();
float partLifeMin = s->ReadLEScalar();
float partLifeMax = s->ReadLEScalar();
float pps = s->ReadLEScalar();
uint32_t numSources = s->ReadLE32();
hsPoint3 *pos = new hsPoint3[numSources];
float *pitch = new float[numSources];
float *yaw = new float[numSources];
int i;
for (i = 0; i < numSources; i++)
{
@ -311,15 +311,15 @@ void plSimpleParticleGenerator::Read(hsStream* s, hsResMgr *mgr)
pitch[i] = s->ReadLEScalar();
yaw[i] = s->ReadLEScalar();
}
hsScalar angleRange = s->ReadLEScalar();
hsScalar velMin = s->ReadLEScalar();
hsScalar velMax = s->ReadLEScalar();
hsScalar xSize = s->ReadLEScalar();
hsScalar ySize = s->ReadLEScalar();
hsScalar scaleMin = s->ReadLEScalar();
hsScalar scaleMax = s->ReadLEScalar();
hsScalar massRange = s->ReadLEScalar();
hsScalar radsPerSec = s->ReadLEScalar();
float angleRange = s->ReadLEScalar();
float velMin = s->ReadLEScalar();
float velMax = s->ReadLEScalar();
float xSize = s->ReadLEScalar();
float ySize = s->ReadLEScalar();
float scaleMin = s->ReadLEScalar();
float scaleMax = s->ReadLEScalar();
float massRange = s->ReadLEScalar();
float radsPerSec = s->ReadLEScalar();
Init(genLife, partLifeMin, partLifeMax, pps, numSources, pos, pitch, yaw, angleRange, velMin, velMax,
xSize, ySize, scaleMin, scaleMax, massRange, radsPerSec);
@ -347,7 +347,7 @@ void plSimpleParticleGenerator::Write(hsStream* s, hsResMgr *mgr)
s->WriteLEScalar(fScaleMin);
s->WriteLEScalar(fScaleMax);
hsScalar massRange = 1.f / fPartInvMassMin - DEFAULT_INVERSE_MASS;
float massRange = 1.f / fPartInvMassMin - DEFAULT_INVERSE_MASS;
s->WriteLEScalar(massRange);
s->WriteLEScalar(fPartRadsPerSecRange);
}
@ -364,8 +364,8 @@ plOneTimeParticleGenerator::~plOneTimeParticleGenerator()
delete [] fDirection;
}
void plOneTimeParticleGenerator::Init(hsScalar count, hsPoint3 *pointArray, hsVector3 *dirArray,
hsScalar xSize, hsScalar ySize, hsScalar scaleMin, hsScalar scaleMax, hsScalar radsPerSecRange)
void plOneTimeParticleGenerator::Init(float count, hsPoint3 *pointArray, hsVector3 *dirArray,
float xSize, float ySize, float scaleMin, float scaleMax, float radsPerSecRange)
{
fCount = count;
fPosition = pointArray;
@ -378,18 +378,18 @@ void plOneTimeParticleGenerator::Init(hsScalar count, hsPoint3 *pointArray, hsVe
}
// The numForced param is required by the parent class, but ignored by this particular generator
hsBool plOneTimeParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, float dt, UInt32 numForced /* = 0 */)
hsBool plOneTimeParticleGenerator::AddAutoParticles(plParticleEmitter *emitter, float dt, uint32_t numForced /* = 0 */)
{
hsScalar currSizeVar;
hsScalar scale = (fScaleMax + fScaleMin) / 2;
hsScalar scaleRange = scale - fScaleMin;
float currSizeVar;
float scale = (fScaleMax + fScaleMin) / 2;
float scaleRange = scale - fScaleMin;
hsScalar tile;
float tile;
hsPoint3 currStart;
hsPoint3 orientation;
hsVector3 initDirection;
hsVector3 zeroVel(0.f, 0.f, 0.f);
hsScalar radsPerSec = 0;
float radsPerSec = 0;
int i;
for (i = 0; i < fCount; i++)
@ -402,13 +402,13 @@ hsBool plOneTimeParticleGenerator::AddAutoParticles(plParticleEmitter *emitter,
else
orientation.Set(&initDirection);
tile = (hsScalar)(sRandom.Rand() % emitter->GetNumTiles());
tile = (float)(sRandom.Rand() % emitter->GetNumTiles());
currSizeVar = scale + scaleRange * sRandom.RandMinusOneToOne();
if( fPartRadsPerSecRange > 0 )
radsPerSec = fPartRadsPerSecRange * sRandom.RandMinusOneToOne();
emitter->AddParticle(currStart, zeroVel, (UInt32)tile, fXSize, fYSize, currSizeVar,
emitter->AddParticle(currStart, zeroVel, (uint32_t)tile, fXSize, fYSize, currSizeVar,
DEFAULT_INVERSE_MASS, -1, orientation, 0, radsPerSec);
}
emitter->fMiscFlags &= ~plParticleEmitter::kNeedsUpdate;
@ -417,15 +417,15 @@ hsBool plOneTimeParticleGenerator::AddAutoParticles(plParticleEmitter *emitter,
void plOneTimeParticleGenerator::Read(hsStream* s, hsResMgr *mgr)
{
UInt32 count = s->ReadLE32();
hsScalar xSize = s->ReadLEScalar();
hsScalar ySize = s->ReadLEScalar();
hsScalar scaleMin = s->ReadLEScalar();
hsScalar scaleMax = s->ReadLEScalar();
hsScalar radsPerSecRange = s->ReadLEScalar();
uint32_t count = s->ReadLE32();
float xSize = s->ReadLEScalar();
float ySize = s->ReadLEScalar();
float scaleMin = s->ReadLEScalar();
float scaleMax = s->ReadLEScalar();
float radsPerSecRange = s->ReadLEScalar();
hsPoint3 *pos = TRACKED_NEW hsPoint3[count];
hsVector3 *dir = TRACKED_NEW hsVector3[count];
hsPoint3 *pos = new hsPoint3[count];
hsVector3 *dir = new hsVector3[count];
int i;
for (i = 0; i < count; i++)
@ -434,12 +434,12 @@ void plOneTimeParticleGenerator::Read(hsStream* s, hsResMgr *mgr)
dir[i].Read(s);
}
Init((hsScalar)count, pos, dir, xSize, ySize, scaleMin, scaleMax, radsPerSecRange);
Init((float)count, pos, dir, xSize, ySize, scaleMin, scaleMax, radsPerSecRange);
}
void plOneTimeParticleGenerator::Write(hsStream* s, hsResMgr *mgr)
{
s->WriteLE32((UInt32)fCount);
s->WriteLE32((uint32_t)fCount);
s->WriteLEScalar(fXSize);
s->WriteLEScalar(fYSize);
s->WriteLEScalar(fScaleMin);

View File

@ -56,9 +56,9 @@ class plParticleGenerator : public plCreatable
public:
// returns false if it's done generating particles and is safe to delete.
virtual hsBool AddAutoParticles(plParticleEmitter *emitter, float dt, UInt32 numForced = 0) = 0;
virtual hsBool AddAutoParticles(plParticleEmitter *emitter, float dt, uint32_t numForced = 0) = 0;
virtual void UpdateParam(UInt32 paramID, hsScalar paramValue) = 0;
virtual void UpdateParam(uint32_t paramID, float paramValue) = 0;
CLASSNAME_REGISTER( plParticleGenerator );
GETINTERFACE_ANY( plParticleGenerator, plCreatable );
@ -73,50 +73,50 @@ class plSimpleParticleGenerator : public plParticleGenerator
public:
plSimpleParticleGenerator();
~plSimpleParticleGenerator();
void Init(hsScalar genLife, hsScalar partLifeMin, hsScalar partLifeMax, hsScalar particlesPerSecond,
UInt32 numSources, hsPoint3 *pos, hsScalar *initPitch, hsScalar *initYaw, hsScalar angleRange,
hsScalar initVelMin, hsScalar initVelMax, hsScalar xSize, hsScalar ySize,
hsScalar scaleMin, hsScalar scaleMax,
hsScalar massRange, hsScalar radsPerSecRange);
void Init(float genLife, float partLifeMin, float partLifeMax, float particlesPerSecond,
uint32_t numSources, hsPoint3 *pos, float *initPitch, float *initYaw, float angleRange,
float initVelMin, float initVelMax, float xSize, float ySize,
float scaleMin, float scaleMax,
float massRange, float radsPerSecRange);
CLASSNAME_REGISTER( plSimpleParticleGenerator );
GETINTERFACE_ANY( plSimpleParticleGenerator, plParticleGenerator);
virtual hsBool AddAutoParticles(plParticleEmitter *emitter, float dt, UInt32 numForced);
virtual void UpdateParam(UInt32 paramID, hsScalar paramValue);
virtual hsBool AddAutoParticles(plParticleEmitter *emitter, float dt, uint32_t numForced);
virtual void UpdateParam(uint32_t paramID, float paramValue);
virtual void Read(hsStream* s, hsResMgr *mgr);
virtual void Write(hsStream* s, hsResMgr *mgr);
protected:
hsScalar fParticlesPerSecond;
UInt32 fNumSources;
float fParticlesPerSecond;
uint32_t fNumSources;
hsPoint3 *fInitPos;
hsScalar *fInitPitch, *fInitYaw;
hsScalar fAngleRange;
hsScalar fVelMin, fVelMax;
hsScalar fXSize, fYSize, fScaleMin, fScaleMax;
hsScalar fGenLife; // How long shall we spit out particles from this location? When this time runs out, we stop
float *fInitPitch, *fInitYaw;
float fAngleRange;
float fVelMin, fVelMax;
float fXSize, fYSize, fScaleMin, fScaleMax;
float fGenLife; // How long shall we spit out particles from this location? When this time runs out, we stop
// spitting particles, but we don't actually die until all of our particles die naturally.
// (Even the ones that we feel are suffering needlessly.)
hsScalar fPartLifeMin; // lifespan for the particles we generate
hsScalar fPartLifeMax;
float fPartLifeMin; // lifespan for the particles we generate
float fPartLifeMax;
hsScalar fPartInvMassMin; // Doing a uniform variant over the inverse mass range (instead of over the mass range
hsScalar fPartInvMassRange; // and then inverting) will favor the low end of the mass range, but then again,
float fPartInvMassMin; // Doing a uniform variant over the inverse mass range (instead of over the mass range
float fPartInvMassRange; // and then inverting) will favor the low end of the mass range, but then again,
// it's just a freaking game. Note though that fPartInvMassMin == 1.f / massMAX.
hsScalar fPartRadsPerSecRange; // Zero means no rot, otherwise uniform random between [-range..range]
float fPartRadsPerSecRange; // Zero means no rot, otherwise uniform random between [-range..range]
hsScalar fParticleSum;
float fParticleSum;
enum
{
kImmortal = 0x1,
kDisabled = 0x2,
};
UInt32 fMiscFlags;
uint32_t fMiscFlags;
};
class plOneTimeParticleGenerator : public plParticleGenerator
@ -125,24 +125,24 @@ public:
plOneTimeParticleGenerator();
~plOneTimeParticleGenerator();
void Init(hsScalar count, hsPoint3 *pointArray, hsVector3 *dirArray,
hsScalar xSize, hsScalar ySize, hsScalar scaleMin, hsScalar scaleMax, hsScalar radsPerSec);
void Init(float count, hsPoint3 *pointArray, hsVector3 *dirArray,
float xSize, float ySize, float scaleMin, float scaleMax, float radsPerSec);
CLASSNAME_REGISTER( plOneTimeParticleGenerator );
GETINTERFACE_ANY( plOneTimeParticleGenerator, plParticleGenerator);
virtual hsBool AddAutoParticles(plParticleEmitter *emitter, float dt, UInt32 numForced = 0);
virtual void UpdateParam(UInt32 paramID, hsScalar paramValue) {}
virtual hsBool AddAutoParticles(plParticleEmitter *emitter, float dt, uint32_t numForced = 0);
virtual void UpdateParam(uint32_t paramID, float paramValue) {}
virtual void Read(hsStream* s, hsResMgr *mgr);
virtual void Write(hsStream* s, hsResMgr *mgr);
protected:
hsScalar fCount;
float fCount;
hsPoint3 *fPosition;
hsVector3 *fDirection;
hsScalar fXSize, fYSize, fScaleMin, fScaleMax;
hsScalar fPartRadsPerSecRange; // Zero means no rot, otherwise uniform random between [-range..range]
float fXSize, fYSize, fScaleMin, fScaleMax;
float fPartRadsPerSecRange; // Zero means no rot, otherwise uniform random between [-range..range]
};
#endif

View File

@ -55,7 +55,7 @@ void plParticleSDLMod::IPutCurrentStateIn(plStateDataRecord* dstState)
if (!sobj)
return;
UInt32 flags = sobj->GetKey()->GetUoid().GetLocation().GetFlags();
uint32_t flags = sobj->GetKey()->GetUoid().GetLocation().GetFlags();
const plParticleSystem *sys = plParticleSystem::ConvertNoRef(sobj->GetModifierByType(plParticleSystem::Index()));
if (!sys)
@ -84,7 +84,7 @@ void plParticleSDLMod::ISetCurrentStateFrom(const plStateDataRecord* srcState)
sys->GenerateParticles(num);
}
UInt32 plParticleSDLMod::IApplyModFlags(UInt32 sendFlags)
uint32_t plParticleSDLMod::IApplyModFlags(uint32_t sendFlags)
{
if (fAttachedToAvatar)
return (sendFlags | plSynchedObject::kDontPersistOnServer | plSynchedObject::kIsAvatarState);

View File

@ -57,7 +57,7 @@ private:
protected:
void IPutCurrentStateIn(plStateDataRecord* dstState);
void ISetCurrentStateFrom(const plStateDataRecord* srcState);
UInt32 IApplyModFlags(UInt32 sendFlags);
uint32_t IApplyModFlags(uint32_t sendFlags);
public:
// var labels
static char kStrNumParticles[];

View File

@ -39,7 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "HeadSpin.h"
#include "plParticleSystem.h"
#include "plParticleEmitter.h"
#include "plParticleGenerator.h"
@ -67,7 +67,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
plProfile_CreateCounter("Num Particles", "Particles", NumParticles);
const hsScalar plParticleSystem::GRAVITY_ACCEL_FEET_PER_SEC2 = 32.0f;
const float plParticleSystem::GRAVITY_ACCEL_FEET_PER_SEC2 = 32.0f;
plParticleSystem::plParticleSystem() : fParticleSDLMod(nil), fAttachedToAvatar(false)
{
@ -89,7 +89,7 @@ plParticleSystem::~plParticleSystem()
delete fHeightCtl;
}
void plParticleSystem::Init(UInt32 xTiles, UInt32 yTiles, UInt32 maxTotalParticles, UInt32 maxEmitters,
void plParticleSystem::Init(uint32_t xTiles, uint32_t yTiles, uint32_t maxTotalParticles, uint32_t maxEmitters,
plController *ambientCtl, plController *diffuseCtl, plController *opacityCtl,
plController *widthCtl, plController *heightCtl)
{
@ -113,7 +113,7 @@ void plParticleSystem::Init(UInt32 xTiles, UInt32 yTiles, UInt32 maxTotalParticl
fMaxTotalParticles = fMaxTotalParticlesLeft = maxTotalParticles;
fMaxEmitters = maxEmitters;
fEmitters = TRACKED_NEW plParticleEmitter *[fMaxEmitters];
fEmitters = new plParticleEmitter *[fMaxEmitters];
int i;
for (i = 0; i < maxEmitters; i++)
fEmitters[i] = nil;
@ -125,7 +125,7 @@ void plParticleSystem::Init(UInt32 xTiles, UInt32 yTiles, UInt32 maxTotalParticl
fHeightCtl = heightCtl;
}
void plParticleSystem::IAddEffect(plParticleEffect *effect, UInt32 type)
void plParticleSystem::IAddEffect(plParticleEffect *effect, uint32_t type)
{
switch(type)
{
@ -147,7 +147,7 @@ plParticleEmitter* plParticleSystem::GetAvailEmitter()
if( !fNumValidEmitters ) // got to start with at least one.
return nil;
hsScalar minTTL = 1.e33;
float minTTL = 1.e33;
int iMinTTL = -1;
int i;
for( i = 0; i < fNumValidEmitters; i++ )
@ -164,7 +164,7 @@ plParticleEmitter* plParticleSystem::GetAvailEmitter()
{
minTTL = 0;
iMinTTL = fNumValidEmitters++;
fEmitters[iMinTTL] = TRACKED_NEW plParticleEmitter();
fEmitters[iMinTTL] = new plParticleEmitter();
fEmitters[iMinTTL]->Clone(fEmitters[0], iMinTTL);
fMaxTotalParticlesLeft -= fEmitters[iMinTTL]->fMaxParticles;
@ -177,11 +177,11 @@ plParticleEmitter* plParticleSystem::GetAvailEmitter()
return fEmitters[iMinTTL];
}
UInt32 plParticleSystem::AddEmitter(UInt32 maxParticles, plParticleGenerator *gen, UInt32 emitterFlags)
uint32_t plParticleSystem::AddEmitter(uint32_t maxParticles, plParticleGenerator *gen, uint32_t emitterFlags)
{
if (fMaxEmitters == 0) // silly rabbit, Trix are for kids!
return 0;
UInt32 currEmitter;
uint32_t currEmitter;
if (fNumValidEmitters == fMaxEmitters) // No more free spots, snag the next in line.
{
int i;
@ -207,7 +207,7 @@ UInt32 plParticleSystem::AddEmitter(UInt32 maxParticles, plParticleGenerator *ge
if (maxParticles < 0)
maxParticles = 0;
fEmitters[currEmitter] = TRACKED_NEW plParticleEmitter();
fEmitters[currEmitter] = new plParticleEmitter();
fEmitters[currEmitter]->Init(this, maxParticles, fNextEmitterToGo, emitterFlags, gen);
fMaxTotalParticlesLeft -= fEmitters[currEmitter]->fMaxParticles;
@ -216,9 +216,9 @@ UInt32 plParticleSystem::AddEmitter(UInt32 maxParticles, plParticleGenerator *ge
return maxParticles;
}
void plParticleSystem::AddParticle(hsPoint3 &pos, hsVector3 &velocity, UInt32 tileIndex,
hsScalar hSize, hsScalar vSize, hsScalar scale, hsScalar invMass, hsScalar life,
hsPoint3 &orientation, UInt32 miscFlags, hsScalar radsPerSec)
void plParticleSystem::AddParticle(hsPoint3 &pos, hsVector3 &velocity, uint32_t tileIndex,
float hSize, float vSize, float scale, float invMass, float life,
hsPoint3 &orientation, uint32_t miscFlags, float radsPerSec)
{
hsAssert(fNumValidEmitters > 0, "Trying to explicitly add particles to a system with no valid emitters.");
if (fNumValidEmitters == 0)
@ -227,7 +227,7 @@ void plParticleSystem::AddParticle(hsPoint3 &pos, hsVector3 &velocity, UInt32 ti
fEmitters[0]->AddParticle(pos, velocity, tileIndex, hSize, vSize, scale, invMass, life, orientation, miscFlags, radsPerSec);
}
void plParticleSystem::GenerateParticles(UInt32 num, hsScalar dt /* = 0.f */)
void plParticleSystem::GenerateParticles(uint32_t num, float dt /* = 0.f */)
{
if (num <= 0)
return;
@ -245,7 +245,7 @@ void plParticleSystem::WipeExistingParticles()
fEmitters[i]->WipeExistingParticles();
}
void plParticleSystem::KillParticles(hsScalar num, hsScalar timeToDie, UInt8 flags)
void plParticleSystem::KillParticles(float num, float timeToDie, uint8_t flags)
{
if (fEmitters[0])
fEmitters[0]->KillParticles(num, timeToDie, flags);
@ -267,14 +267,14 @@ void plParticleSystem::DisableGenerators()
fEmitters[i]->UpdateGenerator(plParticleUpdateMsg::kParamEnabled, 0.f);
}
UInt16 plParticleSystem::StealParticlesFrom(plParticleSystem *victim, UInt16 num)
uint16_t plParticleSystem::StealParticlesFrom(plParticleSystem *victim, uint16_t num)
{
if (fNumValidEmitters <= 0)
return 0; // you just lose
if (victim)
{
UInt16 numStolen = fEmitters[0]->StealParticlesFrom(victim->fNumValidEmitters > 0 ? victim->fEmitters[0] : nil, num);
uint16_t numStolen = fEmitters[0]->StealParticlesFrom(victim->fNumValidEmitters > 0 ? victim->fEmitters[0] : nil, num);
GetTarget(0)->DirtySynchState(kSDLParticleSystem, 0);
victim->GetTarget(0)->DirtySynchState(kSDLParticleSystem, 0);
return numStolen;
@ -288,7 +288,7 @@ plParticleGenerator *plParticleSystem::GetExportedGenerator() const
return (fNumValidEmitters > 0 ? fEmitters[0]->fGenerator : nil);
}
plParticleEffect *plParticleSystem::GetEffect(UInt16 type) const
plParticleEffect *plParticleSystem::GetEffect(uint16_t type) const
{
int i;
for (i = 0; i < fForces.GetCount(); i++)
@ -306,9 +306,9 @@ plParticleEffect *plParticleSystem::GetEffect(UInt16 type) const
return nil;
}
UInt32 plParticleSystem::GetNumValidParticles(hsBool immortalOnly /* = false */) const
uint32_t plParticleSystem::GetNumValidParticles(hsBool immortalOnly /* = false */) const
{
UInt32 count = 0;
uint32_t count = 0;
int i, j;
for (i = 0; i < fNumValidEmitters; i++)
{
@ -332,7 +332,7 @@ const hsMatrix44 &plParticleSystem::GetLocalToWorld() const
return fTarget->GetCoordinateInterface()->GetLocalToWorld();
}
hsBool plParticleSystem::IEval(double secs, hsScalar del, UInt32 dirty)
hsBool plParticleSystem::IEval(double secs, float del, uint32_t dirty)
{
return false;
}
@ -367,7 +367,7 @@ hsBool plParticleSystem::IShouldUpdate(plPipeline* pipe) const
// Now, are we visible?
hsBool isVisible = pipe->TestVisibleWorld(wBnd);
hsScalar delta = fLastTime > 0 ? hsScalar(fCurrTime - fLastTime) : hsTimer::GetDelSysSeconds();
float delta = fLastTime > 0 ? float(fCurrTime - fLastTime) : hsTimer::GetDelSysSeconds();
if( isVisible )
{
// If we know how fast the fastest particle is moving, then we can
@ -382,13 +382,13 @@ hsBool plParticleSystem::IShouldUpdate(plPipeline* pipe) const
// We're in view, but how close are we to the camera? Look at closest point.
hsPoint2 depth;
wBnd.TestPlane(pipe->GetViewDirWorld(), depth);
hsScalar eyeDist = pipe->GetViewDirWorld().InnerProduct(pipe->GetViewPositionWorld());
hsScalar dist = depth.fX - eyeDist;
float eyeDist = pipe->GetViewDirWorld().InnerProduct(pipe->GetViewPositionWorld());
float dist = depth.fX - eyeDist;
static hsScalar kUpdateCutoffDist = 100.f;
static float kUpdateCutoffDist = 100.f;
if( dist > kUpdateCutoffDist )
{
static hsScalar kDistantUpdateSecs = 0.1f;
static float kDistantUpdateSecs = 0.1f;
return delta >= kDistantUpdateSecs;
}
#endif // ALWAYS_IF_VISIBLE
@ -397,7 +397,7 @@ hsBool plParticleSystem::IShouldUpdate(plPipeline* pipe) const
}
static hsScalar kOffscreenUpdateSecs = 1.f;
static float kOffscreenUpdateSecs = 1.f;
return delta >= kOffscreenUpdateSecs;
}
@ -407,10 +407,10 @@ plDrawInterface* plParticleSystem::ICheckDrawInterface()
if( !di )
return nil;
if( di->GetDrawableMeshIndex(0) == UInt32(-1) )
if( di->GetDrawableMeshIndex(0) == uint32_t(-1) )
{
di->SetUpForParticleSystem( fMaxEmitters + 1, fMaxTotalParticles, fTexture, fPermaLights );
hsAssert(di->GetDrawableMeshIndex( 0 ) != (UInt32)-1, "SetUpForParticleSystem should never fail"); // still invalid, didn't fix it.
hsAssert(di->GetDrawableMeshIndex( 0 ) != (uint32_t)-1, "SetUpForParticleSystem should never fail"); // still invalid, didn't fix it.
}
return di;
@ -419,10 +419,10 @@ plDrawInterface* plParticleSystem::ICheckDrawInterface()
void plParticleSystem::IHandleRenderMsg(plPipeline* pipe)
{
fCurrTime = hsTimer::GetSysSeconds();
hsScalar delta = hsScalar(fCurrTime - fLastTime);
float delta = float(fCurrTime - fLastTime);
if (delta == 0)
return;
plConst(hsScalar) kMaxDelta(0.3f);
plConst(float) kMaxDelta(0.3f);
if( delta > kMaxDelta )
delta = kMaxDelta;
@ -536,7 +536,7 @@ hsBool plParticleSystem::MsgReceive(plMessage* msg)
return plModifier::MsgReceive(msg);
}
void plParticleSystem::UpdateGenerator(UInt32 paramID, hsScalar value)
void plParticleSystem::UpdateGenerator(uint32_t paramID, float value)
{
int i;
for (i = 0; i < fNumValidEmitters; i++)
@ -554,7 +554,7 @@ void plParticleSystem::AddTarget(plSceneObject *so)
plgDispatch::Dispatch()->RegisterForExactType(plAgeLoadedMsg::Index(), GetKey());
delete fParticleSDLMod;
fParticleSDLMod = TRACKED_NEW plParticleSDLMod;
fParticleSDLMod = new plParticleSDLMod;
fParticleSDLMod->SetAttachedToAvatar(fAttachedToAvatar);
so->AddModifier(fParticleSDLMod);
}
@ -585,7 +585,7 @@ void plParticleSystem::IPreSim()
double secs = fPreSim;
while (secs > 0)
{
fEmitters[i]->IUpdateParticles((hsScalar)PRESIM_UPDATE_TICK);
fEmitters[i]->IUpdateParticles((float)PRESIM_UPDATE_TICK);
secs -= PRESIM_UPDATE_TICK;
}
}
@ -593,15 +593,15 @@ void plParticleSystem::IPreSim()
fPreSim = 0;
}
void plParticleSystem::IReadEffectsArray(hsTArray<plParticleEffect *> &effects, UInt32 type, hsStream *s, hsResMgr *mgr)
void plParticleSystem::IReadEffectsArray(hsTArray<plParticleEffect *> &effects, uint32_t type, hsStream *s, hsResMgr *mgr)
{
plGenRefMsg *msg;
effects.Reset();
UInt32 count = s->ReadLE32();
uint32_t count = s->ReadLE32();
int i;
for (i = 0; i < count; i++)
{
msg = TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, (Int8)type);
msg = new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, (int8_t)type);
mgr->ReadKeyNotifyMe(s, msg, plRefFlags::kActiveRef);
}
}
@ -611,7 +611,7 @@ void plParticleSystem::Read(hsStream *s, hsResMgr *mgr)
plModifier::Read(s, mgr);
plGenRefMsg* msg;
msg = TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, 0); // Material
msg = new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, 0); // Material
mgr->ReadKeyNotifyMe(s, msg, plRefFlags::kActiveRef);
fAmbientCtl = plController::ConvertNoRef(mgr->ReadCreatable(s));
@ -620,10 +620,10 @@ void plParticleSystem::Read(hsStream *s, hsResMgr *mgr)
fWidthCtl = plController::ConvertNoRef(mgr->ReadCreatable(s));
fHeightCtl = plController::ConvertNoRef(mgr->ReadCreatable(s));
UInt32 xTiles = s->ReadLE32();
UInt32 yTiles = s->ReadLE32();
UInt32 maxTotal = s->ReadLE32();
UInt32 maxEmitters = s->ReadLE32();
uint32_t xTiles = s->ReadLE32();
uint32_t yTiles = s->ReadLE32();
uint32_t maxTotal = s->ReadLE32();
uint32_t maxEmitters = s->ReadLE32();
Init(xTiles, yTiles, maxTotal, maxEmitters, fAmbientCtl, fDiffuseCtl, fOpacityCtl, fWidthCtl, fHeightCtl);
fPreSim = s->ReadLEScalar();

View File

@ -72,25 +72,25 @@ class plParticleSystem : public plModifier
friend class plSimpleParticleGenerator;
protected:
static const hsScalar GRAVITY_ACCEL_FEET_PER_SEC2;
static const float GRAVITY_ACCEL_FEET_PER_SEC2;
plSceneObject *fTarget;
hsGMaterial *fTexture; // One texture per system (Tiling is your friend!)
UInt32 fXTiles, fYTiles; // Width/height of the texture (in tiles) for determining a particle's UVs
uint32_t fXTiles, fYTiles; // Width/height of the texture (in tiles) for determining a particle's UVs
double fCurrTime;
double fLastTime;
hsVector3 fAccel;
hsScalar fPreSim;
hsScalar fDrag;
hsScalar fWindMult;
float fPreSim;
float fDrag;
float fWindMult;
bool fAttachedToAvatar;
UInt32 fMaxTotalParticles;
UInt32 fMaxTotalParticlesLeft;
UInt32 fNumValidEmitters;
UInt32 fMaxEmitters;
UInt32 fNextEmitterToGo;
uint32_t fMaxTotalParticles;
uint32_t fMaxTotalParticlesLeft;
uint32_t fNumValidEmitters;
uint32_t fMaxEmitters;
uint32_t fNextEmitterToGo;
plParticleEmitter **fEmitters; // Various locations we're emitting particles from (the first one is
// reserved for particles added explicitly (to keep all the bookkeeping
@ -113,17 +113,17 @@ protected:
plParticleSDLMod *fParticleSDLMod;
hsBool IShouldUpdate(plPipeline* pipe) const;
virtual hsBool IEval(double secs, hsScalar del, UInt32 dirty); // required by plModifier
virtual hsBool IEval(double secs, float del, uint32_t dirty); // required by plModifier
void IHandleRenderMsg(plPipeline* pipe);
plDrawInterface* ICheckDrawInterface();
void IAddEffect(plParticleEffect *effect, UInt32 type);
void IReadEffectsArray(hsTArray<plParticleEffect *> &effects, UInt32 type, hsStream *s, hsResMgr *mgr);
void IAddEffect(plParticleEffect *effect, uint32_t type);
void IReadEffectsArray(hsTArray<plParticleEffect *> &effects, uint32_t type, hsStream *s, hsResMgr *mgr);
void IPreSim();
public:
plParticleSystem();
virtual ~plParticleSystem();
void Init(UInt32 xTiles, UInt32 yTiles, UInt32 maxTotalParticles, UInt32 numEmitters,
void Init(uint32_t xTiles, uint32_t yTiles, uint32_t maxTotalParticles, uint32_t numEmitters,
plController *ambientCtl, plController *diffuseCtl, plController *opacityCtl,
plController *widthCtl, plController *heightCtl);
@ -138,11 +138,11 @@ public:
{
kParticleSystemAlwaysUpdate = 0x1
};
UInt8 fMiscFlags; // Not read/written (could be, but it's not needed yet.)
uint8_t fMiscFlags; // Not read/written (could be, but it's not needed yet.)
// There might not be enough particles available. this function returns the number of maxParticles that
// the emitter actually received.
UInt32 AddEmitter(UInt32 maxParticles, plParticleGenerator *gen, UInt32 emitterFlags);
uint32_t AddEmitter(uint32_t maxParticles, plParticleGenerator *gen, uint32_t emitterFlags);
plParticleEmitter* GetAvailEmitter();
@ -151,34 +151,34 @@ public:
// These are just public wrappers to the equivalent plParticleEmitter functions, provided for the purpose
// of adding particles to a system explicitly.
void AddParticle(hsPoint3 &pos, hsVector3 &velocity, UInt32 tileIndex,
hsScalar hSize, hsScalar vSize, hsScalar scale, hsScalar invMass, hsScalar life,
hsPoint3 &orientation, UInt32 miscFlags, hsScalar radsPerSec=0.f);
void GenerateParticles(UInt32 num, hsScalar dt = 0.f);
void AddParticle(hsPoint3 &pos, hsVector3 &velocity, uint32_t tileIndex,
float hSize, float vSize, float scale, float invMass, float life,
hsPoint3 &orientation, uint32_t miscFlags, float radsPerSec=0.f);
void GenerateParticles(uint32_t num, float dt = 0.f);
void WipeExistingParticles(); // Instant nuke
void KillParticles(hsScalar num, hsScalar timeToDie, UInt8 flags); // Sets a death timer. They'll get removed on the next update (if time has run out)
UInt16 StealParticlesFrom(plParticleSystem *victim, UInt16 num); // Returns the number of particles actually stolen
void KillParticles(float num, float timeToDie, uint8_t flags); // Sets a death timer. They'll get removed on the next update (if time has run out)
uint16_t StealParticlesFrom(plParticleSystem *victim, uint16_t num); // Returns the number of particles actually stolen
void TranslateAllParticles(hsPoint3 &amount); // Used to recenter the system when linking between ages.
void DisableGenerators();
UInt32 GetNumTiles() const { return fXTiles * fYTiles; }
void SetTileIndex(plParticle &particle, UInt32 index); // Sets the UV coordinates appropriate for the current texture
UInt32 GetNumValidParticles(hsBool immortalOnly = false) const; // Takes a bit longer if we want a count of immortal particles...
UInt32 GetMaxTotalParticles() const { return fMaxTotalParticles; }
uint32_t GetNumTiles() const { return fXTiles * fYTiles; }
void SetTileIndex(plParticle &particle, uint32_t index); // Sets the UV coordinates appropriate for the current texture
uint32_t GetNumValidParticles(hsBool immortalOnly = false) const; // Takes a bit longer if we want a count of immortal particles...
uint32_t GetMaxTotalParticles() const { return fMaxTotalParticles; }
const hsMatrix44 &GetLocalToWorld() const;
void SetAccel(const hsVector3& a) { fAccel = GRAVITY_ACCEL_FEET_PER_SEC2 * a; }
void SetGravity(hsScalar pct) { fAccel.Set(0, 0, -GRAVITY_ACCEL_FEET_PER_SEC2 * pct); }
void SetDrag(hsScalar d) { fDrag = -d; }
void SetWindMult(hsScalar m) { fWindMult = m; }
void SetPreSim(hsScalar time) { fPreSim = time; }
void UpdateGenerator(UInt32 paramID, hsScalar value);
void SetGravity(float pct) { fAccel.Set(0, 0, -GRAVITY_ACCEL_FEET_PER_SEC2 * pct); }
void SetDrag(float d) { fDrag = -d; }
void SetWindMult(float m) { fWindMult = m; }
void SetPreSim(float time) { fPreSim = time; }
void UpdateGenerator(uint32_t paramID, float value);
plParticleGenerator *GetExportedGenerator() const;
const hsVector3& GetAccel() const { return fAccel; }
hsScalar GetDrag() const { return fDrag; }
hsScalar GetWindMult() const { return fWindMult; }
plParticleEffect *GetEffect(UInt16 type) const;
float GetDrag() const { return fDrag; }
float GetWindMult() const { return fWindMult; }
plParticleEffect *GetEffect(uint16_t type) const;
plParticleSDLMod* GetSDLMod() {return fParticleSDLMod;}
// Functions related to/required by plModifier