mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-10 22:24:33 +00:00
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:
parent
c2c5674fe9
commit
b44158cb89
52 changed files with 1860 additions and 1086 deletions
|
|
@ -182,4 +182,54 @@ public:
|
|||
bool isValid(void) const { return notNull() && static_cast<AssetBase*>(mpAsset.getObject())->isAssetValid(); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// AssetRef is a simple struct that contains an asset Id and an AssetPtr.
|
||||
// This is used in cases where we want to be able to track the asset Id even if the asset pointer is null (e.g. when the asset fails to load and we want to keep the asset Id around so that we can retry loading it later).
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
struct AssetRef
|
||||
{
|
||||
StringTableEntry assetId;
|
||||
AssetPtr<T> assetPtr;
|
||||
|
||||
AssetRef()
|
||||
{
|
||||
assetId = StringTable->EmptyString();
|
||||
}
|
||||
AssetRef<T>& operator=(const char* pAssetId)
|
||||
{
|
||||
assetId = StringTable->insert(pAssetId);
|
||||
assetPtr = pAssetId;
|
||||
|
||||
// Return Reference.
|
||||
return *this;
|
||||
}
|
||||
AssetRef<T>& operator=(const AssetPtr<T>& pAssetPtr)
|
||||
{
|
||||
if (pAssetPtr.notNull())
|
||||
assetId = StringTable->insert(pAssetPtr->getAssetId());
|
||||
|
||||
assetPtr = pAssetPtr;
|
||||
|
||||
// Return Reference.
|
||||
return *this;
|
||||
}
|
||||
AssetRef<T>& operator=(const AssetRef<T>& pAssetRef)
|
||||
{
|
||||
assetId = pAssetRef.assetId;
|
||||
assetPtr = pAssetRef.assetPtr;
|
||||
|
||||
// Return Reference.
|
||||
return *this;
|
||||
}
|
||||
|
||||
StringTableEntry getAssetId(void) const { return assetId; }
|
||||
bool isAssetId(const char* pAssetId) const { return assetId == StringTable->insert(pAssetId); }
|
||||
bool hasAssetId() const { return assetId != StringTable->EmptyString(); }
|
||||
|
||||
/// Validity.
|
||||
bool isNull(void) const { return assetPtr.isNull(); }
|
||||
bool notNull(void) const { return !assetPtr.isNull(); }
|
||||
bool isValid(void) const { return notNull() && static_cast<AssetBase*>(assetPtr)->isAssetValid(); }
|
||||
};
|
||||
#endif // _ASSET_PTR_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue