Cleans up ShapeAsset of some unnecessary/redundant elements like extra material and animations tracking

Removed the old SHAPE_ASSET macros
Implements AssetRef struct that acts as a universal wrapper for an templated AssetPtr and AssetId pair
Adds Type handling for AssetRef for ShapeAsset to unify handling in classes that utilize a shapeAsset, so assigning an assetPtr or an assetId will keep a record of the assignment in the event the assetPtr is invalid.
Update all classes that utilized the old SHAPE_ASSET macros to utilize the AssetRef struct and updated the class code to utilize it to provide much more clean and concise code that isn't blocked behind macro definitions
Added a new example class: shapeDatablockExample which allows render of a simple shape object utilizing a simple example datablock.
This commit is contained in:
JeffR 2026-05-31 01:19:26 -05:00
parent c2c5674fe9
commit b44158cb89
52 changed files with 1860 additions and 1086 deletions

View file

@ -245,9 +245,11 @@ bool AITurretShapeData::preload(bool server, String &errorStr)
if (!Parent::preload(server, errorStr))
return false;
Resource<TSShape> shape = shapeAssetRef.assetPtr->getShapeResource();
// We have mShape at this point. Resolve nodes.
scanNode = getShape()->findNode("scanPoint");
aimNode = getShape()->findNode("aimPoint");
scanNode = shape->findNode("scanPoint");
aimNode = shape->findNode("aimPoint");
if (scanNode == -1) scanNode = pitchNode;
if (scanNode == -1) scanNode = headingNode;
@ -259,7 +261,7 @@ bool AITurretShapeData::preload(bool server, String &errorStr)
for (U32 j = 0; j < MaxStates; j++) {
StateData& s = state[j];
if (stateSequence[j] && stateSequence[j][0])
s.sequence = getShape()->findSequence(stateSequence[j]);
s.sequence = shape->findSequence(stateSequence[j]);
if (s.sequence != -1)
{
// This state has an animation sequence

View file

@ -216,36 +216,43 @@ bool TurretShapeData::preload(bool server, String &errorStr)
if (!Parent::preload(server, errorStr))
return false;
if (shapeAssetRef.isNull())
return false;
Resource<TSShape> shape = shapeAssetRef.assetPtr->getShapeResource();
if (!shape)
return false;
// We have mShape at this point. Resolve nodes.
headingNode = getShape()->findNode("heading");
pitchNode = getShape()->findNode("pitch");
headingNode = shape->findNode("heading");
pitchNode = shape->findNode("pitch");
// Find any mirror pitch nodes
for (U32 i = 0; i < NumMirrorDirectionNodes; ++i)
{
char name[32];
dSprintf(name, 31, "pitch%d", i+1);
pitchNodes[i] = getShape()->findNode(name);
pitchNodes[i] = shape->findNode(name);
dSprintf(name, 31, "heading%d", i+1);
headingNodes[i] = getShape()->findNode(name);
headingNodes[i] = shape->findNode(name);
}
// Resolve weapon mount point node indexes
for (U32 i = 0; i < ShapeBase::MaxMountedImages; i++) {
char fullName[256];
dSprintf(fullName,sizeof(fullName),"weaponMount%d",i);
weaponMountNode[i] = getShape()->findNode(fullName);
weaponMountNode[i] = shape->findNode(fullName);
}
// Recoil animations
recoilSequence[0] = getShape()->findSequence("light_recoil");
recoilSequence[1] = getShape()->findSequence("medium_recoil");
recoilSequence[2] = getShape()->findSequence("heavy_recoil");
recoilSequence[0] = shape->findSequence("light_recoil");
recoilSequence[1] = shape->findSequence("medium_recoil");
recoilSequence[2] = shape->findSequence("heavy_recoil");
// Optional sequences used when the turret rotates
pitchSequence = getShape()->findSequence("pitch");
headingSequence = getShape()->findSequence("heading");
pitchSequence = shape->findSequence("pitch");
headingSequence = shape->findSequence("heading");
return true;
}