Red code legacy renderer (#383)
- Remove some references to gEnv->pRenderer/GetIEditor()->GetRenderer() that is now always null. - Restore the debug console to existence. - Stop building the following in preparation for their removal: Code/CryEngine/Cry3DEngine/* Code/CryEngine/RenderDll/* Code/Tools/CryFXC/* Code/Tools/HLSLCrossCompiler/* Code/Tools/HLSLCrossCompilerMETAL/* Code/Tools/RC/* Code/Tools/ShaderCacheGen/* Tools/CrySCompileServer/*
This commit is contained in:
@@ -28,7 +28,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
@@ -42,7 +41,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
@@ -56,7 +54,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 3600
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
@@ -74,7 +71,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
@@ -88,7 +84,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
)
|
||||
@@ -104,7 +99,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
@@ -123,7 +117,6 @@ endif()
|
||||
# TIMEOUT 1500
|
||||
# RUNTIME_DEPENDENCIES
|
||||
# Legacy::Editor
|
||||
# Legacy::CryRenderNULL
|
||||
# AZ::AssetProcessor
|
||||
# AutomatedTesting.Assets
|
||||
# )
|
||||
@@ -139,7 +132,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
Gem::EditorPythonBindings.Editor
|
||||
@@ -157,7 +149,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
Gem::EditorPythonBindings.Editor
|
||||
@@ -295,7 +286,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
TIMEOUT 1500
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Editor
|
||||
Legacy::CryRenderNULL
|
||||
AZ::AssetProcessor
|
||||
AutomatedTesting.Assets
|
||||
COMPONENT
|
||||
@@ -314,7 +304,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
# AZ::AssetProcessor
|
||||
# AZ::AssetProcessorBatch
|
||||
# AutomatedTesting.GameLauncher
|
||||
# Legacy::CryRenderNULL
|
||||
#)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
add_subdirectory(Cry3DEngine)
|
||||
add_subdirectory(CryCommon)
|
||||
add_subdirectory(CryFont)
|
||||
add_subdirectory(CrySystem)
|
||||
add_subdirectory(RenderDll)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#if defined(USE_GEOM_CACHES)
|
||||
|
||||
#include "../RenderDll/Common/Shaders/Vertex.h"
|
||||
#include <Vertex.h>
|
||||
#include <CryCommon/StaticInstance.h>
|
||||
|
||||
class CREGeomCache
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//=============================================================
|
||||
|
||||
#include "VertexFormats.h"
|
||||
#include "../RenderDll/Common/Shaders/Vertex.h"
|
||||
#include <Vertex.h>
|
||||
|
||||
struct SSkyLightRenderParams;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <CrySizer.h>
|
||||
#include <Cry_Geo.h> // for AABB
|
||||
#include <VertexFormats.h>
|
||||
#include <../RenderDll/Common/Shaders/Vertex.h>
|
||||
#include <Vertex.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
|
||||
// Description:
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "smartptr.h"
|
||||
#include <IFlares.h> // <> required for Interfuscator
|
||||
#include "VertexFormats.h"
|
||||
#include <RenderDll/Common/Shaders/Vertex.h>
|
||||
#include <Vertex.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/containers/map.h>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,8 +60,6 @@ ly_add_target(
|
||||
Legacy::CrySystem.XMLBinary
|
||||
Legacy::RemoteConsoleCore
|
||||
AZ::AzFramework
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::Cry3DEngine
|
||||
)
|
||||
|
||||
ly_add_source_properties(
|
||||
|
||||
@@ -14,14 +14,3 @@
|
||||
# NOTE: functions in cmake are global, therefore adding functions to this file
|
||||
# is being avoided to prevent overriding functions declared in other targets platfrom
|
||||
# specific cmake files
|
||||
|
||||
if (LY_MONOLITHIC_GAME) # Only Atom is supported in monolithic builds
|
||||
set(LY_BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
Legacy::CryRenderOther
|
||||
)
|
||||
else()
|
||||
set(LY_RUNTIME_DEPENDENCIES
|
||||
Legacy::CryRenderMetal
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -58,75 +58,6 @@
|
||||
extern CMTSafeHeap* g_pPakHeap;
|
||||
#if defined(AZ_PLATFORM_ANDROID)
|
||||
#include <AzCore/Android/Utils.h>
|
||||
#elif defined(AZ_PLATFORM_IOS)
|
||||
|
||||
#if defined(AZ_MONOLITHIC_BUILD)
|
||||
extern bool UIKitGetPrimaryPhysicalDisplayDimensions(int& o_widthPixels, int& o_heightPixels);
|
||||
#else
|
||||
|
||||
using NativeScreenType = UIScreen;
|
||||
using NativeWindowType = UIWindow;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool UIKitGetPrimaryPhysicalDisplayDimensions(int& o_widthPixels, int& o_heightPixels)
|
||||
{
|
||||
|
||||
NativeScreenType* nativeScreen = [NativeScreenType mainScreen];
|
||||
CGRect screenBounds = [nativeScreen bounds];
|
||||
CGFloat screenScale = [nativeScreen scale];
|
||||
o_widthPixels = static_cast<int>(screenBounds.size.width * screenScale);
|
||||
o_heightPixels = static_cast<int>(screenBounds.size.height * screenScale);
|
||||
|
||||
const bool isScreenLandscape = o_widthPixels > o_heightPixels;
|
||||
|
||||
UIInterfaceOrientation uiOrientation = UIInterfaceOrientationUnknown;
|
||||
#if defined(__IPHONE_13_0) || defined(__TVOS_13_0)
|
||||
if(@available(iOS 13.0, tvOS 13.0, *))
|
||||
{
|
||||
UIWindow* foundWindow = nil;
|
||||
|
||||
//Find the key window
|
||||
NSArray* windows = [[UIApplication sharedApplication] windows];
|
||||
for (UIWindow* window in windows)
|
||||
{
|
||||
if (window.isKeyWindow)
|
||||
{
|
||||
foundWindow = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Check if the key window is found
|
||||
if(foundWindow)
|
||||
{
|
||||
uiOrientation = foundWindow.windowScene.interfaceOrientation;
|
||||
}
|
||||
else
|
||||
{
|
||||
//If no key window is found create a temporary window in order to extract the orientation
|
||||
//This can happen as this function gets called before the renderer is initialized
|
||||
CGRect screenBounds = [[NativeScreenType mainScreen] bounds];
|
||||
UIWindow* tempWindow = [[NativeWindowType alloc] initWithFrame: screenBounds];
|
||||
uiOrientation = tempWindow.windowScene.interfaceOrientation;
|
||||
[tempWindow release];
|
||||
}
|
||||
}
|
||||
#else
|
||||
uiOrientation = UIApplication.sharedApplication.statusBarOrientation;
|
||||
#endif
|
||||
|
||||
const bool isInterfaceLandscape = UIInterfaceOrientationIsLandscape(uiOrientation);
|
||||
if (isScreenLandscape != isInterfaceLandscape)
|
||||
{
|
||||
const int width = o_widthPixels;
|
||||
o_widthPixels = o_heightPixels;
|
||||
o_heightPixels = width;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
extern int CryMemoryGetAllocatedSize();
|
||||
@@ -151,8 +82,6 @@ bool CSystem::GetPrimaryPhysicalDisplayDimensions([[maybe_unused]] int& o_widthP
|
||||
return true;
|
||||
#elif defined(AZ_PLATFORM_ANDROID)
|
||||
return AZ::Android::Utils::GetWindowSize(o_widthPixels, o_heightPixels);
|
||||
#elif defined(AZ_PLATFORM_IOS)
|
||||
return UIKitGetPrimaryPhysicalDisplayDimensions(o_widthPixels, o_heightPixels);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -8,11 +8,3 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
if(LY_MONOLITHIC_GAME) # only Atom is supported in monolithic
|
||||
list(APPEND LY_BUILD_DEPENDENCIES Legacy::CryRenderOther)
|
||||
else()
|
||||
set(LY_RUNTIME_DEPENDENCIES
|
||||
Legacy::CryRenderGL
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -8,15 +8,3 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
if (LY_MONOLITHIC_GAME) # only Atom is supported in monolithic
|
||||
set(LY_BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
Legacy::CryRenderOther
|
||||
)
|
||||
else()
|
||||
set(LY_BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Legacy::CryRenderGL
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -13,12 +13,6 @@ set(LY_TARGET_PROPERTIES
|
||||
BUILD_RPATH @executable_path/
|
||||
)
|
||||
|
||||
if(LY_MONOLITHIC_GAME) # only Atom is supported in monolithic builds
|
||||
list(APPEND LY_BUILD_DEPENDENCIES Legacy::CryRenderOther)
|
||||
else()
|
||||
set(LY_RUNTIME_DEPENDENCIES Legacy::CryRenderMetal)
|
||||
endif()
|
||||
|
||||
# Add resources and app icons to launchers
|
||||
list(APPEND candidate_paths ${project_real_path}/Resources/Platform/Mac)
|
||||
list(APPEND candidate_paths ${project_real_path}/Gem/Resources/Platform/Mac) # Legacy projects
|
||||
|
||||
@@ -9,11 +9,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(LY_BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Legacy::CryRenderD3D11
|
||||
)
|
||||
|
||||
set(ICON_FILE ${project_real_path}/Gem/Resources/GameSDK.ico)
|
||||
if(NOT EXISTS ${ICON_FILE})
|
||||
# Try the common LauncherUnified icon instead
|
||||
|
||||
@@ -14,13 +14,6 @@ set(LY_LINK_OPTIONS
|
||||
-ObjC
|
||||
)
|
||||
|
||||
if(LY_MONOLITHIC_GAME) # only Atom is supported in monolithic
|
||||
list(APPEND LY_BUILD_DEPENDENCIES Legacy::CryRenderOther)
|
||||
else()
|
||||
list(APPEND LY_BUILD_DEPENDENCIES CrySystem.Static)
|
||||
set(LY_RUNTIME_DEPENDENCIES Legacy::CryRenderMetal)
|
||||
endif()
|
||||
|
||||
# Add resources and app icons to launchers
|
||||
list(APPEND candidate_paths ${project_real_path}/Resources/Platform/iOS)
|
||||
list(APPEND candidate_paths ${project_real_path}/Gem/Resources/Platform/iOS) # Legacy projects
|
||||
|
||||
@@ -67,7 +67,6 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
|
||||
${game_gem_dependencies}
|
||||
Legacy::CrySystem
|
||||
Legacy::CryFont
|
||||
Legacy::Cry3DEngine
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
|
||||
@@ -97,7 +96,6 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
|
||||
${game_gem_dependencies}
|
||||
Legacy::CrySystem
|
||||
Legacy::CryFont
|
||||
Legacy::Cry3DEngine
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -106,13 +104,7 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
|
||||
set(game_runtime_dependencies
|
||||
Legacy::CrySystem
|
||||
Legacy::CryFont
|
||||
Legacy::Cry3DEngine
|
||||
)
|
||||
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED AND NOT LY_MONOLITHIC_GAME) # Only Atom is supported in monolithic builds
|
||||
set(server_runtime_dependencies
|
||||
Legacy::CryRenderNULL
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
#define MIN_RES 64
|
||||
#define MAX_RES 8192
|
||||
|
||||
CCustomResolutionDlg::CCustomResolutionDlg(int w, int h, QWidget* pParent /*=NULL*/)
|
||||
: QDialog(pParent)
|
||||
@@ -46,18 +47,17 @@ CCustomResolutionDlg::~CCustomResolutionDlg()
|
||||
|
||||
void CCustomResolutionDlg::OnInitDialog()
|
||||
{
|
||||
int maxRes = GetIEditor()->GetRenderer()->GetMaxSquareRasterDimension();
|
||||
m_ui->m_width->setRange(MIN_RES, maxRes);
|
||||
m_ui->m_width->setRange(MIN_RES, MAX_RES);
|
||||
m_ui->m_width->setValue(m_wDefault);
|
||||
|
||||
m_ui->m_height->setRange(MIN_RES, maxRes);
|
||||
m_ui->m_height->setRange(MIN_RES, MAX_RES);
|
||||
m_ui->m_height->setValue(m_hDefault);
|
||||
|
||||
QString maxDimensionString;
|
||||
QTextStream(&maxDimensionString)
|
||||
<< "Maximum Dimension: " << maxRes << Qt::endl
|
||||
<< "Maximum Dimension: " << MAX_RES << Qt::endl
|
||||
<< Qt::endl
|
||||
<< "Note: Dimensions over 4K may be" << Qt::endl
|
||||
<< "Note: Dimensions over 8K may be" << Qt::endl
|
||||
<< "unstable depending on hardware.";
|
||||
|
||||
m_ui->m_maxDimension->setText(maxDimensionString);
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
#include "GameEngine.h"
|
||||
#include "CryEditDoc.h"
|
||||
|
||||
// Cry3DEngine
|
||||
#include <Cry3DEngine/Environment/OceanEnvironmentBus.h>
|
||||
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_EnvironmentPanel.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
@@ -36,15 +32,6 @@ CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/)
|
||||
{
|
||||
XmlNodeRef node = GetIEditor()->GetDocument()->GetEnvironmentTemplate();
|
||||
|
||||
// is the feature toggle enabled?
|
||||
bool bHasOceanFeature = false;
|
||||
AZ::OceanFeatureToggleBus::BroadcastResult(bHasOceanFeature, &AZ::OceanFeatureToggleBus::Events::OceanComponentEnabled);
|
||||
if (bHasOceanFeature)
|
||||
{
|
||||
node->findChild("Ocean")->setAttr("hidden", true);
|
||||
node->findChild("OceanAnimation")->setAttr("hidden", true);
|
||||
}
|
||||
|
||||
m_onSetCallback = AZStd::bind(&CCryEditDoc::OnEnvironmentPropertyChanged, GetIEditor()->GetDocument(), AZStd::placeholders::_1);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -8,8 +8,3 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
set(LY_BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Legacy::CryRenderNULL
|
||||
)
|
||||
@@ -275,8 +275,6 @@ void CRenderViewport::resizeEvent(QResizeEvent* event)
|
||||
|
||||
gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height());
|
||||
|
||||
gEnv->pRenderer->EF_DisableTemporalEffects();
|
||||
|
||||
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
|
||||
{
|
||||
// We queue the window resize event because the render overlay may be hidden.
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
#include "Undo/Undo.h"
|
||||
#include "LyViewPaneNames.h"
|
||||
|
||||
// Cry3DEngine
|
||||
#include <Cry3DEngine/Environment/OceanEnvironmentBus.h>
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_TimeOfDayDialog.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
@@ -69,14 +66,6 @@ namespace TimeOfDayDetails
|
||||
return static_cast<float>(time.msecsSinceStartOfDay() / 60000) / 60.0;
|
||||
}
|
||||
|
||||
// Is the ocean component feature toggle enabled?
|
||||
AZ_INLINE static bool HasOceanFeatureToggle()
|
||||
{
|
||||
bool bHasOceanFeature = false;
|
||||
AZ::OceanFeatureToggleBus::BroadcastResult(bHasOceanFeature, &AZ::OceanFeatureToggleBus::Events::OceanComponentEnabled);
|
||||
return bHasOceanFeature;
|
||||
}
|
||||
|
||||
AZ_INLINE static bool SkipUserInterface(int value)
|
||||
{
|
||||
// Check for obsolete parameters that we still want to keep around to migrate legacy data to new data
|
||||
@@ -89,13 +78,6 @@ namespace TimeOfDayDetails
|
||||
(enumValue == ITimeOfDay::PARAM_TERRAIN_OCCL_MULTIPLIER) ||
|
||||
(enumValue == ITimeOfDay::PARAM_SUN_COLOR_MULTIPLIER);
|
||||
|
||||
// Only check the ocean parameters if the ocean feature (aka the Infinite Ocean Component)
|
||||
// has been enabled
|
||||
skipParameter |= HasOceanFeatureToggle() &&
|
||||
((enumValue == ITimeOfDay::PARAM_OCEANFOG_COLOR) ||
|
||||
(enumValue == ITimeOfDay::PARAM_OCEANFOG_COLOR_MULTIPLIER) ||
|
||||
(enumValue == ITimeOfDay::PARAM_OCEANFOG_DENSITY));
|
||||
|
||||
return skipParameter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,704 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// Copied utils functions from CryPhysics that are used by non-physics systems
|
||||
// This functions will be eventually removed, DO *NOT* use these functions
|
||||
// TO-DO: Re-implement users using new code
|
||||
// LY-109806
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Cry_Math.h"
|
||||
|
||||
namespace LegacyCryPhysicsUtils
|
||||
{
|
||||
namespace polynomial_tpl_IMPL
|
||||
{
|
||||
template<class ftype, int degree>
|
||||
class polynomial_tpl
|
||||
{
|
||||
public:
|
||||
explicit polynomial_tpl() { denom = (ftype)1; };
|
||||
explicit polynomial_tpl(ftype op) { zero(); data[degree] = op; }
|
||||
AZ_FORCE_INLINE polynomial_tpl& zero()
|
||||
{
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
data[i] = 0;
|
||||
}
|
||||
denom = (ftype)1;
|
||||
return *this;
|
||||
}
|
||||
polynomial_tpl(const polynomial_tpl<ftype, degree>& src) { *this = src; }
|
||||
polynomial_tpl& operator=(const polynomial_tpl<ftype, degree>& src)
|
||||
{
|
||||
denom = src.denom;
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
data[i] = src.data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template<int degree1>
|
||||
AZ_FORCE_INLINE polynomial_tpl& operator=(const polynomial_tpl<ftype, degree1>& src)
|
||||
{
|
||||
int i;
|
||||
denom = src.denom;
|
||||
for (i = 0; i <= min(degree, degree1); i++)
|
||||
{
|
||||
data[i] = src.data[i];
|
||||
}
|
||||
for (; i < degree; i++)
|
||||
{
|
||||
data[i] = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
AZ_FORCE_INLINE polynomial_tpl& set(ftype* pdata)
|
||||
{
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
data[degree - i] = pdata[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
AZ_FORCE_INLINE ftype& operator[](int idx) { return data[idx]; }
|
||||
|
||||
void calc_deriviative(polynomial_tpl<ftype, degree>& deriv, int curdegree = degree) const;
|
||||
|
||||
AZ_FORCE_INLINE polynomial_tpl& fixsign()
|
||||
{
|
||||
ftype sg = sgnnz(denom);
|
||||
denom *= sg;
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
data[i] *= sg;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
int findroots(ftype start, ftype end, ftype* proots, int nIters = 20, int curdegree = degree, bool noDegreeCheck = false) const;
|
||||
int nroots(ftype start, ftype end) const;
|
||||
|
||||
AZ_FORCE_INLINE ftype eval(ftype x) const
|
||||
{
|
||||
ftype res = 0;
|
||||
for (int i = degree; i >= 0; i--)
|
||||
{
|
||||
res = res * x + data[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
AZ_FORCE_INLINE ftype eval(ftype x, int subdegree) const
|
||||
{
|
||||
ftype res = data[subdegree];
|
||||
for (int i = subdegree - 1; i >= 0; i--)
|
||||
{
|
||||
res = res * x + data[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
AZ_FORCE_INLINE polynomial_tpl& operator+=(ftype op) { data[0] += op * denom; return *this; }
|
||||
AZ_FORCE_INLINE polynomial_tpl& operator-=(ftype op) { data[0] -= op * denom; return *this; }
|
||||
AZ_FORCE_INLINE polynomial_tpl operator*(ftype op) const
|
||||
{
|
||||
polynomial_tpl<ftype, degree> res;
|
||||
res.denom = denom;
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
res.data[i] = data[i] * op;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
AZ_FORCE_INLINE polynomial_tpl& operator*=(ftype op)
|
||||
{
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
data[i] *= op;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
AZ_FORCE_INLINE polynomial_tpl operator/(ftype op) const
|
||||
{
|
||||
polynomial_tpl<ftype, degree> res = *this;
|
||||
res.denom = denom * op;
|
||||
return res;
|
||||
}
|
||||
AZ_FORCE_INLINE polynomial_tpl& operator/=(ftype op) { denom *= op; return *this; }
|
||||
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree * 2> sqr() const { return *this * *this; }
|
||||
|
||||
ftype denom;
|
||||
ftype data[degree + 1];
|
||||
};
|
||||
|
||||
template <class ftype>
|
||||
struct tagPolyE
|
||||
{
|
||||
inline static ftype polye() { return (ftype)1E-10; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline float tagPolyE<float>::polye() { return 1e-6f; }
|
||||
|
||||
template <class ftype>
|
||||
inline ftype polye() { return tagPolyE<ftype>::polye(); }
|
||||
|
||||
// Don't use this macro; use AZStd::max instead. This is only here to make the template const arguments below readable
|
||||
// and because Visual Studio 2013 doesn't have a const_expr version of std::max
|
||||
#define deprecated_degmax(degree1, degree2) (((degree1) > (degree2)) ? (degree1) : (degree2))
|
||||
|
||||
template<class ftype, int degree>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator+(const polynomial_tpl<ftype, degree>& pn, ftype op)
|
||||
{
|
||||
polynomial_tpl<ftype, degree> res = pn;
|
||||
res.data[0] += op * res.denom;
|
||||
return res;
|
||||
}
|
||||
template<class ftype, int degree>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator-(const polynomial_tpl<ftype, degree>& pn, ftype op)
|
||||
{
|
||||
polynomial_tpl<ftype, degree> res = pn;
|
||||
res.data[0] -= op * res.denom;
|
||||
return res;
|
||||
}
|
||||
|
||||
template<class ftype, int degree>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator+(ftype op, const polynomial_tpl<ftype, degree>& pn)
|
||||
{
|
||||
polynomial_tpl<ftype, degree> res = pn;
|
||||
res.data[0] += op * res.denom;
|
||||
return res;
|
||||
}
|
||||
template<class ftype, int degree>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator-(ftype op, const polynomial_tpl<ftype, degree>& pn)
|
||||
{
|
||||
polynomial_tpl<ftype, degree> res = pn;
|
||||
res.data[0] -= op * res.denom;
|
||||
for (int i = 0; i <= degree; i++)
|
||||
{
|
||||
res.data[i] = -res.data[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
template<class ftype, int degree>
|
||||
polynomial_tpl<ftype, degree * 2> AZ_FORCE_INLINE psqr(const polynomial_tpl<ftype, degree>& op) { return op * op; }
|
||||
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> operator+(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
|
||||
{
|
||||
polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> res;
|
||||
int i;
|
||||
for (i = 0; i <= min(degree1, degree2); i++)
|
||||
{
|
||||
res.data[i] = op1.data[i] * op2.denom + op2.data[i] * op1.denom;
|
||||
}
|
||||
for (; i <= degree1; i++)
|
||||
{
|
||||
res.data[i] = op1.data[i] * op2.denom;
|
||||
}
|
||||
for (; i <= degree2; i++)
|
||||
{
|
||||
res.data[i] = op2.data[i] * op1.denom;
|
||||
}
|
||||
res.denom = op1.denom * op2.denom;
|
||||
return res;
|
||||
}
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> operator-(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
|
||||
{
|
||||
polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> res;
|
||||
int i;
|
||||
for (i = 0; i <= min(degree1, degree2); i++)
|
||||
{
|
||||
res.data[i] = op1.data[i] * op2.denom - op2.data[i] * op1.denom;
|
||||
}
|
||||
for (; i <= degree1; i++)
|
||||
{
|
||||
res.data[i] = op1.data[i] * op2.denom;
|
||||
}
|
||||
for (; i <= degree2; i++)
|
||||
{
|
||||
res.data[i] = op2.data[i] * op1.denom;
|
||||
}
|
||||
res.denom = op1.denom * op2.denom;
|
||||
return res;
|
||||
}
|
||||
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1>& operator+=(polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
|
||||
{
|
||||
for (int i = 0; i < min(degree1, degree2); i++)
|
||||
{
|
||||
op1.data[i] = op1.data[i] * op2.denom + op2.data[i] * op1.denom;
|
||||
}
|
||||
op1.denom *= op2.denom;
|
||||
return op1;
|
||||
}
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1>& operator-=(polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
|
||||
{
|
||||
for (int i = 0; i < min(degree1, degree2); i++)
|
||||
{
|
||||
op1.data[i] = op1.data[i] * op2.denom - op2.data[i] * op1.denom;
|
||||
}
|
||||
op1.denom *= op2.denom;
|
||||
return op1;
|
||||
}
|
||||
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1 + degree2> operator*(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
|
||||
{
|
||||
polynomial_tpl<ftype, degree1 + degree2> res;
|
||||
res.zero();
|
||||
int j;
|
||||
switch (degree1)
|
||||
{
|
||||
case 8:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[8 + j] += op1.data[8] * op2.data[j];
|
||||
}
|
||||
case 7:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[7 + j] += op1.data[7] * op2.data[j];
|
||||
}
|
||||
case 6:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[6 + j] += op1.data[6] * op2.data[j];
|
||||
}
|
||||
case 5:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[5 + j] += op1.data[5] * op2.data[j];
|
||||
}
|
||||
case 4:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[4 + j] += op1.data[4] * op2.data[j];
|
||||
}
|
||||
case 3:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[3 + j] += op1.data[3] * op2.data[j];
|
||||
}
|
||||
case 2:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[2 + j] += op1.data[2] * op2.data[j];
|
||||
}
|
||||
case 1:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[1 + j] += op1.data[1] * op2.data[j];
|
||||
}
|
||||
case 0:
|
||||
for (j = 0; j <= degree2; j++)
|
||||
{
|
||||
res.data[0 + j] += op1.data[0] * op2.data[j];
|
||||
}
|
||||
}
|
||||
res.denom = op1.denom * op2.denom;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
template <class ftype>
|
||||
AZ_FORCE_INLINE void polynomial_divide(const polynomial_tpl<ftype, 8>& num, const polynomial_tpl<ftype, 8>& den, polynomial_tpl<ftype, 8>& quot,
|
||||
polynomial_tpl<ftype, 8>& rem, int degree1, int degree2)
|
||||
{
|
||||
int i, j, k, l;
|
||||
ftype maxel;
|
||||
for (i = 0; i <= degree1; i++)
|
||||
{
|
||||
rem.data[i] = num.data[i];
|
||||
}
|
||||
for (i = 0; i <= degree1 - degree2; i++)
|
||||
{
|
||||
quot.data[i] = 0;
|
||||
}
|
||||
for (i = 1, maxel = fabs_tpl(num.data[0]); i <= degree1; i++)
|
||||
{
|
||||
maxel = max(maxel, num.data[i]);
|
||||
}
|
||||
for (maxel *= polye<ftype>(); degree1 >= 0 && fabs_tpl(num.data[degree1]) < maxel; degree1--)
|
||||
{
|
||||
;
|
||||
}
|
||||
for (i = 1, maxel = fabs_tpl(den.data[0]); i <= degree2; i++)
|
||||
{
|
||||
maxel = max(maxel, den.data[i]);
|
||||
}
|
||||
for (maxel *= polye<ftype>(); degree2 >= 0 && fabs_tpl(den.data[degree2]) < maxel; degree2--)
|
||||
{
|
||||
;
|
||||
}
|
||||
rem.denom = num.denom;
|
||||
quot.denom = (ftype)1;
|
||||
if (degree1 < 0 || degree2 < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (k = degree1 - degree2, l = degree1; l >= degree2; l--, k--)
|
||||
{
|
||||
quot.data[k] = rem.data[l] * den.denom;
|
||||
quot.denom *= den.data[degree2];
|
||||
for (i = degree1 - degree2; i > k; i--)
|
||||
{
|
||||
quot.data[i] *= den.data[degree2];
|
||||
}
|
||||
for (i = degree2 - 1, j = l - 1; i >= 0; i--, j--)
|
||||
{
|
||||
rem.data[j] = rem.data[j] * den.data[degree2] - den.data[i] * rem.data[l];
|
||||
}
|
||||
for (; j >= 0; j--)
|
||||
{
|
||||
rem.data[j] *= den.data[degree2];
|
||||
}
|
||||
rem.denom *= den.data[degree2];
|
||||
}
|
||||
}
|
||||
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1 - degree2> operator/(const polynomial_tpl<ftype, degree1>& num, const polynomial_tpl<ftype, degree2>& den)
|
||||
{
|
||||
polynomial_tpl<ftype, degree1 - degree2> quot;
|
||||
polynomial_tpl<ftype, degree1> rem;
|
||||
polynomial_divide((polynomial_tpl<ftype, 8>&)num, (polynomial_tpl<ftype, 8>&)den, (polynomial_tpl<ftype, 8>&)quot,
|
||||
(polynomial_tpl<ftype, 8>&)rem, degree1, degree2);
|
||||
return quot;
|
||||
}
|
||||
template <class ftype, int degree1, int degree2>
|
||||
AZ_FORCE_INLINE polynomial_tpl<ftype, degree2 - 1> operator%(const polynomial_tpl<ftype, degree1>& num, const polynomial_tpl<ftype, degree2>& den)
|
||||
{
|
||||
polynomial_tpl<ftype, degree1 - degree2> quot;
|
||||
polynomial_tpl<ftype, degree1> rem;
|
||||
polynomial_divide((polynomial_tpl<ftype, 8>&)num, (polynomial_tpl<ftype, 8>&)den, (polynomial_tpl<ftype, 8>&)quot,
|
||||
(polynomial_tpl<ftype, 8>&)rem, degree1, degree2);
|
||||
return (polynomial_tpl<ftype, degree2 - 1>&)rem;
|
||||
}
|
||||
|
||||
template <class ftype, int degree>
|
||||
AZ_FORCE_INLINE void polynomial_tpl<ftype, degree>::calc_deriviative(polynomial_tpl<ftype, degree>& deriv, int curdegree) const
|
||||
{
|
||||
for (int i = 0; i < curdegree; i++)
|
||||
{
|
||||
deriv.data[i] = data[i + 1] * (i + 1);
|
||||
}
|
||||
deriv.denom = denom;
|
||||
}
|
||||
|
||||
template<typename to_t, typename from_t>
|
||||
to_t* convert_type(from_t* input)
|
||||
{
|
||||
typedef union
|
||||
{
|
||||
to_t* to;
|
||||
from_t* from;
|
||||
} convert_union;
|
||||
convert_union u;
|
||||
u.from = input;
|
||||
return u.to;
|
||||
}
|
||||
|
||||
template <class ftype, int degree>
|
||||
AZ_FORCE_INLINE int polynomial_tpl<ftype, degree>::nroots(ftype start, ftype end) const
|
||||
{
|
||||
polynomial_tpl<ftype, degree> f[degree + 1];
|
||||
int i, j, sg_a, sg_b;
|
||||
ftype val, prevval;
|
||||
|
||||
calc_deriviative(f[0]);
|
||||
polynomial_divide(*convert_type<polynomial_tpl<ftype, 8> >(this), *convert_type< polynomial_tpl<ftype, 8> >(&f[0]), *convert_type<polynomial_tpl<ftype, 8> >(&f[degree]),
|
||||
*convert_type<polynomial_tpl<ftype, 8> >(&f[1]), degree, degree - 1);
|
||||
f[1].denom = -f[1].denom;
|
||||
for (i = 2; i < degree; i++)
|
||||
{
|
||||
polynomial_divide(*convert_type<polynomial_tpl<ftype, 8> >(&f[i - 2]), *convert_type<polynomial_tpl<ftype, 8> >(&f[i - 1]), *convert_type<polynomial_tpl<ftype, 8> >(&f[degree]),
|
||||
*convert_type<polynomial_tpl<ftype, 8> >(&f[i]), degree + 1 - i, degree - i);
|
||||
f[i].denom = -f[i].denom;
|
||||
if (fabs_tpl(f[i].denom) > (ftype)1E10)
|
||||
{
|
||||
for (j = 0; j <= degree - 1 - i; j++)
|
||||
{
|
||||
f[i].data[j] *= (ftype)1E-10;
|
||||
}
|
||||
f[i].denom *= (ftype)1E-10;
|
||||
}
|
||||
}
|
||||
|
||||
prevval = eval(start) * denom;
|
||||
for (i = sg_a = 0; i < degree; i++, prevval = val)
|
||||
{
|
||||
val = f[i].eval(start, degree - 1 - i) * f[i].denom;
|
||||
sg_a += isneg(val * prevval);
|
||||
}
|
||||
|
||||
prevval = eval(end) * denom;
|
||||
for (i = sg_b = 0; i < degree; i++, prevval = val)
|
||||
{
|
||||
val = f[i].eval(end, degree - 1 - i) * f[i].denom;
|
||||
sg_b += isneg(val * prevval);
|
||||
}
|
||||
|
||||
return fabs_tpl(sg_a - sg_b);
|
||||
}
|
||||
|
||||
template<class ftype>
|
||||
AZ_FORCE_INLINE ftype cubert_tpl(ftype x) { return fabs_tpl(x) > (ftype)1E-20 ? exp_tpl(log_tpl(fabs_tpl(x)) * (ftype)(1.0 / 3)) * sgnnz(x) : x; }
|
||||
template<class ftype>
|
||||
AZ_FORCE_INLINE ftype pow_tpl(ftype x, ftype pow) { return fabs_tpl(x) > (ftype)1E-20 ? exp_tpl(log_tpl(fabs_tpl(x)) * pow) * sgnnz(x) : x; }
|
||||
template<class ftype>
|
||||
AZ_FORCE_INLINE void swap(ftype* ptr, int i, int j) { ftype t = ptr[i]; ptr[i] = ptr[j]; ptr[j] = t; }
|
||||
|
||||
template <class ftype, int maxdegree>
|
||||
int polynomial_tpl<ftype, maxdegree>::findroots(ftype start, ftype end, ftype* proots, [[maybe_unused]] int nIters, int degree, bool noDegreeCheck) const
|
||||
{
|
||||
AZ_UNUSED(nIters);
|
||||
int i, j, nRoots = 0;
|
||||
ftype maxel;
|
||||
if (!noDegreeCheck)
|
||||
{
|
||||
for (i = 1, maxel = fabs_tpl(data[0]); i <= degree; i++)
|
||||
{
|
||||
maxel = max(maxel, data[i]);
|
||||
}
|
||||
for (maxel *= polye<ftype>(); degree > 0 && fabs_tpl(data[degree]) <= maxel; degree--)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (maxdegree >= 1)
|
||||
{
|
||||
if (degree == 1)
|
||||
{
|
||||
proots[0] = data[0] / data[1];
|
||||
nRoots = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (maxdegree >= 2)
|
||||
{
|
||||
if (degree == 2)
|
||||
{
|
||||
ftype a, b, c, d, bound[2], sg;
|
||||
|
||||
a = data[2];
|
||||
b = data[1];
|
||||
c = data[0];
|
||||
d = aznumeric_cast<ftype>(sgnnz(a));
|
||||
a *= d;
|
||||
b *= d;
|
||||
c *= d;
|
||||
d = b * b - a * c * 4;
|
||||
bound[0] = start * a * 2 + b;
|
||||
bound[1] = end * a * 2 + b;
|
||||
sg = aznumeric_cast<ftype>((sgnnz(bound[0] * bound[1]) + 1) >> 1);
|
||||
bound[0] *= bound[0];
|
||||
bound[1] *= bound[1];
|
||||
bound[isneg(fabs_tpl(bound[1]) - fabs_tpl(bound[0]))] *= sg;
|
||||
|
||||
if (isnonneg(d) & inrange(d, bound[0], bound[1]))
|
||||
{
|
||||
d = sqrt_tpl(d);
|
||||
a = (ftype)0.5 / a;
|
||||
proots[nRoots] = (-b - d) * a;
|
||||
nRoots += inrange(proots[nRoots], start, end);
|
||||
proots[nRoots] = (-b + d) * a;
|
||||
nRoots += inrange(proots[nRoots], start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (maxdegree >= 3)
|
||||
{
|
||||
if (degree == 3)
|
||||
{
|
||||
ftype t, a, b, c, a3, p, q, Q, Qr, Ar, Ai, phi;
|
||||
|
||||
t = (ftype)1.0 / data[3];
|
||||
a = data[2] * t;
|
||||
b = data[1] * t;
|
||||
c = data[0] * t;
|
||||
a3 = a * (ftype)(1.0 / 3);
|
||||
p = b - a * a3;
|
||||
q = (a3 * b - c) * (ftype)0.5 - cube(a3);
|
||||
Q = cube(p * (ftype)(1.0 / 3)) + q * q;
|
||||
Qr = sqrt_tpl(fabs_tpl(Q));
|
||||
|
||||
if (Q > 0)
|
||||
{
|
||||
proots[0] = cubert_tpl(q + Qr) + cubert_tpl(q - Qr) - a3;
|
||||
nRoots = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
phi = atan2_tpl(Qr, q) * (ftype)(1.0 / 3);
|
||||
t = pow_tpl(Qr * Qr + q * q, (ftype)(1.0 / 6));
|
||||
Ar = t * cos_tpl(phi);
|
||||
Ai = t * sin_tpl(phi);
|
||||
proots[0] = 2 * Ar - a3;
|
||||
proots[1] = aznumeric_cast<ftype>(-Ar + Ai * sqrt3 - a3);
|
||||
proots[2] = aznumeric_cast<ftype>(-Ar - Ai * sqrt3 - a3);
|
||||
i = idxmax3(proots);
|
||||
swap(proots, i, 2);
|
||||
i = isneg(proots[0] - proots[1]);
|
||||
swap(proots, i, 1);
|
||||
nRoots = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (maxdegree >= 4)
|
||||
{
|
||||
if (degree == 4)
|
||||
{
|
||||
ftype t, a3, a2, a1, a0, y, R, D, E, subroots[3];
|
||||
const ftype e = (ftype)1E-9;
|
||||
|
||||
t = (ftype)1.0 / data[4];
|
||||
a3 = data[3] * t;
|
||||
a2 = data[2] * t;
|
||||
a1 = data[1] * t;
|
||||
a0 = data[0] * t;
|
||||
polynomial_tpl<ftype, 3> p3aux;
|
||||
ftype kp3aux[] = { 1, -a2, a1 * a3 - 4 * a0, 4 * a2 * a0 - a1 * a1 - a3 * a3 * a0 };
|
||||
p3aux.set(kp3aux);
|
||||
if (!p3aux.findroots((ftype)-1E20, (ftype)1E20, subroots))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
R = a3 * a3 * (ftype)0.25 - a2 + (y = subroots[0]);
|
||||
|
||||
if (R > -e)
|
||||
{
|
||||
if (R < e)
|
||||
{
|
||||
D = E = a3 * a3 * (ftype)(3.0 / 4) - 2 * a2;
|
||||
t = y * y - 4 * a0;
|
||||
if (t < -e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
t = 2 * sqrt_tpl(max((ftype)0, t));
|
||||
}
|
||||
else
|
||||
{
|
||||
R = sqrt_tpl(max((ftype)0, R));
|
||||
D = E = a3 * a3 * (ftype)(3.0 / 4) - R * R - 2 * a2;
|
||||
t = (4 * a3 * a2 - 8 * a1 - a3 * a3 * a3) / R * (ftype)0.25;
|
||||
}
|
||||
if (D + t > -e)
|
||||
{
|
||||
D = sqrt_tpl(max((ftype)0, D + t));
|
||||
proots[nRoots++] = a3 * (ftype)-0.25 + (R - D) * (ftype)0.5;
|
||||
proots[nRoots++] = a3 * (ftype)-0.25 + (R + D) * (ftype)0.5;
|
||||
}
|
||||
if (E - t > -e)
|
||||
{
|
||||
E = sqrt_tpl(max((ftype)0, E - t));
|
||||
proots[nRoots++] = a3 * (ftype)-0.25 - (R + E) * (ftype)0.5;
|
||||
proots[nRoots++] = a3 * (ftype)-0.25 - (R - E) * (ftype)0.5;
|
||||
}
|
||||
if (nRoots == 4)
|
||||
{
|
||||
i = idxmax3(proots);
|
||||
if (proots[3] < proots[i])
|
||||
{
|
||||
swap(proots, i, 3);
|
||||
}
|
||||
i = idxmax3(proots);
|
||||
swap(proots, i, 2);
|
||||
i = isneg(proots[0] - proots[1]);
|
||||
swap(proots, i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (maxdegree > 4)
|
||||
{
|
||||
if (degree > 4)
|
||||
{
|
||||
ftype roots[maxdegree + 1], prevroot, val, prevval[2], curval, bound[2], middle;
|
||||
polynomial_tpl<ftype, maxdegree> deriv;
|
||||
int nExtremes, iter, iBound;
|
||||
calc_deriviative(deriv);
|
||||
|
||||
// find a subset of deriviative extremes between start and end
|
||||
for (nExtremes = deriv.findroots(start, end, roots + 1, nIters, degree - 1) + 1; nExtremes > 1 && roots[nExtremes - 1] > end; nExtremes--)
|
||||
{
|
||||
;
|
||||
}
|
||||
for (i = 1; i < nExtremes && roots[i] < start; i++)
|
||||
{
|
||||
;
|
||||
}
|
||||
roots[i - 1] = start;
|
||||
PREFAST_ASSUME(nExtremes < maxdegree + 1);
|
||||
roots[nExtremes++] = end;
|
||||
|
||||
for (prevroot = start, prevval[0] = eval(start, degree), nRoots = 0; i < nExtremes; prevval[0] = val, prevroot = roots[i++])
|
||||
{
|
||||
val = eval(roots[i], degree);
|
||||
if (val * prevval[0] < 0)
|
||||
{
|
||||
// we have exactly one root between prevroot and roots[i]
|
||||
bound[0] = prevroot;
|
||||
bound[1] = roots[i];
|
||||
iter = 0;
|
||||
do
|
||||
{
|
||||
middle = (bound[0] + bound[1]) * (ftype)0.5;
|
||||
curval = eval(middle, degree);
|
||||
iBound = isneg(prevval[0] * curval);
|
||||
bound[iBound] = middle;
|
||||
prevval[iBound] = curval;
|
||||
} while (++iter < nIters);
|
||||
proots[nRoots++] = middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nRoots && proots[i] < start; i++)
|
||||
{
|
||||
;
|
||||
}
|
||||
for (; nRoots > i&& proots[nRoots - 1] > end; nRoots--)
|
||||
{
|
||||
;
|
||||
}
|
||||
for (j = i; j < nRoots; j++)
|
||||
{
|
||||
proots[j - i] = proots[j];
|
||||
}
|
||||
|
||||
return nRoots - i;
|
||||
}
|
||||
} // namespace polynomial_tpl_IMPL
|
||||
template<class ftype, int degree>
|
||||
using polynomial_tpl = polynomial_tpl_IMPL::polynomial_tpl<ftype, degree>;
|
||||
|
||||
typedef polynomial_tpl<real, 3> P3;
|
||||
typedef polynomial_tpl<real, 2> P2;
|
||||
typedef polynomial_tpl<real, 1> P1;
|
||||
typedef polynomial_tpl<float, 3> P3f;
|
||||
typedef polynomial_tpl<float, 2> P2f;
|
||||
typedef polynomial_tpl<float, 1> P1f;
|
||||
} // namespace LegacyCryPhysicsUtils
|
||||
@@ -38,7 +38,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#define NO_BUFFER_OVERRUN PREFAST_SUPPRESS_WARNING(6385 6386)
|
||||
#include <ISplines.h>
|
||||
#include "../Cry3DEngine/Cry_LegacyPhysUtils.h"
|
||||
#include "Cry_LegacyPhysUtils.h"
|
||||
|
||||
namespace CurveEditorHelpers
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#define INDEX_NOT_OUT_OF_RANGE PREFAST_SUPPRESS_WARNING(6201)
|
||||
#define NO_BUFFER_OVERRUN PREFAST_SUPPRESS_WARNING(6385 6386)
|
||||
#include "../Cry3DEngine/Cry_LegacyPhysUtils.h"
|
||||
#include "Cry_LegacyPhysUtils.h"
|
||||
|
||||
#pragma warning (pop)
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ ly_add_target(
|
||||
${additional_dependencies}
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetBuilder
|
||||
Legacy::RC
|
||||
)
|
||||
|
||||
# Aggregates all combined AssetBuilders into a single LY_ASSET_BUILDERS #define
|
||||
|
||||
@@ -16,13 +16,9 @@ add_subdirectory(AzTestRunner)
|
||||
add_subdirectory(CrashHandler)
|
||||
add_subdirectory(CryCommonTools)
|
||||
add_subdirectory(CryXML)
|
||||
add_subdirectory(HLSLCrossCompiler)
|
||||
add_subdirectory(HLSLCrossCompilerMETAL)
|
||||
add_subdirectory(News)
|
||||
add_subdirectory(PythonBindingsExample)
|
||||
add_subdirectory(RC)
|
||||
add_subdirectory(RemoteConsole)
|
||||
add_subdirectory(ShaderCacheGen)
|
||||
add_subdirectory(DeltaCataloger)
|
||||
add_subdirectory(SerializeContextTools)
|
||||
add_subdirectory(AssetBundler)
|
||||
|
||||
@@ -23,7 +23,6 @@ ly_add_target(
|
||||
PUBLIC
|
||||
AZ::AzCore
|
||||
Legacy::CryCommon
|
||||
Legacy::CryRender.Headers
|
||||
Gem::ImGui.Static
|
||||
)
|
||||
|
||||
|
||||
@@ -54,8 +54,7 @@ namespace AssetMemoryAnalyzer
|
||||
namespace AssetMemoryAnalyzer
|
||||
{
|
||||
class AnalyzerImpl :
|
||||
public AZ::Debug::MemoryDrillerBus::Handler,
|
||||
public Render::Debug::VRAMDrillerBus::Handler
|
||||
public AZ::Debug::MemoryDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(AnalyzerImpl, "{E460E4DE-2160-4171-A4B6-3C2DB6692C32}");
|
||||
@@ -73,13 +72,6 @@ namespace AssetMemoryAnalyzer
|
||||
void ReallocateAllocation(AZ::IAllocator* allocator, void* prevAddress, void* newAddress, size_t newByteSize, size_t newAlignment) override;
|
||||
void ResizeAllocation(AZ::IAllocator* allocator, void* address, size_t newSize) override;
|
||||
|
||||
// VRAMDrillerBus
|
||||
void RegisterCategory(Render::Debug::VRAMAllocationCategory category, const char* categoryName, const Render::Debug::VRAMSubCategoryType& subcategories) override;
|
||||
void UnregisterAllCategories() override;
|
||||
void RegisterAllocation(void* address, size_t byteSize, const char* allocationName, Render::Debug::VRAMAllocationCategory category, Render::Debug::VRAMAllocationSubcategory subcategories) override;
|
||||
void UnregisterAllocation(void* address) override;
|
||||
void GetCurrentVRAMStats(Render::Debug::VRAMAllocationCategory category, Render::Debug::VRAMAllocationSubcategory subcategory, AZStd::string& categoryName, AZStd::string& subcategoryName, size_t& numberBytesAllocated, size_t& numberAllocations) override;
|
||||
|
||||
AZStd::shared_ptr<FrameAnalysis> GetAnalysis();
|
||||
|
||||
private:
|
||||
@@ -112,13 +104,11 @@ namespace AssetMemoryAnalyzer
|
||||
m_assetTracking(&m_assetTree, &m_allocationTable)
|
||||
{
|
||||
AZ::Debug::MemoryDrillerBus::Handler::BusConnect();
|
||||
Render::Debug::VRAMDrillerBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
AnalyzerImpl::~AnalyzerImpl()
|
||||
{
|
||||
AZ::Debug::MemoryDrillerBus::Handler::BusDisconnect();
|
||||
Render::Debug::VRAMDrillerBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void AnalyzerImpl::RegisterAllocator(AZ::IAllocator* allocator)
|
||||
@@ -181,44 +171,6 @@ namespace AssetMemoryAnalyzer
|
||||
m_allocationTable.ResizeAllocation(address, newSize);
|
||||
}
|
||||
|
||||
void AnalyzerImpl::RegisterCategory(Render::Debug::VRAMAllocationCategory category, const char* categoryName, const Render::Debug::VRAMSubCategoryType& subcategories)
|
||||
{
|
||||
AZ_UNUSED(category);
|
||||
AZ_UNUSED(categoryName);
|
||||
AZ_UNUSED(subcategories);
|
||||
}
|
||||
|
||||
void AnalyzerImpl::UnregisterAllCategories()
|
||||
{
|
||||
}
|
||||
|
||||
void AnalyzerImpl::RegisterAllocation(void* address, size_t byteSize, const char* allocationName, Render::Debug::VRAMAllocationCategory category, Render::Debug::VRAMAllocationSubcategory subcategories)
|
||||
{
|
||||
// Bit-flip address so that it won't collide with heap allocations (calls to the VRAM driller tend to use the same pointers from the heap objects that own the VRAM)
|
||||
address = (void*)~(size_t)address;
|
||||
|
||||
Data::AllocationData::CategoryInfo categoryInfo;
|
||||
categoryInfo.m_vramInfo.m_category = category;
|
||||
categoryInfo.m_vramInfo.m_subcategories = subcategories;
|
||||
RegisterAllocationCommon(address, byteSize, allocationName, 0, categoryInfo, Data::AllocationCategories::VRAM);
|
||||
}
|
||||
|
||||
void AnalyzerImpl::UnregisterAllocation(void* address)
|
||||
{
|
||||
address = (void*)~(size_t)address;
|
||||
UnregisterAllocationCommon(address);
|
||||
}
|
||||
|
||||
void AnalyzerImpl::GetCurrentVRAMStats(Render::Debug::VRAMAllocationCategory category, Render::Debug::VRAMAllocationSubcategory subcategory, AZStd::string& categoryName, AZStd::string& subcategoryName, size_t& numberBytesAllocated, size_t& numberAllocations)
|
||||
{
|
||||
AZ_UNUSED(category);
|
||||
AZ_UNUSED(subcategory);
|
||||
AZ_UNUSED(categoryName);
|
||||
AZ_UNUSED(subcategoryName);
|
||||
AZ_UNUSED(numberBytesAllocated);
|
||||
AZ_UNUSED(numberAllocations);
|
||||
}
|
||||
|
||||
void AnalyzerImpl::RegisterAllocationCommon(void* address, size_t byteSize, const char* fileName, int lineNum, Data::AllocationData::CategoryInfo categoryInfo, Data::AllocationCategories category)
|
||||
{
|
||||
if (m_performingAnalysis)
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/AssetTrackingTypes.h>
|
||||
#include <Common/Memory/VRAMDriller.h>
|
||||
|
||||
namespace AssetMemoryAnalyzer
|
||||
{
|
||||
@@ -48,13 +47,6 @@ namespace AssetMemoryAnalyzer
|
||||
AZ::IAllocator* m_allocator;
|
||||
}
|
||||
m_heapInfo;
|
||||
|
||||
struct
|
||||
{
|
||||
Render::Debug::VRAMAllocationCategory m_category;
|
||||
Render::Debug::VRAMAllocationSubcategory m_subcategories;
|
||||
}
|
||||
m_vramInfo;
|
||||
};
|
||||
|
||||
CodePoint* m_codePoint;
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include "AssetMemoryAnalyzer_precompiled.h"
|
||||
|
||||
#include <AzCore/Debug/AssetTrackingTypesImpl.h>
|
||||
#include <AzCore/IO/SystemFile.h> // For AZ_MAX_PATH_LEN
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <Common/Memory/VRAMDrillerBus.h>
|
||||
|
||||
#include "AssetMemoryAnalyzerSystemComponent.h"
|
||||
|
||||
@@ -186,9 +186,6 @@ namespace AssetMemoryAnalyzer
|
||||
|
||||
void AssetMemoryAnalyzerSystemComponent::Init()
|
||||
{
|
||||
static_assert(AZ_ARRAY_SIZE(VRAM_CATEGORIES) == Render::Debug::VRAMAllocationCategory::VRAM_CATEGORY_NUMBER_CATEGORIES, "VRAMAllocationCategory has changed length! Fix VRAM_CATEGORIES to match.");
|
||||
static_assert(AZ_ARRAY_SIZE(VRAM_SUBCATEGORIES) == Render::Debug::VRAMAllocationSubcategory::VRAM_SUBCATEGORY_NUMBER_SUBCATEGORIES, "VRAMAllocationSubcategory has changed length! Fix VRAM_SUBCATEGORIES to match.");
|
||||
|
||||
m_impl->m_debugImGUI.Init(this);
|
||||
m_impl->m_exportCSV.Init(this);
|
||||
m_impl->m_exportJSON.Init(this);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "FormatUtils.h"
|
||||
|
||||
#include <AzCore/Debug/AssetTracking.h>
|
||||
#include <Common/Memory/VRAMDrillerBus.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/JSON/filewritestream.h>
|
||||
#include <AzCore/JSON/rapidjson.h>
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace AZ
|
||||
void OnRenderTick() override;
|
||||
void OnViewportSizeChanged(AzFramework::WindowSize size) override;
|
||||
|
||||
DebugConsole m_debugConsole;
|
||||
bool m_initialized = false;
|
||||
};
|
||||
} // namespace LYIntegration
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <RC/ResourceCompilerScene/Common/ExportContextGlobal.h>
|
||||
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
|
||||
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
|
||||
#include <SceneAPI/SceneCore/Utilities/CoordinateSystemConverter.h>
|
||||
@@ -21,6 +20,16 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RC
|
||||
{
|
||||
enum class Phase
|
||||
{
|
||||
Construction, // The target is created.
|
||||
Filling, // Data is added to the target.
|
||||
Finalizing // Work on the target has completed.
|
||||
};
|
||||
}
|
||||
|
||||
namespace SceneAPI
|
||||
{
|
||||
namespace Events
|
||||
|
||||
@@ -399,6 +399,11 @@ namespace LmbrCentral
|
||||
const ShapeDrawParams& shapeDrawParams, const PolygonPrismMesh& polygonPrismMesh,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
if (!gEnv->pRenderer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto geomRenderer = gEnv->pRenderer->GetIRenderAuxGeom();
|
||||
|
||||
const SAuxGeomRenderFlags oldFlags = geomRenderer->GetRenderFlags();
|
||||
|
||||
@@ -108,7 +108,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
AZ::SceneData
|
||||
Legacy::CryCommon
|
||||
Legacy::CryCommonTools
|
||||
Legacy::Cry3DEngine.CGF.Static
|
||||
Gem::LmbrCentral
|
||||
Gem::PhysX.NumericalMethods
|
||||
Gem::PhysX.Static
|
||||
|
||||
-1
@@ -15,7 +15,6 @@
|
||||
#include <SceneAPI/SceneCore/Components/GenerationComponent.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Scene.h>
|
||||
|
||||
#include <RC/ResourceCompilerScene/Common/ExportContextGlobal.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
|
||||
AssetProcessor
|
||||
AutomatedTesting.GameLauncher
|
||||
AutomatedTesting.Assets
|
||||
Legacy::CryRenderNULL
|
||||
COMPONENT TestTools
|
||||
)
|
||||
|
||||
@@ -55,7 +54,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
|
||||
AssetProcessor
|
||||
AutomatedTesting.GameLauncher
|
||||
AutomatedTesting.Assets
|
||||
Legacy::CryRenderNULL
|
||||
COMPONENT TestTools
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -30,6 +30,5 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
|
||||
# AssetProcessor
|
||||
# AutomatedTesting.GameLauncher
|
||||
# AutomatedTesting.Assets
|
||||
# Legacy::CryRenderNULL
|
||||
# )
|
||||
endif()
|
||||
@@ -355,7 +355,6 @@ function(ly_add_editor_python_test)
|
||||
RUNTIME_DEPENDENCIES
|
||||
${ly_add_editor_python_test_RUNTIME_DEPENDENCIES}
|
||||
Gem::EditorPythonBindings.Editor
|
||||
Legacy::CryRenderNULL
|
||||
Legacy::Editor
|
||||
TEST_SUITE ${ly_add_editor_python_test_TEST_SUITE}
|
||||
LABELS FRAMEWORK_pytest
|
||||
|
||||
Reference in New Issue
Block a user