mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
variation on #387 that also introduces errorcodes
This commit is contained in:
parent
80eb4ab2ba
commit
220771d2fe
4 changed files with 123 additions and 23 deletions
|
|
@ -54,7 +54,9 @@
|
|||
#include "ShapeAnimationAsset.h"
|
||||
#endif
|
||||
|
||||
#ifdef TORQUE_TOOLS
|
||||
#include "gui/editor/guiInspectorTypes.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class ShapeAsset : public AssetBase
|
||||
|
|
@ -81,6 +83,13 @@ protected:
|
|||
ShapeAssetChanged mChangeSignal;
|
||||
|
||||
public:
|
||||
enum ShapeAssetErrCode
|
||||
{
|
||||
TooManyVerts = AssetErrCode::Extended,
|
||||
TooManyBones,
|
||||
MissingAnimatons
|
||||
};
|
||||
|
||||
ShapeAsset();
|
||||
virtual ~ShapeAsset();
|
||||
|
||||
|
|
@ -96,6 +105,7 @@ public:
|
|||
DECLARE_CONOBJECT(ShapeAsset);
|
||||
|
||||
bool loadShape();
|
||||
U32 mLoadedState;
|
||||
|
||||
TSShape* getShape() { return mShape; }
|
||||
|
||||
|
|
@ -138,8 +148,9 @@ public:
|
|||
inline StringTableEntry getShapeConstructorFilePath(void) const { return mConstructorFilePath; };
|
||||
|
||||
static bool getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
|
||||
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||
static bool getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
static U32 getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
|
||||
static StringTableEntry getNoShapeAssetId() { return StringTable->insert("Core_Rendering:noshape"); }
|
||||
|
||||
|
|
@ -154,6 +165,7 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
#ifdef TORQUE_TOOLS
|
||||
DefineConsoleType(TypeShapeAssetPtr, S32)
|
||||
DefineConsoleType(TypeShapeAssetId, String)
|
||||
|
||||
|
|
@ -182,6 +194,72 @@ public:
|
|||
DECLARE_CONOBJECT(GuiInspectorTypeShapeAssetId);
|
||||
static void consoleInit();
|
||||
};
|
||||
#endif
|
||||
|
||||
#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str()
|
||||
|
||||
#define initShapeAsset(name) m##name##Filename = StringTable->EmptyString(); m##name##AssetId = StringTable->EmptyString(); m##name##Asset = NULL;
|
||||
#define bindShapeAsset(name) if (m##name##AssetId != StringTable->EmptyString()) m##name##Asset = m##name##AssetId;
|
||||
|
||||
#define scriptBindShapeAsset(name, consoleClass, docs) addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Filename, consoleClass), consoleClass::_set##name##Filename, & defaultProtectedGetFn, assetText(name, docs)); \
|
||||
addProtectedField(assetText(name, Asset), TypeShapeAssetId, Offset(m##name##AssetId, consoleClass), consoleClass::_set##name##Asset, & defaultProtectedGetFn, assetText(name, asset reference.));
|
||||
|
||||
#define DECLARE_SHAPEASSET(className,name) protected: \
|
||||
StringTableEntry m##name##Filename;\
|
||||
StringTableEntry m##name##AssetId;\
|
||||
AssetPtr<ShapeAsset> m##name##Asset;\
|
||||
public: \
|
||||
const StringTableEntry& get##name() const { return m##name##Filename; }\
|
||||
void set##name(FileName _in) { m##name##Filename = _in; }\
|
||||
const AssetPtr<ShapeAsset> & get##name##Asset() const { return m##name##Asset; }\
|
||||
void set##name##Asset(AssetPtr<ShapeAsset>_in) { m##name##Asset = _in; }\
|
||||
static bool _set##name##Filename(void* obj, const char* index, const char* data)\
|
||||
{\
|
||||
className* shape = static_cast<className*>(obj);\
|
||||
\
|
||||
StringTableEntry assetId = ShapeAsset::getAssetIdByFilename(StringTable->insert(data));\
|
||||
if (assetId != StringTable->EmptyString())\
|
||||
{\
|
||||
if (shape->_set##name##Asset(obj, index, assetId))\
|
||||
{\
|
||||
if (assetId == StringTable->insert("Core_Rendering:noShape"))\
|
||||
{\
|
||||
shape->m##name##Filename = data;\
|
||||
shape->m##name##AssetId = StringTable->EmptyString();\
|
||||
\
|
||||
return true;\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
shape->m##name##AssetId = assetId;\
|
||||
shape->m##name##Filename = StringTable->EmptyString();\
|
||||
\
|
||||
return false;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
shape->m##name##Asset = StringTable->EmptyString();\
|
||||
}\
|
||||
\
|
||||
return true;\
|
||||
}\
|
||||
\
|
||||
static bool _set##name##Asset(void* obj, const char* index, const char* data)\
|
||||
{\
|
||||
className* shape = static_cast<className*>(obj);\
|
||||
shape->m##name##AssetId = StringTable->insert(data);\
|
||||
if (ShapeAsset::getAssetById(shape->m##name##AssetId, &shape->m##name##Asset))\
|
||||
{\
|
||||
if (shape->m##name##Asset.getAssetId() != StringTable->insert("Core_Rendering:noShape"))\
|
||||
shape->m##name##Filename = StringTable->EmptyString();\
|
||||
\
|
||||
shape->setMaskBits(-1);\
|
||||
return true;\
|
||||
}\
|
||||
return false;\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue