fill in the validated variables

This commit is contained in:
AzaezelX 2025-03-09 11:53:23 -05:00
parent fa760fa746
commit f633ef3a3d
184 changed files with 1359 additions and 1216 deletions

View file

@ -384,7 +384,11 @@ ExplosionData* ExplosionData::cloneAndPerformSubstitutions(const SimObject* owne
return sub_explosion_db;
}
IRangeValidator expPartDensityRange(0, 1<<14);
IRangeValidator expDebrisNumRange(0, 1000);
FRangeValidator expPlaySpeedRange(0.05f, FLT_MAX);
FRangeValidator expLightRadiusRange(0.0f, MaxLightRadius,1<<8);
FRangeValidator expTimeRange(0.0f, 1.0f, 1 << 8);
void ExplosionData::initPersistFields()
{
docsURL;
@ -409,10 +413,10 @@ void ExplosionData::initPersistFields()
"The second effect spawns the list of ParticleEmitters given by the emitter[] "
"field. These emitters generate particles in the normal way throughout the "
"lifetime of the explosion." );
addField( "particleDensity", TypeS32, Offset(particleDensity, ExplosionData),
addFieldV( "particleDensity", TypeRangedS32, Offset(particleDensity, ExplosionData), &expPartDensityRange,
"@brief Density of the particle cloud created at the start of the explosion.\n\n"
"@see particleEmitter" );
addField( "particleRadius", TypeF32, Offset(particleRadius, ExplosionData),
addFieldV( "particleRadius", TypeRangedF32, Offset(particleRadius, ExplosionData),&CommonValidators::PositiveFloat,
"@brief Radial distance from the explosion center at which cloud particles "
"are emitted.\n\n"
"@see particleEmitter" );
@ -425,21 +429,21 @@ void ExplosionData::initPersistFields()
addGroup("Debris");
addField( "debris", TYPEID< DebrisData >(), Offset(debrisList, ExplosionData), EC_NUM_DEBRIS_TYPES,
"List of DebrisData objects to spawn with this explosion." );
addField( "debrisThetaMin", TypeF32, Offset(debrisThetaMin, ExplosionData),
addFieldV( "debrisThetaMin", TypeRangedF32, Offset(debrisThetaMin, ExplosionData), &CommonValidators::PosDegreeRangeHalf,
"Minimum angle, from the horizontal plane, to eject debris from." );
addField( "debrisThetaMax", TypeF32, Offset(debrisThetaMax, ExplosionData),
addFieldV( "debrisThetaMax", TypeRangedF32, Offset(debrisThetaMax, ExplosionData), &CommonValidators::PosDegreeRangeHalf,
"Maximum angle, from the horizontal plane, to eject debris from." );
addField( "debrisPhiMin", TypeF32, Offset(debrisPhiMin, ExplosionData),
addFieldV( "debrisPhiMin", TypeRangedF32, Offset(debrisPhiMin, ExplosionData), &CommonValidators::PosDegreeRange,
"Minimum reference angle, from the vertical plane, to eject debris from." );
addField( "debrisPhiMax", TypeF32, Offset(debrisPhiMax, ExplosionData),
addFieldV( "debrisPhiMax", TypeRangedF32, Offset(debrisPhiMax, ExplosionData), &CommonValidators::PosDegreeRange,
"Maximum reference angle, from the vertical plane, to eject debris from." );
addField( "debrisNum", TypeS32, Offset(debrisNum, ExplosionData),
addFieldV( "debrisNum", TypeRangedS32, Offset(debrisNum, ExplosionData), &expDebrisNumRange,
"Number of debris objects to create." );
addField( "debrisNumVariance", TypeS32, Offset(debrisNumVariance, ExplosionData),
addFieldV( "debrisNumVariance", TypeRangedS32, Offset(debrisNumVariance, ExplosionData), &expDebrisNumRange,
"Variance in the number of debris objects to create (must be from 0 - debrisNum)." );
addField( "debrisVelocity", TypeF32, Offset(debrisVelocity, ExplosionData),
addFieldV( "debrisVelocity", TypeRangedF32, Offset(debrisVelocity, ExplosionData), &CommonValidators::PositiveFloat,
"Velocity to toss debris at." );
addField( "debrisVelocityVariance", TypeF32, Offset(debrisVelocityVariance, ExplosionData),
addFieldV( "debrisVelocityVariance", TypeRangedF32, Offset(debrisVelocityVariance, ExplosionData), &CommonValidators::PositiveFloat,
"Variance in the debris initial velocity (must be >= 0)." );
addField( "subExplosion", TYPEID< ExplosionData >(), Offset(explosionList, ExplosionData), EC_MAX_SUB_EXPLOSIONS,
"List of additional ExplosionData objects to create at the start of the explosion." );
@ -450,27 +454,27 @@ void ExplosionData::initPersistFields()
addField("explosionScale", TypePoint3F, Offset(explosionScale, ExplosionData),
"\"X Y Z\" scale factor applied to the explosionShape model at the start "
"of the explosion.");
addField("playSpeed", TypeF32, Offset(playSpeed, ExplosionData),
addFieldV("playSpeed", TypeRangedF32, Offset(playSpeed, ExplosionData),&expPlaySpeedRange,
"Time scale at which to play the explosionShape <i>ambient</i> sequence.");
addField( "delayMS", TypeS32, Offset(delayMS, ExplosionData),
addFieldV( "delayMS", TypeRangedS32, Offset(delayMS, ExplosionData), &CommonValidators::PositiveInt,
"Amount of time, in milliseconds, to delay the start of the explosion effect "
"from the creation of the Explosion object." );
addField( "delayVariance", TypeS32, Offset(delayVariance, ExplosionData),
addFieldV( "delayVariance", TypeRangedS32, Offset(delayVariance, ExplosionData), &CommonValidators::PositiveInt,
"Variance, in milliseconds, of delayMS." );
addField( "lifetimeMS", TypeS32, Offset(lifetimeMS, ExplosionData),
addFieldV( "lifetimeMS", TypeRangedS32, Offset(lifetimeMS, ExplosionData), &CommonValidators::PositiveInt,
"@brief Lifetime, in milliseconds, of the Explosion object.\n\n"
"@note If explosionShape is defined and contains an <i>ambient</i> animation, "
"this field is ignored, and the playSpeed scaled duration of the animation "
"is used instead." );
addField( "lifetimeVariance", TypeS32, Offset(lifetimeVariance, ExplosionData),
addFieldV( "lifetimeVariance", TypeRangedS32, Offset(lifetimeVariance, ExplosionData), &CommonValidators::PositiveInt,
"Variance, in milliseconds, of the lifetimeMS of the Explosion object.\n" );
addField( "offset", TypeF32, Offset(offset, ExplosionData),
addFieldV( "offset", TypeRangedF32, Offset(offset, ExplosionData), &CommonValidators::PositiveFloat,
"@brief Offset distance (in a random direction) of the center of the explosion "
"from the Explosion object position.\n\n"
"Most often used to create some variance in position for subExplosion effects." );
addField( "times", TypeF32, Offset(times, ExplosionData), EC_NUM_TIME_KEYS,
addFieldV( "times", TypeRangedF32, Offset(times, ExplosionData), &expTimeRange, EC_NUM_TIME_KEYS,
"@brief Time keyframes used to scale the explosionShape model.\n\n"
"Values should be in increasing order from 0.0 - 1.0, and correspond to "
"the life of the Explosion where 0 is the beginning and 1 is the end of "
@ -491,22 +495,22 @@ void ExplosionData::initPersistFields()
addField( "camShakeAmp", TypePoint3F, Offset(camShakeAmp, ExplosionData),
"@brief Amplitude of camera shaking, defined in the \"X Y Z\" axes.\n\n"
"Set any value to 0 to disable shaking in that axis." );
addField( "camShakeDuration", TypeF32, Offset(camShakeDuration, ExplosionData),
addFieldV( "camShakeDuration", TypeRangedF32, Offset(camShakeDuration, ExplosionData), &CommonValidators::PositiveFloat,
"Duration (in seconds) to shake the camera." );
addField( "camShakeRadius", TypeF32, Offset(camShakeRadius, ExplosionData),
addFieldV( "camShakeRadius", TypeRangedF32, Offset(camShakeRadius, ExplosionData), &CommonValidators::PositiveFloat,
"Radial distance that a camera's position must be within relative to the "
"center of the explosion to be shaken." );
addField( "camShakeFalloff", TypeF32, Offset(camShakeFalloff, ExplosionData),
addFieldV( "camShakeFalloff", TypeRangedF32, Offset(camShakeFalloff, ExplosionData), &CommonValidators::PositiveFloat,
"Falloff value for the camera shake." );
endGroup("Camera Shake");
addGroup("Light Emitter");
addField( "lightStartRadius", TypeF32, Offset(lightStartRadius, ExplosionData),
addFieldV( "lightStartRadius", TypeRangedF32, Offset(lightStartRadius, ExplosionData), &expLightRadiusRange,
"@brief Initial radius of the PointLight created by this explosion.\n\n"
"Radius is linearly interpolated from lightStartRadius to lightEndRadius "
"over the lifetime of the explosion.\n"
"@see lifetimeMS" );
addField( "lightEndRadius", TypeF32, Offset(lightEndRadius, ExplosionData),
addFieldV( "lightEndRadius", TypeRangedF32, Offset(lightEndRadius, ExplosionData), &expLightRadiusRange,
"@brief Final radius of the PointLight created by this explosion.\n\n"
"@see lightStartRadius" );
addField( "lightStartColor", TypeColorF, Offset(lightStartColor, ExplosionData),
@ -517,15 +521,15 @@ void ExplosionData::initPersistFields()
addField( "lightEndColor", TypeColorF, Offset(lightEndColor, ExplosionData),
"@brief Final color of the PointLight created by this explosion.\n\n"
"@see lightStartColor" );
addField( "lightStartBrightness", TypeF32, Offset(lightStartBrightness, ExplosionData),
addFieldV( "lightStartBrightness", TypeRangedF32, Offset(lightStartBrightness, ExplosionData), &expLightRadiusRange,
"@brief Initial brightness of the PointLight created by this explosion.\n\n"
"Brightness is linearly interpolated from lightStartBrightness to "
"lightEndBrightness over the lifetime of the explosion.\n"
"@see lifetimeMS" );
addField("lightEndBrightness", TypeF32, Offset(lightEndBrightness, ExplosionData),
addFieldV("lightEndBrightness", TypeRangedF32, Offset(lightEndBrightness, ExplosionData), &expLightRadiusRange,
"@brief Final brightness of the PointLight created by this explosion.\n\n"
"@see lightStartBrightness" );
addField( "lightNormalOffset", TypeF32, Offset(lightNormalOffset, ExplosionData),
addFieldV( "lightNormalOffset", TypeRangedF32, Offset(lightNormalOffset, ExplosionData), &CommonValidators::PositiveFloat,
"Distance (in the explosion normal direction) of the PointLight position "
"from the explosion center." );
endGroup("Light Emitter");
@ -754,12 +758,12 @@ void ExplosionData::packData(BitStream* stream)
// Dynamic light info
stream->writeFloat(lightStartRadius/MaxLightRadius, 8);
stream->writeFloat(lightEndRadius/MaxLightRadius, 8);
stream->writeFloat(lightStartColor.red,7);
stream->writeFloat(lightStartColor.green,7);
stream->writeFloat(lightStartColor.blue,7);
stream->writeFloat(lightEndColor.red,7);
stream->writeFloat(lightEndColor.green,7);
stream->writeFloat(lightEndColor.blue,7);
stream->writeFloat(lightStartColor.red,8);
stream->writeFloat(lightStartColor.green,8);
stream->writeFloat(lightStartColor.blue,8);
stream->writeFloat(lightEndColor.red,8);
stream->writeFloat(lightEndColor.green,8);
stream->writeFloat(lightEndColor.blue,8);
stream->writeFloat(lightStartBrightness/MaxLightRadius, 8);
stream->writeFloat(lightEndBrightness/MaxLightRadius, 8);
stream->write(lightNormalOffset);
@ -858,12 +862,12 @@ void ExplosionData::unpackData(BitStream* stream)
//
lightStartRadius = stream->readFloat(8) * MaxLightRadius;
lightEndRadius = stream->readFloat(8) * MaxLightRadius;
lightStartColor.red = stream->readFloat(7);
lightStartColor.green = stream->readFloat(7);
lightStartColor.blue = stream->readFloat(7);
lightEndColor.red = stream->readFloat(7);
lightEndColor.green = stream->readFloat(7);
lightEndColor.blue = stream->readFloat(7);
lightStartColor.red = stream->readFloat(8);
lightStartColor.green = stream->readFloat(8);
lightStartColor.blue = stream->readFloat(8);
lightEndColor.red = stream->readFloat(8);
lightEndColor.green = stream->readFloat(8);
lightEndColor.blue = stream->readFloat(8);
lightStartBrightness = stream->readFloat(8) * MaxLightRadius;
lightEndBrightness = stream->readFloat(8) * MaxLightRadius;
stream->read( &lightNormalOffset );