瀏覽代碼

Merge pull request #658 from Azaezel/alpha40/imageArrayProfileFixes

imageasset array profile fixes
Brian Roberts 4 年之前
父節點
當前提交
2bb4d34efd

+ 12 - 3
Engine/source/T3D/assets/ImageAsset.h

@@ -304,13 +304,13 @@ if (m##name##AssetId != StringTable->EmptyString())\
 #pragma region Arrayed Asset Macros
 #pragma region Arrayed Asset Macros
 
 
 //Arrayed Assets
 //Arrayed Assets
-#define DECLARE_IMAGEASSET_ARRAY(className, name, profile, max) public: \
+#define DECLARE_IMAGEASSET_ARRAY(className, name, max) public: \
    static const U32 sm##name##Count = max;\
    static const U32 sm##name##Count = max;\
    GFXTexHandle m##name[max];\
    GFXTexHandle m##name[max];\
    StringTableEntry m##name##Name[max]; \
    StringTableEntry m##name##Name[max]; \
    StringTableEntry m##name##AssetId[max];\
    StringTableEntry m##name##AssetId[max];\
    AssetPtr<ImageAsset>  m##name##Asset[max];\
    AssetPtr<ImageAsset>  m##name##Asset[max];\
-   GFXTextureProfile * m##name##Profile = &profile;\
+   GFXTextureProfile * m##name##Profile[max];\
 public: \
 public: \
    const StringTableEntry get##name##File(const U32& index) const { return m##name##Name[index]; }\
    const StringTableEntry get##name##File(const U32& index) const { return m##name##Name[index]; }\
    void set##name##File(const FileName &_in, const U32& index) { m##name##Name[index] = StringTable->insert(_in.c_str());}\
    void set##name##File(const FileName &_in, const U32& index) { m##name##Name[index] = StringTable->insert(_in.c_str());}\
@@ -374,7 +374,7 @@ public: \
       }\
       }\
       if (get##name(index) != StringTable->EmptyString() && m##name##Name[index] != StringTable->insert("texhandle"))\
       if (get##name(index) != StringTable->EmptyString() && m##name##Name[index] != StringTable->insert("texhandle"))\
       {\
       {\
-         m##name[index].set(get##name(index), m##name##Profile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));\
+         m##name[index].set(get##name(index), m##name##Profile[index], avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));\
       }\
       }\
       else\
       else\
       {\
       {\
@@ -445,6 +445,15 @@ public: \
       return ret;\
       return ret;\
    }
    }
 
 
+#define INIT_IMAGEASSET_ARRAY(name, profile, index) \
+{\
+   m##name##Name[index] = StringTable->EmptyString(); \
+   m##name##AssetId[index] = StringTable->EmptyString(); \
+   m##name##Asset[index] = NULL;\
+   m##name[index] = NULL;\
+   m##name##Profile[index] = &profile;\
+}
+
 #define DEF_IMAGEASSET_ARRAY_BINDS(className,name)\
 #define DEF_IMAGEASSET_ARRAY_BINDS(className,name)\
 DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\
 DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\
 {\
 {\

+ 1 - 1
Engine/source/T3D/fx/splash.cpp

@@ -98,7 +98,7 @@ SplashData::SplashData()
    U32 i;
    U32 i;
    for (i = 0; i < NUM_TEX; i++)
    for (i = 0; i < NUM_TEX; i++)
    {
    {
-      INIT_ASSET_ARRAY(Texture, i);
+      INIT_IMAGEASSET_ARRAY(Texture, GFXStaticTextureSRGBProfile, i);
    }
    }
 
 
    for( i=0; i<NUM_TIME_KEYS; i++ )
    for( i=0; i<NUM_TIME_KEYS; i++ )

+ 1 - 1
Engine/source/T3D/fx/splash.h

@@ -122,7 +122,7 @@ public:
    F32               times[ NUM_TIME_KEYS ];
    F32               times[ NUM_TIME_KEYS ];
    LinearColorF            colors[ NUM_TIME_KEYS ];
    LinearColorF            colors[ NUM_TIME_KEYS ];
 
 
-   DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, GFXStaticTextureSRGBProfile, NUM_TEX);
+   DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, NUM_TEX);
    DECLARE_IMAGEASSET_ARRAY_SETGET(SplashData, Texture)
    DECLARE_IMAGEASSET_ARRAY_SETGET(SplashData, Texture)
 
 
    ExplosionData*    explosion;
    ExplosionData*    explosion;

+ 3 - 0
Engine/source/environment/basicClouds.cpp

@@ -98,6 +98,9 @@ BasicClouds::BasicClouds()
    mTexOffset[0].set( 0.5f, 0.5f );
    mTexOffset[0].set( 0.5f, 0.5f );
    mTexOffset[1].set( 0.5f, 0.5f );
    mTexOffset[1].set( 0.5f, 0.5f );
    mTexOffset[2].set( 0.5f, 0.5f );
    mTexOffset[2].set( 0.5f, 0.5f );
+
+   for (U32 i=0; i< TEX_COUNT;i++)
+      INIT_IMAGEASSET_ARRAY(Texture, GFXStaticTextureSRGBProfile, i);
 }
 }
 
 
 IMPLEMENT_CO_NETOBJECT_V1( BasicClouds );
 IMPLEMENT_CO_NETOBJECT_V1( BasicClouds );

