diff --git a/Code/Editor/Controls/ImageHistogramCtrl.cpp b/Code/Editor/Controls/ImageHistogramCtrl.cpp index 48bc7a70d2..bdb81e3655 100644 --- a/Code/Editor/Controls/ImageHistogramCtrl.cpp +++ b/Code/Editor/Controls/ImageHistogramCtrl.cpp @@ -188,7 +188,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event) float scale = 0; i = static_cast(((float)x / graphWidth) * (kNumColorLevels - 1)); - i = CLAMP(i, 0, kNumColorLevels - 1); + i = AZStd::clamp(i, 0, kNumColorLevels - 1); switch (m_drawMode) { @@ -253,7 +253,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event) for (size_t x = 0, xCount = abs(rcGraph.width()); x < xCount; ++x) { i = static_cast(((float)x / graphWidth) * (kNumColorLevels - 1)); - i = CLAMP(i, 0, kNumColorLevels - 1); + i = AZStd::clamp(i, 0, kNumColorLevels - 1); crtX = static_cast(rcGraph.left() + x + 1); scaleR = scaleG = scaleB = scaleA = 0; @@ -345,7 +345,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event) { pos = (float)x / graphWidth; i = static_cast((float)((int)(pos * kNumColorLevels) % aThirdOfNumColorLevels) / aThirdOfNumColorLevels * kNumColorLevels); - i = CLAMP(i, 0, kNumColorLevels - 1); + i = AZStd::clamp(i, 0, kNumColorLevels - 1); scale = 0; // R diff --git a/Code/Editor/Controls/SplineCtrl.cpp b/Code/Editor/Controls/SplineCtrl.cpp index 8ccf103c25..73264274b7 100644 --- a/Code/Editor/Controls/SplineCtrl.cpp +++ b/Code/Editor/Controls/SplineCtrl.cpp @@ -101,7 +101,7 @@ void CSplineCtrl::PointToTimeValue(const QPoint& point, float& time, float& valu { time = XOfsToTime(point.x()); float t = float(m_rcSpline.bottom() - point.y()) / m_rcSpline.height(); - value = LERP(m_fMinValue, m_fMaxValue, t); + value = AZ::Lerp(m_fMinValue, m_fMaxValue, t); } ////////////////////////////////////////////////////////////////////////// @@ -109,7 +109,7 @@ float CSplineCtrl::XOfsToTime(int x) { // m_fMinTime to m_fMaxTime time range. float t = float(x - m_rcSpline.left()) / m_rcSpline.width(); - return LERP(m_fMinTime, m_fMaxTime, t); + return AZ::Lerp(m_fMinTime, m_fMaxTime, t); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index 796e16dd53..5294ebbc7e 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -54,7 +54,6 @@ // CryCommon #include #include -#include // AzFramework #include @@ -70,7 +69,6 @@ #include "Include/IDisplayViewport.h" #include "Objects/ObjectManager.h" #include "ProcessInfo.h" -#include "IPostEffectGroup.h" #include "EditorPreferencesPageGeneral.h" #include "ViewportManipulatorController.h" #include "EditorViewportSettings.h" @@ -100,7 +98,6 @@ #include #include -#include #include AZ_CVAR( diff --git a/Code/Editor/Export/ExportManager.cpp b/Code/Editor/Export/ExportManager.cpp index 220c341f5c..5527aa6ce6 100644 --- a/Code/Editor/Export/ExportManager.cpp +++ b/Code/Editor/Export/ExportManager.cpp @@ -356,10 +356,9 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh for (int v = 0; v < meshDesc.m_nCoorCount; ++v) { - Export::UV tc; - meshDesc.m_pTexCoord[v].ExportTo(tc.u, tc.v); - tc.v = 1.0f - tc.v; - pObj->m_texCoords.push_back(tc); + Vec2 uv = meshDesc.m_pTexCoord[v].GetUV(); + uv.y = 1.0f - uv.y; + pObj->m_texCoords.push_back({uv.x,uv.y}); } if (pIndMesh->GetSubSetCount() && !(pIndMesh->GetSubSetCount() == 1 && pIndMesh->GetSubSet(0).nNumIndices == 0)) diff --git a/Code/Editor/Geometry/TriMesh.cpp b/Code/Editor/Geometry/TriMesh.cpp index d56aa038b5..efc201095d 100644 --- a/Code/Editor/Geometry/TriMesh.cpp +++ b/Code/Editor/Geometry/TriMesh.cpp @@ -161,61 +161,6 @@ void* CTriMesh::ReAllocElements(void* old_ptr, int new_elem_num, int size_of_ele return realloc(old_ptr, new_elem_num * size_of_element); } -////////////////////////////////////////////////////////////////////////// -// Unshare all vertices and split on 3 arrays, positions/texcoords. -////////////////////////////////////////////////////////////////////////// -void CTriMesh::SetFromMesh(CMesh& mesh) -{ - bbox = mesh.m_bbox; - - int maxVerts = mesh.GetIndexCount(); - - SetVertexCount(maxVerts); - SetUVCount(maxVerts); - if (mesh.m_pColor0) - { - SetColorsCount(maxVerts); - } - - SetFacesCount(mesh.GetIndexCount()); - - int numv = 0; - int numface = 0; - for (int nSubset = 0; nSubset < mesh.GetSubSetCount(); nSubset++) - { - SMeshSubset& subset = mesh.m_subsets[nSubset]; - for (int i = subset.nFirstIndexId; i < subset.nFirstIndexId + subset.nNumIndices; i += 3) - { - CTriFace& face = pFaces[numface++]; - for (int j = 0; j < 3; j++) - { - int idx = mesh.m_pIndices[i + j]; - pVertices[numv].pos = mesh.m_pPositions ? mesh.m_pPositions[idx] : mesh.m_pPositionsF16[idx].ToVec3(); - pWeights[numv] = 0.0f; - pUV[numv] = mesh.m_pTexCoord[idx]; - if (mesh.m_pColor0) - { - pColors[numv] = mesh.m_pColor0[idx]; - } - - face.v [j] = numv; - face.uv[j] = numv; - face.n [j] = mesh.m_pNorms[idx].GetN(); - face.MatID = static_cast(subset.nMatID); - face.flags = 0; - - numv++; - } - } - } - SetFacesCount(numface); - SharePositions(); - ShareUV(); - UpdateEdges(); - - CalcFaceNormals(); -} - ///////////////////////////////////////////////////////////////////////////////////// inline int FindVertexInHash(const Vec3& vPosToFind, const CTriVertex* pVectors, std::vector& hash, float fEpsilon) { @@ -360,76 +305,6 @@ void CTriMesh::CalcFaceNormals() #define TEX_EPS 0.001f #define VER_EPS 0.001f -////////////////////////////////////////////////////////////////////////// -void CTriMesh::UpdateIndexedMesh(IIndexedMesh* pIndexedMesh) const -{ - { - const int maxVerts = nFacesCount * 3; - - pIndexedMesh->SetVertexCount(maxVerts); - pIndexedMesh->SetTexCoordCount(maxVerts); - if (pColors) - { - pIndexedMesh->SetColorCount(maxVerts); - } - pIndexedMesh->SetIndexCount(0); - pIndexedMesh->SetFaceCount(nFacesCount); - } - - ////////////////////////////////////////////////////////////////////////// - // To find really used materials - std::vector usedMaterialIds; - uint16 MatIdToSubset[MAX_SUB_MATERIALS]; - uint16 nLastSubsetId = 0; - memset(MatIdToSubset, 0, sizeof(MatIdToSubset)); - ////////////////////////////////////////////////////////////////////////// - - CMesh& mesh = *pIndexedMesh->GetMesh(); - AABB bb; - bb.Reset(); - for (int i = 0; i < nFacesCount; ++i) - { - const CTriFace& face = pFaces[i]; - SMeshFace& meshFace = mesh.m_pFaces[i]; - - // Remap new used material ID to index of chunk id. - if (!MatIdToSubset[face.MatID]) - { - MatIdToSubset[face.MatID] = 1 + nLastSubsetId++; - usedMaterialIds.push_back(face.MatID); // Order of material ids in usedMaterialIds correspond to the indices of chunks. - } - meshFace.nSubset = static_cast(MatIdToSubset[face.MatID] - 1); - - for (int j = 0; j < 3; ++j) - { - const int dstVIdx = i * 3 + j; - - mesh.m_pPositions[dstVIdx] = pVertices[face.v[j]].pos; - mesh.m_pNorms[dstVIdx] = SMeshNormal(face.n[j]); - mesh.m_pTexCoord[dstVIdx] = pUV[face.uv[j]]; - if (pColors) - { - mesh.m_pColor0[dstVIdx] = pColors[face.v[j]]; - } - - meshFace.v[j] = dstVIdx; - - bb.Add(mesh.m_pPositions[dstVIdx]); - } - } - - pIndexedMesh->SetBBox(bb); - - pIndexedMesh->SetSubSetCount(static_cast(usedMaterialIds.size())); - for (int i = 0; i < usedMaterialIds.size(); i++) - { - pIndexedMesh->SetSubsetMaterialId(i, usedMaterialIds[i]); - } - - pIndexedMesh->Optimize(); -} - - ////////////////////////////////////////////////////////////////////////// void CTriMesh::CopyStream(CTriMesh& fromMesh, int stream) { diff --git a/Code/Editor/Geometry/TriMesh.h b/Code/Editor/Geometry/TriMesh.h index 9bb73f945d..a6c58b8f9d 100644 --- a/Code/Editor/Geometry/TriMesh.h +++ b/Code/Editor/Geometry/TriMesh.h @@ -198,8 +198,6 @@ public: void GetStreamInfo(int stream, void*& pStream, int& nElementSize) const; int GetStreamSize(int stream) const { return m_streamSize[stream]; }; - void SetFromMesh(CMesh& mesh); - void UpdateIndexedMesh(IIndexedMesh* pIndexedMesh) const; // Calculate per face normal. void CalcFaceNormals(); diff --git a/Code/Editor/Include/Command.h b/Code/Editor/Include/Command.h index e4fea5a3e7..dfdcec78ef 100644 --- a/Code/Editor/Include/Command.h +++ b/Code/Editor/Include/Command.h @@ -8,14 +8,12 @@ // Description : Classes to deal with commands - - -#ifndef CRYINCLUDE_EDITOR_INCLUDE_COMMAND_H -#define CRYINCLUDE_EDITOR_INCLUDE_COMMAND_H #pragma once #include - +#include +#include +#include #include "Util/EditorUtils.h" inline AZStd::string ToString(const QString& s) @@ -23,8 +21,20 @@ inline AZStd::string ToString(const QString& s) return s.toUtf8().data(); } + class CCommand { + 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; + } public: CCommand( const AZStd::string& module, @@ -77,7 +87,7 @@ public: return false; } } - int GetArgCount() const + size_t GetArgCount() const { return m_args.size(); } const AZStd::string& GetArg(int i) const { @@ -85,7 +95,7 @@ public: return m_args[i]; } private: - DynArray m_args; + AZStd::vector m_args; unsigned char m_stringFlags; // This is needed to quote string parameters when logging a command. }; @@ -115,7 +125,7 @@ protected: static inline AZStd::string ToString_(const char* val) { return val; } template - static bool FromString_(T& t, const char* s) { return ::FromString(t, s); } + static bool FromString_(T& t, const char* s) { return FromString(t, s); } static inline bool FromString_(const char*& val, const char* s) { return (val = s) != 0; } @@ -789,4 +799,3 @@ QString CCommand6::Execute(const CCommand::CArgs& args) } return ""; } -#endif // CRYINCLUDE_EDITOR_INCLUDE_COMMAND_H diff --git a/Code/Editor/Include/IFileUtil.h b/Code/Editor/Include/IFileUtil.h index 700e04f6d3..e179f892d9 100644 --- a/Code/Editor/Include/IFileUtil.h +++ b/Code/Editor/Include/IFileUtil.h @@ -9,6 +9,7 @@ #pragma once #include "../Include/SandboxAPI.h" +#include #include class QWidget; @@ -103,7 +104,7 @@ struct IFileUtil } }; - typedef DynArray FileArray; + using FileArray = AZStd::vector; typedef bool (* ScanDirectoryUpdateCallBack)(const QString& msg); diff --git a/Code/Editor/Include/IObjectManager.h b/Code/Editor/Include/IObjectManager.h index 360cc8fe34..fb99a50bb0 100644 --- a/Code/Editor/Include/IObjectManager.h +++ b/Code/Editor/Include/IObjectManager.h @@ -89,7 +89,7 @@ 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& objects) const = 0; + //virtual void GetObjects(DynArray& 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. diff --git a/Code/Editor/Lib/Tests/IEditorMock.h b/Code/Editor/Lib/Tests/IEditorMock.h index 242bf4d25c..30f1d23576 100644 --- a/Code/Editor/Lib/Tests/IEditorMock.h +++ b/Code/Editor/Lib/Tests/IEditorMock.h @@ -9,7 +9,6 @@ #include #include -#include #include class CEditorMock @@ -85,8 +84,8 @@ public: MOCK_METHOD0(GetObjectManager, struct IObjectManager* ()); MOCK_METHOD0(GetSettingsManager, CSettingsManager* ()); MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType)); - MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ()); - MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ()); + MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ()); + MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ()); MOCK_METHOD0(GetIconManager, IIconManager* ()); MOCK_METHOD0(GetMusicManager, CMusicManager* ()); MOCK_METHOD2(GetTerrainElevation, float(float , float )); @@ -183,7 +182,7 @@ public: MOCK_METHOD0(GetEnv, SSystemGlobalEnvironment* ()); MOCK_METHOD0(GetImageUtil, IImageUtil* ()); MOCK_METHOD0(GetEditorSettings, SEditorSettings* ()); - MOCK_METHOD0(GetLogFile, ILogFile* ()); + MOCK_METHOD0(GetLogFile, ILogFile* ()); MOCK_METHOD0(UnloadPlugins, void()); MOCK_METHOD0(LoadPlugins, void()); MOCK_METHOD1(GetSearchPath, QString(EEditorPathName)); diff --git a/Code/Editor/Objects/BaseObject.cpp b/Code/Editor/Objects/BaseObject.cpp index c653830e70..0d5f982bd4 100644 --- a/Code/Editor/Objects/BaseObject.cpp +++ b/Code/Editor/Objects/BaseObject.cpp @@ -2057,53 +2057,7 @@ bool CBaseObject::IsChildOf(CBaseObject* node) } ////////////////////////////////////////////////////////////////////////// -void CBaseObject::GetAllChildren(TBaseObjects& outAllChildren, CBaseObject* pObj) const -{ - const CBaseObject* pBaseObj = pObj ? pObj : this; - for (size_t i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i) - { - CBaseObject* pChild = pBaseObj->GetChild(i); - if (pChild == nullptr) - { - continue; - } - outAllChildren.push_back(pChild); - GetAllChildren(outAllChildren, pChild); - } -} - -void CBaseObject::GetAllChildren(DynArray< _smart_ptr >& outAllChildren, CBaseObject* pObj) const -{ - const CBaseObject* pBaseObj = pObj ? pObj : this; - - for (size_t i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i) - { - CBaseObject* pChild = pBaseObj->GetChild(i); - if (pChild == nullptr) - { - continue; - } - outAllChildren.push_back(pChild); - GetAllChildren(outAllChildren, pChild); - } -} - -void CBaseObject::GetAllChildren(CSelectionGroup& outAllChildren, CBaseObject* pObj) const -{ - const CBaseObject* pBaseObj = pObj ? pObj : this; - - for (size_t i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i) - { - CBaseObject* pChild = pBaseObj->GetChild(i); - if (pChild == nullptr) - { - continue; - } - outAllChildren.AddObject(pChild); - GetAllChildren(outAllChildren, pChild); - } -} ////////////////////////////////////////////////////////////////////////// void CBaseObject::CloneChildren(CBaseObject* pFromObject) diff --git a/Code/Editor/Objects/BaseObject.h b/Code/Editor/Objects/BaseObject.h index ece0bf67c3..89e47ae881 100644 --- a/Code/Editor/Objects/BaseObject.h +++ b/Code/Editor/Objects/BaseObject.h @@ -408,10 +408,6 @@ public: CBaseObject* GetParent() const { return m_parent; }; //! Scans hierarchy up to determine if we child of specified node. virtual bool IsChildOf(CBaseObject* node); - //! Get all child objects - void GetAllChildren(TBaseObjects& outAllChildren, CBaseObject* pObj = nullptr) const; - void GetAllChildren(DynArray< _smart_ptr >& outAllChildren, CBaseObject* pObj = nullptr) const; - void GetAllChildren(CSelectionGroup& outAllChildren, CBaseObject* pObj = nullptr) const; //! Clone Children void CloneChildren(CBaseObject* pFromObject); //! Attach new child node. diff --git a/Code/Editor/Objects/DisplayContext.h b/Code/Editor/Objects/DisplayContext.h index a78e35cdba..0f0f0e665a 100644 --- a/Code/Editor/Objects/DisplayContext.h +++ b/Code/Editor/Objects/DisplayContext.h @@ -18,6 +18,7 @@ #include "SandboxAPI.h" #include #include +#include #include diff --git a/Code/Editor/Objects/ObjectManager.cpp b/Code/Editor/Objects/ObjectManager.cpp index f8eebb1b19..9c452ac1ad 100644 --- a/Code/Editor/Objects/ObjectManager.cpp +++ b/Code/Editor/Objects/ObjectManager.cpp @@ -759,16 +759,16 @@ void CObjectManager::GetObjects(CBaseObjectsArray& objects) const } } -void CObjectManager::GetObjects(DynArray& 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(DynArray& 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 { diff --git a/Code/Editor/Objects/ObjectManager.h b/Code/Editor/Objects/ObjectManager.h index aa9faab0e4..a2e0822a2b 100644 --- a/Code/Editor/Objects/ObjectManager.h +++ b/Code/Editor/Objects/ObjectManager.h @@ -122,7 +122,7 @@ 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& objects) const; + //void GetObjects(DynArray& 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. diff --git a/Code/Editor/ToolsConfigPage.cpp b/Code/Editor/ToolsConfigPage.cpp index 50001dc2f0..509dca55e3 100644 --- a/Code/Editor/ToolsConfigPage.cpp +++ b/Code/Editor/ToolsConfigPage.cpp @@ -59,8 +59,8 @@ public: } const QString iconsDir = gSettings.searchPaths[EDITOR_PATH_UI_ICONS][0]; CFileUtil::ScanDirectory(iconsDir, "*.png", pngFiles); - m_iconImages.reserve(pngFiles.size()); - m_iconFiles.reserve(pngFiles.size()); + m_iconImages.reserve(static_cast(pngFiles.size())); + m_iconFiles.reserve(static_cast(pngFiles.size())); for (size_t i = 0; i < pngFiles.size(); ++i) { const QString path = Path::Make(iconsDir, pngFiles[i].filename); diff --git a/Code/Editor/Util/DynamicArray2D.cpp b/Code/Editor/Util/DynamicArray2D.cpp index 6ac3edbb6b..3f09c557de 100644 --- a/Code/Editor/Util/DynamicArray2D.cpp +++ b/Code/Editor/Util/DynamicArray2D.cpp @@ -62,11 +62,6 @@ CDynamicArray2D::~CDynamicArray2D() } -void CDynamicArray2D::GetMemoryUsage(ICrySizer* pSizer) -{ - pSizer->Add((char*)this, m_Dimension1 * m_Dimension2 * sizeof(float) + sizeof(*this)); -} - void CDynamicArray2D::ScaleImage(CDynamicArray2D* pDestination) { //////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/Util/DynamicArray2D.h b/Code/Editor/Util/DynamicArray2D.h index 80e40bfd22..20d26d2d87 100644 --- a/Code/Editor/Util/DynamicArray2D.h +++ b/Code/Editor/Util/DynamicArray2D.h @@ -24,8 +24,6 @@ public: virtual ~CDynamicArray2D(); // void ScaleImage(CDynamicArray2D* pDestination); - // - void GetMemoryUsage(ICrySizer* pSizer); float** m_Array; // diff --git a/Code/Editor/Util/GdiUtil.cpp b/Code/Editor/Util/GdiUtil.cpp index 1048b5f4dd..72e5e28605 100644 --- a/Code/Editor/Util/GdiUtil.cpp +++ b/Code/Editor/Util/GdiUtil.cpp @@ -28,7 +28,7 @@ QColor ScaleColor(const QColor& c, float aScale) const float g = static_cast(aColor.green()) * aScale; const float b = static_cast(aColor.blue()) * aScale; - return QColor(CLAMP(static_cast(r), 0, 255), CLAMP(static_cast(g), 0, 255), CLAMP(static_cast(b), 0, 255)); + return QColor(AZStd::clamp(static_cast(r), 0, 255), AZStd::clamp(static_cast(g), 0, 255), AZStd::clamp(static_cast(b), 0, 255)); } CAlphaBitmap::CAlphaBitmap() diff --git a/Code/Editor/Util/ImageHistogram.cpp b/Code/Editor/Util/ImageHistogram.cpp index acea2dc340..4cc9816065 100644 --- a/Code/Editor/Util/ImageHistogram.cpp +++ b/Code/Editor/Util/ImageHistogram.cpp @@ -105,7 +105,7 @@ void CImageHistogram::ComputeHistogram(BYTE* pImageData, UINT aWidth, UINT aHeig ++m_count[3][a]; lumIndex = (r + b + g) / 3; - lumIndex = CLAMP(lumIndex, 0, kNumColorLevels - 1); + lumIndex = AZStd::clamp(lumIndex, 0, kNumColorLevels - 1); ++m_lumCount[lumIndex]; if (m_maxCount[0] < m_count[0][r]) diff --git a/Code/Editor/Viewport.cpp b/Code/Editor/Viewport.cpp index 0ddad5c31e..92e193bddf 100644 --- a/Code/Editor/Viewport.cpp +++ b/Code/Editor/Viewport.cpp @@ -1491,7 +1491,7 @@ void QtViewport::OnRawInput([[maybe_unused]] UINT wParam, HRAWINPUT lParam) float as = 0.001f * gSettings.cameraMoveSpeed; Ang3 ypr = CCamera::CreateAnglesYPR(Matrix33(viewTM)); ypr.x += -all6DOFs[5] * as * fScaleYPR; - ypr.y = CLAMP(ypr.y + all6DOFs[3] * as * fScaleYPR, -1.5f, 1.5f); // to keep rotation in reasonable range + ypr.y = AZStd::clamp(ypr.y + all6DOFs[3] * as * fScaleYPR, -1.5f, 1.5f); // to keep rotation in reasonable range ypr.z = 0; // to have camera always upward viewTM = Matrix34(CCamera::CreateOrientationYPR(ypr), viewTM.GetTranslation()); diff --git a/Code/Editor/ViewportTitleDlg.cpp b/Code/Editor/ViewportTitleDlg.cpp index a6dee5382e..1f04f71712 100644 --- a/Code/Editor/ViewportTitleDlg.cpp +++ b/Code/Editor/ViewportTitleDlg.cpp @@ -19,9 +19,6 @@ #include -// CryCommon -#include - // Editor #include "Settings.h" #include "ViewPane.h" @@ -800,8 +797,8 @@ void CViewportTitleDlg::OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_ const int eventHeight = static_cast(lparam); const QWidget* viewport = m_pViewPane->GetViewport(); - // This should eventually be converted to an EBus to make it easy to connect to the correct viewport - // sending the event. But for now, just detect that we've gotten width/height values that match our + // This should eventually be converted to an EBus to make it easy to connect to the correct viewport + // sending the event. But for now, just detect that we've gotten width/height values that match our // associated viewport if (viewport && (eventWidth == viewport->width()) && (eventHeight == viewport->height())) { diff --git a/Code/LauncherUnified/Launcher.h b/Code/LauncherUnified/Launcher.h index 5ff6009e43..7c4c09c19f 100644 --- a/Code/LauncherUnified/Launcher.h +++ b/Code/LauncherUnified/Launcher.h @@ -10,7 +10,9 @@ #include // for AZ_COMMAND_LINE_LEN #include #include +#include #include +#include struct IOutputPrintSink; @@ -34,7 +36,7 @@ namespace O3DELauncher #define COMMAND_LINE_ARG_COUNT_LIMIT (AZ_COMMAND_LINE_LEN+1) / 2 // Assume that the limit to how many arguments we can maintain is the max buffer size divided by 2 // to account for an argument and a spec in between each argument (with the worse case scenario being - + struct PlatformMainInfo { typedef bool (*ResourceLimitUpdater)(); @@ -69,7 +71,7 @@ namespace O3DELauncher void* m_window = nullptr; //!< maps to \ref SSystemInitParams::hWnd void* m_instance = nullptr; //!< maps to \ref SSystemInitParams::hInstance - IOutputPrintSink* m_printSink = nullptr; //!< maps to \ref SSystemInitParams::pPrintSync + IOutputPrintSink* m_printSink = nullptr; //!< maps to \ref SSystemInitParams::pPrintSync }; enum class ReturnCode : unsigned char diff --git a/Code/Legacy/CryCommon/Common_TypeInfo.cpp b/Code/Legacy/CryCommon/Common_TypeInfo.cpp index 6a295c696f..ccb28cbc3d 100644 --- a/Code/Legacy/CryCommon/Common_TypeInfo.cpp +++ b/Code/Legacy/CryCommon/Common_TypeInfo.cpp @@ -7,150 +7,10 @@ */ -#include "TypeInfo_impl.h" #include "Cry_Geo.h" - -STRUCT_INFO_T_BEGIN(Vec2_tpl, class, F) -VAR_INFO(x) -VAR_INFO(y) -STRUCT_INFO_T_END(Vec2_tpl, class, F) - +#include "Cry_Color.h" #include "Cry_Vector3.h" -STRUCT_INFO_T_BEGIN(Vec3_tpl, typename, F) -VAR_INFO(x) -VAR_INFO(y) -VAR_INFO(z) -STRUCT_INFO_T_END(Vec3_tpl, typename, F) - -typedef TFixed TFixedUChar_1_255_0; -STRUCT_INFO_T_INSTANTIATE(Vec3_tpl, TFixedUChar_1_255_0) - -STRUCT_INFO_T_BEGIN(Vec4_tpl, typename, F) -VAR_INFO(x) -VAR_INFO(y) -VAR_INFO(z) -VAR_INFO(w) -STRUCT_INFO_T_END(Vec4_tpl, typename, F) - -STRUCT_INFO_T_INSTANTIATE(Vec4_tpl, short) - -STRUCT_INFO_T_BEGIN(Ang3_tpl, typename, F) -VAR_INFO(x) -VAR_INFO(y) -VAR_INFO(z) -STRUCT_INFO_T_END(Ang3_tpl, typename, F) - -STRUCT_INFO_T_BEGIN(Plane_tpl, typename, F) -VAR_INFO(n) -VAR_INFO(d) -STRUCT_INFO_T_END(Plane_tpl, typename, F) - -//----------------------------------------------------------------- -//#include "Cry_Quat_info.h" -STRUCT_INFO_T_BEGIN(Quat_tpl, typename, F) -VAR_INFO(v) -VAR_INFO(w) -STRUCT_INFO_T_END(Quat_tpl, typename, F) - -STRUCT_INFO_T_INSTANTIATE(Quat_tpl, float) - -STRUCT_INFO_T_BEGIN(QuatT_tpl, typename, F) -VAR_INFO(q) -VAR_INFO(t) -STRUCT_INFO_T_END(QuatT_tpl, typename, F) - -STRUCT_INFO_T_INSTANTIATE(QuatT_tpl, float) - -STRUCT_INFO_T_BEGIN(QuatTS_tpl, typename, F) -VAR_INFO(q) -VAR_INFO(t) -VAR_INFO(s) -STRUCT_INFO_T_END(QuatTS_tpl, typename, F) - -STRUCT_INFO_T_BEGIN(DualQuat_tpl, typename, F) -VAR_INFO(nq) -VAR_INFO(dq) -STRUCT_INFO_T_END(DualQuat_tpl, typename, F) - - -//------------------------------------------------------------ -//#include "Cry_Matrix_info.h" -STRUCT_INFO_T_BEGIN(Matrix33_tpl, typename, F) -VAR_INFO(m00) -VAR_INFO(m01) -VAR_INFO(m02) -VAR_INFO(m10) -VAR_INFO(m11) -VAR_INFO(m12) -VAR_INFO(m20) -VAR_INFO(m21) -VAR_INFO(m22) -STRUCT_INFO_T_END(Matrix33_tpl, typename, F) - -STRUCT_INFO_T_BEGIN(Matrix34_tpl, typename, F) -VAR_INFO(m00) -VAR_INFO(m01) -VAR_INFO(m02) -VAR_INFO(m03) -VAR_INFO(m10) -VAR_INFO(m11) -VAR_INFO(m12) -VAR_INFO(m13) -VAR_INFO(m20) -VAR_INFO(m21) -VAR_INFO(m22) -VAR_INFO(m23) -STRUCT_INFO_T_END(Matrix34_tpl, typename, F) - -STRUCT_INFO_T_INSTANTIATE(Matrix34_tpl, float) - -STRUCT_INFO_T_BEGIN(Matrix44_tpl, typename, F) -VAR_INFO(m00) -VAR_INFO(m01) -VAR_INFO(m02) -VAR_INFO(m03) -VAR_INFO(m10) -VAR_INFO(m11) -VAR_INFO(m12) -VAR_INFO(m13) -VAR_INFO(m20) -VAR_INFO(m21) -VAR_INFO(m22) -VAR_INFO(m23) -VAR_INFO(m30) -VAR_INFO(m31) -VAR_INFO(m32) -VAR_INFO(m33) -STRUCT_INFO_T_END(Matrix44_tpl, typename, F) - - -//#include "Cry_Color_info.h" -STRUCT_INFO_T_BEGIN(Color_tpl, class, T) -VAR_INFO(r) -VAR_INFO(g) -VAR_INFO(b) -VAR_INFO(a) -STRUCT_INFO_T_END(Color_tpl, class, T) - -STRUCT_INFO_T_INSTANTIATE(Color_tpl, unsigned char) - -//#include "Cry_Geo_info.h" -STRUCT_INFO_BEGIN(AABB) -VAR_INFO(min) -VAR_INFO(max) -STRUCT_INFO_END(AABB) - -STRUCT_INFO_BEGIN(RectF) -VAR_INFO(x) -VAR_INFO(y) -VAR_INFO(w) -VAR_INFO(h) -STRUCT_INFO_END(RectF) - -#include "TimeValue_info.h" -#include "CryHalf_info.h" - // Manually instantiate templates as needed here. template struct Vec3_tpl; template struct Vec4_tpl; diff --git a/Code/Legacy/CryCommon/CryArray.h b/Code/Legacy/CryCommon/CryArray.h deleted file mode 100644 index b4878ec25a..0000000000 --- a/Code/Legacy/CryCommon/CryArray.h +++ /dev/null @@ -1,1322 +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_CRYARRAY_H -#define CRYINCLUDE_CRYCOMMON_CRYARRAY_H -#pragma once - -#include -#include - -//--------------------------------------------------------------------------- -// Convenient iteration macros - -#define for_ptr(T, it, b, e) for (T* it = (b), * _e = (e); it != _e; ++it) -#define for_array_ptr(T, it, arr) for_ptr (T, it, (arr).begin(), (arr).end()) -#define for_array(i, arr) for (int i = 0, _e = (arr).size(); i < _e; i++) - -//--------------------------------------------------------------------------- -// Specify semantics for moving objects. -// If raw_movable() is true, objects will be moved with memmove(). -// If false, with the templated move_init() function. -template -bool raw_movable([[maybe_unused]] T const& dest) -{ - return false; -} - -// This container was written before C++11 and move semantics. As a result, it attempts -// to fake move semantics where possible by constructing over top of existing instances. -// This works great, unless the type being operated on has internal pointers to its own -// memory space (for instance a string with SSO, or COW semantics). -template -struct fake_move_helper -{ - static void move(T& dest, T& source) - { - ::new(&dest) T(source); - source.~T(); - } -}; - -// Generic move function: transfer an existing source object to uninitialized dest address. -// Addresses must not overlap (requirement on caller). -// May be specialized for specific types, to provide a more optimal move. -// For types that can be trivially moved (memcpy), do not specialize move_init, rather specialize raw_movable to return true. -template -void move_init(T& dest, T& source) -{ - assert(&dest != &source); - fake_move_helper::move(dest, source); -} - -/*--------------------------------------------------------------------------- -Public classes: - - Array - StaticArray - DynArray - StaticDynArray - -Support classes are placed in namespaces NArray and NAlloc to reduce global name usage. ----------------------------------------------------------------------------*/ - -namespace NArray -{ - // We should never have these defined as macros. - #undef min - #undef max - - // Define our own min/max here, to avoid including entire . - template - inline T min(T a, T b) - { return a < b ? a : b; } - template - inline T max(T a, T b) - { return a > b ? a : b; } - - // Automatic inference of signed from unsigned int type. - template - struct IntTraits - { - typedef T TSigned; - }; - - template<> - struct IntTraits - { - typedef int TSigned; - }; - template<> - struct IntTraits - { - typedef int64 TSigned; - }; -#if !defined(LINUX) && !defined(APPLE) - template<> - struct IntTraits - { - typedef long TSigned; - }; -#endif - - /*--------------------------------------------------------------------------- - // STORAGE prototype for Array. - struct Storage - { - template - struct Store - { - [const] T* begin() [const]; - I size() const; - }; - }; - ---------------------------------------------------------------------------*/ - - //--------------------------------------------------------------------------- - // ArrayStorage: Default STORAGE Array. - // Simply contains a pointer and count to an existing array, - // performs no allocation or deallocation. - - struct ArrayStorage - { - template - struct Store - { - // Construction. - Store() - : m_aElems(0) - , m_nCount(0) - {} - Store(T* elems, I count) - : m_aElems(elems) - , m_nCount(count) - {} - Store(T* start, T* finish) - : m_aElems(start) - , m_nCount(check_cast(finish - start)) - {} - - void set(T* elems, I count) - { - m_aElems = elems; - m_nCount = count; - } - - // Basic storage. - CONST_VAR_FUNCTION(T * begin(), - { return m_aElems; - }) - inline I size() const - { return m_nCount; } - - // Modifiers, alter range in place. - void erase_front(I count = 1) - { - assert(count >= 0 && count <= m_nCount); - m_nCount -= count; - m_aElems += count; - } - - void erase_back(I count = 1) - { - assert(count >= 0 && count <= m_nCount); - m_nCount -= count; - } - - void resize(I count) - { - assert(count >= 0 && count <= m_nCount); - m_nCount = count; - } - - protected: - T* m_aElems; - I m_nCount; - }; - }; - - //--------------------------------------------------------------------------- - // StaticArrayStorage: STORAGE scheme with a statically sized member array. - - template - struct StaticArrayStorage - { - template - struct Store - { - // Basic storage. - CONST_VAR_FUNCTION(T * begin(), - { return m_aElems; - }) - inline static I size() - { return (I)nSIZE; } - - protected: - T m_aElems[nSIZE]; - }; - }; -}; - -//--------------------------------------------------------------------------- -// Array: Non-growing array. -// S serves as base class, and implements storage scheme: begin(), size() - -template< class T, class I = int, class STORE = NArray::ArrayStorage > -struct Array - : STORE::template Store -{ - typedef typename STORE::template Store S; - - // Tedious redundancy. - using S::size; - using S::begin; - - // STL-compatible typedefs. - typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - - typedef T* iterator; - typedef const T* const_iterator; - - typedef I size_type; - typedef typename NArray::IntTraits::TSigned - difference_type; - - typedef Array array; - typedef Array const_array; - - // Construction. - Array() - {} - - // Forward single- and double-argument constructors. - template - explicit Array(const In& i) - : S(i) - {} - - template - Array(const In1& i1, const In2& i2) - : S(i1, i2) - {} - - // Accessors. - inline bool empty() const - { return size() == 0; } - inline size_type size_mem() const - { return size() * sizeof(T); } - - CONST_VAR_FUNCTION(T * data(), - { return begin(); - }) - - CONST_VAR_FUNCTION(T * end(), - { return begin() + size(); - }) - - CONST_VAR_FUNCTION(T * rbegin(), - { return begin() + size() - 1; - }) - - CONST_VAR_FUNCTION(T * rend(), - { return begin() - 1; - }) - - CONST_VAR_FUNCTION(T & front(), - { - assert(!empty()); - return *begin(); - }) - - CONST_VAR_FUNCTION(T & back(), - { - assert(!empty()); - return *rbegin(); - }) - - CONST_VAR_FUNCTION(T & at(size_type i), - { - CRY_ASSERT_TRACE(i >= 0 && i < size(), ("Index %lld is out of range (array size is %lld)", (long long int) i, (long long int) size())); - return begin()[i]; - }) - - CONST_VAR_FUNCTION(T & operator [](size_type i), - { - CRY_ASSERT_TRACE(i >= 0 && i < size(), ("Index %lld is out of range (array size is %lld)", (long long int) i, (long long int) size())); - return begin()[i]; - }) - - // Conversion to canonical array type. - operator array() - { return array(begin(), size()); } - operator const_array() const - { - return const_array(begin(), size()); - } - - // Additional conversion via operator() to full or sub array. - array operator ()(size_type i, size_type count) - { - assert(i >= 0 && i + count <= size()); - return array(begin() + i, count); - } - const_array operator ()(size_type i, size_type count) const - { - assert(i >= 0 && i + count <= size()); - return const_array(begin() + i, count); - } - - array operator ()(size_type i = 0) - { return (*this)(i, size() - i); } - const_array operator ()(size_type i = 0) const - { return (*this)(i, size() - i); } - - // Basic element assignment functions. - - // Copy values to existing elements. - void fill(const T& val) - { - for_array_ptr (T, it, *this) - * it = val; - } - - void copy(const_array source) - { - assert(source.size() >= size()); - const T* s = source.begin(); - for_array_ptr (T, it, *this) - * it = *s++; - } - - // Raw element construct/destruct functions. - iterator init() - { - for_array_ptr (T, it, *this) - new(it) T; - return begin(); - } - iterator init(const T& val) - { - for_array_ptr (T, it, *this) - new(it) T(val); - return begin(); - } - iterator init(const_array source) - { - assert(source.size() >= size()); - assert(source.end() <= begin() || source.begin() >= end()); - const_iterator s = source.begin(); - for_array_ptr (T, it, *this) - new(it) T(*s++); - return begin(); - } - - iterator move_init(array source) - { - assert(source.size() >= size()); - iterator s = source.begin(); - if (s != begin()) - { - if (raw_movable(*s)) - { - memmove(begin(), s, size_mem()); - } - else if (s > begin() || source.end() <= begin()) - { - for_array_ptr (T, it, *this) - ::move_init(*it, *s++); - } - else - { - s += size(); - for (iterator it = end(); it > begin(); ) - { - ::move_init(*--it, *--s); - } - } - } - return begin(); - } - - void destroy() - { - // Destroy in reverse order, to complement construction order. - for (iterator it = rbegin(); it > rend(); --it) - { - it->~T(); - } - } -}; - -// Type-inferring constructor. - -template -inline Array ArrayT(T* elems, I count) -{ - return Array(elems, count); -} - -template -inline Array ArrayT(T* start, T* finish) -{ - return Array(start, finish); -} - -// StaticArray -// A superior alternative to static C arrays. -// Provides standard STL-like Array interface, including bounds-checking. -// standard: Type array[256]; -// structured: StaticArray array; - -template -struct StaticArray - : Array< T, I, NArray::StaticArrayStorage > -{ -}; - -//--------------------------------------------------------------------------- -// Specify allocation for dynamic arrays - -namespace NAlloc -{ - // Multi-purpose allocation function prototype - // pMem = 0, nSize != 0: allocate new mem, nSize = actual amount alloced - // pMem != 0, nSize = 0: deallcate mem - // pMem != 0, nSize != 0: nSize = actual amount allocated - typedef void* (* Allocator)(void* pMem, size_t& nSize, size_t nAlign, bool bSlack); - - // - // Allocation utilities - // - - inline size_t realloc_size(size_t nMinSize) - { - // Choose an efficient realloc size, when growing an existing (non-zero) block. - // Find the next power-of-two, minus a bit of presumed system alloc overhead. - static const size_t nMinAlloc = 32; - static const size_t nOverhead = 16; - static const size_t nDoubleLimit = - sizeof(size_t) < 8 ? 1 << 12 // 32-bit system - : 1 << 16; // >= 64-bit system - - nMinSize += nOverhead; - size_t nAlloc = nMinAlloc; - while (nAlloc < nMinSize) - { - nAlloc <<= 1; - } - if (nAlloc > nDoubleLimit) - { - size_t nAlign = NArray::max(nAlloc >> 3, nDoubleLimit); - nAlloc = Align(nMinSize, nAlign); - } - return nAlloc - nOverhead; - } - - template - T* reallocate(A& allocator, T* old_elems, I old_size, I& new_size, size_t alignment = 1, bool allow_slack = false) - { - T* new_elems; - if (new_size) - { - size_t new_bytes = new_size * sizeof(T); - new_elems = (T*) allocator.alloc(0, new_bytes, alignment, allow_slack); - assert(IsAligned(new_elems, alignment)); - assert(new_bytes >= new_size * sizeof(T)); - new_size = check_cast(new_bytes / sizeof(T)); - } - else - { - new_elems = 0; - } - - if (old_elems) - { - Array old_elems_array(old_elems, old_size); - if (new_elems) - { - // Move elements. - ArrayT(new_elems, NArray::min(old_size, new_size)).move_init(old_elems_array); - } - - // Dealloc old. - old_elems_array.destroy(); // call destructors - size_t zero = 0; - allocator.alloc(old_elems, zero, alignment); - } - - return new_elems; - } - - template - inline size_t get_alloc_size(const A& allocator, const void* pMem, size_t nSize, size_t nAlign) - { - non_const(allocator).alloc((void*)pMem, nSize, nAlign); - return nSize; - } - - struct AllocFunction - { - Allocator m_Function; - - void* alloc(void* pMem, size_t& nSize, size_t nAlign, bool bSlack = false) - { - return m_Function(pMem, nSize, nAlign, bSlack); - } - }; - - // Adds prefix bytes to allocation, preserving alignment - template - struct AllocPrefix - : A - { - void* alloc(void* pMem, size_t& nSize, size_t nAlign, bool bSlack = false) - { - // Adjust pointer and size for prefix bytes - nAlign = NArray::max(nAlign, alignof(Prefix)); - size_t nPrefixSize = Align(sizeof(Prefix), nAlign); - - if (pMem) - { - pMem = (char*)pMem - nPrefixSize; - } - if (nSize) - { - nSize = Align(nSize, nSizeAlign); - nSize += nPrefixSize; - } - - pMem = A::alloc(pMem, nSize, nAlign, bSlack); - - if (nSize) - { - nSize -= nPrefixSize; - } - if (pMem) - { - pMem = (char*)pMem + nPrefixSize; - } - return pMem; - } - }; - - // Stores and retrieves allocator function in memory, for compatibility with diverse allocators - template - struct AllocCompatible - { - void* alloc(void* pMem, size_t& nSize, size_t nAlign, bool bSlack = false) - { - nAlign = NArray::max(nAlign, alignof(Allocator)); - if (pMem) - { - // Retrieve original allocation function, for dealloc or size query - AllocPrefix alloc_prefix; - alloc_prefix.m_Function = ((Allocator*)pMem)[-1]; - return alloc_prefix.alloc(pMem, nSize, nAlign, bSlack); - } - else if (nSize) - { - // Allocate new with this module's base_allocator, storing pointer to function - AllocPrefix alloc_prefix; - pMem = alloc_prefix.alloc(pMem, nSize, nAlign, bSlack); - if (pMem) - { - ((Allocator*)pMem)[-1] = &A::alloc; - } - } - return pMem; - } - }; - - //--------------------------------------------------------------------------- - // Allocators for DynArray. - - // Standard CryModule memory allocation, using aligned versions - struct ModuleAlloc - { - static void* alloc(void* pMem, size_t& nSize, size_t nAlign, bool bSlack = false) - { - if (pMem) - { - if (nSize) - { - // Return memory usage, adding presumed alignment padding - if (nAlign > sizeof(size_t)) - { - nSize += nAlign - sizeof(size_t); - } - } - else - { - // Dealloc - CryModuleMemalignFree(pMem); - } - } - else if (nSize) - { - // Alloc - if (bSlack) - { - nSize = realloc_size(nSize); - } - return CryModuleMemalign(nSize, nAlign); - } - return 0; - } - }; - - // Standard allocator for DynArray stores a compatibility pointer in the memory - typedef AllocCompatible StandardAlloc; -}; - -//--------------------------------------------------------------------------- -// Storage schemes for dynamic arrays -namespace NArray -{ - //--------------------------------------------------------------------------- - // SmallDynStorage: STORAGE scheme for DynArray. - // Array is just a single pointer, size and capacity information stored before the array data. - - template - struct SmallDynStorage - { - template - struct Store - : private A - { - struct Header - { - static const I nCAP_BIT = I(1) << (sizeof(I) * 8 - 1); - - ILINE char* data() const - { - assert(IsAligned(this, sizeof(I))); - return (char*)(this + 1); - } - ILINE bool is_null() const - { return m_nSizeCap == 0; } - ILINE I size() const - { return m_nSizeCap & ~nCAP_BIT; } - - I capacity() const - { - I aligned_bytes = static_cast(Align(size() * sizeof(T), sizeof(I))); - if (m_nSizeCap & nCAP_BIT) - { - // Capacity stored in word following data - return *(I*)(data() + aligned_bytes); - } - else - { - // Capacity - size < sizeof(I) - return aligned_bytes / sizeof(T); - } - } - - void set_sizes(I s, I c) - { - // Store size, and assert against overflow. - assert(s <= c); - m_nSizeCap = s; - I aligned_bytes = static_cast(Align(s * sizeof(T), sizeof(I))); - if (c * sizeof(T) >= aligned_bytes + sizeof(I)) - { - // Has extra capacity, more than word-alignment - m_nSizeCap |= nCAP_BIT; - *(I*)(data() + aligned_bytes) = c; - } - assert(size() == s); - assert(capacity() == c); - } - - protected: - I m_nSizeCap; // Store allocation size, with last bit indicating extra capacity. - - public: - - static T* null_header() - { - // m_aElems is never 0, for empty array points to a static empty header. - // Declare a big enough static var to account for alignment. - struct EmptyHeader - { - Header head; - char pad[alignof(T)]; - }; - static EmptyHeader s_EmptyHeader; - - // The actual header pointer can be anywhere in the struct, it's all initialized to 0. - static T* s_EmptyElems = (T*)Align(s_EmptyHeader.pad, alignof(T)); - - return s_EmptyElems; - } - }; - - // Construction. - Store() - { - set_null(); - } - - Store(const A& a) - : A(a) - { - set_null(); - } - - // Basic storage. - CONST_VAR_FUNCTION(T * begin(), - { return m_aElems; - }) - inline I size() const - { return header()->size(); } - inline I capacity() const - { return header()->capacity(); } - size_t get_alloc_size() const - { return is_null() ? 0 : NAlloc::get_alloc_size(allocator(), begin(), capacity() * sizeof(T), alignof(T)); } - - void resize_raw(I new_size, bool allow_slack = false) - { - I new_cap = capacity(); - if (allow_slack ? new_size > new_cap : new_size != new_cap) - { - new_cap = new_size; - m_aElems = NAlloc::reallocate(allocator(), header()->is_null() ? 0 : m_aElems, size(), new_cap, alignof(T), allow_slack); - if (!m_aElems) - { - set_null(); - return; - } - } - header()->set_sizes(new_size, new_cap); - } - - protected: - - T* m_aElems; - - CONST_VAR_FUNCTION(Header * header(), - { - assert(m_aElems); - return ((Header*)m_aElems) - 1; - }) - - void set_null() - { m_aElems = Header::null_header(); } - bool is_null() const - { return header()->is_null(); } - - typedef NAlloc::AllocPrefix AP; - - AP& allocator() - { - static_assert(sizeof(AP) == sizeof(A)); - return *(AP*)this; - } - const AP& allocator() const - { - return *(const AP*)this; - } - }; - }; - - //--------------------------------------------------------------------------- - // StaticDynStorage: STORAGE scheme with a statically sized member array. - - template - struct StaticDynStorage - { - template - struct Store - : ArrayStorage::Store - { - Store() - : ArrayStorage::Store((T*)Align(m_aData, alignof(T)), 0) {} - - static I capacity() - { return (I)nSIZE; } - static size_t get_alloc_size() - { return 0; } - - void resize_raw(I new_size, [[maybe_unused]] bool allow_slack = false) - { - // cannot realloc, just set size - assert(new_size >= 0 && new_size <= capacity()); - this->m_nCount = new_size; - } - - protected: - - char m_aData[nSIZE * sizeof(T) + alignof(T) - 1]; // Storage for elems, deferred construction - }; - }; -}; - -// Legacy base class of DynArray, only used for read-only access -#define DynArrayRef DynArray - -//--------------------------------------------------------------------------- -// DynArray: Extension of Array allowing dynamic allocation. -// S specifies storage scheme, as with Array, but adds resize(), capacity(), ... -// A specifies the actual memory allocation function: alloc() - -// NOTE: This version has been re-based on AZStd::vector for correctness and performance -// The original implementation has been retained as LegacyDynArray below, for the few -// cases where we must retain the old internal behavior -template< class T, class I = int, class STORE = NArray::SmallDynStorage<> > -struct DynArray - : public AZStd::vector -{ - typedef AZStd::vector vector_base; - using value_type = typename vector_base::value_type; - using size_type = I; - using iterator = typename vector_base::iterator; - using const_iterator = typename vector_base::const_iterator; - - using vector_base::begin; - using vector_base::end; - - DynArray() - : vector_base::vector() - { - } - - explicit DynArray(size_type numElements) - : vector_base::vector(numElements) - { - } - - DynArray(size_type numElements, const T& value) - : vector_base::vector(numElements, value) - { - } - - // Ignore any specialized allocators, they all pull from the LegacyAllocator now - // Because we mandate that all DynArrays use the StdLegacyAllocator, matching allocators - // isn't meaningful here, so it's factored out - // Note that the STORE/S& is ignored entirely, because we do not support sharing storage - // between 2 DynArrays anymore. LegacyDynArray can still do that, but this feature is no longer used - template >::value>> - explicit DynArray(const S&) - : vector_base::vector() - { - } - - size_type capacity() const - { - return static_cast(vector_base::capacity()); - } - - size_type size() const - { - return static_cast(vector_base::size()); - } - - size_type available() const - { - return capacity() - size(); - } - - size_type get_alloc_size() const - { - return capacity() * sizeof(T); - } - - // Grow array, return iterator to new raw elems. - iterator grow_raw(size_type count = 1, bool /*allow_slack*/ = true) - { - vector_base::resize(size() + count); - return end() - count; - } - - iterator grow(size_type count) - { - return grow_raw(count); - } - iterator grow(size_type count, const T& val) - { - vector_base::reserve(size() + count); - for (size_type idx = 0; idx < count; ++idx) - { - vector_base::push_back(val); - } - return end() - count; - } - - void shrink() - { - // Realloc memory to exact array size. - vector_base::shrink_to_fit(); - } - - void resize(size_type newSize) - { - vector_base::resize(newSize); - } - - void resize(size_type new_size, const T& val) - { - size_type s = size(); - if (new_size > s) - { - grow(new_size - s, val); - } - else - { - pop_back(s - new_size); - } - } - - void assign(const_iterator first, const_iterator last) - { - vector_base::assign(first, last); - } - - void assign(size_type n, const T& val) - { - clear(); - grow(n, val); - } - - iterator push_back() - { - return grow(1); - } - iterator push_back(const T& val) - { - vector_base::push_back(val); - return vector_base::end() - 1; - } - iterator push_back(const DynArray& other) - { - return insert(end(), other.begin(), other.end()); - } - - iterator insert_raw(iterator pos, size_type count = 1) - { - // Grow array, return iterator to inserted raw elems. - assert(pos >= begin() && pos <= end()); - vector_base::insert(pos, count, T()); - return pos; - } - - iterator insert(iterator it, const T& val) - { - vector_base::insert(it, 1, val); - return it; - } - iterator insert(iterator it, size_type count, const T& val) - { - vector_base::insert(it, count, val); - return it; - } - iterator insert(iterator it, const_iterator start, const_iterator finish) - { - vector_base::insert(it, start, finish); - return it; - } - - iterator insert(size_type pos) - { - return insert_raw(begin() + pos); - } - iterator insert(size_type pos, const T& val) - { - iterator it = insert_raw(begin() + pos); - *it = val; - return it; - } - - void pop_back(size_type count = 1, [[maybe_unused]] bool allow_slack = true) - { - // Destroy erased elems, change size without reallocing. - assert(count >= 0 && count <= size()); - for (size_type idx = 0; idx < count; ++idx) - { - vector_base::pop_back(); - } - } - - iterator erase(iterator pos) - { - return vector_base::erase(pos); - } - - iterator erase(iterator start, iterator finish) - { - AZ_Assert(start >= begin() && finish >= start && finish <= end(), "DynArray: Erasure range out of bounds"); - - // Copy over erased elems, destroy those at end. - iterator it = start, e = end(); - while (finish < e) - { - *it++ = *finish++; - } - pop_back(check_cast(finish - it)); - return it; - } - - iterator erase(size_type pos, size_type count = 1) - { - return erase(begin() + pos, begin() + pos + count); - } - - void clear() - { - vector_base::clear(); - vector_base::shrink_to_fit(); - } -}; - -//--------------------------------------------------------------------------- -// Original Cry DynArray -//--------------------------------------------------------------------------- -template< class T, class I = int, class STORE = NArray::SmallDynStorage<> > -struct LegacyDynArray - : Array< T, I, STORE > -{ - typedef LegacyDynArray self_type; - typedef Array super_type; - typedef typename STORE::template Store S; - - // Tedious redundancy for GCC. - using_type(super_type, size_type); - using_type(super_type, iterator); - using_type(super_type, const_iterator); - using_type(super_type, array); - using_type(super_type, const_array); - - using super_type::size; - using super_type::capacity; - using super_type::begin; - using super_type::end; - using super_type::at; - using super_type::copy; - using super_type::init; - using super_type::destroy; - - // - // Construction. - // - LegacyDynArray() - {} - - LegacyDynArray(size_type count) - { - grow(count); - } - LegacyDynArray(size_type count, const T& val) - { - grow(count, val); - } - -#if !defined(_DISALLOW_INITIALIZER_LISTS) - // Initializer-list - LegacyDynArray(std::initializer_list l) - { - push_back(Array(l.begin(), l.size())); - } -#endif - - // Copying from a generic array type. - LegacyDynArray(const_array a) - { - push_back(a); - } - self_type& operator =(const_array a) - { - if (a.begin() >= begin() && a.end() <= end()) - { - // Assigning from (partial) self; remove undesired elements. - erase((T*)a.end(), end()); - erase(begin(), (T*)a.begin()); - } - else - { - // Assert no overlap. - assert(a.end() <= begin() || a.begin() >= end()); - if (a.size() == size()) - { - // If same size, perform element copy. - copy(a); - } - else - { - // If different sizes, destroy then copy init elements. - pop_back(size()); - push_back(a); - } - } - return *this; - } - - // Copy init/assign. - inline LegacyDynArray(const self_type& a) - { - push_back(a()); - } - inline self_type& operator =(const self_type& a) - { - return *this = a(); - } - - // Init/assign from basic storage type. - inline LegacyDynArray(const S& a) - { - push_back(const_array(a.begin(), a.size())); - } - inline self_type& operator =(const S& a) - { - return *this = const_array(a.begin(), a.size()); - } - - inline ~LegacyDynArray() - { - destroy(); - S::resize_raw(0); - } - - void swap(self_type& a) - { - // Swap storage structures, no element copying - S temp = static_cast(*this); - static_cast(*this) = static_cast(a); - static_cast(a) = temp; - } - - inline size_type available() const - { - return capacity() - size(); - } - - // - // Allocation modifiers. - // - - void reserve(size_type count) - { - if (count > capacity()) - { - I s = size(); - S::resize_raw(count, false); - S::resize_raw(s, true); - } - } - - // Grow array, return iterator to new raw elems. - iterator grow_raw(size_type count = 1, bool allow_slack = true) - { - S::resize_raw(size() + count, allow_slack); - return end() - count; - } - Array append_raw(size_type count = 1, bool allow_slack = true) - { - return Array(grow_raw(count, allow_slack), count); - } - - iterator grow(size_type count) - { - return append_raw(count).init(); - } - iterator grow(size_type count, const T& val) - { - return append_raw(count).init(val); - } - - void shrink() - { - // Realloc memory to exact array size. - S::resize_raw(size()); - } - - void resize(size_type new_size) - { - size_type s = size(); - if (new_size > s) - { - append_raw(new_size - s, false).init(); - } - else - { - pop_back(s - new_size, false); - } - } - void resize(size_type new_size, const T& val) - { - size_type s = size(); - if (new_size > s) - { - append_raw(new_size - s, false).init(val); - } - else - { - pop_back(s - new_size, false); - } - } - - void assign(size_type n, const T& val) - { - resize(n); - fill(val); - } - - void assign(const_iterator start, const_iterator finish) - { - *this = const_array(start, finish); - } - - iterator push_back() - { - return grow(1); - } - iterator push_back(const T& val) - { - return grow(1, val); - } - iterator push_back(const_array a) - { - return append_raw(a.size(), false).init(a); - } - - array insert_raw(iterator pos, size_type count = 1) - { - // Grow array, return iterator to inserted raw elems. - assert(pos >= begin() && pos <= end()); - size_t i = pos - begin(); - append_raw(count); - (*this)(i + count).move_init((*this)(i)); - return (*this)(i, count); - } - - iterator insert(iterator it, const T& val) - { - return insert_raw(it, 1).init(val); - } - iterator insert(iterator it, size_type count, const T& val) - { - return insert_raw(it, count).init(val); - } - iterator insert(iterator it, const_iterator start, const_iterator finish) - { - return insert(it, const_array(start, finish)); - } - iterator insert(iterator it, const_array a) - { - return insert_raw(it, a.size()).init(a); - } - - iterator insert(size_type pos) - { - return insert_raw(&at(pos)).init(); - } - iterator insert(size_type pos, const T& val) - { - return insert_raw(&at(pos)).init(val); - } - iterator insert(size_type pos, const_array a) - { - return insert_raw(&at(pos), a.size()).init(a); - } - - void pop_back(size_type count = 1, bool allow_slack = true) - { - // Destroy erased elems, change size without reallocing. - assert(count >= 0 && count <= size()); - size_type new_size = size() - count; - (*this)(new_size).destroy(); - S::resize_raw(new_size, allow_slack); - } - - iterator erase(iterator start, iterator finish) - { - assert(start >= begin() && finish >= start && finish <= end()); - - // Copy over erased elems, destroy those at end. - iterator it = start, e = end(); - while (finish < e) - { - *it++ = *finish++; - } - pop_back(check_cast(finish - it)); - return it; - } - - iterator erase(iterator it) - { - return erase(it, it + 1); - } - - iterator erase(size_type pos, size_type count = 1) - { - return erase(begin() + pos, begin() + pos + count); - } - - void clear() - { - destroy(); - S::resize_raw(0); - } -}; - -template -struct StaticDynArray - : LegacyDynArray< T, I, NArray::StaticDynStorage > -{ -}; - - - - #include "CryPodArray.h" - - -#endif // CRYINCLUDE_CRYCOMMON_CRYARRAY_H diff --git a/Code/Legacy/CryCommon/CryCommon.cpp b/Code/Legacy/CryCommon/CryCommon.cpp deleted file mode 100644 index e2eb7c78a8..0000000000 --- a/Code/Legacy/CryCommon/CryCommon.cpp +++ /dev/null @@ -1,53 +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 - * - */ - - - -// This contains compiled code that is used by other projects in the solution. -// Because we don't want static DLL dependencies, the CryCommon project is not compiled into a library. -// Instead, this .cpp file is included in every project which needs it. -// But we also include it in the CryCommon project (disabled in the build), -// so that CryCommon can have the same editable settings as other projects. - -// Set this to 1 to get an output of some pre-defined compiler symbols. - -#if 0 - -#ifdef _WIN32 -#pragma message("_WIN32") -#endif -#ifdef _WIN64 -#pragma message("_WIN64") -#endif - -#ifdef _M_IX86 -#pragma message("_M_IX86") -#endif -#ifdef _M_PPC -#pragma message("_M_PPC") -#endif - -#ifdef _DEBUG -#pragma message("_DEBUG") -#endif - -#ifdef _DLL -#pragma message("_DLL") -#endif -#ifdef _USRDLL -#pragma message("_USRDLL") -#endif -#ifdef _MT -#pragma message("_MT") -#endif - -#endif - -#include - -#include "TypeInfo_impl.h" diff --git a/Code/Legacy/CryCommon/CryCustomTypes.h b/Code/Legacy/CryCommon/CryCustomTypes.h deleted file mode 100644 index 58a6bc9306..0000000000 --- a/Code/Legacy/CryCommon/CryCustomTypes.h +++ /dev/null @@ -1,1204 +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 : Derived CTypeInfos for structs, enums, etc. -// Compressed numerical types and associated TypeInfos - - -#ifndef CRYINCLUDE_CRYCOMMON_CRYCUSTOMTYPES_H -#define CRYINCLUDE_CRYCOMMON_CRYCUSTOMTYPES_H -#pragma once - -#include "CryTypeInfo.h" -#include -#include -#include -#include - -#define STATIC_CONST(T, name, val) \ - static inline T name() { static T t = val; return t; } - -#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof *(arr)) -#define ARRAY_VAR(arr) ArrayT(&(arr)[0], (int)ARRAY_COUNT(arr)) - -//--------------------------------------------------------------------------- -// String helper function. - -template -inline bool HasString(const T& val, FToString flags, const void* def_data = 0) -{ - if (flags.SkipDefault) - { - if (val == (def_data ? *(const T*)def_data : T())) - { - return false; - } - } - return true; -} - -float NumToFromString(float val, int digits, bool floating, char buffer[], int buf_size); - -template -AZStd::string NumToString(T val, int min_digits, int max_digits, bool floating) -{ - char buffer[64]; - float f(val); - for (int digits = min_digits; digits < max_digits; digits++) - { - if (T(NumToFromString(f, digits, floating, buffer, 64)) == val) - { - break; - } - } - return buffer; -} - -//--------------------------------------------------------------------------- -// TypeInfo for structs - -struct CStructInfo - : CTypeInfo -{ - CStructInfo(cstr name, size_t size, size_t align, Array vars = Array(), Array templates = Array()); - virtual bool IsType(CTypeInfo const& Info) const; - virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const; - virtual bool FromString(void* data, cstr str, FFromString flags = 0) const; - virtual bool ToValue(const void* data, void* value, const CTypeInfo& typeVal) const; - virtual bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const; - virtual bool ValueEqual(const void* data, const void* def_data) const; - virtual void SwapEndian(void* pData, size_t nCount, bool bWriting) const; - virtual void GetMemoryUsage(ICrySizer* pSizer, void const* data) const; - - virtual const CVarInfo* NextSubVar(const CVarInfo* pPrev, bool bRecurseBase = false) const; - virtual const CVarInfo* FindSubVar(cstr name) const; - - virtual CTypeInfo const* const* NextTemplateType(CTypeInfo const* const* pPrev) const - { - pPrev = pPrev ? pPrev + 1 : TemplateTypes.begin(); - return pPrev < TemplateTypes.end() ? pPrev : 0; - } - -protected: - Array Vars; - AZStd::fixed_string<16> EndianDesc; // Encodes instructions for endian swapping. - bool HasBitfields; - Array TemplateTypes; - - void MakeEndianDesc(); - size_t AddEndianDesc(cstr desc, size_t dim, size_t elem_size); - bool IsCompatibleType(CTypeInfo const& Info) const; -}; - -//--------------------------------------------------------------------------- -// Template TypeInfo for base types, using global To/FromString functions. - -template -struct TTypeInfo - : CTypeInfo -{ - TTypeInfo(cstr name) - : CTypeInfo(name, sizeof(T), alignof(T)) - {} - - virtual bool ToValue(const void* data, void* value, const CTypeInfo& typeVal) const - { - if (&typeVal == this) - { - return *(T*)value = *(const T*)data, true; - } - return false; - } - virtual bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const - { - if (&typeVal == this) - { - return *(T*)data = *(const T*)value, true; - } - return false; - } - - virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const - { - if (!HasString(*(const T*)data, flags, def_data)) - { - return AZStd::string(); - } - return ::ToString(*(const T*)data); - } - virtual bool FromString(void* data, cstr str, FFromString flags = 0) const - { - if (!*str) - { - if (!flags.SkipEmpty) - { - *(T*)data = T(); - } - return true; - } - return ::FromString(*(T*)data, str); - } - virtual bool ValueEqual(const void* data, const void* def_data = 0) const - { - return *(const T*)data == (def_data ? *(const T*)def_data : T()); - } - - virtual void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer, [[maybe_unused]] void const* data) const - {} -}; - -//--------------------------------------------------------------------------- -// Template TypeInfo for modified types (e.g. compressed, range-limited) - -template -struct TProxyTypeInfo - : CTypeInfo -{ - TProxyTypeInfo(cstr name) - : CTypeInfo(name, sizeof(S), alignof(S)) - {} - - virtual bool IsType(CTypeInfo const& Info) const - { return &Info == this || ValTypeInfo().IsType(Info); } - - virtual bool ToValue(const void* data, void* value, const CTypeInfo& typeVal) const - { - if (&typeVal == this) - { - *(S*)value = *(const S*)data; - return true; - } - T val = T(*(const S*)data); - return ValTypeInfo().ToValue(&val, value, typeVal); - } - virtual bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const - { - if (&typeVal == this) - { - *(S*)data = *(const S*)value; - return true; - } - T val; - if (ValTypeInfo().FromValue(&val, value, typeVal)) - { - *(S*)data = S(val); - return true; - } - return false; - } - - virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const - { - T val = T(*(const S*)data); - T def_val = def_data ? T(*(const S*)def_data) : T(); - return ValTypeInfo().ToString(&val, flags, &def_val); - } - virtual bool FromString(void* data, cstr str, FFromString flags = 0) const - { - T val; - if (!*str) - { - if (!flags.SkipEmpty) - { - *(S*)data = S(); - } - return true; - } - if (!TypeInfo(&val).FromString(&val, str)) - { - return false; - } - *(S*)data = S(val); - return true; - } - - // Forward additional TypeInfo functions. - virtual bool GetLimit(ENumericLimit eLimit, float& fVal) const - { return ValTypeInfo().GetLimit(eLimit, fVal); } - virtual cstr EnumElem(uint nIndex) const - { return ValTypeInfo().EnumElem(nIndex); } - -protected: - - static const CTypeInfo& ValTypeInfo() - { return TypeInfo((T*)0); } -}; - -//--------------------------------------------------------------------------- -// Customisation for string. - -template<> -inline AZStd::string TTypeInfo::ToString(const void* data, FToString flags, const void* def_data) const -{ - const AZStd::string& val = *(const AZStd::string*)data; - if (def_data && flags.SkipDefault) - { - if (val == *(const AZStd::string*)def_data) - { - return AZStd::string(); - } - } - return val; -} - -template<> -inline bool TTypeInfo::FromString(void* data, cstr str, FFromString flags) const -{ - if (!*str && flags.SkipEmpty) - { - return true; - } - *(AZStd::string*)data = str; - return true; -} - -template<> -void TTypeInfo::GetMemoryUsage(ICrySizer* pSizer, void const* data) const; - -//--------------------------------------------------------------------------- -// -// TypeInfo for small integer types. - - -template -struct TIntTraits -{ - static const bool bSIGNED - = T(-1) < T(0); - - static const T nMIN_FACTOR - = bSIGNED ? T(-1) : T(0); - - static const size_t nPOS_BITS - = sizeof(T) * 8 - bSIGNED; - - static const T nMIN = std::numeric_limits::min(); - - static const T nMAX = std::numeric_limits::max(); -}; - -template -struct TIntType -{}; - -template<> -struct TIntType<1> -{ - typedef int8 TType; -}; -template<> -struct TIntType<2> -{ - typedef int16 TType; -}; -template<> -struct TIntType<4> -{ - typedef int32 TType; -}; -template<> -struct TIntType<8> -{ - typedef int64 TType; -}; - -template -inline bool ConvertInt(D& dest, S src) -{ - if constexpr (TIntTraits::nPOS_BITS < TIntTraits::nPOS_BITS) - { - src = clamp_tpl(src, S(TIntTraits::nMIN), S(TIntTraits::nMAX)); - } - else if constexpr (TIntTraits::bSIGNED < TIntTraits::bSIGNED) - { - src = max(src, S(0)); - } - - dest = D(src); - assert(S(dest) == src); - return true; -} - -template -inline bool ConvertInt(D& dest, const void* src, const CTypeInfo& typeSrc) -{ - if (typeSrc.IsType()) - { - switch (typeSrc.Size) - { - case 1: - return ConvertInt(dest, *(const int8*)src); - case 2: - return ConvertInt(dest, *(const int16*)src); - case 4: - return ConvertInt(dest, *(const int32*)src); - case 8: - return ConvertInt(dest, *(const int64*)src); - } - } - else if (typeSrc.IsType()) - { - switch (typeSrc.Size) - { - case 1: - return ConvertInt(dest, *(const uint8*)src); - case 2: - return ConvertInt(dest, *(const uint16*)src); - case 4: - return ConvertInt(dest, *(const uint32*)src); - case 8: - return ConvertInt(dest, *(const uint64*)src); - } - } - return false; -} - -template -inline bool ConvertInt(void* dest, const CTypeInfo& typeDest, S src) -{ - if (typeDest.IsType()) - { - switch (typeDest.Size) - { - case 1: - return ConvertInt(*(int8*)dest, src); - case 2: - return ConvertInt(*(int16*)dest, src); - case 4: - return ConvertInt(*(int32*)dest, src); - case 8: - return ConvertInt(*(int64*)dest, src); - } - } - else if (typeDest.IsType()) - { - switch (typeDest.Size) - { - case 1: - return ConvertInt(*(uint8*)dest, src); - case 2: - return ConvertInt(*(uint16*)dest, src); - case 4: - return ConvertInt(*(uint32*)dest, src); - case 8: - return ConvertInt(*(uint64*)dest, src); - } - } - return false; -} - -template -struct TIntTypeInfo - : TTypeInfo -{ - TIntTypeInfo(cstr name) - : TTypeInfo(name) - {} - - virtual bool IsType(CTypeInfo const& Info) const - { return &Info == this || &Info == (TIntTraits::bSIGNED ? &TypeInfo((int*)0) : &TypeInfo((uint*)0)); } - - virtual bool GetLimit(ENumericLimit eLimit, float& fVal) const - { - if (eLimit == eLimit_Min) - { - return fVal = float(TIntTraits::nMIN), true; - } - if (eLimit == eLimit_Max) - { - return fVal = float(TIntTraits::nMAX), true; - } - if (eLimit == eLimit_Step) - { - return fVal = 1.f, true; - } - return false; - } - - // Override to allow int conversion - virtual bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const - { return ConvertInt(*(T*)data, value, typeVal); } - virtual bool ToValue(const void* data, void* value, const CTypeInfo& typeVal) const - { return ConvertInt(value, typeVal, *(const T*)data); } -}; - -//--------------------------------------------------------------------------- -// Store any type, such as an enum, in a small int. - -template -struct TRangedType -{ - typedef TRangedType TThis; - - TRangedType(T init = T(nDEFAULT)) - : m_Val(init) - { - CheckRange(m_Val); - } - - operator T() const - { - return m_Val; - } - - CUSTOM_STRUCT_INFO(CCustomInfo) - -protected: - T m_Val; - - static bool HasMin() - { return nMIN > INT_MIN; } - static bool HasMax() - { return nMAX < INT_MAX; } - - static bool CheckRange(T& val) - { - if (HasMin() && val < T(nMIN)) - { - val = T(nMIN); - return false; - } - else if (HasMax() && val > T(nMAX)) - { - val = T(nMAX); - return false; - } - return true; - } - - // Adaptor TypeInfo for specifying limits, and implementing range checking - struct CCustomInfo - : TProxyTypeInfo - { - CCustomInfo() - : TProxyTypeInfo(::TypeInfo((T*) 0).Name) - {} - - virtual bool GetLimit(ENumericLimit eLimit, float& fVal) const - { - if (eLimit == eLimit_Min && HasMin()) - { - return fVal = T(nMIN), true; - } - if (eLimit == eLimit_Max && HasMax()) - { - return fVal = T(nMAX), true; - } - return ::TypeInfo((T*)0).GetLimit(eLimit, fVal); - } - }; -}; - -//--------------------------------------------------------------------------- -// Store any type, such as an enum, in a small int. - -template -struct TSmall -{ - typedef TSmall TThis; - typedef T TValue; - - inline TSmall(T val = T(nDefault)) - { - set(val); - } - void set(T val = T(nDefault)) - { - m_Val = S(val) - S(nOffset); - - // The unary operator+() forces integer promotion to happen and thus - // induces a call to operator T(), which allows the equality operator to work. - assert(+(*this) == val); - } - - inline operator T() const - { return T(T(m_Val) + nOffset); } - inline T operator +() const - { return T(T(m_Val) + nOffset); } - - CUSTOM_STRUCT_INFO(CCustomInfo) - -protected: - S m_Val; - - struct CCustomInfo - : TProxyTypeInfo - { - CCustomInfo() - : TProxyTypeInfo("TSmall<>") - {} - - virtual bool GetLimit(ENumericLimit eLimit, float& fVal) const - { - if (eLimit == eLimit_Min) - { - return fVal = float(TIntTraits::nMIN + nOffset), true; - } - if (eLimit == eLimit_Max) - { - return fVal = float(TIntTraits::nMAX + nOffset), true; - } - if (eLimit == eLimit_Step) - { - return fVal = 1.f, true; - } - return false; - } - }; -}; - -//--------------------------------------------------------------------------- -// Quantise a float linearly in an int. -template::nMAX, bool bTRUNC = false> -struct TFixed -{ - typedef float TValue; - - inline TFixed() - : m_Store(0) - {} - - inline TFixed(float fIn) - { - float fStore = ToStore(fIn); - fStore = clamp_tpl(fStore, float(TIntTraits::nMIN_FACTOR * nQUANT), float(nQUANT)); - m_Store = bTRUNC ? S(fStore) : fStore < 0.f ? S(fStore - 0.5f) : S(fStore + 0.5f); - } - - // Conversion. - inline operator float() const - { return FromStore(m_Store); } - inline float operator +() const - { return FromStore(m_Store); } - inline bool operator !() const - { return !m_Store; } - - inline bool operator ==(const TFixed& x) const - { return m_Store == x.m_Store; } - inline bool operator ==(float x) const - { return m_Store == TFixed(x); } - inline S GetStore() const - { return m_Store; } - - static S GetMaxStore() - { return nQUANT; } - static float GetMaxValue() - { return float(nLIMIT); } - - CUSTOM_STRUCT_INFO(CCustomInfo) - -protected: - S m_Store; - - typedef TFixed TThis; - - static const int nMAX = nLIMIT; - static const int nMIN = TIntTraits::nMIN_FACTOR * nLIMIT; - - static inline float ToStore(float f) - { return f * float(nQUANT) / float(nLIMIT); } - static inline float FromStore(float f) - { return f * float(nLIMIT) / float(nQUANT); } - - // TypeInfo implementation. - struct CCustomInfo - : TProxyTypeInfo - { - CCustomInfo() - : TProxyTypeInfo("TFixed<>") - {} - - virtual bool GetLimit(ENumericLimit eLimit, float& fVal) const - { - if (eLimit == eLimit_Min) - { - return fVal = float(nMIN), true; - } - if (eLimit == eLimit_Max) - { - return fVal = float(nMAX), true; - } - if (eLimit == eLimit_Step) - { - return fVal = FromStore(1.f), true; - } - return false; - } - - // Override ToString: Limit to significant digits. - virtual AZStd::string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const - { - if (!HasString(*(const S*)data, flags, def_data)) - { - return AZStd::string(); - } - static int digits = int_ceil(log10f(float(nQUANT))); - return NumToString(*(const TFixed*)data, 1, digits + 3, true); - } - }; -}; - - -// Define the canonical float-to-byte quantisation. -typedef TFixed UnitFloat8; - -#ifdef COMPRESSED_FLOATS - -//--------------------------------------------------------------------------- -// A floating point number, with templated storage size (and sign), and number of exponent bits -template -struct TFloat -{ - typedef float TValue; - - ILINE TFloat() - : m_Store(0) - {} - - ILINE TFloat(float fIn) - : m_Store(FromFloat(fIn)) - {} - - ILINE operator float() const - { return ToFloat(m_Store); } - ILINE float operator +() const - { return ToFloat(m_Store); } - - ILINE bool operator !() const - { return !m_Store; } - - ILINE bool operator ==(TFloat x) const - { return m_Store == x.m_Store; } - ILINE bool operator ==(float x) const - { return float(*this) == x; } - - inline TFloat& operator *=(float x) - { return *this = *this * x; } - - ILINE uint32 partial_float_conversion() const - { return (0 == m_Store) ? 0 : ToFloatCore(m_Store); } - - STATIC_CONST(float, fMAX, ToFloat(TIntTraits::nMAX)); - STATIC_CONST(float, fPOS_MIN, ToFloat(1 << nMANT_BITS)); - STATIC_CONST(float, fMIN, -fMAX() * (float)TIntTraits::bSIGNED); - - CUSTOM_STRUCT_INFO(CCustomInfo) - -protected: - S m_Store; - - typedef TFloat TThis; - - static const S nBITS = sizeof(S) * 8; - static const S nSIGN = TIntTraits::bSIGNED; - static const S nMANT_BITS = nBITS - nEXP_BITS - nSIGN; - static const S nSIGN_MASK = S(nSIGN << (nBITS - 1)); - static const S nMANT_MASK = (S(1) << nMANT_BITS) - 1; - static const S nEXP_MASK = ~S(nMANT_MASK | nSIGN_MASK); - static const int nEXP_MAX = 1 << (nEXP_BITS - 1), - nEXP_MIN = 1 - nEXP_MAX; - - STATIC_CONST(float, fROUNDER, 1.f + fPOS_MIN() * 0.5f); - - static inline S FromFloat(float fIn) - { - static_assert(sizeof(S) <= 4); - static_assert(nEXP_BITS > 0 && nEXP_BITS <= 8 && nEXP_BITS < sizeof(S) * 8 - 4); - - // Clamp to allowed range. - float fClamped = clamp_tpl(fIn * fROUNDER(), fMIN(), fMAX()); - - // Bit shift to convert from IEEE float32. - uint32 uBits = *(const uint32*)&fClamped; - - // Convert exp. - int32 iExp = (uBits >> 23) & 0xFF; - iExp -= 127 + nEXP_MIN; - IF (iExp < 0, 0) - { - // Underflow. - return 0; - } - - // Reduce mantissa. - uint32 uMant = uBits >> (23 - nMANT_BITS); - - S bits = (uMant & nMANT_MASK) - | (iExp << nMANT_BITS) - | ((uBits >> (32 - nBITS)) & nSIGN_MASK); - - #ifdef _DEBUG - fIn = clamp_tpl(fIn, fMIN(), fMAX()); - float fErr = fabs(ToFloat(bits) - fIn); - float fMaxErr = fabs(fIn) / float(1 << nMANT_BITS); - assert(fErr <= fMaxErr); - #endif - - return bits; - } - - static inline uint32 ToFloatCore(S bits) - { - // Extract FP components. - uint32 uBits = bits & nMANT_MASK, - uExp = (bits & ~nSIGN_MASK) >> nMANT_BITS, - uSign = bits & nSIGN_MASK; - - // Shift to 32-bit. - uBits <<= 23 - nMANT_BITS; - uBits |= (uExp + 127 + nEXP_MIN) << 23; - uBits |= uSign << (32 - nBITS); - - return uBits; - } - - static ILINE float ToFloat(S bits) - { - IF (bits == 0, 0) - { - return 0.f; - } - - uint32 uBits = ToFloatCore(bits); - return *(float*)&uBits; - } - - // TypeInfo implementation. - struct CCustomInfo - : TProxyTypeInfo - { - CCustomInfo() - : TProxyTypeInfo("TFloat<>") - {} - - virtual bool GetLimit(ENumericLimit eLimit, float& fVal) const - { - if (eLimit == eLimit_Min) - { - return fVal = fMIN(), true; - } - if (eLimit == eLimit_Max) - { - return fVal = fMAX(), true; - } - if (eLimit == eLimit_Step) - { - return fVal = fPOS_MIN(), true; - } - return false; - } - - // Override ToString: Limit to significant digits. - virtual string ToString(const void* data, FToString flags = 0, const void* def_data = 0) const - { - if (!HasString(*(const S*)data, flags, def_data)) - { - return string(); - } - static int digits = int_ceil(log10f(1 << nMANT_BITS)); - return NumToString(*(const TFloat*)data, 1, digits + 3, true); - } - }; -}; - -// Canonical float16 types, with range ~= 64K. -typedef TFloat SFloat16; -typedef TFloat UFloat16; - -template -ILINE T partial_float_cast(const SFloat16& s) { return static_cast(s.partial_float_conversion()); } - -template -ILINE T partial_float_cast(const UFloat16& u) { return static_cast(u.partial_float_conversion()); } - -#ifdef _DEBUG - -// Classes for unit tests. -template -void TestValues(T val) -{ - T2 val2 = val; - T2 val2c; - - bool b = TypeInfo(&val2c).FromValue(&val2c, val); - assert(b); - assert(val2 == val2c); - b = TypeInfo(&val2c).ToValue(&val2c, val); - assert(b); - assert(val2 == T2(val)); -} - -template -void TestTypes(T val) -{ - T2 val2 = val; - string s = TypeInfo(&val2).ToString(&val2); - bool b = TypeInfo(&val).FromString(&val, s); - assert(b); - assert(val2 == T2(val)); - - TestValues(val); -} - -template -void TestType(T val) -{ - TestTypes(val); -} - -#endif // _DEBUG - -#endif // COMPRESSED_FLOATS - -//--------------------------------------------------------------------------- -// TypeInfo for enums - -//--------------------------------------------------------------------------- -// Implement data features based on enum definition -/* - interface EnumDef - { - typedef TInt; - uint Count(); - TInt Value(uint i); - cstr Name(uint i); - bool MatchName(uint i, cstr str); - cstr ToName(TInt value); - } const -*/ - -template -struct TEnumInfo - : TIntTypeInfo - , TEnumDef -{ - TEnumInfo(cstr name) - : TIntTypeInfo(name) {} - - virtual cstr EnumElem(uint nIndex) const - { - if (nIndex < TEnumDef::Count()) - { - cstr name = TEnumDef::Name(nIndex); - if (*name != '_') - { - return name; - } - } - return 0; - } - - virtual bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const - { - TInt val; - if (ConvertInt(val, value, typeVal)) - { - if (TEnumDef::ToName(val)) - { - return *(TInt*)data = val, true; - } - } - return false; - } - - virtual AZStd::string ToString(const void* data, FToString flags, const void* def_data) const - { - TInt val = *(const TInt*)(data); - if (flags.SkipDefault && val == (def_data ? *(const TInt*)def_data : TInt(0))) - { - return AZStd::string(); - } - - if (cstr sName = TEnumDef::ToName(val)) - { - return sName; - } - - // Unmatched value, return as number. - return ::ToString(val); - } - - virtual bool FromString(void* data, cstr str, FFromString flags) const - { - if (!*str) - { - if (!flags.SkipEmpty) - { - *(TInt*)data = (TInt)0; - } - return true; - } - - for (int i = 0, count = TEnumDef::Count(); i < count; i++) - { - if (TEnumDef::MatchName(i, str)) - { - return *(TInt*)data = check_cast(TEnumDef::Value(i)), true; - } - } - - // No match, attempt numeric or bool conversion. - if (::FromString(*(TInt*)data, str)) - { - return true; - } - - bool b; - if (::FromString(b, str)) - { - return *(TInt*)data = b, true; - } - - return false; - } -}; - -//--------------------------------------------------------------------------- -// TypeInfo for regular enums - -struct CSimpleEnumDef -{ - void Init(Array names, char* enum_str); - - // TEnumDef implementations - ILINE uint Count() const - { return asNames.size(); } - ILINE static uint Value(uint i) - { return i; } - ILINE cstr Name(uint i) const - { return asNames[i]; } - ILINE bool MatchName(uint i, cstr str) const - { - cstr name = asNames[i]; - if (*name == '_') - { - name++; - } - return azstricmp(name, str) == 0; - } - ILINE cstr ToName(uint value) const - { - if (value < Count()) - { - return asNames[value]; - } - return 0; - } - -protected: - - Array asNames; -}; - -struct CSimpleEnumInfo - : TEnumInfo -{ - CSimpleEnumInfo(cstr name, Array names, char* enum_str) - : TEnumInfo(name) - { - Init(names, enum_str); - } -}; - -// Define a regular small enum with TypeInfo - -#define DEFINE_ENUM_VALUE(EType, E, TInt) \ - TInt Value; \ - ILINE EType(E val = E(0)) \ - : Value(aznumeric_caster(val)) {} \ - ILINE operator E() const { return E(Value); } \ - ILINE E operator +() const { return E(Value); } \ - -#define DEFINE_ENUM(EType, ...) \ - struct EType \ - { \ - enum E { __VA_ARGS__, _count }; \ - typedef uint8 TInt; \ - DEFINE_ENUM_VALUE(EType, E, TInt) \ - ILINE static uint Count() { return _count; } \ - static const CSimpleEnumInfo& TypeInfo() { \ - static cstr names[_count]; \ - static char enum_str[] = #__VA_ARGS__; \ - static CSimpleEnumInfo info( #EType, Array(&names[0], _count), enum_str); \ - return info; \ - } \ - }; - -//--------------------------------------------------------------------------- -// TypeInfo for irregular enums - -struct CEnumDef -{ - typedef int64 TValue; - - struct SElem - { - TValue Value; - cstr Name; - }; - - void Init(Array elems, char* enum_str = 0); - - // TEnumDef implementations - ILINE uint Count() const - { return Elems.size(); } - ILINE TValue Value(uint i) const - { return Elems[i].Value; } - ILINE cstr Name(uint i) const - { return *Elems[i].Name ? Elems[i].Name + nPrefixLength : ""; } - bool MatchName(uint i, cstr str) const; - cstr ToName(TValue val) const; - - struct SInit - { - static LegacyDynArray* s_pElems; - - static void Init(LegacyDynArray& elems) - { - s_pElems = &elems; - } - SInit() - { - TValue val = s_pElems->empty() ? 0 : s_pElems->back().Value + 1; - s_pElems->push_back()->Value = val; - } - SInit(TValue val) - { - s_pElems->push_back()->Value = val; - } - }; - -protected: - - Array Elems; - TValue MinValue; - bool bRegular; - uint nPrefixLength; -}; - -template -struct CEnumInfo - : TEnumInfo -{ - CEnumInfo(cstr name, Array elems, char* enum_str = 0) - : TEnumInfo(name) - { - CEnumDef::Init(elems, enum_str); - } -}; - -struct CEnumDefUuid - : public TTypeInfo -{ - struct SElem - { - AZ::Uuid Value; - cstr Name; - }; - - CEnumDefUuid(cstr name, Array elems, char* enum_str = 0) - : TTypeInfo(name) - { - CEnumDefUuid::Init(elems, enum_str); - } - void Init(Array elems, char* enum_str = 0); - - // TEnumDef implementations - ILINE uint Count() const - { - return Elems.size(); - } - ILINE AZ::Uuid Value(uint i) const - { - return Elems[i].Value; - } - ILINE cstr Name(uint i) const - { - return *Elems[i].Name ? Elems[i].Name + nPrefixLength : ""; - } - bool MatchName(uint i, cstr str) const; - cstr ToName(AZ::Uuid val) const; - - cstr EnumElem(uint nIndex) const override - { - if (nIndex < Count()) - { - cstr name = Name(nIndex); - if (*name != '_') - { - return name; - } - } - return 0; - } - - bool FromValue(void* data, const void* value, const CTypeInfo& typeVal) const override - { - if (&typeVal == this) - { - const AZ::Uuid& valueUuid = *reinterpret_cast(value); - if (ToName(valueUuid)) - { - AZ::Uuid& dataUuid = *reinterpret_cast(data); - dataUuid = valueUuid; - return true; - } - } - return false; - } - - AZStd::string ToString(const void* data, FToString flags, const void* def_data) const override - { - const AZ::Uuid& uuidData = *reinterpret_cast(data); - const AZ::Uuid& defUuidData = *reinterpret_cast(def_data); - if (flags.SkipDefault && uuidData == (def_data ? defUuidData : AZ::Uuid::CreateNull())) - { - return AZStd::string(); - } - - if (cstr sName = ToName(uuidData)) - { - return sName; - } - - return AZStd::string(); - } - - bool FromString(void* data, cstr str, FFromString flags) const override - { - AZ::Uuid& uuidData = *reinterpret_cast(data); - if (!*str) - { - if (!flags.SkipEmpty) - { - uuidData = AZ::Uuid::CreateNull(); - } - return true; - } - - for (int i = 0, count = Count(); i < count; i++) - { - if (MatchName(i, str)) - { - uuidData = Value(i); - return true; - } - } - - return false; - } - -protected: - - Array Elems; - bool bRegular; - uint nPrefixLength; -}; - -#endif // CRYINCLUDE_CRYCOMMON_CRYCUSTOMTYPES_H diff --git a/Code/Legacy/CryCommon/CryHalf.inl b/Code/Legacy/CryCommon/CryHalf.inl index b0d322f418..a9683540e1 100644 --- a/Code/Legacy/CryCommon/CryHalf.inl +++ b/Code/Legacy/CryCommon/CryHalf.inl @@ -141,7 +141,6 @@ struct CryHalf2 void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {} - AUTO_STRUCT_INFO }; struct CryHalf4 @@ -197,7 +196,6 @@ struct CryHalf4 void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {} - AUTO_STRUCT_INFO }; #endif // #ifndef CRY_HALF_INL diff --git a/Code/Legacy/CryCommon/CryHalf_info.h b/Code/Legacy/CryCommon/CryHalf_info.h deleted file mode 100644 index 8e4105f8b2..0000000000 --- a/Code/Legacy/CryCommon/CryHalf_info.h +++ /dev/null @@ -1,28 +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_CRYHALF_INFO_H -#define CRYINCLUDE_CRYCOMMON_CRYHALF_INFO_H -#pragma once - -#include "CryHalf.inl" - -STRUCT_INFO_BEGIN(CryHalf2) -STRUCT_VAR_INFO(x, TYPE_INFO(CryHalf)) -STRUCT_VAR_INFO(y, TYPE_INFO(CryHalf)) -STRUCT_INFO_END(CryHalf2) - -STRUCT_INFO_BEGIN(CryHalf4) -STRUCT_VAR_INFO(x, TYPE_INFO(CryHalf)) -STRUCT_VAR_INFO(y, TYPE_INFO(CryHalf)) -STRUCT_VAR_INFO(z, TYPE_INFO(CryHalf)) -STRUCT_VAR_INFO(w, TYPE_INFO(CryHalf)) -STRUCT_INFO_END(CryHalf4) - -#endif // CRYINCLUDE_CRYCOMMON_CRYHALF_INFO_H diff --git a/Code/Legacy/CryCommon/CryHeaders.h b/Code/Legacy/CryCommon/CryHeaders.h deleted file mode 100644 index 49ea28ee0e..0000000000 --- a/Code/Legacy/CryCommon/CryHeaders.h +++ /dev/null @@ -1,1506 +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_CRYHEADERS_H -#define CRYINCLUDE_CRYCOMMON_CRYHEADERS_H -#pragma once - - -#include "BaseTypes.h" -#include "Cry_Math.h" - -#ifdef MAX_SUB_MATERIALS -// This checks that the values are in sync in the different files. -static_assert(MAX_SUB_MATERIALS == 128); -#else - #define MAX_SUB_MATERIALS 128 -#endif - -#include "CryEndian.h" - -// Chunk type must fit into uint16 -enum ChunkTypes -{ - ChunkType_ANY = 0, - - ChunkType_Mesh = 0x1000, // was 0xCCCC0000 in chunk files with versions <= 0x745 - ChunkType_Helper, - ChunkType_VertAnim, - ChunkType_BoneAnim, - ChunkType_GeomNameList, // obsolete - ChunkType_BoneNameList, - ChunkType_MtlList, // obsolete - ChunkType_MRM, // obsolete - ChunkType_SceneProps, // obsolete - ChunkType_Light, // obsolete - ChunkType_PatchMesh, // not implemented - ChunkType_Node, - ChunkType_Mtl, // obsolete - ChunkType_Controller, - ChunkType_Timing, - ChunkType_BoneMesh, - ChunkType_BoneLightBinding, // obsolete. describes the lights binded to bones - ChunkType_MeshMorphTarget, // describes a morph target of a mesh chunk - ChunkType_BoneInitialPos, // describes the initial position (4x3 matrix) of each bone; just an array of 4x3 matrices - ChunkType_SourceInfo, // describes the source from which the cgf was exported: source max file, machine and user - ChunkType_MtlName, // material name - ChunkType_ExportFlags, // Special export flags. - ChunkType_DataStream, // Stream data. - ChunkType_MeshSubsets, // Array of mesh subsets. - ChunkType_MeshPhysicsData, // Physicalized mesh data. - - // these are the new compiled chunks for characters - ChunkType_CompiledBones = 0x2000, // was 0xACDC0000 in chunk files with versions <= 0x745 - ChunkType_CompiledPhysicalBones, - ChunkType_CompiledMorphTargets, - ChunkType_CompiledPhysicalProxies, - ChunkType_CompiledIntFaces, - ChunkType_CompiledIntSkinVertices, - ChunkType_CompiledExt2IntMap, - - ChunkType_BreakablePhysics = 0x3000, // was 0xAAFC0000 in chunk files with versions <= 0x745 - ChunkType_FaceMap, // obsolete - ChunkType_MotionParameters, - ChunkType_FootPlantInfo, // obsolete - ChunkType_BonesBoxes, - ChunkType_FoliageInfo, - ChunkType_Timestamp, - ChunkType_GlobalAnimationHeaderCAF, - ChunkType_GlobalAnimationHeaderAIM, - ChunkType_BspTreeData -}; - -enum ECgfStreamType -{ - CGF_STREAM_POSITIONS, - CGF_STREAM_NORMALS, - CGF_STREAM_TEXCOORDS, - CGF_STREAM_COLORS, - CGF_STREAM_COLORS2, - CGF_STREAM_INDICES, - CGF_STREAM_TANGENTS, - CGF_STREAM_DUMMY0_, // used to be CGF_STREAM_SHCOEFFS, dummy is needed to keep existing assets loadable - CGF_STREAM_DUMMY1_, // used to be CGF_STREAM_SHAPEDEFORMATION, dummy is needed to keep existing assets loadable - CGF_STREAM_BONEMAPPING, - CGF_STREAM_FACEMAP, - CGF_STREAM_VERT_MATS, - CGF_STREAM_QTANGENTS, - CGF_STREAM_SKINDATA, - CGF_STREAM_DUMMY2_, // used to be old console specific, dummy is needed to keep existing assets loadable - CGF_STREAM_P3S_C4B_T2S, - CGF_STREAM_NUM_TYPES -}; - -////////////////////////////////////////////////////////////////////////// -enum EPhysicsGeomType -{ - PHYS_GEOM_TYPE_NONE = -1, - PHYS_GEOM_TYPE_DEFAULT = 0x1000 + 0, - PHYS_GEOM_TYPE_NO_COLLIDE = 0x1000 + 1, - PHYS_GEOM_TYPE_OBSTRUCT = 0x1000 + 2, - - PHYS_GEOM_TYPE_DEFAULT_PROXY = 0x1000 + 0x100, // Default physicalization, but only proxy (NoDraw geometry). -}; - -struct CryVertex -{ - Vec3 p; //position - Vec3 n; //normal vector - - AUTO_STRUCT_INFO -}; - -struct CryFace -{ - int v0, v1, v2; //vertex indices - int MatID; //mat ID - - int& operator [] (int i) {return (&v0)[i]; } - int operator [] (int i) const {return (&v0)[i]; } - bool isDegenerate () const {return v0 == v1 || v1 == v2 || v2 == v0; } - - AUTO_STRUCT_INFO -}; - -struct CryUV -{ - float u, v; //texture coordinates - AUTO_STRUCT_INFO -}; - -struct CrySkinVtx -{ - int bVolumetric; - int idx[4]; - float w[4]; - Matrix33 M; - - AUTO_STRUCT_INFO -}; - -////////////////////////////////////////////////////////////////////////// -struct CryLink -{ - int BoneID; - Vec3 offset; - float Blending; - - AUTO_STRUCT_INFO -}; - -struct CryIRGB -{ - unsigned char r, g, b; - AUTO_STRUCT_INFO -}; - -struct NAME_ENTITY -{ - char name[64]; -}; - -struct phys_geometry; - -struct CryBonePhysics -{ - phys_geometry* pPhysGeom; // id of a separate mesh for this bone // MUST not be in File Structures!!! - // additional joint parameters - int flags; - float min[3], max[3]; - float spring_angle[3]; - float spring_tension[3]; - float damping[3]; - float framemtx[3][3]; -}; - -// the compatible between 32- and 64-bits structure -struct CryBonePhysics_Comp -{ - int nPhysGeom; // id of a separate mesh for this bone - // additional joint parameters - int flags; - float min[3], max[3]; - float spring_angle[3]; - float spring_tension[3]; - float damping[3]; - float framemtx[3][3]; - - AUTO_STRUCT_INFO -}; - -#define __copy3(MEMBER) left.MEMBER[0] = right.MEMBER[0]; left.MEMBER[1] = right.MEMBER[1]; left.MEMBER[2] = right.MEMBER[2]; -inline void CopyPhysInfo(CryBonePhysics& left, const CryBonePhysics_Comp& right) -{ - left.pPhysGeom = (phys_geometry*)(INT_PTR)right.nPhysGeom; - left.flags = right.flags; - __copy3(min); - __copy3(max); - __copy3(spring_angle); - __copy3(spring_tension); - __copy3(damping); - __copy3(framemtx[0]); - __copy3(framemtx[1]); - __copy3(framemtx[2]); -} -inline void CopyPhysInfo(CryBonePhysics_Comp& left, const CryBonePhysics& right) -{ - left.nPhysGeom = (int)(INT_PTR)right.pPhysGeom; - left.flags = right.flags; - __copy3(min); - __copy3(max); - __copy3(spring_angle); - __copy3(spring_tension); - __copy3(damping); - __copy3(framemtx[0]); - __copy3(framemtx[1]); - __copy3(framemtx[2]); -} -#undef __copy3 - -struct CryBoneDescData -{ - unsigned int m_nControllerID; // unic id of bone (generated from bone name in the max) - - // [Sergiy] physics info for different lods - // lod 0 is the physics of alive body, lod 1 is the physics of a dead body - CryBonePhysics m_PhysInfo[2]; - float m_fMass; - - Matrix34 m_DefaultW2B; //intitalpose matrix World2Bone - Matrix34 m_DefaultB2W; //intitalpose matrix Bone2World - - enum - { - kBoneNameMaxSize = 256, - }; - char m_arrBoneName[CryBoneDescData::kBoneNameMaxSize]; - - int m_nLimbId; // set by model state class - - // this bone parent is this[m_nOffsetParent], 0 if the bone is root. Normally this is <= 0 - int m_nOffsetParent; - - // The whole hierarchy of bones is kept in one big array that belongs to the ModelState - // Each bone that has children has its own range of bone objects in that array, - // and this points to the beginning of that range and defines the number of bones. - unsigned m_numChildren; - // the beginning of the subarray of children is at this[m_nOffsetChildren] - // this is 0 if there are no children - int m_nOffsetChildren; -}; - -struct CryBoneDescData_Comp -{ - unsigned int m_nControllerID; // unique id of bone (generated from bone name) - - // [Sergiy] physics info for different lods - // lod 0 is the physics of alive body, lod 1 is the physics of a dead body - CryBonePhysics_Comp m_PhysInfo[2]; - float m_fMass; - - Matrix34 m_DefaultW2B; //intitalpose matrix World2Bone - Matrix34 m_DefaultB2W; //intitalpose matrix Bone2World - - char m_arrBoneName[256]; - - int m_nLimbId; // set by model state class - - // this bone parent is this[m_nOffsetParent], 0 if the bone is root. Normally this is <= 0 - int m_nOffsetParent; - - // The whole hierarchy of bones is kept in one big array that belongs to the ModelState - // Each bone that has children has its own range of bone objects in that array, - // and this points to the beginning of that range and defines the number of bones. - unsigned m_numChildren; - // the beginning of the subarray of children is at this[m_nOffsetChildren] - // this is 0 if there are no children - int m_nOffsetChildren; - - AUTO_STRUCT_INFO -}; - -inline void CopyBoneDescData(CryBoneDescData_Comp& left, const CryBoneDescData& right) -{ - left.m_nControllerID = right.m_nControllerID; - - CopyPhysInfo(left.m_PhysInfo[0], right.m_PhysInfo[0]); - CopyPhysInfo(left.m_PhysInfo[1], right.m_PhysInfo[1]); - - left.m_fMass = right.m_fMass; - left.m_DefaultW2B = right.m_DefaultW2B; - left.m_DefaultB2W = right.m_DefaultB2W; - memcpy(left.m_arrBoneName, right.m_arrBoneName, sizeof(left.m_arrBoneName)); - left.m_nLimbId = right.m_nLimbId; - left.m_nOffsetParent = right.m_nOffsetParent; - left.m_numChildren = right.m_numChildren; - left.m_nOffsetChildren = right.m_nOffsetChildren; -} - -struct BONE_ENTITY -{ - int BoneID; - int ParentID; - int nChildren; - - // Id of controller (CRC32 From name of bone). - unsigned int ControllerID; - - char prop[32]; - CryBonePhysics_Comp phys; - - AUTO_STRUCT_INFO -}; - -struct KEY_HEADER -{ - int KeyTime; //in ticks - AUTO_STRUCT_INFO -}; - -struct RANGE_ENTITY -{ - char name[32]; - int start; - int end; - AUTO_STRUCT_INFO -}; - -//======================================== -//Timing Chunk Header -//======================================== -struct TIMING_CHUNK_DESC_0918 -{ - enum - { - VERSION = 0x0918 - }; - - f32 m_SecsPerTick; // seconds/ticks - int32 m_TicksPerFrame; // ticks/Frame - - RANGE_ENTITY global_range; // covers all of the time ranges - int qqqqnSubRanges; - - AUTO_STRUCT_INFO -}; - - -struct SPEED_CHUNK_DESC_2 -{ - enum - { - VERSION = 0x0922 - }; - - float Speed; - float Distance; - float Slope; - uint32 AnimFlags; - f32 MoveDir[3]; - QuatT StartPosition; - AUTO_STRUCT_INFO -}; - - -struct MotionParams905 -{ - uint32 m_nAssetFlags; - uint32 m_nCompression; - - int32 m_nTicksPerFrame; - f32 m_fSecsPerTick; - int32 m_nStart; - int32 m_nEnd; - - f32 m_fMoveSpeed; - f32 m_fTurnSpeed; - f32 m_fAssetTurn; - f32 m_fDistance; - f32 m_fSlope; - - QuatT m_StartLocation; - QuatT m_EndLocation; - - f32 m_LHeelStart, m_LHeelEnd; - f32 m_LToe0Start, m_LToe0End; - f32 m_RHeelStart, m_RHeelEnd; - f32 m_RToe0Start, m_RToe0End; - - MotionParams905() - { - m_nAssetFlags = 0; - m_nCompression = std::numeric_limits::max(); - m_nTicksPerFrame = 0; - m_fSecsPerTick = 0; - m_nStart = 0; - m_nEnd = 0; - - m_fMoveSpeed = -1; - m_fTurnSpeed = -1; - m_fAssetTurn = -1; - m_fDistance = -1; - m_fSlope = -1; - - m_LHeelStart = -1; - m_LHeelEnd = -1; - m_LToe0Start = -1; - m_LToe0End = -1; - m_RHeelStart = -1; - m_RHeelEnd = -1; - m_RToe0Start = -1; - m_RToe0End = -1; - - m_StartLocation.SetIdentity(); - m_EndLocation.SetIdentity(); - } -}; - - -struct CHUNK_MOTION_PARAMETERS -{ - enum - { - VERSION = 0x0925 - }; - - MotionParams905 mp; -}; - - - -struct CHUNK_GAHCAF_INFO -{ - enum - { - VERSION = 0x0971 - }; - enum - { - FILEPATH_SIZE = 256 - }; - - uint32 m_Flags; - char m_FilePath[FILEPATH_SIZE]; - uint32 m_FilePathCRC32; - uint32 m_FilePathDBACRC32; - - f32 m_LHeelStart, m_LHeelEnd; - f32 m_LToe0Start, m_LToe0End; - f32 m_RHeelStart, m_RHeelEnd; - f32 m_RToe0Start, m_RToe0End; - - f32 m_fStartSec; //asset-feature: Start time in seconds. - f32 m_fEndSec; //asset-feature: End time in seconds. - f32 m_fTotalDuration; //asset-feature: asset-feature: total duration in seconds. - uint32 m_nControllers; - - //locator information - QuatT m_StartLocation; - QuatT m_LastLocatorKey; - Vec3 m_vVelocity; //asset-feature: the velocity vector for this asset - f32 m_fDistance; //asset-feature: the absolute distance this objects is moving - f32 m_fSpeed; //asset-feature: speed (meters in second) - f32 m_fSlope; //asset-feature: uphill-downhill measured in degrees - f32 m_fTurnSpeed; //asset-feature: turning speed per second - f32 m_fAssetTurn; //asset-feature: radiant between first and last frame -}; - - - - -struct CHUNK_GAHAIM_INFO -{ - struct VirtualExampleInit2 - { - Vec2 polar; - uint8 i0, i1, i2, i3; - f32 w0, w1, w2, w3; - }; - struct VirtualExample - { - uint8 i0, i1, i2, i3; - int16 v0, v1, v2, v3; - }; - - enum - { - VERSION = 0x0970 - }; - enum - { - XGRID = 17 - }; - enum - { - YGRID = 9 - }; - enum - { - FILEPATH_SIZE = 256 - }; - - uint32 m_Flags; - char m_FilePath[FILEPATH_SIZE]; - uint32 m_FilePathCRC32; - - f32 m_fStartSec; //asset-feature: Start time in seconds. - f32 m_fEndSec; //asset-feature: End time in seconds. - f32 m_fTotalDuration; //asset-feature: asset-feature: total duration in seconds. - - uint32 m_AnimTokenCRC32; - - uint64 m_nExist; - Quat m_MiddleAimPoseRot; - Quat m_MiddleAimPose; - VirtualExample m_PolarGrid[XGRID * YGRID]; - uint32 m_numAimPoses; -}; - - -//======================================== -//Material Chunk Header -//======================================== - -////////////////////////////////////////////////////////////////////////// -#define MTL_NAME_CHUNK_DESC_0800_MAX_SUB_MATERIALS (32) -struct MTL_NAME_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - enum EFlags - { - FLAG_MULTI_MATERIAL = 0x0001, // Have sub materials info. - FLAG_SUB_MATERIAL = 0x0002, // This is sub material. - FLAG_SH_COEFFS = 0x0004, // This material should get spherical harmonics coefficients computed. - FLAG_SH_2SIDED = 0x0008, // This material will be used as 2 sided in the sh precomputation - FLAG_SH_AMBIENT = 0x0010, // This material will get an ambient sh term(to not shadow it entirely) - }; - - int nFlags; // see EFlags. - int nFlags2; - char name[128]; //material/shader name - int nPhysicalizeType; - int nSubMaterials; - int nSubMatChunkId[MTL_NAME_CHUNK_DESC_0800_MAX_SUB_MATERIALS]; - int nAdvancedDataChunkId; - float sh_opacity; - int reserve[32]; - - AUTO_STRUCT_INFO -}; - -struct MTL_NAME_CHUNK_DESC_0802 -{ - enum - { - VERSION = 0x0802 - }; - - char name[128]; //material/shader name - int nSubMaterials; - - // Data continues from here. - // 1) if nSubMaterials is 0, this is a single-material: we store physicalization type of the material (int32). - // 2) if nSubMaterials is not 0, this is a multi-material: we store nSubMaterials physicalization types (int32 - // value for each sub-material). After the physicalization types we store chain of ASCIIZ names of sub-materials. - - AUTO_STRUCT_INFO -}; - -//======================================== -//Mesh Chunk Header -//======================================== - -struct MESH_CHUNK_DESC_0745 -{ - // Versions 0x0744 and 0x0745 are *exactly* the same. - // Version number was increased from 0x0744 to 0x0745 just because - // it was the only way to inform *old* (existing) executables that - // NODE_CHUNK_DESC(!) chunk format was changed and cannot be read - // by them (old CLoaderCGF::LoadNodeChunk() didn't check - // NODE_CHUNK_DESC's version number). - enum - { - VERSION = 0x0745 - }; - enum - { - COMPATIBLE_OLD_VERSION = 0x0744 - }; - - enum EFlags1 - { - FLAG1_BONE_INFO = 0x01, - }; - enum EFlags2 - { - FLAG2_HAS_VERTEX_COLOR = 0x01, - FLAG2_HAS_VERTEX_ALPHA = 0x02, - FLAG2_HAS_TOPOLOGY_IDS = 0x04, - }; - unsigned char flags1; - unsigned char flags2; - int nVerts; - int nTVerts; // # of texture vertices (0 or nVerts) - int nFaces; - int VertAnimID; // id of the related vertAnim chunk if present. otherwise it is -1 - - AUTO_STRUCT_INFO -}; - -// Compiled Mesh chunk. -struct MESH_CHUNK_DESC_0801 -{ - // Versions 0x0800 and 0x0801 are *exactly* the same. - // Version number was increased from 0x0800 to 0x0801 just because - // it was the only way to inform *old* (existing) executables that - // NODE_CHUNK_DESC(!) chunk format was changed and cannot be read - // by them (old CLoaderCGF::LoadNodeChunk() didn't check - // NODE_CHUNK_DESC's version number). - enum - { - VERSION = 0x0801 - }; - enum - { - COMPATIBLE_OLD_VERSION = 0x0800 - }; - - enum EFlags - { - MESH_IS_EMPTY = 0x0001, // Empty mesh (no streams are saved) - HAS_TEX_MAPPING_DENSITY = 0x0002, // texMappingDensity contains a valid value - HAS_EXTRA_WEIGHTS = 0x0004, // The weight stream will have weights for influences 5-8 - HAS_FACE_AREA = 0x0008, // geometricMeanFaceArea contains a valid value - }; - - int nFlags; // @see EFlags - int nFlags2; - - // Just for info. - int nVerts; // Number of vertices. - int nIndices; // Number of indices. - int nSubsets; // Number of mesh subsets. - - int nSubsetsChunkId; // Chunk id of subsets. (Must be ChunkType_MeshSubsets) - int nVertAnimID; // id of the related vertAnim chunk if present. otherwise it is -1 - - // ChunkIDs of data streams (Must be ChunkType_DataStream). - int GetStreamChunkID(ECgfStreamType streamType, [[maybe_unused]] int streamIndex) const - { - // Ignore streamIndex since all chunks with version 0x0801 have only one stream per type - return nStreamChunkID[streamType]; - } - int nStreamChunkID[ECgfStreamType::CGF_STREAM_NUM_TYPES]; // Index is one of ECgfStreamType values. - - // Chunk IDs of physical mesh data. (Must be ChunkType_MeshPhysicsData) - int nPhysicsDataChunkId[4]; - - // Bounding box of the mesh. - Vec3 bboxMin; - Vec3 bboxMax; - - float texMappingDensity; - float geometricMeanFaceArea; - int reserved[31]; - AUTO_STRUCT_INFO -}; - -struct MESH_CHUNK_DESC_0802 -{ - // Version 0x0802 adds an additional dimention to the nStreamChunkID array to allow for multiple streams of the same type - enum - { - VERSION = 0x0802 - }; - enum - { - COMPATIBLE_OLD_VERSION = 0x0802 - }; - - enum EFlags - { - MESH_IS_EMPTY = 0x0001, // Empty mesh (no streams are saved) - HAS_TEX_MAPPING_DENSITY = 0x0002, // texMappingDensity contains a valid value - HAS_EXTRA_WEIGHTS = 0x0004, // The weight stream will have weights for influences 5-8 - HAS_FACE_AREA = 0x0008, // geometricMeanFaceArea contains a valid value - }; - - int nFlags; // @see EFlags - int nFlags2; - - // Just for info. - int nVerts; // Number of vertices. - int nIndices; // Number of indices. - int nSubsets; // Number of mesh subsets. - - int nSubsetsChunkId; // Chunk id of subsets. (Must be ChunkType_MeshSubsets) - int nVertAnimID; // id of the related vertAnim chunk if present. otherwise it is -1 - - // ChunkIDs of data streams (Must be ChunkType_DataStream). - int GetStreamChunkID(ECgfStreamType streamType, int streamIndex) const - { - return nStreamChunkID[streamType][streamIndex]; - } - int nStreamChunkID[ECgfStreamType::CGF_STREAM_NUM_TYPES][8]; // [ECgfStreamType value][streamIndex] e.g. [CGF_STREAM_TEXCOORDS][1] to get UV set 1 - - // Chunk IDs of physical mesh data. (Must be ChunkType_MeshPhysicsData) - int nPhysicsDataChunkId[4]; - - // Bounding box of the mesh. - Vec3 bboxMin; - Vec3 bboxMax; - - float texMappingDensity; - float geometricMeanFaceArea; - int reserved[31]; - AUTO_STRUCT_INFO -}; - - -////////////////////////////////////////////////////////////////////////// -// Stream chunk contains data about a mesh data stream (positions, normals, etc...) -////////////////////////////////////////////////////////////////////////// -struct STREAM_DATA_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - enum EFlags { }; // Not implemented. - - int nFlags; - int nStreamType; // Stream type one of ECgfStreamType. - int nCount; // Number of elements. - int nElementSize; // Element Size. - int reserved[2]; - - // Data starts here at the end of the chunk.. - //char streamData[nCount*nElementSize]; - - AUTO_STRUCT_INFO -}; - -struct STREAM_DATA_CHUNK_DESC_0801 -{ - enum - { - VERSION = 0x0801 - }; - - enum EFlags { }; // Not implemented. - - int nFlags; - int nStreamType; // Stream type one of ECgfStreamType. - int nStreamIndex; // To handle multiple streams of the same type - int nCount; // Number of elements. - int nElementSize; // Element Size. - int reserved[2]; - - // Data starts here at the end of the chunk.. - //char streamData[nCount*nElementSize]; - - AUTO_STRUCT_INFO -}; - -////////////////////////////////////////////////////////////////////////// -// Contains array of mesh subsets. -// Each subset holds an info about material id, indices ranges etc... -////////////////////////////////////////////////////////////////////////// -struct MESH_SUBSETS_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - enum EFlags - { - SH_HAS_DECOMPR_MAT = 0x0001, // obsolete - BONEINDICES = 0x0002, - HAS_SUBSET_TEXEL_DENSITY = 0x0004, - }; - - int nFlags; - int nCount; // Number of elements. - int reserved[2]; - - struct MeshSubset - { - int nFirstIndexId; - int nNumIndices; - int nFirstVertId; - int nNumVerts; - int nMatID; // Material sub-object Id. - float fRadius; - Vec3 vCenter; - - AUTO_STRUCT_INFO - }; - - struct MeshBoneIDs - { - uint32 numBoneIDs; - uint16 arrBoneIDs[0x80]; - - AUTO_STRUCT_INFO - }; - - struct MeshSubsetTexelDensity - { - float texelDensity; - - AUTO_STRUCT_INFO - }; - - // Data starts here at the end of the chunk. - //Subset streamData[nCount]; - - MESH_SUBSETS_CHUNK_DESC_0800() - : nFlags(0) - , nCount(0) - { - } - - AUTO_STRUCT_INFO -}; - -////////////////////////////////////////////////////////////////////////// -// Contain array of mesh subsets. -// Each subset holds an info about material id, indices ranges etc... -////////////////////////////////////////////////////////////////////////// -struct MESH_PHYSICS_DATA_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - int nDataSize; // Size of physical data at the end of the chunk. - int nFlags; - int nTetrahedraDataSize; - int nTetrahedraChunkId; // Chunk of physics Tetrahedra data. - int reserved[2]; - - // Data starts here at the end of the chunk. - //char physicsData[nDataSize]; - //char tetrahedraData[nTetrahedraDataSize]; - - AUTO_STRUCT_INFO -}; - - -struct VERTANIM_CHUNK_DESC_0744 -{ - enum - { - VERSION = 0x0744 - }; - - int GeomID; // ID of the related mesh chunk - int nKeys; // # of keys - int nVerts; // # of vertices this object has - int nFaces; // # of faces this object has (for double check purpose) - - AUTO_STRUCT_INFO -}; - -typedef VERTANIM_CHUNK_DESC_0744 VERTANIM_CHUNK_DESC; -#define VERTANIM_CHUNK_DESC_VERSION VERTANIM_CHUNK_DESC_0744::VERSION - -//======================================== -//Bone Anim Chunk Header -//======================================== - -struct BONEANIM_CHUNK_DESC_0290 -{ - enum - { - VERSION = 0x0290 - }; - - int nBones; - - AUTO_STRUCT_INFO -}; - -//======================================== -//Bonelist Chunk Header -//======================================== - -// this structure describes the bone names -// it's followed by numEntities packed \0-terminated strings, the list terminated by double-\0 -struct BONENAMELIST_CHUNK_DESC_0745 -{ - enum - { - VERSION = 0x0745 - }; - - int numEntities; - AUTO_STRUCT_INFO -}; - - -struct COMPILED_BONE_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - char reserved[32]; - AUTO_STRUCT_INFO -}; - -struct COMPILED_PHYSICALBONE_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - char reserved[32]; - AUTO_STRUCT_INFO -}; - -struct COMPILED_PHYSICALPROXY_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - uint32 numPhysicalProxies; - AUTO_STRUCT_INFO -}; - -struct COMPILED_MORPHTARGETS_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800, VERSION1 = 0x801 - }; - - uint32 numMorphTargets; - AUTO_STRUCT_INFO -}; - - -struct COMPILED_INTFACES_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - AUTO_STRUCT_INFO -}; - -struct COMPILED_INTSKINVERTICES_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - char reserved[32]; - AUTO_STRUCT_INFO -}; - -struct COMPILED_EXT2INTMAP_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800 - }; - - AUTO_STRUCT_INFO -}; - -struct COMPILED_BONEBOXES_CHUNK_DESC_0800 -{ - enum - { - VERSION = 0x0800, VERSION1 = 0x801 - }; - - AUTO_STRUCT_INFO -}; - -// Keyframe and Timing Primitives __________________________________________________________________________________________________________________ -struct BaseKey -{ - int time; - AUTO_STRUCT_INFO -}; - -struct BaseTCB -{ - float t, c, b; - float ein, eout; - AUTO_STRUCT_INFO -}; - -struct BaseKey1 - : BaseKey -{ - float val; - AUTO_STRUCT_INFO -}; -struct BaseKey3 - : BaseKey -{ - Vec3 val; - AUTO_STRUCT_INFO -}; -struct BaseKeyQ - : BaseKey -{ - CryQuat val; - AUTO_STRUCT_INFO -}; - -struct CryLin1Key - : BaseKey1 -{ - AUTO_STRUCT_INFO -}; -struct CryLin3Key - : BaseKey3 -{ - AUTO_STRUCT_INFO -}; -struct CryLinQKey - : BaseKeyQ -{ - AUTO_STRUCT_INFO -}; -struct CryTCB1Key - : BaseKey1 - , BaseTCB -{ - AUTO_STRUCT_INFO -}; -struct CryTCB3Key - : BaseKey3 - , BaseTCB -{ - AUTO_STRUCT_INFO -}; -struct CryTCBQKey - : BaseKeyQ - , BaseTCB -{ - AUTO_STRUCT_INFO -}; -struct CryBez1Key - : BaseKey1 -{ - float intan, outtan; - AUTO_STRUCT_INFO -}; -struct CryBez3Key - : BaseKey3 -{ - Vec3 intan, outtan; - AUTO_STRUCT_INFO -}; -struct CryBezQKey - : BaseKeyQ -{ - AUTO_STRUCT_INFO -}; - -struct CryKeyPQLog -{ - int nTime; - Vec3 vPos; - Vec3 vRotLog; // logarithm of the rotation - - // resets to initial position/rotation/time - void reset () - { - nTime = 0; - vPos.x = vPos.y = vPos.z = 0; - vRotLog.x = vRotLog.y = vRotLog.z = 0; - } - - AUTO_STRUCT_INFO -}; - -//======================================== -//Controller Chunk Header -//======================================== -enum CtrlTypes -{ - CTRL_NONE, - CTRL_CRYBONE, - CTRL_LINEER1, CTRL_LINEER3, CTRL_LINEERQ, - CTRL_BEZIER1, CTRL_BEZIER3, CTRL_BEZIERQ, - CTRL_TCB1, CTRL_TCB3, CTRL_TCBQ, - CTRL_BSPLINE_2O, // 2-byte fixed values, open - CTRL_BSPLINE_1O, // 1-byte fixed values, open - CTRL_BSPLINE_2C, // 2-byte fixed values, closed - CTRL_BSPLINE_1C, // 1-byte fixed values, closed - CTRL_CONST // constant position&rotation -}; - -enum CtrlFlags -{ - CTRL_ORT_CYCLE = 0x01, - CTRL_ORT_LOOP = 0x02 -}; - -// Used to store TCB-controllers in .anm files -struct CONTROLLER_CHUNK_DESC_0826 -{ - enum - { - VERSION = 0x0826 - }; - - CtrlTypes type; //one ot the CtrlTypes values - int nKeys; // # of keys this controller has; toatl # of knots (positional and orientational) in the case of B-Spline - - //unsigned short nSubCtrl; // # of sub controllers; not used now/reserved - unsigned int nFlags; // Flags of controller. - //int nSubCtrl; // # of sub controllers; not used now/reserved - - unsigned nControllerId; // unique generated in exporter id based on crc32 of bone name - - AUTO_STRUCT_INFO -}; - -// Format used to store uncompressed sampled animation exported from DCC into .i_caf files (earlier .caf) -struct CONTROLLER_CHUNK_DESC_0827 -{ - enum - { - VERSION = 0x0827 - }; - unsigned numKeys; - unsigned nControllerId; - - AUTO_STRUCT_INFO -}; - -// Unused format (was it introduced to fix missing header in 827?) -struct CONTROLLER_CHUNK_DESC_0828 -{ - enum - { - VERSION = 0x0828 - }; -}; - -struct CONTROLLER_CHUNK_DESC_0829 -{ - enum - { - VERSION = 0x0829 - }; - - enum - { - eKeyTimeRotation = 0, eKeyTimePosition = 1, eKeyTimeScale = 2 - }; - - unsigned int nControllerId; - - uint16 numRotationKeys; - uint16 numPositionKeys; - uint8 RotationFormat; - uint8 RotationTimeFormat; - uint8 PositionFormat; - uint8 PositionKeysInfo; - uint8 PositionTimeFormat; - uint8 TracksAligned; - - AUTO_STRUCT_INFO -}; - -// Added new controller flags field, correspond to v827 and v829 respectively -struct CONTROLLER_CHUNK_DESC_0830 -{ - enum - { - VERSION = 0x830 - }; - - CONTROLLER_CHUNK_DESC_0830(){} - - CONTROLLER_CHUNK_DESC_0830(const CONTROLLER_CHUNK_DESC_0827* oldChunk) - : numKeys(oldChunk->numKeys) - , nControllerId(oldChunk->nControllerId) - , nFlags(0) - {} - - unsigned numKeys; - unsigned nControllerId; - unsigned nFlags; - - AUTO_STRUCT_INFO -}; - -struct CONTROLLER_CHUNK_DESC_0831 -{ - enum - { - VERSION = 0x831 - }; - - CONTROLLER_CHUNK_DESC_0831(){} - - CONTROLLER_CHUNK_DESC_0831(const CONTROLLER_CHUNK_DESC_0829* oldChunk) - : nControllerId(oldChunk->nControllerId) - , nFlags(0) - , numPositionKeys(oldChunk->numPositionKeys) - , numRotationKeys(oldChunk->numRotationKeys) - , RotationFormat(oldChunk->RotationFormat) - , RotationTimeFormat(oldChunk->RotationTimeFormat) - , PositionFormat(oldChunk->PositionFormat) - , PositionKeysInfo(oldChunk->PositionKeysInfo) - , PositionTimeFormat(oldChunk->PositionTimeFormat) - , TracksAligned(oldChunk->TracksAligned) - {} - - enum - { - eKeyTimeRotation = 0, eKeyTimePosition = 1, eKeyTimeScale = 2 - }; - - unsigned int nControllerId; - unsigned int nFlags; - - uint16 numRotationKeys; - uint16 numPositionKeys; - uint8 RotationFormat; - uint8 RotationTimeFormat; - uint8 PositionFormat; - uint8 PositionKeysInfo; - uint8 PositionTimeFormat; - uint8 TracksAligned; - - AUTO_STRUCT_INFO -}; - -struct CONTROLLER_CHUNK_DESC_0905 -{ - enum - { - VERSION = 0x0905 - }; - - uint32 numKeyPos; - uint32 numKeyRot; - uint32 numKeyTime; - uint32 numAnims; - AUTO_STRUCT_INFO -}; - -//======================================== -//Node Chunk Header -//======================================== -struct NODE_CHUNK_DESC_0824 -{ - // Versions 0x0823 and 0x0824 have exactly same layout. - // The only difference between 0x0823 and 0x0824 is that some members - // are now named _obsoleteXXX_ and are not filled/used in 0x0824. - enum - { - VERSION = 0x0824 - }; - enum - { - COMPATIBLE_OLD_VERSION = 0x0823 - }; - - char name[64]; - - int ObjectID; // ID of this node's object chunk (if present) - int ParentID; // chunk ID of the parent Node's chunk - int nChildren; // # of children Nodes - int MatID; // Material chunk No - - uint8 _obsoleteA_[4]; // uint8 IsGroupHead; uint8 IsGroupMember; uint8 _padding_[2]. not used anymore. - - float tm[4][4]; // transformation matrix - - float _obsoleteB_[3]; // position component of the matrix, stored as Vec3. not used anymore. - float _obsoleteC_[4]; // rotation component of the matrix, stored as CryQuat. not used anymore. - float _obsoleteD_[3]; // scale component of the matrix, stored as Vec3. not used anymore. - - int pos_cont_id; // position controller chunk id - int rot_cont_id; // rotation controller chunk id - int scl_cont_id; // scale controller chunk id - - int PropStrLen; // length of the property string - - AUTO_STRUCT_INFO -}; - -//======================================== -//Helper Chunk Header -//======================================== -enum HelperTypes -{ - HP_POINT = 0, - HP_DUMMY = 1, - HP_XREF = 2, - HP_CAMERA = 3, - HP_GEOMETRY = 4 -}; - -struct HELPER_CHUNK_DESC_0744 -{ - enum - { - VERSION = 0x0744 - }; - - HelperTypes type; // one of the HelperTypes values - Vec3 size; // size in local x,y,z axises (for dummy only) - - AUTO_STRUCT_INFO -}; - -typedef HELPER_CHUNK_DESC_0744 HELPER_CHUNK_DESC; -#define HELPER_CHUNK_DESC_VERSION HELPER_CHUNK_DESC::VERSION - - -// ChunkType_MeshMorphTarget - morph target of a mesh chunk -// This chunk contains only the information about the vertices that are changed in the mesh -// This chunk is followed by an array of numMorphVertices structures SMeshMorphTargetVertex, -// immediately followed by the name (null-terminated, variable-length string) of the morph target. -// The string is after the array because of future alignment considerations; it may be padded with 0s. -struct MESHMORPHTARGET_CHUNK_DESC_0001 -{ - enum - { - VERSION = 0x0001 - }; - uint32 nChunkIdMesh; // the chunk id of the mesh chunk (ChunkType_Mesh) for which this morph target is - uint32 numMorphVertices; // number of MORPHED vertices - - AUTO_STRUCT_INFO -}; - - -// an array of these structures follows the MESHMORPHTARGET_CHUNK_DESC_0001 -// there are numMorphVertices of them -struct SMeshMorphTargetVertex -{ - uint32 nVertexId; // vertex index in the original (mesh) array of vertices - Vec3 ptVertex; // the target point of the morph target - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{} - AUTO_STRUCT_INFO -}; - -struct SMeshMorphTargetHeader -{ - uint32 MeshID; - uint32 NameLength; //size of the name string - uint32 numIntVertices; //type SMeshMorphTargetVertex - uint32 numExtVertices; //type SMeshMorphTargetVertex - - AUTO_STRUCT_INFO -}; - -struct SMeshPhysicalProxyHeader -{ - uint32 ChunkID; - uint32 numPoints; - uint32 numIndices; - uint32 numMaterials; - - AUTO_STRUCT_INFO -}; - -// -// ChunkType_BoneInitialPos - describes the initial position (4x3 matrix) of each bone; just an array of 4x3 matrices -// This structure is followed by -struct BONEINITIALPOS_CHUNK_DESC_0001 -{ - enum - { - VERSION = 0x0001 - }; - // the chunk id of the mesh chunk (ChunkType_Mesh) with bone info for which these bone initial positions are applicable. - // there might be some unused bones here as well. There must be the same number of bones as in the other chunks - they're placed - // in BoneId order. - unsigned nChunkIdMesh; - // this is the number of bone initial pose matrices here - unsigned numBones; - - AUTO_STRUCT_INFO -}; - -// an array of these matrices follows the BONEINITIALPOS_CHUNK_DESC_0001 header -// there are numBones of them -// TO BE REPLACED WITH Matrix43 -struct SBoneInitPosMatrix -{ - float mx[4][3]; - float* operator [] (int i) {return mx[i]; } - const float* operator [] (int i) const {return mx[i]; } - const Vec3& getOrt (int nOrt) const {return *(const Vec3*)(mx[nOrt]); } - - AUTO_STRUCT_INFO -}; - -////////////////////////////////////////////////////////////////////////// -// Custom Attributes chunk description. -////////////////////////////////////////////////////////////////////////// -struct EXPORT_FLAGS_CHUNK_DESC -{ - enum - { - VERSION = 0x0001 - }; - enum EFlags - { - MERGE_ALL_NODES = 0x0001, - HAVE_AUTO_LODS = 0x0002, - USE_CUSTOM_NORMALS = 0x0004, - WANT_F32_VERTICES = 0x0008, - EIGHT_WEIGHTS_PER_VERTEX = 0x0010, - //START: Prevent reprocessing skinning data for skinned CGF - SKINNED_CGF = 0x0020, - //END: Prevent reprocessing skinning data for skinned CGF - }; - enum ESrcFlags - { - FROM_MAX_EXPORTER = 0x0000, - FROM_COLLADA_XSI = 0x1001, - FROM_COLLADA_MAX = 0x1002, - FROM_COLLADA_MAYA = 0x1003, - }; - - unsigned int flags; // @see EFlags - unsigned int rc_version[4]; // Resource compiler version. - char rc_version_string[16]; // Version as a string. - unsigned int assetAuthorTool; - unsigned int authorToolVersion; - unsigned int reserved[30]; - - AUTO_STRUCT_INFO -}; - -struct BREAKABLE_PHYSICS_CHUNK_DESC -{ - enum - { - VERSION = 0x0001 - }; - - unsigned int granularity; - int nMode; - int nRetVtx; - int nRetTets; - int nReserved[10]; - - AUTO_STRUCT_INFO -}; - -struct FOLIAGE_INFO_CHUNK_DESC -{ - enum - { - //START: Add Skinned Geometry (.CGF) export type (for touch bending vegetation) - VERSION = 0x0001, - VERSION2 = 0x0002 - //END: Add Skinned Geometry (.CGF) export type (for touch bending vegetation) - }; - - int nSpines; - int nSpineVtx; - int nSkinnedVtx; - int nBoneIds; - - AUTO_STRUCT_INFO -}; - -struct FOLIAGE_SPINE_SUB_CHUNK -{ - unsigned char nVtx; - char _paddingA_[3]; - float len; - Vec3 navg; - unsigned char iAttachSpine; - unsigned char iAttachSeg; - char _paddingB_[2]; - - AUTO_STRUCT_INFO -}; - -#endif // CRYINCLUDE_CRYCOMMON_CRYHEADERS_H diff --git a/Code/Legacy/CryCommon/CryHeaders_info.cpp b/Code/Legacy/CryCommon/CryHeaders_info.cpp deleted file mode 100644 index 3487055013..0000000000 --- a/Code/Legacy/CryCommon/CryHeaders_info.cpp +++ /dev/null @@ -1,486 +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 "TypeInfo_impl.h" -#include "CryHeaders.h" - -STRUCT_INFO_BEGIN(CryVertex) -STRUCT_VAR_INFO(p, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(n, TYPE_INFO(Vec3)) -STRUCT_INFO_END(CryVertex) - -STRUCT_INFO_BEGIN(CryFace) -STRUCT_VAR_INFO(v0, TYPE_INFO(int)) -STRUCT_VAR_INFO(v1, TYPE_INFO(int)) -STRUCT_VAR_INFO(v2, TYPE_INFO(int)) -STRUCT_VAR_INFO(MatID, TYPE_INFO(int)) -STRUCT_INFO_END(CryFace) - -STRUCT_INFO_BEGIN(CryUV) -STRUCT_VAR_INFO(u, TYPE_INFO(float)) -STRUCT_VAR_INFO(v, TYPE_INFO(float)) -STRUCT_INFO_END(CryUV) - -STRUCT_INFO_BEGIN(CrySkinVtx) -STRUCT_VAR_INFO(bVolumetric, TYPE_INFO(int)) -STRUCT_VAR_INFO(idx, TYPE_INFO_ARRAY(4, TYPE_INFO(int))) -STRUCT_VAR_INFO(w, TYPE_INFO_ARRAY(4, TYPE_INFO(float))) -STRUCT_VAR_INFO(M, TYPE_INFO(Matrix33)) -STRUCT_INFO_END(CrySkinVtx) - -STRUCT_INFO_BEGIN(CryLink) -STRUCT_VAR_INFO(BoneID, TYPE_INFO(int)) -STRUCT_VAR_INFO(offset, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(Blending, TYPE_INFO(float)) -STRUCT_INFO_END(CryLink) - -STRUCT_INFO_BEGIN(CryIRGB) -STRUCT_VAR_INFO(r, TYPE_INFO(unsigned char)) -STRUCT_VAR_INFO(g, TYPE_INFO(unsigned char)) -STRUCT_VAR_INFO(b, TYPE_INFO(unsigned char)) -STRUCT_INFO_END(CryIRGB) - -STRUCT_INFO_BEGIN(CryBonePhysics_Comp) -STRUCT_VAR_INFO(nPhysGeom, TYPE_INFO(int)) -STRUCT_VAR_INFO(flags, TYPE_INFO(int)) -STRUCT_VAR_INFO(min, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(max, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(spring_angle, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(spring_tension, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(damping, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(framemtx, TYPE_ARRAY(3, TYPE_ARRAY(3, TYPE_INFO(float)))) -STRUCT_INFO_END(CryBonePhysics_Comp) - -STRUCT_INFO_BEGIN(CryBoneDescData_Comp) -STRUCT_VAR_INFO(m_nControllerID, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(m_PhysInfo, TYPE_ARRAY(2, TYPE_INFO(BONE_PHYSICS_COMP))) -STRUCT_VAR_INFO(m_fMass, TYPE_INFO(float)) -STRUCT_VAR_INFO(m_DefaultW2B, TYPE_INFO(Matrix34)) -STRUCT_VAR_INFO(m_DefaultB2W, TYPE_INFO(Matrix34)) -STRUCT_VAR_INFO(m_arrBoneName, TYPE_ARRAY(256, TYPE_INFO(char))) -STRUCT_VAR_INFO(m_nLimbId, TYPE_INFO(int)) -STRUCT_VAR_INFO(m_nOffsetParent, TYPE_INFO(int)) -STRUCT_VAR_INFO(m_numChildren, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(m_nOffsetChildren, TYPE_INFO(int)) -STRUCT_INFO_END(CryBoneDescData_Comp) - -STRUCT_INFO_BEGIN(BONE_ENTITY) -STRUCT_VAR_INFO(BoneID, TYPE_INFO(int)) -STRUCT_VAR_INFO(ParentID, TYPE_INFO(int)) -STRUCT_VAR_INFO(nChildren, TYPE_INFO(int)) -STRUCT_VAR_INFO(ControllerID, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(prop, TYPE_ARRAY(32, TYPE_INFO(char))) -STRUCT_VAR_INFO(phys, TYPE_INFO(BONE_PHYSICS_COMP)) -STRUCT_INFO_END(BONE_ENTITY) - -ENUM_INFO_BEGIN(ChunkTypes) -ENUM_ELEM_INFO(, ChunkType_ANY) -ENUM_ELEM_INFO(, ChunkType_Mesh) -ENUM_ELEM_INFO(, ChunkType_Helper) -ENUM_ELEM_INFO(, ChunkType_VertAnim) -ENUM_ELEM_INFO(, ChunkType_BoneAnim) -ENUM_ELEM_INFO(, ChunkType_GeomNameList) -ENUM_ELEM_INFO(, ChunkType_BoneNameList) -ENUM_ELEM_INFO(, ChunkType_MtlList) -ENUM_ELEM_INFO(, ChunkType_MRM) -ENUM_ELEM_INFO(, ChunkType_SceneProps) -ENUM_ELEM_INFO(, ChunkType_Light) -ENUM_ELEM_INFO(, ChunkType_PatchMesh) -ENUM_ELEM_INFO(, ChunkType_Node) -ENUM_ELEM_INFO(, ChunkType_Mtl) -ENUM_ELEM_INFO(, ChunkType_Controller) -ENUM_ELEM_INFO(, ChunkType_Timing) -ENUM_ELEM_INFO(, ChunkType_BoneMesh) -ENUM_ELEM_INFO(, ChunkType_BoneLightBinding) -ENUM_ELEM_INFO(, ChunkType_MeshMorphTarget) -ENUM_ELEM_INFO(, ChunkType_BoneInitialPos) -ENUM_ELEM_INFO(, ChunkType_SourceInfo) -ENUM_ELEM_INFO(, ChunkType_MtlName) -ENUM_ELEM_INFO(, ChunkType_ExportFlags) -ENUM_ELEM_INFO(, ChunkType_DataStream) -ENUM_ELEM_INFO(, ChunkType_MeshSubsets) -ENUM_ELEM_INFO(, ChunkType_MeshPhysicsData) -ENUM_ELEM_INFO(, ChunkType_CompiledBones) -ENUM_ELEM_INFO(, ChunkType_CompiledPhysicalBones) -ENUM_ELEM_INFO(, ChunkType_CompiledMorphTargets) -ENUM_ELEM_INFO(, ChunkType_CompiledPhysicalProxies) -ENUM_ELEM_INFO(, ChunkType_CompiledIntFaces) -ENUM_ELEM_INFO(, ChunkType_CompiledIntSkinVertices) -ENUM_ELEM_INFO(, ChunkType_CompiledExt2IntMap) -ENUM_ELEM_INFO(, ChunkType_BreakablePhysics) -ENUM_ELEM_INFO(, ChunkType_FaceMap) -ENUM_ELEM_INFO(, ChunkType_MotionParameters) -ENUM_ELEM_INFO(, ChunkType_FootPlantInfo) -ENUM_ELEM_INFO(, ChunkType_BonesBoxes) -ENUM_ELEM_INFO(, ChunkType_FoliageInfo) -ENUM_INFO_END(ChunkTypes) - -STRUCT_INFO_BEGIN(RANGE_ENTITY) -STRUCT_VAR_INFO(name, TYPE_ARRAY(32, TYPE_INFO(char))) -STRUCT_VAR_INFO(start, TYPE_INFO(int)) -STRUCT_VAR_INFO(end, TYPE_INFO(int)) -STRUCT_INFO_END(RANGE_ENTITY) - -STRUCT_INFO_BEGIN(TIMING_CHUNK_DESC_0918) -STRUCT_VAR_INFO(m_SecsPerTick, TYPE_INFO(float)) -STRUCT_VAR_INFO(m_TicksPerFrame, TYPE_INFO(int)) -STRUCT_VAR_INFO(global_range, TYPE_INFO(RANGE_ENTITY)) -STRUCT_VAR_INFO(qqqqnSubRanges, TYPE_INFO(int)) -STRUCT_INFO_END(TIMING_CHUNK_DESC_0918) - - -STRUCT_INFO_BEGIN(SPEED_CHUNK_DESC_2) -STRUCT_VAR_INFO(Speed, TYPE_INFO(float)) -STRUCT_VAR_INFO(Distance, TYPE_INFO(float)) -STRUCT_VAR_INFO(Slope, TYPE_INFO(float)) -STRUCT_VAR_INFO(AnimFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(MoveDir, TYPE_ARRAY(3, TYPE_INFO(f32))) -STRUCT_VAR_INFO(StartPosition, TYPE_INFO(QuatT)) -STRUCT_INFO_END(SPEED_CHUNK_DESC_2) - -STRUCT_INFO_BEGIN(MTL_NAME_CHUNK_DESC_0800) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFlags2, TYPE_INFO(int)) -STRUCT_VAR_INFO(name, TYPE_ARRAY(128, TYPE_INFO(char))) -STRUCT_VAR_INFO(nPhysicalizeType, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSubMaterials, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSubMatChunkId, TYPE_ARRAY(MTL_NAME_CHUNK_DESC_0800_MAX_SUB_MATERIALS, TYPE_INFO(int))) -STRUCT_VAR_INFO(nAdvancedDataChunkId, TYPE_INFO(int)) -STRUCT_VAR_INFO(sh_opacity, TYPE_INFO(float)) -STRUCT_VAR_INFO(reserve, TYPE_ARRAY(32, TYPE_INFO(int))) -STRUCT_INFO_END(MTL_NAME_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(MTL_NAME_CHUNK_DESC_0802) -STRUCT_VAR_INFO(name, TYPE_ARRAY(128, TYPE_INFO(char))) -STRUCT_VAR_INFO(nSubMaterials, TYPE_INFO(int)) -STRUCT_INFO_END(MTL_NAME_CHUNK_DESC_0802) - -STRUCT_INFO_BEGIN(MESH_CHUNK_DESC_0745) -STRUCT_VAR_INFO(flags1, TYPE_INFO(unsigned char)) -STRUCT_VAR_INFO(flags2, TYPE_INFO(unsigned char)) -STRUCT_VAR_INFO(nVerts, TYPE_INFO(int)) -STRUCT_VAR_INFO(nTVerts, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFaces, TYPE_INFO(int)) -STRUCT_VAR_INFO(VertAnimID, TYPE_INFO(int)) -STRUCT_INFO_END(MESH_CHUNK_DESC_0745) - -STRUCT_INFO_BEGIN(MESH_CHUNK_DESC_0801) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFlags2, TYPE_INFO(int)) -STRUCT_VAR_INFO(nVerts, TYPE_INFO(int)) -STRUCT_VAR_INFO(nIndices, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSubsets, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSubsetsChunkId, TYPE_INFO(int)) -STRUCT_VAR_INFO(nVertAnimID, TYPE_INFO(int)) -STRUCT_VAR_INFO(nStreamChunkID, TYPE_ARRAY(16, TYPE_INFO(int))) -STRUCT_VAR_INFO(nPhysicsDataChunkId, TYPE_ARRAY(4, TYPE_INFO(int))) -STRUCT_VAR_INFO(bboxMin, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(bboxMax, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(texMappingDensity, TYPE_INFO(float)) -STRUCT_VAR_INFO(geometricMeanFaceArea, TYPE_INFO(float)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(30, TYPE_INFO(int))) -STRUCT_INFO_END(MESH_CHUNK_DESC_0801) - -STRUCT_INFO_BEGIN(MESH_CHUNK_DESC_0802) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFlags2, TYPE_INFO(int)) -STRUCT_VAR_INFO(nVerts, TYPE_INFO(int)) -STRUCT_VAR_INFO(nIndices, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSubsets, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSubsetsChunkId, TYPE_INFO(int)) -STRUCT_VAR_INFO(nVertAnimID, TYPE_INFO(int)) -STRUCT_VAR_INFO(nStreamChunkID, TYPE_ARRAY(16, TYPE_ARRAY(8, TYPE_INFO(int)))) -STRUCT_VAR_INFO(nPhysicsDataChunkId, TYPE_ARRAY(4, TYPE_INFO(int))) -STRUCT_VAR_INFO(bboxMin, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(bboxMax, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(texMappingDensity, TYPE_INFO(float)) -STRUCT_VAR_INFO(geometricMeanFaceArea, TYPE_INFO(float)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(30, TYPE_INFO(int))) -STRUCT_INFO_END(MESH_CHUNK_DESC_0802) - -STRUCT_INFO_BEGIN(STREAM_DATA_CHUNK_DESC_0800) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nStreamType, TYPE_INFO(int)) -STRUCT_VAR_INFO(nCount, TYPE_INFO(int)) -STRUCT_VAR_INFO(nElementSize, TYPE_INFO(int)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(2, TYPE_INFO(int))) -STRUCT_INFO_END(STREAM_DATA_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(STREAM_DATA_CHUNK_DESC_0801) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nStreamType, TYPE_INFO(int)) -STRUCT_VAR_INFO(nStreamIndex, TYPE_INFO(int)) -STRUCT_VAR_INFO(nCount, TYPE_INFO(int)) -STRUCT_VAR_INFO(nElementSize, TYPE_INFO(int)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(2, TYPE_INFO(int))) -STRUCT_INFO_END(STREAM_DATA_CHUNK_DESC_0801) - -STRUCT_INFO_BEGIN(MESH_SUBSETS_CHUNK_DESC_0800::MeshSubset) -STRUCT_VAR_INFO(nFirstIndexId, TYPE_INFO(int)) -STRUCT_VAR_INFO(nNumIndices, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFirstVertId, TYPE_INFO(int)) -STRUCT_VAR_INFO(nNumVerts, TYPE_INFO(int)) -STRUCT_VAR_INFO(nMatID, TYPE_INFO(int)) -STRUCT_VAR_INFO(fRadius, TYPE_INFO(float)) -STRUCT_VAR_INFO(vCenter, TYPE_INFO(Vec3)) -STRUCT_INFO_END(MESH_SUBSETS_CHUNK_DESC_0800::MeshSubset) - -STRUCT_INFO_BEGIN(MESH_SUBSETS_CHUNK_DESC_0800::MeshBoneIDs) -STRUCT_VAR_INFO(numBoneIDs, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(arrBoneIDs, TYPE_ARRAY(128, TYPE_INFO(uint16))) -STRUCT_INFO_END(MESH_SUBSETS_CHUNK_DESC_0800::MeshBoneIDs) - -STRUCT_INFO_BEGIN(MESH_SUBSETS_CHUNK_DESC_0800::MeshSubsetTexelDensity) -STRUCT_VAR_INFO(texelDensity, TYPE_INFO(float)) -STRUCT_INFO_END(MESH_SUBSETS_CHUNK_DESC_0800::MeshSubsetTexelDensity) - - -STRUCT_INFO_BEGIN(MESH_SUBSETS_CHUNK_DESC_0800) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nCount, TYPE_INFO(int)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(2, TYPE_INFO(int))) -STRUCT_INFO_END(MESH_SUBSETS_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(MESH_PHYSICS_DATA_CHUNK_DESC_0800) -STRUCT_VAR_INFO(nDataSize, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int)) -STRUCT_VAR_INFO(nTetrahedraDataSize, TYPE_INFO(int)) -STRUCT_VAR_INFO(nTetrahedraChunkId, TYPE_INFO(int)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(2, TYPE_INFO(int))) -STRUCT_INFO_END(MESH_PHYSICS_DATA_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(BONEANIM_CHUNK_DESC_0290) -STRUCT_VAR_INFO(nBones, TYPE_INFO(int)) -STRUCT_INFO_END(BONEANIM_CHUNK_DESC_0290) - -STRUCT_INFO_BEGIN(BONENAMELIST_CHUNK_DESC_0745) -STRUCT_VAR_INFO(numEntities, TYPE_INFO(int)) -STRUCT_INFO_END(BONENAMELIST_CHUNK_DESC_0745) - -STRUCT_INFO_BEGIN(COMPILED_BONE_CHUNK_DESC_0800) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(32, TYPE_INFO(char))) -STRUCT_INFO_END(COMPILED_BONE_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(COMPILED_PHYSICALBONE_CHUNK_DESC_0800) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(32, TYPE_INFO(char))) -STRUCT_INFO_END(COMPILED_PHYSICALBONE_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(COMPILED_PHYSICALPROXY_CHUNK_DESC_0800) -STRUCT_VAR_INFO(numPhysicalProxies, TYPE_INFO(uint32)) -STRUCT_INFO_END(COMPILED_PHYSICALPROXY_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(COMPILED_MORPHTARGETS_CHUNK_DESC_0800) -STRUCT_VAR_INFO(numMorphTargets, TYPE_INFO(uint32)) -STRUCT_INFO_END(COMPILED_MORPHTARGETS_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(COMPILED_INTSKINVERTICES_CHUNK_DESC_0800) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(32, TYPE_INFO(char))) -STRUCT_INFO_END(COMPILED_INTSKINVERTICES_CHUNK_DESC_0800) - -STRUCT_INFO_BEGIN(BaseKey) -STRUCT_VAR_INFO(time, TYPE_INFO(int)) -STRUCT_INFO_END(BaseKey) - -STRUCT_INFO_BEGIN(BaseTCB) -STRUCT_VAR_INFO(t, TYPE_INFO(float)) -STRUCT_VAR_INFO(c, TYPE_INFO(float)) -STRUCT_VAR_INFO(b, TYPE_INFO(float)) -STRUCT_VAR_INFO(ein, TYPE_INFO(float)) -STRUCT_VAR_INFO(eout, TYPE_INFO(float)) -STRUCT_INFO_END(BaseTCB) - -STRUCT_INFO_BEGIN(BaseKey3) -STRUCT_BASE_INFO(BaseKey) -STRUCT_VAR_INFO(val, TYPE_INFO(Vec3)) -STRUCT_INFO_END(BaseKey3) - -STRUCT_INFO_BEGIN(BaseKeyQ) -STRUCT_BASE_INFO(BaseKey) -STRUCT_VAR_INFO(val, TYPE_INFO(CryQuat)) -STRUCT_INFO_END(BaseKeyQ) - -STRUCT_INFO_BEGIN(CryTCB3Key) -STRUCT_BASE_INFO(BaseKey3) -STRUCT_BASE_INFO(BaseTCB) -STRUCT_INFO_END(CryTCB3Key) - -STRUCT_INFO_BEGIN(CryTCBQKey) -STRUCT_BASE_INFO(BaseKeyQ) -STRUCT_BASE_INFO(BaseTCB) -STRUCT_INFO_END(CryTCBQKey) - -STRUCT_INFO_BEGIN(CryKeyPQLog) -STRUCT_VAR_INFO(nTime, TYPE_INFO(int)) -STRUCT_VAR_INFO(vPos, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(vRotLog, TYPE_INFO(Vec3)) -STRUCT_INFO_END(CryKeyPQLog) - -ENUM_INFO_BEGIN(CtrlTypes) -ENUM_ELEM_INFO(, CTRL_NONE) -ENUM_ELEM_INFO(, CTRL_CRYBONE) -ENUM_ELEM_INFO(, CTRL_LINEER1) -ENUM_ELEM_INFO(, CTRL_LINEER3) -ENUM_ELEM_INFO(, CTRL_LINEERQ) -ENUM_ELEM_INFO(, CTRL_BEZIER1) -ENUM_ELEM_INFO(, CTRL_BEZIER3) -ENUM_ELEM_INFO(, CTRL_BEZIERQ) -ENUM_ELEM_INFO(, CTRL_TCB1) -ENUM_ELEM_INFO(, CTRL_TCB3) -ENUM_ELEM_INFO(, CTRL_TCBQ) -ENUM_ELEM_INFO(, CTRL_BSPLINE_2O) -ENUM_ELEM_INFO(, CTRL_BSPLINE_1O) -ENUM_ELEM_INFO(, CTRL_BSPLINE_2C) -ENUM_ELEM_INFO(, CTRL_BSPLINE_1C) -ENUM_ELEM_INFO(, CTRL_CONST) -ENUM_INFO_END(CtrlTypes) - -STRUCT_INFO_BEGIN(CONTROLLER_CHUNK_DESC_0826) -STRUCT_VAR_INFO(type, TYPE_INFO(CtrlTypes)) -STRUCT_VAR_INFO(nKeys, TYPE_INFO(int)) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(nControllerId, TYPE_INFO(unsigned int)) -STRUCT_INFO_END(CONTROLLER_CHUNK_DESC_0826) - -STRUCT_INFO_BEGIN(CONTROLLER_CHUNK_DESC_0827) -STRUCT_VAR_INFO(numKeys, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(nControllerId, TYPE_INFO(unsigned int)) -STRUCT_INFO_END(CONTROLLER_CHUNK_DESC_0827) - -STRUCT_INFO_BEGIN(CONTROLLER_CHUNK_DESC_0829) -STRUCT_VAR_INFO(nControllerId, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(numRotationKeys, TYPE_INFO(uint16)) -STRUCT_VAR_INFO(numPositionKeys, TYPE_INFO(uint16)) -STRUCT_VAR_INFO(RotationFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(RotationTimeFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(PositionFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(PositionKeysInfo, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(PositionTimeFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(TracksAligned, TYPE_INFO(uint8)) -STRUCT_INFO_END(CONTROLLER_CHUNK_DESC_0829) - -STRUCT_INFO_BEGIN(CONTROLLER_CHUNK_DESC_0830) -STRUCT_VAR_INFO(numKeys, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(nFlags, Type_info(unsigned int)) -STRUCT_VAR_INFO(nControllerId, TYPE_INFO(unsigned int)) -STRUCT_INFO_END(CONTROLLER_CHUNK_DESC_0830) - -STRUCT_INFO_BEGIN(CONTROLLER_CHUNK_DESC_0831) -STRUCT_VAR_INFO(nControllerId, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(nFlags, Type_info(unsigned int)) -STRUCT_VAR_INFO(numRotationKeys, TYPE_INFO(uint16)) -STRUCT_VAR_INFO(numPositionKeys, TYPE_INFO(uint16)) -STRUCT_VAR_INFO(RotationFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(RotationTimeFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(PositionFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(PositionKeysInfo, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(PositionTimeFormat, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(TracksAligned, TYPE_INFO(uint8)) -STRUCT_INFO_END(CONTROLLER_CHUNK_DESC_0831) - -STRUCT_INFO_BEGIN(CONTROLLER_CHUNK_DESC_0905) -STRUCT_VAR_INFO(numKeyPos, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numKeyRot, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numKeyTime, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numAnims, TYPE_INFO(uint32)) -STRUCT_INFO_END(CONTROLLER_CHUNK_DESC_0905) - -STRUCT_INFO_BEGIN(NODE_CHUNK_DESC_0824) -STRUCT_VAR_INFO(name, TYPE_ARRAY(64, TYPE_INFO(char))) -STRUCT_VAR_INFO(ObjectID, TYPE_INFO(int)) -STRUCT_VAR_INFO(ParentID, TYPE_INFO(int)) -STRUCT_VAR_INFO(nChildren, TYPE_INFO(int)) -STRUCT_VAR_INFO(MatID, TYPE_INFO(int)) -STRUCT_VAR_INFO(_obsoleteA_, TYPE_ARRAY(4, TYPE_INFO(uint8))) -STRUCT_VAR_INFO(tm, TYPE_ARRAY(4, TYPE_ARRAY(4, TYPE_INFO(float)))) -STRUCT_VAR_INFO(_obsoleteB_, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(_obsoleteC_, TYPE_ARRAY(4, TYPE_INFO(float))) -STRUCT_VAR_INFO(_obsoleteD_, TYPE_ARRAY(3, TYPE_INFO(float))) -STRUCT_VAR_INFO(pos_cont_id, TYPE_INFO(int)) -STRUCT_VAR_INFO(rot_cont_id, TYPE_INFO(int)) -STRUCT_VAR_INFO(scl_cont_id, TYPE_INFO(int)) -STRUCT_VAR_INFO(PropStrLen, TYPE_INFO(int)) -STRUCT_INFO_END(NODE_CHUNK_DESC_0824) - -ENUM_INFO_BEGIN(HelperTypes) -ENUM_ELEM_INFO(, HP_POINT) -ENUM_ELEM_INFO(, HP_DUMMY) -ENUM_ELEM_INFO(, HP_XREF) -ENUM_ELEM_INFO(, HP_CAMERA) -ENUM_ELEM_INFO(, HP_GEOMETRY) -ENUM_INFO_END(HelperTypes) - -STRUCT_INFO_BEGIN(HELPER_CHUNK_DESC_0744) -STRUCT_VAR_INFO(type, TYPE_INFO(HelperTypes)) -STRUCT_VAR_INFO(size, TYPE_INFO(Vec3)) -STRUCT_INFO_END(HELPER_CHUNK_DESC_0744) - -STRUCT_INFO_BEGIN(MESHMORPHTARGET_CHUNK_DESC_0001) -STRUCT_VAR_INFO(nChunkIdMesh, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(numMorphVertices, TYPE_INFO(unsigned int)) -STRUCT_INFO_END(MESHMORPHTARGET_CHUNK_DESC_0001) - -STRUCT_INFO_BEGIN(SMeshMorphTargetVertex) -STRUCT_VAR_INFO(nVertexId, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(ptVertex, TYPE_INFO(Vec3)) -STRUCT_INFO_END(SMeshMorphTargetVertex) - -STRUCT_INFO_BEGIN(SMeshMorphTargetHeader) -STRUCT_VAR_INFO(MeshID, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(NameLength, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numIntVertices, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numExtVertices, TYPE_INFO(uint32)) -STRUCT_INFO_END(SMeshMorphTargetHeader) - -STRUCT_INFO_BEGIN(SMeshPhysicalProxyHeader) -STRUCT_VAR_INFO(ChunkID, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numPoints, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numIndices, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(numMaterials, TYPE_INFO(uint32)) -STRUCT_INFO_END(SMeshPhysicalProxyHeader) - -STRUCT_INFO_BEGIN(BONEINITIALPOS_CHUNK_DESC_0001) -STRUCT_VAR_INFO(nChunkIdMesh, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(numBones, TYPE_INFO(unsigned int)) -STRUCT_INFO_END(BONEINITIALPOS_CHUNK_DESC_0001) - -STRUCT_INFO_BEGIN(SBoneInitPosMatrix) -STRUCT_VAR_INFO(mx, TYPE_ARRAY(4, TYPE_ARRAY(3, TYPE_INFO(float)))) -STRUCT_INFO_END(SBoneInitPosMatrix) - -STRUCT_INFO_BEGIN(EXPORT_FLAGS_CHUNK_DESC) -STRUCT_VAR_INFO(flags, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(rc_version, TYPE_ARRAY(4, TYPE_INFO(unsigned int))) -STRUCT_VAR_INFO(rc_version_string, TYPE_ARRAY(16, TYPE_INFO(char))) -STRUCT_VAR_INFO(assetAuthorTool, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(authorToolVersion, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(reserved, TYPE_ARRAY(30, TYPE_INFO(unsigned int))) -STRUCT_INFO_END(EXPORT_FLAGS_CHUNK_DESC) - -STRUCT_INFO_BEGIN(BREAKABLE_PHYSICS_CHUNK_DESC) -STRUCT_VAR_INFO(granularity, TYPE_INFO(unsigned int)) -STRUCT_VAR_INFO(nMode, TYPE_INFO(int)) -STRUCT_VAR_INFO(nRetVtx, TYPE_INFO(int)) -STRUCT_VAR_INFO(nRetTets, TYPE_INFO(int)) -STRUCT_VAR_INFO(nReserved, TYPE_ARRAY(10, TYPE_INFO(int))) -STRUCT_INFO_END(BREAKABLE_PHYSICS_CHUNK_DESC) - -STRUCT_INFO_BEGIN(FOLIAGE_INFO_CHUNK_DESC) -STRUCT_VAR_INFO(nSpines, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSpineVtx, TYPE_INFO(int)) -STRUCT_VAR_INFO(nSkinnedVtx, TYPE_INFO(int)) -STRUCT_VAR_INFO(nBoneIds, TYPE_INFO(int)) -STRUCT_INFO_END(FOLIAGE_INFO_CHUNK_DESC) - -STRUCT_INFO_BEGIN(FOLIAGE_SPINE_SUB_CHUNK) -STRUCT_VAR_INFO(nVtx, TYPE_INFO(char)) -STRUCT_VAR_INFO(len, TYPE_INFO(float)) -STRUCT_VAR_INFO(navg, TYPE_INFO(Vec3)) -STRUCT_VAR_INFO(iAttachSpine, TYPE_INFO(unsigned char)) -STRUCT_VAR_INFO(iAttachSeg, TYPE_INFO(unsigned char)) -STRUCT_INFO_END(FOLIAGE_SPINE_SUB_CHUNK) diff --git a/Code/Legacy/CryCommon/CrySizer.h b/Code/Legacy/CryCommon/CrySizer.h index 3f9eed84f6..27323368ab 100644 --- a/Code/Legacy/CryCommon/CrySizer.h +++ b/Code/Legacy/CryCommon/CrySizer.h @@ -24,7 +24,6 @@ #include "Cry_Math.h" #include -#include #include #include #include @@ -36,7 +35,6 @@ struct AABB; struct SVF_P3F; struct SVF_P3F_C4B_T2F; -struct SVF_P3F_C4B_T2S; struct SVF_P3S_C4B_T2S; struct SPipTangents; @@ -237,7 +235,6 @@ public: void AddObject(const AABB&) {} void AddObject(const SVF_P3F&) {} void AddObject(const SVF_P3F_C4B_T2F&) {} - void AddObject(const SVF_P3F_C4B_T2S&) {} void AddObject(const SVF_P3S_C4B_T2S&) {} void AddObject(const SPipTangents&) {} void AddObject([[maybe_unused]] const AZ::Vector3& rObj) {} @@ -301,26 +298,6 @@ public: } } - template - void AddObject(const DynArray& rVector) - { - if (rVector.empty()) - { - this->AddObject(rVector.begin(), rVector.get_alloc_size()); - return; - } - - if (!this->AddObject(rVector.begin(), rVector.get_alloc_size())) - { - return; - } - - for (typename DynArray::const_iterator it = rVector.begin(); it != rVector.end(); ++it) - { - this->AddObject(*it); - } - } - template void AddObject(const PodArray& rVector) { diff --git a/Code/Legacy/CryCommon/CryTypeInfo.cpp b/Code/Legacy/CryCommon/CryTypeInfo.cpp deleted file mode 100644 index 82743f7eef..0000000000 --- a/Code/Legacy/CryCommon/CryTypeInfo.cpp +++ /dev/null @@ -1,1472 +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 TypeInfo classes and functions. - -#include -#include "CryTypeInfo.h" -#include "CryCustomTypes.h" -#include "Cry_Math.h" -#include "CrySizer.h" -#include "CryEndian.h" -#include "TypeInfo_impl.h" -#include - -// Traits -#if defined(AZ_RESTRICTED_PLATFORM) - #include AZ_RESTRICTED_FILE(CryTypeInfo_cpp) -#elif defined(LINUX) || defined(APPLE) -#define CRYTYPEINFO_CPP_TRAIT_DEFINE_LTOA_S 1 -#endif - -#if CRYTYPEINFO_CPP_TRAIT_DEFINE_LTOA_S - -char* _ltoa_s(long value, char* string, size_t size, int32 radix) -{ - if (10 == radix) - { - sprintf_s(string, size, "%ld", value); - } - else - { - sprintf_s(string, size, "%lx", value); - } - return(string); -} - - -char* _i64toa_s(int64 value, char* string, size_t size, int32 radix) -{ - if (10 == radix) - { - sprintf_s(string, size, "%llu", (unsigned long long)value); - } - else - { - sprintf_s(string, size, "%llx", (unsigned long long)value); - } - return(string); -} - -char* _ultoa_s(uint32 value, char* string, size_t size, int32 radix) -{ - if (10 == radix) - { - sprintf_s(string, size, "%.d", value); - } - else - { - sprintf_s(string, size, "%.x", value); - } - return(string); -} - -#endif //LINUX || MAC - -////////////////////////////////////////////////////////////////////// -// Case-insensitive comparison helpers. - -class StrNoCase -{ -public: - inline StrNoCase(cstr str) - : m_Str(str) {} - inline bool operator == (cstr str) const { return azstricmp(m_Str, str) == 0; } - inline bool operator != (cstr str) const { return azstricmp(m_Str, str) != 0; } -private: - cstr m_Str; -}; - -// Default Endian swap function, forwards to TypeInfo. -void SwapEndian(const CTypeInfo& Info, [[maybe_unused]] size_t nSizeCheck, void* data, size_t nCount, bool bWriting) -{ - assert(nSizeCheck == Info.Size); - Info.SwapEndian(data, nCount, bWriting); -} - -////////////////////////////////////////////////////////////////////// -// Basic TypeInfo implementations. - -// Basic type infos. - -DEFINE_TYPE_INFO(void, CTypeInfo, ("void", 0, 0)) - -TYPE_INFO_BASIC(bool) -TYPE_INFO_BASIC(char) -TYPE_INFO_BASIC(wchar_t) - -TYPE_INFO_INT(signed char) -TYPE_INFO_INT(unsigned char) -TYPE_INFO_INT(short) -TYPE_INFO_INT(unsigned short) -TYPE_INFO_INT(int) -TYPE_INFO_INT(unsigned int) -TYPE_INFO_INT(long) -TYPE_INFO_INT(unsigned long) -TYPE_INFO_INT(int64) -TYPE_INFO_INT(uint64) - -TYPE_INFO_BASIC(float) -TYPE_INFO_BASIC(double) - -TYPE_INFO_BASIC(AZStd::string) - - -const CTypeInfo&PtrTypeInfo() -{ - static CTypeInfo Info(TYPE_INFO_NAME(void*), sizeof(void*), alignof(void*)); - return Info; -} - -////////////////////////////////////////////////////////////////////// -// Basic type info implementations. - -// String conversion functions needed by TypeInfo. - -// bool -AZStd::string ToString(bool const& val) -{ - return val ? "true" : "false"; -} - -bool FromString(bool& val, cstr s) -{ - if (!strcmp(s, "0") || !azstricmp(s, "false")) - { - val = false; - return true; - } - if (!strcmp(s, "1") || !azstricmp(s, "true")) - { - val = true; - return true; - } - return false; -} - -// int64 -AZStd::string ToString(int64 const& val) -{ - char buffer[64]; - _i64toa_s(val, buffer, sizeof(buffer), 10); - return buffer; -} -// uint64 -AZStd::string ToString(uint64 const& val) -{ - char buffer[64]; - sprintf_s(buffer, "%" PRIu64, val); - return buffer; -} - - - -// long -AZStd::string ToString(long const& val) -{ - char buffer[64]; - _ltoa_s(val, buffer, sizeof(buffer), 10); - return buffer; -} - -// ulong -AZStd::string ToString(unsigned long const& val) -{ - char buffer[64]; - _ultoa_s(val, buffer, sizeof(buffer), 10); - return buffer; -} - -template -bool ClampedIntFromString(T& val, const char* s) -{ - bool signbit = *s == '-'; - s += signbit; - if (signbit && !TIntTraits::bSIGNED) - { - // Negative number on unsigned. - val = T(0); - return true; - } - - uint digit = (uint8) * s - '0'; - if (digit > 9) - { - // No digits. - return false; - } - - // Extract digits until overflow. - T v = static_cast(digit); - while ((digit = (uint8) * ++s - '0') <= 9) - { - T vnew = static_cast(v * 10 + digit); - if (vnew < v) - { - // Overflow. - if (signbit) - { - val = TIntTraits::nMIN; - } - else - { - val = TIntTraits::nMAX; - } - return true; - } - v = vnew; - } - - val = signbit ? ~v + 1 : v; - return true; -} - -bool FromString(int64& val, const char* s) { return ClampedIntFromString(val, s); } -bool FromString(uint64& val, const char* s) { return ClampedIntFromString(val, s); } - -bool FromString(long& val, const char* s) { return ClampedIntFromString(val, s); } -bool FromString(unsigned long& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(int const& val) { return ToString(long(val)); } -bool FromString(int& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(unsigned int const& val) { return ToString((unsigned long)(val)); } -bool FromString(unsigned int& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(short const& val) { return ToString(long(val)); } -bool FromString(short& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(unsigned short const& val) { return ToString((unsigned long)(val)); } -bool FromString(unsigned short& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(char const& val) { return ToString(long(val)); } -bool FromString(char& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(wchar_t const& val) { return ToString(long(val)); } -bool FromString(wchar_t& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(signed char const& val) { return ToString(long(val)); } -bool FromString(signed char& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(unsigned char const& val) { return ToString((unsigned long)(val)); } -bool FromString(unsigned char& val, const char* s) { return ClampedIntFromString(val, s); } - -AZStd::string ToString(const AZ::Uuid& val) -{ - return val.ToString(); -} - -bool FromString(AZ::Uuid& val, const char* s) -{ - val = AZ::Uuid(s); - return true; -} - -float NumToFromString(float val, int digits, bool floating, char buffer[], int buf_size) -{ - assert(buf_size >= 32); - if (floating) - { - if (val >= powf(10.f, float(digits))) - { - sprintf_s(buffer, buf_size, "%.0f", val); - } - else - { - sprintf_s(buffer, buf_size, "%.*g", digits, val); - } - } - else - { - sprintf_s(buffer, buf_size, "%.*f", digits, float(val)); - } -#if !defined(NDEBUG) - int readCount = -#endif - azsscanf(buffer, "%g", &val); - assert(readCount == 1); - return val; -} - -// double -AZStd::string ToString(double const& val) -{ - char buffer[64]; - sprintf_s(buffer, "%.16g", val); - return buffer; -} -bool FromString(double& val, const char* s) -{ - return azsscanf(s, "%lg", &val) == 1; -} - -// float -AZStd::string ToString(float const& val) -{ - char buffer[64]; - for (int digits = 7; digits < 10; digits++) - { - if (NumToFromString(val, digits, true, buffer, 64) == val) - { - break; - } - } - return buffer; -} - -bool FromString(float& val, const char* s) -{ - return azsscanf(s, "%g", &val) == 1; -} - - - -// string override. -template <> -void TTypeInfo::GetMemoryUsage(ICrySizer* pSizer, void const* data) const -{ - // CRAIG: just a temp hack to try and get things working -#if !defined(LINUX) && !defined(APPLE) - pSizer->AddString(*(AZStd::string*)data); -#endif -} - -#if defined(TEST_TYPEINFO) && defined(_DEBUG) - -struct STypeInfoTest -{ - STypeInfoTest() - { - TestType(AZStd::string("well")); - - TestType(true); - - TestType(int8(-0x12)); - TestType(uint8(0x87)); - TestType(int16(-0x1234)); - TestType(uint16(0x8765)); - TestType(int32(-0x12345678)); - TestType(uint32(0x87654321)); - TestType(int64(-0x123456789ABCDEF0LL)); - TestType(uint64(0xFEDCBA9876543210LL)); - - TestType(float(1234.5678)); - TestType(float(12345678)); - TestType(float(12345678e-20)); - TestType(float(12345678e20)); - - TestType(double(987654321.0123456789)); - TestType(double(9876543210123456789.0)); - TestType(double(9876543210123456789e-40)); - TestType(double(9876543210123456789e40)); - } -}; -static STypeInfoTest _TypeInfoTest; - -#endif //TEST_TYPEINFO - - -////////////////////////////////////////////////////////////////////// -// CTypeInfo implementation - -//--------------------------------------------------------------------------- -// Endian helper functions. - -void CTypeInfo::SwapEndian(void* pData, size_t nCount, [[maybe_unused]] bool bWriting) const -{ - switch (Size) - { - case 1: - break; - case 2: - ::SwapEndianBase((uint16*)pData, nCount); - break; - case 4: - ::SwapEndianBase((uint32*)pData, nCount); - break; - case 8: - ::SwapEndianBase((uint64*)pData, nCount); - break; - default: - assert(0); - } -} - -// If attr name is found, return pointer to start of value text; else 0. -static cstr FindAttr(cstr attrs, cstr name) -{ - size_t name_len = strlen(name); - while (attrs) - { - attrs = strchr(attrs, '<'); - if (!attrs) - { - return 0; - } - - attrs++; - size_t attr_len = strcspn(attrs, "=>"); - if (attr_len == name_len && _strnicmp(attrs, name, name_len) == 0) - { - attrs += attr_len; - if (*attrs == '=') - { - ++attrs; - } - return attrs; - } - attrs += attr_len; - if (*attrs == '=') - { - attrs = strchr(attrs + 1, '>'); - } - } - return 0; -} - -bool CTypeInfo::CVarInfo::GetAttr(cstr name) const -{ - return FindAttr(Attrs, name) != 0; -} - -bool CTypeInfo::CVarInfo::GetAttr(cstr name, AZStd::string& val) const -{ - cstr valstr = FindAttr(Attrs, name); - if (!valstr) - { - return false; - } - - // Find attr delimiter. - cstr end = strchr(valstr, '>'); - if (!end) - { - return false; - } - - // Strip quotes. - if (*valstr == '"') - { - valstr++; - if (end - valstr > 1 && end[-1] == '"') - { - end--; - } - } - val = AZStd::string(valstr, end - valstr); - return true; -} - -bool CTypeInfo::CVarInfo::GetAttr(cstr name, float& val) const -{ - cstr valstr = FindAttr(Attrs, name); - if (!valstr) - { - return false; - } - val = (float)atof(valstr); - return true; -} - -cstr CTypeInfo::CVarInfo::GetComment() const -{ - cstr send = strrchr(Attrs, '>'); - if (send) - { - do - { - ++send; - } while (*send == ' '); - return send; - } - else - { - return Attrs; - } -} - -////////////////////////////////////////////////////////////////////// -// CStructInfo implementation - -inline cstr DisplayName(cstr name) -{ - // Skip prefixes in Name. - cstr dname = name; - while (islower((unsigned char)*dname) || *dname == '_') - { - dname++; - } - if (isupper((unsigned char)*dname)) - { - return dname; - } - else - { - return name; - } -} - -CStructInfo::CStructInfo(cstr name, size_t size, size_t align, Array vars, Array templates) - : CTypeInfo(name, size, align) - , Vars(vars) - , TemplateTypes(templates) - , HasBitfields(false) -{ - // Process and validate offsets and sizes. - if (Vars.size() > 0) - { - size = 0; - int bitoffset = 0; - - for (int i = 0; i < Vars.size(); i++) - { - CStructInfo::CVarInfo& var = Vars[i]; - - // Convert name. - var.Name = DisplayName(var.Name); - - if (var.bBitfield) - { - HasBitfields = true; - if (bitoffset > 0) - { - // Continuing bitfield. - var.Offset = Vars[i - 1].Offset; - var.BitWordWidth = Vars[i - 1].BitWordWidth; - - if (bitoffset + var.ArrayDim > var.GetSize() * 8) - { - // Overflows word, start on next one. - bitoffset = 0; - size += var.GetSize(); - } - } - - if (bitoffset == 0) - { - var.Offset = check_cast(size); - - // Detect real word size of bitfield, from offset of next field. - size_t next_offset = Size; - for (int j = i + 1; j < Vars.size(); j++) - { - if (!Vars[j].bBitfield) - { - next_offset = Vars[j].Offset; - break; - } - } - assert(next_offset > size); - size_t wordsize = min(next_offset - size, var.Type.Size); - size = next_offset; - switch (wordsize) - { - case 1: - var.BitWordWidth = 0; - break; - case 2: - var.BitWordWidth = 1; - break; - case 4: - var.BitWordWidth = 2; - break; - case 8: - var.BitWordWidth = 3; - break; - default: - assert(0); - } - } - - assert(var.ArrayDim <= var.GetSize() * 8); - var.BitOffset = bitoffset; - bitoffset += var.ArrayDim; - } - else - { - bitoffset = 0; - if (var.Offset >= size) - { - size = var.Offset + var.GetSize(); - } - } - } - assert(Align(size, Alignment) == Align(Size, Alignment)); - } -} - -size_t EndianDescSize(cstr desc) -{ - // Iterate the endian descriptor. - size_t nSize = 0; - for (; *desc; desc++) - { - size_t count = *desc & 0x3F; - size_t nType = *(uint8*)desc >> 6; - nSize += count << nType; - } - return nSize; -} - -size_t CStructInfo::AddEndianDesc(cstr desc, size_t dim, size_t elem_size) -{ - if (dim == 0) - { - return 0; - } - - size_t endian_size = EndianDescSize(desc); - size_t total_size = elem_size * (dim - 1) + endian_size; - - if (desc[1] || (endian_size < elem_size && dim > 1)) - { - // Composite endian descriptor, replicate it. - assert(endian_size <= elem_size); - assert(elem_size - endian_size < 0x40); - while (dim-- > 0) - { - EndianDesc += (cstr)desc; - if (dim > 1 && endian_size < elem_size) - { - EndianDesc += char(0x40 | (elem_size - endian_size)); - } - } - } - else - { - // Single endian component. Replicate using count field. - size_t subdim = desc[0] & 0x3F; - dim *= subdim; - if (!EndianDesc.empty()) - { - // Combine with previous component if possible. - char prevdesc = *(EndianDesc.end() - 1); - if ((prevdesc & ~0x3F) == (desc[0] & ~0x3F)) - { - // Combine with previous char. - size_t maxdim = min(dim, size_t(0x3F - (prevdesc & 0x3F))); - prevdesc += check_cast(maxdim); - EndianDesc.erase(EndianDesc.length() - 1, 1); - EndianDesc.append(1, prevdesc); - dim -= maxdim; - } - } - for (; dim > 0x3F; dim -= 0x3F) - { - EndianDesc += desc[0] | 0x3F; - } - if (dim > 0) - { - EndianDesc += check_cast((desc[0] & ~0x3F) | dim); - } - } - - return total_size; -} - -bool CStructInfo::FromValue(void* data, const void* value, const CTypeInfo& typeVal) const -{ - if (IsCompatibleType(typeVal)) - { - bool bOK = true; - int i = 0; - for AllSubVars(pToVar, typeVal) - { - if (!Vars[i].Type.FromValue(Vars[i].GetAddress(data), pToVar->GetAddress(value), pToVar->Type)) - { - bOK = false; - } - i++; - } - return bOK; - } - - // Check all subclasses. - for (int i = 0; i < Vars.size() && Vars[i].IsBaseClass(); i++) - { - if (Vars[i].Type.FromValue(Vars[i].GetAddress(data), value, typeVal)) - { - return true; - } - } - return false; -} - -bool CStructInfo::ToValue(const void* data, void* value, const CTypeInfo& typeVal) const -{ - if (IsCompatibleType(typeVal)) - { - bool bOK = true; - int i = 0; - for AllSubVars(pToVar, typeVal) - { - if (!Vars[i].Type.ToValue(Vars[i].GetAddress(data), pToVar->GetAddress(value), pToVar->Type)) - { - bOK = false; - } - i++; - } - return bOK; - } - - // Check all subclasses. - for (int i = 0; i < Vars.size() && Vars[i].IsBaseClass(); i++) - { - if (Vars[i].Type.ToValue(Vars[i].GetAddress(data), value, typeVal)) - { - return true; - } - } - return false; -} - -// Parse structs as comma-separated values. - -/* , 1, ,2 1,2 - - Top 1 ,2 1,2 ; strip trail commas - Child Named 1 (,2) (1,2) ; strip trail commas, paren if internal commas - Nameless , 1, ,2 1,2 ; -*/ - -static void StripCommas(AZStd::string& str) -{ - size_t nLast = str.size(); - while (nLast > 0 && str[nLast - 1] == ',') - { - nLast--; - } - str.resize(nLast); -} - -AZStd::string CStructInfo::ToString(const void* data, FToString flags, const void* def_data) const -{ - AZStd::string str; // Return str. - - for (int i = 0; i < Vars.size(); i++) - { - // Handling of empty values: Skip trailing empty values. - // If there are intermediate empty values, replace them with non-empty ones. - const CVarInfo& var = Vars[i]; - - if (!var.IsInline()) - { - // Named sub var or struct. - if (!flags.NamedFields && i > 0) - { - str += ","; - } - - AZStd::string substr = var.ToString(data, FToString(flags).Sub(0), def_data); - - if (flags.SkipDefault && substr.empty()) - { - continue; - } - - if (flags.NamedFields) - { - if (*str.c_str()) - { - str += ","; - } - if (*var.Name) - { - str += var.Name; - str += "="; - } - } - if (substr.find(',') != AZStd::string::npos || substr.find('=') != AZStd::string::npos) - { - // Encase nested composite types in parens. - str += "("; - str += substr; - str += ")"; - } - else - { - str += substr; - } - } - else - { - // Nameless base struct. Treat children as inline. - str += var.ToString(data, FToString(flags).Sub(1), def_data); - } - } - - if (flags.SkipDefault && !flags.Sub) - { - StripCommas(str); - } - return str; -} - -// Retrieve and return one subelement from src, advancing the pointer. -// Copy to tempstr if necessary. - -typedef AZStd::fixed_string<256> CTempStr; - -void ParseElement(cstr& src, cstr& varname, cstr& val, CTempStr& tempstr) -{ - varname = val = 0; - - while (*src == ' ') - { - src++; - } - if (!*src) - { - return; - } - - // Find end of var assignment. - int nest = 0; - cstr eq = 0; - - cstr end; - for (end = src; *end; end++) - { - if (*end == '(') - { - nest++; - } - else if (*end == ')') - { - nest--; - } - else if (nest == 0) - { - if (*end == '=' && !eq) - { - eq = end; - } - else if (*end == ',') - { - break; - } - } - } - - // Advance src past element. - val = src; - src = end; - - if (*src == ',') - { - src++; - } - - if (eq) - { - varname = val; - val = eq + 1; - } - - PREFAST_ASSUME(val); - if (*val == '(' && end[-1] == ')') - { - // Remove parens. - val++; - end--; - } - - if (eq) - { - if (*end) - { - // Must copy sub string to temp. - val = tempstr.c_str() + (val - varname); - eq = tempstr.c_str() + (eq - varname); - tempstr.assign(varname, end); - varname = tempstr.c_str(); - non_const(*eq) = 0; - } - else - { - // Copy just varname to temp, return val in place. - tempstr.assign(varname, eq); - varname = tempstr.c_str(); - } - } - else if (*end) - { - // Must copy sub string to temp. - tempstr.assign(val, end); - val = tempstr.c_str(); - } - - // Else can return val without copying. -} - -bool CStructInfo::FromString(void* data, cstr str, FFromString flags) const -{ - if (!flags.SkipEmpty) - { - // Initialise all to default - for (int i = 0; i < Vars.size(); i++) - { - Vars[i].FromString(data, ""); - } - } - - CTempStr tempstr; - const CVarInfo* pVar = 0; - int nErrors = 0; - - while (*str) - { - cstr varname, val; - ParseElement(str, varname, val, tempstr); - - if (varname) - { - pVar = FindSubVar(varname); - } - else - { - pVar = NextSubVar(pVar, true); - } - if (pVar) - { - if (*val || !flags.SkipEmpty) - { - nErrors += !pVar->FromString(data, val, flags); - } - } - else - { - nErrors++; - } - } - - return !nErrors; -} - -bool CStructInfo::ValueEqual(const void* data, const void* def_data) const -{ - for (int i = 0; i < Vars.size(); i++) - { - const CVarInfo& var = Vars[i]; - if (!var.Type.ValueEqual((char*)data + var.Offset, (def_data ? (char*)def_data + var.Offset : 0))) - { - return false; - } - } - return true; -} - -void CStructInfo::SwapEndian(void* data, size_t nCount, bool bWriting) const -{ - non_const(*this).MakeEndianDesc(); - - if (EndianDesc.length() == 1 && !HasBitfields && EndianDescSize(EndianDesc.c_str()) == Size) - { - // Optimised array swap. - size_t nElems = (EndianDesc[0u] & 0x3F) * nCount; - switch (EndianDesc[0u] & 0xC0) - { - case 0: // Skip bytes - break; - case 0x40: // Swap 2 bytes - ::SwapEndianBase((uint16*)data, nElems); - break; - case 0x80: // Swap 4 bytes - ::SwapEndianBase((uint32*)data, nElems); - break; - case 0xC0: // Swap 8 bytes - ::SwapEndianBase((uint64*)data, nElems); - break; - } - return; - } - - for (; nCount-- > 0; data = (char*)data + Size) - { - // First swap bits. - // Iterate the endian descriptor. - void* step = data; - for (cstr desc = EndianDesc.c_str(); *desc; desc++) - { - size_t nElems = *desc & 0x3F; - switch (*desc & 0xC0) - { - case 0: // Skip bytes - step = (uint8*)step + nElems; - break; - case 0x40: // Swap 2 bytes - ::SwapEndianBase((uint16*)step, nElems); - step = (uint16*)step + nElems; - break; - case 0x80: // Swap 4 bytes - ::SwapEndianBase((uint32*)step, nElems); - step = (uint32*)step + nElems; - break; - case 0xC0: // Swap 8 bytes - ::SwapEndianBase((uint64*)step, nElems); - step = (uint64*)step + nElems; - break; - } - } - - // Then bitfields if needed. - if (HasBitfields) - { - uint64 uOrigBits = 0, uNewBits = 0; - for (int i = 0; i < Vars.size(); i++) - { - CVarInfo const& var = Vars[i]; - if (var.bBitfield) - { - // Reverse location of all bitfields in word. - size_t nWordBits = var.GetElemSize() * 8; - assert(nWordBits <= 64); - if (var.BitOffset == 0) - { - // Initialise bitfield swapping. - var.Type.ToValue(var.GetAddress(data), uOrigBits); - uNewBits = 0; - } - size_t nSrcOffset = (GetPlatformEndian() == eLittleEndian) == bWriting ? var.BitOffset : nWordBits - var.GetBits() - var.BitOffset; - size_t nDstOffset = nWordBits - var.GetBits() - nSrcOffset; - - uint64 uFieldVal = uOrigBits >> nSrcOffset; - uFieldVal &= ((1 << var.GetBits()) - 1); - uNewBits |= uFieldVal << nDstOffset; - var.Type.FromValue(var.GetAddress(data), uNewBits); - } - } - } - } -} - -void CStructInfo::MakeEndianDesc() -{ - if (!EndianDesc.empty()) - { - return; - } - - size_t last_offset = 0; - for (int i = 0; i < Vars.size(); i++) - { - CVarInfo const& var = Vars[i]; - bool bUnionAlias = var.bBitfield ? var.BitOffset > 0 : var.Offset < last_offset; - if (!bUnionAlias) - { - // Add endian desc for member. - cstr subdesc = 0; - if (var.Type.HasSubVars()) - { - // Struct-computed endian desc. - CStructInfo const& infoSub = static_cast(var.Type); - non_const(infoSub).MakeEndianDesc(); - subdesc = infoSub.EndianDesc.c_str(); - if (!*subdesc) - { - // No swapping. - continue; - } - } - else - { - // Basic type. - switch (var.GetElemSize()) - { - case 0: - case 1: - continue; // No swapping needed. - case 2: - subdesc = "\x41"; - break; - case 4: - subdesc = "\x81"; - break; - case 8: - subdesc = "\xC1"; - break; - default: - assert(0); - } - } - - // Apply any padding to current offset. - assert(last_offset <= var.Offset); - if (last_offset < var.Offset) - { - last_offset += AddEndianDesc("\x01", var.Offset - last_offset, 1); - } - last_offset += AddEndianDesc(subdesc, var.GetDim(), var.GetElemSize()); - } - } -} - -void CStructInfo::GetMemoryUsage(ICrySizer* pSizer, void const* data) const -{ - for (int i = 0; i < Vars.size(); i++) - { - Vars[i].Type.GetMemoryUsage(pSizer, (char*)data + Vars[i].Offset); - } -} - -const CTypeInfo::CVarInfo* CStructInfo::NextSubVar(const CVarInfo* pPrev, bool bRecurseBase) const -{ - if (pPrev >= Vars.begin() && pPrev < Vars.end()) - { - // pPrev is within this struct's vars - if (++pPrev < Vars.end()) - { - return pPrev; - } - return 0; - } - - if (Vars.empty()) - { - return 0; - } - - if (bRecurseBase) - { - // Recurse into inline base structs - const CVarInfo* pBase = Vars.begin(); - if (pBase->IsInline()) - { - if (const CVarInfo* pNext = pBase->Type.NextSubVar(pPrev, true)) - { - return pNext; - } - if (++pBase < Vars.end()) - { - return pBase; - } - return 0; - } - } - - if (!pPrev) - { - // Return first var - return Vars.begin(); - } - - return 0; -} - -const CTypeInfo::CVarInfo* CStructInfo::FindSubVar(cstr name) const -{ - static int s_nLast = 0; - int nSize = Vars.size(); - if (s_nLast >= nSize) - { - s_nLast = 0; - } - - for (int i = s_nLast, iEnd = s_nLast + nSize; i < iEnd; i++) - { - int v = i >= nSize ? i - nSize : i; - const CVarInfo& var = Vars[v]; - if (var.Type.Size > 0 && StrNoCase(var.GetName()) == name) - { - s_nLast = v; - return &var; - } - if (var.IsBaseClass()) - { - if (const CVarInfo* pSubVar = var.Type.FindSubVar(name)) - { - return pSubVar; - } - } - } - return 0; -} - -bool CStructInfo::IsCompatibleType(CTypeInfo const& Info) const -{ - if (this == &Info) - { - return true; - } - - if (!TemplateTypes.empty() && Info.IsTemplate() && strcmp(Name, Info.Name) == 0) - { - CTypeInfo const* const* pA = NextTemplateType(0); - CTypeInfo const* const* pB = Info.NextTemplateType(0); - - while (pA && pB && (*pA)->IsType(**pB)) - { - pA = Info.NextTemplateType(pA); - pB = Info.NextTemplateType(pB); - } - return !pA && !pB; - } - - return false; -} - -bool CStructInfo::IsType(CTypeInfo const& Info) const -{ - if (IsCompatibleType(Info)) - { - return true; - } - - // Check all subclasses. - for (int i = 0; i < Vars.size() && Vars[i].IsBaseClass(); i++) - { - if (Vars[i].Type.IsType(Info)) - { - return true; - } - } - return false; -} - -////////////////////////////////////////////////////////////////////// -// CSimpleEnumDef implementation - -cstr ParseNextEnum(char*& rs) -{ - char* s = rs; - while (isspace(*s)) - { - s++; - } - if (!*s) - { - return 0; - } - - cstr se = s; - while (isalnum(*s) || *s == '_') - { - s++; - } - - if (*s == ',') - { - *s++ = 0; - } - else if (*s) - { - *s++ = 0; - while (*s && *s != ',') - { - s++; - } - if (*s) - { - s++; - } - } - rs = s; - return se; -} - -void CSimpleEnumDef::Init(Array names, char* enum_str) -{ - asNames = names; - - // Split copy of enums string into elements, store in array. - int i = 0; - while (cstr se = ParseNextEnum(enum_str)) - { - asNames[i++] = se; - } -} - -////////////////////////////////////////////////////////////////////// -// CEnumDef implementation - -void CEnumDef::Init(Array elems, char* enum_str) -{ - Elems = elems; - MinValue = 0; - bRegular = true; - nPrefixLength = 0; - - if (enum_str) - { - // Parse enum names from str - int i = 0; - while (cstr se = ParseNextEnum(enum_str)) - { - Elems[i++].Name = se; - } - } - - // Analyse names and values. - if (!elems.empty()) - { - cstr sPrefix = ""; - MinValue = Elems[0].Value; - for (int i = 0; i < elems.size(); i++) - { - if (Elems[i].Value != i + Elems[0].Value) - { - bRegular = false; - } - MinValue = min(MinValue, Elems[i].Value); - - // Find common prefix. - cstr sElem = Elems[i].Name; - if (*sElem) - { - if (!*sPrefix) - { - sPrefix = sElem; - nPrefixLength = static_cast(strlen(sPrefix)); - } - else - { - uint p = 0; - while (p < nPrefixLength && sElem[p] == sPrefix[p]) - { - p++; - } - nPrefixLength = p; - } - } - } - - // Ensure prefix is on underscore boundary. - while (nPrefixLength > 0 && sPrefix[nPrefixLength - 1] != '_') - { - nPrefixLength--; - } - } -} - -bool CEnumDef::MatchName(uint i, cstr str) const -{ - cstr name = Elems[i].Name; - if (*name && nPrefixLength) - { - if (azstricmp(name + nPrefixLength, str) == 0) - { - return true; - } - } - if (*name == '_') - { - name++; - } - return azstricmp(name, str) == 0; -} - -cstr CEnumDef::ToName(TValue value) const -{ - // Find matching element. - if (bRegular) - { - TValue index = value - MinValue; - if (index >= 0 && index < Elems.size()) - { - return Name((uint)index); - } - } - else - { - for (int i = 0; i < Elems.size(); i++) - { - if (Elems[i].Value == value) - { - return Name(i); - } - } - } - - // No match - return 0; -} - -LegacyDynArray* CEnumDef::SInit::s_pElems = 0; - -void CEnumDefUuid::Init(Array elems, char* enum_str) -{ - Elems = elems; - bRegular = false; - nPrefixLength = 0; - - if (enum_str) - { - // Parse enum names from str - int i = 0; - while (cstr se = ParseNextEnum(enum_str)) - { - Elems[i++].Name = se; - } - } - - // Analyse names and values. - if (!elems.empty()) - { - cstr sPrefix = ""; - for (int i = 0; i < elems.size(); i++) - { - // Find common prefix. - cstr sElem = Elems[i].Name; - if (*sElem) - { - if (!*sPrefix) - { - sPrefix = sElem; - nPrefixLength = static_cast(strlen(sPrefix)); - } - else - { - uint p = 0; - while (p < nPrefixLength && sElem[p] == sPrefix[p]) - { - p++; - } - nPrefixLength = p; - } - } - } - - // Ensure prefix is on underscore boundary. - while (nPrefixLength > 0 && sPrefix[nPrefixLength - 1] != '_') - { - nPrefixLength--; - } - } -} - -bool CEnumDefUuid::MatchName(uint i, cstr str) const -{ - cstr name = Elems[i].Name; - if (*name && nPrefixLength) - { - if (azstricmp(name + nPrefixLength, str) == 0) - { - return true; - } - } - if (*name == '_') - { - name++; - } - return azstricmp(name, str) == 0; -} - -cstr CEnumDefUuid::ToName(AZ::Uuid value) const -{ - // Find matching element. - for (int i = 0; i < Elems.size(); ++i) - { - if (Elems[i].Value == value) - { - return Elems[i].Name; - } - } - // No match - return 0; -} diff --git a/Code/Legacy/CryCommon/CryTypeInfo.h b/Code/Legacy/CryCommon/CryTypeInfo.h deleted file mode 100644 index dbc3fdb642..0000000000 --- a/Code/Legacy/CryCommon/CryTypeInfo.h +++ /dev/null @@ -1,219 +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 of CTypeInfo and related types. - - -#ifndef CRYINCLUDE_CRYCOMMON_CRYTYPEINFO_H -#define CRYINCLUDE_CRYCOMMON_CRYTYPEINFO_H -#pragma once - -#include -#include "CryArray.h" -#include "Options.h" -#include "TypeInfo_decl.h" - -class ICrySizer; - -//--------------------------------------------------------------------------- -// Specify options for converting data to/from strings -struct FToString -{ - OPT_STRUCT(FToString) - OPT_VAR(bool, SkipDefault) // Omit default values on writing. - OPT_VAR(bool, NamedFields) // Add Name= text to sub-values. - OPT_VAR(bool, Sub) // Write sub-structures (internal usage). -}; - -struct FFromString -{ - OPT_STRUCT(FFromString) - OPT_VAR(bool, SkipEmpty) // Do not set values from empty strings (otherwise, set to zero). -}; - -// Specify which limits a variable has -enum ENumericLimit -{ - eLimit_Min, - eLimit_Max, - eLimit_SoftMin, - eLimit_SoftMax, - eLimit_MinIsInfinite, - eLimit_Step, -}; - -//--------------------------------------------------------------------------- -// Type info base class, and default implementation - -struct CTypeInfo -{ - cstr Name; - size_t Size; - size_t Alignment; - - CTypeInfo(cstr name, size_t size, size_t align) - : Name(name) - , Size(size) - , Alignment(align) {} - - virtual ~CTypeInfo() - {} - - // - // Inheritance. - // - virtual bool IsType(CTypeInfo const& Info) const - { return this == &Info; } - - template - bool IsType() const - { return IsType(TypeInfo((T*)0)); } - - // - // Data access interface. - // - - // Convert value to string. - virtual AZStd::string ToString([[maybe_unused]] const void* data, [[maybe_unused]] FToString flags = 0, [[maybe_unused]] const void* def_data = 0) const - { return ""; } - - // Write value from string, return success. - virtual bool FromString([[maybe_unused]] void* data, [[maybe_unused]] cstr str, [[maybe_unused]] FFromString flags = 0) const - { return false; } - - // Read and write values of a specified type. - virtual bool ToValue([[maybe_unused]] const void* data, [[maybe_unused]] void* value, [[maybe_unused]] const CTypeInfo& typeVal) const - { return false; } - - virtual bool FromValue([[maybe_unused]] void* data, [[maybe_unused]] const void* value, [[maybe_unused]] const CTypeInfo& typeVal) const - { return false; } - - // Templated interface to above functions. - template - bool ToValue(const void* data, T& value) const - { return ToValue(data, &value, TypeInfo(&value)); } - template - bool FromValue(void* data, const T& value) const - { return FromValue(data, &value, TypeInfo(&value)); } - - virtual bool ValueEqual(const void* data, const void* def_data = 0) const - { return ToString(data, FToString().SkipDefault(1), def_data).empty(); } - - virtual bool GetLimit([[maybe_unused]] ENumericLimit eLimit, [[maybe_unused]] float& fVal) const - { return false; } - - // Convert numeric formats from big-to-little endian or vice versa. - // Swaps bitfield order as well (which may be separate from integer bit order). - virtual void SwapEndian(void* pData, size_t nCount, bool bWriting) const; - - // Track memory used by any internal structures (not counting object size itself). - // Add to CrySizer as needed, return remaining mem count. - virtual void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer, [[maybe_unused]] const void* data) const - {} - - // - // Structure interface. - // - struct CVarInfo - { - const CTypeInfo& Type; // Info for type of variable. - cstr Name; // Display name of variable. - cstr Attrs; // Var-specific attribute string, of form: - // "" for each attr, concatenated. - // Remaining text considered as comment. - uint32 Offset; // Offset in bytes from struct start. - uint32 ArrayDim : 22, // Number of array elements, or bits if bitfield. - bBaseClass : 1, // Sub-var is actually a base class. - bBitfield : 1, // Var is a bitfield, ArrayDim is number of bits. - BitOffset : 6, // Additional offset in bits for bitfields. - // Bit offset is computed in declaration order; on some platforms, it goes high to low. - BitWordWidth : 2; // Width of bitfield = 1 byte << BitWordWidth - - - // Accessors. - cstr GetName() const { return Name; } - size_t GetDim() const { return bBitfield ? 1 : ArrayDim; } - size_t GetSize() const { return bBitfield ? (size_t)1 << BitWordWidth : Type.Size* ArrayDim; } - size_t GetElemSize() const { return bBitfield ? (size_t)1 << BitWordWidth : Type.Size; } - size_t GetBits() const { return bBitfield ? ArrayDim : ArrayDim* Type.Size* 8; } - bool IsBaseClass() const { return bBaseClass; } - bool IsInline() const - { - if (bBaseClass && Offset == 0) - { - const CVarInfo* pFirst = Type.NextSubVar(0); - if (pFirst) - { - return pFirst->IsBaseClass(); - } - } - return false; - } - - bool GetLimit(ENumericLimit eLimit, float& fVal) const - { - return Type.GetLimit(eLimit, fVal); - } - - // Useful functions. - void* GetAddress(void* base) const - { - return (char*)base + Offset; - } - const void* GetAddress(const void* base) const - { - return (const char*)base + Offset; - } - bool FromString(void* base, cstr str, FFromString flags = 0) const - { - assert(!bBitfield); - return Type.FromString((char*)base + Offset, str, flags); - } - AZStd::string ToString(const void* base, FToString flags = 0, const void* def_base = 0) const - { - assert(!bBitfield); - return Type.ToString((const char*)base + Offset, flags, def_base ? (const char*)def_base + Offset : 0); - } - - // Attribute access. Not fast. - bool GetAttr(cstr name) const; - bool GetAttr(cstr name, float& val) const; - bool GetAttr(cstr name, AZStd::string& val) const; - - // Comment, excluding attributes. - cstr GetComment() const; - }; - - // Structure var iteration. - virtual CVarInfo const* NextSubVar([[maybe_unused]] CVarInfo const* pPrev, [[maybe_unused]] bool bRecurseBase = false) const - { return 0; } - inline bool HasSubVars() const - { return NextSubVar(0) != 0; } - #define AllSubVars(pVar, Info) \ - (const CTypeInfo::CVarInfo* pVar = (Info).NextSubVar(0); pVar; pVar = (Info).NextSubVar(pVar)) - - // Named var search. - virtual const CVarInfo* FindSubVar([[maybe_unused]] cstr name) const - { return 0; } - - virtual CTypeInfo const* const* NextTemplateType([[maybe_unused]] CTypeInfo const* const* pPrev) const - { return 0; } - inline bool IsTemplate() const - { return NextTemplateType(0) != 0; } - - // - // String enumeration interface. - // Return sequential strings in enumeration, then 0 when out of range. - // String/int conversion is handled by ToString/FromString. - // - virtual cstr EnumElem([[maybe_unused]] uint nIndex) const { return 0; } -}; - - -#endif // CRYINCLUDE_CRYCOMMON_CRYTYPEINFO_H diff --git a/Code/Legacy/CryCommon/Cry_Camera.h b/Code/Legacy/CryCommon/Cry_Camera.h index 4d33260c44..852467d787 100644 --- a/Code/Legacy/CryCommon/Cry_Camera.h +++ b/Code/Legacy/CryCommon/Cry_Camera.h @@ -17,7 +17,6 @@ //DOC-IGNORE-BEGIN #include #include -#include //DOC-IGNORE-END ////////////////////////////////////////////////////////////////////// @@ -546,7 +545,7 @@ public: ILINE void SetMatrixNoUpdate(const Matrix34& mat) { assert(mat.IsOrthonormal()); m_Matrix = mat; }; ILINE const Matrix34& GetMatrix() const { return m_Matrix; }; ILINE Vec3 GetViewdir() const { return m_Matrix.GetColumn1(); }; - + ILINE void SetEntityRotation(const Quat& entityRot) { m_entityRot = entityRot; } ILINE Quat GetEntityRotation() { return m_entityRot; } ILINE void SetEntityPos(const Vec3& entityPos) { m_entityPos = entityPos; } @@ -626,11 +625,6 @@ public: uint8 IsAABBVisible_EH(const ::AABB& aabb, bool* pAllInside) const; uint8 IsAABBVisible_EH(const ::AABB& aabb) const; - // Multi-camera - bool IsAABBVisible_EHM(const ::AABB& aabb, bool* pAllInside) const; - bool IsAABBVisible_EM(const ::AABB& aabb) const; - bool IsAABBVisible_FM(const ::AABB& aabb) const; - //OBB-frustum test bool IsOBBVisible_F(const Vec3& wpos, const OBB& obb) const; uint8 IsOBBVisible_FH(const Vec3& wpos, const OBB& obb) const; @@ -648,7 +642,6 @@ public: SetFrustum(640, 480); m_zrangeMin = 0.0f; m_zrangeMax = 1.0f; - m_pMultiCamera = NULL; m_pPortal = NULL; m_JustActivated = 0; m_nPosX = m_nPosY = m_nSizeX = m_nSizeY = 0; @@ -704,8 +697,8 @@ private: Vec3 m_edge_flt; // this is the left/upper vertex of the far-clip-plane f32 m_asymLeft, m_asymRight, m_asymBottom, m_asymTop; // Shift to create asymmetric frustum (only used for GPU culling of tessellated objects) - f32 m_asymLeftProj, m_asymRightProj, m_asymBottomProj, m_asymTopProj; - f32 m_asymLeftFar, m_asymRightFar, m_asymBottomFar, m_asymTopFar; + f32 m_asymLeftProj, m_asymRightProj, m_asymBottomProj, m_asymTopProj; + f32 m_asymLeftFar, m_asymRightFar, m_asymBottomFar, m_asymTopFar; //usually we update these values every frame (they depend on m_Matrix) Vec3 m_cltp, m_crtp, m_clbp, m_crbp; //this are the 4 vertices of the projection-plane in cam-space @@ -774,7 +767,6 @@ public: uint16 x1, y1, x2, y2; }; ScissorInfo m_ScissorInfo; - class PodArray* m_pMultiCamera; // maybe used for culling instead of this camera Vec3 m_OccPosition; //Position for calculate occlusions (needed for portals rendering) inline const Vec3& GetOccPos() const { return(m_OccPosition); } @@ -930,7 +922,7 @@ inline void CCamera::SetFrustum(int nWidth, int nHeight, f32 FOV, f32 nearplane, //Apply asym shift to the camera frustum - Necessary for properly culling tessellated objects in VR //These are applied in UpdateFrustum to the camera space frustum planes - //Can't apply asym shift to frustum edges here. That would only apply to the top left corner + //Can't apply asym shift to frustum edges here. That would only apply to the top left corner //rather than the whole frustum. It would also interfere with shadow map application //m_asym is at the near plane, we want it at the projection plane too @@ -1576,102 +1568,6 @@ inline uint8 CCamera::IsAABBVisible_EH(const AABB& aabb) const return AdditionalCheck(aabb); //result is either "exclusion" or "overlap" } -// Description: -// Makes culling taking into account presence of m_pMultiCamera -// If m_pMultiCamera exists - object is visible if at least one of cameras see's it -// -// return values: -// true - box visible -// true - not visible -inline bool CCamera::IsAABBVisible_EHM(const AABB& aabb, bool* pAllInside) const -{ - assert(pAllInside && *pAllInside == false); - - if (!m_pMultiCamera) // use main camera - { - return IsAABBVisible_EH(aabb, pAllInside) != CULL_EXCLUSION; - } - - bool bVisible = false; - - for (int i = 0; i < m_pMultiCamera->Count(); i++) - { - bool bAllIn = false; - - if (m_pMultiCamera->GetAt(i).IsAABBVisible_EH(aabb, &bAllIn)) - { - bVisible = true; - - // don't break here always because another camera may include bbox completely - if (bAllIn) - { - *pAllInside = true; - break; - } - } - } - - return bVisible; -} - -// Description: -// Makes culling taking into account presence of m_pMultiCamera -// If m_pMultiCamera exists - object is visible if at least one of cameras see's it -// -// return values: -// true - box visible -// true - not visible -ILINE bool CCamera::IsAABBVisible_EM(const AABB& aabb) const -{ - if (!m_pMultiCamera) // use main camera - { - return IsAABBVisible_E(aabb) != CULL_EXCLUSION; - } - - // check several parallel cameras - object is visible if at least one camera see's it - - for (int i = 0; i < m_pMultiCamera->Count(); i++) - { - if (m_pMultiCamera->GetAt(i).IsAABBVisible_E(aabb)) - { - return true; - } - } - - return false; -} - - -// Description: -// Makes culling taking into account presence of m_pMultiCamera -// If m_pMultiCamera exists - object is visible if at least one of cameras see's it -// -// return values: -// true - box visible -// true - not visible -ILINE bool CCamera::IsAABBVisible_FM(const AABB& aabb) const -{ - PrefetchLine(&aabb, sizeof(AABB)); - - if (!m_pMultiCamera) // use main camera - { - return IsAABBVisible_F(aabb) != CULL_EXCLUSION; - } - - // check several parallel cameras - object is visible if at least one camera see's it - - for (int i = 0; i < m_pMultiCamera->Count(); i++) - { - if (m_pMultiCamera->GetAt(i).IsAABBVisible_F(aabb)) - { - return true; - } - } - - return false; -} - - // Description diff --git a/Code/Legacy/CryCommon/Cry_Color.h b/Code/Legacy/CryCommon/Cry_Color.h index abb79c6662..4f00f0c373 100644 --- a/Code/Legacy/CryCommon/Cry_Color.h +++ b/Code/Legacy/CryCommon/Cry_Color.h @@ -14,9 +14,9 @@ #define CRYINCLUDE_CRYCOMMON_CRY_COLOR_H #pragma once -#include #include #include +#include "Cry_Math.h" ILINE float FClamp(float X, float Min, float Max) { @@ -362,8 +362,6 @@ struct Color_tpl AZStd::array primitiveArray = { { r, g, b, a } }; return primitiveArray; } - - AUTO_STRUCT_INFO }; diff --git a/Code/Legacy/CryCommon/Cry_Geo.h b/Code/Legacy/CryCommon/Cry_Geo.h index f8a356c66f..95213c62dc 100644 --- a/Code/Legacy/CryCommon/Cry_Geo.h +++ b/Code/Legacy/CryCommon/Cry_Geo.h @@ -54,7 +54,6 @@ enum EGeomForm MaxGeomForm }; -AUTO_TYPE_INFO(EGeomForm) enum EGeomType { @@ -63,7 +62,6 @@ enum EGeomType GeomType_Physics, GeomType_Render, }; -AUTO_TYPE_INFO(EGeomType) struct PosNorm { @@ -104,7 +102,6 @@ struct RectF , h(1) { } - AUTO_STRUCT_INFO }; struct RectI @@ -705,8 +702,6 @@ struct AABB result.Add(c.mTip); return result; } - - AUTO_STRUCT_INFO }; ILINE bool IsEquivalent(const AABB& a, const AABB& b, float epsilon = VEC_EPSILON) diff --git a/Code/Legacy/CryCommon/Cry_GeoOverlap.h b/Code/Legacy/CryCommon/Cry_GeoOverlap.h deleted file mode 100644 index 039f292f5b..0000000000 --- a/Code/Legacy/CryCommon/Cry_GeoOverlap.h +++ /dev/null @@ -1,1982 +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 : Common overlap-tests - - -#ifndef CRYINCLUDE_CRYCOMMON_CRY_GEOOVERLAP_H -#define CRYINCLUDE_CRYCOMMON_CRY_GEOOVERLAP_H -#pragma once - -#include -#include - -namespace Distance -{ - template - ILINE F Point_TriangleSq(const Vec3_tpl& p, const Triangle_tpl& t); - template - ILINE F Point_Lineseg2DSq(Vec3_tpl p, Lineseg lineseg, F& fT); - simdf Point_TriangleByPointsSq(const hwvec3& p, const hwvec3& t0, const hwvec3& t1, const hwvec3& t2); -} - - -namespace Overlap { - ILINE void FINDMINMAX(const f32 x0, const f32 x1, const f32 x2, f32& min_value, f32& max_value) - { - min_value = max_value = x0; - min_value = min(x1, min_value); - max_value = max(x1, max_value); - min_value = min(x2, min_value); - max_value = max(x2, max_value); - } - - inline bool Lineseg_AABB2D(const Lineseg&, const AABB&); - ILINE bool AABB_AABB2D(const AABB&, const AABB&); - - //////////////////////////////////////////////////////////////// - // Checks if the point is inside an AABB - /* inline bool Point_AABB(const Vec3 &p, const Vec3 &mins,const Vec3 &maxs) - { - if ((p.x>=mins.x && p.x<=maxs.x) && (p.y>=mins.y && p.y<=maxs.y) && (p.z>=mins.z && p.z<=maxs.z)) return (true); - return (false); - }*/ - - // Description: - // Checks if the point is inside an AABB - // The min value of the AABB is inclusive - // The max value of the AABB is exclusive - ILINE bool Point_AABB(const Vec3& p, const AABB& aabb) - { - return ((p.x >= aabb.min.x && p.x < aabb.max.x) && (p.y >= aabb.min.y && p.y < aabb.max.y) && (p.z >= aabb.min.z && p.z < aabb.max.z)); - } - - // Description: - // Checks if the point is inside a 2D AABB - // The min value of the AABB is inclusive - // The max value of the AABB is exclusive - template - ILINE bool Point_AABB2D(const PtType& p, const AABB& aabb) - { - return ((p.x >= aabb.min.x && p.x < aabb.max.x) && (p.y >= aabb.min.y && p.y < aabb.max.y)); - } - - // Description: - // Checks if the point is inside an AABB - // The min and max value of the AABB is inclusive - ILINE bool Point_AABB_MaxInclusive(const Vec3& p, const AABB& aabb) - { - return ((p.x >= aabb.min.x && p.x <= aabb.max.x) && (p.y >= aabb.min.y && p.y <= aabb.max.y) && (p.z >= aabb.min.z && p.z <= aabb.max.z)); - } - - // Description: - // Checks if the point is inside a 2D AABB - // The min and max value of the AABB is inclusive - template - ILINE bool Point_AABB2D_MaxInclusive(const PtType& p, const AABB& aabb) - { - return ((p.x >= aabb.min.x && p.x <= aabb.max.x) && (p.y >= aabb.min.y && p.y <= aabb.max.y)); - } - - // Description: - // Checks if a point is inside an OBB. - // Example: - // bool result=Overlap::Point_OBB( point, obb ); - ILINE bool Point_OBB(const Vec3& p, const Vec3& wpos, const OBB& obb) - { - AABB aabb = AABB(obb.c - obb.h, obb.c + obb.h); - Vec3 t = (p - wpos) * obb.m33; - return ((t.x >= aabb.min.x && t.x <= aabb.max.x) && (t.y >= aabb.min.y && t.y <= aabb.max.y) && (t.z >= aabb.min.z && t.z <= aabb.max.z)); - } - - // Description: - // Checks if a point is inside a sphere. - // Example: - // bool result=Overlap::Point_Sphere( point, sphere ); - ILINE bool Point_Sphere(const Vec3& p, const ::Sphere& s) - { - Vec3 distc = p - s.center; - f32 sqrad = s.radius * s.radius; - return (sqrad > (distc | distc)); - } - - /// Two line segments, in 2D (ignore z) - inline bool Lineseg_Lineseg2D(const Lineseg& lineA, const Lineseg& lineB) - { - const float Epsilon = 0.0000001f; - - Vec3 delta = lineB.start - lineA.start; - - Vec3 dirA = lineA.end - lineA.start; - Vec3 dirB = lineB.end - lineB.start; - - float det = dirA.x * dirB.y - dirA.y * dirB.x; - float detA = delta.x * dirB.y - delta.y * dirB.x; - float detB = delta.x * dirA.y - delta.y * dirA.x; - - float absDet = fabs_tpl(det); - - if (absDet >= Epsilon) - { - float invDet = 1.0f / det; - - float a = detA * invDet; - float b = detB * invDet; - - if ((a > 1.0f) || (a < 0.0f) || (b > 1.0f) || (b < 0.0f)) - { - return false; - } - } - else - { - return false; - } - - return true; - } - - - - /// Check if a point is within a polygon, in 2D (i.e. ignoring z coordinate) - /// The VecContainer should be a container of Vec3_tpl such that we can traverse - /// it using iterators. - /// - /// This works by checking all the lines that start/end above/below the point - /// and counting how many have the point on the right/left side. If the - /// point is inside, then left/right counts should be odd - if outside then - /// even. If it's on the edge then this algorithm will return an arbitrary - /// result. This is basically the same as casting a ray horizontally and - /// counting the intersections. - /// Don't mess with putting tolerances etc in this code, or chaning the < - /// to <= etc in case you're worried about the "ray" going through a vertex. - /// the only issue is when the point is on the edge - if you're worried about - /// that then use the separate function that indicates if a point is within - /// a certain tolerance of an edge. - template - inline bool Point_Polygon2D(const PtType& p, const VecContainer& polygon, const AABB* pAABBPolygon = 0) - { - if (pAABBPolygon && !Overlap::Point_AABB2D(p, *pAABBPolygon)) - { - return false; - } - - int count = 0; - - typename VecContainer::const_iterator li, linext; - typename VecContainer::const_iterator liend = polygon.end(); - for (li = polygon.begin(); li != liend; ++li) - { - linext = li; - ++linext; - if (linext == liend) - { - linext = polygon.begin(); - } - const PtType& l0 = *li; - const PtType& l1 = *linext; - - if ((((l1.y <= p.y) && (p.y < l0.y)) || - ((l0.y <= p.y) && (p.y < l1.y))) && - (p.x < (l0.x - l1.x) * (p.y - l1.y) / (l0.y - l1.y) + l1.x)) - { - count = !count; - } - } - return (0 != count); - } - - template - inline bool Point_Polygon2D(const PtType& p, const PtType* polygon, size_t vertexCount, const AABB* pAABBPolygon = 0) - { - if (pAABBPolygon && !Overlap::Point_AABB2D(p, *pAABBPolygon)) - { - return false; - } - - bool count = false; - - for (size_t i = 0; i < vertexCount; ++i) - { - const PtType l0 = polygon[i % vertexCount]; - const PtType l1 = polygon[(i + 1) % vertexCount]; - - if ((((l1.y <= p.y) && (p.y < l0.y)) || - ((l0.y <= p.y) && (p.y < l1.y))) && - (p.x < (l0.x - l1.x) * (p.y - l1.y) / (l0.y - l1.y) + l1.x)) - { - count = !count; - } - } - - return count; - } - - - template - inline bool Circle_Polygon2D(const Vec3_tpl& p, F radius, const VecContainer& polygon) - { - if (Overlap::Point_Polygon2D(p, polygon)) - { - return true; - } - typename VecContainer::const_iterator li, linext; - typename VecContainer::const_iterator liend = polygon.end(); - for (li = polygon.begin(); li != liend; ++li) - { - linext = li; - ++linext; - if (linext == liend) - { - linext = polygon.begin(); - } - const Vec3_tpl& l0 = *li; - const Vec3_tpl& l1 = *linext; - float junk; - if (Distance::Point_Lineseg2DSq(p, Lineseg(l0, l1), junk) < square(radius)) - { - return true; - } - } - return false; - } - /// Checks if a line segment overlaps a polygon (defined by a container of sorted - /// points) in 2D (ignoring z). If you know the polygon AABB pass it in (z is ignored) - template - inline bool Lineseg_Polygon2D(const Lineseg& lineseg, - const VecContainer& polygon, - const AABB* pAABBPolygon = 0) - { - if (pAABBPolygon && !Overlap::Lineseg_AABB2D(lineseg, *pAABBPolygon)) - { - return false; - } - - typename VecContainer::const_iterator it; - for (it = polygon.begin(); it != polygon.end(); ++it) - { - typename VecContainer::const_iterator itNext = it; - ++itNext; - if (itNext == polygon.end()) - { - itNext = polygon.begin(); - } - - Lineseg polySeg(*it, *itNext); - if (Lineseg_Lineseg2D(lineseg, polySeg)) - { - return true; - } - } - return false; - } - - /// Checks for overlap of two polygons in 2D (ignoring z) - template - inline bool Polygon_Polygon2D(const VecContainerA& polygonA, const VecContainerB& polygonB, - const AABB* pAABBA = 0, const AABB* pAABBB = 0) - { - const typename VecContainerA::const_iterator itEndA = polygonA.end(); - const typename VecContainerB::const_iterator itEndB = polygonB.end(); - typename VecContainerA::const_iterator itA; - typename VecContainerB::const_iterator itB; - - AABB aabbA, aabbB; - if (!pAABBA) - { - pAABBA = &aabbA; - aabbA.Reset(); - for (itA = polygonA.begin(); itA != itEndA; ++itA) - { - aabbA.Add(*itA); - } - } - if (!pAABBB) - { - pAABBB = &aabbB; - aabbB.Reset(); - for (itB = polygonB.begin(); itB != itEndB; ++itB) - { - aabbB.Add(*itB); - } - } - - // AABB - if (!Overlap::AABB_AABB2D(*pAABBA, *pAABBB)) - { - return false; - } - - // points of A in B - for (itA = polygonA.begin(); itA != itEndA; ++itA) - { - if (Point_Polygon2D(*itA, polygonB, pAABBB)) - { - return true; - } - } - // points of B in A - for (itB = polygonB.begin(); itB != itEndB; ++itB) - { - if (Point_Polygon2D(*itB, polygonA, pAABBA)) - { - return true; - } - } - // segments of one A against B - for (itA = polygonA.begin(); itA != itEndA; ++itA) - { - typename VecContainerA::const_iterator itNext = itA; - ++itNext; - if (itNext == itEndA) - { - itNext = polygonA.begin(); - } - if (Lineseg_Polygon2D(Lineseg(*itA, *itNext), polygonB, pAABBB)) - { - return true; - } - } - return false; - } - - - /// Checks if a triangle (defined by three vertices) overlaps a polygon (defined - /// by a container of sorted points), all in 2D only (ignoring z). - template - inline bool Triangle_Polygon2D(const Vec3_tpl& p0, const Vec3_tpl& p1, const Vec3_tpl& p2, - const VecContainer& polygon) - { - // Check for triangle points within the poly - if (Point_Polygon2D(p0, polygon)) - { - return true; - } - if (Point_Polygon2D(p1, polygon)) - { - return true; - } - if (Point_Polygon2D(p2, polygon)) - { - return true; - } - - // check the poly points against the triangle - static std::vector triangle; - triangle.clear(); - triangle.push_back(p0); - triangle.push_back(p1); - triangle.push_back(p2); - - typename VecContainer::const_iterator it; - for (it = polygon.begin(); it != polygon.end(); ++it) - { - if (Point_Polygon2D(*it, triangle)) - { - return true; - } - } - - // finally check the edges - if (Overlap::Lineseg_Polygon2D(Lineseg(p0, p1), polygon)) - { - return true; - } - if (Overlap::Lineseg_Polygon2D(Lineseg(p1, p2), polygon)) - { - return true; - } - if (Overlap::Lineseg_Polygon2D(Lineseg(p2, p0), polygon)) - { - return true; - } - return false; - } - - //----------------------------------------------------------------------------------------- - - - //! check if a Lineseg and a Sphere overlap - inline bool Lineseg_Sphere(const Lineseg& ls, const ::Sphere& s) - { - float radius2 = s.radius * s.radius; - - //check if one of the two edpoints of the line is inside the sphere - Vec3 diff = ls.end - s.center; - if (diff.x * diff.x + diff.y * diff.y + diff.z * diff.z <= radius2) - { - return true; - } - - Vec3 AC = s.center - ls.start; - if (AC.x * AC.x + AC.y * AC.y + AC.z * AC.z <= radius2) - { - return true; - } - - //check distance from the sphere to the line - Vec3 AB = ls.end - ls.start; - - float r = (AC.x * AB.x + AC.y * AB.y + AC.z * AB.z) / (AB.x * AB.x + AB.y * AB.y + AB.z * AB.z); - - //projection falls outside the line - if (r < 0 || r > 1) - { - return false; - } - - //check if the distance from the line to the center of the sphere is less than radius - Vec3 point = ls.start + r * AB; - if ((point.x - s.center.x) * (point.x - s.center.x) + (point.y - s.center.y) * (point.y - s.center.y) + (point.z - s.center.z) * (point.z - s.center.z) > radius2) - { - return false; - } - - return true; - } - - - /*! - * we use the SEPARATING AXIS TEST to check if a Linesegment overlap an AABB. - * - * Example: - * bool result=Overlap::Lineseg_AABB( ls, pos,aabb ); - */ - inline bool Lineseg_AABB (const Lineseg& ls, const AABB& aabb) - { - //calculate the half-length-vectors of the AABB - Vec3 h = (aabb.max - aabb.min) * 0.5f; - //"t" is the transfer-vector from one center to the other - Vec3 t = (ls.start + ls.end) * 0.5f - (aabb.max + aabb.min) * 0.5f; - //calculate line-direction - Vec3 ld = (ls.end - ls.start) * 0.5f; - if (fabsf(t.x) > (h.x + fabsf(ld.x))) - { - return 0; - } - if (fabsf(t.y) > (h.y + fabsf(ld.y))) - { - return 0; - } - if (fabsf(t.z) > (h.z + fabsf(ld.z))) - { - return 0; - } - if (fabsf(t.z * ld.y - t.y * ld.z) > (fabsf(h.y * ld.z) + fabsf(h.z * ld.y))) - { - return 0; - } - if (fabsf(t.x * ld.z - t.z * ld.x) > (fabsf(h.x * ld.z) + fabsf(h.z * ld.x))) - { - return 0; - } - if (fabsf(t.y * ld.x - t.x * ld.y) > (fabsf(h.x * ld.y) + fabsf(h.y * ld.x))) - { - return 0; - } - return 1; //no separating axis found, objects overlap - } - - /// 2D seaparating axis test - ignores z - inline bool Lineseg_AABB2D (const Lineseg& ls, const AABB& aabb) - { - //calculate the half-length-vectors of the AABB - Vec3 h = (aabb.max - aabb.min) * 0.5f; - //"t" is the transfer-vector from one center to the other - Vec3 t = (ls.start + ls.end) * 0.5f - (aabb.max + aabb.min) * 0.5f; - //calculate line-direction - Vec3 ld = (ls.end - ls.start) * 0.5f; - if (fabsf(t.x) > (h.x + fabsf(ld.x))) - { - return 0; - } - if (fabsf(t.y) > (h.y + fabsf(ld.y))) - { - return 0; - } - if (fabsf(t.y * ld.x - t.x * ld.y) > (fabsf(h.x * ld.y) + fabsf(h.y * ld.x))) - { - return 0; - } - return 1; //no separating axis found, objects overlap - } - - - - /*! - * we use the SEPARATING AXIS TEST to check if two OBB's overlap. - * - * Example: - * bool result=Overlap::Lineseg_OBB( lineseg, pos,obb ); - */ - inline bool Lineseg_OBB (const Lineseg& ls, const Vec3& pos, const OBB& obb) - { - //the new center-position of Lineseg and OBB in world-space - Vec3 wposobb = obb.m33 * obb.c + pos; - Vec3 wposls = (ls.start + ls.end) * 0.5f; - //"t" is the transfer-vector from one center to the other - Vec3 t = (wposls - wposobb) * obb.m33; - //calculate line-direction in local obb-space - Vec3 ld = ((ls.end - ls.start) * obb.m33) * 0.5f; - if (fabsf(t.x) > (obb.h.x + fabsf(ld.x))) - { - return 0; - } - if (fabsf(t.y) > (obb.h.y + fabsf(ld.y))) - { - return 0; - } - if (fabsf(t.z) > (obb.h.z + fabsf(ld.z))) - { - return 0; - } - if (fabsf(t.z * ld.y - t.y * ld.z) > (fabsf(obb.h.y * ld.z) + fabsf(obb.h.z * ld.y))) - { - return 0; - } - if (fabsf(t.x * ld.z - t.z * ld.x) > (fabsf(obb.h.x * ld.z) + fabsf(obb.h.z * ld.x))) - { - return 0; - } - if (fabsf(t.y * ld.x - t.x * ld.y) > (fabsf(obb.h.x * ld.y) + fabsf(obb.h.y * ld.x))) - { - return 0; - } - return 1; //no separating axis found, objects overlap - } - - - - - /*! - * - * overlap-test between a line and a triangle. - * IMPORTANT: this is a single-sided test. That means its not enough - * that the triangle and line overlap, its also important that the triangle - * is "visible" when you are looking along the line-direction. - * - * If you need a double-sided test, you'll have to call this function twice with - * reversed order of triangle vertices. - * - * return values - * return "true" if line and triangle overlap. - * - */ - inline bool Line_Triangle(const Line& line, const Vec3& v0, const Vec3& v1, const Vec3& v2) - { - const float Epsilon = 0.0000001f; - - Vec3 edgeA = v1 - v0; - Vec3 edgeB = v2 - v0; - - Vec3 dir = line.direction; - - Vec3 p = dir.Cross(edgeA); - Vec3 t = line.pointonline - v0; - Vec3 q = t.Cross(edgeB); - - float dot = edgeB.Dot(p); - - float u = t.Dot(p); - float v = dir.Dot(q); - - float DotGreaterThanEpsilon = dot - Epsilon; - float VGreaterEqualThanZero = v; - float UGreaterEqualThanZero = u; - float UVLessThanDot = dot - (u + v); - float ULessThanDot = dot - u; - - float UVGreaterEqualThanZero = (float)fsel(VGreaterEqualThanZero, UGreaterEqualThanZero, VGreaterEqualThanZero); - float UUVLessThanDot = (float)fsel(UVLessThanDot, ULessThanDot, UVLessThanDot); - float BothGood = (float)fsel(UVGreaterEqualThanZero, UUVLessThanDot, UVGreaterEqualThanZero); - float AllGood = (float)fsel(DotGreaterThanEpsilon, BothGood, DotGreaterThanEpsilon); - - return AllGood >= 0.0f; - } - - - /*! - * - * overlap-test between a ray and a triangle. - * IMPORTANT: this is a single-sided test. That means its not sufficient - * that the triangle and ray overlap, its also important that the triangle - * is "visible" when you are looking from the origin along the ray-direction. - * - * If you need a double-sided test, you'll have to call this function twice with - * reversed order of triangle vertices. - * - * return values - * return "true" if ray and triangle overlap. - */ - inline bool Ray_Triangle(const Ray& ray, const Vec3& v0, const Vec3& v1, const Vec3& v2) - { - const float Epsilon = 0.0000001f; - - Vec3 edgeA = v1 - v0; - Vec3 edgeB = v2 - v0; - - Vec3 dir = ray.direction; - - Vec3 p = dir.Cross(edgeA); - Vec3 t = ray.origin - v0; - Vec3 q = t.Cross(edgeB); - - float dot = edgeB.Dot(p); - - float u = t.Dot(p); - float v = dir.Dot(q); - - float DotGreaterThanEpsilon = dot - Epsilon; - float VGreaterEqualThanZero = v; - float UGreaterEqualThanZero = u; - float UVLessThanDot = dot - (u + v); - float ULessThanDot = dot - u; - - float UVGreaterEqualThanZero = (float)fsel(VGreaterEqualThanZero, UGreaterEqualThanZero, VGreaterEqualThanZero); - float UUVLessThanDot = (float)fsel(UVLessThanDot, ULessThanDot, UVLessThanDot); - float BothGood = (float)fsel(UVGreaterEqualThanZero, UUVLessThanDot, UVGreaterEqualThanZero); - float AllGood = (float)fsel(DotGreaterThanEpsilon, BothGood, DotGreaterThanEpsilon); - - if (AllGood < 0.0f) - { - return false; - } - - float dt = edgeA.Dot(q) / dot; - - Vec3 result = (dir * dt) + ray.origin; - - float AfterStart = (result - ray.origin).Dot(dir); - - return AfterStart >= 0.0f; - } - - /*---------------------------------------------------------------------------------- - * Sphere_AABB - * Sphere and AABB are assumed to be in the same space - * - * Example: - * bool result=Overlap::Sphere_AABB_Inside( sphere, aabb ); - * - * 0 = no overlap - * 1 = overlap - *----------------------------------------------------------------------------------*/ - ILINE bool Sphere_AABB(const ::Sphere& s, const AABB& aabb) - { - Vec3 center(s.center); - - Vec3 aabb_min(aabb.min); - Vec3 aabb_max(aabb.max); - - float radiusSq = s.radius * s.radius; - - float x = (float)fsel(aabb_min.x - center.x, center.x - aabb_min.x, fsel(center.x - aabb_max.x, center.x - aabb_max.x, 0.0f)); - float y = (float)fsel(aabb_min.y - center.y, center.y - aabb_min.y, fsel(center.y - aabb_max.y, center.y - aabb_max.y, 0.0f)); - float z = (float)fsel(aabb_min.z - center.z, center.z - aabb_min.z, fsel(center.z - aabb_max.z, center.z - aabb_max.z, 0.0f)); - - return (x * x + y * y + z * z) < radiusSq; - } - - // As Sphere_AABB but ignores z parts - ILINE bool Sphere_AABB2D(const ::Sphere& s, const AABB& aabb) - { - Vec3 center(s.center); - - Vec3 aabb_min(aabb.min); - Vec3 aabb_max(aabb.max); - - float radiusSq = s.radius * s.radius; - - float x = (float)fsel(aabb_min.x - center.x, center.x - aabb_min.x, fsel(center.x - aabb_max.x, center.x - aabb_max.x, 0.0f)); - float y = (float)fsel(aabb_min.y - center.y, center.y - aabb_min.y, fsel(center.y - aabb_max.y, center.y - aabb_max.y, 0.0f)); - - return (x * x + y * y) < radiusSq; - } - - - /*! - * - * conventional method to check if a Sphere and an AABB overlap, - * or if the Sphere is completely inside the AABB. - * Sphere and AABB are assumed to be in the same space - * - * Example: - * bool result=Overlap::Sphere_AABB_Inside( sphere, aabb ); - * - * return values: - * 0x00 = no overlap - * 0x01 = Sphere and AABB overlap - * 0x02 = Sphere in inside AABB - */ - ILINE char Sphere_AABB_Inside(const ::Sphere& s, const AABB& aabb) - { - if (Sphere_AABB(s, aabb)) - { - Vec3 amin = aabb.min - s.center; - Vec3 amax = aabb.max - s.center; - if (amin.x >= (-s.radius)) - { - return 1; - } - if (amin.y >= (-s.radius)) - { - return 1; - } - if (amin.z >= (-s.radius)) - { - return 1; - } - if (amax.x <= (+s.radius)) - { - return 1; - } - if (amax.y <= (+s.radius)) - { - return 1; - } - if (amax.z <= (+s.radius)) - { - return 1; - } - //yes, its inside - return 2; - } - return 0; - } - - //---------------------------------------------------------------------------------- - // Sphere_OBB - // VERY IMPORTANT: Sphere is assumed to be in the space of the OBB, otherwise it won't work - // - //--- 0 = no overlap --------------------------- - //--- 1 = overlap ----------------- - //---------------------------------------------------------------------------------- - inline bool Sphere_OBB(const ::Sphere& s, const OBB& obb) - { - //first we transform the sphere-center into the AABB-space of the OBB - Vec3 SphereInOBBSpace = s.center * obb.m33; - //the rest ist the same as the "Overlap::Sphere_AABB" calculation - float quatradius = s.radius * s.radius; - Vec3 quat(0, 0, 0); - AABB aabb = AABB(obb.c - obb.h, obb.c + obb.h); - if (SphereInOBBSpace.x < aabb.min.x) - { - quat.x = SphereInOBBSpace.x - aabb.min.x; - } - else if (SphereInOBBSpace.x > aabb.max.x) - { - quat.x = SphereInOBBSpace.x - aabb.max.x; - } - if (SphereInOBBSpace.y < aabb.min.y) - { - quat.y = SphereInOBBSpace.y - aabb.min.y; - } - else if (SphereInOBBSpace.y > aabb.max.y) - { - quat.y = SphereInOBBSpace.y - aabb.max.y; - } - if (SphereInOBBSpace.z < aabb.min.z) - { - quat.z = SphereInOBBSpace.z - aabb.min.z; - } - else if (SphereInOBBSpace.z > aabb.max.z) - { - quat.z = SphereInOBBSpace.z - aabb.max.z; - } - return((quat | quat) < quatradius); - } - - - //---------------------------------------------------------------------------------- - // Sphere_Sphere overlap test - // - //--- 0 = no overlap --------------------------- - //--- 1 = overlap ----------------- - //---------------------------------------------------------------------------------- - inline bool Sphere_Sphere(const ::Sphere& s1, const ::Sphere& s2) - { - Vec3 distc = s1.center - s2.center; - f32 sqrad = (s1.radius + s2.radius) * (s1.radius + s2.radius); - return (sqrad > (distc | distc)); - } - - ILINE bool HWVSphere_HWVSphere(const HWVSphere& s1, const HWVSphere& s2) - { - simdf fTotalRadius = SIMDFAdd(s1.radius, s2.radius); - hwvec3 distc = HWVSub(s1.center, s2.center); - simdf fTotalRadiusSqr = SIMDFMult(fTotalRadius, fTotalRadius); - simdf fDistanceSqr = HWV3Dot(distc, distc); - return SIMDFLessThanEqualB(fDistanceSqr, fTotalRadiusSqr); - } - - //---------------------------------------------------------------------------------- - // Sphere_Triangle overlap test - // - //--- 0 = no overlap --------------------------- - //--- 1 = overlap ----------------- - //---------------------------------------------------------------------------------- - template - ILINE bool Sphere_Triangle(const ::Sphere& s, const Triangle_tpl& t) - { - //create a "bouding sphere" around triangle for fast rejection test - Vec3_tpl middle = (t.v0 + t.v1 + t.v2) * (1 / 3.0f); - Vec3_tpl ov0 = t.v0 - middle; - Vec3_tpl ov1 = t.v1 - middle; - Vec3_tpl ov2 = t.v2 - middle; - F SqRad0 = (ov0 | ov0); - F SqRad1 = (ov1 | ov1); - F SqRad2 = (ov2 | ov2); - - SqRad0 = (F)fsel(SqRad0 - SqRad1, SqRad0, SqRad1); - SqRad0 = (F)fsel(SqRad0 - SqRad2, SqRad0, SqRad2); - - //first simple rejection-test... - if (Sphere_Sphere(s, ::Sphere(middle, sqrt_tpl(SqRad0))) == 0) - { - return 0; //overlap not possible - } - //...and now the hardcore-test! - if ((s.radius * s.radius) < Distance::Point_TriangleSq(s.center, t)) - { - return 0; - } - return 1; //sphere and triangle are overlapping - } - - ILINE bool HWVSphere_TriangleFromPoints(const HWVSphere& s, const hwvec3& t0, const hwvec3& t1, const hwvec3& t2) - { - //create a "bounding sphere" around triangle for fast rejection test - SIMDFConstant(fOneThird, 1.0f / 3.0f); - - hwvec3 middle = HWVMultiplySIMDF(HWVAdd(t0, HWVAdd(t1, t2)), fOneThird); - - hwvec3 ov0 = HWVSub(t0, middle); - hwvec3 ov1 = HWVSub(t1, middle); - hwvec3 ov2 = HWVSub(t2, middle); - - simdf SqRad0 = HWV3Dot(ov0, ov0); - simdf SqRad1 = HWV3Dot(ov1, ov1); - simdf SqRad2 = HWV3Dot(ov2, ov2); - - SqRad0 = SIMDFMax(SqRad0, SqRad1); - SqRad0 = SIMDFMax(SqRad0, SqRad2); - - //first simple rejection-test... - //if( HWVSphere_HWVSphere(s, HWVSphere(middle, SIMDFSqrtEstFast(SqRad0)))==0 ) - if (HWVSphere_HWVSphere(s, HWVSphere(middle, SIMDFSqrtEst(SqRad0))) == 0) - { - return 0; //overlap not possible - } - else - { - //...and now the hardcore-test! - simdf fRadiusSq = SIMDFMult(s.radius, s.radius); - simdf fDistToTriangleSq = Distance::Point_TriangleByPointsSq(s.center, t0, t1, t2); - - return SIMDFLessThanEqualB(fDistToTriangleSq, fRadiusSq); - } - } - - /*! - * - * we use the SEPARATING AXIS TEST to check if a triangle and AABB overlap. - * - * Example: - * bool result=Overlap::AABB_Triangle( pos,aabb, tv0,tv1,tv2 ); - * - */ - inline bool AABB_Triangle (const AABB& aabb, const Vec3& tv0, const Vec3& tv1, const Vec3& tv2) - { - //------ convert AABB into half-length AABB ----------- - Vec3 h = (aabb.max - aabb.min) * 0.5f; //calculate the half-length-vectors - Vec3 c = (aabb.max + aabb.min) * 0.5f; //the center is relative to the PIVOT - - //move everything so that the boxcenter is in (0,0,0) - Vec3 v0 = tv0 - c; - Vec3 v1 = tv1 - c; - Vec3 v2 = tv2 - c; - - //compute triangle edges - Vec3 e0 = v1 - v0; - Vec3 e1 = v2 - v1; - Vec3 e2 = v0 - v2; - - //-------------------------------------------------------------------------------------- - // use SEPARATING AXIS THEOREM to test overlap between AABB and triangle - // cross-product(edge from triangle, {x,y,z}-direction), this are 3x3=9 tests - //-------------------------------------------------------------------------------------- - float min, max, p0, p1, p2, rad, fex, fey, fez; - fex = fabsf(e0.x); - fey = fabsf(e0.y); - fez = fabsf(e0.z); - - //AXISTEST_X01(e0.z, e0.y, fez, fey); - p0 = e0.z * v0.y - e0.y * v0.z; - p2 = e0.z * v2.y - e0.y * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * h.y + fey * h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Y02(e0.z, e0.x, fez, fex); - p0 = -e0.z * v0.x + e0.x * v0.z; - p2 = -e0.z * v2.x + e0.x * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * h.x + fex * h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Z12(e0.y, e0.x, fey, fex); - p1 = e0.y * v1.x - e0.x * v1.y; - p2 = e0.y * v2.x - e0.x * v2.y; - if (p2 < p1) - { - min = p2; - max = p1; - } - else - { - min = p1; - max = p2; - } - rad = fey * h.x + fex * h.y; - if (min > rad || max < -rad) - { - return 0; - } - - //----------------------------------------------- - - fex = fabsf(e1.x); - fey = fabsf(e1.y); - fez = fabsf(e1.z); - //AXISTEST_X01(e1.z, e1.y, fez, fey); - p0 = e1.z * v0.y - e1.y * v0.z; - p2 = e1.z * v2.y - e1.y * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * h.y + fey * h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Y02(e1.z, e1.x, fez, fex); - p0 = -e1.z * v0.x + e1.x * v0.z; - p2 = -e1.z * v2.x + e1.x * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * h.x + fex * h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Z0(e1.y, e1.x, fey, fex); - p0 = e1.y * v0.x - e1.x * v0.y; - p1 = e1.y * v1.x - e1.x * v1.y; - if (p0 < p1) - { - min = p0; - max = p1; - } - else - { - min = p1; - max = p0; - } - rad = fey * h.x + fex * h.y; - if (min > rad || max < -rad) - { - return 0; - } - - //----------------------------------------------- - - fex = fabsf(e2.x); - fey = fabsf(e2.y); - fez = fabsf(e2.z); - //AXISTEST_X2(e2.z, e2.y, fez, fey); - p0 = e2.z * v0.y - e2.y * v0.z; - p1 = e2.z * v1.y - e2.y * v1.z; - if (p0 < p1) - { - min = p0; - max = p1; - } - else - { - min = p1; - max = p0; - } - rad = fez * h.y + fey * h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Y1(e2.z, e2.x, fez, fex); - p0 = -e2.z * v0.x + e2.x * v0.z; - p1 = -e2.z * v1.x + e2.x * v1.z; - if (p0 < p1) - { - min = p0; - max = p1; - } - else - { - min = p1; - max = p0; - } - rad = fez * h.x + fex * h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Z12(e2.y, e2.x, fey, fex); - p1 = e2.y * v1.x - e2.x * v1.y; - p2 = e2.y * v2.x - e2.x * v2.y; - if (p2 < p1) - { - min = p2; - max = p1; - } - else - { - min = p1; - max = p2; - } - rad = fey * h.x + fex * h.y; - if (min > rad || max < -rad) - { - return 0; - } - - //the {x,y,z}-directions (actually, since we use the AABB of the triangle we don't even need to test these) - //first test overlap in the {x,y,z}-directions - //find min, max of the triangle each direction, and test for overlap in that direction -- - //this is equivalent to testing a minimal AABB around the triangle against the AABB - AABB taabb; - FINDMINMAX(v0.x, v1.x, v2.x, taabb.min.x, taabb.max.x); - FINDMINMAX(v0.y, v1.y, v2.y, taabb.min.y, taabb.max.y); - FINDMINMAX(v0.z, v1.z, v2.z, taabb.min.z, taabb.max.z); - - //test in X-direction - FINDMINMAX(v0.x, v1.x, v2.x, taabb.min.x, taabb.max.x); - if (taabb.min.x > h.x || taabb.max.x < -h.x) - { - return 0; - } - - //test in Y-direction - FINDMINMAX(v0.y, v1.y, v2.y, taabb.min.y, taabb.max.y); - if (taabb.min.y > h.y || taabb.max.y < -h.y) - { - return 0; - } - - //test in Z-direction - FINDMINMAX(v0.z, v1.z, v2.z, taabb.min.z, taabb.max.z); - if (taabb.min.z > h.z || taabb.max.z < -h.z) - { - return 0; - } - - //test if the box intersects the plane of the triangle - //compute plane equation of triangle: normal*x+d=0 - Plane_tpl plane = Plane_tpl::CreatePlane((e0 % e1), v0); - - Vec3 vmin, vmax; - if (plane.n.x > 0.0f) - { - vmin.x = -h.x; - vmax.x = +h.x; - } - else - { - vmin.x = +h.x; - vmax.x = -h.x; - } - if (plane.n.y > 0.0f) - { - vmin.y = -h.y; - vmax.y = +h.y; - } - else - { - vmin.y = +h.y; - vmax.y = -h.y; - } - if (plane.n.z > 0.0f) - { - vmin.z = -h.z; - vmax.z = +h.z; - } - else - { - vmin.z = +h.z; - vmax.z = -h.z; - } - if ((plane | vmin) > 0.0f) - { - return 0; - } - if ((plane | vmax) < 0.0f) - { - return 0; - } - return 1; - } - - - - /*! - * - * we use the SEPARATING AXIS TEST to check if a triangle and an OBB overlaps. - * - * Example: - * bool result=Overlap::OBB_Trinagle( pos1,obb1, tv0,tv1,tv2 ); - * - */ - inline bool OBB_Triangle(const Vec3& pos, const OBB& obb, const Vec3& tv0, const Vec3& tv1, const Vec3& tv2) - { - Vec3 p = obb.m33 * obb.c + pos; //the new center-position in world-space - - //move everything so that the boxcenter is in (0,0,0) - Vec3 v0 = (tv0 - p) * obb.m33; //pre-transform - Vec3 v1 = (tv1 - p) * obb.m33; //pre-transform - Vec3 v2 = (tv2 - p) * obb.m33; //pre-transform - - - //compute triangle edges - Vec3 e0 = v1 - v0; - Vec3 e1 = v2 - v1; - Vec3 e2 = v0 - v2; - - //-------------------------------------------------------------------------------------- - // use SEPARATING AXIS THEOREM to test intersection between AABB and triangle - // cross-product(edge from triangle, {x,y,z}-direction), this are 3x3=9 tests - //-------------------------------------------------------------------------------------- - float min, max, p0, p1, p2, rad, fex, fey, fez; - fex = fabsf(e0.x); - fey = fabsf(e0.y); - fez = fabsf(e0.z); - - //AXISTEST_X01(e0.z, e0.y, fez, fey); - p0 = e0.z * v0.y - e0.y * v0.z; - p2 = e0.z * v2.y - e0.y * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * obb.h.y + fey * obb.h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Y02(e0.z, e0.x, fez, fex); - p0 = -e0.z * v0.x + e0.x * v0.z; - p2 = -e0.z * v2.x + e0.x * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * obb.h.x + fex * obb.h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Z12(e0.y, e0.x, fey, fex); - p1 = e0.y * v1.x - e0.x * v1.y; - p2 = e0.y * v2.x - e0.x * v2.y; - if (p2 < p1) - { - min = p2; - max = p1; - } - else - { - min = p1; - max = p2; - } - rad = fey * obb.h.x + fex * obb.h.y; - if (min > rad || max < -rad) - { - return 0; - } - - //----------------------------------------------- - - fex = fabsf(e1.x); - fey = fabsf(e1.y); - fez = fabsf(e1.z); - //AXISTEST_X01(e1.z, e1.y, fez, fey); - p0 = e1.z * v0.y - e1.y * v0.z; - p2 = e1.z * v2.y - e1.y * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * obb.h.y + fey * obb.h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Y02(e1.z, e1.x, fez, fex); - p0 = -e1.z * v0.x + e1.x * v0.z; - p2 = -e1.z * v2.x + e1.x * v2.z; - if (p0 < p2) - { - min = p0; - max = p2; - } - else - { - min = p2; - max = p0; - } - rad = fez * obb.h.x + fex * obb.h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Z0(e1.y, e1.x, fey, fex); - p0 = e1.y * v0.x - e1.x * v0.y; - p1 = e1.y * v1.x - e1.x * v1.y; - if (p0 < p1) - { - min = p0; - max = p1; - } - else - { - min = p1; - max = p0; - } - rad = fey * obb.h.x + fex * obb.h.y; - if (min > rad || max < -rad) - { - return 0; - } - - //----------------------------------------------- - - fex = fabsf(e2.x); - fey = fabsf(e2.y); - fez = fabsf(e2.z); - //AXISTEST_X2(e2.z, e2.y, fez, fey); - p0 = e2.z * v0.y - e2.y * v0.z; - p1 = e2.z * v1.y - e2.y * v1.z; - if (p0 < p1) - { - min = p0; - max = p1; - } - else - { - min = p1; - max = p0; - } - rad = fez * obb.h.y + fey * obb.h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Y1(e2.z, e2.x, fez, fex); - p0 = -e2.z * v0.x + e2.x * v0.z; - p1 = -e2.z * v1.x + e2.x * v1.z; - if (p0 < p1) - { - min = p0; - max = p1; - } - else - { - min = p1; - max = p0; - } - rad = fez * obb.h.x + fex * obb.h.z; - if (min > rad || max < -rad) - { - return 0; - } - - //AXISTEST_Z12(e2.y, e2.x, fey, fex); - p1 = e2.y * v1.x - e2.x * v1.y; - p2 = e2.y * v2.x - e2.x * v2.y; - if (p2 < p1) - { - min = p2; - max = p1; - } - else - { - min = p1; - max = p2; - } - rad = fey * obb.h.x + fex * obb.h.y; - if (min > rad || max < -rad) - { - return 0; - } - - //the {x,y,z}-directions (actually, since we use the AABB of the triangle we don't even need to test these) - //first test overlap in the {x,y,z}-directions - //find min, max of the triangle each direction, and test for overlap in that direction -- - //this is equivalent to testing a minimal AABB around the triangle against the AABB - AABB taabb; - FINDMINMAX(v0.x, v1.x, v2.x, taabb.min.x, taabb.max.x); - FINDMINMAX(v0.y, v1.y, v2.y, taabb.min.y, taabb.max.y); - FINDMINMAX(v0.z, v1.z, v2.z, taabb.min.z, taabb.max.z); - - // test in X-direction - FINDMINMAX(v0.x, v1.x, v2.x, taabb.min.x, taabb.max.x); - if (taabb.min.x > obb.h.x || taabb.max.x < -obb.h.x) - { - return 0; - } - - // test in Y-direction - FINDMINMAX(v0.y, v1.y, v2.y, taabb.min.y, taabb.max.y); - if (taabb.min.y > obb.h.y || taabb.max.y < -obb.h.y) - { - return 0; - } - - // test in Z-direction - FINDMINMAX(v0.z, v1.z, v2.z, taabb.min.z, taabb.max.z); - if (taabb.min.z > obb.h.z || taabb.max.z < -obb.h.z) - { - return 0; - } - - //test if the box overlaps the plane of the triangle - //compute plane equation of triangle: normal*x+d=0 - Plane_tpl plane = Plane_tpl::CreatePlane((e0 % e1), v0); - - Vec3 vmin, vmax; - if (plane.n.x > 0.0f) - { - vmin.x = -obb.h.x; - vmax.x = +obb.h.x; - } - else - { - vmin.x = +obb.h.x; - vmax.x = -obb.h.x; - } - if (plane.n.y > 0.0f) - { - vmin.y = -obb.h.y; - vmax.y = +obb.h.y; - } - else - { - vmin.y = +obb.h.y; - vmax.y = -obb.h.y; - } - if (plane.n.z > 0.0f) - { - vmin.z = -obb.h.z; - vmax.z = +obb.h.z; - } - else - { - vmin.z = +obb.h.z; - vmax.z = -obb.h.z; - } - if ((plane | vmin) > 0.0f) - { - return 0; - } - if ((plane | vmax) < 0.0f) - { - return 0; - } - return 1; - } - - - - - - - - - - /*! - * - * conventional method to check if two AABB's overlap. - * both AABBs are assumed to be in the same space - * - * Example: - * bool result=Overlap::AABB_AABB( aabb1, aabb2 ); - * - */ - ILINE bool AABB_AABB(const AABB& aabb1, const AABB& aabb2) - { - if (aabb1.min.x >= aabb2.max.x) - { - return 0; - } - if (aabb1.min.y >= aabb2.max.y) - { - return 0; - } - if (aabb1.min.z >= aabb2.max.z) - { - return 0; - } - if (aabb1.max.x <= aabb2.min.x) - { - return 0; - } - if (aabb1.max.y <= aabb2.min.y) - { - return 0; - } - if (aabb1.max.z <= aabb2.min.z) - { - return 0; - } - return 1; //the aabb's overlap - } - - /// AABB overlap test - but ignores z values - ILINE bool AABB_AABB2D(const AABB& aabb1, const AABB& aabb2) - { - if (aabb1.min.x >= aabb2.max.x) - { - return 0; - } - if (aabb1.min.y >= aabb2.max.y) - { - return 0; - } - if (aabb1.max.x <= aabb2.min.x) - { - return 0; - } - if (aabb1.max.y <= aabb2.min.y) - { - return 0; - } - return 1; //the aabb's overlap - } - - - /*! - * - * Conventional method to check if two AABB's overlap. - * Both AABBs are in local object space. Used the position-vector - * to translate them into world-space - * - * Example: - * bool result=Overlap::AABB_AABB( pos1,aabb1, pos2,aabb2 ); - * - */ - ILINE bool AABB_AABB(const Vec3& pos1, const AABB& aabb1, const Vec3& pos2, const AABB& aabb2) - { - AABB waabb1(aabb1.min + pos1, aabb1.max + pos1); - AABB waabb2(aabb2.min + pos2, aabb2.max + pos2); - return AABB_AABB(waabb1, waabb2); - } - - - /*! - * - * conventional method to check if two AABB's overlap - * or if AABB1 is comletely inside AABB2. - * both AABBs are assumed to be in the same space - * - * Example: - * bool result=Overlap::AABB_AABB_Inside( aabb1, aabb2 ); - * - * return values: - * 0x00 = no overlap - * 0x01 = both AABBs one overlap - * 0x02 = AABB1 in inside AABB2 - */ - ILINE char AABB_AABB_Inside(const AABB& aabb1, const AABB& aabb2) - { - if (AABB_AABB(aabb1, aabb2)) - { - if (aabb1.min.x <= aabb2.min.x) - { - return 1; - } - if (aabb1.min.y <= aabb2.min.y) - { - return 1; - } - if (aabb1.min.z <= aabb2.min.z) - { - return 1; - } - if (aabb1.max.x >= aabb2.max.x) - { - return 1; - } - if (aabb1.max.y >= aabb2.max.y) - { - return 1; - } - if (aabb1.max.z >= aabb2.max.z) - { - return 1; - } - //yes, its inside - return 2; - } - return 0; - } - - - /*! - * - * we use the SEPARATING AXIS TEST to check if and AABB and an OBB overlap. - * - * Example: - * bool result=Overlap::AABB_OBB( aabb, pos,obb ); - * - */ - inline bool AABB_OBB (const AABB& aabb, const Vec3& pos, const OBB& obb) - { - Vec3 h = (aabb.max - aabb.min) * 0.5f; //calculate the half-length-vectors - Vec3 c = (aabb.max + aabb.min) * 0.5f; //the center in world-space - - //"t" is the transfer-vector from one center to the other - Vec3 t = obb.m33 * obb.c + pos - c; - - f32 ra, rb; - - //-------------------------------------------------------------------------- - //-- we use the vectors "1,0,0","0,1,0" and "0,0,1" as separating axis - //-------------------------------------------------------------------------- - rb = fabsf(obb.m33.m00 * obb.h.x) + fabsf(obb.m33.m01 * obb.h.y) + fabsf(obb.m33.m02 * obb.h.z); - if (fabsf(t.x) > (fabsf(h.x) + rb)) - { - return 0; - } - rb = fabsf(obb.m33.m10 * obb.h.x) + fabsf(obb.m33.m11 * obb.h.y) + fabsf(obb.m33.m12 * obb.h.z); - if (fabsf(t.y) > (fabsf(h.y) + rb)) - { - return 0; - } - rb = fabsf(obb.m33.m20 * obb.h.x) + fabsf(obb.m33.m21 * obb.h.y) + fabsf(obb.m33.m22 * obb.h.z); - if (fabsf(t.z) > (fabsf(h.z) + rb)) - { - return 0; - } - - //-------------------------------------------------------------------------- - //-- we use the orientation-vectors "Mx","My" and "Mz" as separating axis - //-------------------------------------------------------------------------- - ra = fabsf(obb.m33.m00 * h.x) + fabsf(obb.m33.m10 * h.y) + fabsf(obb.m33.m20 * h.z); - if (fabsf(t | Vec3(obb.m33.m00, obb.m33.m10, obb.m33.m20)) > (ra + obb.h.x)) - { - return 0; - } - ra = fabsf(obb.m33.m01 * h.x) + fabsf(obb.m33.m11 * h.y) + fabsf(obb.m33.m21 * h.z); - if (fabsf(t | Vec3(obb.m33.m01, obb.m33.m11, obb.m33.m21)) > (ra + obb.h.y)) - { - return 0; - } - ra = fabsf(obb.m33.m02 * h.x) + fabsf(obb.m33.m12 * h.y) + fabsf(obb.m33.m22 * h.z); - if (fabsf(t | Vec3(obb.m33.m02, obb.m33.m12, obb.m33.m22)) > (ra + obb.h.z)) - { - return 0; - } - - //--------------------------------------------------------------------- - //---- using 9 cross products we generate new separating axis - //--------------------------------------------------------------------- - const float e0 = h.x + h.y + h.z, e1 = obb.h.x + obb.h.y + obb.h.z, e = (e0 + e1 - fabsf(e0 - e1)) * 0.0001f; - ra = h.y * fabsf(obb.m33.m20) + h.z * fabsf(obb.m33.m10); - rb = obb.h.y * fabsf(obb.m33.m02) + obb.h.z * fabsf(obb.m33.m01); - if (fabsf(t.z * obb.m33.m10 - t.y * obb.m33.m20) > (ra + rb) + e) - { - return 0; - } - ra = h.y * fabsf(obb.m33.m21) + h.z * fabsf(obb.m33.m11); - rb = obb.h.x * fabsf(obb.m33.m02) + obb.h.z * fabsf(obb.m33.m00); - if (fabsf(t.z * obb.m33.m11 - t.y * obb.m33.m21) > (ra + rb) + e) - { - return 0; - } - ra = h.y * fabsf(obb.m33.m22) + h.z * fabsf(obb.m33.m12); - rb = obb.h.x * fabsf(obb.m33.m01) + obb.h.y * fabsf(obb.m33.m00); - if (fabsf(t.z * obb.m33.m12 - t.y * obb.m33.m22) > (ra + rb) + e) - { - return 0; - } - - - ra = h.x * fabsf(obb.m33.m20) + h.z * fabsf(obb.m33.m00); - rb = obb.h.y * fabsf(obb.m33.m12) + obb.h.z * fabsf(obb.m33.m11); - if (fabsf(t.x * obb.m33.m20 - t.z * obb.m33.m00) > (ra + rb) + e) - { - return 0; - } - ra = h.x * fabsf(obb.m33.m21) + h.z * fabsf(obb.m33.m01); - rb = obb.h.x * fabsf(obb.m33.m12) + obb.h.z * fabsf(obb.m33.m10); - if (fabsf(t.x * obb.m33.m21 - t.z * obb.m33.m01) > (ra + rb) + e) - { - return 0; - } - ra = h.x * fabsf(obb.m33.m22) + h.z * fabsf(obb.m33.m02); - rb = obb.h.x * fabsf(obb.m33.m11) + obb.h.y * fabsf(obb.m33.m10); - if (fabsf(t.x * obb.m33.m22 - t.z * obb.m33.m02) > (ra + rb) + e) - { - return 0; - } - - - ra = h.x * fabsf(obb.m33.m10) + h.y * fabsf(obb.m33.m00); - rb = obb.h.y * fabsf(obb.m33.m22) + obb.h.z * fabsf(obb.m33.m21); - if (fabsf(t.y * obb.m33.m00 - t.x * obb.m33.m10) > (ra + rb) + e) - { - return 0; - } - ra = h.x * fabsf(obb.m33.m11) + h.y * fabsf(obb.m33.m01); - rb = obb.h.x * fabsf(obb.m33.m22) + obb.h.z * fabsf(obb.m33.m20); - if (fabsf(t.y * obb.m33.m01 - t.x * obb.m33.m11) > (ra + rb) + e) - { - return 0; - } - ra = h.x * fabsf(obb.m33.m12) + h.y * fabsf(obb.m33.m02); - rb = obb.h.x * fabsf(obb.m33.m21) + obb.h.y * fabsf(obb.m33.m20); - if (fabsf(t.y * obb.m33.m02 - t.x * obb.m33.m12) > (ra + rb) + e) - { - return 0; - } - - //no separating axis found, we have an intersection - return 1; - } - - /*! - * - * we use the SEPARATING AXIS TEST to check if two OBB's overlap. - * - * Example: - * bool result=Overlap::OBB_OBB( pos1,obb1, pos2,obb2 ); - * - */ - inline bool OBB_OBB (const Vec3& pos1, const OBB& obb1, const Vec3& pos2, const OBB& obb2) - { - //tranform obb2 in local space of obb1 - Matrix33 M = obb1.m33.T() * obb2.m33; - - //the new center-position in world-space - Vec3 p1 = obb1.m33 * obb1.c + pos1; - Vec3 p2 = obb2.m33 * obb2.c + pos2; - - //"t" is the transfer-vector from one center to the other - Vec3 t = (p2 - p1) * obb1.m33; - - float ra, rb; - - //-------------------------------------------------------------------------- - //-- we use the vectors "1,0,0","0,1,0" and "0,0,1" as separating axis - //-------------------------------------------------------------------------- - rb = fabsf(M.m00 * obb2.h.x) + fabsf(M.m01 * obb2.h.y) + fabsf(M.m02 * obb2.h.z); - if (fabsf(t.x) > (fabsf(obb1.h.x) + rb)) - { - return 0; - } - rb = fabsf(M.m10 * obb2.h.x) + fabsf(M.m11 * obb2.h.y) + fabsf(M.m12 * obb2.h.z); - if (fabsf(t.y) > (fabsf(obb1.h.y) + rb)) - { - return 0; - } - rb = fabsf(M.m20 * obb2.h.x) + fabsf(M.m21 * obb2.h.y) + fabsf(M.m22 * obb2.h.z); - if (fabsf(t.z) > (fabsf(obb1.h.z) + rb)) - { - return 0; - } - - //-------------------------------------------------------------------------- - //-- we use the orientation-vectors "Mx","My" and "Mz" as separating axis - //-------------------------------------------------------------------------- - ra = fabsf(M.m00 * obb1.h.x) + fabsf(M.m10 * obb1.h.y) + fabsf(M.m20 * obb1.h.z); - if (fabsf(t | Vec3(M.m00, M.m10, M.m20)) > (ra + obb2.h.x)) - { - return 0; - } - ra = fabsf(M.m01 * obb1.h.x) + fabsf(M.m11 * obb1.h.y) + fabsf(M.m21 * obb1.h.z); - if (fabsf(t | Vec3(M.m01, M.m11, M.m21)) > (ra + obb2.h.y)) - { - return 0; - } - ra = fabsf(M.m02 * obb1.h.x) + fabsf(M.m12 * obb1.h.y) + fabsf(M.m22 * obb1.h.z); - if (fabsf(t | Vec3(M.m02, M.m12, M.m22)) > (ra + obb2.h.z)) - { - return 0; - } - - //--------------------------------------------------------------------- - //---- using 9 cross products we generate new separating axis - //--------------------------------------------------------------------- - ra = obb1.h.y * fabsf(M.m20) + obb1.h.z * fabsf(M.m10); - rb = obb2.h.y * fabsf(M.m02) + obb2.h.z * fabsf(M.m01); - if (fabsf(t.z * M.m10 - t.y * M.m20) > (ra + rb)) - { - return 0; - } - ra = obb1.h.y * fabsf(M.m21) + obb1.h.z * fabsf(M.m11); - rb = obb2.h.x * fabsf(M.m02) + obb2.h.z * fabsf(M.m00); - if (fabsf(t.z * M.m11 - t.y * M.m21) > (ra + rb)) - { - return 0; - } - ra = obb1.h.y * fabsf(M.m22) + obb1.h.z * fabsf(M.m12); - rb = obb2.h.x * fabsf(M.m01) + obb2.h.y * fabsf(M.m00); - if (fabsf(t.z * M.m12 - t.y * M.m22) > (ra + rb)) - { - return 0; - } - - - ra = obb1.h.x * fabsf(M.m20) + obb1.h.z * fabsf(M.m00); - rb = obb2.h.y * fabsf(M.m12) + obb2.h.z * fabsf(M.m11); - if (fabsf(t.x * M.m20 - t.z * M.m00) > (ra + rb)) - { - return 0; - } - ra = obb1.h.x * fabsf(M.m21) + obb1.h.z * fabsf(M.m01); - rb = obb2.h.x * fabsf(M.m12) + obb2.h.z * fabsf(M.m10); - if (fabsf(t.x * M.m21 - t.z * M.m01) > (ra + rb)) - { - return 0; - } - ra = obb1.h.x * fabsf(M.m22) + obb1.h.z * fabsf(M.m02); - rb = obb2.h.x * fabsf(M.m11) + obb2.h.y * fabsf(M.m10); - if (fabsf(t.x * M.m22 - t.z * M.m02) > (ra + rb)) - { - return 0; - } - - - ra = obb1.h.x * fabsf(M.m10) + obb1.h.y * fabsf(M.m00); - rb = obb2.h.y * fabsf(M.m22) + obb2.h.z * fabsf(M.m21); - if (fabsf(t.y * M.m00 - t.x * M.m10) > (ra + rb)) - { - return 0; - } - ra = obb1.h.x * fabsf(M.m11) + obb1.h.y * fabsf(M.m01); - rb = obb2.h.x * fabsf(M.m22) + obb2.h.z * fabsf(M.m20); - if (fabsf(t.y * M.m01 - t.x * M.m11) > (ra + rb)) - { - return 0; - } - ra = obb1.h.x * fabsf(M.m12) + obb1.h.y * fabsf(M.m02); - rb = obb2.h.x * fabsf(M.m21) + obb2.h.y * fabsf(M.m20); - if (fabsf(t.y * M.m02 - t.x * M.m12) > (ra + rb)) - { - return 0; - } - - return 1; //no separating axis found, we have an overlap - } - - - - - - -#define PLANE_X 0 -#define PLANE_Y 1 -#define PLANE_Z 2 -#define PLANE_NON_AXIAL 3 - - //! check if the point is inside a triangle - inline bool PointInTriangle(const Vec3& point, const Vec3& v0, const Vec3& v1, const Vec3& v2, const Vec3& normal) - { - float xt, yt; - Vec3 nn; - - int p1, p2; - - nn = normal; - nn.x = (float)fabs(nn.x); - nn.y = (float)fabs(nn.y); - nn.z = (float)fabs(nn.z); - - if ((nn.x >= nn.y) && (nn.x >= nn.z)) - { - xt = point.y; - yt = point.z; - p1 = PLANE_Y; - p2 = PLANE_Z; - } - else - if ((nn.y >= nn.x) && (nn.y >= nn.z)) - { - xt = point.x; - yt = point.z; - p1 = PLANE_X; - p2 = PLANE_Z; - } - else - { - xt = point.x; - yt = point.y; - p1 = PLANE_X; - p2 = PLANE_Y; - } - - float Ax, Ay, Bx, By; - float s; - - bool front = false; - bool back = false; - - - Ax = (v0)[p1]; - Bx = (v1)[p1]; - Ay = (v0)[p2]; - By = (v1)[p2]; - - s = ((Ay - yt) * (Bx - Ax) - (Ax - xt) * (By - Ay)); - - if (s >= 0) - { - if (back) - { - return (false); - } - front = true; - } - else - { - if (front) - { - return (false); - } - back = true; - } - - Ax = (v1)[p1]; - Bx = (v2)[p1]; - Ay = (v1)[p2]; - By = (v2)[p2]; - - s = ((Ay - yt) * (Bx - Ax) - (Ax - xt) * (By - Ay)); - - if (s >= 0) - { - if (back) - { - return (false); - } - front = true; - } - else - { - if (front) - { - return (false); - } - back = true; - } - - Ax = (v2)[p1]; - Bx = (v0)[p1]; - Ay = (v2)[p2]; - By = (v0)[p2]; - - s = ((Ay - yt) * (Bx - Ax) - (Ax - xt) * (By - Ay)); - - if (s >= 0) - { - if (back) - { - return (false); - } - front = true; - } - else - { - if (front) - { - return (false); - } - back = true; - } - - return (true); - } -} - - - -#endif // CRYINCLUDE_CRYCOMMON_CRY_GEOOVERLAP_H diff --git a/Code/Legacy/CryCommon/Cry_Math.h b/Code/Legacy/CryCommon/Cry_Math.h index 885361f4e3..74a18e8910 100644 --- a/Code/Legacy/CryCommon/Cry_Math.h +++ b/Code/Legacy/CryCommon/Cry_Math.h @@ -18,7 +18,7 @@ #include "Cry_ValidNumber.h" #include // eLittleEndian #include -#include +//#include #include /////////////////////////////////////////////////////////////////////////////// // Forward declarations // diff --git a/Code/Legacy/CryCommon/Cry_Matrix33.h b/Code/Legacy/CryCommon/Cry_Matrix33.h index 02d1586931..9e0b12fafa 100644 --- a/Code/Legacy/CryCommon/Cry_Matrix33.h +++ b/Code/Legacy/CryCommon/Cry_Matrix33.h @@ -1194,8 +1194,6 @@ struct Matrix33_tpl return true; } - - AUTO_STRUCT_INFO }; /////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/Cry_Matrix34.h b/Code/Legacy/CryCommon/Cry_Matrix34.h index d409cfef8b..0659d3bc47 100644 --- a/Code/Legacy/CryCommon/Cry_Matrix34.h +++ b/Code/Legacy/CryCommon/Cry_Matrix34.h @@ -1213,8 +1213,6 @@ struct Matrix34_tpl m.m23 = pdotn * n.z; return m; } - - AUTO_STRUCT_INFO }; /////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/Cry_Matrix44.h b/Code/Legacy/CryCommon/Cry_Matrix44.h index e97325141c..20d7494e16 100644 --- a/Code/Legacy/CryCommon/Cry_Matrix44.h +++ b/Code/Legacy/CryCommon/Cry_Matrix44.h @@ -655,8 +655,6 @@ struct Matrix44_tpl (fabs_tpl(m0.m30 - m1.m30) <= e) && (fabs_tpl(m0.m31 - m1.m31) <= e) && (fabs_tpl(m0.m32 - m1.m32) <= e) && (fabs_tpl(m0.m33 - m1.m33) <= e) ); } - - AUTO_STRUCT_INFO }; /////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/Cry_Quat.h b/Code/Legacy/CryCommon/Cry_Quat.h index b062c584b7..a18d8a2ad9 100644 --- a/Code/Legacy/CryCommon/Cry_Quat.h +++ b/Code/Legacy/CryCommon/Cry_Quat.h @@ -888,9 +888,6 @@ struct Quat_tpl { return CreateNlerp(IDENTITY, *this, scale); } - - - AUTO_STRUCT_INFO }; @@ -1409,8 +1406,6 @@ struct QuatT_tpl { return QuatT_tpl(t * scale, q.GetScaled(scale)); } - - AUTO_STRUCT_INFO }; typedef QuatT_tpl QuatT; //always 32 bit @@ -1690,8 +1685,6 @@ struct QuatTS_tpl ILINE Vec3_tpl GetRow0() const { return q.GetRow0(); } ILINE Vec3_tpl GetRow1() const { return q.GetRow1(); } ILINE Vec3_tpl GetRow2() const { return q.GetRow2(); } - - AUTO_STRUCT_INFO }; typedef QuatTS_tpl QuatTS; //always 64 bit @@ -1947,8 +1940,6 @@ struct QuatTNS_tpl ILINE Vec3_tpl GetRow0() const { return q.GetRow0(); } ILINE Vec3_tpl GetRow1() const { return q.GetRow1(); } ILINE Vec3_tpl GetRow2() const { return q.GetRow2(); } - - AUTO_STRUCT_INFO }; typedef QuatTNS_tpl QuatTNS; @@ -2097,8 +2088,6 @@ struct DualQuat_tpl nq *= norm; dq *= norm; } - - AUTO_STRUCT_INFO }; #ifndef MAX_API_NUM diff --git a/Code/Legacy/CryCommon/Cry_Vector2.h b/Code/Legacy/CryCommon/Cry_Vector2.h index f17259d70f..a8722c1b02 100644 --- a/Code/Legacy/CryCommon/Cry_Vector2.h +++ b/Code/Legacy/CryCommon/Cry_Vector2.h @@ -295,8 +295,6 @@ struct Vec2_tpl { return sqrt_tpl((x - vec1.x) * (x - vec1.x) + (y - vec1.y) * (y - vec1.y)); } - - AUTO_STRUCT_INFO }; /////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/Cry_Vector3.h b/Code/Legacy/CryCommon/Cry_Vector3.h index 7b735df0fa..bd1cc11430 100644 --- a/Code/Legacy/CryCommon/Cry_Vector3.h +++ b/Code/Legacy/CryCommon/Cry_Vector3.h @@ -845,8 +845,6 @@ struct Vec3_tpl { return Vec3_tpl(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); } - - AUTO_STRUCT_INFO }; // dot product (2 versions) @@ -1175,8 +1173,6 @@ struct Ang3_tpl } return true; } - - AUTO_STRUCT_INFO }; typedef Ang3_tpl Ang3; @@ -1406,8 +1402,6 @@ struct Plane_tpl Vec3_tpl MirrorPosition(const Vec3_tpl& i) { return i - n * (2 * ((n | i) + d)); } ILINE bool IsValid() const { return !n.IsZeroFast(); } //A plane with a zero normal isn't valid. - - AUTO_STRUCT_INFO }; typedef Plane_tpl Plane; //always 32 bit diff --git a/Code/Legacy/CryCommon/Cry_Vector4.h b/Code/Legacy/CryCommon/Cry_Vector4.h index bafeefe00b..bbb3395fb3 100644 --- a/Code/Legacy/CryCommon/Cry_Vector4.h +++ b/Code/Legacy/CryCommon/Cry_Vector4.h @@ -227,8 +227,6 @@ struct Vec4_tpl ILINE void SetLerp(const Vec4_tpl& p, const Vec4_tpl& q, F t) { *this = p * (1.0f - t) + q * t; } ILINE static Vec4_tpl CreateLerp(const Vec4_tpl& p, const Vec4_tpl& q, F t) { return p * (1.0f - t) + q * t; } - - AUTO_STRUCT_INFO }; diff --git a/Code/Legacy/CryCommon/HMDBus.h b/Code/Legacy/CryCommon/HMDBus.h index 674b7ffd1e..dab4c28668 100644 --- a/Code/Legacy/CryCommon/HMDBus.h +++ b/Code/Legacy/CryCommon/HMDBus.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -36,7 +35,7 @@ namespace AZ * Event triggered when an HMD initializes successfully */ virtual void OnHMDInitialized() {} - + /** * Event triggered when an HMD shuts down */ @@ -56,7 +55,7 @@ namespace AZ virtual ~HMDInitBus() {} /// - /// Attempt to initialize this device. If initialization is initially successful (device exists and is able to startup) then this device should connect to the + /// Attempt to initialize this device. If initialization is initially successful (device exists and is able to startup) then this device should connect to the /// HMDDeviceRequestBus in order to be used as an HMD from the main Open 3D Engine system. /// /// @return If true, initialization fully succeeded. @@ -120,21 +119,10 @@ namespace AZ }; /// - /// Get per-eye camera info from the device. The specific info to get is defined in the EyeCameraInfo struct. This function can be used to setup - /// rendering cameras per-eye. Note that each eye may have different projection matrix information. - /// - /// @param eye The specific eye to get camera data for. - /// @param nearPlane Near distance for the main render camera. - /// @param farPlane Far distance for the main render camera. - /// @param cameraInfo Returned camera information for this particular eye. - /// - virtual void GetPerEyeCameraInfo([[maybe_unused]] const EStereoEye eye, [[maybe_unused]] const float nearPlane, [[maybe_unused]] const float farPlane, [[maybe_unused]] PerEyeCameraInfo& cameraInfo) {} - - /// /// Update the HMD's internal state and handle events /// This is NOT where tracking is updated. This is for game-time /// events such as controllers connecting/disconnecting or - /// certain compositor events being triggered. + /// certain compositor events being triggered. /// virtual void UpdateInternalState() {} @@ -164,9 +152,9 @@ namespace AZ /// /// Retrieve the latest tracking state that was cached since the last call /// to UpdateTrackingStates. - /// - /// TODO: Differentiate between tracking states viable for rendering and - /// tracking states viable for game simulation. + /// + /// TODO: Differentiate between tracking states viable for rendering and + /// tracking states viable for game simulation. /// virtual TrackingState* GetTrackingState() { return nullptr; } @@ -196,7 +184,7 @@ namespace AZ /// /// Set the current tracking level of the HMD. Supported tracking levels are defined in struct TrackingLevel. - /// + /// /// @param level The tracking level we want to use with this HMD /// virtual void SetTrackingLevel([[maybe_unused]] const AZ::VR::HMDTrackingLevel level) {} @@ -209,7 +197,7 @@ namespace AZ /// /// Enable/disable debugging for this device. The device can decide what the most appropriate debugging information is /// displayed to the user (e.g. HMD position, performance info, latency timing, etc.). - /// + /// /// @param enable Set to true to enable debugging /// virtual void EnableDebugging([[maybe_unused]] bool enable) {} @@ -230,16 +218,16 @@ namespace AZ virtual HMDDeviceInfo* GetDeviceInfo() { return nullptr; } /// - /// Get whether or not the HMD has been initialized. The HMD has been initialized when it has fully established an interface - /// with its necessary SDK and is ready to be used. - /// + /// Get whether or not the HMD has been initialized. The HMD has been initialized when it has fully established an interface + /// with its necessary SDK and is ready to be used. + /// /// @return True if the device has been initialized and is usable /// virtual bool IsInitialized() { return false; } /// /// Get the play space of the device, if exists - /// + /// /// @return True if the device has been initialized and is usable /// virtual const Playspace* GetPlayspace() { return nullptr; } @@ -251,21 +239,13 @@ namespace AZ /// virtual void UpdateTrackingStates() {} - /// - /// Retrieves the current index into the VR system's swapchain that should be used. - /// This only really need to be overridden by VR implementations that keep track - /// of an internal swapchain like Oculus. OpenVR will handle swapchains - /// internally and can just return 0. - /// - virtual AZ::u32 GetSwapchainIndex([[maybe_unused]] const EStereoEye& eye) { return 0; } - protected: }; using HMDDeviceRequestBus = AZ::EBus; /// - /// Bus to define HMD debugging. This includes visualization of any HMD-specific objects as well as any + /// Bus to define HMD debugging. This includes visualization of any HMD-specific objects as well as any /// VR performance metrics displayed in the HMD. /// class HMDDebuggerBus diff --git a/Code/Legacy/CryCommon/IConsole.h b/Code/Legacy/CryCommon/IConsole.h index e03de35aa1..dcbb0399aa 100644 --- a/Code/Legacy/CryCommon/IConsole.h +++ b/Code/Legacy/CryCommon/IConsole.h @@ -6,12 +6,11 @@ * */ - -#ifndef CRYINCLUDE_CRYCOMMON_ICONSOLE_H -#define CRYINCLUDE_CRYCOMMON_ICONSOLE_H #pragma once #include +#include +#include struct SFunctor; @@ -454,24 +453,6 @@ struct IConsole virtual void DumpKeyBinds(IKeyBindDumpSink* pCallback) = 0; virtual const char* FindKeyBind(const char* sCmd) const = 0; - ////////////////////////////////////////////////////////////////////////// - // Hashing of cvars (for anti-cheat). Separates setting of range, calculation, - // and retrieval of result so calculation can be done at a known safe point - // (e.g end of frame) when we know cvars won't be modified or in temporary state - - // Get Number of cvars that can be hashed - virtual int GetNumCheatVars() = 0; - // Set the range of cvars - virtual void SetCheatVarHashRange(size_t firstVar, size_t lastVar) = 0; - // Calculate the hash from current cvars - virtual void CalcCheatVarHash() = 0; - // Since hash is calculated async, check if it's completed - virtual bool IsHashCalculated() = 0; - // Get the hash calculated - virtual uint64 GetCheatVarHash() = 0; - virtual void PrintCheatVars(bool bUseLastHashRange) = 0; - virtual char* GetCheatVarAt(uint32 nOffset) = 0; - ////////////////////////////////////////////////////////////////////////// // Console variable sink. // Adds a new console variables sink callback. @@ -644,19 +625,6 @@ struct ICVar // Returns an ID to use when getting or removing the functor virtual uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) = 0; - ////////////////////////////////////////////////////////////////////////// - // Returns the number of registered on change functos. - virtual uint64 GetNumberOfOnChangeFunctors() const = 0; - - ////////////////////////////////////////////////////////////////////////// - // Returns the functors with the specified id. - virtual const SFunctor& GetOnChangeFunctor(uint64 nFunctorId) const = 0; - - ////////////////////////////////////////////////////////////////////////// - // Removes an on change functor - // returns true if removal was successful. - virtual bool RemoveOnChangeFunctor(uint64 nFunctorId) = 0; - ////////////////////////////////////////////////////////////////////////// // Get the current callback function. virtual ConsoleVarFunc GetOnChangeCallback() const = 0; @@ -685,5 +653,3 @@ struct ICVar // Set the data probe string value of the variable virtual void SetDataProbeString(const char* pDataProbeString) = 0; }; - -#endif // CRYINCLUDE_CRYCOMMON_ICONSOLE_H diff --git a/Code/Legacy/CryCommon/IEntityRenderState.h b/Code/Legacy/CryCommon/IEntityRenderState.h index c4267b28f2..b459a6acaa 100644 --- a/Code/Legacy/CryCommon/IEntityRenderState.h +++ b/Code/Legacy/CryCommon/IEntityRenderState.h @@ -13,9 +13,10 @@ #include #include #include +#include -namespace AZ +namespace AZ { class Vector2; } @@ -29,560 +30,16 @@ struct SFrameLodInfo; struct pe_params_area; struct pe_articgeomparams; -// @NOTE: When removing an item from this enum, replace it with a dummy - ID's from this enum are stored in data and should not change. -enum EERType -{ - eERType_NotRenderNode, - eERType_Dummy_10, - eERType_Dummy8, - eERType_Light, - eERType_Cloud, - eERType_TerrainSystem, // used to be eERType_Dummy_1 which used to be eERType_VoxelObject, preserve order for compatibility - eERType_FogVolume, - eERType_Decal, - eERType_Dummy_6, // used to be eERType_ParticleEmitter, preserve order for compatibility - eERType_WaterVolume, - eERType_Dummy_5, // used to be eERType_WaterWave, preserve order for compatibility - eERType_Dummy_7, // used to be eERType_Road, preserve order for compatibility - eERType_DistanceCloud, - eERType_VolumeObject, - eERType_Dummy_0, // used to be eERType_AutoCubeMap, preserve order for compatibility - eERType_Rope, - eERType_PrismObject, - eERType_Dummy_2, // used to be eERType_IsoMesh, preserve order for compatibility - eERType_Dummy_4, - eERType_RenderComponent, - eERType_GameEffect, - eERType_BreakableGlass, - eERType_Dummy_3, // used to be eERType_LightShape, preserve order for compatibility - eERType_Dummy_9, - eERType_GeomCache, - eERType_StaticMeshRenderComponent, - eERType_DynamicMeshRenderComponent, - eERType_SkinnedMeshRenderComponent, - eERType_TypesNum, // MUST BE AT END TOTAL NUMBER OF ERTYPES -}; - -enum ERNListType -{ - eRNListType_Unknown, - eRNListType_DecalsAndRoads, - eRNListType_ListsNum, - eRNListType_First = eRNListType_Unknown, // This should be the last member - // And it counts on eRNListType_Unknown - // being the first enum element. -}; - -enum EOcclusionObjectType -{ - eoot_OCCLUDER, - eoot_OCEAN, - eoot_OCCELL, - eoot_OCCELL_OCCLUDER, - eoot_OBJECT, - eoot_OBJECT_TO_LIGHT, - eoot_TERRAIN_NODE, - eoot_PORTAL, -}; - -// RenderNode flags - -#define ERF_GOOD_OCCLUDER BIT(0) -#define ERF_PROCEDURAL BIT(1) -#define ERF_CLONE_SOURCE BIT(2) // set if this object was cloned from another one -#define ERF_CASTSHADOWMAPS BIT(3) // if you ever set this flag, be sure also to set ERF_HAS_CASTSHADOWMAPS -#define ERF_RENDER_ALWAYS BIT(4) -#define ERF_DYNAMIC_DISTANCESHADOWS BIT(5) -#define ERF_HIDABLE BIT(6) -#define ERF_HIDABLE_SECONDARY BIT(7) -#define ERF_HIDDEN BIT(8) -#define ERF_SELECTED BIT(9) -#define ERF_PROCEDURAL_ENTITY BIT(10) // this is an object generated at runtime which has a limited lifetime (matches procedural entity) -#define ERF_OUTDOORONLY BIT(11) -#define ERF_NODYNWATER BIT(12) -#define ERF_EXCLUDE_FROM_TRIANGULATION BIT(13) -#define ERF_REGISTER_BY_BBOX BIT(14) -#define ERF_STATIC_INSTANCING BIT(15) -#define ERF_VOXELIZE_STATIC BIT(16) -#define ERF_NO_PHYSICS BIT(17) -#define ERF_NO_DECALNODE_DECALS BIT(18) -#define ERF_REGISTER_BY_POSITION BIT(19) -#define ERF_COMPONENT_ENTITY BIT(20) -#define ERF_RECVWIND BIT(21) -#define ERF_COLLISION_PROXY BIT(22) // Collision proxy is a special object that is only visible in editor -// and used for physical collisions with player and vehicles. -#define ERF_LOD_BBOX_BASED BIT(23) // Lod changes based on bounding boxes. -#define ERF_SPEC_BIT0 BIT(24) // Bit0 of min config specification. -#define ERF_SPEC_BIT1 BIT(25) // Bit1 of min config specification. -#define ERF_SPEC_BIT2 BIT(26) // Bit2 of min config specification. -#define ERF_SPEC_BITS_MASK (ERF_SPEC_BIT0 | ERF_SPEC_BIT1 | ERF_SPEC_BIT2) // Bit mask of the min spec bits. -#define ERF_SPEC_BITS_SHIFT (24) // Bit offset of the ERF_SPEC_BIT0. -#define ERF_RAYCAST_PROXY BIT(27) // raycast proxy is only used for raycasting -#define ERF_HUD BIT(28) // Hud object that can avoid some visibility tests -#define ERF_RAIN_OCCLUDER BIT(29) // Is used for rain occlusion map -#define ERF_HAS_CASTSHADOWMAPS BIT(30) // at one point had ERF_CASTSHADOWMAPS set -#define ERF_ACTIVE_LAYER BIT(31) // the node is on a currently active layer - -struct IShadowCaster -{ - // - virtual ~IShadowCaster(){} - virtual bool HasOcclusionmap([[maybe_unused]] int nLod, [[maybe_unused]] IRenderNode* pLightOwner) { return false; } - virtual CLodValue ComputeLod(int wantedLod, [[maybe_unused]] const SRenderingPassInfo& passInfo) { return CLodValue(wantedLod); } - virtual void Render(const SRendParams& RendParams, const SRenderingPassInfo& passInfo) = 0; - virtual const AABB GetBBoxVirtual() = 0; - virtual void FillBBox(AABB& aabb) = 0; - virtual EERType GetRenderNodeType() = 0; - virtual bool IsRenderNode() { return true; } - // - uint8 m_cStaticShadowLod; -}; - -// Optional filter function for octree queries to perform custom filtering of the results. -// return true to keep the render node, false to filter it out. -using ObjectTreeQueryFilterCallback = AZStd::function; - -struct IOctreeNode -{ -public: - virtual ~IOctreeNode() {}; - - virtual void GetObjectsByType(PodArray& lstObjects, EERType objType, const AABB* pBBox, ObjectTreeQueryFilterCallback filterCallback = nullptr) = 0; - - struct CVisArea* m_pVisArea; -}; - -struct SLodDistDissolveTransitionState -{ - float fStartDist; - int8 nOldLod; - int8 nNewLod; - bool bFarside; -}; - -struct SLightInfo -{ - bool operator == (const SLightInfo& other) const - { return other.vPos.IsEquivalent(vPos, 0.1f) && fabs(other.fRadius - fRadius) < 0.1f; } - Vec3 vPos; - float fRadius; - bool bAffecting; -}; - struct IRenderNode - : public IShadowCaster { - enum EInternalFlags - { - DECAL_OWNER = BIT(0), // Owns some decals. - REQUIRES_NEAREST_CUBEMAP = BIT(1), // Pick nearest cube map - UPDATE_DECALS = BIT(2), // The node changed geometry - decals must be updated. - REQUIRES_FORWARD_RENDERING = BIT(3), // Special shadow processing needed. - WAS_INVISIBLE = BIT(4), // Was invisible last frame. - WAS_IN_VISAREA = BIT(5), // Was inside vis-ares last frame. - WAS_FARAWAY = BIT(6), // Was considered 'far away' for the purposes of physics deactivation. - HAS_OCCLUSION_PROXY = BIT(7) // This node has occlusion proxy. - }; - - IRenderNode() - { - m_dwRndFlags = 0; - m_fViewDistanceMultiplier = static_cast(IRenderNode::VIEW_DISTANCE_MULTIPLIER_MAX); // By default object is not limited by distance. - m_ucLodRatio = 100; - m_pOcNode = 0; - m_fWSMaxViewDist = 0; - m_nInternalFlags = 0; - m_nMaterialLayers = 0; - m_pRNTmpData = NULL; - m_pPrev = m_pNext = NULL; - m_nSID = 0; - m_cShadowLodBias = 0; - m_cStaticShadowLod = 0; - } - - virtual bool CanExecuteRenderAsJob() { return false; } - - // - // Debug info about object. - virtual const char* GetName() const = 0; - virtual const char* GetEntityClassName() const = 0; - virtual AZStd::string GetDebugString([[maybe_unused]] char type = 0) const { return ""; } - virtual float GetImportance() const { return 1.f; } - - // Description: - // Releases IRenderNode. - virtual void ReleaseNode([[maybe_unused]] bool bImmediate = false) { delete this; } - - - virtual IRenderNode* Clone() const { return NULL; } - - // Description: - // Sets render node transformation matrix. - virtual void SetMatrix([[maybe_unused]] const Matrix34& mat) {} - - // Description: - // Gets local bounds of the render node. - virtual void GetLocalBounds(AABB& bbox) { AABB WSBBox(GetBBox()); bbox = AABB(WSBBox.min - GetPos(true), WSBBox.max - GetPos(true)); } - - virtual Vec3 GetPos(bool bWorldOnly = true) const = 0; - virtual const AABB GetBBox() const = 0; - virtual void FillBBox(AABB& aabb) { aabb = GetBBox(); } - virtual void SetBBox(const AABB& WSBBox) = 0; - - virtual void SetScale([[maybe_unused]] const Vec3& scale) {} - - //Get the scales assuming the scale is uniform or per column as needed. - virtual float GetUniformScale() { return 1.0f; } - virtual float GetColumnScale([[maybe_unused]] int column) { return 1.0f; } - - // Summary: - // Changes the world coordinates position of this node by delta - // Don't forget to call this base function when overriding it. - virtual void OffsetPosition(const Vec3& delta) = 0; - - // Return true when the node is initialized and ready to render - virtual bool IsReady() const { return true; } - - // Summary: - // Renders node geometry - virtual void Render(const struct SRendParams& EntDrawParams, const SRenderingPassInfo& passInfo) = 0; - - // Hides/disables node in renderer. - virtual void Hide(bool bHide) { SetRndFlags(ERF_HIDDEN, bHide); } - bool IsHidden() const { return (GetRndFlags() & ERF_HIDDEN) != 0; } - // Gives access to object components. - virtual struct IStatObj* GetEntityStatObj(unsigned int nPartId = 0, unsigned int nSubPartId = 0, Matrix34A* pMatrix = NULL, bool bReturnOnlyVisible = false); - virtual _smart_ptr GetEntitySlotMaterial([[maybe_unused]] unsigned int nPartId, [[maybe_unused]] bool bReturnOnlyVisible = false, [[maybe_unused]] bool* pbDrawNear = NULL) { return NULL; } - virtual void SetEntityStatObj([[maybe_unused]] unsigned int nSlot, [[maybe_unused]] IStatObj* pStatObj, [[maybe_unused]] const Matrix34A* pMatrix = NULL) {}; - virtual int GetSlotCount() const { return 1; } - - // Summary: - // Returns IRenderMesh of the object. - virtual struct IRenderMesh* GetRenderMesh([[maybe_unused]] int nLod) { return 0; }; - - // Description: - // Allows to adjust default lod distance settings, - // if fLodRatio is 100 - default lod distance is used. - virtual void SetLodRatio(int nLodRatio) { m_ucLodRatio = static_cast(min(255, max(0, nLodRatio))); } - - // Summary: - // Gets material layers mask. - virtual uint8 GetMaterialLayers() const { return m_nMaterialLayers; } - - - // Summary - // Physicalizes if it isn't already. - virtual void CheckPhysicalized() {}; - - // Summary: - // Physicalizes node. - virtual void Physicalize([[maybe_unused]] bool bInstant = false) {} - - virtual ~IRenderNode() { assert(!m_pRNTmpData); }; - - // Summary: - // Sets override material for this instance. - virtual void SetMaterial(_smart_ptr pMat) = 0; - // Summary: - // Queries override material of this instance. - virtual _smart_ptr GetMaterial(Vec3* pHitPos = NULL) = 0; - virtual _smart_ptr GetMaterialOverride() = 0; - virtual void GetMaterials(AZStd::vector<_smart_ptr>& materials) - { - _smart_ptr currentMaterial = GetMaterialOverride(); - if (!currentMaterial) - { - currentMaterial = GetMaterial(); - } - if (currentMaterial) - { - materials.push_back(currentMaterial); - } + struct IStatObj* GetEntityStatObj(unsigned int = 0, unsigned int = 0, Matrix34A* = NULL, bool = false) { + return nullptr; } - // Used by the editor during export - virtual void SetCollisionClassIndex([[maybe_unused]] int tableIndex) {} - - virtual int GetEditorObjectId() { return 0; } - virtual void SetEditorObjectId([[maybe_unused]] int nEditorObjectId) {} - virtual void SetStatObjGroupIndex([[maybe_unused]] int nVegetationGroupIndex) { } - virtual int GetStatObjGroupId() const { return -1; } - virtual void SetLayerId([[maybe_unused]] uint16 nLayerId) { } - virtual uint16 GetLayerId() { return 0; } - virtual float GetMaxViewDist() = 0; - - virtual EERType GetRenderNodeType() = 0; - virtual bool IsAllocatedOutsideOf3DEngineDLL() - { - return GetRenderNodeType() == eERType_RenderComponent || - GetRenderNodeType() == eERType_StaticMeshRenderComponent || - GetRenderNodeType() == eERType_DynamicMeshRenderComponent || - GetRenderNodeType() == eERType_SkinnedMeshRenderComponent; - } - virtual void Dephysicalize([[maybe_unused]] bool bKeepIfReferenced = false) {} - virtual void Dematerialize() {} - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - - virtual void Precache() {}; - - virtual const AABB GetBBoxVirtual() { return GetBBox(); } - - // virtual float GetLodForDistance(float fDistance) { return 0; } - - virtual void OnRenderNodeBecomeVisible([[maybe_unused]] const SRenderingPassInfo& passInfo) {} - virtual void OnPhysAreaChange() {} - - virtual bool IsMovableByGame() const { return false; } - - virtual uint8 GetSortPriority() { return 0; } - - // Types of voxelization for objects and lights - enum EVoxelGIMode : int - { - VM_None = 0, // No voxelization - VM_Static, // Incremental or asynchronous lazy voxelization - VM_Dynamic, // Real-time every-frame voxelization on GPU - }; - - virtual EVoxelGIMode GetVoxelGIMode() { return VM_None; } - virtual void SetDesiredVoxelGIMode([[maybe_unused]] EVoxelGIMode voxelMode) {} - - virtual void SetMinSpec(int nMinSpec) { m_dwRndFlags &= ~ERF_SPEC_BITS_MASK; m_dwRndFlags |= (nMinSpec << ERF_SPEC_BITS_SHIFT) & ERF_SPEC_BITS_MASK; }; - - // Description: - // Allows to adjust default max view distance settings, - // if fMaxViewDistRatio is 1.0f - default max view distance is used. - virtual void SetViewDistanceMultiplier(float fViewDistanceMultiplier); - // - - void CopyIRenderNodeData(IRenderNode* pDest) const - { - pDest->m_fWSMaxViewDist = m_fWSMaxViewDist; - pDest->m_dwRndFlags = m_dwRndFlags; - //pDest->m_pOcNode = m_pOcNode; // Removed to stop the registering from earlying out. - pDest->m_fViewDistanceMultiplier = m_fViewDistanceMultiplier; - pDest->m_ucLodRatio = m_ucLodRatio; - pDest->m_cShadowLodBias = m_cShadowLodBias; - pDest->m_cStaticShadowLod = m_cStaticShadowLod; - pDest->m_nInternalFlags = m_nInternalFlags; - pDest->m_nMaterialLayers = m_nMaterialLayers; - //pDestBrush->m_pRNTmpData //If this is copied from the source render node, there are two - // pointers to the same data, and if either is deleted, there will - // be a crash when the dangling pointer is used on the other - } - - // Rendering flags. - ILINE void SetRndFlags(unsigned int dwFlags) { m_dwRndFlags = dwFlags; } - ILINE void SetRndFlags(unsigned int dwFlags, bool bEnable) - { - if (bEnable) - { - SetRndFlags(m_dwRndFlags | dwFlags); - } - else - { - SetRndFlags(m_dwRndFlags & (~dwFlags)); - } - } - ILINE unsigned int GetRndFlags() const { return m_dwRndFlags; } - - // Object draw frames (set if was drawn). - ILINE void SetDrawFrame(int nFrameID, int nRecursionLevel) - { - assert(m_pRNTmpData); - int* pDrawFrames = (int*)m_pRNTmpData; - pDrawFrames[nRecursionLevel] = nFrameID; - } - - ILINE int GetDrawFrame(int nRecursionLevel = 0) const - { - IF (!m_pRNTmpData, 0) - { - return 0; - } - - int* pDrawFrames = (int*)m_pRNTmpData; - return pDrawFrames[nRecursionLevel]; - } - - // Returns: - // Current VisArea or null if in outdoors or entity was not registered in 3dengine. - ILINE IVisArea* GetEntityVisArea() const { return m_pOcNode ? (IVisArea*)(m_pOcNode->m_pVisArea) : NULL; } - - // Summary: - // Makes object visible at any distance. - ILINE void SetViewDistUnlimited() { SetViewDistanceMultiplier(100.0f); } - - // Summary: - // Retrieves the view distance settings. - ILINE float GetViewDistanceMultiplier() const - { - return m_fViewDistanceMultiplier; - } - - // Summary: - // Returns lod distance ratio. - ILINE int GetLodRatio() const { return m_ucLodRatio; } - - // Summary: - // Returns lod distance ratio - ILINE float GetLodRatioNormalized() const { return 0.01f * m_ucLodRatio; } - - virtual bool GetLodDistances([[maybe_unused]] const SFrameLodInfo& frameLodInfo, [[maybe_unused]] float* distances) const { return false; } - - // Returns distance for first lod change, not factoring in distance multiplier or lod ratio - virtual float GetFirstLodDistance() const { return FLT_MAX; } - - // Description: - // Bias value to add to the regular lod - virtual void SetShadowLodBias(int8 nShadowLodBias) { m_cShadowLodBias = nShadowLodBias; } - - // Summary: - // Returns lod distance ratio. - ILINE int GetShadowLodBias() const { return m_cShadowLodBias; } - - // Summary: - // Sets material layers mask. - ILINE void SetMaterialLayers(uint8 nMtlLayers) { m_nMaterialLayers = nMtlLayers; } - - ILINE int GetMinSpec() const { return (m_dwRndFlags & ERF_SPEC_BITS_MASK) >> ERF_SPEC_BITS_SHIFT; }; - - static const ERNListType GetRenderNodeListId(const EERType eRType) - { - switch (eRType) - { - case eERType_Decal: - return eRNListType_DecalsAndRoads; - default: - return eRNListType_Unknown; - } - } - - virtual AZ::EntityId GetEntityId() { return AZ::EntityId(); } - - ////////////////////////////////////////////////////////////////////////// - // Variables - ////////////////////////////////////////////////////////////////////////// - -public: - - // Every sector has linked list of IRenderNode objects. - IRenderNode* m_pNext, * m_pPrev; - - // Current objects tree cell. - IOctreeNode* m_pOcNode; - - // Pointer to temporary data allocated only for currently visible objects. - struct CRNTmpData* m_pRNTmpData; - - // Max view distance. - float m_fWSMaxViewDist; - - // Render flags. - int m_dwRndFlags; - - // Shadow LOD bias - // Set to SHADOW_LODBIAS_DISABLE to disable any shadow lod overrides for this rendernode - static const int8 SHADOW_LODBIAS_DISABLE = -128; - int8 m_cShadowLodBias; - - // Segment Id - int m_nSID; + int GetSlotCount() const { return 1; } // Max view distance settings. - static const int VIEW_DISTANCE_MULTIPLIER_MAX = 100; - float m_fViewDistanceMultiplier; + static constexpr int VIEW_DISTANCE_MULTIPLIER_MAX = 100; - // LOD settings. - unsigned char m_ucLodRatio; - - // Flags for render node internal usage, one or more bits from EInternalFlags. - unsigned char m_nInternalFlags; - - // Material layers bitmask -> which material layers are active. - unsigned char m_nMaterialLayers; -}; - -inline void IRenderNode::SetViewDistanceMultiplier(float fViewDistanceMultiplier) -{ - fViewDistanceMultiplier = CLAMP(fViewDistanceMultiplier, 0.0f, 100.0f); - if (fabs(m_fViewDistanceMultiplier - fViewDistanceMultiplier) > FLT_EPSILON) - { - m_fViewDistanceMultiplier = fViewDistanceMultiplier; - } -} - - -/////////////////////////////////////////////////////////////////////////////// -inline IStatObj* IRenderNode::GetEntityStatObj([[maybe_unused]] unsigned int nPartId, [[maybe_unused]] unsigned int nSubPartId, [[maybe_unused]] Matrix34A* pMatrix, [[maybe_unused]] bool bReturnOnlyVisible) -{ - return 0; -} - - -//We must use interfaces instead of unsafe type casts and unnecessary includes - -struct ILightSource - : public IRenderNode -{ - // - virtual void SetLightProperties(const CDLight& light) = 0; - virtual CDLight& GetLightProperties() = 0; - virtual const Matrix34& GetMatrix() = 0; - virtual struct ShadowMapFrustum* GetShadowFrustum(int nId = 0) = 0; - virtual bool IsLightAreasVisible() = 0; - virtual void SetCastingException(IRenderNode* pNotCaster) = 0; - virtual void SetName(const char* name) = 0; - // -}; - -struct SCloudMovementProperties -{ - bool m_autoMove; - Vec3 m_speed; - Vec3 m_spaceLoopBox; - float m_fadeDistance; -}; - -// Summary: -// ICloudRenderNode is an interface to the Cloud Render Node object. -struct ICloudRenderNode - : public IRenderNode -{ - // - // Description: - // Loads a cloud from a cloud description XML file. - virtual bool LoadCloud(const char* sCloudFilename) = 0; - virtual bool LoadCloudFromXml(XmlNodeRef cloudNode) = 0; - virtual void SetMovementProperties(const SCloudMovementProperties& properties) = 0; - // -}; - -// Summary: -// IVoxelObject is an interface to the Voxel Object Render Node object. -struct IVoxelObject - : public IRenderNode -{ - // - virtual void SetCompiledData(void* pData, int nSize, uint8 ucChildId, EEndian eEndian) = 0; - virtual void SetObjectName(const char* pName) = 0; - virtual void SetMatrix(const Matrix34& mat) = 0; - virtual bool ResetTransformation() = 0; - virtual void InterpolateVoxelData() = 0; - virtual void SetFlags(int nFlags) = 0; - virtual void Regenerate() = 0; - virtual void CopyHM() = 0; - virtual bool IsEmpty() = 0; - // -}; - -// LY renderer system spec levels. -enum class EngineSpec : AZ::u32 -{ - Low = 1, - Medium, - High, - VeryHigh, - Never = UINT_MAX, }; diff --git a/Code/Legacy/CryCommon/IEntityRenderState_info.cpp b/Code/Legacy/CryCommon/IEntityRenderState_info.cpp deleted file mode 100644 index 762c741214..0000000000 --- a/Code/Legacy/CryCommon/IEntityRenderState_info.cpp +++ /dev/null @@ -1,41 +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 "TypeInfo_impl.h" -#include // <> required for Interfuscator - -ENUM_INFO_BEGIN(EERType) -ENUM_ELEM_INFO(, eERType_NotRenderNode) -ENUM_ELEM_INFO(, eERType_Dummy_10) -ENUM_ELEM_INFO(, eERType_Light) -ENUM_ELEM_INFO(, eERType_Cloud) -ENUM_ELEM_INFO(, eERType_TerrainSystem) -ENUM_ELEM_INFO(, eERType_FogVolume) -ENUM_ELEM_INFO(, eERType_Decal) -ENUM_ELEM_INFO(, eERType_Dummy_6) -ENUM_ELEM_INFO(, eERType_WaterVolume) -ENUM_ELEM_INFO(, eERType_Dummy_7) -ENUM_ELEM_INFO(, eERType_DistanceCloud) -ENUM_ELEM_INFO(, eERType_VolumeObject) -ENUM_ELEM_INFO(, eERType_Dummy_0) -ENUM_ELEM_INFO(, eERType_Rope) -ENUM_ELEM_INFO(, eERType_PrismObject) -ENUM_ELEM_INFO(, eERType_Dummy_2) -ENUM_ELEM_INFO(, eERType_Dummy_4) -ENUM_ELEM_INFO(, eERType_RenderComponent) -ENUM_ELEM_INFO(, eERType_StaticMeshRenderComponent) -ENUM_ELEM_INFO(, eERType_DynamicMeshRenderComponent) -ENUM_ELEM_INFO(, eERType_SkinnedMeshRenderComponent) -ENUM_ELEM_INFO(, eERType_GameEffect) -ENUM_ELEM_INFO(, eERType_BreakableGlass) -ENUM_ELEM_INFO(, eERType_Dummy_3) -ENUM_ELEM_INFO(, eERType_Dummy_9) -ENUM_ELEM_INFO(, eERType_GeomCache) -ENUM_ELEM_INFO(, eERType_TypesNum) -ENUM_INFO_END(EERType) diff --git a/Code/Legacy/CryCommon/IFont.h b/Code/Legacy/CryCommon/IFont.h index 41e9f5653a..15cc6568bf 100644 --- a/Code/Legacy/CryCommon/IFont.h +++ b/Code/Legacy/CryCommon/IFont.h @@ -19,6 +19,7 @@ #include #include +#include #include struct ISystem; diff --git a/Code/Legacy/CryCommon/IIndexedMesh.h b/Code/Legacy/CryCommon/IIndexedMesh.h index 1c91bb82b8..a84cebacb3 100644 --- a/Code/Legacy/CryCommon/IIndexedMesh.h +++ b/Code/Legacy/CryCommon/IIndexedMesh.h @@ -7,16 +7,12 @@ */ -#ifndef CRYINCLUDE_CRYCOMMON_IINDEXEDMESH_H -#define CRYINCLUDE_CRYCOMMON_IINDEXEDMESH_H #pragma once -#include "CryHeaders.h" #include "Cry_Color.h" #include "StlUtils.h" #include "CryEndian.h" -#include #include // for AABB #include #include @@ -58,74 +54,16 @@ public: t = other.y; } - void ExportTo(Vec2f16& other) const - { - other = Vec2f16(s, t); - } - - void ExportTo(float& others, float& othert) const - { - others = s; - othert = t; - } - - bool operator ==(const SMeshTexCoord& other) const - { - return (s == other.s) && (t == other.t); - } - - bool operator !=(const SMeshTexCoord& other) const - { - return !(*this == other); - } - - bool operator <(const SMeshTexCoord& other) const - { - return (s != other.s) ? (s < other.s) : (t < other.t); - } - - bool IsEquivalent(const Vec2& other, float epsilon = 0.003f) const - { - return - (fabs_tpl(s - other.x) <= epsilon) && - (fabs_tpl(t - other.y) <= epsilon); - } - bool IsEquivalent(const SMeshTexCoord& other, float epsilon = 0.00005f) const { return (fabs_tpl(s - other.s) <= epsilon) && (fabs_tpl(t - other.t) <= epsilon); } - ILINE Vec2 GetUV() const { return Vec2(s, t); } - - void GetUV(Vec2& otheruv) const - { - otheruv = GetUV(); - } - - void GetUV(Vec4& otheruv) const - { - otheruv = Vec4(s, t, 0.0f, 1.0f); - } - - void Lerp(const SMeshTexCoord& other, float pos) - { - Vec2 texA; - Vec2 texB; - this->GetUV(); - other.GetUV(); - - texA.SetLerp(texA, texB, pos); - - *this = SMeshTexCoord(texA); - } - - AUTO_STRUCT_INFO }; // Description: @@ -145,55 +83,6 @@ public: b = otherb; a = othera; } - - void TransferRGBTo(SMeshColor& other) const - { - other.r = r; - other.g = g; - other.b = b; - } - - void TransferATo(SMeshColor& other) const - { - other.a = a; - } - - void MaskA(uint8 maska) - { - a &= maska; - } - - bool operator ==(const SMeshColor& other) const - { - return (r == other.r) && (g == other.g) && (b == other.b) && (a == other.a); - } - - bool operator !=(const SMeshColor& other) const - { - return !(*this == other); - } - - bool operator <(const SMeshColor& other) const - { - return (r != other.r) ? (r < other.r) : (g != other.g) ? (g < other.g) : (b != other.b) ? (b < other.b) : (a < other.a); - } - - ILINE ColorB GetRGBA() const - { - return ColorB(r, g, b, a); - } - - void GetRGBA(ColorB& otherc) const - { - otherc = GetRGBA(); - } - - void GetRGBA(Vec4& otherc) const - { - otherc = Vec4(r, g, b, a); - } - - AUTO_STRUCT_INFO }; @@ -203,8 +92,6 @@ struct SMeshFace { int v[3]; // indices to vertex, normals and optionally tangent basis arrays unsigned char nSubset; // index to mesh subsets array. - - AUTO_STRUCT_INFO }; // Description: @@ -222,380 +109,11 @@ public: Normal = othern; } - bool operator ==(const SMeshNormal& othern) const - { - return (Normal.x == othern.Normal.x) && (Normal.y == othern.Normal.y) && (Normal.z == othern.Normal.z); - } + Vec3 GetN() const { return Normal; } - bool operator !=(const SMeshNormal& othern) const - { - return !(*this == othern); - } - - bool operator <(const SMeshNormal& othern) const - { - return (Normal.x != othern.Normal.x) ? (Normal.x < othern.Normal.x) : (Normal.y != othern.Normal.y) ? (Normal.y < othern.Normal.y) : (Normal.z < othern.Normal.z); - } - - bool IsEquivalent(const Vec3& othern, float epsilon = 0.00005f) const - { - return - Normal.IsEquivalent(othern, epsilon); - } - - bool IsEquivalent(const SMeshNormal& othern, float epsilon = 0.00005f) const - { - return - IsEquivalent(othern.Normal, epsilon); - } - - ILINE Vec3 GetN() const - { - return Normal; - } - - void GetN(Vec3& othern) const - { - othern = GetN(); - } - - void RotateBy(const Matrix33& rot) - { - Normal = rot * Normal; - } - - void RotateSafelyBy(const Matrix33& rot) - { - Normal = rot * Normal; - // normalize in case "rot" wasn't length-preserving - Normal.Normalize(); - } - - void RotateBy(const Matrix34& trn) - { - Normal = trn.TransformVector(Normal); - } - - void RotateSafelyBy(const Matrix34& trn) - { - Normal = trn.TransformVector(Normal); - // normalize in case "trn" wasn't length-preserving - Normal.Normalize(); - } - - void Slerp(const SMeshNormal& other, float pos) - { - Vec3 nrmA = this->GetN(); - Vec3 nrmB = other.GetN(); - - nrmA.Normalize(); - nrmB.Normalize(); - - nrmA.SetSlerp(nrmA, nrmB, pos); - - *this = SMeshNormal(nrmA); - } - - AUTO_STRUCT_INFO }; -// Description: -// Mesh tangents (tangent space normals). -struct SMeshTangents -{ - SMeshTangents() {} - -private: - Vec4sf Tangent; - Vec4sf Bitangent; - -public: - explicit SMeshTangents(const Vec4sf& othert, const Vec4sf& otherb) - { - Tangent = othert; - Bitangent = otherb; - } - - explicit SMeshTangents(const SPipTangents& other) - { - Tangent = other.Tangent; - Bitangent = other.Bitangent; - } - - explicit SMeshTangents(const Vec4& othert, const Vec4& otherb) - { - Tangent = PackingSNorm::tPackF2Bv(othert); - Bitangent = PackingSNorm::tPackF2Bv(otherb); - } - - explicit SMeshTangents(const Vec3& othert, const Vec3& otherb, const Vec3& othern) - { - // TODO: can be optimized to use only integer arithmetic - int16 othersign = 1; - if (othert.Cross(otherb).Dot(othern) < 0) - { - othersign = -1; - } - - Tangent = Vec4sf(PackingSNorm::tPackF2B(othert.x), PackingSNorm::tPackF2B(othert.y), PackingSNorm::tPackF2B(othert.z), PackingSNorm::tPackS2B(othersign)); - Bitangent = Vec4sf(PackingSNorm::tPackF2B(otherb.x), PackingSNorm::tPackF2B(otherb.y), PackingSNorm::tPackF2B(otherb.z), PackingSNorm::tPackS2B(othersign)); - } - - explicit SMeshTangents(const Vec3& othert, const Vec3& otherb, const int16& othersign) - { - Tangent = Vec4sf(PackingSNorm::tPackF2B(othert.x), PackingSNorm::tPackF2B(othert.y), PackingSNorm::tPackF2B(othert.z), PackingSNorm::tPackS2B(othersign)); - Bitangent = Vec4sf(PackingSNorm::tPackF2B(otherb.x), PackingSNorm::tPackF2B(otherb.y), PackingSNorm::tPackF2B(otherb.z), PackingSNorm::tPackS2B(othersign)); - } - - void ExportTo(Vec4sf& othert, Vec4sf& otherb) const - { - othert = Tangent; - otherb = Bitangent; - } - - void ExportTo(SPipTangents& other) const - { - other.Tangent = Tangent; - other.Bitangent = Bitangent; - } - - bool operator ==(const SMeshTangents& other) const - { - return - Tangent[0] == other.Tangent[0] || - Tangent[1] == other.Tangent[1] || - Tangent[2] == other.Tangent[2] || - Tangent[3] == other.Tangent[3] || - Bitangent[0] == other.Bitangent[0] || - Bitangent[1] == other.Bitangent[1] || - Bitangent[2] == other.Bitangent[2] || - Bitangent[3] == other.Bitangent[3]; - } - - bool operator !=(const SMeshTangents& other) const - { - return !(*this == other); - } - - bool IsEquivalent(const Vec3& othert, const Vec3& otherb, const int16& othersign, float epsilon = 0.01f) const - { - // TODO: can be optimized to use only integer arithmetic - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - return - (tng.w == othersign) && - (btg.w == othersign) && - (tng3.Dot(othert) >= (1.0f - epsilon)) && - (btg3.Dot(otherb) >= (1.0f - epsilon)); - } - - void GetTB(Vec4sf& othert, Vec4sf& otherb) const - { - othert = Tangent; - otherb = Bitangent; - } - - void GetTB(Vec4& othert, Vec4& otherb) const - { - othert = PackingSNorm::tPackB2F(Tangent); - otherb = PackingSNorm::tPackB2F(Bitangent); - } - - void GetTB(Vec3& othert, Vec3& otherb) const - { - const Vec4 t = PackingSNorm::tPackB2F(Tangent); - const Vec4 b = PackingSNorm::tPackB2F(Bitangent); - - othert = Vec3(t.x, t.y, t.z); - otherb = Vec3(b.x, b.y, b.z); - } - - ILINE Vec3 GetN() const - { - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - // assumes w 1 or -1 - return tng3.Cross(btg3) * tng.w; - } - - void GetN(Vec3& othern) const - { - othern = GetN(); - } - - void GetTBN(Vec3& othert, Vec3& otherb, Vec3& othern) const - { - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - // assumes w 1 or -1 - othert = tng3; - otherb = btg3; - othern = tng3.Cross(btg3) * tng.w; - } - - ILINE int16 GetR() const - { - return PackingSNorm::tPackB2S(Tangent.w); - } - - void GetR(int16& sign) const - { - sign = GetR(); - } - - void RotateBy(const Matrix33& rot) - { - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - tng3 = rot * tng3; - btg3 = rot * btg3; - - *this = SMeshTangents(tng3, btg3, PackingSNorm::tPackB2S(Tangent.w)); - } - - void RotateSafelyBy(const Matrix33& rot) - { - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - tng3 = rot * tng3; - btg3 = rot * btg3; - - // normalize in case "rot" wasn't length-preserving - tng3.Normalize(); - btg3.Normalize(); - - *this = SMeshTangents(tng3, btg3, PackingSNorm::tPackB2S(Tangent.w)); - } - - void RotateBy(const Matrix34& trn) - { - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - tng3 = trn.TransformVector(tng3); - btg3 = trn.TransformVector(btg3); - - *this = SMeshTangents(tng3, btg3, PackingSNorm::tPackB2S(Tangent.w)); - } - - void RotateSafelyBy(const Matrix34& trn) - { - Vec4 tng, btg; - GetTB(tng, btg); - - Vec3 tng3(tng.x, tng.y, tng.z); - Vec3 btg3(btg.x, btg.y, btg.z); - - tng3 = trn.TransformVector(tng3); - btg3 = trn.TransformVector(btg3); - - // normalize in case "rot" wasn't length-preserving - tng3.Normalize(); - btg3.Normalize(); - - *this = SMeshTangents(tng3, btg3, PackingSNorm::tPackB2S(Tangent.w)); - } - - void SlerpTowards(const SMeshTangents& other, const SMeshNormal& normal, float pos) - { - Vec3 tngA, btgA; - Vec3 tngB, btgB; - this->GetTB(tngA, btgA); - other.GetTB(tngB, btgB); - - // Q: necessary? - tngA.Normalize(); - tngB.Normalize(); - btgA.Normalize(); - btgB.Normalize(); - - tngA.SetSlerp(tngA, tngB, pos); - btgA.SetSlerp(btgA, btgB, pos); - - *this = SMeshTangents(tngA, btgA, normal.GetN()); - } - - AUTO_STRUCT_INFO -}; - -struct SMeshQTangents -{ - SMeshQTangents() {} - -private: - Vec4sf TangentBitangent; - -public: - explicit SMeshQTangents(const SPipQTangents& other) - { - TangentBitangent = other.QTangent; - } - - explicit SMeshQTangents(const Quat& other) - { - TangentBitangent.x = PackingSNorm::tPackF2B(other.v.x); - TangentBitangent.y = PackingSNorm::tPackF2B(other.v.y); - TangentBitangent.z = PackingSNorm::tPackF2B(other.v.z); - TangentBitangent.w = PackingSNorm::tPackF2B(other.w); - } - - void ExportTo(SPipQTangents& other) - { - other.QTangent = TangentBitangent; - } - - ILINE Quat GetQ() const - { - Quat q; - - q.v.x = PackingSNorm::tPackB2F(TangentBitangent.x); - q.v.y = PackingSNorm::tPackB2F(TangentBitangent.y); - q.v.z = PackingSNorm::tPackB2F(TangentBitangent.z); - q.w = PackingSNorm::tPackB2F(TangentBitangent.w); - - return q; - } - - AUTO_STRUCT_INFO -}; - -// Description: -// for skinning every vertex has 4 bones and 4 weights. -struct SMeshBoneMapping_uint16 -{ - typedef uint16 BoneId; - typedef uint8 Weight; - - BoneId boneIds[4]; - Weight weights[4]; - - AUTO_STRUCT_INFO -}; - struct SMeshBoneMapping_uint8 { typedef uint8 BoneId; @@ -603,27 +121,8 @@ struct SMeshBoneMapping_uint8 BoneId boneIds[4]; Weight weights[4]; - - AUTO_STRUCT_INFO }; -//START: Add LOD support for touch bending vegetation -struct SMeshBoneMappingInfo_uint8 -{ - SMeshBoneMappingInfo_uint8(int vertexCount) - { - //Will be deleted by ~SFoliageInfoCGF() - pBoneMapping = new SMeshBoneMapping_uint8[vertexCount]; - nVertexCount = vertexCount; - } - - int nVertexCount; - struct SMeshBoneMapping_uint8* pBoneMapping; - - AUTO_STRUCT_INFO -}; -//END: Add LOD support for touch bending vegetation - // Subset of mesh is a continuous range of vertices and indices that share same material. struct SMeshSubset { @@ -653,1529 +152,11 @@ struct SMeshSubset , nNumVerts(0) , nMatID(0) , nMatFlags(0) - , nPhysicalizeType(PHYS_GEOM_TYPE_DEFAULT) + , nPhysicalizeType(0x1000) , vertexFormat(eVF_P3S_C4B_T2S) { } - void GetMemoryUsage([[maybe_unused]] class ICrySizer* pSizer) const - { - } - - // fix numVerts - void FixRanges(vtx_idx* pIndices) - { - int startVertexToMerge = nFirstVertId; - int startIndexToMerge = nFirstIndexId; - int numIndiciesToMerge = nNumIndices; - // find good min and max AGAIN - int maxVertexInUse = 0; - for (int n = 0; n < numIndiciesToMerge; n++) - { - int i = (int)pIndices[n + startIndexToMerge]; - startVertexToMerge = (i < startVertexToMerge ? i : startVertexToMerge);// min - maxVertexInUse = (i > maxVertexInUse ? i : maxVertexInUse);// max - } - nNumVerts = maxVertexInUse - startVertexToMerge + 1; - } -}; - -class CMeshHelpers -{ -public: - template - static bool ComputeTexMappingAreas( - size_t indexCount, const TIndex* pIndices, - size_t vertexCount, - const TPosition* pPositions, size_t stridePositions, - const TTexCoordinates* pTexCoords, size_t strideTexCoords, - float& computedPosArea, float& computedTexArea, const char*& errorText) - { - static const float minPosArea = 10e-6f; - static const float minTexArea = 10e-8f; - - computedPosArea = 0; - computedTexArea = 0; - errorText = "?"; - - if (indexCount <= 0) - { - errorText = "index count is 0"; - return false; - } - - if (vertexCount <= 0) - { - errorText = "vertex count is 0"; - return false; - } - - if ((pIndices == NULL) || (pPositions == NULL)) - { - errorText = "indices and/or positions are NULL"; - return false; - } - - if (pTexCoords == NULL) - { - errorText = "texture coordinates are NULL"; - return false; - } - - if (indexCount % 3 != 0) - { - assert(0); - errorText = "bad number of indices"; - return false; - } - - // Compute average geometry area of face - - int count = 0; - float posAreaSum = 0; - float texAreaSum = 0; - for (size_t i = 0; i < indexCount; i += 3) - { - const size_t index0 = pIndices[i]; - const size_t index1 = pIndices[i + 1]; - const size_t index2 = pIndices[i + 2]; - - if ((index0 >= vertexCount) || (index1 >= vertexCount) || (index2 >= vertexCount)) - { - errorText = "bad vertex index detected"; - return false; - } - - const Vec3 pos0 = ToVec3(*(const TPosition*) (((const char*)pPositions) + index0 * stridePositions)); - const Vec3 pos1 = ToVec3(*(const TPosition*) (((const char*)pPositions) + index1 * stridePositions)); - const Vec3 pos2 = ToVec3(*(const TPosition*) (((const char*)pPositions) + index2 * stridePositions)); - - const Vec2 tex0 = ToVec2(*(const TTexCoordinates*) (((const char*)pTexCoords) + index0 * strideTexCoords)); - const Vec2 tex1 = ToVec2(*(const TTexCoordinates*) (((const char*)pTexCoords) + index1 * strideTexCoords)); - const Vec2 tex2 = ToVec2(*(const TTexCoordinates*) (((const char*)pTexCoords) + index2 * strideTexCoords)); - - const float posArea = ((pos1 - pos0).Cross(pos2 - pos0)).GetLength() * 0.5f; - const float texArea = fabsf((tex1 - tex0).Cross(tex2 - tex0)) * 0.5f; - - if ((posArea >= minPosArea) && (texArea >= minTexArea)) - { - posAreaSum += posArea; - texAreaSum += texArea; - ++count; - } - } - - if (count == 0 || (posAreaSum < minPosArea) || (texAreaSum < minTexArea)) - { - errorText = "faces are too small or have stretched mapping"; - return false; - } - - computedPosArea = posAreaSum; - computedTexArea = texAreaSum; - return true; - } - - template - static bool CollectFaceAreas(size_t indexCount, const vtx_idx* pIndices, size_t vertexCount, - const TPosition* pPositions, size_t stridePositions, std::vector& areas) - { - static const float minFaceArea = 10e-6f; - - if (indexCount % 3 != 0) - { - return false; - } - - areas.reserve(areas.size() + indexCount / 3); - - for (size_t i = 0; i < indexCount; i += 3) - { - const uint index0 = pIndices[i]; - const uint index1 = pIndices[i + 1]; - const uint index2 = pIndices[i + 2]; - - if ((index0 >= vertexCount) || (index1 >= vertexCount) || (index2 >= vertexCount)) - { - return false; - } - - const Vec3 pos0 = ToVec3(*(const TPosition*) (((const char*)pPositions) + index0 * stridePositions)); - const Vec3 pos1 = ToVec3(*(const TPosition*) (((const char*)pPositions) + index1 * stridePositions)); - const Vec3 pos2 = ToVec3(*(const TPosition*) (((const char*)pPositions) + index2 * stridePositions)); - - const float faceArea = ((pos1 - pos0).Cross(pos2 - pos0)).GetLength() * 0.5f; - - if (faceArea >= minFaceArea) - { - areas.push_back(faceArea); - } - } - - return true; - } - -private: - template - inline static Vec3 ToVec3(const T& v) - { - return v.ToVec3(); - } - - template - inline static Vec2 ToVec2(const T& v) - { - Vec2 uv; - v.GetUV(uv); - - return uv; - } -}; - -template <> -inline Vec3 CMeshHelpers::ToVec3(const Vec3& v) -{ - return v; -} - -template <> -inline Vec2 CMeshHelpers::ToVec2(const Vec2& v) -{ - return v; -} - -template <> -inline Vec2 CMeshHelpers::ToVec2(const Vec2f16& v) -{ - return v.ToVec2(); -} - -template <> -inline Vec2 CMeshHelpers::ToVec2(const SMeshTexCoord& v) -{ - return v.GetUV(); -} - - -////////////////////////////////////////////////////////////////////////// -// Description: -// General purpose mesh class. -////////////////////////////////////////////////////////////////////////// -class CMesh -{ -public: - // e.g. no more than 8 positions, 8 colors, 8 uv sets, etc. - const static uint maxStreamsPerType = 8; - enum EStream - { - POSITIONS = 0, - POSITIONSF16, - NORMALS, - FACES, - TOPOLOGY_IDS, - TEXCOORDS, - COLORS, - INDICES, - TANGENTS, - BONEMAPPING, - VERT_MATS, - QTANGENTS, - P3S_C4B_T2S, - - EXTRABONEMAPPING, // Extra stream. Does not have a stream ID in the CGF. Its data is saved at the end of the BONEMAPPING stream. - - LAST_STREAM, - }; - - SMeshFace* m_pFaces; // faces are used in mesh processing/compilation - int32* m_pTopologyIds; - - // geometry data - vtx_idx* m_pIndices; // indices are used for the final render-mesh - Vec3* m_pPositions; - Vec3f16* m_pPositionsF16; - - SMeshNormal* m_pNorms; - SMeshTangents* m_pTangents; - SMeshQTangents* m_pQTangents; - SMeshTexCoord* m_pTexCoord; - SMeshColor* m_pColor0; - SMeshColor* m_pColor1; - - int* m_pVertMats; - SVF_P3S_C4B_T2S* m_pP3S_C4B_T2S; - - SMeshBoneMapping_uint16* m_pBoneMapping; //bone-mapping for the final render-mesh - SMeshBoneMapping_uint16* m_pExtraBoneMapping; //bone indices and weights for bones 5 to 8. - - int m_nCoorCount; //number of texture coordinates in m_pTexCoord array - int m_streamSize[LAST_STREAM][maxStreamsPerType]; - - // Bounding box. - AABB m_bbox; - - // Array of mesh subsets. - DynArray m_subsets; - - // Mask that indicate if this stream is using not allocated in Mesh pointer; - // ex. if (m_sharedStreamMasks[0] & (1< the 1st normals stream is shared - // if (m_sharedStreamMasks[1] & (1< the 2nd uv set stream is shared - uint32 m_sharedStreamMasks[maxStreamsPerType]; - - // Texture space area divided by geometry area. Zero if cannot compute. - float m_texMappingDensity; - - // Geometric mean value calculated from the areas of this mesh faces. - float m_geometricMeanFaceArea; - - ////////////////////////////////////////////////////////////////////////// - void GetMemoryUsage(class ICrySizer* pSizer) const - { - pSizer->AddObject(this, sizeof(*this)); - pSizer->AddObject(m_subsets); - - for (int streamType = 0; streamType < LAST_STREAM; streamType++) - { - for (int streamIndex = 0; streamIndex < GetNumberOfStreamsByType(streamType); ++streamIndex) - { - void* pStream; - int nElementSize = 0; - GetStreamInfo(streamType, streamIndex, pStream, nElementSize); - pSizer->AddObject(pStream, m_streamSize[streamType][streamIndex] * nElementSize); - } - } - } - - ////////////////////////////////////////////////////////////////////////// - CMesh() - { - m_pFaces = NULL; - m_pTopologyIds = NULL; - m_pIndices = NULL; - m_pPositions = NULL; - m_pPositionsF16 = NULL; - m_pNorms = NULL; - m_pTangents = NULL; - m_pQTangents = NULL; - m_pTexCoord = NULL; - m_pColor0 = NULL; - m_pColor1 = NULL; - m_pVertMats = NULL; - m_pP3S_C4B_T2S = NULL; - m_pBoneMapping = NULL; - m_pExtraBoneMapping = NULL; - - m_nCoorCount = 0; - - memset(m_texCoords, 0, sizeof(m_texCoords)); - memset(m_streamSize, 0, sizeof(m_streamSize)); - - m_bbox.Reset(); - - memset(m_sharedStreamMasks, 0, sizeof(m_sharedStreamMasks)); - - m_texMappingDensity = 0.0f; - m_geometricMeanFaceArea = 0.0f; - } - - virtual ~CMesh() - { - FreeStreams(); - } - - void FreeStreams() - { - for (int streamType = 0; streamType < LAST_STREAM; ++streamType) - { - for (int streamIndex = 0; streamIndex < GetNumberOfStreamsByType(streamType); ++streamIndex) - { - ReallocStream(streamType, streamIndex, 0); - } - } - } - - int GetFaceCount() const - { - return m_streamSize[FACES][0]; - } - int GetVertexCount() const - { - return max(max(m_streamSize[POSITIONS][0], m_streamSize[POSITIONSF16][0]), m_streamSize[P3S_C4B_T2S][0]); - } - int GetTexCoordCount() const - { - return m_nCoorCount; - } - int GetTangentCount() const - { - return m_streamSize[TANGENTS][0]; - } - int GetSubSetCount() const - { - return m_subsets.size(); - } - int GetIndexCount() const - { - return m_streamSize[INDICES][0]; - } - - void SetFaceCount(int nNewCount) - { - ReallocStream(FACES, 0, nNewCount); - } - - void SetVertexCount(int nNewCount) - { - if (GetVertexCount() != nNewCount || GetVertexCount() == 0) - { - ReallocStream(POSITIONS, 0, nNewCount); - ReallocStream(POSITIONSF16, 0, 0); - ReallocStream(NORMALS, 0, nNewCount); - - if (m_pColor0) - { - ReallocStream(COLORS, 0, nNewCount); - } - - if (m_pColor1) - { - ReallocStream(COLORS, 1, nNewCount); - } - - if (m_pVertMats) - { - ReallocStream(VERT_MATS, 0, nNewCount); - } - } - } - - void SetTexCoordsCount(int nNewCount) - { - if (m_nCoorCount != nNewCount || m_nCoorCount == 0) - { - ReallocStream(TEXCOORDS, 0, nNewCount); - m_nCoorCount = nNewCount; - } - } - - void SetTexCoordsAndTangentsCount(int nNewCount) - { - if (m_nCoorCount != nNewCount || m_nCoorCount == 0) - { - ReallocStream(TEXCOORDS, 0, nNewCount); - ReallocStream(TANGENTS, 0, nNewCount); - m_nCoorCount = nNewCount; - } - } - - void SetIndexCount(int nNewCount) - { - ReallocStream(INDICES, 0, nNewCount); - } - // Once m_pTexCoords, m_pColors, etc. are wrapped in vectors, return the size of the vector - // or if we go with fixed size arrays, with a bunch of nullptrs, maybe just return the fixed size or the number of non-null ptrs - int GetNumberOfStreamsByType(int streamType) const - { - if (streamType == COLORS || streamType == TEXCOORDS) - { - return 2; - } - return 1; - } - - bool Has32BitPositions(void) const - { - return m_pPositions != nullptr; - } - - bool Has16BitPositions(void) const - { - return m_pPositionsF16 != nullptr; - } - - bool IsUVSetEmptyForSubmesh(uint submeshIndex, uint uvSet) - { - // Get a pointer to the uv set - SMeshTexCoord* texCoords = nullptr; - if (uvSet == 0) - { - texCoords = m_pTexCoord; - } - else - { - texCoords = m_texCoords[uvSet]; - } - - if (texCoords) - { - // Iterate through the vertices for the submesh - Vec2 emptyTexCoord = Vec2(0.0f, 0.0f); - for (int i = m_subsets[submeshIndex].nFirstVertId; i < m_subsets[submeshIndex].nFirstVertId + m_subsets[submeshIndex].nNumVerts; ++i) - { - // If any of the texture coordinates for the given uv set are non-zero, return false. - if (texCoords[i].GetUV() != emptyTexCoord) - { - return false; - } - } - } - // If no valid texture coordinates are found for submesh for the given uv set, return true. - return true; - } - - void SetSubmeshVertexFormats(void) - { - EVertexFormat desiredFormat = eVF_Unknown; - for (int submeshIndex = 0; submeshIndex < m_subsets.size(); ++submeshIndex) - { - // Choose float or short based on the precision of the positions - if (this->Has32BitPositions()) - { - // Choose one or two uv sets - if (IsUVSetEmptyForSubmesh(submeshIndex, 1)) - { - desiredFormat = eVF_P3F_C4B_T2F; - } - else - { - desiredFormat = eVF_P3F_C4B_T2F_T2F; - } - } - else if (this->Has16BitPositions()) - { - // Choose one or two uv sets - if (IsUVSetEmptyForSubmesh(submeshIndex, 1)) - { - desiredFormat = eVF_P3S_C4B_T2S; - } - else - { - desiredFormat = eVF_P3S_C4B_T2S_T2S; - } - } - else - { - AZ_Assert(false, "Submesh does not contain positions"); - } - - // Set the vertex format for the submesh - m_subsets[submeshIndex].vertexFormat = AZ::Vertex::Format(desiredFormat); - } - } - - AZ::Vertex::Format GetVertexFormatForSubmesh(int submeshIndex) const - { - assert(submeshIndex < m_subsets.size()); - - return m_subsets[submeshIndex].vertexFormat; - } - - AZ::Vertex::Format GetMeshGroupVertexFormat() const - { - AZ::Vertex::Format meshGroupFormat; - for (int submeshIndex = 0; submeshIndex < m_subsets.size(); ++submeshIndex) - { - if (m_subsets[submeshIndex].vertexFormat > meshGroupFormat) - { - meshGroupFormat = m_subsets[submeshIndex].vertexFormat; - } - } - - return meshGroupFormat; - } - - // Set specific stream type as shared. If there are multiple streams for a given type (such as multiple uv sets), then all streams of that type will be marked as shared - void SetSharedStream(int streamType, int streamIndex, void* pStream, int nElementCount) - { - AZ_Assert(streamType >= 0 && streamType < LAST_STREAM && streamIndex < maxStreamsPerType, "Stream type %d outside of allowable range (%d to %d) of CMesh::EStream, or stream index %d exceeds the maximum number of vertex streams (%d) per type.", streamType, 0, CMesh::LAST_STREAM, streamIndex, maxStreamsPerType); - if ((m_sharedStreamMasks[streamIndex] & (1 << streamType)) == 0) - { - ReallocStream(streamType, streamIndex, 0); - m_sharedStreamMasks[streamIndex] |= (1 << streamType); - } - SetStreamData(streamType, streamIndex, pStream, nElementCount); - } - - template - T* GetStreamPtrAndElementCount(int streamType, int streamIndex, int* pElementCount = 0) const - { - void* pStream = 0; - int nElementSize = 0; - GetStreamInfo(streamType, streamIndex, pStream, nElementSize); - - if (nElementSize != sizeof(T)) - { - AZ_Assert(false, "The element size %d returned by GetStreamInfo does not match the size %d of type T", nElementSize, sizeof(T)); - pStream = 0; - } - - const int nElementCount = (pStream ? this->m_streamSize[streamType][streamIndex] : 0); - - if (pElementCount) - { - *pElementCount = nElementCount; - } - return (T*)pStream; - } - - template - T* GetStreamPtr(int streamType, int streamIndex = 0) const - { - void* pStream = 0; - int nElementSize = 0; - GetStreamInfo(streamType, streamIndex, pStream, nElementSize); - - if (nElementSize != sizeof(T)) - { - AZ_Assert(false, "The element size %d returned by GetStreamInfo does not match the size %d of type T", nElementSize, sizeof(T)); - pStream = 0; - } - - return (T*)pStream; - } - - void GetStreamInfo(int streamType, int streamIndex, void*& pStream, int& nElementSize) const - { - pStream = 0; - nElementSize = 0; - AZ_Assert(streamType >= 0 && streamType < LAST_STREAM && streamIndex < maxStreamsPerType, "Stream type %d outside of allowable range (%d to %d) of CMesh::EStream, or stream index %d exceeds the maximum number of vertex streams (%d) per type.", streamType, 0, CMesh::LAST_STREAM, streamIndex, maxStreamsPerType); - - switch (streamType) - { - case POSITIONS: - pStream = m_pPositions; - nElementSize = sizeof(Vec3); - break; - case POSITIONSF16: - pStream = m_pPositionsF16; - nElementSize = sizeof(Vec3f16); - break; - case NORMALS: - pStream = m_pNorms; - nElementSize = sizeof(Vec3); - break; - case VERT_MATS: - pStream = m_pVertMats; - nElementSize = sizeof(int); - break; - case FACES: - pStream = m_pFaces; - nElementSize = sizeof(SMeshFace); - break; - case TOPOLOGY_IDS: - pStream = m_pTopologyIds; - nElementSize = sizeof(int32); - break; - case TEXCOORDS: - if (streamIndex == 0) - { - pStream = m_pTexCoord; - } - else - { - pStream = m_texCoords[streamIndex]; - } - nElementSize = sizeof(SMeshTexCoord); - break; - case COLORS: - if (streamIndex == 0) - { - pStream = m_pColor0; - } - else - { - pStream = m_pColor1; - } - nElementSize = sizeof(SMeshColor); - break; - case INDICES: - pStream = m_pIndices; - nElementSize = sizeof(vtx_idx); - break; - case TANGENTS: - pStream = m_pTangents; - nElementSize = sizeof(SMeshTangents); - break; - case QTANGENTS: - pStream = m_pQTangents; - nElementSize = sizeof(SMeshQTangents); - break; - case BONEMAPPING: - pStream = m_pBoneMapping; - nElementSize = sizeof(SMeshBoneMapping_uint16); - break; - case EXTRABONEMAPPING: - pStream = m_pExtraBoneMapping; - nElementSize = sizeof(SMeshBoneMapping_uint16); - break; - case P3S_C4B_T2S: - pStream = m_pP3S_C4B_T2S; - nElementSize = sizeof(SVF_P3S_C4B_T2S); - break; - default: - AZ_Assert(false, "Unknown stream"); - break; - } - } - - - virtual void ReallocStream(int streamType, int streamIndex, int nNewCount) - { - if (streamType < 0 || streamType >= LAST_STREAM || streamIndex >= maxStreamsPerType) - { - AZ_Assert(false, "Stream type %d outside of allowable range (%d to %d) of CMesh::EStream, or stream index %d exceeds the maximum number of vertex streams (%d) per type.", streamType, 0, CMesh::LAST_STREAM, streamIndex, maxStreamsPerType); - return; - } - - if (m_sharedStreamMasks[streamIndex] & (1 << streamType)) - { - m_sharedStreamMasks[streamIndex] &= ~(1 << streamType); - - if (nNewCount <= 0) - { - SetStreamData(streamType, 0, nullptr, 0); - } - else - { - const int nOldCount = m_streamSize[streamType][streamIndex]; - void* pOldElements = 0; - int nElementSize = 0; - GetStreamInfo(streamType, streamIndex, pOldElements, nElementSize); - - void* const pNewElements = realloc(0, nNewCount * nElementSize); - if (!pNewElements) - { - AZ_Assert(false, "Allocation failed"); - SetStreamData(streamType, streamIndex, nullptr, 0); - return; - } - - if (nOldCount > 0) - { - memcpy(pNewElements, pOldElements, min(nOldCount, nNewCount) * nElementSize); - } - if (nNewCount > nOldCount) - { - memset((char*)pNewElements + nOldCount * nElementSize, 0, (nNewCount - nOldCount) * nElementSize); - } - - SetStreamData(streamType, streamIndex, pNewElements, nNewCount); - } - } - else - { - const int nOldCount = m_streamSize[streamType][streamIndex]; - if (nOldCount == nNewCount) - { - // stream already has required size - return; - } - - void* pOldElements = 0; - int nElementSize = 0; - GetStreamInfo(streamType, streamIndex, pOldElements, nElementSize); - - if (nNewCount <= 0) - { - free(pOldElements); - SetStreamData(streamType, streamIndex, nullptr, 0); - } - else - { - void* const pNewElements = realloc(pOldElements, nNewCount * nElementSize); - if (!pNewElements) - { - AZ_Assert(false, "Allocation failed"); - free(pOldElements); - SetStreamData(streamType, streamIndex, nullptr, 0); - return; - } - - if (nNewCount > nOldCount) - { - memset((char*)pNewElements + nOldCount * nElementSize, 0, (nNewCount - nOldCount) * nElementSize); - } - - SetStreamData(streamType, streamIndex, pNewElements, nNewCount); - } - } - } - - // Copy mesh from source mesh. - void Copy(const CMesh& mesh) - { - for (int streamType = 0; streamType < LAST_STREAM; streamType++) - { - for (int streamIndex = 0; streamIndex < GetNumberOfStreamsByType(streamType); ++streamIndex) - { - ReallocStream(streamType, streamIndex, mesh.m_streamSize[streamType][streamIndex]); - if (mesh.m_streamSize[streamType][streamIndex] > 0) - { - void* pSrcStream = 0; - void* pTrgStream = 0; - int nElementSize = 0; - mesh.GetStreamInfo(streamType, streamIndex, pSrcStream, nElementSize); - GetStreamInfo(streamType, streamIndex, pTrgStream, nElementSize); - if (pSrcStream && pTrgStream) - { - memcpy(pTrgStream, pSrcStream, m_streamSize[streamType][streamIndex] * nElementSize); - } - } - } - } - m_bbox = mesh.m_bbox; - m_subsets = mesh.m_subsets; - m_texMappingDensity = mesh.m_texMappingDensity; - m_geometricMeanFaceArea = mesh.m_geometricMeanFaceArea; - } - - bool CompareStreams(const CMesh& mesh) const - { - for (int streamType = 0; streamType < LAST_STREAM; streamType++) - { - for (int streamIndex = 0; streamIndex < GetNumberOfStreamsByType(streamType); ++streamIndex) - { - if (m_streamSize[streamType][streamIndex] != mesh.m_streamSize[streamType][streamIndex]) - { - return false; - } - - if (m_streamSize[streamType][streamIndex]) - { - void* pStream1 = 0; - void* pStream2 = 0; - int nElementSize1 = 0; - int nElementSize2 = 0; - GetStreamInfo(streamType, streamIndex, pStream1, nElementSize1); - mesh.GetStreamInfo(streamType, streamIndex, pStream2, nElementSize2); - - assert(nElementSize1 == nElementSize2); - - if ((pStream1 && !pStream2) || (!pStream1 && pStream2)) - { - return false; - } - - if (pStream1 && pStream2) - { - if (memcmp(pStream1, pStream2, m_streamSize[streamType][streamIndex] * nElementSize1) != 0) - { - return false; - } - } - } - } - } - return true; - } - - // Add streams from source mesh to the end of existing streams. - const char* Append(const CMesh& mesh) - { - return Append(mesh, 0, -1, 0, -1); - } - - // Add streams from source mesh to the end of existing streams. - const char* Append(const CMesh& mesh, int fromVertex, int vertexCount, int fromFace, int faceCount) - { - if (GetIndexCount() > 0 || mesh.GetIndexCount() > 0) - { - assert(0); - return "Cmesh::Append() cannot handle meshes with indices, it can handle faces only"; - } - - // Non-ranged requests should start from 0th element and element count should be <0. - if ((vertexCount < 0 && fromVertex != 0) || (faceCount < 0 && fromFace != 0)) - { - assert(0); - return "Cmesh::Append(): Bad CMesh parameters"; - } - if (vertexCount < 0) - { - vertexCount = mesh.GetVertexCount(); - } - if (faceCount < 0) - { - faceCount = mesh.GetFaceCount(); - } - - const int oldVertexCount = GetVertexCount(); - const int oldFaceCount = GetFaceCount(); - - if (GetTexCoordCount() != 0 && GetTexCoordCount() != oldVertexCount) - { - assert(0); - return "Cmesh::Append(): Mismatch in target CMesh vert/tcoord counts"; - } - - if (mesh.GetTexCoordCount() != 0 && mesh.GetTexCoordCount() != mesh.GetVertexCount()) - { - assert(0); - return "Cmesh::Append(): Mismatch in source CMesh vert/tcoord counts"; - } - - for (int streamType = 0; streamType < LAST_STREAM; ++streamType) - { - for (int streamIndex = 0; streamIndex < GetNumberOfStreamsByType(streamType); ++streamIndex) - { - const int oldCount = (streamType == FACES) ? oldFaceCount : oldVertexCount; - - const int from = (streamType == FACES) ? fromFace : fromVertex; - const int count = (streamType == FACES) ? faceCount : vertexCount; - - const int oldStreamSize = m_streamSize[streamType][streamIndex]; - const int streamSize = mesh.m_streamSize[streamType][streamIndex]; - - if (oldStreamSize <= 0 && (count <= 0 || streamSize <= 0)) - { - continue; - } - - ReallocStream(streamType, streamIndex, oldCount + count); - - if (count > 0) - { - void* pSrcStream = 0; - void* pTrgStream = 0; - int srcElementSize = 0; - int trgElementSize = 0; - mesh.GetStreamInfo(streamType, streamIndex, pSrcStream, srcElementSize); - GetStreamInfo(streamType, streamIndex, pTrgStream, trgElementSize); - - assert(srcElementSize == trgElementSize); - - if (pSrcStream && pTrgStream) - { - memcpy( - (char*)pTrgStream + oldCount * trgElementSize, - (char*)pSrcStream + from * srcElementSize, - count * srcElementSize); - } - } - } - } - - { - const int nOffset = oldVertexCount - fromVertex; - const int newFaceCount = GetFaceCount(); - - for (int i = oldFaceCount; i < newFaceCount; ++i) - { - m_pFaces[i].v[0] += nOffset; - m_pFaces[i].v[1] += nOffset; - m_pFaces[i].v[2] += nOffset; - } - } - - m_bbox.Add(mesh.m_bbox.min); - m_bbox.Add(mesh.m_bbox.max); - - return 0; - } - - void RemoveRangeFromStream(int streamType, int streamIndex, int nFirst, int nCount) - { - if (streamType < 0 || streamType >= LAST_STREAM || streamIndex >= maxStreamsPerType) - { - AZ_Assert(false, "Stream type %d outside of allowable range (%d to %d) of CMesh::EStream, or stream index %d exceeds the maximum number of vertex streams (%d) per type.", streamType, 0, CMesh::LAST_STREAM, streamIndex, maxStreamsPerType); - return; - } - - if (m_sharedStreamMasks[streamIndex] & (1 << streamType)) - { - // Make shared stream non-shared - ReallocStream(streamType, streamIndex, m_streamSize[streamType][streamIndex]); - } - - const int nTotalCount = m_streamSize[streamType][streamIndex]; - - int nElementSize; - void* pStream = 0; - GetStreamInfo(streamType, streamIndex, pStream, nElementSize); - - if (nFirst >= nTotalCount || nTotalCount <= 0 || pStream == 0) - { - return; - } - if (nFirst + nCount > nTotalCount) - { - nCount = nTotalCount - nFirst; - } - if (nCount <= 0) - { - return; - } - - const int nTailCount = nTotalCount - (nFirst + nCount); - if (nTailCount > 0) - { - char* const pRangeStart = (char*)pStream + nFirst * nElementSize; - char* const pRangeEnd = (char*)pStream + (nFirst + nCount) * nElementSize; - memmove(pRangeStart, pRangeEnd, nTailCount * nElementSize); - } - - ReallocStream(streamType, streamIndex, nTotalCount - nCount); - } - - bool Validate(const char** const ppErrorDescription) const - { - const int vertexCount = GetVertexCount(); - const int faceCount = GetFaceCount(); - const int indexCount = GetIndexCount(); - - if ((faceCount <= 0) && (indexCount <= 0)) - { - if (vertexCount > 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "no any indices, but vertices exist"; - } - return false; - } - } - - if ((uint)vertexCount > (sizeof(vtx_idx) == 2 ? 0xffff : 0x7fffffff)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = - (sizeof(vtx_idx) == 2) - ? "vertex count is greater or equal than 64K" - : "vertex count is greater or equal than 2G"; - } - return false; - } - - if (faceCount > 0) - { - if (vertexCount <= 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "no any vertices, but faces exist"; - } - return false; - } - } - - if (indexCount > 0) - { - if (vertexCount <= 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "no any vertices, but indices exist"; - } - return false; - } - } - - for (int i = 0; i < faceCount; ++i) - { - const SMeshFace& face = m_pFaces[i]; - for (int j = 0; j < 3; ++j) - { - const int v = face.v[j]; - if ((v < 0) || (v >= vertexCount)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a face refers vertex outside of vertex array"; - } - return false; - } - } - } - - for (int i = 0; i < indexCount; i++) - { - if ((uint)m_pIndices[i] >= (uint)vertexCount) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "an index refers vertex outside of vertex array"; - } - return false; - } - } - - if (GetTexCoordCount() != 0 && GetTexCoordCount() != vertexCount) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "number of texture coordinates is different from number of vertices"; - } - return false; - } - - if (!_finite(m_bbox.min.x) || !_finite(m_bbox.min.y) || !_finite(m_bbox.min.z) || - !_finite(m_bbox.max.x) || !_finite(m_bbox.max.y) || !_finite(m_bbox.max.z)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "bounding box contains damaged data"; - } - return false; - } - - if (m_bbox.IsReset()) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "bounding box is not set"; - } - return false; - } - - if (m_bbox.max.x < m_bbox.min.x || - m_bbox.max.y < m_bbox.min.y || - m_bbox.max.z < m_bbox.min.z) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "bounding box min is greater than max"; - } - return false; - } - - if (m_bbox.min.GetDistance(m_bbox.max) < 0.001f) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "bounding box is less than 1 mm in size"; - } - return false; - } - - for (int s = 0, subsetCount = m_subsets.size(); s < subsetCount; ++s) - { - const SMeshSubset& subset = m_subsets[s]; - - if (subset.nNumIndices <= 0) - { - if (subset.nNumVerts > 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset without indices contains vertices"; - } - return false; - } - continue; - } - else if (subset.nNumVerts <= 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset has indices but vertices are missing"; - } - return false; - } - - if (subset.nFirstIndexId < 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset has negative start position in index array"; - } - return false; - } - if (subset.nFirstIndexId + subset.nNumIndices > indexCount) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset refers indices outside of index array"; - } - return false; - } - if (subset.nFirstVertId < 0) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset has negative start position in vertex array"; - } - return false; - } - if (subset.nFirstVertId + subset.nNumVerts > vertexCount) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset refers vertices outside of vertex array"; - } - return false; - } - - for (int ii = subset.nFirstIndexId; ii < subset.nFirstIndexId + subset.nNumIndices; ++ii) - { - const uint index = m_pIndices[ii]; - if (index < (uint)subset.nFirstVertId) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset refers a vertex lying before subset vertices"; - } - return false; - } - if (index >= (uint)(subset.nFirstVertId + subset.nNumVerts)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset refers a vertex lying after subset vertices"; - } - return false; - } - - Vec3 p(ZERO); - const Vec3* pp = &p; - if (m_pPositions) - { - pp = &m_pPositions[index]; - } - else if (m_pPositionsF16) - { - p = m_pPositionsF16[index].ToVec3(); - } - else if (m_pP3S_C4B_T2S) - { - p = m_pP3S_C4B_T2S[index].xyz.ToVec3(); - } - if (!_finite(pp->x)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset contains a vertex with damaged x component"; - } - return false; - } - if (!_finite(pp->y)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset contains a vertex with damaged y component"; - } - return false; - } - if (!_finite(pp->z)) - { - if (ppErrorDescription) - { - ppErrorDescription[0] = "a mesh subset contains a vertex with damaged z component"; - } - return false; - } - } - } - - return true; - } - - bool ComputeSubsetTexMappingAreas( - size_t subsetIndex, - float& computedPosArea, float& computedTexArea, const char*& errorText) - { - computedPosArea = 0.0f; - computedTexArea = 0.0f; - errorText = ""; - - if (subsetIndex >= (size_t)m_subsets.size()) - { - errorText = "subset index is bad"; - return false; - } - - if (GetIndexCount() <= 0) - { - errorText = "missing indices"; - return false; - } - - if ((GetVertexCount() <= 0) || ((m_pPositions == NULL) && (m_pPositionsF16 == NULL))) - { - errorText = "missing vertices"; - return false; - } - - if ((m_pTexCoord == NULL) || (GetTexCoordCount() <= 0)) - { - errorText = "missing texture coordinates"; - return false; - } - - const SMeshSubset& subset = m_subsets[subsetIndex]; - - if ((subset.nNumIndices <= 0) || (subset.nFirstIndexId < 0)) - { - errorText = "missing or bad indices in subset"; - return false; - } - - bool ok; - if (m_pPositions) - { - ok = CMeshHelpers::ComputeTexMappingAreas( - subset.nNumIndices, &m_pIndices[subset.nFirstIndexId], - GetVertexCount(), - &m_pPositions[0], sizeof(m_pPositions[0]), - &m_pTexCoord[0], sizeof(m_pTexCoord[0]), - computedPosArea, computedTexArea, errorText); - } - else - { - ok = CMeshHelpers::ComputeTexMappingAreas( - subset.nNumIndices, &m_pIndices[subset.nFirstIndexId], - GetVertexCount(), - &m_pPositionsF16[0], sizeof(m_pPositionsF16[0]), - &m_pTexCoord[0], sizeof(m_pTexCoord[0]), - computedPosArea, computedTexArea, errorText); - } - - return ok; - } - - // note: this function doesn't work for "old" uncompressed meshes (with faces instead of indices) - bool RecomputeTexMappingDensity() - { - m_texMappingDensity = 0; - - if (GetFaceCount() > 0) - { - // uncompressed mesh - not supported - return false; - } - - if ((GetIndexCount() <= 0) || (GetVertexCount() <= 0) || ((m_pPositions == NULL) && (m_pPositionsF16 == NULL))) - { - return false; - } - - if ((m_pTexCoord == NULL) || (GetTexCoordCount() <= 0)) - { - return false; - } - - float totalPosArea = 0; - float totalTexArea = 0; - - for (size_t i = 0, count = m_subsets.size(); i < count; ++i) - { - - float posArea; - float texArea; - const char* errorText = ""; - - const bool ok = ComputeSubsetTexMappingAreas(i, posArea, texArea, errorText); - - if (ok) - { - totalPosArea += posArea; - totalTexArea += texArea; - } - } - - if (totalPosArea <= 0) - { - return false; - } - - m_texMappingDensity = totalTexArea / totalPosArea; - return true; - } - - bool RecomputeGeometricMeanFaceArea() - { - m_geometricMeanFaceArea = 0.0f; - - if (GetFaceCount() > 0) - { - // uncompressed mesh - not supported - return false; - } - - if ((GetIndexCount() <= 0) || (GetVertexCount() <= 0) || ((m_pPositions == NULL) && (m_pPositionsF16 == NULL))) - { - return false; - } - - std::vector areas; - const size_t subsetCount = m_subsets.size(); - - for (size_t i = 0; i < subsetCount; ++i) - { - CollectSubsetFaceAreas(m_subsets[i], areas); - } - - const size_t areasCount = areas.size(); - if (areasCount == 0) - { - return false; - } - - float fGeometricTotal = 0.0f; - for (size_t i = 0; i < areasCount; ++i) - { - fGeometricTotal += logf(areas[i]); - } - - m_geometricMeanFaceArea = expf(fGeometricTotal / areasCount); - - assert(m_geometricMeanFaceArea > 0.0f); - - return true; - } - - bool CollectSubsetFaceAreas(const SMeshSubset& subset, std::vector& areas) - { - if ((subset.nNumIndices <= 0) || (subset.nFirstIndexId < 0)) - { - return false; - } - - bool ok = false; - if (m_pPositions != NULL) - { - ok = CMeshHelpers::CollectFaceAreas(subset.nNumIndices, &m_pIndices[subset.nFirstIndexId], - GetVertexCount(), &m_pPositions[0], sizeof(m_pPositions[0]), areas); - } - else if (m_pPositionsF16 != NULL) - { - ok = CMeshHelpers::CollectFaceAreas(subset.nNumIndices, &m_pIndices[subset.nFirstIndexId], - GetVertexCount(), &m_pPositionsF16[0], sizeof(m_pPositionsF16[0]), areas); - } - - return ok; - } - - ////////////////////////////////////////////////////////////////////////// - // Estimates the size of the render mesh. - uint32 EstimateRenderMeshMemoryUsage() const - { - const size_t cSizeStream[VSF_NUM] = { - 0U, - sizeof(SPipTangents), // VSF_TANGENTS - sizeof(SPipQTangents), // VSF_QTANGENTS - sizeof(SVF_W4B_I4S), // VSF_HWSKIN_INFO - sizeof(SVF_P3F), // VSF_VERTEX_VELOCITY -#if ENABLE_NORMALSTREAM_SUPPORT - sizeof(SPipNormal), // VSF_NORMALS -#endif - }; - - uint32 nMeshSize = 0; - uint32 activeStreams = (GetVertexCount()) ? 1U << VSF_GENERAL : 0U; - activeStreams |= - (m_pQTangents) ? (1U << VSF_QTANGENTS) : - (m_pTangents) ? (1U << VSF_TANGENTS) : 0U; - if (m_pBoneMapping) - { - activeStreams |= 1U << VSF_HWSKIN_INFO; - } - for (uint32 i = 0; i < VSF_NUM; i++) - { - if (activeStreams & (1U << i)) - { - nMeshSize += static_cast(((i == VSF_GENERAL) ? sizeof(SVF_P3S_C4B_T2S) : cSizeStream[i]) * GetVertexCount()); - nMeshSize += TARGET_DEFAULT_ALIGN - (nMeshSize & (TARGET_DEFAULT_ALIGN - 1)); - } - } - if (GetIndexCount()) - { - nMeshSize += GetIndexCount() * sizeof(vtx_idx); - nMeshSize += TARGET_DEFAULT_ALIGN - (nMeshSize & (TARGET_DEFAULT_ALIGN - 1)); - } - - return nMeshSize; - } - ////////////////////////////////////////////////////////////////////////// - - // This function used when we do not have an actual mesh, but only vertex/index count of it. - static uint32 ApproximateRenderMeshMemoryUsage(int nVertexCount, int nIndexCount) - { - uint32 nMeshSize = 0; - nMeshSize += nVertexCount * sizeof(SVF_P3S_C4B_T2S); - nMeshSize += nVertexCount * sizeof(SPipTangents); - - nMeshSize += nIndexCount * sizeof(vtx_idx); - return nMeshSize; - } - -private: - // Set stream size. - void SetStreamData(int streamType, int streamIndex, void* pStream, int nNewCount) - { - if (streamType < 0 || streamType >= LAST_STREAM || streamIndex >= maxStreamsPerType) - { - AZ_Assert(false, "Stream type %d outside of allowable range (%d to %d) of CMesh::EStream, or stream index %d exceeds the maximum number of vertex streams (%d) per type.", streamType, 0, CMesh::LAST_STREAM, streamIndex, maxStreamsPerType); - return; - } - m_streamSize[streamType][streamIndex] = nNewCount; - switch (streamType) - { - case POSITIONS: - m_pPositions = (Vec3*)pStream; - break; - case POSITIONSF16: - m_pPositionsF16 = (Vec3f16*)pStream; - break; - case NORMALS: - m_pNorms = (SMeshNormal*)pStream; - break; - case VERT_MATS: - m_pVertMats = (int*)pStream; - break; - case FACES: - m_pFaces = (SMeshFace*)pStream; - break; - case TOPOLOGY_IDS: - m_pTopologyIds = (int32*)pStream; - break; - case TEXCOORDS: - if (streamIndex == 0) - { - m_pTexCoord = (SMeshTexCoord*)pStream; - } - else - { - m_texCoords[streamIndex] = (SMeshTexCoord*)pStream; - } - m_nCoorCount = nNewCount; - break; - case COLORS: - if (streamIndex == 0) - { - m_pColor0 = (SMeshColor*)pStream; - } - else - { - m_pColor1 = (SMeshColor*)pStream; - } - break; - case INDICES: - m_pIndices = (vtx_idx*)pStream; - break; - case TANGENTS: - m_pTangents = (SMeshTangents*)pStream; - break; - case QTANGENTS: - m_pQTangents = (SMeshQTangents*)pStream; - break; - case BONEMAPPING: - m_pBoneMapping = (SMeshBoneMapping_uint16*)pStream; - break; - case EXTRABONEMAPPING: - m_pExtraBoneMapping = (SMeshBoneMapping_uint16*)pStream; - break; - case P3S_C4B_T2S: - m_pP3S_C4B_T2S = (SVF_P3S_C4B_T2S*)pStream; - m_nCoorCount = nNewCount; - break; - default: - AZ_Assert(false, "Unknown stream"); - break; - } - } - - SMeshTexCoord* m_texCoords[maxStreamsPerType]; }; // Description: @@ -2209,10 +190,6 @@ struct IIndexedMesh //! Gives read-only access to mesh data virtual void GetMeshDescription(SMeshDescription& meshDesc) const = 0; - virtual CMesh* GetMesh() = 0; - - virtual void SetMesh(CMesh& mesh) = 0; - /*! Frees vertex and face streams. Calling this function invalidates SMeshDescription pointers */ virtual void FreeStreams() = 0; @@ -2228,54 +205,17 @@ struct IIndexedMesh /*! Reallocates vertices, normals and colors. Calling this function invalidates SMeshDescription pointers */ virtual void SetVertexCount(int nNewCount) = 0; - /*! Reallocates colors. Calling this function invalidates SMeshDescription pointers */ - virtual void SetColorCount(int nNewCount) = 0; - //! Return number of allocated texture coordinates virtual int GetTexCoordCount() const = 0; - /*! Reallocates texture coordinates. Calling this function invalidates SMeshDescription pointers */ - virtual void SetTexCoordCount(int nNewCount, int numStreams = 1) = 0; - - //! Return number of allocated tangents. - virtual int GetTangentCount() const = 0; - - /*! Reallocates tangents. Calling this function invalidates SMeshDescription pointers */ - virtual void SetTangentCount(int nNewCount) = 0; - // Get number of indices in the mesh. virtual int GetIndexCount() const = 0; - // Set number of indices in the mesh. - virtual void SetIndexCount(int nNewCount) = 0; - - // Allocates m_pBoneMapping in CMesh - virtual void AllocateBoneMapping() = 0; - ////////////////////////////////////////////////////////////////////////// // Subset access. ////////////////////////////////////////////////////////////////////////// virtual int GetSubSetCount() const = 0; - virtual void SetSubSetCount(int nSubsets) = 0; virtual const SMeshSubset& GetSubSet(int nIndex) const = 0; - virtual void SetSubsetBounds(int nIndex, const Vec3& vCenter, float fRadius) = 0; - virtual void SetSubsetIndexVertexRanges(int nIndex, int nFirstIndexId, int nNumIndices, int nFirstVertId, int nNumVerts) = 0; - virtual void SetSubsetMaterialId(int nIndex, int nMatID) = 0; - virtual void SetSubsetMaterialProperties(int nIndex, int nMatFlags, int nPhysicalizeType, const AZ::Vertex::Format& vertexFormat) = 0; - ////////////////////////////////////////////////////////////////////////// - // Mesh bounding box. - ////////////////////////////////////////////////////////////////////////// - virtual void SetBBox(const AABB& box) = 0; - virtual AABB GetBBox() const = 0; - virtual void CalcBBox() = 0; - - virtual void RestoreFacesFromIndices() = 0; // - - // Optimizes mesh - virtual void Optimize(const char* szComment = NULL) = 0; }; - - -#endif // CRYINCLUDE_CRYCOMMON_IINDEXEDMESH_H diff --git a/Code/Legacy/CryCommon/IIndexedMesh_info.cpp b/Code/Legacy/CryCommon/IIndexedMesh_info.cpp deleted file mode 100644 index fe15ab7949..0000000000 --- a/Code/Legacy/CryCommon/IIndexedMesh_info.cpp +++ /dev/null @@ -1,46 +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 "TypeInfo_impl.h" -#include // <> required for Interfuscator - -STRUCT_INFO_BEGIN(SMeshTexCoord) -STRUCT_VAR_INFO(s, TYPE_INFO(float)) -STRUCT_VAR_INFO(t, TYPE_INFO(float)) -STRUCT_INFO_END(SMeshTexCoord) - -STRUCT_INFO_BEGIN(SMeshNormal) -STRUCT_VAR_INFO(Normal, TYPE_INFO(Vec3)) -STRUCT_INFO_END(SMeshNormal) - -STRUCT_INFO_BEGIN(SMeshColor) -STRUCT_VAR_INFO(r, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(g, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(b, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(a, TYPE_INFO(uint8)) -STRUCT_INFO_END(SMeshColor) - -STRUCT_INFO_BEGIN(SMeshTangents) -STRUCT_VAR_INFO(Tangent, TYPE_INFO(Vec4sf)) -STRUCT_VAR_INFO(Bitangent, TYPE_INFO(Vec4sf)) -STRUCT_INFO_END(SMeshTangents) - -STRUCT_INFO_BEGIN(SMeshQTangents) -STRUCT_VAR_INFO(TangentBitangent, TYPE_INFO(Vec4sf)) -STRUCT_INFO_END(SMeshQTangents) - -STRUCT_INFO_BEGIN(SMeshBoneMapping_uint16) -STRUCT_VAR_INFO(boneIds, TYPE_ARRAY(4, TYPE_INFO(SMeshBoneMapping_uint16::BoneId))) -STRUCT_VAR_INFO(weights, TYPE_ARRAY(4, TYPE_INFO(SMeshBoneMapping_uint16::Weight))) -STRUCT_INFO_END(SMeshBoneMapping_uint16) - -STRUCT_INFO_BEGIN(SMeshBoneMapping_uint8) -STRUCT_VAR_INFO(boneIds, TYPE_ARRAY(4, TYPE_INFO(SMeshBoneMapping_uint8::BoneId))) -STRUCT_VAR_INFO(weights, TYPE_ARRAY(4, TYPE_INFO(SMeshBoneMapping_uint8::Weight))) -STRUCT_INFO_END(SMeshBoneMapping_uint8) diff --git a/Code/Legacy/CryCommon/ILocalizationManager.h b/Code/Legacy/CryCommon/ILocalizationManager.h index 2cba093f21..0f0ba88250 100644 --- a/Code/Legacy/CryCommon/ILocalizationManager.h +++ b/Code/Legacy/CryCommon/ILocalizationManager.h @@ -73,11 +73,11 @@ struct SLocalizedSoundInfoGame bool bIsIntercepted; // SoundMoods. - int nNumSoundMoods; + size_t nNumSoundMoods; SLocalizedAdvancesSoundEntry* pSoundMoods; // EventParameters. - int nNumEventParameters; + size_t nNumEventParameters; SLocalizedAdvancesSoundEntry* pEventParameters; }; diff --git a/Code/Legacy/CryCommon/IMaterial.h b/Code/Legacy/CryCommon/IMaterial.h index e1502b0f1a..1b3ef258ce 100644 --- a/Code/Legacy/CryCommon/IMaterial.h +++ b/Code/Legacy/CryCommon/IMaterial.h @@ -10,36 +10,12 @@ // Description : IMaterial interface declaration. #pragma once -struct ISurfaceType; -struct ISurfaceTypeManager; -class ICrySizer; - -enum EEfResTextures : int; // Need to specify a fixed size for the forward declare to work on clang - -struct SShaderItem; -struct SShaderParam; -struct IShader; -struct IMaterial; -struct IMaterialManager; -struct CMaterialCGF; -struct IRenderMesh; - -#include -#include #include #include -#ifdef MAX_SUB_MATERIALS -// This checks that the values are in sync in the different files. -static_assert(MAX_SUB_MATERIALS == 128); -#else -#define MAX_SUB_MATERIALS 128 -#endif - -// Special names for materials. -#define MTL_SPECIAL_NAME_COLLISION_PROXY "collision_proxy" -#define MTL_SPECIAL_NAME_COLLISION_PROXY_VEHICLE "nomaterial_vehicle" -#define MTL_SPECIAL_NAME_RAYCAST_PROXY "raycast_proxy" +struct IShader; +struct ISurfaceType; +struct SShaderItem; namespace AZ { @@ -59,380 +35,15 @@ namespace AZ using MaterialNotificationEventBus = AZ::EBus; } -enum -{ - MAX_STREAM_PREDICTION_ZONES = 2 -}; - -////////////////////////////////////////////////////////////////////////// -// Description: -// IMaterial is an interface to the material object, SShaderItem host which is a combination of IShader and SShaderInputResources. -// Material bind together rendering algorithm (Shader) and resources needed to render this shader, textures, colors, etc... -// All materials except for pure sub material childs have a unique name which directly represent .mtl file on disk. -// Ex: "Materials/Fire/Burn" -// Materials can be created by Sandbox MaterialEditor. -////////////////////////////////////////////////////////////////////////// -enum EMaterialFlags -{ - MTL_FLAG_WIRE = 0x0001, // Use wire frame rendering for this material. - MTL_FLAG_2SIDED = 0x0002, // Use 2 Sided rendering for this material. - MTL_FLAG_ADDITIVE = 0x0004, // Use Additive blending for this material. - //MTL_FLAG_DETAIL_DECAL = 0x0008, // UNUSED RESERVED FOR LEGACY REASONS - MTL_FLAG_LIGHTING = 0x0010, // Should lighting be applied on this material. - MTL_FLAG_NOSHADOW = 0x0020, // Material do not cast shadows. - MTL_FLAG_ALWAYS_USED = 0x0040, // When set forces material to be export even if not explicitly used. - MTL_FLAG_PURE_CHILD = 0x0080, // Not shared sub material, sub material unique to his parent multi material. - MTL_FLAG_MULTI_SUBMTL = 0x0100, // This material is a multi sub material. - MTL_FLAG_NOPHYSICALIZE = 0x0200, // Should not physicalize this material. - MTL_FLAG_NODRAW = 0x0400, // Do not render this material. - MTL_FLAG_NOPREVIEW = 0x0800, // Cannot preview the material. - MTL_FLAG_NOTINSTANCED = 0x1000, // Do not instantiate this material. - MTL_FLAG_COLLISION_PROXY = 0x2000, // This material is the collision proxy. - MTL_FLAG_SCATTER = 0x4000, // Use scattering for this material - MTL_FLAG_REQUIRE_FORWARD_RENDERING = 0x8000, // This material has to be rendered in forward rendering passes (alpha/additive blended) - MTL_FLAG_NON_REMOVABLE = 0x10000, // Material with this flag once created are never removed from material manager (Used for decal materials, this flag should not be saved). - MTL_FLAG_HIDEONBREAK = 0x20000, // Non-physicalized subsets with such materials will be removed after the object breaks - MTL_FLAG_UIMATERIAL = 0x40000, // Used for UI in Editor. Don't need show it DB. - MTL_64BIT_SHADERGENMASK = 0x80000, // ShaderGen mask is remapped - MTL_FLAG_RAYCAST_PROXY = 0x100000, - MTL_FLAG_REQUIRE_NEAREST_CUBEMAP = 0x200000, // materials with alpha blending requires special processing for shadows - MTL_FLAG_CONSOLE_MAT = 0x400000, - MTL_FLAG_DELETE_PENDING = 0x800000, // Internal use only - MTL_FLAG_BLEND_TERRAIN = 0x1000000, - MTL_FLAG_IS_TERRAIN = 0x2000000,// indication to the loader - Terrain type - MTL_FLAG_IS_SKY = 0x4000000,// indication to the loader - Sky type - MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH= 0x8000000 // high vertex shading quality behaves more accurately with fog volumes. -}; - -#define MTL_FLAGS_SAVE_MASK (MTL_FLAG_WIRE | MTL_FLAG_2SIDED | MTL_FLAG_ADDITIVE | MTL_FLAG_LIGHTING | \ - MTL_FLAG_NOSHADOW | MTL_FLAG_MULTI_SUBMTL | MTL_FLAG_SCATTER | MTL_FLAG_REQUIRE_FORWARD_RENDERING | MTL_FLAG_FOG_VOLUME_SHADING_QUALITY_HIGH | MTL_FLAG_HIDEONBREAK | MTL_FLAG_UIMATERIAL | MTL_64BIT_SHADERGENMASK | MTL_FLAG_REQUIRE_NEAREST_CUBEMAP | MTL_FLAG_CONSOLE_MAT | MTL_FLAG_BLEND_TERRAIN) - -// Post effects flags -enum EPostEffectFlags -{ - POST_EFFECT_GHOST = 0x1, - POST_EFFECT_HOLOGRAM = 0x2, - - POST_EFFECT_MASK = POST_EFFECT_GHOST | POST_EFFECT_HOLOGRAM -}; - -// Bit offsets for shader layer flags -enum EMaterialLayerFlags -{ - // Active layers flags - MTL_LAYER_FROZEN = 0x0001, - MTL_LAYER_WET = 0x0002, - MTL_LAYER_DYNAMICFROZEN = 0x0008, - - // Usage flags - MTL_LAYER_USAGE_NODRAW = 0x0001, // Layer is disabled - MTL_LAYER_USAGE_REPLACEBASE = 0x0002, // Replace base pass rendering with layer - optimization - MTL_LAYER_USAGE_FADEOUT = 0x0004, // Layer doesn't render but still causes parent to fade out - - // Blend offsets - MTL_LAYER_BLEND_FROZEN = 0xff000000, - MTL_LAYER_BLEND_WET = 0x00fe0000, - MTL_LAYER_BLEND_DYNAMICFROZEN = 0x000000ff, - - MTL_LAYER_FROZEN_MASK = 0xff, - MTL_LAYER_WET_MASK = 0xfe, // bit stolen - MTL_LAYER_DYNAMICFROZEN_MASK = 0xff, - - MTL_LAYER_BLEND_MASK = (MTL_LAYER_BLEND_FROZEN | MTL_LAYER_BLEND_WET | MTL_LAYER_BLEND_DYNAMICFROZEN), - - // Slot count - MTL_LAYER_MAX_SLOTS = 3 -}; - -// copy flags -enum EMaterialCopyFlags -{ - // copy flags - MTL_COPY_DEFAULT = 0, - MTL_COPY_NAME = BIT(0), - MTL_COPY_TEXTURES = BIT(1), -}; - struct IMaterial { // TODO: Remove it! - //! default texture mapping - uint8 m_ucDefautMappingAxis; - float m_fDefautMappingScale; - // virtual ~IMaterial() {} - - ////////////////////////////////////////////////////////////////////////// - // Reference counting. - ////////////////////////////////////////////////////////////////////////// virtual void AddRef() = 0; virtual void Release() = 0; - virtual int GetNumRefs() = 0; - virtual IMaterialManager* GetMaterialManager() = 0; - - ////////////////////////////////////////////////////////////////////////// - // material name - ////////////////////////////////////////////////////////////////////////// - //! Set material name, (Do not use this directly - virtual void SetName(const char* pName) = 0; - //! Returns material name. - virtual const char* GetName() const = 0; - - //! Set/get shader name. The shader name may include technique name so it could be deferent than GetShaderItem()->m_pShader->GetName(). - virtual void SetShaderName(const char* pName) = 0; - virtual const char* GetShaderName() const = 0; - - //! Material flags. - //! @see EMaterialFlags - virtual void SetFlags(int flags) = 0; - virtual int GetFlags() const = 0; - virtual void UpdateFlags() = 0; - - // Returns true if this is the default material. - virtual bool IsDefault() = 0; - - virtual int GetSurfaceTypeId() = 0; - - // Assign a different surface type to this material. - virtual void SetSurfaceType(const char* sSurfaceTypeName) = 0; - - virtual ISurfaceType* GetSurfaceType() = 0; - - // shader item virtual SShaderItem& GetShaderItem() = 0; virtual const SShaderItem& GetShaderItem() const = 0; - // Returns shader item for correct sub material or for single material. - // Even if this is not sub material or nSubMtlSlot is invalid it will return valid renderable shader item. - virtual SShaderItem& GetShaderItem(int nSubMtlSlot) = 0; - virtual const SShaderItem& GetShaderItem(int nSubMtlSlot) const = 0; - - // Returns true if streamed in - virtual bool IsStreamedIn(const int nMinPrecacheRoundIds[MAX_STREAM_PREDICTION_ZONES], IRenderMesh* pRenderMesh) const = 0; - - // Description: - // Fill an array of integeres representing surface ids of the sub materials or the material itself. - // Arguments: - // pSurfaceIdsTable is a pointer to the array of int with size enough to hold MAX_SUB_MATERIALS surface type ids. - // Return: - // number of filled items. - virtual int FillSurfaceTypeIds(int pSurfaceIdsTable[]) = 0; - - ////////////////////////////////////////////////////////////////////////// - // UserData used to link with the Editor. - ////////////////////////////////////////////////////////////////////////// - virtual void SetUserData(void* pUserData) = 0; - virtual void* GetUserData() const = 0; - - ////////////////////////////////////////////////////////////////////////// - //! Set or get a material parameter value. - //! \param sParamName - Name of the parameter - //! \param v - Input or output value depending on bGet - //! \param bGet - If true, v is an output; if false, v is an input - //! \param allowShaderParam - If true, and sParamName is not a built-in parameter of the Material, then custom shader parameters will be searched as well. Defaults to false to preserve legacy behavior. - //! \param materialIndex - Index of the sub-material if this is a material group - //! return - True if sParamName was found - virtual bool SetGetMaterialParamFloat(const char* sParamName, float& v, bool bGet, bool allowShaderParam = false, int materialIndex = 0) = 0; - //! Set or get a material parameter value. - //! \param sParamName - Name of the parameter - //! \param v - Input or output value depending on bGet - //! \param bGet - If true, v is an output; if false, v is an input - //! \param allowShaderParam - If true, and sParamName is not a built-in parameter of the Material, then custom shader parameters will be searched as well. Defaults to false to preserve legacy behavior. - //! \param materialIndex - Index of the sub-material if this is a material group - //! return - True if sParamName was found - virtual bool SetGetMaterialParamVec3(const char* sParamName, Vec3& v, bool bGet, bool allowShaderParam = false, int materialIndex = 0) = 0; - //! Set or get a material parameter value. - //! \param sParamName - Name of the parameter - //! \param v - Input or output value depending on bGet - //! \param bGet - If true, v is an output; if false, v is an input - //! \param allowShaderParam - If true, and sParamName is not a built-in parameter of the Material, then custom shader parameters will be searched as well. Defaults to false to preserve legacy behavior. - //! \param materialIndex - Index of the sub-material if this is a material group - //! return - True if sParamName was found - virtual bool SetGetMaterialParamVec4(const char* sParamName, Vec4& v, bool bGet, bool allowShaderParam = false, int materialIndex = 0) = 0; - - virtual void SetDirty(bool dirty = true) = 0; - virtual bool IsDirty() const = 0; - - //! Returns true if the material is the parent of a group of materials - virtual bool IsMaterialGroup() const = 0; - - //! Returns true if the material is a single material belongs to a material group - virtual bool IsSubMaterial() const = 0; - - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - - virtual size_t GetResourceMemoryUsage(ICrySizer* pSizer) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Makes this specific material enter sketch mode. - // Current supported sketch modes: - // - 0, no sketch. - // - 1, normal sketch mode. - // - 2, fast sketch mode. - virtual void SetSketchMode(int mode) = 0; - - // Sets FT_DONT_STREAM flag for all textures used by the material - // If a stream is already in process, this will stop the stream and flush the device texture - virtual void DisableTextureStreaming() = 0; - ////////////////////////////////////////////////////////////////////////// - // Tells to texture streamer to start loading textures asynchronously - ////////////////////////////////////////////////////////////////////////// - virtual void RequestTexturesLoading(const float fMipFactor) = 0; - - virtual void PrecacheMaterial(const float fEntDistance, struct IRenderMesh* pRenderMesh, bool bFullUpdate, bool bDrawNear = false) = 0; - - // Estimates texture memory usage for this material - // When nMatID is not negative only caluclate for one sub-material - virtual int GetTextureMemoryUsage(ICrySizer* pSizer, int nMatID = -1) = 0; - - // Set & retrieve a material link name - // This value by itself is not used by the material system per-se and hence - // has no real effect, however it is used on a higher level to tie related materials - // together, for example by procedural breakable glass to determine which material to - // switch to. - virtual void SetMaterialLinkName(const char* name) = 0; - virtual const char* GetMaterialLinkName() const = 0; - virtual void SetKeepLowResSysCopyForDiffTex() = 0; - - virtual uint32 GetDccMaterialHash() const = 0; - virtual void SetDccMaterialHash(uint32 hash) = 0; - - virtual void UpdateShaderItems() = 0; - - // -}; - - - -////////////////////////////////////////////////////////////////////////// -// Description: -// IMaterialManagerListener is a callback interface to listenen -// for special events of material manager, (used by Editor). -struct IMaterialManagerListener -{ - // - virtual ~IMaterialManagerListener(){} - // Called when material manager tries to load a material. - // nLoadingFlags - Zero or a bitwise combination of the flagas defined in ELoadingFlags. - virtual void OnCreateMaterial(_smart_ptr pMaterial) = 0; - virtual void OnDeleteMaterial(_smart_ptr pMaterial) = 0; - virtual bool IsCurrentMaterial(_smart_ptr pMaterial) const = 0; - // -}; - -using IMaterialRef = _smart_ptr; -////////////////////////////////////////////////////////////////////////// -// Description: -// IMaterialManager interface provide access to the material manager -// implemented in 3d engine. -struct IMaterialManager -{ - //! Loading flags - enum ELoadingFlags - { - ELoadingFlagsPreviewMode = BIT(0), - }; - - // - virtual ~IMaterialManager(){} - - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - - // Summary: - // Creates a new material object and register it with the material manager - // Return Value: - // A newly created object derived from IMaterial. - virtual _smart_ptr CreateMaterial(const char* sMtlName, int nMtlFlags = 0) = 0; - - // Summary: - // Renames a material object - // Note: - // Do not use IMaterial::SetName directly. - // Arguments: - // pMtl - Pointer to a material object - // sNewName - New name to assign to the material - virtual void RenameMaterial(_smart_ptr pMtl, const char* sNewName) = 0; - - // Description: - // Finds named material. - virtual _smart_ptr FindMaterial(const char* sMtlName) const = 0; - - // Description: - // Loads material. - // nLoadingFlags - Zero or a bitwise combination of the values defined in ELoadingFlags. - virtual _smart_ptr LoadMaterial(const char* sMtlName, bool bMakeIfNotFound = true, bool bNonremovable = false, unsigned long nLoadingFlags = 0) = 0; - - // Description: - // Loads material from xml. - virtual _smart_ptr LoadMaterialFromXml(const char* sMtlName, XmlNodeRef mtlNode) = 0; - - // Description: - // Reloads the material from disk. - virtual void ReloadMaterial(_smart_ptr pMtl) = 0; - - // Description: - // Saves material. - virtual bool SaveMaterial(XmlNodeRef mtlNode, _smart_ptr pMtl) = 0; - - // Description: - // Clone single material or multi sub material. - // Arguments: - // nSubMtl - when negative all sub materials of MultiSubMtl are cloned, if positive only specified slot is cloned. - virtual _smart_ptr CloneMaterial(_smart_ptr pMtl, int nSubMtl = -1) = 0; - - // Description: - // Copy single material. - virtual void CopyMaterial(_smart_ptr pMtlSrc, _smart_ptr pMtlDest, EMaterialCopyFlags flags) = 0; - - // Description: - // Clone MultiSubMtl material. - // Arguments: - // sSubMtlName - name of the sub-material to clone, if NULL all submaterial are cloned. - virtual _smart_ptr CloneMultiMaterial(_smart_ptr pMtl, const char* sSubMtlName = 0) = 0; - - // Description: - // Associate a special listener callback with material manager inside 3d engine. - // This listener callback is used primerly by the editor. - virtual void SetListener(IMaterialManagerListener* pListener) = 0; - - // Description: - // Retrieve a default engine material. - virtual _smart_ptr GetDefaultMaterial() = 0; - - // Description: - // Retrieve a default engine material for terrain layer - virtual _smart_ptr GetDefaultTerrainLayerMaterial() = 0; - - // Description: - // Retrieve a default engine material with material layers presets. - virtual _smart_ptr GetDefaultLayersMaterial() = 0; - - // Description: - // Retrieve a default engine material for drawing helpers. - virtual _smart_ptr GetDefaultHelperMaterial() = 0; - - // Description: - // Retrieve surface type by name. - virtual ISurfaceType* GetSurfaceTypeByName(const char* sSurfaceTypeName, const char* sWhy = NULL) = 0; - virtual int GetSurfaceTypeIdByName(const char* sSurfaceTypeName, const char* sWhy = NULL) = 0; - // Description: - // Retrieve surface type by unique surface type id. - virtual ISurfaceType* GetSurfaceType(int nSurfaceTypeId, const char* sWhy = NULL) = 0; - // Description: - // Retrieve interface to surface type manager. - virtual ISurfaceTypeManager* GetSurfaceTypeManager() = 0; - - // Get IMaterial pointer from the CGF material structure. - // nLoadingFlags - Zero, or a bitwise combination of the enum items from ELoadingFlags. - virtual _smart_ptr LoadCGFMaterial(CMaterialCGF* pMaterialCGF, const char* sCgfFilename, unsigned long nLoadingFlags = 0) = 0; - - // for statistics - call once to get the count (pData==0), again to get the data(pData!=0) - virtual void GetLoadedMaterials(AZStd::vector<_smart_ptr>* pData, uint32& nObjCount) const = 0; - - // Updates material data in the renderer - virtual void RefreshMaterialRuntime() = 0; - - // }; diff --git a/Code/Legacy/CryCommon/IMovieSystem.h b/Code/Legacy/CryCommon/IMovieSystem.h index 5d878c45ec..b5302b58f5 100644 --- a/Code/Legacy/CryCommon/IMovieSystem.h +++ b/Code/Legacy/CryCommon/IMovieSystem.h @@ -21,7 +21,6 @@ #include #include #include -#include // forward declaration. struct IAnimTrack; diff --git a/Code/Legacy/CryCommon/IPathfinder.h b/Code/Legacy/CryCommon/IPathfinder.h index 781e379cf9..7a05321c99 100644 --- a/Code/Legacy/CryCommon/IPathfinder.h +++ b/Code/Legacy/CryCommon/IPathfinder.h @@ -15,11 +15,12 @@ struct IAIPathAgent; #include #include -#include #include #include +#include #include +#include #include #include @@ -131,8 +132,7 @@ struct NavigationBlocker Location location; }; -typedef DynArray NavigationBlockers; - +using NavigationBlockers = AZStd::vector; //==================================================================== // PathPointDescriptor @@ -240,8 +240,7 @@ struct PathfindingExtraConstraint UConstraint constraint; }; -typedef DynArray PathfindingExtraConstraints; - +using PathfindingExtraConstraints = AZStd::vector; struct PathfindRequest { @@ -557,26 +556,6 @@ public: virtual void Draw(const Vec3& drawOffset = ZERO) const = 0; virtual void Dump(const char* name) const = 0; - bool ArePathsEqual(const INavPath& otherNavPath) - { - const TPathPoints& path1 = this->GetPath(); - const TPathPoints& path2 = otherNavPath.GetPath(); - const TPathPoints::size_type path1Size = path1.size(); - const TPathPoints::size_type path2Size = path2.size(); - if (path1Size != path2Size) - { - return false; - } - - TPathPoints::const_iterator path1It = path1.begin(); - TPathPoints::const_iterator path1End = path1.end(); - TPathPoints::const_iterator path2It = path2.begin(); - - typedef std::pair TMismatchResult; - - TMismatchResult result = std::mismatch(path1It, path1End, path2It, PathPointDescriptor::ArePointsEquivalent); - return result.first == path1.end(); - } }; using INavPathPtr = AZStd::shared_ptr; diff --git a/Code/Legacy/CryCommon/IPhysics.h b/Code/Legacy/CryCommon/IPhysics.h deleted file mode 100644 index a1825d3e44..0000000000 --- a/Code/Legacy/CryCommon/IPhysics.h +++ /dev/null @@ -1,38 +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 -#include "Cry_Math.h" -#include "primitives.h" -#include // <> required for Interfuscator - -////////////////////////////////////////////////////////////////////////// -// IDs that can be used for foreign id. -////////////////////////////////////////////////////////////////////////// -enum EPhysicsForeignIds -{ - PHYS_FOREIGN_ID_TERRAIN = 0, - PHYS_FOREIGN_ID_STATIC = 1, - PHYS_FOREIGN_ID_ENTITY = 2, - PHYS_FOREIGN_ID_FOLIAGE = 3, - PHYS_FOREIGN_ID_ROPE = 4, - PHYS_FOREIGN_ID_SOUND_OBSTRUCTION = 5, - PHYS_FOREIGN_ID_SOUND_PROXY_OBSTRUCTION = 6, - PHYS_FOREIGN_ID_SOUND_REVERB_OBSTRUCTION = 7, - PHYS_FOREIGN_ID_WATERVOLUME = 8, - PHYS_FOREIGN_ID_BREAKABLE_GLASS = 9, - PHYS_FOREIGN_ID_BREAKABLE_GLASS_FRAGMENT = 10, - PHYS_FOREIGN_ID_RIGID_PARTICLE = 11, - PHYS_FOREIGN_ID_RESERVED1 = 12, - PHYS_FOREIGN_ID_RAGDOLL = 13, - PHYS_FOREIGN_ID_COMPONENT_ENTITY = 14, - - PHYS_FOREIGN_ID_USER = 100, // All user defined foreign ids should start from this enum. -}; diff --git a/Code/Legacy/CryCommon/IPostEffectGroup.h b/Code/Legacy/CryCommon/IPostEffectGroup.h deleted file mode 100644 index d8452b75ab..0000000000 --- a/Code/Legacy/CryCommon/IPostEffectGroup.h +++ /dev/null @@ -1,49 +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 - -typedef AZStd::variant PostEffectGroupParam; - -// A prioritized group of postprocessing effect parameters. -// These are defined in XML files and can be enabled or disabled using flow graph or Lua scripts. -// Effect groups can also optionally specify blend curves to smoothly transition between effects, whether to stay enabled until explicitly disabled, -// and whether to make effect strength based on distance from the camera. -class IPostEffectGroup -{ -public: - virtual ~IPostEffectGroup(){} - - virtual const char* GetName() const = 0; - virtual void SetEnable(bool enable) = 0; - virtual bool GetEnable() const = 0; - virtual unsigned int GetPriority() const = 0; - virtual bool GetHold() const = 0; - virtual float GetFadeDistance() const = 0; - virtual void SetParam(const char* name, const PostEffectGroupParam& value) = 0; - virtual PostEffectGroupParam* GetParam(const char* name) = 0; - virtual void ClearParams() = 0; - // Increases the strength of the effects based on distance from the camera each time it's called. The effect strength is cleared each frame. - // Only applies to effect groups with the fadeDistance attribute set. - virtual void ApplyAtPosition(const Vec3& position) = 0; -}; - -typedef AZStd::list PostEffectGroupList; - -class IPostEffectGroupManager -{ -public: - virtual ~IPostEffectGroupManager(){} - - virtual IPostEffectGroup* GetGroup(const char* name) = 0; - virtual IPostEffectGroup* GetGroup(const unsigned int index) = 0; - virtual const unsigned int GetGroupCount() = 0; - // Returns a list of IPostEffectGroups who had their Enabled state toggled this frame - virtual const PostEffectGroupList& GetGroupsToggledThisFrame() = 0; -}; diff --git a/Code/Legacy/CryCommon/IRenderMesh.h b/Code/Legacy/CryCommon/IRenderMesh.h deleted file mode 100644 index 0e225579ad..0000000000 --- a/Code/Legacy/CryCommon/IRenderMesh.h +++ /dev/null @@ -1,282 +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_IRENDERMESH_H -#define CRYINCLUDE_CRYCOMMON_IRENDERMESH_H -#pragma once - -#include "VertexFormats.h" -#include -#include // PublicRenderPrimitiveType -#include -#include -#include - -class CMesh; -class CRenderObject; -struct SSkinningData; -struct IMaterial; -struct IIndexedMesh; -struct SMRendTexVert; -struct UCol; -struct GeomInfo; - -struct TFace; -struct SMeshSubset; -struct SRenderingPassInfo; -struct SRendItemSorter; -struct SRenderObjectModifier; - -namespace AZ -{ - namespace Vertex - { - class Format; - } -} - -enum eRenderPrimitiveType : int8; - -// Keep this in sync with BUFFER_USAGE hints DevBuffer.h -enum ERenderMeshType -{ - eRMT_Immmutable = 0, - eRMT_Static = 1, - eRMT_Dynamic = 2, - eRMT_Transient = 3, -}; - - -#define FSM_VERTEX_VELOCITY 1 -#define FSM_NO_TANGENTS 2 -#define FSM_CREATE_DEVICE_MESH 4 -#define FSM_SETMESH_ASYNC 8 -#define FSM_ENABLE_NORMALSTREAM 16 -#define FSM_IGNORE_TEXELDENSITY 32 - -// Invalidate video buffer flags -#define FMINV_STREAM 1 -#define FMINV_STREAM_MASK ((1 << VSF_NUM) - 1) -#define FMINV_INDICES 0x100 -#define FMINV_ALL -1 - -// Stream lock flags -#define FSL_READ 0x01 -#define FSL_WRITE 0x02 -#define FSL_DYNAMIC 0x04 -#define FSL_DISCARD 0x08 -#define FSL_VIDEO 0x10 -#define FSL_SYSTEM 0x20 -#define FSL_INSTANCED 0x40 -#define FSL_NONSTALL_MAP 0x80 // Map must not stall for VB/IB locking -#define FSL_VBIBPUSHDOWN 0x100 // Push down from vram on demand if target architecture supports it, used internally -#define FSL_DIRECT 0x200 // Access VRAM directly if target architecture supports it, used internally -#define FSL_LOCKED 0x400 // Internal use -#define FSL_SYSTEM_CREATE (FSL_WRITE | FSL_DISCARD | FSL_SYSTEM) -#define FSL_SYSTEM_UPDATE (FSL_WRITE | FSL_SYSTEM) -#define FSL_VIDEO_CREATE (FSL_WRITE | FSL_DISCARD | FSL_VIDEO) -#define FSL_VIDEO_UPDATE (FSL_WRITE | FSL_VIDEO) - -#define FSL_ASYNC_DEFER_COPY (1u << 1) -#define FSL_FREE_AFTER_ASYNC (2u << 1) - -struct IRenderMesh -{ - enum EMemoryUsageArgument - { - MEM_USAGE_COMBINED, - MEM_USAGE_ONLY_SYSTEM, - MEM_USAGE_ONLY_VIDEO, - MEM_USAGE_ONLY_STREAMS, - }; - - // Render mesh initialization parameters, that can be used to create RenderMesh from raw pointers. - struct SInitParamerers - { - AZ::Vertex::Format vertexFormat; - ERenderMeshType eType; - - void* pVertBuffer; - int nVertexCount; - SPipTangents* pTangents; - SPipNormal* pNormals; - vtx_idx* pIndices; - int nIndexCount; - PublicRenderPrimitiveType nPrimetiveType; - int nRenderChunkCount; - int nClientTextureBindID; - bool bOnlyVideoBuffer; - bool bPrecache; - bool bLockForThreadAccess; - - SInitParamerers() - : vertexFormat(eVF_P3F_C4B_T2F) - , eType(eRMT_Static) - , pVertBuffer(0) - , nVertexCount(0) - , pTangents(0) - , pNormals(0) - , pIndices(0) - , nIndexCount(0) - , nPrimetiveType(PublicRenderPrimitiveType::prtTriangleList) - , nRenderChunkCount(0) - , nClientTextureBindID(0) - , bOnlyVideoBuffer(false) - , bPrecache(true) - , bLockForThreadAccess(false) {} - }; - - struct ThreadAccessLock - { - ThreadAccessLock(IRenderMesh* pRM) - : m_pRM(pRM) - { - m_pRM->LockForThreadAccess(); - } - - ~ThreadAccessLock() - { - m_pRM->UnLockForThreadAccess(); - } - - private: - ThreadAccessLock(const ThreadAccessLock&); - ThreadAccessLock& operator = (const ThreadAccessLock&); - - private: - IRenderMesh* m_pRM; - }; - - // - virtual ~IRenderMesh(){} - - ////////////////////////////////////////////////////////////////////////// - // Reference Counting. - virtual void AddRef() = 0; - virtual int Release() = 0; - ////////////////////////////////////////////////////////////////////////// - - // Prevent rendering if video memory could not been allocated for it - virtual bool CanRender() = 0; - - // Returns type name given to the render mesh on creation time. - virtual const char* GetTypeName() = 0; - // Returns the name of the source given to the render mesh on creation time. - virtual const char* GetSourceName() const = 0; - - virtual int GetIndicesCount() = 0; - virtual int GetVerticesCount() = 0; - virtual AZ::Vertex::Format GetVertexFormat() = 0; - virtual ERenderMeshType GetMeshType() = 0; - virtual float GetGeometricMeanFaceArea() const = 0; - - virtual bool CheckUpdate(uint32 nStreamMask) = 0; - virtual int GetStreamStride(int nStream) const = 0; - - virtual int GetNumVerts() const = 0; - virtual int GetNumInds() const = 0; - virtual const eRenderPrimitiveType GetPrimitiveType() const = 0; - - virtual void SetSkinned(bool bSkinned = true) = 0; - virtual uint GetSkinningWeightCount() const = 0; - - // Create render buffers from render mesh. Returns the final size of the render mesh or ~0U on failure - virtual size_t SetMesh(CMesh& mesh, int nSecColorsSetOffset, uint32 flags, bool requiresLock) = 0; - virtual void CopyTo(IRenderMesh* pDst, int nAppendVtx = 0, bool bDynamic = false, bool fullCopy = true) = 0; - virtual void SetSkinningDataVegetation(struct SMeshBoneMapping_uint8* pBoneMapping) = 0; - virtual void SetSkinningDataCharacter(CMesh& mesh, struct SMeshBoneMapping_uint16* pBoneMapping, struct SMeshBoneMapping_uint16* pExtraBoneMapping) = 0; - // Creates an indexed mesh from this render mesh (accepts an optional pointer to an IIndexedMesh object that should be used) - virtual IIndexedMesh* GetIndexedMesh(IIndexedMesh* pIdxMesh = 0) = 0; - virtual int GetRenderChunksCount(_smart_ptr pMat, int& nRenderTrisCount) = 0; - - virtual IRenderMesh* GenerateMorphWeights() = 0; - virtual IRenderMesh* GetMorphBuddy() = 0; - virtual void SetMorphBuddy(IRenderMesh* pMorph) = 0; - - virtual bool UpdateVertices(const void* pVertBuffer, int nVertCount, int nOffset, int nStream, uint32 copyFlags, bool requiresLock = true) = 0; - virtual bool UpdateIndices(const vtx_idx* pNewInds, int nInds, int nOffsInd, uint32 copyFlags, bool requiresLock = true) = 0; - virtual void SetCustomTexID(int nCustomTID) = 0; - - virtual void GenerateQTangents() = 0; - virtual void CreateChunksSkinned() = 0; - virtual void NextDrawSkinned() = 0; - virtual IRenderMesh* GetVertexContainer() = 0; - virtual void SetVertexContainer(IRenderMesh* pBuf) = 0; - virtual void SetBBox(const Vec3& vBoxMin, const Vec3& vBoxMax) = 0; - virtual void GetBBox(Vec3& vBoxMin, Vec3& vBoxMax) = 0; - virtual void UpdateBBoxFromMesh() = 0; - virtual uint32* GetPhysVertexMap() = 0; - virtual bool IsEmpty() = 0; - - virtual int8* GetPosPtrNoCache(int32& nStride, uint32 nFlags) = 0; - virtual int8* GetPosPtr(int32& nStride, uint32 nFlags) = 0; - virtual int8* GetColorPtr(int32& nStride, uint32 nFlags) = 0; - virtual int8* GetNormPtr(int32& nStride, uint32 nFlags) = 0; - //! Returns a pointer to the first uv coordinate in the interleaved vertex stream - virtual int8* GetUVPtrNoCache(int32& nStride, uint32 nFlags, uint32 uvSetIndex = 0) = 0; - /*! Get a pointer to the mesh's uv coordinates and the stride from the beginning of one uv coordinate to the next - \param[out] nStride The stride in between successive uv coordinates. - \param nFlags Stream lock flags (FSL_READ, FSL_WRITE, etc) - \param uvSetIndex Which uv set to retrieve (defaults to 0) - \return A pointer to cached uvs which contains all of the uv coordinates contiguous in memory, or as a fallback a pointer to the first uv coordinate in the interleaved vertex stream - Either way, nStride is set such that the caller can use it to iterate over the data in the same way regardless of which pointer was returned - Returns nullptr if there is no uv coordinate stream at the given index - */ - virtual int8* GetUVPtr(int32& nStride, uint32 nFlags, uint32 uvSetIndex = 0) = 0; - - virtual int8* GetTangentPtr(int32& nStride, uint32 nFlags) = 0; - virtual int8* GetQTangentPtr(int32& nStride, uint32 nFlags) = 0; - - virtual int8* GetHWSkinPtr(int32& nStride, uint32 nFlags, bool remapped = false) = 0; - virtual int8* GetVelocityPtr(int32& nStride, uint32 nFlags) = 0; - - virtual void UnlockStream(int nStream) = 0; - virtual void UnlockIndexStream() = 0; - - virtual vtx_idx* GetIndexPtr(uint32 nFlags, int32 nOffset = 0) = 0; - virtual const PodArray >* GetTrisForPosition(const Vec3& vPos, _smart_ptr pMaterial) = 0; - - virtual float GetExtent(EGeomForm eForm) = 0; - virtual void GetRandomPos(PosNorm& ran, EGeomForm eForm, SSkinningData const* pSkinning = NULL) = 0; - - virtual void Render(const struct SRendParams& rParams, CRenderObject* pObj, _smart_ptr pMaterial, const SRenderingPassInfo& passInfo, bool bSkinned = false) = 0; - virtual void Render(CRenderObject* pObj, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0; - virtual void SetREUserData(float* pfCustomData, float fFogScale = 0, float fAlpha = 1) = 0; - - // Debug draw this render mesh. - virtual void DebugDraw(const struct SGeometryDebugDrawInfo& info, uint32 nVisibleChunksMask = ~0, float fExtrdueScale = 0.01f) = 0; - - // Returns mesh memory usage and add it to the CrySizer (if not NULL). - // Arguments: - // pSizer - Sizer interface, can be NULL if caller only want to calculate size - // nType - see EMemoryUsageArgument - virtual size_t GetMemoryUsage(ICrySizer* pSizer, EMemoryUsageArgument nType) const = 0; - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - - // Get allocated only in video memory or only in system memory. - virtual int GetAllocatedBytes(bool bVideoMem) const = 0; - virtual float GetAverageTrisNumPerChunk(_smart_ptr pMat) = 0; - virtual int GetTextureMemoryUsage(const _smart_ptr pMaterial, ICrySizer* pSizer = NULL, bool bStreamedIn = true) const = 0; - virtual void KeepSysMesh(bool keep) = 0; // HACK: temp workaround for GDC-888 - virtual void UnKeepSysMesh() = 0; - virtual void SetMeshLod(int nLod) = 0; - - virtual void LockForThreadAccess() = 0; - virtual void UnLockForThreadAccess() = 0; - - // Sets the async update state - will sync before rendering to this - virtual volatile int* SetAsyncUpdateState(void) = 0; - virtual void CreateRemappedBoneIndicesPair(const DynArray& arrRemapTable, const uint pairGuid) = 0; - virtual void ReleaseRemappedBoneIndicesPair(const uint pairGuid) = 0; - - virtual void OffsetPosition(const Vec3& delta) = 0; - // -}; - -#endif // CRYINCLUDE_CRYCOMMON_IRENDERMESH_H diff --git a/Code/Legacy/CryCommon/ISerialize.h b/Code/Legacy/CryCommon/ISerialize.h index b153a52487..82ba9aef0d 100644 --- a/Code/Legacy/CryCommon/ISerialize.h +++ b/Code/Legacy/CryCommon/ISerialize.h @@ -17,7 +17,6 @@ #include #include #include "MiniQueue.h" -#include #include #include #include @@ -105,8 +104,6 @@ struct SNetObjectID } void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const { /*nothing*/} - - AUTO_STRUCT_INFO }; // this enumeration details what "kind" of serialization we are @@ -154,8 +151,6 @@ private: ////////////////////////////////////////////////////////////////////////// struct SSerializeString { - AUTO_STRUCT_INFO - SSerializeString() {}; SSerializeString(const SSerializeString& src) { m_str.assign(src.c_str()); }; explicit SSerializeString(const char* sbegin, const char* send) @@ -571,8 +566,6 @@ public: CONTAINER_VALUE(std::list, push_back); CONTAINER_VALUE(std::set, insert); CONTAINER_VALUE(std::deque, push_back); - CONTAINER_VALUE(VectorSet, insert); - CONTAINER_VALUE(DynArray, insert); PAIR_CONTAINER_VALUE(std::list, push_back); PAIR_CONTAINER_VALUE(std::vector, push_back); diff --git a/Code/Legacy/CryCommon/IShader.h b/Code/Legacy/CryCommon/IShader.h index 93f8534dfc..e9a00d3b76 100644 --- a/Code/Legacy/CryCommon/IShader.h +++ b/Code/Legacy/CryCommon/IShader.h @@ -6,161 +6,35 @@ * */ - // Description : Shaders common interface. - #pragma once - #if defined(LINUX) || defined(APPLE) #include #endif #include "smartptr.h" - #include "Cry_Vector3.h" - #include "Cry_Color.h" -#include "smartptr.h" - #include "VertexFormats.h" #include - - -#include -#include - -struct IMaterial; -class CRendElementBase; -class CRenderObject; -class CREMesh; -struct IRenderMesh; -struct IShader; -struct IVisArea; - -class CRendElement; -class CRendElementBase; -class CTexture; -class CTexAnim; -class CShader; -class ITexAnim; -struct SShaderPass; -struct SShaderItem; -class ITexture; -struct IMaterial; -struct SParam; -struct SShaderSerializeContext; -struct IAnimNode; -struct SSkinningData; -struct SSTexSamplerFX; -struct SShaderTextureSlot; -struct IRenderElement; - -namespace AZ -{ - class LegacyJobExecutor; - - namespace Vertex - { - class Format; - } -} - -//================================================================ -// Summary: -// Geometry Culling type. -enum ECull -{ - eCULL_Back = 0, // Back culling flag. - eCULL_Front, // Front culling flag. - eCULL_None // No culling flag. -}; - -enum ERenderResource -{ - eRR_Unknown, - eRR_Mesh, - eRR_Texture, - eRR_Shader, - eRR_ShaderResource, -}; - enum EEfResTextures : int // This needs a fixed size so the enum can be forward declared (needed by IMaterial.h) { EFTT_DIFFUSE = 0, EFTT_NORMALS, EFTT_SPECULAR, - EFTT_ENV, - EFTT_DETAIL_OVERLAY, - EFTT_SECOND_SMOOTHNESS, - EFTT_HEIGHT, - EFTT_DECAL_OVERLAY, - EFTT_SUBSURFACE, - EFTT_CUSTOM, - EFTT_CUSTOM_SECONDARY, EFTT_OPACITY, EFTT_SMOOTHNESS, EFTT_EMITTANCE, - EFTT_OCCLUSION, - EFTT_SPECULAR_2, - EFTT_MAX, EFTT_UNKNOWN = EFTT_MAX }; -enum EEfResSamplers -{ - EFSS_ANISO_HIGH = 0, - EFSS_ANISO_LOW, - EFSS_TRILINEAR, - EFSS_BILINEAR, - EFSS_TRILINEAR_CLAMP, - EFSS_BILINEAR_CLAMP, - EFSS_ANISO_HIGH_BORDER, - EFSS_TRILINEAR_BORDER, - - EFSS_MAX, -}; - -//========================================================================= - -// Summary: -// Array Pointers for Shaders. - -enum ESrcPointer -{ - eSrcPointer_Unknown, - eSrcPointer_Vert, - eSrcPointer_Color, - eSrcPointer_Tex, - eSrcPointer_TexLM, - eSrcPointer_Normal, - eSrcPointer_Tangent, - eSrcPointer_Max, -}; - -struct SWaveForm; -struct SWaveForm2; - -#define FRF_REFRACTIVE 1 -// FREE 2 -#define FRF_HEAT 4 -#define MAX_HEATSCALE 4 - #if !defined(MAX_JOINT_AMOUNT) #error MAX_JOINT_AMOUNT is not defined #endif -#if (MAX_JOINT_AMOUNT <= 256) -typedef uint8 JointIdType; -#else -typedef uint16 JointIdType; -#endif - -// The soft maximum cap for the sliders for emissive intensity. Also used to clamp legacy glow calculations in MaterialHelpers::MigrateXmlLegacyData. -// Note this is a "soft max" because the Emissive Intensity slider is capped at 200, but values higher than 200 may be entered in the text field. -#define EMISSIVE_INTENSITY_SOFT_MAX 200.0f //========================================================================= @@ -176,17 +50,10 @@ enum EParamType eType_STRING, eType_FCOLOR, eType_VECTOR, - eType_TEXTURE_HANDLE, - eType_CAMERA, - eType_FCOLORA, // with alpha channel }; -enum ESamplerType -{ - eSType_UNKNOWN, - eSType_Sampler, - eSType_SamplerComp, -}; +struct IShader; +class CCamera; union UParamVal { @@ -201,999 +68,20 @@ union UParamVal CCamera* m_pCamera; }; -// Note: -// In order to facilitate the memory allocation tracking, we're using here this class; -// if you don't like it, please write a substitute for all string within the project and use them everywhere. struct SShaderParam { AZStd::string m_Name; - AZStd::string m_Script; UParamVal m_Value; EParamType m_Type; - uint8 m_eSemantic; - uint8 m_Pad[3] = { 0 }; - - void Construct() - { - memset(&m_Value, 0, sizeof(m_Value)); - m_Type = eType_UNKNOWN; - m_eSemantic = 0; - m_Name.clear(); - m_Script.clear(); - } - - SShaderParam() - { - Construct(); - } - size_t Size() - { - size_t nSize = sizeof(*this); - if (m_Type == eType_STRING) - { - nSize += strlen (m_Value.m_String) + 1; - } - - return nSize; - } - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(m_Script); - if (m_Type == eType_STRING) - { - pSizer->AddObject(m_Value.m_String, strlen (m_Value.m_String) + 1); - } - } - - void Destroy() - { - if (m_Type == eType_STRING) - { - delete [] m_Value.m_String; - } - } - - ~SShaderParam() - { - Destroy(); - } - - SShaderParam (const SShaderParam& src) - { - m_Name = src.m_Name; - m_Script = src.m_Script; - m_Type = src.m_Type; - m_eSemantic = src.m_eSemantic; - if (m_Type == eType_STRING) - { - const size_t len = strlen(src.m_Value.m_String) + 1; - m_Value.m_String = new char[len]; - azstrcpy(m_Value.m_String, len, src.m_Value.m_String); - } - else - { - m_Value = src.m_Value; - } - } - - SShaderParam& operator = (const SShaderParam& src) - { - this->~SShaderParam(); - new(this)SShaderParam(src); - return *this; - } - - static bool SetParam(const char* name, AZStd::vector* Params, const UParamVal& pr) - { - uint32 i; - for (i = 0; i < (uint32)Params->size(); i++) - { - SShaderParam* sp = &(*Params)[i]; - if (!sp || &sp->m_Value == &pr) - { - continue; - } - if (azstricmp(sp->m_Name.c_str(), name) == 0) - { - if (sp->m_Type == eType_STRING) - { - delete[] sp->m_Value.m_String; - } - - - switch (sp->m_Type) - { - case eType_FLOAT: - sp->m_Value.m_Float = pr.m_Float; - break; - case eType_SHORT: - sp->m_Value.m_Short = pr.m_Short; - break; - case eType_INT: - case eType_TEXTURE_HANDLE: - sp->m_Value.m_Int = pr.m_Int; - break; - - case eType_VECTOR: - sp->m_Value.m_Vector[0] = pr.m_Vector[0]; - sp->m_Value.m_Vector[1] = pr.m_Vector[1]; - sp->m_Value.m_Vector[2] = pr.m_Vector[2]; - break; - - case eType_FCOLOR: - case eType_FCOLORA: - sp->m_Value.m_Color[0] = pr.m_Color[0]; - sp->m_Value.m_Color[1] = pr.m_Color[1]; - sp->m_Value.m_Color[2] = pr.m_Color[2]; - sp->m_Value.m_Color[3] = pr.m_Color[3]; - break; - - case eType_STRING: - { - char* str = pr.m_String; - const size_t len = strlen(str) + 1; - sp->m_Value.m_String = new char [len]; - azstrcpy(sp->m_Value.m_String, len, str); - } - break; - } - break; - } - } - if (i == Params->size()) - { - return false; - } - return true; - } - static bool GetValue(const char* szName, AZStd::vector* Params, float* v, int nID); - - static bool GetValue(uint8 eSemantic, AZStd::vector* Params, float* v, int nID); - - void CopyValue(const SShaderParam& src) - { - if (m_Type == eType_STRING && this != &src) - { - delete[] m_Value.m_String; - - if (src.m_Type == eType_STRING) - { - size_t size = strlen(src.m_Value.m_String) + 1; - m_Value.m_String = new char[size]; - azstrcpy(m_Value.m_String, size, src.m_Value.m_String); - return; - } - } - - m_Value = src.m_Value; - } - - void CopyValueNoString(const SShaderParam& src) - { - assert(m_Type != eType_STRING && src.m_Type != eType_STRING); - - m_Value = src.m_Value; - } - - void CopyType(const SShaderParam& src) - { - m_Type = src.m_Type; - } }; - -// Summary: -// Vertex modificators definitions (must be 16 bit flag). - -#define MDV_BENDING 0x100 -#define MDV_DET_BENDING 0x200 -#define MDV_DET_BENDING_GRASS 0x400 -#define MDV_WIND 0x800 -#define MDV_DEPTH_OFFSET 0x2000 - -// Does the vertex shader require position-invariant compilation? -// This would be true of shaders rendering multiple times with different vertex shaders - for example during zprepass and the gbuffer pass -// Note this is different than the technique flag FHF_POSITION_INVARIANT as that does custom behavior for terrain -#define MDV_POSITION_INVARIANT 0x4000 - - -//============================================================================== -// CRenderObject - -////////////////////////////////////////////////////////////////////// -// CRenderObject::m_ObjFlags: Flags used by shader pipeline - -enum ERenderObjectFlags -{ - FOB_VERTEX_VELOCITY = BIT(0), - FOB_RENDER_TRANS_AFTER_DOF = BIT(1), //transparencies rendered after depth of field - //Unused = BIT(2), - FOB_RENDER_AFTER_POSTPROCESSING = BIT(3), - FOB_OWNER_GEOMETRY = BIT(4), - FOB_MESH_SUBSET_INDICES = BIT(5), - FOB_SELECTED = BIT(6), - FOB_RENDERER_IDENDITY_OBJECT = BIT(7), - FOB_GLOBAL_ILLUMINATION = BIT(8), - FOB_NO_FOG = BIT(9), - FOB_DECAL = BIT(10), - FOB_OCTAGONAL = BIT(11), - FOB_POINT_SPRITE = BIT(13), - FOB_SOFT_PARTICLE = BIT(14), - FOB_REQUIRES_RESOLVE = BIT(15), - FOB_UPDATED_RTMASK = BIT(16), - FOB_AFTER_WATER = BIT(17), - FOB_BENDED = BIT(18), - FOB_ZPREPASS = BIT(19), - FOB_PARTICLE_SHADOWS = BIT(20), - FOB_DISSOLVE = BIT(21), - FOB_MOTION_BLUR = BIT(22), - FOB_NEAREST = BIT(23), // [Rendered in Camera Space] - FOB_SKINNED = BIT(24), - FOB_DISSOLVE_OUT = BIT(25), - FOB_DYNAMIC_OBJECT = BIT(26), - FOB_ALLOW_TESSELLATION = BIT(27), - FOB_DECAL_TEXGEN_2D = BIT(28), - FOB_IN_DOORS = BIT(29), - FOB_HAS_PREVMATRIX = BIT(30), - FOB_LIGHTVOLUME = BIT(31), - - FOB_DECAL_MASK = (FOB_DECAL | FOB_DECAL_TEXGEN_2D), - FOB_PARTICLE_MASK = (FOB_SOFT_PARTICLE | FOB_NO_FOG | FOB_GLOBAL_ILLUMINATION | FOB_PARTICLE_SHADOWS | FOB_NEAREST | FOB_MOTION_BLUR | FOB_LIGHTVOLUME | FOB_ALLOW_TESSELLATION | FOB_IN_DOORS | FOB_AFTER_WATER), - - // WARNING: FOB_MASK_AFFECTS_MERGING must start from 0x10000/bit 16 (important for instancing). - FOB_MASK_AFFECTS_MERGING_GEOM = (FOB_ZPREPASS | FOB_SKINNED | FOB_BENDED | FOB_DYNAMIC_OBJECT | FOB_ALLOW_TESSELLATION | FOB_NEAREST), - FOB_MASK_AFFECTS_MERGING = (FOB_ZPREPASS | FOB_MOTION_BLUR | FOB_HAS_PREVMATRIX | FOB_SKINNED | FOB_BENDED | FOB_PARTICLE_SHADOWS | FOB_AFTER_WATER | FOB_DISSOLVE | FOB_DISSOLVE_OUT | FOB_NEAREST | FOB_DYNAMIC_OBJECT | FOB_ALLOW_TESSELLATION) -}; - -struct SSkyInfo -{ - ITexture* m_SkyBox[3]; - float m_fSkyLayerHeight; - - int Size() - { - int nSize = sizeof(SSkyInfo); - return nSize; - } - SSkyInfo() - { - memset(this, 0, sizeof(SSkyInfo)); - } -}; - - -// Description: -// Interface for the skinnable objects (renderer calls its functions to get the skinning data). -// should only created by EF_CreateSkinningData -struct alignas(16) SSkinningData -{ - uint32 nNumBones; - uint32 nHWSkinningFlags; - DualQuat* pBoneQuatsS; - Matrix34* pBoneMatrices; - JointIdType* pRemapTable; - AZ::LegacyJobExecutor* pAsyncJobExecutor; - AZ::LegacyJobExecutor* pAsyncDataJobExecutor; - SSkinningData* pPreviousSkinningRenderData; // used for motion blur - uint32 remapGUID; - void* pCharInstCB; // used if per char instance cbs are available in renderdll (d3d11+); - // members below are for Software Skinning - void* pCustomData; // client specific data, used for example for sw-skinning on animation side - SSkinningData* pNextSkinningData; // List to the next element which needs SW-Skinning - [[maybe_unused]] int m_padding[2]; // padding to avoid MSVC warning 4324 -}; - -struct alignas(16) SRenderObjData -{ - uintptr_t m_uniqueObjectId; - - SSkinningData* m_pSkinningData; - - float m_fTempVars[10]; // Different useful vars (ObjVal component in shaders) - - // using a pointer, the client code has to ensure that the data stays valid - const AZStd::vector* m_pShaderParams; - - uint32 m_nHUDSilhouetteParams; - - uint64 m_nSubObjHideMask; - - - uint16 m_FogVolumeContribIdx[2]; - - uint16 m_nLightID; - uint16 m_LightVolumeId; - - uint8 m_screenBounds[4]; - - uint16 m_nCustomFlags; - uint8 m_nCustomData; - - SRenderObjData() - { - Init(); - } - - void Init() - { - m_nSubObjHideMask = 0; - m_uniqueObjectId = 0; - m_nLightID = 0; - m_LightVolumeId = 0; - m_pSkinningData = NULL; - m_screenBounds[0] = m_screenBounds[1] = m_screenBounds[2] = m_screenBounds[3] = 0; - m_nCustomData = 0; - m_nCustomFlags = 0; - m_nHUDSilhouetteParams = 0; - - m_pShaderParams = nullptr; - m_FogVolumeContribIdx[0] = m_FogVolumeContribIdx[1] = static_cast(-1); - - // The following should be changed to be something like 0xac to indicate invalid data so that by default - // data that was not set will break render features and will be traced (otherwise, default 0 just might pass) - memset(m_fTempVars, 0, 10 * sizeof(float)); - } - - void SetShaderParams(const AZStd::vector* pShaderParams) - { - m_pShaderParams = pShaderParams; - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - AZ_UNUSED(pSizer); - } -}; - -////////////////////////////////////////////////////////////////////// -// Objects using in shader pipeline - - -// Summary: -// Same as in the 3dEngine. -#define MAX_LIGHTS_NUM 32 - -struct ShadowMapFrustum; - -////////////////////////////////////////////////////////////////////// -/// -/// Objects using in shader pipeline -/// Single rendering item, that can be created from 3DEngine and persist across multiple frames -/// It can be compiled into the platform specific efficient rendering compiled object. -/// -////////////////////////////////////////////////////////////////////// -class alignas(16) CRenderObject -{ -public: - AZ_CLASS_ALLOCATOR(CRenderObject, AZ::LegacyAllocator, 0); - - struct SInstanceInfo - { - Matrix34 m_Matrix; - ColorF m_AmbColor; - }; - - struct SInstanceData - { - Matrix34 m_MatInst; - Vec4 m_vBendInfo; - Vec4 m_vDissolveInfo; - }; - - struct PerInstanceConstantBufferKey - { - PerInstanceConstantBufferKey() - : m_Id{0xFFFF} - , m_IndirectId{0xFF} - {} - - bool IsValid() const - { - return m_Id != 0xFFFF; - } - - AZ::u16 m_Id; - AZ::u8 m_IndirectId; - }; - - ////////////////////////////////////////////////////////////////////////// - SInstanceInfo m_II; //!< Per instance data - - uint64 m_ObjFlags; //!< Combination of FOB_ flags. - uint32 m_Id; - - float m_fAlpha; //!< Object alpha. - float m_fDistance; //!< Distance to the object. - - union - { - float m_fSort; //!< Custom sort value. - uint16 m_nSort; - }; - - uint64 m_nRTMask; //!< Shader runtime modification flags - uint16 m_nMDV; //!< Vertex modifier flags for Shader. - uint16 m_nRenderQuality; //!< 65535 - full quality, 0 - lowest quality, used by CStatObj - int16 m_nTextureID; //!< Custom texture id. - - union - { - uint8 m_breakableGlassSubFragIndex; - uint8 m_ParticleObjFlags; - }; - uint8 m_nClipVolumeStencilRef; //!< Per instance vis area stencil reference ID - uint8 m_DissolveRef; //!< Dissolve value - uint8 m_RState; //!< Render state used for object - - bool m_NoDecalReceiver; - - uint32 m_nMaterialLayers; //!< Which mtl layers active and how much to blend them - - - _smart_ptr m_pCurrMaterial; //!< Parent material used for render object. - - - PerInstanceConstantBufferKey m_PerInstanceConstantBufferKey; - - [[maybe_unused]] int m_padding[1]; // padding to avoid MSVC warning 4324 - - //! Embedded SRenderObjData, optional data carried by CRenderObject - SRenderObjData m_data; - -public: - - ////////////////////////////////////////////////////////////////////////// - // Methods - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - /// Constructor - ////////////////////////////////////////////////////////////////////////// - CRenderObject() - : m_Id(~0u) - { - Init(); - } - ~CRenderObject() {} - - //========================================================================================================= - - Vec3 GetTranslation() const { return m_II.m_Matrix.GetTranslation(); } - float GetScaleX() const { return sqrt_tpl(m_II.m_Matrix(0, 0) * m_II.m_Matrix(0, 0) + m_II.m_Matrix(0, 1) * m_II.m_Matrix(0, 1) + m_II.m_Matrix(0, 2) * m_II.m_Matrix(0, 2)); } - float GetScaleZ() const { return sqrt_tpl(m_II.m_Matrix(2, 0) * m_II.m_Matrix(2, 0) + m_II.m_Matrix(2, 1) * m_II.m_Matrix(2, 1) + m_II.m_Matrix(2, 2) * m_II.m_Matrix(2, 2)); } - - void Init() - { - m_ObjFlags = 0; - m_nRenderQuality = 65535; - - m_RState = 0; - m_fDistance = 0.0f; - - m_nClipVolumeStencilRef = 0; - m_nMaterialLayers = 0; - m_DissolveRef = 0; - - m_nMDV = 0; - m_fSort = 0; - - m_II.m_AmbColor = Col_White; - m_fAlpha = 1.0f; - m_nTextureID = -1; - m_pCurrMaterial = nullptr; - - m_PerInstanceConstantBufferKey = {}; - - m_nRTMask = 0; - - - m_NoDecalReceiver = false; - m_data.Init(); - } - void AssignId(uint32 id) { m_Id = id; } - - ILINE Matrix34A& GetMatrix() { return m_II.m_Matrix; } - - -protected: - - // Disallow copy (potential bugs with PERMANENT objects) - // alwasy use IRendeer::EF_DuplicateRO if you want a copy - // of a CRenderObject - CRenderObject& operator= (CRenderObject& other) = default; - - void CloneObject(CRenderObject* srcObj) - { - *this = *srcObj; - } - - friend class CRenderer; -}; - -enum EResClassName -{ - eRCN_Texture, - eRCN_Shader, -}; - -// className: CTexture, CHWShader_VS, CHWShader_PS, CShader -struct SResourceAsync -{ - AZ_CLASS_ALLOCATOR(SResourceAsync, AZ::SystemAllocator, 0); - int nReady; // 0: Not ready; 1: Ready; -1: Error - int8* pData; - EResClassName eClassName; // Resource class name - char* Name; // Resource name - union - { - // CTexture parameters - struct - { - int nWidth, nHeight, nMips, nTexFlags, nFormat, nTexId; - }; - // CShader parameters - struct - { - int nShaderFlags; - }; - }; - void* pResource; // Pointer to created resource - - SResourceAsync() - { - memset(this, 0, sizeof(SResourceAsync)); - } - - ~SResourceAsync() - { - delete Name; - } -}; - -#include "IRenderer.h" - -//============================================================================== - -// Summary: -// Color operations flags. -enum EColorOp -{ - eCO_NOSET = 0, - eCO_DISABLE = 1, - eCO_REPLACE = 2, - eCO_DECAL = 3, - eCO_ARG2 = 4, - eCO_MODULATE = 5, - eCO_MODULATE2X = 6, - eCO_MODULATE4X = 7, - eCO_BLENDDIFFUSEALPHA = 8, - eCO_BLENDTEXTUREALPHA = 9, - eCO_DETAIL = 10, - eCO_ADD = 11, - eCO_ADDSIGNED = 12, - eCO_ADDSIGNED2X = 13, - eCO_MULTIPLYADD = 14, - eCO_BUMPENVMAP = 15, - eCO_BLEND = 16, - eCO_MODULATEALPHA_ADDCOLOR = 17, - eCO_MODULATECOLOR_ADDALPHA = 18, - eCO_MODULATEINVALPHA_ADDCOLOR = 19, - eCO_MODULATEINVCOLOR_ADDALPHA = 20, - eCO_DOTPRODUCT3 = 21, - eCO_LERP = 22, - eCO_SUBTRACT = 23, - eCO_MODULATE_METAL_FONT_SPECIAL_MODE = 24, -}; - -enum EColorArg -{ - eCA_Unknown, - eCA_Specular, - eCA_Texture, - eCA_Texture1, - eCA_Normal, - eCA_Diffuse, - eCA_Previous, - eCA_Constant, -}; - -#define DEF_TEXARG0 (eCA_Texture | (eCA_Diffuse << 3)) -#define DEF_TEXARG1 (eCA_Texture | (eCA_Previous << 3)) - -enum ETexModRotateType -{ - ETMR_NoChange, - ETMR_Fixed, - ETMR_Constant, - ETMR_Oscillated, - ETMR_Max -}; - -enum ETexModMoveType -{ - ETMM_NoChange, - ETMM_Fixed, - ETMM_Constant, - ETMM_Jitter, - ETMM_Pan, - ETMM_Stretch, - ETMM_StretchRepeat, - ETMM_Max -}; - -enum ETexGenType -{ - ETG_Stream, - ETG_World, - ETG_Camera, - ETG_Max -}; - - - - -////////////////////////////////////////////////////////////////////// -#define FILTER_NONE -1 -#define FILTER_POINT 0 -#define FILTER_LINEAR 1 -#define FILTER_BILINEAR 2 -#define FILTER_TRILINEAR 3 -#define FILTER_ANISO2X 4 -#define FILTER_ANISO4X 5 -#define FILTER_ANISO8X 6 -#define FILTER_ANISO16X 7 - -////////////////////////////////////////////////////////////////////// -#define TADDR_WRAP 0 -#define TADDR_CLAMP 1 -#define TADDR_MIRROR 2 -#define TADDR_BORDER 3 - - -struct IRenderTarget -{ - virtual ~IRenderTarget(){} - virtual void Release() = 0; - virtual void AddRef() = 0; -}; - - struct IRenderShaderResources { - // - virtual void AddRef() = 0; virtual void UpdateConstants(IShader* pSH) = 0; - virtual void CloneConstants(const IRenderShaderResources* pSrc) = 0; - virtual bool HasLMConstants() const = 0; - // properties - - virtual ColorF GetColorValue(EEfResTextures slot) const = 0; virtual void SetColorValue(EEfResTextures slot, const ColorF& color) = 0; - - virtual float GetStrengthValue(EEfResTextures slot) const = 0; virtual void SetStrengthValue(EEfResTextures slot, float value) = 0; - - // configs - virtual const float& GetAlphaRef() const = 0; - virtual void SetAlphaRef(float v) = 0; - - virtual int GetResFlags() = 0; - virtual void SetMtlLayerNoDrawFlags(uint8 nFlags) = 0; - virtual uint8 GetMtlLayerNoDrawFlags() const = 0; - virtual SSkyInfo* GetSkyInfo() = 0; - virtual void SetMaterialName(const char* szName) = 0; - - virtual AZStd::vector& GetParameters() = 0; - - virtual ColorF GetFinalEmittance() = 0; - virtual float GetVoxelCoverage() = 0; - - virtual ~IRenderShaderResources() {} - virtual void Release() = 0; - virtual void ConvertToInputResource(struct SInputShaderResources* pDst) = 0; - virtual IRenderShaderResources* Clone() const = 0; - virtual void SetShaderParams(struct SInputShaderResources* pDst, IShader* pSH) = 0; - - virtual size_t GetResourceMemoryUsage(ICrySizer* pSizer) = 0; - - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - // - - bool IsEmissive() const - { - // worst: *reinterpret_cast(&) > 0x00000000 - // causes value to pass from FPU to CPU registers - return GetStrengthValue(EFTT_EMITTANCE) > 0.0f; - } - - bool IsTransparent() const - { - // worst: *reinterpret_cast(&) < 0x3f800000 - // causes value to pass from FPU to CPU registers - return GetStrengthValue(EFTT_OPACITY) < 1.0f; - } - - bool IsAlphaTested() const - { - return GetAlphaRef() > 0.0f; - } - - bool IsInvisible() const - { - const float o = GetStrengthValue(EFTT_OPACITY); - const float a = GetAlphaRef(); - - return o == 0.0f || a == 1.0f || o <= a; - } -}; - - -//=================================================================================== -// Shader gen structure (used for automatic shader script generating). - -// -#define SHGF_HIDDEN 1 -#define SHGF_PRECACHE 2 -#define SHGF_AUTO_PRECACHE 4 -#define SHGF_LOWSPEC_AUTO_PRECACHE 8 -#define SHGF_RUNTIME 0x10 - -#define SHGD_LM_DIFFUSE 0x1 -#define SHGD_TEX_DETAIL 0x2 -#define SHGD_TEX_NORMALS 0x4 -#define SHGD_TEX_ENVCM 0x8 -#define SHGD_TEX_SPECULAR 0x10 -#define SHGD_TEX_SECOND_SMOOTHNESS 0x20 -#define SHGD_TEX_HEIGHT 0x40 -#define SHGD_TEX_SUBSURFACE 0x80 -#define SHGD_HW_BILINEARFP16 0x100 -#define SHGD_HW_SEPARATEFP16 0x200 -#define SHGD_HW_ORBIS 0x800 -#define SHGD_TEX_CUSTOM 0x1000 -#define SHGD_TEX_CUSTOM_SECONDARY 0x2000 -#define SHGD_TEX_DECAL 0x4000 -#define SHGD_TEX_OCC 0x8000 -#define SHGD_TEX_SPECULAR_2 0x10000 -#define SHGD_HW_GLES3 0x20000 -#define SHGD_USER_ENABLED 0x40000 -#define SHGD_HW_SAA 0x80000 -#define SHGD_TEX_EMITTANCE 0x100000 -#define SHGD_HW_DX10 0x200000 -#define SHGD_HW_DX11 0x400000 -#define SHGD_HW_GL4 0x800000 -#define SHGD_HW_WATER_TESSELLATION 0x1000000 -#define SHGD_HW_SILHOUETTE_POM 0x2000000 -// Confetti Nicholas Baldwin: adding metal shader language support -#define SHGD_HW_METAL 0x4000000 -#define SHGD_TEX_MASK ( SHGD_TEX_DETAIL | SHGD_TEX_NORMALS | SHGD_TEX_ENVCM | SHGD_TEX_SPECULAR | SHGD_TEX_SECOND_SMOOTHNESS | \ - SHGD_TEX_HEIGHT | SHGD_TEX_SUBSURFACE | SHGD_TEX_CUSTOM | SHGD_TEX_CUSTOM_SECONDARY | SHGD_TEX_DECAL | \ - SHGD_TEX_OCC | SHGD_TEX_SPECULAR_2 | SHGD_TEX_EMITTANCE) - - -//=================================================================================== - -enum EShaderType -{ - eST_All = -1, // To set all with one call. - - eST_General = 0, - eST_Metal, - eST_Glass, - eST_Ice, - eST_Shadow, - eST_Water, - eST_FX, - eST_PostProcess, - eST_HDR, - eST_Sky, - eST_Compute, - eST_Max // To define array size. -}; - -enum EShaderDrawType -{ - eSHDT_General, - eSHDT_Light, - eSHDT_Shadow, - eSHDT_Terrain, - eSHDT_Overlay, - eSHDT_OceanShore, - eSHDT_Fur, - eSHDT_NoDraw, - eSHDT_CustomDraw, - eSHDT_Sky, - eSHDT_Volume -}; - -enum EShaderQuality -{ - eSQ_Low = 0, - eSQ_Medium = 1, - eSQ_High = 2, - eSQ_VeryHigh = 3, - eSQ_Max = 4 -}; - -enum ERenderQuality -{ - eRQ_Low = 0, - eRQ_Medium = 1, - eRQ_High = 2, - eRQ_VeryHigh = 3, - eRQ_Max = 4 -}; - - -//==================================================================================== -// Phys. material flags - -#define MATF_NOCLIP 1 - -//==================================================================================== -// Registered shader techniques ID's - -enum EShaderTechniqueID -{ - TTYPE_GENERAL = -1, - TTYPE_Z = 0, - TTYPE_SHADOWGEN, - TTYPE_GLOWPASS, - TTYPE_MOTIONBLURPASS, - TTYPE_CUSTOMRENDERPASS, - TTYPE_EFFECTLAYER, - TTYPE_SOFTALPHATESTPASS, - TTYPE_WATERREFLPASS, - TTYPE_WATERCAUSTICPASS, - TTYPE_ZPREPASS, - TTYPE_PARTICLESTHICKNESSPASS, - - // PC specific techniques must go after this point, to support shader serializing - // TTYPE_CONSOLE_MAX must equal TTYPE_MAX for console - TTYPE_CONSOLE_MAX, - TTYPE_DEBUG = TTYPE_CONSOLE_MAX, - - TTYPE_MAX -}; - - -//================================================================ -// Different preprocess flags for shaders that require preprocessing (like recursive render to texture, screen effects, visibility check, ...) -// SShader->m_nPreprocess flags in priority order - -#define SPRID_FIRST 25 -#define SPRID_SCANTEXWATER 26 -#define FSPR_SCANTEXWATER (1 << SPRID_SCANTEXWATER) -#define SPRID_SCANTEX 27 -#define FSPR_SCANTEX (1 << SPRID_SCANTEX) -#define SPRID_SCANLCM 28 -#define FSPR_SCANLCM (1 << SPRID_SCANLCM) -#define SPRID_GENSPRITES_DEPRECATED 29 -#define FSPR_GENSPRITES_DEPRECATED (1 << SPRID_GENSPRITES_DEPRECATED) -#define SPRID_CUSTOMTEXTURE 30 -#define FSPR_CUSTOMTEXTURE (1 << SPRID_CUSTOMTEXTURE) -#define SPRID_GENCLOUDS 31 -#define FSPR_GENCLOUDS (1 << SPRID_GENCLOUDS) - -#define FSPR_MASK 0xfff00000 -#define FSPR_MAX (1 << 31) - -#define FEF_DONTSETTEXTURES 1 // Set: explicit setting of samplers (e.g. tex->Apply(1,nTexStatePoint)), not set: set sampler by sematics (e.g. $ZTarget). -#define FEF_DONTSETSTATES 2 - -// SShader::m_Flags -// Different useful flags -#define EF_RELOAD 1 // Shader needs tangent vectors array. -#define EF_FORCE_RELOAD 2 -#define EF_RELOADED 4 -#define EF_NODRAW 8 -#define EF_HASCULL 0x10 -#define EF_SUPPORTSDEFERREDSHADING_MIXED 0x20 -#define EF_SUPPORTSDEFERREDSHADING_FULL 0x40 -#define EF_SUPPORTSDEFERREDSHADING (EF_SUPPORTSDEFERREDSHADING_MIXED | EF_SUPPORTSDEFERREDSHADING_FULL) -#define EF_DECAL 0x80 -#define EF_LOADED 0x100 -#define EF_LOCALCONSTANTS 0x200 -#define EF_BUILD_TREE 0x400 -#define EF_LIGHTSTYLE 0x800 -#define EF_NOCHUNKMERGING 0x1000 -#define EF_SUNFLARES 0x2000 -#define EF_NEEDNORMALS 0x4000 // Need normals operations. -#define EF_OFFSETBUMP 0x8000 -#define EF_NOTFOUND 0x10000 -#define EF_DEFAULT 0x20000 -#define EF_SKY 0x40000 -#define EF_USELIGHTS 0x80000 -#define EF_ALLOW3DC 0x100000 -#define EF_FOGSHADER 0x200000 -#define EF_FAILED_IMPORT 0x400000 // Currently just for debug, can be removed if necessary -#define EF_PRECACHESHADER 0x800000 -#define EF_FORCEREFRACTIONUPDATE 0x1000000 -#define EF_SUPPORTSINSTANCING_CONST 0x2000000 -#define EF_SUPPORTSINSTANCING_ATTR 0x4000000 -#define EF_SUPPORTSINSTANCING (EF_SUPPORTSINSTANCING_CONST | EF_SUPPORTSINSTANCING_ATTR) -#define EF_WATERPARTICLE 0x8000000 -#define EF_CLIENTEFFECT 0x10000000 -#define EF_SYSTEM 0x20000000 -#define EF_REFRACTIVE 0x40000000 -#define EF_NOPREVIEW 0x80000000 - -#define EF_PARSE_MASK (EF_SUPPORTSINSTANCING | EF_SKY | EF_HASCULL | EF_USELIGHTS | EF_REFRACTIVE) - - -// SShader::Flags2 -// Additional Different useful flags - -#define EF2_PREPR_GENSPRITES_DEPRECATED 0x1 -#define EF2_PREPR_GENCLOUDS 0x2 -#define EF2_PREPR_SCANWATER 0x4 -#define EF2_NOCASTSHADOWS 0x8 -#define EF2_NODRAW 0x10 -#define EF2_HASOPAQUE 0x40 -#define EF2_AFTERHDRPOSTPROCESS 0x80 -#define EF2_DONTSORTBYDIST 0x100 -#define EF2_FORCE_WATERPASS 0x200 -#define EF2_FORCE_GENERALPASS 0x400 -#define EF2_AFTERPOSTPROCESS 0x800 -#define EF2_IGNORERESOURCESTATES 0x1000 -#define EF2_EYE_OVERLAY 0x2000 -#define EF2_FORCE_TRANSPASS 0x4000 -#define EF2_DEFAULTVERTEXFORMAT 0x8000 -#define EF2_FORCE_ZPASS 0x10000 -#define EF2_FORCE_DRAWLAST 0x20000 -#define EF2_FORCE_DRAWAFTERWATER 0x40000 -// free 0x80000 -#define EF2_DEPTH_FIXUP 0x100000 -#define EF2_SINGLELIGHTPASS 0x200000 -#define EF2_FORCE_DRAWFIRST 0x400000 -#define EF2_HAIR 0x800000 -#define EF2_DETAILBUMPMAPPING 0x1000000 -#define EF2_HASALPHATEST 0x2000000 -#define EF2_HASALPHABLEND 0x4000000 -#define EF2_ZPREPASS 0x8000000 -#define EF2_VERTEXCOLORS 0x10000000 -#define EF2_SKINPASS 0x20000000 -#define EF2_HW_TESSELLATION 0x40000000 -#define EF2_ALPHABLENDSHADOWS 0x80000000 - -class CCryNameR; -class CCryNameTSCRC; -struct IShader -{ -public: - // - virtual ~IShader(){} - virtual int GetID() = 0; - virtual int AddRef() = 0; - virtual int Release() = 0; - virtual int ReleaseForce() = 0; - - virtual const char* GetName() = 0; - virtual const char* GetName() const = 0; - virtual int GetFlags() const = 0; - virtual int GetFlags2() const = 0; - virtual void SetFlags2(int Flags) = 0; - virtual void ClearFlags2(int Flags) = 0; - virtual bool Reload(int nFlags, const char* szShaderName) = 0; - - virtual int GetTexId () = 0; - - virtual ECull GetCull(void) = 0; - virtual int Size(int Flags) = 0; - - virtual int GetTechniqueID(int nTechnique, int nRegisteredTechnique) = 0; - virtual AZ::Vertex::Format GetVertexFormat(void) = 0; - - - virtual EShaderType GetShaderType() = 0; - virtual EShaderDrawType GetShaderDrawType() const = 0; - virtual uint32 GetVertexModificator() = 0; - - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - // - - static uint32 GetTextureSlot(EEfResTextures textureType) { return (uint32)textureType; } }; struct SShaderItem @@ -1203,72 +91,11 @@ struct SShaderItem int32 m_nTechnique; uint32 m_nPreprocessFlags; - SShaderItem() - { - m_pShader = NULL; - m_pShaderResources = NULL; - m_nTechnique = -1; - m_nPreprocessFlags = 1; - } - SShaderItem(IShader* pSH) - { - m_pShader = pSH; - m_pShaderResources = NULL; - m_nTechnique = -1; - m_nPreprocessFlags = 1; - } - SShaderItem(IShader* pSH, IRenderShaderResources* pRS) - { - m_pShader = pSH; - m_pShaderResources = pRS; - m_nTechnique = -1; - m_nPreprocessFlags = 1; - } - SShaderItem(IShader* pSH, IRenderShaderResources* pRS, int nTechnique) - { - m_pShader = pSH; - m_pShaderResources = pRS; - m_nTechnique = nTechnique; - m_nPreprocessFlags = 1; - } - - uint32 PostLoad(); bool Update(); bool RefreshResourceConstants(); - // Note: - // If you change this function please check bTransparent variable in CRenderMesh::Render(). - // See also: - // CRenderMesh::Render() - bool IsZWrite() const - { - IShader* pSH = m_pShader; - if (pSH->GetFlags() & (EF_NODRAW | EF_DECAL)) - { - return false; - } - if (pSH->GetFlags2() & EF2_FORCE_ZPASS) - { - return true; - } - if (m_pShaderResources && m_pShaderResources->IsTransparent()) - { - return false; - } - return true; - } inline struct SShaderTechnique* GetTechnique() const; - bool IsMergable(SShaderItem& PrevSI); - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(m_pShader); - pSizer->AddObject(m_pShaderResources); - } }; - -#include // <> required for Interfuscator - struct IAnimNode; struct ILightAnimWrapper @@ -1289,30 +116,3 @@ protected: IAnimNode* m_pNode; }; - -#define MAX_RECURSION_LEVELS 2 - -#define DECAL_HAS_NORMAL_MAP (1 << 0) -#define DECAL_STATIC (1 << 1) -#define DECAL_HAS_SPECULAR_MAP (1 << 2) - - -// Summary: -// Runtime shader flags for HW skinning. -enum EHWSkinningRuntimeFlags -{ - eHWS_MotionBlured = 0x04, - eHWS_Skinning_DQ_Linear = 0x08, // Convert dual-quaternions to matrices on the GPU - eHWS_Skinning_Matrix = 0x10, // Pass float3x4 skinning matrices directly to the GPU -}; - -// Enum of data types that can be used as bones on GPU for skinning -enum EBoneTypes -{ - eBoneType_DualQuat = 0, - eBoneType_Matrix, - eBoneType_Count, -}; - - -#include diff --git a/Code/Legacy/CryCommon/ISplines.h b/Code/Legacy/CryCommon/ISplines.h index ff67ae0d56..a1c5c674b0 100644 --- a/Code/Legacy/CryCommon/ISplines.h +++ b/Code/Legacy/CryCommon/ISplines.h @@ -12,6 +12,7 @@ #pragma once #include +#include ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/IStatObj.h b/Code/Legacy/CryCommon/IStatObj.h index a268f40406..b2cde275c5 100644 --- a/Code/Legacy/CryCommon/IStatObj.h +++ b/Code/Legacy/CryCommon/IStatObj.h @@ -11,7 +11,6 @@ #include "smartptr.h" // TYPEDEF_AUTOPTR #include "IMaterial.h" -#include "ISerialize.h" // forward declarations ////////////////////////////////////////////////////////////////////// @@ -35,15 +34,12 @@ struct phys_geometry; struct IChunkFile; // General forward declaration. -class CRenderObject; struct SMeshLodInfo; -#include "CryHeaders.h" #include "Cry_Color.h" #include "Cry_Math.h" #include "Cry_Geo.h" #include "CrySizer.h" -#include "stridedptr.h" #define MAX_STATOBJ_LODS_NUM 6 @@ -150,70 +146,6 @@ enum EFileStreamingStatus ecss_Ready }; -// Interface for streaming of objects like CStatObj. -struct IStreamable -{ - struct SInstancePriorityInfo - { - int nRoundId; - float fMaxImportance; - }; - - IStreamable() - { - ZeroStruct(m_arrUpdateStreamingPrioriryRoundInfo); - m_eStreamingStatus = ecss_NotLoaded; - fCurImportance = 0; - m_nSelectedFrameId = 0; - m_nStatsInUse = 0; - } - - bool UpdateStreamingPrioriryLowLevel(float fImportance, int nRoundId, bool bFullUpdate) - { - bool bRegister = false; - - if (m_arrUpdateStreamingPrioriryRoundInfo[0].nRoundId != nRoundId) - { - if (!m_arrUpdateStreamingPrioriryRoundInfo[0].nRoundId) - { - bRegister = true; - } - - m_arrUpdateStreamingPrioriryRoundInfo[1] = m_arrUpdateStreamingPrioriryRoundInfo[0]; - - m_arrUpdateStreamingPrioriryRoundInfo[0].nRoundId = nRoundId; - m_arrUpdateStreamingPrioriryRoundInfo[0].fMaxImportance = fImportance; - } - else - { - m_arrUpdateStreamingPrioriryRoundInfo[0].fMaxImportance = max(m_arrUpdateStreamingPrioriryRoundInfo[0].fMaxImportance, fImportance); - } - - if (bFullUpdate) - { - m_arrUpdateStreamingPrioriryRoundInfo[1] = m_arrUpdateStreamingPrioriryRoundInfo[0]; - m_arrUpdateStreamingPrioriryRoundInfo[1].nRoundId--; - } - - return bRegister; - } - - // - virtual ~IStreamable(){} - virtual void StartStreaming(bool bFinishNow, IReadStream_AutoPtr* ppStream) = 0; - virtual int GetStreamableContentMemoryUsage(bool bJustForDebug = false) = 0; - virtual void ReleaseStreamableContent() = 0; - virtual void GetStreamableName(AZStd::string& sName) = 0; - virtual uint32 GetLastDrawMainFrameId() = 0; - virtual bool IsUnloadable() const = 0; - - SInstancePriorityInfo m_arrUpdateStreamingPrioriryRoundInfo[2]; - float fCurImportance; - EFileStreamingStatus m_eStreamingStatus; - uint32 m_nSelectedFrameId : 31; - uint32 m_nStatsInUse : 1; -}; - struct SMeshBoneMapping_uint8; struct SSpine; struct SMeshColor; @@ -221,7 +153,6 @@ struct SMeshColor; // Summary: // Interface to hold static object data struct IStatObj - : public IStreamable { //! Loading flags enum ELoadingFlags @@ -262,50 +193,6 @@ struct IStatObj }; ////////////////////////////////////////////////////////////////////////// - // Statistics information about this object. - struct SStatistics - { - int nVertices; - int nVerticesPerLod[MAX_STATOBJ_LODS_NUM]; - int nIndices; - int nIndicesPerLod[MAX_STATOBJ_LODS_NUM]; - int nMeshSize; - int nMeshSizeLoaded; - int nPhysProxySize; - int nPhysProxySizeMax; - int nPhysPrimitives; - int nDrawCalls; - int nLods; - int nSubMeshCount; - int nNumRefs; - bool bSplitLods; // Lods split between files. - - // Optional texture sizer. - ICrySizer* pTextureSizer; - ICrySizer* pTextureSizer2; - - SStatistics() { Reset(); } - - void Reset() - { - pTextureSizer = NULL; - pTextureSizer2 = NULL; - nVertices = 0; - nIndices = 0; - nMeshSize = 0; - nMeshSizeLoaded = 0; - nNumRefs = 0; - nPhysProxySize = 0; - nPhysPrimitives = 0; - nDrawCalls = 0; - nLods = 0; - nSubMeshCount = 0; - bSplitLods = false; - ZeroStruct(nVerticesPerLod); - ZeroStruct(nIndicesPerLod); - } - }; - // // Description: // Increase the reference count of the object. @@ -337,10 +224,6 @@ struct IStatObj // Retrieves the internal flag m_nVehicleOnlyPhysics. virtual unsigned int GetVehicleOnlyPhysics() = 0; - // Description: - // Retrieves the internal flag m_nIdMaterialBreakable. - virtual int GetIDMatBreakable() = 0; - // Description: // Retrieves the internal flag m_bBreakableByGame. virtual unsigned int GetBreakableByGame() = 0; @@ -364,34 +247,6 @@ struct IStatObj //! Access to rendering geometry for indoor engine ( optimized vert arrays, lists of shader pointers ) virtual struct IRenderMesh* GetRenderMesh() = 0; - // Description: - // Returns the physical representation of the object. - // Arguments: - // nType - one of PHYS_GEOM_TYPE_'s, or an explicit slot index - // Return Value: - // A pointer to a phys_geometry structure. - // Summary: - // Get the physic representation - virtual phys_geometry* GetPhysGeom(int nType = PHYS_GEOM_TYPE_DEFAULT) = 0; - - // Description: - // Updates rendermesh's vertices, normals, and tangents with the data provided - // Summary: - // Updates vertices in the range [iVtx0..iVtx0+nVtx-1], vertices are in their original order - // (as they are physicalized). Clones the object if necessary to make the modifications - // Return Value: - // modified IStatObj (a clone or this one, if it's already a clone) - virtual IStatObj* UpdateVertices(strided_pointer pVtx, strided_pointer pNormals, int iVtx0, int nVtx, int* pVtxMap = 0, float rscale = 1.f) = 0; - - // Description: - // Skins rendermesh's vertices based on skeleton vertices - // Summary: - // Skins vertices based on mtxSkelToMesh[pSkelVtx[i]] - // Clones the object if necessary to make the modifications - // Return Value: - // modified IStatObj (a clone or this one, if it's already a clone) - virtual IStatObj* SkinVertices(strided_pointer pSkelVtx, const Matrix34& mtxSkelToMesh) = 0; - // Description: // Sets and replaces the physical representation of the object. // Arguments: @@ -431,18 +286,6 @@ struct IStatObj // Get the minimal bounding box component virtual Vec3 GetBoxMax() = 0; - // Return Value: - // A Vec3 object containing the bounding box center. - // Summary: - // Get the center of bounding box - virtual const Vec3 GetVegCenter() = 0; - - // Arguments: - // Minimum bounding box component - // Summary: - // Set the minimum bounding box component - virtual void SetBBoxMin(const Vec3& vBBoxMin) = 0; - // Arguments: // Minimum bounding box component // Summary: @@ -502,17 +345,9 @@ struct IStatObj virtual int FindNearesLoadedLOD(int nLodIn, bool bSearchUp = false) = 0; virtual int FindHighestLOD(int nBias) = 0; - virtual bool LoadCGF(const char* filename, bool bLod, unsigned long nLoadingFlags, const void* pData, const int nDataSize) = 0; - virtual void DisableStreaming() = 0; - virtual void TryMergeSubObjects(bool bFromStreaming) = 0; - virtual bool IsUnloadable() const = 0; - virtual void SetCanUnload(bool value) = 0; - virtual AZStd::string& GetFileName() = 0; virtual const AZStd::string& GetFileName() const = 0; - virtual const AZStd::string& GetCGFNodeName() const = 0; - // Summary: // Returns the filename of the object // Return Value: @@ -527,25 +362,6 @@ struct IStatObj // None virtual void SetFilePath(const char* szFileName) = 0; - // Summary: - // Returns the name of the geometry - // Return Value: - // A null terminated string which contains the name of the geometry - virtual const char* GetGeoName() = 0; - - // Summary: - // Sets the name of the geometry - virtual void SetGeoName(const char* szGeoName) = 0; - - // Summary: - // Compares if another object is the same - // Arguments: - // szFileName - Filename of the object to compare - // szGeomName - Geometry name of the object to compare (optional) - // Return Value: - // A boolean which equals to true in case both object are the same, or false in the opposite case. - virtual bool IsSameObject(const char* szFileName, const char* szGeomName) = 0; - // Description: // Will return the position of the helper named in the argument. The // helper should have been specified during the exporting process of @@ -679,9 +495,6 @@ struct IStatObj // hides all non-physicalized geometry, clones the object if necessary virtual IStatObj* HideFoliage() = 0; - // serializes the StatObj's mesh into a stream - virtual int Serialize(TSerialize ser) = 0; - // Get object properties as loaded from CGF. virtual const char* GetProperties() = 0; @@ -702,9 +515,6 @@ struct IStatObj // Debug Draw this static object. virtual void DebugDraw(const struct SGeometryDebugDrawInfo& info, float fExtrdueScale = 0.01f) = 0; - // Fill statistics about the level. - virtual void GetStatistics(SStatistics& stats) = 0; - // Returns initial hide mask virtual uint64 GetInitialHideMask() = 0; diff --git a/Code/Legacy/CryCommon/IStereoRenderer.h b/Code/Legacy/CryCommon/IStereoRenderer.h deleted file mode 100644 index 63fba6d214..0000000000 --- a/Code/Legacy/CryCommon/IStereoRenderer.h +++ /dev/null @@ -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 - * - */ - - -#ifndef __ISTEREORENDERER_H__ -#define __ISTEREORENDERER_H__ - -#pragma once - -#include "StereoRendererBus.h" - -enum EStereoEye -{ - STEREO_EYE_LEFT = 0, - STEREO_EYE_RIGHT = 1, - STEREO_EYE_COUNT -}; - -enum EStereoDevice -{ - STEREO_DEVICE_NONE = 0, - STEREO_DEVICE_FRAMECOMP = 1, - STEREO_DEVICE_HDMI = 2, - STEREO_DEVICE_DRIVER = 3, //!< Nvidia and AMD drivers. - STEREO_DEVICE_DUALHEAD = 4, - STEREO_DEVICE_COUNT, - - STEREO_DEVICE_DEFAULT = 100 //!< Auto-detect device. -}; - -enum EStereoMode -{ - STEREO_MODE_NO_STEREO = 0, //!< Stereo disabled. - STEREO_MODE_DUAL_RENDERING = 1, - STEREO_MODE_COUNT, -}; - -enum EStereoOutput -{ - STEREO_OUTPUT_STANDARD = 0, - STEREO_OUTPUT_IZ3D = 1, - STEREO_OUTPUT_CHECKERBOARD = 2, - STEREO_OUTPUT_ABOVE_AND_BELOW = 3, - STEREO_OUTPUT_SIDE_BY_SIDE = 4, - STEREO_OUTPUT_LINE_BY_LINE = 5, - STEREO_OUTPUT_ANAGLYPH = 6, - STEREO_OUTPUT_HMD = 7, - STEREO_OUTPUT_COUNT, -}; - -enum EStereoDeviceState -{ - STEREO_DEVSTATE_OK = 0, - STEREO_DEVSTATE_UNSUPPORTED_DEVICE, - STEREO_DEVSTATE_REQ_1080P, - STEREO_DEVSTATE_REQ_FRAMEPACKED, - STEREO_DEVSTATE_BAD_DRIVER, - STEREO_DEVSTATE_REQ_FULLSCREEN -}; - -class IStereoRenderer - : public AZ::StereoRendererRequestBus::Handler -{ -public: - enum EHmdRender - { - eHR_Eyes = 0, - eHR_Latency - }; - - // - virtual ~IStereoRenderer(){} - - virtual EStereoDevice GetDevice() = 0; - virtual EStereoDeviceState GetDeviceState() = 0; - virtual void GetInfo(EStereoDevice* device, EStereoMode* mode, EStereoOutput* output, EStereoDeviceState* state) const = 0; - - virtual bool GetStereoEnabled() = 0; - virtual float GetStereoStrength() = 0; - virtual float GetMaxSeparationScene(bool half = true) = 0; - virtual float GetZeroParallaxPlaneDist() = 0; - - virtual void OnHmdDeviceChanged() = 0; - - virtual void OnResolutionChanged() {} - - virtual void GetNVControlValues(bool& stereoEnabled, float& stereoStrength) = 0; - // - - enum class Status - { - kRenderingFirstEye, - kRenderingSecondEye, - kIdle ///< Not currently rendering to either eye. - }; - - virtual Status GetStatus() const = 0; -}; - -#endif diff --git a/Code/Legacy/CryCommon/ISystem.h b/Code/Legacy/CryCommon/ISystem.h index 6008c4ae32..722e73c774 100644 --- a/Code/Legacy/CryCommon/ISystem.h +++ b/Code/Legacy/CryCommon/ISystem.h @@ -1095,57 +1095,6 @@ struct ISystem using CrySystemNotificationBus = AZ::EBus; }; -#if defined(USE_DISK_PROFILER) - -struct DiskOperationInfo -{ - DiskOperationInfo() - : m_nSeeksCount(0) - , m_nFileOpenCount(0) - , m_nFileReadCount(0) - , m_dOperationSize(0.) - , m_dOperationTime(0.) {} - int m_nSeeksCount; - int m_nFileOpenCount; - int m_nFileReadCount; - double m_dOperationTime; - double m_dOperationSize; - - DiskOperationInfo& operator -= (const DiskOperationInfo& rv) - { - m_nSeeksCount -= rv.m_nSeeksCount; - m_nFileOpenCount -= rv.m_nFileOpenCount; - m_nFileReadCount -= rv.m_nFileReadCount; - m_dOperationSize -= rv.m_dOperationSize; - m_dOperationTime -= rv.m_dOperationTime; - return *this; - } - - DiskOperationInfo& operator += (const DiskOperationInfo& rv) - { - m_nSeeksCount += rv.m_nSeeksCount; - m_nFileOpenCount += rv.m_nFileOpenCount; - m_nFileReadCount += rv.m_nFileReadCount; - m_dOperationSize += rv.m_dOperationSize; - m_dOperationTime += rv.m_dOperationTime; - return *this; - } - - DiskOperationInfo operator - (const DiskOperationInfo& rv) - { - DiskOperationInfo res(*this); - return res -= rv; - } - - DiskOperationInfo operator + (const DiskOperationInfo& rv) - { - DiskOperationInfo res(*this); - return res += rv; - } -}; - -#endif - ////////////////////////////////////////////////////////////////////////// // CrySystem DLL Exports. ////////////////////////////////////////////////////////////////////////// @@ -1365,9 +1314,6 @@ namespace Detail bool IsConstCVar() const { return true; } void SetOnChangeCallback(ConsoleVarFunc pChangeFunc) { (void)pChangeFunc; } uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) { (void)pChangeFunctor; return 0; } - uint64 GetNumberOfOnChangeFunctors() const { return 0; } - const SFunctor& GetOnChangeFunctor([[maybe_unused]] uint64 nFunctorIndex) const { InvalidAccess(); SFunctor* pNull = nullptr; return *pNull; } - bool RemoveOnChangeFunctor([[maybe_unused]] const uint64 nElement) { return true; } ConsoleVarFunc GetOnChangeCallback() const { InvalidAccess(); return NULL; } void GetMemoryUsage([[maybe_unused]] class ICrySizer* pSizer) const {} int GetRealIVal() const { return GetIVal(); } diff --git a/Code/Legacy/CryCommon/ITexture.h b/Code/Legacy/CryCommon/ITexture.h index 170e3b6709..b370005f83 100644 --- a/Code/Legacy/CryCommon/ITexture.h +++ b/Code/Legacy/CryCommon/ITexture.h @@ -5,60 +5,12 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - - -#ifndef CRYINCLUDE_CRYCOMMON_ITEXTURE_H -#define CRYINCLUDE_CRYCOMMON_ITEXTURE_H #pragma once -#include - -#include "Cry_Math.h" -#include "Cry_Color.h" -#include "Tarray.h" -#include -class CTexture; - -#ifndef COMPILER_SUPPORTS_ENUM_SPECIFICATION -# if defined(_MSC_VER) -# define COMPILER_SUPPORTS_ENUM_SPECIFICATION 1 -# else -# define COMPILER_SUPPORTS_ENUM_SPECIFICATION 0 -# endif -#endif - -#if COMPILER_SUPPORTS_ENUM_SPECIFICATION -enum ETEX_Type : uint8 -#else -typedef uint8 ETEX_Type; -enum eTEX_Type -#endif -{ - eTT_1D = 0, - eTT_2D, - eTT_3D, - eTT_Cube, - eTT_CubeArray, - eTT_Dyn2D, - eTT_User, - eTT_NearestCube, - - eTT_2DArray, - eTT_2DMS, - - eTT_Auto2D, - - eTT_MaxTexType, // not used -}; - +#include // Texture formats -#if COMPILER_SUPPORTS_ENUM_SPECIFICATION -enum ETEX_Format : uint8 -#else -typedef uint8 ETEX_Format; -enum eTEX_Format -#endif +enum ETEX_Format : AZ::u8 { eTF_Unknown = 0, eTF_R8G8B8A8S, @@ -147,277 +99,20 @@ enum eTEX_Format eTF_MaxFormat // unused, must be always the last in the list }; -#if COMPILER_SUPPORTS_ENUM_SPECIFICATION -enum ETEX_TileMode : uint8 -#else -typedef uint8 ETEX_TileMode; -enum eTEX_TileMode -#endif -{ - eTM_None = 0, - eTM_LinearPadded, - eTM_Optimal, -}; - - -enum ETextureFlags -{ - FT_NOMIPS = 0x00000001, - FT_TEX_NORMAL_MAP = 0x00000002, - FT_TEX_WAS_NOT_PRE_TILED = 0x00000004, - FT_USAGE_DEPTHSTENCIL = 0x00000008, - FT_USAGE_ALLOWREADSRGB = 0x00000010, - FT_FILESINGLE = 0x00000020, // suppress loading of additional files like _DDNDIF (faster, RC can tag the file for that) - FT_TEX_FONT = 0x00000040, - FT_HAS_ATTACHED_ALPHA = 0x00000080, - FT_USAGE_UNORDERED_ACCESS = 0x00000100, - FT_USAGE_READBACK = 0x00000200, - FT_USAGE_MSAA = 0x00000400, - FT_FORCE_MIPS = 0x00000800, - FT_USAGE_RENDERTARGET = 0x00001000, - FT_USAGE_DYNAMIC = 0x00002000, - FT_STAGE_READBACK = 0x00004000, - FT_STAGE_UPLOAD = 0x00008000, - FT_DONT_RELEASE = 0x00010000, - FT_ASYNC_PREPARE = 0x00020000, - FT_DONT_STREAM = 0x00040000, -#if defined(AZ_RESTRICTED_PLATFORM) - #include AZ_RESTRICTED_FILE(ITexture_h) -#endif - -#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED) - #undef AZ_RESTRICTED_SECTION_IMPLEMENTED -#else -#if defined(AZ_PLATFORM_IOS) - FT_USAGE_MEMORYLESS = 0x00080000, //reusing an unused bit for ios -#else - FT_USAGE_PREDICATED_TILING = 0x00080000, //unused -#endif -#endif - FT_FAILED = 0x00100000, - FT_FROMIMAGE = 0x00200000, - FT_STATE_CLAMP = 0x00400000, - FT_USAGE_ATLAS = 0x00800000, - FT_ALPHA = 0x01000000, - FT_REPLICATE_TO_ALL_SIDES = 0x02000000, - FT_KEEP_LOWRES_SYSCOPY = 0x04000000, // keep low res copy in system memory for voxelization on CPU - FT_SPLITTED = 0x08000000, // for split dds files - FT_USE_HTILE = 0x10000000, - FT_IGNORE_PRECACHE = 0x20000000, - FT_COMPOSITE = 0x40000000, - FT_USAGE_UAV_RWTEXTURE = 0x80000000, -}; - struct SDepthTexture; -struct STextureStreamingStats -{ - STextureStreamingStats(bool bComputeTexturesPerFrame) - : bComputeReuquiredTexturesPerFrame(bComputeTexturesPerFrame) - { - nMaxPoolSize = 0; - nCurrentPoolSize = 0; - nStreamedTexturesSize = 0; - nStaticTexturesSize = 0; - nThroughput = 0; - nNumTexturesPerFrame = 0; - nRequiredStreamedTexturesSize = 0; - nRequiredStreamedTexturesCount = 0; - bPoolOverflow = false; - bPoolOverflowTotally = false; - fPoolFragmentation = 0.0f; - } - size_t nMaxPoolSize; - size_t nCurrentPoolSize; - size_t nStreamedTexturesSize; - size_t nStaticTexturesSize; - uint32 nNumTexturesPerFrame; - size_t nThroughput; - size_t nRequiredStreamedTexturesSize; - uint32 nRequiredStreamedTexturesCount; - float fPoolFragmentation; - uint32 bPoolOverflow : 1; - uint32 bPoolOverflowTotally : 1; - const bool bComputeReuquiredTexturesPerFrame; -}; - - ////////////////////////////////////////////////////////////////////// // Texture object interface -class CDeviceTexture; class ITexture { protected: virtual ~ITexture() {} public: - - // virtual int AddRef() = 0; virtual int Release() = 0; virtual int ReleaseForce() = 0; - virtual const ColorF& GetClearColor() const = 0; - virtual const ETEX_Format GetDstFormat() const = 0; - virtual const ETEX_Format GetSrcFormat() const = 0; - virtual const ETEX_Type GetTexType() const = 0; - virtual void ApplyTexture(int nTUnit, int nState = -1) = 0; virtual const char* GetName() const = 0; - virtual const int GetWidth() const = 0; - virtual const int GetHeight() const = 0; - virtual const int GetDepth() const = 0; - virtual const int GetTextureID() const = 0; - virtual const uint32 GetFlags() const = 0; - virtual const int GetNumMips() const = 0; - virtual const int GetRequiredMip() const = 0; - virtual const int GetDeviceDataSize() const = 0; - virtual const int GetDataSize() const = 0; - virtual const ETEX_Type GetTextureType() const = 0; - // Sets the texture type of the texture to be used before the texture is loaded. - // Once the texture is loaded the type from the file will overwrite whatever - // value was set here. - virtual void SetTextureType(ETEX_Type type) = 0; - virtual const bool IsTextureLoaded() const = 0; - virtual void PrecacheAsynchronously(float fMipFactor, int nFlags, int nUpdateId, int nCounter = 1) = 0; - virtual uint8* GetData32(int nSide = 0, int nLevel = 0, uint8* pDst = NULL, ETEX_Format eDstFormat = eTF_R8G8B8A8) = 0; - virtual bool SetFilter(int nFilter) = 0; // FILTER_ flags - virtual void SetClamp(bool bEnable) = 0; // Texture addressing set - virtual float GetAvgBrightness() const = 0; - - virtual int StreamCalculateMipsSigned(float fMipFactor) const = 0; - virtual int GetStreamableMipNumber() const = 0; - virtual int GetStreamableMemoryUsage(int nStartMip) const = 0; - virtual int GetMinLoadedMip() const = 0; - - using StagingHook = AZStd::function; - virtual void Readback(AZ::u32 subresourceIndex, StagingHook callback) = 0; - - virtual bool Reload() = 0; - // Used for debugging/profiling. - virtual const char* GetFormatName() const = 0; - virtual const char* GetTypeName() const = 0; - virtual const bool IsStreamedVirtual() const = 0; - virtual const bool IsShared() const = 0; - virtual const bool IsStreamable() const = 0; - virtual bool IsStreamedIn(const int nMinPrecacheRoundIds[2]) const = 0; - virtual const int GetAccessFrameId() const = 0; - - virtual const ETEX_Format GetTextureDstFormat() const = 0; - virtual const ETEX_Format GetTextureSrcFormat() const = 0; - - virtual bool IsPostponed() const = 0; - virtual const bool IsParticularMipStreamed(float fMipFactor) const = 0; - - // get low res system memory (used for CPU voxelization) - virtual const ColorB* GetLowResSystemCopy([[maybe_unused]] uint16& nWidth, [[maybe_unused]] uint16& nHeight, [[maybe_unused]] int** ppLowResSystemCopyAtlasId) { return 0; } - - // - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const - { - static_assert(eTT_MaxTexType <= 255); - static_assert(eTF_MaxFormat <= 255); - /*LATER*/ - } - - virtual void SetKeepSystemCopy(bool bKeepSystemCopy) = 0; - virtual void UpdateTextureRegion(const uint8_t* data, int nX, int nY, int nZ, int USize, int VSize, int ZSize, ETEX_Format eTFSrc) = 0; - virtual CDeviceTexture* GetDevTexture() const = 0; - -}; - -struct STextureLoadData -{ - void* m_pData; - size_t m_DataSize; - int m_Width; - int m_Height; - ETEX_Format m_Format; - int m_NumMips; - int m_nFlags; - ITexture* m_pTexture; - STextureLoadData() - : m_pData(nullptr) - , m_Width(0) - , m_Height(0) - , m_Format(eTF_Unknown) - , m_NumMips(0) - , m_nFlags(0) - , m_pTexture(nullptr) - { - } - ~STextureLoadData() - { - if (m_pData) - { - CryModuleFree(m_pData); - } - } - - static void* AllocateData(size_t dataSize) - { - return CryModuleMalloc(dataSize); - } -}; -struct ITextureLoadHandler -{ - virtual ~ITextureLoadHandler() {} - virtual bool LoadTextureData(const char* path, STextureLoadData& loadData) = 0; - virtual bool SupportsExtension(const char* ext) const = 0; - virtual void Update() = 0; }; //========================================================================================= - -class IDynTexture -{ -public: - enum - { - fNeedRegenerate = 1ul << 0, - }; - // - virtual ~IDynTexture(){} - virtual void Release() = 0; - virtual void GetSubImageRect(uint32& nX, uint32& nY, uint32& nWidth, uint32& nHeight) = 0; - virtual void GetImageRect(uint32& nX, uint32& nY, uint32& nWidth, uint32& nHeight) = 0; - virtual int GetTextureID() = 0; - virtual void Lock() = 0; - virtual void UnLock() = 0; - virtual int GetWidth() = 0; - virtual int GetHeight() = 0; - virtual bool IsValid() = 0; - virtual uint8 GetFlags() const = 0; - virtual void SetFlags([[maybe_unused]] uint8 flags) {} - virtual bool Update(int nNewWidth, int nNewHeight) = 0; - virtual void Apply(int nTUnit, int nTS = -1) = 0; - virtual bool ClearRT() = 0; - virtual bool SetRT(int nRT, bool bPush, struct SDepthTexture* pDepthSurf, bool bScreenVP = false) = 0; - virtual bool SetRectStates() = 0; - virtual bool RestoreRT(int nRT, bool bPop) = 0; - virtual ITexture* GetTexture() = 0; - virtual void SetUpdateMask() = 0; - virtual void ResetUpdateMask() = 0; - virtual bool IsSecondFrame() = 0; - virtual bool GetImageData32([[maybe_unused]] uint8* pData, [[maybe_unused]] int nDataSize) { return 0; } - // -}; - -// Animating Texture sequence definition -class ITexAnim -{ -public: - virtual ~ITexAnim() {}; - virtual void Release() = 0; - virtual void AddRef() = 0; -}; - -struct AZ_DEPRECATED(STexAnim, "STexAnim has been deprecated and replaced by the abstract interface ITexAnim above and CTexAnim in RenderDLL/Common/Textures/Texture.h. This was done to keep proper ref counting between CryRenderDLL and EditorLib.") {}; - -struct STexComposition -{ - _smart_ptr pTexture; - uint16 nSrcSlice; - uint16 nDstSlice; -}; - -#endif // CRYINCLUDE_CRYCOMMON_ITEXTURE_H diff --git a/Code/Legacy/CryCommon/IViewSystem.h b/Code/Legacy/CryCommon/IViewSystem.h index 583c0982c9..d8514aadf6 100644 --- a/Code/Legacy/CryCommon/IViewSystem.h +++ b/Code/Legacy/CryCommon/IViewSystem.h @@ -9,12 +9,8 @@ // Description : View System interfaces. - -#ifndef CRYINCLUDE_CRYACTION_IVIEWSYSTEM_H -#define CRYINCLUDE_CRYACTION_IVIEWSYSTEM_H #pragma once -#include #include #include @@ -233,7 +229,6 @@ struct IView virtual CCamera& GetCamera() = 0; virtual const CCamera& GetCamera() const = 0; - virtual void Serialize(TSerialize ser) = 0; virtual void PostSerialize() = 0; virtual void SetCurrentParams(SViewParams& params) = 0; virtual const SViewParams* GetCurrentParams() = 0; @@ -281,7 +276,6 @@ struct IViewSystem virtual bool AddListener(IViewSystemListener* pListener) = 0; virtual bool RemoveListener(IViewSystemListener* pListener) = 0; - virtual void Serialize(TSerialize ser) = 0; virtual void PostSerialize() = 0; // Get default distance to near clipping plane. @@ -299,5 +293,3 @@ struct IViewSystem virtual void SetControlAudioListeners(bool const bActive) = 0; virtual void ForceUpdate(float elapsed) = 0; }; - -#endif // CRYINCLUDE_CRYACTION_IVIEWSYSTEM_H diff --git a/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h b/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h index 8d988d0df5..be449bb6ad 100644 --- a/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h +++ b/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Code/Legacy/CryCommon/LyShine/UiBase.h b/Code/Legacy/CryCommon/LyShine/UiBase.h index af6314be2c..5eef06b94e 100644 --- a/Code/Legacy/CryCommon/LyShine/UiBase.h +++ b/Code/Legacy/CryCommon/LyShine/UiBase.h @@ -12,10 +12,12 @@ #include #include #include +#include #include #include #include +#include // This is a workaround for AZCore including WinUser.h which defines DrawText to be DrawTextA #ifdef DrawText @@ -44,7 +46,7 @@ namespace LyShine typedef AZStd::string StringType; // not yet decided if we should use wchar_t or UTF8 //! Used for passing lists of entities - typedef DynArray EntityArray; + typedef AZStd::vector EntityArray; enum class BlendMode { diff --git a/Code/Legacy/CryCommon/MemoryAccess.h b/Code/Legacy/CryCommon/MemoryAccess.h deleted file mode 100644 index 8343c961a8..0000000000 --- a/Code/Legacy/CryCommon/MemoryAccess.h +++ /dev/null @@ -1,567 +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 : Misc mathematical functions - -#pragma once - - -#include - -// Section dictionary -#if defined(AZ_RESTRICTED_PLATFORM) -#undef AZ_RESTRICTED_SECTION -#define MEMORYACCESS_H_SECTION_TRAITS 1 -#define MEMORYACCESS_H_SECTION_CRYPREFETCH 2 -#endif - -// Traits -#if defined(AZ_RESTRICTED_PLATFORM) - #define AZ_RESTRICTED_SECTION MEMORYACCESS_H_SECTION_TRAITS - #include AZ_RESTRICTED_FILE(MemoryAccess_h) -#else -#define MEMORYACCESS_H_TRAIT_USE_LEGACY_PREFETCHLINE 1 -#endif - -#if MEMORYACCESS_H_TRAIT_USE_LEGACY_PREFETCHLINE -#define PrefetchLine(ptr, off) cryPrefetchT0SSE((void*)((UINT_PTR)ptr + off)) -#else -#define PrefetchLine(ptr, off) (void)(0) -#endif -#define ResetLine128(ptr, off) (void)(0) -#define FlushLine128(ptr, off) (void)(0) - - - -//======================================================================================== - -// cryMemcpy flags -#define MC_CPU_TO_GPU 0x10 -#define MC_GPU_TO_CPU 0x20 -#define MC_CPU_TO_CPU 0x40 - -extern int g_CpuFlags; - -// -#define CPUF_SSE 0x01 -#define CPUF_SSE2 0x02 -#define CPUF_3DNOW 0x04 -#define CPUF_MMX 0x08 -#define CPUF_SSE3 0x10 -#define CPUF_F16C 0x20 -#define CPUF_SSE41 0x40 - -#ifdef _CPU_SSE - -#ifdef _CPU_X86 -#include -#endif - -#define _MM_PREFETCH(MemPtr, Hint) _mm_prefetch((MemPtr), (Hint)); -#define _MM_PREFETCH_LOOP(nCount, MemPtr, Hint) { for (int p = 0; p < nCount; p += 64) { _mm_prefetch((const char*)(MemPtr) + p, Hint); } \ -} -#else //_CPU_SSE -#define _MM_PREFETCH(MemPtr, Hint) -#define _MM_PREFETCH_LOOP(nCount, MemPtr, Hint) -#endif //_CPU_SSE - -void cryMemcpy(void* Dst, const void* Src, int Count); -#if defined(LINUX) || defined(APPLE) -// Define this for Mac and Linux since it is used with the pthread sources - #define mymemcpy16 memcpy -#endif - - -//========================================================================================== -// 3DNow! optimizations - -#if defined _CPU_X86 && !defined(LINUX) && !defined(APPLE) -// *************************************************************************** -inline void cryPrecacheSSE(const void* src, int nbytes) -{ - _asm - { - mov esi, src - mov ecx, nbytes - // 64 bytes per pass - shr ecx, 6 - jz endLabel - -loopMemToL1: - prefetchnta 64[ESI] // Prefetch next loop, non-temporal - prefetchnta 96[ESI] - - movq mm1, 0[ESI]// Read in source data - movq mm2, 8[ESI] - movq mm3, 16[ESI] - movq mm4, 24[ESI] - movq mm5, 32[ESI] - movq mm6, 40[ESI] - movq mm7, 48[ESI] - movq mm0, 56[ESI] - - add esi, 64 - dec ecx - jnz loopMemToL1 - - emms - -endLabel: - } -} - - -#endif - - - -ILINE void cryPrefetchT0SSE(const void* src) -{ -#if defined(WIN32) && !defined(WIN64) - _asm - { - mov esi, src - prefetchT0 [ESI] // Prefetch - } -#else - _MM_PREFETCH((char*)src, _MM_HINT_T0); -#endif -} - -//================================================================================= - -// Very optimized memcpy() routine for AMD Athlon and Duron family. -// This code uses any of FOUR different basic copy methods, depending -// on the transfer size. -// NOTE: Since this code uses MOVNTQ (also known as "Non-Temporal MOV" or -// "Streaming Store"), and also uses the software prefetch instructions, -// be sure you're running on Athlon/Duron or other recent CPU before calling! - -#define TINY_BLOCK_COPY 64 // Upper limit for movsd type copy. -// The smallest copy uses the X86 "movsd" instruction, in an optimized -// form which is an "unrolled loop". - -#define IN_CACHE_COPY 64 * 1024 // Upper limit for movq/movq copy w/SW prefetch. -// Next is a copy that uses the MMX registers to copy 8 bytes at a time, -// also using the "unrolled loop" optimization. This code uses -// the software prefetch instruction to get the data into the cache. - -#define UNCACHED_COPY 197 * 1024 // Upper limit for movq/movntq w/SW prefetch. -// For larger blocks, which will spill beyond the cache, it's faster to -// use the Streaming Store instruction MOVNTQ. This write instruction -// bypasses the cache and writes straight to main memory. This code also -// uses the software prefetch instruction to pre-read the data. -// USE 64 * 1024 FOR THIS VALUE IF YOU'RE ALWAYS FILLING A "CLEAN CACHE". - -#define BLOCK_PREFETCH_COPY infinity // No limit for movq/movntq w/block prefetch. -#define CACHEBLOCK 80h // Number of 64-byte blocks (cache lines) for block prefetch. -// For the largest size blocks, a special technique called Block Prefetch -// can be used to accelerate the read operations. Block Prefetch reads -// one address per cache line, for a series of cache lines, in a short loop. -// This is faster than using software prefetch. The technique is great for -// getting maximum read bandwidth, especially in DDR memory systems. - - -#if defined _CPU_X86 && !defined(LINUX) && !defined(APPLE) -// Inline assembly syntax for use with Visual C++ -inline void cryMemcpy(void* Dst, const void* Src, int Count) -{ - if (g_CpuFlags & CPUF_SSE) - { - __asm - { - mov ecx, [Count]; - number of bytes to copy - mov edi, [Dst]; - destination - mov esi, [Src]; - source - mov ebx, ecx; - keep a copy of count - - cld - cmp ecx, TINY_BLOCK_COPY - jb $memcpy_ic_3; - tiny ? skip mmx copy - - cmp ecx, 32 * 1024; - dont align between 32k - 64k because - jbe $memcpy_do_align; - it appears to be slower - cmp ecx, 64*1024 - jbe $memcpy_align_done - $memcpy_do_align : - mov ecx, 8; - a trick thats faster than rep movsb ... - sub ecx, edi; - align destination to qword - and ecx, 111b; - get the low bits - sub ebx, ecx; - update copy count - neg ecx; - set up to jump into the array - add ecx, offset $memcpy_align_done - jmp ecx; - jump to array of movsbs - - align 4 - movsb - movsb - movsb - movsb - movsb - movsb - movsb - movsb - -$memcpy_align_done:; - destination is dword aligned - mov ecx, ebx; - number of bytes left to copy - shr ecx, 6; - get 64 - byte block count - jz $memcpy_ic_2; - finish the last few bytes - - cmp ecx, IN_CACHE_COPY / 64; - too big 4 cache ? use uncached copy - jae $memcpy_uc_test - - // This is small block copy that uses the MMX registers to copy 8 bytes - // at a time. It uses the "unrolled loop" optimization, and also uses - // the software prefetch instruction to get the data into the cache. - align 16 - $memcpy_ic_1 :; - 64 - byte block copies, in - cache copy - - prefetchnta [esi + (200 * 64 / 34 + 192)]; - start reading ahead - - movq mm0, [esi + 0]; - read 64 bits - movq mm1, [esi + 8] - movq [edi + 0], mm0; - write 64 bits - movq [edi + 8], mm1; -note: the normal movq writes the - movq mm2, [esi + 16]; - data to cache; - a cache line will be - movq mm3, [esi + 24]; - allocated as needed, to store the data - movq [edi + 16], mm2 - movq [edi + 24], mm3 - movq mm0, [esi + 32] - movq mm1, [esi + 40] - movq [edi + 32], mm0 - movq [edi + 40], mm1 - movq mm2, [esi + 48] - movq mm3, [esi + 56] - movq [edi + 48], mm2 - movq [edi + 56], mm3 - - add esi, 64; - update source pointer - add edi, 64; - update destination pointer - dec ecx; - count down - jnz $memcpy_ic_1; - last 64 - byte block ? - - $memcpy_ic_2 : - mov ecx, ebx; - has valid low 6 bits of the byte count -$memcpy_ic_3: - shr ecx, 2; - dword count - and ecx, 1111b; - only look at the "remainder" bits - neg ecx; - set up to jump into the array - add ecx, offset $memcpy_last_few - jmp ecx; - jump to array of movsds - -$memcpy_uc_test: - cmp ecx, UNCACHED_COPY / 64; - big enough ? use block prefetch copy - jae $memcpy_bp_1 - - $memcpy_64_test : - or ecx, ecx; - tail end of block prefetch will jump here - jz $memcpy_ic_2; - no more 64 - byte blocks left - - // For larger blocks, which will spill beyond the cache, it's faster to - // use the Streaming Store instruction MOVNTQ. This write instruction - // bypasses the cache and writes straight to main memory. This code also - // uses the software prefetch instruction to pre-read the data. - align 16 -$memcpy_uc_1:; - 64 - byte blocks, uncached copy - - prefetchnta [esi + (200 * 64 / 34 + 192)]; - start reading ahead - - movq mm0, [esi + 0]; - read 64 bits - add edi, 64; - update destination pointer - movq mm1, [esi + 8] - add esi, 64; - update source pointer - movq mm2, [esi - 48] - movntq [edi - 64], mm0; - write 64 bits, bypassing the cache - movq mm0, [esi - 40]; -note: movntq also prevents the CPU - movntq [edi - 56], mm1; - from READING the destination address - movq mm1, [esi - 32]; - into the cache, only to be over - written - movntq [edi - 48], mm2; - so that also helps performance - movq mm2, [esi - 24] - movntq [edi - 40], mm0 - movq mm0, [esi - 16] - movntq [edi - 32], mm1 - movq mm1, [esi - 8] - movntq [edi - 24], mm2 - movntq [edi - 16], mm0 - dec ecx - movntq [edi - 8], mm1 - jnz $memcpy_uc_1; - last 64 - byte block ? - - jmp $memcpy_ic_2; - almost done - - // For the largest size blocks, a special technique called Block Prefetch - // can be used to accelerate the read operations. Block Prefetch reads - // one address per cache line, for a series of cache lines, in a short loop. - // This is faster than using software prefetch. The technique is great for - // getting maximum read bandwidth, especially in DDR memory systems. - $memcpy_bp_1 :; - large blocks, block prefetch copy - - cmp ecx, CACHEBLOCK; - big enough to run another prefetch loop ? - jl $memcpy_64_test; - no, back to regular uncached copy - - mov eax, CACHEBLOCK / 2; - block prefetch loop, unrolled 2X - add esi, CACHEBLOCK* 64; - move to the top of the block - align 16 - $memcpy_bp_2 : - mov edx, [esi - 64]; - grab one address per cache line - mov edx, [esi - 128]; - grab one address per cache line - sub esi, 128; - go reverse order to suppress HW prefetcher - dec eax; - count down the cache lines - jnz $memcpy_bp_2; - keep grabbing more lines into cache - - mov eax, CACHEBLOCK; - now that its in cache, do - { - the copy - align 16 -$memcpy_bp_3: - movq mm0, [esi ]; - } read 64 bits - movq mm1, [esi + 8] - movq mm2, [esi + 16] - movq mm3, [esi + 24] - movq mm4, [esi + 32] - movq mm5, [esi + 40] - movq mm6, [esi + 48] - movq mm7, [esi + 56] - add esi, 64; - update source pointer - movntq [edi ], mm0; - write 64 bits, bypassing cache - movntq [edi + 8], mm1; -note: movntq also prevents the CPU - movntq [edi + 16], mm2; - from READING the destination address - movntq [edi + 24], mm3; - into the cache, only to be over - written, - movntq [edi + 32], mm4; - so that also helps performance - movntq [edi + 40], mm5 - movntq [edi + 48], mm6 - movntq [edi + 56], mm7 - add edi, 64; - update dest pointer - - dec eax; - count down - - jnz $memcpy_bp_3; - keep copying - sub ecx, CACHEBLOCK; - update the 64 - byte block count - jmp $memcpy_bp_1; - keep processing chunks - - // The smallest copy uses the X86 "movsd" instruction, in an optimized - // form which is an "unrolled loop". Then it handles the last few bytes. - align 4 - movsd - movsd; - perform last 1 - 15 dword copies - movsd - movsd - movsd - movsd - movsd - movsd - movsd - movsd; - perform last 1 - 7 dword copies - movsd - movsd - movsd - movsd - movsd - movsd - -$memcpy_last_few:; - dword aligned from before movsds - mov ecx, ebx; - has valid low 2 bits of the byte count - and ecx, 11b; - the last few cows must come home - jz $memcpy_final; - no more, lets leave - rep movsb; - the last 1, 2, or 3 bytes - -$memcpy_final: - emms; - clean up the MMX state - sfence; - flush the write buffer - // mov eax, [dest] ; ret value = destination pointer - } - } - else - { - memcpy(Dst, Src, Count); - } -} - -inline void cryPrefetch(const void* Src, int nCount) -{ - nCount >>= 6; - if (nCount > 0) - { - _asm - { - mov esi, Src; - mov ecx, nCount; -mPr0: - align 16 - dec ecx; - mov eax, [esi]; - mov eax, 0; - lea esi, [esi + 40h]; - jne mPr0; - } - } - else - { - _asm - { - mov esi, Src; - mov ecx, nCount; -mPr1: - align 16 - inc ecx; - mov eax, [esi]; - mov eax, 0; - lea esi, [esi - 40h]; - jne mPr1; - } - } -} - -inline void cryMemcpy (void* inDst, const void* inSrc, int nCount, int nFlags) -{ - cryMemcpy(inDst, inSrc, nCount); -} - -//========================================================================================== -// SSE optimizations - - -#else - -const int PREFNTA_BLOCK = 0x4000; - -ILINE void cryMemcpy(void* Dst, const void* Src, int n) -{ - char* dst = (char*)Dst; - char* src = (char*)Src; - while (n > PREFNTA_BLOCK) - { - _MM_PREFETCH_LOOP(PREFNTA_BLOCK, src, _MM_HINT_NTA); - - memcpy(dst, src, PREFNTA_BLOCK); - src += PREFNTA_BLOCK; - dst += PREFNTA_BLOCK; - n -= PREFNTA_BLOCK; - } - _MM_PREFETCH_LOOP(n, src, _MM_HINT_NTA); - memcpy(dst, src, n); -} - -ILINE void cryMemcpy(void* Dst, const void* Src, int n, [[maybe_unused]] int nFlags) -{ - char* dst = (char*)Dst; - char* src = (char*)Src; - while (n > PREFNTA_BLOCK) - { - _MM_PREFETCH_LOOP(PREFNTA_BLOCK, src, _MM_HINT_NTA); - memcpy(dst, src, PREFNTA_BLOCK); - src += PREFNTA_BLOCK; - dst += PREFNTA_BLOCK; - n -= PREFNTA_BLOCK; - } - _MM_PREFETCH_LOOP(n, src, _MM_HINT_NTA); - memcpy(dst, src, n); -} - - -#endif - - -#if defined(AZ_RESTRICTED_PLATFORM) - #define AZ_RESTRICTED_SECTION MEMORYACCESS_H_SECTION_CRYPREFETCH - #include AZ_RESTRICTED_FILE(MemoryAccess_h) -#endif -#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED) -#undef AZ_RESTRICTED_SECTION_IMPLEMENTED -#else -//implement something usual to bring one memory location into L1 data cache -ILINE void CryPrefetch(const void* const cpSrc) -{ - cryPrefetchT0SSE(cpSrc); -} -#endif - -#define CryPrefetchInl CryPrefetch diff --git a/Code/Legacy/CryCommon/Mocks/ICVarMock.h b/Code/Legacy/CryCommon/Mocks/ICVarMock.h index 9fad05cc35..08f4471ad1 100644 --- a/Code/Legacy/CryCommon/Mocks/ICVarMock.h +++ b/Code/Legacy/CryCommon/Mocks/ICVarMock.h @@ -36,9 +36,6 @@ public: MOCK_CONST_METHOD0(IsConstCVar, bool()); MOCK_METHOD1(SetOnChangeCallback, void(ConsoleVarFunc)); MOCK_METHOD1(AddOnChangeFunctor, uint64(const SFunctor& pChangeFunctor)); - MOCK_CONST_METHOD0(GetNumberOfOnChangeFunctors, uint64()); - MOCK_CONST_METHOD1(GetOnChangeFunctor, const SFunctor&(uint64)); - MOCK_METHOD1(RemoveOnChangeFunctor, bool(uint64)); MOCK_CONST_METHOD0(GetOnChangeCallback, ConsoleVarFunc()); MOCK_CONST_METHOD1(GetMemoryUsage, void(class ICrySizer* pSizer)); MOCK_CONST_METHOD0(GetRealIVal, int()); diff --git a/Code/Legacy/CryCommon/Mocks/IConsoleMock.h b/Code/Legacy/CryCommon/Mocks/IConsoleMock.h index b416aa5f11..9c947b9c0f 100644 --- a/Code/Legacy/CryCommon/Mocks/IConsoleMock.h +++ b/Code/Legacy/CryCommon/Mocks/IConsoleMock.h @@ -69,13 +69,6 @@ public: MOCK_METHOD1(SetInputLine, void (const char* szLine)); MOCK_METHOD1(DumpKeyBinds, void (IKeyBindDumpSink * pCallback)); MOCK_CONST_METHOD1(FindKeyBind, const char*(const char* sCmd)); - MOCK_METHOD0(GetNumCheatVars, int ()); - MOCK_METHOD2(SetCheatVarHashRange, void (size_t firstVar, size_t lastVar)); - MOCK_METHOD0(CalcCheatVarHash, void ()); - MOCK_METHOD0(IsHashCalculated, bool ()); - MOCK_METHOD0(GetCheatVarHash, uint64 ()); - MOCK_METHOD1(PrintCheatVars, void (bool bUseLastHashRange)); - MOCK_METHOD1(GetCheatVarAt, char* (uint32 nOffset)); MOCK_METHOD1(AddConsoleVarSink, void (IConsoleVarSink * pSink)); MOCK_METHOD1(RemoveConsoleVarSink, void (IConsoleVarSink * pSink)); MOCK_METHOD1(GetHistoryElement, const char*(bool bUpOrDown)); diff --git a/Code/Legacy/CryCommon/Mocks/ITextureMock.h b/Code/Legacy/CryCommon/Mocks/ITextureMock.h index 1a9bca9082..8dc657195c 100644 --- a/Code/Legacy/CryCommon/Mocks/ITextureMock.h +++ b/Code/Legacy/CryCommon/Mocks/ITextureMock.h @@ -20,154 +20,6 @@ public: int()); MOCK_METHOD0(ReleaseForce, int()); - MOCK_CONST_METHOD0(GetClearColor, - const ColorF& ()); - MOCK_CONST_METHOD0(GetDstFormat, - const ETEX_Format()); - MOCK_CONST_METHOD0(GetSrcFormat, - const ETEX_Format()); - MOCK_CONST_METHOD0(GetTexType, - const ETEX_Type()); - MOCK_METHOD2(ApplyTexture, - void(int, int)); MOCK_CONST_METHOD0(GetName, const char*()); - MOCK_CONST_METHOD0(GetWidth, - const int()); - MOCK_CONST_METHOD0(GetHeight, - const int()); - MOCK_CONST_METHOD0(GetDepth, - const int()); - MOCK_CONST_METHOD0(GetTextureID, - const int()); - MOCK_CONST_METHOD0(GetFlags, - const uint32()); - MOCK_CONST_METHOD0(GetNumMips, - const int()); - MOCK_CONST_METHOD0(GetRequiredMip, - const int()); - MOCK_CONST_METHOD0(GetDeviceDataSize, - const int()); - MOCK_CONST_METHOD0(GetDataSize, - const int()); - MOCK_CONST_METHOD0(GetTextureType, - const ETEX_Type()); - MOCK_METHOD1(SetTextureType, - void(ETEX_Type type)); - MOCK_CONST_METHOD0(IsTextureLoaded, - const bool()); - MOCK_METHOD4(PrecacheAsynchronously, - void(float, int, int, int)); - MOCK_METHOD4(GetData32, - uint8 * (int nSide, int nLevel, uint8 * pDst, ETEX_Format eDstFormat)); - MOCK_METHOD1(SetFilter, - bool(int nFilter)); - MOCK_METHOD1(SetClamp, - void(bool bEnable)); - MOCK_CONST_METHOD0(GetAvgBrightness, - float()); - MOCK_CONST_METHOD1(StreamCalculateMipsSigned, - int(float fMipFactor)); - MOCK_CONST_METHOD0(GetStreamableMipNumber, - int()); - MOCK_CONST_METHOD1(GetStreamableMemoryUsage, - int(int nStartMip)); - MOCK_CONST_METHOD0(GetMinLoadedMip, - int()); - MOCK_METHOD2(Readback, - void(AZ::u32 subresourceIndex, StagingHook callback)); - MOCK_METHOD0(Reload, - bool()); - MOCK_CONST_METHOD0(GetFormatName, - const char*()); - MOCK_CONST_METHOD0(GetTypeName, - const char*()); - MOCK_CONST_METHOD0(IsStreamedVirtual, - const bool()); - MOCK_CONST_METHOD0(IsShared, - const bool()); - MOCK_CONST_METHOD0(IsStreamable, - const bool()); - MOCK_CONST_METHOD1(IsStreamedIn, - bool(const int nMinPrecacheRoundIds[2])); - MOCK_CONST_METHOD0(GetAccessFrameId, - const int()); - MOCK_CONST_METHOD0(GetTextureDstFormat, - const ETEX_Format()); - MOCK_CONST_METHOD0(GetTextureSrcFormat, - const ETEX_Format()); - MOCK_CONST_METHOD0(IsPostponed, - bool()); - MOCK_CONST_METHOD1(IsParticularMipStreamed, - const bool(float fMipFactor)); - MOCK_METHOD3(GetLowResSystemCopy, - const ColorB * (uint16 & nWidth, uint16 & nHeight, int** ppLowResSystemCopyAtlasId)); - MOCK_METHOD1(SetKeepSystemCopy, - void(bool bKeepSystemCopy)); - MOCK_METHOD8(UpdateTextureRegion, - void(const uint8_t * data, int nX, int nY, int nZ, int USize, int VSize, int ZSize, ETEX_Format eTFSrc)); - MOCK_CONST_METHOD0(GetDevTexture, - CDeviceTexture * ()); -}; - -class ITextureLoadHandlerMock - : public ITextureLoadHandler -{ -public: - MOCK_METHOD2(LoadTextureData, - bool(const char* path, STextureLoadData & loadData)); - MOCK_CONST_METHOD1(SupportsExtension, - bool(const char* ext)); - MOCK_METHOD0(Update, - void()); -}; - -class IDynTextureMock - : public IDynTexture -{ -public: - MOCK_METHOD0(Release, - void()); - MOCK_METHOD4(GetSubImageRect, - void(uint32 & nX, uint32 & nY, uint32 & nWidth, uint32 & nHeight)); - MOCK_METHOD4(GetImageRect, - void(uint32 & nX, uint32 & nY, uint32 & nWidth, uint32 & nHeight)); - MOCK_METHOD0(GetTextureID, - int()); - MOCK_METHOD0(Lock, - void()); - MOCK_METHOD0(UnLock, - void()); - MOCK_METHOD0(GetWidth, - int()); - MOCK_METHOD0(GetHeight, - int()); - MOCK_METHOD0(IsValid, - bool()); - MOCK_CONST_METHOD0(GetFlags, - uint8()); - MOCK_METHOD1(SetFlags, - void(uint8 flags)); - MOCK_METHOD2(Update, - bool(int nNewWidth, int nNewHeight)); - MOCK_METHOD2(Apply, - void(int, int)); - MOCK_METHOD0(ClearRT, - bool()); - MOCK_METHOD4(SetRT, - bool(int nRT, bool bPush, struct SDepthTexture* pDepthSurf, bool bScreenVP)); - MOCK_METHOD0(SetRectStates, - bool()); - MOCK_METHOD2(RestoreRT, - bool(int nRT, bool bPop)); - MOCK_METHOD0(GetTexture, - ITexture * ()); - MOCK_METHOD0(SetUpdateMask, - void()); - MOCK_METHOD0(ResetUpdateMask, - void()); - MOCK_METHOD0(IsSecondFrame, - bool()); - MOCK_METHOD2(GetImageData32, - bool(uint8 * pData, int nDataSize)); }; diff --git a/Code/Legacy/CryCommon/Options.h b/Code/Legacy/CryCommon/Options.h deleted file mode 100644 index 935c8bd371..0000000000 --- a/Code/Legacy/CryCommon/Options.h +++ /dev/null @@ -1,90 +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 : Facilities for defining and combining general-purpose or specific options, for functions or structs. - - -#ifndef CRYINCLUDE_CRYCOMMON_OPTIONS_H -#define CRYINCLUDE_CRYCOMMON_OPTIONS_H -#pragma once - - -// Facilities for collecting options in a struct, and quickly constructing them. -// Used, for example, as construction argument. Safer and more informative than bool arguments. -// -// Example: -// struct FObjectOpts; -// struct CObject { CObject(FObjectOpts = ZERO); }; -// CObject object_def(); -// CObject object( FObjectOpts().Size(8).AllowGrowth(true) ); - -template -struct TOptVar -{ - typedef T TValue; - - TOptVar() - : _val(T(NInit)) - { - offset(this); - } - TOptVar(T val) - : _val(val) {} - - operator T () const - { - return _val; - } - T operator ()() const - { return _val; } - T operator +() const - { return _val; } - bool operator !() const - { return !_val; } - - TContainer& operator()(T val) - { - _val = val; - return *(TContainer*)((char*)this - offset()); - } - -private: - T _val; - - static size_t offset(void* self = 0) - { - static size_t _offset = TContainer::static_offset(self); - return _offset; - } -}; - -#define OPT_STRUCT(TOpts) \ - typedef TOpts TThis; typedef uint TInt; \ - static size_t static_offset(void* var) { static void* _first = var; return (char*)var - (char*)_first; } \ - TOpts([[maybe_unused]] void* p = 0) {} \ - TOpts operator()() const { return TOpts(*this); } \ - -#define OPT_VAR(Type, Var) \ - enum E##Var {}; TOptVar Var; \ - -#define OPT_VAR_INIT(Type, Var, init) \ - enum E##Var {}; TOptVar Var; \ - -#define BIT_STRUCT(Struc, Int) \ - typedef Struc TThis; typedef Int TInt; \ - TInt Mask() const { return *(const TInt*)this; } \ - TInt& Mask() { return *(TInt*)this; } \ - Struc(TInt init = 0) { static_assert(sizeof(TThis) == sizeof(TInt)); Mask() = init; } \ - -#define BIT_VAR(Var) \ - TInt _##Var : 1; \ - bool Var() const { return _##Var; } \ - TThis& Var(bool val) { _##Var = val; return *this; } \ - -#endif // CRYINCLUDE_CRYCOMMON_OPTIONS_H diff --git a/Code/Legacy/CryCommon/StereoRendererBus.h b/Code/Legacy/CryCommon/StereoRendererBus.h deleted file mode 100644 index 370bbaef27..0000000000 --- a/Code/Legacy/CryCommon/StereoRendererBus.h +++ /dev/null @@ -1,43 +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 - -namespace AZ -{ - /// - /// The Stereo Renderer bus allows other systems to query various properties on the stereo renderer - /// - class StereoRendererBus - : public EBusTraits - { - public: - - ////////////////////////////////////////////////////////////////////////// - // EBus Traits - static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Multiple; - static const EBusAddressPolicy AddressPolicy = EBusAddressPolicy::Single; - using MutexType = AZStd::recursive_mutex; - ////////////////////////////////////////////////////////////////////////// - - virtual ~StereoRendererBus() {} - - /// - /// Return whether the renderer is rendering to the HMD - /// - /// @return True if rendering to the HMD - /// - virtual bool IsRenderingToHMD() { return false; } - - protected: - }; - - using StereoRendererRequestBus = EBus < StereoRendererBus >; -} diff --git a/Code/Legacy/CryCommon/StlUtils.h b/Code/Legacy/CryCommon/StlUtils.h index d7e5697593..4aafd4dd0e 100644 --- a/Code/Legacy/CryCommon/StlUtils.h +++ b/Code/Legacy/CryCommon/StlUtils.h @@ -9,14 +9,13 @@ // Description : Various convenience utility functions for STL and alike // Used in Animation subsystem, and in some tools -#ifndef CRYINCLUDE_CRYCOMMON_STLUTILS_H -#define CRYINCLUDE_CRYCOMMON_STLUTILS_H #pragma once #include #include #include #include +#include #if (defined(LINUX) || defined(APPLE)) #include "platform.h" @@ -527,58 +526,6 @@ namespace stl // typedef AZStd::unordered_map, stl::equality_string_insensitive > StringToIntHash; ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // useful when the key is already the result of an hash function - // key needs to be convertible to size_t - ////////////////////////////////////////////////////////////////////////// - template - class hash_simple - { - public: - enum // parameters for hash table - { - bucket_size = 4, // 0 < bucket_size - min_buckets = 8 - };// min_buckets = 2 ^^ N, 0 < N - - size_t operator()(const Key& key) const - { - return size_t(key); - }; - bool operator()(const Key& key1, const Key& key2) const - { - return key1 < key2; - } - }; - - // simple hash class that has the avalanche property (a change in one bit affects all others) - // ... use this if you have uint32 key values! - class hash_uint32 - { - public: - enum // parameters for hash table - { - bucket_size = 4, // 0 < bucket_size - min_buckets = 8 // min_buckets = 2 ^^ N, 0 < N - }; - - ILINE size_t operator()(uint32 a) const - { - a = (a + 0x7ed55d16) + (a << 12); - a = (a ^ 0xc761c23c) ^ (a >> 19); - a = (a + 0x165667b1) + (a << 5); - a = (a + 0xd3a2646c) ^ (a << 9); - a = (a + 0xfd7046c5) + (a << 3); - a = (a ^ 0xb55a4f09) ^ (a >> 16); - return a; - }; - bool operator()(uint32 key1, uint32 key2) const - { - return key1 < key2; - } - }; - - ////////////////////////////////////////////////////////////////////////// //! Case sensitive string hash ////////////////////////////////////////////////////////////////////////// @@ -655,130 +602,6 @@ namespace stl } }; - - // Support for both Microsoft and SGI kind of hash_map. - -#if defined(_STLP_HASH_MAP) || defined(APPLE) || defined(LINUX) - // STL Port - template > - struct hash_compare - { - enum - { // parameters for hash table - bucket_size = 4, // 0 < bucket_size - min_buckets = 8 // min_buckets = 2 ^^ N, 0 < N - }; - - size_t operator()(const _Key& _Keyval) const - { - // return hash value. - uint32 a = _Keyval; - a = (a + 0x7ed55d16) + (a << 12); - a = (a ^ 0xc761c23c) ^ (a >> 19); - a = (a + 0x165667b1) + (a << 5); - a = (a + 0xd3a2646c) ^ (a << 9); - a = (a + 0xfd7046c5) + (a << 3); - a = (a ^ 0xb55a4f09) ^ (a >> 16); - return a; - } - - // Less then function. - bool operator()(const _Key& _Keyval1, const _Key& _Keyval2) const - { // test if _Keyval1 ordered before _Keyval2 - _Predicate comp; - return (comp(_Keyval1, _Keyval2)); - } - }; - - template - struct stlport_hash_equal - { - // Equal function. - bool operator()(const Key& k1, const Key& k2) const - { - HashFunc less; - // !(k1 < k2) && !(k2 < k1) - return !less(k1, k2) && !less(k2, k1); - } - }; - - template , class Alloc = std::allocator< std::pair > > - struct hash_map - : public std__hash_map, Alloc> - { - hash_map() - : std__hash_map, Alloc>(HashFunc::min_buckets) {} - }; - - template , class Alloc = std::allocator< std::pair > > - struct hash_multimap - : public std__hash_multimap, Alloc> - { - hash_multimap() - : std__hash_multimap, Alloc>(HashFunc::min_buckets) {} - }; -#endif - - ////////////////////////////////////////////////////////////////////////// - template - class intrusive_linked_list_node - { - public: - intrusive_linked_list_node() { link_to_intrusive_list(static_cast(this)); } - // Not virtual by design - ~intrusive_linked_list_node() { unlink_from_intrusive_list(static_cast(this)); } - - static T* get_intrusive_list_root() { return m_root_intrusive; }; - - static void link_to_intrusive_list(T* pNode) - { - if (m_root_intrusive) - { - // Add to the beginning of the list. - T* head = m_root_intrusive; - pNode->m_prev_intrusive = 0; - pNode->m_next_intrusive = head; - head->m_prev_intrusive = pNode; - m_root_intrusive = pNode; - } - else - { - m_root_intrusive = pNode; - pNode->m_prev_intrusive = 0; - pNode->m_next_intrusive = 0; - } - } - static void unlink_from_intrusive_list(T* pNode) - { - if (pNode == m_root_intrusive) // if head of list. - { - m_root_intrusive = pNode->m_next_intrusive; - if (m_root_intrusive) - { - m_root_intrusive->m_prev_intrusive = 0; - } - } - else - { - if (pNode->m_prev_intrusive) - { - pNode->m_prev_intrusive->m_next_intrusive = pNode->m_next_intrusive; - } - if (pNode->m_next_intrusive) - { - pNode->m_next_intrusive->m_prev_intrusive = pNode->m_prev_intrusive; - } - } - pNode->m_next_intrusive = 0; - pNode->m_prev_intrusive = 0; - } - - public: - static T* m_root_intrusive; - T* m_next_intrusive; - T* m_prev_intrusive; - }; - template inline void reconstruct(T& t) { @@ -860,30 +683,6 @@ namespace stl } }; - template - struct scoped_set - { - scoped_set(T& ref, T val) - : m_ref(&ref) - , m_oldVal(ref) - { - ref = val; - } - - ~scoped_set() - { - (*m_ref) = m_oldVal; - } - - private: - scoped_set(const scoped_set& other); - scoped_set& operator = (const scoped_set& other); - - private: - T* m_ref; - T m_oldVal; - }; - template inline void for_each_array(T (&buffer)[Length], Func func) { @@ -910,64 +709,6 @@ namespace stl template<> \ Class * stl::intrusive_linked_list_node::m_root_intrusive = nullptr; - -// Performs a less-than compare on a serial sequence space, such that earlier values compare less-than later values. -// Unlike a normal integral value, this accounts for overflowing the limit of the underlying type. -// For example, assuming a 2-bit unsigned underlying type (with possible values 0, 1, 2 and 3), the following will hold: 0 < 1 && 1 < 2 && 2 < 3 && 3 < 0 -// Assuming two equal values V1 and V2, V2 can be incremented up to "(2 ^ (bits - 1) - 1)" times and V1 < V2 will continue to hold. -// See also RFC-1982 that documents this http://tools.ietf.org/html/rfc1982 -template -struct SSerialCompare -{ - static_assert(std::is_integral::value && std::is_unsigned::value, "T must be an unsigned integral type"); - - static const T limit = (T(1) << (sizeof(T) * 8 - 1)); - - bool operator()(T lhs, T rhs) - { - return ((lhs < rhs) && (rhs - lhs < limit)) || ((lhs > rhs) && (lhs - rhs > limit)); - } -}; - -template -unsigned sizeOfVP(Container& arr) -{ - int i; - unsigned size = 0; - for (i = 0; i < (int)arr.size(); i++) - { - typename Container::value_type& T = arr[i]; - size += T->Size(); - } - size += (arr.capacity() - arr.size()) * sizeof(typename Container::value_type); - return size; -} - -template -unsigned sizeOfV(Container& arr) -{ - int i; - unsigned size = 0; - for (i = 0; i < (int)arr.size(); i++) - { - typename Container::value_type& T = arr[i]; - size += T.Size(); - } - size += (arr.capacity() - arr.size()) * sizeof(typename Container::value_type); - return size; -} -template -unsigned sizeOfA(Container& arr) -{ - int i; - unsigned size = 0; - for (i = 0; i < arr.size(); i++) - { - typename Container::value_type& T = arr[i]; - size += T.Size(); - } - return size; -} // define the maplikestruct, used to approximate the memory requirements for a map node namespace stl { @@ -1027,5 +768,3 @@ unsigned sizeOfMapS(Map& map) size += map.size() * sizeof(stl::MapLikeStruct); return size; } - -#endif // CRYINCLUDE_CRYCOMMON_STLUTILS_H diff --git a/Code/Legacy/CryCommon/Tarray.h b/Code/Legacy/CryCommon/Tarray.h deleted file mode 100644 index 77c27f0ef8..0000000000 --- a/Code/Legacy/CryCommon/Tarray.h +++ /dev/null @@ -1,56 +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_TARRAY_H -#define CRYINCLUDE_CRYCOMMON_TARRAY_H -#pragma once - - -#include -#include -#include - -#ifndef CLAMP -#define CLAMP(X, mn, mx) ((X) < (mn) ? (mn) : ((X) < (mx) ? (X) : (mx))) -#endif - -#ifndef SATURATE -#define SATURATE(X) clamp_tpl(X, 0.f, 1.f) -#endif - -#ifndef SATURATEB -#define SATURATEB(X) CLAMP(X, 0, 255) -#endif - -#ifndef LERP -#define LERP(A, B, Alpha) ((A) + (Alpha) * ((B)-(A))) -#endif - -// Safe memory freeing -#ifndef SAFE_DELETE -#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } \ -} -#endif - -#ifndef SAFE_DELETE_ARRAY -#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } \ -} -#endif - -#ifndef SAFE_RELEASE -#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } \ -} -#endif - -#ifndef SAFE_RELEASE_FORCE -#define SAFE_RELEASE_FORCE(p) { if (p) { (p)->ReleaseForce(); (p) = NULL; } \ -} -#endif - -#endif // CRYINCLUDE_CRYCOMMON_TARRAY_H diff --git a/Code/Legacy/CryCommon/TimeValue.h b/Code/Legacy/CryCommon/TimeValue.h index abe37c8608..14f402eb3d 100644 --- a/Code/Legacy/CryCommon/TimeValue.h +++ b/Code/Legacy/CryCommon/TimeValue.h @@ -164,8 +164,6 @@ public: ILINE bool operator==(const CTimeValue& inRhs) const { return m_lValue == inRhs.m_lValue; }; ILINE bool operator!=(const CTimeValue& inRhs) const { return m_lValue != inRhs.m_lValue; }; - AUTO_STRUCT_INFO - void GetMemoryStatistics(class ICrySizer*) const { /*nothing*/} private: // ---------------------------------------------------------- diff --git a/Code/Legacy/CryCommon/TimeValue_info.h b/Code/Legacy/CryCommon/TimeValue_info.h deleted file mode 100644 index 4de34e7997..0000000000 --- a/Code/Legacy/CryCommon/TimeValue_info.h +++ /dev/null @@ -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 - * - */ - - -#ifndef CRYINCLUDE_CRYCOMMON_TIMEVALUE_INFO_H -#define CRYINCLUDE_CRYCOMMON_TIMEVALUE_INFO_H -#pragma once - -#include "TimeValue.h" - -STRUCT_INFO_BEGIN(CTimeValue) -STRUCT_VAR_INFO(m_lValue, TYPE_INFO(int64)) -STRUCT_INFO_END(CTimeValue) - - -#endif // CRYINCLUDE_CRYCOMMON_TIMEVALUE_INFO_H diff --git a/Code/Legacy/CryCommon/TypeInfo_decl.h b/Code/Legacy/CryCommon/TypeInfo_decl.h deleted file mode 100644 index 28a0b370a9..0000000000 --- a/Code/Legacy/CryCommon/TypeInfo_decl.h +++ /dev/null @@ -1,120 +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 : Macros and other definitions needed for TypeInfo declarations. - - -#ifndef CRYINCLUDE_CRYCOMMON_TYPEINFO_DECL_H -#define CRYINCLUDE_CRYCOMMON_TYPEINFO_DECL_H -#pragma once - -#include -#include - -////////////////////////////////////////////////////////////////////////// -// Meta-type support. -////////////////////////////////////////////////////////////////////////// - -// Currently enable type info for all platforms. -#if !defined(ENABLE_TYPE_INFO) -#define ENABLE_TYPE_INFO -#endif -#ifdef ENABLE_TYPE_INFO - -struct CTypeInfo; - -// If TypeInfo exists for T, it is accessed via TypeInfo(T*). -// Default TypeInfo() is implemented by a struct member function. -template -inline const CTypeInfo& TypeInfo(const T* t) -{ - return t->TypeInfo(); -} - -// Declare a class's TypeInfo member -#define STRUCT_INFO \ - const CTypeInfo&TypeInfo() const; - -#define NULL_STRUCT_INFO \ - const CTypeInfo&TypeInfo() const { return *(CTypeInfo*)0; } - -// Declare an override for a type without TypeInfo() member (e.g. basic type) -#define DECLARE_TYPE_INFO(Type) \ - template<> \ - const CTypeInfo&TypeInfo(const Type*); - -// Template version. -#define DECLARE_TYPE_INFO_T(Type) \ - template \ - const CTypeInfo&TypeInfo(const Type*); - -// Type info declaration, with additional prototypes for string conversions. -#define BASIC_TYPE_INFO(Type) \ - AZStd::string ToString(Type const & val); \ - bool FromString(Type & val, const char* s); \ - DECLARE_TYPE_INFO(Type) - -#define CUSTOM_STRUCT_INFO(Struct) \ - const CTypeInfo&TypeInfo() const \ - { static Struct Info; return Info; } - -#else // ENABLE_TYPE_INFO - -#define STRUCT_INFO -#define NULL_STRUCT_INFO -#define DECLARE_TYPE_INFO(Type) -#define DECLARE_TYPE_INFO_T(Type) -#define BASIC_TYPE_INFO(T) - -#endif // ENABLE_TYPE_INFO - -// Specify automatic tool generation of TypeInfo bodies. -#define AUTO_STRUCT_INFO STRUCT_INFO -#define AUTO_TYPE_INFO DECLARE_TYPE_INFO -#define AUTO_TYPE_INFO_T DECLARE_TYPE_INFO_T - -// Obsolete "LOCAL" versions (all infos now generated in local files). -#define AUTO_STRUCT_INFO_LOCAL STRUCT_INFO -#define AUTO_TYPE_INFO_LOCAL DECLARE_TYPE_INFO -#define AUTO_TYPE_INFO_LOCAL_T DECLARE_TYPE_INFO_T - -// Overrides for basic types. -DECLARE_TYPE_INFO(void) - -BASIC_TYPE_INFO(bool) -BASIC_TYPE_INFO(char) -BASIC_TYPE_INFO(wchar_t) -BASIC_TYPE_INFO(signed char) -BASIC_TYPE_INFO(unsigned char) -BASIC_TYPE_INFO(short) -BASIC_TYPE_INFO(unsigned short) -BASIC_TYPE_INFO(int) -BASIC_TYPE_INFO(unsigned int) -BASIC_TYPE_INFO(long) -BASIC_TYPE_INFO(unsigned long) -BASIC_TYPE_INFO(int64) -BASIC_TYPE_INFO(uint64) - -BASIC_TYPE_INFO(float) -BASIC_TYPE_INFO(double) - -BASIC_TYPE_INFO(AZ::Uuid) - -DECLARE_TYPE_INFO(AZStd::string) - -// All pointers share same TypeInfo. -const CTypeInfo&PtrTypeInfo(); -template -inline const CTypeInfo& TypeInfo([[maybe_unused]] T** t) -{ - return PtrTypeInfo(); -} - - -#endif // CRYINCLUDE_CRYCOMMON_TYPEINFO_DECL_H diff --git a/Code/Legacy/CryCommon/TypeInfo_impl.h b/Code/Legacy/CryCommon/TypeInfo_impl.h deleted file mode 100644 index 9c4bb6bca7..0000000000 --- a/Code/Legacy/CryCommon/TypeInfo_impl.h +++ /dev/null @@ -1,213 +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 of CTypeInfo, and other things to access meta-type info. - - -#ifndef CRYINCLUDE_CRYCOMMON_TYPEINFO_IMPL_H -#define CRYINCLUDE_CRYCOMMON_TYPEINFO_IMPL_H -#pragma once - - -#include "CryCustomTypes.h" - -#define ENABLE_TYPE_INFO_NAMES 1 - -//--------------------------------------------------------------------------- -// DECLARATION MACROS -// Used to construct meta TypeInfo objects in AutoTypeInfo files. -// Two possible levels of TypeInfo: default, with size and offset info only, allowing Endian conversion; -// and full, with string, attr, and enum info, allowing UI and serialisation. -// The full version is selected by the ENABLE_TYPE_INFO_NAMES macro. - -#ifdef ENABLE_TYPE_INFO - - #ifndef ENABLE_TYPE_INFO_NAMES -// This symbol must be defined only once per module. - #define ENABLE_TYPE_INFO_NAMES 0 - #endif - - #if ENABLE_TYPE_INFO_NAMES - #define TYPE_INFO_NAME(n) #n - #else - #define TYPE_INFO_NAME(n) "" - #endif - #define TYPE_INFO_NAME_T(n) #n "<>" - -// Set of template functions for automatically returning the base element type for any scalar or array variable. - -template -inline T& ElemType(T* at) -{ return *at; } - -template -inline T& ElemType(T (*at)[N]) -{ return **at; } - -template -inline T& ElemType(T (*at)[N][N2]) -{ return ***at; } - -template -inline T& ElemType(T (*at)[N][N2][N3]) -{ return ****at; } - -template -inline T& ValType([[maybe_unused]] T t) -{ static T _t; return _t; } - -//--------------------------------------------------------------------------- -// Macros for constructing StructInfos (invoked by AutoTypeInfo.h) - - #define DEFINE_TYPE_INFO(T, Type, Args) \ - template<> \ - const CTypeInfo&TypeInfo(const T*) \ - { static Type Info Args; return Info; } \ - - #define STRUCT_INFO_EMPTY_BODY(T) \ - { \ - static CStructInfo Info(#T, sizeof(T), alignof(T)); \ - return Info; \ - } \ - - #define STRUCT_INFO_EMPTY(T) \ - const CTypeInfo&T::TypeInfo() const \ - STRUCT_INFO_EMPTY_BODY(T) \ - - #define STRUCT_INFO_T_EMPTY(T, Key, Arg) \ - template \ - STRUCT_INFO_EMPTY(T) - - #define STRUCT_INFO_TYPE_EMPTY(T) \ - DEFINE_TYPE_INFO(T, CStructInfo, (#T, sizeof(T), alignof(T))) - - #define STRUCT_INFO_TYPE_T_EMPTY(T, TArgs, TDecl) \ - template TDecl const CTypeInfo&TypeInfo(const T TArgs*) \ - STRUCT_INFO_EMPTY_BODY(T TArgs) \ - -// Define TypeInfo for a primitive type, without string conversion. - #define TYPE_INFO_PLAIN(T) DEFINE_TYPE_INFO(T, CTypeInfo, (#T, sizeof(T), alignof(T))) - -// Define TypeInfo for a basic type (undecomposable as far as TypeInfo cares), with external string converters. - #define TYPE_INFO_BASIC(T) DEFINE_TYPE_INFO(T, TTypeInfo, (#T)) - -// Variant for int types, allowing conversion between sizes. - #define TYPE_INFO_INT(T) DEFINE_TYPE_INFO(T, TIntTypeInfo, (#T)) - - #define STRUCT_INFO_BEGIN(T) \ - const CTypeInfo&T::TypeInfo() const { \ - static CStructInfo::CVarInfo Vars[] = { \ - - #define STRUCT_INFO_END(T) \ - }; \ - static CStructInfo Info(#T, sizeof(T), alignof(T), ARRAY_VAR(Vars)); \ - return Info; \ - } - - #define BASE_INFO_ATTRS(BaseType, Attrs) \ - { ::TypeInfo((const BaseType*)this), "", Attrs, uint32((char*)static_cast(this) - (char*)this), 1, 1, 0, 0, 0 }, - - #define BASE_INFO(BaseType) BASE_INFO_ATTRS(BaseType, "") - - #define ALIAS_INFO_ATTRS(AliasName, VarName, Attrs) \ - { ::TypeInfo(&ElemType(&VarName)), TYPE_INFO_NAME(AliasName), Attrs, uint32((char*)&VarName - (char*)this), sizeof(VarName) / sizeof(ElemType(&VarName)), 0, 0, 0, 0 }, - - #define ALIAS_INFO_STRINGNAME_ATTR(AliasStringName, VarName, Attrs) \ - { ::TypeInfo(&ElemType(&VarName)), AliasStringName, Attrs, uint32((char*)&VarName - (char*)this), sizeof(VarName) / sizeof(ElemType(&VarName)), 0, 0, 0, 0 }, - - #define VAR_INFO_ATTRS(VarName, Attrs) \ - ALIAS_INFO_ATTRS(VarName, VarName, Attrs) - - #define VAR_INFO(VarName) \ - VAR_INFO_ATTRS(VarName, "") - - #define ALIAS_INFO(AliasName, VarName) \ - ALIAS_INFO_ATTRS(AliasName, VarName, "") - - #define ATTRS_INFO(Attrs) \ - { ::TypeInfo((void*)0), "", Attrs, 0, 0, 0, 0, 0, 0 }, - - #define BITFIELD_INFO(VarName, Bits) \ - { ::TypeInfo(&ValType(VarName)), TYPE_INFO_NAME(VarName), "", 0, Bits, 0, 1, 0, 0 }, - -// Conversion macros for older system. - #define STRUCT_BASE_INFO(BaseType) BASE_INFO(BaseType) - #define STRUCT_VAR_INFO(VarName, InfoName) VAR_INFO(VarName) - #define STRUCT_BITFIELD_INFO(VarName, VarType, Bits) BITFIELD_INFO(VarName, Bits) - -// Template versions - -template -Array TypeInfoArray1(T const* pt) -{ - static CTypeInfo const* s_info = &::TypeInfo(pt); - return ArrayT(&s_info, 1); -} - - #define STRUCT_INFO_T_BEGIN(T, Key, Arg) \ - template \ - STRUCT_INFO_BEGIN(T) - - #define STRUCT_INFO_T_END(T, Key, Arg) \ - }; \ - static CStructInfo Info(#T "<>", sizeof(T), alignof(T), ARRAY_VAR(Vars), TypeInfoArray1((Arg*)0)); \ - return Info; \ - } - - #define STRUCT_INFO_T2_BEGIN(T, Key1, Arg1, Key2, Arg2) \ - template \ - const CTypeInfo&T::TypeInfo() const { \ - typedef T TThis; \ - static CStructInfo::CVarInfo Vars[] = { \ - - #define STRUCT_INFO_T2_END(T, Key1, Arg1, Key2, Arg2) \ - }; \ - static CTypeInfo const* TemplateTypes[] = { &::TypeInfo((Arg1*)0), &::TypeInfo((Arg2*)0) }; \ - static CStructInfo Info(#T "<,>", sizeof(TThis), alignof(TThis), ARRAY_VAR(Vars), ARRAY_VAR(TemplateTypes)); \ - return Info; \ - } - - #define STRUCT_INFO_T_INSTANTIATE(T, TArgs) \ - template const CTypeInfo& T::TypeInfo() const; - -//--------------------------------------------------------------------------- -// Enum type info - - #if ENABLE_TYPE_INFO_NAMES - -// Enums represented as full CEnumInfo types, with string conversion. - #define ENUM_INFO_BEGIN(T) \ - template<> \ - const CTypeInfo&TypeInfo(const T*) { \ - static CEnumDef::SElem Elems[] = { \ - - #define ENUM_INFO_END(T) \ - }; \ - typedef TIntType::TType TInt; \ - static CEnumInfo Info(#T, ARRAY_VAR(Elems)); \ - return Info; \ - } \ - - #define ENUM_ELEM_INFO(Scope, Elem) \ - { Scope Elem, #Elem }, - - #else // ENABLE_TYPE_INFO_NAMES - -// Enums represented as simple types, with no elements or string conversion. - #define ENUM_INFO_BEGIN(T) \ - TYPE_INFO_PLAIN(T) \ - - #define ENUM_INFO_END(T) - #define ENUM_ELEM_INFO(Scope, Elem) - - #endif // ENABLE_TYPE_INFO_NAMES - -#endif // ENABLE_TYPE_INFO - -#endif // CRYINCLUDE_CRYCOMMON_TYPEINFO_IMPL_H diff --git a/Code/Legacy/CryCommon/VectorSet.h b/Code/Legacy/CryCommon/VectorSet.h deleted file mode 100644 index 15b05e62ef..0000000000 --- a/Code/Legacy/CryCommon/VectorSet.h +++ /dev/null @@ -1,492 +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 : std::set replacement implemented using sorted vector. - - -#ifndef CRYINCLUDE_CRYCOMMON_VECTORSET_H -#define CRYINCLUDE_CRYCOMMON_VECTORSET_H -#pragma once - - -//-------------------------------------------------------------------------- -// VectorSet -// -// Usage Notes: -// This class is designed to be an (almost, see below) drop-in replacement -// for std::set. It features an almost identical interface, but it is -// implemented using a sorted vector rather than a tree. This is in most -// cases more efficient, as there is less dynamic memory allocation and -// pointer dereferencing. -// -// ************************************************************************* -// PLEASE NOTE: There is one vital difference between std::set and VectorSet -// that you will need to note before trying to replace std::set. Since -// VectorSet is implemented using a vector, iterators can and will be -// invalidated by many operations, such as insertions and deletions, and -// due to sorting potentially even normal lookups. Please Please PLEASE make -// sure that you are not storing any iterators to this class. -// ************************************************************************* -// -// The class varies from the std::set API in that two of the erase methods -// methods are not of void return type but return an iterator - this is -// required in practice because they invalidate iterators, as noted above. -// -// * iterator erase(iterator where); -// * iterator erase(iterator first, iterator last); -// -// It also adds operator[] to the API. -// -// -// Performance Notes: -// -// This class uses the empty base optimization hack to allow comparison -// predicate objects that have no state to take up no space in the object. -// As a result the size of the overall VectorMap instance is the same as -// that of the std::vector it uses to store the elements. -// -// In addition to the normal map interface, this class provides the -// following members that can be used to manage memory requirements: -// -// * void reserve(size_type count); -// Allocate enough space for count elements (see vector::reserve()). -// -// * size_type capacity() const; -// Report how many elements can be stored without reallocating (see -// vector::capacity()). -// -// * void resize(size_type new_size, const_reference x=key_type()); -// see vector::resize()). -// -//-------------------------------------------------------------------------- - -template , typename A = AZ::StdLegacyAllocator > -class VectorSet - : private T // Empty base optimization -{ -public: - typedef K key_type; - typedef A allocator_type; - typedef T key_compare; - typedef T value_compare; - typedef AZStd::vector container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - typedef typename container_type::reverse_iterator reverse_iterator; - typedef typename container_type::const_reverse_iterator const_reverse_iterator; - typedef typename container_type::size_type size_type; - typedef typename container_type::difference_type difference_type; - typedef key_type& reference; - typedef const key_type& const_reference; - typedef key_type* pointer; - typedef const key_type* const_pointer; - - VectorSet(); - explicit VectorSet(const key_compare& comp); - explicit VectorSet(const key_compare& comp, const allocator_type& allocator); - VectorSet(const VectorSet& right); - template - VectorSet(InputIterator first, InputIterator last); - template - VectorSet(InputIterator first, InputIterator last, const key_compare& comp); - template - VectorSet(InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& allocator); - void SwapElementsWithVector(container_type& elementVector); - const_iterator begin() const; - iterator begin(); - size_type capacity() const; - void resize(size_type __new_size, const_reference __x = key_type()); - void clear(); - size_type count(const_reference key) const; - bool empty() const; - const_iterator end() const; - iterator end(); - std::pair equal_range(const_reference key) const; - std::pair equal_range(const_reference key); - iterator erase(iterator where); // See documentation above - iterator erase(iterator first, iterator last); // See documentation above - size_t erase(const_reference key); - iterator find(const_reference key); - const_iterator find(const_reference key) const; - allocator_type get_allocator() const; - std::pair insert(const_reference value); - iterator insert(iterator _Where, const_reference value); - template - void insert(InputIterator first, InputIterator last); - key_compare key_comp() const; - const_iterator lower_bound(const_reference key) const; - iterator lower_bound(const_reference key); - size_type max_size() const; - const_reverse_iterator rbegin() const; - reverse_iterator rbegin(); - const_reverse_iterator rend() const; - reverse_iterator rend(); - void reserve(size_type count); - size_type size() const; - void swap(VectorSet& right); - const_iterator upper_bound(const_reference key) const; - iterator upper_bound(const_reference key); - value_compare value_comp() const; - reference operator[](int index); // See documentation above - const_reference operator[](int index) const; // See documentation above - - template - void GetMemoryUsage(Sizer* pSizer) const - { - pSizer->AddObject(m_entries); - } -private: - container_type m_entries; -}; - -template -VectorSet::VectorSet() -{ -} - -template -VectorSet::VectorSet(const key_compare& comp) - : key_compare(comp) -{ -} - -template -VectorSet::VectorSet(const key_compare& comp, const allocator_type& allocator) - : key_compare(comp) - , m_entries(allocator) -{ -} - -template -VectorSet::VectorSet(const VectorSet& right) - : key_compare(right) - , m_entries(right.m_entries) -{ -} - -template -template -VectorSet::VectorSet(InputIterator first, InputIterator last) -{ - for (; first != last; ++first) - { - m_entries.push_back(*first); - } - std::sort(m_entries.begin(), m_entries.end(), static_cast(*this)); -} - -template -template -VectorSet::VectorSet(InputIterator first, InputIterator last, const key_compare& comp) - : key_compare(comp) -{ - for (; first != last; ++first) - { - m_entries.push_back(*first); - } - std::sort(m_entries.begin(), m_entries.end(), static_cast(*this)); -} - -template -template -VectorSet::VectorSet(InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& allocator) - : key_compare(comp) - , m_entries(allocator) -{ - for (; first != last; ++first) - { - m_entries.push_back(*first); - } - std::sort(m_entries.begin(), m_entries.end(), static_cast(*this)); -} - -template -void VectorSet::SwapElementsWithVector(container_type& elementVector) -{ - m_entries.swap(elementVector); - std::sort(m_entries.begin(), m_entries.end(), static_cast(*this)); -} - -template -typename VectorSet::const_iterator VectorSet::begin() const -{ - return m_entries.begin(); -} - -template -typename VectorSet::iterator VectorSet::begin() -{ - return m_entries.begin(); -} - -template -typename VectorSet::size_type VectorSet::capacity() const -{ - return m_entries.capacity(); -} - -template -void VectorSet::clear() -{ - m_entries.clear(); -} - -template -void VectorSet::resize(size_type __new_size, const_reference __x) -{ - m_entries.resize(__new_size, __x); -} - -template -typename VectorSet::size_type VectorSet::count(const_reference key) const -{ - return size_type(std::binary_search(m_entries.begin(), m_entries.end(), key, static_cast(*this))); -} - -template -bool VectorSet::empty() const -{ - return m_entries.empty(); -} - -template -typename VectorSet::const_iterator VectorSet::end() const -{ - return m_entries.end(); -} - -template -typename VectorSet::iterator VectorSet::end() -{ - return m_entries.end(); -} - -template -std::pair::const_iterator, typename VectorSet::const_iterator> VectorSet::equal_range(const_reference key) const -{ - const_iterator lower = lower_bound(key); - if (lower != m_entries.end() && key_compare::operator()(key, *lower)) - { - lower = m_entries.end(); - } - const_iterator upper = lower; - if (upper != m_entries.end()) - { - ++upper; - } - return std::make_pair(lower, upper); -} - -template -std::pair::iterator, typename VectorSet::iterator> VectorSet::equal_range(const_reference key) -{ - iterator lower = lower_bound(key); - if (lower != m_entries.end() && key_compare::operator()(key, *lower)) - { - lower = m_entries.end(); - } - iterator upper = lower; - if (upper != m_entries.end()) - { - ++upper; - } - return std::make_pair(lower, upper); -} - -template -typename VectorSet::iterator VectorSet::erase(iterator where) -{ - return m_entries.erase(where); -} - -template -typename VectorSet::iterator VectorSet::erase(iterator first, iterator last) -{ - return m_entries.erase(first, last); -} - -template -size_t VectorSet::erase(const_reference key) -{ - iterator where = find(key); - - if (where != m_entries.end()) - { - // Note erasing entries does not invalidate the sort - no need to trigger a re-sort. - m_entries.erase(where); - return 1; - } - - return 0; -} - -template -typename VectorSet::iterator VectorSet::find(const_reference key) -{ - iterator it = lower_bound(key); - if (it != m_entries.end() && key_compare::operator()(key, *it)) - { - it = m_entries.end(); - } - return it; -} - -template -typename VectorSet::const_iterator VectorSet::find(const_reference key) const -{ - const_iterator it = lower_bound(key); - if (it != m_entries.end() && key_compare::operator()(key, *it)) - { - it = m_entries.end(); - } - return it; -} - -template -typename VectorSet::allocator_type VectorSet::get_allocator() const -{ - return m_entries.get_allocator(); -} - -template -std::pair::iterator, bool> VectorSet::insert(const_reference value) -{ - iterator it = lower_bound(value); - bool insertionMade = false; - if (it == m_entries.end() || key_compare::operator()(value, (*it))) - { - it = m_entries.insert(it, value), insertionMade = true; - } - return std::make_pair(it, insertionMade); -} - -template -typename VectorSet::iterator VectorSet::insert(iterator where, const_reference value) -{ - return insert(value); -} - -template -template -void VectorSet::insert(InputIterator first, InputIterator last) -{ - for (; first != last; ++first) - { - insert(*first); - } -} - -template -typename VectorSet::key_compare VectorSet::key_comp() const -{ - return static_cast(*this); -} - -template -typename VectorSet::const_iterator VectorSet::lower_bound(const_reference key) const -{ - return std::lower_bound(m_entries.begin(), m_entries.end(), key, static_cast(*this)); -} - -template -typename VectorSet::iterator VectorSet::lower_bound(const_reference key) -{ - return std::lower_bound(m_entries.begin(), m_entries.end(), key, static_cast(*this)); -} - -template -typename VectorSet::size_type VectorSet::max_size() const -{ - return m_entries.max_size(); -} - -template -typename VectorSet::const_reverse_iterator VectorSet::rbegin() const -{ - return m_entries.rbegin(); -} - -template -typename VectorSet::reverse_iterator VectorSet::rbegin() -{ - return m_entries.rbegin(); -} - -template -typename VectorSet::const_reverse_iterator VectorSet::rend() const -{ - return m_entries.rend(); -} - -template -typename VectorSet::reverse_iterator VectorSet::rend() -{ - return m_entries.rend(); -} - -template -void VectorSet::reserve(size_type count) -{ - m_entries.reserve(count); -} - -template -typename VectorSet::size_type VectorSet::size() const -{ - return m_entries.size(); -} - -template -void VectorSet::swap(VectorSet& other) -{ - m_entries.swap(other.m_entries); - std::swap(static_cast(*this), static_cast(other)); -} - -template -typename VectorSet::const_iterator VectorSet::upper_bound(const_reference key) const -{ - const_iterator upper = lower_bound(key); - if (upper != m_entries.end() && !key_compare::operator()(key, *upper)) - { - ++upper; - } - return upper; -} - -template -typename VectorSet::iterator VectorSet::upper_bound(const_reference key) -{ - iterator upper = lower_bound(key); - if (upper != m_entries.end() && !key_compare::operator()(key, *upper)) - { - ++upper; - } - return upper; -} - -template -typename VectorSet::value_compare VectorSet::value_comp() const -{ - return static_cast(*this); -} - -template -typename VectorSet::reference VectorSet::operator[](int index) -{ - return m_entries[index]; -} - -template -typename VectorSet::const_reference VectorSet::operator[](int index) const -{ - return m_entries[index]; -} - -#endif // CRYINCLUDE_CRYCOMMON_VECTORSET_H diff --git a/Code/Legacy/CryCommon/Vertex.h b/Code/Legacy/CryCommon/Vertex.h index b9e0b25d38..f4e8f71a56 100644 --- a/Code/Legacy/CryCommon/Vertex.h +++ b/Code/Legacy/CryCommon/Vertex.h @@ -9,6 +9,9 @@ #include #include #include +#include +#include + namespace AZ { namespace Vertex @@ -77,7 +80,7 @@ namespace AZ UInt32_4, NumTypes - }; + }; struct AttributeTypeData { @@ -127,15 +130,15 @@ namespace AZ return (static_cast(type) << kUsageBitCount) | static_cast(usage); } static AttributeUsage GetUsage(const uint8 attribute) - { + { return static_cast(attribute & kUsageMask); } static AttributeType GetType(const uint8 attribute) - { + { return static_cast((attribute & kTypeMask) >> kUsageBitCount); } static uint8 GetByteLength(const uint8 attribute) - { + { return AttributeTypeDataTable[(uint)GetType(attribute)].byteSize; } static const AZStd::string& GetSemanticName(uint8 attribute) @@ -167,126 +170,22 @@ namespace AZ AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); m_enum = eVF_P3F_C4B_T2F; break; - case eVF_P3F_C4B_T2F_T2F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - m_enum = eVF_P3F_C4B_T2F_T2F; - break; case eVF_P3S_C4B_T2S: AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float16_4));// vec3f16 is backed by a CryHalf4 AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float16_2)); m_enum = eVF_P3S_C4B_T2S; break; - case eVF_P3S_C4B_T2S_T2S: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float16_4));// vec3f16 is backed by a CryHalf4 - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float16_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float16_2)); - m_enum = eVF_P3S_C4B_T2S_T2S; - break; - case eVF_P3S_N4B_C4B_T2S: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float16_4));// vec3f16 is backed by a CryHalf4 - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Normal, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float16_2)); - m_enum = eVF_P3S_N4B_C4B_T2S; - break; - case eVF_P3F_C4B_T4B_N3F2: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Tangent, AttributeType::Float32_3));//x-axis - AddAttribute(Attribute::CreateAttribute(AttributeUsage::BiTangent, AttributeType::Float32_3));//y-axis -#ifdef PARTICLE_MOTION_BLUR // Nonfunctional and disabled. - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3));//prevPos - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Tangent, AttributeType::Float32_3));//prevXTan - AddAttribute(Attribute::CreateAttribute(AttributeUsage::BiTangent, AttributeType::Float32_3));//prevYTan -#endif - m_enum = eVF_P3F_C4B_T4B_N3F2;// Particles. - break; - case eVF_TP3F_C4B_T2F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - m_enum = eVF_TP3F_C4B_T2F;// Fonts (28 bytes). - break; - case eVF_TP3F_T2F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_TP3F_T2F_T3F; - break; - case eVF_P3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_T3F; // Miscellaneus. - break; - case eVF_P3F_T2F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_T2F_T3F; - break; // Additional streams - case eVF_T2F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - m_enum = eVF_T2F; // Light maps TC (8 bytes). - break; case eVF_W4B_I4S:// Skinned weights/indices stream. AddAttribute(Attribute::CreateAttribute(AttributeUsage::Weights, AttributeType::Byte_4)); AddAttribute(Attribute::CreateAttribute(AttributeUsage::Indices, AttributeType::UInt16_4)); m_enum = eVF_W4B_I4S; break; - case eVF_C4B_C4B:// SH coefficients. - // We use the "Weights" usage since sh coefs use an unknown usage of 4 bytes. - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Weights, AttributeType::Byte_4)); //coef0 - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Weights, AttributeType::Byte_4)); //coef1 - m_enum = eVF_C4B_C4B; - break; - case eVF_P3F_P3F_I4B:// Shape deformation stream. - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); //thin - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); //fat - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Indices, AttributeType::Byte_4)); - m_enum = eVF_P3F_P3F_I4B; - break; case eVF_P3F:// Velocity stream. AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); m_enum = eVF_P3F; break; - case eVF_C4B_T2S: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float16_2)); - m_enum = eVF_C4B_T2S;// General (Position is merged with Tangent stream) - break; - case eVF_P2F_T4F_C4F: // Lens effects simulation - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - m_enum = eVF_P2F_T4F_C4F; - break; - case eVF_P2F_T4F_T4F_C4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - m_enum = eVF_P2F_T4F_T4F_C4F; - break; - case eVF_P2S_N4B_C4B_T1F:// terrain - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float16_2));// xy-coordinates in terrain - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Normal, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1));// z-coordinate in terrain - m_enum = eVF_P2S_N4B_C4B_T1F; - break; - case eVF_P3F_C4B_T2S: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float16_2)); - m_enum = eVF_P3F_C4B_T2S; - break; case eVF_P2F_C4B_T2F_F4B: AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_2)); AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); @@ -299,546 +198,6 @@ namespace AZ AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Byte_4)); m_enum = eVF_P3F_C4B; break; - case eVF_P3F_C4F_T2F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - m_enum = eVF_P3F_C4F_T2F; - break; - case eVF_P3F_C4F_T2F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T3F; - break; - case eVF_P3F_C4F_T2F_T3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T3F_T3F; - break; - case eVF_P3F_C4F_T2F_T1F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - m_enum = eVF_P3F_C4F_T2F_T1F; - break; - case eVF_P3F_C4F_T2F_T1F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T1F_T3F; - break; - case eVF_P3F_C4F_T2F_T1F_T3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T1F_T3F_T3F; - break; - case eVF_P3F_C4F_T4F_T2F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - m_enum = eVF_P3F_C4F_T4F_T2F; - break; - case eVF_P3F_C4F_T4F_T2F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T4F_T2F_T3F; - break; - case eVF_P3F_C4F_T4F_T2F_T3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T4F_T2F_T3F_T3F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T3F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T3F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F; - break; - case eVF_P4F_T2F_C4F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P4F_T2F_C4F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T4F; - break; - case eVF_P3F_C4F_T2F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T3F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T3F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T1F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T1F_T4F; - break; - case eVF_P3F_C4F_T2F_T1F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T1F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T3F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F; - break; - case eVF_P4F_T2F_C4F_T4F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P4F_T2F_C4F_T4F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T3F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T3F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T1F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T1F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T1F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T1F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T4F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T4F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F_T4F; - break; - case eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_1)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_3)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F_T4F; - break; - case eVF_P4F_T2F_C4F_T4F_T4F_T4F_T4F: - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Position, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_2)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::Color, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - AddAttribute(Attribute::CreateAttribute(AttributeUsage::TexCoord, AttributeType::Float32_4)); - m_enum = eVF_P4F_T2F_C4F_T4F_T4F_T4F_T4F; - break; case eVF_Max: default: AZ_Error("VF", false, "Invalid vertex format"); @@ -854,115 +213,19 @@ namespace AZ static const uint8 kHas16BitFloatTexCoords = 0x2; static const uint8 kHas32BitFloatTexCoords = 0x1; - - //! Helper function to check to see if the vertex format has a position attribute that uses 16 bit floats for the underlying type - bool Has16BitFloatPosition() const - { - return (m_flags & kHas16BitFloatPosition) != 0x0; - } - - //! Helper function to check to see if the vertex format has a texture coordinate attribute that uses 16 bit floats for the underlying type - bool Has16BitFloatTextureCoordinates() const - { - return (m_flags & kHas16BitFloatTexCoords) != 0x0; - } - - //! Helper function to check to see if the vertex format has a texture coordinate attribute that uses 32 bit floats for the underlying type - bool Has32BitFloatTextureCoordinates() const - { - return (m_flags & kHas32BitFloatTexCoords) != 0x0; - } - uint32 GetAttributeUsageCount(AttributeUsage usage) const { return (uint32)m_attributeUsageCounts[(uint)usage]; } - bool TryGetAttributeOffsetAndType(AttributeUsage usage, uint32 index, uint& outOffset, AttributeType& outType) const - { - outOffset = 0; - outType = AttributeType::NumTypes; - for (uint ii=0; ii < m_numAttributes; ++ii) - { - uint8 attribute = m_vertexAttributes[ii]; - if (Attribute::GetUsage(attribute) == usage) - { - if (index == 0) - { - outType = Attribute::GetType(attribute); - return true; - } - else - { - --index; - } - } - outOffset += Attribute::GetByteLength(attribute); - } - return false; - } - - uint8 GetAttributeByteLength(AttributeUsage usage) const - { - for (uint ii = 0; ii < m_numAttributes; ++ii) - { - uint8 attribute = m_vertexAttributes[ii]; - if (Attribute::GetUsage(attribute) == usage) - { - return Attribute::GetByteLength(attribute); - } - } - return 0; - } - - const uint8* GetAttributes( uint32 &outCount) const { outCount = m_numAttributes; return m_vertexAttributes; } - //! Return true if the vertex format is a superset of the input - bool IsSupersetOf(const AZ::Vertex::Format& input) const - { - uint32 count = 0; - const uint8* attributes = input.GetAttributes(count); - for ( uint8 ii=0; ii(stride); } - + #ifdef PARTICLE_MOTION_BLUR @@ -1056,34 +319,5 @@ namespace AZ uint8 m_flags = 0x0; }; - - // bNeedNormals=1 - float normals; bNeedNormals=2 - byte normals //waltont TODO (this was copied as is from vertexformats.h) this comment is out of date and the function does not even use all the parameters. This should be replaceable with the new vertex class, and should be replaced when refactoring CHWShader_D3D::mfVertexFormat which handles the shader parsing/serialization - _inline Format VertFormatForComponents([[maybe_unused]] bool bNeedCol, [[maybe_unused]] bool bHasTC, bool bHasTC2, bool bHasPS, bool bHasNormal) - { - AZ::Vertex::Format RequestedVertFormat; - - if (bHasPS) - { - RequestedVertFormat = AZ::Vertex::Format(eVF_P3F_C4B_T4B_N3F2); - } - else - if (bHasNormal) - { - RequestedVertFormat = AZ::Vertex::Format(eVF_P3S_N4B_C4B_T2S); - } - else - { - if (!bHasTC2) - { - RequestedVertFormat = AZ::Vertex::Format(eVF_P3S_C4B_T2S); - } - else - { - RequestedVertFormat = AZ::Vertex::Format(eVF_P3F_C4B_T2F_T2F); - } - } - - return RequestedVertFormat; - } } } diff --git a/Code/Legacy/CryCommon/VertexFormats.h b/Code/Legacy/CryCommon/VertexFormats.h index 2231d4dfd0..8f5d0f0923 100644 --- a/Code/Legacy/CryCommon/VertexFormats.h +++ b/Code/Legacy/CryCommon/VertexFormats.h @@ -7,12 +7,9 @@ */ -#ifndef CRYINCLUDE_CRYCOMMON_VERTEXFORMATS_H -#define CRYINCLUDE_CRYCOMMON_VERTEXFORMATS_H - #pragma once -#include +#include // Stream Configuration options #define ENABLE_NORMALSTREAM_SUPPORT 1 @@ -22,94 +19,16 @@ enum EVertexFormat : uint8 // Base stream eVF_P3F_C4B_T2F, - eVF_P3F_C4B_T2F_T2F, eVF_P3S_C4B_T2S, - eVF_P3S_C4B_T2S_T2S, // For UV2 support - eVF_P3S_N4B_C4B_T2S, - - eVF_P3F_C4B_T4B_N3F2, // Particles. - eVF_TP3F_C4B_T2F, // Fonts (28 bytes). - eVF_TP3F_T2F_T3F, // Miscellaneus. - eVF_P3F_T3F, // Miscellaneus. (AuxGeom) - eVF_P3F_T2F_T3F, // Miscellaneus. // Additional streams - eVF_T2F, // Light maps TC (8 bytes). eVF_W4B_I4S, // Skinned weights/indices stream. - eVF_C4B_C4B, // SH coefficients. - eVF_P3F_P3F_I4B, // Shape deformation stream. eVF_P3F, // Velocity stream. - eVF_C4B_T2S, // General (Position is merged with Tangent stream) - // Lens effects simulation - eVF_P2F_T4F_C4F, // primary - eVF_P2F_T4F_T4F_C4F, - eVF_P2S_N4B_C4B_T1F, - eVF_P3F_C4B_T2S, eVF_P2F_C4B_T2F_F4B, // UI eVF_P3F_C4B,// Auxiliary geometry - - - eVF_P3F_C4F_T2F, //numbering for tracking the new vertex formats and for comparison with testing 23 - eVF_P3F_C4F_T2F_T3F, - eVF_P3F_C4F_T2F_T3F_T3F, - eVF_P3F_C4F_T2F_T1F, - eVF_P3F_C4F_T2F_T1F_T3F, - eVF_P3F_C4F_T2F_T1F_T3F_T3F, - eVF_P3F_C4F_T4F_T2F, - eVF_P3F_C4F_T4F_T2F_T3F, //30 - eVF_P3F_C4F_T4F_T2F_T3F_T3F, - eVF_P3F_C4F_T4F_T2F_T1F, - eVF_P3F_C4F_T4F_T2F_T1F_T3F, - eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F, - eVF_P3F_C4F_T2F_T2F_T1F, //35 - eVF_P3F_C4F_T2F_T2F_T1F_T3F, - eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F, //40 - eVF_P4F_T2F_C4F_T4F_T4F, - eVF_P3F_C4F_T2F_T4F, - eVF_P3F_C4F_T2F_T3F_T4F, - eVF_P3F_C4F_T2F_T3F_T3F_T4F, - eVF_P3F_C4F_T2F_T1F_T4F, //45 - eVF_P3F_C4F_T2F_T1F_T3F_T4F, - eVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F, - eVF_P3F_C4F_T4F_T2F_T4F, - eVF_P3F_C4F_T4F_T2F_T3F_T4F, - eVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F, //50 - eVF_P3F_C4F_T4F_T2F_T1F_T4F, - eVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F, - eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F, //55 - eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F, - eVF_P4F_T2F_C4F_T4F_T4F_T4F, //60 - eVF_P3F_C4F_T2F_T4F_T4F, - eVF_P3F_C4F_T2F_T3F_T4F_T4F, - eVF_P3F_C4F_T2F_T3F_T3F_T4F_T4F, - eVF_P3F_C4F_T2F_T1F_T4F_T4F, - eVF_P3F_C4F_T2F_T1F_T3F_T4F_T4F, //65 - eVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F_T4F, - eVF_P3F_C4F_T4F_T2F_T4F_T4F, - eVF_P3F_C4F_T4F_T2F_T3F_T4F_T4F, - eVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F_T4F, - eVF_P3F_C4F_T4F_T2F_T1F_T4F_T4F, //70 - eVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F_T4F, - eVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T4F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F_T4F, //75 - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F_T4F, - eVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F_T4F, - eVF_P4F_T2F_C4F_T4F_T4F_T4F_T4F, - eVF_Max, }; @@ -143,8 +62,6 @@ struct UCol (bcolor[2] - 128.0f) / 127.5f ); } - - AUTO_STRUCT_INFO }; struct Vec3f16 @@ -242,14 +159,6 @@ struct SVF_P3F_C4B_T2F Vec2 st; }; -struct SVF_P3F_C4B_T2F_T2F -{ - Vec3 xyz; - UCol color; - Vec2 st; - Vec2 st2; -}; - struct SVF_P2F_C4B_T2F_F4B { Vec2 xy; @@ -261,743 +170,23 @@ struct SVF_P2F_C4B_T2F_F4B uint8 pad; }; -struct SVF_TP3F_C4B_T2F //Fonts -{ - Vec4 pos; - UCol color; - Vec2 st; -}; struct SVF_P3S_C4B_T2S { Vec3f16 xyz; UCol color; Vec2f16 st; - - AUTO_STRUCT_INFO }; -struct SVF_P3S_C4B_T2S_T2S -{ - Vec3f16 xyz; - UCol color; - Vec2f16 st; - Vec2f16 st2; - - AUTO_STRUCT_INFO -}; - -struct SVF_P3F_C4B_T2S -{ - Vec3 xyz; - UCol color; - Vec2f16 st; -}; - -struct SVF_P3S_N4B_C4B_T2S -{ - Vec3f16 xyz; - UCol normal; - UCol color; - Vec2f16 st; -}; - -struct SVF_P2S_N4B_C4B_T1F -{ - CryHalf2 xy; - UCol normal; - UCol color; - float z; -}; - -struct SVF_T2F -{ - Vec2 st; -}; struct SVF_W4B_I4S { UCol weights; uint16 indices[4]; }; -struct SVF_C4B_C4B -{ - UCol coef0; - UCol coef1; -}; -struct SVF_P3F_P3F_I4B -{ - Vec3 thin; - Vec3 fat; - UCol index; -}; + struct SVF_P3F { Vec3 xyz; }; -struct SVF_P3F_T3F -{ - Vec3 p; - Vec3 st; -}; -struct SVF_P3F_T2F_T3F -{ - Vec3 p; - Vec2 st0; - Vec3 st1; -}; -struct SVF_TP3F_T2F_T3F -{ - Vec4 p; - Vec2 st0; - Vec3 st1; -}; -struct SVF_P2F_T4F_C4F -{ - Vec2 p; - Vec4 st; - Vec4 color; -}; - -struct SVF_P2F_T4F_T4F_C4F -{ - Vec2 p; - Vec4 st; - Vec4 st2; - Vec4 color; -}; - -struct SVF_P3F_C4B_I4B_PS4F -{ - Vec3 xyz; - Vec2 prevXaxis; - Vec2 prevYaxis; - UCol color; - Vec3 prevPos; - struct SpriteInfo - { - uint8 tex_x, tex_y, tex_z, backlight; // xyzw - } info; - Vec2 xaxis; - Vec2 yaxis; -}; - -struct SVF_P3F_C4B_T4B_N3F2 -{ - Vec3 xyz; - UCol color; - UCol st; // st is used as a color, even though st usually refers to a TexCoord - Vec3 xaxis; - Vec3 yaxis; -#ifdef PARTICLE_MOTION_BLUR - Vec3 prevPos; - Vec3 prevXTan; - Vec3 prevYTan; -#endif -}; - -struct SVF_C4B_T2S -{ - UCol color; - Vec2f16 st; -}; - -struct SVF_P3F_C4F_T2F -{ - Vec3 xyz; - Vec4 color; - Vec2 st; -}; - -struct SVF_P3F_C4F_T2F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec3 st1; -}; - -struct SVF_P3F_C4F_T2F_T3F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec3 st1; - Vec3 st2; -}; - -struct SVF_P3F_C4F_T2F_T1F -{ - Vec3 xyz; - Vec4 color; - Vec2 st; - float z; -}; - -struct SVF_P3F_C4F_T2F_T1F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec3 st1; -}; - -struct SVF_P3F_C4F_T2F_T1F_T3F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec3 st1; - Vec3 st2; -}; - - -struct SVF_P3F_C4F_T4F_T2F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; -}; - -struct SVF_P3F_C4F_T4F_T2F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec3 st2; -}; - -struct SVF_P3F_C4F_T4F_T2F_T3F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec3 st2; - Vec3 st3; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec3 st2; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec3 st3; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec3 st2; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec3 st3; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec3 st2; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec3 st2; - Vec3 st3; -}; - -struct SVF_P4F_T2F_C4F_T4F_T4F -{ - Vec4 xyzw; - Vec2 st0; - Vec4 color; - Vec4 st1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec4 st1; -}; - -struct SVF_P3F_C4F_T2F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec3 st1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T3F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec3 st1; - Vec3 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T1F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec4 st1; -}; - -struct SVF_P3F_C4F_T2F_T1F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec3 st1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec3 st1; - Vec3 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T4F_T2F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T4F_T2F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec3 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec3 st2; - Vec3 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec3 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec3 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec3 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec3 st2; - Vec3 st3; - Vec4 st4; -}; - -struct SVF_P4F_T2F_C4F_T4F_T4F_T4F -{ - Vec4 xyzw; - Vec2 st0; - Vec4 color; - Vec4 st1; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec4 st1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec3 st1; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T3F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec3 st1; - Vec3 st2; - Vec4 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T2F_T1F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec4 st1; - Vec4 st2; -}; - -struct SVF_P3F_C4F_T2F_T1F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec3 st1; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T1F_T3F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - float z; - Vec3 st1; - Vec3 st2; - Vec4 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T4F_T2F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T4F_T2F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec3 st2; - Vec4 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T4F_T2F_T3F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - Vec3 st2; - Vec3 st3; - Vec4 st4; - Vec4 st5; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec4 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T4F_T2F_T1F_T3F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec4 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec3 st3; - Vec4 st4; - Vec4 st5; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec4 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T3F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z; - Vec3 st2; - Vec3 st3; - Vec4 st4; - Vec4 st5; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec4 st2; - Vec4 st3; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec3 st2; - Vec4 st3; - Vec4 st4; -}; - -struct SVF_P3F_C4F_T2F_T2F_T1F_T1F_T3F_T3F_T4F_T4F -{ - Vec3 xyz; - Vec4 color; - Vec2 st0; - Vec2 st1; - float z0; - float z1; - Vec3 st2; - Vec3 st3; - Vec4 st4; - Vec4 st5; -}; - -struct SVF_P4F_T2F_C4F_T4F_T4F_T4F_T4F -{ - Vec4 xyzw; - Vec2 st0; - Vec4 color; - Vec4 st1; - Vec4 st2; - Vec4 st3; - Vec4 st4; -}; - //============================================================= // Signed norm value packing [-1,+1] @@ -1240,8 +429,6 @@ public: *this = SPipTangents(tng3, btg3, PackingSNorm::tPackB2S(Tangent.w)); } - - friend struct SMeshTangents; }; struct SPipQTangents @@ -1290,8 +477,6 @@ public: const Quat q = GetQ(); return q.GetColumn2() * (q.w < 0.0f ? -1.0f : +1.0f); } - - friend struct SMeshQTangents; }; struct SPipNormal @@ -1328,8 +513,6 @@ struct SPipNormal // normalize in case "trn" wasn't length-preserving *this = SPipNormal(trn.TransformVector(*this).normalize()); } - - friend struct SMeshNormal; }; //================================================================================================== @@ -1364,24 +547,4 @@ enum EStreamIDs VSF_MORPHBUDDY_WEIGHTS = 15, // Morphing weights }; -// Stream Masks (Used during updating) -enum EStreamMasks -{ - VSM_GENERAL = 1 << VSF_GENERAL, - VSM_TANGENTS = ((1 << VSF_TANGENTS) | (1 << VSF_QTANGENTS)), - VSM_HWSKIN = 1 << VSF_HWSKIN_INFO, - VSM_VERTEX_VELOCITY = 1 << VSF_VERTEX_VELOCITY, -# if ENABLE_NORMALSTREAM_SUPPORT - VSM_NORMALS = 1 << VSF_NORMALS, -#endif - - VSM_MORPHBUDDY = 1 << VSF_MORPHBUDDY, - VSM_INSTANCED = 1 << VSF_INSTANCED, - - VSM_MASK = ((1 << VSF_NUM) - 1), -}; - //================================================================================================================== - -#endif // CRYINCLUDE_CRYCOMMON_VERTEXFORMATS_H - diff --git a/Code/Legacy/CryCommon/crycommon_files.cmake b/Code/Legacy/CryCommon/crycommon_files.cmake index 7131eb7207..2f5030ccc4 100644 --- a/Code/Legacy/CryCommon/crycommon_files.cmake +++ b/Code/Legacy/CryCommon/crycommon_files.cmake @@ -7,18 +7,15 @@ # set(FILES - CryCommon.cpp IAudioInterfacesCommonData.h IAudioSystem.h ICmdLine.h IConsole.h IEntityRenderState.h - IEntityRenderState_info.cpp IFont.h IFunctorBase.h IGem.h IIndexedMesh.h - IIndexedMesh_info.cpp ILevelSystem.h ILocalizationManager.h LocalizationManagerBus.h @@ -27,19 +24,15 @@ set(FILES IMaterial.h IMiniLog.h IMovieSystem.h - IPhysics.h - IPostEffectGroup.h IProcess.h IReadWriteXMLSink.h IRenderAuxGeom.h IRenderer.h - IRenderMesh.h ISerialize.h IShader.h ISplines.h IStatObj.h StatObjBus.h - IStereoRenderer.h ISurfaceType.h ISystem.h ITexture.h @@ -49,42 +42,31 @@ set(FILES IWindowMessageHandler.h IXml.h MicrophoneBus.h - physinterface.h HMDBus.h VRCommon.h - StereoRendererBus.h INavigationSystem.h IMNM.h SFunctor.h FunctorBaseFunction.h FunctorBaseMember.h - stridedptr.h - Options.h SerializationTypes.h CryEndian.h CryRandomInternal.h Random.h LCGRandom.h - CryTypeInfo.cpp BaseTypes.h - MemoryAccess.h AnimKey.h BitFiddling.h Common_TypeInfo.cpp - CryArray.h CryAssert.h CryCrc32.h - CryCustomTypes.h CryFile.h - CryHeaders.h - CryHeaders_info.cpp CryListenerSet.h CryLegacyAllocator.h CryPath.h CryPodArray.h CrySizer.h CrySystemBus.h - CryTypeInfo.h CryVersion.h LegacyAllocator.cpp LegacyAllocator.h @@ -93,7 +75,6 @@ set(FILES MultiThread_Containers.h NullAudioSystem.h PNoise3.h - primitives.h ProjectDefines.h Range.h ScopedVariableSetter.h @@ -102,14 +83,9 @@ set(FILES smartptr.h StlUtils.h Synchronization.h - Tarray.h Timer.h TimeValue.h - TimeValue_info.h - TypeInfo_decl.h - TypeInfo_impl.h VectorMap.h - VectorSet.h VertexFormats.h XMLBinaryHeaders.h RenderBus.h @@ -123,13 +99,11 @@ set(FILES Cry_Geo.h Cry_GeoDistance.h Cry_GeoIntersect.h - Cry_GeoOverlap.h Cry_Math.h Cry_Quat.h Cry_ValidNumber.h Cry_Vector2.h Cry_Vector3.h - CryHalf_info.h CryHalf.inl MathConversion.h Cry_HWMatrix.h diff --git a/Code/Legacy/CryCommon/physinterface.h b/Code/Legacy/CryCommon/physinterface.h deleted file mode 100644 index 06d07af82b..0000000000 --- a/Code/Legacy/CryCommon/physinterface.h +++ /dev/null @@ -1,24 +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 : declarations of all physics interfaces and structures -#pragma once - - -#include - -#include "Cry_Geo.h" -#include "stridedptr.h" -#include "primitives.h" -#ifdef NEED_ENDIAN_SWAP - #include "CryEndian.h" -#endif - -#include -#include diff --git a/Code/Legacy/CryCommon/platform.h b/Code/Legacy/CryCommon/platform.h index 3b80079c0f..37f0636c3a 100644 --- a/Code/Legacy/CryCommon/platform.h +++ b/Code/Legacy/CryCommon/platform.h @@ -353,12 +353,6 @@ void SetFlags(T& dest, U flags, bool b) #include AZ_RESTRICTED_FILE(platform_h) #endif -// Include support for meta-type data. -#include "TypeInfo_decl.h" - -// Include array. -#include - bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes); threadID CryGetCurrentThreadId(); diff --git a/Code/Legacy/CryCommon/primitives.h b/Code/Legacy/CryCommon/primitives.h deleted file mode 100644 index e44690a977..0000000000 --- a/Code/Legacy/CryCommon/primitives.h +++ /dev/null @@ -1,294 +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_PRIMITIVES_H -#define CRYINCLUDE_CRYCOMMON_PRIMITIVES_H -#pragma once - - - -typedef int index_t; -enum -{ - PHYS_MAX_INDICES = 1 << 30 -}; - -#include "stridedptr.h" - -namespace primitives { - ////////////////////////// primitives ////////////////////// - - struct primitive - { - }; - - struct box - : primitive - { - enum entype - { - type = 0 - }; - Matrix33 Basis; // v_box = Basis*v_world; Basis = Rotation.T() - int bOriented; - Vec3 center; - Vec3 size; - AUTO_STRUCT_INFO - }; - - struct triangle - : primitive - { - enum entype - { - type = 1 - }; - Vec3 pt[3]; - Vec3 n; - AUTO_STRUCT_INFO - }; - - struct indexed_triangle - : triangle - { - int idx; - AUTO_STRUCT_INFO - }; - - typedef float (* getHeightCallback)(int ix, int iy); - typedef unsigned char (* getSurfTypeCallback)(int ix, int iy); - - struct grid - : primitive - { - Matrix33 Basis; - int bOriented; - Vec3 origin; - vector2df step, stepr; - vector2di size; - vector2di stride; - int bCyclic; - grid() { bCyclic = 0; } - int inrange(int ix, int iy) { return bCyclic | -((ix - size.x & - 1 - ix & iy - size.y & - 1 - iy) >> 31); } - int getcell_safe(int ix, int iy) { int mask = -inrange(ix, iy); return (iy & size.y - 1) * stride.y + (ix & size.x - 1) * stride.x & mask | size.x * size.y & ~mask; } - int crop(int i, int icoord, int bAllowBorder = 1) { int brd = bAllowBorder + (1 << 30 & - bCyclic); return max(-brd, min(size[icoord] - 1 + brd, i)); } - vector2di cropxy(const vector2di& ic, int bAllowBorder = 1) { int brd = bAllowBorder + (1 << 30 & - bCyclic); return vector2di(max(-brd, min(size.x - 1 + brd, ic.x)), max(-brd, min(size.y - 1 + brd, ic.y))); } - int iscyclic() { return bCyclic; } - AUTO_STRUCT_INFO - }; - - struct heightfield - : grid - { - enum entype - { - type = 2 - }; - heightfield& operator=(const heightfield& src) - { - step = src.step; - stepr = src.stepr; - size = src.size; - stride = src.stride; - heightscale = src.heightscale; - typemask = src.typemask; - typehole = src.typehole; - typepower = src.typepower; - fpGetHeightCallback = src.fpGetHeightCallback; - fpGetSurfTypeCallback = src.fpGetSurfTypeCallback; - return *this; - } - - ILINE float getheight(int ix, int iy) const - { - float result = (*fpGetHeightCallback)(ix, iy); - return result * heightscale; - } - ILINE int gettype(int ix, int iy) const - { - int itype = (((*fpGetSurfTypeCallback)(ix, iy)) & typemask) >> typepower, idelta = itype - typehole; - return itype | ((idelta - 1) >> 31 ^ idelta >> 31); - } - - float heightscale; - unsigned short typemask; - int typehole; - int typepower; - getHeightCallback fpGetHeightCallback; - getSurfTypeCallback fpGetSurfTypeCallback; - }; - - struct ray - : primitive - { - enum entype - { - type = 3 - }; - Vec3 origin; - Vec3 dir; - AUTO_STRUCT_INFO - }; - - struct sphere - : primitive - { - enum entype - { - type = 4 - }; - Vec3 center; - float r; - AUTO_STRUCT_INFO - }; - - struct cylinder - : primitive - { - enum entype - { - type = 5 - }; - Vec3 center; - Vec3 axis; - float r, hh; - AUTO_STRUCT_INFO - }; - - struct capsule - : cylinder - { - enum entype - { - type = 6 - }; - AUTO_STRUCT_INFO - }; - - struct grid3d - : primitive - { - Matrix33 Basis; - int bOriented; - Vec3 origin; - Vec3 step, stepr; - Vec3i size; - Vec3i stride; - }; - - struct voxelgrid - : grid3d - { - enum entype - { - type = 7 - }; - Matrix33 R; - Vec3 offset; - float scale, rscale; - strided_pointer pVtx; - index_t* pIndices; - Vec3* pNormals; - char* pIds; - int* pCellTris; - int* pTriBuf; - }; - - struct plane - : primitive - { - enum entype - { - type = 8 - }; - Vec3 n; - Vec3 origin; - AUTO_STRUCT_INFO - }; - - struct coord_plane - : plane - { - Vec3 axes[2]; - AUTO_STRUCT_INFO - }; -} - -AUTO_TYPE_INFO(primitives::getHeightCallback) -AUTO_TYPE_INFO(primitives::getSurfTypeCallback) - -struct prim_inters -{ - prim_inters() { minPtDist2 = 0.0f; ptbest.zero(); } - Vec3 pt[2]; - Vec3 n; - unsigned char iFeature[2][2]; - float minPtDist2; - short id[2]; - int iNode[2]; - Vec3* ptborder; - int nborderpt, nbordersz; - Vec3 ptbest; - int nBestPtVal; -}; - -struct contact -{ - real t, taux; - Vec3 pt; - Vec3 n; - unsigned int iFeature[2]; -}; - -const int NPRIMS = 8; // since plane is currently not supported in collision checks - -///////////////////// geometry contact structures /////////////////// - -struct geom_contact_area -{ - enum entype - { - polygon, polyline - }; - int type; - int npt; - int nmaxpt; - float minedge; - int* piPrim[2]; - int* piFeature[2]; - Vec3* pt; - Vec3 n1; // normal of other object surface (or edge) -}; - -const int IFEAT_LOG2 = 23; -const int IDXMASK = ~(0xFF << IFEAT_LOG2); -const int TRIEND = 0x80 << IFEAT_LOG2; - -struct geom_contact -{ - real t; - Vec3 pt; - Vec3 n; - Vec3 dir; // unprojection direction - int iUnprojMode; - float vel; // original velocity along this direction, <0 if least squares normal was used - int id[2]; // external ids for colliding geometry parts - int iPrim[2]; - int iFeature[2]; - int iNode[2]; // BV-tree nodes of contacting primitives - Vec3* ptborder; // intersection border - int (*idxborder)[2]; // primitive index | primitive's feature's id << IFEAT_LOG2 - int nborderpt; - int bClosed; - Vec3 center; - bool bBorderConsecutive; - geom_contact_area* parea; -}; - -#endif // CRYINCLUDE_CRYCOMMON_PRIMITIVES_H diff --git a/Code/Legacy/CryCommon/smartptr.h b/Code/Legacy/CryCommon/smartptr.h index baf51d5030..ec2b437696 100644 --- a/Code/Legacy/CryCommon/smartptr.h +++ b/Code/Legacy/CryCommon/smartptr.h @@ -146,8 +146,6 @@ public: { std::swap(p, other.p); } - - AUTO_STRUCT_INFO }; template diff --git a/Code/Legacy/CryCommon/stridedptr.h b/Code/Legacy/CryCommon/stridedptr.h deleted file mode 100644 index 8a74aa97b1..0000000000 --- a/Code/Legacy/CryCommon/stridedptr.h +++ /dev/null @@ -1,114 +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_STRIDEDPTR_H -#define CRYINCLUDE_CRYCOMMON_STRIDEDPTR_H -#pragma once - -#include -#include - -template -class strided_pointer -{ -public: - strided_pointer() - : data(0) - , iStride(sizeof(dtype)) - { - } - - strided_pointer(dtype* pdata, int32 stride = sizeof(dtype)) - : data(pdata) - , iStride(stride) - { - } - - template - strided_pointer(dtype1* pdata) - { - set(pdata, sizeof(dtype1)); - } - - template - strided_pointer(const strided_pointer& src) - { - set(src.data, src.iStride); - } - - template - ILINE strided_pointer& operator=(const strided_pointer& src) - { - set(src.data, src.iStride); - return *this; - } - - ILINE dtype& operator[](int32 idx) { return *(dtype*)((char*)data + idx * iStride); } - ILINE const dtype& operator[](int32 idx) const { return *(const dtype*)((const char*)data + idx * iStride); } - ILINE strided_pointer operator+(int32 idx) const { return strided_pointer((dtype*)((char*)data + idx * iStride), iStride); } - ILINE strided_pointer operator-(int32 idx) const { return strided_pointer((dtype*)((char*)data - idx * iStride), iStride); } - - ILINE operator bool() const - { - return data != 0; - } - -private: - template - ILINE void set(dtype1* pdata, int32 stride) - { -# if !defined(eLittleEndian) -# error eLittleEndian is not defined, please include CryEndian.h. -# endif - static_assert(metautils::is_const::value || !metautils::is_const::value); - // note: we allow xint32 -> xint16 converting - static_assert( - (metautils::is_same::type, typename metautils::remove_const::type>::value || - ((metautils::is_same::type, sint32>::value || - metautils::is_same::type, uint32>::value || - metautils::is_same::type, sint16>::value || - metautils::is_same::type, uint16>::value) && - (metautils::is_same::type, sint16>::value || - metautils::is_same::type, uint16>::value)))); - data = (dtype*)pdata + (sizeof(dtype1) / sizeof(dtype) - 1) * (int)eLittleEndian; - iStride = stride; - } - -private: - // Prevents assignment of a structure member's address by mistake: - // stridedPtrObject = &myStruct.member; - // Use explicit constructor instead: - // stridedPtrObject = strided_pointer(&myStruct.member, sizeof(myStruct)); - // - // Keep it private and non-implemented. - strided_pointer& operator=(dtype* pdata); - - // Prevents using the address directly by mistake: - // memcpy(destination, stridedPtrObject, sizeof(baseType) * n); - // Use address of the first element instead: - // memcpy(destination, &stridedPtrObject[0], stridedPtrObject.iStride * n); - // - // Keep it private and non-implemented. - operator void*() const; - - // Prevents direct dereferencing to avoid confusing it with "normal" pointers: - // val = *stridedPtrObject; - // Use operator [] instead: - // val = stridedPtrObject[0]; - // - // Keep it private and non-implemented. - dtype& operator*() const; - -public: - dtype* data; - int32 iStride; -}; - - -#endif // CRYINCLUDE_CRYCOMMON_STRIDEDPTR_H diff --git a/Code/Legacy/CrySystem/LocalizedStringManager.h b/Code/Legacy/CrySystem/LocalizedStringManager.h index 283eaa79bf..1fba05f9ac 100644 --- a/Code/Legacy/CrySystem/LocalizedStringManager.h +++ b/Code/Legacy/CrySystem/LocalizedStringManager.h @@ -10,9 +10,11 @@ #pragma once #include +#include #include #include #include +#include #include "Huffman.h" @@ -153,9 +155,9 @@ private: CryHalf fVolume; CryHalf fRadioRatio; // SoundMoods - DynArray SoundMoods; + AZStd::vector SoundMoods; // EventParameters - DynArray EventParameters; + AZStd::vector EventParameters; // ~audio specific part // subtitle & radio flags @@ -312,5 +314,3 @@ private: mutable AZStd::mutex m_cs; typedef AZStd::lock_guard AutoLock; }; - - diff --git a/Code/Legacy/CrySystem/SimpleStringPool.h b/Code/Legacy/CrySystem/SimpleStringPool.h index d1a618425c..13be471f9e 100644 --- a/Code/Legacy/CrySystem/SimpleStringPool.h +++ b/Code/Legacy/CrySystem/SimpleStringPool.h @@ -12,7 +12,7 @@ #pragma once #include "ISystem.h" - +#include #include //TODO: Pull most of this into a cpp file! @@ -265,23 +265,6 @@ public: return ret; } - void GetMemoryUsage(ICrySizer* pSizer) const - { - BLOCK* pBlock = m_blocks; - while (pBlock) - { - pSizer->AddObject(pBlock, offsetof(BLOCK, s) + pBlock->size * sizeof(char)); - pBlock = pBlock->next; - } - - pBlock = m_free_blocks; - while (pBlock) - { - pSizer->AddObject(pBlock, offsetof(BLOCK, s) + pBlock->size * sizeof(char)); - pBlock = pBlock->next; - } - } - private: CSimpleStringPool(const CSimpleStringPool&); CSimpleStringPool& operator = (const CSimpleStringPool&); diff --git a/Code/Legacy/CrySystem/System.cpp b/Code/Legacy/CrySystem/System.cpp index 70fb9382e1..0f0a62f8c6 100644 --- a/Code/Legacy/CrySystem/System.cpp +++ b/Code/Legacy/CrySystem/System.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -641,7 +643,7 @@ void CSystem::SleepIfNeeded() allowStallCatchup = true; float totalElapsed = (now - prevNow.Front()).GetSeconds(); - float wantSleepTime = CLAMP(minTime * (prevNow.Size() - 1) - totalElapsed, 0, (minTime - elapsed) * 0.9f); + float wantSleepTime = AZStd::clamp(minTime * (prevNow.Size() - 1) - totalElapsed, 0.0f, (minTime - elapsed) * 0.9f); static float sleepTime = 0; sleepTime = (15 * sleepTime + wantSleepTime) / 16; int sleepMS = (int)(1000.0f * sleepTime + 0.5f); diff --git a/Code/Legacy/CrySystem/ViewSystem/View.cpp b/Code/Legacy/CrySystem/ViewSystem/View.cpp index 7b3883f014..36cd891e3e 100644 --- a/Code/Legacy/CrySystem/ViewSystem/View.cpp +++ b/Code/Legacy/CrySystem/ViewSystem/View.cpp @@ -13,7 +13,6 @@ #include #include "View.h" #include -#include #include #include #include @@ -541,13 +540,13 @@ void CView::GetMemoryUsage(ICrySizer* s) const s->AddObject(m_shakes); } -void CView::Serialize(TSerialize ser) -{ - if (ser.IsReading()) - { - ResetShaking(); - } -} +//void CView::Serialize(TSerialize ser) +//{ +// if (ser.IsReading()) +// { +// ResetShaking(); +// } +//} void CView::PostSerialize() { diff --git a/Code/Legacy/CrySystem/ViewSystem/View.h b/Code/Legacy/CrySystem/ViewSystem/View.h index 58d7e64869..689c254897 100644 --- a/Code/Legacy/CrySystem/ViewSystem/View.h +++ b/Code/Legacy/CrySystem/ViewSystem/View.h @@ -15,6 +15,7 @@ #include class CGameObject; +struct ISystem; namespace LegacyViewSystem { @@ -106,7 +107,6 @@ public: virtual void SetActive(const bool bActive); // ~IView - void Serialize(TSerialize ser) override; void PostSerialize() override; CCamera& GetCamera() override { return m_camera; } const CCamera& GetCamera() const override { return m_camera; } diff --git a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp index 01c7340919..1d141a5e13 100644 --- a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp +++ b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp @@ -617,16 +617,16 @@ void CViewSystem::GetMemoryUsage(ICrySizer* s) const s->AddContainer(m_views); } -void CViewSystem::Serialize(TSerialize ser) -{ - TViewMap::iterator iter = m_views.begin(); - TViewMap::iterator iterEnd = m_views.end(); - while (iter != iterEnd) - { - iter->second->Serialize(ser); - ++iter; - } -} +//void CViewSystem::Serialize(TSerialize ser) +//{ +// TViewMap::iterator iter = m_views.begin(); +// TViewMap::iterator iterEnd = m_views.end(); +// while (iter != iterEnd) +// { +// iter->second->Serialize(ser); +// ++iter; +// } +//} void CViewSystem::PostSerialize() { diff --git a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h index 644a197e46..dd49e09e04 100644 --- a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h +++ b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.h @@ -53,7 +53,6 @@ public: virtual unsigned int GetViewId(IView* pView); virtual unsigned int GetActiveViewId(); - virtual void Serialize(TSerialize ser); virtual void PostSerialize(); virtual IView* GetViewByEntityId(const AZ::EntityId& id, bool forceCreate); diff --git a/Code/Legacy/CrySystem/XConsole.cpp b/Code/Legacy/CrySystem/XConsole.cpp index 88a7fc262e..bb8316981a 100644 --- a/Code/Legacy/CrySystem/XConsole.cpp +++ b/Code/Legacy/CrySystem/XConsole.cpp @@ -1762,7 +1762,7 @@ void CXConsole::ExecuteString(const char* command, const bool bSilentMode, const AZ::StringFunc::TrimWhiteSpace(str, true, false); // Unroll the exec command - + bool unroll = (0 == AZ::StringFunc::Find(str, "exec", 0, false, false)); if (unroll) @@ -2891,75 +2891,6 @@ int CXConsole::GetNumVisibleVars() return numVars; } - -////////////////////////////////////////////////////////////////////////// -bool CXConsole::IsHashCalculated() -{ - return m_bCheatHashDirty == false; -} - -////////////////////////////////////////////////////////////////////////// -int CXConsole::GetNumCheatVars() -{ - return static_cast(m_randomCheckedVariables.size()); -} - -////////////////////////////////////////////////////////////////////////// -uint64 CXConsole::GetCheatVarHash() -{ - return m_nCheatHash; -} - -////////////////////////////////////////////////////////////////////////// -void CXConsole::SetCheatVarHashRange(size_t firstVar, size_t lastVar) -{ - // check inputs are sane -#if !defined(NDEBUG) - size_t numVars = GetNumCheatVars(); - assert(firstVar < numVars && lastVar < numVars && lastVar >= firstVar); -#endif - -#if defined(DEFENCE_CVAR_HASH_LOGGING) - if (m_bCheatHashDirty) - { - CryLog("HASHING: WARNING - trying to set up new cvar hash range while existing hash still calculating!"); - } -#endif - - m_nCheatHashRangeFirst = firstVar; - m_nCheatHashRangeLast = lastVar; - m_bCheatHashDirty = true; -} - -////////////////////////////////////////////////////////////////////////// -void CXConsole::CalcCheatVarHash() -{ - if (!m_bCheatHashDirty) - { - return; - } - - CCrc32 runningNameCrc32; - CCrc32 runningNameValueCrc32; - - AddCVarsToHash(m_randomCheckedVariables.begin() + m_nCheatHashRangeFirst, m_randomCheckedVariables.begin() + m_nCheatHashRangeLast, runningNameCrc32, runningNameValueCrc32); - AddCVarsToHash(m_alwaysCheckedVariables.begin(), m_alwaysCheckedVariables.end() - 1, runningNameCrc32, runningNameValueCrc32); - - // store hash - m_nCheatHash = (((uint64)runningNameCrc32.Get()) << 32) | runningNameValueCrc32.Get(); - m_bCheatHashDirty = false; - -#if defined(DEFENCE_CVAR_HASH_LOGGING) - if (!gEnv->IsDedicated()) - { - CryLog("HASHING: Range %d->%d = %llx(%x,%x), max cvars = %d", m_nCheatHashRangeFirst, m_nCheatHashRangeLast, - m_nCheatHash, runningNameCrc32.Get(), runningNameValueCrc32.Get(), - GetNumCheatVars()); - PrintCheatVars(true); - } -#endif -} - void CXConsole::AddCVarsToHash(ConsoleVariablesVector::const_iterator begin, ConsoleVariablesVector::const_iterator end, CCrc32& runningNameCrc32, CCrc32& runningNameValueCrc32) { for (ConsoleVariablesVector::const_iterator it = begin; it <= end; ++it) @@ -2974,162 +2905,6 @@ void CXConsole::AddCVarsToHash(ConsoleVariablesVector::const_iterator begin, Con } } -void CXConsole::CmdDumpAllAnticheatVars([[maybe_unused]] IConsoleCmdArgs* pArgs) -{ -#if defined(DEFENCE_CVAR_HASH_LOGGING) - CXConsole* pConsole = (CXConsole*)gEnv->pConsole; - - if (pConsole->IsHashCalculated()) - { - CryLog("HASHING: Displaying Full Anticheat Cvar list:"); - pConsole->PrintCheatVars(false); - } - else - { - CryLogAlways("DumpAllAnticheatVars - cannot complete, cheat vars are in a state of flux, please retry."); - } -#endif -} - -void CXConsole::CmdDumpLastHashedAnticheatVars([[maybe_unused]] IConsoleCmdArgs* pArgs) -{ -#if defined(DEFENCE_CVAR_HASH_LOGGING) - CXConsole* pConsole = (CXConsole*)gEnv->pConsole; - - if (pConsole->IsHashCalculated()) - { - CryLog("HASHING: Displaying Last Hashed Anticheat Cvar list:"); - pConsole->PrintCheatVars(true); - } - else - { - CryLogAlways("DumpLastHashedAnticheatVars - cannot complete, cheat vars are in a state of flux, please retry."); - } -#endif -} - -void CXConsole::PrintCheatVars([[maybe_unused]] bool bUseLastHashRange) -{ -#if defined(DEFENCE_CVAR_HASH_LOGGING) - if (m_bCheatHashDirty) - { - return; - } - - size_t i = 0; - char floatFormatBuf[64]; - - size_t nStart = 0; - size_t nEnd = m_mapVariables.size(); - - if (bUseLastHashRange) - { - nStart = m_nCheatHashRangeFirst; - nEnd = m_nCheatHashRangeLast; - } - - // iterate over all const cvars in our range - // then hash the string. - CryLog("VF_CHEAT & ~VF_CHEAT_NOCHECK list:"); - - ConsoleVariablesMap::const_iterator it, end = m_mapVariables.end(); - for (it = m_mapVariables.begin(); it != end; ++it) - { - // only count cheat cvars - if ((it->second->GetFlags() & VF_CHEAT) == 0 || - (it->second->GetFlags() & VF_CHEAT_NOCHECK) != 0) - { - continue; - } - - // count up - i++; - - // if we haven't reached the first var, or have passed the last var, break out - if (i - 1 < nStart) - { - continue; - } - if (i - 1 > nEnd) - { - break; - } - - // add name & variable to string. We add both since adding only the value could cause - // many collisions with variables all having value 0 or all 1. - string hashStr = it->first; - if (it->second->GetType() == CVAR_FLOAT) - { - sprintf(floatFormatBuf, "%.1g", it->second->GetFVal()); - hashStr += floatFormatBuf; - } - else - { - hashStr += it->second->GetString(); - } - - CryLog("%s", hashStr.c_str()); - } - - // iterate over any must-check variables - CryLog("VF_CHEAT_ALWAYS_CHECK list:"); - - for (it = m_mapVariables.begin(); it != end; ++it) - { - // only count cheat cvars - if ((it->second->GetFlags() & VF_CHEAT_ALWAYS_CHECK) == 0) - { - continue; - } - - // add name & variable to string. We add both since adding only the value could cause - // many collisions with variables all having value 0 or all 1. - string hashStr = it->first; - hashStr += it->second->GetString(); - - CryLog("%s", hashStr.c_str()); - } -#endif -} - -char* CXConsole::GetCheatVarAt(uint32 nOffset) -{ - if (m_bCheatHashDirty) - { - return NULL; - } - - size_t i = 0; - size_t nStart = nOffset; - - // iterate over all const cvars in our range - // then hash the string. - ConsoleVariablesMap::const_iterator it, end = m_mapVariables.end(); - for (it = m_mapVariables.begin(); it != end; ++it) - { - // only count cheat cvars - if ((it->second->GetFlags() & VF_CHEAT) == 0 || - (it->second->GetFlags() & VF_CHEAT_NOCHECK) != 0) - { - continue; - } - - // count up - i++; - - // if we haven't reached the first var continue - if (i - 1 < nStart) - { - continue; - } - - return (char*)it->first; - } - - return NULL; -} - - ////////////////////////////////////////////////////////////////////////// size_t CXConsole::GetSortedVars(AZStd::vector& pszArray, const char* szPrefix) { diff --git a/Code/Legacy/CrySystem/XConsole.h b/Code/Legacy/CrySystem/XConsole.h index 67d9371e8d..3ff9824e6f 100644 --- a/Code/Legacy/CrySystem/XConsole.h +++ b/Code/Legacy/CrySystem/XConsole.h @@ -182,11 +182,6 @@ public: virtual int GetNumVars(); virtual int GetNumVisibleVars(); virtual size_t GetSortedVars(AZStd::vector& pszArray, const char* szPrefix = 0); - virtual int GetNumCheatVars(); - virtual void SetCheatVarHashRange(size_t firstVar, size_t lastVar); - virtual void CalcCheatVarHash(); - virtual bool IsHashCalculated(); - virtual uint64 GetCheatVarHash(); virtual void FindVar(const char* substr); virtual const char* AutoComplete(const char* substr); virtual const char* AutoCompletePrev(const char* substr); @@ -231,9 +226,6 @@ public: // 0 if the operation failed ICVar* RegisterCVarGroup(const char* sName, const char* szFileName); - virtual void PrintCheatVars(bool bUseLastHashRange); - virtual char* GetCheatVarAt(uint32 nOffset); - void SetProcessingGroup(bool isGroup) { m_bIsProcessingGroup = isGroup; } bool GetIsProcessingGroup(void) const { return m_bIsProcessingGroup; } @@ -286,9 +278,6 @@ protected: // ------------------------------------------------------------------ static const char* GetFlagsString(const uint32 dwFlags); - static void CmdDumpAllAnticheatVars(IConsoleCmdArgs* pArgs); - static void CmdDumpLastHashedAnticheatVars(IConsoleCmdArgs* pArgs); - private: // ---------------------------------------------------------- typedef std::map ConsoleVariablesMap; // key points into string stored in ICVar or in .exe/.dll diff --git a/Code/Legacy/CrySystem/XConsoleVariable.cpp b/Code/Legacy/CrySystem/XConsoleVariable.cpp index ab6ed0b078..efd5ecd495 100644 --- a/Code/Legacy/CrySystem/XConsoleVariable.cpp +++ b/Code/Legacy/CrySystem/XConsoleVariable.cpp @@ -129,40 +129,6 @@ uint64 CXConsoleVariableBase::AddOnChangeFunctor(const SFunctor& pChangeFunctor) return newId; } -uint64 CXConsoleVariableBase::GetNumberOfOnChangeFunctors() const -{ - return m_changeFunctors.size(); -} - -const SFunctor& CXConsoleVariableBase::GetOnChangeFunctor(uint64 nFunctorId) const -{ - auto predicate = [nFunctorId](const std::pair& entry) -> bool { return entry.first == nFunctorId; }; - auto changeFunctor = std::find_if(m_changeFunctors.begin(), m_changeFunctors.end(), predicate); - if (changeFunctor != m_changeFunctors.end()) - { - return (*changeFunctor).second; - } - - static SFunctor sDummyFunctor; - assert(false && "[CXConsoleVariableBase::GetOnChangeFunctor] Trying to get a functor for an id that does not exist."); - - return sDummyFunctor; -} - -bool CXConsoleVariableBase::RemoveOnChangeFunctor(const uint64 nFunctorId) -{ - auto predicate = [nFunctorId](const std::pair& entry) -> bool { return entry.first == nFunctorId; }; - auto changeFunctor = std::find_if(m_changeFunctors.begin(), m_changeFunctors.end(), predicate); - - if (changeFunctor != m_changeFunctors.end()) - { - m_changeFunctors.erase(changeFunctor); - return true; - } - - return false; -} - ConsoleVarFunc CXConsoleVariableBase::GetOnChangeCallback() const { return m_pChangeFunc; diff --git a/Code/Legacy/CrySystem/XConsoleVariable.h b/Code/Legacy/CrySystem/XConsoleVariable.h index 122389407f..f761287b41 100644 --- a/Code/Legacy/CrySystem/XConsoleVariable.h +++ b/Code/Legacy/CrySystem/XConsoleVariable.h @@ -108,9 +108,6 @@ public: virtual void ForceSet(const char* s); virtual void SetOnChangeCallback(ConsoleVarFunc pChangeFunc); virtual uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) override; - virtual bool RemoveOnChangeFunctor(const uint64 nFunctorId) override; - virtual uint64 GetNumberOfOnChangeFunctors() const; - virtual const SFunctor& GetOnChangeFunctor(uint64 nFunctorId) const override; virtual ConsoleVarFunc GetOnChangeCallback() const; virtual bool ShouldReset() const { return (m_nFlags & VF_RESETTABLE) != 0; } @@ -250,7 +247,7 @@ public: virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); } private: // -------------------------------------------------------------------------------------------- - AZStd::string m_sValue; + AZStd::string m_sValue; AZStd::string m_sDefault; //!< }; @@ -315,7 +312,7 @@ public: virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); } protected: // -------------------------------------------------------------------------------------------- - int m_iValue; + int m_iValue; int m_iDefault; //!< }; @@ -382,7 +379,7 @@ public: virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); } protected: // -------------------------------------------------------------------------------------------- - int64 m_iValue; + int64 m_iValue; int64 m_iDefault; //!< }; @@ -488,7 +485,7 @@ protected: private: // -------------------------------------------------------------------------------------------- - float m_fValue; + float m_fValue; float m_fDefault; //!< }; @@ -578,7 +575,7 @@ public: virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); } private: // -------------------------------------------------------------------------------------------- - int& m_iValue; + int& m_iValue; int m_iDefault; //!< }; diff --git a/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp b/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp index 9086f40ede..9897895dcd 100644 --- a/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp @@ -9,7 +9,6 @@ #include "EditorNavigationUtil.h" #include -#include #include #include #include @@ -47,7 +46,7 @@ namespace LmbrCentral Call(FN_OnTraversalStarted, requestId); } - void OnTraversalPathUpdate(PathfindRequest::NavigationRequestId requestId, const AZ::Vector3& nextPathPosition, const AZ::Vector3& inflectionPosition) override + void OnTraversalPathUpdate(PathfindRequest::NavigationRequestId requestId, const AZ::Vector3& nextPathPosition, const AZ::Vector3& inflectionPosition) override { Call(FN_OnTraversalPathUpdate, requestId, nextPathPosition, inflectionPosition); } @@ -460,7 +459,7 @@ namespace LmbrCentral const bool usesAZCharacterPhysics = Physics::CharacterRequestBus::FindFirstHandler(entityId) != nullptr; m_usesCharacterPhysics = usesLegacyCharacterPhysics || usesAZCharacterPhysics; - + AZ_Warning("NavigationComponent", usesAZCharacterPhysics || Physics::RigidBodyRequestBus::FindFirstHandler(entityId), "Entity %s cannot be moved physically because it is missing a physics component", GetEntity()->GetName().c_str()); @@ -791,10 +790,10 @@ namespace LmbrCentral m_lastResponseCache.SetNextPathPosition(nextPathPosition); m_lastResponseCache.SetInflectionPosition(inflectionPosition); - // when using the custom movement method we just update the path and rely on + // when using the custom movement method we just update the path and rely on // the user to move the entity NavigationComponentNotificationBus::Event(m_entity->GetId(), - &NavigationComponentNotificationBus::Events::OnTraversalPathUpdate, + &NavigationComponentNotificationBus::Events::OnTraversalPathUpdate, m_lastResponseCache.GetRequestId(), nextPathPosition, inflectionPosition); @@ -808,7 +807,7 @@ namespace LmbrCentral if (m_usesCharacterPhysics) { - Physics::CharacterRequestBus::Event(GetEntityId(), + Physics::CharacterRequestBus::Event(GetEntityId(), &Physics::CharacterRequestBus::Events::AddVelocity, targetVelocity); } else diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimUndoManager.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimUndoManager.cpp index 025b8c94d8..3a3234fdce 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimUndoManager.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimUndoManager.cpp @@ -6,11 +6,10 @@ * */ - #include "UiAnimUndoManager.h" #include "UiAnimUndoObject.h" #include "Undo/IUndoManagerListener.h" -#include +#include // UI Editor #include "EditorCommon.h" diff --git a/Gems/LyShine/Code/Editor/EditorCommon.h b/Gems/LyShine/Code/Editor/EditorCommon.h index 9af5958c67..a13332b0fd 100644 --- a/Gems/LyShine/Code/Editor/EditorCommon.h +++ b/Gems/LyShine/Code/Editor/EditorCommon.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Gems/LyShine/Code/Editor/EditorWindow.cpp b/Gems/LyShine/Code/Editor/EditorWindow.cpp index 663570bbf0..a4ad4d7043 100644 --- a/Gems/LyShine/Code/Editor/EditorWindow.cpp +++ b/Gems/LyShine/Code/Editor/EditorWindow.cpp @@ -2112,8 +2112,8 @@ int EditorWindow::GetCanvasMaxHierarchyDepth(const LyShine::EntityArray& rootChi return depth; } - int numChildrenCurLevel = rootChildElements.size(); - int numChildrenNextLevel = 0; + size_t numChildrenCurLevel = rootChildElements.size(); + size_t numChildrenNextLevel = 0; std::list elementList(rootChildElements.begin(), rootChildElements.end()); while (!elementList.empty()) { diff --git a/Gems/LyShine/Code/Editor/HierarchyHelpers.cpp b/Gems/LyShine/Code/Editor/HierarchyHelpers.cpp index 5d97ecb83c..91e5781608 100644 --- a/Gems/LyShine/Code/Editor/HierarchyHelpers.cpp +++ b/Gems/LyShine/Code/Editor/HierarchyHelpers.cpp @@ -186,16 +186,20 @@ namespace HierarchyHelpers if (listOfNewlyCreatedTopLevelElements.empty()) { // This happens when the serialization version numbers DON'T match. - QMessageBox(QMessageBox::Critical, - "Error", - QString("Failed to load elements. The serialization format is incompatible."), - QMessageBox::Ok, widget->GetEditorWindow()).exec(); + QMessageBox( + QMessageBox::Critical, "Error", QString("Failed to load elements. The serialization format is incompatible."), QMessageBox::Ok, + widget->GetEditorWindow()) + .exec(); // Nothing more to do. return LyShine::EntityArray(); } - completeListOfNewlyCreatedTopLevelElements.push_back(listOfNewlyCreatedTopLevelElements); + completeListOfNewlyCreatedTopLevelElements.insert( + completeListOfNewlyCreatedTopLevelElements.end(), + listOfNewlyCreatedTopLevelElements.begin(), + listOfNewlyCreatedTopLevelElements.end() + ); } } diff --git a/Gems/LyShine/Code/Editor/PropertiesContainer.cpp b/Gems/LyShine/Code/Editor/PropertiesContainer.cpp index 9f9023f84d..e86cffcc08 100644 --- a/Gems/LyShine/Code/Editor/PropertiesContainer.cpp +++ b/Gems/LyShine/Code/Editor/PropertiesContainer.cpp @@ -544,7 +544,7 @@ AzToolsFramework::ComponentEditor* PropertiesContainer::CreateComponentEditor([[ { AzToolsFramework::ComponentEditor* editor = new AzToolsFramework::ComponentEditor(m_serializeContext, m_propertiesWidget, this); connect(editor, &AzToolsFramework::ComponentEditor::OnDisplayComponentEditorMenu, this, &PropertiesContainer::OnDisplayUiComponentEditorMenu); - + m_rowLayout->addWidget(editor); editor->hide(); @@ -788,7 +788,7 @@ void PropertiesContainer::Update() } else // more than one entity selected { - displayName = (ToString(selectedEntitiesAmount) + " elements selected").c_str(); + displayName = QString::number(selectedEntitiesAmount) + " elements selected"; } // Update the selected element display name diff --git a/Gems/LyShine/Code/Editor/SerializeHelpers.cpp b/Gems/LyShine/Code/Editor/SerializeHelpers.cpp index 724b6dee14..f9ce70caec 100644 --- a/Gems/LyShine/Code/Editor/SerializeHelpers.cpp +++ b/Gems/LyShine/Code/Editor/SerializeHelpers.cpp @@ -243,11 +243,14 @@ namespace SerializeHelpers insertBefore); } - // if a list of entities was passed then add all the entities that we added + // if a list of entities was passed then add all the entities that we added // to the list if (cumulativeListOfCreatedEntities) { - cumulativeListOfCreatedEntities->push_back(validatedListOfNewlyCreatedTopLevelElements); + cumulativeListOfCreatedEntities->insert( + cumulativeListOfCreatedEntities->end(), + validatedListOfNewlyCreatedTopLevelElements.begin(), + validatedListOfNewlyCreatedTopLevelElements.end()); } } @@ -363,7 +366,7 @@ namespace SerializeHelpers entityRestoreInfos.insert(entityRestoreInfos.end(), unserializedEntities->m_entityRestoreInfos.begin(), unserializedEntities->m_entityRestoreInfos.end()); entityRestoreInfos.insert(entityRestoreInfos.end(), - unserializedEntities->m_childEntityRestoreInfos.begin(), unserializedEntities->m_childEntityRestoreInfos.end()); + unserializedEntities->m_childEntityRestoreInfos.begin(), unserializedEntities->m_childEntityRestoreInfos.end()); } } // namespace EntityHelpers diff --git a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp index 4b5f072966..d967b88610 100644 --- a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp @@ -706,7 +706,7 @@ AZStd::string UiCanvasComponent::GetUniqueChildName(AZ::EntityId parentEntityId, if (includeChildren) { - children.push_back(*includeChildren); + children.insert(children.end(),includeChildren->begin(),includeChildren->end()); } // First, check if base name is unique @@ -1862,7 +1862,7 @@ AZ::RHI::AttachmentId UiCanvasComponent::UseRenderTarget(const AZ::Name& renderT // Notify LyShine render pass that it needs to rebuild QueueRttPassRebuild(); - + return attachmentImage->GetAttachmentId(); } @@ -4101,7 +4101,7 @@ UiCanvasComponent* UiCanvasComponent::FixupPostLoad(AZ::Entity* canvasEntity, AZ canvasComponent->m_editorToGameEntityIdMap = *previousRemapTable; ReuseOrGenerateNewIdsAndFixRefs(&entityContainer, canvasComponent->m_editorToGameEntityIdMap, context); - + AzFramework::SliceEntityOwnershipServiceRequestBus::EventResult(isLoadingRootEntitySuccessful, canvasComponent->m_entityContext->GetContextId(), &AzFramework::SliceEntityOwnershipServiceRequestBus::Events::HandleRootEntityReloadedFromStream, rootSliceEntity, false, nullptr); diff --git a/Gems/LyShine/Code/Source/UiElementComponent.cpp b/Gems/LyShine/Code/Source/UiElementComponent.cpp index 0aa57e4041..cb81ea639c 100644 --- a/Gems/LyShine/Code/Source/UiElementComponent.cpp +++ b/Gems/LyShine/Code/Source/UiElementComponent.cpp @@ -561,7 +561,7 @@ LyShine::EntityArray UiElementComponent::FindAllChildrenIntersectingRect(const A // Check children of this child first // child elements do not have to be contained in the parent element's bounds LyShine::EntityArray childMatches = childElementComponent->FindAllChildrenIntersectingRect(bound0, bound1, isInGame); - result.push_back(childMatches); + result.insert(result.end(),childMatches.begin(),childMatches.end()); bool isSelectable = true; if (!isInGame) @@ -943,7 +943,7 @@ bool UiElementComponent::GetAreElementAndAncestorsEnabled() { return m_parentElementComponent->GetAreElementAndAncestorsEnabled(); } - + return true; } @@ -1327,7 +1327,7 @@ void UiElementComponent::Reflect(AZ::ReflectContext* context) serializeContext->Class() // Persistent IDs for this are simply the entity id ->PersistentId([](const void* instance) -> AZ::u64 - { + { const ChildEntityIdOrderEntry* entry = reinterpret_cast(instance); return static_cast(entry->m_entityId); }) @@ -1680,7 +1680,7 @@ void UiElementComponent::OnPatchEnd(const AZ::DataPatchNodeInfo& patchInfo) entityIdLoaded = true; } } - + if (entityIdLoaded) { oldChildrenDataPatchFound = true; @@ -1812,7 +1812,7 @@ void UiElementComponent::OnPatchEnd(const AZ::DataPatchNodeInfo& patchInfo) m_childEntityIdOrder.push_back({elementChanged.second, m_childEntityIdOrder.size()}); } } - + // sort the added elements by index AZStd::sort(elementsAdded.begin(), elementsAdded.end()); for (auto& elementAdded : elementsAdded) diff --git a/Gems/LyShine/Code/Tests/UiDynamicScrollBoxComponentTest.cpp b/Gems/LyShine/Code/Tests/UiDynamicScrollBoxComponentTest.cpp index 3ea3550e76..425ab6bb9a 100644 --- a/Gems/LyShine/Code/Tests/UiDynamicScrollBoxComponentTest.cpp +++ b/Gems/LyShine/Code/Tests/UiDynamicScrollBoxComponentTest.cpp @@ -93,7 +93,7 @@ namespace UnitTest static int FindDescendantCount(const AZ::Entity* entity) { LyShine::EntityArray children = entity->FindComponent()->GetChildElements(); - int numDescendants = children.size(); + int numDescendants = static_cast(children.size()); for(const AZ::Entity* child : children) { numDescendants += FindDescendantCount(child); @@ -105,7 +105,7 @@ namespace UnitTest static int FindCanvasElementCount(UiCanvasComponent* uiCanvasComponent) { const LyShine::EntityArray childEntities = uiCanvasComponent->GetChildElements(); - int numCanvasElements = childEntities.size(); + int numCanvasElements = static_cast(childEntities.size()); for (const AZ::Entity* childEntity : childEntities) { numCanvasElements += FindDescendantCount(childEntity); diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp b/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp index 39e84d24a7..7e32301b71 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp @@ -12,7 +12,6 @@ #include "AnimSplineTrack.h" #include "CompoundSplineTrack.h" #include "BoolTrack.h" -#include "IPostEffectGroup.h" #include "Maestro/Types/AnimNodeType.h" #include "Maestro/Types/AnimParamType.h" #include "Maestro/Types/AnimValueType.h" @@ -236,7 +235,7 @@ CAnimNode* CAnimPostFXNode::CreateNode(const int id, AnimNodeType nodeType) retNode = aznew CAnimPostFXNode(id, nodeType, pDesc); static_cast(retNode)->m_nodeType = nodeType; } - + return retNode; } diff --git a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h index 63f287f513..0c8bc38f1a 100644 --- a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h +++ b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h @@ -12,6 +12,8 @@ #pragma once #include "AnimNode.h" +#include +#include class CAnimMaterialNode : public CAnimNode @@ -43,7 +45,7 @@ public: virtual void SetKeyValueRange(float fMin, float fMax){ m_fMinKeyValue = fMin; m_fMaxKeyValue = fMax; }; virtual void InitializeTrack(IAnimTrack* pTrack, const CAnimParamType& paramType); - + static void Reflect(AZ::ReflectContext* context); protected: diff --git a/Gems/Maestro/Code/Source/Cinematics/Movie.h b/Gems/Maestro/Code/Source/Cinematics/Movie.h index 7c8edd15ae..0d7d1743f1 100644 --- a/Gems/Maestro/Code/Source/Cinematics/Movie.h +++ b/Gems/Maestro/Code/Source/Cinematics/Movie.h @@ -15,6 +15,9 @@ #pragma once #include +#include +#include + #include "IMovieSystem.h" #include "IShader.h" diff --git a/Gems/Maestro/Code/Source/MaestroSystemComponent.h b/Gems/Maestro/Code/Source/MaestroSystemComponent.h index b27075dbc0..8b37dee183 100644 --- a/Gems/Maestro/Code/Source/MaestroSystemComponent.h +++ b/Gems/Maestro/Code/Source/MaestroSystemComponent.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "Cinematics/Movie.h" #include "Maestro/MaestroBus.h"