mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-11 16:30:48 +00:00
Adds handling for datablocks to be reloaded if the assets they utilize have their files directly edited.
This commit is contained in:
parent
0eafadb1a0
commit
f31acf774e
23 changed files with 121 additions and 37 deletions
|
|
@ -370,7 +370,7 @@ public: \
|
|||
|
||||
#pragma region Arrayed Asset Macros
|
||||
|
||||
#define DECLARE_SHAPEASSET_ARRAY(className,name,max) public: \
|
||||
#define DECLARE_SHAPEASSET_ARRAY(className,name,max,changeFunc) public: \
|
||||
static const U32 sm##name##Count = max;\
|
||||
Resource<TSShape>m##name[max];\
|
||||
StringTableEntry m##name##Name[max]; \
|
||||
|
|
@ -384,6 +384,10 @@ public: \
|
|||
\
|
||||
bool _set##name(StringTableEntry _in, const U32& index)\
|
||||
{\
|
||||
if (m##name##Asset[index].notNull())\
|
||||
{\
|
||||
m##name##Asset[index]->getChangedSignal().remove(this, &className::changeFunc);\
|
||||
}\
|
||||
if(m##name##AssetId[index] != _in || m##name##Name[index] != _in)\
|
||||
{\
|
||||
if(index >= sm##name##Count || index < 0)\
|
||||
|
|
@ -430,6 +434,8 @@ public: \
|
|||
if (get##name(index) != StringTable->EmptyString() && m##name##Asset[index].notNull())\
|
||||
{\
|
||||
m##name[index] = m##name##Asset[index]->getShapeResource();\
|
||||
\
|
||||
m##name##Asset[index]->getChangedSignal().notify(this, &className::changeFunc);\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
|
|
|
|||
|
|
@ -111,7 +111,10 @@ public:
|
|||
void onPerformSubstitutions() override;
|
||||
bool allowSubstitutions() const override { return true; }
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
//**************************************************************************
|
||||
|
|
|
|||
|
|
@ -143,7 +143,10 @@ public:
|
|||
ExplosionData* cloneAndPerformSubstitutions(const SimObject*, S32 index=0);
|
||||
bool allowSubstitutions() const override { return true; }
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ protected:
|
|||
RectF mBillboardRects[MAX_COVERTYPES];
|
||||
|
||||
/// The cover shape filenames.
|
||||
DECLARE_SHAPEASSET_ARRAY(GroundCover, Shape, MAX_COVERTYPES);
|
||||
DECLARE_SHAPEASSET_ARRAY(GroundCover, Shape, MAX_COVERTYPES, onShapeChanged);
|
||||
DECLARE_ASSET_ARRAY_NET_SETGET(GroundCover, Shape, -1);
|
||||
|
||||
/// The cover shape instances.
|
||||
|
|
@ -409,6 +409,8 @@ protected:
|
|||
S32 randSeed );
|
||||
|
||||
void _debugRender( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
|
||||
|
||||
void onShapeChanged(){}
|
||||
};
|
||||
|
||||
#endif // _GROUNDCOVER_H_
|
||||
|
|
|
|||
|
|
@ -92,7 +92,10 @@ class ParticleData : public SimDataBlock
|
|||
static bool protectedSetSizes(void* object, const char* index, const char* data);
|
||||
static bool protectedSetTimes(void* object, const char* index, const char* data);
|
||||
|
||||
void onImageChanged() {}
|
||||
void onImageChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
public:
|
||||
ParticleData();
|
||||
|
|
|
|||
|
|
@ -69,8 +69,14 @@ class PrecipitationData : public GameBaseData
|
|||
void packData(BitStream* stream) override;
|
||||
void unpackData(BitStream* stream) override;
|
||||
|
||||
void onDropChanged() {}
|
||||
void onSplashChanged() {}
|
||||
void onDropChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
void onSplashChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
struct Raindrop
|
||||
|
|
|
|||
|
|
@ -124,7 +124,10 @@ public:
|
|||
|
||||
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, NUM_TEX, onTextureChanged);
|
||||
DECLARE_IMAGEASSET_ARRAY_SETGET(SplashData, Texture)
|
||||
void onTextureChanged() {}
|
||||
void onTextureChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
ExplosionData* explosion;
|
||||
S32 explosionId;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,10 @@ protected:
|
|||
void _makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count );
|
||||
void _renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
|
||||
|
||||
void onImageChanged() {}
|
||||
void onImageChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,10 @@ public:
|
|||
void packData( BitStream *stream ) override;
|
||||
void unpackData( BitStream *stream ) override;
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
DECLARE_CONOBJECT( PhysicsDebrisData );
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,10 @@ public:
|
|||
SimObjectRef< ExplosionData > explosion;
|
||||
SimObjectRef< PhysicsShapeData > destroyedShape;
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
typedef PhysicsShapeData::SimType PhysicsSimType;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ struct PlayerData: public ShapeBaseData {
|
|||
/// that we don't create a TSThread on the player if we don't
|
||||
/// need to.
|
||||
|
||||
DECLARE_SHAPEASSET_ARRAY(PlayerData, ShapeFP, ShapeBase::MaxMountedImages); ///< Used to render with mounted images in first person [optional]
|
||||
DECLARE_SHAPEASSET_ARRAY(PlayerData, ShapeFP, ShapeBase::MaxMountedImages, onShapeChanged); ///< Used to render with mounted images in first person [optional]
|
||||
DECLARE_ASSET_ARRAY_SETGET(PlayerData, ShapeFP);
|
||||
|
||||
StringTableEntry imageAnimPrefixFP; ///< Passed along to mounted images to modify
|
||||
|
|
@ -366,6 +366,11 @@ struct PlayerData: public ShapeBaseData {
|
|||
void packData(BitStream* stream) override;
|
||||
void unpackData(BitStream* stream) override;
|
||||
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
/// @name Callbacks
|
||||
/// @{
|
||||
DECLARE_CALLBACK( void, onPoseChange, ( Player* obj, const char* oldPose, const char* newPose ) );
|
||||
|
|
|
|||
|
|
@ -154,7 +154,10 @@ public:
|
|||
ProjectileData(const ProjectileData&, bool = false);
|
||||
bool allowSubstitutions() const override { return true; }
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
|
|||
|
||||
S32 i;
|
||||
U32 assetStatus = ShapeAsset::getAssetErrCode(mShapeAsset);
|
||||
if (assetStatus == AssetBase::Ok|| assetStatus == AssetBase::UsingFallback)
|
||||
if (assetStatus == AssetBase::Ok || assetStatus == AssetBase::UsingFallback)
|
||||
{
|
||||
if (!server && !mShape->preloadMaterialList(mShape.getPath()) && NetConnection::filesWereDownloaded())
|
||||
shapeError = true;
|
||||
|
|
@ -904,7 +904,17 @@ void ShapeBaseData::unpackData(BitStream* stream)
|
|||
silent_bbox_check = stream->readFlag();
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
void ShapeBaseData::onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
void ShapeBaseData::onDebrisChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ struct ShapeBaseImageData: public GameBaseData {
|
|||
F32 scriptAnimTransitionTime; ///< The amount of time to transition between the previous sequence and new sequence
|
||||
///< when the script prefix has changed.
|
||||
|
||||
DECLARE_SHAPEASSET_ARRAY(ShapeBaseImageData, Shape, MaxShapes); ///< Name of shape to render.
|
||||
DECLARE_SHAPEASSET_ARRAY(ShapeBaseImageData, Shape, MaxShapes, onShapeChanged); ///< Name of shape to render.
|
||||
DECLARE_ASSET_ARRAY_SETGET(ShapeBaseImageData, Shape);
|
||||
|
||||
//DECLARE_SHAPEASSET(ShapeBaseImageData, ShapeFP); ///< Name of shape to render in first person (optional).
|
||||
|
|
@ -505,6 +505,11 @@ struct ShapeBaseImageData: public GameBaseData {
|
|||
|
||||
void handleStateSoundTrack(const U32& stateId);
|
||||
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// @name Callbacks
|
||||
|
|
@ -681,8 +686,8 @@ public:
|
|||
Vector<TextureTagRemapping> txr_tag_remappings;
|
||||
bool silent_bbox_check;
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onDebrisChanged() {}
|
||||
void onShapeChanged();
|
||||
void onDebrisChanged();
|
||||
public:
|
||||
ShapeBaseData(const ShapeBaseData&, bool = false);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,7 +74,10 @@ struct WheeledVehicleTire: public SimDataBlock
|
|||
void packData(BitStream* stream) override;
|
||||
void unpackData(BitStream* stream) override;
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,10 @@ protected:
|
|||
public:
|
||||
enum { MaxLifetimeTicks = 4095 };
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
public:
|
||||
// variables set in datablock definition:
|
||||
|
|
|
|||
|
|
@ -71,7 +71,10 @@ public:
|
|||
|
||||
static void initPersistFields();
|
||||
|
||||
void onChangeTexture() {}
|
||||
void onChangeTexture()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
DECLARE_CONOBJECT(afxBillboardData);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -94,7 +94,10 @@ public:
|
|||
|
||||
static void initPersistFields();
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
void onSequenceChanged() {}
|
||||
|
||||
DECLARE_CONOBJECT(afxModelData);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,10 @@ public:
|
|||
|
||||
static void convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg);
|
||||
|
||||
void onImageChanged() {}
|
||||
void onImageChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
public:
|
||||
DECLARE_IMAGEASSET(afxZodiacData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,10 @@ public:
|
|||
FACES_BITS = 3
|
||||
};
|
||||
|
||||
void onImageChanged() {}
|
||||
void onImageChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
|
||||
public:
|
||||
DECLARE_IMAGEASSET(afxZodiacPlaneData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile);
|
||||
|
|
|
|||
|
|
@ -425,39 +425,42 @@ void SimDataBlock::write(Stream &stream, U32 tabStop, U32 flags)
|
|||
// MARK: ---- API ----
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineMethod( SimDataBlock, reloadOnLocalClient, void, (),,
|
||||
"Reload the datablock. This can only be used with a local client configuration." )
|
||||
void SimDataBlock::reloadOnLocalClient()
|
||||
{
|
||||
// Make sure we're running a local client.
|
||||
|
||||
GameConnection* localClient = GameConnection::getLocalClientConnection();
|
||||
if( !localClient )
|
||||
if (!localClient)
|
||||
return;
|
||||
|
||||
// Do an in-place pack/unpack/preload.
|
||||
|
||||
if( !object->preload( true, NetConnection::getErrorBuffer() ) )
|
||||
if (!preload(true, NetConnection::getErrorBuffer()))
|
||||
{
|
||||
Con::errorf( NetConnection::getErrorBuffer() );
|
||||
Con::errorf(NetConnection::getErrorBuffer());
|
||||
return;
|
||||
}
|
||||
|
||||
U8 buffer[ 16384 ];
|
||||
BitStream stream( buffer, 16384 );
|
||||
U8 buffer[16384];
|
||||
BitStream stream(buffer, 16384);
|
||||
|
||||
object->packData( &stream );
|
||||
packData(&stream);
|
||||
stream.setPosition(0);
|
||||
object->unpackData( &stream );
|
||||
unpackData(&stream);
|
||||
|
||||
if( !object->preload( false, NetConnection::getErrorBuffer() ) )
|
||||
if (!preload(false, NetConnection::getErrorBuffer()))
|
||||
{
|
||||
Con::errorf( NetConnection::getErrorBuffer() );
|
||||
Con::errorf(NetConnection::getErrorBuffer());
|
||||
return;
|
||||
}
|
||||
|
||||
// Trigger a post-apply so that change notifications respond.
|
||||
object->inspectPostApply();
|
||||
inspectPostApply();
|
||||
}
|
||||
DefineEngineMethod( SimDataBlock, reloadOnLocalClient, void, (),,
|
||||
"Reload the datablock. This can only be used with a local client configuration." )
|
||||
{
|
||||
object->reloadOnLocalClient();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -176,6 +176,8 @@ public:
|
|||
/// Used by the console system to automatically tell datablock classes apart
|
||||
/// from non-datablock classes.
|
||||
static const bool __smIsDatablock = true;
|
||||
|
||||
void reloadOnLocalClient();
|
||||
protected:
|
||||
struct SubstitutionStatement
|
||||
{
|
||||
|
|
|
|||
|
|
@ -143,7 +143,10 @@ public:
|
|||
return theSignal;
|
||||
}
|
||||
|
||||
void onShapeChanged() {}
|
||||
void onShapeChanged()
|
||||
{
|
||||
reloadOnLocalClient();
|
||||
}
|
||||
};
|
||||
|
||||
typedef Vector<ForestItemData*> ForestItemDataVector;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue