diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index a13d8c422..a0055df9b 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -181,6 +181,17 @@ const String ImageAsset::mErrCodeStrings[] = "UnKnown" }; //----------------------------------------------------------------------------- + +ImageAsset::ImageAsset() : + mImageFile(StringTable->EmptyString()), + mUseMips(true), + mIsHDRImage(false), + mImageType(Albedo), + mTextureHandle(NULL) +{ + mLoadedState = AssetErrCode::NotLoaded; +} + //----------------------------------------------------------------------------- ImageAsset::~ImageAsset() @@ -618,7 +629,7 @@ void GuiInspectorTypeImageAssetPtr::consoleInit() { Parent::consoleInit(); - ConsoleBaseType::getType(TypeImageAssetPtr)->setInspectorFieldType("GuiInspectorTypeImageAssetPtr"); + ConsoleBaseType::getType(TypeImageAssetPtrRefactor)->setInspectorFieldType("GuiInspectorTypeImageAssetPtr"); } GuiControl* GuiInspectorTypeImageAssetPtr::constructEditControl() diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index 75ea87803..b41b4469c 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -592,7 +592,26 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\ private: \ AssetPtr m##name##Asset; \ public: \ - void _set##name(StringTableEntry _in); \ + 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; \ + } \ + }; \ 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 get##name##Asset(void) { return m##name##Asset; } \ diff --git a/Engine/source/environment/cloudLayer.cpp b/Engine/source/environment/cloudLayer.cpp index d6de0c055..ebc503a8c 100644 --- a/Engine/source/environment/cloudLayer.cpp +++ b/Engine/source/environment/cloudLayer.cpp @@ -112,8 +112,6 @@ CloudLayer::CloudLayer() mTexOffset[0] = mTexOffset[1] = mTexOffset[2] = Point2F::Zero; mHeight = 4.0f; - - INIT_ASSET(Texture); } IMPLEMENT_CO_NETOBJECT_V1( CloudLayer ); @@ -131,8 +129,6 @@ bool CloudLayer::onAdd() addToScene(); - LOAD_IMAGEASSET(Texture); - if ( isClientObject() ) { _initBuffers(); @@ -194,8 +190,8 @@ void CloudLayer::initPersistFields() docsURL; addGroup( "CloudLayer" ); - INITPERSISTFIELD_IMAGEASSET(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density)."); - + INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).") + addArray( "Textures", TEX_COUNT ); addField( "texScale", TypeF32, Offset( mTexScale, CloudLayer ), TEX_COUNT, @@ -243,7 +239,9 @@ U32 CloudLayer::packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) { U32 retMask = Parent::packUpdate( conn, mask, stream ); - PACK_ASSET(conn, Texture); + if (stream->writeFlag(mTextureAsset.notNull())) { + NetStringHandle assetIdStr = mTextureAsset.getAssetId(); conn->packNetStringHandleU(stream, assetIdStr); + } for ( U32 i = 0; i < TEX_COUNT; i++ ) { @@ -265,10 +263,9 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream ) { Parent::unpackUpdate( conn, stream ); - UNPACK_ASSET(conn, Texture); - - if(mTextureAssetId != StringTable->EmptyString()) - mTextureAsset = mTextureAssetId; + if (stream->readFlag()) { + mTextureAsset.setAssetId(_getStringTable()->insert(conn->unpackNetStringHandleU(stream).getString())); + } for ( U32 i = 0; i < TEX_COUNT; i++ ) { @@ -334,7 +331,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba { GFXTransformSaver saver; - if (!mTextureAsset || !mTextureAsset->isAssetValid()) + if (!mTextureAsset) return; const Point3F &camPos = state->getCameraPosition(); @@ -385,7 +382,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba mShaderConsts->setSafe( mExposureSC, mExposure ); - GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), getTextureResource()); + GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTextureAsset->getTexture(&GFXStaticTextureSRGBProfile)); GFX->setVertexBuffer( mVB ); GFX->setPrimitiveBuffer( mPB ); diff --git a/Engine/source/environment/cloudLayer.h b/Engine/source/environment/cloudLayer.h index ba8110c39..675b3b78b 100644 --- a/Engine/source/environment/cloudLayer.h +++ b/Engine/source/environment/cloudLayer.h @@ -61,7 +61,6 @@ class CloudLayer : public SceneObject }; #define TEX_COUNT 3 - public: CloudLayer(); @@ -97,8 +96,9 @@ protected: static U32 smVertCount; static U32 smTriangleCount; - DECLARE_IMAGEASSET(CloudLayer, Texture, onImageChanged, GFXStaticTextureSRGBProfile); - DECLARE_ASSET_NET_SETGET(CloudLayer, Texture, CloudLayerMask); +public: + + DECLARE_IMAGEASSET_REFACTOR(CloudLayer,Texture, GFXStaticTextureSRGBProfile) GFXShaderRef mShader;