Merge branch 'development' into cmake/warn_virtual

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Legacy/CryCommon/IConsole.h
#	Code/Legacy/CrySystem/LocalizedStringManager.h
#	Code/Legacy/CrySystem/XConsole.h
#	Code/Legacy/CrySystem/XConsoleVariable.h
#	Code/Legacy/CrySystem/XML/XmlUtils.cpp
#	cmake/Platform/Common/Clang/Configurations_clang.cmake
This commit is contained in:
Esteban Papp
2021-09-07 18:42:40 -07:00
228 changed files with 1196 additions and 16357 deletions
@@ -17,15 +17,15 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
return()
endif()
# Enable after installing NodeJS and CDK on jenkins Windows AMI.
ly_add_pytest(
NAME AutomatedTesting::AWSTests
TEST_SUITE periodic
TEST_SUITE awsi
TEST_SERIAL
PATH ${CMAKE_CURRENT_LIST_DIR}/${PAL_PLATFORM_NAME}/
RUNTIME_DEPENDENCIES
Legacy::Editor
AZ::AssetProcessor
AutomatedTesting.GameLauncher
AutomatedTesting.Assets
COMPONENT
AWS
@@ -133,7 +133,7 @@ def update_kinesis_analytics_application_status(aws_metrics_utils: pytest.fixtur
aws_metrics_utils.stop_kinesis_data_analytics_application(
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsApplicationName'))
@pytest.mark.SUITE_periodic
@pytest.mark.SUITE_awsi
@pytest.mark.usefixtures('automatic_process_killer')
@pytest.mark.usefixtures('aws_credentials')
@pytest.mark.usefixtures('resource_mappings')
@@ -21,7 +21,7 @@ AWS_CLIENT_AUTH_FEATURE_NAME = 'AWSClientAuth'
logger = logging.getLogger(__name__)
@pytest.mark.SUITE_periodic
@pytest.mark.SUITE_awsi
@pytest.mark.usefixtures('asset_processor')
@pytest.mark.usefixtures('automatic_process_killer')
@pytest.mark.usefixtures('aws_utils')
@@ -74,7 +74,7 @@ def write_test_data_to_dynamodb_table(resource_mappings: pytest.fixture, aws_uti
raise
@pytest.mark.SUITE_periodic
@pytest.mark.SUITE_awsi
@pytest.mark.usefixtures('automatic_process_killer')
@pytest.mark.usefixtures('asset_processor')
@pytest.mark.parametrize('feature_name', [AWS_CORE_FEATURE_NAME])
+3 -12
View File
@@ -236,10 +236,7 @@ QString CEditorCommandManager::Execute(const AZStd::string& module, const AZStd:
}
else
{
QString errMsg;
errMsg = QStringLiteral("Error: Trying to execute a unknown command, '%1'!").arg(fullName.c_str());
CryLogAlways(errMsg.toUtf8().data());
CryLogAlways("Error: Trying to execute a unknown command, '%s'!", fullName.c_str());
}
return "";
@@ -272,10 +269,7 @@ QString CEditorCommandManager::Execute(const AZStd::string& cmdLine)
}
else
{
QString errMsg;
errMsg = QStringLiteral("Error: Trying to execute a unknown command, '%1'!").arg(cmdLine.c_str());
CryLogAlways(errMsg.toUtf8().data());
CryLogAlways("Error: Trying to execute a unknown command, '%s'!", cmdLine.c_str());
}
return "";
@@ -294,10 +288,7 @@ void CEditorCommandManager::Execute(int commandId)
}
else
{
QString errMsg;
errMsg = QStringLiteral("Error: Trying to execute a unknown command of ID '%1'!").arg(commandId);
CryLogAlways(errMsg.toUtf8().data());
CryLogAlways("Error: Trying to execute a unknown command of ID '%d'!", commandId);
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ void CConsoleDialog::SetInfoText(const char* text)
{
if (gEnv && gEnv->pLog) // before log system was initialized
{
CryLogAlways(text);
CryLogAlways("%s", text);
}
}
+3 -7
View File
@@ -26,9 +26,6 @@
#include <AzQtComponents/Components/Widgets/ScrollBar.h>
#include <AzQtComponents/Components/Widgets/SliderCombo.h>
// CryCommon
#include <CryCommon/SFunctor.h>
// Editor
#include "QtViewPaneManager.h"
#include "Core/QtEditorApplication.h"
@@ -392,7 +389,7 @@ void CConsoleSCB::RegisterViewClass()
opts.showInMenu = true;
opts.builtInActionId = ID_VIEW_CONSOLEWINDOW;
opts.shortcut = QKeySequence(Qt::Key_QuoteLeft);
AzToolsFramework::RegisterViewPane<CConsoleSCB>(LyViewPane::Console, LyViewPane::CategoryTools, opts);
}
@@ -606,8 +603,7 @@ static CVarBlock* VarBlockFromConsoleVars()
// Add our on change handler so we can update the CVariable created for
// the matching ICVar that has been modified
SFunctor onChange;
onChange.Set(OnVariableUpdated, i, pCVar);
AZStd::function<void()> onChange = [row=i,pCVar=pCVar]() { OnVariableUpdated(row,pCVar); };
pCVar->AddOnChangeFunctor(onChange);
pVariable->SetDescription(pCVar->GetHelp());
@@ -929,7 +925,7 @@ QWidget* ConsoleVariableItemDelegate::createEditor(QWidget* parent, const QStyle
return editor;
}
}
// If we get here, value being edited is a string, so use our styled line
// edit widget
AzQtComponents::StyledLineEdit* lineEdit = new AzQtComponents::StyledLineEdit(parent);
-10
View File
@@ -1887,16 +1887,6 @@ void CCryEditDoc::SetDocumentReady(bool bReady)
m_bDocumentReady = bReady;
}
void CCryEditDoc::GetMemoryUsage(ICrySizer* pSizer) const
{
{
SIZER_COMPONENT_NAME(pSizer, "UndoManager(estimate)");
GetIEditor()->GetUndoManager()->GetMemoryUsage(pSizer);
}
pSizer->Add(*this);
}
void CCryEditDoc::RegisterConsoleVariables()
{
doc_validate_surface_types = gEnv->pConsole->GetCVar("doc_validate_surface_types");
-2
View File
@@ -129,8 +129,6 @@ public: // Create from serialization only
void RegisterListener(IDocListener* listener);
void UnregisterListener(IDocListener* listener);
void GetMemoryUsage(ICrySizer* pSizer) const;
static bool IsBackupOrTempLevelSubdirectory(const QString& folderName);
protected:
-54
View File
@@ -249,60 +249,6 @@ void CErrorReport::SetImmediateMode(bool bEnable)
}
}
//////////////////////////////////////////////////////////////////////////
void CErrorReport::Report(SValidatorRecord& record)
{
if ((record.flags & VALIDATOR_FLAG_IGNORE_IN_EDITOR))
{
return;
}
CErrorRecord err;
if (record.text)
{
err.error = record.text;
}
if (record.description)
{
err.description = record.description;
}
if (record.file)
{
err.file = record.file;
}
else
{
err.file = m_currentFilename;
}
err.severity = (CErrorRecord::ESeverity)record.severity;
err.assetScope = record.assetScope;
err.flags = 0;
if (record.flags & VALIDATOR_FLAG_FILE)
{
err.flags |= CErrorRecord::FLAG_NOFILE;
}
if (record.flags & VALIDATOR_FLAG_TEXTURE)
{
err.flags |= CErrorRecord::FLAG_TEXTURE;
}
if (record.flags & VALIDATOR_FLAG_SCRIPT)
{
err.flags |= CErrorRecord::FLAG_SCRIPT;
}
if (record.flags & VALIDATOR_FLAG_AI)
{
err.flags |= CErrorRecord::FLAG_AI;
}
err.module = record.module;
err.pObject = m_pObject;
err.pItem = m_pItem;
ReportError(err);
}
//////////////////////////////////////////////////////////////////////////
void CErrorReport::SetCurrentValidatorObject(CBaseObject* pObject)
{
-5
View File
@@ -121,11 +121,6 @@ public:
//! Assign current filename.
void SetCurrentFile(const QString& file);
//////////////////////////////////////////////////////////////////////////
// Implement IValidator interface.
//////////////////////////////////////////////////////////////////////////
virtual void Report(SValidatorRecord& record);
private:
//! Array of all error records added to report.
std::vector<CErrorRecord> m_errors;
-5
View File
@@ -176,11 +176,6 @@ struct SSystemUserCallback
return CryMessageBox(text, caption, uType);
}
void GetMemoryUsage(ICrySizer* pSizer) override
{
GetIEditor()->GetMemoryUsage(pSizer);
}
void OnSplashScreenDone()
{
m_pLogo = nullptr;
+1 -7
View File
@@ -5,10 +5,6 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_GAMEEXPORTER_H
#define CRYINCLUDE_EDITOR_GAMEEXPORTER_H
#pragma once
#include "Util/PakFile.h"
@@ -62,7 +58,7 @@ public:
// In auto exporting mode, highest possible settings will be chosen and no UI dialogs will be shown.
void SetAutoExportMode(bool bAuto) { m_bAutoExportMode = bAuto; }
bool Export(unsigned int flags = 0, EEndian eExportEndian = GetPlatformEndian(), const char* subdirectory = 0);
bool Export(unsigned int flags = 0, EEndian eExportEndian = eEndianness_Little, const char* subdirectory = 0);
static CGameExporter* GetCurrentExporter() { return m_pCurrentExporter; }
@@ -116,5 +112,3 @@ void SetupTerrainInfo(const size_t octreeCompiledDataSize, Func&& setupTerrainFn
setupTerrainFn(octreeCompiledDataSize);
}
}
#endif // CRYINCLUDE_EDITOR_GAMEEXPORTER_H
-1
View File
@@ -701,7 +701,6 @@ struct IEditor
virtual CUIEnumsDatabase* GetUIEnumsDatabase() = 0;
virtual void AddUIEnums() = 0;
virtual void GetMemoryUsage(ICrySizer* pSizer) = 0;
virtual void ReduceMemory() = 0;
//! Export manager for exporting objects and a terrain from the game to DCC tools
-12
View File
@@ -1506,18 +1506,6 @@ void CEditorImpl::ShowStatusText(bool bEnable)
m_bShowStatusText = bEnable;
}
void CEditorImpl::GetMemoryUsage(ICrySizer* pSizer)
{
SIZER_COMPONENT_NAME(pSizer, "Editor");
if (GetDocument())
{
SIZER_COMPONENT_NAME(pSizer, "Document");
GetDocument()->GetMemoryUsage(pSizer);
}
}
void CEditorImpl::ReduceMemory()
{
GetIEditor()->GetUndoManager()->ClearRedoStack();
-1
View File
@@ -280,7 +280,6 @@ public:
void SetMatEditMode(bool bIsMatEditMode);
CUIEnumsDatabase* GetUIEnumsDatabase() { return m_pUIEnumsDatabase; };
void AddUIEnums();
void GetMemoryUsage(ICrySizer* pSizer);
void ReduceMemory();
// Get Export manager
IExportManager* GetExportManager();
+1 -4
View File
@@ -64,10 +64,7 @@ void CIconManager::Reset()
int i;
for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++)
{
if (m_objects[i])
{
m_objects[i]->Release();
}
delete m_objects[i];
m_objects[i] = nullptr;
}
for (i = 0; i < eIcon_COUNT; i++)
+6 -7
View File
@@ -24,16 +24,15 @@ inline AZStd::string ToString(const QString& s)
class CCommand
{
static inline bool FromString(int32 &val, const char* s) {
if(!s)
static inline bool FromString(int32& val, const char* s)
{
if (!s)
{
return false;
}
val = (int)strtol(s, nullptr, 10);
if(val==0 && errno!=0) {
return false;
}
return true;
val = static_cast<int>(strtol(s, nullptr, 10));
const bool parsing_error = val == 0 && errno != 0;
return !parsing_error;
}
public:
CCommand(
+1 -1
View File
@@ -15,6 +15,6 @@ struct IEditorMaterial
: public CBaseLibraryItem
{
virtual int GetFlags() const = 0;
virtual _smart_ptr<IMaterial> GetMatInfo(bool bUseExistingEngineMaterial = false) = 0;
virtual IMaterial* GetMatInfo(bool bUseExistingEngineMaterial = false) = 0;
virtual void DisableHighlightForFrame() = 0;
};
+1 -1
View File
@@ -19,7 +19,7 @@
struct IEditorMaterialManager
{
virtual void GotoMaterial(_smart_ptr<IMaterial> pMaterial) = 0;
virtual void GotoMaterial(IMaterial* pMaterial) = 0;
};
#endif // CRYINCLUDE_EDITOR_MATERIAL_MATERIALMANAGER_H
+1 -14
View File
@@ -9,23 +9,18 @@
// Description : Class that collects error reports to present them later.
#ifndef CRYINCLUDE_EDITOR_INTERFACE_ERRORREPORT_H
#define CRYINCLUDE_EDITOR_INTERFACE_ERRORREPORT_H
#pragma once
#include <IValidator.h>
// forward declarations.
class CParticleItem;
class CBaseObject;
class CBaseLibraryItem;
class CErrorRecord;
class QString;
/*! Error report manages collection of errors occurred during map analyzes or level load.
*/
struct IErrorReport
: public IValidator
{
virtual ~IErrorReport(){}
@@ -62,12 +57,4 @@ struct IErrorReport
//! Assign current filename.
virtual void SetCurrentFile(const QString& file) = 0;
//////////////////////////////////////////////////////////////////////////
// Implement IValidator interface.
//////////////////////////////////////////////////////////////////////////
virtual void Report(SValidatorRecord& record) = 0;
};
#endif // CRYINCLUDE_EDITOR_ERRORREPORT_H
-1
View File
@@ -89,7 +89,6 @@ public:
//! Get array of objects, managed by manager (not contain sub objects of groups).
//! @param layer if 0 get objects for all layers, or layer to get objects from.
virtual void GetObjects(CBaseObjectsArray& objects) const = 0;
//virtual void GetObjects(DynArray<CBaseObject*>& objects) const = 0;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
-1
View File
@@ -172,7 +172,6 @@ public:
MOCK_METHOD0(IsSourceControlConnected, bool());
MOCK_METHOD0(GetUIEnumsDatabase, CUIEnumsDatabase* ());
MOCK_METHOD0(AddUIEnums, void());
MOCK_METHOD1(GetMemoryUsage, void(ICrySizer* ));
MOCK_METHOD0(ReduceMemory, void());
MOCK_METHOD0(GetExportManager, IExportManager* ());
MOCK_METHOD2(SetEditorConfigSpec, void(ESystemConfigSpec , ESystemConfigPlatform ));
+3 -3
View File
@@ -67,7 +67,7 @@ SANDBOX_API void ErrorV(const char* format, va_list argList)
str += szBuffer;
//CLogFile::WriteLine( str );
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, str.toUtf8().data());
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, "%s", str.toUtf8().data());
if (!CCryEditApp::instance()->IsInTestMode() && !CCryEditApp::instance()->IsInExportMode() && !CCryEditApp::instance()->IsInLevelLoadTestMode())
{
@@ -95,7 +95,7 @@ SANDBOX_API void WarningV(const char* format, va_list argList)
char szBuffer[MAX_LOGBUFFER_SIZE];
azvsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, format, argList);
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, szBuffer);
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "%s", szBuffer);
bool bNoUI = false;
ICVar* pCVar = gEnv->pConsole->GetCVar("sys_no_crash_dialog");
@@ -478,7 +478,7 @@ void CLogFile::WriteString(const char* pszString)
{
if (gEnv && gEnv->pLog)
{
gEnv->pLog->LogPlus(pszString);
gEnv->pLog->LogPlus("%s", pszString);
}
}
+2 -2
View File
@@ -2735,7 +2735,7 @@ bool CBaseObject::IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayH
return false;
}
Matrix34A worldTM;
Matrix34 worldTM;
IStatObj* pStatObj = pRenderNode->GetEntityStatObj(0, 0, &worldTM);
if (!pStatObj)
{
@@ -2743,7 +2743,7 @@ bool CBaseObject::IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayH
}
// transform decal into object space
Matrix34A worldTM_Inverted = worldTM.GetInverted();
Matrix34 worldTM_Inverted = worldTM.GetInverted();
Matrix33 worldRot(worldTM_Inverted);
worldRot.Transpose();
// put hit direction into the object space
+1 -12
View File
@@ -710,7 +710,7 @@ void CObjectManager::ShowDuplicationMsgWarning(CBaseObject* obj, const QString&
);
// If id is taken.
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, sRenameWarning.toUtf8().data());
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_WARNING, "%s", sRenameWarning.toUtf8().data());
if (bShowMsgBox)
{
@@ -760,17 +760,6 @@ void CObjectManager::GetObjects(CBaseObjectsArray& objects) const
}
}
//void CObjectManager::GetObjects(DynArray<CBaseObject*>& objects) const
//{
// CBaseObjectsArray objectArray;
// GetObjects(objectArray);
// objects.clear();
// for (size_t i = 0, iCount(objectArray.size()); i < iCount; ++i)
// {
// objects.push_back(objectArray[i]);
// }
//}
void CObjectManager::GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const
{
objects.clear();
-1
View File
@@ -122,7 +122,6 @@ public:
//! Get array of objects, managed by manager (not contain sub objects of groups).
//! @param layer if 0 get objects for all layers, or layer to get objects from.
void GetObjects(CBaseObjectsArray& objects) const;
//void GetObjects(DynArray<CBaseObject*>& objects) const;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
@@ -37,7 +37,6 @@
#include <AzToolsFramework/ToolsComponents/EditorEntityIconComponentBus.h>
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
#include <LmbrCentral/Rendering/RenderNodeBus.h>
#include <LmbrCentral/Rendering/MaterialOwnerBus.h>
#include <IDisplayViewport.h>
#include <CryCommon/Cry_GeoIntersect.h>
+1 -5
View File
@@ -24,11 +24,7 @@ PLUGIN_API IPlugin* CreatePluginInstance(PLUGIN_INIT_PARAM* pInitParam)
// Make sure the ffmpeg command can be executed before registering the command
if (!CFFMPEGPlugin::RuntimeTest())
{
AZStd::string msg =
"FFMPEG plugin: Failed to execute FFmepg. Please run Setup Assistant, "
"go to the 'Optional software' section of the 'Install software' tab, "
"and make sure the FFmpeg executable is correctly configured.";
GetIEditor()->GetSystem()->GetILog()->Log(msg.c_str());
GetIEditor()->GetSystem()->GetILog()->Log("FFMPEG plugin: Failed to execute FFmpeg. Please install FFmpeg.");
}
else
{
+1 -1
View File
@@ -313,7 +313,7 @@ namespace
{
if (strcmp(pMessage, "") != 0)
{
CryLogAlways(pMessage);
CryLogAlways("%s", pMessage);
}
}
@@ -719,8 +719,7 @@ bool CSequenceBatchRenderDialog::GetResolutionFromCustomResText(const char* cust
int scannedWidth = retCustomWidth; // initialize with default fall-back values - they'll be overwritten in the case of a succesful sscanf below.
int scannedHeight = retCustomHeight;
QString strFormat = QString::fromLatin1(customResFormat).replace(QRegularExpression(QStringLiteral("%\\d")), QStringLiteral("%d"));
scanSuccess = (azsscanf(customResText, strFormat.toStdString().c_str(), &scannedWidth, &scannedHeight) == 2);
scanSuccess = (azsscanf(customResText, "Custom(%d x %d)...", &scannedWidth, &scannedHeight) == 2);
if (scanSuccess)
{
retCustomWidth = scannedWidth;
-36
View File
@@ -62,17 +62,6 @@ public:
}
}
// to get memory statistics
void GetMemoryUsage(ICrySizer* pSizer)
{
for (int i = 0; i < m_undoSteps.size(); i++)
{
m_undoSteps[i]->GetMemoryUsage(pSizer);
}
pSizer->Add(*this);
}
private:
//! Undo steps included in this step.
std::vector<CUndoStep*> m_undoSteps;
@@ -746,31 +735,6 @@ int CUndoManager::GetMaxUndoStep() const
return GetIEditor()->GetEditorSettings()->undoLevels;
}
void CUndoManager::GetMemoryUsage(ICrySizer* pSizer)
{
if (m_currentUndo)
{
m_currentUndo->GetMemoryUsage(pSizer);
}
if (m_superUndo)
{
m_superUndo->GetMemoryUsage(pSizer);
}
for (std::list<CUndoStep*>::const_iterator it = m_undoStack.begin(); it != m_undoStack.end(); it++)
{
(*it)->GetMemoryUsage(pSizer);
}
for (std::list<CUndoStep*>::const_iterator it = m_redoStack.begin(); it != m_redoStack.end(); it++)
{
(*it)->GetMemoryUsage(pSizer);
}
pSizer->Add(*this);
}
void CUndoManager::AddListener(IUndoManagerListener* pListener)
{
stl::push_back_unique(m_listeners, pListener);
+1 -18
View File
@@ -12,9 +12,9 @@
#pragma once
#include "IUndoManagerListener.h"
#include "CrySizer.h" // ICrySizer
#include "IUndoObject.h"
#include <AzCore/Asset/AssetManager.h>
#include <CryCommon/StlUtils.h>
struct IUndoObject;
class CSuperUndoStep;
@@ -79,20 +79,6 @@ public:
}
}
// to get memory statistics
void GetMemoryUsage(ICrySizer* pSizer)
{
size_t nThisSize = sizeof(*this);
for (int i = 0; i < m_undoObjects.size(); i++)
{
nThisSize += m_undoObjects[i]->GetSize();
}
pSizer->Add(m_name);
pSizer->Add(this, nThisSize);
}
// get undo object at index i
IUndoObject* GetUndoObject(int i = 0)
{
@@ -241,9 +227,6 @@ public:
void ClearUndoStack(int num);
void ClearRedoStack(int num);
// to get memory statistics
void GetMemoryUsage(ICrySizer* pSizer);
void AddListener(IUndoManagerListener* pListener);
void RemoveListener(IUndoManagerListener* pListener);
-3
View File
@@ -20,9 +20,6 @@
#include <Cry_Color.h>
#include <CryCommon/ISystem.h>
//! Typedef for quaternion.
//typedef CryQuat Quat;
#include <QColor>
#include <QDataStream>
#include <QGuiApplication>
+1 -1
View File
@@ -52,7 +52,7 @@ bool CImageASC::Save(const QString& fileName, const CFloatImage& image)
}
// First print the file header
fprintf(file, fileHeader.c_str());
fprintf(file, "%s", fileHeader.c_str());
// Then print all the pixels.
for (uint32 y = 0; y < height; y++)
+1 -1
View File
@@ -103,7 +103,7 @@ bool CImageUtil::SavePGM(const QString& fileName, const CImageEx& image)
}
// First print the file header
fprintf(file, fileHeader.c_str());
fprintf(file, "%s", fileHeader.c_str());
// Then print all the pixels.
for (uint32 y = 0; y < height; y++)
+1 -1
View File
@@ -37,7 +37,7 @@ public:
struct SStatObj
{
Matrix34 tm;
_smart_ptr<IStatObj> pStatObj;
IStatObj* pStatObj;
};
private:
+1 -1
View File
@@ -78,7 +78,7 @@ bool CMemoryBlock::Allocate(int size, int uncompressedSize)
{
QString str;
str = QStringLiteral("CMemoryBlock::Allocate failed to allocate %1Mb of Memory").arg(size / (1024 * 1024));
CryLogAlways(str.toUtf8().data());
CryLogAlways("%s", str.toUtf8().data());
QMessageBox::critical(QApplication::activeWindow(), QString(), str + QString("\r\nSandbox will try to reduce its working memory set to free memory for this allocation."));
GetIEditor()->ReduceMemory();
@@ -18,7 +18,7 @@ namespace AZ
{
void OutputToDebugger([[maybe_unused]] const char* window, [[maybe_unused]] const char* message)
{
__android_log_print(ANDROID_LOG_INFO, window, message);
__android_log_print(ANDROID_LOG_INFO, window, "%s", message);
}
}
}
@@ -311,7 +311,6 @@ namespace AzFramework
// On some platforms, threadid is just a number but on other platforms it is a pointer of some kind
// uintptr_t will ensure that the data will always fit
uintptr_t threadID = threadId ? threadId : (uintptr_t)(AZStd::this_thread::get_id().m_id);
const char* printFormatter = m_machineReadable ? "~~%p~~%s~~" : "{%p}[%14s]";
// while it may be tempting to check the fileio Pointer here, any emit of any warning or error would be fatal
// since we're already logging, and we don't want to log while you log.
@@ -331,7 +330,14 @@ namespace AzFramework
azsnprintf(buffer, 80, "~~%llu~~%i", rawTime, severity);
m_fileIO->Write(m_fileHandle, buffer, strlen(buffer));
azsnprintf(buffer, 80, printFormatter, threadID, categoryActual);
if (m_machineReadable) // Branching instead of using a ternary on the format string to avoid warning 4774 (format literal expected)
{
azsnprintf(buffer, 80, "~~%p~~%s~~", reinterpret_cast<void*>(threadID), categoryActual);
}
else
{
azsnprintf(buffer, 80, "{%p}[%14s]", reinterpret_cast<void*>(threadID), categoryActual);
}
m_fileIO->Write(m_fileHandle, buffer, strlen(buffer));
m_fileIO->Write(m_fileHandle, dataSource, dataLength);
@@ -349,8 +355,14 @@ namespace AzFramework
{
return;
}
azsnprintf(categorybuffer, 64, printFormatter, threadID, categoryActual);
if (m_machineReadable) // Branching instead of using a ternary on the format string to avoid warning 4774 (format literal expected)
{
azsnprintf(categorybuffer, 64, "~~%p~~%s~~", reinterpret_cast<void*>(threadID), categoryActual);
}
else
{
azsnprintf(categorybuffer, 64, "{%p}[%14s]", reinterpret_cast<void*>(threadID), categoryActual);
}
if ((category) && (categoryLen))
{
@@ -92,8 +92,7 @@ namespace AzManipulatorTestFramework
{
if (m_logging)
{
AZStd::string message = AZStd::string::format(format, args...);
AZ_Printf("[ActionDispatcher] %s", message.c_str());
AZ_Printf("ActionDispatcher", format, args...);
}
}
@@ -150,7 +149,7 @@ namespace AzManipulatorTestFramework
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MouseLButtonDown()
{
Log("Mouse left button down");
Log("%s", "Mouse left button down");
MouseLButtonDownImpl();
return static_cast<DerivedDispatcherT*>(this);
}
@@ -158,7 +157,7 @@ namespace AzManipulatorTestFramework
template <typename DerivedDispatcherT>
DerivedDispatcherT* ActionDispatcher<DerivedDispatcherT>::MouseLButtonUp()
{
Log("Mouse left button up");
Log("%s", "Mouse left button up");
MouseLButtonUpImpl();
return static_cast<DerivedDispatcherT*>(this);
}
@@ -24,7 +24,7 @@ namespace AzManipulatorTestFramework
{
const char* error = "Couldn't add action to sequence, dispatcher is locked (you must call ResetSequence() \
before adding actions to this dispatcher)";
Log(error);
Log("%s", error);
AZ_Assert(false, "Error: %s", error);
}
@@ -108,7 +108,7 @@ namespace AzManipulatorTestFramework
RetainedModeActionDispatcher* RetainedModeActionDispatcher::ResetSequence()
{
Log("Resetting the action sequence");
Log("%s", "Resetting the action sequence");
m_actions.clear();
m_dispatcher.ResetEvent();
m_locked = false;
+14 -4
View File
@@ -305,10 +305,20 @@ namespace O3DELauncher
m_commandLine[m_commandLineLen++] = ' ';
}
azsnprintf(m_commandLine + m_commandLineLen,
AZ_COMMAND_LINE_LEN - m_commandLineLen,
needsQuote ? "\"%s\"" : "%s",
arg);
if (needsQuote) // Branching instead of using a ternary on the format string to avoid warning 4774 (format literal expected)
{
azsnprintf(m_commandLine + m_commandLineLen,
AZ_COMMAND_LINE_LEN - m_commandLineLen,
"\"%s\"",
arg);
}
else
{
azsnprintf(m_commandLine + m_commandLineLen,
AZ_COMMAND_LINE_LEN - m_commandLineLen,
"%s",
arg);
}
// Inject the argument in the argument buffer to preserve/replicate argC and argV
azstrncpy(&m_commandLineArgBuffer[m_nextCommandLineArgInsertPoint],
@@ -426,7 +426,7 @@ void android_main(android_app* appState)
if (status != ReturnCode::Success)
{
MAIN_EXIT_FAILURE(appState, GetReturnCodeString(status));
MAIN_EXIT_FAILURE(appState, "%s", GetReturnCodeString(status));
}
}
-5
View File
@@ -6,9 +6,6 @@
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_BASETYPES_H
#define CRYINCLUDE_CRYCOMMON_BASETYPES_H
#pragma once
static_assert(sizeof(char) == 1);
@@ -78,5 +75,3 @@ typedef float f32;
typedef double f64;
static_assert(sizeof(f32) == 4);
static_assert(sizeof(f64) == 8);
#endif // CRYINCLUDE_CRYCOMMON_BASETYPES_H
-543
View File
@@ -1,543 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : various integer bit fiddling hacks
#pragma once
#include <AzCore/Casting/numeric_cast.h>
// Section dictionary
#if defined(AZ_RESTRICTED_PLATFORM)
#define BITFIDDLING_H_SECTION_TRAITS 1
#define BITFIDDLING_H_SECTION_INTEGERLOG2 2
#endif
// Traits
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION BITFIDDLING_H_SECTION_TRAITS
#include AZ_RESTRICTED_FILE(BitFiddling_h)
#elif defined(LINUX) || defined(APPLE)
#define BITFIDDLING_H_TRAIT_HAS_COUNT_LEADING_ZEROS 1
#endif
#if BITFIDDLING_H_TRAIT_HAS_COUNT_LEADING_ZEROS
#define countLeadingZeros32(x) __builtin_clz(x)
#else // Windows implementation
ILINE uint32 countLeadingZeros32(uint32 x)
{
DWORD result = 32 ^ 31; // assumes result is unmodified if _BitScanReverse returns 0
_BitScanReverse(&result, x);
result ^= 31; // needed because the index is from LSB (whereas all other implementations are from MSB)
return result;
}
#endif
inline uint32 circularShift(uint32 nbits, uint32 i)
{
return (i << nbits) | (i >> (32 - nbits));
}
template <typename T>
inline size_t countTrailingZeroes(T v)
{
size_t n = 0;
v = ~v & (v - 1);
while (v)
{
++n;
v >>= 1;
}
return n;
}
// this function returns the integer logarithm of various numbers without branching
#define IL2VAL(mask, shift) \
c |= ((x & mask) != 0) * shift; \
x >>= ((x & mask) != 0) * shift
template <typename TInteger>
inline bool IsPowerOfTwo(TInteger x)
{
return (x & (x - 1)) == 0;
}
inline uint32 NextPower2(uint32 n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n++;
return n;
}
inline uint8 IntegerLog2(uint8 x)
{
uint8 c = 0;
IL2VAL(0xf0, 4);
IL2VAL(0xc, 2);
IL2VAL(0x2, 1);
return c;
}
inline uint16 IntegerLog2(uint16 x)
{
uint16 c = 0;
IL2VAL(0xff00, 8);
IL2VAL(0xf0, 4);
IL2VAL(0xc, 2);
IL2VAL(0x2, 1);
return c;
}
inline uint32 IntegerLog2(uint32 x)
{
return 31 - countLeadingZeros32(x);
}
inline uint64 IntegerLog2(uint64 x)
{
uint64 c = 0;
IL2VAL(0xffffffff00000000ull, 32);
IL2VAL(0xffff0000u, 16);
IL2VAL(0xff00, 8);
IL2VAL(0xf0, 4);
IL2VAL(0xc, 2);
IL2VAL(0x2, 1);
return c;
}
#if defined(APPLE) || defined(LINUX)
inline unsigned long int IntegerLog2(unsigned long int x)
{
#if defined(PLATFORM_64BIT)
return IntegerLog2((uint64)x);
#else
return IntegerLog2((uint32)x);
#endif
}
#endif
#undef IL2VAL
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION BITFIDDLING_H_SECTION_INTEGERLOG2
#include AZ_RESTRICTED_FILE(BitFiddling_h)
#endif
template <typename TInteger>
inline TInteger IntegerLog2_RoundUp(TInteger x)
{
return 1 + IntegerLog2(x - 1);
}
static ILINE uint8 BitIndex(uint8 v)
{
uint32 vv = v;
return aznumeric_caster(31 - countLeadingZeros32(vv));
}
static ILINE uint8 BitIndex(uint16 v)
{
uint32 vv = v;
return aznumeric_caster(31 - countLeadingZeros32(vv));
}
static ILINE uint8 BitIndex(uint32 v)
{
return aznumeric_caster(31 - countLeadingZeros32(v));
}
static ILINE uint8 CountBits(uint8 v)
{
uint8 c = v;
c = ((c >> 1) & 0x55) + (c & 0x55);
c = ((c >> 2) & 0x33) + (c & 0x33);
c = ((c >> 4) & 0x0f) + (c & 0x0f);
return c;
}
static ILINE uint8 CountBits(uint16 v)
{
return CountBits((uint8)(v & 0xff)) +
CountBits((uint8)((v >> 8) & 0xff));
}
static ILINE uint8 CountBits(uint32 v)
{
return CountBits((uint8)(v & 0xff)) +
CountBits((uint8)((v >> 8) & 0xff)) +
CountBits((uint8)((v >> 16) & 0xff)) +
CountBits((uint8)((v >> 24) & 0xff));
}
// Branchless version of return v < 0 ? alt : v;
ILINE int32 Isel32(int32 v, int32 alt)
{
return ((static_cast<int32>(v) >> 31) & alt) | ((static_cast<int32>(~v) >> 31) & v);
}
// Character-to-bitfield mapping
inline uint32 AlphaBit(char c)
{
return c >= 'a' && c <= 'z' ? 1 << (c - 'z' + 31) : 0;
}
inline uint64 AlphaBit64(char c)
{
return (c >= 'a' && c <= 'z' ? 1U << (c - 'z' + 31) : 0) |
(c >= 'A' && c <= 'Z' ? 1LL << (c - 'Z' + 63) : 0);
}
inline uint32 AlphaBits(uint32 wc)
{
// Handle wide multi-char constants, can be evaluated at compile-time.
return AlphaBit((char)wc)
| AlphaBit((char)(wc >> 8))
| AlphaBit((char)(wc >> 16))
| AlphaBit((char)(wc >> 24));
}
inline uint32 AlphaBits(const char* s)
{
// Handle string of any length.
uint32 n = 0;
while (*s)
{
n |= AlphaBit(*s++);
}
return n;
}
inline uint64 AlphaBits64(const char* s)
{
// Handle string of any length.
uint64 n = 0;
while (*s)
{
n |= AlphaBit64(*s++);
}
return n;
}
// s should point to a buffer at least 65 chars long
inline void BitsAlpha64(uint64 n, char* s)
{
for (int i = 0; n != 0; n >>= 1, i++)
{
if (n & 1)
{
*s++ = i < 32 ? static_cast<char>(i + 'z' - 31) : static_cast<char>(i + 'Z' - 63);
}
}
*s++ = '\0';
}
// if hardware doesn't support 3Dc we can convert to DXT5 (different channels are used)
// with almost the same quality but the same memory requirements
inline void ConvertBlock3DcToDXT5(uint8 pDstBlock[16], const uint8 pSrcBlock[16])
{
assert(pDstBlock != pSrcBlock); // does not work in place
// 4x4 block requires 8 bytes in DXT5 or 3DC
// DXT5: 8 bit alpha0, 8 bit alpha1, 16*3 bit alpha lerp
// 16bit col0, 16 bit col1 (R5G6B5 low byte then high byte), 16*2 bit color lerp
// 3DC: 8 bit x0, 8 bit x1, 16*3 bit x lerp
// 8 bit y0, 8 bit y1, 16*3 bit y lerp
for (uint32 dwK = 0; dwK < 8; ++dwK)
{
pDstBlock[dwK] = pSrcBlock[dwK];
}
for (uint32 dwK = 8; dwK < 16; ++dwK)
{
pDstBlock[dwK] = 0;
}
// 6 bit green channel (highest bits)
// by using all 3 channels with a slight offset we can get more precision but then a dot product would be needed in PS
// because of bilinear filter we cannot just distribute bits to get perfect result
uint16 colDst0 = (((uint16)pSrcBlock[8] + 2) >> 2) << 5;
uint16 colDst1 = (((uint16)pSrcBlock[9] + 2) >> 2) << 5;
bool bFlip = colDst0 <= colDst1;
if (bFlip)
{
uint16 help = colDst0;
colDst0 = colDst1;
colDst1 = help;
}
bool bEqual = colDst0 == colDst1;
// distribute bytes by hand to not have problems with endianess
pDstBlock[8 + 0] = (uint8)colDst0;
pDstBlock[8 + 1] = (uint8)(colDst0 >> 8);
pDstBlock[8 + 2] = (uint8)colDst1;
pDstBlock[8 + 3] = (uint8)(colDst1 >> 8);
uint16* pSrcBlock16 = (uint16*)(pSrcBlock + 10);
uint16* pDstBlock16 = (uint16*)(pDstBlock + 12);
// distribute 16 3 bit values to 16 2 bit values (loosing LSB)
for (uint32 dwK = 0; dwK < 16; ++dwK)
{
uint32 dwBit0 = dwK * 3 + 0;
uint32 dwBit1 = dwK * 3 + 1;
uint32 dwBit2 = dwK * 3 + 2;
uint8 hexDataIn = (((pSrcBlock16[(dwBit2 >> 4)] >> (dwBit2 & 0xf)) & 1) << 2) // get HSB
| (((pSrcBlock16[(dwBit1 >> 4)] >> (dwBit1 & 0xf)) & 1) << 1)
| ((pSrcBlock16[(dwBit0 >> 4)] >> (dwBit0 & 0xf)) & 1); // get LSB
uint8 hexDataOut = 0;
switch (hexDataIn)
{
case 0:
hexDataOut = 0;
break; // color 0
case 1:
hexDataOut = 1;
break; // color 1
case 2:
hexDataOut = 0;
break; // mostly color 0
case 3:
hexDataOut = 2;
break;
case 4:
hexDataOut = 2;
break;
case 5:
hexDataOut = 3;
break;
case 6:
hexDataOut = 3;
break;
case 7:
hexDataOut = 1;
break; // mostly color 1
default:
assert(0);
}
if (bFlip)
{
if (hexDataOut < 2)
{
hexDataOut = 1 - hexDataOut; // 0<->1
}
else
{
hexDataOut = 5 - hexDataOut; // 2<->3
}
}
if (bEqual)
{
if (hexDataOut == 3)
{
hexDataOut = 1;
}
}
pDstBlock16[(dwK >> 3)] |= (hexDataOut << ((dwK & 0x7) << 1));
}
}
// is a bit on in a new bit field, but off in an old bit field
static ILINE bool TurnedOnBit(unsigned bit, unsigned oldBits, unsigned newBits)
{
return (newBits & bit) != 0 && (oldBits & bit) == 0;
}
inline uint32 cellUtilCountLeadingZero(uint32 x)
{
uint32 y;
uint32 n = 32;
y = x >> 16;
if (y != 0)
{
n = n - 16;
x = y;
}
y = x >> 8;
if (y != 0)
{
n = n - 8;
x = y;
}
y = x >> 4;
if (y != 0)
{
n = n - 4;
x = y;
}
y = x >> 2;
if (y != 0)
{
n = n - 2;
x = y;
}
y = x >> 1;
if (y != 0)
{
return n - 2;
}
return n - x;
}
inline uint32 cellUtilLog2(uint32 x)
{
return 31 - cellUtilCountLeadingZero(x);
}
inline void convertSwizzle(uint8*& dst, const uint8*& src,
const uint32 SrcPitch, const uint32 depth,
const uint32 xpos, const uint32 ypos,
const uint32 SciX1, const uint32 SciY1,
const uint32 SciX2, const uint32 SciY2,
const uint32 level)
{
if (level == 1)
{
switch (depth)
{
case 16:
if (xpos >= SciX1 && xpos < SciX2 && ypos >= SciY1 && ypos < SciY2)
{
// *((uint32*&)dst)++ = ((uint32*)src)[ypos * width + xpos];
// *((uint32*&)dst)++ = ((uint32*)src)[ypos * width + xpos+1];
// *((uint32*&)dst)++ = ((uint32*)src)[ypos * width + xpos+2];
// *((uint32*&)dst)++ = ((uint32*)src)[ypos * width + xpos+3];
*((uint32*&)dst)++ = *((uint32*)(src + (ypos * SrcPitch + xpos * 16)));
*((uint32*&)dst)++ = *((uint32*)(src + (ypos * SrcPitch + xpos * 16 + 4)));
*((uint32*&)dst)++ = *((uint32*)(src + (ypos * SrcPitch + xpos * 16 + 8)));
*((uint32*&)dst)++ = *((uint32*)(src + (ypos * SrcPitch + xpos * 16 + 12)));
}
else
{
((uint32*&)dst) += 4;
}
break;
case 8:
if (xpos >= SciX1 && xpos < SciX2 && ypos >= SciY1 && ypos < SciY2)
{
*((uint32*&)dst)++ = *((uint32*)(src + (ypos * SrcPitch + xpos * 8)));
*((uint32*&)dst)++ = *((uint32*)(src + (ypos * SrcPitch + xpos * 8 + 4)));
}
else
{
((uint32*&)dst) += 2;
}
break;
case 4:
if (xpos >= SciX1 && xpos < SciX2 && ypos >= SciY1 && ypos < SciY2)
{
*((uint32*&)dst) = *((uint32*)(src + (ypos * SrcPitch + xpos * 4)));
}
dst += 4;
break;
case 3:
if (xpos >= SciX1 && xpos < SciX2 && ypos >= SciY1 && ypos < SciY2)
{
*dst++ = src[ypos * SrcPitch + xpos * depth];
*dst++ = src[ypos * SrcPitch + xpos * depth + 1];
*dst++ = src[ypos * SrcPitch + xpos * depth + 2];
}
else
{
dst += 3;
}
break;
case 1:
if (xpos >= SciX1 && xpos < SciX2 && ypos >= SciY1 && ypos < SciY2)
{
*dst++ = src[ypos * SrcPitch + xpos * depth];
}
else
{
dst++;
}
break;
default:
assert(0);
}
return;
}
else
{
convertSwizzle(dst, src, SrcPitch, depth, xpos, ypos, SciX1, SciY1, SciX2, SciY2, level - 1);
convertSwizzle(dst, src, SrcPitch, depth, xpos + (1U << (level - 2)), ypos, SciX1, SciY1, SciX2, SciY2, level - 1);
convertSwizzle(dst, src, SrcPitch, depth, xpos, ypos + (1U << (level - 2)), SciX1, SciY1, SciX2, SciY2, level - 1);
convertSwizzle(dst, src, SrcPitch, depth, xpos + (1U << (level - 2)), ypos + (1U << (level - 2)), SciX1, SciY1, SciX2, SciY2, level - 1);
}
}
inline void Linear2Swizzle(uint8* dst,
const uint8* src,
const uint32 SrcPitch,
const uint32 width,
const uint32 height,
const uint32 depth,
const uint32 SciX1, const uint32 SciY1,
const uint32 SciX2, const uint32 SciY2)
{
src -= SciY1 * SrcPitch + SciX1 * depth;
if (width == height)
{
convertSwizzle(dst, src, SrcPitch, depth, 0, 0, SciX1, SciY1, SciX2, SciY2, cellUtilLog2(width) + 1);
}
else
if (width > height)
{
uint32 baseLevel = cellUtilLog2(width) - (cellUtilLog2(width) - cellUtilLog2(height));
for (uint32 i = 0; i < (1UL << (cellUtilLog2(width) - cellUtilLog2(height))); i++)
{
convertSwizzle(dst, src, SrcPitch, depth, (1U << baseLevel) * i, 0, SciX1, SciY1, SciX2, SciY2, baseLevel + 1);
}
}
else
// if (width < height)//wtf
{
uint32 baseLevel = cellUtilLog2(height) - (cellUtilLog2(height) - cellUtilLog2(width));
for (uint32 i = 0; i < (1UL << (cellUtilLog2(height) - cellUtilLog2(width))); i++)
{
convertSwizzle(dst, src, SrcPitch, depth, 0, (1U << baseLevel) * i, SciX1, SciY1, SciX2, SciY2, baseLevel + 1);
}
}
}
-21
View File
@@ -1,21 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "Cry_Geo.h"
#include "Cry_Color.h"
#include "Cry_Vector3.h"
// Manually instantiate templates as needed here.
template struct Vec3_tpl<float>;
template struct Vec4_tpl<float>;
template struct Vec2_tpl<float>;
template struct Ang3_tpl<float>;
template struct Plane_tpl<float>;
template struct Matrix33_tpl<float>;
template struct Color_tpl<float>;
-210
View File
@@ -1,210 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "BaseTypes.h"
// CRC-32
//
// Polynomial:
// 0x04C11DB7
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
//
// Validation:
// CCrc32::Compute("123456789") == 0xCBF43926
//
// Examples of using:
//
// printf("crc32: %08x\n", (unsigned)CCrc32::Compute(ptr, size));
//
// CCrc32 crc;
// crc.Add(ptr0, size0);
// crc.Add(ptr1, size1);
// printf("crc32: %08x\n", (unsigned)crc.Get());
class CCrc32
{
public:
static uint32 Compute(const void* const pData, const size_t sizeInBytes)
{
CCrc32 c;
c.Add(pData, sizeInBytes);
return c.Get();
}
static uint32 Compute(const char* const szData)
{
CCrc32 c;
c.Add(szData);
return c.Get();
}
static uint32 ComputeLowercase(const char* const pData, const size_t sizeInBytes)
{
CCrc32 c;
c.AddLowercase(pData, sizeInBytes);
return c.Get();
}
static uint32 ComputeLowercase(const char* const szData)
{
CCrc32 c;
c.AddLowercase(szData);
return c.Get();
}
CCrc32()
: m_crc(0xFFFFffff)
, m_pTable(GetTable())
{
}
CCrc32(unsigned int initializer)
: m_crc(initializer)
, m_pTable(GetTable())
{
}
void Reset()
{
m_crc = 0xFFFFffff;
}
uint32 Get() const
{
return ~m_crc;
}
unsigned int Add(const void* const pData, size_t sizeInBytes)
{
const uint8* p = (const uint8*)pData;
while (sizeInBytes--)
{
m_crc = (m_crc >> 8) ^ m_pTable[(m_crc & 0xFF) ^ (*p++)];
}
return Get();
}
unsigned int Add(const char* szData)
{
while (*szData)
{
m_crc = (m_crc >> 8) ^ m_pTable[(m_crc & 0xFF) ^ uint8(*szData++)];
}
return Get();
}
#if defined(CRY_TMP_ASCII_TO_LOWER)
# error CRY_TMP_ASCII_TO_LOWER already defined
#endif
#define CRY_TMP_ASCII_TO_LOWER(c) uint8(((c) <= 'Z' && (c) >= 'A') ? (c) + ('a' - 'A') : (c))
unsigned int AddLowercase(const char* pData, size_t sizeInBytes)
{
while (sizeInBytes--)
{
const uint8 c = *pData++;
m_crc = (m_crc >> 8) ^ m_pTable[(m_crc & 0xFF) ^ CRY_TMP_ASCII_TO_LOWER(c)];
}
return Get();
}
unsigned int AddLowercase(const char* szData)
{
while (*szData)
{
const uint8 c = *szData++;
m_crc = (m_crc >> 8) ^ m_pTable[(m_crc & 0xFF) ^ CRY_TMP_ASCII_TO_LOWER(c)];
}
return Get();
}
#undef CRY_TMP_ASCII_TO_LOWER
private:
static const uint32* GetTable()
{
static const uint32 table[256] =
{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
return &table[0];
}
private:
uint32 m_crc;
const uint32* const m_pTable;
};
// eof
-75
View File
@@ -6,9 +6,6 @@
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_CRYENDIAN_H
#define CRYINCLUDE_CRYCOMMON_CRYENDIAN_H
#pragma once
#include <BaseTypes.h>
@@ -68,18 +65,6 @@ enum EEndianness
#endif
};
// Legacy macros
#define GetPlatformEndian() false
/////////////////////////////////////////////////////////////////////////////////////
inline bool IsSystemLittleEndian()
{
const int a = 1;
return 1 == *(const char*)&a;
}
/////////////////////////////////////////////////////////////////////////////////////
// SwapEndian function, using TypeInfo.
@@ -233,63 +218,3 @@ inline void SwapEndian(T& t, bool bSwapEndian = eLittleEndian)
SwapEndianBase(&t, 1);
}
}
template<class T>
inline T SwapEndianValue(T t, bool bSwapEndian = eLittleEndian)
{
if (bSwapEndian)
{
SwapEndianBase(&t, 1);
}
return t;
}
//---------------------------------------------------------------------------
// Object-oriented data extraction for endian-swapping reading.
template<class T, class D>
inline T* StepData(D*& pData, size_t nCount, bool bSwapEndian)
{
T* Elems = (T*)pData;
SwapEndian(Elems, nCount, bSwapEndian);
pData = (D*)((T*)pData + nCount);
return Elems;
}
template<class T, class D>
inline T* StepData(D*& pData, bool bSwapEndian)
{
return StepData<T, D>(pData, 1, bSwapEndian);
}
template<class T, class D>
inline void StepData(T*& Result, D*& pData, size_t nCount, bool bSwapEndian)
{
Result = StepData<T, D>(pData, nCount, bSwapEndian);
}
template<class T, class D>
inline void StepDataCopy(T* Dest, D*& pData, size_t nCount, bool bSwapEndian)
{
memcpy(Dest, pData, nCount * sizeof(T));
SwapEndian(Dest, nCount, bSwapEndian);
pData = (D*)((T*)pData + nCount);
}
template<class T, class D>
inline void StepDataWrite(D*& pDest, const T* aSrc, size_t nCount, bool bSwapEndian)
{
memcpy(pDest, aSrc, nCount * sizeof(T));
if (bSwapEndian)
{
SwapEndianBase((T*)pDest, nCount, true);
}
(T*&)pDest += nCount;
}
template<class T, class D>
inline void StepDataWrite(D*& pDest, const T& Src, bool bSwapEndian)
{
StepDataWrite(pDest, &Src, 1, bSwapEndian);
}
#endif // CRYINCLUDE_CRYCOMMON_CRYENDIAN_H
-163
View File
@@ -6,12 +6,7 @@
*
*/
// Description : File wrapper.
#ifndef CRYINCLUDE_CRYCOMMON_CRYFILE_H
#define CRYINCLUDE_CRYCOMMON_CRYFILE_H
#pragma once
#include <CryPath.h>
@@ -20,86 +15,16 @@
#include <IConsole.h>
#include <AzCore/IO/FileIO.h>
//////////////////////////////////////////////////////////////////////////
// Defines for CryEngine filetypes extensions.
//////////////////////////////////////////////////////////////////////////
#define CRY_GEOMETRY_FILE_EXT "cgf"
#define CRY_SKEL_FILE_EXT "chr" //will be a SKEL soon
#define CRY_SKIN_FILE_EXT "skin"
#define CRY_CHARACTER_ANIMATION_FILE_EXT "caf"
#define CRY_CHARACTER_DEFINITION_FILE_EXT "cdf"
#define CRY_CHARACTER_LIST_FILE_EXT "cid"
#define CRY_ANIM_GEOMETRY_FILE_EXT "cga"
#define CRY_ANIM_GEOMETRY_ANIMATION_FILE_EXT "anm"
#define CRY_COMPILED_FILE_EXT "(c)"
#define CRY_BINARY_XML_FILE_EXT "binxml"
#define CRY_XML_FILE_EXT "xml"
#define CRY_CHARACTER_PARAM_FILE_EXT "chrparams"
#define CRY_GEOM_CACHE_FILE_EXT "cax"
//////////////////////////////////////////////////////////////////////////
#define CRYFILE_MAX_PATH 260
//////////////////////////////////////////////////////////////////////////
inline const char* CryGetExt(const char* filepath)
{
const char* str = filepath;
size_t len = strlen(filepath);
for (const char* p = str + len - 1; p >= str; --p)
{
switch (*p)
{
case ':':
case '/':
case '\\':
// we've reached a path separator - it means there's no extension in this name
return "";
case '.':
// there's an extension in this file name
return p + 1;
}
}
return "";
}
// Summary:
// Checks if specified file name is a character file.
// Summary:
// Checks if specified file name is a character file.
inline bool IsCharacterFile(const char* filename)
{
const char* ext = CryGetExt(filename);
if (_stricmp(ext, CRY_SKEL_FILE_EXT) == 0 || _stricmp(ext, CRY_SKIN_FILE_EXT) == 0 || _stricmp(ext, CRY_CHARACTER_DEFINITION_FILE_EXT) == 0 || _stricmp(ext, CRY_ANIM_GEOMETRY_FILE_EXT) == 0)
{
return true;
}
else
{
return false;
}
}
// Description:
// Checks if specified file name is a static geometry file.
inline bool IsStatObjFile(const char* filename)
{
const char* ext = CryGetExt(filename);
if (_stricmp(ext, CRY_GEOMETRY_FILE_EXT) == 0)
{
return true;
}
else
{
return false;
}
}
// Summary:
// Wrapper on file system.
class CCryFile
{
public:
CCryFile();
CCryFile(AZ::IO::IArchive* pIArchive); // allow an alternative IArchiveinterface
CCryFile(const char* filename, const char* mode);
~CCryFile();
@@ -112,13 +37,6 @@ public:
// Summary:
// Reads data from a file at the current file position.
size_t ReadRaw(void* lpBuf, size_t nSize);
// Summary:
// Template version, for automatic size support.
template<class T>
inline size_t ReadTypeRaw(T* pDest, size_t nCount = 1)
{
return ReadRaw(pDest, sizeof(T) * nCount);
}
// Summary:
// Automatic endian-swapping version.
@@ -137,27 +55,6 @@ public:
// Summary:
// Moves the current file pointer to the specified position.
size_t Seek(size_t seek, int mode);
// Summary:
// Moves the current file pointer at the beginning of the file.
void SeekToBegin();
// Summary:
// Moves the current file pointer at the end of the file.
size_t SeekToEnd();
// Summary:
// Retrieves the current file pointer.
size_t GetPosition();
// Summary:
// Tests for end-of-file on a selected file.
bool IsEof();
// Summary:
// Flushes any data yet to be written.
void Flush();
// Summary:
// Gets a handle to a pack object.
AZ::IO::HandleType GetHandle() const { return m_fileHandle; };
// Description:
// Retrieves the filename of the selected file.
@@ -193,12 +90,6 @@ inline CCryFile::CCryFile()
m_pIArchive = gEnv ? gEnv->pCryPak : NULL;
}
inline CCryFile::CCryFile(AZ::IO::IArchive* pIArchive)
{
m_fileHandle = AZ::IO::InvalidHandle;
m_pIArchive = pIArchive;
}
//////////////////////////////////////////////////////////////////////////
inline CCryFile::CCryFile(const char* filename, const char* mode)
{
@@ -336,58 +227,6 @@ inline size_t CCryFile::Seek(size_t seek, int mode)
return 1;
}
//////////////////////////////////////////////////////////////////////////
inline void CCryFile::SeekToBegin()
{
Seek(0, SEEK_SET);
}
//////////////////////////////////////////////////////////////////////////
inline size_t CCryFile::SeekToEnd()
{
return Seek(0, SEEK_END);
}
//////////////////////////////////////////////////////////////////////////
inline size_t CCryFile::GetPosition()
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
return m_pIArchive->FTell(m_fileHandle);
}
AZ::u64 tellOffset = 0;
AZ::IO::FileIOBase::GetInstance()->Tell(m_fileHandle, tellOffset);
return static_cast<size_t>(tellOffset);
}
//////////////////////////////////////////////////////////////////////////
inline bool CCryFile::IsEof()
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
return m_pIArchive->FEof(m_fileHandle) != 0;
}
return AZ::IO::FileIOBase::GetInstance()->Eof(m_fileHandle);
}
//////////////////////////////////////////////////////////////////////////
inline void CCryFile::Flush()
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
m_pIArchive->FFlush(m_fileHandle);
}
AZ::IO::FileIOBase::GetInstance()->Flush(m_fileHandle);
}
//////////////////////////////////////////////////////////////////////////
inline bool CCryFile::IsInPak() const
{
@@ -433,5 +272,3 @@ inline const char* CCryFile::GetAdjustedFilename() const
}
return szAdjustedFile;
}
#endif // CRYINCLUDE_CRYCOMMON_CRYFILE_H
-7
View File
@@ -15,7 +15,6 @@
typedef uint16 CryHalf;
class ICrySizer;
typedef union floatint_union
{
@@ -138,9 +137,6 @@ struct CryHalf2
{
return x != rhs.x || y != rhs.y;
}
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
};
struct CryHalf4
@@ -193,9 +189,6 @@ struct CryHalf4
{
return x != rhs.x || y != rhs.y || z != rhs.z || w != rhs.w;
}
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
};
#endif // #ifndef CRY_HALF_INL
+2 -8
View File
@@ -21,7 +21,8 @@
#pragma once
#include <CrySizer.h>
#include "Cry_Math.h"
#include <StlUtils.h>
/************************************************************************
Core elements:
@@ -151,13 +152,6 @@ public:
// Allow TListeners::Notifier style usage
typedef class CListenerNotifier<T> Notifier;
void GetMemoryUsage(ICrySizer* pSizer) const
{
pSizer->AddContainer(m_listeners);
#if defined(CRY_LISTENERSET_DEBUG)
pSizer->AddContainer(m_allocatedNames);
#endif
}
private: // DO NOT REMOVE - following methods only to be accessed only via CNotifier
struct ListenerRecord
-212
View File
@@ -1,212 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Simple POD types container
#ifndef CRYINCLUDE_CRYCOMMON_CRYPODARRAY_H
#define CRYINCLUDE_CRYCOMMON_CRYPODARRAY_H
#pragma once
#include <AzCore/std/containers/vector.h>
//////////////////////////////////////////////////////////////////////////
// POD Array
// vector like class (random access O(1)) without construction/destructor/copy constructor/assignment handling
// over-allocation allows safe prefetching where required without worrying about memory page boundaries
//////////////////////////////////////////////////////////////////////////
template <class T, size_t overAllocBytes = 0>
class PodArray
{
AZStd::vector<T> m_elements;
public:
typedef T value_type;
typedef T* iterator;
typedef const T* const_iterator;
//////////////////////////////////////////////////////////////////////////
// STL compatible interface
//////////////////////////////////////////////////////////////////////////
void resize(size_t numElements)
{
m_elements.resize(numElements);
}
//////////////////////////////////////////////////////////////////////////
ILINE void reserve(unsigned numElements) { m_elements.reserve(numElements); }
ILINE void push_back(const T& rElement) { m_elements.push_back(rElement); }
ILINE size_t size() const { return m_elements.size(); }
ILINE size_t capacity() const { return m_elements.capacity(); }
ILINE void clear() { m_elements.clear(); }
ILINE T* begin() { return m_elements.begin(); }
ILINE T* end() { return m_elements.end(); }
ILINE const T* begin() const { return m_elements.begin(); }
ILINE const T* end() const { return m_elements.end(); }
ILINE bool empty() const { return m_elements.empty(); }
ILINE const T& front() const { return m_elements.front(); }
ILINE T& front() { return m_elements.front(); }
ILINE const T& back() const { return m_elements.back(); }
ILINE T& back() { return m_elements.back(); }
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
PodArray()
: m_elements()
{
}
PodArray(int elem_count, int nNewCount = 0)
{
m_elements.reserve(elem_count);
m_elements.resize(nNewCount);
}
PodArray(const PodArray<T>& from)
: m_elements(from.m_elements)
{
}
~PodArray()
{
}
void Reset() { m_elements.clear(); }
void Free()
{
m_elements.clear();
m_elements.shrink_to_fit();
}
ILINE void Clear()
{
m_elements.clear();
}
int Find(const T& p)
{
const auto it = AZStd::find(m_elements.begin(), m_elements.end(), p);
if (it != m_elements.end())
{
return static_cast<int>(AZStd::distance(m_elements.begin(), it));
}
return -1;
}
inline void AddList(const PodArray<T>& lstAnother)
{
AZStd::copy(lstAnother.m_elements.begin(), lstAnother.m_elements.end(), AZStd::back_inserter(m_elements));
}
inline void AddList(T* pAnotherArray, int nAnotherCount)
{
AZStd::copy(pAnotherArray, pAnotherArray + nAnotherCount, AZStd::back_inserter(m_elements));
}
ILINE void Add(const T& p)
{
m_elements.push_back(p);
}
ILINE T& AddNew()
{
m_elements.emplace_back();
return m_elements.back();
}
void InsertBefore(const T& p, const unsigned int nBefore)
{
m_elements.insert(m_elements.begin() + nBefore, p);
}
void CheckAllocated(int elem_count)
{
if (m_elements.size() < elem_count)
{
m_elements.resize(elem_count);
}
}
void PreAllocate(int elem_count, int nNewCount = -1)
{
m_elements.reserve(elem_count);
if (nNewCount >= 0)
{
m_elements.resize(nNewCount);
}
}
inline void Delete(const int nElemId, const int nElemCount = 1)
{
AZ_Assert(nElemId >= 0 && nElemId + nElemCount <= size(), "Index out of bounds");
m_elements.erase(m_elements.begin() + nElemId, m_elements.begin() + nElemId + nElemCount);
}
inline void DeleteFastUnsorted(const int nElemId, const int nElemCount = 1)
{
AZ_Assert(nElemId >= 0 && nElemId + nElemCount <= size(), "Index out of bounds");
m_elements.erase(m_elements.begin() + nElemId, m_elements.begin() + nElemId + nElemCount);
}
inline bool Delete(const T& del)
{
const size_t numElements = m_elements.size();
m_elements.erase(std::remove(m_elements.begin(), m_elements.end(), del), m_elements.end());
return numElements != m_elements.size();
}
ILINE size_t Count() const { return m_elements.size(); }
ILINE size_t Size() const { return m_elements.size(); }
ILINE int IsEmpty() const { return m_elements.empty(); }
ILINE const T& operator [] (int i) const { return m_elements[i]; }
ILINE T& operator [] (int i) { return m_elements[i]; }
ILINE const T& GetAt(int i) const { return m_elements[i]; }
ILINE T& GetAt(int i) { return m_elements[i]; }
ILINE const T* Get(int i) const { return &m_elements[i]; }
ILINE T* Get(int i) { return &m_elements[i]; }
ILINE const T* GetElements() const { return m_elements.data(); }
ILINE T* GetElements() { return m_elements.data(); }
ILINE unsigned int GetDataSize() const { return m_elements.size() * sizeof(T); }
const T& Last() const { return m_elements.back(); }
T& Last() { return m_elements.back(); }
ILINE void DeleteLast()
{
assert(!m_elements.empty());
m_elements.pop_back();
}
PodArray<T>& operator=(const PodArray<T>& source_list)
{
m_elements = source_list.m_elements;
return *this;
}
//////////////////////////////////////////////////////////////////////////
// Return true if arrays have the same data.
bool Compare(const PodArray<T>& l) const
{
return m_elements == l.m_elements;
}
// for statistics
ILINE size_t ComputeSizeInMemory() const
{
return (sizeof(*this) + sizeof(T) * m_elements.capacity()) + overAllocBytes;
}
ILINE void RemoveIf(AZStd::function<bool(const T&)> testFunc)
{
m_elements.erase(AZStd::remove_if(m_elements.begin(), m_elements.end(), testFunc), m_elements.end());
}
};
#endif // CRYINCLUDE_CRYCOMMON_CRYPODARRAY_H
-563
View File
@@ -1,563 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Declaration and definition of the CrySizer class, which is used to
// calculate the memory usage by the subsystems and components, to help
// the artists keep the memory budged low.
#ifndef CRYINCLUDE_CRYCOMMON_CRYSIZER_H
#define CRYINCLUDE_CRYCOMMON_CRYSIZER_H
#pragma once
//////////////////////////////////////////////////////////////////////////
// common containers for overloads
#include <list>
#include "Cry_Math.h"
#include <StlUtils.h>
#include <CryPodArray.h>
#include <Cry_Vector3.h>
#include <Cry_Quat.h>
#include <Cry_Color.h>
#include <smartptr.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
// forward declarations for overloads
struct AABB;
struct SVF_P3F;
struct SVF_P3F_C4B_T2F;
struct SVF_P3S_C4B_T2S;
struct SPipTangents;
#ifdef WIN64
#include <string.h> // workaround for Amd64 compiler
#endif
namespace AZ
{
class Vector3;
}
// flags applicable to the ICrySizer (retrieved via getFlags() method)
//
enum ICrySizerFlagsEnum
{
// if this flag is set, during getSize(), the subsystem must count all the objects
// it uses in the other subsystems also
CSF_RecurseSubsystems = 1 << 0,
CSF_Reserved1 = 1 << 1,
CSF_Reserved2 = 1 << 2
};
//////////////////////////////////////////////////////////////////////////
// Helper functions to calculate size of the std containers.
//////////////////////////////////////////////////////////////////////////
namespace stl
{
template <class Map>
inline size_t size_of_map(const Map& m)
{
if (!m.empty())
{
return m.size() * sizeof(typename Map::value_type) + m.size() * sizeof(MapLikeStruct);
}
return 0;
}
template <class Map>
inline size_t size_of_set(const Map& m)
{
if (!m.empty())
{
return m.size() * sizeof(typename Map::value_type) + m.size() * sizeof(MapLikeStruct);
}
return 0;
}
template <class List>
inline size_t size_of_list(const List& c)
{
if (!c.empty())
{
return c.size() * sizeof(typename List::value_type) + c.size() * sizeof(void*) * 2; // sizeof stored type + 2 pointers prev,next
}
return 0;
}
template <class Deque>
inline size_t size_of_deque(const Deque& c)
{
if (!c.empty())
{
return c.size() * sizeof(typename Deque::value_type);
}
return 0;
}
};
//////////////////////////////////////////////////////////////////////////
// interface ICrySizer
// USAGE
// An instance of this class is passed down to each and every component in the system.
// Every component it's passed to optionally pushes its name on top of the
// component name stack (thus ensuring that all the components calculated down
// the tree will be assigned the correct subsystem/component name)
// Every component must Add its size with one of the Add* functions, and Add the
// size of all its subcomponents recursively
// In order to push the component/system name on the name stack, the clients must
// use the SIZER_COMPONENT_NAME macro or CrySizerComponentNameHelper class:
//
// void X::getSize (ICrySizer* pSizer)
// {
// SIZER_COMPONENT_NAME(pSizer, X);
// if (!pSizer->Add (this))
// return;
// pSizer->Add (m_arrMySimpleArray);
// pSizer->Add (m_setMySimpleSet);
// m_pSubobject->getSize (pSizer);
// }
//
// The Add* functions return bool. If they return true, then the object has been added
// to the set for the first time, and you should go on recursively adding all its children.
// If it returns false, then you can spare time and rather not go on into recursion;
// however it doesn't reflect on the results: an object that's added more than once is
// counted only once.
//
// WARNING:
// If you have an array (pointer), you should Add its size with addArray
class ICrySizer
{
public:
virtual ~ICrySizer(){}
// this class is used to push/pop the name to/from the stack automatically
// (to exclude stack overruns or underruns at runtime)
friend class CrySizerComponentNameHelper;
virtual void Release() = 0;
// Return total calculated size.
virtual size_t GetTotalSize() = 0;
// Return total objects added.
virtual size_t GetObjectCount() = 0;
// Resets the counting.
virtual void Reset() = 0;
virtual void End() = 0;
// adds an object identified by the unique pointer (it needs not be
// the actual object position in the memory, though it would be nice,
// but it must be unique throughout the system and unchanging for this object)
// nCount parameter is only used for counting number of objects, it doesnt affect the size of the object.
// RETURNS: true if the object has actually been added (for the first time)
// and calculated
virtual bool AddObject (const void* pIdentifier, size_t nSizeBytes, int nCount = 1) = 0;
template<typename Type>
bool AddObjectSize(const Type* pObj)
{
return AddObject(pObj, sizeof *pObj);
}
////////////////////////////////////////////////////////////////////////////////////////
// temp dummy function while checking in the CrySizer changes, will be removed soon
template<typename Type>
void AddObject(const Type& rObj)
{
(void)rObj;
}
template<typename Type>
void AddObject(Type* pObj)
{
if (pObj)
{
//forward to reference object to allow function overload
this->AddObject(*pObj);
}
}
// overloads for smart_ptr and other common objects
template<typename T>
void AddObject(const _smart_ptr<T>& rObj) { this->AddObject(rObj.get()); }
template<typename T>
void AddObject(const AZStd::shared_ptr<T>& rObj) { this->AddObject(rObj.get()); }
template<typename T>
void AddObject(const std::shared_ptr<T>& rObj) { this->AddObject(rObj.get()); }
template<typename T>
void AddObject(const std::unique_ptr<T>& rObj) { this->AddObject(rObj.get()); }
template<typename T, typename U>
void AddObject(const std::pair<T, U>& rPair)
{
this->AddObject(rPair.first);
this->AddObject(rPair.second);
}
template<typename T, typename U>
void AddObject(const AZStd::pair<T, U>& rPair)
{
this->AddObject(rPair.first);
this->AddObject(rPair.second);
}
void AddObject(const AZStd::string& rString) {this->AddObject(rString.c_str(), rString.capacity()); }
void AddObject(const wchar_t&) {}
void AddObject(const char&) {}
void AddObject(const unsigned char&) {}
void AddObject(const signed char&) {}
void AddObject(const short&) {}
void AddObject(const unsigned short&) {}
void AddObject(const int&) {}
void AddObject(const unsigned int&) {}
void AddObject(const long&) {}
void AddObject(const unsigned long&) {}
void AddObject(const float&) {}
void AddObject(const bool&) {}
void AddObject(const unsigned long long&) {}
void AddObject(const long long&) {}
void AddObject(const double&) {}
void AddObject(const Vec2&) {}
void AddObject(const Vec3&) {}
void AddObject(const Vec4&) {}
void AddObject(const Ang3&) {}
void AddObject(const Matrix34&) {}
void AddObject(const Quat&) {}
void AddObject(const QuatT&) {}
void AddObject(const QuatTS&) {}
void AddObject(const ColorF&) {}
void AddObject(const AABB&) {}
void AddObject(const SVF_P3F&) {}
void AddObject(const SVF_P3F_C4B_T2F&) {}
void AddObject(const SVF_P3S_C4B_T2S&) {}
void AddObject(const SPipTangents&) {}
void AddObject([[maybe_unused]] const AZ::Vector3& rObj) {}
void AddObject(void*) {}
// overloads for container, will automaticly traverse the content
template<typename T, typename Alloc>
void AddObject(const std::list<T, Alloc>& rList)
{
// dummy struct to get correct element size
struct Dummy
{
void* a;
void* b;
T t;
};
for (typename std::list<T, Alloc>::const_iterator it = rList.begin(); it != rList.end(); ++it)
{
if (this->AddObject(&(*it), sizeof(Dummy)))
{
this->AddObject(*it);
}
}
}
template<typename K, typename T, typename Comp, typename Equal, typename Alloc>
void AddObject([[maybe_unused]] const AZStd::unordered_map<K, T, Comp, Equal, Alloc>& rVector)
{
}
template<typename T, typename Alloc>
void AddObject(const std::vector<T, Alloc>& rVector)
{
if (rVector.empty())
{
this->AddObject(&rVector, rVector.capacity() * sizeof(T));
return;
}
if (!this->AddObject(&rVector[0], rVector.capacity() * sizeof(T)))
{
return;
}
for (typename std::vector<T, Alloc>::const_iterator it = rVector.begin(); it != rVector.end(); ++it)
{
this->AddObject(*it);
}
}
template<typename T, typename Alloc>
void AddObject(const std::deque<T, Alloc>& rVector)
{
for (typename std::deque<T, Alloc>::const_iterator it = rVector.begin(); it != rVector.end(); ++it)
{
if (this->AddObject(&(*it), sizeof(T)))
{
this->AddObject(*it);
}
}
}
template<typename T>
void AddObject(const PodArray<T>& rVector)
{
if (!this->AddObject(rVector.begin(), rVector.capacity() * sizeof(T)))
{
return;
}
for (typename PodArray<T>::const_iterator it = rVector.begin(); it != rVector.end(); ++it)
{
this->AddObject(*it);
}
}
template<typename K, typename T, typename Comp, typename Alloc>
void AddObject(const std::map<K, T, Comp, Alloc>& rVector)
{
// dummy struct to get correct element size
struct Dummy
{
void* a;
void* b;
void* c;
void* d;
K k;
T t;
};
for (typename std::map<K, T, Comp, Alloc>::const_iterator it = rVector.begin(); it != rVector.end(); ++it)
{
if (this->AddObject(&(*it), sizeof(Dummy)))
{
this->AddObject(it->first);
this->AddObject(it->second);
}
}
}
template<typename T, typename Comp, typename Alloc>
void AddObject(const std::set<T, Comp, Alloc>& rVector)
{
// dummy struct to get correct element size
struct Dummy
{
void* a;
void* b;
void* c;
void* d;
T t;
};
for (typename std::set<T, Comp, Alloc>::const_iterator it = rVector.begin(); it != rVector.end(); ++it)
{
if (this->AddObject(&(*it), sizeof(Dummy)))
{
this->AddObject(*it);
}
}
}
template <typename TKey, typename TValue, typename TPredicate, typename TAlloc>
void AddObject (const std::multimap<TKey, TValue, TPredicate, TAlloc>& rContainer)
{
AddContainer(rContainer);
}
////////////////////////////////////////////////////////////////////////////////////////
template <typename T>
bool Add (const T* pId, size_t num)
{
return AddObject(pId, num * sizeof(T));
}
template <class T>
bool Add (const T& rObject)
{
return AddObject (&rObject, sizeof(T));
}
bool Add (const char* szText)
{
return AddObject(szText, strlen(szText) + 1);
}
template <class StringCls>
bool AddString (const StringCls& strText)
{
if (!strText.empty())
{
return AddObject (strText.c_str(), strText.size());
}
else
{
return false;
}
}
#ifdef _XSTRING_
template <class Elem, class Traits, class Allocator>
bool Add (const std::basic_string<Elem, Traits, Allocator>& strText)
{
AddString (strText);
return true;
}
#endif
#ifndef NOT_USE_CRY_STRING
bool Add (const AZStd::string& strText)
{
AddString(strText);
return true;
}
#endif
// Template helper function to add generic stl container
template <typename Container>
bool AddContainer (const Container& rContainer)
{
if (rContainer.capacity())
{
return AddObject (&rContainer, rContainer.capacity() * sizeof(typename Container::value_type));
}
return false;
}
template <typename Container>
bool AddHashMap(const Container& rContainer)
{
if (!rContainer.empty())
{
return AddObject (&(*rContainer.begin()), rContainer.size() * sizeof(typename Container::value_type));
}
return false;
}
// Specialization of the AddContainer for the std::list
template <typename Type, typename TAlloc>
bool AddContainer (const std::list<Type, TAlloc>& rContainer)
{
if (!rContainer.empty())
{
return AddObject(&(*rContainer.begin()), stl::size_of_list(rContainer));
}
return false;
}
// Specialization of the AddContainer for the std::deque
template <typename Type, typename TAlloc>
bool AddContainer (const std::deque<Type, TAlloc>& rContainer)
{
if (!rContainer.empty())
{
return AddObject(&(*rContainer.begin()), stl::size_of_deque(rContainer));
}
return false;
}
// Specialization of the AddContainer for the std::map
template <typename TKey, typename TValue, typename TPredicate, typename TAlloc>
bool AddContainer (const std::map<TKey, TValue, TPredicate, TAlloc>& rContainer)
{
if (!rContainer.empty())
{
return AddObject(&(*rContainer.begin()), stl::size_of_map(rContainer));
}
return false;
}
// Specialization of the AddContainer for the std::multimap
template <typename TKey, typename TValue, typename TPredicate, typename TAlloc>
bool AddContainer (const std::multimap<TKey, TValue, TPredicate, TAlloc>& rContainer)
{
if (!rContainer.empty())
{
return AddObject(&(*rContainer.begin()), stl::size_of_map(rContainer));
}
return false;
}
// Specialization of the AddContainer for the std::set
template <typename TKey, typename TPredicate, typename TAlloc>
bool AddContainer (const std::set<TKey, TPredicate, TAlloc>& rContainer)
{
if (!rContainer.empty())
{
return AddObject(&(*rContainer.begin()), stl::size_of_set(rContainer));
}
return false;
}
// Specialization of the AddContainer for the AZStd::unordered_map
template <typename KEY, typename TYPE, class HASH, class EQUAL, class ALLOCATOR>
bool AddContainer(const AZStd::unordered_map<KEY, TYPE, HASH, EQUAL, ALLOCATOR>& rContainer)
{
if (!rContainer.empty())
{
return AddObject(&(*rContainer.begin()), rContainer.size() * sizeof(typename AZStd::unordered_map<KEY, TYPE, HASH, EQUAL, ALLOCATOR>::value_type));
}
else
{
return false;
}
}
void Test()
{
std::map<int, float> mymap;
AddContainer(mymap);
}
// returns the flags
unsigned GetFlags() const {return m_nFlags; }
protected:
// these functions must operate on the component name stack
// they are to be only accessible from within class CrySizerComponentNameHelper
// which should be used through macro SIZER_COMPONENT_NAME
virtual void Push (const char* szComponentName) = 0;
// pushes the name that is the name of the previous component . (dot) this name
virtual void PushSubcomponent (const char* szSubcomponentName) = 0;
virtual void Pop () = 0;
unsigned m_nFlags;
};
//////////////////////////////////////////////////////////////////////////
// This is on-stack class that is only used to push/pop component names
// to/from the sizer name stack.
//
// USAGE:
//
// Create an instance of this class at the start of a function, before
// calling Add* methods of the sizer interface. Everything added in the
// function and below will be considered this component, unless
// explicitly set otherwise.
//
class CrySizerComponentNameHelper
{
public:
// pushes the component name on top of the name stack of the given sizer
CrySizerComponentNameHelper (ICrySizer* pSizer, const char* szComponentName, bool bSubcomponent)
: m_pSizer(pSizer)
{
if (bSubcomponent)
{
pSizer->PushSubcomponent (szComponentName);
}
else
{
pSizer->Push (szComponentName);
}
}
// pops the component name off top of the name stack of the sizer
~CrySizerComponentNameHelper()
{
m_pSizer->Pop();
}
protected:
ICrySizer* m_pSizer;
};
// use this to push (and automatically pop) the sizer component name at the beginning of the
// getSize() function
#define SIZER_COMPONENT_NAME(pSizerPointer, szComponentName) CrySizerComponentNameHelper AZ_JOIN(sizerHelper, __LINE__)(pSizerPointer, szComponentName, false)
#define SIZER_SUBCOMPONENT_NAME(pSizerPointer, szComponentName) CrySizerComponentNameHelper AZ_JOIN(sizerHelper, __LINE__)(pSizerPointer, szComponentName, true)
#endif // CRYINCLUDE_CRYCOMMON_CRYSIZER_H
File diff suppressed because it is too large Load Diff
-779
View File
@@ -8,21 +8,12 @@
// Description : 4D Color template.
#ifndef CRYINCLUDE_CRYCOMMON_CRY_COLOR_H
#define CRYINCLUDE_CRYCOMMON_CRY_COLOR_H
#pragma once
#include <platform.h>
#include <AzCore/std/containers/array.h>
#include "Cry_Math.h"
ILINE float FClamp(float X, float Min, float Max)
{
return X < Min ? Min : X < Max ? X : Max;
}
template <class T>
struct Color_tpl;
@@ -54,44 +45,6 @@ struct Color_tpl
ILINE Color_tpl(const Vec3& c, float fAlpha);
ILINE Color_tpl(const Vec4& c);
void Clamp(float Min = 0, float Max = 1.0f)
{
r = ::FClamp(r, Min, Max);
g = ::FClamp(g, Min, Max);
b = ::FClamp(b, Min, Max);
a = ::FClamp(a, Min, Max);
}
void ScaleCol (float f)
{
r = static_cast<T>(r * f);
g = static_cast<T>(g * f);
b = static_cast<T>(b * f);
}
float Luminance() const
{
return r * 0.30f + g * 0.59f + b * 0.11f;
}
ILINE float Max() const
{
return max(r, max(b, g));
}
float NormalizeCol (ColorF& out) const
{
float max = Max();
if (max == 0)
{
return 0;
}
out = *this / max;
return max;
}
ILINE Color_tpl(const Vec3& vVec)
{
r = (T)vVec.x;
@@ -114,20 +67,6 @@ struct Color_tpl
a = static_cast<T>(fA);
}
ILINE void set(T _x, T _y = 0, T _z = 0, T _w = 0)
{
r = _x;
g = _y;
b = _z;
a = _w;
}
ILINE void set(T _x, T _y = 0, T _z = 0)
{
r = _x;
g = _y;
b = _z;
a = 1;
}
ILINE Color_tpl operator + () const
{
return *this;
@@ -227,117 +166,12 @@ struct Color_tpl
return (r != v.r) || (g != v.g) || (b != v.b) || (a != v.a);
}
ILINE unsigned char pack_rgb332() const;
ILINE unsigned short pack_argb4444() const;
ILINE unsigned short pack_rgb555() const;
ILINE unsigned short pack_rgb565() const;
ILINE unsigned int pack_bgr888() const;
ILINE unsigned int pack_rgb888() const;
ILINE unsigned int pack_abgr8888() const;
ILINE unsigned int pack_argb8888() const;
inline Vec4 toVec4() const { return Vec4(r, g, b, a); }
inline Vec3 toVec3() const { return Vec3(r, g, b); }
inline void toFloat4(f32* out) const;
inline void toHSV(f32& h, f32& s, f32& v) const;
inline void fromHSV(f32 h, f32 s, f32 v);
inline void clamp(T bottom = 0.0f, T top = 1.0f);
inline void maximum(const Color_tpl<T>& ca, const Color_tpl<T>& cb);
inline void minimum(const Color_tpl<T>& ca, const Color_tpl<T>& cb);
inline void abs();
inline void adjust_contrast(T c);
inline void adjust_saturation(T s);
inline void adjust_luminance(float newLum);
inline void lerpFloat(const Color_tpl<T>& ca, const Color_tpl<T>& cb, float s);
inline void negative(const Color_tpl<T>& c);
inline void grey(const Color_tpl<T>& c);
// helper function - maybe we can improve the integration
static inline uint32 ComputeAvgCol_Fast(const uint32 dwCol0, const uint32 dwCol1)
{
uint32 dwHalfCol0 = (dwCol0 / 2) & 0x7f7f7f7f; // each component /2
uint32 dwHalfCol1 = (dwCol1 / 2) & 0x7f7f7f7f; // each component /2
return dwHalfCol0 + dwHalfCol1;
}
// mCIE: adjusted to compensate problems of DXT compression (extra bit in green channel causes green/purple artifacts)
// explained in CryEngine wiki: ColorSpaces
Color_tpl<T> RGB2mCIE() const
{
Color_tpl<T> in = *this;
// to get grey chrominance for dark colors
in.r += 0.000001f;
in.g += 0.000001f;
in.b += 0.000001f;
float RGBSum = in.r + in.g + in.b;
float fInv = 1.0f / RGBSum;
float RNorm = 3 * 10.0f / 31.0f * in.r * fInv;
float GNorm = 3 * 21.0f / 63.0f * in.g * fInv;
float Scale = RGBSum / 3.0f;
// test grey
// out.r = 10.0f/31.0f; // 1/3 = 10/30 Red range 0..30, 31 unused
// out.g = 21.0f/63.0f; // 1/3 = 21/63 Green range 0..63
RNorm = max(0.0f, min(1.0f, RNorm));
GNorm = max(0.0f, min(1.0f, GNorm));
return Color_tpl<T>(RNorm, GNorm, Scale);
}
// mCIE: adjusted to compensate problems of DXT compression (extra bit in green channel causes green/purple artefacts)
// explained in CryEngine wiki: ColorSpaces
Color_tpl<T> mCIE2RGB() const
{
Color_tpl<T> out = *this;
float fScale = out.b; // Blue range 0..31
// test grey
// out.r = 10.0f/31.0f; // 1/3 = 10/30 Red range 0..30, 31 unused
// out.g = 21.0f/63.0f; // 1/3 = 21/63 Green range 0..63
out.r *= 31.0f / 30.0f; //
out.g *= 63.0f / 63.0f; //
out.b = 0.999f - out.r - out.g;
float s = 3.0f * fScale;
out.r *= s;
out.g *= s;
out.b *= s;
out.Clamp();
return out;
}
void rgb2srgb()
{
for (int i = 0; i < 3; i++)
{
T& c = (*this)[i];
if (c < 0.0031308f)
{
c = 12.92f * c;
}
else
{
c = 1.055f * pow(c, 1.0f / 2.4f) - 0.055f;
}
}
}
void srgb2rgb()
{
for (int i = 0; i < 3; i++)
@@ -355,8 +189,6 @@ struct Color_tpl
}
}
void GetMemoryUsage([[maybe_unused]] class ICrySizer* pSizer) const { /*nothing*/}
AZStd::array<T, 4> GetAsArray() const
{
AZStd::array<T, 4> primitiveArray = { { r, g, b, a } };
@@ -512,35 +344,10 @@ ILINE Color_tpl<uint8>::Color_tpl(const Vec4& c)
a = (uint8)(c.w * 255);
}
template<>
inline void Color_tpl<uint8>::toFloat4(f32* out) const
{
out[0] = r / 255.0f;
out[1] = g / 255.0f;
out[2] = b / 255.0f;
out[3] = a / 255.0f;
}
template<>
inline void Color_tpl<f32>::toFloat4(f32* out) const
{
out[0] = r;
out[1] = g;
out[2] = b;
out[3] = a;
}
//////////////////////////////////////////////////////////////////////////////////////////////
// functions implementation
///////////////////////////////////////////////
///////////////////////////////////////////////
/*template <class T>
inline Color_tpl<T>::Color_tpl(const T *p_elts)
{
r = p_elts[0]; g = p_elts[1]; b = p_elts[2]; a = p_elts[3];
}*/
///////////////////////////////////////////////
///////////////////////////////////////////////
template <class T>
@@ -549,178 +356,6 @@ ILINE Color_tpl<T> operator * (T s, const Color_tpl<T>& v)
return Color_tpl<T>(v.r * s, v.g * s, v.b * s, v.a * s);
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned char Color_tpl<T>::pack_rgb332() const
{
unsigned char cr;
unsigned char cg;
unsigned char cb;
if constexpr (sizeof(r) == 1) // char and unsigned char
{
cr = (unsigned char)r;
cg = (unsigned char)g;
cb = (unsigned char)b;
}
else if constexpr (sizeof(r) == 2) // short and unsigned short
{
cr = (unsigned short)(r) >> 8;
cg = (unsigned short)(g) >> 8;
cb = (unsigned short)(b) >> 8;
}
else // float or double
{
cr = (unsigned char)(r * 255.0f);
cg = (unsigned char)(g * 255.0f);
cb = (unsigned char)(b * 255.0f);
}
return ((cr >> 5) << 5) | ((cg >> 5) << 2) | (cb >> 5);
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned short Color_tpl<T>::pack_argb4444() const
{
unsigned char cr;
unsigned char cg;
unsigned char cb;
unsigned char ca;
if constexpr (sizeof(r) == 1) // char and unsigned char
{
cr = (unsigned char)r;
cg = (unsigned char)g;
cb = (unsigned char)b;
ca = (unsigned char)a;
}
else if constexpr (sizeof(r) == 2) // short and unsigned short
{
cr = (unsigned short)(r) >> 8;
cg = (unsigned short)(g) >> 8;
cb = (unsigned short)(b) >> 8;
ca = (unsigned short)(a) >> 8;
}
else // float or double
{
cr = (unsigned char)(r * 255.0f);
cg = (unsigned char)(g * 255.0f);
cb = (unsigned char)(b * 255.0f);
ca = (unsigned char)(a * 255.0f);
}
return ((ca >> 4) << 12) | ((cr >> 4) << 8) | ((cg >> 4) << 4) | (cb >> 4);
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned short Color_tpl<T>::pack_rgb555() const
{
unsigned char cr;
unsigned char cg;
unsigned char cb;
if constexpr (sizeof(r) == 1) // char and unsigned char
{
cr = (unsigned char)r;
cg = (unsigned char)g;
cb = (unsigned char)b;
}
else if constexpr (sizeof(r) == 2) // short and unsigned short
{
cr = (unsigned short)(r) >> 8;
cg = (unsigned short)(g) >> 8;
cb = (unsigned short)(b) >> 8;
}
else // float or double
{
cr = (unsigned char)(r * 255.0f);
cg = (unsigned char)(g * 255.0f);
cb = (unsigned char)(b * 255.0f);
}
return ((cr >> 3) << 10) | ((cg >> 3) << 5) | (cb >> 3);
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned short Color_tpl<T>::pack_rgb565() const
{
unsigned short cr;
unsigned short cg;
unsigned short cb;
if constexpr (sizeof(r) == 1) // char and unsigned char
{
cr = (unsigned short)r;
cg = (unsigned short)g;
cb = (unsigned short)b;
}
else if constexpr (sizeof(r) == 2) // short and unsigned short
{
cr = (unsigned short)(r) >> 8;
cg = (unsigned short)(g) >> 8;
cb = (unsigned short)(b) >> 8;
}
else // float or double
{
cr = (unsigned short)(r * 255.0f);
cg = (unsigned short)(g * 255.0f);
cb = (unsigned short)(b * 255.0f);
}
return ((cr >> 3) << 11) | ((cg >> 2) << 5) | (cb >> 3);
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned int Color_tpl<T>::pack_bgr888() const
{
unsigned char cr;
unsigned char cg;
unsigned char cb;
if constexpr (sizeof(r) == 1) // char and unsigned char
{
cr = (unsigned char)r;
cg = (unsigned char)g;
cb = (unsigned char)b;
}
else if constexpr (sizeof(r) == 2) // short and unsigned short
{
cr = (unsigned short)(r) >> 8;
cg = (unsigned short)(g) >> 8;
cb = (unsigned short)(b) >> 8;
}
else // float or double
{
cr = (unsigned char)(r * 255.0f);
cg = (unsigned char)(g * 255.0f);
cb = (unsigned char)(b * 255.0f);
}
return (cb << 16) | (cg << 8) | cr;
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned int Color_tpl<T>::pack_rgb888() const
{
unsigned char cr;
unsigned char cg;
unsigned char cb;
if constexpr (sizeof(r) == 1) // char and unsigned char
{
cr = (unsigned char)r;
cg = (unsigned char)g;
cb = (unsigned char)b;
}
else if constexpr (sizeof(r) == 2) // short and unsigned short
{
cr = (unsigned short)(r) >> 8;
cg = (unsigned short)(g) >> 8;
cb = (unsigned short)(b) >> 8;
}
else // float or double
{
cr = (unsigned char)(r * 255.0f);
cg = (unsigned char)(g * 255.0f);
cb = (unsigned char)(b * 255.0f);
}
return (cr << 16) | (cg << 8) | cb;
}
///////////////////////////////////////////////
template <class T>
ILINE unsigned int Color_tpl<T>::pack_abgr8888() const
@@ -786,211 +421,6 @@ ILINE unsigned int Color_tpl<T>::pack_argb8888() const
return (ca << 24) | (cr << 16) | (cg << 8) | cb;
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::toHSV(f32& h, f32& s, f32& v) const
{
f32 red, green, blue;
if constexpr (sizeof(this->r) == 1) // 8bit integer
{
red = this->r * (1.0f / f32(0xff));
green = this->g * (1.0f / f32(0xff));
blue = this->b * (1.0f / f32(0xff));
}
else if constexpr (sizeof(this->r) == 2) // 16bit integer
{
red = this->r * (1.0f / f32(0xffff));
green = this->g * (1.0f / f32(0xffff));
blue = this->b * (1.0f / f32(0xffff));
}
else // floating point
{
red = this->r;
green = this->g;
blue = this->b;
}
if ((blue > green) && (blue > red))
{
if (!::iszero(v = blue))
{
const f32 min = red < green ? red : green;
const f32 delta = v - min;
if (!::iszero(delta))
{
s = delta / v;
h = (240.0f / 360.0f) + (red - green) / delta * (60.0f / 360.0f);
}
else
{
s = 0.0f;
h = (240.0f / 360.0f) + (red - green) * (60.0f / 360.0f);
}
if (h < 0.0f)
{
h += 1.0f;
}
}
else
{
s = 0.0f;
h = 0.0f;
}
}
else if (green > red)
{
if (!::iszero(v = green))
{
const f32 min = red < blue ? red : blue;
const f32 delta = v - min;
if (!::iszero(delta))
{
s = delta / v;
h = (120.0f / 360.0f) + (blue - red) / delta * (60.0f / 360.0f);
}
else
{
s = 0.0f;
h = (120.0f / 360.0f) + (blue - red) * (60.0f / 360.0f);
}
if (h < 0.0f)
{
h += 1.0f;
}
}
else
{
s = 0.0f;
h = 0.0f;
}
}
else
{
if (!::iszero(v = red))
{
const f32 min = green < blue ? green : blue;
const f32 delta = v - min;
if (!::iszero(delta))
{
s = delta / v;
h = (green - blue) / delta * (60.0f / 360.0f);
}
else
{
s = 0.0f;
h = (green - blue) * (60.0f / 360.0f);
}
if (h < 0.0f)
{
h += 1.0f;
}
}
else
{
s = 0.0f;
h = 0.0f;
}
}
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::fromHSV(f32 h, f32 s, f32 v)
{
f32 red, green, blue;
if (::iszero(v))
{
red = 0.0f;
green = 0.0f;
blue = 0.0f;
}
else if (::iszero(s))
{
red = v;
green = v;
blue = v;
}
else
{
const f32 hi = h * 6.0f;
const int32 i = (int32)::floor(hi);
const f32 f = hi - i;
const f32 v0 = v * (1.0f - s);
const f32 v1 = v * (1.0f - s * f);
const f32 v2 = v * (1.0f - s * (1.0f - f));
switch (i)
{
case 0:
red = v;
green = v2;
blue = v0;
break;
case 1:
red = v1;
green = v;
blue = v0;
break;
case 2:
red = v0;
green = v;
blue = v2;
break;
case 3:
red = v0;
green = v1;
blue = v;
break;
case 4:
red = v2;
green = v0;
blue = v;
break;
case 5:
red = v;
green = v0;
blue = v1;
break;
case 6:
red = v;
green = v2;
blue = v0;
break;
case -1:
red = v;
green = v0;
blue = v1;
break;
default:
red = 0.0f;
green = 0.0f;
blue = 0.0f;
break;
}
}
if constexpr (sizeof(this->r) == 1) // 8bit integer
{
this->r = red * f32(0xff);
this->g = green * f32(0xff);
this->b = blue * f32(0xff);
}
else if constexpr (sizeof(this->r) == 2) // 16bit integer
{
this->r = red * f32(0xffff);
this->g = green * f32(0xffff);
this->b = blue * f32(0xffff);
}
else // floating point
{
this->r = red;
this->g = green;
this->b = blue;
}
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::clamp(T bottom, T top)
@@ -1001,214 +431,5 @@ inline void Color_tpl<T>::clamp(T bottom, T top)
a = min(top, max(bottom, a));
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::maximum(const Color_tpl<T>& ca, const Color_tpl<T>& cb)
{
r = max(ca.r, cb.r);
g = max(ca.g, cb.g);
b = max(ca.b, cb.b);
a = max(ca.a, cb.a);
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::minimum(const Color_tpl<T>& ca, const Color_tpl<T>& cb)
{
r = min(ca.r, cb.r);
g = min(ca.g, cb.g);
b = min(ca.b, cb.b);
a = min(ca.a, cb.a);
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::abs()
{
r = fabs_tpl(r);
g = fabs_tpl(g);
b = fabs_tpl(b);
a = fabs_tpl(a);
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::adjust_contrast(T c)
{
r = 0.5f + c * (r - 0.5f);
g = 0.5f + c * (g - 0.5f);
b = 0.5f + c * (b - 0.5f);
a = 0.5f + c * (a - 0.5f);
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::adjust_saturation(T s)
{
// Approximate values for each component's contribution to luminance.
// Based upon the NTSC standard described in ITU-R Recommendation BT.709.
T grey = r * 0.2125f + g * 0.7154f + b * 0.0721f;
r = grey + s * (r - grey);
g = grey + s * (g - grey);
b = grey + s * (b - grey);
a = grey + s * (a - grey);
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::adjust_luminance(float newLum)
{
// Optimized yet equivalent version of replacing luminance in XYZ space.
// Color and luminance are expected to be linear.
Color_tpl<f32> colF(r, g, b, a);
float lum = colF.r * 0.212671f + colF.g * 0.715160f + colF.b * 0.072169f;
if (iszero(lum))
{
return;
}
*this = Color_tpl<T>(colF * newLum / lum);
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::lerpFloat(const Color_tpl<T>& ca, const Color_tpl<T>& cb, float s)
{
r = (T)(ca.r + s * (cb.r - ca.r));
g = (T)(ca.g + s * (cb.g - ca.g));
b = (T)(ca.b + s * (cb.b - ca.b));
a = (T)(ca.a + s * (cb.a - ca.a));
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::negative([[maybe_unused]] const Color_tpl<T>& c)
{
r = T(1.0f) - r;
g = T(1.0f) - g;
b = T(1.0f) - b;
a = T(1.0f) - a;
}
///////////////////////////////////////////////
template <class T>
inline void Color_tpl<T>::grey([[maybe_unused]] const Color_tpl<T>& c)
{
T m = (r + g + b) / T(3);
r = m;
g = m;
b = m;
}
//////////////////////////////////////////////////////////////////////////////////////////////
//#define RGBA8(r,g,b,a) (ColorB((uint8)(r),(uint8)(g),(uint8)(b),(uint8)(a)))
#if defined(NEED_ENDIAN_SWAP)
#define RGBA8(a, b, g, r) ((uint32)(((uint8)(r) | ((uint16)((uint8)(g)) << 8)) | (((uint32)(uint8)(b)) << 16)) | (((uint32)(uint8)(a)) << 24))
#else
#define RGBA8(r, g, b, a) ((uint32)(((uint8)(r) | ((uint16)((uint8)(g)) << 8)) | (((uint32)(uint8)(b)) << 16)) | (((uint32)(uint8)(a)) << 24))
#endif
#define Col_Black ColorF (0.000f, 0.000f, 0.000f) // 0xFF000000 RGB: 0, 0, 0
#define Col_White ColorF (1.000f, 1.000f, 1.000f) // 0xFFFFFFFF RGB: 255, 255, 255
#define Col_Aquamarine ColorF (0.498f, 1.000f, 0.831f) // 0xFF7FFFD4 RGB: 127, 255, 212
#define Col_Azure ColorF (0.000f, 0.498f, 1.000f) // 0xFF007FFF RGB: 0, 127, 255
#define Col_Blue ColorF (0.000f, 0.000f, 1.000f) // 0xFF0000FF RGB: 0, 0, 255
#define Col_BlueViolet ColorF (0.541f, 0.169f, 0.886f) // 0xFF8A2BE2 RGB: 138, 43, 226
#define Col_Brown ColorF (0.647f, 0.165f, 0.165f) // 0xFFA52A2A RGB: 165, 42, 42
#define Col_CadetBlue ColorF (0.373f, 0.620f, 0.627f) // 0xFF5F9EA0 RGB: 95, 158, 160
#define Col_Coral ColorF (1.000f, 0.498f, 0.314f) // 0xFFFF7F50 RGB: 255, 127, 80
#define Col_CornflowerBlue ColorF (0.392f, 0.584f, 0.929f) // 0xFF6495ED RGB: 100, 149, 237
#define Col_Cyan ColorF (0.000f, 1.000f, 1.000f) // 0xFF00FFFF RGB: 0, 255, 255
#define Col_DarkGray ColorF (0.663f, 0.663f, 0.663f) // 0xFFA9A9A9 RGB: 169, 169, 169
#define Col_DarkGrey ColorF (0.663f, 0.663f, 0.663f) // 0xFFA9A9A9 RGB: 169, 169, 169
#define Col_DarkGreen ColorF (0.000f, 0.392f, 0.000f) // 0xFF006400 RGB: 0, 100, 0
#define Col_DarkOliveGreen ColorF (0.333f, 0.420f, 0.184f) // 0xFF556B2F RGB: 85, 107, 47
#define Col_DarkOrchid ColorF (0.600f, 0.196f, 0.800f) // 0xFF9932CC RGB: 153, 50, 204
#define Col_DarkSlateBlue ColorF (0.282f, 0.239f, 0.545f) // 0xFF483D8B RGB: 72, 61, 139
#define Col_DarkSlateGray ColorF (0.184f, 0.310f, 0.310f) // 0xFF2F4F4F RGB: 47, 79, 79
#define Col_DarkSlateGrey ColorF (0.184f, 0.310f, 0.310f) // 0xFF2F4F4F RGB: 47, 79, 79
#define Col_DarkTurquoise ColorF (0.000f, 0.808f, 0.820f) // 0xFF00CED1 RGB: 0, 206, 209
#define Col_DarkWood ColorF (0.050f, 0.010f, 0.005f) // 0xFF0D0301 RGB: 13, 3, 1
#define Col_DeepPink ColorF (1.000f, 0.078f, 0.576f) // 0xFFFF1493 RGB: 255, 20, 147
#define Col_DimGray ColorF (0.412f, 0.412f, 0.412f) // 0xFF696969 RGB: 105, 105, 105
#define Col_DimGrey ColorF (0.412f, 0.412f, 0.412f) // 0xFF696969 RGB: 105, 105, 105
#define Col_FireBrick ColorF (0.698f, 0.133f, 0.133f) // 0xFFB22222 RGB: 178, 34, 34
#define Col_ForestGreen ColorF (0.133f, 0.545f, 0.133f) // 0xFF228B22 RGB: 34, 139, 34
#define Col_Gold ColorF (1.000f, 0.843f, 0.000f) // 0xFFFFD700 RGB: 255, 215, 0
#define Col_Goldenrod ColorF (0.855f, 0.647f, 0.125f) // 0xFFDAA520 RGB: 218, 165, 32
#define Col_Gray ColorF (0.502f, 0.502f, 0.502f) // 0xFF808080 RGB: 128, 128, 128
#define Col_Grey ColorF (0.502f, 0.502f, 0.502f) // 0xFF808080 RGB: 128, 128, 128
#define Col_Green ColorF (0.000f, 0.502f, 0.000f) // 0xFF008000 RGB: 0, 128, 0
#define Col_GreenYellow ColorF (0.678f, 1.000f, 0.184f) // 0xFFADFF2F RGB: 173, 255, 47
#define Col_IndianRed ColorF (0.804f, 0.361f, 0.361f) // 0xFFCD5C5C RGB: 205, 92, 92
#define Col_Khaki ColorF (0.941f, 0.902f, 0.549f) // 0xFFF0E68C RGB: 240, 230, 140
#define Col_LightBlue ColorF (0.678f, 0.847f, 0.902f) // 0xFFADD8E6 RGB: 173, 216, 230
#define Col_LightGray ColorF (0.827f, 0.827f, 0.827f) // 0xFFD3D3D3 RGB: 211, 211, 211
#define Col_LightGrey ColorF (0.827f, 0.827f, 0.827f) // 0xFFD3D3D3 RGB: 211, 211, 211
#define Col_LightSteelBlue ColorF (0.690f, 0.769f, 0.871f) // 0xFFB0C4DE RGB: 176, 196, 222
#define Col_LightWood ColorF (0.600f, 0.240f, 0.100f) // 0xFF993D1A RGB: 153, 61, 26
#define Col_Lime ColorF (0.000f, 1.000f, 0.000f) // 0xFF00FF00 RGB: 0, 255, 0
#define Col_LimeGreen ColorF (0.196f, 0.804f, 0.196f) // 0xFF32CD32 RGB: 50, 205, 50
#define Col_Magenta ColorF (1.000f, 0.000f, 1.000f) // 0xFFFF00FF RGB: 255, 0, 255
#define Col_Maroon ColorF (0.502f, 0.000f, 0.000f) // 0xFF800000 RGB: 128, 0, 0
#define Col_MedianWood ColorF (0.300f, 0.120f, 0.030f) // 0xFF4D1F09 RGB: 77, 31, 9
#define Col_MediumAquamarine ColorF (0.400f, 0.804f, 0.667f) // 0xFF66CDAA RGB: 102, 205, 170
#define Col_MediumBlue ColorF (0.000f, 0.000f, 0.804f) // 0xFF0000CD RGB: 0, 0, 205
#define Col_MediumForestGreen ColorF (0.420f, 0.557f, 0.137f) // 0xFF6B8E23 RGB: 107, 142, 35
#define Col_MediumGoldenrod ColorF (0.918f, 0.918f, 0.678f) // 0xFFEAEAAD RGB: 234, 234, 173
#define Col_MediumOrchid ColorF (0.729f, 0.333f, 0.827f) // 0xFFBA55D3 RGB: 186, 85, 211
#define Col_MediumSeaGreen ColorF (0.235f, 0.702f, 0.443f) // 0xFF3CB371 RGB: 60, 179, 113
#define Col_MediumSlateBlue ColorF (0.482f, 0.408f, 0.933f) // 0xFF7B68EE RGB: 123, 104, 238
#define Col_MediumSpringGreen ColorF (0.000f, 0.980f, 0.604f) // 0xFF00FA9A RGB: 0, 250, 154
#define Col_MediumTurquoise ColorF (0.282f, 0.820f, 0.800f) // 0xFF48D1CC RGB: 72, 209, 204
#define Col_MediumVioletRed ColorF (0.780f, 0.082f, 0.522f) // 0xFFC71585 RGB: 199, 21, 133
#define Col_MidnightBlue ColorF (0.098f, 0.098f, 0.439f) // 0xFF191970 RGB: 25, 25, 112
#define Col_Navy ColorF (0.000f, 0.000f, 0.502f) // 0xFF000080 RGB: 0, 0, 128
#define Col_NavyBlue ColorF (0.137f, 0.137f, 0.557f) // 0xFF23238E RGB: 35, 35, 142
#define Col_Orange ColorF (1.000f, 0.647f, 0.000f) // 0xFFFFA500 RGB: 255, 165, 0
#define Col_OrangeRed ColorF (1.000f, 0.271f, 0.000f) // 0xFFFF4500 RGB: 255, 69, 0
#define Col_Orchid ColorF (0.855f, 0.439f, 0.839f) // 0xFFDA70D6 RGB: 218, 112, 214
#define Col_PaleGreen ColorF (0.596f, 0.984f, 0.596f) // 0xFF98FB98 RGB: 152, 251, 152
#define Col_Pink ColorF (1.000f, 0.753f, 0.796f) // 0xFFFFC0CB RGB: 255, 192, 203
#define Col_Plum ColorF (0.867f, 0.627f, 0.867f) // 0xFFDDA0DD RGB: 221, 160, 221
#define Col_Red ColorF (1.000f, 0.000f, 0.000f) // 0xFFFF0000 RGB: 255, 0, 0
#define Col_Salmon ColorF (0.980f, 0.502f, 0.447f) // 0xFFFA8072 RGB: 250, 128, 114
#define Col_SeaGreen ColorF (0.180f, 0.545f, 0.341f) // 0xFF2E8B57 RGB: 46, 139, 87
#define Col_Sienna ColorF (0.627f, 0.322f, 0.176f) // 0xFFA0522D RGB: 160, 82, 45
#define Col_SkyBlue ColorF (0.529f, 0.808f, 0.922f) // 0xFF87CEEB RGB: 135, 206, 235
#define Col_SlateBlue ColorF (0.416f, 0.353f, 0.804f) // 0xFF6A5ACD RGB: 106, 90, 205
#define Col_SpringGreen ColorF (0.000f, 1.000f, 0.498f) // 0xFF00FF7F RGB: 0, 255, 127
#define Col_SteelBlue ColorF (0.275f, 0.510f, 0.706f) // 0xFF4682B4 RGB: 70, 130, 180
#define Col_Tan ColorF (0.824f, 0.706f, 0.549f) // 0xFFD2B48C RGB: 210, 180, 140
#define Col_Thistle ColorF (0.847f, 0.749f, 0.847f) // 0xFFD8BFD8 RGB: 216, 191, 216
#define Col_Transparent ColorF (0.0f, 0.0f, 0.0f, 0.0f) // 0x00000000 RGB: 0, 0, 0
#define Col_Turquoise ColorF (0.251f, 0.878f, 0.816f) // 0xFF40E0D0 RGB: 64, 224, 208
#define Col_Violet ColorF (0.933f, 0.510f, 0.933f) // 0xFFEE82EE RGB: 238, 130, 238
#define Col_VioletRed ColorF (0.800f, 0.196f, 0.600f) // 0xFFCC3299 RGB: 204, 50, 153
#define Col_Wheat ColorF (0.961f, 0.871f, 0.702f) // 0xFFF5DEB3 RGB: 245, 222, 179
#define Col_Yellow ColorF (1.000f, 1.000f, 0.000f) // 0xFFFFFF00 RGB: 255, 255, 0
#define Col_YellowGreen ColorF (0.604f, 0.804f, 0.196f) // 0xFF9ACD32 RGB: 154, 205, 50
#define Col_TrackviewDefault ColorF (0.187820792f, 0.187820792f, 1.0f)
#define Clr_Empty ColorF(0.0f, 0.0f, 0.0f, 1.0f)
#define Clr_Dark ColorF(0.15f, 0.15f, 0.15f, 1.0f)
#define Clr_White ColorF(1.0f, 1.0f, 1.0f, 1.0f)
#define Clr_WhiteTrans ColorF(1.0f, 1.0f, 1.0f, 0.0f)
#define Clr_Full ColorF(1.0f, 1.0f, 1.0f, 1.0f)
#define Clr_Neutral ColorF(1.0f, 1.0f, 1.0f, 1.0f)
#define Clr_Transparent ColorF(0.0f, 0.0f, 0.0f, 0.0f)
#define Clr_FrontVector ColorF(0.0f, 0.0f, 0.5f, 1.0f)
#define Clr_Static ColorF(127.0f / 255.0f, 127.0f / 255.0f, 0.0f, 0.0f)
#define Clr_Median ColorF(0.5f, 0.5f, 0.5f, 0.0f)
#define Clr_MedianHalf ColorF(0.5f, 0.5f, 0.5f, 0.5f)
#define Clr_FarPlane ColorF(1.0f, 0.0f, 0.0f, 0.0f)
#define Clr_FarPlane_R ColorF(bReverseDepth ? 0.0f : 1.0f, 0.0f, 0.0f, 0.0f)
#define Clr_Unknown ColorF(0.0f, 0.0f, 0.0f, 0.0f)
#define Clr_Unused ColorF(0.0f, 0.0f, 0.0f, 0.0f)
#define Clr_Debug ColorF(1.0f, 0.0f, 0.0f, 1.0f)
#endif // CRYINCLUDE_CRYCOMMON_CRY_COLOR_H
+7 -790
View File
@@ -8,10 +8,6 @@
// Description : Common structures for geometry computations
#ifndef CRYINCLUDE_CRYCOMMON_CRY_GEO_H
#define CRYINCLUDE_CRYCOMMON_CRY_GEO_H
#pragma once
#include "Cry_Math.h"
@@ -29,11 +25,6 @@ struct AABB;
template <typename F>
struct OBB_tpl;
struct Sphere;
struct AAEllipsoid;
struct Ellipsoid;
struct Cone;
//-----------------------------------------------------
@@ -41,127 +32,12 @@ struct Cone;
// Definitions //
///////////////////////////////////////////////////////////////////////////////
//
// Random geometry generation functions.
//
enum EGeomForm
{
GeomForm_Vertices,
GeomForm_Edges,
GeomForm_Surface,
GeomForm_Volume,
MaxGeomForm
};
enum EGeomType
{
GeomType_None,
GeomType_BoundingBox,
GeomType_Physics,
GeomType_Render,
};
struct PosNorm
{
Vec3 vPos;
Vec3 vNorm;
void zero()
{
vPos.zero();
vNorm.zero();
}
// transform by matrix, etc
void operator <<= (Matrix34 const& mx)
{
vPos = mx * vPos;
vNorm = Matrix33(mx) * vNorm;
}
void operator <<= (QuatTS const& qts)
{
vPos = qts * vPos;
vNorm = qts.q * vNorm;
}
void operator <<= (DualQuat const& dq)
{
vPos = dq * vPos;
vNorm = dq.nq * vNorm;
}
};
struct RectF
{
float x, y, w, h;
RectF()
: x(0)
, y(0)
, w(1)
, h(1)
{
}
};
struct RectI
{
int x, y, w, h;
RectI()
: x(0)
, y(0)
, w(1)
, h(1)
{
}
RectI(int inX, int inY, int inW, int inH)
: x(inX)
, y(inY)
, w(inW)
, h(inH)
{
}
_inline void Add(RectI rcAdd)
{
int x2 = x + w;
int y2 = y + h;
int x22 = rcAdd.x + rcAdd.w;
int y22 = rcAdd.y + rcAdd.h;
x = min(x, rcAdd.x);
y = min(y, rcAdd.y);
x2 = max(x2, x22);
y2 = max(y2, y22);
w = x2 - x;
h = y2 - y;
}
_inline void Add(int inX, int inY, int inW, int inH)
{
Add(RectI(inX, inY, inW, inH));
}
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// struct Line
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
struct Line
{
Vec3 pointonline;
Vec3 direction; //caution: the direction is important for any intersection test
//default Line constructor (without initialisation)
inline Line(void) {}
inline Line(const Vec3& o, const Vec3& d) { pointonline = o; direction = d; }
inline void operator () (const Vec3& o, const Vec3& d) { pointonline = o; direction = d; }
~Line(void) {};
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -190,26 +66,18 @@ struct Ray
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <typename F>
struct Lineseg_tpl
struct Lineseg
{
Vec3_tpl<F> start;
Vec3_tpl<F> end;
Vec3_tpl<float> start;
Vec3_tpl<float> end;
//default Lineseg constructor (without initialisation)
inline Lineseg_tpl(void) {}
inline Lineseg_tpl(const Vec3_tpl<F>& s, const Vec3_tpl<F>& e) { start = s; end = e; }
inline void operator () (const Vec3_tpl<F>& s, const Vec3_tpl<F>& e) { start = s; end = e; }
inline Lineseg(void) {}
inline Lineseg(const Vec3_tpl<float>& s, const Vec3_tpl<float>& e) { start = s; end = e; }
Vec3 GetPoint(F t) const {return t * end + (F(1.0) - t) * start; }
~Lineseg_tpl(void) {};
~Lineseg(void) {};
};
typedef Lineseg_tpl<float> Lineseg;
typedef Lineseg_tpl<real> Linesegr;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -240,33 +108,6 @@ struct Triangle_tpl
}
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// struct Cone
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
struct Cone
{
Vec3 mTip;
Vec3 mDir;
Vec3 mBase;
float mHeight;
float mBaseRadius;
Cone() {}
Cone(const Vec3& tip, const Vec3& dir, float height, float baseRadius)
: mTip(tip)
, mDir(dir)
, mBase(tip + dir * height)
, mHeight(height)
, mBaseRadius(baseRadius) {}
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -343,12 +184,6 @@ struct AABB
ILINE float GetRadius() const
{ return IsResetSel(0.0f, (max - min).GetLengthFloat() * 0.5f); }
ILINE float GetRadiusSqr() const
{ return IsResetSel(0.0f, ((max - min) * 0.5f).GetLengthSquaredFloat()); }
ILINE float GetVolume() const
{ return IsResetSel(0.0f, (max.x - min.x) * (max.y - min.y) * (max.z - min.z)); }
ILINE void Add(const Vec3& v)
{
min.CheckMin(v);
@@ -368,133 +203,6 @@ struct AABB
max.CheckMax(bb.max);
}
inline void Move(const Vec3& v)
{
const float moveMult = IsResetSel(0.0f, 1.0f);
const Vec3 vMove = v * moveMult;
min += vMove;
max += vMove;
}
inline void Expand(Vec3 const& v)
{
if (!IsReset())
{
min -= v;
max += v;
}
}
// Augment the box on all sides by a box.
inline void Augment(AABB const& bb)
{
if (!IsReset() && !bb.IsReset())
{
Add(min + bb.min);
Add(max + bb.max);
}
}
void ClipToBox(AABB const& bb)
{
min.CheckMax(bb.min);
max.CheckMin(bb.max);
}
void ClipMoveToBox(AABB const& bb)
{
for (int a = 0; a < 3; a++)
{
if (max[a] - min[a] > bb.max[a] - bb.min[a])
{
min[a] = bb.min[a];
max[a] = bb.max[a];
}
else if (min[a] < bb.min[a])
{
max[a] += bb.min[a] - min[a];
min[a] = bb.min[a];
}
else if (max[a] > bb.max[a])
{
min[a] += bb.max[a] - max[a];
max[a] = bb.max[a];
}
}
}
//! Check if this bounding box overlap with bounding box of sphere.
bool IsOverlapSphereBounds(const Vec3& pos, float radius) const
{
assert(min.IsValid());
assert(max.IsValid());
assert(pos.IsValid());
if (pos.x > min.x && pos.x < max.x && pos.y > min.y && pos.y < max.y && pos.z > min.z && pos.z < max.z)
{
return true;
}
if (pos.x + radius < min.x)
{
return false;
}
if (pos.y + radius < min.y)
{
return false;
}
if (pos.z + radius < min.z)
{
return false;
}
if (pos.x - radius > max.x)
{
return false;
}
if (pos.y - radius > max.y)
{
return false;
}
if (pos.z - radius > max.z)
{
return false;
}
return true;
}
//! Check if this bounding box contain sphere within itself.
bool IsContainSphere(const Vec3& pos, float radius) const
{
assert(min.IsValid());
assert(max.IsValid());
assert(pos.IsValid());
if (pos.x - radius < min.x)
{
return false;
}
if (pos.y - radius < min.y)
{
return false;
}
if (pos.z - radius < min.z)
{
return false;
}
if (pos.x + radius > max.x)
{
return false;
}
if (pos.y + radius > max.y)
{
return false;
}
if (pos.z + radius > max.z)
{
return false;
}
return true;
}
//! Check if this bounding box contains a point within itself.
bool IsContainPoint(const Vec3& pos) const
{
@@ -541,27 +249,6 @@ struct AABB
return sqrt(GetDistanceSqr(v));
}
bool ContainsBox(AABB const& b) const
{
assert(min.IsValid());
assert(max.IsValid());
assert(b.min.IsValid());
assert(b.max.IsValid());
return min.x <= b.min.x && min.y <= b.min.y && min.z <= b.min.z
&& max.x >= b.max.x && max.y >= b.max.y && max.z >= b.max.z;
}
bool ContainsBox2D(AABB const& b) const
{
assert(min.IsValid());
assert(max.IsValid());
assert(b.min.IsValid());
assert(b.max.IsValid());
return min.x <= b.min.x && min.y <= b.min.y
&& max.x >= b.max.x && max.y >= b.max.y;
}
// Check two bounding boxes for intersection.
inline bool IsIntersectBox(const AABB& b) const
{
@@ -622,86 +309,6 @@ struct AABB
max = pos + sz;
}
}
ILINE static AABB CreateTransformedAABB(const Matrix34& m34, const AABB& aabb)
{ AABB taabb; taabb.SetTransformedAABB(m34, aabb); return taabb; }
ILINE void SetTransformedAABB(const QuatT& qt, const AABB& aabb)
{
if (aabb.IsReset())
{
Reset();
}
else
{
Matrix33 m33 = Matrix33(qt.q);
m33.m00 = fabs_tpl(m33.m00);
m33.m01 = fabs_tpl(m33.m01);
m33.m02 = fabs_tpl(m33.m02);
m33.m10 = fabs_tpl(m33.m10);
m33.m11 = fabs_tpl(m33.m11);
m33.m12 = fabs_tpl(m33.m12);
m33.m20 = fabs_tpl(m33.m20);
m33.m21 = fabs_tpl(m33.m21);
m33.m22 = fabs_tpl(m33.m22);
Vec3 sz = m33 * ((aabb.max - aabb.min) * 0.5f);
Vec3 pos = qt * ((aabb.max + aabb.min) * 0.5f);
min = pos - sz;
max = pos + sz;
}
}
ILINE static AABB CreateTransformedAABB(const QuatT& qt, const AABB& aabb)
{ AABB taabb; taabb.SetTransformedAABB(qt, aabb); return taabb; }
//create an AABB using just the extensions of the OBB and ignore the orientation.
template<typename F>
ILINE void SetAABBfromOBB(const OBB_tpl<F>& obb)
{ min = obb.c - obb.h; max = obb.c + obb.h; }
template<typename F>
ILINE static AABB CreateAABBfromOBB(const OBB_tpl<F>& obb)
{ return AABB(obb.c - obb.h, obb.c + obb.h); }
/*!
* converts an OBB into an tight fitting AABB
*
* Example:
* AABB aabb = AABB::CreateAABBfromOBB(wposition,obb,1.0f);
*
* return values:
* expanded AABB in world-space
*/
template<typename F>
ILINE void SetAABBfromOBB(const Vec3& wpos, const OBB_tpl<F>& obb, f32 scaling = 1.0f)
{
Vec3 pos = obb.m33 * obb.c * scaling + wpos;
Vec3 sz = obb.m33.GetFabs() * obb.h * scaling;
min = pos - sz;
max = pos + sz;
}
template<typename F>
ILINE static AABB CreateAABBfromOBB(const Vec3& wpos, const OBB_tpl<F>& obb, f32 scaling = 1.0f)
{ AABB taabb; taabb.SetAABBfromOBB(wpos, obb, scaling); return taabb; }
/* Converts a Cone into a tight fitting AABB */
ILINE static AABB CreateAABBfromCone(const Cone& c)
{
// Construct AABB for cone base
Vec3 baseX = Vec3(1.f - c.mDir.x * c.mDir.x, c.mDir.x * c.mDir.y, c.mDir.x * c.mDir.z).GetNormalized() * c.mBaseRadius;
Vec3 baseY = Vec3(c.mDir.y * c.mDir.x, 1.f - c.mDir.y * c.mDir.y, c.mDir.y * c.mDir.z).GetNormalized() * c.mBaseRadius;
Vec3 baseZ = Vec3(c.mDir.z * c.mDir.x, c.mDir.z * c.mDir.y, 1.f - c.mDir.z * c.mDir.z).GetNormalized() * c.mBaseRadius;
Vec3 aabbMax = Vec3(baseX.x, baseY.y, baseZ.z).abs();
Vec3 aabbMin = -aabbMax;
AABB result(aabbMin, aabbMax);
result.Move(c.mBase);
// add tip
result.Add(c.mTip);
return result;
}
};
ILINE bool IsEquivalent(const AABB& a, const AABB& b, float epsilon = VEC_EPSILON)
@@ -710,9 +317,6 @@ ILINE bool IsEquivalent(const AABB& a, const AABB& b, float epsilon = VEC_EPSILO
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -752,6 +356,7 @@ struct OBB_tpl
~OBB_tpl(void) {};
};
typedef OBB_tpl<f32> OBB;
@@ -774,392 +379,4 @@ struct Sphere
void operator()(const Vec3& c, float r) { center = c; radius = r; }
};
struct HWVSphere
{
hwvec3 center;
simdf radius;
ILINE HWVSphere(const hwvec3& c, const simdf& r)
{
center = c;
radius = r;
}
ILINE HWVSphere(const ::Sphere& sp)
{
center = HWVLoadVecUnaligned(&sp.center);
radius = SIMDFLoadFloat(sp.radius);
}
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// struct AAEllipsoid
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
struct AAEllipsoid
{
Vec3 center;
Vec3 radius_vec;
//default AAEllipsoid constructor (without initialisation)
inline AAEllipsoid(void) {}
inline AAEllipsoid(const Vec3& c, const Vec3& rv) { radius_vec = rv; center = c; }
inline void operator () (const Vec3& c, const Vec3& rv) { radius_vec = rv; center = c; }
~AAEllipsoid(void) {};
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// struct Ellipsoid
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
struct Ellipsoid
{
Matrix34 ExtensionPos;
//default Ellipsoid constructor (without initialisation)
inline Ellipsoid(void) {}
inline Ellipsoid(const Matrix34& ep) { ExtensionPos = ep; }
inline void operator () (const Matrix34& ep) { ExtensionPos = ep; }
~Ellipsoid(void) {};
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// struct TRect
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <class Num>
struct TRect_tpl
{
typedef Vec2_tpl<Num> Vec;
Vec Min, Max;
inline TRect_tpl() {}
inline TRect_tpl(Num x1, Num y1, Num x2, Num y2)
: Min(x1, y1)
, Max(x2, y2) {}
inline TRect_tpl(const TRect_tpl<Num>& rc)
: Min(rc.Min)
, Max(rc.Max) {}
inline TRect_tpl(const Vec& min, const Vec& max)
: Min(min)
, Max(max) {}
inline TRect_tpl<Num> operator * (Num k) const
{
return TRect_tpl<Num>(Min.x * k, Min.y * k, Max.x * k, Max.y * k);
}
inline TRect_tpl<Num> operator / (Num k) const
{
return TRect_tpl<Num>(Min.x / k, Min.y / k, Max.x / k, Max.y / k);
}
inline bool IsEmpty() const { return Max.x < Min.x && Max.y < Min.y; }
inline TRect_tpl<Num>& SetEmpty() { Max = Vec(-1, -1); Min = Vec(0, 0); return *this; }
inline Vec GetDim() const { return Max - Min; }
inline Num GetWidth() const { return Max.x - Min.x; }
inline Num GetHeight() const { return Max.y - Min.y; }
inline bool IsEqual(const TRect_tpl<Num>& rc) const { return Min.x == rc.Min.x && Min.y == rc.Min.y && Max.x == rc.Max.x && Max.y == rc.Max.y; }
inline bool InRect(const TRect_tpl<Num>& rc) const { return rc.Min.x >= Min.x && rc.Max.x <= Max.x && rc.Min.y >= Min.y && rc.Max.y <= Max.y; }
inline bool InRect(Vec pt) const { return pt.x >= Min.x && pt.x <= Max.x && pt.y >= Min.y && pt.y <= Max.y; }
inline Vec& IntoRect(Vec& pt) const
{
if (pt.x < Min.x)
{
pt.x = Min.x;
}
else if (pt.x > Max.x)
{
pt.x = Max.x;
}
if (pt.y < Min.y)
{
pt.y = Min.y;
}
else if (pt.y > Max.y)
{
pt.y = Max.y;
}
return pt;
}
inline bool Intersects(const TRect_tpl<Num>& rc) const
{
return !IsEmpty() && !rc.IsEmpty() &&
!(Min.x > rc.Max.x || Max.x < rc.Min.x ||
Min.y > rc.Max.y || Max.y < rc.Min.y);
}
inline TRect_tpl<Num>& DoUnite(const TRect_tpl<Num>& rc)
{
if (IsEmpty())
{
Min = rc.Min;
Max = rc.Max;
return *this;
}
if (rc.IsEmpty())
{
return *this;
}
if (Min.x > rc.Min.x)
{
Min.x = rc.Min.x;
}
if (Min.y > rc.Min.y)
{
Min.y = rc.Min.y;
}
if (Max.x < rc.Max.x)
{
Max.x = rc.Max.x;
}
if (Max.y < rc.Max.y)
{
Max.y = rc.Max.y;
}
return *this;
}
inline TRect_tpl<Num>& DoIntersect(const TRect_tpl<Num>& rc)
{
if (IsEmpty())
{
return *this;
}
if (rc.IsEmpty())
{
return SetEmpty();
}
if (Min.x < rc.Min.x)
{
Min.x = rc.Min.x;
}
if (Min.y < rc.Min.y)
{
Min.y = rc.Min.y;
}
if (Max.x > rc.Max.x)
{
Max.x = rc.Max.x;
}
if (Max.y > rc.Max.y)
{
Max.y = rc.Max.y;
}
if (Min.x == Max.x || Min.y == Max.y)
{
return SetEmpty();
}
return *this;
}
inline TRect_tpl<Num> GetSubRect(const TRect_tpl<Num>& rc) const
{
if (IsEmpty())
{
return *this;
}
if (rc.IsEmpty())
{
return rc;
}
return TRect_tpl<Num>(Min.x + rc.Min.x * GetWidth(),
Min.y + rc.Min.y * GetHeight(),
Min.x + rc.Max.x * GetWidth(),
Min.y + rc.Max.y * GetHeight());
}
inline TRect_tpl<Num> GetSubRectInv(const TRect_tpl<Num>& rcSub) const
{
if (IsEmpty())
{
return *this;
}
if (rcSub.IsEmpty())
{
return rcSub;
}
return TRect_tpl((rcSub.Min.x - Min.x) / GetWidth(),
(rcSub.Min.y - Min.y) / GetHeight(),
(rcSub.Max.x - Min.x) / GetWidth(),
(rcSub.Max.y - Min.y) / GetHeight());
}
};
typedef TRect_tpl<float> Rectf;
typedef TRect_tpl<int> Recti;
typedef Triangle_tpl<f32> Triangle;
typedef Triangle_tpl<f64> Triangle_f64;
typedef OBB_tpl<f32> OBB;
//////////////////////////////////////////////////////////////////////////
// Manage linear and rotational 3D velocity in a class
class Velocity3
{
public:
Vec3 vLin, vRot;
Velocity3()
{}
Velocity3(type_zero)
: vLin(ZERO)
, vRot(ZERO) {}
Velocity3(Vec3 const& lin)
: vLin(lin)
, vRot(ZERO) {}
Velocity3(Vec3 const& lin, Vec3 const& rot)
: vLin(lin)
, vRot(rot) {}
void FromDelta(QuatT const& loc0, QuatT const& loc1, float fTime)
{
float fInvT = 1.f / fTime;
vLin = (loc1.t - loc0.t) * fInvT;
vRot = Quat::log(loc1.q * loc0.q.GetInverted()) * fInvT;
}
Vec3 VelocityAt(Vec3 const& vPosRel) const
{ return vLin + (vRot % vPosRel); }
void operator += (Velocity3 const& vv)
{
vLin += vv.vLin;
vRot += vv.vRot;
}
void operator *= (float f)
{
vLin *= f;
vRot *= f;
}
void Interp(Velocity3 const& vv, float f)
{
vLin += (vv.vLin - vLin) * f;
vRot += (vv.vRot - vRot) * f;
}
};
/////////////////////////////////////////////////////////////////////////
//this is some special engine stuff, should be moved to a better location
/////////////////////////////////////////////////////////////////////////
// for bbox's checks and calculations
#define MAX_BB +99999.0f
#define MIN_BB -99999.0f
//! checks if this has been set to minBB
inline bool IsMinBB(const Vec3& v)
{
if (v.x <= MIN_BB)
{
return (true);
}
if (v.y <= MIN_BB)
{
return (true);
}
if (v.z <= MIN_BB)
{
return (true);
}
return (false);
}
//! checks if this has been set to maxBB
inline bool IsMaxBB(const Vec3& v)
{
if (v.x >= MAX_BB)
{
return (true);
}
if (v.y >= MAX_BB)
{
return (true);
}
if (v.z >= MAX_BB)
{
return (true);
}
return (false);
}
inline Vec3 SetMaxBB(void) { return Vec3(MAX_BB, MAX_BB, MAX_BB); }
inline Vec3 SetMinBB(void) { return Vec3(MIN_BB, MIN_BB, MIN_BB); }
inline void AddToBounds (const Vec3& v, Vec3& mins, Vec3& maxs)
{
if (v.x < mins.x)
{
mins.x = v.x;
}
if (v.x > maxs.x)
{
maxs.x = v.x;
}
if (v.y < mins.y)
{
mins.y = v.y;
}
if (v.y > maxs.y)
{
maxs.y = v.y;
}
if (v.z < mins.z)
{
mins.z = v.z;
}
if (v.z > maxs.z)
{
maxs.z = v.z;
}
}
////////////////////////////////////////////////////////////////
//! calc the area of a polygon giving a list of vertices and normal
inline float CalcArea(const Vec3* vertices, int numvertices, const Vec3& normal)
{
Vec3 csum(0, 0, 0);
int n = numvertices;
for (int i = 0, j = 1; i <= n - 2; i++, j++)
{
csum.x += vertices[i].y * vertices[j].z - vertices[i].z * vertices[j].y;
csum.y += vertices[i].z * vertices[j].x - vertices[i].x * vertices[j].z;
csum.z += vertices[i].x * vertices[j].y - vertices[i].y * vertices[j].x;
}
csum.x += vertices[n - 1].y * vertices[0].z - vertices[n - 1].z * vertices[0].y;
csum.y += vertices[n - 1].z * vertices[0].x - vertices[n - 1].x * vertices[0].z;
csum.z += vertices[n - 1].x * vertices[0].y - vertices[n - 1].y * vertices[0].x;
float area = 0.5f * (float)fabs(normal | csum);
return (area);
}
#endif // CRYINCLUDE_CRYCOMMON_CRY_GEO_H
-85
View File
@@ -1,85 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Scalar implementation of hardware vector based matrix
#ifndef CRYINCLUDE_CRYCOMMON_CRY_HWMATRIX_H
#define CRYINCLUDE_CRYCOMMON_CRY_HWMATRIX_H
#pragma once
struct hwmtx33
{
hwvec3 m0, m1, m2;
};
ILINE void HWMtx33LoadAligned(hwmtx33& out, const Matrix34A& inMtx)
{
out.m0 = HWVLoadVecAligned(reinterpret_cast<const Vec4A*>(&inMtx.m00));
out.m1 = HWVLoadVecAligned(reinterpret_cast<const Vec4A*>(&inMtx.m10));
out.m2 = HWVLoadVecAligned(reinterpret_cast<const Vec4A*>(&inMtx.m20));
}
ILINE hwvec3 HWMtx33RotateVec(const hwmtx33& m, const hwvec3& v)
{
return Vec3((m.m0[0] * v.x) + (m.m0[1] * v.y) + (m.m0[2] * v.z),
(m.m1[0] * v.x) + (m.m1[1] * v.y) + (m.m1[2] * v.z),
(m.m2[0] * v.x) + (m.m2[1] * v.y) + (m.m2[2] * v.z));
}
ILINE hwvec3 HWMtx33RotateVecOpt(const hwmtx33& m, const hwvec3& v)
{
return HWMtx33RotateVec(m, v);
}
ILINE hwmtx33 HWMtx33CreateRotationV0V1(const hwvec3& v0, const hwvec3& v1)
{
assert((fabs_tpl(1 - (v0 | v0))) < 0.01); //check if unit-vector
assert((fabs_tpl(1 - (v1 | v1))) < 0.01); //check if unit-vector
hwmtx33 m;
float dot = v0 | v1;
if (dot < -0.9999f)
{
Vec3 axis = v0.GetOrthogonal().GetNormalized();
m.m0[0] = (2.0f * axis.x * axis.x - 1);
m.m0[1] = (2.0f * axis.x * axis.y);
m.m0[2] = (2.0f * axis.x * axis.z);
m.m1[0] = (2.0f * axis.y * axis.x);
m.m1[1] = (2.0f * axis.y * axis.y - 1);
m.m1[2] = (2.0f * axis.y * axis.z);
m.m2[0] = (2.0f * axis.z * axis.x);
m.m2[1] = (2.0f * axis.z * axis.y);
m.m2[2] = (2.0f * axis.z * axis.z - 1);
}
else
{
Vec3 v = v0 % v1;
f32 h = 1.0f / (1.0f + dot);
m.m0[0] = (dot + h * v.x * v.x);
m.m0[1] = (h * v.x * v.y - v.z);
m.m0[2] = (h * v.x * v.z + v.y);
m.m1[0] = (h * v.x * v.y + v.z);
m.m1[1] = (dot + h * v.y * v.y);
m.m1[2] = (h * v.y * v.z - v.x);
m.m2[0] = (h * v.x * v.z - v.y);
m.m2[1] = (h * v.y * v.z + v.x);
m.m2[2] = (dot + h * v.z * v.z);
}
return m;
}
//Returns a matrix optimized for this platform's matrix ops, in this case, not doing a thing;
ILINE hwmtx33 HWMtx33GetOptimized(const hwmtx33& m)
{
return (hwmtx33)m;
}
#endif // CRYINCLUDE_CRYCOMMON_CRY_HWMATRIX_H
-278
View File
@@ -1,278 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description: Hardware vector class - scalar implementation
#ifndef CRYINCLUDE_CRYCOMMON_CRY_HWVECTOR3_H
#define CRYINCLUDE_CRYCOMMON_CRY_HWVECTOR3_H
#pragma once
#define HWV_PERMUTE_0X 0
#define HWV_PERMUTE_0Y 1
#define HWV_PERMUTE_0Z 2
#define HWV_PERMUTE_0W 3
#define HWV_PERMUTE_1X 4
#define HWV_PERMUTE_1Y 5
#define HWV_PERMUTE_1Z 6
#define HWV_PERMUTE_1W 7
typedef Vec3 hwvec3;
typedef Vec4 hwvec4;
typedef float simdf;
typedef Vec4 hwvec4fconst;
typedef int hwvec4i[4];
#define HWV3Constant(name, f0, f1, f2) const Vec3 name(f0, f1, f2)
#define SIMDFConstant(name, f0) const simdf name = f0
#define HWV4PermuteControl(name, i0, i1, i2, i3) static const hwvec4i name = {i0, i1, i2, i3};
#define SIMDFAsVec3(a) (hwvec3)a
#define HWV3AsSIMDF(a) (simdf)a.x
ILINE hwvec3 HWVLoadVecUnaligned(const Vec3* pLoadFrom)
{
return *pLoadFrom;
}
ILINE hwvec3 HWVLoadVecAligned(const Vec4A* pLoadFrom)
{
return Vec3(pLoadFrom->x, pLoadFrom->y, pLoadFrom->z);
}
ILINE void HWVSaveVecUnaligned(Vec3* pSaveTo, const hwvec3& pLoadFrom)
{
*pSaveTo = pLoadFrom;
}
ILINE void HWVSaveVecAligned(Vec4* pSaveTo, const hwvec4& pLoadFrom)
{
*pSaveTo = pLoadFrom;
}
ILINE hwvec3 HWVAdd(const hwvec3& a, const hwvec3& b)
{
return hwvec3(a.x + b.x, a.y + b.y, a.z + b.z);
}
ILINE hwvec3 HWVMultiply(const hwvec3& a, const hwvec3& b)
{
return hwvec3(a.x * b.x, a.y * b.y, a.z * b.z);
}
ILINE hwvec3 HWVMultiplySIMDF(const hwvec3& a, const simdf& b)
{
return hwvec3(a.x * b, a.y * b, a.z * b);
}
ILINE hwvec3 HWVMultiplyAdd(const hwvec3& a, const hwvec3& b, const hwvec3& c)
{
return hwvec3((a.x * b.x) + c.x, (a.y * b.y) + c.y, (a.z * b.z) + c.z);
}
ILINE hwvec3 HWVMultiplySIMDFAdd(const hwvec3& a, const simdf& b, const hwvec3& c)
{
return hwvec3((a.x * b) + c.x, (a.y * b) + c.y, (a.z * b) + c.z);
}
ILINE hwvec3 HWVSub(const hwvec3& a, const hwvec3& b)
{
return (a - b);
}
ILINE hwvec3 HWVCross(const hwvec3& a, const hwvec3& b)
{
return hwvec3((a.y * b.z) - (a.z * b.y)
, (a.z * b.x) - (a.x * b.z)
, (a.x * b.y) - (a.y * b.x));
}
ILINE simdf HWV3Dot(const hwvec3& a, const hwvec3& b)
{
return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
}
ILINE hwvec3 HWVMax(const hwvec3& a, const hwvec3& b)
{
return Vec3(a.x > b.x ? a.x : b.x,
a.y > b.y ? a.y : b.y,
a.z > b.z ? a.z : b.z);
}
ILINE hwvec3 HWVMin(const hwvec3& a, const hwvec3& b)
{
return Vec3(a.x < b.x ? a.x : b.x,
a.y < b.y ? a.y : b.y,
a.z < b.z ? a.z : b.z);
}
ILINE hwvec3 HWVClamp(const hwvec3& a, const hwvec3& min, const hwvec3& max)
{
return HWVMax(min, HWVMin(a, max));
}
ILINE hwvec3 HWV3Normalize(const hwvec3& a)
{
float fInvLen = isqrt_safe_tpl((a.x * a.x) + (a.y * a.y) + (a.z * a.z));
return Vec3(a.x * fInvLen, a.y * fInvLen, a.z * fInvLen);
}
ILINE hwvec3 HWVGetOrthogonal(const hwvec3& a)
{
hwvec3 result = a;
//int i = isneg(square(0.9f)*a.GetLengthSquared()-(a.x*a.x));
int i = isneg(square(0.9f) * a.GetLengthSquared() - a.x * a.x);
result[i] = 0;
result[incm3(i)] = a[decm3(i)];
result[decm3(i)] = -a[incm3(i)];
return result;
}
ILINE simdf HWV3SplatXToSIMDF(const hwvec3& a)
{
return a.x;
}
ILINE simdf HWV3SplatYToSIMDF(const hwvec3& a)
{
return a.y;
}
ILINE hwvec3 HWV3PermuteWord(const hwvec3& a, const hwvec3& b, const hwvec4i& p)
{
hwvec3 selection[2] = {a, b};
float* fSelection = (float*)selection;
return Vec3(fSelection[p[0]], fSelection[p[1]], fSelection[p[2]]);
}
ILINE hwvec3 HWV3Zero()
{
return Vec3(0.0f, 0.0f, 0.0f);
}
ILINE hwvec4 HWV4Zero()
{
return Vec4(0.0f, 0.0f, 0.0f, 0.0f);
}
ILINE hwvec3 HWV3Negate(const hwvec3& a)
{
return Vec3(-a.x, -a.y, -a.z);
}
ILINE hwvec3 HWVSelect(const hwvec3& a, const hwvec3& b, const hwvec3& control)
{
return Vec3(control[0] > 0.0f ? b[0] : a[0],
control[1] > 0.0f ? b[1] : a[1],
control[2] > 0.0f ? b[2] : a[2]);
}
ILINE hwvec3 HWVSelectSIMDF(const hwvec3& a, const hwvec3& b, const bool& control)
{
return control ? b : a;
}
ILINE simdf HWV3LengthSq(const hwvec3& a)
{
return a.len2();
}
//////////////////////////////////////////////////
//SIMDF functions for float stored in HWVEC4 data
//////////////////////////////////////////////////
ILINE simdf SIMDFLoadFloat(const float& f)
{
return f;
}
ILINE void SIMDFSaveFloat(float* f, const simdf& a)
{
*f = a;
}
ILINE bool SIMDFGreaterThan(const simdf& a, const simdf& b)
{
return (a > b);
}
ILINE bool SIMDFLessThanEqualB(const simdf& a, const simdf& b)
{
return (a <= b);
}
ILINE bool SIMDFLessThanEqual(const simdf& a, const simdf& b)
{
return (a <= b);
}
ILINE bool SIMDFLessThanB(const simdf& a, const simdf& b)
{
return (a < b);
}
ILINE bool SIMDFLessThan(const simdf& a, const simdf& b)
{
return (a < b);
}
ILINE simdf SIMDFAdd(const simdf& a, const simdf& b)
{
return a + b;
}
ILINE simdf SIMDFMult(const simdf& a, const simdf& b)
{
return a * b;
}
ILINE simdf SIMDFReciprocal(const simdf& a)
{
return 1.0f / a;
}
ILINE simdf SIMDFSqrt(const simdf& a)
{
return sqrt_tpl(a);
}
ILINE simdf SIMDFSqrtEst(const simdf& a)
{
return sqrt_tpl(a);
}
ILINE simdf SIMDFSqrtEstFast(const simdf& a)
{
return sqrt_tpl(a);
}
ILINE simdf SIMDFMax(const simdf& a, const simdf& b)
{
return max(a, b);
}
ILINE simdf SIMDFMin(const simdf& a, const simdf& b)
{
return min(a, b);
}
ILINE simdf SIMDFClamp(const simdf& a, const simdf& min, const simdf& max)
{
return clamp_tpl(a, min, max);
}
ILINE simdf SIMDFAbs(const simdf& a)
{
return fabsf(a);
}
#endif // CRYINCLUDE_CRYCOMMON_CRY_HWVECTOR3_H
+1 -187
View File
@@ -8,8 +8,6 @@
// Description : Common math class
#pragma once
//========================================================================================
@@ -18,7 +16,6 @@
#include "Cry_ValidNumber.h"
#include <CryEndian.h> // eLittleEndian
#include <CryHalf.inl>
//#include <MetaUtils.h>
#include <float.h>
///////////////////////////////////////////////////////////////////////////////
// Forward declarations //
@@ -27,8 +24,7 @@ template <typename F>
struct Vec2_tpl;
template <typename F>
struct Vec3_tpl;
template <typename F>
struct Vec4_tpl;
struct Vec4;
template <typename F>
struct Ang3_tpl;
@@ -38,14 +34,6 @@ template <typename F>
struct AngleAxis_tpl;
template <typename F>
struct Quat_tpl;
template <typename F>
struct QuatT_tpl;
template <typename F>
struct DualQuat_tpl;
template <typename F>
struct QuatTS_tpl;
template <typename F>
struct QuatTNS_tpl;
template <typename F>
struct Diag33_tpl;
@@ -94,14 +82,8 @@ const f32 gf_halfPI = f32(1.57079632679489661923132169163975144209858469968755);
#define TANGENT30_2 0.57735026918962576450914878050196f * 2 // 2*tan(30)
#define LN2 0.69314718055994530941723212145818f // ln(2)
ILINE f32 fsel(const f32 _a, const f32 _b, const f32 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f64 fsel(const f64 _a, const f64 _b, const f64 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f32 fself(const f32 _a, const f32 _b, const f32 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f32 fsels(const f32 _a, const f32 _b, const f32 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f32 fres(const f32 _a) { return 1.f / _a; }
template<class T>
ILINE T isel(int c, T a, T b) { return (c < 0) ? b : a; }
@@ -319,13 +301,6 @@ ILINE int64 pos_round(f64 f) { return int64(f + 0.5); }
ILINE int32 int_ceil(f32 f) { int32 i = int32(f); return (f > f32(i)) ? i + 1 : i; }
ILINE int64 int_ceil(f64 f) { int64 i = int64(f); return (f > f64(i)) ? i + 1 : i; }
ILINE float ufrac8_to_float(float u) { return u * (1.f / 255.f); }
ILINE float ifrac8_to_float(float i) { return i * (1.f / 127.f); }
ILINE uint8 float_to_ufrac8(float f) { int i = pos_round(f * 255.f); assert(i >= 0 && i < 256); return uint8(i); }
ILINE int8 float_to_ifrac8(float f) { int i = int_round(f * 127.f); assert(abs(i) <= 127); return int8(i); }
template<class F>
ILINE F sqr(const F& op) { return op * op; }
template<class F>
@@ -490,11 +465,8 @@ ILINE int64 iszero(long int x) { return -(x >> 63 ^ (x - 1) >> 63); }
#endif
ILINE float if_neg_else(float test, float val_neg, float val_nonneg) { return (float)fsel(test, val_nonneg, val_neg); }
ILINE float if_pos_else(float test, float val_pos, float val_nonpos) { return (float)fsel(-test, val_nonpos, val_pos); }
template<class F>
ILINE int32 inrange(F x, F end1, F end2) { return isneg(fabs_tpl(end1 + end2 - x * (F)2) - fabs_tpl(end1 - end2)); }
template<class F>
ILINE F cond_select(int32 bFirst, F op1, F op2) { F arg[2] = { op1, op2 }; return arg[bFirst ^ 1]; }
template<class F>
ILINE int32 idxmax3(const F* pdata)
@@ -510,56 +482,6 @@ ILINE int32 idxmax3(const Vec3_tpl<F>& vec)
imax |= isneg(vec[imax] - vec.z) << 1;
return imax & (2 | (imax >> 1 ^ 1));
}
template<class F>
ILINE int32 idxmin3(const F* pdata)
{
int32 imin = isneg(pdata[1] - pdata[0]);
imin |= isneg(pdata[2] - pdata[imin]) << 1;
return imin & (2 | (imin >> 1 ^ 1));
}
template<class F>
ILINE int32 idxmin3(const Vec3_tpl<F>& vec)
{
int32 imin = isneg(vec.y - vec.x);
imin |= isneg(vec.z - vec[imin]) << 1;
return imin & (2 | (imin >> 1 ^ 1));
}
// Approximation of exp(-x)
ILINE float approxExp(float x) { return fres(1.f + x); }
// Approximation of 1.f - exp(-x)
ILINE float approxOneExp(float x) { return x * fres(1.f + x); }
ILINE int ilog2(uint64 x) // if x==1<<i (i=0..63), returns i
{
#if defined(CRY_PLATFORM_X64)
# if defined(AZ_RESTRICTED_PLATFORM)
# include AZ_RESTRICTED_FILE(Cry_Math_h)
# endif
# if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
# undef AZ_RESTRICTED_SECTION_IMPLEMENTED
# elif defined(CRY_PLATFORM_LINUX)
# define HAS_BIT_SCAN_FORWARD64 0
# else
# define HAS_BIT_SCAN_FORWARD64 1
# endif
#endif
#if HAS_BIT_SCAN_FORWARD64
unsigned long i;
_BitScanForward64(&i, x);
return i;
#else
union
{
float f;
uint i;
} u;
u.f = (float)x;
return (u.i >> 23) - 127;
#endif
}
static int32 inc_mod3[] = {1, 2, 0}, dec_mod3[] = {2, 0, 1};
#ifdef PHYSICS_EXPORTS
@@ -596,114 +518,6 @@ enum type_identity
#include "Cry_Matrix34.h"
#include "Cry_Matrix44.h"
#include "Cry_Quat.h"
#include "Cry_HWVector3.h"
#include "Cry_HWMatrix.h"
//////////////////////////////////////////////////////////////////////////
/// This function relaxes a value (val) towards a desired value (to) whilst maintaining continuity
/// of val and its rate of change (valRate). timeDelta is the time between this call and the previous one.
/// The caller would normally keep val and valRate as working variables, and smoothTime is normally
/// a fixed parameter. The to/timeDelta values can change.
///
/// Implementation details:
///
/// This is a critically damped spring system. A linear spring is attached between "val" and "to" that
/// drags "val" to "to". At the same time a damper between the two removes oscillations; it's tweaked
/// so it doesn't dampen more than necessary. In combination this gives smooth ease-in and ease-out behavior.
///
/// smoothTime can be interpreted in a couple of ways:
/// - it's the "expected time to reach the target when at maximum velocity" (the target will, however, not be reached
/// in that time because the speed will decrease the closer it gets to the target)
/// - it's the 'lag time', how many seconds "val" lags behind "to". If your
/// target has a certain speed, the lag distance is simply the smoothTime times that speed.
/// - it's 2/omega, where omega is the spring's natural frequency (or less formally a measure of the spring stiffness)
///
/// The implementation is stable for varying timeDelta, but for performance reasons it uses a polynomial approximation
/// to the exponential function. The approximation works well (within 0.1% of accuracy) when smoothTime > 2*deltaTime,
/// which is usually the case. (but it might be troublesome when you want a stiff spring or have frame hikes!)
/// The implementation handles cases where smoothTime==0 separately and reliably. In that case the target will be
/// reached immediately, and valRate is updated appropriately.
///
/// Based on "Critically Damped Ease-In/Ease-Out Smoothing", Thomas Lowe, Game Programming Gems IV
///
template <typename T>
ILINE void SmoothCD(
T& val, ///< in/out: value to be smoothed
T& valRate, ///< in/out: rate of change of the value
const float timeDelta, ///< in: time interval
const T& to, ///< in: the target value
const float smoothTime) ///< in: timescale for smoothing
{
if (smoothTime > 0.0f)
{
const float omega = 2.0f / smoothTime;
const float x = omega * timeDelta;
const float exp = 1.0f / (1.0f + x + 0.48f * x * x + 0.235f * x * x * x);
const T change = (val - to);
const T temp = (T)((valRate + change * omega) * timeDelta);
valRate = (T)((valRate - temp * omega) * exp);
val = (T)(to + (change + temp) * exp);
}
else if (timeDelta > 0.0f)
{
valRate = (T)((to - val) / timeDelta);
val = to;
}
else
{
val = to;
T zeroizeAmount = valRate;
valRate -= zeroizeAmount; // zero it...
}
}
template <typename T>
ILINE void SmoothCDWithMaxRate(
T& val, ///< in/out: value to be smoothed
T& valRate, ///< in/out: rate of change of the value
const float timeDelta, ///< in: time interval
const T& to, ///< in: the target value
const float smoothTime, ///< in: timescale for smoothing
const T& maxValRate) ///< in: maximum allowed rate of change
{
if (smoothTime > 0.0f)
{
const float omega = 2.0f / smoothTime;
const float x = omega * timeDelta;
const float exp = 1.0f / (1.0f + x + 0.48f * x * x + 0.235f * x * x * x);
const T unclampedChange = val - to;
const T maxChange = maxValRate * smoothTime;
const T clampedChange = clamp_tpl<T>(unclampedChange, -maxChange, maxChange);
const T clampedTo = val - clampedChange;
const T temp = (T)((valRate + clampedChange * omega) * timeDelta);
valRate = (T)((valRate - temp * omega) * exp);
val = (T)(clampedTo + (clampedChange + temp) * exp);
}
else if (timeDelta > 0.0f)
{
const T unclampedRate = (T)((to - val) / timeDelta);
valRate = clamp_tpl<T>(unclampedRate, -maxValRate, maxValRate);
val += valRate * timeDelta;
}
else
{
val = to;
T zeroizeAmount = valRate;
valRate -= zeroizeAmount; // zero it...
}
}
// Smoothes linear blending into cubic (b-spline) with 0-derivatives
// near 0 and 1
inline f32 SmoothBlendValue (const f32 fBlend)
{
const f32 fBlendAdj = fBlend - 0.5f;
return (f32)fsel(-fBlend, 0.f, fsel(fBlend - 1.f, 1.f, 0.5f - 2.f * (fBlendAdj * fBlendAdj * fBlendAdj) + 1.5f * fBlendAdj));
}
// function for safe comparsion of floating point values
ILINE bool fcmp(f32 fA, f32 fB, f32 fEpsilon = FLT_EPSILON)
+4 -273
View File
@@ -8,10 +8,6 @@
// Description : Common matrix class
#ifndef CRYINCLUDE_CRYCOMMON_CRY_MATRIX33_H
#define CRYINCLUDE_CRYCOMMON_CRY_MATRIX33_H
#pragma once
@@ -64,7 +60,6 @@ struct Matrix33_tpl
#else
ILINE Matrix33_tpl(){};
#endif
//set matrix to Identity
ILINE Matrix33_tpl(type_identity)
{
@@ -78,21 +73,6 @@ struct Matrix33_tpl
m21 = 0;
m22 = 1;
}
//set matrix to Zero
ILINE Matrix33_tpl(type_zero)
{
m00 = 0;
m01 = 0;
m02 = 0;
m10 = 0;
m11 = 0;
m12 = 0;
m20 = 0;
m21 = 0;
m22 = 0;
}
//ASSIGNMENT OPERATOR of identical Matrix33 types.
//The assignment operator has precedence over assignment constructor
//Matrix33 m; m=m33;
@@ -118,7 +98,7 @@ struct Matrix33_tpl
//CONSTRUCTOR for identical float-types. It initializes a Matrix33 with 9 floats.
//Matrix33(0,1,2, 3,4,5, 6,7,8);
explicit ILINE Matrix33_tpl<F>(F x00, F x01, F x02, F x10, F x11, F x12, F x20, F x21, F x22)
explicit ILINE Matrix33_tpl(F x00, F x01, F x02, F x10, F x11, F x12, F x20, F x21, F x22)
{
m00 = x00;
m01 = x01;
@@ -130,26 +110,11 @@ struct Matrix33_tpl
m21 = x21;
m22 = x22;
}
//CONSTRUCTOR for different float-types. It initializes a Matrix33 with 9 floats.
//Matrix33(0.0,1.0,2.0, 3.0,4.0,5.0, 6.0,7.0,8.0);
template<class F1>
explicit ILINE Matrix33_tpl<F>(F1 x00, F1 x01, F1 x02, F1 x10, F1 x11, F1 x12, F1 x20, F1 x21, F1 x22)
{
m00 = F(x00);
m01 = F(x01);
m02 = F(x02);
m10 = F(x10);
m11 = F(x11);
m12 = F(x12);
m20 = F(x20);
m21 = F(x21);
m22 = F(x22);
}
//CONSTRUCTOR for identical float-types. It initializes a Matrix33 with 3 vectors stored in the columns.
//Matrix33(v0,v1,v2);
explicit ILINE Matrix33_tpl<F>(const Vec3_tpl<F>&vx, const Vec3_tpl<F>&vy, const Vec3_tpl<F>&vz)
explicit ILINE Matrix33_tpl(const Vec3_tpl<F>&vx, const Vec3_tpl<F>&vy, const Vec3_tpl<F>&vz)
{
m00 = vx.x;
m01 = vy.x;
@@ -164,7 +129,7 @@ struct Matrix33_tpl
//CONSTRUCTOR for different float-types. It initializes a Matrix33 with 3 vectors stored in the columns and converts between floats/doubles.
//Matrix33r(v0,v1,v2);
template<class F1>
explicit ILINE Matrix33_tpl<F>(const Vec3_tpl<F1>&vx, const Vec3_tpl<F1>&vy, const Vec3_tpl<F1>&vz)
explicit ILINE Matrix33_tpl(const Vec3_tpl<F1>&vx, const Vec3_tpl<F1>&vy, const Vec3_tpl<F1>&vz)
{
m00 = F(vx.x);
m01 = F(vy.x);
@@ -209,8 +174,6 @@ struct Matrix33_tpl
m22 = F(m.m22);
}
//CONSTRUCTOR for identical float-types. It converts a Matrix34 into a Matrix33.
//Needs to be 'explicit' because we loose the translation vector in the conversion process
//Matrix33(m34);
@@ -245,9 +208,6 @@ struct Matrix33_tpl
m22 = F(m.m22);
}
//CONSTRUCTOR for identical float-types. It converts a Matrix44 into a Matrix33.
//Needs to be 'explicit' because we loose the translation vector and the 3rd row in the conversion process
//Matrix33(m44);
@@ -356,26 +316,6 @@ struct Matrix33_tpl
SetRotationXYZ(Ang3_tpl<F>(F(ang.x), F(ang.y), F(ang.z)));
}
//Bracket OPERATOR: initializes a Matrix33 with 9 floats.
//Matrix33 m; m(0,1,2, 3,4,5, 6,7,8);
ILINE void operator () (F x00, F x01, F x02, F x10, F x11, F x12, F x20, F x21, F x22)
{
m00 = x00;
m01 = x01;
m02 = x02;
m10 = x10;
m11 = x11;
m12 = x12;
m20 = x20;
m21 = x21;
m22 = x22;
assert(IsValid());
}
//---------------------------------------------------------------------------------------
ILINE void SetIdentity(void)
@@ -391,27 +331,6 @@ struct Matrix33_tpl
m22 = 1;
}
ILINE static Matrix33_tpl<F> CreateIdentity()
{
Matrix33_tpl<F> m33;
m33.SetIdentity();
return m33;
}
ILINE void SetZero()
{
m00 = 0;
m01 = 0;
m02 = 0;
m10 = 0;
m11 = 0;
m12 = 0;
m20 = 0;
m21 = 0;
m22 = 0;
}
/*!
* Create a rotation matrix around an arbitrary axis (Eulers Theorem).
* The axis is specified as a normalized Vec3. The angle is assumed to be in radians.
@@ -597,7 +516,7 @@ struct Matrix33_tpl
F dot = v0 | v1;
if (dot < F(-0.9999f))
{
Vec3d axis = v0.GetOrthogonal().GetNormalized();
Vec3_tpl<F> axis = v0.GetOrthogonal().GetNormalized();
m00 = F(2 * axis.x * axis.x - 1);
m01 = F(2 * axis.x * axis.y);
m02 = F(2 * axis.x * axis.z);
@@ -723,28 +642,6 @@ struct Matrix33_tpl
return m33;
}
//! calculate 2 vector that form a orthogonal base with a given input vector (by M.M.)
//! /param invDirection input direction (has to be normalized)
//! /param outvA first output vector that is perpendicular to the input direction
//! /param outvB second output vector that is perpendicular the input vector and the first output vector
ILINE static Matrix33_tpl<F> CreateOrthogonalBase(const Vec3& invDirection)
{
Vec3 outvA;
if (invDirection.z < -0.5f || invDirection.z > 0.5f)
{
outvA = Vec3(invDirection.z, invDirection.y, -invDirection.x);
}
else
{
outvA = Vec3(invDirection.y, -invDirection.x, invDirection.z);
}
Vec3 outvB = (invDirection % outvA).GetNormalized();
outvA = (invDirection % outvB).GetNormalized();
return CreateFromVectors(invDirection, outvA, outvB);
}
//////////////////////////////////////////////////////////////////////////
ILINE static Matrix33_tpl<F> CreateOrientation(const Vec3_tpl<F>& dir, const Vec3_tpl<F>& up, float rollAngle)
{
@@ -779,77 +676,6 @@ struct Matrix33_tpl
return tm;
}
/*!
* Direct-Matrix-Slerp: for the sake of completeness, I have included the following expression
* for Spherical-Linear-Interpolation without using quaternions. This is much faster then converting
* both matrices into quaternions in order to do a quaternion slerp and then converting the slerped
* quaternion back into a matrix.
* This is a high-precision calculation. Given two orthonormal 3x3 matrices this function calculates
* the shortest possible interpolation-path between the two rotations. The interpolation curve forms
* a great arc on the rotation sphere (geodesic). Not only does Slerp follow a great arc it follows
* the shortest great arc. Furthermore Slerp has constant angular velocity. All in all Slerp is the
* optimal interpolation curve between two rotations.
*
* STABILITY PROBLEM: There are two singularities at angle=0 and angle=PI. At 0 the interpolation-axis
* is arbitrary, which means any axis will produce the same result because we have no rotation. Thats
* why I'm using (1,0,0). At PI the rotations point away from each other and the interpolation-axis
* is unpredictable. In this case I'm also using the axis (1,0,0). If the angle is ~0 or ~PI, then we
* have to normalize a very small vector and this can cause numerical instability. The quaternion-slerp
* has exactly the same problems.
* Ivo
* Example:
* Matrix33 slerp=Matrix33::CreateSlerp( m,n,0.333f );
*/
ILINE void SetSlerp(const Matrix33_tpl<F>& m, const Matrix33_tpl<F>& n, F t)
{
assert(m.IsValid());
assert(n.IsValid());
//calculate delta-rotation between m and n (=39 flops)
Matrix33_tpl<F> d, i;
d.m00 = m.m00 * n.m00 + m.m10 * n.m10 + m.m20 * n.m20;
d.m01 = m.m00 * n.m01 + m.m10 * n.m11 + m.m20 * n.m21;
d.m02 = m.m00 * n.m02 + m.m10 * n.m12 + m.m20 * n.m22;
d.m10 = m.m01 * n.m00 + m.m11 * n.m10 + m.m21 * n.m20;
d.m11 = m.m01 * n.m01 + m.m11 * n.m11 + m.m21 * n.m21;
d.m12 = m.m01 * n.m02 + m.m11 * n.m12 + m.m21 * n.m22;
d.m20 = d.m01 * d.m12 - d.m02 * d.m11;
d.m21 = d.m02 * d.m10 - d.m00 * d.m12;
d.m22 = d.m00 * d.m11 - d.m01 * d.m10;
assert(d.IsOrthonormalRH(0.0001f));
Vec3_tpl<F> axis(d.m21 - d.m12, d.m02 - d.m20, d.m10 - d.m01);
F l = sqrt(axis | axis);
if (l > F(0.00001))
{
axis /= l;
}
else
{
axis(1, 0, 0);
}
i.SetRotationAA(acos(clamp_tpl((d.m00 + d.m11 + d.m22 - 1) * 0.5f, F(-1), F(+1))) * t, axis); //angle interpolation and calculation of new delta-matrix (=26 flops)
//final concatenation (=39 flops)
m00 = F(m.m00 * i.m00 + m.m01 * i.m10 + m.m02 * i.m20);
m01 = F(m.m00 * i.m01 + m.m01 * i.m11 + m.m02 * i.m21);
m02 = F(m.m00 * i.m02 + m.m01 * i.m12 + m.m02 * i.m22);
m10 = F(m.m10 * i.m00 + m.m11 * i.m10 + m.m12 * i.m20);
m11 = F(m.m10 * i.m01 + m.m11 * i.m11 + m.m12 * i.m21);
m12 = F(m.m10 * i.m02 + m.m11 * i.m12 + m.m12 * i.m22);
m20 = m01 * m12 - m02 * m11;
m21 = m02 * m10 - m00 * m12;
m22 = m00 * m11 - m01 * m10;
assert(this->IsOrthonormalRH(0.0001f));
}
ILINE static Matrix33_tpl<F> CreateSlerp(const Matrix33_tpl<F> m, const Matrix33_tpl<F> n, F t)
{
Matrix33_tpl<F> m33;
m33.SetSlerp(m, n, t);
return m33;
}
ILINE void SetScale(const Vec3_tpl<F>& s)
{
m00 = s.x;
@@ -880,9 +706,6 @@ struct Matrix33_tpl
}
ILINE static Matrix33_tpl<F> CreateFromVectors(const Vec3_tpl<F>& vx, const Vec3_tpl<F>& vy, const Vec3_tpl<F>& vz) { Matrix33_tpl<F> dst; dst.SetFromVectors(vx, vy, vz); return dst; }
ILINE void Transpose() // in-place transposition
{
F t;
@@ -896,56 +719,6 @@ struct Matrix33_tpl
m12 = m21;
m21 = t;
}
ILINE Matrix33_tpl<F> GetTransposed() const
{
Matrix33_tpl<F> dst;
dst.m00 = m00;
dst.m01 = m10;
dst.m02 = m20;
dst.m10 = m01;
dst.m11 = m11;
dst.m12 = m21;
dst.m20 = m02;
dst.m21 = m12;
dst.m22 = m22;
return dst;
}
ILINE Matrix33_tpl<F> T() const { return GetTransposed(); }
ILINE Matrix33_tpl& Fabs()
{
m00 = fabs_tpl(m00);
m01 = fabs_tpl(m01);
m02 = fabs_tpl(m02);
m10 = fabs_tpl(m10);
m11 = fabs_tpl(m11);
m12 = fabs_tpl(m12);
m20 = fabs_tpl(m20);
m21 = fabs_tpl(m21);
m22 = fabs_tpl(m22);
return *this;
}
ILINE Matrix33_tpl<F> GetFabs() const { Matrix33_tpl<F> m = *this; m.Fabs(); return m; }
ILINE void Adjoint(void)
{
//rescue members
Matrix33_tpl<F> m = *this;
//calculate the adjoint-matrix
m00 = m.m11 * m.m22 - m.m12 * m.m21;
m01 = m.m12 * m.m20 - m.m10 * m.m22;
m02 = m.m10 * m.m21 - m.m11 * m.m20;
m10 = m.m21 * m.m02 - m.m22 * m.m01;
m11 = m.m22 * m.m00 - m.m20 * m.m02;
m12 = m.m20 * m.m01 - m.m21 * m.m00;
m20 = m.m01 * m.m12 - m.m02 * m.m11;
m21 = m.m02 * m.m10 - m.m00 * m.m12;
m22 = m.m00 * m.m11 - m.m01 * m.m10;
}
ILINE Matrix33_tpl<F> GetAdjoint() const { Matrix33_tpl<F> dst = *this; dst.Adjoint(); return dst; }
/*!
*
@@ -1201,8 +974,6 @@ struct Matrix33_tpl
///////////////////////////////////////////////////////////////////////////////
typedef Matrix33_tpl<f32> Matrix33; //always 32 bit
typedef Matrix33_tpl<f64> Matrix33d; //always 64 bit
typedef Matrix33_tpl<real> Matrix33r; //variable float precision. depending on the target system it can be between 32, 64 or 80 bit
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
@@ -1360,9 +1131,6 @@ ILINE Matrix33_tpl<F1>& operator+=(Matrix33_tpl<F1>& l, const Matrix33_tpl<F2>&
return l;
}
template<class F1, class F2>
ILINE Matrix33_tpl<F1> operator - (const Matrix33_tpl<F1>& l, const Matrix33_tpl<F2>& r)
{
@@ -1397,9 +1165,6 @@ ILINE Matrix33_tpl<F1>& operator-=(Matrix33_tpl<F1>& l, const Matrix33_tpl<F2>&
return l;
}
template<class F>
ILINE Matrix33_tpl<F> operator*(const Matrix33_tpl<F>& m, F op)
{
@@ -1462,37 +1227,3 @@ ILINE Vec2_tpl<F1> operator*(const Vec2_tpl<F1>& v, const Matrix33_tpl<F2>& m)
assert(v.IsValid());
return Vec2_tpl<F1>(v.x * m.m00 + v.y * m.m10, v.x * m.m01 + v.y * m.m11);
}
template<class F1>
ILINE Matrix33_tpl<F1>& crossproduct_matrix(const Vec3_tpl<F1>& v, Matrix33_tpl<F1>& m)
{
m.m00 = 0;
m.m01 = -v.z;
m.m02 = v.y;
m.m10 = v.z;
m.m11 = 0;
m.m12 = -v.x;
m.m20 = -v.y;
m.m21 = v.x;
m.m22 = 0;
return m;
}
template<class F1>
ILINE Matrix33_tpl<F1>& dotproduct_matrix(const Vec3_tpl<F1>& v, const Vec3_tpl<F1>& op, Matrix33_tpl<F1>& m)
{
m.m00 = v.x * op.x;
m.m10 = v.y * op.x;
m.m20 = v.z * op.x;
m.m01 = v.x * op.y;
m.m11 = v.y * op.y;
m.m21 = v.z * op.y;
m.m02 = v.x * op.z;
m.m12 = v.y * op.z;
m.m22 = v.z * op.z;
return m;
}
#endif // CRYINCLUDE_CRYCOMMON_CRY_MATRIX33_H
+4 -430
View File
@@ -8,16 +8,8 @@
// Description : Common matrix class
#ifndef CRYINCLUDE_CRYCOMMON_CRY_MATRIX34_H
#define CRYINCLUDE_CRYCOMMON_CRY_MATRIX34_H
#pragma once
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -347,220 +339,6 @@ struct Matrix34_tpl
*this = Matrix33_tpl<F>(q);
}
//CONSTRUCTOR for identical float-types. It converts a QuatT into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
explicit ILINE Matrix34_tpl<F>(const QuatT_tpl<F> &q)
{
*this = Matrix34_tpl<F>(Matrix33_tpl<F>(q.q), q.t);
}
//CONSTRUCTOR for different float-types. It converts a QuatT into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
template<class F1>
ILINE explicit Matrix34_tpl(const QuatT_tpl<F1> q)
{
*this = Matrix34_tpl<F>(Matrix33_tpl<F1>(q.q), q.t);
}
//CONSTRUCTOR for identical float-types. It converts a QuatTS into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
explicit ILINE Matrix34_tpl<F>(const QuatTS_tpl<F> &q)
{
assert(q.q.IsValid());
Vec3_tpl<F> v2 = q.q.v + q.q.v;
F xx = 1 - v2.x * q.q.v.x;
F yy = v2.y * q.q.v.y;
F xw = v2.x * q.q.w;
F xy = v2.y * q.q.v.x;
F yz = v2.z * q.q.v.y;
F yw = v2.y * q.q.w;
F xz = v2.z * q.q.v.x;
F zz = v2.z * q.q.v.z;
F zw = v2.z * q.q.w;
m00 = (1 - yy - zz) * q.s;
m01 = (xy - zw) * q.s;
m02 = (xz + yw) * q.s;
m03 = q.t.x;
m10 = (xy + zw) * q.s;
m11 = (xx - zz) * q.s;
m12 = (yz - xw) * q.s;
m13 = q.t.y;
m20 = (xz - yw) * q.s;
m21 = (yz + xw) * q.s;
m22 = (xx - yy) * q.s;
m23 = q.t.z;
}
//CONSTRUCTOR for different float-types. It converts a QuatTS into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
template<class F1>
ILINE explicit Matrix34_tpl<F>(const QuatTS_tpl<F1> &q)
{
assert(q.q.IsValid());
Vec3_tpl<F1> v2 = q.q.v + q.q.v;
F1 xx = 1 - v2.x * q.q.v.x;
F1 yy = v2.y * q.q.v.y;
F1 xw = v2.x * q.q.w;
F1 xy = v2.y * q.q.v.x;
F1 yz = v2.z * q.q.v.y;
F1 yw = v2.y * q.q.w;
F1 xz = v2.z * q.q.v.x;
F1 zz = v2.z * q.q.v.z;
F1 zw = v2.z * q.q.w;
m00 = F((1 - yy - zz) * q.s);
m01 = F((xy - zw) * q.s);
m02 = F((xz + yw) * q.s);
m03 = F(q.t.x);
m10 = F((xy + zw) * q.s);
m11 = F((xx - zz) * q.s);
m12 = F((yz - xw) * q.s);
m13 = F(q.t.y);
m20 = F((xz - yw) * q.s);
m21 = F((yz + xw) * q.s);
m22 = F((xx - yy) * q.s);
m23 = F(q.t.z);
}
//CONSTRUCTOR for identical float-types. It converts a QuatTNS into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
explicit ILINE Matrix34_tpl<F>(const QuatTNS_tpl<F> &q)
{
assert(q.q.IsValid());
Vec3_tpl<F> v2 = q.q.v + q.q.v;
F xx = 1 - v2.x * q.q.v.x;
F yy = v2.y * q.q.v.y;
F xw = v2.x * q.q.w;
F xy = v2.y * q.q.v.x;
F yz = v2.z * q.q.v.y;
F yw = v2.y * q.q.w;
F xz = v2.z * q.q.v.x;
F zz = v2.z * q.q.v.z;
F zw = v2.z * q.q.w;
m00 = (1 - yy - zz) * q.s.x;
m01 = (xy - zw) * q.s.y;
m02 = (xz + yw) * q.s.z;
m03 = q.t.x;
m10 = (xy + zw) * q.s.x;
m11 = (xx - zz) * q.s.y;
m12 = (yz - xw) * q.s.z;
m13 = q.t.y;
m20 = (xz - yw) * q.s.x;
m21 = (yz + xw) * q.s.y;
m22 = (xx - yy) * q.s.z;
m23 = q.t.z;
}
//CONSTRUCTOR for different float-types. It converts a QuatTNS into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
template<class F1>
ILINE explicit Matrix34_tpl<F>(const QuatTNS_tpl<F1> &q)
{
assert(q.q.IsValid());
Vec3_tpl<F1> v2 = q.q.v + q.q.v;
F1 xx = 1 - v2.x * q.q.v.x;
F1 yy = v2.y * q.q.v.y;
F1 xw = v2.x * q.q.w;
F1 xy = v2.y * q.q.v.x;
F1 yz = v2.z * q.q.v.y;
F1 yw = v2.y * q.q.w;
F1 xz = v2.z * q.q.v.x;
F1 zz = v2.z * q.q.v.z;
F1 zw = v2.z * q.q.w;
m00 = F((1 - yy - zz) * q.s.x);
m01 = F((xy - zw) * q.s.y);
m02 = F((xz + yw) * q.s.z);
m03 = F(q.t.x);
m10 = F((xy + zw) * q.s.x);
m11 = F((xx - zz) * q.s.y);
m12 = F((yz - xw) * q.s.z);
m13 = F(q.t.y);
m20 = F((xz - yw) * q.s.x);
m21 = F((yz + xw) * q.s.y);
m22 = F((xx - yy) * q.s.z);
m23 = F(q.t.z);
}
//CONSTRUCTOR for identical float-types. It converts a DualQuat into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
ILINE explicit Matrix34_tpl<F>(const DualQuat_tpl<F> &q)
{
assert((fabs_tpl(1 - (q.nq | q.nq))) < 0.01); //check if unit-quaternion
Vec3_tpl<F> t = (q.nq.w * q.dq.v - q.dq.w * q.nq.v + q.nq.v % q.dq.v); //perfect for HLSL
Vec3_tpl<F> v2 = q.nq.v + q.nq.v;
F xx = 1 - v2.x * q.nq.v.x;
F yy = v2.y * q.nq.v.y;
F xw = v2.x * q.nq.w;
F xy = v2.y * q.nq.v.x;
F yz = v2.z * q.nq.v.y;
F yw = v2.y * q.nq.w;
F xz = v2.z * q.nq.v.x;
F zz = v2.z * q.nq.v.z;
F zw = v2.z * q.nq.w;
m00 = 1 - yy - zz;
m01 = xy - zw;
m02 = xz + yw;
m03 = t.x + t.x;
m10 = xy + zw;
m11 = xx - zz;
m12 = yz - xw;
m13 = t.y + t.y;
m20 = xz - yw;
m21 = yz + xw;
m22 = xx - yy;
m23 = t.z + t.z;
}
//CONSTRUCTOR for different float-types. It converts a DualQuat into a Matrix34.
//Needs to be 'explicit' because we loose float-precision in the conversion process
//Matrix34(QuatT);
template<class F1>
ILINE explicit Matrix34_tpl<F>(const DualQuat_tpl<F1> &q)
{
assert((fabs_tpl(1 - (q.nq | q.nq))) < 0.01); //check if unit-quaternion
Vec3_tpl<F1> t = (q.nq.w * q.dq.v - q.dq.w * q.nq.v + q.nq.v % q.dq.v); //perfect for HLSL
Vec3_tpl<F1> v2 = q.nq.v + q.nq.v;
F1 xx = 1 - v2.x * q.nq.v.x;
F1 yy = v2.y * q.nq.v.y;
F1 xw = v2.x * q.nq.w;
F1 xy = v2.y * q.nq.v.x;
F1 yz = v2.z * q.nq.v.y;
F1 yw = v2.y * q.nq.w;
F1 xz = v2.z * q.nq.v.x;
F1 zz = v2.z * q.nq.v.z;
F1 zw = v2.z * q.nq.w;
m00 = F(1 - yy - zz);
m01 = F(xy - zw);
m02 = F(xz + yw);
m03 = F(t.x + t.x);
m10 = F(xy + zw);
m11 = F(xx - zz);
m12 = F(yz - xw);
m13 = F(t.y + t.y);
m20 = F(xz - yw);
m21 = F(yz + xw);
m22 = F(xx - yy);
m23 = F(t.z + t.z);
}
//apply scaling to the columns of the matrix.
ILINE void ScaleColumn(const Vec3_tpl<F>& s)
{
@@ -580,7 +358,7 @@ struct Matrix34_tpl
* Initializes the Matrix34 with the identity.
*
*/
void SetIdentity(void)
void SetIdentity()
{
m00 = 1.0f;
m01 = 0.0f;
@@ -596,58 +374,12 @@ struct Matrix34_tpl
m23 = 0.0f;
}
ILINE static Matrix34_tpl<F> CreateIdentity(void)
ILINE static Matrix34_tpl<F> CreateIdentity()
{
Matrix34_tpl<F> m;
m.SetIdentity();
return m;
}
ILINE bool IsIdentity() const
{
return 0 == (fabs_tpl((F)1 - m00) + fabs_tpl(m01) + fabs_tpl(m02) + fabs_tpl(m03) + fabs_tpl(m10) + fabs_tpl((F)1 - m11) + fabs_tpl(m12) + fabs_tpl(m13) + fabs_tpl(m20) + fabs_tpl(m21) + fabs_tpl((F)1 - m22)) + fabs_tpl(m23);
}
ILINE int IsZero() const
{
return 0 == (fabs_tpl(m00) + fabs_tpl(m01) + fabs_tpl(m02) + fabs_tpl(m03) + fabs_tpl(m10) + fabs_tpl(m11) + fabs_tpl(m12) + fabs_tpl(m13) + fabs_tpl(m20) + fabs_tpl(m21) + fabs_tpl(m22)) + fabs_tpl(m23);
}
/*!
* Create a rotation matrix around an arbitrary axis (Eulers Theorem).
* The axis is specified as an normalized Vec3. The angle is assumed to be in radians.
* This function also assumes a translation-vector and stores it in the right column.
*
* Example:
* Matrix34 m34;
* Vec3 axis=GetNormalized( Vec3(-1.0f,-0.3f,0.0f) );
* m34.SetRotationAA( 3.14314f, axis, Vec3(5,5,5) );
*/
ILINE void SetRotationAA(const F rad, const Vec3_tpl<F>& axis, const Vec3_tpl<F>& t = Vec3(ZERO))
{
*this = Matrix33_tpl<F>::CreateRotationAA(rad, axis);
this->SetTranslation(t);
}
ILINE static Matrix34_tpl<F> CreateRotationAA(const F rad, const Vec3_tpl<F>& axis, const Vec3_tpl<F>& t = Vec3(ZERO))
{
Matrix34_tpl<F> m34;
m34.SetRotationAA(rad, axis, t);
return m34;
}
ILINE void SetRotationAA(const Vec3_tpl<F>& rot, const Vec3_tpl<F>& t = Vec3(ZERO))
{
*this = Matrix33_tpl<F>::CreateRotationAA(rot);
this->SetTranslation(t);
}
ILINE static Matrix34_tpl<F> CreateRotationAA(const Vec3_tpl<F>& rot, const Vec3_tpl<F>& t = Vec3(ZERO))
{
Matrix34_tpl<F> m34;
m34.SetRotationAA(rot, t);
return m34;
}
/*!
* Create rotation-matrix about X axis using an angle.
* The angle is assumed to be in radians.
@@ -690,28 +422,6 @@ struct Matrix34_tpl
return m34;
}
/*!
* Create rotation-matrix about Z axis using an angle.
* The angle is assumed to be in radians.
* The translation-vector is set to zero.
*
* Example:
* Matrix34 m34;
* m34.SetRotationZ(0.5f);
*/
ILINE void SetRotationZ(const f32 rad, const Vec3_tpl<F>& t = Vec3(ZERO))
{
*this = Matrix33_tpl<F>::CreateRotationZ(rad);
this->SetTranslation(t);
}
ILINE static Matrix34_tpl<F> CreateRotationZ(const f32 rad, const Vec3_tpl<F>& t = Vec3(ZERO))
{
Matrix34_tpl<F> m34;
m34.SetRotationZ(rad, t);
return m34;
}
/*!
*
* Convert three Euler angle to mat33 (rotation order:XYZ)
@@ -742,22 +452,6 @@ struct Matrix34_tpl
}
ILINE void SetRotationAA(F c, F s, Vec3_tpl<F> axis, const Vec3_tpl<F>& t = Vec3(ZERO))
{
assert(axis.IsValid());
assert(t.IsValid());
*this = Matrix33_tpl<F>::CreateRotationAA(c, s, axis);
m03 = t.x;
m13 = t.y;
m23 = t.z;
}
ILINE static Matrix34_tpl<F> CreateRotationAA(F c, F s, Vec3_tpl<F> axis, const Vec3_tpl<F>& t = Vec3(ZERO))
{
Matrix34_tpl<F> m34;
m34.SetRotationAA(c, s, axis, t);
return m34;
}
ILINE void SetTranslationMat(const Vec3_tpl<F>& v)
{
m00 = 1.0f;
@@ -804,25 +498,6 @@ struct Matrix34_tpl
return m;
}
void InvertFast()
{ // in-place transposition
assert(IsOrthonormal());
F t;
Vec3 v(m03, m13, m23);
t = m01;
m01 = m10;
m10 = t;
m03 = -v.x * m00 - v.y * m01 - v.z * m20;
t = m02;
m02 = m20;
m20 = t;
m13 = -v.x * m10 - v.y * m11 - v.z * m21;
t = m12;
m12 = m21;
m21 = t;
m23 = -v.x * m20 - v.y * m21 - v.z * m22;
}
Matrix34_tpl<F> GetInvertedFast() const
{
assert(IsOrthonormal());
@@ -875,14 +550,6 @@ struct Matrix34_tpl
m22 = z.z;
}
//determinant is ambiguous: only the upper-left-submatrix's determinant is calculated
ILINE f32 Determinant() const
{
return (m00 * m11 * m22) + (m01 * m12 * m20) + (m02 * m10 * m21) - (m02 * m11 * m20) - (m00 * m12 * m21) - (m01 * m10 * m22);
}
//--------------------------------------------------------------------------------
//---- helper functions to access matrix-members ------------
//--------------------------------------------------------------------------------
@@ -896,10 +563,8 @@ struct Matrix34_tpl
ILINE void SetRow(int i, const Vec3_tpl<F>& v) { assert(i < 3); F* p = (F*)(&m00); p[0 + 4 * i] = v.x; p[1 + 4 * i] = v.y; p[2 + 4 * i] = v.z; }
ILINE const Vec3_tpl<F>& GetRow(int i) const { assert(i < 3); return *(const Vec3_tpl<F>*)(&m00 + 4 * i); }
ILINE const Vec4_tpl<F>& GetRow4(int i) const { assert(i < 3); return *(const Vec4_tpl<F>*)(&m00 + 4 * i); }
ILINE const Vec4& GetRow4(int i) const { assert(i < 3); return *(const Vec4*)(&m00 + 4 * i); }
ILINE void SetColumn(int i, const Vec3_tpl<F>& v) { assert(i < 4); F* p = (F*)(&m00); p[i + 4 * 0] = v.x; p[i + 4 * 1] = v.y; p[i + 4 * 2] = v.z; }
ILINE Vec3_tpl<F> GetColumn(int i) const { assert(i < 4); F* p = (F*)(&m00); return Vec3(p[i + 4 * 0], p[i + 4 * 1], p[i + 4 * 2]); }
ILINE Vec3_tpl<F> GetColumn0() const { return Vec3_tpl<F>(m00, m10, m20); }
ILINE Vec3_tpl<F> GetColumn1() const { return Vec3_tpl<F>(m01, m11, m21); }
ILINE Vec3_tpl<F> GetColumn2() const { return Vec3_tpl<F>(m02, m12, m22); }
@@ -908,8 +573,6 @@ struct Matrix34_tpl
ILINE void SetTranslation(const Vec3_tpl<F>& t) { m03 = t.x; m13 = t.y; m23 = t.z; }
ILINE Vec3_tpl<F> GetTranslation() const { return Vec3_tpl<F>(m03, m13, m23); }
ILINE void ScaleTranslation (F s) { m03 *= s; m13 *= s; m23 *= s; }
ILINE Matrix34_tpl<F> AddTranslation(const Vec3_tpl<F>& t) { m03 += t.x; m13 += t.y; m23 += t.z; return *this; }
ILINE void SetRotation33(const Matrix33_tpl<F>& m33)
{
@@ -924,19 +587,6 @@ struct Matrix34_tpl
m22 = m33.m22;
}
ILINE void GetRotation33(Matrix33_tpl<F>& m33) const
{
m33.m00 = m00;
m33.m01 = m01;
m33.m02 = m02;
m33.m10 = m10;
m33.m11 = m11;
m33.m12 = m12;
m33.m20 = m20;
m33.m21 = m21;
m33.m22 = m22;
}
//check if we have an orthonormal-base (general case, works even with reflection matrices)
int IsOrthonormal(F threshold = 0.001) const
{
@@ -1031,15 +681,6 @@ struct Matrix34_tpl
return true;
}
bool IsDegenerate(float epsilon = FLT_EPSILON) const
{
//check the basis vectors for 0 vector
return GetColumn0().len2() < epsilon
|| GetColumn1().len2() < epsilon
|| GetColumn2().len2() < epsilon;
}
/*!
* Create a matrix with SCALING, ROTATION and TRANSLATION (in this order).
*
@@ -1093,43 +734,12 @@ struct Matrix34_tpl
* Example 1:
* Matrix m34;
* m34.SetScale( Vec3(0.5f, 1.0f, 2.0f) );
* Example 2:
* Matrix34 m34 = Matrix34::CreateScale( Vec3(0.5f, 1.0f, 2.0f) );
*/
ILINE void SetScale(const Vec3_tpl<F>& s, const Vec3_tpl<F>& t = Vec3(ZERO))
{
*this = Matrix33::CreateScale(s);
this->SetTranslation(t);
}
ILINE static Matrix34_tpl<F> CreateScale(const Vec3_tpl<F>& s, const Vec3_tpl<F>& t = Vec3(ZERO))
{
Matrix34_tpl<F> m34;
m34.SetScale(s, t);
return m34;
}
ILINE Matrix44_tpl<F> GetTransposed() const
{
Matrix44_tpl<F> tmp;
tmp.m00 = m00;
tmp.m01 = m10;
tmp.m02 = m20;
tmp.m03 = 0;
tmp.m10 = m01;
tmp.m11 = m11;
tmp.m12 = m21;
tmp.m13 = 0;
tmp.m20 = m02;
tmp.m21 = m12;
tmp.m22 = m22;
tmp.m23 = 0;
tmp.m30 = m03;
tmp.m31 = m13;
tmp.m32 = m23;
tmp.m33 = 1;
return tmp;
}
/*!
* calculate a real inversion of a Matrix34
@@ -1141,7 +751,7 @@ struct Matrix34_tpl
* Example 2:
* Matrix34 im34 = m34.GetInverted();
*/
void Invert(void)
void Invert()
{
//rescue members
Matrix34_tpl<F> m = *this;
@@ -1182,37 +792,6 @@ struct Matrix34_tpl
dst.Invert();
return dst;
}
/*!
* Name: ReflectMat34
* Description: reflect a rotation matrix with respect to a plane.
*
* Example:
* Vec3 normal( 0.0f,-1.0f, 0.0f);
* Vec3 pos(0,1000,0);
* Matrix34 m34=CreateReflectionMat( pos, normal );
*/
ILINE static Matrix34_tpl<F> CreateReflectionMat (const Vec3_tpl<F>& p, const Vec3_tpl<F>& n)
{
Matrix34_tpl<F> m;
F vxy = -2.0f * n.x * n.y;
F vxz = -2.0f * n.x * n.z;
F vyz = -2.0f * n.y * n.z;
F pdotn = 2.0f * (p | n);
m.m00 = 1.0f - 2.0f * n.x * n.x;
m.m01 = vxy;
m.m02 = vxz;
m.m03 = pdotn * n.x;
m.m10 = vxy;
m.m11 = 1.0f - 2.0f * n.y * n.y;
m.m12 = vyz;
m.m13 = pdotn * n.y;
m.m20 = vxz;
m.m21 = vyz;
m.m22 = 1.0f - 2.0f * n.z * n.z;
m.m23 = pdotn * n.z;
return m;
}
};
///////////////////////////////////////////////////////////////////////////////
@@ -1220,8 +799,6 @@ struct Matrix34_tpl
///////////////////////////////////////////////////////////////////////////////
typedef Matrix34_tpl<f32> Matrix34; //always 32 bit
typedef Matrix34_tpl<f64> Matrix34d;//always 64 bit
typedef Matrix34_tpl<real> Matrix34r;//variable float precision. depending on the target system it can be between 32, 64 or bit
#if AZ_COMPILER_MSVC
typedef __declspec(align(16)) Matrix34_tpl<f32> Matrix34A;
#elif AZ_COMPILER_CLANG
@@ -1423,6 +1000,3 @@ ILINE Matrix44_tpl<F> operator * (const Matrix34_tpl<F>& l, const Matrix44_tpl<F
m.m33 = r.m33;
return m;
}
#endif // CRYINCLUDE_CRYCOMMON_CRY_MATRIX34_H
+8 -8
View File
@@ -568,12 +568,12 @@ struct Matrix44_tpl
ILINE F& operator () (uint32 i, uint32 j) { assert ((i < 4) && (j < 4)); F* p_data = (F*)(&m00); return p_data[i * 4 + j]; }
ILINE void SetRow(int i, const Vec3_tpl<F>& v) { assert(i < 4); F* p = (F*)(&m00); p[0 + 4 * i] = v.x; p[1 + 4 * i] = v.y; p[2 + 4 * i] = v.z; }
ILINE void SetRow4(int i, const Vec4_tpl<F>& v) { assert(i < 4); F* p = (F*)(&m00); p[0 + 4 * i] = v.x; p[1 + 4 * i] = v.y; p[2 + 4 * i] = v.z; p[3 + 4 * i] = v.w; }
ILINE void SetRow4(int i, const Vec4& v) { assert(i < 4); F* p = (F*)(&m00); p[0 + 4 * i] = v.x; p[1 + 4 * i] = v.y; p[2 + 4 * i] = v.z; p[3 + 4 * i] = v.w; }
ILINE const Vec3_tpl<F>& GetRow(int i) const { assert(i < 4); return *(const Vec3_tpl<F>*)(&m00 + 4 * i); }
ILINE void SetColumn(int i, const Vec3_tpl<F>& v) { assert(i < 4); F* p = (F*)(&m00); p[i + 4 * 0] = v.x; p[i + 4 * 1] = v.y; p[i + 4 * 2] = v.z; }
ILINE Vec3_tpl<F> GetColumn(int i) const { assert(i < 4); F* p = (F*)(&m00); return Vec3(p[i + 4 * 0], p[i + 4 * 1], p[i + 4 * 2]); }
ILINE Vec4_tpl<F> GetColumn4(int i) const { assert(i < 4); F* p = (F*)(&m00); return Vec4(p[i + 4 * 0], p[i + 4 * 1], p[i + 4 * 2], p[i + 4 * 3]); }
ILINE Vec4 GetColumn4(int i) const { assert(i < 4); F* p = (F*)(&m00); return Vec4(p[i + 4 * 0], p[i + 4 * 1], p[i + 4 * 2], p[i + 4 * 3]); }
ILINE Vec3 GetTranslation() const { return Vec3(m03, m13, m23); }
ILINE void SetTranslation(const Vec3& t) { m03 = t.x; m13 = t.y; m23 = t.z; }
@@ -792,24 +792,24 @@ ILINE Matrix44_tpl<F1> operator * (const Matrix44_tpl<F1>& l, const Matrix44_tpl
}
//post-multiply
template<class F1, class F2>
ILINE Vec4_tpl<F1> operator*(const Matrix44_tpl<F2>& m, const Vec4_tpl<F1>& v)
template<class F2>
ILINE Vec4 operator*(const Matrix44_tpl<F2>& m, const Vec4& v)
{
assert(m.IsValid());
assert(v.IsValid());
return Vec4_tpl<F1>(v.x * m.m00 + v.y * m.m01 + v.z * m.m02 + v.w * m.m03,
return Vec4(v.x * m.m00 + v.y * m.m01 + v.z * m.m02 + v.w * m.m03,
v.x * m.m10 + v.y * m.m11 + v.z * m.m12 + v.w * m.m13,
v.x * m.m20 + v.y * m.m21 + v.z * m.m22 + v.w * m.m23,
v.x * m.m30 + v.y * m.m31 + v.z * m.m32 + v.w * m.m33);
}
//pre-multiply
template<class F1, class F2>
ILINE Vec4_tpl<F1> operator*(const Vec4_tpl<F1>& v, const Matrix44_tpl<F2>& m)
template<class F2>
ILINE Vec4 operator*(const Vec4& v, const Matrix44_tpl<F2>& m)
{
assert(m.IsValid());
assert(v.IsValid());
return Vec4_tpl<F1>(v.x * m.m00 + v.y * m.m10 + v.z * m.m20 + v.w * m.m30,
return Vec4(v.x * m.m00 + v.y * m.m10 + v.z * m.m20 + v.w * m.m30,
v.x * m.m01 + v.y * m.m11 + v.z * m.m21 + v.w * m.m31,
v.x * m.m02 + v.y * m.m12 + v.z * m.m22 + v.w * m.m32,
v.x * m.m03 + v.y * m.m13 + v.z * m.m23 + v.w * m.m33);
File diff suppressed because it is too large Load Diff
-8
View File
@@ -302,21 +302,13 @@ struct Vec2_tpl
///////////////////////////////////////////////////////////////////////////////
typedef Vec2_tpl<f32> Vec2; // always 32 bit
typedef Vec2_tpl<f64> Vec2d; // always 64 bit
typedef Vec2_tpl<int32> Vec2i;
typedef Vec2_tpl<uint32> Vec2ui;
typedef Vec2_tpl<real> Vec2r; // variable float precision. depending on the target system it can be 32, 64 or 80 bit
typedef Vec2_tpl<float> vector2f;
#if defined(LINUX64)
typedef Vec2_tpl<int> vector2l;
#else
typedef Vec2_tpl<long> vector2l;
#endif
typedef Vec2_tpl<float> vector2df;
typedef Vec2_tpl<real> vector2d;
typedef Vec2_tpl<int> vector2di;
typedef Vec2_tpl<unsigned int> vector2dui;
template<class F>
Vec2_tpl<F> operator*(F op1, const Vec2_tpl<F>& op2) {return Vec2_tpl<F>(op1 * op2.x, op1 * op2.y); }
+2 -45
View File
@@ -178,21 +178,6 @@ struct Vec3_tpl
assert(IsValid());
}
explicit ILINE Vec3_tpl<F>(const Vec4_tpl<F> &v) {
x = F(v.x);
y = F(v.y);
z = F(v.z);
}
template<class T>
explicit ILINE Vec3_tpl<F>(const Vec4_tpl<T> &v) {
x = F(v.x);
y = F(v.y);
z = F(v.z);
}
/*!
* overloaded arithmetic operator
*
@@ -847,6 +832,8 @@ struct Vec3_tpl
}
};
using Vec3i = Vec3_tpl<int32>;
// dot product (2 versions)
template<class F1, class F2>
ILINE F1 operator * (const Vec3_tpl<F1>& v0, const Vec3_tpl<F2>& v1)
@@ -943,15 +930,6 @@ ILINE bool IsEquivalent(const Vec3_tpl<F>& v0, const Vec3_tpl<F>& v1, f32 epsilo
///////////////////////////////////////////////////////////////////////////////
typedef Vec3_tpl<f32> Vec3; // always 32 bit
typedef Vec3_tpl<f64> Vec3d; // always 64 bit
typedef Vec3_tpl<int32> Vec3i;
typedef Vec3_tpl<uint32> Vec3ui;
typedef Vec3_tpl<real> Vec3r; // variable float precision. depending on the target system it can be 32, 64 or 80 bit
template<>
inline Vec3_tpl<f64>::Vec3_tpl(type_min) { x = y = z = -1.7E308; }
template<>
inline Vec3_tpl<f64>::Vec3_tpl(type_max) { x = y = z = 1.7E308; }
template<>
inline Vec3_tpl<f32>::Vec3_tpl(type_min) { x = y = z = -3.3E38f; }
template<>
@@ -1176,8 +1154,6 @@ struct Ang3_tpl
};
typedef Ang3_tpl<f32> Ang3;
typedef Ang3_tpl<real> Ang3r;
typedef Ang3_tpl<f64> Ang3_f64;
//---------------------------------------
@@ -1251,7 +1227,6 @@ struct AngleAxis_tpl
};
typedef AngleAxis_tpl<f32> AngleAxis;
typedef AngleAxis_tpl<f64> AngleAxis_f64;
template<typename F>
ILINE const Vec3_tpl<F> AngleAxis_tpl<F>::operator * (const Vec3_tpl<F>& v) const
@@ -1260,22 +1235,6 @@ ILINE const Vec3_tpl<F> AngleAxis_tpl<F>::operator * (const Vec3_tpl<F>& v) cons
return origin + (v - origin) * cos_tpl(angle) + (axis % v) * sin_tpl(angle);
}
//////////////////////////////////////////////////////////////////////
template<typename F>
struct Plane_tpl
@@ -1405,8 +1364,6 @@ struct Plane_tpl
};
typedef Plane_tpl<f32> Plane; //always 32 bit
typedef Plane_tpl<f64> Planed;//always 64 bit
typedef Plane_tpl<real> Planer;//variable float precision. depending on the target system it can be between 32, 64 or 80 bit
// declare common constants. Must be done after the class for compiler conformance
+41 -111
View File
@@ -5,37 +5,31 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Common vector class
#pragma once
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// class Vec4_tpl
// class Vec4
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <typename F>
struct Vec4_tpl
struct Vec4
{
typedef F value_type;
using value_type = f32;
enum
{
component_count = 4
};
F x, y, z, w;
f32 x, y, z, w;
#if defined(_DEBUG)
ILINE Vec4_tpl()
ILINE Vec4()
{
if constexpr (sizeof(F) == 4)
if constexpr (sizeof(f32) == 4)
{
uint32* p = alias_cast<uint32*>(&x);
p[0] = F32NAN;
@@ -43,49 +37,25 @@ struct Vec4_tpl
p[2] = F32NAN;
p[3] = F32NAN;
}
if constexpr (sizeof(F) == 8)
{
uint64* p = alias_cast<uint64*>(&x);
p[0] = F64NAN;
p[1] = F64NAN;
p[2] = F64NAN;
p[3] = F64NAN;
}
}
#else
ILINE Vec4_tpl() {}
ILINE Vec4() {}
#endif
template<typename F2>
ILINE Vec4_tpl<F>& operator = (const Vec4_tpl<F2>& v1)
{
x = F(v1.x);
y = F(v1.y);
z = F(v1.z);
w = F(v1.w);
return (*this);
}
ILINE Vec4(f32 vx, f32 vy, f32 vz, f32 vw) { x = vx; y = vy; z = vz; w = vw; }
ILINE Vec4(const Vec3_tpl<f32>& v, f32 vw) { x = v.x; y = v.y; z = v.z; w = vw; }
explicit ILINE Vec4(f32 m) { x = y = z = w = m; }
ILINE Vec4(type_zero) { x = y = z = w = f32(0); }
ILINE Vec4_tpl(F vx, F vy, F vz, F vw) { x = vx; y = vy; z = vz; w = vw; }
ILINE Vec4_tpl(const Vec3_tpl<F>& v, F vw) { x = v.x; y = v.y; z = v.z; w = vw; }
explicit ILINE Vec4_tpl(F m) { x = y = z = w = m; }
ILINE Vec4_tpl(type_zero) { x = y = z = w = F(0); }
ILINE void operator () (f32 vx, f32 vy, f32 vz, f32 vw) { x = vx; y = vy; z = vz; w = vw; }
ILINE void operator () (const Vec3_tpl<f32>& v, f32 vw) { x = v.x; y = v.y; z = v.z; w = vw; }
ILINE void operator () (F vx, F vy, F vz, F vw) { x = vx; y = vy; z = vz; w = vw; }
ILINE void operator () (const Vec3_tpl<F>& v, F vw) { x = v.x; y = v.y; z = v.z; w = vw; }
ILINE f32& operator [] (int index) { assert(index >= 0 && index <= 3); return ((f32*)this)[index]; }
ILINE f32 operator [] (int index) const { assert(index >= 0 && index <= 3); return ((f32*)this)[index]; }
ILINE F& operator [] (int index) { assert(index >= 0 && index <= 3); return ((F*)this)[index]; }
ILINE F operator [] (int index) const { assert(index >= 0 && index <= 3); return ((F*)this)[index]; }
template <class T>
ILINE Vec4_tpl(const Vec4_tpl<T>& v)
: x((F)v.x)
, y((F)v.y)
, z((F)v.z)
, w((F)v.w) { assert(this->IsValid()); }
ILINE Vec4& zero() { x = y = z = w = 0; return *this; }
ILINE Vec4_tpl& zero() { x = y = z = w = 0; return *this; }
ILINE bool IsEquivalent(const Vec4_tpl<F>& v1, F epsilon = VEC_EPSILON) const
ILINE bool IsEquivalent(const Vec4& v1, f32 epsilon = VEC_EPSILON) const
{
assert(v1.IsValid());
assert(this->IsValid());
@@ -93,7 +63,7 @@ struct Vec4_tpl
}
ILINE Vec4_tpl& operator=(const Vec4_tpl& src)
ILINE Vec4& operator=(const Vec4& src)
{
x = src.x;
y = src.y;
@@ -102,17 +72,17 @@ struct Vec4_tpl
return *this;
}
ILINE Vec4_tpl<F> operator * (F k) const
ILINE Vec4 operator * (f32 k) const
{
return Vec4_tpl<F>(x * k, y * k, z * k, w * k);
return Vec4(x * k, y * k, z * k, w * k);
}
ILINE Vec4_tpl<F> operator / (F k) const
ILINE Vec4 operator / (f32 k) const
{
k = (F)1.0 / k;
return Vec4_tpl<F>(x * k, y * k, z * k, w * k);
k = (f32)1.0 / k;
return Vec4(x * k, y * k, z * k, w * k);
}
ILINE Vec4_tpl<F>& operator *= (F k)
ILINE Vec4& operator *= (f32 k)
{
x *= k;
y *= k;
@@ -120,9 +90,9 @@ struct Vec4_tpl
w *= k;
return *this;
}
ILINE Vec4_tpl<F>& operator /= (F k)
ILINE Vec4& operator /= (f32 k)
{
k = (F)1.0 / k;
k = (f32)1.0 / k;
x *= k;
y *= k;
z *= k;
@@ -130,7 +100,7 @@ struct Vec4_tpl
return *this;
}
ILINE void operator += (const Vec4_tpl<F>& v)
ILINE void operator += (const Vec4& v)
{
x += v.x;
y += v.y;
@@ -138,7 +108,7 @@ struct Vec4_tpl
w += v.w;
}
ILINE void operator -= (const Vec4_tpl<F>& v)
ILINE void operator -= (const Vec4& v)
{
x -= v.x;
y -= v.y;
@@ -147,17 +117,17 @@ struct Vec4_tpl
}
ILINE F Dot (const Vec4_tpl<F>& vec2) const
ILINE f32 Dot (const Vec4& vec2) const
{
return x * vec2.x + y * vec2.y + z * vec2.z + w * vec2.w;
}
ILINE F GetLength() const
ILINE f32 GetLength() const
{
return sqrt_tpl(Dot(*this));
}
ILINE F GetLengthSquared() const
ILINE f32 GetLengthSquared() const
{
return Dot(*this);
}
@@ -190,24 +160,24 @@ struct Vec4_tpl
* Example:
* if (v0==v1) dosomething;
*/
ILINE bool operator==(const Vec4_tpl<F>& vec)
ILINE bool operator==(const Vec4& vec)
{
return x == vec.x && y == vec.y && z == vec.z && w == vec.w;
}
ILINE bool operator!=(const Vec4_tpl<F>& vec) { return !(*this == vec); }
ILINE bool operator!=(const Vec4& vec) { return !(*this == vec); }
ILINE friend bool operator ==(const Vec4_tpl<F>& v0, const Vec4_tpl<F>& v1)
ILINE friend bool operator ==(const Vec4& v0, const Vec4& v1)
{
return ((v0.x == v1.x) && (v0.y == v1.y) && (v0.z == v1.z) && (v0.w == v1.w));
}
ILINE friend bool operator !=(const Vec4_tpl<F>& v0, const Vec4_tpl<F>& v1) { return !(v0 == v1); }
ILINE friend bool operator !=(const Vec4& v0, const Vec4& v1) { return !(v0 == v1); }
//! normalize the vector
// The default Normalize function is in fact "safe". 0 vectors remain unchanged.
ILINE void Normalize()
{
assert(this->IsValid());
F fInvLen = isqrt_safe_tpl(x * x + y * y + z * z + w * w);
f32 fInvLen = isqrt_safe_tpl(x * x + y * y + z * z + w * w);
x *= fInvLen;
y *= fInvLen;
z *= fInvLen;
@@ -218,61 +188,21 @@ struct Vec4_tpl
ILINE void NormalizeFast()
{
assert(this->IsValid());
F fInvLen = isqrt_fast_tpl(x * x + y * y + z * z + w * w);
f32 fInvLen = isqrt_fast_tpl(x * x + y * y + z * z + w * w);
x *= fInvLen;
y *= fInvLen;
z *= fInvLen;
w *= fInvLen;
}
ILINE void SetLerp(const Vec4_tpl<F>& p, const Vec4_tpl<F>& q, F t) { *this = p * (1.0f - t) + q * t; }
ILINE static Vec4_tpl<F> CreateLerp(const Vec4_tpl<F>& p, const Vec4_tpl<F>& q, F t) { return p * (1.0f - t) + q * t; }
};
typedef Vec4_tpl<f32> Vec4; // always 32 bit
typedef Vec4_tpl<f64> Vec4d; // always 64 bit
typedef Vec4_tpl<int32> Vec4i;
typedef Vec4_tpl<uint32> Vec4ui;
typedef Vec4_tpl<real> Vec4r; // variable float precision. depending on the target system it can be 32, 64 or 80 bit
#if defined(WIN32) || defined(WIN64) || defined(LINUX) || defined(APPLE)
typedef Vec4_tpl<f32> Vec4A;
#elif defined(AZ_RESTRICTED_PLATFORM)
#include AZ_RESTRICTED_FILE(Cry_Vector4_h)
#endif
//vector self-addition
template<class F1, class F2>
ILINE Vec4_tpl<F1>& operator += (Vec4_tpl<F1>& v0, const Vec4_tpl<F2>& v1)
{
v0 = v0 + v1;
return v0;
}
//vector addition
template<class F1, class F2>
ILINE Vec4_tpl<F1> operator + (const Vec4_tpl<F1>& v0, const Vec4_tpl<F2>& v1)
ILINE Vec4 operator + (const Vec4& v0, const Vec4& v1)
{
return Vec4_tpl<F1>(v0.x + v1.x, v0.y + v1.y, v0.z + v1.z, v0.w + v1.w);
return Vec4(v0.x + v1.x, v0.y + v1.y, v0.z + v1.z, v0.w + v1.w);
}
//vector subtraction
template<class F1, class F2>
ILINE Vec4_tpl<F1> operator - (const Vec4_tpl<F1>& v0, const Vec4_tpl<F2>& v1)
ILINE Vec4 operator - (const Vec4& v0, const Vec4& v1)
{
return Vec4_tpl<F1>(v0.x - v1.x, v0.y - v1.y, v0.z - v1.z, v0.w - v1.w);
}
//vector multiplication
template<class F1, class F2>
ILINE Vec4_tpl<F1> operator * (const Vec4_tpl<F1> v0, const Vec4_tpl<F2>& v1)
{
return Vec4_tpl<F1>(v0.x * v1.x, v0.y * v1.y, v0.z * v1.z, v0.w * v1.w);
}
//vector division
template<class F1, class F2>
ILINE Vec4_tpl<F1> operator / (const Vec4_tpl<F1>& v0, const Vec4_tpl<F2>& v1)
{
return Vec4_tpl<F1>(v0.x / v1.x, v0.y / v1.y, v0.z / v1.z, v0.w / v1.w);
return Vec4(v0.x - v1.x, v0.y - v1.y, v0.z - v1.z, v0.w - v1.w);
}
@@ -1,93 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Implementation of the common function template specializations.
#ifndef CRYINCLUDE_CRYCOMMON_FUNCTORBASEFUNCTION_H
#define CRYINCLUDE_CRYCOMMON_FUNCTORBASEFUNCTION_H
#pragma once
#include "IFunctorBase.h"
//////////////////////////////////////////////////////////////////////////
// Return type void
// No arguments.
template<>
class TFunctor<void (*)()>
: public IFunctorBase
{
public:
typedef void (* TFunctionType)();
TFunctor(TFunctionType pFunction)
: m_pfnFunction(pFunction){}
virtual void Call()
{
m_pfnFunction();
}
private:
TFunctionType m_pfnFunction;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Return type void
// 1 argument.
template<typename tArgument1>
class TFunctor<void (*)(tArgument1)>
: public IFunctorBase
{
public:
typedef void (* TFunctionType)(tArgument1);
TFunctor(TFunctionType pFunction, tArgument1 Argument1)
: m_pfnFunction(pFunction)
, m_tArgument1(Argument1){}
virtual void Call()
{
m_pfnFunction(m_tArgument1);
}
private:
TFunctionType m_pfnFunction;
tArgument1 m_tArgument1;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Return type void
// 2 arguments.
template<typename tArgument1, typename tArgument2>
class TFunctor<void (*)(tArgument1, tArgument2)>
: public IFunctorBase
{
public:
typedef void (* TFunctionType)(tArgument1, tArgument2);
TFunctor(TFunctionType pFunction, const tArgument1& Argument1, const tArgument2& Argument2)
: m_pfnFunction(pFunction)
, m_tArgument1(Argument1)
, m_tArgument2(Argument2){}
virtual void Call()
{
m_pfnFunction(m_tArgument1, m_tArgument2);
}
private:
TFunctionType m_pfnFunction;
tArgument1 m_tArgument1;
tArgument2 m_tArgument2;
};
//////////////////////////////////////////////////////////////////////////
#endif // CRYINCLUDE_CRYCOMMON_FUNCTORBASEFUNCTION_H
-97
View File
@@ -1,97 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Implementation of the member function template specializations.
#ifndef CRYINCLUDE_CRYCOMMON_FUNCTORBASEMEMBER_H
#define CRYINCLUDE_CRYCOMMON_FUNCTORBASEMEMBER_H
#pragma once
#include "IFunctorBase.h"
//////////////////////////////////////////////////////////////////////////
// Return type void
// No Arguments
template<typename tCalleeType>
class TFunctor<void (tCalleeType::*)()>
: public IFunctorBase
{
public:
typedef void (tCalleeType::* TMemberFunctionType)();
TFunctor(tCalleeType* pCallee, TMemberFunctionType pMemberFunction)
: m_pCalee(pCallee)
, m_pfnMemberFunction(pMemberFunction){}
virtual void Call()
{
(m_pCalee->*m_pfnMemberFunction)();
}
private:
tCalleeType* m_pCalee;
TMemberFunctionType m_pfnMemberFunction;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Return type void
// 1 argument.
template<typename tCalleeType, typename tArgument1>
class TFunctor<void (tCalleeType::*)(tArgument1)>
: public IFunctorBase
{
public:
typedef void (tCalleeType::* TMemberFunctionType)(tArgument1);
TFunctor(tCalleeType* pCallee, TMemberFunctionType pMemberFunction, const tArgument1& Argument1)
: m_pCalee(pCallee)
, m_pfnMemberFunction(pMemberFunction)
, m_tArgument1(Argument1){}
virtual void Call()
{
(m_pCalee->*m_pfnMemberFunction)(m_tArgument1);
}
private:
tCalleeType* m_pCalee;
TMemberFunctionType m_pfnMemberFunction;
tArgument1 m_tArgument1;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Return type void
// 2 arguments.
template<typename tCalleeType, typename tArgument1, typename tArgument2>
class TFunctor<void (tCalleeType::*)(tArgument1, tArgument2)>
: public IFunctorBase
{
public:
typedef void (tCalleeType::* TMemberFunctionType)(tArgument1, tArgument2);
TFunctor(tCalleeType* pCallee, TMemberFunctionType pMemberFunction, const tArgument1& Argument1, const tArgument2& Argument2)
: m_pCalee(pCallee)
, m_pfnMemberFunction(pMemberFunction)
, m_tArgument1(Argument1)
, m_tArgument2(Argument2){}
virtual void Call()
{
(m_pCalee->*m_pfnMemberFunction)(m_tArgument1, m_tArgument2);
}
private:
tCalleeType* m_pCalee;
TMemberFunctionType m_pfnMemberFunction;
tArgument1 m_tArgument1;
tArgument2 m_tArgument2;
};
//////////////////////////////////////////////////////////////////////////
#endif // CRYINCLUDE_CRYCOMMON_FUNCTORBASEMEMBER_H
+2 -28
View File
@@ -10,15 +10,13 @@
#include <CryCommon/platform.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/function/function_template.h>
#include <AzCore/std/string/string_view.h>
struct SFunctor;
struct ConsoleBind;
struct ICVar;
class ITexture;
class ICrySizer;
struct ISystem;
#define CVAR_INT 1
@@ -192,15 +190,6 @@ struct IConsole
// Return:
// pointer to the interface ICVar
virtual ICVar* RegisterInt(const char* sName, int iValue, int nFlags, const char* help = "", ConsoleVarFunc pChangeFunc = nullptr) = 0;
// Create a new console variable that store the value in a int64
// Arguments:
// sName - console variable name
// iValue - default value
// nFlags - user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data)
// help - help text that is shown when you use <sName> ? in the console
// Return:
// pointer to the interface ICVar
virtual ICVar* RegisterInt64(const char* sName, int64 iValue, int nFlags, const char* help = "", ConsoleVarFunc pChangeFunc = nullptr) = 0;
// Create a new console variable that store the value in a float
// Arguments:
// sName - console variable name
@@ -243,14 +232,6 @@ struct IConsole
// pointer to the interface ICVar
virtual ICVar* Register(const char* name, const char** src, const char* defaultvalue, int nFlags = 0, const char* help = "", ConsoleVarFunc pChangeFunc = nullptr, bool allowModify = true) = 0;
// Registers an existing console variable
// Should only be used with static duration objects, object is never freed
// Arguments:
// pVar - the existing console variable
// Return:
// pointer to the interface ICVar (that was passed in)
virtual ICVar* Register(ICVar* pVar) = 0;
// ! Remove a variable from the console
// @param sVarName console variable name
// @param bDelete if true the variable is deleted
@@ -431,9 +412,6 @@ struct IConsole
virtual void ResetAutoCompletion() = 0;
//////////////////////////////////////////////////////////////////////////
// Calculation of the memory used by the whole console system
virtual void GetMemoryUsage (ICrySizer* pSizer) const = 0;
// Function related to progress bar
virtual void ResetProgressBar(int nProgressRange) = 0;
// Function related to progress bar
@@ -619,16 +597,12 @@ struct ICVar
// Adds a new on change functor to the list.
// It will add from index 1 on (0 is reserved).
// Returns an ID to use when getting or removing the functor
virtual uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) = 0;
virtual uint64 AddOnChangeFunctor(const AZStd::function<void()>& pChangeFunctor) = 0;
//////////////////////////////////////////////////////////////////////////
// Get the current callback function.
virtual ConsoleVarFunc GetOnChangeCallback() const = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
virtual void GetMemoryUsage(class ICrySizer* pSizer) const = 0;
//////////////////////////////////////////////////////////////////////////
// only useful for CVarGroups, other types return GetIVal()
// CVarGroups set multiple other CVars and this function returns
+3 -22
View File
@@ -7,33 +7,14 @@
*/
#pragma once
#include <CryCommon/Cry_Matrix34.h>
#include "IStatObj.h"
#include <IRenderer.h>
#include <limits>
#include <AzCore/Component/EntityId.h>
#include <AzCore/std/algorithm.h>
namespace AZ
{
class Vector2;
}
struct IMaterial;
struct IRenderNode;
struct IVisArea;
struct SRenderingPassInfo;
struct SRendItemSorter;
struct SFrameLodInfo;
struct pe_params_area;
struct pe_articgeomparams;
struct IStatObj;
struct IRenderNode
{
// Gives access to object components.
struct IStatObj* GetEntityStatObj(unsigned int = 0, unsigned int = 0, Matrix34A* = NULL, bool = false) {
IStatObj* GetEntityStatObj(unsigned int = 0, unsigned int = 0, Matrix34* = nullptr, bool = false) {
return nullptr;
}
-8
View File
@@ -23,7 +23,6 @@
#include <AzCore/EBus/EBus.h>
struct ISystem;
class ICrySizer;
struct ICryFont;
struct IFFont;
@@ -94,9 +93,6 @@ struct ICryFont
//! \param glyphSizeY Height (in pixels) of the characters to be rendered at in the font texture.
virtual void AddCharsToFontTextures(FontFamilyPtr pFontFamily, const char* pChars, int glyphSizeX = defaultGlyphSizeX, int glyphSizeY = defaultGlyphSizeY) = 0;
// Summary:
// Puts the objects used in this module into the sizer interface
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// Summary:
// All font names separated by ,
// Example:
@@ -266,10 +262,6 @@ struct IFFont
// Wraps text based on specified maximum line width (UTF-8)
virtual void WrapText(AZStd::string& result, float maxWidth, const char* pStr, const STextDrawContext& ctx) = 0;
// Description:
// Puts the memory used by this font into the given sizer.
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// Description:
// useful for special feature rendering interleaved with fonts (e.g. box behind the text)
virtual void GetGradientTextureCoord(float& minU, float& minV, float& maxU, float& maxV) const = 0;
-50
View File
@@ -10,13 +10,8 @@
#pragma once
#include "Cry_Color.h"
#include "StlUtils.h"
#include "CryEndian.h"
#include <Cry_Geo.h> // for AABB
#include <VertexFormats.h>
#include <Vertex.h>
#include <AzCore/Casting/numeric_cast.h>
// Description:
// 2D Texture coordinates used by CMesh.
@@ -28,32 +23,6 @@ private:
float s, t;
public:
explicit SMeshTexCoord(float x, float y)
{
s = x;
t = y;
}
explicit SMeshTexCoord(const Vec2f16& other)
{
const Vec2 uv = other.ToVec2();
s = uv.x;
t = uv.y;
}
explicit SMeshTexCoord(const Vec2& other)
{
s = other.x;
t = other.y;
}
explicit SMeshTexCoord(const Vec4& other)
{
s = other.x;
t = other.y;
}
bool IsEquivalent(const SMeshTexCoord& other, float epsilon = 0.00005f) const
{
return
@@ -113,16 +82,6 @@ public:
};
struct SMeshBoneMapping_uint8
{
typedef uint8 BoneId;
typedef uint8 Weight;
BoneId boneIds[4];
Weight weights[4];
};
// Subset of mesh is a continuous range of vertices and indices that share same material.
struct SMeshSubset
{
@@ -181,7 +140,6 @@ struct IIndexedMesh
int m_nIndexCount; // number of elements in m_pIndices array
};
// <interfuscator:shuffle>
virtual ~IIndexedMesh() {}
// Release indexed mesh.
@@ -190,15 +148,9 @@ struct IIndexedMesh
//! Gives read-only access to mesh data
virtual void GetMeshDescription(SMeshDescription& meshDesc) const = 0;
/*! Frees vertex and face streams. Calling this function invalidates SMeshDescription pointers */
virtual void FreeStreams() = 0;
//! Return number of allocated faces
virtual int GetFaceCount() const = 0;
/*! Reallocates faces. Calling this function invalidates SMeshDescription pointers */
virtual void SetFaceCount(int nNewCount) = 0;
//! Return number of allocated vertices, normals and colors
virtual int GetVertexCount() const = 0;
@@ -216,6 +168,4 @@ struct IIndexedMesh
//////////////////////////////////////////////////////////////////////////
virtual int GetSubSetCount() const = 0;
virtual const SMeshSubset& GetSubSet(int nIndex) const = 0;
// </interfuscator:shuffle>
};
-9
View File
@@ -8,13 +8,8 @@
// Description : Gathers level information. Loads a level.
#ifndef CRYINCLUDE_CRYACTION_ILEVELSYSTEM_H
#define CRYINCLUDE_CRYACTION_ILEVELSYSTEM_H
#pragma once
#include <CrySizer.h>
#include <IXml.h>
#include <AzCore/Asset/AssetCommon.h>
@@ -56,8 +51,6 @@ struct ILevelSystemListener
virtual void OnLoadingProgress([[maybe_unused]] const char* levelName, [[maybe_unused]] int progressAmount) {}
//! Called after a level is unloaded, before the data is freed.
virtual void OnUnloadComplete([[maybe_unused]] const char* levelName) {}
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const { }
};
struct ILevelSystem
@@ -95,5 +88,3 @@ protected:
static constexpr const char* LevelsDirectoryName = "levels";
};
#endif // CRYINCLUDE_CRYACTION_ILEVELSYSTEM_H
@@ -43,10 +43,6 @@ struct SLocalizedAdvancesSoundEntry
{
AZStd::string sName;
float fValue;
void GetMemoryUsage(ICrySizer* pSizer) const
{
pSizer->AddObject(sName);
}
};
// Localization Sound Info structure, containing sound related parameters.
-7
View File
@@ -16,9 +16,6 @@
// this code is disable by default due it's runtime cost
//#define SUPPORT_LOG_IDENTER
// forward declarations
class ICrySizer;
// Summary:
// Callback interface to the ILog.
struct ILogCallback
@@ -121,10 +118,6 @@ struct ILog
virtual const char* GetModuleFilter() = 0;
// Notes:
// Collect memory statistics in CrySizer
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// Asset scope strings help to figure out asset dependencies in case of asset loading errors.
// Should not be used directly, only by using define CRY_DEFINE_ASSET_SCOPE
// @see CRY_DEFINE_ASSET_SCOPE
-6
View File
@@ -14,7 +14,6 @@
#include <AzCore/EBus/EBus.h>
struct IShader;
struct ISurfaceType;
struct SShaderItem;
namespace AZ
@@ -38,12 +37,7 @@ namespace AZ
struct IMaterial
{
// TODO: Remove it!
virtual ~IMaterial() {}
virtual void AddRef() = 0;
virtual void Release() = 0;
virtual SShaderItem& GetShaderItem() = 0;
virtual const SShaderItem& GetShaderItem() const = 0;
};
-47
View File
@@ -6,9 +6,6 @@
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_IMOVIESYSTEM_H
#define CRYINCLUDE_CRYCOMMON_IMOVIESYSTEM_H
#pragma once
#include <AzCore/Component/ComponentBus.h>
@@ -255,8 +252,6 @@ struct SAnimContext
// TODO: Mask should be stored with dynamic length
uint32 trackMask; //!< To update certain types of tracks only
float startTime; //!< The start time of this playing sequence
void Serialize(XmlNodeRef& xmlNode, bool loading);
};
/** Parameters for cut-scene cameras
@@ -891,7 +886,6 @@ struct ITrackEventListener
// event - Track event added
// pUserData - Data to accompany reason
virtual void OnTrackEvent(IAnimSequence* sequence, int reason, const char* event, void* pUserData) = 0;
virtual void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{};
// </interfuscator:shuffle>
};
@@ -1152,8 +1146,6 @@ struct IMovieListener
//! callback on movie events
virtual void OnMovieEvent(EMovieEvent movieEvent, IAnimSequence* pAnimSequence) = 0;
// </interfuscator:shuffle>
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{}
};
/** Movie System interface.
@@ -1326,7 +1318,6 @@ struct IMovieSystem
virtual bool IsRecording() const = 0;
virtual void EnableCameraShake(bool bEnabled) = 0;
virtual bool IsCameraShakeEnabled() const = 0;
// Pause any playing sequences.
virtual void Pause() = 0;
@@ -1381,8 +1372,6 @@ struct IMovieSystem
virtual void EnableBatchRenderMode(bool bOn) = 0;
virtual bool IsInBatchRenderMode() const = 0;
virtual ILightAnimWrapper* CreateLightAnimWrapper(const char* name) const = 0;
virtual void LoadParamTypeFromXml(CAnimParamType& animParamType, const XmlNodeRef& xmlNode, const uint version) = 0;
virtual void SaveParamTypeToXml(const CAnimParamType& animParamType, XmlNodeRef& xmlNode) = 0;
@@ -1408,40 +1397,6 @@ struct IMovieSystem
// </interfuscator:shuffle>
};
inline void SAnimContext::Serialize(XmlNodeRef& xmlNode, bool bLoading)
{
if (bLoading)
{
XmlString name;
if (xmlNode->getAttr("sequence", name))
{
sequence = gEnv->pMovieSystem->FindLegacySequenceByName(name.c_str());
}
xmlNode->getAttr("dt", dt);
xmlNode->getAttr("fps", fps);
xmlNode->getAttr("time", time);
xmlNode->getAttr("bSingleFrame", singleFrame);
xmlNode->getAttr("bResetting", resetting);
xmlNode->getAttr("trackMask", trackMask);
xmlNode->getAttr("startTime", startTime);
}
else
{
if (sequence)
{
AZStd::string fullname = sequence->GetName();
xmlNode->setAttr("sequence", fullname.c_str());
}
xmlNode->setAttr("dt", dt);
xmlNode->setAttr("fps", fps);
xmlNode->setAttr("time", time);
xmlNode->setAttr("bSingleFrame", singleFrame);
xmlNode->setAttr("bResetting", resetting);
xmlNode->setAttr("trackMask", trackMask);
xmlNode->setAttr("startTime", startTime);
}
}
inline void CAnimParamType::SaveToXml(XmlNodeRef& xmlNode) const
{
gEnv->pMovieSystem->SaveParamTypeToXml(*this, xmlNode);
@@ -1456,5 +1411,3 @@ inline void CAnimParamType::Serialize(XmlNodeRef& xmlNode, bool bLoading, const
{
gEnv->pMovieSystem->SerializeParamType(*this, xmlNode, bLoading, version);
}
#endif // CRYINCLUDE_CRYCOMMON_IMOVIESYSTEM_H
+1
View File
@@ -23,6 +23,7 @@ struct IAIPathAgent;
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <limits>
#include <list>
// Hacks to deal with windows header inclusion.
#ifdef GetObject
-105
View File
@@ -1,105 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Moved Craig's ReadWriteXMLSink from CryAction to CrySystem
#ifndef CRYINCLUDE_CRYCOMMON_IREADWRITEXMLSINK_H
#define CRYINCLUDE_CRYCOMMON_IREADWRITEXMLSINK_H
#pragma once
#include <IXml.h>
#include <AzCore/std/containers/variant.h>
struct IReadXMLSink;
struct IWriteXMLSource;
struct IReadWriteXMLSink
{
// <interfuscator:shuffle>
virtual ~IReadWriteXMLSink(){}
virtual bool ReadXML(const char* definitionFile, const char* dataFile, IReadXMLSink* pSink) = 0;
virtual bool ReadXML(const char* definitionFile, XmlNodeRef node, IReadXMLSink* pSink) = 0;
virtual bool ReadXML(XmlNodeRef definition, const char* dataFile, IReadXMLSink* pSink) = 0;
virtual bool ReadXML(XmlNodeRef definition, XmlNodeRef node, IReadXMLSink* pSink) = 0;
virtual XmlNodeRef CreateXMLFromSource(const char* definitionFile, IWriteXMLSource* pSource) = 0;
virtual bool WriteXML(const char* definitionFile, const char* dataFile, IWriteXMLSource* pSource) = 0;
// </interfuscator:shuffle>
};
struct SReadWriteXMLCommon
{
typedef AZStd::variant<Vec3, int, float, const char*, bool> TValue;
};
TYPEDEF_AUTOPTR(IReadXMLSink);
typedef IReadXMLSink_AutoPtr IReadXMLSinkPtr;
// this interface allows customization of the data read routines
struct IReadXMLSink
: public SReadWriteXMLCommon
{
// <interfuscator:shuffle>
virtual ~IReadXMLSink(){}
// reference counting
virtual void AddRef() = 0;
virtual void Release() = 0;
virtual IReadXMLSinkPtr BeginTable(const char* name, const XmlNodeRef& definition) = 0;
virtual IReadXMLSinkPtr BeginTableAt(int elem, const XmlNodeRef& definition) = 0;
virtual bool SetValue(const char* name, const TValue& value, const XmlNodeRef& definition) = 0;
virtual bool EndTableAt(int elem) = 0;
virtual bool EndTable(const char* name) = 0;
virtual IReadXMLSinkPtr BeginArray(const char* name, const XmlNodeRef& definition) = 0;
virtual bool SetAt(int elem, const TValue& value, const XmlNodeRef& definition) = 0;
virtual bool EndArray(const char* name) = 0;
virtual bool Complete() = 0;
virtual bool IsCreationMode() = 0;
virtual XmlNodeRef GetCreationNode() = 0;
virtual void SetCreationNode(XmlNodeRef definition) = 0;
// </interfuscator:shuffle>
};
TYPEDEF_AUTOPTR(IWriteXMLSource);
typedef IWriteXMLSource_AutoPtr IWriteXMLSourcePtr;
// this interface allows customization of the data write routines
struct IWriteXMLSource
: public SReadWriteXMLCommon
{
// <interfuscator:shuffle>
virtual ~IWriteXMLSource(){}
// reference counting
virtual void AddRef() = 0;
virtual void Release() = 0;
virtual IWriteXMLSourcePtr BeginTable(const char* name) = 0;
virtual IWriteXMLSourcePtr BeginTableAt(int elem) = 0;
virtual bool HaveValue(const char* name) = 0;
virtual bool GetValue(const char* name, TValue& value, const XmlNodeRef& definition) = 0;
virtual bool EndTableAt(int elem) = 0;
virtual bool EndTable(const char* name) = 0;
virtual IWriteXMLSourcePtr BeginArray(const char* name, size_t* numElems, const XmlNodeRef& definition) = 0;
virtual bool HaveElemAt(int elem) = 0;
virtual bool GetAt(int elem, TValue& value, const XmlNodeRef& definition) = 0;
virtual bool EndArray(const char* name) = 0;
virtual bool Complete() = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_IREADWRITEXMLSINK_H
+1 -251
View File
@@ -455,7 +455,7 @@ enum EAuxGeomPublicRenderflags_DepthWrite
// EAuxGeomPublicRenderflagBitMasks
enum EAuxGeomPublicRenderflags_DepthTest
{
e_DepthTestOn = 0x0 << e_DepthTestShift,
e_DepthTestOn = 0x0 << e_DepthTestShift,
e_DepthTestOff = 0x1 << e_DepthTestShift,
};
@@ -465,10 +465,6 @@ enum EAuxGeomPublicRenderflags_Defaults
// Default render flags for 3d primitives.
e_Def3DPublicRenderflags = e_Mode3D | e_AlphaNone | e_DrawInFrontOff | e_FillModeSolid |
e_CullModeBack | e_DepthWriteOn | e_DepthTestOn,
// Default render flags for 2d primitives.
e_Def2DPublicRenderflags = e_Mode2D | e_AlphaNone | e_DrawInFrontOff | e_FillModeSolid |
e_CullModeBack | e_DepthWriteOn | e_DepthTestOn
};
@@ -487,48 +483,15 @@ struct SAuxGeomRenderFlags
bool operator !=(const SAuxGeomRenderFlags& rhs) const;
bool operator !=(uint32 rhs) const;
// Summary:
// Gets the flags for 2D/3D rendering mode.
EAuxGeomPublicRenderflags_Mode2D3D GetMode2D3DFlag() const;
// Summary:
// Sets the flags for 2D/3D rendering mode.
void SetMode2D3DFlag(const EAuxGeomPublicRenderflags_Mode2D3D& state);
// Summary:
// Gets the flags for alpha blend mode.
EAuxGeomPublicRenderflags_AlphaBlendMode GetAlphaBlendMode() const;
// Summary:
// Sets the flags for the alpha blend mode.
void SetAlphaBlendMode(const EAuxGeomPublicRenderflags_AlphaBlendMode& state);
EAuxGeomPublicRenderflags_DrawInFrontMode GetDrawInFrontMode() const;
void SetDrawInFrontMode(const EAuxGeomPublicRenderflags_DrawInFrontMode& state);
// Summary:
// Gets the flags for the filling mode.
EAuxGeomPublicRenderflags_FillMode GetFillMode() const;
// Summary:
// Sets the flags for the filling mode.
void SetFillMode(const EAuxGeomPublicRenderflags_FillMode& state);
// Summary:
// Gets the flags for the culling mode.
EAuxGeomPublicRenderflags_CullMode GetCullMode() const;
// Summary:
// Sets the flags for the culling mode.
void SetCullMode(const EAuxGeomPublicRenderflags_CullMode& state);
EAuxGeomPublicRenderflags_DepthWrite GetDepthWriteFlag() const;
void SetDepthWriteFlag(const EAuxGeomPublicRenderflags_DepthWrite& state);
// Summary:
// Gets the flags for the depth test.
EAuxGeomPublicRenderflags_DepthTest GetDepthTestFlag() const;
// Summary:
// Sets the flags for the depth test.
void SetDepthTestFlag(const EAuxGeomPublicRenderflags_DepthTest& state);
};
@@ -596,86 +559,6 @@ SAuxGeomRenderFlags::operator !=(uint32 rhs) const
}
inline EAuxGeomPublicRenderflags_Mode2D3D
SAuxGeomRenderFlags::GetMode2D3DFlag() const
{
int mode2D3D((int)(m_renderFlags & (uint32)e_Mode2D3DMask));
switch (mode2D3D)
{
case e_Mode2D:
{
return(e_Mode2D);
}
case e_Mode3D:
default:
{
assert(e_Mode3D == mode2D3D);
return(e_Mode3D);
}
}
}
inline void
SAuxGeomRenderFlags::SetMode2D3DFlag(const EAuxGeomPublicRenderflags_Mode2D3D& state)
{
m_renderFlags &= ~e_Mode2D3DMask;
m_renderFlags |= state;
}
inline EAuxGeomPublicRenderflags_AlphaBlendMode
SAuxGeomRenderFlags::GetAlphaBlendMode() const
{
uint32 alphaBlendMode(m_renderFlags & e_AlphaBlendingMask);
switch (alphaBlendMode)
{
case e_AlphaAdditive:
{
return(e_AlphaAdditive);
}
case e_AlphaBlended:
{
return(e_AlphaBlended);
}
case e_AlphaNone:
default:
{
assert(e_AlphaNone == alphaBlendMode);
return(e_AlphaNone);
}
}
}
inline void
SAuxGeomRenderFlags::SetAlphaBlendMode(const EAuxGeomPublicRenderflags_AlphaBlendMode& state)
{
m_renderFlags &= ~e_AlphaBlendingMask;
m_renderFlags |= state;
}
inline EAuxGeomPublicRenderflags_DrawInFrontMode
SAuxGeomRenderFlags::GetDrawInFrontMode() const
{
uint32 drawInFrontMode(m_renderFlags & e_DrawInFrontMask);
switch (drawInFrontMode)
{
case e_DrawInFrontOff:
{
return(e_DrawInFrontOff);
}
case e_DrawInFrontOn:
default:
{
assert(e_DrawInFrontOn == drawInFrontMode);
return(e_DrawInFrontOn);
}
}
}
inline void
SAuxGeomRenderFlags::SetDrawInFrontMode(const EAuxGeomPublicRenderflags_DrawInFrontMode& state)
{
@@ -683,31 +566,6 @@ SAuxGeomRenderFlags::SetDrawInFrontMode(const EAuxGeomPublicRenderflags_DrawInFr
m_renderFlags |= state;
}
inline EAuxGeomPublicRenderflags_FillMode
SAuxGeomRenderFlags::GetFillMode() const
{
uint32 fillMode(m_renderFlags & e_FillModeMask);
switch (fillMode)
{
case e_FillModePoint:
{
return(e_FillModePoint);
}
case e_FillModeWireframe:
{
return(e_FillModeWireframe);
}
case e_FillModeSolid:
default:
{
assert(e_FillModeSolid == fillMode);
return(e_FillModeSolid);
}
}
}
inline void
SAuxGeomRenderFlags::SetFillMode(const EAuxGeomPublicRenderflags_FillMode& state)
{
@@ -715,117 +573,9 @@ SAuxGeomRenderFlags::SetFillMode(const EAuxGeomPublicRenderflags_FillMode& state
m_renderFlags |= state;
}
inline EAuxGeomPublicRenderflags_CullMode
SAuxGeomRenderFlags::GetCullMode() const
{
uint32 cullMode(m_renderFlags & e_CullModeMask);
switch (cullMode)
{
case e_CullModeNone:
{
return(e_CullModeNone);
}
case e_CullModeFront:
{
return(e_CullModeFront);
}
case e_CullModeBack:
default:
{
assert(e_CullModeBack == cullMode);
return(e_CullModeBack);
}
}
}
inline void
SAuxGeomRenderFlags::SetCullMode(const EAuxGeomPublicRenderflags_CullMode& state)
{
m_renderFlags &= ~e_CullModeMask;
m_renderFlags |= state;
}
inline EAuxGeomPublicRenderflags_DepthWrite
SAuxGeomRenderFlags::GetDepthWriteFlag() const
{
uint32 depthWriteFlag(m_renderFlags & e_DepthWriteMask);
switch (depthWriteFlag)
{
case e_DepthWriteOff:
{
return(e_DepthWriteOff);
}
case e_DepthWriteOn:
default:
{
assert(e_DepthWriteOn == depthWriteFlag);
return(e_DepthWriteOn);
}
}
}
inline void
SAuxGeomRenderFlags::SetDepthWriteFlag(const EAuxGeomPublicRenderflags_DepthWrite& state)
{
m_renderFlags &= ~e_DepthWriteMask;
m_renderFlags |= state;
}
inline EAuxGeomPublicRenderflags_DepthTest
SAuxGeomRenderFlags::GetDepthTestFlag() const
{
uint32 depthTestFlag(m_renderFlags & e_DepthTestMask);
switch (depthTestFlag)
{
case e_DepthTestOff:
{
return(e_DepthTestOff);
}
case e_DepthTestOn:
default:
{
assert(e_DepthTestOn == depthTestFlag);
return(e_DepthTestOn);
}
}
}
inline void
SAuxGeomRenderFlags::SetDepthTestFlag(const EAuxGeomPublicRenderflags_DepthTest& state)
{
m_renderFlags &= ~e_DepthTestMask;
m_renderFlags |= state;
}
class CRenderAuxGeomRenderFlagsRestore
{
public:
explicit CRenderAuxGeomRenderFlagsRestore(IRenderAuxGeom* pRender);
~CRenderAuxGeomRenderFlagsRestore();
private:
IRenderAuxGeom* m_pRender;
SAuxGeomRenderFlags m_backuppedRenderFlags;
// copy-construction not supported
CRenderAuxGeomRenderFlagsRestore(const CRenderAuxGeomRenderFlagsRestore&);
CRenderAuxGeomRenderFlagsRestore& operator=(const CRenderAuxGeomRenderFlagsRestore&);
};
inline CRenderAuxGeomRenderFlagsRestore::CRenderAuxGeomRenderFlagsRestore(IRenderAuxGeom* pRender)
{
m_pRender = pRender;
m_backuppedRenderFlags = m_pRender->GetRenderFlags();
}
inline CRenderAuxGeomRenderFlagsRestore::~CRenderAuxGeomRenderFlagsRestore()
{
m_pRender->SetRenderFlags(m_backuppedRenderFlags);
}
-29
View File
@@ -193,32 +193,3 @@ struct DynUiPrimitive : public AZStd::intrusive_slist_node<DynUiPrimitive>
int m_numIndices = 0;
};
using DynUiPrimitiveList = AZStd::intrusive_slist<DynUiPrimitive, AZStd::slist_base_hook<DynUiPrimitive>>;
class CLodValue
{
public:
CLodValue() = default;
CLodValue(int nLodA)
{
m_nLodA = aznumeric_caster(nLodA);
}
CLodValue(int nLodA, uint8 nDissolveRef, int nLodB)
{
m_nLodA = aznumeric_caster(nLodA);
m_nLodB = aznumeric_caster(nLodB);
m_nDissolveRef = nDissolveRef;
}
int LodA() const { return m_nLodA; }
int LodB() const { return m_nLodB; }
uint8 DissolveRefA() const { return m_nDissolveRef; }
uint8 DissolveRefB() const { return 255 - m_nDissolveRef; }
private:
int16 m_nLodA = -1;
int16 m_nLodB = -1;
uint8 m_nDissolveRef = 0;
};
+71 -734
View File
@@ -6,144 +6,24 @@
*
*/
// Description : main header file
#ifndef CRYINCLUDE_CRYCOMMON_ISERIALIZE_H
#define CRYINCLUDE_CRYCOMMON_ISERIALIZE_H
#pragma once
#include <AzCore/Math/Vector3.h>
#include <Cry_Math.h>
#include <IXml.h>
#include "MiniQueue.h"
#include <VectorMap.h>
#include <StlUtils.h>
#include <AzCore/Math/Vector3.h>
#include <list>
// Forward declarations
class CTimeValue;
// Forward template declaration
template<class T, class U>
class InterpolatedValue_tpl;
// Unfortunately this needs to be here - should be in CryNetwork somewhere.
struct SNetObjectID
{
static const uint16 InvalidId = std::numeric_limits<uint16>::max();
SNetObjectID()
: id(InvalidId)
, salt(0) {}
SNetObjectID(uint16 i, uint16 s)
: id(i)
, salt(s) {}
uint16 id;
uint16 salt;
ILINE bool operator!() const
{
return id == InvalidId;
}
typedef uint16 (SNetObjectID::* unknown_bool_type);
ILINE operator unknown_bool_type() const
{
return !!(*this) ? &SNetObjectID::id : NULL;
}
ILINE bool operator!=(const SNetObjectID& rhs) const
{
return !(*this == rhs);
}
ILINE bool operator==(const SNetObjectID& rhs) const
{
return id == rhs.id && salt == rhs.salt;
}
ILINE bool operator<(const SNetObjectID& rhs) const
{
return id < rhs.id || (id == rhs.id && salt < rhs.salt);
}
ILINE bool operator>(const SNetObjectID& rhs) const
{
return id > rhs.id || (id == rhs.id && salt > rhs.salt);
}
bool IsLegal() const
{
return salt != 0;
}
const char* GetText(char* tmpBuf = nullptr, size_t bufferSize = 0) const
{
static char singlebuf[64];
if (!tmpBuf)
{
tmpBuf = singlebuf;
bufferSize = sizeof(singlebuf);
}
if (id == InvalidId)
{
sprintf_s(tmpBuf, bufferSize, "<nil>");
}
else if (!salt)
{
sprintf_s(tmpBuf, bufferSize, "illegal:%d:%d", id, salt);
}
else
{
sprintf_s(tmpBuf, bufferSize, "%d:%d", id, salt);
}
return tmpBuf;
}
uint32 GetAsUint32() const
{
return (uint32(salt) << 16) | id;
}
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const { /*nothing*/}
};
// this enumeration details what "kind" of serialization we are
// performing, so that classes that want to, for instance, tailor
// the data they present depending on where data is being written
// to can do so
enum ESerializationTarget
enum class ESerializationTarget
{
eST_SaveGame,
eST_Network,
eST_Script
};
// this inner class defines an interface so that OnUpdate
// functions can be passed abstractly through to concrete
// serialization classes
struct ISerializeUpdateFunction
{
// <interfuscator:shuffle>
virtual ~ISerializeUpdateFunction(){}
virtual void Execute() = 0;
// </interfuscator:shuffle>
};
// concrete implementation of IUpdateFunction for a general functor class
template <class F_Update>
class CSerializeUpdateFunction
: public ISerializeUpdateFunction
{
public:
CSerializeUpdateFunction(F_Update& update)
: m_rUpdate(update) {}
virtual void Execute()
{
m_rUpdate();
}
private:
F_Update m_rUpdate;
};
//////////////////////////////////////////////////////////////////////////
@@ -151,34 +31,68 @@ private:
//////////////////////////////////////////////////////////////////////////
struct SSerializeString
{
SSerializeString() {};
SSerializeString(const SSerializeString& src) { m_str.assign(src.c_str()); };
SSerializeString(){};
SSerializeString(const SSerializeString& src)
{
m_str.assign(src.c_str());
};
explicit SSerializeString(const char* sbegin, const char* send)
: m_str(sbegin, send) {};
~SSerializeString() {}
: m_str(sbegin, send){};
~SSerializeString()
{
}
// Casting to const char*
SSerializeString(const char* s)
: m_str(s) { };
//operator const char* () const { return m_str; }
: m_str(s){};
SSerializeString& operator =(const SSerializeString& src) { m_str.assign(src.c_str()); return *this; }
SSerializeString& operator =(const char* src) { m_str.assign(src); return *this; }
SSerializeString& operator=(const SSerializeString& src)
{
m_str.assign(src.c_str());
return *this;
}
SSerializeString& operator=(const char* src)
{
m_str.assign(src);
return *this;
}
bool operator != (const SSerializeString& src) { return m_str != src.m_str; }
bool operator!=(const SSerializeString& src)
{
return m_str != src.m_str;
}
size_t size() const { return m_str.size(); }
size_t length() const { return m_str.length(); }
const char* c_str() const { return m_str.c_str(); };
bool empty() const { return m_str.empty(); }
void resize(int sz) { m_str.resize(sz); }
void reserve(int sz) { m_str.reserve(sz); }
size_t size() const
{
return m_str.size();
}
size_t length() const
{
return m_str.length();
}
const char* c_str() const
{
return m_str.c_str();
};
bool empty() const
{
return m_str.empty();
}
void resize(int sz)
{
m_str.resize(sz);
}
void reserve(int sz)
{
m_str.reserve(sz);
}
void set_string(const AZStd::string& s)
{
m_str.assign(s.begin(), s.size());
}
operator const AZStd::string() const {
operator const AZStd::string() const
{
return m_str;
}
@@ -195,21 +109,17 @@ struct ISerialize
{
static const int ENUM_POLICY_TAG = 0xe0000000;
ILINE ISerialize() {}
ISerialize()
{
}
// <interfuscator:shuffle>
virtual ~ISerialize(){}
virtual ~ISerialize()
{
}
// this is for string values -- they need special support
virtual void ReadStringValue(const char* name, SSerializeString& curValue, uint32 policy = 0) = 0;
virtual void WriteStringValue(const char* name, SSerializeString& buffer, uint32 policy = 0) = 0;
// this function should be implemented to call the passed in interface
// if we are reading, and to not call it if we are writing
virtual void Update(ISerializeUpdateFunction* pUpdate) = 0;
// for network updates: notify the network engine that this value was only partially read and we
// should re-request an update from the server soon
virtual void FlagPartialRead() = 0;
virtual void ReadStringValue(const char* name, SSerializeString& curValue) = 0;
virtual void WriteStringValue(const char* name, SSerializeString& buffer) = 0;
//////////////////////////////////////////////////////////////////////////
// these functions should be implemented to deal with groups
@@ -224,43 +134,18 @@ struct ISerialize
//////////////////////////////////////////////////////////////////////////
virtual bool IsReading() const = 0;
virtual bool ShouldCommitValues() const = 0;
virtual ESerializationTarget GetSerializationTarget() const = 0;
virtual bool Ok() const = 0;
// </interfuscator:shuffle>
// declare all primitive Value() implementations
#define SERIALIZATION_TYPE(T) \
virtual void Value(const char* name, T & x, uint32 policy) = 0;
virtual void Value(const char* name, T& x) = 0;
#include "SerializationTypes.h"
#undef SERIALIZATION_TYPE
// declare all primitive Value() implementations
#define SERIALIZATION_TYPE(T) \
virtual void ValueWithDefault(const char* name, T & x, const T&defaultValue) = 0;
#include "SerializationTypes.h"
SERIALIZATION_TYPE(SSerializeString)
#undef SERIALIZATION_TYPE
void Value([[maybe_unused]] const char* name, [[maybe_unused]] AZ::Vector3& x)
{
}
template <class B>
void Value(const char* name, B& x)
{
Value(name, x, 0);
}
template <class B>
void Value(const char* name, B& x, uint32 policy);
template <class B>
void ValueWithDefault(const char* name, B& x, const B& defaultValue);
};
// this class provides a wrapper so that ISerialize can be used much more
// easily; it is a template so that if we need to wrap a more specific
// ISerialize implementation we can do so easily
template <class TISerialize>
template<class TISerialize>
class CSerializeWrapper
{
public:
@@ -276,507 +161,42 @@ public:
// have been made to follow the trend.
// the value function allows us to declare that a value needs
// to be serialized/deserialized; we can pass a serialization policy
// in order to compress the value, and an update function to allow
// us to be informed of when this value is changed
template <typename T_Value>
ILINE void Value(const char* szName, T_Value& value, int policy)
{
m_pSerialize->Value(szName, value, policy);
}
// to be serialized/deserialized;
template <typename T_Value>
template<typename T_Value>
ILINE void Value(const char* szName, T_Value& value)
{
m_pSerialize->Value(szName, value);
}
void Value(const char* szName, AZStd::string& value, int policy)
void Value(const char* szName, AZStd::string& value)
{
if (IsWriting())
{
SSerializeString& serializeString = SetSharedSerializeString(value);
m_pSerialize->WriteStringValue(szName, serializeString, policy);
m_pSerialize->WriteStringValue(szName, serializeString);
}
else
{
if (GetSerializationTarget() != eST_Script)
{
value = "";
}
value = "";
SSerializeString& serializeString = SetSharedSerializeString(value);
m_pSerialize->ReadStringValue(szName, serializeString, policy);
m_pSerialize->ReadStringValue(szName, serializeString);
value = serializeString.c_str();
}
}
ILINE void Value(const char* szName, AZStd::string& value)
{
Value(szName, value, 0);
}
void Value(const char* szName, const AZStd::string& value, int policy)
void Value(const char* szName, const AZStd::string& value)
{
if (IsWriting())
{
SSerializeString& serializeString = SetSharedSerializeString(value);
m_pSerialize->WriteStringValue(szName, serializeString, policy);
m_pSerialize->WriteStringValue(szName, serializeString);
}
else
{
assert(0 && "This function can only be used for Writing");
}
}
ILINE void Value(const char* szName, const AZStd::string& value)
{
Value(szName, value, 0);
}
template <class T_Class, typename T_Value>
void Value(const char* szName, T_Class* pInst, T_Value (T_Class::* get)() const, void (T_Class::* set)(T_Value))
{
if (IsWriting())
{
T_Value temp = (pInst->*get)();
Value(szName, temp);
}
else
{
T_Value temp;
Value(szName, temp);
(pInst->*set)(temp);
}
}
template<class T, class TT>
void Value(const char* name, InterpolatedValue_tpl<T, TT>& val)
{
if (IsWriting())
{
T a = val.Get();
Value(name, a);
}
if (IsReading())
{
T a;
Value(name, a);
val.SetGoal(a);
}
}
template<class T, class TT>
void Value(const char* name, InterpolatedValue_tpl<T, TT>& val, int policy)
{
if (IsWriting())
{
T a = val.Get();
Value(name, a, policy);
}
if (IsReading())
{
T a;
Value(name, a, policy);
val.SetGoal(a);
}
}
bool ValueChar(const char* name, char* buffer, int len)
{
AZStd::string temp;
if (IsReading())
{
Value(name, temp);
if ((int)temp.length() > len - 1)
{
return false; // truncated read
}
memcpy(buffer, temp.data(), temp.length() + 1);
buffer[len - 1] = 0;
}
else
{
temp = AZStd::string(buffer, buffer + len);
Value(name, temp);
}
return true;
}
template <typename T>
void ValueWithDefault(const char* name, T& x, const T& defaultValue)
{
m_pSerialize->ValueWithDefault(name, x, defaultValue);
}
void ValueWithDefault(const char* szName, AZStd::string& value, const AZStd::string& defaultValue)
{
static SSerializeString defaultSerializeString;
{
defaultSerializeString.set_string(defaultValue);
}
SSerializeString& serializeString = SetSharedSerializeString(value);
m_pSerialize->ValueWithDefault(szName, serializeString, defaultSerializeString);
if (IsReading())
{
value = serializeString.c_str();
}
}
template <class T_Class, typename T_Value, class T_SerializationPolicy>
void Value(const char* szName, T_Class* pInst, T_Value (T_Class::* get)() const, void (T_Class::* set)(T_Value),
const T_SerializationPolicy& policy)
{
if (IsWriting())
{
T_Value temp = (pInst->*get)();
Value(szName, temp, policy);
}
else
{
T_Value temp = static_cast<T_Value>(0);
Value(szName, temp, policy);
(pInst->*set)(temp);
}
}
// a value that is written by referring to a map of key/value pairs - we receive the key, and write the value
template <class T_Key, class T_Map>
void MappedValue(const char* szName, T_Key& value, const T_Map& mapper)
{
typedef typename T_Map::ValueType T_Value;
if (IsWriting())
{
T_Value write = mapper.KeyToValue(value);
Value(szName, write);
}
else
{
T_Value read;
Value(szName, read);
value = mapper.ValueToKey(read);
}
}
#define CONTAINER_VALUE(container_type, insert_function) \
template <typename T_Value, class Allocator> \
void Value(const char* name, container_type<T_Value, Allocator>&cont) \
{ \
if (!BeginOptionalGroup(name, true)) {return; } \
if (IsWriting()) \
{ \
uint32 count = cont.size(); \
Value("Size", count); \
for (typename container_type<T_Value, Allocator>::iterator iter = cont.begin(); iter != cont.end(); ++iter) \
{ \
BeginGroup("i"); \
T_Value value = *iter; \
Value("v", value); \
EndGroup(); \
} \
} \
else \
{ \
cont.clear(); \
uint32 count = 0; \
Value("Size", count); \
while (count--) \
{ \
BeginGroup("i"); \
T_Value temp; \
Value("v", temp); \
cont.insert_function(temp); \
EndGroup(); \
} \
} \
EndGroup(); \
} \
template <typename T_Value, class T_Map> \
void MappedValue(const char* name, container_type<T_Value>&cont, const T_Map&mapper) \
{ \
if (!BeginOptionalGroup(name, true)) {return; } \
if (IsWriting()) \
{ \
uint32 count = cont.size(); \
Value("Size", count); \
for (typename container_type<T_Value>::iterator iter = cont.begin(); iter != cont.end(); ++iter) \
{ \
BeginGroup("i"); \
MappedValue("v", *iter, mapper); \
EndGroup(); \
} \
} \
else \
{ \
cont.clear(); \
uint32 count = 0; \
Value("Size", count); \
while (count--) \
{ \
BeginGroup("i"); \
T_Value temp; \
MappedValue("v", temp, mapper); \
cont.insert_function(temp); \
EndGroup(); \
} \
} \
EndGroup(); \
}
#define PAIR_CONTAINER_VALUE(container_type, insert_function) \
template <typename T_Value1, typename T_Value2, class Allocator> \
void Value(const char* name, container_type<std::pair<T_Value1, T_Value2>, Allocator>&cont) \
{ \
if (!BeginOptionalGroup(name, true)) {return; } \
if (IsWriting()) \
{ \
uint32 count = cont.size(); \
Value("Size", count); \
for (typename container_type<std::pair<T_Value1, T_Value2>, Allocator>::iterator iter = cont.begin(); iter != cont.end(); ++iter) \
{ \
BeginGroup("i"); \
T_Value1 value1 = iter->first; \
T_Value2 value2 = iter->second; \
Value("v1", value1); \
Value("v2", value2); \
EndGroup(); \
} \
} \
else \
{ \
cont.clear(); \
uint32 count = 0; \
Value("Size", count); \
while (count--) \
{ \
BeginGroup("i"); \
T_Value1 temp1; \
T_Value2 temp2; \
Value("v1", temp1); \
Value("v2", temp2); \
cont.insert_function(std::pair<T_Value1, T_Value2>(temp1, temp2)); \
EndGroup(); \
} \
} \
EndGroup(); \
} \
CONTAINER_VALUE(std::vector, push_back);
CONTAINER_VALUE(std::list, push_back);
CONTAINER_VALUE(std::set, insert);
CONTAINER_VALUE(std::deque, push_back);
PAIR_CONTAINER_VALUE(std::list, push_back);
PAIR_CONTAINER_VALUE(std::vector, push_back);
template <typename T_Value>
void DummyValues(uint32 numDummyValues)
{
T_Value dummyValue;
for (uint32 i = 0; i < numDummyValues; ++i)
{
Value("Value", dummyValue);
}
}
template <typename T_Value, uint8 N>
void Value(const char* name, MiniQueue<T_Value, N>& cont)
{
if (!BeginOptionalGroup(name, true))
{
return;
}
if (IsWriting())
{
uint32 count = cont.Size();
Value("Size", count);
for (typename MiniQueue<T_Value, N>::SIterator iter = cont.Begin(); iter != cont.End(); ++iter)
{
T_Value value = *iter;
Value("Value", value);
}
}
else
{
cont.Clear();
uint32 count = 0;
Value("Size", count);
while (count--)
{
T_Value temp;
Value("Value", temp);
cont.Push(temp);
}
}
DummyValues<T_Value>(cont.Capacity() - cont.Size());
EndGroup();
}
template <typename T_Value, uint8 N, class T_Map>
void MappedValue(const char* name, MiniQueue<T_Value, N>& cont, const T_Map& mapper)
{
if (!BeginOptionalGroup(name, true))
{
return;
}
if (IsWriting())
{
uint8 count = cont.Size();
Value("Size", count);
for (typename MiniQueue<T_Value, N>::SIterator iter = cont.Begin(); iter != cont.End(); ++iter)
{
BeginGroup("i");
MappedValue("Value", *iter, mapper);
EndGroup();
}
}
else
{
cont.Clear();
uint8 count = 0;
Value("Size", count);
while (count--)
{
BeginGroup("i");
T_Value temp;
MappedValue("Value", temp, mapper);
cont.Push(temp);
EndGroup();
}
}
EndGroup();
}
#define MAP_CONTAINER_VALUE(container_type) \
template <typename T_Key, typename T_Value> \
void Value(const char* name, container_type<T_Key, T_Value>&cont) \
{ \
if (!BeginOptionalGroup(name, true)) {return; } \
if (IsWriting()) \
{ \
uint32 count = (uint32)cont.size(); \
Value("Size", count); \
for (typename container_type<T_Key, T_Value>::iterator iter = cont.begin(); iter != cont.end(); ++iter) \
{ \
T_Key tempKey = iter->first; \
BeginGroup("pair"); \
Value("k", tempKey); \
Value("v", iter->second); \
EndGroup(); \
} \
} \
else \
{ \
cont.clear(); \
uint32 count; \
Value("Size", count); \
while (count--) \
{ \
std::pair<T_Key, T_Value> temp; \
BeginGroup("pair"); \
Value("k", temp.first); \
Value("v", temp.second); \
EndGroup(); \
cont.insert(temp); \
} \
} \
EndGroup(); \
}
#define HASH_CONTAINER_VALUE(container_type) \
template <typename T_Key, typename T_Value, typename T_Hash> \
void Value(const char* name, container_type<T_Key, T_Value, T_Hash>&cont) \
{ \
if (!BeginOptionalGroup(name, true)) {return; } \
if (IsWriting()) \
{ \
uint32 count = (uint32)cont.size(); \
Value("Size", count); \
for (typename container_type<T_Key, T_Value, T_Hash>::iterator iter = cont.begin(); iter != cont.end(); ++iter) \
{ \
T_Key tempKey = iter->first; \
BeginGroup("pair"); \
Value("k", tempKey); \
Value("v", iter->second); \
EndGroup(); \
} \
} \
else \
{ \
cont.clear(); \
uint32 count; \
Value("Size", count); \
while (count--) \
{ \
AZStd::pair<T_Key, T_Value> temp; \
BeginGroup("pair"); \
Value("k", temp.first); \
Value("v", temp.second); \
EndGroup(); \
cont.insert(temp); \
} \
} \
EndGroup(); \
}
MAP_CONTAINER_VALUE(std::map);
MAP_CONTAINER_VALUE(std::multimap);
MAP_CONTAINER_VALUE(VectorMap);
HASH_CONTAINER_VALUE(AZStd::unordered_map);
template <typename T_Value>
ILINE void EnumValue(const char* szName, T_Value& value,
T_Value first, T_Value last)
{
int32 nValue = int32(value) - first;
Value(szName, nValue, ISerialize::ENUM_POLICY_TAG | (last - first));
value = T_Value(nValue + first);
}
template <typename T_Value, class T_Class>
ILINE void EnumValue(const char* szName,
T_Class* pClass, T_Value (T_Class::* GetValue)() const, void (T_Class::* SetValue)(T_Value),
T_Value first, T_Value last)
{
bool w = IsWriting();
int nValue;
if (w)
{
nValue = int32((pClass->*GetValue)()) - first;
}
Value(szName, nValue, ISerialize::ENUM_POLICY_TAG | (last - first));
if (!w)
{
(pClass->*SetValue)(T_Value(nValue + first));
}
}
/*
// we can request that a functor be called whenever our values
// are being updated by calling this function
template <class F_Update>
ILINE void OnUpdate( F_Update& update )
{
CUpdateFunction<F_Update> func(update);
m_pSerialize->Update( &func );
}
template <class T>
ILINE void OnUpdate( T * pCls, void (T::*func)() )
{
class CFunc : public IUpdateFunction
{
public:
CFunc( T * pCls, void (T::*func)() ) : m_pCls(pCls), m_func(func) {}
virtual void Execute()
{
(m_pCls->*m_func)();
}
private:
T * m_pCls;
void (T::*m_func)();
};
CFunc ifunc( pCls, func );
m_pSerialize->Update( &ifunc );
}
*/
// groups help us find common data
ILINE void BeginGroup(const char* szName)
{
@@ -791,12 +211,6 @@ public:
m_pSerialize->EndGroup();
}
// fetch the serialization target
ILINE ESerializationTarget GetSerializationTarget() const
{
return m_pSerialize->GetSerializationTarget();
}
ILINE bool IsWriting() const
{
return !m_pSerialize->IsReading();
@@ -805,27 +219,12 @@ public:
{
return m_pSerialize->IsReading();
}
ILINE bool ShouldCommitValues() const
{
assert(m_pSerialize->IsReading());
return m_pSerialize->ShouldCommitValues();
}
ILINE bool Ok() const
{
return m_pSerialize->Ok();
}
friend ILINE TISerialize* GetImpl(CSerializeWrapper<TISerialize> ser)
{
return ser.m_pSerialize;
}
ILINE void FlagPartialRead()
{
m_pSerialize->FlagPartialRead();
}
operator CSerializeWrapper<ISerialize>()
{
return CSerializeWrapper<ISerialize>(m_pSerialize);
@@ -844,65 +243,3 @@ private:
// default serialize class to use!!
typedef CSerializeWrapper<ISerialize> TSerialize;
// simple struct to declare something serializable... useful for
// exposition
struct ISerializable
{
virtual ~ISerializable(){}
virtual void SerializeWith(TSerialize) = 0;
};
template <class B>
void ISerialize::Value(const char* name, B& x, uint32 policy)
{
if (!BeginOptionalGroup(name, true))
{
return;
}
TSerialize ser(this);
x.Serialize(ser);
EndGroup();
}
//
//template <>
//void ISerialize::Value(const char * name, AZ::Vector3& x, uint32 policy)
//{
//
//}
// Based off ValueWithDefault in SimpleSerialize.h
template <class B>
void ISerialize::ValueWithDefault(const char* name, B& x, const B& defaultValue)
{
if (BeginOptionalGroup(name, x != defaultValue))
{
TSerialize ser(this);
x.Serialize(ser);
EndGroup();
}
else if (IsReading())
{
x = defaultValue;
}
}
//////////////////////////////////////////////////////////////////////////
// Used to automatically Begin/End group in serialization stream
//////////////////////////////////////////////////////////////////////////
struct SSerializeScopedBeginGroup
{
SSerializeScopedBeginGroup(TSerialize& ser, const char* sGroupName)
{
m_pSer = &ser;
m_pSer->BeginGroup(sGroupName);
}
~SSerializeScopedBeginGroup()
{
m_pSer->EndGroup();
}
private:
TSerialize* m_pSer;
};
#endif // CRYINCLUDE_CRYCOMMON_ISERIALIZE_H
-5
View File
@@ -41,7 +41,6 @@ enum EEfResTextures : int // This needs a fixed size so the enum can be forward
enum EParamType
{
eType_UNKNOWN,
eType_BYTE,
eType_BOOL,
eType_SHORT,
eType_INT,
@@ -90,10 +89,6 @@ struct SShaderItem
IRenderShaderResources* m_pShaderResources;
int32 m_nTechnique;
uint32 m_nPreprocessFlags;
bool Update();
bool RefreshResourceConstants();
inline struct SShaderTechnique* GetTechnique() const;
};
struct IAnimNode;
+1 -3
View File
@@ -347,8 +347,6 @@ namespace spline
m_c[3] = T((2.0f * v0 - 2.0f * v1 + s0 + s1) * idt * idt * idt);
}
}
void GetMemoryUsage(ICrySizer* pSizer) const {}
};
inline float fast_fmod(float x, float y)
@@ -410,7 +408,7 @@ namespace spline
//! TCB spline key used in quaternion spline with angle axis as input.
struct TCBAngAxisKey
: public TCBSplineKey<CryQuat>
: public TCBSplineKey<Quat>
{
float angle;
Vec3 axis;
+9 -491
View File
@@ -5,43 +5,14 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "smartptr.h" // TYPEDEF_AUTOPTR
#include "IMaterial.h"
// forward declarations
//////////////////////////////////////////////////////////////////////
struct ShadowMapFrustum;
struct SRenderingPassInfo;
struct SRendItemSorter;
struct ITetrLattice;
struct SPhysGeomArray;
struct CStatObj;
class CRenderObject;
class CDLight;
class IReadStream;
class CLodValue;
TYPEDEF_AUTOPTR(IReadStream);
//! Interface to non animated object
struct phys_geometry;
struct IChunkFile;
// General forward declaration.
struct SMeshLodInfo;
#include "Cry_Color.h"
#include "Cry_Math.h"
#include "Cry_Geo.h"
#include "CrySizer.h"
#include "IMaterial.h"
#define MAX_STATOBJ_LODS_NUM 6
// General forward declaration.
struct SRenderingPassInfo;
//////////////////////////////////////////////////////////////////////////
// Type of static sub object.
@@ -50,184 +21,46 @@ enum EStaticSubObjectType
{
STATIC_SUB_OBJECT_MESH, // This simple geometry part of the multi-sub object geometry.
STATIC_SUB_OBJECT_HELPER_MESH, // Special helper mesh, not rendered usually, used for broken pieces.
STATIC_SUB_OBJECT_POINT,
STATIC_SUB_OBJECT_DUMMY,
STATIC_SUB_OBJECT_XREF,
STATIC_SUB_OBJECT_CAMERA,
STATIC_SUB_OBJECT_LIGHT,
};
//////////////////////////////////////////////////////////////////////////
// Flags that can be set on static object.
//////////////////////////////////////////////////////////////////////////
enum EStaticObjectFlags
{
STATIC_OBJECT_HIDDEN = BIT(0), // When set static object will not be displayed.
STATIC_OBJECT_CLONE = BIT(1), // specifies whether this object was cloned for modification
STATIC_OBJECT_GENERATED = BIT(2), // tells that the object was generated procedurally (breakable obj., f.i.)
STATIC_OBJECT_CANT_BREAK = BIT(3), // StatObj has geometry unsuitable for procedural breaking
STATIC_OBJECT_DEFORMABLE = BIT(4), // StatObj can be procedurally smeared (using SmearStatObj)
STATIC_OBJECT_COMPOUND = BIT(5), // StatObj has subobject meshes
STATIC_OBJECT_MULTIPLE_PARENTS = BIT(6), // Child StatObj referenced by several parents
// Collisions
STATIC_OBJECT_NO_PLAYER_COLLIDE = BIT(10),
// Special flags.
STATIC_OBJECT_SPAWN_ENTITY = BIT(20), // StatObj spawns entity when broken.
STATIC_OBJECT_NO_AUTO_HIDEPOINTS = BIT(22), // Do not generate AI auto hide points around object if it's dynamic
STATIC_OBJECT_DYNAMIC = BIT(23), // mesh data should be kept in system memory (and yes, the name *is* an oxymoron)
};
#define HIT_NO_HIT (-1)
#define HIT_UNKNOWN (-2)
#define HIT_OBJ_TYPE_BRUSH 0
#define HIT_OBJ_TYPE_TERRAIN 1
#define HIT_OBJ_TYPE_VISAREA 2
// used for on-CPU voxelization
struct SRayHitTriangle
{
SRayHitTriangle() { ZeroStruct(*this); }
Vec3 v[3];
Vec2 t[3];
ColorB c[3];
Vec3 n;
_smart_ptr<IMaterial> pMat;
uint8 nTriArea;
uint8 nOpacity;
uint8 nHitObjType;
};
struct SRayHitInfo
{
SRayHitInfo()
{
memset(this, 0, sizeof(*this));
nHitTriID = HIT_UNKNOWN;
}
//////////////////////////////////////////////////////////////////////////
// Input parameters.
Vec3 inReferencePoint;
Ray inRay;
bool bInFirstHit;
bool inRetTriangle;
bool bUseCache;
bool bOnlyZWrite;
bool bGetVertColorAndTC;
float fMaxHitDistance; // When not 0, only hits with closer distance will be registered.
Vec3 vTri0;
Vec3 vTri1;
Vec3 vTri2;
float fMinHitOpacity;
//////////////////////////////////////////////////////////////////////////
// Output parameters.
float fDistance; // Distance from reference point.
Vec3 vHitPos;
Vec3 vHitNormal;
int nHitMatID; // Material Id that was hit.
int nHitTriID; // Triangle Id that was hit.
int nHitSurfaceID; // Material Id that was hit.
struct IRenderMesh* pRenderMesh;
struct IStatObj* pStatObj;
Vec2 vHitTC;
Vec4 vHitColor;
Vec4 vHitTangent;
Vec4 vHitBitangent;
PodArray<SRayHitTriangle>* pHitTris;
};
enum EFileStreamingStatus
{
ecss_NotLoaded,
ecss_InProgress,
ecss_Ready
// More inputs
bool bInFirstHit;
bool bUseCache;
};
struct SMeshBoneMapping_uint8;
struct SSpine;
struct SMeshColor;
// Summary:
// Interface to hold static object data
struct IStatObj
{
//! Loading flags
enum ELoadingFlags
{
ELoadingFlagsPreviewMode = BIT(0),
ELoadingFlagsForceBreakable = BIT(1),
ELoadingFlagsIgnoreLoDs = BIT(2),
ELoadingFlagsTessellate = BIT(3), // if e_StatObjTessellation enabled
ELoadingFlagsJustGeometry = BIT(4), // for streaming, to avoid parsing all chunks
};
//////////////////////////////////////////////////////////////////////////
// SubObject
//////////////////////////////////////////////////////////////////////////
struct SSubObject
{
SSubObject() { bShadowProxy = 0; }
EStaticSubObjectType nType;
AZStd::string name;
AZStd::string properties;
int nParent; // Index of the parent sub object, if there`s hierarchy between them.
Matrix34 tm; // Transformation matrix.
Matrix34 localTM; // Local transformation matrix, relative to parent.
IStatObj* pStatObj; // Static object for sub part of CGF.
Vec3 helperSize; // Size of the helper (if helper).
struct IRenderMesh* pWeights; // render mesh with a single deformation weights stream
unsigned int bIdentityMatrix : 1; // True if sub object matrix is identity.
unsigned int bHidden : 1; // True if sub object is hidden
unsigned int bShadowProxy : 1; // Child StatObj has 'shadowproxy' in name
unsigned int nBreakerJoints : 8; // number of joints that can switch this part to a broken state
void GetMemoryUsage(ICrySizer* pSizer) const
{
pSizer->AddObject(name);
pSizer->AddObject(properties);
}
};
//////////////////////////////////////////////////////////////////////////
// <interfuscator:shuffle>
// Description:
// Increase the reference count of the object.
// Summary:
// Notifies that the object is being used
virtual int AddRef() = 0;
// Description:
// Decrease the reference count of the object. If the reference count
// reaches zero, the object will be deleted from memory.
// Summary:
// Notifies that the object is no longer needed
virtual int Release() = 0;
// Description:
// Set static object flags.
// Arguments:
// nFlags - flags to set, a combination of EStaticObjectFlags values.
virtual void SetFlags(int nFlags) = 0;
// Description:
// Retrieve flags set on the static object.
virtual int GetFlags() const = 0;
// Sets the default object indicator
virtual void SetDefaultObject(bool state) = 0;
// Description:
// Retrieves the internal flag m_nVehicleOnlyPhysics.
virtual unsigned int GetVehicleOnlyPhysics() = 0;
// Description:
// Retrieves the internal flag m_bBreakableByGame.
virtual unsigned int GetBreakableByGame() = 0;
virtual ~IStatObj() {}
// Description:
// Provide access to the faces, vertices, texture coordinates, normals and
// colors of the object used later for CRenderMesh construction.
@@ -237,86 +70,6 @@ struct IStatObj
// Get the object source geometry
virtual struct IIndexedMesh* GetIndexedMesh(bool bCreateIfNone = false) = 0;
// Description:
// Create an empty indexed mesh ready to be filled with data
// If an indexed mesh already exists it is returned
// Return Value:
// An empty indexed mesh or the existing indexed mesh
virtual struct IIndexedMesh* CreateIndexedMesh() = 0;
//! Access to rendering geometry for indoor engine ( optimized vert arrays, lists of shader pointers )
virtual struct IRenderMesh* GetRenderMesh() = 0;
// Description:
// Sets and replaces the physical representation of the object.
// Arguments:
// pPhysGeom - A pointer to a phys_geometry class.
// nType - Pass 0 to set the physic geometry or pass 1 to set the obstruct geometry
// Summary:
// Set the physic representation
virtual void SetPhysGeom(phys_geometry* pPhysGeom, int nType = 0) = 0;
virtual float GetAIVegetationRadius() const = 0;
virtual void SetAIVegetationRadius(float radius) = 0;
// Description:
// Set default material for the geometry.
// Arguments:
// pMaterial - A valid pointer to the material.
virtual void SetMaterial(_smart_ptr<IMaterial> pMaterial) = 0;
// Description:
// Returns default material of the geometry.
// Arguments:
// nType - Pass 0 to get the physic geometry or pass 1 to get the obstruct geometry
// Return Value:
// A pointer to a phys_geometry class.
virtual _smart_ptr<IMaterial> GetMaterial() = 0;
virtual const _smart_ptr<IMaterial> GetMaterial() const = 0;
// Return Value:
// A Vec3 object containing the bounding box.
// Summary:
// Get the minimal bounding box component
virtual Vec3 GetBoxMin() = 0;
// Return Value:
// A Vec3 object containing the bounding box.
// Summary:
// Get the minimal bounding box component
virtual Vec3 GetBoxMax() = 0;
// Arguments:
// Minimum bounding box component
// Summary:
// Set the minimum bounding box component
virtual void SetBBoxMax(const Vec3& vBBoxMax) = 0;
// Summary:
// Get the object radius
// Return Value:
// A float containing the radius
virtual float GetRadius() = 0;
// Description:
// Reloads one or more component of the object. The possible flags
// are FRO_SHADERS, FRO_TEXTURES and FRO_GEOMETRY.
// Arguments:
// nFlags - One or more flag which indicate which element of the object
// to reload
// Summary:
// Reloads the object
virtual void Refresh(int nFlags) = 0;
// Description:
// Registers the object elements into the renderer.
// Arguments:
// rParams - Render parameters
// nLogLevel - Level of the LOD
// Summary:
// Renders the object
virtual void Render(const struct SRendParams& rParams, const SRenderingPassInfo& passInfo) = 0;
// Summary:
// Get the bounding box
// Arguments:
@@ -324,13 +77,6 @@ struct IStatObj
// Maxs - Position of the top right far corner of the bounding box
virtual AABB GetAABB() = 0;
// Summary:
// Generate a random point in object.
// Arguments:
// eForm - Object aspect to generate on (surface, volume, etc)
virtual float GetExtent(EGeomForm eForm) = 0;
virtual void GetRandomPos(PosNorm& ran, EGeomForm eForm) const = 0;
// Description:
// Returns the LOD object, if present.
// Arguments:
@@ -341,64 +87,6 @@ struct IStatObj
// Summary:
// Get the LOD object
virtual IStatObj* GetLodObject(int nLodLevel, bool bReturnNearest = false) = 0;
virtual IStatObj* GetLowestLod() = 0;
virtual int FindNearesLoadedLOD(int nLodIn, bool bSearchUp = false) = 0;
virtual int FindHighestLOD(int nBias) = 0;
virtual AZStd::string& GetFileName() = 0;
virtual const AZStd::string& GetFileName() const = 0;
// Summary:
// Returns the filename of the object
// Return Value:
// A null terminated string which contain the filename of the object.
virtual const char* GetFilePath() const = 0;
// Summary:
// Set the filename of the object
// Arguments:
// szFileName - New filename of the object
// Return Value:
// None
virtual void SetFilePath(const char* szFileName) = 0;
// Description:
// Will return the position of the helper named in the argument. The
// helper should have been specified during the exporting process of
// the cgf file.
// Arguments:
// szHelperName - A null terminated string holding the name of the helper
// Return Value:
// A Vec3 object which contains the position.
// Summary:
// Gets the position of a specified helper
virtual Vec3 GetHelperPos(const char* szHelperName) = 0;
// Summary:
// Gets the transformation matrix of a specified helper, see GetHelperPos
virtual const Matrix34& GetHelperTM(const char* szHelperName) = 0;
//! Tell us if the object is not found
virtual bool IsDefaultObject() = 0;
// Summary:
// Free the geometry data
virtual void FreeIndexedMesh() = 0;
// Pushes the underlying tree of objects into the given Sizer object for statistics gathering
virtual void GetMemoryUsage(class ICrySizer* pSizer) const = 0;
//DOC-IGNORE-BEGIN
//! used for sprites
virtual float& GetRadiusVert() = 0;
//! used for sprites
virtual float& GetRadiusHors() = 0;
//DOC-IGNORE-END
// Summary:
// Determines if the object has physics capabilities
virtual bool IsPhysicsExist() = 0;
// Summary:
// Returns a pointer to the object
@@ -406,12 +94,6 @@ struct IStatObj
// A pointer to the current object, which is simply done like this "return this;"
virtual struct IStatObj* GetIStatObj() { return this; }
// Summary:
// Invalidates geometry inside IStatObj, will mark hosted IIndexedMesh as invalid.
// Arguments:
// bPhysics - if true will also recreate physics for indexed mesh.
virtual void Invalidate(bool bPhysics = false, float tolerance = 0.05f) = 0;
//////////////////////////////////////////////////////////////////////////
// Interface to the Sub Objects.
//////////////////////////////////////////////////////////////////////////
@@ -419,174 +101,10 @@ struct IStatObj
// Retrieve number of sub-objects.
virtual int GetSubObjectCount() const = 0;
// Summary:
// Sets number of sub-objects.
virtual void SetSubObjectCount(int nCount) = 0;
// Summary:
// Retrieve sub object by index, where 0 <= nIndex < GetSubObjectCount()
virtual IStatObj::SSubObject* GetSubObject(int nIndex) = 0;
// Summary:
// Check if this object is sub object of another IStatObj.
virtual bool IsSubObject() const = 0;
// Summary:
// Retrieve parent static object, only relevant when this IStatObj is Sub-object.
virtual IStatObj* GetParentObject() const = 0;
// Summary:
// Retrieve the static object, from which this one was cloned (if that is the case)
virtual IStatObj* GetCloneSourceObject() const = 0;
// Summary:
// Find sub-pbject by name.
virtual IStatObj::SSubObject* FindSubObject(const char* sNodeName) = 0;
// Find sub-object by name (including spaces, comma and semi-colon.
virtual IStatObj::SSubObject* FindSubObject_CGA(const char* sNodeName) = 0;
// Summary:
// Find object by full name (use all the characters)
virtual IStatObj::SSubObject* FindSubObject_StrStr(const char* sNodeName) = 0;
// Remove Sub-Object.
virtual bool RemoveSubObject(int nIndex) = 0;
// Copy Sub-Object.
virtual bool CopySubObject(int nToIndex, IStatObj* pFromObj, int nFromIndex) = 0;
// adds a new sub object
virtual IStatObj::SSubObject& AddSubObject(IStatObj* pStatObj) = 0;
virtual bool IsDeformable() = 0;
//////////////////////////////////////////////////////////////////////////
// Save contents of static object to the CGF file.
//////////////////////////////////////////////////////////////////////////
// Save object to the CGF file.
// Arguments:
// sFilename
// Filename of the CGF file.
// Note that the function fails if pOutChunkFile is NULL and the path
// to the file does not exist on the drive. You can call
// CFileUtil::CreatePath() before SaveToCGF() call to create all
// folders that do not exist yet.
// pOutChunkFile
// Optional output parameter. If it is specified then the file will not be written to
// the drive but instead the function returns a pointer to the IChunkFile interface with
// filled CGF chunks. Caller of the function is responsible to call Release method
// of IChunkFile to release it later.
virtual bool SaveToCGF(const char* sFilename, IChunkFile** pOutChunkFile = NULL, bool bHavePhysicalProxy = false) = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
// Clones static geometry, Makes an exact copy of the Static object and the contained geometry.
//virtual IStatObj* Clone(bool bCloneChildren=true, bool nDynamic=false) = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
// Clones static geometry, Makes an exact copy of the Static object and the contained geometry.
virtual IStatObj* Clone(bool bCloneGeometry, bool bCloneChildren, bool bMeshesOnly) = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
// makes sure that both objects have one-to-one vertex correspondance
// sets MorphBuddy for this object's render mesh
// returns 0 if failed (due to objects having no vertex maps most likely)
virtual int SetDeformationMorphTarget(IStatObj* pDeformed) = 0;
// chages the weights of the deformation morphing according to point, radius, and strength
// (radius==0 updates all weights of all vertices)
// if the object is a compound object, updates the weights of its subobjects that have deformation morphs; clones the object if necessary
// otherwise, updates the weights passed as a pWeights param
virtual IStatObj* DeformMorph(const Vec3& pt, float r, float strength, IRenderMesh* pWeights = 0) = 0;
// hides all non-physicalized geometry, clones the object if necessary
virtual IStatObj* HideFoliage() = 0;
// Get object properties as loaded from CGF.
virtual const char* GetProperties() = 0;
// Get physical properties specified for object.
virtual bool GetPhysicalProperties(float& mass, float& density) = 0;
// Returns the last B operand for this object as A, along with its relative scale
virtual IStatObj* GetLastBooleanOp(float& scale) = 0;
virtual SSubObject* GetSubObject(int nIndex) = 0;
// Intersect ray with static object.
// Ray must be in object local space.
virtual bool RayIntersection(SRayHitInfo& hitInfo, _smart_ptr<IMaterial> pCustomMtl = 0) = 0;
// Intersect lineseg with static object. Works on dedi server as well.
// Lineseg must be in object local space. Returns the hit position and the surface type id of the point hit.
virtual bool LineSegIntersection(const Lineseg& lineSeg, Vec3& hitPos, int& surfaceTypeId) = 0;
// Debug Draw this static object.
virtual void DebugDraw(const struct SGeometryDebugDrawInfo& info, float fExtrdueScale = 0.01f) = 0;
// Returns initial hide mask
virtual uint64 GetInitialHideMask() = 0;
// Updates hide mask as new mask = (mask & maskAND) | maskOR
virtual uint64 UpdateInitialHideMask(uint64 maskAND = 0ul - 1ul, uint64 maskOR = 0) = 0;
// Set the filename of the mesh of the next state (for example damaged version)
virtual void SetStreamingDependencyFilePath(const char* szFileName) = 0;
virtual void ComputeGeometricMean(SMeshLodInfo& lodInfo) = 0;
// Returns the distance for the first LOD switch. Used for brushes and vegetation.
virtual float GetLodDistance() const = 0;
// Returns true if the mesh has been stripped
virtual bool IsMeshStrippedCGF() const = 0;
virtual void LoadLowLODs(bool bUseStreaming, unsigned long nLoadingFlags) = 0;
// Indicates if lods have been loaded
virtual bool AreLodsLoaded() const = 0;
// Indicates if a garbage check should be done
virtual bool CheckGarbage() const = 0;
// Sets state of check garbage flags
virtual void SetCheckGarbage(bool val) = 0;
// Returns the number of child references
virtual int CountChildReferences() const = 0;
// Returns the user count
virtual int GetUserCount() const = 0;
// Shutdown
virtual void ShutDown() = 0;
virtual int GetMaxUsableLod() const = 0;
virtual int GetMinUsableLod() const = 0;
virtual SMeshBoneMapping_uint8* GetBoneMapping() const = 0;
virtual int GetSpineCount() const = 0;
virtual SSpine* GetSpines() const = 0;
virtual IStatObj* GetLodLevel0() = 0;
virtual void SetLodLevel0(IStatObj* lod) = 0;
virtual _smart_ptr<CStatObj>* GetLods() = 0;
virtual int GetLoadedLodsNum() = 0;
virtual bool UpdateStreamableComponents(float fImportance, const Matrix34A& objMatrix, bool bFullUpdate, int nNewLod) = 0;
virtual SPhysGeomArray& GetArrPhysGeomInfo() = 0;
virtual bool IsLodsAreLoadedFromSeparateFile() = 0;
virtual void StartStreaming(bool bFinishNow, IReadStream_AutoPtr* ppStream) = 0;
virtual void UpdateStreamingPrioriryInternal(const Matrix34A& objMatrix, float fDistance, bool bFullUpdate) = 0;
virtual void SetMerged(bool state) = 0;
virtual int GetRenderMeshMemoryUsage() const = 0;
virtual void SetLodObject(int nLod, IStatObj* pLod) = 0;
virtual int GetLoadedTrisCount() const = 0;
virtual int GetRenderTrisCount() const = 0;
virtual int GetRenderMatIds() const = 0;
virtual bool IsUnmergable() const = 0;
virtual void SetUnmergable(bool state) = 0;
virtual int GetSubObjectMeshCount() const = 0;
virtual void SetSubObjectMeshCount(int count) = 0;
virtual void CleanUnusedLods() = 0;
virtual AZStd::vector<SMeshColor>& GetClothData() = 0;
virtual bool RayIntersection(SRayHitInfo& hitInfo, IMaterial* pCustomMtl = nullptr) = 0;
};
-244
View File
@@ -1,244 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Defines interfaces to access Surface Types.
#ifndef CRYINCLUDE_CRYCOMMON_ISURFACETYPE_H
#define CRYINCLUDE_CRYCOMMON_ISURFACETYPE_H
#pragma once
//////////////////////////////////////////////////////////////////////////
// Flags that ISurfaceType::GetFlags() can return.
//////////////////////////////////////////////////////////////////////////
enum ESurfaceTypeFlags
{
SURFACE_TYPE_NO_PHYSICALIZE = BIT(1), // This surface should not be physicalized.
SURFACE_TYPE_NO_COLLIDE = BIT(2), // Should only be set for vegetation canopy mats
SURFACE_TYPE_VEHICLE_ONLY_COLLISION = BIT(3),
SURFACE_TYPE_CAN_SHATTER = BIT(4), // This surface type can shatter
SURFACE_TYPE_BULLET_PIERCEABLE = BIT(5), // This surface is pierceable by bullets (used by MFX system to spawn front/back FX)
};
// Parameter structure passed to ISurfaceType::Execute
struct SSurfaceTypeExecuteParams
{
Vec3 hitPoint;
Vec3 hitNormal;
int hitType;
};
#define SURFACE_BREAKAGE_TYPE(x) x
//////////////////////////////////////////////////////////////////////////
// Surface definition.
//////////////////////////////////////////////////////////////////////////
struct ISurfaceType
{
//////////////////////////////////////////////////////////////////////////
struct SSurfaceTypeAIParams
{
float fImpactRadius;
float fImpactSoundRadius;
float fFootStepRadius;
float proneMult;
float crouchMult;
float movingMult;
SSurfaceTypeAIParams()
{
fImpactRadius = 2.5f;
fImpactSoundRadius = 20.0f;
fFootStepRadius = 20.0f;
proneMult = 0.2f;
crouchMult = 0.5f;
movingMult = 2.5f;
}
};
struct SPhysicalParams
{
int breakable_id;
int break_energy;
float hole_size;
float hole_size_explosion;
float hit_radius;
float hit_points;
float hit_points_secondary;
float hit_maxdmg;
float hit_lifetime;
int pierceability;
float damage_reduction;
float ric_angle;
float ric_dam_reduction;
float ric_vel_reduction;
float friction;
float bouncyness;
int iBreakability;
int collType;
float sound_obstruction;
};
struct SBreakable2DParams
{
AZStd::string particle_effect;
float blast_radius;
float blast_radius_first;
float vert_size_spread;
int rigid_body;
float life_time;
float cell_size;
int max_patch_tris;
float filter_angle;
float shard_density;
int use_edge_alpha;
float crack_decal_scale;
AZStd::string crack_decal_mtl;
float max_fracture;
AZStd::string full_fracture_fx;
AZStd::string fracture_fx;
int no_procedural_full_fracture;
AZStd::string broken_mtl;
float destroy_timeout;
float destroy_timeout_spread;
SBreakable2DParams()
: blast_radius(0)
, rigid_body(0)
, life_time(0)
, cell_size(0)
, max_patch_tris(0)
, shard_density(0)
, crack_decal_scale(0)
, max_fracture(1.0f)
, vert_size_spread(0)
, filter_angle(0)
, use_edge_alpha(0)
, blast_radius_first(0)
, no_procedural_full_fracture(0)
, destroy_timeout(0)
, destroy_timeout_spread(0) {}
};
struct SBreakageParticles
{
AZStd::string type;
AZStd::string particle_effect;
int count_per_unit;
float count_scale;
float scale;
SBreakageParticles()
: count_per_unit(1)
, count_scale(1)
, scale(1) {}
};
// <interfuscator:shuffle>
virtual ~ISurfaceType(){}
// Releases surface type.
virtual void Release() = 0;
// Return unique Id of this surface type.
// Maximum of 65535 simultanious surface types can exist.
virtual uint16 GetId() const = 0;
// Unique name of the surface type.
virtual const char* GetName() const = 0;
// Typename of this surface type.
virtual const char* GetType() const = 0;
// Flags of the surface type.
// Return:
// A combination of ESurfaceTypeFlags flags.
virtual int GetFlags() const = 0;
// Execute material.
virtual void Execute(SSurfaceTypeExecuteParams& params) = 0;
// returns a some cached properties for faster access
virtual int GetBreakability() const = 0;
virtual float GetBreakEnergy() const = 0;
virtual int GetHitpoints() const = 0;
//////////////////////////////////////////////////////////////////////////
virtual const SPhysicalParams& GetPhyscalParams() = 0;
// Optional AI Params.
virtual const SSurfaceTypeAIParams* GetAIParams() = 0;
// Optional params for 2D breakable plane.
virtual SBreakable2DParams* GetBreakable2DParams() = 0;
virtual SBreakageParticles* GetBreakageParticles(const char* sType, bool bLookInDefault = true) = 0;
//////////////////////////////////////////////////////////////////////////
// Called by Surface manager.
//////////////////////////////////////////////////////////////////////////
// Loads surface, (do not use directly).
virtual bool Load(int nId) = 0;
// </interfuscator:shuffle>
};
//////////////////////////////////////////////////////////////////////////
// Description:
// This interface is used to enumerate all items registered to the surface type manager.
//////////////////////////////////////////////////////////////////////////
struct ISurfaceTypeEnumerator
{
// <interfuscator:shuffle>
virtual ~ISurfaceTypeEnumerator(){}
virtual void Release() = 0;
virtual ISurfaceType* GetFirst() = 0;
virtual ISurfaceType* GetNext() = 0;
// </interfuscator:shuffle>
};
// Description:
// Manages loading and mapping of physical surface materials to Ids and materials scripts.
// Behaviour:
// At start will enumerate all material names.
// When the surface is first time requested by name it will be loaded and cached
// and new unique id will be generated for it.
struct ISurfaceTypeManager
{
// <interfuscator:shuffle>
virtual ~ISurfaceTypeManager(){}
// Description:
// Load Surface types
virtual void LoadSurfaceTypes() = 0;
// Description:
// Return surface type by name.
// If surface is not yet loaded it will be loaded and and cached.
// Arguments:
// sName - Name of the surface type ("mat_metal","mat_wood", etc..)
// warn - print warning message if surface not found
virtual ISurfaceType* GetSurfaceTypeByName(const char* sName, const char* sWhy = NULL, bool warn = true) = 0;
// Description:
// Return surface type by id.
// If surface is not yet loaded it will be loaded and and cached.
// Arguments:
// sName - Name of the surface type ("mat_metal","mat_wood", etc..)
virtual ISurfaceType* GetSurfaceType(int nSurfaceId, const char* sWhy = NULL) = 0;
// Description:
// Retrieve an interface to the enumerator class that allow to iterate over all surface types.
virtual ISurfaceTypeEnumerator* GetEnumerator() = 0;
// Register a new surface type.
virtual bool RegisterSurfaceType(ISurfaceType* pSurfaceType, bool bDefault = false) = 0;
virtual void UnregisterSurfaceType(ISurfaceType* pSurfaceType) = 0;
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_ISURFACETYPE_H
+6 -36
View File
@@ -6,8 +6,6 @@
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_ISYSTEM_H
#define CRYINCLUDE_CRYCOMMON_ISYSTEM_H
#pragma once
#ifdef CRYSYSTEM_EXPORTS
@@ -15,10 +13,10 @@
#else
#define CRYSYSTEM_API DLL_IMPORT
#endif
#include <AzCore/IO/SystemFile.h>
#include "CryAssert.h"
#include <AzCore/IO/SystemFile.h>
#include <CryCommon/IValidator.h>
#if defined(AZ_RESTRICTED_PLATFORM)
#undef AZ_RESTRICTED_SECTION
@@ -33,7 +31,6 @@
// Forward declarations
////////////////////////////////////////////////////////////////////////////////////////////////
#include <IXml.h> // <> required for Interfuscator
#include "IValidator.h" // <> required for Interfuscator
#include <ILog.h> // <> required for Interfuscator
#include "CryVersion.h"
#include "smartptr.h"
@@ -61,9 +58,7 @@ struct SFileVersion;
struct INameTable;
struct ILevelSystem;
struct IViewSystem;
class ICrySizer;
class IXMLBinarySerializer;
struct IReadWriteXMLSink;
struct IAVI_Reader;
class CPNoise3;
struct ILocalizationManager;
@@ -84,9 +79,11 @@ class CCamera;
struct CLoadingTimeProfiler;
class ICmdLine;
class ILyShine;
enum EValidatorModule : int;
enum EValidatorSeverity : int;
enum ESystemUpdateFlags
{
// Summary:
@@ -435,9 +432,6 @@ struct ISystemUserCallback
// Show message by provider.
virtual int ShowMessage(const char* text, const char* caption, unsigned int uType) { return CryMessageBox(text, caption, uType); }
// Description:
// Collects the memory information in the user program/application.
virtual void GetMemoryUsage(ICrySizer* pSizer) = 0;
// </interfuscator:shuffle>
// Post console load, for cvar setting
@@ -1313,9 +1307,8 @@ namespace Detail
const char* GetHelp() { return NULL; }
bool IsConstCVar() const { return true; }
void SetOnChangeCallback(ConsoleVarFunc pChangeFunc) { (void)pChangeFunc; }
uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) { (void)pChangeFunctor; return 0; }
uint64 AddOnChangeFunctor(const AZStd::function<void()>& pChangeFunctor) { (void)pChangeFunctor; return 0; }
ConsoleVarFunc GetOnChangeCallback() const { InvalidAccess(); return NULL; }
void GetMemoryUsage([[maybe_unused]] class ICrySizer* pSizer) const {}
int GetRealIVal() const { return GetIVal(); }
void SetLimits([[maybe_unused]] float min, [[maybe_unused]] float max) { return; }
void GetLimits([[maybe_unused]] float& min, [[maybe_unused]] float& max) { return; }
@@ -1411,18 +1404,9 @@ static void AssertConsoleExists(void)
// Preferred way to register an int CVar with a callback
#define REGISTER_INT_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
// Summary:
// Preferred way to register an int64 CVar
#define REGISTER_INT64(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt64(_name, (_def_val), (_flags), CVARHELP(_comment)))
// Summary:
// Preferred way to register an int64 CVar with a callback
#define REGISTER_INT64_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt64(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
// Summary:
// Preferred way to register a float CVar
#define REGISTER_FLOAT(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment)))
// Summary:
// Preferred way to register a float CVar with a callback
#define REGISTER_FLOAT_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
// Summary:
// Offers more flexibility but more code is required
#define REGISTER_CVAR2(_name, _var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment)))
// Summary:
@@ -1432,9 +1416,6 @@ static void AssertConsoleExists(void)
// Offers more flexibility but more code is required, explicit address taking of destination variable
#define REGISTER_CVAR3(_name, _var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment)))
// Summary:
// Offers more flexibility but more code is required, explicit address taking of destination variable
#define REGISTER_CVAR3_CB(_name, _var, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment), _onchangefunction))
// Summary:
// Preferred way to register a console command
#define REGISTER_COMMAND(_name, _func, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? false : gEnv->pConsole->AddCommand(_name, _func, (_flags), CVARHELP(_comment)))
// Summary:
@@ -1465,12 +1446,10 @@ static void AssertConsoleExists(void)
#define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0) /* consumed; pure cvar not available */
#define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
#define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); *(_var) = _def_val
#define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) NULL; static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0); _var = _def_val
#define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) /* consumed; command not available */
#else
#define REGISTER_CVAR_DEV_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR(_var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
@@ -1479,12 +1458,10 @@ static void AssertConsoleExists(void)
#define REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_CB_DEV_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT64_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_FLOAT_DEV_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEV_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_COMMAND_DEV_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEV_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#endif // defined(_RELEASE)
//
@@ -1508,12 +1485,9 @@ static void AssertConsoleExists(void)
#define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_INT64_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR2_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_CVAR3_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment); static_assert(((_flags) & ILLEGAL_DEV_FLAGS) == 0)
#else
#define REGISTER_CVAR_DEDI_ONLY(_var, _def_val, _flags, _comment) REGISTER_CVAR_DEV_ONLY(_var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
@@ -1522,12 +1496,9 @@ static void AssertConsoleExists(void)
#define REGISTER_STRING_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_STRING_CB_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
#define REGISTER_INT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
#define REGISTER_INT_CB_DEDI_ONLY(_name, _def_val, _flags, _comment, _onchangefunction) REGISTER_INT_CB_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
#define REGISTER_INT64_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_INT64_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
#define REGISTER_FLOAT_DEDI_ONLY(_name, _def_val, _flags, _comment) REGISTER_FLOAT_DEV_ONLY(_name, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
#define REGISTER_CVAR2_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR2_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
#define REGISTER_CVAR2_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR2_CB_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
#define REGISTER_CVAR3_DEDI_ONLY(_name, _var, _def_val, _flags, _comment) REGISTER_CVAR3_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment)
#define REGISTER_CVAR3_CB_DEDI_ONLY(_name, _var, _def_val, _flags, _comment, _onchangefunction) REGISTER_CVAR3_CB_DEV_ONLY(_name, _var, _def_val, ((_flags) | VF_DEDI_ONLY), _comment, _onchangefunction)
#define REGISTER_COMMAND_DEDI_ONLY(_name, _func, _flags, _comment) REGISTER_COMMAND_DEV_ONLY(_name, _func, ((_flags) | VF_DEDI_ONLY), _comment)
#endif // defined(_RELEASE)
//
@@ -1592,4 +1563,3 @@ inline void CryLogAlways(const char* format, ...)
}
#endif // EXCLUDE_NORMAL_LOG
#endif // CRYINCLUDE_CRYCOMMON_ISYSTEM_H
-71
View File
@@ -13,7 +13,6 @@
enum ETEX_Format : AZ::u8
{
eTF_Unknown = 0,
eTF_R8G8B8A8S,
eTF_R8G8B8A8 = 2, // may be saved into file
eTF_A8 = 4,
@@ -25,76 +24,6 @@ enum ETEX_Format : AZ::u8
eTF_R8G8,
eTF_R8G8S,
eTF_R16G16,
eTF_R16G16S,
eTF_R16G16F,
eTF_R11G11B10F,
eTF_R10G10B10A2,
eTF_R16G16B16A16,
eTF_R16G16B16A16S,
eTF_R16G16B16A16F,
eTF_R32G32B32A32F,
eTF_CTX1,
eTF_BC1 = 22, // may be saved into file
eTF_BC2 = 23, // may be saved into file
eTF_BC3 = 24, // may be saved into file
eTF_BC4U, // 3Dc+
eTF_BC4S,
eTF_BC5U, // 3Dc
eTF_BC5S,
eTF_BC6UH,
eTF_BC6SH,
eTF_BC7,
eTF_R9G9B9E5,
// hardware depth buffers
eTF_D16,
eTF_D24S8,
eTF_D32F,
eTF_D32FS8,
// only available as hardware format under DX11.1 with DXGI 1.2
eTF_B5G6R5,
eTF_B5G5R5,
eTF_B4G4R4A4,
// only available as hardware format under OpenGL
eTF_EAC_R11,
eTF_EAC_RG11,
eTF_ETC2,
eTF_ETC2A,
// only available as hardware format under DX9
eTF_A8L8,
eTF_L8,
eTF_L8V8U8,
eTF_B8G8R8,
eTF_L8V8U8X8,
eTF_B8G8R8X8,
eTF_B8G8R8A8,
eTF_PVRTC2,
eTF_PVRTC4,
eTF_ASTC_4x4,
eTF_ASTC_5x4,
eTF_ASTC_5x5,
eTF_ASTC_6x5,
eTF_ASTC_6x6,
eTF_ASTC_8x5,
eTF_ASTC_8x6,
eTF_ASTC_8x8,
eTF_ASTC_10x5,
eTF_ASTC_10x6,
eTF_ASTC_10x8,
eTF_ASTC_10x10,
eTF_ASTC_12x10,
eTF_ASTC_12x12,
// add R16 unsigned int format for hardware that do not support float point rendering
eTF_R16U,
eTF_R16G16U,
eTF_R10G10B10A2UI,
eTF_MaxFormat // unused, must be always the last in the list
};
+3 -51
View File
@@ -9,21 +9,15 @@
// Description : IValidator interface used to check objects for warnings and errors
// Report missing resources or invalid files.
#ifndef CRYINCLUDE_CRYCOMMON_IVALIDATOR_H
#define CRYINCLUDE_CRYCOMMON_IVALIDATOR_H
#pragma once
# define MAX_WARNING_LENGTH 4096
#if MAX_WARNING_LENGTH < 33
#error "MAX_WARNING_LENGTH should be bigger than 32"
#endif
static_assert(MAX_WARNING_LENGTH>32,"MAX_WARNING_LENGTH should be bigger than 32");
#define ERROR_CANT_FIND_CENTRAL_DIRECTORY "Cannot find Central Directory Record in pak. This is either not a pak file, or a pak file without Central Directory. It does not mean that the data is permanently lost, but it may be severely damaged. Please repair the file with external tools, there may be enough information left to recover the file completely."
enum EValidatorSeverity
enum EValidatorSeverity : int
{
VALIDATOR_ERROR,
VALIDATOR_ERROR_DBGBRK, // will __debugbreak() if sys_error_debugbreak is 1
@@ -31,7 +25,7 @@ enum EValidatorSeverity
VALIDATOR_COMMENT
};
enum EValidatorModule
enum EValidatorModule : int
{
VALIDATOR_MODULE_UNKNOWN,
VALIDATOR_MODULE_RENDERER,
@@ -61,45 +55,3 @@ enum EValidatorFlags
VALIDATOR_FLAG_IGNORE_IN_EDITOR = 0x0040, // Do not log this with the editor
VALIDATOR_FLAG_SKIP_VALIDATOR = 0x0080, // Do not call validator's Report()
};
struct SValidatorRecord
{
//! Severity of this error.
EValidatorSeverity severity;
//! In which module error occured.
EValidatorModule module;
//! Error Text.
const char* text;
//! File which is missing or causing problem.
const char* file;
//! Additional description for this error.
const char* description;
//! Asset scope sring
const char* assetScope;
//! Flags that suggest kind of error.
int flags;
//////////////////////////////////////////////////////////////////////////
SValidatorRecord()
{
module = VALIDATOR_MODULE_UNKNOWN;
text = NULL;
file = NULL;
assetScope = NULL;
description = NULL;
severity = VALIDATOR_WARNING;
flags = 0;
}
};
/*! This interface will be given to Validate methods of engine, for resources and objects validation.
*/
struct IValidator
{
// <interfuscator:shuffle>
virtual ~IValidator(){}
virtual void Report(SValidatorRecord& record) = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_IVALIDATOR_H
+4 -75
View File
@@ -5,18 +5,12 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_IXML_H
#define CRYINCLUDE_CRYCOMMON_IXML_H
#pragma once
#include <platform.h>
#include <Cry_Math.h>
#include <AzCore/IO/FileIO.h>
class ICrySizer;
template <class T>
struct Color_tpl;
typedef Color_tpl<uint8> ColorB;
@@ -24,17 +18,12 @@ typedef Color_tpl<uint8> ColorB;
template <typename F>
struct Vec2_tpl;
typedef Vec2_tpl<f32> Vec2;
typedef Vec2_tpl<f64> Vec2d;
template <typename F>
struct Vec3_tpl;
typedef Vec3_tpl<f32> Vec3;
typedef Vec3_tpl<f64> Vec3d;
template <typename F>
struct Vec4_tpl;
typedef Vec4_tpl<f32> Vec4;
typedef Vec4_tpl<f64> Vec4d;
struct Vec4;
template <typename F>
struct Quat_tpl;
@@ -59,7 +48,6 @@ class QColor;
class QString;
class IXMLBinarySerializer;
struct IReadWriteXMLSink;
struct ISerialize;
/*
@@ -329,11 +317,9 @@ public:
virtual void setAttr(const char* key, float value) = 0;
virtual void setAttr(const char* key, double value) = 0;
virtual void setAttr(const char* key, const Vec2& value) = 0;
virtual void setAttr(const char* key, const Vec2d& value) = 0;
virtual void setAttr(const char* key, const Ang3& value) = 0;
virtual void setAttr(const char* key, const Vec3& value) = 0;
virtual void setAttr(const char* key, const Vec4& value) = 0;
virtual void setAttr(const char* key, const Vec3d& value) = 0;
virtual void setAttr(const char* key, const Quat& value) = 0;
#if defined(LINUX64) || defined(APPLE)
// Compatibility functions, on Linux and Mac long int is the default int64_t
@@ -378,11 +364,9 @@ public:
virtual bool getAttr(const char* key, float& value) const = 0;
virtual bool getAttr(const char* key, double& value) const = 0;
virtual bool getAttr(const char* key, Vec2& value) const = 0;
virtual bool getAttr(const char* key, Vec2d& value) const = 0;
virtual bool getAttr(const char* key, Ang3& value) const = 0;
virtual bool getAttr(const char* key, Vec3& value) const = 0;
virtual bool getAttr(const char* key, Vec4& value) const = 0;
virtual bool getAttr(const char* key, Vec3d& value) const = 0;
virtual bool getAttr(const char* key, Quat& value) const = 0;
virtual bool getAttr(const char* key, bool& value) const = 0;
virtual bool getAttr(const char* key, XmlString& value) const = 0;
@@ -401,13 +385,6 @@ public:
}
#endif
// </interfuscator:shuffle>
// <interfuscator:shuffle>
// Summary:
// Collect all allocated memory
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// Summary:
// Copies children to this node from a given node.
// Children are reference copied (shallow copy) and the children's parent is NOT set to this
@@ -700,7 +677,7 @@ public:
XmlNodeRefIterator& operator=(const XmlNodeRefIterator& other) = default;
XmlNodeRefIterator& operator++()
XmlNodeRefIterator& operator++()
{
++m_index;
Update();
@@ -714,7 +691,7 @@ public:
return ret;
}
IXmlNode* operator*() const
IXmlNode* operator*() const
{
return m_currentChildNode;
}
@@ -794,7 +771,6 @@ struct IXmlSerializer
virtual ISerialize* GetWriter(XmlNodeRef& node) = 0;
virtual ISerialize* GetReader(XmlNodeRef& node) = 0;
// </interfuscator:shuffle>
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
};
//////////////////////////////////////////////////////////////////////////
@@ -802,7 +778,6 @@ struct IXmlSerializer
// XML Parser interface.
struct IXmlParser
{
// <interfuscator:shuffle>
virtual ~IXmlParser(){}
virtual void AddRef() = 0;
virtual void Release() = 0;
@@ -814,9 +789,6 @@ struct IXmlParser
// Summary:
// Parses xml from memory buffer.
virtual XmlNodeRef ParseBuffer(const char* buffer, int nBufLen, bool bCleanPools, bool bSuppressWarnings = false) = 0;
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// </interfuscator:shuffle>
};
//////////////////////////////////////////////////////////////////////////
@@ -863,7 +835,6 @@ struct IXmlTableReader
// to know absolute cell index (i.e. column).
// Returns false if no cells left in the row.
virtual bool ReadCell(int& columnIndex, const char*& pContent, size_t& contentSize) = 0;
virtual float GetCurrentRowHeight() = 0;
// </interfuscator:shuffle>
};
@@ -877,28 +848,17 @@ struct IXmlUtils
// Summary:
// Loads xml file, returns 0 if load failed.
virtual XmlNodeRef LoadXmlFromFile(const char* sFilename, bool bReuseStrings = false, bool bEnablePatching = true) = 0;
virtual XmlNodeRef LoadXmlFromFile(const char* sFilename, bool bReuseStrings = false) = 0;
// Summary:
// Loads xml from memory buffer, returns 0 if load failed.
virtual XmlNodeRef LoadXmlFromBuffer(const char* buffer, size_t size, bool bReuseStrings = false, bool bSuppressWarnings = false) = 0;
// Summary:
// Creates an MD5 hash of an XML file
virtual const char* HashXml(XmlNodeRef node) = 0;
// Summary:
// Gets an object that can read a xml into a IReadXMLSink
// and writes a xml from a IWriteXMLSource
virtual IReadWriteXMLSink* GetIReadWriteXMLSink() = 0;
// Summary:
// Creates XML Writer for ISerialize interface.
// See also:
// IXmlSerializer
virtual IXmlSerializer* CreateXmlSerializer() = 0;
// </interfuscator:shuffle>
// <interfuscator:shuffle>
// Summary:
// Creates XML Parser.
// Notes:
@@ -908,40 +868,9 @@ struct IXmlUtils
// After use it must be released with call to Release method.
virtual IXmlParser* CreateXmlParser() = 0;
// Summary:
// Creates XML to file in the binary form.
virtual bool SaveBinaryXmlFile(const char* sFilename, XmlNodeRef root) = 0;
// Summary:
// Reads XML data from file in the binary form.
virtual XmlNodeRef LoadBinaryXmlFile(const char* sFilename, bool bEnablePatching = true) = 0;
// Summary:
// Enables or disables checking for binary xml files.
// Return Value:
// The previous status.
virtual bool EnableBinaryXmlLoading(bool bEnable) = 0;
// Summary:
// Creates XML Table reader.
// Notes:
// After use it must be released with call to Release method.
virtual IXmlTableReader* CreateXmlTableReader() = 0;
// Init xml stats nodes pool
virtual void InitStatsXmlNodePool(uint32 nPoolSize) = 0;
// Creates new xml node for statistics.
virtual XmlNodeRef CreateStatsXmlNode(const char* sNodeName) = 0;
// Set owner thread
virtual void SetStatsOwnerThread(threadID threadId) = 0;
// Free memory held on to by xml pool if empty
virtual void FlushStatsXmlNodePool() = 0;
// Sets the patch which is used to transform loaded XML files. the patch itself is encoded into XML
// Set to NULL to clear an existing transform and disable further patching
virtual void SetXMLPatcher(XmlNodeRef* pPatcher) = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_IXML_H
@@ -429,7 +429,6 @@ extern DWORD GetCurrentProcessId(void);
//helper function
extern void adaptFilenameToLinux(char* rAdjustedFilename);
extern const int comparePathNames(const char* cpFirst, const char* cpSecond, unsigned int len);//returns 0 if identical
extern void replaceDoublePathFilename(char* szFileName);//removes "\.\" to "\" and "/./" to "/"
//////////////////////////////////////////////////////////////////////////
@@ -8,7 +8,6 @@
#pragma once
#include <CrySizer.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
@@ -42,10 +42,10 @@ public: // types
void UnitClamp()
{
m_left = FClamp(m_left, 0.0f, 1.0f);
m_top = FClamp(m_top, 0.0f, 1.0f);
m_right = FClamp(m_right, 0.0f, 1.0f);
m_bottom = FClamp(m_bottom, 0.0f, 1.0f);
m_left = AZStd::clamp(m_left, 0.0f, 1.0f);
m_top = AZStd::clamp(m_top, 0.0f, 1.0f);
m_right = AZStd::clamp(m_right, 0.0f, 1.0f);
m_bottom = AZStd::clamp(m_bottom, 0.0f, 1.0f);
}
bool operator==(const Anchors& rhs) const
-75
View File
@@ -1,75 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Marsenne Twister PRNG. See MT.h for more info.
#include "MTPseudoRandom.h"
// non-inline function definitions and static member definitions cannot
// reside in header file because of the risk of multiple declarations
void CMTRand_int32::gen_state() // generate new m_nState vector
{
for (int i = 0; i < (n - m); ++i)
{
m_nState[i] = m_nState[i + m] ^ twiddle(m_nState[i], m_nState[i + 1]);
}
for (int i = n - m; i < (n - 1); ++i)
{
m_nState[i] = m_nState[i + m - n] ^ twiddle(m_nState[i], m_nState[i + 1]);
}
m_nState[n - 1] = m_nState[m - 1] ^ twiddle(m_nState[n - 1], m_nState[0]);
p = 0; // reset position
}
void CMTRand_int32::seed(uint32 s) // init by 32 bit seed
{ //if (s == 0)
//m_nRandom = 1;
for (int i = 0; i < n; ++i)
{
m_nState[i] = 0x0UL;
}
m_nState[0] = s;
for (int i = 1; i < n; ++i)
{
m_nState[i] = 1812433253UL * (m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) + i;
// see Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier
// in the previous versions, MSBs of the seed affect only MSBs of the array m_nState
// 2002/01/09 modified by Makoto Matsumoto
}
p = n; // force gen_state() to be called for next random number
}
void CMTRand_int32::seed(const uint32* array, int size) // init by array
{
seed(19650218UL);
int i = 1, j = 0;
for (int k = ((n > size) ? n : size); k; --k)
{
m_nState[i] = (m_nState[i] ^ ((m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) * 1664525UL))
+ array[j] + j; // non linear
++j;
j %= size;
if ((++i) == n)
{
m_nState[0] = m_nState[n - 1];
i = 1;
}
}
for (int k = n - 1; k; --k)
{
m_nState[i] = (m_nState[i] ^ ((m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) * 1566083941UL)) - i;
if ((++i) == n)
{
m_nState[0] = m_nState[n - 1];
i = 1;
}
}
m_nState[0] = 0x80000000UL; // MSB is 1; assuring non-zero initial array
p = n; // force gen_state() to be called for next random number
}
-166
View File
@@ -1,166 +0,0 @@
// mtrand.h
// C++ include file for MT19937, with initialization improved 2002/1/26.
// Coded by Takuji Nishimura and Makoto Matsumoto.
// Ported to C++ by Jasper Bedaux 2003/1/1 (see http://www.bedaux.net/mtrand/).
// The generators returning floating point numbers are based on
// a version by Isaku Wada, 2002/01/09
// Static shared data converted to per-instance, 2008-11-13 by JSP.
//
// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The names of its contributors may not be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Any feedback is very welcome.
// http://www.math.keio.ac.jp/matumoto/emt.html
// email: matumoto@math.keio.ac.jp
//
// Feedback about the C++ port should be sent to Jasper Bedaux,
// see http://www.bedaux.net/mtrand/ for e-mail address and info.
//-------------------------------------------------------------------------
// History:
// - 28:7:2005: File created and minor changes by Marco Corbetta
//
//*************************************************************************/
// Modified from original
#ifndef CRYINCLUDE_CRYCOMMON_MTPSEUDORANDOM_H
#define CRYINCLUDE_CRYCOMMON_MTPSEUDORANDOM_H
#pragma once
#include <CryRandomInternal.h>
//////////////////////////////////////////////////////////////////////////
class CMTRand_int32
{
// Mersenne Twister random number generator
public:
// default constructor
CMTRand_int32() { seed(5489UL); }
// constructor with 32 bit int as seed
CMTRand_int32(uint32 seed_value) { seed(seed_value); }
// constructor with array of 32 bit integers as seed
CMTRand_int32(const uint32* array, int size) { seed(array, size); }
// seeds with 32 bit integer
void seed(uint32 seed_value);
// seeds with array
void seed(const uint32*, int size);
// overloaded operator() to make this a generator (functor)
//uint32 operator()() { return rand_int32(); }
~CMTRand_int32() {}
// Functions with PascalCase names were added for
// interchangeability with CRndGen (see LCGRandom.h).
void Seed(uint32 seed_value)
{
seed(seed_value);
}
uint32 GenerateUint32()
{
return rand_int32();
}
uint64 GenerateUint64()
{
const uint32 a = GenerateUint32();
const uint32 b = GenerateUint32();
return ((uint64)b << 32) | (uint64)a;
}
float GenerateFloat()
{
return (float)GenerateUint32() * (1.0f / 4294967295.0f);
}
// Ranged function returns random value within the *inclusive* range
// between minValue and maxValue.
// Any orderings work correctly: minValue <= maxValue and
// minValue >= minValue.
template <class T>
T GetRandom(const T minValue, const T maxValue)
{
return CryRandom_Internal::BoundedRandom<CMTRand_int32, T>::Get(*this, minValue, maxValue);
}
// Vector (Vec2, Vec3, Vec4) ranged function returns vector with
// every component within the *inclusive* ranges between minValue.component
// and maxValue.component.
// All orderings work correctly: minValue.component <= maxValue.component and
// minValue.component >= maxValue.component.
template <class T>
T GetRandomComponentwise(const T& minValue, const T& maxValue)
{
return CryRandom_Internal::BoundedRandomComponentwise<CMTRand_int32, T>::Get(*this, minValue, maxValue);
}
// The function returns a random unit vector (Vec2, Vec3, Vec4).
template <class T>
T GetRandomUnitVector()
{
return CryRandom_Internal::GetRandomUnitVector<CMTRand_int32, T>(*this);
}
protected: // used by derived classes, otherwise not accessible; use the ()-operator
// generates 32 bit random int
uint32 rand_int32()
{
if (p >= n) gen_state(); // new m_nState vector needed
// gen_state() is split off to be non-inline, because it is only called once
// in every 624 calls and otherwise irand() would become too big to get inlined
uint32 x = m_nState[p++];
x ^= (x >> 11);
x ^= (x << 7) & 0x9D2C5680UL;
x ^= (x << 15) & 0xEFC60000UL;
return x ^ (x >> 18);
}
private:
static const int n = 624, m = 397; // compile time constants
// the variables below are static (no duplicates can exist)
uint32 m_nState[n+1]; // m_nState vector array
int p; // position in m_nState array
// private functions used to generate the pseudo random numbers
uint32 twiddle(uint32 u, uint32 v)
{
return (((u & 0x80000000UL) | (v & 0x7FFFFFFFUL)) >> 1)
^ ((v & 1UL) ? 0x9908B0DFUL : 0x0UL);
}
void gen_state(); // generate new m_nState
// make copy constructor and assignment operator unavailable, they don't make sense
CMTRand_int32(const CMTRand_int32&); // copy constructor not defined
void operator=(const CMTRand_int32&); // assignment operator not defined
};
#endif // CRYINCLUDE_CRYCOMMON_MTPSEUDORANDOM_H
-29
View File
@@ -153,35 +153,6 @@ inline AZ::Matrix3x4 LYTransformToAZMatrix3x4(const Matrix34& source)
return AZ::Matrix3x4::CreateFromRowMajorFloat12(source.GetData());
}
inline AZ::Transform LYQuatTToAZTransform(const QuatT& source)
{
return AZ::Transform::CreateFromQuaternionAndTranslation(
LYQuaternionToAZQuaternion(source.q),
LYVec3ToAZVec3(source.t));
}
inline QuatT AZTransformToLYQuatT(const AZ::Transform& source)
{
return QuatT(
AZQuaternionToLYQuaternion(source.GetRotation()),
AZVec3ToLYVec3(source.GetTranslation()));
}
inline QuatT AZMatrix3x4ToLYQuatT(const AZ::Matrix3x4& source)
{
AZ::Matrix3x4 sourceNoScale(source);
sourceNoScale.ExtractScale();
return QuatT(
AZQuaternionToLYQuaternion(AZ::Quaternion::CreateFromMatrix3x4(sourceNoScale)),
AZVec3ToLYVec3(source.GetTranslation()));
}
inline DualQuat AZMatrix3x4ToLYDualQuat(const AZ::Matrix3x4& matrix3x4)
{
return DualQuat(AZMatrix3x4ToLYMatrix3x4(matrix3x4));
}
inline AABB AZAabbToLyAABB(const AZ::Aabb& source)
{
return AABB(AZVec3ToLYVec3(source.GetMin()), AZVec3ToLYVec3(source.GetMax()));
-135
View File
@@ -1,135 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_METAUTILS_H
#define CRYINCLUDE_CRYCOMMON_METAUTILS_H
#pragma once
namespace metautils
{
// select
template<bool Condition, typename Ty1, typename Ty2>
struct select;
template<typename Ty1, typename Ty2>
struct select<true, Ty1, Ty2>
{
typedef Ty1 type;
};
template<typename Ty1, typename Ty2>
struct select<false, Ty1, Ty2>
{
typedef Ty2 type;
};
// is_same
// Identifies whether types Ty1 and Ty2 are the same including const & volatile.
template<typename Ty1, typename Ty2>
struct is_same;
template<typename Ty1>
struct is_same<Ty1, Ty1>
{
enum
{
value = true,
};
};
template<typename Ty1, typename Ty2>
struct is_same
{
enum
{
value = false,
};
};
// remove_const
// Removes top level const qualifier.
template<class Ty>
struct remove_const
{
typedef Ty type;
};
template<class Ty>
struct remove_const<const Ty>
{
typedef Ty type;
};
template<class Ty>
struct remove_const<const Ty[]>
{
typedef Ty type[];
};
template<class Ty, unsigned int N>
struct remove_const<const Ty[N]>
{
typedef Ty type[N];
};
// is_const
// Determines whether type Ty is const qualified.
template <typename Ty>
struct is_const
{
enum
{
value = false
};
};
template <typename Ty>
struct is_const<const Ty>
{
enum
{
value = true
};
};
template<class Ty, unsigned int N>
struct is_const<Ty[N]>
{
enum
{
value = false
};
};
template<class Ty, unsigned int N>
struct is_const<const Ty[N]>
{
enum
{
value = true
};
};
template<class Ty>
struct is_const<Ty&>
{
enum
{
value = false
};
};
};
#endif // CRYINCLUDE_CRYCOMMON_METAUTILS_H
+2 -3
View File
@@ -11,7 +11,7 @@
#include <IConsole.h>
#include <AzTest/AzTest.h>
#include <SFunctor.h>
#include <AzCore/std/function/function_template.h>
class CVarMock
: public ICVar
@@ -35,9 +35,8 @@ public:
MOCK_METHOD0(GetHelp, const char*());
MOCK_CONST_METHOD0(IsConstCVar, bool());
MOCK_METHOD1(SetOnChangeCallback, void(ConsoleVarFunc));
MOCK_METHOD1(AddOnChangeFunctor, uint64(const SFunctor& pChangeFunctor));
MOCK_METHOD1(AddOnChangeFunctor, uint64(const AZStd::function<void()>& pChangeFunctor));
MOCK_CONST_METHOD0(GetOnChangeCallback, ConsoleVarFunc());
MOCK_CONST_METHOD1(GetMemoryUsage, void(class ICrySizer* pSizer));
MOCK_CONST_METHOD0(GetRealIVal, int());
MOCK_METHOD2(SetLimits, void(float, float));
MOCK_METHOD2(GetLimits, void(float&, float&));
@@ -21,12 +21,10 @@ public:
MOCK_METHOD1(Init, void(ISystem * pSystem));
MOCK_METHOD5(RegisterString, ICVar * (const char* sName, const char* sValue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc));
MOCK_METHOD5(RegisterInt, ICVar * (const char* sName, int iValue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc));
MOCK_METHOD5(RegisterInt64, ICVar * (const char* sName, int64 iValue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc));
MOCK_METHOD5(RegisterFloat, ICVar * (const char* sName, float fValue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc));
MOCK_METHOD7(Register, ICVar * (const char* name, float* src, float defaultvalue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc, bool allowModify));
MOCK_METHOD7(Register, ICVar * (const char* name, int* src, int defaultvalue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc, bool allowModify));
MOCK_METHOD7(Register, ICVar * (const char* name, const char** src, const char* defaultvalue, int nFlags, const char* help, ConsoleVarFunc pChangeFunc, bool allowModify));
MOCK_METHOD1(Register, ICVar * (ICVar * pVar));
MOCK_METHOD2(UnregisterVariable, void(const char* sVarName, bool bDelete ));
MOCK_METHOD1(SetScrollMax, void(int value));
MOCK_METHOD1(AddOutputPrintSink, void(IOutputPrintSink * inpSink));
@@ -63,7 +61,6 @@ public:
MOCK_METHOD2(RegisterAutoComplete, void (const char* sVarOrCommand, IConsoleArgumentAutoComplete * pArgAutoComplete));
MOCK_METHOD1(UnRegisterAutoComplete, void (const char* sVarOrCommand));
MOCK_METHOD0(ResetAutoCompletion, void ());
MOCK_CONST_METHOD1(GetMemoryUsage, void (ICrySizer * pSizer));
MOCK_METHOD1(ResetProgressBar, void (int nProgressRange));
MOCK_METHOD0(TickProgressBar, void ());
MOCK_METHOD1(SetInputLine, void (const char* szLine));

Some files were not shown because too many files have changed in this diff Show More