diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index 150f60b80..2328280da 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -122,7 +122,7 @@ public: U32 load() override; - TSShape* getShape() { return mShape; } + TSShape* getShape() { load(); return mShape; } Resource getShapeResource() { load(); return mShape; } @@ -295,7 +295,7 @@ public: }; \ \ inline StringTableEntry _get##name##AssetId(void) const { return m##name##Asset.getAssetId(); } \ - Resource get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShapeResource(); else return ResourceManager::get().load( "" ); } \ + TSShape* get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShape(); else return NULL; } \ AssetPtr get##name##Asset(void) { return m##name##Asset; } \ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast(obj)->_set##name(_getStringTable()->insert(data)); return false; } \ StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; } @@ -353,12 +353,12 @@ public: }; \ \ inline StringTableEntry _get##name##AssetId(void) const { return m##name##Asset.getAssetId(); } \ - Resource get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShapeResource(); else return ResourceManager::get().load( "" ); } \ + TSShape* get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShape(); else return NULL; } \ AssetPtr get##name##Asset(void) { return m##name##Asset; } \ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast(obj)->_set##name(_getStringTable()->insert(data)); return false; } \ StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; } -#define INITPERSISTFIELD_SHAPEASSET_REFACTOR(name, consoleClass, docs) \ +#define INITPERSISTFIELD_SHAPEASSET_REFACTOR(name, consoleClass, docs) \ addProtectedField(assetText(name, Asset), TypeShapeAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.)); \ addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.)); @@ -414,7 +414,7 @@ public: }; \ \ inline StringTableEntry _get##name##AssetId(const U32& index) const { return m##name##Asset[index].getAssetId(); } \ - Resource get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShapeResource(); else return ResourceManager::get().load( "" ); } \ + TSShape* get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShape(); else return NULL; } \ AssetPtr get##name##Asset(const U32& index) { return m##name##Asset[index]; } \ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}\ StringTableEntry get##name##File(const U32& idx) { return m##name##Asset[idx].notNull() ? m##name##Asset[idx]->getShapeFile() : ""; } @@ -472,7 +472,7 @@ public: }; \ \ inline StringTableEntry _get##name##AssetId(const U32& index) const { return m##name##Asset[index].getAssetId(); } \ - Resource get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShapeResource(); else return ResourceManager::get().load( "" ); } \ + TSShape* get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShape(); else return NULL; } \ AssetPtr get##name##Asset(const U32& index) { return m##name##Asset[index]; } \ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}\ StringTableEntry get##name##File(const U32& idx) { return m##name##Asset[idx].notNull() ? m##name##Asset[idx]->getShapeFile() : ""; } diff --git a/Engine/source/T3D/debris.cpp b/Engine/source/T3D/debris.cpp index b7566ab72..19b03c6ae 100644 --- a/Engine/source/T3D/debris.cpp +++ b/Engine/source/T3D/debris.cpp @@ -274,21 +274,20 @@ bool DebrisData::preload(bool server, String &errorStr) if( server ) return true; - if (mShapeAsset.notNull()) + if (getShape()) { - if (!getShape()) - { - errorStr = String::ToString("DebrisData::load: Couldn't load shape \"%s\"", _getShapeAssetId()); - return false; - } - else { TSShapeInstance* pDummy = new TSShapeInstance(getShape(), !server); delete pDummy; - if (!server && !getShape()->preloadMaterialList(getShape().getPath()) && NetConnection::filesWereDownloaded()) + if (!server && !getShape()->preloadMaterialList(getShapeFile()) && NetConnection::filesWereDownloaded()) return false; } } + else + { + errorStr = String::ToString("DebrisData::load: Couldn't load shape \"%s\"", _getShapeAssetId()); + return false; + } return true; } diff --git a/Engine/source/T3D/examples/renderShapeExample.cpp b/Engine/source/T3D/examples/renderShapeExample.cpp index 2762cfe9b..bbfc7ac30 100644 --- a/Engine/source/T3D/examples/renderShapeExample.cpp +++ b/Engine/source/T3D/examples/renderShapeExample.cpp @@ -191,7 +191,7 @@ void RenderShapeExample::createShape() // Attempt to preload the Materials for this shape if ( isClientObject() && - !getShape()->preloadMaterialList(getShape().getPath() ) && + !getShape()->preloadMaterialList(getShapeFile()) && NetConnection::filesWereDownloaded() ) { return; diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index f28a90b72..f30709905 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -896,7 +896,7 @@ bool ExplosionData::preload(bool server, String &errorStr) } } - if (mExplosionShapeAsset.notNull()) { + if (getExplosionShape()) { // Resolve animations explosionAnimation = getExplosionShape()->findSequence("ambient"); diff --git a/Engine/source/T3D/fx/groundCover.cpp b/Engine/source/T3D/fx/groundCover.cpp index bf53746cb..130ae2883 100644 --- a/Engine/source/T3D/fx/groundCover.cpp +++ b/Engine/source/T3D/fx/groundCover.cpp @@ -889,7 +889,7 @@ void GroundCover::_initShapes() if ( mShapeAsset[i].isNull() || getShape(i) == nullptr) continue; - if ( isClientObject() && !getShape(i)->preloadMaterialList(getShape(i).getPath()) && NetConnection::filesWereDownloaded() ) + if ( isClientObject() && !getShape(i)->preloadMaterialList(getShapeFile(i)) && NetConnection::filesWereDownloaded() ) { Con::warnf( "GroundCover::_initShapes() material preload failed for shape: %s", _getShapeAssetId(i)); continue; diff --git a/Engine/source/T3D/guiObjectView.cpp b/Engine/source/T3D/guiObjectView.cpp index c086c85ac..f6699c037 100644 --- a/Engine/source/T3D/guiObjectView.cpp +++ b/Engine/source/T3D/guiObjectView.cpp @@ -345,7 +345,7 @@ bool GuiObjectView::setObjectModel( const String& modelName ) return false; } - if (!getModel()->preloadMaterialList(getModel().getPath())) return false; + if (!getModel()->preloadMaterialList(getModelFile())) return false; // Instantiate it. @@ -398,7 +398,7 @@ bool GuiObjectView::setMountedObject( const String& modelName ) return false; } - if (!getMountedModel()->preloadMaterialList(getMountedModel().getPath())) return false; + if (!getMountedModel()->preloadMaterialList(getMountedModelFile())) return false; mMountedModelInstance = new TSShapeInstance(getMountedModel(), true); mMountedModelInstance->resetMaterialList(); diff --git a/Engine/source/T3D/guiObjectView.h b/Engine/source/T3D/guiObjectView.h index a6e3535b9..da460e452 100644 --- a/Engine/source/T3D/guiObjectView.h +++ b/Engine/source/T3D/guiObjectView.h @@ -274,10 +274,10 @@ class GuiObjectView : public GuiTSCtrl, protected AssetPtrCallback protected: void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override { - if (mModelAsset.notNull()) + if (getModel()) setObjectModel(_getModelAssetId()); - if (mMountedModelAsset.notNull()) + if (getMountedModel()) setMountedObject(_getMountedModelAssetId()); } }; diff --git a/Engine/source/T3D/physics/physicsDebris.cpp b/Engine/source/T3D/physics/physicsDebris.cpp index 35fee7a34..010d1aff5 100644 --- a/Engine/source/T3D/physics/physicsDebris.cpp +++ b/Engine/source/T3D/physics/physicsDebris.cpp @@ -97,7 +97,7 @@ bool PhysicsDebrisData::preload( bool server, String &errorStr ) if ( server ) return true; - if ( mShapeAsset.notNull() ) + if ( getShape() ) { // Create a dummy shape to force the generation of shaders and materials // during the level load and not during gameplay. diff --git a/Engine/source/T3D/physics/physicsShape.cpp b/Engine/source/T3D/physics/physicsShape.cpp index 55e488009..da95d4ef7 100644 --- a/Engine/source/T3D/physics/physicsShape.cpp +++ b/Engine/source/T3D/physics/physicsShape.cpp @@ -285,16 +285,15 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer ) bool shapeError = false; - if (mShapeAsset.notNull()) + if (getShape()) { - if (bool(getShape()) == false) - { - errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", _getShapeAssetId()); - return false; - } - if (!server && !getShape()->preloadMaterialList(getShape().getPath()) && NetConnection::filesWereDownloaded()) + if (!server && !getShape()->preloadMaterialList(getShapeFile()) && NetConnection::filesWereDownloaded()) shapeError = true; - + } + else + { + errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", _getShapeAssetId()); + return false; } // Prepare the shared physics collision shape. diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 4453dd8bf..a0f4093ca 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -615,18 +615,18 @@ bool PlayerData::preload(bool server, String &errorStr) return false; } - if (!server && !getShapeFP(i)->preloadMaterialList(getShapeFP(i).getPath()) && NetConnection::filesWereDownloaded()) + if (!server && !getShapeFP(i)->preloadMaterialList(getShapeFPFile(i)) && NetConnection::filesWereDownloaded()) shapeError = true; if (computeCRC) { Con::printf("Validation required for mounted image %d shape: %s", i, _getShapeFPAssetId(i)); - Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(getShapeFP(i).getPath()); + Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(getShapeFPFile(i)); if (!fileRef) { - errorStr = String::ToString("PlayerData: Mounted image %d loading failed, shape \"%s\" is not found.", i, getShapeFP(i).getPath().getFullPath().c_str()); + errorStr = String::ToString("PlayerData: Mounted image %d loading failed, shape \"%s\" is not found.", i, getShapeFPFile(i)); return false; } diff --git a/Engine/source/T3D/projectile.cpp b/Engine/source/T3D/projectile.cpp index cf8df1065..3f63e6b7f 100644 --- a/Engine/source/T3D/projectile.cpp +++ b/Engine/source/T3D/projectile.cpp @@ -381,22 +381,18 @@ bool ProjectileData::preload(bool server, String &errorStr) Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockid(lightDesc): %d", lightDescId); } - if (mProjectileShapeAsset.notNull()) + if (getProjectileShape()) { - //If we've got a shapeAsset assigned for our projectile, but we failed to load the shape data itself, report the error - if (!getProjectileShape()) - { - errorStr = String::ToString("ProjectileData::load: Couldn't load shape \"%s\"", _getProjectileShapeAssetId()); - return false; - } - else - { - activateSeq = getProjectileShape()->findSequence("activate"); - maintainSeq = getProjectileShape()->findSequence("maintain"); + activateSeq = getProjectileShape()->findSequence("activate"); + maintainSeq = getProjectileShape()->findSequence("maintain"); - TSShapeInstance* pDummy = new TSShapeInstance(getProjectileShape(), !server); - delete pDummy; - } + TSShapeInstance* pDummy = new TSShapeInstance(getProjectileShape(), !server); + delete pDummy; + } + else + { + errorStr = String::ToString("ProjectileData::load: Couldn't load shape \"%s\"", _getProjectileShapeAssetId()); + return false; } return true; diff --git a/Engine/source/T3D/shapeBase.cpp b/Engine/source/T3D/shapeBase.cpp index af078b2e2..03a2b18eb 100644 --- a/Engine/source/T3D/shapeBase.cpp +++ b/Engine/source/T3D/shapeBase.cpp @@ -343,7 +343,7 @@ bool ShapeBaseData::preload(bool server, String &errorStr) "ShapeBaseData::preload: invalid debris data"); } - if(mDebrisShapeAsset.notNull()) + if(getDebrisShape()) { TSShapeInstance* pDummy = new TSShapeInstance(getDebrisShape(), !server); delete pDummy; @@ -351,12 +351,13 @@ bool ShapeBaseData::preload(bool server, String &errorStr) } S32 i; - if (mShapeAsset.notNull()) + if (getShape()) { + //mShapeAsset->load(); U32 assetStatus = ShapeAsset::getAssetErrCode(mShapeAsset); if (assetStatus == AssetBase::Ok || assetStatus == AssetBase::UsingFallback) { - if (!server && !getShape()->preloadMaterialList(getShape().getPath()) && NetConnection::filesWereDownloaded()) + if (!server && !getShape()->preloadMaterialList(getShapeFile()) && NetConnection::filesWereDownloaded()) shapeError = true; if (computeCRC) diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index 95281cbd6..b99123a00 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -461,7 +461,7 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr) { Con::printf("Validation required for shape asset: %s", mShapeAsset[i]->getAssetId()); - Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(getShape(i).getPath()); + Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(getShapeFile(i)); if (!fileRef) { diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 2d9f61477..1c74b6287 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -390,16 +390,10 @@ bool TSStatic::_createShape() mAmbientThread = NULL; //mShape = NULL; - if (mShapeAsset.notNull()) + if (getShape()) { - if (!getShape()) - { - Con::errorf("TSStatic::_createShape() - Shape Asset %s had no valid shape!", mShapeAsset.getAssetId()); - return false; - } - if (isClientObject() && - !getShape()->preloadMaterialList(getShape().getPath()) && + !getShape()->preloadMaterialList(getShapeFile()) && NetConnection::filesWereDownloaded()) return false; @@ -440,6 +434,11 @@ bool TSStatic::_createShape() Sim::findObject(cubeDescId, reflectorDesc); } } + else + { + Con::errorf("TSStatic::_createShape() - Shape Asset %s had no valid shape!", mShapeAsset.getAssetId()); + return false; + } //Set up the material slot vars for easy manipulation /*S32 materialCount = mShape->materialList->getMaterialNameList().size(); //mMeshAsset->getMaterialCount(); diff --git a/Engine/source/afx/afxMagicMissile.h b/Engine/source/afx/afxMagicMissile.h index 26f731ae3..15c8b2b71 100644 --- a/Engine/source/afx/afxMagicMissile.h +++ b/Engine/source/afx/afxMagicMissile.h @@ -139,7 +139,7 @@ public: */ // variables set on preload: - Resource projectileShape; + TSShape* projectileShape; /* S32 activateSeq; S32 maintainSeq; diff --git a/Engine/source/afx/ce/afxModel.cpp b/Engine/source/afx/ce/afxModel.cpp index 00a2e0f71..4915bae76 100644 --- a/Engine/source/afx/ce/afxModel.cpp +++ b/Engine/source/afx/ce/afxModel.cpp @@ -127,14 +127,8 @@ bool afxModelData::preload(bool server, String &errorStr) if (server) return true; - if (mShapeAsset.notNull()) + if (getShape()) { - if (!getShape()) - { - errorStr = String::ToString("afxModelData::load: Failed to load shape \"%s\"", _getShapeAssetId()); - return false; - } - // just parse up the string and collect the remappings in txr_tag_remappings. if (remap_txr_tags != ST_NULLSTRING) { @@ -167,7 +161,11 @@ bool afxModelData::preload(bool server, String &errorStr) delete pDummy; } } - + else + { + errorStr = String::ToString("afxModelData::load: Failed to load shape \"%s\"", _getShapeAssetId()); + return false; + } return true; } diff --git a/Engine/source/forest/forestItem.h b/Engine/source/forest/forestItem.h index 2b7337593..3f01571f0 100644 --- a/Engine/source/forest/forestItem.h +++ b/Engine/source/forest/forestItem.h @@ -143,7 +143,7 @@ public: return theSignal; } - Resource mShape; + TSShape* mShape; protected: void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override diff --git a/Engine/source/forest/ts/tsForestItemData.cpp b/Engine/source/forest/ts/tsForestItemData.cpp index 292ca564d..e27c4c80e 100644 --- a/Engine/source/forest/ts/tsForestItemData.cpp +++ b/Engine/source/forest/ts/tsForestItemData.cpp @@ -127,7 +127,7 @@ void TSForestItemData::_loadShape() return; if ( mIsClientObject && - !mShape->preloadMaterialList(mShape.getPath()) ) + !mShape->preloadMaterialList(getShapeFile()) ) return; // Lets add an autobillboard detail if don't have one. @@ -177,7 +177,7 @@ void TSForestItemData::_checkLastDetail() // TODO: Expose some real parameters to the datablock maybe? if ( detail->subShapeNum != -1 ) { - mShape->addImposter(mShape.getPath(), 10, 4, 0, 0, 256, 0, 0); + mShape->addImposter(getShapeFile(), 10, 4, 0, 0, 256, 0, 0); // HACK: If i don't do this it crashes! while ( mShape->detailCollisionAccelerators.size() < mShape->details.size() )