mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
all DECLARE_IMAGEASSET refactored
This commit is contained in:
parent
24b374f545
commit
fa8110ce8f
44 changed files with 248 additions and 306 deletions
|
|
@ -105,7 +105,6 @@ VolumetricFog::VolumetricFog()
|
|||
mFrontBufferTarget = NULL;
|
||||
|
||||
z_buf = NULL;
|
||||
mTexture = NULL;
|
||||
|
||||
mIsVBDirty = false;
|
||||
mIsPBDirty = false;
|
||||
|
|
@ -138,7 +137,6 @@ VolumetricFog::VolumetricFog()
|
|||
mSpeed2.set(0.1f, 0.1f);
|
||||
|
||||
INIT_ASSET(Shape);
|
||||
INIT_ASSET(Texture);
|
||||
}
|
||||
|
||||
VolumetricFog::~VolumetricFog()
|
||||
|
|
@ -159,8 +157,6 @@ VolumetricFog::~VolumetricFog()
|
|||
|
||||
z_buf = NULL;
|
||||
|
||||
if (!mTexture.isNull())
|
||||
mTexture.free();
|
||||
}
|
||||
|
||||
void VolumetricFog::initPersistFields()
|
||||
|
|
@ -185,7 +181,7 @@ void VolumetricFog::initPersistFields()
|
|||
endGroup("VolumetricFogData");
|
||||
|
||||
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),
|
||||
"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 height = (F32)mPlatformWindow->getClientExtent().y;
|
||||
|
||||
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width);
|
||||
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height);
|
||||
// load texture.
|
||||
getTexture();
|
||||
mTexScale.x = 2.0f - ((F32)mTextureAsset->getTextureWidth() / width);
|
||||
mTexScale.y = 2.0f - ((F32)mTextureAsset->getTextureHeight() / height);
|
||||
}
|
||||
|
||||
UpdateBuffers(0,true);
|
||||
|
|
@ -545,7 +543,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
stream->write(mFogDensity);
|
||||
if (stream->writeFlag(mask & FogModulationMask))
|
||||
{
|
||||
PACK_ASSET(con, Texture);
|
||||
PACK_ASSET_REFACTOR(con, Texture);
|
||||
mTexTiles = mFabs(mTexTiles);
|
||||
stream->write(mTexTiles);
|
||||
stream->write(mStrength);
|
||||
|
|
@ -597,7 +595,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
MatrixF mat;
|
||||
VectorF scale;
|
||||
VectorF mOldScale = getScale();
|
||||
StringTableEntry oldTextureName = mTextureAssetId;
|
||||
StringTableEntry oldTextureName = mTextureAsset.getAssetId();
|
||||
StringTableEntry oldShapeAsset = mShapeAssetId;
|
||||
StringTableEntry oldShape = mShapeName;
|
||||
|
||||
|
|
@ -615,7 +613,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
}
|
||||
if (stream->readFlag())// Fog Modulation
|
||||
{
|
||||
UNPACK_ASSET(con, Texture);
|
||||
UNPACK_ASSET_REFACTOR(con, Texture);
|
||||
stream->read(&mTexTiles);
|
||||
mTexTiles = mFabs(mTexTiles);
|
||||
stream->read(&mStrength);
|
||||
|
|
@ -625,12 +623,11 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
|
||||
if (isProperlyAdded())
|
||||
{
|
||||
if (oldTextureName != mTextureAssetId)
|
||||
if (oldTextureName != mTextureAsset.getAssetId())
|
||||
InitTexture();
|
||||
if (oldTextureName != StringTable->EmptyString() && mTextureAssetId == StringTable->EmptyString())
|
||||
if (oldTextureName != StringTable->EmptyString() && mTextureAsset.isNull())
|
||||
{
|
||||
mIsTextured = false;
|
||||
mTexture.free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1149,7 +1146,7 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
|||
|
||||
if (mIsTextured && mStrength > 0.0f)
|
||||
{
|
||||
GFX->setTexture(3, mTexture);
|
||||
GFX->setTexture(3, getTexture());
|
||||
mShaderConsts->setSafe(mIsTexturedSC, 1.0f);
|
||||
}
|
||||
else
|
||||
|
|
@ -1222,15 +1219,16 @@ void VolumetricFog::InitTexture()
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!mTexture.isNull())
|
||||
if (!mTextureAsset.isNull())
|
||||
{
|
||||
mIsTextured = true;
|
||||
|
||||
// load asset.
|
||||
getTexture();
|
||||
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
||||
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
||||
|
||||
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width);
|
||||
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height);
|
||||
mTexScale.x = 2.0f - ((F32)mTextureAsset->getTextureWidth() / width);
|
||||
mTexScale.y = 2.0f - ((F32)mTextureAsset->getTextureHeight() / height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,8 +162,7 @@ class VolumetricFog : public SceneObject
|
|||
F32 mInvScale;
|
||||
|
||||
// Fog Modulation data
|
||||
DECLARE_IMAGEASSET(VolumetricFog, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_ASSET_NET_SETGET(VolumetricFog, Texture, FogModulationMask);
|
||||
DECLARE_IMAGEASSET_NET_REFACTOR(VolumetricFog, Texture, GFXStaticTextureSRGBProfile, FogModulationMask)
|
||||
|
||||
bool mIsTextured;
|
||||
F32 mTexTiles;
|
||||
|
|
@ -221,8 +220,6 @@ class VolumetricFog : public SceneObject
|
|||
|
||||
static bool _setShapeAsset(void* obj, const char* index, const char* data);
|
||||
|
||||
void onImageChanged() {}
|
||||
|
||||
public:
|
||||
// Public methods
|
||||
VolumetricFog();
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(CloudLayer,Texture, GFXStaticTextureSRGBProfile)
|
||||
DECLARE_IMAGEASSET_NET_REFACTOR(CloudLayer,Texture, GFXStaticTextureSRGBProfile, CloudLayerMask)
|
||||
|
||||
GFXShaderRef mShader;
|
||||
|
||||
|
|
|
|||
|
|
@ -260,10 +260,6 @@ WaterObject::WaterObject()
|
|||
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
|
||||
constructInPlace(mMatrixSet);
|
||||
|
||||
INIT_ASSET(RippleTex);
|
||||
INIT_ASSET(FoamTex);
|
||||
INIT_ASSET(DepthGradientTex);
|
||||
|
||||
mCubemapName = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +296,7 @@ void WaterObject::initPersistFields()
|
|||
addField( "overallWaveMagnitude", TypeF32, Offset( mOverallWaveMagnitude, WaterObject ), "Master variable affecting entire body"
|
||||
" 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 );
|
||||
|
||||
|
|
@ -314,7 +310,7 @@ void WaterObject::initPersistFields()
|
|||
|
||||
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 );
|
||||
|
||||
|
|
@ -366,7 +362,7 @@ void WaterObject::initPersistFields()
|
|||
|
||||
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." );
|
||||
|
||||
|
|
@ -547,9 +543,9 @@ U32 WaterObject::packUpdate( NetConnection * conn, U32 mask, BitStream *stream )
|
|||
|
||||
if ( stream->writeFlag( mask & TextureMask ) )
|
||||
{
|
||||
PACK_ASSET(conn, RippleTex);
|
||||
PACK_ASSET(conn, DepthGradientTex);
|
||||
PACK_ASSET(conn, FoamTex);
|
||||
PACK_ASSET_REFACTOR(conn, RippleTex);
|
||||
PACK_ASSET_REFACTOR(conn, DepthGradientTex);
|
||||
PACK_ASSET_REFACTOR(conn, FoamTex);
|
||||
|
||||
stream->writeString( mCubemapName );
|
||||
}
|
||||
|
|
@ -669,9 +665,9 @@ void WaterObject::unpackUpdate( NetConnection * conn, BitStream *stream )
|
|||
// TextureMask
|
||||
if ( stream->readFlag() )
|
||||
{
|
||||
UNPACK_ASSET(conn, RippleTex);
|
||||
UNPACK_ASSET(conn, DepthGradientTex);
|
||||
UNPACK_ASSET(conn, FoamTex);
|
||||
UNPACK_ASSET_REFACTOR(conn, RippleTex);
|
||||
UNPACK_ASSET_REFACTOR(conn, DepthGradientTex);
|
||||
UNPACK_ASSET_REFACTOR(conn, FoamTex);
|
||||
|
||||
mCubemapName = stream->readSTString();
|
||||
|
||||
|
|
@ -767,13 +763,13 @@ void WaterObject::renderObject( ObjectRenderInst *ri, SceneRenderState *state, B
|
|||
void WaterObject::setCustomTextures( S32 matIdx, U32 pass, const WaterMatParams ¶mHandles )
|
||||
{
|
||||
// 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.
|
||||
if ( matIdx == WaterMat )
|
||||
{
|
||||
GFX->setTexture( paramHandles.mFoamSamplerSC->getSamplerRegister(pass), mFoamTex );
|
||||
GFX->setTexture( paramHandles.mDepthGradSamplerSC->getSamplerRegister(pass), mDepthGradientTex );
|
||||
GFX->setTexture( paramHandles.mFoamSamplerSC->getSamplerRegister(pass), getFoamTex() );
|
||||
GFX->setTexture( paramHandles.mDepthGradSamplerSC->getSamplerRegister(pass), getDepthGradientTex() );
|
||||
}
|
||||
|
||||
if ( ( matIdx == WaterMat || matIdx == BasicWaterMat ) && mCubemap )
|
||||
|
|
@ -1118,7 +1114,7 @@ void WaterObject::updateUnderwaterEffect( SceneRenderState *state )
|
|||
// be fetched by the effect when it renders.
|
||||
if ( !mNamedDepthGradTex.isRegistered() )
|
||||
mNamedDepthGradTex.registerWithName( "waterDepthGradMap" );
|
||||
mNamedDepthGradTex.setTexture( mDepthGradientTex );
|
||||
mNamedDepthGradTex.setTexture( getDepthGradientTex() );
|
||||
}
|
||||
else
|
||||
effect->disable();
|
||||
|
|
@ -1172,7 +1168,7 @@ bool WaterObject::initMaterial( S32 idx )
|
|||
void WaterObject::initTextures()
|
||||
{
|
||||
if ( mNamedDepthGradTex.isRegistered() )
|
||||
mNamedDepthGradTex.setTexture( mDepthGradientTex );
|
||||
mNamedDepthGradTex.setTexture( getDepthGradientTex() );
|
||||
|
||||
if ( mCubemapName != StringTable->EmptyString() )
|
||||
Sim::findObject( mCubemapName, mCubemap );
|
||||
|
|
|
|||
|
|
@ -203,10 +203,6 @@ protected:
|
|||
/// Callback used internally when smEnableTrueReflections changes.
|
||||
void _onEnableTrueReflections();
|
||||
|
||||
void onRippleTexChanged() {}
|
||||
void onFoamTexChanged() {}
|
||||
void onDepthGradientTexChanged() {}
|
||||
|
||||
protected:
|
||||
|
||||
static bool _setFullReflect( void *object, const char *index, const char *data );
|
||||
|
|
@ -273,12 +269,9 @@ protected:
|
|||
F32 mDepthGradientMax;
|
||||
|
||||
// Other textures
|
||||
DECLARE_IMAGEASSET(WaterObject, RippleTex, onRippleTexChanged, GFXStaticTextureProfile);
|
||||
DECLARE_ASSET_NET_SETGET(WaterObject, RippleTex, TextureMask);
|
||||
DECLARE_IMAGEASSET(WaterObject, FoamTex, onFoamTexChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_ASSET_NET_SETGET(WaterObject, FoamTex, TextureMask);
|
||||
DECLARE_IMAGEASSET(WaterObject, DepthGradientTex, onDepthGradientTexChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_ASSET_NET_SETGET(WaterObject, DepthGradientTex, TextureMask);
|
||||
DECLARE_IMAGEASSET_NET_REFACTOR(WaterObject, RippleTex, GFXStaticTextureProfile, TextureMask)
|
||||
DECLARE_IMAGEASSET_NET_REFACTOR(WaterObject, FoamTex, GFXStaticTextureSRGBProfile, TextureMask)
|
||||
DECLARE_IMAGEASSET_NET_REFACTOR(WaterObject, DepthGradientTex, GFXStaticTextureSRGBProfile, TextureMask)
|
||||
|
||||
StringTableEntry mCubemapName;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue