Merge branch 'TorqueGameEngines:development' into gametsctrl-mouserefactor

This commit is contained in:
Olathuss 2025-03-08 12:02:08 -07:00 committed by GitHub
commit 7cdfe63233
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 194 additions and 144 deletions

View file

@ -214,17 +214,62 @@ class BitfieldConsoleBaseType : public ConsoleBaseType
public:
const char* getData( void* dptr, const EnumTable*, BitSet32 ) override
const char* getData(void* dptr, const EnumTable* tbl, BitSet32) override
{
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%i", *((S32 *) dptr) );
return returnBuffer;
BitSet32 dptrVal = BitSet32(*(U32*)dptr);
String returnBuffer;
if (!tbl) tbl = getEnumTable();
const U32 numEnums = tbl->getNumValues();
bool first = true;
if (dptrVal.testStrict(-1)) //test for all
{
return Con::getReturnBuffer("-1");
}
else if (!dptrVal.test(-1)) //test for none
{
return Con::getReturnBuffer("0");
}
for (U32 i = 0; i < numEnums; i++)
{
if (dptrVal.test(BIT(i)))
{
if (first)
{
returnBuffer = String::ToString("%s",(*tbl)[i].getName());
}
else
{
returnBuffer += String::ToString(" | %s", (*tbl)[i].getName());
}
first = false;
}
}
return Con::getReturnBuffer(returnBuffer);
}
void setData( void* dptr, S32 argc, const char** argv, const EnumTable*, BitSet32 ) override
void setData( void* dptr, S32 argc, const char** argv, const EnumTable* tbl, BitSet32 ) override
{
if( argc != 1 ) return; \
*((S32 *) dptr) = dAtoui(argv[0]); \
if( argc != 1 ) return;
S32 retVal = dAtoui(argv[0]);
if (retVal == 0 && retVal != -1) //zero we need to double check. -1 we know is all on
{
BitSet32 mask;
if (!tbl) tbl = getEnumTable();
const U32 numEnums = tbl->getNumValues();
String inString(argv[0]);
for (U32 i = 0; i < numEnums; i++)
{
if (inString.find((*tbl)[i].getName()) != String::NPos)
mask.set(BIT(i));
}
retVal = mask.getMask();
}
*((S32*)dptr) = retVal;
}
};

View file

