diff --git a/Engine/source/T3D/fx/particle.cpp b/Engine/source/T3D/fx/particle.cpp index 2e331fb7f..ca8ead21f 100644 --- a/Engine/source/T3D/fx/particle.cpp +++ b/Engine/source/T3D/fx/particle.cpp @@ -149,10 +149,10 @@ void ParticleData::initPersistFields() "Variance in lifetime of particle, from 0 - lifetimeMS." ); addField( "spinSpeed", TYPEID< F32 >(), Offset(spinSpeed, ParticleData), "Speed at which to spin the particle." ); - addField( "spinRandomMin", TYPEID< F32 >(), Offset(spinRandomMin, ParticleData), - "Minimum allowed spin speed of this particle, between -10000 and spinRandomMax." ); - addField( "spinRandomMax", TYPEID< F32 >(), Offset(spinRandomMax, ParticleData), - "Maximum allowed spin speed of this particle, between spinRandomMin and 10000." ); + addFieldV( "spinRandomMin", TYPEID< F32 >(), Offset(spinRandomMin, ParticleData), new FRangeValidator(-1000.f, 1000.f), + "Minimum allowed spin speed of this particle, between -1000 and spinRandomMax." ); + addFieldV( "spinRandomMax", TYPEID< F32 >(), Offset(spinRandomMax, ParticleData), new FRangeValidator(-1000.f, 1000.f), + "Maximum allowed spin speed of this particle, between spinRandomMin and 1000." ); addField( "useInvAlpha", TYPEID< bool >(), Offset(useInvAlpha, ParticleData), "@brief Controls how particles blend with the scene.\n\n" "If true, particles blend like ParticleBlendStyle NORMAL, if false, " @@ -200,7 +200,8 @@ void ParticleData::initPersistFields() "@brief Particle RGBA color keyframe values.\n\n" "The particle color will linearly interpolate between the color/time keys " "over the lifetime of the particle." ); - addField( "sizes", TYPEID< F32 >(), Offset(sizes, ParticleData), PDC_NUM_KEYS, + addProtectedField( "sizes", TYPEID< F32 >(), Offset(sizes, ParticleData), &protectedSetSizes, + &defaultProtectedGetFn, PDC_NUM_KEYS, "@brief Particle size keyframe values.\n\n" "The particle size will linearly interpolate between the size/time keys " "over the lifetime of the particle." ); @@ -343,6 +344,22 @@ void ParticleData::unpackData(BitStream* stream) } } +bool ParticleData::protectedSetSizes( void *object, const char *index, const char *data) +{ + ParticleData *pData = static_cast( object ); + F32 val = dAtof(data); + U32 i; + + if (!index) + i = 0; + else + i = dAtoui(index); + + pData->sizes[i] = mClampF( val, 0.f, MaxParticleSize ); + + return false; +} + bool ParticleData::protectedSetTimes( void *object, const char *index, const char *data) { ParticleData *pData = static_cast( object ); @@ -356,7 +373,7 @@ bool ParticleData::protectedSetTimes( void *object, const char *index, const cha pData->times[i] = mClampF( val, 0.f, 1.f ); - return true; + return false; } //----------------------------------------------------------------------------- @@ -379,11 +396,11 @@ bool ParticleData::onAdd() Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) lifetimeVariance >= lifetime", getName()); lifetimeVarianceMS = lifetimeMS - 1; } - if (spinSpeed > 10000.0 || spinSpeed < -10000.0) { + if (spinSpeed > 1000.f || spinSpeed < -1000.f) { Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinSpeed invalid", getName()); return false; } - if (spinRandomMin > 10000.0 || spinRandomMin < -10000.0) { + if (spinRandomMin > 1000.f || spinRandomMin < -1000.f) { Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinRandomMin invalid", getName()); spinRandomMin = -360.0; return false; @@ -393,7 +410,7 @@ bool ParticleData::onAdd() spinRandomMin = spinRandomMax - (spinRandomMin - spinRandomMax ); return false; } - if (spinRandomMax > 10000.0 || spinRandomMax < -10000.0) { + if (spinRandomMax > 1000.f || spinRandomMax < -1000.f) { Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinRandomMax invalid", getName()); spinRandomMax = 360.0; return false; diff --git a/Engine/source/T3D/fx/particle.h b/Engine/source/T3D/fx/particle.h index 3f1b7ff26..14db8c096 100644 --- a/Engine/source/T3D/fx/particle.h +++ b/Engine/source/T3D/fx/particle.h @@ -79,6 +79,7 @@ class ParticleData : public SimDataBlock StringTableEntry textureName; GFXTexHandle textureHandle; + static bool protectedSetSizes( void *object, const char *index, const char *data ); static bool protectedSetTimes( void *object, const char *index, const char *data ); public: