mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
tsforestitem and forestitem
This commit is contained in:
parent
08f52cfa16
commit
9208cdfcd6
|
|
@ -53,7 +53,8 @@ ForestItemData::ForestItemData()
|
|||
mTightnessCoefficient( 0.4f ),
|
||||
mDampingCoefficient( 0.7f )
|
||||
{
|
||||
INIT_ASSET(Shape);
|
||||
mShape = NULL;
|
||||
mShapeAsset.registerRefreshNotify(this);
|
||||
}
|
||||
|
||||
void ForestItemData::initPersistFields()
|
||||
|
|
@ -61,10 +62,8 @@ void ForestItemData::initPersistFields()
|
|||
docsURL;
|
||||
addGroup( "Shapes" );
|
||||
|
||||
INITPERSISTFIELD_SHAPEASSET(Shape, ForestItemData, "Shape asset for this item type");
|
||||
|
||||
addProtectedField( "shapeFile", TypeShapeFilename, Offset( mShapeName, ForestItemData ), &_setShapeData, &defaultProtectedGetFn,
|
||||
"Shape file for this item type", AbstractClassRep::FIELD_HideInInspectors );
|
||||
INITPERSISTFIELD_SHAPEASSET_REFACTOR(Shape, ForestItemData, "Shape asset for this item type");
|
||||
|
||||
endGroup( "Shapes" );
|
||||
|
||||
addGroup("Physics");
|
||||
|
|
@ -164,7 +163,7 @@ void ForestItemData::packData(BitStream* stream)
|
|||
|
||||
stream->write( localName );
|
||||
|
||||
PACKDATA_ASSET(Shape);
|
||||
PACKDATA_ASSET_REFACTOR(Shape);
|
||||
|
||||
stream->writeFlag( mCollidable );
|
||||
|
||||
|
|
@ -190,7 +189,7 @@ void ForestItemData::unpackData(BitStream* stream)
|
|||
stream->read( &localName );
|
||||
setInternalName( localName );
|
||||
|
||||
UNPACKDATA_ASSET(Shape);
|
||||
UNPACKDATA_ASSET_REFACTOR(Shape);
|
||||
|
||||
mCollidable = stream->readFlag();
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ struct RayInfo;
|
|||
class AbstractPolyList;
|
||||
|
||||
|
||||
class ForestItemData : public SimDataBlock
|
||||
class ForestItemData : public SimDataBlock, protected AssetPtrCallback
|
||||
{
|
||||
protected:
|
||||
|
||||
|
|
@ -62,8 +62,7 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
DECLARE_SHAPEASSET(ForestItemData, Shape, onShapeChanged);
|
||||
DECLARE_ASSET_SETGET(ForestItemData, Shape);
|
||||
DECLARE_SHAPEASSET_REFACTOR(ForestItemData, Shape)
|
||||
|
||||
/// This is the radius used during placement to ensure
|
||||
/// the element isn't crowded up against other trees.
|
||||
|
|
@ -144,7 +143,10 @@ public:
|
|||
return theSignal;
|
||||
}
|
||||
|
||||
void onShapeChanged()
|
||||
Resource<TSShape> mShape;
|
||||
|
||||
protected:
|
||||
void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ void TSForestItemData::inspectPostApply()
|
|||
|
||||
void TSForestItemData::_onResourceChanged( const Torque::Path &path )
|
||||
{
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(mShapeAsset);
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(_getShapeAssetId());
|
||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( path != Path(mShapeAsset->getShapeFilePath()) )
|
||||
if ( path != Path(getShapeFile()) )
|
||||
return;
|
||||
|
||||
SAFE_DELETE( mShapeInstance );
|
||||
|
|
@ -116,18 +116,18 @@ void TSForestItemData::_onResourceChanged( const Torque::Path &path )
|
|||
|
||||
void TSForestItemData::_loadShape()
|
||||
{
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(mShapeAsset);
|
||||
mShape = getShape();
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(_getShapeAssetId());
|
||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_setShape(mShapeAssetId);
|
||||
|
||||
if ( !(bool)mShape )
|
||||
return;
|
||||
|
||||
if ( mIsClientObject &&
|
||||
!mShape->preloadMaterialList(mShapeAsset->getShapeFilePath()) )
|
||||
!mShape->preloadMaterialList(mShape.getPath()) )
|
||||
return;
|
||||
|
||||
// Lets add an autobillboard detail if don't have one.
|
||||
|
|
@ -165,7 +165,7 @@ TSShapeInstance* TSForestItemData::_getShapeInstance() const
|
|||
|
||||
void TSForestItemData::_checkLastDetail()
|
||||
{
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(mShapeAsset);
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(_getShapeAssetId());
|
||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||
{
|
||||
return;
|
||||
|
|
@ -177,7 +177,7 @@ void TSForestItemData::_checkLastDetail()
|
|||
// TODO: Expose some real parameters to the datablock maybe?
|
||||
if ( detail->subShapeNum != -1 )
|
||||
{
|
||||
mShape->addImposter(mShapeAsset->getShapeFilePath(), 10, 4, 0, 0, 256, 0, 0 );
|
||||
mShape->addImposter(mShape.getPath(), 10, 4, 0, 0, 256, 0, 0);
|
||||
|
||||
// HACK: If i don't do this it crashes!
|
||||
while ( mShape->detailCollisionAccelerators.size() < mShape->details.size() )
|
||||
|
|
|
|||
Loading…
Reference in a new issue