@@ -116,7 +116,7 @@ DebrisData::DebrisData()
116116 terminalVelocity = 0 .0f ;
117117 ignoreWater = true ;
118118
119- mShapeAsset .registerRefreshNotify (this );
119+ shapeAssetRef. assetPtr .registerRefreshNotify (this );
120120}
121121
122122// #define TRACK_DEBRIS_DATA_CLONES
@@ -152,7 +152,7 @@ DebrisData::DebrisData(const DebrisData& other, bool temp_clone) : GameBaseData(
152152 terminalVelocity = other.terminalVelocity ;
153153 ignoreWater = other.ignoreWater ;
154154
155- mShapeAsset = other.mShapeAsset ;
155+ shapeAssetRef = other.shapeAssetRef ;
156156
157157 textureName = other.textureName ;
158158 explosionId = other.explosionId ; // -- for pack/unpack of explosion ptr
@@ -190,8 +190,8 @@ DebrisData* DebrisData::cloneAndPerformSubstitutions(const SimObject* owner, S32
190190}
191191
192192void DebrisData::onPerformSubstitutions ()
193- {
194- _setShape ( _getShapeAssetId ()) ;
193+ {
194+ shapeAssetRef = shapeAssetRef. assetId ;
195195}
196196
197197bool DebrisData::onAdd ()
@@ -278,17 +278,21 @@ bool DebrisData::preload(bool server, String &errorStr)
278278
279279 if ( server ) return true ;
280280
281- if (getShape ())
281+ if (!shapeAssetRef. isNull ())
282282 {
283- TSShapeInstance* pDummy = new TSShapeInstance (getShape (), !server);
284- delete pDummy;
285- if (!server && !getShape ()->preloadMaterialList (getShapeFile ()) && NetConnection::filesWereDownloaded ())
283+ Resource<TSShape> shape = shapeAssetRef.assetPtr ->getShapeResource ();
284+ if (shape)
285+ {
286+ TSShapeInstance* pDummy = new TSShapeInstance (shape, !server);
287+ delete pDummy;
288+ if (!server && !shapeAssetRef.assetPtr ->preloadMaterialList () && NetConnection::filesWereDownloaded ())
289+ return false ;
290+ }
291+ else
292+ {
293+ errorStr = String::ToString (" DebrisData(%s)::preload: Couldn't load shape \" %s\" " , getName (), shapeAssetRef.assetId );
286294 return false ;
287- }
288- else if (!mShapeAsset .isNull ())
289- {
290- errorStr = String::ToString (" DebrisData::load: Couldn't load shape \" %s\" " , _getShapeAssetId ());
291- return false ;
295+ }
292296 }
293297
294298 return true ;
@@ -305,7 +309,8 @@ void DebrisData::initPersistFields()
305309 addGroup (" Shapes" );
306310 addField (" texture" , TypeString, Offset (textureName, DebrisData),
307311 " @brief Texture imagemap to use for this debris object.\n\n Not used any more.\n " , AbstractClassRep::FIELD_HideInInspectors);
308- INITPERSISTFIELD_SHAPEASSET_REFACTOR (Shape, DebrisData, " Shape to use for this debris object." );
312+ ADD_FIELD (" shapeAsset" , TypeShapeAssetRef, Offset (shapeAssetRef, DebrisData))
313+ .doc (" Shape to use for this debris object." );
309314 endGroup (" Shapes" );
310315
311316 addGroup (" Particle Effects" );
@@ -390,7 +395,7 @@ void DebrisData::packData(BitStream* stream)
390395
391396 stream->writeString ( textureName );
392397
393- PACKDATA_ASSET_REFACTOR (Shape );
398+ AssetDatabase. packDataAsset (stream, shapeAssetRef. assetId );
394399
395400 for ( S32 i=0 ; i<DDC_NUM_EMITTERS; i++ )
396401 {
@@ -434,7 +439,7 @@ void DebrisData::unpackData(BitStream* stream)
434439
435440 textureName = stream->readSTString ();
436441
437- UNPACKDATA_ASSET_REFACTOR (Shape );
442+ shapeAssetRef = AssetDatabase. unpackDataAsset (stream );
438443
439444 for ( S32 i=0 ; i<DDC_NUM_EMITTERS; i++ )
440445 {
@@ -677,18 +682,19 @@ bool Debris::onAdd()
677682 mFriction = mDataBlock ->friction ;
678683
679684 // Setup our bounding box
680- if ( mDataBlock ->getShape ())
681- {
682- mObjBox = mDataBlock ->getShape ()->mBounds ;
683- }
684- else
685+ mObjBox = Box3F (Point3F (-1 , -1 , -1 ), Point3F (1 , 1 , 1 ));
686+
687+ Resource<TSShape> shape;
688+ if ( mDataBlock ->shapeAssetRef .notNull ())
685689 {
686- mObjBox = Box3F (Point3F (-1 , -1 , -1 ), Point3F (1 , 1 , 1 ));
690+ shape = mDataBlock ->shapeAssetRef .assetPtr ->getShapeResource ();
691+ if (shape)
692+ mObjBox = shape->mBounds ;
687693 }
688694
689- if ( mDataBlock -> getShape () )
695+ if (shape )
690696 {
691- mShape = new TSShapeInstance ( mDataBlock -> getShape () , true );
697+ mShape = new TSShapeInstance (shape , true );
692698 }
693699
694700 if ( mPart )
0 commit comments