2015-10-13 15:19:36 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Copyright (c) 2013 GarageGames, LLC
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
// IN THE SOFTWARE.
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-05-14 14:16:43 -05:00
|
|
|
#ifndef SHAPE_ASSET_H
|
|
|
|
|
#define SHAPE_ASSET_H
|
2015-10-13 15:19:36 -05:00
|
|
|
|
|
|
|
|
#ifndef _ASSET_BASE_H_
|
|
|
|
|
#include "assets/assetBase.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _ASSET_DEFINITION_H_
|
|
|
|
|
#include "assets/assetDefinition.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _STRINGUNIT_H_
|
|
|
|
|
#include "string/stringUnit.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _ASSET_FIELD_TYPES_H_
|
|
|
|
|
#include "assets/assetFieldTypes.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _TSSHAPE_H_
|
2016-01-09 00:37:41 -06:00
|
|
|
#include "ts/tsShape.h"
|
2015-10-13 15:19:36 -05:00
|
|
|
#endif
|
|
|
|
|
#ifndef __RESOURCE_H__
|
|
|
|
|
#include "core/resource.h"
|
|
|
|
|
#endif
|
2018-01-28 14:48:02 -06:00
|
|
|
#ifndef _ASSET_PTR_H_
|
|
|
|
|
#include "assets/assetPtr.h"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef MATERIALASSET_H
|
|
|
|
|
#include "MaterialAsset.h"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef SHAPE_ANIMATION_ASSET_H
|
|
|
|
|
#include "ShapeAnimationAsset.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-12-01 19:16:36 -06:00
|
|
|
#ifdef TORQUE_TOOLS
|
2018-01-28 14:48:02 -06:00
|
|
|
#include "gui/editor/guiInspectorTypes.h"
|
2020-12-01 19:16:36 -06:00
|
|
|
#endif
|
2020-12-20 19:01:43 -06:00
|
|
|
#ifndef _BITSTREAM_H_
|
|
|
|
|
#include "core/stream/bitStream.h"
|
|
|
|
|
#endif
|
2021-10-03 02:56:26 -05:00
|
|
|
#include "assetMacroHelpers.h"
|
2015-10-13 15:19:36 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
class ShapeAsset : public AssetBase
|
|
|
|
|
{
|
|
|
|
|
typedef AssetBase Parent;
|
2023-10-08 13:19:43 -05:00
|
|
|
typedef AssetPtr<ShapeAsset> ConcreteAssetPtr;
|
2015-10-13 15:19:36 -05:00
|
|
|
|
|
|
|
|
public:
|
2020-12-01 19:16:36 -06:00
|
|
|
enum ShapeAssetErrCode
|
|
|
|
|
{
|
|
|
|
|
TooManyVerts = AssetErrCode::Extended,
|
|
|
|
|
TooManyBones,
|
2020-12-03 15:37:51 -06:00
|
|
|
MissingAnimatons,
|
|
|
|
|
Extended
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
static StringTableEntry smNoShapeAssetFallback;
|
|
|
|
|
|
2023-10-08 13:19:43 -05:00
|
|
|
static const String mErrCodeStrings[U32(ShapeAssetErrCode::Extended) - U32(Parent::Extended) + 1];
|
|
|
|
|
static U32 getAssetErrCode(ConcreteAssetPtr checkAsset) { if (checkAsset) return checkAsset->mLoadedState; else return 0; }
|
2021-07-19 01:07:08 -05:00
|
|
|
|
2020-12-03 15:37:51 -06:00
|
|
|
static String getAssetErrstrn(U32 errCode)
|
|
|
|
|
{
|
|
|
|
|
if (errCode < Parent::Extended) return Parent::getAssetErrstrn(errCode);
|
|
|
|
|
if (errCode > ShapeAssetErrCode::Extended) return "undefined error";
|
2023-10-08 13:19:43 -05:00
|
|
|
return mErrCodeStrings[errCode - Parent::Extended];
|
2020-12-01 19:16:36 -06:00
|
|
|
};
|
|
|
|
|
|
2025-06-20 15:58:20 +01:00
|
|
|
private:
|
|
|
|
|
StringTableEntry mShapeFile;
|
|
|
|
|
StringTableEntry mConstructorFileName;
|
|
|
|
|
StringTableEntry mDiffuseImposterFileName;
|
|
|
|
|
StringTableEntry mNormalImposterFileName;
|
|
|
|
|
|
|
|
|
|
//Material assets we're dependent on and use
|
|
|
|
|
Vector<StringTableEntry> mMaterialAssetIds;
|
|
|
|
|
Vector<AssetPtr<MaterialAsset>> mMaterialAssets;
|
|
|
|
|
|
|
|
|
|
//Animation assets we're dependent on and use
|
|
|
|
|
Vector<StringTableEntry> mAnimationAssetIds;
|
|
|
|
|
Vector<AssetPtr<ShapeAnimationAsset>> mAnimationAssets;
|
|
|
|
|
|
|
|
|
|
Resource<TSShape> mShape;
|
|
|
|
|
public:
|
|
|
|
|
|
2015-10-13 15:19:36 -05:00
|
|
|
ShapeAsset();
|
|
|
|
|
virtual ~ShapeAsset();
|
|
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
/// Set up some global script interface stuff.
|
|
|
|
|
static void consoleInit();
|
|
|
|
|
|
2015-10-13 15:19:36 -05:00
|
|
|
/// Engine.
|
|
|
|
|
static void initPersistFields();
|
2024-03-18 18:13:00 +00:00
|
|
|
void copyTo(SimObject* object) override;
|
2015-10-13 15:19:36 -05:00
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
virtual void setDataField(StringTableEntry slotName, StringTableEntry array, StringTableEntry value);
|
2018-01-28 14:48:02 -06:00
|
|
|
|
2015-10-13 15:19:36 -05:00
|
|
|
/// Declare Console Object.
|
|
|
|
|
DECLARE_CONOBJECT(ShapeAsset);
|
|
|
|
|
|
2024-04-06 14:48:22 -05:00
|
|
|
U32 load() override;
|
2015-10-13 15:19:36 -05:00
|
|
|
|
2025-07-06 19:51:55 -05:00
|
|
|
TSShape* getShape() { load(); return mShape; }
|
2015-10-13 15:19:36 -05:00
|
|
|
|
2023-11-12 16:33:17 -06:00
|
|
|
Resource<TSShape> getShapeResource() { load(); return mShape; }
|
2016-05-13 23:14:55 -05:00
|
|
|
|
2018-01-28 14:48:02 -06:00
|
|
|
void SplitSequencePathAndName(String& srcPath, String& srcName);
|
2021-07-19 01:07:08 -05:00
|
|
|
|
2025-06-20 15:58:20 +01:00
|
|
|
U32 getShapeFilenameHash() { return _StringTable::hashString(mShapeFile); }
|
2018-01-28 14:48:02 -06:00
|
|
|
|
2019-05-04 11:49:42 -05:00
|
|
|
Vector<AssetPtr<MaterialAsset>> getMaterialAssets() { return mMaterialAssets; }
|
|
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
inline AssetPtr<MaterialAsset> getMaterialAsset(U32 matId)
|
|
|
|
|
{
|
|
|
|
|
if (matId >= mMaterialAssets.size())
|
|
|
|
|
return nullptr;
|
|
|
|
|
else
|
|
|
|
|
return mMaterialAssets[matId];
|
2019-05-04 11:49:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clearMaterialAssets() { mMaterialAssets.clear(); }
|
|
|
|
|
|
|
|
|
|
void addMaterialAssets(AssetPtr<MaterialAsset> matPtr) { mMaterialAssets.push_back(matPtr); }
|
|
|
|
|
|
2018-01-28 14:48:02 -06:00
|
|
|
S32 getMaterialCount() { return mMaterialAssets.size(); }
|
|
|
|
|
S32 getAnimationCount() { return mAnimationAssets.size(); }
|
|
|
|
|
ShapeAnimationAsset* getAnimation(S32 index);
|
|
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
void _onResourceChanged(const Torque::Path& path);
|
2019-05-04 11:49:42 -05:00
|
|
|
|
|
|
|
|
void setShapeFile(const char* pScriptFile);
|
2025-06-20 15:58:20 +01:00
|
|
|
inline StringTableEntry getShapeFile(void) const { return mShapeFile; };
|
2019-05-04 11:49:42 -05:00
|
|
|
|
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path
Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc
Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector
Adjusted expand behavior of guiTree to be more reliable
Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields
Removed redundant PreMult translucency type code
Added setting of feature so probes work when in forward/basic lit mode
Corrected indexing error in SQLiteObject class so it properly parses with the updated console API
Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy
Fixed var when trying to bind the camera to the client
Added project setting field to dictate the default render mode between Forward or Deferred
Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field
Integrated DOF PostFX into updated PostFX Editor paradigm
Updated setting group name for vignette postFX
Shifted shaderCache to be in data/cache along with other cached files
Added helper function to replace strings in a file
Fixed ExampleCppObject asset to have correct loose file references
Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default
Fixed verve reference to root scene group
Adjusted location of a nonmodal gui profile so it loads at the correct time
Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag
Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful
Initial work into zip and folder drag-and-drop asset importing support
Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions
Updated example asset type file
Ensured all asset types have proper handling for move, rename and delete actions
Fixed double-click behavior on folders in the AB
Fixed CPP asset preview
Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser
Added ability to convert a non-module top-level folder in the AB into a module
Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules
Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake
Fixed convex editor's material handling to work with AB and reference back properly
Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow
Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open
Added some additional common text gui profiles
Disabled calls to old editor settings logic in various editors to remove spam
Added callOnModules call so tools can initialize properly when the world editor is opened
Fixed logic test for visualizers
Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 01:47:28 -06:00
|
|
|
void setShapeConstructorFile(const char* pScriptFile);
|
|
|
|
|
inline StringTableEntry getShapeConstructorFile(void) const { return mConstructorFileName; };
|
|
|
|
|
|
2021-12-10 00:01:26 -06:00
|
|
|
//Imposter images
|
|
|
|
|
void setDiffuseImposterFile(const char* pImageFile);
|
|
|
|
|
inline StringTableEntry getDiffuseImposterFile(void) const { return mDiffuseImposterFileName; };
|
|
|
|
|
|
|
|
|
|
void setNormalImposterFile(const char* pImageFile);
|
2025-06-20 17:13:20 +01:00
|
|
|
inline StringTableEntry getNormalImposterFile(void) const { return mNormalImposterFileName; };
|
2021-12-10 00:01:26 -06:00
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
2020-12-01 19:16:36 -06:00
|
|
|
|
2020-04-15 12:15:12 -05:00
|
|
|
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
2020-12-01 19:16:36 -06:00
|
|
|
static U32 getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
2020-03-19 09:47:38 -05:00
|
|
|
|
2021-01-27 01:54:26 -06:00
|
|
|
#ifdef TORQUE_TOOLS
|
2021-12-24 17:26:45 -06:00
|
|
|
const char* generateCachedPreviewImage(S32 resolution, String overrideMaterial = "");
|
2021-01-27 01:54:26 -06:00
|
|
|
#endif
|
|
|
|
|
|
2015-10-13 15:19:36 -05:00
|
|
|
protected:
|
2025-06-20 15:58:20 +01:00
|
|
|
// Asset Base callback
|
|
|
|
|
void initializeAsset(void) override;
|
|
|
|
|
void onAssetRefresh(void) override;
|
2019-05-04 11:49:42 -05:00
|
|
|
|
2025-06-20 15:58:20 +01:00
|
|
|
/// Taml callbacks.
|
|
|
|
|
void onTamlPreWrite(void) override;
|
|
|
|
|
void onTamlPostWrite(void) override;
|
|
|
|
|
|
|
|
|
|
protected:
|
2021-07-19 01:07:08 -05:00
|
|
|
static bool setShapeFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setShapeFile(data); return false; }
|
2019-05-04 11:49:42 -05:00
|
|
|
static const char* getShapeFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getShapeFile(); }
|
2025-06-20 15:58:20 +01:00
|
|
|
static bool writeShapeFile(void* obj, StringTableEntry pFieldName) { return static_cast<ShapeAsset*>(obj)->getShapeFile() != StringTable->EmptyString(); }
|
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path
Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc
Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector
Adjusted expand behavior of guiTree to be more reliable
Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields
Removed redundant PreMult translucency type code
Added setting of feature so probes work when in forward/basic lit mode
Corrected indexing error in SQLiteObject class so it properly parses with the updated console API
Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy
Fixed var when trying to bind the camera to the client
Added project setting field to dictate the default render mode between Forward or Deferred
Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field
Integrated DOF PostFX into updated PostFX Editor paradigm
Updated setting group name for vignette postFX
Shifted shaderCache to be in data/cache along with other cached files
Added helper function to replace strings in a file
Fixed ExampleCppObject asset to have correct loose file references
Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default
Fixed verve reference to root scene group
Adjusted location of a nonmodal gui profile so it loads at the correct time
Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag
Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful
Initial work into zip and folder drag-and-drop asset importing support
Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions
Updated example asset type file
Ensured all asset types have proper handling for move, rename and delete actions
Fixed double-click behavior on folders in the AB
Fixed CPP asset preview
Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser
Added ability to convert a non-module top-level folder in the AB into a module
Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules
Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake
Fixed convex editor's material handling to work with AB and reference back properly
Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow
Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open
Added some additional common text gui profiles
Disabled calls to old editor settings logic in various editors to remove spam
Added callOnModules call so tools can initialize properly when the world editor is opened
Fixed logic test for visualizers
Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 01:47:28 -06:00
|
|
|
|
|
|
|
|
static bool setShapeConstructorFile(void* obj, const char* index, const char* data) { static_cast<ShapeAsset*>(obj)->setShapeConstructorFile(data); return false; }
|
|
|
|
|
static const char* getShapeConstructorFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getShapeConstructorFile(); }
|
|
|
|
|
|
2021-12-10 00:01:26 -06:00
|
|
|
static bool setDiffuseImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setDiffuseImposterFile(data); return false; }
|
|
|
|
|
static const char* getDiffuseImposterFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getDiffuseImposterFile(); }
|
2025-06-20 15:58:20 +01:00
|
|
|
|
2021-12-10 00:01:26 -06:00
|
|
|
static bool setNormalImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setNormalImposterFile(data); return false; }
|
2025-06-20 17:13:20 +01:00
|
|
|
static const char* getNormalImposterFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getNormalImposterFile(); }
|
2015-10-13 15:19:36 -05:00
|
|
|
};
|
|
|
|
|
|
2020-04-15 12:15:12 -05:00
|
|
|
DefineConsoleType(TypeShapeAssetId, String)
|
2018-01-28 14:48:02 -06:00
|
|
|
|
2025-06-19 13:34:07 +01:00
|
|
|
DECLARE_STRUCT(AssetPtr<ShapeAsset>)
|
2025-06-20 15:58:20 +01:00
|
|
|
DefineConsoleType(TypeShapeAssetPtr, AssetPtr<ShapeAsset>)
|
2025-06-19 13:34:07 +01:00
|
|
|
|
2022-06-13 12:38:08 -05:00
|
|
|
#ifdef TORQUE_TOOLS
|
2018-01-28 14:48:02 -06:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// TypeAssetId GuiInspectorField Class
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
class GuiInspectorTypeShapeAssetPtr : public GuiInspectorTypeFileName
|
|
|
|
|
{
|
|
|
|
|
typedef GuiInspectorTypeFileName Parent;
|
|
|
|
|
public:
|
|
|
|
|
|
2022-12-08 20:00:55 -06:00
|
|
|
GuiTextCtrl* mLabel;
|
|
|
|
|
GuiBitmapButtonCtrl* mPreviewBorderButton;
|
|
|
|
|
GuiBitmapCtrl* mPreviewImage;
|
|
|
|
|
GuiButtonCtrl* mEditButton;
|
2018-01-28 14:48:02 -06:00
|
|
|
|
|
|
|
|
DECLARE_CONOBJECT(GuiInspectorTypeShapeAssetPtr);
|
|
|
|
|
static void consoleInit();
|
|
|
|
|
|
2024-03-18 18:13:00 +00:00
|
|
|
GuiControl* constructEditControl() override;
|
|
|
|
|
bool updateRects() override;
|
2022-12-08 20:00:55 -06:00
|
|
|
|
2024-03-18 18:13:00 +00:00
|
|
|
void updateValue() override;
|
2022-12-08 20:00:55 -06:00
|
|
|
|
|
|
|
|
void updatePreviewImage();
|
|
|
|
|
void setPreviewImage(StringTableEntry assetId);
|
2018-01-28 14:48:02 -06:00
|
|
|
};
|
2015-10-13 15:19:36 -05:00
|
|
|
|
2020-04-15 12:15:12 -05:00
|
|
|
class GuiInspectorTypeShapeAssetId : public GuiInspectorTypeShapeAssetPtr
|
|
|
|
|
{
|
|
|
|
|
typedef GuiInspectorTypeShapeAssetPtr Parent;
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
DECLARE_CONOBJECT(GuiInspectorTypeShapeAssetId);
|
|
|
|
|
static void consoleInit();
|
|
|
|
|
};
|
2021-07-19 01:07:08 -05:00
|
|
|
|
2025-06-20 15:58:20 +01:00
|
|
|
#endif
|
2025-06-19 13:34:07 +01:00
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// REFACTOR
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#pragma region Refactor Asset Macros
|
|
|
|
|
|
|
|
|
|
#define DECLARE_SHAPEASSET_REFACTOR(className, name) \
|
|
|
|
|
private: \
|
|
|
|
|
AssetPtr<ShapeAsset> m##name##Asset; \
|
|
|
|
|
StringTableEntry m##name##File = StringTable->EmptyString(); \
|
|
|
|
|
public: \
|
|
|
|
|
void _set##name(StringTableEntry _in) { \
|
|
|
|
|
if (m##name##Asset.getAssetId() == _in) \
|
|
|
|
|
return; \
|
|
|
|
|
if(get##name##File() == _in) \
|
|
|
|
|
return; \
|
2025-06-19 16:58:44 +01:00
|
|
|
if(_in == NULL || _in == StringTable->EmptyString() || _in == "") \
|
2025-06-19 13:34:07 +01:00
|
|
|
{ \
|
|
|
|
|
m##name##Asset = NULL; \
|
|
|
|
|
m##name##File = ""; \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
|
|
{ \
|
|
|
|
|
StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
|
|
AssetQuery query; \
|
|
|
|
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
|
|
if (foundAssetcount != 0) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = query.mAssetList[0]; \
|
|
|
|
|
} \
|
|
|
|
|
else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
|
|
if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
|
|
{ \
|
|
|
|
|
ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
|
|
privateShape->setShapeFile(_in); \
|
|
|
|
|
shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
|
|
shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
|
|
} \
|
|
|
|
|
m##name##Asset = shapeAssetId; \
|
|
|
|
|
m##name##File = _in; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
m##name##Asset = _in; \
|
|
|
|
|
m##name##File = get##name##File(); \
|
|
|
|
|
} \
|
|
|
|
|
}; \
|
|
|
|
|
\
|
|
|
|
|
inline StringTableEntry _get##name##AssetId(void) const { return m##name##Asset.getAssetId(); } \
|
2025-07-06 19:51:55 -05:00
|
|
|
TSShape* get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShape(); else return NULL; } \
|
2025-06-19 13:34:07 +01:00
|
|
|
AssetPtr<ShapeAsset> get##name##Asset(void) { return m##name##Asset; } \
|
|
|
|
|
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false; } \
|
2025-06-20 15:58:20 +01:00
|
|
|
StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; }
|
2025-06-19 13:34:07 +01:00
|
|
|
|
|
|
|
|
#define DECLARE_SHAPEASSET_NET_REFACTOR(className, name, mask) \
|
|
|
|
|
private: \
|
|
|
|
|
AssetPtr<ShapeAsset> m##name##Asset; \
|
|
|
|
|
StringTableEntry m##name##File = StringTable->EmptyString(); \
|
|
|
|
|
public: \
|
|
|
|
|
void _set##name(StringTableEntry _in) { \
|
|
|
|
|
if (m##name##Asset.getAssetId() == _in) \
|
|
|
|
|
return; \
|
|
|
|
|
if(get##name##File() == _in) \
|
|
|
|
|
return; \
|
2025-06-19 16:58:44 +01:00
|
|
|
if(_in == NULL || _in == StringTable->EmptyString() || _in == "") \
|
2025-06-19 13:34:07 +01:00
|
|
|
{ \
|
|
|
|
|
m##name##Asset = NULL; \
|
|
|
|
|
m##name##File = ""; \
|
|
|
|
|
setMaskBits(mask); \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
|
|
{ \
|
|
|
|
|
StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
|
|
AssetQuery query; \
|
|
|
|
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
|
|
if (foundAssetcount != 0) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = query.mAssetList[0]; \
|
|
|
|
|
} \
|
|
|
|
|
else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
|
|
if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
|
|
{ \
|
|
|
|
|
ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
|
|
privateShape->setShapeFile(_in); \
|
|
|
|
|
shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
|
|
shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
|
|
} \
|
|
|
|
|
m##name##Asset = shapeAssetId; \
|
|
|
|
|
m##name##File = _in; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
m##name##Asset = _in; \
|
|
|
|
|
m##name##File = get##name##File(); \
|
|
|
|
|
} \
|
|
|
|
|
setMaskBits(mask); \
|
|
|
|
|
}; \
|
|
|
|
|
\
|
|
|
|
|
inline StringTableEntry _get##name##AssetId(void) const { return m##name##Asset.getAssetId(); } \
|
2025-07-06 19:51:55 -05:00
|
|
|
TSShape* get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShape(); else return NULL; } \
|
2025-06-19 13:34:07 +01:00
|
|
|
AssetPtr<ShapeAsset> get##name##Asset(void) { return m##name##Asset; } \
|
|
|
|
|
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false; } \
|
2025-06-20 15:58:20 +01:00
|
|
|
StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; }
|
2025-06-19 13:34:07 +01:00
|
|
|
|
2025-07-06 19:51:55 -05:00
|
|
|
#define INITPERSISTFIELD_SHAPEASSET_REFACTOR(name, consoleClass, docs) \
|
2025-06-20 15:58:20 +01:00
|
|
|
addProtectedField(assetText(name, Asset), TypeShapeAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.)); \
|
2025-06-19 13:34:07 +01:00
|
|
|
addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DECLARE_SHAPEASSET_ARRAY_REFACTOR(className, name, max) \
|
|
|
|
|
private: \
|
|
|
|
|
AssetPtr<ShapeAsset> m##name##Asset[max]; \
|
|
|
|
|
StringTableEntry m##name##File[max] = {StringTable->EmptyString() }; \
|
|
|
|
|
public: \
|
|
|
|
|
void _set##name(StringTableEntry _in, const U32& index){ \
|
|
|
|
|
if (m##name##Asset[index].getAssetId() == _in) \
|
|
|
|
|
return; \
|
|
|
|
|
if(get##name##File(index) == _in) \
|
|
|
|
|
return; \
|
2025-06-19 16:58:44 +01:00
|
|
|
if(_in == NULL || _in == StringTable->EmptyString() || _in == "") \
|
2025-06-19 13:34:07 +01:00
|
|
|
{ \
|
|
|
|
|
m##name##Asset[index] = NULL; \
|
|
|
|
|
m##name##File[index] = ""; \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
|
|
{ \
|
|
|
|
|
StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
|
|
AssetQuery query; \
|
|
|
|
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
|
|
if (foundAssetcount != 0) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = query.mAssetList[0]; \
|
|
|
|
|
} \
|
|
|
|
|
else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
|
|
if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
|
|
{ \
|
|
|
|
|
ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
|
|
privateShape->setShapeFile(_in); \
|
|
|
|
|
shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
|
|
shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
|
|
} \
|
|
|
|
|
m##name##Asset[index] = shapeAssetId; \
|
|
|
|
|
m##name##File[index] = _in; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
m##name##Asset[index] = _in; \
|
|
|
|
|
m##name##File[index] = get##name##File(index); \
|
|
|
|
|
} \
|
2025-06-19 14:10:00 +01:00
|
|
|
}; \
|
|
|
|
|
\
|
|
|
|
|
inline StringTableEntry _get##name##AssetId(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
|
2025-07-06 19:51:55 -05:00
|
|
|
TSShape* get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShape(); else return NULL; } \
|
2025-06-19 14:10:00 +01:00
|
|
|
AssetPtr<ShapeAsset> 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<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}\
|
2025-06-20 15:58:20 +01:00
|
|
|
StringTableEntry get##name##File(const U32& idx) { return m##name##Asset[idx].notNull() ? m##name##Asset[idx]->getShapeFile() : ""; }
|
2025-06-19 14:10:00 +01:00
|
|
|
|
|
|
|
|
#define DECLARE_SHAPEASSET_ARRAY_NET_REFACTOR(className, name, max, mask) \
|
|
|
|
|
private: \
|
|
|
|
|
AssetPtr<ShapeAsset> m##name##Asset[max]; \
|
|
|
|
|
StringTableEntry m##name##File[max] = {StringTable->EmptyString() }; \
|
|
|
|
|
public: \
|
|
|
|
|
void _set##name(StringTableEntry _in, const U32& index){ \
|
|
|
|
|
if (m##name##Asset[index].getAssetId() == _in) \
|
|
|
|
|
return; \
|
|
|
|
|
if(get##name##File(index) == _in) \
|
|
|
|
|
return; \
|
|
|
|
|
if (_in == NULL || _in == StringTable->EmptyString()) \
|
|
|
|
|
{ \
|
|
|
|
|
m##name##Asset[index] = NULL; \
|
|
|
|
|
m##name##File[index] = ""; \
|
|
|
|
|
setMaskBits(mask); \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
|
|
{ \
|
|
|
|
|
StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
|
|
AssetQuery query; \
|
|
|
|
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
|
|
if (foundAssetcount != 0) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = query.mAssetList[0]; \
|
|
|
|
|
} \
|
|
|
|
|
else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
|
|
{ \
|
|
|
|
|
shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
|
|
if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
|
|
{ \
|
|
|
|
|
ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
|
|
privateShape->setShapeFile(_in); \
|
|
|
|
|
shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
|
|
shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
|
|
} \
|
|
|
|
|
m##name##Asset[index] = shapeAssetId; \
|
|
|
|
|
m##name##File[index] = _in; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
m##name##Asset[index] = _in; \
|
|
|
|
|
m##name##File[index] = get##name##File(index); \
|
|
|
|
|
} \
|
|
|
|
|
setMaskBits(mask); \
|
2025-06-19 13:34:07 +01:00
|
|
|
}; \
|
|
|
|
|
\
|
|
|
|
|
inline StringTableEntry _get##name##AssetId(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
|
2025-07-06 19:51:55 -05:00
|
|
|
TSShape* get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShape(); else return NULL; } \
|
2025-06-19 13:34:07 +01:00
|
|
|
AssetPtr<ShapeAsset> 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<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}\
|
2025-06-20 15:58:20 +01:00
|
|
|
StringTableEntry get##name##File(const U32& idx) { return m##name##Asset[idx].notNull() ? m##name##Asset[idx]->getShapeFile() : ""; }
|
2025-06-19 13:34:07 +01:00
|
|
|
|
|
|
|
|
#define INITPERSISTFIELD_SHAPEASSET_ARRAY_REFACTOR(name, arraySize, consoleClass, docs) \
|
2025-06-20 15:58:20 +01:00
|
|
|
addProtectedField(assetText(name, Asset), TypeShapeAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));\
|
2025-06-19 13:34:07 +01:00
|
|
|
addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));
|
|
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// REFACTOR END
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
2021-07-19 01:07:08 -05:00
|
|
|
#endif
|