@ -47,42 +47,42 @@
ImplementBitfieldType(GameTypeMasksType,
"The type of animation effect to apply to this material.\n"
"@ingroup GFX\n\n")
{ SceneObjectTypes::StaticObjectType, "StaticObjectType", "Static Objects.\n" },
{ SceneObjectTypes::EnvironmentObjectType, "EnvironmentObjectType" , "Objects considered part of the background or environment of a level.\n" },
{ SceneObjectTypes::TerrainObjectType, "TerrainObjectType" , "Terrain Objects.\n" },
{ SceneObjectTypes::WaterObjectType, "WaterObjectType", "Water Objects.\n" },
{ SceneObjectTypes::TriggerObjectType, "TriggerObjectType", "Interactive Trigger Objects.\n" },
{ SceneObjectTypes::MarkerObjectType, "MarkerObjectType", "Marker Objects, utilized primarily for tooling.\n" },
{ SceneObjectTypes::LightObjectType, "LightObjectType", "Lights.\n" },
{ SceneObjectTypes::ZoneObjectType, "ZoneObjectType", "zones.\n" },
{ SceneObjectTypes::StaticShapeObjectType, "StaticShapeObjectType", "Static Shape Objects. Distinct from StaticObjectType in that Static Shapes have additional functionality and behaviors.\n" },
{ SceneObjectTypes::DynamicShapeObjectType, "DynamicShapeObjectType", "Any sort of Dynamic Object.\n" },
{ SceneObjectTypes::GameBaseObjectType, "GameBaseObjectType", "Any Gamebase-based Objects. Objects generally associated to gameplay functionality.\n" },
{ SceneObjectTypes::GameBaseHiFiObjectType, "GameBaseHiFiObjectType", "Specialised Gamebase-based Objects. currently narrowly used. if at all.\n" },
{ SceneObjectTypes::ShapeBaseObjectType, "ShapeBaseObjectType", "Any Gamebase-based Objects. Objects generally associated to gameplay functionality.\n" },
{ SceneObjectTypes::CameraObjectType, "CameraObjectType", "Camera Objects.\n" },
{ SceneObjectTypes::PlayerObjectType, "PlayerObjectType", "Player Objects.\n" },
{ SceneObjectTypes::ItemObjectType, "ItemObjectType", "Item Objects.\n" },
{ SceneObjectTypes::VehicleObjectType, "VehicleObjectType", "Any sort of Vehicle Object.\n" },
{ SceneObjectTypes::VehicleBlockerObjectType, "VehicleBlockerObjectType", "\n" },
{ SceneObjectTypes::ProjectileObjectType, "ProjectileObjectType", "Projectiles.\n" },
{ SceneObjectTypes::ExplosionObjectType, "ExplosionObjectType", "Explosion and Effects.\n" },
{ SceneObjectTypes::CorpseObjectType, "CorpseObjectType", "Corpses of controlled objects.\n" },
{ SceneObjectTypes::DebrisObjectType, "DebrisObjectType", "Debris or debris-like things such as shell casings.\n" },
{ SceneObjectTypes::PhysicalZoneObjectType, "PhysicalZoneObjectType", "Physical Zones. Distinct from triggers in that they have physics forces applications.\n" },
{ SceneObjectTypes::EntityObjectType, "EntityObjectType", "A generic entity.\n" },
{ SceneObjectTypes::InteriorLikeObjectType, "InteriorLikeObjectType", "InteriorLikeObjectType (deprecated).\n" },
{ SceneObjectTypes::TerrainLikeObjectType, "TerrainLikeObjectType", "Pseudo-terrains, like groundplanes, or meshroads.\n" },
{ SceneObjectTypes::StaticObjectType, "$TypeMasks::StaticObjectType", "Static Objects.\n" },
{ SceneObjectTypes::EnvironmentObjectType, "$TypeMasks::EnvironmentObjectType" , "Objects considered part of the background or environment of a level.\n" },
{ SceneObjectTypes::TerrainObjectType, "$TypeMasks::TerrainObjectType" , "Terrain Objects.\n" },
{ SceneObjectTypes::WaterObjectType, "$TypeMasks::WaterObjectType", "Water Objects.\n" },
{ SceneObjectTypes::TriggerObjectType, "$TypeMasks::TriggerObjectType", "Interactive Trigger Objects.\n" },
{ SceneObjectTypes::MarkerObjectType, "$TypeMasks::MarkerObjectType", "Marker Objects, utilized primarily for tooling.\n" },
{ SceneObjectTypes::LightObjectType, "$TypeMasks::LightObjectType", "Lights.\n" },
{ SceneObjectTypes::ZoneObjectType, "$TypeMasks::ZoneObjectType", "zones.\n" },
{ SceneObjectTypes::StaticShapeObjectType, "$TypeMasks::StaticShapeObjectType", "Static Shape Objects. Distinct from StaticObjectType in that Static Shapes have additional functionality and behaviors.\n" },
{ SceneObjectTypes::DynamicShapeObjectType, "$TypeMasks::DynamicShapeObjectType", "Any sort of Dynamic Object.\n" },
{ SceneObjectTypes::GameBaseObjectType, "$TypeMasks::GameBaseObjectType", "Any Gamebase-based Objects. Objects generally associated to gameplay functionality.\n" },
{ SceneObjectTypes::GameBaseHiFiObjectType, "$TypeMasks::GameBaseHiFiObjectType", "Specialised Gamebase-based Objects. currently narrowly used. if at all.\n" },
{ SceneObjectTypes::ShapeBaseObjectType, "$TypeMasks::ShapeBaseObjectType", "Any Gamebase-based Objects. Objects generally associated to gameplay functionality.\n" },
{ SceneObjectTypes::CameraObjectType, "$TypeMasks::CameraObjectType", "Camera Objects.\n" },
{ SceneObjectTypes::PlayerObjectType, "$TypeMasks::PlayerObjectType", "Player Objects.\n" },
{ SceneObjectTypes::ItemObjectType, "$TypeMasks::ItemObjectType", "Item Objects.\n" },
{ SceneObjectTypes::VehicleObjectType, "$TypeMasks::VehicleObjectType", "Any sort of Vehicle Object.\n" },
{ SceneObjectTypes::VehicleBlockerObjectType, "$TypeMasks::VehicleBlockerObjectType", "\n" },
{ SceneObjectTypes::ProjectileObjectType, "$TypeMasks::ProjectileObjectType", "Projectiles.\n" },
{ SceneObjectTypes::ExplosionObjectType, "$TypeMasks::ExplosionObjectType", "Explosion and Effects.\n" },
{ SceneObjectTypes::CorpseObjectType, "$TypeMasks::CorpseObjectType", "Corpses of controlled objects.\n" },
{ SceneObjectTypes::DebrisObjectType, "$TypeMasks::DebrisObjectType", "Debris or debris-like things such as shell casings.\n" },
{ SceneObjectTypes::PhysicalZoneObjectType, "$TypeMasks::PhysicalZoneObjectType", "Physical Zones. Distinct from triggers in that they have physics forces applications.\n" },
{ SceneObjectTypes::EntityObjectType, "$TypeMasks::EntityObjectType", "A generic entity.\n" },
{ SceneObjectTypes::InteriorLikeObjectType, "$TypeMasks::InteriorLikeObjectType", "InteriorLikeObjectType (deprecated).\n" },
{ SceneObjectTypes::TerrainLikeObjectType, "$TypeMasks::TerrainLikeObjectType", "Pseudo-terrains, like groundplanes, or meshroads.\n" },
#if defined(AFX_CAP_AFXMODEL_TYPE)
{ SceneObjectTypes::afxModelObjectType, "afxModelObjectType", "afx-specific model typemask.\n" },
#else
{ SceneObjectTypes::N_A_27, "N_A_27", "unused 27th bit.\n" },
{ SceneObjectTypes::N_A_27, "$TypeMasks::N_A_27", "unused 27th bit.\n" },
#endif
{ SceneObjectTypes::N_A_28, "N_A_28", "unused 28th bit.\n" },
{ SceneObjectTypes::PathShapeObjectType, "PathShapeObjectType", "Path-following Objects.\n" },
{ SceneObjectTypes::TurretObjectType, "TurretObjectType", "Turret Objects.\n" },
{ SceneObjectTypes::N_A_31, "N_A_31", "unused 31st bit.\n" },
{ SceneObjectTypes::N_A_32, "N_A_32", "unused 32nd bit.\n" },
{ SceneObjectTypes::N_A_28, "$TypeMasks::N_A_28", "unused 28th bit.\n" },
{ SceneObjectTypes::PathShapeObjectType, "$TypeMasks::PathShapeObjectType", "Path-following Objects.\n" },
{ SceneObjectTypes::TurretObjectType, "$TypeMasks::TurretObjectType", "Turret Objects.\n" },
{ SceneObjectTypes::N_A_31, "$TypeMasks::N_A_31", "unused 31st bit.\n" },
{ SceneObjectTypes::N_A_32, "$TypeMasks::N_A_32", "unused 32nd bit.\n" },
EndImplementBitfieldType;

