Files
o3de/Assets/Engine/Scripts/EngineCommon.lua
T
lumberyard-employee-dm 3dec5d3b71 LYN-2537 engine assets (#254)
* LYN-2537 Moved the Engine and Editor folder to be within the EngineAssets folder

* Fixed Documentation in bootstrap.cfg to correct the path to the user project specific registry file

* Adding a newline to the output of AssetCatalog 'Registering asset..., but type is not set' message

* Updating the AssetProcessorPlatformConfig.setreg Scan Folder to detect
the @ENGINEROOT@/EngineAssets/Engine path for engine runtime assets and
@ENGINEROOT@/EngineAssets/Editor path for engine tool assets

* Updating references to Icons and other assets to account for moving the
Engine and Editor folder under a single EngineAssets folder

* Moving the Engine Settings Registry folder from Engine/Registry -> Registry

* Removed the LY_PROJECT_CMAKE_PATH define as it is not portable to other locations. It is hard coded to the project location that was used for the CMake configuration. Furthermore it paths with backslashes within it are treated as escape characters and not a path separator

* Updated the LyTestTools asset_processor.py script to copy the exclude.filetag from the EngineAssets/Engine directory now

* Fixed Atom Shader Preprocessing when running using an External Project

* Updated the TSGenerateAction.cpp to fix the build error with using a renamed variable

* Updated the Install_Common.cmake ly_setup_others function to install the
EngineAssets directory and the each of the Gem's Assets directory while
maintaining the relative directory structure to the Engine Root
Also updated the install step to install the Registry folder at the
engine root

* Fixed the copying of the Registry folder to be in the install root, instead of under a second 'Registry' folder

* Moving the AssetProcessorPlatformConfig.setreg file over to the Registry folder

* Updated the LyTestTools and C++ code to point that the new location of
the AssetProcessorPlatformConfig.setreg file inside of the Registry
folder

* Renamed Test AssetProcessor*Config.ini files to have the .setreg extension

* Converted the AssetProcessor test setreg files from ini format to json
format using the SerializeContextTools convert-ini command

* Updated the AssetProcessor CMakeLists.txt to copy over the test setreg files to the build folder

* Updated the assetprocessor test file list to point at the renamed AsssetProcessor*Config setreg filenames

* Removed the Output Prefix code from the AssetProcessor. The complexity that it brought to the AP code is not needed, as users can replicate the behavior by just moving there assets underneath a another folder, underneath the scan folder

* Adding back support to read the AssetProcessorPlatformConfig.setreg file from the asset root. This is only needed for C++ UnitTests as they run in an environment where the accessing the Engine Settings Registry is not available

* Updating the Install_common.cmake logic to copy any "Assets" folder to
the install layout.
The Script has also been updated to copy over the "Assets" folder in the
Engine Root to the install layout instead of an "EngineAssets" folder

* Updating References to EngineAssets source asset folder in code to be the Assets source folder

* Moved the Engine Source Asset folder of 'EngineAssets' to a new folder name of 'Assets'. This is inline with the naming scheme we use for Gem asset folders

* Adding the EngineFinder.cmake to the AutomatedTesting project to allow it to work in a project centric manner

* Updating the LyTestTools copy_assets_to_project function to be able to copy assets with folders to the temporary project root
Fixed an issue in LyTestTools where the temporary log directory could have shutil.rmtree being called twice on it leading to an exception which fails an automated test

Updated the asset_procesor_gui_tests_2 AddScanFolder test to not use the
output prefix, but instead place the source asset root into a
subdirectory

* Correct the AssetProcessorPlatformConfig Scan Folders for the EngineAssets directory to point at the Assets directory

* Updated the asset procesor batch dependency test scan folder to point at the 'Assets' folder instead of 'EngineAssets'
2021-04-28 21:38:43 -05:00

299 lines
8.2 KiB
Lua

----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
----------------------------------------------------
-- Common Globals and Definitions.
----------------------------------------------------
----------------------------------------------------
-- data structure passed to the Signals, use this global to avoid temporary lua mem allocation
g_SignalData_point = {x=0,y=0,z=0};
g_SignalData_point2 = {x=0,y=0,z=0};
-- REMEMBER! ALWAYS write
-- g_SignalData.point = g_SignalData_point
-- before doing direct value assignment (i.e. not referenced) like
-- g_SignalData.point.x = ...
-- and any math.lua vector function on it (FastSumVectors(g_SignalData.point,..) etc
g_SignalData = {
point = g_SignalData_point, -- since g_SignalData.point is always used as a handler
point2 = g_SignalData_point2,
ObjectName = "",
id = NULL_ENTITY,
fValue = 0,
iValue = 0,
iValue2 = 0,
}
g_StringTemp1 = " ";
g_HitTable = {{},{},{},{},{},{},{},{},{},{},}
function ShowTime()
local ttime=System.GetLocalOSTime();
System.Log(string.format("%d/%d/%d, %02d:%02d", ttime.mday, ttime.mon+1, ttime.year+1900, ttime.hour, ttime.min));
end
function count(_tbl)
local count = 0;
if (_tbl) then
for i,v in pairs(_tbl) do
count = count+1;
end
end
return count;
end
function new(_obj, norecurse)
if (type(_obj) == "table") then
local _newobj = {};
if (norecurse) then
for i,f in pairs(_obj) do
_newobj[i] = f;
end
else
for i,f in pairs(_obj) do
if ((type(f) == "table") and (_obj~=f)) then -- avoid recursing into itself
_newobj[i] = new(f);
else
_newobj[i] = f;
end
end
end
return _newobj;
else
return _obj;
end
end
function merge(dst, src, recurse)
for i,v in pairs(src) do
if (type(v) ~= "function") then
if(recurse) then
if((type(v) == "table") and (v ~= src))then -- avoid recursing into itself
if (dst[i] == nil) then
dst[i] = {};
end
merge(dst[i], v, recurse);
elseif (dst[i] == nil) then
dst[i] = v;
end
elseif (dst[i] == nil) then
dst[i] = v;
end
end
end
return dst;
end
function mergef(dst, src, recursive)
for i,v in pairs(src) do
if (recursive) then
if((type(v) == "table") and (v ~= src))then -- avoid recursing into itself
if (dst[i] == nil) then
dst[i] = {};
end
mergef(dst[i], v, recursive);
elseif (dst[i] == nil) then
dst[i] = v;
end
elseif (dst[i] == nil) then
dst[i] = v;
end
end
return dst;
end
function Vec2Str(vec)
return string.format("(x: %.3f y: %.3f z: %.3f)", vec.x, vec.y, vec.z);
end
function LogError(fmt, ...)
System.Log("$4"..string.format(fmt, ...));
end
function LogWarning(fmt, ...)
System.Log("$6"..string.format(fmt, ...));
end
function Log(fmt, ...)
System.Log(string.format(fmt, ...));
end
g_dump_tabs=0;
function dump(_class, no_func, depth)
if not _class then
System.Log("$2nil");
else
if (not depth) then
depth = 8;
end
local str="";
for n=0,g_dump_tabs,1 do
str=str.." ";
end
for i,field in pairs(_class) do
if(type(field)=="table") then
if (g_dump_tabs < depth) then
g_dump_tabs=g_dump_tabs+1;
System.Log(str.."$4"..tostring(i).."$1= {");
dump(field, no_func, depth);
System.Log(str.."$1}");
g_dump_tabs=g_dump_tabs-1;
else
System.Log(str.."$4"..tostring(i).."$1= { $4...$1 }");
end
else
if(type(field)=="number" ) then
System.Log("$2"..str.."$6"..tostring(i).."$1=$8"..field);
elseif(type(field) == "string") then
System.Log("$2"..str.."$6"..tostring(i).."$1=$8".."\""..field.."\"");
elseif(type(field) == "boolean") then
System.Log("$2"..str.."$6"..tostring(i).."$1=$8".."\""..tostring(field).."\"");
else
if(not no_func)then
if(type(field)=="function")then
System.Log("$2"..str.."$5"..tostring(i).."()");
else
System.Log("$2"..str.."$7"..tostring(i).."$8<userdata>");
end
end
end
end
end
end
end
-- check if a string is set and it's length > 0
function EmptyString(str)
if (str and string.len(str) > 0) then
return false;
end
return true;
end
-- check if a number value is true or false
-- usefull for entity parameters
function NumberToBool(n)
if (n and (tonumber(n) ~= 0)) then
return true;
else
return false;
end
end
-- easy way to log entity id
-- accepts both entity table or entityid
function EntityName(entity)
if (type(entity) == "userdata") then
local e = System.GetEntity(entity);
if (e) then
return e:GetName();
end
elseif (type(entity) == "table") then
return entity:GetName();
end
return "";
end
-- easy way to get entity by name
-- usefull for "console debugging"!
function EntityNamed(name)
return System.GetEntityByName(name);
end
function SafeTableGet( table, name )
if table then return table[name] else return nil end
end
----------------------------------------------------
-- Load commonly used globals.
----------------------------------------------------
Script.ReloadScript("scripts/Utils/Containers.lua");
Script.ReloadScript("scripts/Utils/Math.lua");
Script.ReloadScript("scripts/Utils/EntityUtils.lua");
----------------------------------------------------
g_AIDebugToggleOn=0;
--///////////////////////////////////////////////////////////////////////////////////
--
----------------------------------------------------
function AIDebugToggle()
if(g_AIDebugToggleOn == 0) then
-- System.Log("___AIDebugToggle switching on");
g_AIDebugToggleOn=1;
System.SetCVar( "ai_DebugDraw",1 );
else
-- System.Log("___AIDebugToggle switching off");
System.SetCVar( "ai_DebugDraw",0 );
g_AIDebugToggleOn=0;
end
end
----------------------------------------------------
-- Removes a value from a table
function RemoveFromTable(tbl, ent)
for i,v in ipairs(tbl) do
if (v == ent) then
table.remove(tbl, i);
break;
end
end
end
-- Inserts a value into a table unless it is already present
function InsertIntoTable(tbl, ent)
local inside = false;
for i,v in ipairs(tbl) do
if (v == ent) then
inside = true;
break;
end
end
if (not inside) then
table.insert(tbl, ent);
end
end
-- Checks if a value is already inside a table
function IsInsideTable(tbl, ent)
for i,v in ipairs(tbl) do
if (v == ent) then
return true;
end
end
return false;
end
function SafeKillTimer(timer)
if (timer) then
Script.KillTimer(timer)
end
end