mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
consolidate addfieldV method contents to avoid duplication
report *what* field is an invalid console type prune down floating point fuzzed validators to 0 default the visual fidelity to POINT_EPSILON (0.0001) rather than 1/FLT_MAX use the bit(bitcount) macro for legibility fix breakangle
This commit is contained in:
parent
47ec0cf0e1
commit
44b0d896b8
|
|
@ -138,11 +138,11 @@ ParticleData::ParticleData()
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
FRangeValidator dragCoefFValidator(0.f, 5.f);
|
||||
FRangeValidator gravCoefFValidator(-10.f, 10.f);
|
||||
FRangeValidator spinRandFValidator(-1000.f, 1000.f);
|
||||
FRangeValidator particleTimeFValidator(0.0f, 1.0f, 1<<8);
|
||||
FRangeValidator particleSizeFValidator(0.0f, MaxParticleSize, 1<<16);
|
||||
FRangeValidator dragCoefFValidator(0.f, 5.f, BIT(10));
|
||||
FRangeValidator gravCoefFValidator(-10.f, 10.f, BIT(12));
|
||||
FRangeValidator spinRandFValidator(-1000.f, 1000.f, BIT(11));
|
||||
FRangeValidator particleTimeFValidator(0.0f, 1.0f, BIT(8));
|
||||
FRangeValidator particleSizeFValidator(0.0f, MaxParticleSize, BIT(16));
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// initPersistFields
|
||||
|
|
|
|||
|
|
@ -507,6 +507,8 @@ void ConsoleObject::addField(const char* in_pFieldname,
|
|||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, avar("ConsoleObject::addProtectedField[%s] - invalid console type", in_pFieldname));
|
||||
|
||||
if (in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
|
|
@ -522,8 +524,6 @@ void ConsoleObject::addField(const char* in_pFieldname,
|
|||
f.writeDataFn = in_writeDataFn;
|
||||
f.networkMask = 0;
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, "ConsoleObject::addField - invalid console type");
|
||||
f.table = conType->getEnumTable();
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
|
|
@ -602,6 +602,8 @@ void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
|||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, avar("ConsoleObject::addProtectedField[%s] - invalid console type", in_pFieldname));
|
||||
|
||||
if (in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
|
|
@ -616,9 +618,6 @@ void ConsoleObject::addProtectedField(const char* in_pFieldname,
|
|||
f.getDataFn = in_getDataFn;
|
||||
f.writeDataFn = in_writeDataFn;
|
||||
f.networkMask = 0;
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, "ConsoleObject::addProtectedField - invalid console type");
|
||||
f.table = conType->getEnumTable();
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
|
|
@ -637,6 +636,8 @@ void ConsoleObject::addProtectedFieldV(const char* in_pFieldname,
|
|||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, avar("ConsoleObject::addProtectedField[%s] - invalid console type", in_pFieldname));
|
||||
|
||||
if (in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
|
|
@ -652,10 +653,7 @@ void ConsoleObject::addProtectedFieldV(const char* in_pFieldname,
|
|||
f.writeDataFn = in_writeDataFn;
|
||||
f.networkMask = 0;
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, "ConsoleObject::addProtectedField - invalid console type");
|
||||
f.table = conType->getEnumTable();
|
||||
|
||||
v->fieldIndex = sg_tempFieldList.size();
|
||||
sg_tempFieldList.push_back(f);
|
||||
}
|
||||
|
||||
|
|
@ -704,30 +702,6 @@ void ConsoleObject::addProtectedFieldV(const char* in_pFieldname,
|
|||
flags);
|
||||
}
|
||||
|
||||
void ConsoleObject::addFieldV(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
TypeValidator *v,
|
||||
const char* in_pFieldDocs)
|
||||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
if(in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
f.type = in_fieldType;
|
||||
f.offset = in_fieldOffset;
|
||||
f.elementCount = 1;
|
||||
f.table = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
f.writeDataFn = &defaultProtectedWriteFn;
|
||||
f.validator = v;
|
||||
f.networkMask = 0;
|
||||
v->fieldIndex = sg_tempFieldList.size();
|
||||
|
||||
sg_tempFieldList.push_back(f);
|
||||
}
|
||||
|
||||
void ConsoleObject::addFieldV(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
|
|
@ -737,11 +711,12 @@ void ConsoleObject::addFieldV(const char* in_pFieldname,
|
|||
{
|
||||
AbstractClassRep::Field f;
|
||||
f.pFieldname = StringTable->insert(in_pFieldname);
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(in_fieldType);
|
||||
AssertFatal(conType, avar("ConsoleObject::addProtectedField[%s] - invalid console type", in_pFieldname));
|
||||
if (in_pFieldDocs)
|
||||
f.pFieldDocs = in_pFieldDocs;
|
||||
f.type = in_fieldType;
|
||||
f.offset = in_fieldOffset;
|
||||
f.elementCount = 1;
|
||||
f.table = NULL;
|
||||
f.setDataFn = &defaultProtectedSetFn;
|
||||
f.getDataFn = &defaultProtectedGetFn;
|
||||
|
|
@ -754,6 +729,19 @@ void ConsoleObject::addFieldV(const char* in_pFieldname,
|
|||
sg_tempFieldList.push_back(f);
|
||||
}
|
||||
|
||||
void ConsoleObject::addFieldV(const char* in_pFieldname,
|
||||
const U32 in_fieldType,
|
||||
const dsize_t in_fieldOffset,
|
||||
TypeValidator* v,
|
||||
const char* in_pFieldDocs)
|
||||
{
|
||||
addFieldV(in_pFieldname,
|
||||
in_fieldType,
|
||||
in_fieldOffset,
|
||||
v,
|
||||
1,
|
||||
in_pFieldDocs);
|
||||
}
|
||||
void ConsoleObject::addDeprecatedField(const char *fieldName)
|
||||
{
|
||||
AbstractClassRep::Field f;
|
||||
|
|
|
|||
|
|
@ -100,15 +100,15 @@ void Point3NormalizeValidator::validateType(SimObject *object, void *typePtr)
|
|||
|
||||
namespace CommonValidators
|
||||
{
|
||||
FRangeValidator F32Range(F32_MIN, F32_MAX, F32_MAX);
|
||||
FRangeValidator DirFloat(-1.0f, 1.0f);
|
||||
FRangeValidator NegDefaultF32(-1.0f, F32_MAX, F32_MAX);
|
||||
FRangeValidator PositiveFloat(0.0f, F32_MAX, F32_MAX);
|
||||
FRangeValidator PositiveNonZeroFloat((F32)POINT_EPSILON, F32_MAX);
|
||||
FRangeValidator F32Range(F32_MIN, F32_MAX, 1 / POINT_EPSILON);
|
||||
FRangeValidator DirFloat(-1.0f, 1.0f, 1 / POINT_EPSILON);
|
||||
FRangeValidator NegDefaultF32(-1.0f, F32_MAX, 1 / POINT_EPSILON);
|
||||
FRangeValidator PositiveFloat(0.0f, F32_MAX, 1 / POINT_EPSILON);
|
||||
FRangeValidator PositiveNonZeroFloat((F32)POINT_EPSILON, F32_MAX, 1 / POINT_EPSILON);
|
||||
FRangeValidator NormalizedFloat(0.0f, 1.0f);
|
||||
|
||||
FRangeValidator F32_8BitPercent(0.0f, 1.0f, 1 << 8);
|
||||
FRangeValidator F32_16BitPercent(0.0f, 1.0f, 1 << 16);
|
||||
FRangeValidator F32_8BitPercent(0.0f, 1.0f, BIT(8));
|
||||
FRangeValidator F32_16BitPercent(0.0f, 1.0f, BIT(16));
|
||||
FRangeValidator ValidSlopeAngle(0.0f, 89.9f, 89.9f);
|
||||
FRangeValidator CornerAngle(0.0f, 90.0f, 90.0f);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
#ifndef _TYPEVALIDATORS_H_
|
||||
#define _TYPEVALIDATORS_H_
|
||||
|
||||
#ifndef _MMATHFN_H_
|
||||
#include "math/mMathFn.h"
|
||||
#endif
|
||||
|
||||
class TypeValidator
|
||||
{
|
||||
public:
|
||||
|
|
@ -50,8 +54,8 @@ class FRangeValidator : public TypeValidator
|
|||
public:
|
||||
FRangeValidator(F32 minValue, F32 maxValue, F32 fidelity = 0.0f)
|
||||
{
|
||||
minV = minValue;
|
||||
maxV = maxValue;
|
||||
minV = mFabs(minValue) > F32_MIN ? minValue : 0.0f;
|
||||
maxV = mFabs(maxValue) > F32_MIN ? maxValue : 0.0f;
|
||||
mFidelity = fidelity;
|
||||
}
|
||||
void validateType(SimObject *object, void *typePtr) override;
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ void DecalRoad::initPersistFields()
|
|||
addProtectedFieldV("textureLength", TypeRangedF32, Offset(mTextureLength, DecalRoad), &DecalRoad::ptSetTextureLength, &defaultProtectedGetFn, &drTextureLengthV,
|
||||
"The length in meters of textures mapped to the DecalRoad" );
|
||||
|
||||
addProtectedFieldV( "breakAngle", TypeF32, Offset( mBreakAngle, DecalRoad ), &DecalRoad::ptSetBreakAngle, &defaultProtectedGetFn, &CommonValidators::PosDegreeRange,
|
||||
addProtectedFieldV( "breakAngle", TypeRangedF32, Offset( mBreakAngle, DecalRoad ), &DecalRoad::ptSetBreakAngle, &defaultProtectedGetFn, &CommonValidators::PosDegreeRange,
|
||||
"Angle in degrees - DecalRoad will subdivided the spline if its curve is greater than this threshold." );
|
||||
|
||||
addField( "renderPriority", TypeS32, Offset( mRenderPriority, DecalRoad ),
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ void SFXDescription::initPersistFields()
|
|||
"Reverb echo depth.");
|
||||
addFieldV("reverbModTime", TypeRangedF32, Offset(mReverb.flModulationTime, SFXDescription), &CommonValidators::PositiveFloat,
|
||||
"Reverb Modulation time.");
|
||||
addFieldV("reverbModDepth", TypeRangedF32, Offset(mReverb.flModulationDepth, SFXDescription), &CommonValidators::PositiveFloat,
|
||||
addFieldV("reverbModDepth", TypeRangedF32, Offset(mReverb.flModulationDepth, SFXDescription), &CommonValidators::NormalizedFloat,
|
||||
"Reverb Modulation Depth.");
|
||||
addFieldV("airAbsorbtionGainHF", TypeRangedF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription), &CommonValidators::PositiveFloat,
|
||||
"High Frequency air absorbtion");
|
||||
|
|
|
|||
Loading…
Reference in a new issue