Torque3D/Engine/source/T3D/assets/ImageAsset.cpp

764 lines
23 KiB
C++
Raw Normal View History

//-----------------------------------------------------------------------------
// Copyright (c) 2013 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef IMAGE_ASSET_H
#include "ImageAsset.h"
#endif
#ifndef _ASSET_MANAGER_H_
#include "assets/assetManager.h"
#endif
#ifndef _CONSOLETYPES_H_
#include "console/consoleTypes.h"
#endif
#ifndef _TAML_
#include "persistence/taml/taml.h"
#endif
#ifndef _ASSET_PTR_H_
#include "assets/assetPtr.h"
#endif
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
#include "gfx/gfxStringEnumTranslate.h"
#include "ImageAssetInspectors.h"
// Debug Profiling.
#include "platform/profiler.h"
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
#include "T3D/assets/assetImporter.h"
#include "gfx/gfxDrawUtil.h"
//-----------------------------------------------------------------------------
StringTableEntry ImageAsset::smNoImageAssetFallback = NULL;
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(ImageAsset);
ConsoleType(ImageAssetPtr, TypeImageAssetPtr, const char*, "")
//-----------------------------------------------------------------------------
ConsoleGetType(TypeImageAssetPtr)
{
// Fetch asset Id.
return *((const char**)(dptr));
}
//-----------------------------------------------------------------------------
ConsoleSetType(TypeImageAssetPtr)
{
// Was a single argument specified?
if (argc == 1)
{
// Yes, so fetch field value.
*((const char**)dptr) = StringTable->insert(argv[0]);
return;
}
// Warn.
Con::warnf("(TypeImageAssetPtr) - Cannot set multiple args to a single asset.");
}
ConsoleType(assetIdString, TypeImageAssetId, const char*, "")
ConsoleGetType(TypeImageAssetId)
{
// Fetch asset Id.
return *((const char**)(dptr));
}
ConsoleSetType(TypeImageAssetId)
{
// Was a single argument specified?
if (argc == 1)
{
*((const char**)dptr) = StringTable->insert(argv[0]);
return;
}
// Warn.
Con::warnf("(TypeImageAssetId) - Cannot set multiple args to a single asset.");
}
//-----------------------------------------------------------------------------
ImplementEnumType(ImageAssetType,
"Type of mesh data available in a shape.\n"
"@ingroup gameObjects")
{ ImageAsset::Albedo, "Albedo", "" },
{ ImageAsset::Normal, "Normal", "" },
{ ImageAsset::ORMConfig, "ORMConfig", "" },
{ ImageAsset::GUI, "GUI", "" },
{ ImageAsset::Roughness, "Roughness", "" },
{ ImageAsset::AO, "AO", "" },
{ ImageAsset::Metalness, "Metalness", "" },
{ ImageAsset::Glow, "Glow", "" },
{ ImageAsset::Particle, "Particle", "" },
{ ImageAsset::Decal, "Decal", "" },
{ ImageAsset::Cubemap, "Cubemap", "" },
EndImplementEnumType;
const String ImageAsset::mErrCodeStrings[] =
{
"TooManyMips",
"UnKnown"
};
//-----------------------------------------------------------------------------
ImageAsset::ImageAsset() : AssetBase(), mIsValidImage(false), mUseMips(true), mIsHDRImage(false), mImageType(Albedo)
{
mImageFileName = StringTable->EmptyString();
mImagePath = StringTable->EmptyString();
mLoadedState = AssetErrCode::NotLoaded;
mChangeSignal.notify(this, &ImageAsset::onAssetRefresh);
}
//-----------------------------------------------------------------------------
ImageAsset::~ImageAsset()
{
}
void ImageAsset::consoleInit()
{
Parent::consoleInit();
Con::addVariable("$Core::NoImageAssetFallback", TypeString, &smNoImageAssetFallback,
"The assetId of the texture to display when the requested image asset is missing.\n"
"@ingroup GFX\n");
smNoImageAssetFallback = StringTable->insert(Con::getVariable("$Core::NoImageAssetFallback"));
}
//-----------------------------------------------------------------------------
void ImageAsset::initPersistFields()
{
docsURL;
// Call parent.
Parent::initPersistFields();
addProtectedField("imageFile", TypeAssetLooseFilePath, Offset(mImageFileName, ImageAsset),
&setImageFileName, &getImageFileName, "Path to the image file.");
addField("useMips", TypeBool, Offset(mUseMips, ImageAsset), "Should the image use mips? (Currently unused).");
addField("isHDRImage", TypeBool, Offset(mIsHDRImage, ImageAsset), "Is the image in an HDR format? (Currently unused)");
addField("imageType", TypeImageAssetType, Offset(mImageType, ImageAsset), "What the main use-case for the image is for.");
}
//------------------------------------------------------------------------------
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
//Utility function to 'fill out' bindings and resources with a matching asset if one exists
U32 ImageAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset)
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
{
AssetQuery query;
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, fileName);
if (foundAssetcount == 0)
{
//Didn't work, so have us fall back to a placeholder asset
imageAsset->setAssetId(ImageAsset::smNoImageAssetFallback);
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
if (imageAsset->isNull())
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
{
//Well that's bad, loading the fallback failed.
Con::warnf("ImageAsset::getAssetByFilename - Finding of asset associated with file %s failed with no fallback asset", fileName);
return AssetErrCode::Failed;
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
}
//handle noshape not being loaded itself
if ((*imageAsset)->mLoadedState == BadFileReference)
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
{
Con::warnf("ImageAsset::getAssetByFilename - Finding of associated with file %s failed, and fallback asset reported error of Bad File Reference.", fileName);
return AssetErrCode::BadFileReference;
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
}
Con::warnf("ImageAsset::getAssetByFilename - Finding of associated with file %s failed, utilizing fallback asset", fileName);
(*imageAsset)->mLoadedState = AssetErrCode::UsingFallback;
return AssetErrCode::UsingFallback;
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
}
else
{
//acquire and bind the asset, and return it out
imageAsset->setAssetId(query.mAssetList[0]);
return (*imageAsset)->load();
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
}
}
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
StringTableEntry ImageAsset::getAssetIdByFilename(StringTableEntry fileName)
{
if (fileName == StringTable->EmptyString())
return StringTable->EmptyString();
StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback;
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
AssetQuery query;
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, fileName);
if (foundAssetcount != 0)
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
{
//acquire and bind the asset, and return it out
imageAssetId = query.mAssetList[0];
}
else
{
AssetPtr<ImageAsset> imageAsset = imageAssetId; //ensures the fallback is loaded
}
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
return imageAssetId;
}
U32 ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* imageAsset)
{
(*imageAsset) = assetId;
if (imageAsset->notNull())
{
return (*imageAsset)->load();
}
else
{
if (imageAsset->isNull())
{
return AssetErrCode::Failed;
}
//handle fallback not being loaded itself
if ((*imageAsset)->mLoadedState == BadFileReference)
{
Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed, and fallback asset reported error of Bad File Reference.", assetId);
return AssetErrCode::BadFileReference;
}
Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed, utilizing fallback asset", assetId);
(*imageAsset)->mLoadedState = AssetErrCode::UsingFallback;
return AssetErrCode::UsingFallback;
}
}
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
//------------------------------------------------------------------------------
void ImageAsset::copyTo(SimObject* object)
{
// Call to parent.
Parent::copyTo(object);
}
U32 ImageAsset::load()
{
if (mLoadedState == AssetErrCode::Ok) return mLoadedState;
if (mImagePath)
{
2021-07-23 02:27:13 +00:00
if (!Torque::FS::IsFile(mImagePath))
{
Con::errorf("ImageAsset::initializeAsset: Attempted to load file %s but it was not valid!", mImageFileName);
mLoadedState = BadFileReference;
return mLoadedState;
}
mLoadedState = Ok;
mIsValidImage = true;
return mLoadedState;
}
mLoadedState = BadFileReference;
mIsValidImage = false;
return mLoadedState;
}
void ImageAsset::initializeAsset()
{
ResourceManager::get().getChangedSignal().notify(this, &ImageAsset::_onResourceChanged);
Updated path handling for loose asset files for CPP, Image, Level, Material, PostFX, Shape, Terrain, TerrainMat and StateMachine assets to be more predictable in when and how they expando the loose file path into a full, useable path Fixed loose file bindings for all associated slots in level asset, such as postFX file, decals, etc Expanded TSStatic onInspect testcase to parse materialSlots and hook-in a specialized material field for editing/quick reference from the inspector Adjusted expand behavior of guiTree to be more reliable Added internal name 'stack' to inspectorGroup's stack child objects for easier access to add programatic fields Removed redundant PreMult translucency type code Added setting of feature so probes work when in forward/basic lit mode Corrected indexing error in SQLiteObject class so it properly parses with the updated console API Tweaked the FOV setting logic in GameConnection::onControlObjectChange to not be spammy Fixed var when trying to bind the camera to the client Added project setting field to dictate the default render mode between Forward or Deferred Integrated MotionBlur PostFX into updated PostFX Editor paradigm and exposed the samples uniform as an editable field Integrated DOF PostFX into updated PostFX Editor paradigm Updated setting group name for vignette postFX Shifted shaderCache to be in data/cache along with other cached files Added helper function to replace strings in a file Fixed ExampleCppObject asset to have correct loose file references Adjusted editor default level logic so it can be modifed and then stored, as well as reset back to the original default Fixed verve reference to root scene group Adjusted location of a nonmodal gui profile so it loads at the correct time Reorganized AssetBrowser loading and refresh logic so it doesn't stack multiple refresh requests back-to-back causing lag Updated the search behavior to search not just the current address, but all child folders as well, making it far more useful Initial work into zip and folder drag-and-drop asset importing support Removed the import config setting for 'always display material maps' as it is redundant with the new importer context menu actions Updated example asset type file Ensured all asset types have proper handling for move, rename and delete actions Fixed double-click behavior on folders in the AB Fixed CPP asset preview Added better logic to discern if a top-level folder belongs to a module or not in the AB directory browser Added ability to convert a non-module top-level folder in the AB into a module Added initial hooks for being able to generate a new Editor Tool, similar to how the AB can generate modules Renamed CPP asset template files to have the .template so they aren't accidentally picked up by cmake Fixed convex editor's material handling to work with AB and reference back properly Updated AB images for folder up/down navigation buttons, and the breadcrumb divider arrow Made PostFX Editor properly allow for input pass-through so you can still edit the level with it open Added some additional common text gui profiles Disabled calls to old editor settings logic in various editors to remove spam Added callOnModules call so tools can initialize properly when the world editor is opened Fixed logic test for visualizers Added ability for cmake to scan tools directory for any tools that add source files
2020-02-04 07:47:28 +00:00
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
}
void ImageAsset::onAssetRefresh()
{
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
// Iterate all dependencies.
while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
{
StringTableEntry assetId = assetDependenciesItr->value;
AssetBase* dependent = AssetDatabase.acquireAsset<AssetBase>(assetId);
dependent->refreshAsset();
}
}
void ImageAsset::_onResourceChanged(const Torque::Path& path)
{
if (path != Torque::Path(mImagePath))
return;
refreshAsset();
}
void ImageAsset::setImageFileName(const char* pScriptFile)
{
// Sanity!
AssertFatal(pScriptFile != NULL, "Cannot use a NULL image file.");
// Update.
mImageFileName = StringTable->insert(pScriptFile, true);
// Refresh the asset.
refreshAsset();
}
GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
{
if (mResourceMap.contains(requestedProfile))
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
{
mLoadedState = Ok;
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
return mResourceMap.find(requestedProfile)->value;
}
else
{
//If we don't have an existing map case to the requested format, we'll just create it and insert it in
GFXTexHandle newTex = TEXMGR->createTexture(mImagePath, requestedProfile);
if (newTex)
{
mResourceMap.insert(requestedProfile, newTex);
mLoadedState = Ok;
return newTex;
}
else
mLoadedState = BadFileReference;
}
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
//if (mTexture.isValid())
// return mTexture;
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
return nullptr;
}
const char* ImageAsset::getImageInfo()
{
if (mIsValidImage)
{
static const U32 bufSize = 2048;
char* returnBuffer = Con::getReturnBuffer(bufSize);
GFXTexHandle newTex = TEXMGR->createTexture(mImagePath, &GFXStaticTextureSRGBProfile);
if (newTex)
{
dSprintf(returnBuffer, bufSize, "%s %d %d %d", GFXStringTextureFormat[newTex->getFormat()], newTex->getHeight(), newTex->getWidth(), newTex->getDepth());
newTex = nullptr;
}
else
{
dSprintf(returnBuffer, bufSize, "ImageAsset::getImageInfo() - Failed to get image info for %s", getAssetId());
}
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
return returnBuffer;
}
return "";
}
const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
{
// must match ImageTypes order
static const char* _names[] = {
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
"Albedo",
"Normal",
2020-09-30 18:51:12 +00:00
"ORMConfig",
Corrects lookup/in-place auto import logic for ImageAssets Fixed sizing issue for material asset ptr fields Fixed type of comment in Particle Asset Hooked GLSL and HLSL shader files to be proper asset loose files for PostEffectAsset Adjusted some default values for default ImportConfig Corrected field type of multiple fields for the importConfig Corrected loading of PopulateMaterialMaps config setting from config file Corrected field types of multiple fields for AssetImportObjects Exposed several utility fields for the Importer to script Added ability to create an AssetImportObject in script and add it to the Importer's current session Ensured stable naming behavior(replacing spaces, -, and . in names with _ Improved getAssetTypeByFile logical lookup so it doesn't accidentally grab cached.dts files Added ability to hard reset an import session, wiping all inbound files for a full reset Added ability to process DTS files to shape import so it can parse out content such as materials for associated asset imports Added better handling for shape materials that are just colors Added callback hook-in so if the importer doesn't have a defined function for importing a given asset type, it'll try calling down into the editor Stabilized imageAsset processing logic when generating a material for it Improved imageType lookup/processing logic in Importer Improved logic for binding in associated image files to materialAssets Improved logic for processing shapes to get related materials and images, ensuring better likelyhood of finding and associating related assets Cleaned up validation logic Added ability to properly look up the editor's default import config if it's set to be used for autoimport Improved handling of originalFilePath logic, so if it's an in-place import, it doesn't bother populating the field Set default UP axis value on shape importing to ensure better default behavior
2020-07-11 21:20:10 +00:00
"GUI",
"Roughness",
"AO",
"Metalness",
"Glow",
"Particle",
"Decal",
"Cubemap"
};
if (type < 0 || type >= ImageTypeCount)
{
Con::errorf("ImageAsset::getAdapterNameFromType - Invalid ImageType, defaulting to Albedo");
return _names[Albedo];
}
return _names[type];
}
ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(const char* name)
{
if (dStrIsEmpty(name))
{
return (ImageTypes)Albedo;
}
S32 ret = -1;
for (S32 i = 0; i < ImageTypeCount; i++)
{
if (!dStricmp(getImageTypeNameFromType((ImageTypes)i), name))
ret = i;
}
if (ret == -1)
{
Con::errorf("ImageAsset::getImageTypeFromName - Invalid ImageType name, defaulting to Albedo");
ret = Albedo;
}
return (ImageTypes)ret;
}
DefineEngineMethod(ImageAsset, getImagePath, const char*, (), ,
Misc Quality of Life and Bug fixes Added handling for if preview images on image assets fails to generate, will fallback to using the full image Added handling for double clicking or drag-n-dropping terrain assets to create them Improved handling of field labels in variable inspector by making the stringtable be case sensitive. Added editor settings for handling of asset double click behavior. Can now select between Edit Asset and Spawn Asset. Support is asset type dependent. Added editor setting for auto-importing loose files when navigating to a folder. If on and the user has flagged to also enable auto-import generally, will auto import all unaffiliated loose files in as assets. Added editor setting for default module to use when creating new assets. Updated various tooling logic so when creating a new material, if this and the 'Always Prompt Module Target' setting is off, it will fill in the target module and target asset path info based on the default module. Fixed issue with editors that use managedData scripts where if the path didn't exist, the script file wouldn't be made. Fixed display issue in terrain editor where if you clear the detail map, the normal/macro/orm maps would disable, but not also clear. Fixed handling of cleared maps in terrain editor so it no longer fills empty maps in with the no image image. Fixed handling of creating new material where it would fill in the diffuse with a no texture image as the default. Fixed issue where canceling out of creating a module would still prompt to create the common default folders. Fixed issue where the Select Module window couldn't be closed via the cancel or x buttons. Based on feedback, reduced default size of the Text Pad window. Fixed issue where the Drop At menu list wouldn't correctly display which item was marked after it was changed. Fixed spawning shape asset handling so it uses whatever the editor's Drop At setting is. Improved themeing of regular bitmap buttons in the editor. Based on feedback, flipped layout of Target Module and Target Path in the Create New Asset window. Improved handling of setting up the Target Path for when creating new assets. If a path is not set, and the user has a Default Module, it will default the path to that module.
2021-08-28 23:51:27 +00:00
"Gets the image filepath of this asset.\n"
"@return File path of the image file.")
{
return object->getImagePath();
}
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
DefineEngineMethod(ImageAsset, getImageInfo, const char*, (), ,
Misc Quality of Life and Bug fixes Added handling for if preview images on image assets fails to generate, will fallback to using the full image Added handling for double clicking or drag-n-dropping terrain assets to create them Improved handling of field labels in variable inspector by making the stringtable be case sensitive. Added editor settings for handling of asset double click behavior. Can now select between Edit Asset and Spawn Asset. Support is asset type dependent. Added editor setting for auto-importing loose files when navigating to a folder. If on and the user has flagged to also enable auto-import generally, will auto import all unaffiliated loose files in as assets. Added editor setting for default module to use when creating new assets. Updated various tooling logic so when creating a new material, if this and the 'Always Prompt Module Target' setting is off, it will fill in the target module and target asset path info based on the default module. Fixed issue with editors that use managedData scripts where if the path didn't exist, the script file wouldn't be made. Fixed display issue in terrain editor where if you clear the detail map, the normal/macro/orm maps would disable, but not also clear. Fixed handling of cleared maps in terrain editor so it no longer fills empty maps in with the no image image. Fixed handling of creating new material where it would fill in the diffuse with a no texture image as the default. Fixed issue where canceling out of creating a module would still prompt to create the common default folders. Fixed issue where the Select Module window couldn't be closed via the cancel or x buttons. Based on feedback, reduced default size of the Text Pad window. Fixed issue where the Drop At menu list wouldn't correctly display which item was marked after it was changed. Fixed spawning shape asset handling so it uses whatever the editor's Drop At setting is. Improved themeing of regular bitmap buttons in the editor. Based on feedback, flipped layout of Target Module and Target Path in the Create New Asset window. Improved handling of setting up the Target Path for when creating new assets. If a path is not set, and the user has a Default Module, it will default the path to that module.
2021-08-28 23:51:27 +00:00
"Gets the info and properties of the image.\n"
"@return The info/properties of the image.")
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
{
return object->getImageInfo();
}
#ifdef TORQUE_TOOLS
DefineEngineStaticMethod(ImageAsset, getAssetIdByFilename, const char*, (const char* filePath), (""),
"Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n"
"@return The AssetId of the associated asset, if any.")
{
return ImageAsset::getAssetIdByFilename(StringTable->insert(filePath));
}
//-----------------------------------------------------------------------------
// GuiInspectorTypeAssetId
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(GuiInspectorTypeImageAssetPtr);
ConsoleDocClass(GuiInspectorTypeImageAssetPtr,
"@brief Inspector field type for Shapes\n\n"
"Editor use only.\n\n"
"@internal"
);
void GuiInspectorTypeImageAssetPtr::consoleInit()
{
Parent::consoleInit();
ConsoleBaseType::getType(TypeImageAssetPtr)->setInspectorFieldType("GuiInspectorTypeImageAssetPtr");
}
GuiControl* GuiInspectorTypeImageAssetPtr::constructEditControl()
{
// Create base filename edit controls
GuiControl* retCtrl = Parent::constructEditControl();
if (retCtrl == NULL)
return retCtrl;
retCtrl->getRenderTooltipDelegate().bind(this, &GuiInspectorTypeImageAssetPtr::renderTooltip);
// Change filespec
char szBuffer[512];
const char* previewImage;
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
if (mInspector->getInspectObject() != nullptr)
{
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ImageAsset\", \"AssetBrowser.changeAsset\", %s);",
getIdString());
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
mBrowseButton->setField("Command", szBuffer);
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString());
previewImage = getData();
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
}
else
{
//if we don't have a target object, we'll be manipulating the desination value directly
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ImageAsset\", \"AssetBrowser.changeAsset\", %s, \"%s\");",
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
mInspector->getIdString(), mVariableName);
mBrowseButton->setField("Command", szBuffer);
previewImage = Con::getVariable(mVariableName);
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
}
mLabel = new GuiTextCtrl();
mLabel->registerObject();
mLabel->setControlProfile(mProfile);
mLabel->setText(mCaption);
addObject(mLabel);
//
GuiTextEditCtrl* editTextCtrl = static_cast<GuiTextEditCtrl*>(retCtrl);
GuiControlProfile* toolEditProfile;
if (Sim::findObject("ToolsGuiTextEditProfile", toolEditProfile))
editTextCtrl->setControlProfile(toolEditProfile);
GuiControlProfile* toolDefaultProfile = nullptr;
Sim::findObject("ToolsGuiDefaultProfile", toolDefaultProfile);
//
mPreviewImage = new GuiBitmapCtrl();
mPreviewImage->registerObject();
if (toolDefaultProfile)
mPreviewImage->setControlProfile(toolDefaultProfile);
updatePreviewImage();
addObject(mPreviewImage);
//
mPreviewBorderButton = new GuiBitmapButtonCtrl();
mPreviewBorderButton->registerObject();
if (toolDefaultProfile)
mPreviewBorderButton->setControlProfile(toolDefaultProfile);
mPreviewBorderButton->_setBitmap(StringTable->insert("ToolsModule:cubemapBtnBorder_n_image"));
mPreviewBorderButton->setField("Command", szBuffer); //clicking the preview does the same thing as the edit button, for simplicity
addObject(mPreviewBorderButton);
//
// Create "Open in Editor" button
/*mEditButton = new GuiBitmapButtonCtrl();
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.editAsset(%d.getText());", retCtrl->getId());
mEditButton->setField("Command", szBuffer);
mEditButton->setText("Edit");
mEditButton->setSizing(horizResizeLeft, vertResizeAspectTop);
mEditButton->setDataField(StringTable->insert("Profile"), NULL, "ToolsGuiButtonProfile");
mEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
mEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
mEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this asset in the Image Editor");
mEditButton->registerObject();
addObject(mEditButton);*/
//
mUseHeightOverride = true;
mHeightOverride = 72;
return retCtrl;
}
bool GuiInspectorTypeImageAssetPtr::updateRects()
{
S32 rowSize = 18;
S32 dividerPos, dividerMargin;
mInspector->getDivider(dividerPos, dividerMargin);
Point2I fieldExtent = getExtent();
Point2I fieldPos = getPosition();
mEditCtrlRect.set(0, 0, fieldExtent.x, fieldExtent.y);
mLabel->resize(Point2I(mProfile->mTextOffset.x, 0), Point2I(fieldExtent.x, rowSize));
RectI previewRect = RectI(Point2I(mProfile->mTextOffset.x, rowSize), Point2I(50, 50));
mPreviewBorderButton->resize(previewRect.point, previewRect.extent);
mPreviewImage->resize(previewRect.point, previewRect.extent);
S32 editPos = previewRect.point.x + previewRect.extent.x + 10;
mEdit->resize(Point2I(editPos, rowSize * 1.5), Point2I(fieldExtent.x - editPos - 5, rowSize));
* Fixes handling for Image, Material and Shape Assets' inspector fields so they properly work with non-object targeted inspectors, such as the PostFXEditor * Updated PostFXEditor scripts to handle refreshing properly when certainl field types(assetId fields) are changed * Adjusted display handling of slider values on guiGameSettingsCtrl to show 0.x decimal format instead of 0.xxxxx * Fixed pad length of item names in guiTreeView for items that are marked to avoid console spam * Fixed local offseting for popupMenus so scaled/offset window position doesn't cause the popup menu to offset from mouse click position(courtesy OTHG_Mars) * Fix issue with terrain where, due to default value save validation, the global scope for the terrain collision list would be whiped when saving, causing players to fall through terrain. Moved to per-terrain convexLists * Fixed issue with the core camera model mesh and updated references so camera bookmarks display properly * Fixed console spam during asset browser initialization where it would try and expand the directory tree even though the dir tree isn't populated yet * Fixed handling of Open File Location RMB menu action to properly deal with script and datablock types * Removed unusuable "Create ___" asset type prompts from the RMB menus for the AB to avoid confusion * Improved slider offset positioning for various popup sliders on editor toolbars * Anchored the visibility popup menu to the button for more consistent formatting and better feel * Shifted various visibility toggles from 'in place' on the menu buttons to functions, allowing it to also properly mark the menu entries as checked or not, improving usability
2022-08-26 20:25:17 +00:00
//mEditButton->resize(Point2I(fieldExtent.x - 105, previewRect.point.y + previewRect.extent.y - rowSize), Point2I(100, rowSize));
mBrowseButton->setHidden(true);
return true;
}
bool GuiInspectorTypeImageAssetPtr::renderTooltip(const Point2I& hoverPos, const Point2I& cursorPos, const char* tipText)
{
if (!mAwake)
return false;
GuiCanvas* root = getRoot();
if (!root)
return false;
AssetPtr<ImageAsset> imgAsset;
U32 assetState = ImageAsset::getAssetById(getData(), &imgAsset);
if (imgAsset == NULL || assetState == ImageAsset::Failed)
return false;
StringTableEntry filename = imgAsset->getImagePath();
if (!filename || !filename[0])
return false;
StringTableEntry previewFilename = filename;
if (Con::isFunction("getAssetPreviewImage"))
{
ConsoleValue consoleRet = Con::executef("getAssetPreviewImage", filename);
previewFilename = StringTable->insert(consoleRet.getString());
if (AssetDatabase.isDeclaredAsset(previewFilename))
{
ImageAsset* previewAsset = AssetDatabase.acquireAsset<ImageAsset>(previewFilename);
previewFilename = previewAsset->getImagePath();
}
}
GFXTexHandle texture(previewFilename, &GFXStaticTextureSRGBProfile, avar("%s() - tooltip texture (line %d)", __FUNCTION__, __LINE__));
if (texture.isNull())
return false;
// Render image at a reasonable screen size while
// keeping its aspect ratio...
Point2I screensize = getRoot()->getWindowSize();
Point2I offset = hoverPos;
Point2I tipBounds;
U32 texWidth = texture.getWidth();
U32 texHeight = texture.getHeight();
F32 aspect = (F32)texHeight / (F32)texWidth;
const F32 newWidth = 150.0f;
F32 newHeight = aspect * newWidth;
// Offset below cursor image
offset.y += 20; // TODO: Attempt to fix?: root->getCursorExtent().y;
tipBounds.x = newWidth;
tipBounds.y = newHeight;
// Make sure all of the tooltip will be rendered width the app window,
// 5 is given as a buffer against the edge
if (screensize.x < offset.x + tipBounds.x + 5)
offset.x = screensize.x - tipBounds.x - 5;
if (screensize.y < offset.y + tipBounds.y + 5)
offset.y = hoverPos.y - tipBounds.y - 5;
RectI oldClip = GFX->getClipRect();
RectI rect(offset, tipBounds);
GFX->setClipRect(rect);
GFXDrawUtil* drawer = GFX->getDrawUtil();
drawer->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch(texture, rect);
GFX->setClipRect(oldClip);
return true;
}
void GuiInspectorTypeImageAssetPtr::updateValue()
{
Parent::updateValue();
updatePreviewImage();
}
void GuiInspectorTypeImageAssetPtr::updatePreviewImage()
{
const char* previewImage;
if (mInspector->getInspectObject() != nullptr)
previewImage = getData();
else
previewImage = Con::getVariable(mVariableName);
//if what we're working with isn't even a valid asset, don't present like we found a good one
if (!AssetDatabase.isDeclaredAsset(previewImage))
{
mPreviewImage->_setBitmap(StringTable->EmptyString());
return;
}
String imgPreviewAssetId = String(previewImage) + "_PreviewImage";
imgPreviewAssetId.replace(":", "_");
imgPreviewAssetId = "ToolsModule:" + imgPreviewAssetId;
if (AssetDatabase.isDeclaredAsset(imgPreviewAssetId.c_str()))
{
mPreviewImage->setBitmap(StringTable->insert(imgPreviewAssetId.c_str()));
}
else
{
if (AssetDatabase.isDeclaredAsset(previewImage))
{
ImageAsset* imgAsset = AssetDatabase.acquireAsset<ImageAsset>(previewImage);
if (imgAsset && imgAsset->isAssetValid())
{
mPreviewImage->_setBitmap(imgAsset->getAssetId());
}
}
}
if (mPreviewImage->getBitmapAsset().isNull())
mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
}
void GuiInspectorTypeImageAssetPtr::setPreviewImage(StringTableEntry assetId)
{
//if what we're working with isn't even a valid asset, don't present like we found a good one
if (!AssetDatabase.isDeclaredAsset(assetId))
{
mPreviewImage->_setBitmap(StringTable->EmptyString());
return;
}
String imgPreviewAssetId = String(assetId) + "_PreviewImage";
imgPreviewAssetId.replace(":", "_");
imgPreviewAssetId = "ToolsModule:" + imgPreviewAssetId;
if (AssetDatabase.isDeclaredAsset(imgPreviewAssetId.c_str()))
{
mPreviewImage->setBitmap(StringTable->insert(imgPreviewAssetId.c_str()));
}
else
{
if (AssetDatabase.isDeclaredAsset(assetId))
{
ImageAsset* imgAsset = AssetDatabase.acquireAsset<ImageAsset>(assetId);
if (imgAsset && imgAsset->isAssetValid())
{
mPreviewImage->_setBitmap(imgAsset->getAssetId());
}
}
}
if (mPreviewImage->getBitmapAsset().isNull())
mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
}
IMPLEMENT_CONOBJECT(GuiInspectorTypeImageAssetId);
ConsoleDocClass(GuiInspectorTypeImageAssetId,
"@brief Inspector field type for Images\n\n"
"Editor use only.\n\n"
"@internal"
);
void GuiInspectorTypeImageAssetId::consoleInit()
{
Parent::consoleInit();
ConsoleBaseType::getType(TypeImageAssetId)->setInspectorFieldType("GuiInspectorTypeImageAssetId");
}
2022-06-13 17:38:08 +00:00
#endif