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

@ -83,24 +83,17 @@ AccumulationVolume::AccumulationVolume()
mObjToWorld.identity(); mObjToWorld.identity();
mWorldToObj.identity(); mWorldToObj.identity();
// Accumulation Texture.
INIT_ASSET(Texture);
resetWorldBox(); resetWorldBox();
} }
AccumulationVolume::~AccumulationVolume() AccumulationVolume::~AccumulationVolume()
{ {
mTexture = nullptr;
} }
void AccumulationVolume::initPersistFields() void AccumulationVolume::initPersistFields()
{ {
docsURL; docsURL;
addProtectedField("textureAsset", TypeImageAssetId, Offset(mTextureAssetId, AccumulationVolume), INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, AccumulationVolume, "Accumulation texture.")
&_setTexture, &defaultProtectedGetFn, "Accumulation texture.");
addProtectedField( "texture", TypeStringFilename, Offset( mTextureName, AccumulationVolume ),
&_setTexture, &defaultProtectedGetFn, "Accumulation texture." );
Parent::initPersistFields(); Parent::initPersistFields();
} }
@ -236,7 +229,7 @@ U32 AccumulationVolume::packUpdate( NetConnection *connection, U32 mask, BitStre
if (stream->writeFlag(mask & InitialUpdateMask)) if (stream->writeFlag(mask & InitialUpdateMask))
{ {
PACK_ASSET(connection, Texture); PACK_ASSET_REFACTOR(connection, Texture);
} }
return retMask; return retMask;
@ -248,7 +241,7 @@ void AccumulationVolume::unpackUpdate( NetConnection *connection, BitStream *str
if (stream->readFlag()) if (stream->readFlag())
{ {
UNPACK_ASSET(connection, Texture); UNPACK_ASSET_REFACTOR(connection, Texture);
//setTexture(mTextureName); //setTexture(mTextureName);
} }
} }
@ -307,7 +300,7 @@ void AccumulationVolume::refreshVolumes()
if ( object.isNull() ) continue; if ( object.isNull() ) continue;
if ( volume->containsPoint(object->getPosition()) ) if ( volume->containsPoint(object->getPosition()) )
object->mAccuTex = volume->getTextureResource(); object->mAccuTex = volume->getTexture();
} }
} }
} }
@ -341,6 +334,6 @@ void AccumulationVolume::updateObject(SceneObject* object)
if ( volume.isNull() ) continue; if ( volume.isNull() ) continue;
if ( volume->containsPoint(object->getPosition()) ) if ( volume->containsPoint(object->getPosition()) )
object->mAccuTex = volume->getTextureResource(); object->mAccuTex = volume->getTexture();
} }
} }

View file

@ -61,10 +61,7 @@ class AccumulationVolume : public ScenePolyhedralSpace
// SceneSpace. // SceneSpace.
void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ) override; void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ) override;
DECLARE_IMAGEASSET(AccumulationVolume, Texture, onTextureChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_NET_REFACTOR(AccumulationVolume, Texture, GFXStaticTextureSRGBProfile, -1)
DECLARE_ASSET_NET_SETGET(AccumulationVolume, Texture, -1);
void onTextureChanged() {}
public: public:

View file

@ -591,7 +591,7 @@ const char* ImageAsset::getImageInfo()
return ""; return "";
} }
DefineEngineMethod(ImageAsset, getImageFile, const char*, (), , DefineEngineMethod(ImageAsset, getImagePath, const char*, (), ,
"Gets the image filepath of this asset.\n" "Gets the image filepath of this asset.\n"
"@return File path of the image file.") "@return File path of the image file.")
{ {

View file

@ -612,6 +612,38 @@ public:
m##name##Asset = _in; \ m##name##Asset = _in; \
} \ } \
}; \ }; \
\
inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
GFXTexHandle get##name() { return m##name##Asset.notNull() ? m##name##Asset->getTexture(&profile) : NULL; } \
AssetPtr<ImageAsset> 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;}
#define DECLARE_IMAGEASSET_NET_REFACTOR(className, name, profile, mask) \
private: \
AssetPtr<ImageAsset> m##name##Asset; \
public: \
void _set##name(StringTableEntry _in){ \
if(m##name##Asset.getAssetId() == _in) \
return; \
\
if(!AssetDatabase.isDeclaredAsset(_in)) \
{ \
StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback; \
AssetQuery query; \
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
if (foundAssetcount != 0) \
{ \
imageAssetId = query.mAssetList[0]; \
} \
m##name##Asset = imageAssetId; \
} \
else \
{ \
m##name##Asset = _in; \
} \
setMaskBits(mask); \
}; \
\
inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \ inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
GFXTexHandle get##name() { return m##name##Asset.notNull() ? m##name##Asset->getTexture(&profile) : NULL; } \ GFXTexHandle get##name() { return m##name##Asset.notNull() ? m##name##Asset->getTexture(&profile) : NULL; } \
AssetPtr<ImageAsset> get##name##Asset(void) { return m##name##Asset; } \ AssetPtr<ImageAsset> get##name##Asset(void) { return m##name##Asset; } \

View file

@ -53,6 +53,52 @@ if (m##name##AssetId != StringTable->EmptyString())\
m##name##Asset = other.m##name##Asset;\ m##name##Asset = other.m##name##Asset;\
m##name = other.m##name m##name = other.m##name
// copy constructor refactor
#define CLONE_ASSET_REFACTOR(name) \
m##name##Asset = other.m##name##Asset;\
//network send - datablock refactor
#define PACKDATA_ASSET_REFACTOR(name)\
if (stream->writeFlag(m##name##Asset.notNull()))\
{\
stream->writeString(m##name##Asset.getAssetId());\
}
//network recieve - datablock
#define UNPACKDATA_ASSET_REFACTOR(name)\
if (stream->readFlag())\
{\
_set##name(stream->readSTString());\
}
//network send - object-instance
#define PACK_ASSET_REFACTOR(netconn, name)\
if (stream->writeFlag(m##name##Asset.notNull()))\
{\
NetStringHandle assetIdStr = m##name##Asset.getAssetId();\
netconn->packNetStringHandleU(stream, assetIdStr);\
}
//network recieve - object-instance
#define UNPACK_ASSET_REFACTOR(netconn, name)\
if (stream->readFlag())\
{\
_set##name(netconn->unpackNetStringHandleU(stream).getString());\
}
#define DEF_ASSET_BINDS_REFACTOR(className,name)\
DefineEngineMethod(className, get##name, StringTableEntry, (), , "get name")\
{\
return object->get##name##Asset()->getImageFile(); \
}\
DefineEngineMethod(className, get##name##Asset, StringTableEntry, (), , assetText(name, asset reference))\
{\
return object->_get##name(); \
}\
DefineEngineMethod(className, set##name, void, (const char* assetName), , assetText(name,assignment. first tries asset then flat file.))\
{\
object->_set##name(StringTable->insert(assetName));\
}
// addProtectedField acessors // addProtectedField acessors
#define DECLARE_ASSET_SETGET(className, name)\ #define DECLARE_ASSET_SETGET(className, name)\
static bool _set##name##Data(void* obj, const char* index, const char* data)\ static bool _set##name##Data(void* obj, const char* index, const char* data)\

View file

@ -122,9 +122,6 @@ ParticleData::ParticleData()
animTexFramesString = NULL; // string of animation frame indices animTexFramesString = NULL; // string of animation frame indices
animTexUVs = NULL; // array of tile vertex UVs animTexUVs = NULL; // array of tile vertex UVs
INIT_ASSET(Texture);
INIT_ASSET(TextureExt);
constrain_pos = false; constrain_pos = false;
start_angle = 0.0f; start_angle = 0.0f;
angle_variance = 0.0f; angle_variance = 0.0f;
@ -149,12 +146,7 @@ void ParticleData::initPersistFields()
{ {
docsURL; docsURL;
addGroup("Basic"); addGroup("Basic");
addProtectedField("textureName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData), _setTextureData, defaultProtectedGetFn, INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, ParticleData, "Texture to use for this particle.");
"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.");
addField("useInvAlpha", TYPEID< bool >(), Offset(useInvAlpha, ParticleData), addField("useInvAlpha", TYPEID< bool >(), Offset(useInvAlpha, ParticleData),
"@brief Controls how particles blend with the scene.\n\n" "@brief Controls how particles blend with the scene.\n\n"
"If true, particles blend like ParticleBlendStyle NORMAL, if false, " "If true, particles blend like ParticleBlendStyle NORMAL, if false, "
@ -239,8 +231,7 @@ void ParticleData::initPersistFields()
endGroup("Over Time"); endGroup("Over Time");
addGroup("AFX"); addGroup("AFX");
addProtectedField("textureExtName", TypeFilename, Offset(mTextureExtName, ParticleData), _setTextureExtData, &defaultProtectedGetFn, "", AbstractClassRep::FIELD_HideInInspectors); INITPERSISTFIELD_IMAGEASSET_REFACTOR(TextureExt, ParticleData, "");
INITPERSISTFIELD_IMAGEASSET(TextureExt, ParticleData, "");
addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData)); addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData));
addField("angle", TypeF32, Offset(start_angle, ParticleData)); addField("angle", TypeF32, Offset(start_angle, ParticleData));
addField("angleVariance", TypeF32, Offset(angle_variance, ParticleData)); addField("angleVariance", TypeF32, Offset(angle_variance, ParticleData));
@ -305,7 +296,7 @@ void ParticleData::packData(BitStream* stream)
stream->writeFloat( times[i], 8); stream->writeFloat( times[i], 8);
} }
PACKDATA_ASSET(Texture); PACKDATA_ASSET_REFACTOR(Texture);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
mathWrite(*stream, texCoords[i]); mathWrite(*stream, texCoords[i]);
@ -319,7 +310,7 @@ void ParticleData::packData(BitStream* stream)
stream->writeInt(framesPerSec, 8); stream->writeInt(framesPerSec, 8);
} }
PACKDATA_ASSET(TextureExt); PACKDATA_ASSET_REFACTOR(TextureExt);
stream->writeFlag(constrain_pos); stream->writeFlag(constrain_pos);
stream->writeFloat(start_angle/360.0f, 11); stream->writeFloat(start_angle/360.0f, 11);
@ -390,7 +381,7 @@ void ParticleData::unpackData(BitStream* stream)
times[i] = stream->readFloat(8); times[i] = stream->readFloat(8);
} }
UNPACKDATA_ASSET(Texture); UNPACKDATA_ASSET_REFACTOR(Texture);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
mathRead(*stream, &texCoords[i]); mathRead(*stream, &texCoords[i]);
@ -403,7 +394,7 @@ void ParticleData::unpackData(BitStream* stream)
framesPerSec = stream->readInt(8); framesPerSec = stream->readInt(8);
} }
UNPACKDATA_ASSET(TextureExt); UNPACKDATA_ASSET_REFACTOR(TextureExt);
constrain_pos = stream->readFlag(); constrain_pos = stream->readFlag();
start_angle = 360.0f*stream->readFloat(11); start_angle = 360.0f*stream->readFloat(11);
@ -698,13 +689,6 @@ bool ParticleData::reload(char errorBuffer[256])
{ {
bool error = false; bool error = false;
StringTableEntry particleTex = getTexture();
if (!_setTexture(particleTex))
{
dSprintf(errorBuffer, 256, "Missing particle texture: %s", particleTex);
}
/* /*
numFrames = 0; numFrames = 0;
for( S32 i=0; i<PDC_MAX_TEX; i++ ) 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; animTexFramesString = other.animTexFramesString;
animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString
CLONE_ASSET(Texture); CLONE_ASSET_REFACTOR(Texture);
spinBias = other.spinBias; spinBias = other.spinBias;
randomizeSpinDir = other.randomizeSpinDir; randomizeSpinDir = other.randomizeSpinDir;
CLONE_ASSET(TextureExt); CLONE_ASSET_REFACTOR(TextureExt);
constrain_pos = other.constrain_pos; constrain_pos = other.constrain_pos;
start_angle = other.start_angle; start_angle = other.start_angle;
@ -816,4 +800,4 @@ void ParticleData::onPerformSubstitutions()
reload(errorBuffer); 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; StringTableEntry animTexFramesString;
Vector<U8> animTexFrames; Vector<U8> animTexFrames;
DECLARE_IMAGEASSET(ParticleData, Texture, onImageChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(ParticleData, Texture, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(ParticleData, Texture);
static bool protectedSetSizes(void* object, const char* index, const char* data); static bool protectedSetSizes(void* object, const char* index, const char* data);
static bool protectedSetTimes(void* object, const char* index, const char* data); static bool protectedSetTimes(void* object, const char* index, const char* data);
void onImageChanged() {}
public: public:
ParticleData(); ParticleData();
~ParticleData(); ~ParticleData();
@ -117,8 +114,7 @@ public:
F32 spinBias; F32 spinBias;
bool randomizeSpinDir; bool randomizeSpinDir;
public: public:
DECLARE_IMAGEASSET(ParticleData, TextureExt, onImageChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(ParticleData, TextureExt,GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(ParticleData, TextureExt);
bool constrain_pos; bool constrain_pos;
F32 start_angle; 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 // otherwise, check that all particles refer to the same texture
else if (particleDataBlocks.size() > 1) 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++) for (S32 i = 1; i < particleDataBlocks.size(); i++)
{ {
// warn if particle textures are inconsistent // 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()); Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName());
break; break;
@ -1227,7 +1227,7 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
if (mDataBlock->textureHandle) if (mDataBlock->textureHandle)
ri->diffuseTex = &*(mDataBlock->textureHandle); ri->diffuseTex = &*(mDataBlock->textureHandle);
else else
ri->diffuseTex = &*(part_list_head.next->dataBlock->getTextureResource()); ri->diffuseTex = &*(part_list_head.next->dataBlock->getTexture());
ri->softnessDistance = mDataBlock->softnessDistance; ri->softnessDistance = mDataBlock->softnessDistance;

View file

@ -129,12 +129,8 @@ PrecipitationData::PrecipitationData()
{ {
INIT_ASSET(Sound); INIT_ASSET(Sound);
INIT_ASSET(Drop);
mDropShaderName = StringTable->EmptyString(); mDropShaderName = StringTable->EmptyString();
INIT_ASSET(Splash);
mSplashShaderName = StringTable->EmptyString(); mSplashShaderName = StringTable->EmptyString();
mDropsPerSide = 4; mDropsPerSide = 4;
@ -146,13 +142,7 @@ void PrecipitationData::initPersistFields()
docsURL; docsURL;
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active."); INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn, INITPERSISTFIELD_IMAGEASSET_REFACTOR(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
"@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"
"The drop texture can contain several different drop sub-textures " "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 " "arranged in a grid. There must be the same number of rows as columns. A "
"random frame will be chosen for each drop."); "random frame will be chosen for each drop.");
@ -160,13 +150,7 @@ void PrecipitationData::initPersistFields()
addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData), addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData),
"The name of the shader used for raindrops." ); "The name of the shader used for raindrops." );
addProtectedField("splashTexture", TypeFilename, Offset(mSplashName, PrecipitationData), &_setSplashData, &defaultProtectedGetFn, INITPERSISTFIELD_IMAGEASSET_REFACTOR(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
"@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"
"The splash texture can contain several different splash sub-textures " "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 " "arranged in a grid. There must be the same number of rows as columns. A "
"random frame will be chosen for each splash."); "random frame will be chosen for each splash.");
@ -206,11 +190,11 @@ void PrecipitationData::packData(BitStream* stream)
PACKDATA_ASSET(Sound); PACKDATA_ASSET(Sound);
PACKDATA_ASSET(Drop); PACKDATA_ASSET_REFACTOR(Drop);
stream->writeString(mDropShaderName); stream->writeString(mDropShaderName);
PACKDATA_ASSET(Splash); PACKDATA_ASSET_REFACTOR(Splash);
stream->writeString(mSplashShaderName); stream->writeString(mSplashShaderName);
stream->write(mDropsPerSide); stream->write(mDropsPerSide);
@ -223,11 +207,11 @@ void PrecipitationData::unpackData(BitStream* stream)
UNPACKDATA_ASSET(Sound); UNPACKDATA_ASSET(Sound);
UNPACKDATA_ASSET(Drop); UNPACKDATA_ASSET_REFACTOR(Drop);
mDropShaderName = stream->readSTString(); mDropShaderName = stream->readSTString();
UNPACKDATA_ASSET(Splash); UNPACKDATA_ASSET_REFACTOR(Splash);
mSplashShaderName = stream->readSTString(); mSplashShaderName = stream->readSTString();
stream->read(&mDropsPerSide); stream->read(&mDropsPerSide);
@ -632,10 +616,10 @@ void Precipitation::initMaterials()
mDropShader = NULL; mDropShader = NULL;
mSplashShader = NULL; mSplashShader = NULL;
if(pd->mDrop.isNull()) if(pd->getDropAsset().isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDrop()); Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDropAsset().getAssetId());
else else
mDropHandle = pd->mDrop; mDropHandle = pd->getDrop();
if ( dStrlen(pd->mDropShaderName) > 0 ) if ( dStrlen(pd->mDropShaderName) > 0 )
{ {
@ -655,10 +639,10 @@ void Precipitation::initMaterials()
} }
} }
if (pd->mSplash.isNull()) if (pd->getSplashAsset().isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplash()); Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplashAsset().getAssetId());
else else
mSplashHandle = pd->mSplash; mSplashHandle = pd->getSplash();
if ( dStrlen(pd->mSplashShaderName) > 0 ) if ( dStrlen(pd->mSplashShaderName) > 0 )
{ {

View file

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

View file

@ -53,7 +53,6 @@ GameMode::GameMode() :
mIsActive(false), mIsActive(false),
mIsAlwaysActive(false) mIsAlwaysActive(false)
{ {
INIT_ASSET(PreviewImage);
} }
void GameMode::initPersistFields() void GameMode::initPersistFields()
@ -63,7 +62,7 @@ void GameMode::initPersistFields()
addField("gameModeName", TypeString, Offset(mGameModeName, GameMode), "Human-readable name of the gamemode"); addField("gameModeName", TypeString, Offset(mGameModeName, GameMode), "Human-readable name of the gamemode");
addField("description", TypeString, Offset(mGameModeDesc, GameMode), "Description of the gamemode"); addField("description", TypeString, Offset(mGameModeDesc, GameMode), "Description of the gamemode");
INITPERSISTFIELD_IMAGEASSET(PreviewImage, GameMode, "Preview Image"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(PreviewImage, GameMode, "Preview Image");
addField("active", TypeBool, Offset(mIsActive, GameMode), "Is the gamemode active"); addField("active", TypeBool, Offset(mIsActive, GameMode), "Is the gamemode active");
addField("alwaysActive", TypeBool, Offset(mIsAlwaysActive, GameMode), "Is the gamemode always active"); addField("alwaysActive", TypeBool, Offset(mIsAlwaysActive, GameMode), "Is the gamemode always active");

View file

@ -21,8 +21,7 @@ private:
StringTableEntry mGameModeName; StringTableEntry mGameModeName;
StringTableEntry mGameModeDesc; StringTableEntry mGameModeDesc;
DECLARE_IMAGEASSET(GameMode, PreviewImage, previewChange, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(GameMode, PreviewImage, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(GameMode, PreviewImage);
bool mIsActive; bool mIsActive;
bool mIsAlwaysActive; bool mIsAlwaysActive;
@ -45,8 +44,6 @@ public:
static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes); static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes);
void previewChange() {}
DECLARE_CALLBACK(void, onActivated, ()); DECLARE_CALLBACK(void, onActivated, ());
DECLARE_CALLBACK(void, onDeactivated, ()); DECLARE_CALLBACK(void, onDeactivated, ());
DECLARE_CALLBACK(void, onSceneLoaded, ()); DECLARE_CALLBACK(void, onSceneLoaded, ());

View file

@ -102,8 +102,6 @@ LevelInfo::LevelInfo()
mAdvancedLightmapSupport = true; mAdvancedLightmapSupport = true;
INIT_ASSET(AccuTexture);
// Register with the light manager activation signal, and we need to do it first // Register with the light manager activation signal, and we need to do it first
// so the advanced light bin manager can be instructed about MRT lightmaps // so the advanced light bin manager can be instructed about MRT lightmaps
LightManager::smActivateSignal.notify(this, &LevelInfo::_onLMActivate, 0.01f); LightManager::smActivateSignal.notify(this, &LevelInfo::_onLMActivate, 0.01f);
@ -114,9 +112,8 @@ LevelInfo::LevelInfo()
LevelInfo::~LevelInfo() LevelInfo::~LevelInfo()
{ {
LightManager::smActivateSignal.remove(this, &LevelInfo::_onLMActivate); LightManager::smActivateSignal.remove(this, &LevelInfo::_onLMActivate);
if (!mAccuTexture.isNull()) if (!mAccuTextureAsset.isNull())
{ {
mAccuTexture.free();
gLevelAccuMap.free(); gLevelAccuMap.free();
} }
} }
@ -174,7 +171,7 @@ void LevelInfo::initPersistFields()
//addField( "advancedLightmapSupport", TypeBool, Offset( mAdvancedLightmapSupport, LevelInfo ), //addField( "advancedLightmapSupport", TypeBool, Offset( mAdvancedLightmapSupport, LevelInfo ),
// "Enable expanded support for mixing static and dynamic lighting (more costly)" ); // "Enable expanded support for mixing static and dynamic lighting (more costly)" );
INITPERSISTFIELD_IMAGEASSET(AccuTexture, LevelInfo, "Accumulation texture."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(AccuTexture, LevelInfo, "Accumulation texture.");
endGroup( "Lighting" ); endGroup( "Lighting" );
@ -224,7 +221,7 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
sfxWrite( stream, mSoundAmbience ); sfxWrite( stream, mSoundAmbience );
stream->writeInt( mSoundDistanceModel, 1 ); stream->writeInt( mSoundDistanceModel, 1 );
PACK_ASSET(conn, AccuTexture); PACK_ASSET_REFACTOR(conn, AccuTexture);
return retMask; return retMask;
} }
@ -273,8 +270,8 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
SFX->setDistanceModel( mSoundDistanceModel ); SFX->setDistanceModel( mSoundDistanceModel );
} }
UNPACK_ASSET(conn, AccuTexture); UNPACK_ASSET_REFACTOR(conn, AccuTexture);
setLevelAccuTexture(getAccuTexture()); setLevelAccuTexture();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -370,24 +367,12 @@ void LevelInfo::_onLMActivate(const char *lm, bool enable)
#endif #endif
} }
bool LevelInfo::_setLevelAccuTexture(void *object, const char *index, const char *data) void LevelInfo::setLevelAccuTexture()
{ {
LevelInfo* volume = reinterpret_cast< LevelInfo* >(object); if (isClientObject() && mAccuTextureAsset.notNull())
volume->setLevelAccuTexture(StringTable->insert(data));
return false;
}
void LevelInfo::setLevelAccuTexture(StringTableEntry name)
{
_setAccuTexture(name);
if (isClientObject() && getAccuTexture() != StringTable->EmptyString())
{ {
if (mAccuTexture.isNull()) gLevelAccuMap = getAccuTexture();
Con::warnf("AccumulationVolume::setTexture - Unable to load texture: %s", getAccuTexture());
else
gLevelAccuMap = mAccuTexture;
} }
AccumulationVolume::refreshVolumes(); AccumulationVolume::refreshVolumes();
} }

View file

@ -106,10 +106,7 @@ class LevelInfo : public NetObject
void _onLMActivate(const char *lm, bool enable); void _onLMActivate(const char *lm, bool enable);
protected: protected:
DECLARE_IMAGEASSET(LevelInfo, AccuTexture, onAccuTextureChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(LevelInfo, AccuTexture, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(LevelInfo, AccuTexture);
void onAccuTextureChanged() {}
public: public:
@ -146,8 +143,7 @@ class LevelInfo : public NetObject
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) override; U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) override;
void unpackUpdate( NetConnection *conn, BitStream *stream ) override; void unpackUpdate( NetConnection *conn, BitStream *stream ) override;
static bool _setLevelAccuTexture(void *object, const char *index, const char *data); void setLevelAccuTexture();
void setLevelAccuTexture(StringTableEntry name);
/// @} /// @}
}; };

View file

@ -132,8 +132,6 @@ LightFlareData::LightFlareData()
for ( U32 i = 0; i < MAX_ELEMENTS; i++ ) for ( U32 i = 0; i < MAX_ELEMENTS; i++ )
mElementDist[i] = -1.0f; mElementDist[i] = -1.0f;
INIT_ASSET(FlareTexture);
} }
LightFlareData::~LightFlareData() LightFlareData::~LightFlareData()
@ -161,7 +159,7 @@ void LightFlareData::initPersistFields()
addField( "flareEnabled", TypeBool, Offset( mFlareEnabled, LightFlareData ), addField( "flareEnabled", TypeBool, Offset( mFlareEnabled, LightFlareData ),
"Allows the user to disable this flare globally for any lights referencing it." ); "Allows the user to disable this flare globally for any lights referencing it." );
INITPERSISTFIELD_IMAGEASSET(FlareTexture, LightFlareData, "The texture / sprite sheet for this flare."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(FlareTexture, LightFlareData, "The texture / sprite sheet for this flare.");
addArray( "Elements", MAX_ELEMENTS ); addArray( "Elements", MAX_ELEMENTS );
@ -220,7 +218,7 @@ void LightFlareData::packData( BitStream *stream )
stream->writeFlag( mFlareEnabled ); stream->writeFlag( mFlareEnabled );
PACKDATA_ASSET(FlareTexture); PACKDATA_ASSET_REFACTOR(FlareTexture);
stream->write( mScale ); stream->write( mScale );
stream->write( mOcclusionRadius ); stream->write( mOcclusionRadius );
@ -245,7 +243,7 @@ void LightFlareData::unpackData( BitStream *stream )
mFlareEnabled = stream->readFlag(); mFlareEnabled = stream->readFlag();
UNPACKDATA_ASSET(FlareTexture); UNPACKDATA_ASSET_REFACTOR(FlareTexture);
stream->read( &mScale ); stream->read( &mScale );
stream->read( &mOcclusionRadius ); stream->read( &mOcclusionRadius );
@ -540,7 +538,7 @@ void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareS
GFXVertexPCT *vert = flareState->vertBuffer.lock(); GFXVertexPCT *vert = flareState->vertBuffer.lock();
const Point2F oneOverTexSize( 1.0f / (F32)mFlareTexture.getWidth(), 1.0f / (F32)mFlareTexture.getHeight() ); const Point2F oneOverTexSize( 1.0f / (F32)getFlareTexture().getWidth(), 1.0f / (F32)getFlareTexture().getHeight());
for ( U32 i = 0; i < mElementCount; i++ ) for ( U32 i = 0; i < mElementCount; i++ )
{ {
@ -614,7 +612,7 @@ void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareS
ri->bbModelViewProj = &MatrixF::Identity; ri->bbModelViewProj = &MatrixF::Identity;
ri->count = elementCount; ri->count = elementCount;
ri->blendStyle = ParticleRenderInst::BlendGreyscale; ri->blendStyle = ParticleRenderInst::BlendGreyscale;
ri->diffuseTex = mFlareTexture; ri->diffuseTex = getFlareTexture();
ri->softnessDistance = 1.0f; ri->softnessDistance = 1.0f;
ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff; // Sort by texture too. ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff; // Sort by texture too.

View file

@ -106,8 +106,6 @@ protected:
void _makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count ); void _makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count );
void _renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat ); void _renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
void onImageChanged() {}
protected: protected:
static const U32 LosMask; static const U32 LosMask;
@ -120,8 +118,7 @@ protected:
F32 mScale; F32 mScale;
bool mFlareEnabled; bool mFlareEnabled;
DECLARE_IMAGEASSET(LightFlareData, FlareTexture, onImageChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(LightFlareData, FlareTexture, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(LightFlareData, FlareTexture);
F32 mOcclusionRadius; F32 mOcclusionRadius;
bool mRenderReflectPass; bool mRenderReflectPass;

View file

@ -264,7 +264,7 @@ void afxZodiacGroundPlaneRenderer::render(SceneRenderState* state)
GFX->setShaderConstBuffer(shader_consts); GFX->setShaderConstBuffer(shader_consts);
// set the texture // set the texture
GFX->setTexture(0, *zode->txr); GFX->setTexture(0, zode->txr);
LinearColorF zode_color = (LinearColorF)zode->color; LinearColorF zode_color = (LinearColorF)zode->color;
zode_color.alpha *= fadebias; zode_color.alpha *= fadebias;
shader_consts->set(color_sc, zode_color); shader_consts->set(color_sc, zode_color);

View file

@ -268,7 +268,7 @@ void afxZodiacMeshRoadRenderer::render(SceneRenderState* state)
GFX->setShaderConstBuffer(shader_consts); GFX->setShaderConstBuffer(shader_consts);
// set the texture // set the texture
GFX->setTexture(0, *zode->txr); GFX->setTexture(0, zode->txr);
LinearColorF zode_color = (LinearColorF)zode->color; LinearColorF zode_color = (LinearColorF)zode->color;
zode_color.alpha *= fadebias; zode_color.alpha *= fadebias;
shader_consts->set(color_sc, zode_color); shader_consts->set(color_sc, zode_color);

View file

@ -268,7 +268,7 @@ void afxZodiacPolysoupRenderer::render(SceneRenderState* state)
GFX->setShaderConstBuffer(shader_consts); GFX->setShaderConstBuffer(shader_consts);
// set the texture // set the texture
GFX->setTexture(0, *zode->txr); GFX->setTexture(0, zode->txr);
LinearColorF zode_color = (LinearColorF)zode->color; LinearColorF zode_color = (LinearColorF)zode->color;
zode_color.alpha *= fadebias; zode_color.alpha *= fadebias;
shader_consts->set(color_sc, zode_color); shader_consts->set(color_sc, zode_color);

View file

@ -281,7 +281,7 @@ void afxZodiacTerrainRenderer::render(SceneRenderState* state)
GFX->setShaderConstBuffer(shader_consts); GFX->setShaderConstBuffer(shader_consts);
// set the texture // set the texture
GFX->setTexture(0, *zode->txr); GFX->setTexture(0, zode->txr);
LinearColorF zode_color = (LinearColorF)zode->color; LinearColorF zode_color = (LinearColorF)zode->color;
zode_color.alpha *= fadebias; zode_color.alpha *= fadebias;
shader_consts->set(color_sc, zode_color); shader_consts->set(color_sc, zode_color);

View file

@ -51,7 +51,6 @@ ConsoleDocClass( afxBillboardData,
afxBillboardData::afxBillboardData() afxBillboardData::afxBillboardData()
{ {
color.set(1.0f, 1.0f, 1.0f, 1.0f); color.set(1.0f, 1.0f, 1.0f, 1.0f);
INIT_ASSET(Texture);
dimensions.set(1.0f, 1.0f); dimensions.set(1.0f, 1.0f);
texCoords[0].set(0.0f, 0.0f); texCoords[0].set(0.0f, 0.0f);
texCoords[1].set(0.0f, 1.0f); texCoords[1].set(0.0f, 1.0f);
@ -66,7 +65,7 @@ afxBillboardData::afxBillboardData(const afxBillboardData& other, bool temp_clon
: GameBaseData(other, temp_clone) : GameBaseData(other, temp_clone)
{ {
color = other.color; color = other.color;
CLONE_ASSET(Texture); CLONE_ASSET_REFACTOR(Texture);
dimensions = other.dimensions; dimensions = other.dimensions;
texCoords[0] = other.texCoords[0]; texCoords[0] = other.texCoords[0];
texCoords[1] = other.texCoords[1]; texCoords[1] = other.texCoords[1];
@ -96,7 +95,7 @@ void afxBillboardData::initPersistFields()
"The color assigned to the quadrangle geometry. The way it combines with the given " "The color assigned to the quadrangle geometry. The way it combines with the given "
"texture varies according to the setting of the textureFunction field."); "texture varies according to the setting of the textureFunction field.");
INITPERSISTFIELD_IMAGEASSET(Texture, afxBillboardData, "An image to use as the billboard's texture."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, afxBillboardData, "An image to use as the billboard's texture.");
addField("dimensions", TypePoint2F, myOffset(dimensions), addField("dimensions", TypePoint2F, myOffset(dimensions),
"A value-pair that specifies the horizontal and vertical dimensions of the billboard " "A value-pair that specifies the horizontal and vertical dimensions of the billboard "
@ -124,7 +123,7 @@ void afxBillboardData::packData(BitStream* stream)
Parent::packData(stream); Parent::packData(stream);
stream->write(color); stream->write(color);
PACKDATA_ASSET(Texture); PACKDATA_ASSET_REFACTOR(Texture);
mathWrite(*stream, dimensions); mathWrite(*stream, dimensions);
mathWrite(*stream, texCoords[0]); mathWrite(*stream, texCoords[0]);
@ -141,7 +140,7 @@ void afxBillboardData::unpackData(BitStream* stream)
Parent::unpackData(stream); Parent::unpackData(stream);
stream->read(&color); stream->read(&color);
UNPACKDATA_ASSET(Texture); UNPACKDATA_ASSET_REFACTOR(Texture);
mathRead(*stream, &dimensions); mathRead(*stream, &dimensions);
mathRead(*stream, &texCoords[0]); mathRead(*stream, &texCoords[0]);
mathRead(*stream, &texCoords[1]); mathRead(*stream, &texCoords[1]);

View file

@ -47,8 +47,7 @@ public:
}; };
public: public:
DECLARE_IMAGEASSET(afxBillboardData, Texture, onChangeTexture, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_REFACTOR(afxBillboardData, Texture, GFXStaticTextureSRGBProfile)
DECLARE_ASSET_SETGET(afxBillboardData, Texture);
LinearColorF color; LinearColorF color;
@ -71,8 +70,6 @@ public:
static void initPersistFields(); static void initPersistFields();
void onChangeTexture() {}
DECLARE_CONOBJECT(afxBillboardData); DECLARE_CONOBJECT(afxBillboardData);
}; };

View file

@ -87,7 +87,7 @@ void afxBillboard::_renderBillboard(ObjectRenderInst *ri, SceneRenderState* stat
GFXTransformSaver saver; GFXTransformSaver saver;
GFX->multWorld(getRenderTransform()); GFX->multWorld(getRenderTransform());
GFX->setTexture(0, mDataBlock->mTexture); GFX->setTexture(0, mDataBlock->getTexture());
MatrixF worldmod = GFX->getWorldMatrix(); MatrixF worldmod = GFX->getWorldMatrix();
MatrixF viewmod = GFX->getViewMatrix(); MatrixF viewmod = GFX->getViewMatrix();

View file

@ -78,8 +78,6 @@ bool afxZodiacData::sPreferDestinationGradients = false;
afxZodiacData::afxZodiacData() afxZodiacData::afxZodiacData()
{ {
INIT_ASSET(Texture);
radius_xy = 1; radius_xy = 1;
vert_range.set(0.0f, 0.0f); vert_range.set(0.0f, 0.0f);
start_ang = 0; start_ang = 0;
@ -120,7 +118,7 @@ afxZodiacData::afxZodiacData()
afxZodiacData::afxZodiacData(const afxZodiacData& other, bool temp_clone) : GameBaseData(other, temp_clone) afxZodiacData::afxZodiacData(const afxZodiacData& other, bool temp_clone) : GameBaseData(other, temp_clone)
{ {
CLONE_ASSET(Texture); CLONE_ASSET_REFACTOR(Texture);
radius_xy = other.radius_xy; radius_xy = other.radius_xy;
vert_range = other.vert_range; vert_range = other.vert_range;
@ -157,7 +155,7 @@ EndImplementEnumType;
void afxZodiacData::initPersistFields() void afxZodiacData::initPersistFields()
{ {
docsURL; docsURL;
INITPERSISTFIELD_IMAGEASSET(Texture, afxZodiacData, "An image to use as the zodiac's texture."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, afxZodiacData, "An image to use as the zodiac's texture.");
addField("radius", TypeF32, Offset(radius_xy, afxZodiacData), addField("radius", TypeF32, Offset(radius_xy, afxZodiacData),
"The zodiac's radius in scene units."); "The zodiac's radius in scene units.");
addField("verticalRange", TypePoint2F, Offset(vert_range, afxZodiacData), addField("verticalRange", TypePoint2F, Offset(vert_range, afxZodiacData),
@ -270,7 +268,7 @@ void afxZodiacData::packData(BitStream* stream)
merge_zflags(); merge_zflags();
PACKDATA_ASSET(Texture); PACKDATA_ASSET_REFACTOR(Texture);
stream->write(radius_xy); stream->write(radius_xy);
stream->write(vert_range.x); stream->write(vert_range.x);
stream->write(vert_range.y); stream->write(vert_range.y);
@ -295,7 +293,7 @@ void afxZodiacData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
UNPACKDATA_ASSET(Texture); UNPACKDATA_ASSET_REFACTOR(Texture);
stream->read(&radius_xy); stream->read(&radius_xy);
stream->read(&vert_range.x); stream->read(&vert_range.x);
stream->read(&vert_range.y); stream->read(&vert_range.y);
@ -342,16 +340,9 @@ void afxZodiacData::onStaticModified(const char* slot, const char* newValue)
void afxZodiacData::onPerformSubstitutions() void afxZodiacData::onPerformSubstitutions()
{ {
if (mTextureAssetId != StringTable->EmptyString()) if (mTextureAsset.notNull())
{ {
mTextureAsset = mTextureAssetId; getTexture();
if (mTextureAsset.notNull())
{
if (getTexture() != StringTable->EmptyString() && mTextureName != StringTable->insert("texhandle"))
{
mTexture.set(getTexture(), mTextureProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
}
}
} }
} }

View file

@ -56,11 +56,8 @@ public:
static void convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg); static void convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg);
void onImageChanged() {}
public: public:
DECLARE_IMAGEASSET(afxZodiacData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile); DECLARE_IMAGEASSET_REFACTOR(afxZodiacData, Texture, AFX_GFXZodiacTextureProfile)
DECLARE_ASSET_SETGET(afxZodiacData, Texture);
F32 radius_xy; F32 radius_xy;
Point2F vert_range; Point2F vert_range;

View file

@ -61,7 +61,7 @@ void afxZodiacMgr::addTerrainZodiac(Point3F& pos, F32 radius, LinearColorF& colo
z.color = color.toColorI(); z.color = color.toColorI();
z.angle = mDegToRad(angle); z.angle = mDegToRad(angle);
z.zflags = zode->zflags; z.zflags = zode->zflags;
z.txr = &zode->mTexture; z.txr = zode->getTexture();
z.distance_max = zode->distance_max*zode->distance_max; z.distance_max = zode->distance_max*zode->distance_max;
z.distance_falloff = zode->distance_falloff*zode->distance_falloff; z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
@ -84,7 +84,7 @@ void afxZodiacMgr::addInteriorZodiac(Point3F& pos, F32 radius, Point2F& vert_ran
z.color = color.toColorI(); z.color = color.toColorI();
z.angle = mDegToRad(angle); z.angle = mDegToRad(angle);
z.zflags = zode->zflags; z.zflags = zode->zflags;
z.txr = &zode->mTexture; z.txr = zode->getTexture();
z.distance_max = zode->distance_max*zode->distance_max; z.distance_max = zode->distance_max*zode->distance_max;
z.distance_falloff = zode->distance_falloff*zode->distance_falloff; z.distance_falloff = zode->distance_falloff*zode->distance_falloff;

View file

@ -67,7 +67,7 @@ private:
ColorI color; // 4// color of zodiac ColorI color; // 4// color of zodiac
F32 angle; // 4// angle in radians F32 angle; // 4// angle in radians
U32 zflags; // 4// 0=normal,1=additive,2=subtractive U32 zflags; // 4// 0=normal,1=additive,2=subtractive
GFXTexHandle* txr; // 4// zodiac texture GFXTexHandle txr; // 4// zodiac texture
F32 distance_max; F32 distance_max;
F32 distance_falloff; F32 distance_falloff;

View file

@ -51,8 +51,6 @@ ConsoleDocClass( afxZodiacPlaneData,
afxZodiacPlaneData::afxZodiacPlaneData() afxZodiacPlaneData::afxZodiacPlaneData()
{ {
INIT_ASSET(Texture);
radius_xy = 1; radius_xy = 1;
start_ang = 0; start_ang = 0;
ang_per_sec = 0; ang_per_sec = 0;
@ -71,7 +69,7 @@ afxZodiacPlaneData::afxZodiacPlaneData()
afxZodiacPlaneData::afxZodiacPlaneData(const afxZodiacPlaneData& other, bool temp_clone) afxZodiacPlaneData::afxZodiacPlaneData(const afxZodiacPlaneData& other, bool temp_clone)
: GameBaseData(other, temp_clone) : GameBaseData(other, temp_clone)
{ {
CLONE_ASSET(Texture); CLONE_ASSET_REFACTOR(Texture);
radius_xy = other.radius_xy; radius_xy = other.radius_xy;
start_ang = other.start_ang; start_ang = other.start_ang;
@ -112,7 +110,7 @@ EndImplementEnumType;
void afxZodiacPlaneData::initPersistFields() void afxZodiacPlaneData::initPersistFields()
{ {
docsURL; docsURL;
INITPERSISTFIELD_IMAGEASSET(Texture, afxZodiacPlaneData, "An image to use as the zodiac's texture."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, afxZodiacPlaneData, "An image to use as the zodiac's texture.");
addField("radius", TypeF32, myOffset(radius_xy), addField("radius", TypeF32, myOffset(radius_xy),
"The zodiac's radius in scene units."); "The zodiac's radius in scene units.");
@ -166,7 +164,7 @@ void afxZodiacPlaneData::packData(BitStream* stream)
merge_zflags(); merge_zflags();
PACKDATA_ASSET(Texture); PACKDATA_ASSET_REFACTOR(Texture);
stream->write(radius_xy); stream->write(radius_xy);
stream->write(start_ang); stream->write(start_ang);
@ -185,7 +183,7 @@ void afxZodiacPlaneData::unpackData(BitStream* stream)
{ {
Parent::unpackData(stream); Parent::unpackData(stream);
UNPACKDATA_ASSET(Texture); UNPACKDATA_ASSET_REFACTOR(Texture);
stream->read(&radius_xy); stream->read(&radius_xy);
stream->read(&start_ang); stream->read(&start_ang);

View file

@ -56,11 +56,8 @@ public:
FACES_BITS = 3 FACES_BITS = 3
}; };
void onImageChanged() {}
public: public:
DECLARE_IMAGEASSET(afxZodiacPlaneData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile); DECLARE_IMAGEASSET_REFACTOR(afxZodiacPlaneData, Texture, AFX_GFXZodiacTextureProfile)
DECLARE_ASSET_SETGET(afxZodiacPlaneData, Texture);
F32 radius_xy; F32 radius_xy;
F32 start_ang; F32 start_ang;

View file

@ -207,7 +207,7 @@ void afxZodiacPlane::_renderZodiacPlane(ObjectRenderInst *ri, SceneRenderState*
GFXTransformSaver saver; GFXTransformSaver saver;
GFX->multWorld(getRenderTransform()); GFX->multWorld(getRenderTransform());
GFX->setTexture(0, mDataBlock->mTexture); GFX->setTexture(0, mDataBlock->getTexture());
PrimBuild::begin(GFXTriangleStrip, 4); PrimBuild::begin(GFXTriangleStrip, 4);
{ {

View file

@ -146,7 +146,7 @@ void afxParticlePool::pool_renderObject_Normal(RenderPassManager *renderManager,
if (main_emitter_data->textureHandle) if (main_emitter_data->textureHandle)
ri->diffuseTex = &*(main_emitter_data->textureHandle); ri->diffuseTex = &*(main_emitter_data->textureHandle);
else else
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureResource()); ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTexture());
ri->softnessDistance = main_emitter_data->softnessDistance; ri->softnessDistance = main_emitter_data->softnessDistance;
@ -277,7 +277,7 @@ void afxParticlePool::pool_renderObject_TwoPass(RenderPassManager *renderManager
//if (main_emitter_data->textureHandle) //if (main_emitter_data->textureHandle)
// ri->diffuseTex = &*(main_emitter_data->textureHandle); // ri->diffuseTex = &*(main_emitter_data->textureHandle);
//else //else
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureExtResource()); ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureExt());
F32 save_sort_dist = ri->sortDistSq; F32 save_sort_dist = ri->sortDistSq;
@ -481,7 +481,7 @@ void afxParticlePool::pool_renderObject_TwoPass(RenderPassManager *renderManager
if (main_emitter_data->textureHandle) if (main_emitter_data->textureHandle)
ri->diffuseTex = &*(main_emitter_data->textureHandle); ri->diffuseTex = &*(main_emitter_data->textureHandle);
else else
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureResource()); ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTexture());
ri->softnessDistance = main_emitter_data->softnessDistance; ri->softnessDistance = main_emitter_data->softnessDistance;

View file

@ -105,7 +105,6 @@ VolumetricFog::VolumetricFog()
mFrontBufferTarget = NULL; mFrontBufferTarget = NULL;
z_buf = NULL; z_buf = NULL;
mTexture = NULL;
mIsVBDirty = false; mIsVBDirty = false;
mIsPBDirty = false; mIsPBDirty = false;
@ -138,7 +137,6 @@ VolumetricFog::VolumetricFog()
mSpeed2.set(0.1f, 0.1f); mSpeed2.set(0.1f, 0.1f);
INIT_ASSET(Shape); INIT_ASSET(Shape);
INIT_ASSET(Texture);
} }
VolumetricFog::~VolumetricFog() VolumetricFog::~VolumetricFog()
@ -159,8 +157,6 @@ VolumetricFog::~VolumetricFog()
z_buf = NULL; z_buf = NULL;
if (!mTexture.isNull())
mTexture.free();
} }
void VolumetricFog::initPersistFields() void VolumetricFog::initPersistFields()
@ -185,7 +181,7 @@ void VolumetricFog::initPersistFields()
endGroup("VolumetricFogData"); endGroup("VolumetricFogData");
addGroup("VolumetricFogModulation"); addGroup("VolumetricFogModulation");
INITPERSISTFIELD_IMAGEASSET(Texture, VolumetricFog, "A texture which contains Fogdensity modulator in the red channel and color with 1-green channel. No texture disables modulation."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, VolumetricFog, "A texture which contains Fogdensity modulator in the red channel and color with 1-green channel. No texture disables modulation.");
addField("tiles", TypeF32, Offset(mTexTiles, VolumetricFog), addField("tiles", TypeF32, Offset(mTexTiles, VolumetricFog),
"How many times the texture is mapped to the object."); "How many times the texture is mapped to the object.");
@ -330,8 +326,10 @@ void VolumetricFog::handleResize(VolumetricFogRTManager *RTM, bool resize)
F32 width = (F32)mPlatformWindow->getClientExtent().x; F32 width = (F32)mPlatformWindow->getClientExtent().x;
F32 height = (F32)mPlatformWindow->getClientExtent().y; F32 height = (F32)mPlatformWindow->getClientExtent().y;
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width); // load texture.
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height); getTexture();
mTexScale.x = 2.0f - ((F32)mTextureAsset->getTextureWidth() / width);
mTexScale.y = 2.0f - ((F32)mTextureAsset->getTextureHeight() / height);
} }
UpdateBuffers(0,true); UpdateBuffers(0,true);
@ -545,7 +543,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->write(mFogDensity); stream->write(mFogDensity);
if (stream->writeFlag(mask & FogModulationMask)) if (stream->writeFlag(mask & FogModulationMask))
{ {
PACK_ASSET(con, Texture); PACK_ASSET_REFACTOR(con, Texture);
mTexTiles = mFabs(mTexTiles); mTexTiles = mFabs(mTexTiles);
stream->write(mTexTiles); stream->write(mTexTiles);
stream->write(mStrength); stream->write(mStrength);
@ -597,7 +595,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
MatrixF mat; MatrixF mat;
VectorF scale; VectorF scale;
VectorF mOldScale = getScale(); VectorF mOldScale = getScale();
StringTableEntry oldTextureName = mTextureAssetId; StringTableEntry oldTextureName = mTextureAsset.getAssetId();
StringTableEntry oldShapeAsset = mShapeAssetId; StringTableEntry oldShapeAsset = mShapeAssetId;
StringTableEntry oldShape = mShapeName; StringTableEntry oldShape = mShapeName;
@ -615,7 +613,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
} }
if (stream->readFlag())// Fog Modulation if (stream->readFlag())// Fog Modulation
{ {
UNPACK_ASSET(con, Texture); UNPACK_ASSET_REFACTOR(con, Texture);
stream->read(&mTexTiles); stream->read(&mTexTiles);
mTexTiles = mFabs(mTexTiles); mTexTiles = mFabs(mTexTiles);
stream->read(&mStrength); stream->read(&mStrength);
@ -625,12 +623,11 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
if (isProperlyAdded()) if (isProperlyAdded())
{ {
if (oldTextureName != mTextureAssetId) if (oldTextureName != mTextureAsset.getAssetId())
InitTexture(); InitTexture();
if (oldTextureName != StringTable->EmptyString() && mTextureAssetId == StringTable->EmptyString()) if (oldTextureName != StringTable->EmptyString() && mTextureAsset.isNull())
{ {
mIsTextured = false; mIsTextured = false;
mTexture.free();
} }
} }
} }
@ -1149,7 +1146,7 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
if (mIsTextured && mStrength > 0.0f) if (mIsTextured && mStrength > 0.0f)
{ {
GFX->setTexture(3, mTexture); GFX->setTexture(3, getTexture());
mShaderConsts->setSafe(mIsTexturedSC, 1.0f); mShaderConsts->setSafe(mIsTexturedSC, 1.0f);
} }
else else
@ -1222,15 +1219,16 @@ void VolumetricFog::InitTexture()
{ {
return; return;
} }
if (!mTexture.isNull()) if (!mTextureAsset.isNull())
{ {
mIsTextured = true; mIsTextured = true;
// load asset.
getTexture();
F32 width = (F32)mPlatformWindow->getClientExtent().x; F32 width = (F32)mPlatformWindow->getClientExtent().x;
F32 height = (F32)mPlatformWindow->getClientExtent().y; F32 height = (F32)mPlatformWindow->getClientExtent().y;
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width); mTexScale.x = 2.0f - ((F32)mTextureAsset->getTextureWidth() / width);
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height); mTexScale.y = 2.0f - ((F32)mTextureAsset->getTextureHeight() / height);
} }
} }

View file

@ -162,8 +162,7 @@ class VolumetricFog : public SceneObject
F32 mInvScale; F32 mInvScale;
// Fog Modulation data // Fog Modulation data
DECLARE_IMAGEASSET(VolumetricFog, Texture, onImageChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_NET_REFACTOR(VolumetricFog, Texture, GFXStaticTextureSRGBProfile, FogModulationMask)
DECLARE_ASSET_NET_SETGET(VolumetricFog, Texture, FogModulationMask);
bool mIsTextured; bool mIsTextured;
F32 mTexTiles; F32 mTexTiles;
@ -221,8 +220,6 @@ class VolumetricFog : public SceneObject
static bool _setShapeAsset(void* obj, const char* index, const char* data); static bool _setShapeAsset(void* obj, const char* index, const char* data);
void onImageChanged() {}
public: public:
// Public methods // Public methods
VolumetricFog(); VolumetricFog();

View file

@ -98,7 +98,7 @@ protected:
public: public:
DECLARE_IMAGEASSET_REFACTOR(CloudLayer,Texture, GFXStaticTextureSRGBProfile) DECLARE_IMAGEASSET_NET_REFACTOR(CloudLayer,Texture, GFXStaticTextureSRGBProfile, CloudLayerMask)
GFXShaderRef mShader; GFXShaderRef mShader;

View file

@ -260,10 +260,6 @@ WaterObject::WaterObject()
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16)); mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
constructInPlace(mMatrixSet); constructInPlace(mMatrixSet);
INIT_ASSET(RippleTex);
INIT_ASSET(FoamTex);
INIT_ASSET(DepthGradientTex);
mCubemapName = StringTable->EmptyString(); mCubemapName = StringTable->EmptyString();
} }
@ -300,7 +296,7 @@ void WaterObject::initPersistFields()
addField( "overallWaveMagnitude", TypeF32, Offset( mOverallWaveMagnitude, WaterObject ), "Master variable affecting entire body" addField( "overallWaveMagnitude", TypeF32, Offset( mOverallWaveMagnitude, WaterObject ), "Master variable affecting entire body"
" of water's undulation" ); " of water's undulation" );
INITPERSISTFIELD_IMAGEASSET(RippleTex, WaterObject, "Normal map used to simulate small surface ripples"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(RippleTex, WaterObject, "Normal map used to simulate small surface ripples");
addArray( "Ripples (texture animation)", MAX_WAVES ); addArray( "Ripples (texture animation)", MAX_WAVES );
@ -314,7 +310,7 @@ void WaterObject::initPersistFields()
addField( "overallRippleMagnitude", TypeF32, Offset( mOverallRippleMagnitude, WaterObject ), "Master variable affecting entire surface"); addField( "overallRippleMagnitude", TypeF32, Offset( mOverallRippleMagnitude, WaterObject ), "Master variable affecting entire surface");
INITPERSISTFIELD_IMAGEASSET(FoamTex, WaterObject, "Diffuse texture for foam in shallow water (advanced lighting only)"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(FoamTex, WaterObject, "Diffuse texture for foam in shallow water (advanced lighting only)");
addArray( "Foam", MAX_FOAM ); addArray( "Foam", MAX_FOAM );
@ -366,7 +362,7 @@ void WaterObject::initPersistFields()
addGroup( "Misc" ); addGroup( "Misc" );
INITPERSISTFIELD_IMAGEASSET(DepthGradientTex, WaterObject, "1D texture defining the base water color by depth"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(DepthGradientTex, WaterObject, "1D texture defining the base water color by depth");
addField( "depthGradientMax", TypeF32, Offset( mDepthGradientMax, WaterObject ), "Depth in world units, the max range of the color gradient texture." ); addField( "depthGradientMax", TypeF32, Offset( mDepthGradientMax, WaterObject ), "Depth in world units, the max range of the color gradient texture." );
@ -547,9 +543,9 @@ U32 WaterObject::packUpdate( NetConnection * conn, U32 mask, BitStream *stream )
if ( stream->writeFlag( mask & TextureMask ) ) if ( stream->writeFlag( mask & TextureMask ) )
{ {
PACK_ASSET(conn, RippleTex); PACK_ASSET_REFACTOR(conn, RippleTex);
PACK_ASSET(conn, DepthGradientTex); PACK_ASSET_REFACTOR(conn, DepthGradientTex);
PACK_ASSET(conn, FoamTex); PACK_ASSET_REFACTOR(conn, FoamTex);
stream->writeString( mCubemapName ); stream->writeString( mCubemapName );
} }
@ -669,9 +665,9 @@ void WaterObject::unpackUpdate( NetConnection * conn, BitStream *stream )
// TextureMask // TextureMask
if ( stream->readFlag() ) if ( stream->readFlag() )
{ {
UNPACK_ASSET(conn, RippleTex); UNPACK_ASSET_REFACTOR(conn, RippleTex);
UNPACK_ASSET(conn, DepthGradientTex); UNPACK_ASSET_REFACTOR(conn, DepthGradientTex);
UNPACK_ASSET(conn, FoamTex); UNPACK_ASSET_REFACTOR(conn, FoamTex);
mCubemapName = stream->readSTString(); mCubemapName = stream->readSTString();
@ -767,13 +763,13 @@ void WaterObject::renderObject( ObjectRenderInst *ri, SceneRenderState *state, B
void WaterObject::setCustomTextures( S32 matIdx, U32 pass, const WaterMatParams &paramHandles ) void WaterObject::setCustomTextures( S32 matIdx, U32 pass, const WaterMatParams &paramHandles )
{ {
// Always use the ripple texture. // Always use the ripple texture.
GFX->setTexture( paramHandles.mRippleSamplerSC->getSamplerRegister(pass), mRippleTex ); GFX->setTexture( paramHandles.mRippleSamplerSC->getSamplerRegister(pass), getRippleTex() );
// Only above-water in advanced-lighting uses the foam texture. // Only above-water in advanced-lighting uses the foam texture.
if ( matIdx == WaterMat ) if ( matIdx == WaterMat )
{ {
GFX->setTexture( paramHandles.mFoamSamplerSC->getSamplerRegister(pass), mFoamTex ); GFX->setTexture( paramHandles.mFoamSamplerSC->getSamplerRegister(pass), getFoamTex() );
GFX->setTexture( paramHandles.mDepthGradSamplerSC->getSamplerRegister(pass), mDepthGradientTex ); GFX->setTexture( paramHandles.mDepthGradSamplerSC->getSamplerRegister(pass), getDepthGradientTex() );
} }
if ( ( matIdx == WaterMat || matIdx == BasicWaterMat ) && mCubemap ) if ( ( matIdx == WaterMat || matIdx == BasicWaterMat ) && mCubemap )
@ -1118,7 +1114,7 @@ void WaterObject::updateUnderwaterEffect( SceneRenderState *state )
// be fetched by the effect when it renders. // be fetched by the effect when it renders.
if ( !mNamedDepthGradTex.isRegistered() ) if ( !mNamedDepthGradTex.isRegistered() )
mNamedDepthGradTex.registerWithName( "waterDepthGradMap" ); mNamedDepthGradTex.registerWithName( "waterDepthGradMap" );
mNamedDepthGradTex.setTexture( mDepthGradientTex ); mNamedDepthGradTex.setTexture( getDepthGradientTex() );
} }
else else
effect->disable(); effect->disable();
@ -1172,7 +1168,7 @@ bool WaterObject::initMaterial( S32 idx )
void WaterObject::initTextures() void WaterObject::initTextures()
{ {
if ( mNamedDepthGradTex.isRegistered() ) if ( mNamedDepthGradTex.isRegistered() )
mNamedDepthGradTex.setTexture( mDepthGradientTex ); mNamedDepthGradTex.setTexture( getDepthGradientTex() );
if ( mCubemapName != StringTable->EmptyString() ) if ( mCubemapName != StringTable->EmptyString() )
Sim::findObject( mCubemapName, mCubemap ); Sim::findObject( mCubemapName, mCubemap );

View file

@ -203,10 +203,6 @@ protected:
/// Callback used internally when smEnableTrueReflections changes. /// Callback used internally when smEnableTrueReflections changes.
void _onEnableTrueReflections(); void _onEnableTrueReflections();
void onRippleTexChanged() {}
void onFoamTexChanged() {}
void onDepthGradientTexChanged() {}
protected: protected:
static bool _setFullReflect( void *object, const char *index, const char *data ); static bool _setFullReflect( void *object, const char *index, const char *data );
@ -273,12 +269,9 @@ protected:
F32 mDepthGradientMax; F32 mDepthGradientMax;
// Other textures // Other textures
DECLARE_IMAGEASSET(WaterObject, RippleTex, onRippleTexChanged, GFXStaticTextureProfile); DECLARE_IMAGEASSET_NET_REFACTOR(WaterObject, RippleTex, GFXStaticTextureProfile, TextureMask)
DECLARE_ASSET_NET_SETGET(WaterObject, RippleTex, TextureMask); DECLARE_IMAGEASSET_NET_REFACTOR(WaterObject, FoamTex, GFXStaticTextureSRGBProfile, TextureMask)
DECLARE_IMAGEASSET(WaterObject, FoamTex, onFoamTexChanged, GFXStaticTextureSRGBProfile); DECLARE_IMAGEASSET_NET_REFACTOR(WaterObject, DepthGradientTex, GFXStaticTextureSRGBProfile, TextureMask)
DECLARE_ASSET_NET_SETGET(WaterObject, FoamTex, TextureMask);
DECLARE_IMAGEASSET(WaterObject, DepthGradientTex, onDepthGradientTexChanged, GFXStaticTextureSRGBProfile);
DECLARE_ASSET_NET_SETGET(WaterObject, DepthGradientTex, TextureMask);
StringTableEntry mCubemapName; StringTableEntry mCubemapName;

View file

@ -374,7 +374,7 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
// We only include materials that // We only include materials that
// have more than a base texture. // have more than a base texture.
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance()>0)) if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance()>0))
continue; continue;
if (deferredMat) if (deferredMat)
@ -382,12 +382,12 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
features.addFeature(MFT_TerrainDetailMap, featureIndex); features.addFeature(MFT_TerrainDetailMap, featureIndex);
// check for macro detail texture // check for macro detail texture
if (mat->MacroMapValid() && mat->getMacroSize() > 0 && mat->getMacroDistance() > 0) if (mat->getMacroMap() && mat->getMacroSize() > 0 && mat->getMacroDistance() > 0)
{ {
features.addFeature(MFT_TerrainMacroMap, featureIndex); features.addFeature(MFT_TerrainMacroMap, featureIndex);
} }
if (mat->ORMConfigMapValid()) if (mat->getORMConfigMap())
{ {
features.addFeature(MFT_TerrainORMMap, featureIndex); features.addFeature(MFT_TerrainORMMap, featureIndex);
} }
@ -401,12 +401,12 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
// Skip normal maps if we need to. // Skip normal maps if we need to.
if (!disableNormalMaps && mat->NormalMapValid()) if (!disableNormalMaps && mat->getNormalMap())
{ {
normalMaps.increment(); normalMaps.increment();
features.addFeature(MFT_TerrainNormalMap, featureIndex); features.addFeature(MFT_TerrainNormalMap, featureIndex);
normalMaps.last() = mat->getNormalMapResource(); normalMaps.last() = mat->getNormalMap();
GFXFormat normalFmt = normalMaps.last().getFormat(); GFXFormat normalFmt = normalMaps.last().getFormat();
if (normalFmt == GFXFormatBC3) if (normalFmt == GFXFormatBC3)
@ -632,7 +632,7 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
// We only include materials that // We only include materials that
// have more than a base texture. // have more than a base texture.
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0)) if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
continue; continue;
mMaterialInfos[i]->mBlendDepthConst = mShader->getShaderConstHandle(avar("$blendDepth%d", i)); mMaterialInfos[i]->mBlendDepthConst = mShader->getShaderConstHandle(avar("$blendDepth%d", i));
@ -676,7 +676,7 @@ void TerrainCellMaterial::_updateMaterialConsts( )
if (mat == NULL) if (mat == NULL)
continue; continue;
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0)) if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
continue; continue;
detailMatCount++; detailMatCount++;
@ -704,7 +704,7 @@ void TerrainCellMaterial::_updateMaterialConsts( )
if (mat == NULL) if (mat == NULL)
continue; continue;
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0)) if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
continue; continue;
F32 detailSize = matInfo->mat->getDetailSize(); F32 detailSize = matInfo->mat->getDetailSize();

View file

@ -81,11 +81,6 @@ TerrainMaterial::TerrainMaterial()
mIsSRGB(false), mIsSRGB(false),
mInvertRoughness(false) mInvertRoughness(false)
{ {
INIT_ASSET(DiffuseMap);
INIT_ASSET(NormalMap);
INIT_ASSET(DetailMap);
INIT_ASSET(ORMConfigMap);
INIT_ASSET(MacroMap);
} }
TerrainMaterial::~TerrainMaterial() TerrainMaterial::~TerrainMaterial()
@ -97,10 +92,10 @@ FRangeValidator hardnessValidator(0.0f, 0.999f);
void TerrainMaterial::initPersistFields() void TerrainMaterial::initPersistFields()
{ {
docsURL; docsURL;
INITPERSISTFIELD_IMAGEASSET(DiffuseMap, TerrainMaterial,"Base Albedo stretched over the whole map"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(DiffuseMap, TerrainMaterial,"Base Albedo stretched over the whole map");
addField( "diffuseSize", TypeF32, Offset( mDiffuseSize, TerrainMaterial ), "Used to scale the diffuse map to the material square" ); addField( "diffuseSize", TypeF32, Offset( mDiffuseSize, TerrainMaterial ), "Used to scale the diffuse map to the material square" );
INITPERSISTFIELD_IMAGEASSET(NormalMap, TerrainMaterial,"NormalMap"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(NormalMap, TerrainMaterial,"NormalMap");
addField( "parallaxScale", TypeF32, Offset( mParallaxScale, TerrainMaterial ), "Used to scale the height from the normal map to give some self " addField( "parallaxScale", TypeF32, Offset( mParallaxScale, TerrainMaterial ), "Used to scale the height from the normal map to give some self "
"occlusion effect (aka parallax) to the terrain material" ); "occlusion effect (aka parallax) to the terrain material" );
@ -113,7 +108,7 @@ void TerrainMaterial::initPersistFields()
addFieldV("blendHeightHardness", TypeF32, Offset(mBlendHardness, TerrainMaterial), &hardnessValidator, "How sharply this layer blends with other textures." addFieldV("blendHeightHardness", TypeF32, Offset(mBlendHardness, TerrainMaterial), &hardnessValidator, "How sharply this layer blends with other textures."
"0->1, soft->hard."); "0->1, soft->hard.");
INITPERSISTFIELD_IMAGEASSET(DetailMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo up close."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(DetailMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo up close.");
addField( "detailSize", TypeF32, Offset( mDetailSize, TerrainMaterial ), "Used to scale the detail map to the material square" ); addField( "detailSize", TypeF32, Offset( mDetailSize, TerrainMaterial ), "Used to scale the detail map to the material square" );
addField( "detailStrength", TypeF32, Offset( mDetailStrength, TerrainMaterial ), "Exponentially sharpens or lightens the detail map rendering on the material" ); addField( "detailStrength", TypeF32, Offset( mDetailStrength, TerrainMaterial ), "Exponentially sharpens or lightens the detail map rendering on the material" );
addField( "detailDistance", TypeF32, Offset( mDetailDistance, TerrainMaterial ), "Changes how far camera can see the detail map rendering on the material" ); addField( "detailDistance", TypeF32, Offset( mDetailDistance, TerrainMaterial ), "Changes how far camera can see the detail map rendering on the material" );
@ -121,12 +116,12 @@ void TerrainMaterial::initPersistFields()
addField( "useSideProjection", TypeBool, Offset( mSideProjection, TerrainMaterial ),"Makes that terrain material project along the sides of steep " addField( "useSideProjection", TypeBool, Offset( mSideProjection, TerrainMaterial ),"Makes that terrain material project along the sides of steep "
"slopes instead of projected downwards"); "slopes instead of projected downwards");
INITPERSISTFIELD_IMAGEASSET(ORMConfigMap, TerrainMaterial, "AO|Roughness|metalness map (uses DetailMap UV Coords)"); INITPERSISTFIELD_IMAGEASSET_REFACTOR(ORMConfigMap, TerrainMaterial, "AO|Roughness|metalness map (uses DetailMap UV Coords)");
addField("isSRGB", TypeBool, Offset(mIsSRGB, TerrainMaterial), "Is the PBR Config map's image in sRGB format?"); addField("isSRGB", TypeBool, Offset(mIsSRGB, TerrainMaterial), "Is the PBR Config map's image in sRGB format?");
addField("invertRoughness", TypeBool, Offset(mInvertRoughness, TerrainMaterial), "Should the roughness channel of the PBR Config map be inverted?"); addField("invertRoughness", TypeBool, Offset(mInvertRoughness, TerrainMaterial), "Should the roughness channel of the PBR Config map be inverted?");
//Macro maps additions //Macro maps additions
INITPERSISTFIELD_IMAGEASSET(MacroMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo at a distance."); INITPERSISTFIELD_IMAGEASSET_REFACTOR(MacroMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo at a distance.");
addField( "macroSize", TypeF32, Offset( mMacroSize, TerrainMaterial ), "Used to scale the Macro map to the material square" ); addField( "macroSize", TypeF32, Offset( mMacroSize, TerrainMaterial ), "Used to scale the Macro map to the material square" );
addField( "macroStrength", TypeF32, Offset( mMacroStrength, TerrainMaterial ), "Exponentially sharpens or lightens the Macro map rendering on the material" ); addField( "macroStrength", TypeF32, Offset( mMacroStrength, TerrainMaterial ), "Exponentially sharpens or lightens the Macro map rendering on the material" );
addField( "macroDistance", TypeF32, Offset( mMacroDistance, TerrainMaterial ), "Changes how far camera can see the Macro map rendering on the material" ); addField( "macroDistance", TypeF32, Offset( mMacroDistance, TerrainMaterial ), "Changes how far camera can see the Macro map rendering on the material" );
@ -228,8 +223,8 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
//material.getDiffuseMap(); //returns the raw file referenced //material.getDiffuseMap(); //returns the raw file referenced
//material.getDiffuseMapAsset(); //returns the asset id //material.getDiffuseMapAsset(); //returns the asset id
//material.setDiffuseMap(%texture); //tries to set the asset and failing that attempts a flat file reference //material.setDiffuseMap(%texture); //tries to set the asset and failing that attempts a flat file reference
DEF_ASSET_BINDS(TerrainMaterial, DiffuseMap); DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, DiffuseMap)
DEF_ASSET_BINDS(TerrainMaterial, NormalMap); DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, NormalMap)
DEF_ASSET_BINDS(TerrainMaterial, DetailMap); DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, DetailMap)
DEF_ASSET_BINDS(TerrainMaterial, ORMConfigMap); DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, ORMConfigMap)
DEF_ASSET_BINDS(TerrainMaterial, MacroMap); DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, MacroMap)

View file

@ -38,24 +38,17 @@ class TerrainMaterial : public SimObject
protected: protected:
/// ///
//FileName mDiffuseMap; DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, DiffuseMap, GFXStaticTextureSRGBProfile)
//AssetPtr<ImageAsset> mDiffuseAsset;
DECLARE_IMAGEASSET(TerrainMaterial, DiffuseMap, onDiffuseMapChanged, GFXStaticTextureSRGBProfile);
DECLARE_ASSET_SETGET(TerrainMaterial, DiffuseMap);
/// The size of the diffuse base map in meters /// The size of the diffuse base map in meters
/// used to generate its texture coordinates. /// used to generate its texture coordinates.
F32 mDiffuseSize; F32 mDiffuseSize;
/// ///
DECLARE_IMAGEASSET(TerrainMaterial, NormalMap, onNormalMapChanged, GFXNormalMapProfile); DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, NormalMap, GFXNormalMapProfile)
DECLARE_ASSET_SETGET(TerrainMaterial, NormalMap);
/// ///
DECLARE_IMAGEASSET(TerrainMaterial, DetailMap, onDetailMapChanged, GFXStaticTextureProfile); DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, DetailMap, GFXStaticTextureProfile)
DECLARE_ASSET_SETGET(TerrainMaterial, DetailMap);
/// The size of the detail map in meters used /// The size of the detail map in meters used
/// to generate the texture coordinates for the /// to generate the texture coordinates for the
@ -69,8 +62,7 @@ protected:
F32 mDetailDistance; F32 mDetailDistance;
/// ///
DECLARE_IMAGEASSET(TerrainMaterial, ORMConfigMap, onORMConfigMapChanged, GFXStaticTextureProfile); DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, ORMConfigMap, GFXStaticTextureProfile)
DECLARE_ASSET_SETGET(TerrainMaterial, ORMConfigMap);
bool mIsSRGB; bool mIsSRGB;
bool mInvertRoughness; bool mInvertRoughness;
@ -81,8 +73,8 @@ protected:
/// planes. /// planes.
bool mSideProjection; bool mSideProjection;
DECLARE_IMAGEASSET(TerrainMaterial, MacroMap, onMacroMapChanged, GFXStaticTextureProfile); DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, MacroMap, GFXStaticTextureProfile)
DECLARE_ASSET_SETGET(TerrainMaterial, MacroMap);
F32 mMacroSize; F32 mMacroSize;
F32 mMacroStrength; F32 mMacroStrength;
F32 mMacroDistance; F32 mMacroDistance;
@ -146,12 +138,6 @@ public:
bool getInvertRoughness() const { return mInvertRoughness; } bool getInvertRoughness() const { return mInvertRoughness; }
void onDiffuseMapChanged() {}
void onNormalMapChanged() {}
void onDetailMapChanged() {}
void onORMConfigMapChanged() {}
void onMacroMapChanged() {}
}; };
#endif // _TERRMATERIAL_H_ #endif // _TERRMATERIAL_H_

View file

@ -96,19 +96,19 @@ void TerrainBlock::_updateMaterials()
{ {
TerrainMaterial *mat = mFile->mMaterials[i]; TerrainMaterial *mat = mFile->mMaterials[i];
if (mat->getDiffuseMap() != StringTable->EmptyString()) if (mat->getDiffuseMapAsset().notNull())
{ {
mBaseTextures[i] = mat->getDiffuseMapResource(); mBaseTextures[i] = mat->getDiffuseMap();
} }
else else
mBaseTextures[ i ] = GFXTexHandle(); mBaseTextures[ i ] = GFXTexHandle();
// Find the maximum detail distance. // Find the maximum detail distance.
if ( mat->getDetailMap() != StringTable->EmptyString() && if ( mat->getDetailMapAsset().notNull() &&
mat->getDetailDistance() > mMaxDetailDistance ) mat->getDetailDistance() > mMaxDetailDistance )
mMaxDetailDistance = mat->getDetailDistance(); mMaxDetailDistance = mat->getDetailDistance();
if ( mat->getMacroMap() != StringTable->EmptyString() && if ( mat->getMacroMapAsset().notNull() &&
mat->getMacroDistance() > mMaxDetailDistance ) mat->getMacroDistance() > mMaxDetailDistance )
mMaxDetailDistance = mat->getMacroDistance(); mMaxDetailDistance = mat->getMacroDistance();
} }
@ -126,19 +126,19 @@ void TerrainBlock::_updateMaterials()
{ {
TerrainMaterial* mat = mFile->mMaterials[i]; TerrainMaterial* mat = mFile->mMaterials[i];
if (mat->getDetailMap() != StringTable->EmptyString()) if (mat->getDetailMapAsset().notNull())
detailTexArray[i] = mat->getDetailMapResource(); detailTexArray[i] = mat->getDetailMap();
if (mat->getMacroMap() != StringTable->EmptyString()) if (mat->getMacroMapAsset().notNull())
macroTexArray[i] = mat->getMacroMapResource(); macroTexArray[i] = mat->getMacroMap();
if (mat->getNormalMap() != StringTable->EmptyString()) if (mat->getNormalMapAsset().notNull())
normalTexArray[i] = mat->getNormalMapResource(); normalTexArray[i] = mat->getNormalMap();
//depending on creation method this may or may not have been shoved into srgb space eroneously //depending on creation method this may or may not have been shoved into srgb space eroneously
GFXTextureProfile* profile = &GFXStaticTextureProfile; GFXTextureProfile* profile = &GFXStaticTextureProfile;
if (mat->getIsSRGB()) if (mat->getIsSRGB())
profile = &GFXStaticTextureSRGBProfile; profile = &GFXStaticTextureSRGBProfile;
if (mat->getORMConfigMap() != StringTable->EmptyString()) if (mat->getORMConfigMapAsset().notNull())
ormTexArray[i] = TEXMGR->createTexture(mat->getORMConfigMap(), profile); ormTexArray[i] = mat->getORMConfigMapAsset()->getTexture(profile);
} }
if (mDetailTextureArray.isNull()) if (mDetailTextureArray.isNull())

View file

@ -1415,7 +1415,7 @@ singleton GuiControlProfile( ToolsGuiMenuBarProfile )
singleton GuiControlProfile( ToolsMenubarProfile : ToolsGuiDefaultProfile ) singleton GuiControlProfile( ToolsMenubarProfile : ToolsGuiDefaultProfile )
{ {
bitmap = "./menubar"; bitmaAsset = "ToolsModule:menubar_image";
category = "Editor"; category = "Editor";
opaque = true; opaque = true;
@ -1433,7 +1433,7 @@ singleton GuiControlProfile (menubarProfile)
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./menubar"; bitmaAsset = "ToolsModule:menubar_image";
category = "Editor"; category = "Editor";
fillColor = EditorSettings.value("Theme/windowBackgroundColor"); fillColor = EditorSettings.value("Theme/windowBackgroundColor");
@ -1447,35 +1447,35 @@ singleton GuiControlProfile (editorMenubarProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./editor-menubar"; bitmaAsset = "ToolsModule:editor_menubar_image";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile (editorMenu_wBorderProfile) singleton GuiControlProfile (editorMenu_wBorderProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./menu-fullborder"; bitmaAsset = "ToolsModule:menu_fullborder_image";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile (inspectorStyleRolloutProfile) singleton GuiControlProfile (inspectorStyleRolloutProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./inspector-style-rollout"; bitmaAsset = "ToolsModule:inspector_style_rollout_image";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile (inspectorStyleRolloutListProfile) singleton GuiControlProfile (inspectorStyleRolloutListProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./inspector-style-rollout-list"; bitmaAsset = "ToolsModule:inspector_style_rollout_list_image";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile (inspectorStyleRolloutDarkProfile) singleton GuiControlProfile (inspectorStyleRolloutDarkProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./inspector-style-rollout-dark"; bitmaAsset = "ToolsModule:inspector_style_rollout_dark_image";
fillColor = EditorSettings.value("Theme/windowBackgroundColor"); fillColor = EditorSettings.value("Theme/windowBackgroundColor");
fontColor = EditorSettings.value("Theme/headerTextColor"); fontColor = EditorSettings.value("Theme/headerTextColor");
@ -1486,14 +1486,14 @@ singleton GuiControlProfile (inspectorStyleRolloutInnerProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./inspector-style-rollout_inner"; bitmaAsset = "ToolsModule:inspector_style_rollout_inner_image";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile (inspectorStyleRolloutNoHeaderProfile) singleton GuiControlProfile (inspectorStyleRolloutNoHeaderProfile)
{ {
border = -2; border = -2;
category = "Editor"; category = "Editor";
bitmap = "./inspector-style-rollout-noheader"; bitmaAsset = "ToolsModule:inspector_style_rollout_noheader_image";
category = "Editor"; category = "Editor";
}; };
singleton GuiControlProfile (IconDropdownProfile) singleton GuiControlProfile (IconDropdownProfile)
@ -1502,7 +1502,6 @@ singleton GuiControlProfile (IconDropdownProfile)
opaque = true; opaque = true;
border = true; border = true;
category = "Editor"; category = "Editor";
//bitmap = "./icon-dropdownbar";
fillColor = EditorSettings.value("Theme/headerColor"); fillColor = EditorSettings.value("Theme/headerColor");
}; };

View file

@ -338,9 +338,9 @@ function RiverEditorGui::createRiver( %this )
baseColor = "45 108 171 255"; baseColor = "45 108 171 255";
rippleTex = "Core_Rendering:ripple_image"; RippleTexAsset = "Core_Rendering:ripple_image";
foamTex = "Core_Rendering:foam_image"; FoamTexAsset = "Core_Rendering:foam_image";
depthGradientTex = "Core_Rendering:depthcolor_ramp_image"; DepthGradientTexAsset = "Core_Rendering:depthcolor_ramp_image";
}; };
return %river; return %river;

View file

@ -1534,7 +1534,7 @@ $guiContent = new GuiContainer(EditorGui,EditorGuiGroup) {
internalName = "slider"; internalName = "slider";
position = "9 17"; position = "9 17";
extent = "129 15"; extent = "129 15";
bitmap = "tools/gui/images/separator-h.png"; bitmapAsset = "ToolsModule:separator_h_image";
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "bottom"; VertSizing = "bottom";
range = "1 200"; range = "1 200";

View file

@ -1282,9 +1282,9 @@ function ObjectBuilderGui::addWaterObjectFields(%this)
%this.addField("waveSpeed[2]", "TypeFloat", "Wave Speed", "1"); %this.addField("waveSpeed[2]", "TypeFloat", "Wave Speed", "1");
%this.addField("overallWaveMagnitude", "TypeFloat", "Overall Wave Magnitude", "1.0"); %this.addField("overallWaveMagnitude", "TypeFloat", "Overall Wave Magnitude", "1.0");
%this.addField("rippleTex", "TypeImageAsset", "Ripple Texture", "Core_Rendering:ripple_image" ); %this.addField("RippleTexAsset", "TypeImageAssetPtrRefactor", "Ripple Texture", "Core_Rendering:ripple_image" );
%this.addField("depthGradientTex", "TypeImageAsset", "Depth Gradient Texture", "Core_Rendering:depthcolor_ramp_image" ); %this.addField("DepthGradientTexAsset", "TypeImageAssetPtrRefactor", "Depth Gradient Texture", "Core_Rendering:depthcolor_ramp_image" );
%this.addField("foamTex", "TypeImageAsset", "Foam Texture", "Core_Rendering:foam_image" ); %this.addField("FoamTexAsset", "TypeImageAssetPtrRefactor", "Foam Texture", "Core_Rendering:foam_image" );
} }
function ObjectBuilderGui::buildWaterBlock(%this) function ObjectBuilderGui::buildWaterBlock(%this)