View file

@ -1522,6 +1522,32 @@ void GuiInspectorTypeBitMask32::setValue( StringTableEntry value )
{
U32 mask = dAtoui( value );
if (mask == 0 && mask != -1) //zero we need to double check. -1 we know is all on
{
BitSet32 bitMask;
const EngineEnumTable* table = mField->table;
if (!table)
{
ConsoleBaseType* type = ConsoleBaseType::getType(mField->type);
if (type && type->getEnumTable())
table = type->getEnumTable();
}
if (table)
{
const EngineEnumTable& t = *table;
const U32 numEntries = t.getNumValues();
String inString(value);
for (U32 i = 0; i < numEntries; i++)
{
if (inString.find(t[i].getName()) != String::NPos)
bitMask.set(t[i].getInt());
}
mask = bitMask.getMask();
}
}
for ( U32 i = 0; i < mArrayCtrl->size(); i++ )
{
GuiCheckBoxCtrl *pCheckBox = dynamic_cast<GuiCheckBoxCtrl*>( mArrayCtrl->at(i) );

View file

@ -233,7 +233,7 @@ void GuiInspectorField::setFirstResponder( GuiControl *firstResponder )
{
Parent::setFirstResponder( firstResponder );
if (( firstResponder == this || firstResponder == mEdit ) && firstResponder->isProperlyAdded())
if (( firstResponder == this || firstResponder == mEdit ) && (firstResponder && firstResponder->isProperlyAdded()))
{
mInspector->setHighlightField( this );
}

View file

@ -71,21 +71,17 @@ ConsoleDocClass(Material,
ImplementBitfieldType(MaterialAnimType,
"The type of animation effect to apply to this material.\n"
"@ingroup GFX\n\n")
{
Material::Scroll, "Scroll", "Scroll the material along the X/Y axis.\n"
},
{ Material::Rotate, "Rotate" , "Rotate the material around a point.\n" },
{ Material::Wave, "Wave" , "Warps the material with an animation using Sin, Triangle or Square mathematics.\n" },
{ Material::Scale, "Scale", "Scales the material larger and smaller with a pulsing effect.\n" },
{ Material::Sequence, "Sequence", "Enables the material to have multiple frames of animation in its imagemap.\n" }
{ Material::Scroll, "$Scroll", "Scroll the material along the X/Y axis.\n"},
{ Material::Rotate, "$Rotate" , "Rotate the material around a point.\n" },
{ Material::Wave, "$Wave" , "Warps the material with an animation using Sin, Triangle or Square mathematics.\n" },
{ Material::Scale, "$Scale", "Scales the material larger and smaller with a pulsing effect.\n" },
{ Material::Sequence, "$Sequence", "Enables the material to have multiple frames of animation in its imagemap.\n" }
EndImplementBitfieldType;
ImplementEnumType(MaterialBlendOp,
"The type of graphical blending operation to apply to this material\n"
"@ingroup GFX\n\n")
{
Material::None, "None", "Disable blending for this material."
},
{ Material::None, "None", "Disable blending for this material."},
{ Material::Mul, "Mul", "Multiplicative blending." },
{ Material::PreMul, "PreMul", "Premultiplied alpha." },
{ Material::Add, "Add", "Adds the color of the material to the frame buffer with full alpha for each pixel." },

View file

@ -115,11 +115,11 @@ public:
enum AnimType
{
Scroll = 1,
Rotate = 2,
Wave = 4,
Scale = 8,
Sequence = 16,
Scroll = BIT(0),
Rotate = BIT(1),
Wave = BIT(2),
Scale = BIT(3),
Sequence = BIT(4),
};
enum WaveType

View file

@ -914,98 +914,81 @@ void ProcessedShaderMaterial::_setTextureTransforms(const U32 pass)
PROFILE_SCOPE( ProcessedShaderMaterial_SetTextureTransforms );
ShaderConstHandles* handles = _getShaderConstHandles(pass);
if (handles->mTexMatSC->isValid())
{
MatrixF texMat( true );
if (!handles->mTexMatSC->isValid())
return;
mMaterial->updateTimeBasedParams();
F32 waveOffset = _getWaveOffset( pass ); // offset is between 0.0 and 1.0
MatrixF texMat(true);
mMaterial->updateTimeBasedParams();
F32 waveOffset = _getWaveOffset(pass); // offset is between 0.0 and 1.0
// handle scroll anim type
if( mMaterial->mAnimFlags[pass] & Material::Scroll )
{
if( mMaterial->mAnimFlags[pass] & Material::Wave )
{
Point3F scrollOffset;
scrollOffset.x = mMaterial->mScrollDir[pass].x * waveOffset;
scrollOffset.y = mMaterial->mScrollDir[pass].y * waveOffset;
scrollOffset.z = 1.0;
// --- Scroll Animation ---
if (mMaterial->mAnimFlags[pass] & Material::Scroll)
{
Point3F offset = (mMaterial->mAnimFlags[pass] & Material::Wave)
? Point3F(mMaterial->mScrollDir[pass].x * waveOffset,
mMaterial->mScrollDir[pass].y * waveOffset, 0.0f)
: Point3F(mMaterial->mScrollOffset[pass].x,
mMaterial->mScrollOffset[pass].y, 0.0f);
texMat.setColumn( 3, scrollOffset );
}
else
{
Point3F offset( mMaterial->mScrollOffset[pass].x,
mMaterial->mScrollOffset[pass].y,
1.0 );
texMat.setColumn( 3, offset );
}
}
// handle rotation
if( mMaterial->mAnimFlags[pass] & Material::Rotate )
{
if( mMaterial->mAnimFlags[pass] & Material::Wave )
{
F32 rotPos = waveOffset * M_2PI;
texMat.set( EulerF( 0.0, 0.0, rotPos ) );
texMat.setColumn( 3, Point3F( 0.5, 0.5, 0.0 ) );
MatrixF test( true );
test.setColumn( 3, Point3F( mMaterial->mRotPivotOffset[pass].x,
mMaterial->mRotPivotOffset[pass].y,
0.0 ) );
texMat.mul( test );
}
else
{
texMat.set( EulerF( 0.0, 0.0, mMaterial->mRotPos[pass] ) );
texMat.setColumn( 3, Point3F( 0.5, 0.5, 0.0 ) );
MatrixF test( true );
test.setColumn( 3, Point3F( mMaterial->mRotPivotOffset[pass].x,
mMaterial->mRotPivotOffset[pass].y,
0.0 ) );
texMat.mul( test );
}
}
// Handle scale + wave offset
if( mMaterial->mAnimFlags[pass] & Material::Scale &&
mMaterial->mAnimFlags[pass] & Material::Wave )
{
F32 wOffset = fabs( waveOffset );
texMat.setColumn( 3, Point3F( 0.5, 0.5, 0.0 ) );
MatrixF temp( true );
temp.setRow( 0, Point3F( wOffset, 0.0, 0.0 ) );
temp.setRow( 1, Point3F( 0.0, wOffset, 0.0 ) );
temp.setRow( 2, Point3F( 0.0, 0.0, wOffset ) );
temp.setColumn( 3, Point3F( -wOffset * 0.5, -wOffset * 0.5, 0.0 ) );
texMat.mul( temp );
}
// handle sequence
if( mMaterial->mAnimFlags[pass] & Material::Sequence )
{
U32 frameNum = (U32)(MATMGR->getTotalTime() * mMaterial->mSeqFramePerSec[pass]);
F32 offset = frameNum * mMaterial->mSeqSegSize[pass];
if ( mMaterial->mAnimFlags[pass] & Material::Scale )
texMat.scale( Point3F( mMaterial->mSeqSegSize[pass], 1.0f, 1.0f ) );
Point3F texOffset = texMat.getPosition();
texOffset.x += offset;
texMat.setPosition( texOffset );
}
GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
shaderConsts->setSafe(handles->mTexMatSC, texMat);
MatrixF scrollMat(true);
scrollMat.setColumn(3, offset);
texMat.mul(scrollMat);
}
// --- Rotation Animation ---
if (mMaterial->mAnimFlags[pass] & Material::Rotate)
{
F32 rotationAngle = (mMaterial->mAnimFlags[pass] & Material::Wave)
? waveOffset * M_2PI
: mMaterial->mRotPos[pass];
MatrixF rotationMat(EulerF(0.0f, 0.0f, rotationAngle));
Point3F pivotPoint(
mMaterial->mRotPivotOffset[pass].x,
mMaterial->mRotPivotOffset[pass].y,
0.0f);
MatrixF finalRotationMat(true);
finalRotationMat.setColumn(3, pivotPoint);
finalRotationMat.mul(rotationMat);
finalRotationMat.setColumn(3, -pivotPoint);
// Apply final rotation matrix
texMat.mul(finalRotationMat);
}
// --- Scale Animation ---
if ((mMaterial->mAnimFlags[pass] & Material::Scale) && (mMaterial->mAnimFlags[pass] & Material::Wave))
{
F32 scaleFactor = mFabs(waveOffset);
MatrixF scaleMat(true);
scaleMat.setRow(0, Point3F(scaleFactor, 0.0f, 0.0f));
scaleMat.setRow(1, Point3F(0.0f, scaleFactor, 0.0f));
scaleMat.setRow(2, Point3F(0.0f, 0.0f, scaleFactor));
// Apply final scale matrix
texMat.mul(scaleMat);
}
// --- Sequence Animation ---
if (mMaterial->mAnimFlags[pass] & Material::Sequence)
{
U32 frameNum = static_cast<U32>(MATMGR->getTotalTime() * mMaterial->mSeqFramePerSec[pass]);
F32 offset = frameNum * mMaterial->mSeqSegSize[pass];
MatrixF sequenceMat(true);
sequenceMat.setColumn(3, Point3F(offset, 0.0f, 0.0f));
if (mMaterial->mAnimFlags[pass] & Material::Scale)
sequenceMat.scale(Point3F(mMaterial->mSeqSegSize[pass], 1.0f, 1.0f));
texMat.mul(sequenceMat);
}
GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
shaderConsts->setSafe(handles->mTexMatSC, texMat);
}
//--------------------------------------------------------------------------