+ 2 - 2
Engine/source/environment/basicClouds.h

@@ -93,7 +93,7 @@ protected:
    static U32 smVertCount;
    static U32 smVertCount;
    static U32 smTriangleCount;
    static U32 smTriangleCount;
 
 
-   DECLARE_IMAGEASSET_ARRAY(BasicClouds, Texture, GFXStaticTextureSRGBProfile, TEX_COUNT);
+   DECLARE_IMAGEASSET_ARRAY(BasicClouds, Texture, TEX_COUNT);
    DECLARE_IMAGEASSET_ARRAY_NET_SETGET(BasicClouds, Texture, -1);
    DECLARE_IMAGEASSET_ARRAY_NET_SETGET(BasicClouds, Texture, -1);
 
 
    GFXStateBlockRef mStateblock;
    GFXStateBlockRef mStateblock;
@@ -122,4 +122,4 @@ protected:
 };
 };
 
 
 
 
-#endif // _BASICCLOUDS_H_
+#endif // _BASICCLOUDS_H_

+ 1 - 1
Engine/source/gfx/sim/cubemapData.cpp

@@ -44,7 +44,7 @@ CubemapData::CubemapData()
 
 
    for (U32 i = 0; i < 6; i++)
    for (U32 i = 0; i < 6; i++)
    {
    {
-      INIT_ASSET_ARRAY(CubeMapFace, i);
+      INIT_IMAGEASSET_ARRAY(CubeMapFace, GFXStaticTextureSRGBProfile, i);
    }
    }
 
 
    INIT_ASSET(CubeMap);
    INIT_ASSET(CubeMap);

+ 1 - 1
Engine/source/gfx/sim/cubemapData.h

@@ -76,7 +76,7 @@ protected:
    DECLARE_IMAGEASSET(CubemapData, CubeMap, onCubemapChanged, GFXStaticTextureSRGBProfile);
    DECLARE_IMAGEASSET(CubemapData, CubeMap, onCubemapChanged, GFXStaticTextureSRGBProfile);
    DECLARE_ASSET_SETGET(CubemapData, CubeMap);
    DECLARE_ASSET_SETGET(CubemapData, CubeMap);
 
 
-   DECLARE_IMAGEASSET_ARRAY(CubemapData, CubeMapFace, GFXStaticTextureSRGBProfile, 6);
+   DECLARE_IMAGEASSET_ARRAY(CubemapData, CubeMapFace, 6);
    DECLARE_IMAGEASSET_ARRAY_SETGET(CubemapData, CubeMapFace);
    DECLARE_IMAGEASSET_ARRAY_SETGET(CubemapData, CubeMapFace);
 
 
    GFXTexHandle mDepthBuff;
    GFXTexHandle mDepthBuff;

+ 2 - 2
Engine/source/gui/controls/guiPopUpCtrl.cpp

@@ -278,8 +278,8 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void)
    mBackgroundCancel = false; //  Added
    mBackgroundCancel = false; //  Added
    mReverseTextList = false; //  Added - Don't reverse text list if displaying up
    mReverseTextList = false; //  Added - Don't reverse text list if displaying up
 
 
-   INIT_ASSET_ARRAY(Bitmap, 0);
-   INIT_ASSET_ARRAY(Bitmap, 1);
+   INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, 0);
+   INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, 1);
 
 
    mBitmapBounds.set(16, 16); //  Added
    mBitmapBounds.set(16, 16); //  Added
    mIdMax = -1;
    mIdMax = -1;

+ 1 - 1
Engine/source/gui/controls/guiPopUpCtrl.h

@@ -126,7 +126,7 @@ protected:
       NumBitmapModes = 2
       NumBitmapModes = 2
    };
    };
 
 
-   DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes);
+   DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, NumBitmapModes);
    DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrl, Bitmap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrl, Bitmap);
 
 
    Point2I mBitmapBounds; //  Added
    Point2I mBitmapBounds; //  Added

+ 2 - 2
Engine/source/gui/controls/guiPopUpCtrlEx.cpp

@@ -329,8 +329,8 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void)
    mBackgroundCancel = false; //  Added
    mBackgroundCancel = false; //  Added
    mReverseTextList = false; //  Added - Don't reverse text list if displaying up
    mReverseTextList = false; //  Added - Don't reverse text list if displaying up
 
 
-   INIT_ASSET_ARRAY(Bitmap, Normal);
-   INIT_ASSET_ARRAY(Bitmap, Depressed);
+   INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, Normal);
+   INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, Depressed);
 
 
    mBitmapBounds.set(16, 16); //  Added
    mBitmapBounds.set(16, 16); //  Added
    mHotTrackItems = false;
    mHotTrackItems = false;

+ 1 - 1
Engine/source/gui/controls/guiPopUpCtrlEx.h

@@ -127,7 +127,7 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
       NumBitmapModes = 2
       NumBitmapModes = 2
    };
    };
 
 
-   DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, GFXDefaultGUIProfile, NumBitmapModes);
+   DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, NumBitmapModes);
    DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrlEx, Bitmap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrlEx, Bitmap);
 
 
    Point2I mBitmapBounds; //  Added
    Point2I mBitmapBounds; //  Added

+ 12 - 12
Engine/source/materials/materialDefinition.cpp

@@ -142,18 +142,18 @@ Material::Material()
       mAccuCoverage[i] = 0.9f;
       mAccuCoverage[i] = 0.9f;
       mAccuSpecular[i] = 16.0f;
       mAccuSpecular[i] = 16.0f;
 
 
-      INIT_ASSET_ARRAY(DiffuseMap, i);
-      INIT_ASSET_ARRAY(OverlayMap, i);
-      INIT_ASSET_ARRAY(LightMap, i);
-      INIT_ASSET_ARRAY(ToneMap, i);
-      INIT_ASSET_ARRAY(DetailMap, i);
-      INIT_ASSET_ARRAY(NormalMap, i);
-      INIT_ASSET_ARRAY(ORMConfigMap, i);
-      INIT_ASSET_ARRAY(RoughMap, i);
-      INIT_ASSET_ARRAY(AOMap, i);
-      INIT_ASSET_ARRAY(MetalMap, i);
-      INIT_ASSET_ARRAY(GlowMap, i);
-      INIT_ASSET_ARRAY(DetailNormalMap, i);
+      INIT_IMAGEASSET_ARRAY(DiffuseMap, GFXStaticTextureSRGBProfile, i);
+      INIT_IMAGEASSET_ARRAY(OverlayMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(LightMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(ToneMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(DetailMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(NormalMap, GFXNormalMapProfile, i);
+      INIT_IMAGEASSET_ARRAY(ORMConfigMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(RoughMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(AOMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(MetalMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(GlowMap, GFXStaticTextureProfile, i);
+      INIT_IMAGEASSET_ARRAY(DetailNormalMap, GFXNormalMapProfile, i);
 
 
       mParallaxScale[i] = 0.0f;
       mParallaxScale[i] = 0.0f;
 
 

+ 12 - 12
Engine/source/materials/materialDefinition.h

@@ -207,49 +207,49 @@ public:
    //-----------------------------------------------------------------------
    //-----------------------------------------------------------------------
    // Data
    // Data
    //-----------------------------------------------------------------------
    //-----------------------------------------------------------------------
-   DECLARE_IMAGEASSET_ARRAY(Material, DiffuseMap, GFXStaticTextureSRGBProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, DiffuseMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DiffuseMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DiffuseMap);
 
 
    bool     mDiffuseMapSRGB[MAX_STAGES];   // SRGB diffuse
    bool     mDiffuseMapSRGB[MAX_STAGES];   // SRGB diffuse
-   DECLARE_IMAGEASSET_ARRAY(Material, OverlayMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, OverlayMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, OverlayMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, OverlayMap);
 
 
-   DECLARE_IMAGEASSET_ARRAY(Material, LightMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, LightMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, LightMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, LightMap);
 
 
-   DECLARE_IMAGEASSET_ARRAY(Material, ToneMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, ToneMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ToneMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ToneMap);
 
 
-   DECLARE_IMAGEASSET_ARRAY(Material, DetailMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, DetailMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailMap);
 
 
-   DECLARE_IMAGEASSET_ARRAY(Material, NormalMap, GFXNormalMapProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, NormalMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, NormalMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, NormalMap);
 
 
-   DECLARE_IMAGEASSET_ARRAY(Material, ORMConfigMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, ORMConfigMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ORMConfigMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ORMConfigMap);
 
 
    bool     mIsSRGb[MAX_STAGES];
    bool     mIsSRGb[MAX_STAGES];
-   DECLARE_IMAGEASSET_ARRAY(Material, RoughMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, RoughMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, RoughMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, RoughMap);
 
 
    bool     mInvertRoughness[MAX_STAGES];
    bool     mInvertRoughness[MAX_STAGES];
    F32      mRoughnessChan[MAX_STAGES];
    F32      mRoughnessChan[MAX_STAGES];
-   DECLARE_IMAGEASSET_ARRAY(Material, AOMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, AOMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, AOMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, AOMap);
 
 
    F32      mAOChan[MAX_STAGES];
    F32      mAOChan[MAX_STAGES];
-   DECLARE_IMAGEASSET_ARRAY(Material, MetalMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, MetalMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, MetalMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, MetalMap);
 
 
    F32      mMetalChan[MAX_STAGES];
    F32      mMetalChan[MAX_STAGES];
-   DECLARE_IMAGEASSET_ARRAY(Material, GlowMap, GFXStaticTextureProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, GlowMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, GlowMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, GlowMap);
 
 
    F32      mGlowMul[MAX_STAGES];
    F32      mGlowMul[MAX_STAGES];
    /// A second normal map which repeats at the detail map
    /// A second normal map which repeats at the detail map
    /// scale and blended with the base normal map.
    /// scale and blended with the base normal map.
-   DECLARE_IMAGEASSET_ARRAY(Material, DetailNormalMap, GFXNormalMapProfile, MAX_STAGES);
+   DECLARE_IMAGEASSET_ARRAY(Material, DetailNormalMap, MAX_STAGES);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailNormalMap);
    DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailNormalMap);
 
 
    /// The strength scalar for the detail normal map.
    /// The strength scalar for the detail normal map.

+ 14 - 8
Engine/source/postFx/postEffect.cpp

@@ -508,7 +508,7 @@ PostEffect::PostEffect()
 
 
    for (U32 i = 0; i < NumTextures; i++)
    for (U32 i = 0; i < NumTextures; i++)
    {
    {
-      INIT_ASSET_ARRAY(Texture, i);
+      INIT_IMAGEASSET_ARRAY(Texture, PostFxTextureProfile, i);
    }
    }
 }
 }
 
 
@@ -602,9 +602,19 @@ bool PostEffect::onAdd()
    scriptPath.setExtension( String::EmptyString );
    scriptPath.setExtension( String::EmptyString );
 
 
    // Find additional textures
    // Find additional textures
-   for( S32 i = 0; i < NumTextures; i++ )
+   for (S32 i = 0; i < NumTextures; i++)
    {
    {
       mTextureType[i] = NormalTextureType;
       mTextureType[i] = NormalTextureType;
+      String texFilename = getTexture(i);
+
+      // Skip empty stages or ones with variable or target names.
+      if (texFilename.isEmpty() ||
+         texFilename[0] == '$' ||
+         texFilename[0] == '#')
+         continue;
+
+      mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
+      _setTexture(texFilename, i);
    }
    }
 
 
    // Is the target a named target?
    // Is the target a named target?
@@ -1625,12 +1635,8 @@ void PostEffect::setTexture( U32 index, const String &texFilePath )
 			texFilePath[0] == '#' )
 			texFilePath[0] == '#' )
 		return;
 		return;
 
 
-    GFXTextureProfile* profile = &PostFxTextureProfile;
-    if (mTexSRGB[index])
-       profile = &PostFxTextureSRGBProfile;
-
-    // Try to load the texture.
-    mTexture[index].set( texFilePath, profile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) );
+    mTextureProfile[index] = (mTexSRGB[index])? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
+    _setTexture(texFilePath, index);
 
 
     mTextureType[index] = NormalTextureType;
     mTextureType[index] = NormalTextureType;
 }
 }

+ 1 - 1
Engine/source/postFx/postEffect.h

@@ -90,7 +90,7 @@ public:
 
 
 protected:
 protected:
 
 
-   DECLARE_IMAGEASSET_ARRAY(PostEffect, Texture, PostFxTextureProfile, NumTextures);
+   DECLARE_IMAGEASSET_ARRAY(PostEffect, Texture, NumTextures);
    DECLARE_IMAGEASSET_ARRAY_SETGET(PostEffect, Texture);
    DECLARE_IMAGEASSET_ARRAY_SETGET(PostEffect, Texture);
 
 
    bool mTexSRGB[NumTextures];
    bool mTexSRGB[NumTextures];