mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
initial commit
change the macro to use the refactor (exact same structure as the imageasset macro)
This commit is contained in:
parent
61a75ada1e
commit
ca1604170d
29 changed files with 700 additions and 457 deletions
|
|
@ -141,7 +141,6 @@ U32 Projectile::smProjectileWarpTicks = 5;
|
|||
//
|
||||
afxMagicMissileData::afxMagicMissileData()
|
||||
{
|
||||
INIT_ASSET(ProjectileShape);
|
||||
INIT_ASSET(ProjectileSound);
|
||||
|
||||
/* From stock Projectile code...
|
||||
|
|
@ -241,11 +240,13 @@ afxMagicMissileData::afxMagicMissileData()
|
|||
reverse_targeting = false;
|
||||
|
||||
caster_safety_time = U32_MAX;
|
||||
|
||||
mProjectileShapeAsset.registerRefreshNotify(this);
|
||||
}
|
||||
|
||||
afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool temp_clone) : GameBaseData(other, temp_clone)
|
||||
{
|
||||
CLONE_ASSET(ProjectileShape);
|
||||
mProjectileShapeAsset = other.mProjectileShapeAsset;
|
||||
projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName
|
||||
CLONE_ASSET(ProjectileSound);
|
||||
splash = other.splash;
|
||||
|
|
@ -305,6 +306,8 @@ afxMagicMissileData::~afxMagicMissileData()
|
|||
{
|
||||
if (wiggle_axis)
|
||||
delete [] wiggle_axis;
|
||||
|
||||
mProjectileShapeAsset.unregisterRefreshNotify();
|
||||
}
|
||||
|
||||
afxMagicMissileData* afxMagicMissileData::cloneAndPerformSubstitutions(const SimObject* owner, S32 index)
|
||||
|
|
@ -334,7 +337,7 @@ void afxMagicMissileData::initPersistFields()
|
|||
static IRangeValidatorScaled ticksFromMS(TickMs, 0, MaxLifetimeTicks);
|
||||
|
||||
addGroup("Shapes");
|
||||
INITPERSISTFIELD_SHAPEASSET(ProjectileShape, afxMagicMissileData, "Shape for the projectile");
|
||||
INITPERSISTFIELD_SHAPEASSET_REFACTOR(ProjectileShape, afxMagicMissileData, "Shape for the projectile");
|
||||
addField("scale", TypePoint3F, Offset(scale, afxMagicMissileData));
|
||||
addField("missileShapeScale", TypePoint3F, myOffset(scale));
|
||||
endGroup("Shapes");
|
||||
|
|
@ -531,10 +534,10 @@ bool afxMagicMissileData::preload(bool server, String &errorStr)
|
|||
U32 assetStatus = ShapeAsset::getAssetErrCode(mProjectileShapeAsset);
|
||||
if (assetStatus == AssetBase::Ok || assetStatus == AssetBase::UsingFallback)
|
||||
{
|
||||
projectileShape = mProjectileShapeAsset->getShapeResource();
|
||||
projectileShape = getProjectileShape();
|
||||
if (bool(projectileShape) == false)
|
||||
{
|
||||
errorStr = String::ToString("afxMagicMissileData::preload: Couldn't load shape \"%s\"", mProjectileShapeAssetId);
|
||||
errorStr = String::ToString("afxMagicMissileData::preload: Couldn't load shape \"%s\"", _getProjectileShapeAssetId());
|
||||
return false;
|
||||
}
|
||||
/* From stock Projectile code...
|
||||
|
|
@ -586,7 +589,7 @@ void afxMagicMissileData::packData(BitStream* stream)
|
|||
{
|
||||
Parent::packData(stream);
|
||||
|
||||
PACKDATA_ASSET(ProjectileShape);
|
||||
PACKDATA_ASSET_REFACTOR(ProjectileShape);
|
||||
|
||||
/* From stock Projectile code...
|
||||
stream->writeFlag(faceViewer);
|
||||
|
|
@ -697,7 +700,7 @@ void afxMagicMissileData::unpackData(BitStream* stream)
|
|||
{
|
||||
Parent::unpackData(stream);
|
||||
|
||||
UNPACKDATA_ASSET(ProjectileShape);
|
||||
UNPACKDATA_ASSET_REFACTOR(ProjectileShape);
|
||||
/* From stock Projectile code...
|
||||
faceViewer = stream->readFlag();
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class SFXSource;
|
|||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
// afxMagicMissileData
|
||||
|
||||
class afxMagicMissileData : public GameBaseData
|
||||
class afxMagicMissileData : public GameBaseData, protected AssetPtrCallback
|
||||
{
|
||||
typedef GameBaseData Parent;
|
||||
|
||||
|
|
@ -66,16 +66,10 @@ protected:
|
|||
public:
|
||||
enum { MaxLifetimeTicks = 4095 };
|
||||
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
public:
|
||||
// variables set in datablock definition:
|
||||
// Shape related
|
||||
DECLARE_SHAPEASSET(afxMagicMissileData, ProjectileShape, onShapeChanged);
|
||||
DECLARE_ASSET_SETGET(afxMagicMissileData, ProjectileShape);
|
||||
DECLARE_SHAPEASSET_REFACTOR(afxMagicMissileData, ProjectileShape)
|
||||
//StringTableEntry projectileShapeName;
|
||||
|
||||
//bool hasLight;
|
||||
|
|
@ -228,6 +222,12 @@ public:
|
|||
afxMagicMissileData* cloneAndPerformSubstitutions(const SimObject*, S32 index=0);
|
||||
bool allowSubstitutions() const override { return true; }
|
||||
void gather_cons_defs(Vector<afxConstraintDef>& defs);
|
||||
|
||||
protected:
|
||||
void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ ConsoleDocClass( afxModelData,
|
|||
|
||||
afxModelData::afxModelData()
|
||||
{
|
||||
INIT_ASSET(Shape);
|
||||
sequence = ST_NULLSTRING;
|
||||
seq_rate = 1.0f;
|
||||
seq_offset = 0.0f;
|
||||
|
|
@ -79,11 +78,13 @@ afxModelData::afxModelData()
|
|||
shadowMaxVisibleDistance = 80.0f;
|
||||
shadowProjectionDistance = 10.0f;
|
||||
shadowSphereAdjust = 1.0;
|
||||
|
||||
mShapeAsset.registerRefreshNotify(this);
|
||||
}
|
||||
|
||||
afxModelData::afxModelData(const afxModelData& other, bool temp_clone) : GameBaseData(other, temp_clone)
|
||||
{
|
||||
CLONE_ASSET(Shape);
|
||||
mShapeAsset = other.mShapeAsset;
|
||||
sequence = other.sequence;
|
||||
seq_rate = other.seq_rate;
|
||||
seq_offset = other.seq_offset;
|
||||
|
|
@ -113,6 +114,8 @@ afxModelData::~afxModelData()
|
|||
{
|
||||
if (remap_buffer)
|
||||
dFree(remap_buffer);
|
||||
|
||||
mShapeAsset.unregisterRefreshNotify();
|
||||
}
|
||||
|
||||
bool afxModelData::preload(bool server, String &errorStr)
|
||||
|
|
@ -126,9 +129,9 @@ bool afxModelData::preload(bool server, String &errorStr)
|
|||
|
||||
if (mShapeAsset.notNull())
|
||||
{
|
||||
if (!mShape)
|
||||
if (!getShape())
|
||||
{
|
||||
errorStr = String::ToString("afxModelData::load: Failed to load shape \"%s\"", mShapeAssetId);
|
||||
errorStr = String::ToString("afxModelData::load: Failed to load shape \"%s\"", _getShapeAssetId());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +163,7 @@ bool afxModelData::preload(bool server, String &errorStr)
|
|||
if (txr_tag_remappings.size() == 0)
|
||||
{
|
||||
// this little hack forces the textures to preload
|
||||
TSShapeInstance* pDummy = new TSShapeInstance(mShape);
|
||||
TSShapeInstance* pDummy = new TSShapeInstance(getShape());
|
||||
delete pDummy;
|
||||
}
|
||||
}
|
||||
|
|
@ -174,7 +177,7 @@ void afxModelData::initPersistFields()
|
|||
{
|
||||
docsURL;
|
||||
addGroup("Shapes");
|
||||
INITPERSISTFIELD_SHAPEASSET(Shape, afxModelData, "The name of a .dts format file to use for the model.");
|
||||
INITPERSISTFIELD_SHAPEASSET_REFACTOR(Shape, afxModelData, "The name of a .dts format file to use for the model.");
|
||||
endGroup("Shapes");
|
||||
|
||||
addGroup("Animation");
|
||||
|
|
@ -258,7 +261,7 @@ void afxModelData::packData(BitStream* stream)
|
|||
{
|
||||
Parent::packData(stream);
|
||||
|
||||
PACKDATA_ASSET(Shape);
|
||||
PACKDATA_ASSET_REFACTOR(Shape);
|
||||
stream->writeString(sequence);
|
||||
stream->write(seq_rate);
|
||||
stream->write(seq_offset);
|
||||
|
|
@ -289,7 +292,7 @@ void afxModelData::unpackData(BitStream* stream)
|
|||
{
|
||||
Parent::unpackData(stream);
|
||||
|
||||
UNPACKDATA_ASSET(Shape);
|
||||
UNPACKDATA_ASSET_REFACTOR(Shape);
|
||||
sequence = stream->readSTString();
|
||||
stream->read(&seq_rate);
|
||||
stream->read(&seq_offset);
|
||||
|
|
@ -318,21 +321,10 @@ void afxModelData::unpackData(BitStream* stream)
|
|||
|
||||
void afxModelData::onPerformSubstitutions()
|
||||
{
|
||||
if (mShapeAssetId != StringTable->EmptyString())
|
||||
if (!getShape())
|
||||
{
|
||||
mShapeAsset = mShapeAssetId;
|
||||
if (mShapeAsset.notNull())
|
||||
{
|
||||
mShape = mShapeAsset->getShapeResource();
|
||||
}
|
||||
|
||||
if (!mShape)
|
||||
{
|
||||
Con::errorf("afxModelData::onPerformSubstitutions: Failed to load shape \"%s\"", mShapeAssetId);
|
||||
return;
|
||||
}
|
||||
|
||||
// REMAP-TEXTURE-TAGS ISSUES?
|
||||
Con::errorf("afxModelData::onPerformSubstitutions: Failed to load shape \"%s\"", _getShapeAssetId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -406,18 +398,18 @@ bool afxModel::onAdd()
|
|||
return false;
|
||||
|
||||
// setup our bounding box
|
||||
if (mDataBlock->mShape)
|
||||
mObjBox = mDataBlock->mShape->mBounds;
|
||||
if (mDataBlock->getShape())
|
||||
mObjBox = mDataBlock->getShape()->mBounds;
|
||||
else
|
||||
mObjBox = Box3F(Point3F(-1, -1, -1), Point3F(1, 1, 1));
|
||||
|
||||
// setup the shape instance and sequence
|
||||
if (mDataBlock->mShape)
|
||||
if (mDataBlock->getShape())
|
||||
{
|
||||
if (/*isClientObject() && */mDataBlock->txr_tag_remappings.size() > 0)
|
||||
{
|
||||
// temporarily substitute material tags with alternates
|
||||
TSMaterialList* mat_list = mDataBlock->mShape->materialList;
|
||||
TSMaterialList* mat_list = mDataBlock->getShape()->materialList;
|
||||
if (mat_list)
|
||||
{
|
||||
for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
|
||||
|
|
@ -438,7 +430,7 @@ bool afxModel::onAdd()
|
|||
}
|
||||
}
|
||||
|
||||
shape_inst = new TSShapeInstance(mDataBlock->mShape);
|
||||
shape_inst = new TSShapeInstance(mDataBlock->getShape());
|
||||
|
||||
if (true) // isClientObject())
|
||||
{
|
||||
|
|
@ -447,7 +439,7 @@ bool afxModel::onAdd()
|
|||
// restore the material tags to original form
|
||||
if (mDataBlock->txr_tag_remappings.size() > 0)
|
||||
{
|
||||
TSMaterialList* mat_list = mDataBlock->mShape->materialList;
|
||||
TSMaterialList* mat_list = mDataBlock->getShape()->materialList;
|
||||
if (mat_list)
|
||||
{
|
||||
for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
|
||||
|
|
@ -513,14 +505,14 @@ bool afxModel::onAdd()
|
|||
|
||||
resetWorldBox();
|
||||
|
||||
if (mDataBlock->mShape)
|
||||
if (mDataBlock->getShape())
|
||||
{
|
||||
// Scan out the collision hulls...
|
||||
static const String sCollisionStr( "collision-" );
|
||||
|
||||
for (U32 i = 0; i < mDataBlock->mShape->details.size(); i++)
|
||||
for (U32 i = 0; i < mDataBlock->getShape()->details.size(); i++)
|
||||
{
|
||||
const String &name = mDataBlock->mShape->names[mDataBlock->mShape->details[i].nameIndex];
|
||||
const String &name = mDataBlock->getShape()->names[mDataBlock->getShape()->details[i].nameIndex];
|
||||
|
||||
if (name.compare( sCollisionStr, sCollisionStr.length(), String::NoCase ) == 0)
|
||||
{
|
||||
|
|
@ -534,7 +526,7 @@ bool afxModel::onAdd()
|
|||
|
||||
char buff[128];
|
||||
dSprintf(buff, sizeof(buff), "LOS-%d", i + 1 + 8/*MaxCollisionShapes*/);
|
||||
U32 los = mDataBlock->mShape->findDetail(buff);
|
||||
U32 los = mDataBlock->getShape()->findDetail(buff);
|
||||
if (los == -1)
|
||||
mLOSDetails.last() = i;
|
||||
else
|
||||
|
|
@ -545,9 +537,9 @@ bool afxModel::onAdd()
|
|||
// Snag any "unmatched" LOS details
|
||||
static const String sLOSStr( "LOS-" );
|
||||
|
||||
for (U32 i = 0; i < mDataBlock->mShape->details.size(); i++)
|
||||
for (U32 i = 0; i < mDataBlock->getShape()->details.size(); i++)
|
||||
{
|
||||
const String &name = mDataBlock->mShape->names[mDataBlock->mShape->details[i].nameIndex];
|
||||
const String &name = mDataBlock->getShape()->names[mDataBlock->getShape()->details[i].nameIndex];
|
||||
|
||||
if (name.compare( sLOSStr, sLOSStr.length(), String::NoCase ) == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,12 +39,11 @@ class TSShape;
|
|||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
// afxModel Data
|
||||
|
||||
struct afxModelData : public GameBaseData
|
||||
struct afxModelData : public GameBaseData, protected AssetPtrCallback
|
||||
{
|
||||
typedef GameBaseData Parent;
|
||||
|
||||
DECLARE_SHAPEASSET(afxModelData, Shape, onShapeChanged);
|
||||
DECLARE_ASSET_SETGET(afxModelData, Shape);
|
||||
DECLARE_SHAPEASSET_REFACTOR(afxModelData, Shape)
|
||||
|
||||
StringTableEntry sequence;
|
||||
|
||||
|
|
@ -94,13 +93,15 @@ public:
|
|||
|
||||
static void initPersistFields();
|
||||
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
void onSequenceChanged() {}
|
||||
|
||||
DECLARE_CONOBJECT(afxModelData);
|
||||
|
||||
protected:
|
||||
void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
|
@ -154,9 +155,9 @@ public:
|
|||
void setSequenceRateFactor(F32 factor);
|
||||
void setSortPriority(S8 priority) { sort_priority = priority; }
|
||||
|
||||
const char* getShapeFileName() const { return mDataBlock->getShape(); }
|
||||
const char* getShapeFileName() const { return mDataBlock->getShapeFile(); }
|
||||
void setVisibility(bool flag) { is_visible = flag; }
|
||||
TSShape* getTSShape() { return mDataBlock->getShapeResource(); }
|
||||
TSShape* getTSShape() { return mDataBlock->getShape(); }
|
||||
TSShapeInstance* getTSShapeInstance() { return shape_inst; }
|
||||
|
||||
U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
U32 packUpdate(NetConnection*, U32, BitStream*) override;
|
||||
void unpackUpdate(NetConnection*, BitStream*) override;
|
||||
|
||||
const char* getShapeFileName() const { return mDataBlock->mShapeAsset->getShapeFileName(); }
|
||||
const char* getShapeFileName() const { return mDataBlock->getShapeFile(); }
|
||||
void setVisibility(bool flag) { mIs_visible = flag; }
|
||||
|
||||
DECLARE_CONOBJECT(afxStaticShape);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue