mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-10 06:04:37 +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
|
|
@ -54,15 +54,15 @@ ForestItemData::ForestItemData()
|
|||
mDampingCoefficient( 0.7f )
|
||||
{
|
||||
mShape = NULL;
|
||||
mShapeAsset.registerRefreshNotify(this);
|
||||
shapeAssetRef.assetPtr.registerRefreshNotify(this);
|
||||
}
|
||||
|
||||
void ForestItemData::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
addGroup( "Shapes" );
|
||||
|
||||
INITPERSISTFIELD_SHAPEASSET_REFACTOR(Shape, ForestItemData, "Shape asset for this item type");
|
||||
ADD_FIELD("shapeAsset", TypeShapeAssetRef, Offset(shapeAssetRef, ForestItemData))
|
||||
.doc("Shape asset for this item type");
|
||||
|
||||
endGroup( "Shapes" );
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ void ForestItemData::packData(BitStream* stream)
|
|||
|
||||
stream->write( localName );
|
||||
|
||||
PACKDATA_ASSET_REFACTOR(Shape);
|
||||
AssetDatabase.packDataAsset(stream, shapeAssetRef.assetId);
|
||||
|
||||
stream->writeFlag( mCollidable );
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ void ForestItemData::unpackData(BitStream* stream)
|
|||
stream->read( &localName );
|
||||
setInternalName( localName );
|
||||
|
||||
UNPACKDATA_ASSET_REFACTOR(Shape);
|
||||
shapeAssetRef = AssetDatabase.unpackDataAsset(stream);
|
||||
|
||||
mCollidable = stream->readFlag();
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ protected:
|
|||
virtual void _preload() {}
|
||||
|
||||
public:
|
||||
|
||||
DECLARE_SHAPEASSET_REFACTOR(ForestItemData, Shape)
|
||||
|
||||
AssetRef<ShapeAsset> shapeAssetRef;
|
||||
|
||||
/// This is the radius used during placement to ensure
|
||||
/// the element isn't crowded up against other trees.
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ void TSForestItemData::inspectPostApply()
|
|||
|
||||
void TSForestItemData::_onResourceChanged( const Torque::Path &path )
|
||||
{
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(_getShapeAssetId());
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(shapeAssetRef.assetPtr);
|
||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( path != Path(getShapeFile()) )
|
||||
if ( path != Path(shapeAssetRef.assetPtr->getShapeFile()) )
|
||||
return;
|
||||
|
||||
SAFE_DELETE( mShapeInstance );
|
||||
|
|
@ -116,8 +116,11 @@ void TSForestItemData::_onResourceChanged( const Torque::Path &path )
|
|||
|
||||
void TSForestItemData::_loadShape()
|
||||
{
|
||||
mShape = getShape();
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(_getShapeAssetId());
|
||||
if (shapeAssetRef.assetPtr.isNull())
|
||||
return;
|
||||
|
||||
mShape = shapeAssetRef.assetPtr->getShape();
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(shapeAssetRef.assetPtr);
|
||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||
{
|
||||
return;
|
||||
|
|
@ -127,7 +130,7 @@ void TSForestItemData::_loadShape()
|
|||
return;
|
||||
|
||||
if ( mIsClientObject &&
|
||||
!mShape->preloadMaterialList(getShapeFile()) )
|
||||
!mShape->preloadMaterialList(shapeAssetRef.assetPtr->getShapeFile()) )
|
||||
return;
|
||||
|
||||
// Lets add an autobillboard detail if don't have one.
|
||||
|
|
@ -165,7 +168,7 @@ TSShapeInstance* TSForestItemData::_getShapeInstance() const
|
|||
|
||||
void TSForestItemData::_checkLastDetail()
|
||||
{
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(_getShapeAssetId());
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(shapeAssetRef.assetPtr);
|
||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||
{
|
||||
return;
|
||||
|
|
@ -177,7 +180,7 @@ void TSForestItemData::_checkLastDetail()
|
|||
// TODO: Expose some real parameters to the datablock maybe?
|
||||
if ( detail->subShapeNum != -1 )
|
||||
{
|
||||
mShape->addImposter(getShapeFile(), 10, 4, 0, 0, 256, 0, 0);
|
||||
mShape->addImposter(shapeAssetRef.assetPtr->getShapeFile(), 10, 4, 0, 0, 256, 0, 0);
|
||||
|
||||
// HACK: If i don't do this it crashes!
|
||||
while ( mShape->detailCollisionAccelerators.size() < mShape->details.size() )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue