all DECLARE_IMAGEASSET refactored

This commit is contained in:
marauder2k7 2024-12-21 17:34:16 +00:00
parent 24b374f545
commit fa8110ce8f
44 changed files with 248 additions and 306 deletions

View file

@ -122,9 +122,6 @@ ParticleData::ParticleData()
animTexFramesString = NULL; // string of animation frame indices
animTexUVs = NULL; // array of tile vertex UVs
INIT_ASSET(Texture);
INIT_ASSET(TextureExt);
constrain_pos = false;
start_angle = 0.0f;
angle_variance = 0.0f;
@ -149,12 +146,7 @@ void ParticleData::initPersistFields()
{
docsURL;
addGroup("Basic");
addProtectedField("textureName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData), _setTextureData, defaultProtectedGetFn,
"Texture file to use for this particle.", AbstractClassRep::FIELD_HideInInspectors);
addField("animTexName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData),
"@brief Texture file to use for this particle if animateTexture is true.\n\n"
"Deprecated. Use textureName instead.", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET(Texture, ParticleData, "Texture to use for this particle.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(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, "
@ -239,8 +231,7 @@ void ParticleData::initPersistFields()
endGroup("Over Time");
addGroup("AFX");
addProtectedField("textureExtName", TypeFilename, Offset(mTextureExtName, ParticleData), _setTextureExtData, &defaultProtectedGetFn, "", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET(TextureExt, ParticleData, "");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(TextureExt, ParticleData, "");
addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData));
addField("angle", TypeF32, Offset(start_angle, ParticleData));
addField("angleVariance", TypeF32, Offset(angle_variance, ParticleData));
@ -305,7 +296,7 @@ void ParticleData::packData(BitStream* stream)
stream->writeFloat( times[i], 8);
}
PACKDATA_ASSET(Texture);
PACKDATA_ASSET_REFACTOR(Texture);
for (i = 0; i < 4; i++)
mathWrite(*stream, texCoords[i]);
@ -319,7 +310,7 @@ void ParticleData::packData(BitStream* stream)
stream->writeInt(framesPerSec, 8);
}
PACKDATA_ASSET(TextureExt);
PACKDATA_ASSET_REFACTOR(TextureExt);
stream->writeFlag(constrain_pos);
stream->writeFloat(start_angle/360.0f, 11);
@ -390,7 +381,7 @@ void ParticleData::unpackData(BitStream* stream)
times[i] = stream->readFloat(8);
}
UNPACKDATA_ASSET(Texture);
UNPACKDATA_ASSET_REFACTOR(Texture);
for (i = 0; i < 4; i++)
mathRead(*stream, &texCoords[i]);
@ -403,7 +394,7 @@ void ParticleData::unpackData(BitStream* stream)
framesPerSec = stream->readInt(8);
}
UNPACKDATA_ASSET(TextureExt);
UNPACKDATA_ASSET_REFACTOR(TextureExt);
constrain_pos = stream->readFlag();
start_angle = 360.0f*stream->readFloat(11);
@ -698,13 +689,6 @@ bool ParticleData::reload(char errorBuffer[256])
{
bool error = false;
StringTableEntry particleTex = getTexture();
if (!_setTexture(particleTex))
{
dSprintf(errorBuffer, 256, "Missing particle texture: %s", particleTex);
}
/*
numFrames = 0;
for( S32 i=0; i<PDC_MAX_TEX; i++ )
@ -775,12 +759,12 @@ ParticleData::ParticleData(const ParticleData& other, bool temp_clone) : SimData
animTexFramesString = other.animTexFramesString;
animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString
CLONE_ASSET(Texture);
CLONE_ASSET_REFACTOR(Texture);
spinBias = other.spinBias;
randomizeSpinDir = other.randomizeSpinDir;
CLONE_ASSET(TextureExt);
CLONE_ASSET_REFACTOR(TextureExt);
constrain_pos = other.constrain_pos;
start_angle = other.start_angle;
@ -816,4 +800,4 @@ void ParticleData::onPerformSubstitutions()
reload(errorBuffer);
}
DEF_ASSET_BINDS(ParticleData, Texture);
DEF_ASSET_BINDS_REFACTOR(ParticleData, Texture);

View file

@ -86,14 +86,11 @@ class ParticleData : public SimDataBlock
StringTableEntry animTexFramesString;
Vector<U8> animTexFrames;
DECLARE_IMAGEASSET(ParticleData, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
DECLARE_ASSET_SETGET(ParticleData, Texture);
DECLARE_IMAGEASSET_REFACTOR(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);
void onImageChanged() {}
public:
ParticleData();
~ParticleData();
@ -117,8 +114,7 @@ public:
F32 spinBias;
bool randomizeSpinDir;
public:
DECLARE_IMAGEASSET(ParticleData, TextureExt, onImageChanged, GFXStaticTextureSRGBProfile);
DECLARE_ASSET_SETGET(ParticleData, TextureExt);
DECLARE_IMAGEASSET_REFACTOR(ParticleData, TextureExt,GFXStaticTextureSRGBProfile)
bool constrain_pos;
F32 start_angle;

View file

@ -742,11 +742,11 @@ bool ParticleEmitterData::preload(bool server, String &errorStr)
// otherwise, check that all particles refer to the same texture
else if (particleDataBlocks.size() > 1)
{
StringTableEntry txr_name = particleDataBlocks[0]->getTexture();
StringTableEntry txr_name = particleDataBlocks[0]->getTextureAsset()->getImageFile();
for (S32 i = 1; i < particleDataBlocks.size(); i++)
{
// warn if particle textures are inconsistent
if (particleDataBlocks[i]->getTexture() != txr_name)
if (particleDataBlocks[i]->getTextureAsset()->getImageFile() != txr_name)
{
Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName());
break;
@ -1227,7 +1227,7 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
if (mDataBlock->textureHandle)
ri->diffuseTex = &*(mDataBlock->textureHandle);
else
ri->diffuseTex = &*(part_list_head.next->dataBlock->getTextureResource());
ri->diffuseTex = &*(part_list_head.next->dataBlock->getTexture());
ri->softnessDistance = mDataBlock->softnessDistance;

View file

@ -129,12 +129,8 @@ PrecipitationData::PrecipitationData()
{
INIT_ASSET(Sound);
INIT_ASSET(Drop);
mDropShaderName = StringTable->EmptyString();
INIT_ASSET(Splash);
mSplashShaderName = StringTable->EmptyString();
mDropsPerSide = 4;
@ -145,14 +141,8 @@ void PrecipitationData::initPersistFields()
{
docsURL;
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
"@brief Texture filename 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.", AbstractClassRep::FIELD_HideInInspectors );
INITPERSISTFIELD_IMAGEASSET(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
INITPERSISTFIELD_IMAGEASSET_REFACTOR(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.");
@ -160,13 +150,7 @@ void PrecipitationData::initPersistFields()
addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData),
"The name of the shader used for raindrops." );
addProtectedField("splashTexture", TypeFilename, Offset(mSplashName, PrecipitationData), &_setSplashData, &defaultProtectedGetFn,
"@brief Texture filename 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.", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
INITPERSISTFIELD_IMAGEASSET_REFACTOR(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.");
@ -206,11 +190,11 @@ void PrecipitationData::packData(BitStream* stream)
PACKDATA_ASSET(Sound);
PACKDATA_ASSET(Drop);
PACKDATA_ASSET_REFACTOR(Drop);
stream->writeString(mDropShaderName);
PACKDATA_ASSET(Splash);
PACKDATA_ASSET_REFACTOR(Splash);
stream->writeString(mSplashShaderName);
stream->write(mDropsPerSide);
@ -223,11 +207,11 @@ void PrecipitationData::unpackData(BitStream* stream)
UNPACKDATA_ASSET(Sound);
UNPACKDATA_ASSET(Drop);
UNPACKDATA_ASSET_REFACTOR(Drop);
mDropShaderName = stream->readSTString();
UNPACKDATA_ASSET(Splash);
UNPACKDATA_ASSET_REFACTOR(Splash);
mSplashShaderName = stream->readSTString();
stream->read(&mDropsPerSide);
@ -632,10 +616,10 @@ void Precipitation::initMaterials()
mDropShader = NULL;
mSplashShader = NULL;
if(pd->mDrop.isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDrop());
if(pd->getDropAsset().isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDropAsset().getAssetId());
else
mDropHandle = pd->mDrop;
mDropHandle = pd->getDrop();
if ( dStrlen(pd->mDropShaderName) > 0 )
{
@ -655,10 +639,10 @@ void Precipitation::initMaterials()
}
}
if (pd->mSplash.isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplash());
if (pd->getSplashAsset().isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplashAsset().getAssetId());
else
mSplashHandle = pd->mSplash;
mSplashHandle = pd->getSplash();
if ( dStrlen(pd->mSplashShaderName) > 0 )
{

View file

@ -49,13 +49,11 @@ class PrecipitationData : public GameBaseData
DECLARE_SOUNDASSET(PrecipitationData, Sound);
DECLARE_ASSET_SETGET(PrecipitationData, Sound);
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
DECLARE_ASSET_SETGET(PrecipitationData, Drop);
DECLARE_IMAGEASSET_REFACTOR(PrecipitationData, Drop, GFXStaticTextureSRGBProfile) ///< Texture for drop particles
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
DECLARE_ASSET_SETGET(PrecipitationData, Splash);
DECLARE_IMAGEASSET_REFACTOR(PrecipitationData, Splash, GFXStaticTextureSRGBProfile) ///< Texture for splash particles
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
@ -68,9 +66,6 @@ class PrecipitationData : public GameBaseData
static void initPersistFields();
void packData(BitStream* stream) override;
void unpackData(BitStream* stream) override;
void onDropChanged() {}
void onSplashChanged() {}
};
struct Raindrop