mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
review notes from Az
Should render fallback for namedTarget if namedTarget fails Add safety around namedtarget getTexture to stop assert Missing assets should revert to fallback image and print a warning to console Remove REFACTOR tag from all macros.
This commit is contained in:
parent
b707b2e2b7
commit
73ad92b757
60 changed files with 189 additions and 164 deletions
|
|
@ -93,7 +93,7 @@ AccumulationVolume::~AccumulationVolume()
|
|||
void AccumulationVolume::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, AccumulationVolume, "Accumulation texture.")
|
||||
INITPERSISTFIELD_IMAGEASSET(Texture, AccumulationVolume, "Accumulation texture.")
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class AccumulationVolume : public ScenePolyhedralSpace
|
|||
// SceneSpace.
|
||||
void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ) override;
|
||||
|
||||
DECLARE_IMAGEASSET_NET_REFACTOR(AccumulationVolume, Texture, GFXStaticTextureSRGBProfile, -1)
|
||||
DECLARE_IMAGEASSET_NET(AccumulationVolume, Texture, GFXStaticTextureSRGBProfile, -1)
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -484,16 +484,22 @@ GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
|||
|
||||
if (isNamedTarget())
|
||||
{
|
||||
GFXTexHandle tex = getNamedTarget()->getTexture();
|
||||
if(tex.isNull())
|
||||
GFXTexHandle tex;
|
||||
AssetPtr<ImageAsset> fallbackAsset;
|
||||
ImageAsset::getAssetById(smNamedTargetAssetFallback, &fallbackAsset);
|
||||
if (getNamedTarget().isValid())
|
||||
{
|
||||
AssetPtr<ImageAsset> fallbackAsset;
|
||||
ImageAsset::getAssetById(smNamedTargetAssetFallback, &fallbackAsset);
|
||||
return fallbackAsset->getTexture();
|
||||
tex = getNamedTarget()->getTexture();
|
||||
if (tex.isNull())
|
||||
{
|
||||
return fallbackAsset->getTexture();
|
||||
}
|
||||
|
||||
return tex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tex;
|
||||
return fallbackAsset->getTexture();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ DefineEnumType(ImageAssetType);
|
|||
|
||||
#pragma region Refactor Asset Macros
|
||||
|
||||
#define DECLARE_IMAGEASSET_REFACTOR(className, name, profile) \
|
||||
#define DECLARE_IMAGEASSET(className, name, profile) \
|
||||
private: \
|
||||
AssetPtr<ImageAsset> m##name##Asset; \
|
||||
public: \
|
||||
|
|
@ -268,6 +268,11 @@ public:
|
|||
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||
} \
|
||||
m##name##Asset = imageAssetId; \
|
||||
} \
|
||||
else \
|
||||
|
|
@ -282,7 +287,7 @@ public:
|
|||
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false;}
|
||||
|
||||
|
||||
#define DECLARE_IMAGEASSET_NET_REFACTOR(className, name, profile, mask) \
|
||||
#define DECLARE_IMAGEASSET_NET(className, name, profile, mask) \
|
||||
private: \
|
||||
AssetPtr<ImageAsset> m##name##Asset; \
|
||||
public: \
|
||||
|
|
@ -308,6 +313,11 @@ public:
|
|||
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||
} \
|
||||
m##name##Asset = imageAssetId; \
|
||||
} \
|
||||
else \
|
||||
|
|
@ -323,11 +333,11 @@ public:
|
|||
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false;}
|
||||
|
||||
|
||||
#define INITPERSISTFIELD_IMAGEASSET_REFACTOR(name, consoleClass, docs) \
|
||||
#define INITPERSISTFIELD_IMAGEASSET(name, consoleClass, docs) \
|
||||
addProtectedField(assetText(name, Asset), TypeImageAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
|
||||
|
||||
|
||||
#define DECLARE_IMAGEASSET_ARRAY_REFACTOR(className, name, profile, max) \
|
||||
#define DECLARE_IMAGEASSET_ARRAY(className, name, profile, max) \
|
||||
private: \
|
||||
AssetPtr<ImageAsset> m##name##Asset[max]; \
|
||||
public: \
|
||||
|
|
@ -353,6 +363,11 @@ public:
|
|||
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||
} \
|
||||
m##name##Asset[index] = imageAssetId; \
|
||||
} \
|
||||
else \
|
||||
|
|
@ -368,7 +383,7 @@ public:
|
|||
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;}
|
||||
|
||||
|
||||
#define DECLARE_IMAGEASSET_ARRAY_NET_REFACTOR(className, name, profile, max, mask) \
|
||||
#define DECLARE_IMAGEASSET_ARRAY_NET(className, name, profile, max, mask) \
|
||||
private: \
|
||||
AssetPtr<ImageAsset> m##name##Asset[max]; \
|
||||
public: \
|
||||
|
|
@ -394,6 +409,11 @@ public:
|
|||
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||
} \
|
||||
m##name##Asset[index] = imageAssetId; \
|
||||
} \
|
||||
else \
|
||||
|
|
@ -410,10 +430,10 @@ public:
|
|||
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;}
|
||||
|
||||
|
||||
#define INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(name, arraySize, consoleClass, docs) \
|
||||
#define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \
|
||||
addProtectedField(assetText(name, Asset), TypeImageAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));
|
||||
|
||||
#define DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(className,name, max)\
|
||||
#define DEF_IMAGEASSET_ARRAY_BINDS(className,name, max)\
|
||||
DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\
|
||||
{\
|
||||
return object->get##name##Asset(index).notNull() ? object->get##name##Asset(index)->getImageFile() : ""; \
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ void ParticleData::initPersistFields()
|
|||
{
|
||||
docsURL;
|
||||
addGroup("Basic");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, ParticleData, "Texture to use for this particle.");
|
||||
INITPERSISTFIELD_IMAGEASSET(Texture, ParticleData, "Texture to use for this particle.");
|
||||
addField("useInvAlpha", TYPEID< bool >(), Offset(useInvAlpha, ParticleData),
|
||||
"@brief Controls how particles blend with the scene.\n\n"
|
||||
"If true, particles blend like ParticleBlendStyle NORMAL, if false, "
|
||||
|
|
@ -233,7 +233,7 @@ void ParticleData::initPersistFields()
|
|||
endGroup("Over Time");
|
||||
|
||||
addGroup("AFX");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(TextureExt, ParticleData, "");
|
||||
INITPERSISTFIELD_IMAGEASSET(TextureExt, ParticleData, "");
|
||||
addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData));
|
||||
addFieldV("angle", TypeRangedF32, Offset(start_angle, ParticleData), &CommonValidators::DegreeRange);
|
||||
addFieldV("angleVariance", TypeRangedF32, Offset(angle_variance, ParticleData), &CommonValidators::DegreeRange);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class ParticleData : public SimDataBlock
|
|||
StringTableEntry animTexFramesString;
|
||||
Vector<U8> animTexFrames;
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(ParticleData, Texture, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(ParticleData, Texture, GFXStaticTextureSRGBProfile)
|
||||
|
||||
static bool protectedSetSizes(void* object, const char* index, const char* data);
|
||||
static bool protectedSetTimes(void* object, const char* index, const char* data);
|
||||
|
|
@ -114,7 +114,7 @@ public:
|
|||
F32 spinBias;
|
||||
bool randomizeSpinDir;
|
||||
public:
|
||||
DECLARE_IMAGEASSET_REFACTOR(ParticleData, TextureExt,GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(ParticleData, TextureExt,GFXStaticTextureSRGBProfile)
|
||||
|
||||
bool constrain_pos;
|
||||
F32 start_angle;
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ void PrecipitationData::initPersistFields()
|
|||
docsURL;
|
||||
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
|
||||
INITPERSISTFIELD_IMAGEASSET(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
|
||||
"The drop texture can contain several different drop sub-textures "
|
||||
"arranged in a grid. There must be the same number of rows as columns. A "
|
||||
"random frame will be chosen for each drop.");
|
||||
|
|
@ -150,7 +150,7 @@ void PrecipitationData::initPersistFields()
|
|||
addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData),
|
||||
"The name of the shader used for raindrops." );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
|
||||
INITPERSISTFIELD_IMAGEASSET(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
|
||||
"The splash texture can contain several different splash sub-textures "
|
||||
"arranged in a grid. There must be the same number of rows as columns. A "
|
||||
"random frame will be chosen for each splash.");
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ class PrecipitationData : public GameBaseData
|
|||
DECLARE_SOUNDASSET(PrecipitationData, Sound);
|
||||
DECLARE_ASSET_SETGET(PrecipitationData, Sound);
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(PrecipitationData, Drop, GFXStaticTextureSRGBProfile) ///< Texture for drop particles
|
||||
DECLARE_IMAGEASSET(PrecipitationData, Drop, GFXStaticTextureSRGBProfile) ///< Texture for drop particles
|
||||
|
||||
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(PrecipitationData, Splash, GFXStaticTextureSRGBProfile) ///< Texture for splash particles
|
||||
DECLARE_IMAGEASSET(PrecipitationData, Splash, GFXStaticTextureSRGBProfile) ///< Texture for splash particles
|
||||
|
||||
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ void SplashData::initPersistFields()
|
|||
addFieldV("times", TypeRangedF32, Offset(times, SplashData), &CommonValidators::NormalizedFloat, NUM_TIME_KEYS, "Times to transition through the splash effect. Up to 4 allowed. Values are 0.0 - 1.0, and corrispond to the life of the particle where 0 is first created and 1 is end of lifespace.\n" );
|
||||
addField("colors", TypeColorF, Offset(colors, SplashData), NUM_TIME_KEYS, "Color values to set the splash effect, rgba. Up to 4 allowed. Will transition through colors based on values set in the times value. Example: colors[0] = \"0.6 1.0 1.0 0.5\".\n" );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(Texture, NUM_TEX, SplashData, "Image to use as the texture for the splash effect.\n");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, NUM_TEX, SplashData, "Image to use as the texture for the splash effect.\n");
|
||||
|
||||
addFieldV("texWrap", TypeRangedF32, Offset(texWrap, SplashData), &CommonValidators::NormalizedFloat, "Amount to wrap the texture around the splash ring, 0.0f - 1.0f.\n");
|
||||
addFieldV("texFactor", TypeRangedF32, Offset(texFactor, SplashData), &CommonValidators::NormalizedFloat, "Factor in which to apply the texture to the splash ring, 0.0f - 1.0f.\n");
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public:
|
|||
F32 times[ NUM_TIME_KEYS ];
|
||||
LinearColorF colors[ NUM_TIME_KEYS ];
|
||||
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(SplashData, Texture, GFXStaticTextureSRGBProfile, NUM_TEX)
|
||||
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, GFXStaticTextureSRGBProfile, NUM_TEX)
|
||||
|
||||
ExplosionData* explosion;
|
||||
S32 explosionId;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ void GameMode::initPersistFields()
|
|||
addField("gameModeName", TypeString, Offset(mGameModeName, GameMode), "Human-readable name of the gamemode");
|
||||
addField("description", TypeString, Offset(mGameModeDesc, GameMode), "Description of the gamemode");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(PreviewImage, GameMode, "Preview Image");
|
||||
INITPERSISTFIELD_IMAGEASSET(PreviewImage, GameMode, "Preview Image");
|
||||
|
||||
addField("active", TypeBool, Offset(mIsActive, GameMode), "Is the gamemode active");
|
||||
addField("alwaysActive", TypeBool, Offset(mIsAlwaysActive, GameMode), "Is the gamemode always active");
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ private:
|
|||
StringTableEntry mGameModeName;
|
||||
StringTableEntry mGameModeDesc;
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(GameMode, PreviewImage, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(GameMode, PreviewImage, GFXStaticTextureSRGBProfile)
|
||||
|
||||
bool mIsActive;
|
||||
bool mIsAlwaysActive;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ void LevelInfo::initPersistFields()
|
|||
//addField( "advancedLightmapSupport", TypeBool, Offset( mAdvancedLightmapSupport, LevelInfo ),
|
||||
// "Enable expanded support for mixing static and dynamic lighting (more costly)" );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(AccuTexture, LevelInfo, "Accumulation texture.");
|
||||
INITPERSISTFIELD_IMAGEASSET(AccuTexture, LevelInfo, "Accumulation texture.");
|
||||
|
||||
endGroup( "Lighting" );
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class LevelInfo : public NetObject
|
|||
void _onLMActivate(const char *lm, bool enable);
|
||||
protected:
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(LevelInfo, AccuTexture, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(LevelInfo, AccuTexture, GFXStaticTextureSRGBProfile)
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void LightFlareData::initPersistFields()
|
|||
addField( "flareEnabled", TypeBool, Offset( mFlareEnabled, LightFlareData ),
|
||||
"Allows the user to disable this flare globally for any lights referencing it." );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(FlareTexture, LightFlareData, "The texture / sprite sheet for this flare.");
|
||||
INITPERSISTFIELD_IMAGEASSET(FlareTexture, LightFlareData, "The texture / sprite sheet for this flare.");
|
||||
|
||||
addArray( "Elements", MAX_ELEMENTS );
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ protected:
|
|||
F32 mScale;
|
||||
bool mFlareEnabled;
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(LightFlareData, FlareTexture, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET(LightFlareData, FlareTexture, GFXStaticTextureSRGBProfile)
|
||||
|
||||
F32 mOcclusionRadius;
|
||||
bool mRenderReflectPass;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue