Torque3D/Engine/source/T3D/assets/PostEffectAsset.cpp
JeffR d044ae0702 Removed unneeded default irradiance and prefilter cubemaps, and their convars
Added getGUIPath console function to guiAsset
Corrected console function documentation for getScriptPath in MaterialAsset
Added getter console functions to PostEffectAsset
Added getAnimationPath console function to PostEffectAsset
Fixes handling of mapto with the reskin usage when generating preview renders for ShapeAssets
Standardizes getShapeFile to getShapePath on ShapeAsset to better match formatting of other getters on assets
Adds sanity checking for getStringWidth to prevent crash if there's an issue with the font being ready at time of request(from Az)
Earlies out on rendering of impostors if it's the deferred bin to prevent unneeded duplicate rendering messing up results(from Az)
Fixed duplicate naming of quality levels on LightingQualityList
Added check so if _makePrettyResString is handed a 'human formatted' resolution string(as in, has <width> x <height> it can handle that properly
Shifted yes/no and on/off option lists to globals for ease and consistency of handling on options menu
Improves check for unapplied graphics options on options menu and applies them all at once
Add sanitizing of variable names so getVariable doesn't have issues when looking up array variables in optionsMenu logic
Adds better tracking of what options menu category is shown so refreshes don't reset it
Add better handling for changing resolution in options menu and getting it to apply properly
Adds better utility functions for setting bools vs optionsLists vs quality lists and updates options fields to use the most appropriate
Removes redundant setting of $pref::SFX::channelVolume vars in defaults.tscript
Removed unneeded extra logging from asset browser drag-n-drop actions
Adds item to RMB context menu in AB to regenerate preview images
Fixes move command for asset types(needed to properly reference the full path of the associated files) and added it for shapes, animations and terrains
Added logic so when the dropdown for selecting a target module on the Create New Asset window is changed, it forcefully updates the target path to point to the module to avoid erroneous paths being provided
Adds proper clamping of values to Forest Editor's brush size in the editor bar. Could be set to below 1 even though it would visually clamp to 1.
Temporarily disables fields and handling of 'open in Torsion'.
Fixes bad pixel in gui/images/tab_border.png which was causing it to fail to generate bitmap array properly
Makes the New GUI option from menubar in GUI Editor use same Create New Asset method as everything else
Disables access to the CubemapDesc reflector field in the material editor as it's not nominally used now in favor of probes
Adds proper loading of roughness and metalness fields in material editor
Fixes the default ReflectProbePreviewMat to use a better base DiffuseMap (No Material) rather than the occluder
Fixes disable display for some options in the advanced panel in the shape editor so they look more fitting to everything else
Adds check to avoid spam of markItem errors in the event requested tree item is invalid
Fixed remove material button and command in TerrainMaterial Editor
2022-04-03 20:00:30 -05:00

227 lines
6.8 KiB
C++

//-----------------------------------------------------------------------------
// 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 POSTEFFECT_ASSET_H
#include "PostEffectAsset.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
// Debug Profiling.
#include "platform/profiler.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(PostEffectAsset);
ConsoleType(PostEffectAssetPtr, TypePostEffectAssetPtr, PostEffectAsset, ASSET_ID_FIELD_PREFIX)
//-----------------------------------------------------------------------------
ConsoleGetType(TypePostEffectAssetPtr)
{
// Fetch asset Id.
return (*((AssetPtr<PostEffectAsset>*)dptr)).getAssetId();
}
//-----------------------------------------------------------------------------
ConsoleSetType(TypePostEffectAssetPtr)
{
// Was a single argument specified?
if (argc == 1)
{
// Yes, so fetch field value.
const char* pFieldValue = argv[0];
// Fetch asset pointer.
AssetPtr<PostEffectAsset>* pAssetPtr = dynamic_cast<AssetPtr<PostEffectAsset>*>((AssetPtrBase*)(dptr));
// Is the asset pointer the correct type?
if (pAssetPtr == NULL)
{
// No, so fail.
//Con::warnf("(TypePostEffectAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
return;
}
// Set asset.
pAssetPtr->setAssetId(pFieldValue);
return;
}
// Warn.
Con::warnf("(TypePostEffectAssetPtr) - Cannot set multiple args to a single asset.");
}
//-----------------------------------------------------------------------------
PostEffectAsset::PostEffectAsset()
{
mScriptFile = StringTable->EmptyString();
mHLSLShaderFile = StringTable->EmptyString();
mGLSLShaderFile = StringTable->EmptyString();
mScriptPath = StringTable->EmptyString();
mHLSLShaderPath = StringTable->EmptyString();
mGLSLShaderPath = StringTable->EmptyString();
}
//-----------------------------------------------------------------------------
PostEffectAsset::~PostEffectAsset()
{
}
//-----------------------------------------------------------------------------
void PostEffectAsset::initPersistFields()
{
// Call parent.
Parent::initPersistFields();
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, PostEffectAsset),
&setScriptFile, &getScriptFile, "Path to the script file.");
addProtectedField("hlslShader", TypeAssetLooseFilePath, Offset(mHLSLShaderFile, PostEffectAsset),
&setHLSLShaderFile, &getHLSLShaderFile, "Path to the hlsl shader file.");
addProtectedField("glslShader", TypeAssetLooseFilePath, Offset(mGLSLShaderFile, PostEffectAsset),
&setGLSLShaderFile, &getGLSLShaderFile, "Path to the glsl shader file.");
}
//------------------------------------------------------------------------------
void PostEffectAsset::copyTo(SimObject* object)
{
// Call to parent.
Parent::copyTo(object);
}
void PostEffectAsset::initializeAsset()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
mHLSLShaderPath = getOwned() ? expandAssetFilePath(mHLSLShaderFile) : mHLSLShaderPath;
mGLSLShaderPath = getOwned() ? expandAssetFilePath(mGLSLShaderFile) : mGLSLShaderPath;
if (Torque::FS::IsScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);
}
void PostEffectAsset::onAssetRefresh()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
mHLSLShaderPath = getOwned() ? expandAssetFilePath(mHLSLShaderFile) : mHLSLShaderPath;
mGLSLShaderPath = getOwned() ? expandAssetFilePath(mGLSLShaderFile) : mGLSLShaderPath;
if (Torque::FS::IsScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);
}
void PostEffectAsset::setScriptFile(const char* pScriptFile)
{
// Sanity!
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
// Fetch image file.
pScriptFile = StringTable->insert(pScriptFile, true);
// Ignore no change,
if (pScriptFile == mScriptFile)
return;
// Update.
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : pScriptFile;
// Refresh the asset.
refreshAsset();
}
void PostEffectAsset::setHLSLShaderFile(const char* pShaderFile)
{
// Sanity!
AssertFatal(pShaderFile != NULL, "Cannot use a NULL shader file.");
// Fetch image file.
pShaderFile = StringTable->insert(pShaderFile, true);
// Ignore no change,
if (pShaderFile == mHLSLShaderFile)
return;
// Update.
mHLSLShaderFile = getOwned() ? expandAssetFilePath(pShaderFile) : pShaderFile;
// Refresh the asset.
refreshAsset();
}
void PostEffectAsset::setGLSLShaderFile(const char* pShaderFile)
{
// Sanity!
AssertFatal(pShaderFile != NULL, "Cannot use a NULL shader file.");
// Fetch image file.
pShaderFile = StringTable->insert(pShaderFile, true);
// Ignore no change,
if (pShaderFile == mGLSLShaderFile)
return;
// Update.
mGLSLShaderFile = getOwned() ? expandAssetFilePath(pShaderFile) : pShaderFile;
// Refresh the asset.
refreshAsset();
}
DefineEngineMethod(PostEffectAsset, getScriptPath, const char*, (), ,
"Gets the script file path for the asset.")
{
return object->getScriptPath();
}
DefineEngineMethod(PostEffectAsset, getHLSLShaderPath, const char*, (), ,
"Gets the HLSL Shader file path for the asset.")
{
return object->getHLSLShaderPath();
}
DefineEngineMethod(PostEffectAsset, getGLSLShaderPath, const char*, (), ,
"Gets the GLSL Shader file path for the asset.")
{
return object->getGLSLShaderPath();
}