Merge branch 'main' into Prefab/CreatePrefab

This commit is contained in:
srikappa
2021-05-17 17:13:02 -07:00
919 changed files with 5368 additions and 52161 deletions
-84
View File
@@ -1,84 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_ARRAY2D_H
#define CRYINCLUDE_CRYCOMMON_ARRAY2D_H
#pragma once
// Dynamic replacement for static 2d array
template <class T>
struct Array2d
{
Array2d()
{
m_nSize = 0;
m_pData = 0;
}
int GetSize() const { return m_nSize; }
int GetDataSize() const { return m_nSize * m_nSize * sizeof(T); }
T* GetData() { return m_pData; }
T* GetDataEnd() { return &m_pData[m_nSize * m_nSize]; }
void SetData(T* pData, int nSize)
{
Allocate(nSize);
memcpy(m_pData, pData, nSize * nSize * sizeof(T));
}
void Allocate(int nSize)
{
if (m_nSize == nSize)
{
return;
}
delete [] m_pData;
m_nSize = nSize;
m_pData = new T [nSize * nSize];
memset(m_pData, 0, nSize * nSize * sizeof(T));
}
~Array2d()
{
delete [] m_pData;
}
void Reset()
{
delete [] m_pData;
m_pData = 0;
m_nSize = 0;
}
T* m_pData;
int m_nSize;
T* operator [] (const int& nPos) const
{
assert(nPos >= 0 && nPos < m_nSize);
return &m_pData[nPos * m_nSize];
}
Array2d& operator = (const Array2d& other)
{
Allocate(other.m_nSize);
memcpy(m_pData, other.m_pData, m_nSize * m_nSize * sizeof(T));
return *this;
}
};
#endif // CRYINCLUDE_CRYCOMMON_ARRAY2D_H
@@ -1,32 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Description: Utilities and functions used when cryphysics is disabled
#pragma once
// Assert if CryPhysics is disabled and no functionality replacement has been implemented
// 1: Runtime AZ_Error
// 2: Runtime Assertion
// 3: Compilation error
// Other: Do nothing
#define ENABLE_CRY_PHYSICS_REPLACEMENT_ASSERT 0
#if (ENABLE_CRY_PHYSICS_REPLACEMENT_ASSERT == 1)
#define CRY_PHYSICS_REPLACEMENT_ASSERT() AZ_Error("CryPhysics", false, __FUNCTION__ " - CRYPHYSICS REPLACEMENT NOT IMPLEMENTED")
#elif (ENABLE_CRY_PHYSICS_REPLACEMENT_ASSERT == 2)
#define CRY_PHYSICS_REPLACEMENT_ASSERT() AZ_Assert(false, "CRYPHYSICS REPLACEMENT NOT IMPLEMENTED")
#elif (ENABLE_CRY_PHYSICS_REPLACEMENT_ASSERT == 3)
#define CRY_PHYSICS_REPLACEMENT_ASSERT() static_assert(false, __FUNCTION__ " - CRYPHYSICS REPLACEMENT NOT IMPLEMENTED")
#else
#define CRY_PHYSICS_REPLACEMENT_ASSERT()
#endif
-100
View File
@@ -1,100 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_CRYPTRARRAY_H
#define CRYINCLUDE_CRYCOMMON_CRYPTRARRAY_H
#pragma once
#include "CryArray.h"
#include "CrySizer.h"
//---------------------------------------------------------------------------
template<class T, class P = T*>
struct PtrArray
: DynArray<P>
{
typedef DynArray<P> super;
// Overrides.
typedef T value_type;
ILINE ~PtrArray(){}
inline T& operator [](int i) const
{ return *super::operator[](i); }
// Iterators.
struct iterator
{
iterator(P* p)
: _ptr(p)
{}
operator P* () const
{
return _ptr;
}
void operator++()
{ _ptr++; }
void operator--()
{ _ptr--; }
T& operator*() const
{ assert(_ptr); return **_ptr; }
T* operator->() const
{ assert(_ptr); return *_ptr; }
protected:
P* _ptr;
};
struct const_iterator
{
const_iterator(const P* p)
: _ptr(p)
{}
operator const P* () const
{
return _ptr;
}
void operator++()
{ _ptr++; }
void operator--()
{ _ptr--; }
T& operator*() const
{ assert(_ptr); return **_ptr; }
T* operator->() const
{ assert(_ptr); return *_ptr; }
protected:
const P* _ptr;
};
void GetMemoryUsage(ICrySizer* pSizer) const
{
pSizer->AddObject(this->begin(), this->get_alloc_size());
for (int i = 0; i < this->size(); ++i)
{
pSizer->AddObject(this->super::operator [](i));
}
}
};
//---------------------------------------------------------------------------
template<class T>
struct SmartPtrArray
: PtrArray< T, _smart_ptr<T> >
{
};
#endif // CRYINCLUDE_CRYCOMMON_CRYPTRARRAY_H
-7
View File
@@ -33,7 +33,6 @@
#include <Cry_Vector3.h>
#include <Cry_Quat.h>
#include <Cry_Color.h>
#include <CryArray2d.h>
#include <smartptr.h>
// forward declarations for overloads
@@ -249,12 +248,6 @@ public:
void AddObject([[maybe_unused]] const AZ::Vector3& rObj) {}
void AddObject(void*) {}
template<typename T>
void AddObject(const Array2d<T>& array2d)
{
this->AddObject(array2d.m_pData, array2d.GetDataSize());
}
// overloads for container, will automaticly traverse the content
template<typename T, typename Alloc>
void AddObject(const std::list<T, Alloc>& rList)
-24
View File
@@ -1,24 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include <cstddef> // size_t
namespace Detail
{
template <typename T, size_t size>
char (&ArrayCountHelper(T(&)[size]))[size];
}
#define CRY_ARRAY_COUNT(arr) sizeof(::Detail::ArrayCountHelper(arr))
-40
View File
@@ -1,40 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
// Include this file instead of including zlib.h directly
// because zconf.h (included by zlib.h) defines WINDOWS and WIN32 - those
// definitions conflict with CryEngine's definitions.
#if defined(CRY_TMP_DEFINED_WINDOWS) || defined(CRY_TMP_DEFINED_WIN32)
# error CRY_TMP_DEFINED_WINDOWS and/or CRY_TMP_DEFINED_WIN32 already defined
#endif
#if defined(WINDOWS)
# define CRY_TMP_DEFINED_WINDOWS 1
#endif
#if defined(WIN32)
# define CRY_TMP_DEFINED_WIN32 1
#endif
#include <zlib.h>
#if !defined(CRY_TMP_DEFINED_WINDOWS)
# undef WINDOWS
#endif
#undef CRY_TMP_DEFINED_WINDOWS
#if !defined(CRY_TMP_DEFINED_WIN32)
# undef WIN32
#endif
#undef CRY_TMP_DEFINED_WIN32
File diff suppressed because it is too large Load Diff
-469
View File
@@ -1,469 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Facility for efficiently generating random positions on geometry
#ifndef CRYINCLUDE_CRYCOMMON_GEOMQUERY_H
#define CRYINCLUDE_CRYCOMMON_GEOMQUERY_H
#pragma once
#include "Cry_Geo.h"
#include "CryArray.h"
#include "Random.h"
//////////////////////////////////////////////////////////////////////
// Extents cache
class CGeomExtent
{
public:
CGeomExtent()
: m_nEmptyEndParts(0) {}
ILINE operator bool() const
{
return m_afCumExtents.capacity() + m_nEmptyEndParts != 0;
}
ILINE int NumParts() const
{
return m_afCumExtents.size();
}
ILINE float TotalExtent() const
{
return !m_afCumExtents.empty() ? m_afCumExtents.back() : 0.f;
}
void Clear()
{
m_afCumExtents.clear();
m_nEmptyEndParts = 0;
}
void AddPart(float fExtent)
{
// Defer empty parts until a non-empty part is added.
if (fExtent <= 0.f)
{
m_nEmptyEndParts++;
}
else
{
float fTotal = TotalExtent();
for (; m_nEmptyEndParts; m_nEmptyEndParts--)
{
m_afCumExtents.push_back(fTotal);
}
m_afCumExtents.push_back(fTotal + fExtent);
}
}
void ReserveParts(int nCount)
{
m_afCumExtents.reserve(nCount);
}
// Find element in sorted array <= index (normalized 0 to 1)
int GetPart(float fIndex) const
{
int last = m_afCumExtents.size() - 1;
if (last <= 0)
{
return last;
}
fIndex *= m_afCumExtents[last];
// Binary search thru array.
int lo = 0, hi = last;
while (lo < hi)
{
int i = (lo + hi) >> 1;
if (fIndex < m_afCumExtents[i])
{
hi = i;
}
else
{
lo = i + 1;
}
}
assert(lo == 0 || m_afCumExtents[lo] > m_afCumExtents[lo - 1]);
return lo;
}
int RandomPart() const
{
return GetPart(cry_random(0.0f, 1.0f));
}
protected:
DynArray<float> m_afCumExtents;
int m_nEmptyEndParts;
};
class CGeomExtents
{
public:
ILINE CGeomExtents()
: m_aExtents(0) {}
~CGeomExtents()
{ delete[] m_aExtents; }
void Clear()
{
delete[] m_aExtents;
m_aExtents = 0;
}
ILINE CGeomExtent const& operator [](EGeomForm eForm) const
{
assert(eForm >= 0 && eForm < MaxGeomForm);
if (m_aExtents)
{
return m_aExtents[eForm];
}
static CGeomExtent s_empty;
return s_empty;
}
ILINE CGeomExtent& Make(EGeomForm eForm)
{
assert(eForm >= 0 && eForm < MaxGeomForm);
if (!m_aExtents)
{
m_aExtents = new CGeomExtent[4];
}
return m_aExtents[eForm];
}
protected:
CGeomExtent* m_aExtents;
};
// Other random/extent functions
inline float ScaleExtent(EGeomForm eForm, float fScale)
{
switch (eForm)
{
default:
return 1;
case GeomForm_Edges:
return fScale;
case GeomForm_Surface:
return fScale * fScale;
case GeomForm_Volume:
return fScale * fScale * fScale;
}
}
inline float BoxExtent(EGeomForm eForm, Vec3 const& vSize)
{
switch (eForm)
{
default:
assert(0);
case GeomForm_Vertices:
return 8.f;
case GeomForm_Edges:
return (vSize.x + vSize.y + vSize.z) * 8.f;
case GeomForm_Surface:
return (vSize.x * vSize.y + vSize.x * vSize.z + vSize.y * vSize.z) * 8.f;
case GeomForm_Volume:
return vSize.x * vSize.y * vSize.z * 8.f;
}
}
// Utility functions.
template<class T>
inline
const typename T::value_type& RandomElem(const T& array)
{
int n = cry_random(0U, array.size() - 1);
return array[n];
}
// Geometric primitive randomizing functions.
ILINE void BoxRandomPos(PosNorm& ran, EGeomForm eForm, Vec3 const& vSize)
{
ran.vPos = cry_random_componentwise(-vSize, vSize);
ran.vNorm = ran.vPos;
if (eForm != GeomForm_Volume)
{
// Generate a random corner, for collapsing random point.
int nCorner = cry_random(0, 7);
ran.vNorm.x = (((nCorner & 1) << 1) - 1) * vSize.x;
ran.vNorm.y = (((nCorner & 2)) - 1) * vSize.y;
ran.vNorm.z = (((nCorner & 4) >> 1) - 1) * vSize.z;
if (eForm == GeomForm_Vertices)
{
ran.vPos = ran.vNorm;
}
else if (eForm == GeomForm_Surface)
{
// Collapse one axis.
float fAxis = cry_random(0.0f, vSize.x * vSize.y + vSize.y * vSize.z + vSize.z * vSize.x);
if ((fAxis -= vSize.y * vSize.z) < 0.f)
{
ran.vPos.x = ran.vNorm.x;
ran.vNorm.y = ran.vNorm.z = 0.f;
}
else if ((fAxis -= vSize.z * vSize.x) < 0.f)
{
ran.vPos.y = ran.vNorm.y;
ran.vNorm.x = ran.vNorm.z = 0.f;
}
else
{
ran.vPos.z = ran.vNorm.z;
ran.vNorm.x = ran.vNorm.y = 0.f;
}
}
else if (eForm == GeomForm_Edges)
{
// Collapse 2 axes.
float fAxis = cry_random(0.0f, vSize.x + vSize.y + vSize.z);
if ((fAxis -= vSize.x) < 0.f)
{
ran.vPos.y = ran.vNorm.y;
ran.vPos.z = ran.vNorm.z;
ran.vNorm.x = 0.f;
}
else if ((fAxis -= vSize.y) < 0.f)
{
ran.vPos.x = ran.vNorm.x;
ran.vPos.z = ran.vNorm.z;
ran.vNorm.y = 0.f;
}
else
{
ran.vPos.x = ran.vNorm.x;
ran.vPos.y = ran.vNorm.y;
ran.vNorm.z = 0.f;
}
}
}
ran.vNorm.Normalize();
}
inline float CircleExtent(EGeomForm eForm, float fRadius)
{
switch (eForm)
{
case GeomForm_Edges:
return gf_PI2 * fRadius;
case GeomForm_Surface:
return gf_PI * square(fRadius);
default:
return 1.f;
}
}
inline Vec2 CircleRandomPoint(EGeomForm eForm, float fRadius)
{
Vec2 vPt;
switch (eForm)
{
case GeomForm_Edges:
// Generate random angle.
sincos_tpl(cry_random(0.0f, gf_PI2), &vPt.y, &vPt.x);
vPt *= fRadius;
break;
case GeomForm_Surface:
// Generate random angle, and radius, adjusted for even distribution.
sincos_tpl(cry_random(0.0f, gf_PI2), &vPt.y, &vPt.x);
vPt *= sqrt(cry_random(0.0f, 1.0f)) * fRadius;
break;
default:
vPt.x = vPt.y = 0.f;
}
return vPt;
}
inline float SphereExtent(EGeomForm eForm, float fRadius)
{
switch (eForm)
{
default:
assert(0);
case GeomForm_Vertices:
case GeomForm_Edges:
return 0.f;
case GeomForm_Surface:
return gf_PI * 4.f * sqr(fRadius);
case GeomForm_Volume:
return gf_PI * 4.f / 3.f * cube(fRadius);
}
}
inline void SphereRandomPos(PosNorm& ran, EGeomForm eForm, float fRadius)
{
switch (eForm)
{
default:
assert(0);
case GeomForm_Vertices:
case GeomForm_Edges:
ran.vPos.zero();
ran.vNorm.zero();
return;
case GeomForm_Surface:
case GeomForm_Volume:
{
// Generate point on surface, as normal.
float fPhi = cry_random(0.0f, gf_PI2);
float fZ = cry_random(-1.f, 1.f);
float fH = sqrt_tpl(1.f - fZ * fZ);
sincos_tpl(fPhi, &ran.vNorm.y, &ran.vNorm.x);
ran.vNorm.x *= fH;
ran.vNorm.y *= fH;
ran.vNorm.z = fZ;
ran.vPos = ran.vNorm;
if (eForm == GeomForm_Volume)
{
float fV = cry_random(0.0f, 1.0f);
float fR = pow_tpl(fV, 0.333333f);
ran.vPos *= fR;
}
ran.vPos *= fRadius;
break;
}
}
}
// Triangle randomisation functions
inline float TriExtent(EGeomForm eForm, Vec3 const aPos[3])
{
switch (eForm)
{
default:
assert(0);
case GeomForm_Edges:
return (aPos[1] - aPos[0]).GetLengthFast();
case GeomForm_Surface:
return ((aPos[1] - aPos[0]) % (aPos[2] - aPos[0])).GetLengthFast() * 0.5f;
case GeomForm_Volume:
// Generate signed volume of pyramid by computing triple product of vertices.
return ((aPos[0] ^ aPos[1]) | aPos[2]) / 6.0f;
}
}
inline void TriRandomPos(PosNorm& ran, EGeomForm eForm, PosNorm const aRan[3], bool bDoNormals)
{
// Generate interpolators for verts.
switch (eForm)
{
default:
assert(0);
case GeomForm_Vertices:
ran = aRan[0];
return;
case GeomForm_Edges:
{
float t = cry_random(0.0f, 1.0f);
ran.vPos = aRan[0].vPos * (1.f - t) + aRan[1].vPos * t;
if (bDoNormals)
{
ran.vNorm = aRan[0].vNorm * (1.f - t) + aRan[1].vNorm * t;
}
break;
}
case GeomForm_Surface:
{
float t0 = cry_random(0.0f, 1.0f);
float t1 = cry_random(0.0f, 1.0f);
float t2 = cry_random(0.0f, 1.0f);
float fSum = t0 + t1 + t2;
ran.vPos = (aRan[0].vPos * t0 + aRan[1].vPos * t1 + aRan[2].vPos * t2) * (1.f / fSum);
if (bDoNormals)
{
ran.vNorm = aRan[0].vNorm * t0 + aRan[1].vNorm * t1 + aRan[2].vNorm * t2;
}
break;
}
case GeomForm_Volume:
{
float t0 = cry_random(0.0f, 1.0f);
float t1 = cry_random(0.0f, 1.0f);
float t2 = cry_random(0.0f, 1.0f);
float t3 = cry_random(0.0f, 1.0f);
float fSum = t0 + t1 + t2 + t3;
ran.vPos = (aRan[0].vPos * t0 + aRan[1].vPos * t1 + aRan[2].vPos * t2) * (1.f / fSum);
if (bDoNormals)
{
ran.vNorm = (aRan[0].vNorm * t0 + aRan[1].vNorm * t1 + aRan[2].vNorm * t2) * (1.f - t3) + ran.vPos.GetNormalizedFast() * t3;
}
break;
}
}
if (bDoNormals)
{
ran.vNorm.Normalize();
}
}
// Mesh random pos functions
inline int TriMeshPartCount(EGeomForm eForm, int nIndices)
{
switch (eForm)
{
default:
assert(0);
case GeomForm_Vertices:
case GeomForm_Edges:
// Number of edges = verts.
return nIndices;
case GeomForm_Surface:
case GeomForm_Volume:
// Number of tris.
assert(nIndices % 3 == 0);
return nIndices / 3;
}
}
inline int TriIndices(int aIndices[3], int nPart, EGeomForm eForm)
{
switch (eForm)
{
default:
assert(0);
case GeomForm_Vertices: // Part is vert index
aIndices[0] = nPart;
return 1;
case GeomForm_Edges: // Part is vert index
aIndices[0] = nPart;
aIndices[1] = nPart % 3 < 2 ? nPart + 1 : nPart - 2;
return 2;
case GeomForm_Surface: // Part is tri index
case GeomForm_Volume:
aIndices[0] = nPart * 3;
aIndices[1] = aIndices[0] + 1;
aIndices[2] = aIndices[0] + 2;
return 3;
}
}
#endif // CRYINCLUDE_CRYCOMMON_GEOMQUERY_H
-617
View File
@@ -1,617 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_HASHGRID_H
#define CRYINCLUDE_CRYCOMMON_HASHGRID_H
#pragma once
template<typename Key, typename DiscreetKey>
struct hash_grid_2d
{
typedef Key key_type;
typedef typename key_type::value_type key_value;
typedef DiscreetKey discreet_type;
typedef typename discreet_type::value_type discreet_value;
typedef hash_grid_2d<Key, DiscreetKey> type;
hash_grid_2d(const key_value& cellSizeX, const key_value& cellSizeY, const key_value& cellSizeZ)
: scaleFactorX(1 / cellSizeX)
, scaleFactorY(1 / cellSizeY)
{
}
inline discreet_type discreet(const key_type& key) const
{
return discreet_type(static_cast<discreet_value>(key[0] * scaleFactorX),
static_cast<discreet_value>(key[1] * scaleFactorY),
static_cast<discreet_value>(0));
}
inline size_t hash(const key_type& key) const
{
return hash(discreet(key));
}
inline size_t hash(const discreet_type& discreet) const
{
return static_cast<size_t>(
(discreet[0] ^ 920129341) +
(discreet[1] ^ 1926129311));
}
inline void swap(type& other)
{
std::swap(scaleFactorX, other.scaleFactorX);
std::swap(scaleFactorY, other.scaleFactorY);
}
private:
key_value scaleFactorX;
key_value scaleFactorY;
};
template<typename Key, typename DiscreetKey>
struct hash_grid_3d
{
typedef Key key_type;
typedef typename key_type::value_type key_value;
typedef DiscreetKey discreet_type;
typedef typename discreet_type::value_type discreet_value;
typedef hash_grid_3d<Key, DiscreetKey> type;
hash_grid_3d(const key_value& cellSizeX, const key_value& cellSizeY, const key_value& cellSizeZ)
: scaleFactorX(1 / cellSizeX)
, scaleFactorY(1 / cellSizeY)
, scaleFactorZ(1 / cellSizeZ)
{
}
inline discreet_type discreet(const key_type& key) const
{
return discreet_type(static_cast<discreet_value>(key[0] * scaleFactorX),
static_cast<discreet_value>(key[1] * scaleFactorY),
static_cast<discreet_value>(key[2] * scaleFactorZ));
}
inline size_t hash(const key_type& key) const
{
return hash(discreet(key));
}
inline size_t hash(const discreet_type& discreet) const
{
return static_cast<size_t>(
(discreet[0] ^ 920129341ul) +
(discreet[1] ^ 1926129311ul) +
(discreet[2] ^ 3926129401ul));
}
inline void swap(type& other)
{
std::swap(scaleFactorX, other.scaleFactorX);
std::swap(scaleFactorY, other.scaleFactorY);
std::swap(scaleFactorZ, other.scaleFactorZ);
}
private:
key_value scaleFactorX;
key_value scaleFactorY;
key_value scaleFactorZ;
};
template<typename KeyType, typename ValueType>
struct hash_grid_no_position
{
KeyType operator()(const ValueType&) const
{
switch (0)
{
case 0:
"hash_grid query performed without a valid position-retriever implementation";
}
;
return KeyType();
}
};
template<int NumberOfCells, typename ValueType, typename KeyHash,
typename PositionRetriever = hash_grid_no_position<typename KeyHash::key_type, ValueType> >
class hash_grid
: protected KeyHash
{
public:
enum
{
CellCount = NumberOfCells,
};
typedef ValueType value_type;
typedef KeyHash key_hash;
typedef typename key_hash::key_type key_type;
typedef typename key_type::value_type key_value;
typedef typename key_hash::discreet_type discreet_type;
typedef typename discreet_type::value_type discreet_value;
typedef PositionRetriever position_retriever_type;
typedef hash_grid<NumberOfCells, ValueType, KeyHash, PositionRetriever> type;
typedef std::vector<value_type> items_type;
struct cell_type
{
cell_type()
: query(0)
{
}
mutable uint32 query;
items_type items;
};
typedef std::vector<cell_type> cells_type;
inline hash_grid(float cellSizeX = 20.0f, float cellSizeY = 20.0f, float cellSizeZ = 20.0f,
const position_retriever_type& _position = position_retriever_type())
: key_hash(cellSizeX, cellSizeY, cellSizeZ)
, position(_position)
, m_cells(CellCount)
, m_count(0)
, m_query(0)
{
}
inline void clear()
{
m_cells.clear();
m_cells.resize(CellCount);
m_count = 0;
m_query = 0;
}
inline void swap(type& other)
{
m_cells.swap(other);
std::swap(m_count, other.m_count);
key_hash::swap(other);
}
inline size_t size() const
{
return m_count;
}
inline bool empty() const
{
return m_count == 0;
}
struct iterator
{
iterator()
: cell(~0u)
, item(~0u)
, grid(0)
{
}
value_type& operator*()
{
return grid->m_cells[cell][item];
}
const value_type& operator*() const
{
return grid->m_cells[cell][item];
}
value_type* operator->() const
{
return (&**this);
}
iterator& operator++()
{
assert(cell < grid_type::CellCount);
cell_type& items = grid->m_cells[cell];
if (!items.empty() && (item < items.size() - 1))
{
++item;
}
else
{
item = 0;
++cell;
while ((cell < type::CellCount) && grid->m_cells[cell].empty())
{
++cell;
}
}
return *this;
}
iterator operator++(int)
{
iterator tmp = *this;
++*this;
return tmp;
}
iterator& operator--()
{
if (item > 0)
{
--item;
}
else
{
--cell;
while ((cell > 0) && grid->m_cells[cell].empty())
{
--cell;
}
assert(cell < type::CellCount);
cell_type& items = grid->m_cells[cell];
item = items.size() - 1;
}
return *this;
}
iterator operator--(int)
{
iterator tmp = *this;
++*this;
return tmp;
}
bool operator==(const iterator& other) const
{
return (cell == other.cell) && (item == other.item) && (grid == other.grid);
}
bool operator!=(const iterator& other) const
{
return !(*this == other);
}
private:
friend class hash_grid<NumberOfCells, ValueType, KeyHash, PositionRetriever>;
typedef hash_grid<NumberOfCells, ValueType, KeyHash, PositionRetriever> grid_type;
iterator(size_t _cell, size_t _item, grid_type* _grid)
: grid(_grid)
, item(_item)
, cell(_cell)
{
}
grid_type* grid;
size_t cell;
size_t item;
};
inline iterator begin()
{
uint32 item = 0;
uint32 cell = 0;
while ((cell < type::CellCount) && m_cells[cell].empty())
{
++cell;
}
return iterator(cell, item, this);
}
inline iterator end()
{
return iterator(CellCount, 0, this);
}
inline iterator insert(const key_type& key, const value_type& value)
{
size_t hash_value = KeyHash::hash(key);
size_t index = hash_value % CellCount;
cell_type& cell = m_cells[index];
items_type& items = cell.items;
items.push_back(value);
++m_count;
return iterator(index, items.size() - 1, this);
}
inline void erase(const key_type& key, const value_type& value)
{
size_t hash_value = KeyHash::hash(key);
size_t index = hash_value % CellCount;
cell_type& cell = m_cells[index];
items_type& items = cell.items;
typename items_type::iterator it = items.begin();
typename items_type::iterator end = items.end();
for (; it != end; ++it)
{
if (*it == value)
{
std::swap(*it, items.back());
items.pop_back();
--m_count;
return;
}
}
}
inline iterator erase(const iterator& it)
{
--m_count;
cell_type& cell = m_cells[it.cell];
items_type& items = cell.items;
std::swap(items[it.item], items.back());
items.pop_back();
if (!items.empty())
{
return it;
}
uint32 index = it.cell;
while ((index < CellCount) && m_cells[index].items.empty())
{
++index;
}
return iterator(index, 0, this);
}
inline iterator find(const key_type& key, const value_type& value)
{
size_t index = KeyHash::hash(key) % CellCount;
cell_type& cell = m_cells[index];
items_type& items = cell.items;
typename items_type::iterator it = items.begin();
typename items_type::iterator iend = items.end();
for (; it != iend; ++it)
{
if (*it == value)
{
return iterator(index, it - items.begin(), this);
}
}
return end();
}
inline iterator move(const iterator& it, const key_type& to)
{
size_t index = KeyHash::hash(to) % CellCount;
if (index == it.cell)
{
return it;
}
cell_type& cell = m_cells[it.cell];
items_type& items = cell.items;
typename items_type::iterator iit = items.begin() + it.item;
cell_type& to_cell = m_cells[index];
items_type& to_items = to_cell.items;
to_items.push_back(*iit);
std::swap(items[it.item], items.back());
items.pop_back();
return iterator(index, to_items.size() - 1, this);
}
template<typename Container>
uint32 query_sphere(const key_type& center, const key_value& radius, Container& container) const
{
uint32 count = 0;
if (!empty())
{
++m_query;
key_type minc(center - key_type(radius));
key_type maxc(center + key_type(radius));
discreet_type mind = KeyHash::discreet(minc);
discreet_type maxd = KeyHash::discreet(maxc);
discreet_type current = mind;
float radius_sq = radius * radius;
for (; current[0] <= maxd[0]; ++current[0])
{
for (; current[1] <= maxd[1]; ++current[1])
{
for (; current[2] <= maxd[2]; ++current[2])
{
size_t hash_value = KeyHash::hash(current);
size_t index = hash_value % CellCount;
const cell_type& cell = m_cells[index];
if (cell.query != m_query)
{
cell.query = m_query;
const items_type& items = cell.items;
typename items_type::const_iterator it = items.begin();
typename items_type::const_iterator end = items.end();
for (; it != end; ++it)
{
if ((position(*it) - center).len2() <= radius_sq)
{
container.push_back(*it);
++count;
}
}
}
}
current[2] = mind[2];
}
current[1] = mind[1];
}
}
return count;
}
template<typename Container>
uint32 query_sphere_distance(const key_type& center, const key_value& radius, Container& container) const
{
uint32 count = 0;
if (!empty())
{
++m_query;
key_type minc(center - key_type(radius));
key_type maxc(center + key_type(radius));
discreet_type mind = KeyHash::discreet(minc);
discreet_type maxd = KeyHash::discreet(maxc);
discreet_type current = mind;
float radius_sq = radius * radius;
for (; current[0] <= maxd[0]; ++current[0])
{
for (; current[1] <= maxd[1]; ++current[1])
{
for (; current[2] <= maxd[2]; ++current[2])
{
size_t hash_value = KeyHash::hash(current);
size_t index = hash_value % CellCount;
const cell_type& cell = m_cells[index];
if (cell.query != m_query)
{
cell.query = m_query;
const items_type& items = cell.items;
typename items_type::const_iterator it = items.begin();
typename items_type::const_iterator end = items.end();
for (; it != end; ++it)
{
float distance_sq = (position(*it) - center).len2();
if (distance_sq <= radius_sq)
{
container.push_back(std::make_pair(distance_sq, *it));
++count;
}
}
}
}
current[2] = mind[2];
}
current[1] = mind[1];
}
}
return count;
}
template<typename Container>
uint32 query_box(const key_type& minc, const key_type& maxc, Container& container) const
{
uint32 count = 0;
if (!empty())
{
++m_query;
discreet_type mind = KeyHash::discreet(minc);
discreet_type maxd = KeyHash::discreet(maxc);
discreet_type current = mind;
for (; current[0] <= maxd[0]; ++current[0])
{
for (; current[1] <= maxd[1]; ++current[1])
{
for (; current[2] <= maxd[2]; ++current[2])
{
size_t hash_value = KeyHash::hash(current);
size_t index = hash_value % CellCount;
const cell_type& cell = m_cells[index];
if (cell.query != m_query)
{
cell.query = m_query;
const items_type& items = cell.items;
typename items_type::const_iterator it = items.begin();
typename items_type::const_iterator end = items.end();
for (; it != end; ++it)
{
key_type pos = position(*it);
if (pos[0] >= minc[0] &&
pos[1] >= minc[1] &&
pos[2] >= minc[2] &&
pos[0] <= maxc[0] &&
pos[1] <= maxc[1] &&
pos[2] <= maxc[2])
{
container.push_back(*it);
++count;
}
}
}
}
current[2] = mind[2];
}
current[1] = mind[1];
}
}
return count;
}
protected:
position_retriever_type position;
cells_type m_cells;
uint32 m_count;
mutable uint32 m_query;
};
#endif // CRYINCLUDE_CRYCOMMON_HASHGRID_H
-250
View File
@@ -1,250 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Containers that use their own heap for allocation.
#ifndef CRYINCLUDE_CRYCOMMON_HEAPCONTAINER_H
#define CRYINCLUDE_CRYCOMMON_HEAPCONTAINER_H
#pragma once
#include "PoolAllocator.h"
//---------------------------------------------------------------------------
template<class T, typename L = stl::PSyncMultiThread>
struct HeapQueue
: public L
{
typedef typename L::Lock Lock;
HeapQueue()
{
reset();
}
T* push_back()
{
Lock lock(*this);
return push_back(m_Allocator.New());
}
template<class I>
T* push_back(I const& init)
{
Lock lock(*this);
Node* pNode = (Node*)m_Allocator.Allocate();
new(static_cast<T*>(pNode))T(init);
return push_back(pNode);
}
template<class I, class J>
T* push_back(I const& i, J const& j)
{
Lock lock(*this);
Node* pNode = (Node*)m_Allocator.Allocate();
new(static_cast<T*>(pNode))T(i, j);
return push_back(pNode);
}
T* pop_front()
{
Lock lock(*this);
// Quick check, before locking.
if (empty())
{
return 0;
}
Node* pNode = *m_ppHead;
if (pNode)
{
m_ppHead = &(*m_ppHead)->pNext;
m_nQueued--;
validate();
}
return pNode;
}
void clear()
{
Lock lock(*this);
validate();
// Destruct all elements.
size_t nCheckAlloc = 0;
while (m_pList)
{
nCheckAlloc++;
Node* pNext = m_pList->pNext;
m_pList->~Node();
m_pList = pNext;
}
assert(nCheckAlloc == m_nAlloc);
// Empty queue structure.
reset();
// Free pool memory all at once.
m_Allocator.FreeMemory(false);
}
size_t size() const
{
return m_nQueued;
}
bool empty() const
{
return m_nQueued == 0;
}
size_t allocated_memory() const
{
// Amortise allocated mem over all list instances.
Lock lock(*this);
return m_Allocator.GetTotalMemory().nAlloc;
}
// Additional lock against storage deletion.
L ClearLock;
void GetMemoryUsage(ICrySizer* pSizer) const
{
pSizer->AddObject(m_Allocator);
}
protected:
struct Node
: T
{
Node* pNext;
};
Node* m_pList; // First (allocated) node in list.
Node** m_ppHead; // Points to pointer to front of queue, for popping.
Node** m_ppTail; // Points to pointer at end of list, and of queue, for pushing.
size_t m_nAlloc, m_nQueued;
void validate()
{
assert(m_nQueued <= m_nAlloc);
assert(m_ppHead);
assert(m_ppTail);
assert(!*m_ppTail);
assert((m_nQueued == 0) == !*m_ppHead);
assert((m_nQueued == 0) == (m_ppHead == m_ppTail));
assert((m_nAlloc == 0) == (m_ppTail == &m_pList));
assert((m_nAlloc == 0) == !m_pList);
}
void reset()
{
m_pList = 0;
m_ppHead = m_ppTail = &m_pList;
m_nAlloc = m_nQueued = 0;
validate();
}
Node* push_back(Node* pNode)
{
pNode->pNext = 0;
*m_ppTail = pNode;
m_ppTail = &pNode->pNext;
m_nAlloc++;
m_nQueued++;
validate();
return pNode;
}
// Allocate all elements from an exclusive pool.
// Any locking is performed by the queue, no further locking needed in allocator.
stl::TPoolAllocator<Node, stl::PSyncNone> m_Allocator;
};
//---------------------------------------------------------------------------
template<class T, class C = std::less<T>, typename L = stl::PSyncNone>
struct HeapPriorityQueue
: public HeapQueue<T, L>
{
// Hand-holding for brain-dead template compiler.
typedef HeapQueue<T, L> super;
typedef typename super::Node Node;
using super::empty;
using super::validate;
using super::m_ppHead;
using super::m_ppTail;
using super::m_nQueued;
public:
typedef typename super::Lock Lock;
// Pop the "largest" element, using class C.
T* pop_largest()
{
Lock lock(*this);
if (!empty())
{
C comp;
// Find highest-valued item.
// To do: improve linear search! Use priority queue.
Node** ppTop = m_ppHead;
for (Node** ppNode = &(*m_ppHead)->pNext; *ppNode; ppNode = &(*ppNode)->pNext)
{
if (comp(**ppTop, **ppNode))
{
ppTop = ppNode;
}
}
Node* pTop = *ppTop;
// Move link to head.
if (ppTop != m_ppHead)
{
if (!pTop->pNext)
{
// End of list.
m_ppTail = ppTop;
}
*ppTop = pTop->pNext;
pTop->pNext = *m_ppHead;
*m_ppHead = pTop;
}
// Pop head.
m_ppHead = &pTop->pNext;
m_nQueued--;
validate();
return pTop;
}
else
{
return NULL;
}
}
void GetMemoryUsage(ICrySizer* pSizer) const
{
HeapQueue<T, L>::GetMemoryUsage(pSizer);
}
};
#endif // CRYINCLUDE_CRYCOMMON_HEAPCONTAINER_H
-103
View File
@@ -1,103 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_ICHUNKFILE_H
#define CRYINCLUDE_CRYCOMMON_ICHUNKFILE_H
#pragma once
#include "CryHeaders.h"
//////////////////////////////////////////////////////////////////////////
// Description:
// Chunked File (.cgf, .chr etc.) interface
//////////////////////////////////////////////////////////////////////////
struct IChunkFile
: _reference_target_t
{
//////////////////////////////////////////////////////////////////////////
// Chunk Description.
//////////////////////////////////////////////////////////////////////////
struct ChunkDesc
{
ChunkTypes chunkType;
int chunkVersion;
int chunkId;
uint32 fileOffset;
void* data;
uint32 size;
bool bSwapEndian;
//////////////////////////////////////////////////////////////////////////
ChunkDesc()
: chunkType(ChunkType_ANY)
, chunkVersion(0)
, chunkId(0)
, fileOffset(0)
, data(0)
, size(0)
, bSwapEndian(false)
{
}
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{ /*nothing*/}
static inline bool LessOffset(const ChunkDesc& d1, const ChunkDesc& d2) { return d1.fileOffset < d2.fileOffset; }
static inline bool LessOffsetByPtr(const ChunkDesc* d1, const ChunkDesc* d2) { return d1->fileOffset < d2->fileOffset; }
static inline bool LessId(const ChunkDesc& d1, const ChunkDesc& d2) { return d1.chunkId < d2.chunkId; }
};
// <interfuscator:shuffle>
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
// Releases chunk file interface.
virtual void Release() = 0;
virtual bool IsReadOnly() const = 0;
virtual bool IsLoaded() const = 0;
virtual bool Read(const char* filename) = 0;
virtual bool ReadFromMemory(const void* pData, int nDataSize) = 0;
// Writes chunks to file.
virtual bool Write(const char* filename) = 0;
// Writes chunks to a memory buffer (allocated inside) and returns
// pointer to the allocated memory (pData) and its size (nSize).
// The memory will be released on destruction of the ChunkFile object, or
// on the next WriteToMemoryBuffer() call, or on ReleaseMemoryBuffer() call.
virtual bool WriteToMemoryBuffer(void** pData, int* nSize) = 0;
// Releases memory that was allocated in WriteToMemoryBuffer()
virtual void ReleaseMemoryBuffer() = 0;
// Adds chunk to file, returns ChunkID of the added chunk.
virtual int AddChunk(ChunkTypes chunkType, int chunkVersion, EEndianness eEndianness, const void* chunkData, int chunkSize) = 0;
virtual void DeleteChunkById(int nChunkId) = 0;
virtual void DeleteChunksByType(ChunkTypes nChunkType) = 0;
virtual ChunkDesc* FindChunkByType(ChunkTypes nChunkType) = 0;
virtual ChunkDesc* FindChunkById(int nChunkId) = 0;
// Gets the number of chunks.
virtual int NumChunks() const = 0;
// Gets chunk description at i-th index.
virtual ChunkDesc* GetChunk(int nIndex) = 0;
virtual const ChunkDesc* GetChunk(int nIndex) const = 0;
virtual const char* GetLastError() const = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_ICHUNKFILE_H
@@ -1,59 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_ICOLORGRADINGCONTROLLER_H
#define CRYINCLUDE_CRYCOMMON_ICOLORGRADINGCONTROLLER_H
#pragma once
struct SColorChartLayer
{
int m_texID;
float m_blendAmount;
SColorChartLayer()
: m_texID(-1)
, m_blendAmount(-1)
{
}
SColorChartLayer(int texID, float blendAmount)
: m_texID(texID)
, m_blendAmount(blendAmount)
{
}
SColorChartLayer(const SColorChartLayer& rhs)
: m_texID(rhs.m_texID)
, m_blendAmount(rhs.m_blendAmount)
{
}
};
struct IColorGradingController
{
public:
// <interfuscator:shuffle>
virtual ~IColorGradingController(){}
virtual int LoadColorChart(const char* pChartFilePath) const = 0;
virtual int LoadDefaultColorChart() const = 0;
virtual void UnloadColorChart(int texID) const = 0;
virtual void SetLayers(const SColorChartLayer* pLayers, uint32 numLayers) = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_ICOLORGRADINGCONTROLLER_H
@@ -27,7 +27,6 @@ namespace AZ
struct IMaterial;
struct IVisArea;
struct SRenderingPassInfo;
struct IGeomCache;
struct SRendItemSorter;
struct SFrameLodInfo;
struct pe_params_area;
@@ -259,9 +258,6 @@ struct IRenderNode
virtual struct IStatObj* GetEntityStatObj(unsigned int nPartId = 0, unsigned int nSubPartId = 0, Matrix34A* pMatrix = NULL, bool bReturnOnlyVisible = false);
virtual _smart_ptr<IMaterial> 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) {};
#if defined(USE_GEOM_CACHES)
virtual struct IGeomCacheRenderNode* GetGeomCacheRenderNode([[maybe_unused]] unsigned int nSlot, [[maybe_unused]] Matrix34A* pMatrix = NULL, [[maybe_unused]] bool bReturnOnlyVisible = false) { return NULL; }
#endif
virtual int GetSlotCount() const { return 1; }
// Summary:
@@ -793,81 +789,4 @@ struct IPrismRenderNode
};
#endif // EXCLUDE_DOCUMENTATION_PURPOSE
//////////////////////////////////////////////////////////////////////////
#if defined(USE_GEOM_CACHES)
struct IGeomCacheRenderNode
: public IRenderNode
{
virtual bool LoadGeomCache(const char* sGeomCacheFileName) = 0;
virtual void SetGeomCache(_smart_ptr<IGeomCache> geomCache) = 0;
// Gets the geometry cache that is rendered
virtual IGeomCache* GetGeomCache() const = 0;
// Sets the time in the animation for the current frame.
// Note that you should start streaming before calling this.
virtual void SetPlaybackTime(const float time) = 0;
// Get the current playback time
virtual float GetPlaybackTime() const = 0;
// Check if cache is streaming.
virtual bool IsStreaming() const = 0;
// Need to start streaming before playback, otherwise there will be stalls.
virtual void StartStreaming(const float time = 0.0f) = 0;
// Stops streaming and trashes the buffers
virtual void StopStreaming() = 0;
// Checks if looping is enabled
virtual bool IsLooping() const = 0;
// Enable/disable looping playback
virtual void SetLooping(const bool bEnable) = 0;
// Gets time delta from current playback position to last ready to play frame
virtual float GetPrecachedTime() const = 0;
// Check if bounds changed since last call to this function
virtual bool DidBoundsChange() = 0;
// Set stand in CGFs and distance
virtual void SetStandIn(const char* pFilePath, const char* pMaterial) = 0;
virtual IStatObj* GetStandIn() = 0;
virtual void SetFirstFrameStandIn(const char* pFilePath, const char* pMaterial) = 0;
virtual IStatObj* GetFirstFrameStandIn() = 0;
virtual void SetLastFrameStandIn(const char* pFilePath, const char* pMaterial) = 0;
virtual IStatObj* GetLastFrameStandIn() = 0;
virtual void SetStandInDistance(const float distance) = 0;
virtual float GetStandInDistance() = 0;
// Set distance at which cache will start streaming automatically (0 means no auto streaming)
virtual void SetStreamInDistance(const float distance) = 0;
virtual float GetStreamInDistance() = 0;
// Start/Stop drawing the cache
virtual void SetDrawing(bool bDrawing) = 0;
// Debug draw geometry
virtual void DebugDraw(const struct SGeometryDebugDrawInfo& info, float fExtrudeScale = 0.01f, uint nodeIndex = 0) const = 0;
// Ray intersection against cache
virtual bool RayIntersection(struct SRayHitInfo& hitInfo, _smart_ptr<IMaterial> pCustomMtl = NULL, uint* pHitNodeIndex = NULL) const = 0;
// Set max view distance
virtual void SetBaseMaxViewDistance(float maxViewDistance) = 0;
// Get node information
virtual uint GetNodeCount() const = 0;
virtual Matrix34 GetNodeTransform(const uint nodeIndex) const = 0;
virtual const char* GetNodeName(const uint nodeIndex) const = 0; // Node name is only stored in editor
virtual uint32 GetNodeNameHash(const uint nodeIndex) const = 0;
virtual bool IsNodeDataValid(const uint nodeIndex) const = 0; // Returns false if cache isn't loaded yet or index is out of range
};
#endif
#endif // CRYINCLUDE_CRYCOMMON_IENTITYRENDERSTATE_H
+4
View File
@@ -145,6 +145,7 @@ struct STextDrawContext
Vec2 m_size;
Vec2i m_requestSize;
float m_widthScale;
float m_lineSpacing;
float m_clipX;
float m_clipY;
@@ -175,6 +176,7 @@ struct STextDrawContext
, m_size(16.0f, 16.0f)
, m_requestSize(static_cast<int32>(m_size.x), static_cast<int32>(m_size.y))
, m_widthScale(1.0f)
, m_lineSpacing(0.f)
, m_clipX(0)
, m_clipY(0)
, m_clipWidth(0)
@@ -209,11 +211,13 @@ struct STextDrawContext
void SetTransform(const Matrix34& transform) { m_transform = transform; }
void SetBaseState(int baseState) { m_baseState = baseState; }
void SetOverrideViewProjMatrices(bool overrideViewProjMatrices) { m_overrideViewProjMatrices = overrideViewProjMatrices; }
void SetLineSpacing(float lineSpacing) { m_lineSpacing = lineSpacing; }
float GetCharWidth() const { return m_size.x; }
float GetCharHeight() const { return m_size.y; }
float GetCharWidthScale() const { return m_widthScale; }
int GetFlags() const { return m_drawTextFlags; }
float GetLineSpacing() const { return m_lineSpacing; }
bool IsColorOverridden() const { return m_colorOverride.a != 0; }
};
-268
View File
@@ -1,268 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_IFUNCVARIABLE_H
#define CRYINCLUDE_CRYCOMMON_IFUNCVARIABLE_H
#pragma once
#include "Cry_Vector2.h"
#include "Cry_Vector3.h"
#include "Cry_Matrix33.h"
#include "Cry_Color.h"
#include "smartptr.h"
#include "StringUtils.h"
class ITexture;
enum FuncParamType
{
e_FLOAT, e_INT, e_BOOL, e_VEC2, e_VEC3, e_VEC4, e_COLOR, e_MATRIX33,
// Though all types of textures are using the same class, it's important for editor to differentiate between them:
e_TEXTURE2D, e_TEXTURE3D, e_TEXTURE_CUBE
};
class IFuncVariable
: public _reference_target_t
{
public:
// <interfuscator:shuffle>
virtual ~IFuncVariable(){};
virtual float GetMin() const = 0;
virtual float GetMax() const = 0;
virtual void InvokeSetter(void* param) = 0;
virtual int GetInt() const = 0;
virtual float GetFloat() const = 0;
virtual bool GetBool() const = 0;
virtual Vec2 GetVec2() const = 0;
virtual Vec3 GetVec3() const = 0;
virtual Vec4 GetVec4() const = 0;
virtual ColorF GetColorF() const = 0;
virtual Matrix33 GetMatrix33() const = 0;
virtual ITexture* GetTexture() const = 0;
// </interfuscator:shuffle>
enum FuncParamType paramType; // float, string, int, vec3 etc
string name;
#if defined(FLARES_SUPPORT_EDITING)
string humanName;
string description;
#endif
};
template <class T>
class MFPVariable
: public IFuncVariable
{
public:
typedef void (T::* OpticsBase_MFPtr)();
OpticsBase_MFPtr pSetter;
OpticsBase_MFPtr pGetter;
T* pObj;
std::pair<float, float> range;
private:
MFPVariable ()
{
Set(e_INT, "", "", NULL, NULL, NULL);
}
public:
float GetMin() const override { return range.first; }
float GetMax() const override { return range.second; }
MFPVariable(FuncParamType type, const char* _humanname, const char* _description, T* obj, OpticsBase_MFPtr setter, OpticsBase_MFPtr getter, float fMin = 0, float fMax = 1.0f)
{
Set(type, _humanname, _description, obj, setter, getter, fMin, fMax);
}
void Set(FuncParamType type, const char* _humanname, const char* _description, T* obj, OpticsBase_MFPtr setter, OpticsBase_MFPtr getter, float fMin = 0, float fMax = 1.0f)
{
paramType = type;
char _nameNoSpace[50];
cry_strcpy(_nameNoSpace, _humanname);
char* p1 = _nameNoSpace;
char* p2 = p1;
while (*p1 != 0)
{
if ((*p1) == ' ')
{
++p1;
}
else
{
*p2++ = *p1++;
}
}
*p2 = 0;
name = _nameNoSpace;
#if defined(FLARES_SUPPORT_EDITING)
humanName = _humanname;
description = _description;
#endif
pObj = obj;
pSetter = setter;
pGetter = getter;
range.first = fMin;
range.second = fMax;
}
#define INVOKE_SETTER(PARAM_TYPE, param) (pObj->*(reinterpret_cast<void (T::*)(PARAM_TYPE)>(pSetter)))(*(PARAM_TYPE*)param)
#define INVOKE_SETTER_P(PARAM_TYPE, param) (pObj->*(reinterpret_cast<void (T::*)(PARAM_TYPE)>(pSetter)))((PARAM_TYPE)param)
void InvokeSetter(void* param) override
{
switch (paramType)
{
case e_FLOAT:
INVOKE_SETTER(float, param);
break;
case e_INT:
INVOKE_SETTER(int, param);
break;
case e_VEC2:
INVOKE_SETTER(Vec2, param);
break;
case e_VEC3:
INVOKE_SETTER(Vec3, param);
break;
case e_VEC4:
INVOKE_SETTER(Vec4, param);
break;
case e_BOOL:
INVOKE_SETTER(bool, param);
break;
case e_COLOR:
INVOKE_SETTER(ColorF, param);
break;
case e_MATRIX33:
INVOKE_SETTER(Matrix33, param);
break;
case e_TEXTURE2D:
INVOKE_SETTER_P(ITexture*, param);
break;
case e_TEXTURE3D:
INVOKE_SETTER_P(ITexture*, param);
break;
case e_TEXTURE_CUBE:
INVOKE_SETTER_P(ITexture*, param);
break;
}
}
#define INVOKE_GETTER(PARAM_TYPE) ((pObj->*reinterpret_cast<PARAM_TYPE (T::*)()>(pGetter))())
int GetInt() const override {return INVOKE_GETTER(int); }
float GetFloat() const override {return INVOKE_GETTER(float); }
bool GetBool() const override {return INVOKE_GETTER(bool); }
Vec2 GetVec2() const override {return INVOKE_GETTER(Vec2); }
Vec3 GetVec3() const override {return INVOKE_GETTER(Vec3); }
Vec4 GetVec4() const override {return INVOKE_GETTER(Vec4); }
ColorF GetColorF() const override {return INVOKE_GETTER(ColorF); }
Matrix33 GetMatrix33() const override {return INVOKE_GETTER(Matrix33); }
ITexture* GetTexture() const override {return INVOKE_GETTER(ITexture*); }
};
class FuncVariableGroup
{
private:
AZStd::vector<_smart_ptr<IFuncVariable> > variables;
string m_name;
#if defined(FLARES_SUPPORT_EDITING)
string m_humanname;
#endif
bool bCollapse;
public:
FuncVariableGroup()
: bCollapse(false)
{
SetName("");
}
~FuncVariableGroup()
{
}
void SetName(const char* name, [[maybe_unused]] const char* humanname = 0)
{
if (!name)
{
return;
}
m_name = name;
#if defined(FLARES_SUPPORT_EDITING)
m_humanname = humanname ? humanname : name;
#endif
}
const char* GetName()
{
return m_name.c_str();
}
#if defined(FLARES_SUPPORT_EDITING)
const char* GetHumanName()
{
return m_humanname.c_str();
}
#endif
void SetCollapse(bool _bCollapse)
{
bCollapse = _bCollapse;
}
bool IsCollapse()
{
return bCollapse;
}
IFuncVariable* FindVariable(const char* name)
{
for (int i = 0, iSize(variables.size()); i < iSize; ++i)
{
if (variables[i] == NULL)
{
continue;
}
if (!strcmp(variables[i]->name.c_str(), name))
{
return variables[i];
}
}
return NULL;
}
void SetVariable(int nIndex, IFuncVariable* v){ variables[nIndex] = v; }
int GetVariableCount() { return variables.size(); }
IFuncVariable* GetVariable(int nIndex)
{
return variables[nIndex];
}
void AddVariable(IFuncVariable* var)
{
variables.push_back(var);
}
};
#endif // CRYINCLUDE_CRYCOMMON_IFUNCVARIABLE_H
-140
View File
@@ -1,140 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Interface for CGeomCache class
#ifndef CRYINCLUDE_CRYCOMMON_IGEOMCACHE_H
#define CRYINCLUDE_CRYCOMMON_IGEOMCACHE_H
#pragma once
#include "smartptr.h" // TYPEDEF_AUTOPTR
// Summary:
// Interface to hold geom cache data
struct IGeomCache
: public IStreamable
{
// Description:
// Increase the reference count of the object.
// Summary:
// Notifies that the object is being used
virtual int AddRef() = 0;
// Description:
// Decrease the reference count of the object. If the reference count
// reaches zero, the object will be deleted from memory.
// Summary:
// Notifies that the object is no longer needed
virtual int Release() = 0;
// Description:
// Checks if the geometry cache was successfully loaded from disk
// Return Value:
// True if valid, otherwise false
virtual bool IsValid() const = 0;
// Description:
// Set default material for the geometry.
// Arguments:
// pMaterial - A valid pointer to the material.
virtual void SetMaterial(_smart_ptr<IMaterial> pMaterial) = 0;
// Description:
// Returns default material of the geometry.
// Arguments:
// nType - Pass 0 to get the physic geometry or pass 1 to get the obstruct geometry
// Return Value:
// A pointer to a phys_geometry class.
virtual _smart_ptr<IMaterial> GetMaterial() = 0;
virtual const _smart_ptr<IMaterial> GetMaterial() const = 0;
// Summary:
// Returns the filename of the object
// Return Value:
// A null terminated string which contain the filename of the object.
virtual const char* GetFilePath() const = 0;
// Summary:
// Returns the duration of the geom cache animation
// Return value:
// float value in seconds
virtual float GetDuration() const = 0;
// Summary:
// Reloads the cache. Need to call this when cache file changed.
virtual void Reload() = 0;
// Summary:
// Returns the max AABB of the geom cache through the whole animation
// Return value:
// The geom cache's max axis aligned bounding box
virtual const AABB& GetAABB() const = 0;
/**
* Tells the GeomCache whether or not it can release its static mesh data
*
* For the new AZ Geom Cache asset we have to be able
* to tell the Geom Cache not to release loaded data.
* This only matters when Geom Caches are not streamed.
*
* The legacy system works like this (if e_streamCGF is 0):
* Load a geom cache entity.
* Entity creates a geom cache render node.
* Node loads geom cache, cache is marked as loaded.
* Render node immediately initializes with the Geom Cache data.
* Because the Geom Cache is not streamed, it releases unneeded data next tick
*
* The AZ system works like this:
* Geom Cache component is created
* Asset is requested
* Asset loads Geom Cache
* Geom Cache loads data and is marked as loaded
* Asset calls AllowReleaseLoadedData(false) and locks loaded state
* Tick happens and data is not freed (this is good, we need that data)
* OnAssetReady event fires and is picked up by Geom Cache Component
* Data is fed from the asset to the Geom Cache Render Node
* Component calls AllowReleaseLoadedData(true)
* Next tick the Geom Cache cleans up unneeded data
*/
virtual void SetProcessedByRenderNode(bool) = 0;
// Summary:
// Returns statistics
// Return value:
// SStatistics struct
struct SStatistics
{
bool m_bPlaybackFromMemory;
float m_averageAnimationDataRate;
uint m_numStaticMeshes;
uint m_numStaticVertices;
uint m_numStaticTriangles;
uint m_numAnimatedMeshes;
uint m_numAnimatedVertices;
uint m_numAnimatedTriangles;
uint m_numMaterials;
uint m_staticDataSize;
uint m_diskAnimationDataSize;
uint m_memoryAnimationDataSize;
};
virtual SStatistics GetStatistics() const = 0;
protected:
virtual ~IGeomCache() {}; // should be never called, use Release() instead
};
#endif // CRYINCLUDE_CRYCOMMON_IGEOMCACHE_H
-76
View File
@@ -1,76 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_IIMAGE_H
#define CRYINCLUDE_CRYCOMMON_IIMAGE_H
#pragma once
/**
* Possible errors for IImageFile::mfGet_error.
*/
enum EImFileError
{
eIFE_OK = 0, eIFE_IOerror, eIFE_OutOfMemory, eIFE_BadFormat, eIFE_ChunkNotFound
};
// here are all of the flags that can be passed into the image load flags
#define FIM_NORMALMAP 0x0001
#define FIM_NOTSUPPORTS_MIPS 0x0004
#define FIM_ALPHA 0x0008 // request attached alpha image
#define FIM_DECAL 0x0010
#define FIM_GREYSCALE 0x0020 // hint this texture is greyscale (could be DXT1 with colored artifacts)
#define FIM_STREAM_PREPARE 0x0080
#define FIM_UNUSED_BIT 0x0100 // Free to use
#define FIM_BIG_ENDIANNESS 0x0400 // for textures converted to big endianness format
#define FIM_SPLITTED 0x0800 // for dds textures stored in splitted files
#define FIM_SRGB_READ 0x1000
#define FIM_X360_NOT_PRETILED 0x2000 // for dds textures that cannot be pretiled
#define FIM_UNUSED_BIT_1 0x4000 // Free to use
#define FIM_RENORMALIZED_TEXTURE 0x8000 // for dds textures with EIF_RenormalizedTexture set in the dds header (not currently supported in the engine at runtime)
#define FIM_HAS_ATTACHED_ALPHA 0x10000 // image has an attached alpha image
#define FIM_SUPPRESS_DOWNSCALING 0x20000 // don't allow to drop mips when texture is non-streamable
#define FIM_DX10IO 0x40000 // for dds textures with extended DX10+ header
#define FIM_NOFALLBACKS 0x80000 // if the texture can't be loaded or is not found, do not replace it with a default 'not found' texture.
class IImageFile
{
public:
virtual int AddRef() = 0;
virtual int Release() = 0;
virtual const string& mfGet_filename () const = 0;
virtual int mfGet_width () const = 0;
virtual int mfGet_height () const = 0;
virtual int mfGet_depth () const = 0;
virtual int mfGet_NumSides () const = 0;
virtual EImFileError mfGet_error () const = 0;
virtual byte* mfGet_image (const int nSide) = 0;
virtual bool mfIs_image (const int nSide) const = 0;
virtual ETEX_Format mfGetFormat() const = 0;
virtual ETEX_TileMode mfGetTileMode() const = 0;
virtual int mfGet_numMips () const = 0;
virtual int mfGet_numPersistentMips () const = 0;
virtual int mfGet_Flags () const = 0;
virtual const ColorF& mfGet_minColor () const = 0;
virtual const ColorF& mfGet_maxColor () const = 0;
virtual int mfGet_ImageSize() const = 0;
protected:
virtual ~IImageFile() {}
};
#endif // CRYINCLUDE_CRYCOMMON_IIMAGE_H
@@ -1,32 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Provides the interface for the lz4 hc decompress wrapper
#ifndef CRYINCLUDE_CRYCOMMON_ILZ4DECOMPRESSOR_H
#define CRYINCLUDE_CRYCOMMON_ILZ4DECOMPRESSOR_H
#pragma once
struct ILZ4Decompressor
{
protected:
virtual ~ILZ4Decompressor() {}; // use Release()
public:
virtual bool DecompressData(const char* pIn, char* pOut, const uint outputSize) const = 0;
virtual void Release() = 0;
};
#endif // CRYINCLUDE_CRYCOMMON_ILZ4DECOMPRESSOR_H
-50
View File
@@ -1,50 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_IMESHBAKING_H
#define CRYINCLUDE_CRYCOMMON_IMESHBAKING_H
#pragma once
struct SMeshBakingMaterialParams
{
float rayLength;
float rayIndent;
bool bAlphaCutout;
bool bIgnore;
};
struct SMeshBakingInputParams
{
IStatObj* pCageMesh;
IStatObj* pInputMesh;
const SMeshBakingMaterialParams* pMaterialParams;
ColorF defaultBackgroundColour;
ColorF dilateMagicColour;
int outputTextureWidth;
int outputTextureHeight;
int numMaterialParams;
int nLodId;
bool bDoDilationPass;
bool bSmoothNormals;
bool bSaveSpecular;
_smart_ptr<IMaterial> pMaterial;
};
struct SMeshBakingOutput
{
ITexture* ppOuputTexture[3];
ITexture* ppIntermediateTexture[3];
};
#endif // CRYINCLUDE_CRYCOMMON_IMESHBAKING_H
-252
View File
@@ -1,252 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
struct IStreamable;
struct SCheckOcclusionJobData;
struct SCheckOcclusionOutput;
class COctreeNode;
struct IStatInstGroup;
namespace NAsyncCull
{
class CCullThread;
}
// Inplace object for IStreamable* to cache StreamableMemoryContentSize
struct SStreamAbleObject
{
explicit SStreamAbleObject(IStreamable* pObj, bool bUpdateMemUsage = true)
: m_pObj(pObj)
, fCurImportance(-1000.f)
{
if (pObj && bUpdateMemUsage)
{
m_nStreamableContentMemoryUsage = pObj->GetStreamableContentMemoryUsage();
}
else
{
m_nStreamableContentMemoryUsage = 0;
}
}
bool operator==(const SStreamAbleObject& rOther) const
{
return m_pObj == rOther.m_pObj;
}
int GetStreamableContentMemoryUsage() const { return m_nStreamableContentMemoryUsage; }
IStreamable* GetStreamAbleObject() const { return m_pObj; }
uint32 GetLastDrawMainFrameId() const
{
return m_pObj->GetLastDrawMainFrameId();
}
float fCurImportance;
private:
IStreamable* m_pObj;
int m_nStreamableContentMemoryUsage;
};
struct SObjManPrecacheCamera
{
SObjManPrecacheCamera()
: vPosition(ZERO)
, vDirection(ZERO)
, bbox(AABB::RESET)
, fImportanceFactor(1.0f)
{
}
Vec3 vPosition;
Vec3 vDirection;
AABB bbox;
float fImportanceFactor;
};
struct SObjManPrecachePoint
{
SObjManPrecachePoint()
: nId(0)
{
}
int nId;
CTimeValue expireTime;
};
struct IObjManager
{
virtual ~IObjManager() {}
virtual void PreloadLevelObjects() = 0;
virtual void UnloadObjects(bool bDeleteAll) = 0;
virtual void CheckTextureReadyFlag() = 0;
virtual void FreeStatObj(IStatObj* pObj) = 0;
virtual _smart_ptr<IStatObj> GetDefaultCGF() = 0;
typedef std::vector< IDecalRenderNode* > DecalsToPrecreate;
virtual DecalsToPrecreate& GetDecalsToPrecreate() = 0;
virtual PodArray<SStreamAbleObject>& GetArrStreamableObjects() = 0;
virtual PodArray<SObjManPrecacheCamera>& GetStreamPreCacheCameras() = 0;
virtual PodArray<COctreeNode*>& GetArrStreamingNodeStack() = 0;
virtual PodArray<SObjManPrecachePoint>& GetStreamPreCachePointDefs() = 0;
typedef std::map<string, IStatObj*, stl::less_stricmp<string> > ObjectsMap;
virtual ObjectsMap& GetNameToObjectMap() = 0;
typedef std::set<IStatObj*> LoadedObjects;
virtual LoadedObjects& GetLoadedObjects() = 0;
virtual Vec3 GetSunColor() = 0;
virtual void SetSunColor(const Vec3& color) = 0;
virtual Vec3 GetSunAnimColor() = 0;
virtual void SetSunAnimColor(const Vec3& color) = 0;
virtual float GetSunAnimSpeed() = 0;
virtual void SetSunAnimSpeed(float sunAnimSpeed) = 0;
virtual AZ::u8 GetSunAnimPhase() = 0;
virtual void SetSunAnimPhase(AZ::u8 sunAnimPhase) = 0;
virtual AZ::u8 GetSunAnimIndex() = 0;
virtual void SetSunAnimIndex(AZ::u8 sunAnimIndex) = 0;
virtual float GetSSAOAmount() = 0;
virtual void SetSSAOAmount(float amount) = 0;
virtual float GetSSAOContrast() = 0;
virtual void SetSSAOContrast(float amount) = 0;
virtual SRainParams& GetRainParams() = 0;
virtual SSnowParams& GetSnowParams() = 0;
virtual bool IsCameraPrecacheOverridden() = 0;
virtual void SetCameraPrecacheOverridden(bool state) = 0;
virtual IStatObj* LoadNewCGF(IStatObj* pObject, int flagCloth, bool bUseStreaming, bool bForceBreakable, unsigned long nLoadingFlags, const char* normalizedFilename, const void* pData, int nDataSize, const char* originalFilename, const char* geomName, IStatObj::SSubObject** ppSubObject) = 0;
virtual IStatObj* LoadFromCacheNoRef(IStatObj* pObject, bool bUseStreaming, unsigned long nLoadingFlags, const char* geomName, IStatObj::SSubObject** ppSubObject) = 0;
virtual IStatObj* AllocateStatObj() = 0;
virtual IStatObj* LoadStatObjUnsafeManualRef(const char* szFileName, const char* szGeomName = NULL, IStatObj::SSubObject** ppSubObject = NULL, bool bUseStreaming = true, unsigned long nLoadingFlags = 0, const void* m_pData = 0, int m_nDataSize = 0, const char* szBlockName = NULL) = 0;
virtual _smart_ptr<IStatObj> LoadStatObjAutoRef(const char* szFileName, const char* szGeomName = NULL, IStatObj::SSubObject** ppSubObject = NULL, bool bUseStreaming = true, unsigned long nLoadingFlags = 0, const void* m_pData = 0, int m_nDataSize = 0, const char* szBlockName = NULL) = 0;
virtual void GetLoadedStatObjArray(IStatObj** pObjectsArray, int& nCount) = 0;
virtual bool InternalDeleteObject(IStatObj* pObject) = 0;
virtual void MakeShadowCastersList(CVisArea* pReceiverArea, const AABB& aabbReceiver, int dwAllowedTypes, int32 nRenderNodeFlags, Vec3 vLightPos, CDLight* pLight, ShadowMapFrustum* pFr, PodArray<struct SPlaneObject>* pShadowHull, const SRenderingPassInfo& passInfo) = 0;
virtual int MakeStaticShadowCastersList(IRenderNode* pIgnoreNode, ShadowMapFrustum* pFrustum, int renderNodeExcludeFlags, int nMaxNodes, const SRenderingPassInfo& passInfo) = 0;
virtual void MakeDepthCubemapRenderItemList(CVisArea* pReceiverArea, const AABB& cubemapAABB, int renderNodeFlags, PodArray<struct IShadowCaster*>* objectsList, const SRenderingPassInfo& passInfo) = 0;
virtual void PrecacheStatObjMaterial(_smart_ptr<IMaterial> pMaterial, const float fEntDistance, IStatObj* pStatObj, bool bFullUpdate, bool bDrawNear) = 0;
virtual void PrecacheStatObj(IStatObj* pStatObj, int nLod, const Matrix34A& statObjMatrix, _smart_ptr<IMaterial> pMaterial, float fImportance, float fEntDistance, bool bFullUpdate, bool bHighPriority) = 0;
virtual int GetLoadedObjectCount() = 0;
virtual uint16 CheckCachedNearestCubeProbe(IRenderNode* pEnt) = 0;
virtual int16 GetNearestCubeProbe(IVisArea* pVisArea, const AABB& objBox, bool bSpecular = true) = 0;
virtual void RenderObject(IRenderNode* o, const AABB& objBox, float fEntDistance, EERType eERType, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0;
virtual void RenderDecalAndRoad(IRenderNode* pEnt, const AABB& objBox, float fEntDistance, bool nCheckOcclusion, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0;
virtual void RenderObjectDebugInfo(IRenderNode* pEnt, float fEntDistance, const SRenderingPassInfo& passInfo) = 0;
virtual void RenderAllObjectDebugInfo() = 0;
virtual void RenderObjectDebugInfo_Impl(IRenderNode* pEnt, float fEntDistance) = 0;
virtual void RemoveFromRenderAllObjectDebugInfo(IRenderNode* pEnt) = 0;
virtual float GetXYRadius(int nType, int nSID = DEFAULT_SID) = 0;
virtual bool GetStaticObjectBBox(int nType, Vec3& vBoxMin, Vec3& vBoxMax, int nSID = DEFAULT_SID) = 0;
virtual IStatObj* GetStaticObjectByTypeID(int nTypeID, int nSID = DEFAULT_SID) = 0;
virtual IStatObj* FindStaticObjectByFilename(const char* filename) = 0;
//virtual float GetBendingRandomFactor() = 0;
virtual float GetGSMMaxDistance() const = 0;
virtual void SetGSMMaxDistance(float value) = 0;
virtual int GetUpdateStreamingPrioriryRoundIdFast() = 0;
virtual int GetUpdateStreamingPrioriryRoundId() = 0;
virtual void IncrementUpdateStreamingPrioriryRoundIdFast(int amount) = 0;
virtual void IncrementUpdateStreamingPrioriryRoundId(int amount) = 0;
virtual NAsyncCull::CCullThread& GetCullThread() = 0;
virtual void SetLockCGFResources(bool state) = 0;
virtual bool IsLockCGFResources() = 0;
virtual bool IsBoxOccluded(const AABB& objBox, float fDistance, OcclusionTestClient* const __restrict pOcclTestVars, bool bIndoorOccludersOnly, EOcclusionObjectType eOcclusionObjectType, const SRenderingPassInfo& passInfo) = 0;
virtual void AddDecalToRenderer(float fDistance, _smart_ptr<IMaterial> pMat, const uint8 sortPrio, Vec3 right, Vec3 up, const UCol& ucResCol, const uint8 uBlendType, const Vec3& vAmbientColor, Vec3 vPos, const int nAfterWater, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0;
virtual void RegisterForStreaming(IStreamable* pObj) = 0;
virtual void UnregisterForStreaming(IStreamable* pObj) = 0;
virtual void UpdateRenderNodeStreamingPriority(IRenderNode* pObj, float fEntDistance, float fImportanceFactor, bool bFullUpdate, const SRenderingPassInfo& passInfo, bool bHighPriority = false) = 0;
virtual void GetMemoryUsage(class ICrySizer* pSizer) const = 0;
virtual void GetBandwidthStats(float* fBandwidthRequested) = 0;
virtual void ReregisterEntitiesInArea(Vec3 vBoxMin, Vec3 vBoxMax) = 0;
virtual void UpdateObjectsStreamingPriority(bool bSyncLoad, const SRenderingPassInfo& passInfo) = 0;
virtual void ProcessObjectsStreaming(const SRenderingPassInfo& passInfo) = 0;
virtual void ProcessObjectsStreaming_Impl(bool bSyncLoad, const SRenderingPassInfo& passInfo) = 0;
virtual void ProcessObjectsStreaming_Sort(bool bSyncLoad, const SRenderingPassInfo& passInfo) = 0;
virtual void ProcessObjectsStreaming_Release() = 0;
virtual void ProcessObjectsStreaming_InitLoad(bool bSyncLoad) = 0;
virtual void ProcessObjectsStreaming_Finish() = 0;
// time counters
virtual bool IsAfterWater(const Vec3& vPos, const SRenderingPassInfo& passInfo) = 0;
virtual void FreeNotUsedCGFs() = 0;
virtual void MakeUnitCube() = 0;
virtual bool CheckOcclusion_TestAABB(const AABB& rAABB, float fEntDistance) = 0;
virtual bool CheckOcclusion_TestQuad(const Vec3& vCenter, const Vec3& vAxisX, const Vec3& vAxisY) = 0;
virtual void PushIntoCullQueue(const SCheckOcclusionJobData& rCheckOcclusionData) = 0;
virtual void PopFromCullQueue(SCheckOcclusionJobData* pCheckOcclusionData) = 0;
virtual void PushIntoCullOutputQueue(const SCheckOcclusionOutput& rCheckOcclusionOutput) = 0;
virtual bool PopFromCullOutputQueue(SCheckOcclusionOutput* pCheckOcclusionOutput) = 0;
virtual void BeginCulling() = 0;
virtual void RemoveCullJobProducer() = 0;
virtual void AddCullJobProducer() = 0;
#ifndef _RELEASE
virtual void CoverageBufferDebugDraw() = 0;
#endif
virtual bool LoadOcclusionMesh(const char* pFileName) = 0;
virtual void ClearStatObjGarbage() = 0;
virtual void CheckForGarbage(IStatObj* pObject) = 0;
virtual void UnregisterForGarbage(IStatObj* pObject) = 0;
virtual int GetObjectLOD(const IRenderNode* pObj, float fDistance) = 0;
virtual bool RayStatObjIntersection(IStatObj* pStatObj, const Matrix34& objMat, _smart_ptr<IMaterial> pMat, Vec3 vStart, Vec3 vEnd, Vec3& vClosestHitPoint, float& fClosestHitDistance, bool bFastTest) = 0;
virtual bool RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal, bool bFastTest, _smart_ptr<IMaterial> pMat) = 0;
virtual bool SphereRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const float fRadius, _smart_ptr<IMaterial> pMat) = 0;
virtual uint8 GetDissolveRef(float fDist, float fMaxViewDist) = 0;
virtual float GetLodDistDissolveRef(SLodDistDissolveTransitionState* pState, float curDist, int nNewLod, const SRenderingPassInfo& passInfo) = 0;
virtual void CleanStreamingData() = 0;
virtual IRenderMesh* GetRenderMeshBox() = 0;
virtual void PrepareCullbufferAsync(const CCamera& rCamera) = 0;
virtual void BeginOcclusionCulling(const SRenderingPassInfo& passInfo) = 0;
virtual void EndOcclusionCulling(bool waitForOcclusionJobCompletion = false) = 0;
virtual void RenderBufferedRenderMeshes(const SRenderingPassInfo& passInfo) = 0;
virtual int GetListStaticTypesCount() = 0;
virtual int GetListStaticTypesGroupCount(int typeId) = 0;
virtual IStatInstGroup* GetIStatInstGroup(int typeId, int groupId) = 0;
virtual int IncrementNextPrecachePointId() = 0;
};
@@ -1,19 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_IPHYSICSDEBUGRENDERER_H
#define CRYINCLUDE_CRYCOMMON_IPHYSICSDEBUGRENDERER_H
#pragma once
#endif // CRYINCLUDE_CRYCOMMON_IPHYSICSDEBUGRENDERER_H
@@ -1,133 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_IPROXIMITYTRIGGERSYSTEM_H
#define CRYINCLUDE_CRYCOMMON_IPROXIMITYTRIGGERSYSTEM_H
#pragma once
#include <AzCore/base.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/std/function/function_fwd.h>
#include <Cry_Geo.h> // AABB
/**
* Represents a registered proximity trigger.
*
* Contains the id of the trigger, its bounds, and whether or not it's active.
*/
struct SProximityElement
{
AZ::EntityId id;
AABB aabb;
uint32 bActivated : 1;
std::vector<SProximityElement*> inside;
using NarrowPassCheckFunction = AZStd::function<bool(const AZ::Vector3&)>;
// Can be used to do an optional narrow pass check on this proximity element
NarrowPassCheckFunction m_narrowPassChecker;
SProximityElement()
{
id = AZ::EntityId(0);
bActivated = 0;
}
~SProximityElement()
{
}
bool AddInside(SProximityElement* elem)
{
// Sorted add.
return stl::binary_insert_unique(inside, elem);
}
bool RemoveInside(SProximityElement* elem)
{
// sorted remove.
return stl::binary_erase(inside, elem);
}
bool IsInside(SProximityElement* elem)
{
return std::binary_search(inside.begin(), inside.end(), elem);
}
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{}
};
/**
* Bus for events dispatched by the proximity trigger system as triggered are
* entered and exited by entities in the world.
*/
class ProximityTriggerEvents
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// Ebus Traits
// ID'd on trigger entity Id
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AZ::EntityId;
//////////////////////////////////////////////////////////////////////////
virtual ~ProximityTriggerEvents() {}
/// Dispatched when an entity enters a trigger. The bus message is ID'd on the triggers entity Id.
virtual void OnTriggerEnter(AZ::EntityId /*entityEntering*/) {};
/// Dispatched when an entity exits a trigger. The bus message is ID'd on the triggers entity Id.
virtual void OnTriggerExit(AZ::EntityId /*entityExiting*/) {};
};
using ProximityTriggerEventBus = AZ::EBus<ProximityTriggerEvents>;
/**
* Bus for requests sent by components or game code to the proximity trigger system.
*/
class ProximityTriggerSystemRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides - proximity trigger system is a singleton
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//////////////////////////////////////////////////////////////////////////
virtual ~ProximityTriggerSystemRequests() {}
/// Creates a new trigger instance.
virtual SProximityElement* CreateTrigger(SProximityElement::NarrowPassCheckFunction narrowPassChecker = nullptr) = 0;
/// Removes a trigger and queues it for deletion.
virtual void RemoveTrigger(SProximityElement* pTrigger) = 0;
/// Moves a trigger in the world or redefines its dimensions.
virtual void MoveTrigger(SProximityElement* pTrigger, const AABB& aabb, bool invalidateCachedAABB = false) = 0;
/// Creates a proxy in the world associated with an entity (Component or Legacy) for interacting with proximity trigger instances.
virtual SProximityElement* CreateEntity(AZ::EntityId id) = 0;
/**
* Set the entity's AABB to a unit AABB at the entity's world position if \aabb is empty, otherwise set the entity's AABB to \aabb
* @param pEntity The pointer to a SProximityElment whose AABB needs to be updated
* @param pos World position of the entity
* @param aabb The new AABB in world space to set
*/
virtual void MoveEntity(SProximityElement* pEntity, const Vec3& pos, const AABB& aabb) = 0;
/// Removes an entity's proximity trigger proxy.
virtual void RemoveEntity(SProximityElement* pEntity, bool instantEvent = false) = 0;
};
using ProximityTriggerSystemRequestBus = AZ::EBus<ProximityTriggerSystemRequests>;
#endif // CRYINCLUDE_CRYCOMMON_IPROXIMITYTRIGGERSYSTEM_H
+6 -16
View File
@@ -16,7 +16,12 @@
#include "Cry_Geo.h"
#include "Cry_Camera.h"
#include "ITexture.h"
#include <IFuncVariable.h> // <> required for Interfuscator
#include "Cry_Vector2.h"
#include "Cry_Vector3.h"
#include "Cry_Matrix33.h"
#include "Cry_Color.h"
#include "smartptr.h"
#include "StringUtils.h"
#include <IXml.h> // <> required for Interfuscator
#include "smartptr.h"
#include <AzCore/Casting/numeric_cast.h>
@@ -99,7 +104,6 @@ struct ShadowFrustumMGPUCache;
struct IAsyncTextureCompileListener;
struct IClipVolume;
struct SClipVolumeBlendInfo;
class IImageFile;
class CRenderView;
struct SDynTexture2;
class CTexture;
@@ -693,7 +697,6 @@ public:
#include <IShader.h> // <> required for Interfuscator
//DOC-IGNORE-END
#include <IRenderMesh.h>
#include "IMeshBaking.h"
// Flags passed in function FreeResources.
#define FRR_SHADERS 1
@@ -1051,11 +1054,6 @@ namespace AZ {
namespace Vertex {
class Format;
}
namespace VideoRenderer
{
struct IVideoRenderer;
struct DrawArguments;
}
}
enum eRenderPrimitiveType : int8;
enum RenderIndexType : int;
@@ -1464,7 +1462,6 @@ struct IRenderer
// Is threadsafe
virtual bool EF_ReloadFile_Request (const char* szFileName) = 0;
virtual _smart_ptr<IImageFile> EF_LoadImage(const char* szFileName, uint32 nFlags) = 0;
// Summary:
// Remaps shader gen mask to common global mask.
virtual uint64 EF_GetRemapedShaderMaskGen(const char* name, uint64 nMaskGen = 0, bool bFixup = 0) = 0;
@@ -1739,8 +1736,6 @@ struct IRenderer
virtual void RemoveTexture(unsigned int TextureId) = 0;
virtual void DeleteFont(IFFont* font) = 0;
virtual bool BakeMesh(const SMeshBakingInputParams* pInputParams, SMeshBakingOutput* pReturnValues) = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////////
// This routines uses 2 destination surfaces. It triggers a backbuffer copy to one of its surfaces,
// and then copies the other surface to system memory. This hopefully will remove any
@@ -2346,11 +2341,6 @@ struct IRenderer
virtual void EndProfilerSection(const char* name) = 0;
virtual void AddProfilerLabel(const char* name) = 0;
// Video Renderer interface
virtual void InitializeVideoRenderer(AZ::VideoRenderer::IVideoRenderer* pVideoRenderer) = 0;
virtual void CleanupVideoRenderer(AZ::VideoRenderer::IVideoRenderer* pVideoRenderer) = 0;
virtual void DrawVideoRenderer(AZ::VideoRenderer::IVideoRenderer* pVideoRenderer, const AZ::VideoRenderer::DrawArguments& drawArguments) = 0;
private:
// use private for EF_Query to prevent client code to submit arbitrary combinations of output data/size
virtual void EF_QueryImpl(ERenderQueryTypes eQuery, void* pInOut0, uint32 nInOutSize0, void* pInOut1, uint32 nInOutSize1) = 0;
+6 -1
View File
@@ -24,7 +24,12 @@
#endif
#include "smartptr.h"
#include <IFuncVariable.h> // <> required for Interfuscator
#include "Cry_Vector2.h"
#include "Cry_Vector3.h"
#include "Cry_Matrix33.h"
#include "Cry_Color.h"
#include "smartptr.h"
#include "StringUtils.h"
#include <IXml.h> // <> required for Interfuscator
#include "smartptr.h"
#include "VertexFormats.h"
-78
View File
@@ -1,78 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include <IShader.h> // <> required for Interfuscator
// Traits
#if defined(AZ_RESTRICTED_PLATFORM)
#include AZ_RESTRICTED_FILE(IShader_info_h)
#elif !defined(LINUX) && !defined(APPLE)
#define ISHADER_INFO_H_TRAIT_DEFINE_ETEX_INFO 1
#endif
#if ISHADER_INFO_H_TRAIT_DEFINE_ETEX_INFO
ENUM_INFO_BEGIN(ETEX_Format)
ENUM_ELEM_INFO(, eTF_Unknown)
ENUM_ELEM_INFO(, eTF_R8G8B8A8S)
ENUM_ELEM_INFO(, eTF_R8G8B8A8)
ENUM_ELEM_INFO(, eTF_A8)
ENUM_ELEM_INFO(, eTF_R8)
ENUM_ELEM_INFO(, eTF_R8S)
ENUM_ELEM_INFO(, eTF_R16)
ENUM_ELEM_INFO(, eTF_R16F)
ENUM_ELEM_INFO(, eTF_R32F)
ENUM_ELEM_INFO(, eTF_R8G8)
ENUM_ELEM_INFO(, eTF_R8G8S)
ENUM_ELEM_INFO(, eTF_R16G16)
ENUM_ELEM_INFO(, eTF_R16G16S)
ENUM_ELEM_INFO(, eTF_R16G16F)
ENUM_ELEM_INFO(, eTF_R11G11B10F)
ENUM_ELEM_INFO(, eTF_R10G10B10A2)
ENUM_ELEM_INFO(, eTF_R16G16B16A16)
ENUM_ELEM_INFO(, eTF_R16G16B16A16S)
ENUM_ELEM_INFO(, eTF_R16G16B16A16F)
ENUM_ELEM_INFO(, eTF_R32G32B32A32F)
ENUM_ELEM_INFO(, eTF_CTX1)
ENUM_ELEM_INFO(, eTF_BC1)
ENUM_ELEM_INFO(, eTF_BC2)
ENUM_ELEM_INFO(, eTF_BC3)
ENUM_ELEM_INFO(, eTF_BC4U)
ENUM_ELEM_INFO(, eTF_BC4S)
ENUM_ELEM_INFO(, eTF_BC5U)
ENUM_ELEM_INFO(, eTF_BC5S)
ENUM_ELEM_INFO(, eTF_BC6UH)
ENUM_ELEM_INFO(, eTF_BC6SH)
ENUM_ELEM_INFO(, eTF_BC7)
ENUM_ELEM_INFO(, eTF_R9G9B9E5)
ENUM_ELEM_INFO(, eTF_D16)
ENUM_ELEM_INFO(, eTF_D24S8)
ENUM_ELEM_INFO(, eTF_D32F)
ENUM_ELEM_INFO(, eTF_D32FS8)
ENUM_ELEM_INFO(, eTF_B5G6R5)
ENUM_ELEM_INFO(, eTF_B5G5R5)
ENUM_ELEM_INFO(, eTF_B4G4R4A4)
ENUM_ELEM_INFO(, eTF_EAC_R11)
ENUM_ELEM_INFO(, eTF_EAC_RG11)
ENUM_ELEM_INFO(, eTF_ETC2)
ENUM_ELEM_INFO(, eTF_ETC2A)
ENUM_ELEM_INFO(, eTF_A8L8)
ENUM_ELEM_INFO(, eTF_L8)
ENUM_ELEM_INFO(, eTF_L8V8U8)
ENUM_ELEM_INFO(, eTF_B8G8R8)
ENUM_ELEM_INFO(, eTF_L8V8U8X8)
ENUM_ELEM_INFO(, eTF_B8G8R8X8)
ENUM_ELEM_INFO(, eTF_B8G8R8A8)
ENUM_INFO_END(ETEX_Format)
#endif
-104
View File
@@ -76,14 +76,9 @@ struct IViewSystem;
class ICrySizer;
class IXMLBinarySerializer;
struct IReadWriteXMLSink;
struct ITextModeConsole;
struct IAVI_Reader;
class CPNoise3;
struct ILocalizationManager;
struct IZLibCompressor;
struct IZLibDecompressor;
struct ILZ4Decompressor;
class IZStdDecompressor;
struct IOutputPrintSink;
struct IWindowMessageHandler;
@@ -524,7 +519,6 @@ struct SSystemInitParams
ISystemUserCallback* pUserCallback;
const char* sLogFileName; // File name to use for log.
bool autoBackupLogs; // if true, logs will be automatically backed up each startup
IValidator* pValidator; // You can specify different validator object to use by System.
IOutputPrintSink* pPrintSync; // Print Sync which can be used to catch all output from engine
char szSystemCmdLine[2048]; // Command line.
@@ -554,7 +548,6 @@ struct SSystemInitParams
pUserCallback = NULL;
sLogFileName = NULL;
autoBackupLogs = true;
pValidator = NULL;
pPrintSync = NULL;
memset(szSystemCmdLine, 0, sizeof(szSystemCmdLine));
@@ -828,14 +821,6 @@ struct ISystem
// Retrieve the name of the user currently logged in to the computer.
virtual const char* GetUserName() = 0;
// Summary:
// Gets current supported CPU features flags. (CPUF_SSE, CPUF_SSE2, CPUF_3DNOW, CPUF_MMX)
virtual int GetCPUFlags() = 0;
// Summary:
// Gets number of CPUs
virtual int GetLogicalCPUCount() = 0;
// Summary:
// Quits the application.
virtual void Quit() = 0;
@@ -852,13 +837,6 @@ struct ISystem
virtual bool IsRelaunch() const = 0;
// Summary:
// Displays an error message to display info for certain time
// Arguments:
// acMessage - Message to show
// fTime - Amount of seconds to show onscreen
virtual void DisplayErrorMessage(const char* acMessage, float fTime, const float* pfColor = 0, bool bHardError = true) = 0;
// Description:
// Displays error message.
// Logs it to console and file and error message box then terminates execution.
@@ -889,14 +867,9 @@ struct ISystem
// return the related subsystem interface
//
virtual IZLibCompressor* GetIZLibCompressor() = 0;
virtual IZLibDecompressor* GetIZLibDecompressor() = 0;
virtual ILZ4Decompressor* GetLZ4Decompressor() = 0;
virtual IZStdDecompressor* GetZStdDecompressor() = 0;
virtual IViewSystem* GetIViewSystem() = 0;
virtual ILevelSystem* GetILevelSystem() = 0;
virtual INameTable* GetINameTable() = 0;
virtual IValidator* GetIValidator() = 0;
virtual ICmdLine* GetICmdLine() = 0;
virtual ILog* GetILog() = 0;
virtual AZ::IO::IArchive* GetIPak() = 0;
@@ -917,7 +890,6 @@ struct ISystem
virtual bool GetForceNonDevMode() const = 0;
virtual bool WasInDevMode() const = 0;
virtual bool IsDevMode() const = 0;
virtual bool IsMODValid(const char* szMODName) const = 0;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -974,13 +946,6 @@ struct ISystem
// Gets build version.
virtual const SFileVersion& GetBuildVersion() = 0;
// Summary:
// Data compression
//##@{
virtual bool CompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize, int level = 3) = 0;
virtual bool DecompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize) = 0;
//##@}
//////////////////////////////////////////////////////////////////////////
// Configuration.
//////////////////////////////////////////////////////////////////////////
@@ -1002,21 +967,8 @@ struct ISystem
// pCallback - 0 means normal LoadConfigVar behaviour is used
virtual void LoadConfiguration(const char* sFilename, ILoadConfigurationEntrySink* pSink = 0, bool warnIfMissing = true) = 0;
// Summary:
// Retrieves current configuration specification for client or server.
// Arguments:
// bClient - If true returns local client config spec, if false returns server config spec.
virtual ESystemConfigSpec GetConfigSpec(bool bClient = true) = 0;
virtual ESystemConfigSpec GetMaxConfigSpec() const = 0;
// Summary:
// Changes current configuration specification for client or server.
// Arguments:
// bClient - If true changes client config spec (sys_spec variable changed),
// if false changes only server config spec (as known on the client).
virtual void SetConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform, bool bClient) = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
@@ -1028,10 +980,6 @@ struct ISystem
virtual void SetConfigPlatform(ESystemConfigPlatform platform) = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
// Detects and set optimal spec.
virtual void AutoDetectSpec(bool detectResolution) = 0;
// Summary:
// Query if system is now paused.
// Pause flag is set when calling system update with pause mode.
@@ -1041,8 +989,6 @@ struct ISystem
// Retrieves localized strings manager interface.
virtual ILocalizationManager* GetLocalizationManager() = 0;
virtual ITextModeConsole* GetITextModeConsole() = 0;
// Summary:
// Retrieves the perlin noise singleton instance.
virtual CPNoise3* GetNoiseGen() = 0;
@@ -1133,22 +1079,10 @@ struct ISystem
virtual ESystemGlobalState GetSystemGlobalState(void) = 0;
virtual void SetSystemGlobalState(ESystemGlobalState systemGlobalState) = 0;
// Summary:
// Asynchronous memcpy
// Note sync variable will be incremented (in calling thread) before job starts
// and decremented when job finishes. Multiple async copies can therefore be
// tied to the same sync variable, therefore it's advised to wait for completion with
// while(*sync) (yield());
virtual void AsyncMemcpy(void* dst, const void* src, size_t size, int nFlags, volatile int* sync) = 0;
// </interfuscator:shuffle>
#if !defined(_RELEASE)
virtual bool IsSavingResourceList() const = 0;
#endif
// Initializes Steam if needed and returns if it was successful
virtual bool SteamInit() = 0;
// Summary:
// Gets the root window message handler function
// The returned pointer is platform-specific:
@@ -1752,44 +1686,6 @@ inline void CryLogAlways(const char* format, ...)
#endif // EXCLUDE_NORMAL_LOG
/*****************************************************
ASYNC MEMCPY FUNCTIONS
*****************************************************/
// Complex delegation required because it is not really easy to
// export a external standalone symbol like a memcpy function when
// building with modules. Dll pay an extra indirection cost for calling this
// function.
#if !defined(AZ_MONOLITHIC_BUILD)
# define CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM
#endif
#define CRY_ASYNC_MEMCPY_API extern "C"
// Note sync variable will be incremented (in calling thread) before job starts
// and decremented when job finishes. Multiple async copies can therefore be
// tied to the same sync variable, therefore wait for completion with
// while(*sync) (yield());
#if defined(CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM)
inline void cryAsyncMemcpy(
void* dst
, const void* src
, size_t size
, int nFlags
, volatile int* sync)
{
GetISystem()->AsyncMemcpy(dst, src, size, nFlags, sync);
}
# else
CRY_ASYNC_MEMCPY_API void cryAsyncMemcpy(
void* dst
, const void* src
, size_t size
, int nFlags
, volatile int* sync);
#endif
//////////////////////////////////////////////////////////////////////////
// Additional headers.
//////////////////////////////////////////////////////////////////////////
@@ -1,35 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Allows creation of text mode displays the for dedicated server
#ifndef CRYINCLUDE_CRYCOMMON_ITEXTMODECONSOLE_H
#define CRYINCLUDE_CRYCOMMON_ITEXTMODECONSOLE_H
#pragma once
struct ITextModeConsole
{
// <interfuscator:shuffle>
virtual ~ITextModeConsole() {}
virtual Vec2_tpl<int> BeginDraw() = 0;
virtual void PutText(int x, int y, const char* msg) = 0;
virtual void EndDraw() = 0;
virtual void OnShutdown() = 0;
virtual void SetTitle([[maybe_unused]] const char* title) {}
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_ITEXTMODECONSOLE_H
-101
View File
@@ -1,101 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ITexture.h>
namespace AZ
{
// General purpose video 'rendering' solution that abstracts video data into textures
// and data to update those textures with.
namespace VideoRenderer
{
enum Constants
{
MaxInputTextureCount = 4,
};
struct VideoTextureDesc
{
CryFixedStringT<64> m_name; // fixed string to avoid dll string copying issues
uint32 m_width{ 4 };
uint32 m_height{ 4 };
ETEX_Format m_format{ eTF_Unknown };
uint32 m_used{ 0 };
};
// Full description of video texture resources for the renderer to create.
struct VideoTexturesDesc
{
VideoTextureDesc m_outputTextureDesc;
VideoTextureDesc m_inputTextureDescs[MaxInputTextureCount];
};
// Full set of textures created from the VideoTexturesDesc provided to the renderer.
struct VideoTextures
{
uint32 m_outputTextureId{ 0 };
uint32 m_inputTextureIds[MaxInputTextureCount]{ 0 };
};
struct VideoUpdateData
{
struct VideoTextureUpdateData
{
// Data to update the texture with, can be null.
const void* m_data{ nullptr };
// Format of above data, required for format conversions if needed.
ETEX_Format m_dataFormat{ eTF_Unknown };
}
m_inputTextureData[MaxInputTextureCount];
};
// Set of data to update and render a frame of video textures.
// Everything should be passed through by value except for the update data, which should be double buffered at the source.
struct DrawArguments
{
// Set of textures to draw with.
VideoTextures m_textures;
// Set of data to update the above textures with if set.
VideoUpdateData m_updateData;
// Flag to indicate that we want to draw to the backbuffer.
uint32 m_drawingToBackbuffer{ 0 };
// Payload information for reference. Useful for debugging.
uint32 m_frameReference{ 0 };
// Scale applied to each texture.
Vec4 m_textureScales[MaxInputTextureCount]{};
// Value added to final composited texture.
Vec4 m_colorAdjustment{ ZERO };
};
// Video Rendering interface to provide callbacks from the Render Thread
struct IVideoRenderer
{
// Called from the Render Thread to request the description of the video textures.
virtual bool GetVideoTexturesDesc(AZ::VideoRenderer::VideoTexturesDesc& videoTexturesDesc) const = 0;
// Called from the Render Thread to get the set of video textures that were previously created. Used at cleanup time.
virtual bool GetVideoTextures(AZ::VideoRenderer::VideoTextures& videoTextures) const = 0;
// Called from the Render Thread to provide the video textures it created from the VideoTexturesDesc.
virtual bool NotifyTexturesCreated(const AZ::VideoRenderer::VideoTextures& videoTextures) = 0;
// CAlled from the Render Thread to notify the video manager that its textures were destroyed.
virtual bool NotifyTexturesDestroyed() = 0;
};
}
}
-219
View File
@@ -1,219 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_IZLIBCOMPRESSOR_H
#define CRYINCLUDE_CRYCOMMON_IZLIBCOMPRESSOR_H
#pragma once
/*
wrapper interface for the zlib compression / deflate interface
supports multiple compression streams with an async compatible wrapper
Gotchas:
the ptr to the input data must remain valid whilst the stream is deflating
the ptr to the output buffer must remain valid whilst the stream is deflating
****************************************************************************************
usage example:
IZLibCompressor *pComp=GetISystem()->GetIZLibCompressor();
// see deflateInit2() documentation zlib manual for more info on the parameters here
// this initializes the stream to produce a gzip format block with fairly low memory requirements
IZLibDeflateStream *pStream=pComp->CreateDeflateStream(2,eZMeth_Deflated,24,3,eZStrat_Default,eZFlush_NoFlush);
char *pOutput=new char[512]; // arbitrary size
const char *pInputData="This is an example piece of data that is to be compressed. It can be any arbitrary block of binary data - not just text";
const int inputBlockSize=16; // to simulate streaming of input, this example provides the input in 16 byte blocks
int totalInput=sizeof(pInputData);
int bytesInput=0;
bool done=false;
FILE *outputFile=fopen("myfile.gz","rb");
do
{
EZDeflateState state=pStream->GetState();
switch (state)
{
case eZDefState_AwaitingInput:
// 'stream' input data, there is no restriction on the block size you can input, if all the data is available immediately, input all of it at once
{
int inputSize=min(inputBlockSize,totalInput-bytesInput);
if (inputSize<=0)
{
pStream->EndInput();
}
else
{
pStream->Input(pInputData+bytesInput,inputSize);
bytesInput+=inputSize;
}
}
break;
case eZDefState_Deflating:
// do something more interesting... like getting out of this loop and running the rest of your game...
break;
case eZDefState_ConsumeOutput:
// stream output to a file
{
int bytesToOutput=pStream->GetBytesOutput();
if (bytesToOutput>0)
{
fwrite(pOutput,1,bytesToOutput,outputFile);
}
pStream->SetOutputBuffer(pOutput,sizeof(pOutput));
}
break;
case eZDefState_Finished:
case ezDefState_Error:
done=true;
break;
}
} while (!done);
fclose(outputFile);
pStream->Release();
delete [] pOutput;
****************************************************************************************/
// don't change the order of these zlib wrapping enum values without updating the mapping
// implementation in CZLibCompressorStream
enum EZLibStrategy
{
eZStrat_Default, // Z_DEFAULT_STRATEGY
eZStrat_Filtered, // Z_FILTERED
eZStrat_HuffmanOnly, // Z_HUFFMAN_ONLY
eZStrat_RLE // Z_RLE
};
enum EZLibMethod
{
eZMeth_Deflated // Z_DEFLATED
};
enum EZLibFlush
{
eZFlush_NoFlush, // Z_NO_FLUSH
eZFlush_PartialFlush, // Z_PARTIAL_FLUSH
eZFlush_SyncFlush, // Z_SYNC_FLUSH
eZFlush_FullFlush, // Z_FULL_FLUSH
};
enum EZDeflateState
{
eZDefState_AwaitingInput, // caller must call Input() or Finish() to continue
eZDefState_Deflating, // caller must wait
eZDefState_ConsumeOutput, // caller must consume output and then call SetOutputBuffer() to continue
eZDefState_Finished, // stream finished, caller must call Release() to destroy stream
eZDefState_Error // error has occurred and the stream has been closed and will no longer compress
};
struct IZLibDeflateStream
{
protected:
virtual ~IZLibDeflateStream() {}; // use Release()
public:
struct SStats
{
int bytesInput;
int bytesOutput;
int curMemoryUsed;
int peakMemoryUsed;
};
// <interfuscator:shuffle>
// Description:
// Specifies the output buffer for the deflate operation
// Should be set before providing input
// The specified buffer must remain valid (ie do not free) whilst compression is in progress (state == eZDefState_Deflating)
virtual void SetOutputBuffer(char* pInBuffer, int inSize) = 0;
// Description:
// Returns the number of bytes from the output buffer that are ready to be consumed. After consuming any output, you should call SetOutputBuffer() again to mark the buffer as available
virtual int GetBytesOutput() = 0;
// Description:
// Begins compressing the source data pInSource of length inSourceSize to a previously specified output buffer
// Only valid to be called if the stream is in state eZDefState_AwaitingInput
// The specified buffer must remain valid (ie do not free) whilst compression is in progress (state == eZDefState_Deflating)
virtual void Input(const char* pInSource, int inSourceSize) = 0;
// Description:
// Finishes the compression, causing all data to be flushed to the output buffer
// Once called no more data can be input
// After calling the caller must wait until GetState() reutrns eZDefState_Finished
virtual void EndInput() = 0;
// Description:
// Returns the state of the stream,
virtual EZDeflateState GetState() = 0;
// Description:
// Gets stats on deflate stream, valid to call at anytime
virtual void GetStats(SStats* pOutStats) = 0;
// Description:
// Deletes the deflate stream. Will assert if stream is in an invalid state to be released (in state eZDefState_Deflating)
virtual void Release() = 0;
// </interfuscator:shuffle>
};
// md5 support structure
struct SMD5Context
{
uint32 buf[4];
uint32 bits[2];
unsigned char in[64];
};
struct IZLibCompressor
{
protected:
virtual ~IZLibCompressor() {}; // use Release()
public:
// <interfuscator:shuffle>
// Description:
// Creates a deflate stream to compress data using zlib
// See documentation for zlib deflateInit2() for usage details
// inFlushMethod is passed to calls to zlib deflate(), see zlib docs on deflate() for more details
virtual IZLibDeflateStream* CreateDeflateStream(int inLevel, EZLibMethod inMethod, int inWindowBits, int inMemLevel, EZLibStrategy inStrategy, EZLibFlush inFlushMethod) = 0;
virtual void Release() = 0;
// Description:
// Initializes an MD5 context
virtual void MD5Init(SMD5Context* pIOCtx) = 0;
// Description:
// Digests some data into an existing MD5 context
virtual void MD5Update(SMD5Context* pIOCtx, const char* pInBuff, unsigned int len) = 0;
// Description:
// Closes the MD5 context and extract the final 16 byte MD5 digest value
virtual void MD5Final(SMD5Context * pIOCtx, char outDigest[16]) = 0;
// </interfuscator:shuffle>
};
#endif // CRYINCLUDE_CRYCOMMON_IZLIBCOMPRESSOR_H
@@ -1,94 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Provides the interface for the zlib inflate wrapper
#ifndef CRYINCLUDE_CRYCOMMON_IZLIBDECOMPRESSOR_H
#define CRYINCLUDE_CRYCOMMON_IZLIBDECOMPRESSOR_H
#pragma once
enum EZInflateState
{
eZInfState_AwaitingInput, // caller must call Input() to continue
eZInfState_Inflating, // caller must wait
eZInfState_ConsumeOutput, // caller must consume output and then call SetOutputBuffer() to continue
eZInfState_Finished, // caller must call Release()
eZInfState_Error // error has occurred and the stream has been closed and will no longer compress
};
struct IZLibInflateStream
{
protected:
virtual ~IZLibInflateStream() {}; // use Release()
public:
struct SStats
{
int bytesInput;
int bytesOutput;
int curMemoryUsed;
int peakMemoryUsed;
};
// Description:
// Specifies the output buffer for the inflate operation
// Should be set before providing input
// The specified buffer must remain valid (ie do not free) whilst compression is in progress (state == eZInfState_Inflating)
virtual void SetOutputBuffer(char* pInBuffer, unsigned int inSize) = 0;
// Description:
// Returns the number of bytes from the output buffer that are ready to be consumed. After consuming any output, you should call SetOutputBuffer() again to mark the buffer as available
virtual unsigned int GetBytesOutput() = 0;
// Description:
// Begins decompressing the source data pInSource of length inSourceSize to a previously specified output buffer
// Only valid to be called if the stream is in state eZInfState_AwaitingInput
// The specified buffer must remain valid (ie do not free) whilst compression is in progress (state == eZInfState_Inflating)
virtual void Input(const char* pInSource, unsigned int inSourceSize) = 0;
// Description:
// Finishes the compression, causing all data to be flushed to the output buffer
// Once called no more data can be input
// After calling the caller must wait until GetState() reuturns eZInfState_Finished
virtual void EndInput() = 0;
// Description:
// Returns the state of the stream,
virtual EZInflateState GetState() = 0;
// Description:
// Gets stats on inflate stream, valid to call at anytime
virtual void GetStats(SStats* pOutStats) = 0;
// Description:
// Deletes the inflate stream. Will assert if stream is in an invalid state to be released (in state eZInfState_Inflating)
virtual void Release() = 0;
};
struct IZLibDecompressor
{
protected:
virtual ~IZLibDecompressor() {}; // use Release()
public:
// Description:
// Creates a inflate stream to decompress data using zlib
virtual IZLibInflateStream* CreateInflateStream() = 0;
virtual void Release() = 0;
};
#endif // CRYINCLUDE_CRYCOMMON_IZLIBDECOMPRESSOR_H
-310
View File
@@ -1,310 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Helper to enable inplace construction and destruction of objects
#ifndef CRYINCLUDE_CRYCOMMON_INPLACEFACTORY_H
#define CRYINCLUDE_CRYCOMMON_INPLACEFACTORY_H
#pragma once
// Inspired by the boost inplace/typed_inplace factory, written by
// Fernando Luis Cacciola Carballal and Tobias Schwinger
//
// See
// http://www.boost.org/doc/libs/1_42_0/libs/utility/in_place_factories.html
// for a detailed description
//
class CInplaceFactory0
{
public:
explicit CInplaceFactory0()
{}
template<class T>
void* apply(void* address) const
{
return new(address) T();
}
template<class T>
void* apply(void* address, std::size_t n) const
{
for (char* next = address = this->template apply<T>(address); !!--n; )
{
this->template apply<T>(next = next + sizeof(T));
}
return address;
}
};
template < typename Arg0 >
class CInplaceFactory1
{
Arg0& m_Arg0;
public:
explicit CInplaceFactory1(Arg0& arg)
: m_Arg0(arg)
{}
template<class T>
void* apply(void* address) const
{
return new(address) T(m_Arg0);
}
template<class T>
void* apply(void* address, std::size_t n) const
{
for (char* next = address = this->template apply<T>(address); !!--n; )
{
this->template apply<T>(next = next + sizeof(T));
}
return address;
}
};
template
<
typename Arg0,
typename Arg1
>
class CInplaceFactory2
{
Arg0& m_Arg0;
Arg1& m_Arg1;
public:
explicit CInplaceFactory2(Arg0& arg0, Arg1& arg1)
: m_Arg0(arg0)
, m_Arg1(arg1)
{}
template<class T>
void* apply(void* address) const
{
return new(address) T(
m_Arg0,
m_Arg1);
}
template<class T>
void* apply(void* address, std::size_t n) const
{
for (char* next = address = this->template apply<T>(address); !!--n; )
{
this->template apply<T>(next = next + sizeof(T));
}
return address;
}
};
template
<
typename Arg0,
typename Arg1,
typename Arg2
>
class CInplaceFactory3
{
Arg0& m_Arg0;
Arg1& m_Arg1;
Arg2& m_Arg2;
public:
explicit CInplaceFactory3(Arg0& arg0, Arg1& arg1, Arg2& arg2)
: m_Arg0(arg0)
, m_Arg1(arg1)
, m_Arg2(arg2)
{}
template<class T>
void* apply(void* address) const
{
return new(address) T(
m_Arg0,
m_Arg1,
m_Arg2);
}
template<class T>
void* apply(void* address, std::size_t n) const
{
for (char* next = address = this->template apply<T>(address); !!--n; )
{
this->template apply<T>(next = next + sizeof(T));
}
return address;
}
};
template
<
typename Arg0,
typename Arg1,
typename Arg2,
typename Arg3
>
class CInplaceFactory4
{
Arg0& m_Arg0;
Arg1& m_Arg1;
Arg2& m_Arg2;
Arg3& m_Arg3;
public:
explicit CInplaceFactory4(Arg0& arg0, Arg1& arg1, Arg2& arg2, Arg3& arg3)
: m_Arg0(arg0)
, m_Arg1(arg1)
, m_Arg2(arg2)
, m_Arg3(arg3)
{}
template<class T>
void* apply(void* address) const
{
return new(address) T(
m_Arg0,
m_Arg1,
m_Arg2,
m_Arg3);
}
template<class T>
void* apply(void* address, std::size_t n) const
{
for (char* next = address = this->template apply<T>(address); !!--n; )
{
this->template apply<T>(next = next + sizeof(T));
}
return address;
}
};
template
<
typename Arg0,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4
>
class CInplaceFactory5
{
Arg0& m_Arg0;
Arg1& m_Arg1;
Arg2& m_Arg2;
Arg3& m_Arg3;
Arg4& m_Arg4;
public:
explicit CInplaceFactory5(Arg0& arg0, Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4)
: m_Arg0(arg0)
, m_Arg1(arg1)
, m_Arg2(arg2)
, m_Arg3(arg3)
, m_Arg4(arg4)
{}
template<class T>
void* apply(void* address) const
{
return new(address) T(
m_Arg0,
m_Arg1,
m_Arg2,
m_Arg3,
m_Arg4);
}
template<class T>
void* apply(void* address, std::size_t n) const
{
for (char* next = address = this->template apply<T>(address); !!--n; )
{
this->template apply<T>(next = next + sizeof(T));
}
return address;
}
};
inline CInplaceFactory0 InplaceFactory()
{
return CInplaceFactory0();
}
template < typename Arg0 >
inline CInplaceFactory1<Arg0> InplaceFactory(Arg0& arg0)
{
return CInplaceFactory1<Arg0>(arg0);
}
template
<
typename Arg0,
typename Arg1
>
inline CInplaceFactory2<Arg0, Arg1> InplaceFactory(Arg0& arg0, Arg1& arg1)
{
return CInplaceFactory2<Arg0, Arg1>(arg0, arg1);
}
template
<
typename Arg0,
typename Arg1,
typename Arg2
>
inline CInplaceFactory3<Arg0, Arg1, Arg2> InplaceFactory(Arg0& arg0, Arg1& arg1, Arg2& arg2)
{
return CInplaceFactory3<Arg0, Arg1, Arg2> (arg0, arg1, arg2);
}
template
<
typename Arg0,
typename Arg1,
typename Arg2,
typename Arg3
>
inline CInplaceFactory4<Arg0, Arg1, Arg2, Arg3> InplaceFactory(
Arg0& arg0, Arg1& arg1, Arg2& arg2, Arg3& arg3)
{
return CInplaceFactory4<Arg0, Arg1, Arg2, Arg3>(arg0, arg1, arg2, arg3);
}
template
<
typename Arg0,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4
>
inline CInplaceFactory5<Arg0, Arg1, Arg2, Arg3, Arg4> InplaceFactory(
Arg0& arg0, Arg1& arg1, Arg2& arg2, Arg3& arg3, Arg4& arg4)
{
return CInplaceFactory5<Arg0, Arg1, Arg2, Arg3, Arg4>(arg0, arg1, arg2, arg3, arg4);
}
#endif // CRYINCLUDE_CRYCOMMON_INPLACEFACTORY_H
-134
View File
@@ -1,134 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#ifndef CRYINCLUDE_CRYCOMMON_MATERIALUTILS_H
#define CRYINCLUDE_CRYCOMMON_MATERIALUTILS_H
#include <AzCore/base.h>
#include <AzCore/IO/SystemFile.h> // for max path len
#include <AzCore/std/string/string.h>
#include <AzCore/Utils/Utils.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <ISystem.h>
namespace MaterialUtils
{
//! UnifyMaterialName - given a non-unified material name, remove the extension, unify the slashes
//! and fix up any legacy naming issues so that the material name can be used in a hash map
//! and will work each lookup.
inline void UnifyMaterialName(char* inputOutputBuffer)
{
if (!inputOutputBuffer)
{
return;
}
// convert slashes and remove extensions:
size_t inputLength = strlen(inputOutputBuffer);
if (inputLength == 0)
{
return;
}
// this must be done first, so that the extension cutting function below does not mistakenly destroy this when it finds the .
if ((azstrnicmp(inputOutputBuffer, "./", 2) == 0) || (azstrnicmp(inputOutputBuffer, ".\\", 2) == 0))
{
memmove(inputOutputBuffer, inputOutputBuffer + 2, inputLength - 2);
inputOutputBuffer[inputLength - 2] = 0;
inputLength -= 2;
}
for (size_t pos = 0; pos < inputLength; ++pos)
{
if (inputOutputBuffer[pos] == '\\')
{
inputOutputBuffer[pos] = '/'; // unify slashes
}
else
{
inputOutputBuffer[pos] = tolower(inputOutputBuffer[pos]);
}
}
AZStd::string tempString(inputOutputBuffer);
AzFramework::StringFunc::Path::StripExtension(tempString);
AZ_Assert(tempString.length() <= inputLength, "Extension stripped string has to be smaller than/same size as original string!");
// real size of inputOutputBuffer is inputLength + 1 with Null character
azstrcpy(inputOutputBuffer, inputLength + 1, tempString.c_str());
#if defined(SUPPORT_LEGACY_MATERIAL_NAMES)
// LEGACY support Some files may start with ./ in front of them. This is not required anymore.
static const char* removals[2] = {
"engine/",
nullptr // reserved for game name
};
static size_t removalSize = sizeof(removals) / sizeof(removals[0]);
// LEGACY support. Some files may start with gamename in front of them. This is not required anymore.
static char cachedGameName[AZ_MAX_PATH_LEN] = { 0 };
if (!removals[removalSize - 1])
{
auto projectName = AZ::Utils::GetProjectName();
if (!projectName.empty())
{
azstrcpy(cachedGameName, AZ_MAX_PATH_LEN, projectName.c_str());
azstrcat(cachedGameName, AZ_MAX_PATH_LEN, "/");
}
if (cachedGameName[0] == 0)
{
// at least substitute something so that unit tests can make this assumption:
azstrcpy(cachedGameName, AZ_MAX_PATH_LEN, "AutomatedTesting/");
}
removals[removalSize - 1] = cachedGameName;
}
for (size_t pos = 0; pos < removalSize; ++pos)
{
if (removals[pos])
{
size_t removalLength = strlen(removals[pos]);
if (removalLength >= inputLength)
{
continue;
}
if (azstrnicmp(inputOutputBuffer, removals[pos], removalLength) == 0)
{
memmove(inputOutputBuffer, inputOutputBuffer + removalLength, inputLength - removalLength);
inputOutputBuffer[inputLength - removalLength] = 0;
inputLength -= removalLength;
}
}
}
// legacy: Files were saved into a mtl with many leading forward or back slashes, we eat them all here. We want it to start with a rel path.
const char* actualFileName = inputOutputBuffer;
size_t finalLength = inputLength;
while ((actualFileName[0]) && ((actualFileName[0] == '\\') || (actualFileName[0] == '/')))
{
++actualFileName;
--finalLength;
}
if (finalLength != inputLength)
{
memmove(inputOutputBuffer, actualFileName, finalLength);
inputOutputBuffer[finalLength] = 0;
inputLength = finalLength;
}
#endif
}
}
#endif // CRYINCLUDE_CRYCOMMON_MATERIALUTILS_H
@@ -12,8 +12,6 @@
#pragma once
#include <IRenderer.h>
#include <IVideoRenderer.h>
#include <IImage.h>
#include <gmock/gmock.h>
struct SRendItemSorter {};
@@ -294,8 +292,6 @@ public:
bool(const char* szFileName));
MOCK_METHOD1(EF_ReloadFile_Request,
bool(const char* szFileName));
MOCK_METHOD2(EF_LoadImage,
_smart_ptr<IImageFile>(const char* szFileName, uint32 nFlags));
MOCK_METHOD3(EF_GetRemapedShaderMaskGen,
uint64(const char*, uint64, bool));
MOCK_METHOD3(EF_GetShaderGlobalMaskGenFromString,
@@ -533,8 +529,6 @@ public:
void(unsigned int TextureId));
MOCK_METHOD1(DeleteFont,
void(IFFont * font));
MOCK_METHOD2(BakeMesh,
bool(const SMeshBakingInputParams * pInputParams, SMeshBakingOutput * pReturnValues));
MOCK_METHOD3(CaptureFrameBufferFast,
bool(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight));
MOCK_METHOD3(CopyFrameBufferFast,
@@ -857,13 +851,6 @@ public:
MOCK_METHOD1(AddProfilerLabel,
void(const char*));
MOCK_METHOD1(InitializeVideoRenderer,
void(AZ::VideoRenderer::IVideoRenderer* pVideoRenderer));
MOCK_METHOD1(CleanupVideoRenderer,
void(AZ::VideoRenderer::IVideoRenderer* pVideoRenderer));
MOCK_METHOD2(DrawVideoRenderer,
void(AZ::VideoRenderer::IVideoRenderer* pVideoRenderer, const AZ::VideoRenderer::DrawArguments& drawArguments));
MOCK_METHOD5(EF_QueryImpl,
void(ERenderQueryTypes eQuery, void* pInOut0, uint32 nInOutSize0, void* pInOut1, uint32 nInOutSize1));
};
@@ -39,10 +39,6 @@ public:
void());
MOCK_METHOD0(GetUserName,
const char*());
MOCK_METHOD0(GetCPUFlags,
int());
MOCK_METHOD0(GetLogicalCPUCount,
int());
MOCK_METHOD0(Quit,
void());
MOCK_METHOD1(Relaunch,
@@ -55,8 +51,6 @@ public:
int());
MOCK_CONST_METHOD0(IsRelaunch,
bool());
MOCK_METHOD4(DisplayErrorMessage,
void(const char*, float, const float*, bool));
void FatalError([[maybe_unused]] const char* sFormat, ...) override {}
void ReportBug([[maybe_unused]] const char* sFormat, ...) override {}
@@ -70,22 +64,12 @@ public:
int(const char* text, const char* caption, unsigned int uType));
MOCK_METHOD1(CheckLogVerbosity,
bool(int verbosity));
MOCK_METHOD0(GetIZLibCompressor,
IZLibCompressor * ());
MOCK_METHOD0(GetIZLibDecompressor,
IZLibDecompressor * ());
MOCK_METHOD0(GetLZ4Decompressor,
ILZ4Decompressor * ());
MOCK_METHOD0(GetZStdDecompressor,
IZStdDecompressor * ());
MOCK_METHOD0(GetIViewSystem,
IViewSystem * ());
MOCK_METHOD0(GetILevelSystem,
ILevelSystem * ());
MOCK_METHOD0(GetINameTable,
INameTable * ());
MOCK_METHOD0(GetIValidator,
IValidator * ());
MOCK_METHOD0(GetICmdLine,
ICmdLine * ());
MOCK_METHOD0(GetILog,
@@ -116,8 +100,6 @@ public:
bool());
MOCK_CONST_METHOD0(IsDevMode,
bool());
MOCK_CONST_METHOD1(IsMODValid,
bool(const char* szMODName));
MOCK_METHOD3(CreateXmlNode,
XmlNodeRef(const char*, bool, bool));
MOCK_METHOD4(LoadXmlFromBuffer,
@@ -147,11 +129,6 @@ public:
MOCK_METHOD0(GetBuildVersion,
const SFileVersion&());
MOCK_METHOD5(CompressDataBlock,
bool(const void*, size_t, void*, size_t &, int));
MOCK_METHOD4(DecompressDataBlock,
bool(const void* input, size_t inputSize, void* output, size_t & outputSize));
MOCK_METHOD1(AddCVarGroupDirectory,
void(const string&));
MOCK_METHOD0(SaveConfiguration,
@@ -159,24 +136,16 @@ public:
MOCK_METHOD3(LoadConfiguration,
void(const char*, ILoadConfigurationEntrySink*, bool));
MOCK_METHOD1(GetConfigSpec,
ESystemConfigSpec(bool));
MOCK_CONST_METHOD0(GetMaxConfigSpec,
ESystemConfigSpec());
MOCK_METHOD3(SetConfigSpec,
void(ESystemConfigSpec spec, ESystemConfigPlatform platform, bool bClient));
MOCK_CONST_METHOD0(GetConfigPlatform,
ESystemConfigPlatform());
MOCK_METHOD1(SetConfigPlatform,
void(ESystemConfigPlatform platform));
MOCK_METHOD1(AutoDetectSpec,
void(bool detectResolution));
MOCK_CONST_METHOD0(IsPaused,
bool());
MOCK_METHOD0(GetLocalizationManager,
ILocalizationManager * ());
MOCK_METHOD0(GetITextModeConsole,
ITextModeConsole * ());
MOCK_METHOD0(GetNoiseGen,
CPNoise3 * ());
MOCK_METHOD0(GetUpdateCounter,
@@ -213,16 +182,12 @@ public:
ESystemGlobalState(void));
MOCK_METHOD1(SetSystemGlobalState,
void(ESystemGlobalState systemGlobalState));
MOCK_METHOD5(AsyncMemcpy,
void(void* dst, const void* src, size_t size, int nFlags, volatile int* sync));
#if !defined(_RELEASE)
MOCK_CONST_METHOD0(IsSavingResourceList,
bool());
#endif
MOCK_METHOD0(SteamInit,
bool());
MOCK_METHOD0(GetRootWindowMessageHandler,
void*());
MOCK_METHOD1(RegisterWindowMessageHandler,
-34
View File
@@ -1,34 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_NAME_TYPEINFO_H
#define CRYINCLUDE_CRYCOMMON_NAME_TYPEINFO_H
#pragma once
#include "CryName.h"
// CCryName TypeInfo
TYPE_INFO_BASIC(CCryName)
string ToString(CCryName const& val)
{
return string(val.c_str());
}
bool FromString(CCryName& val, const char* s)
{
val = s;
return true;
}
#endif // CRYINCLUDE_CRYCOMMON_NAME_TYPEINFO_H
-85
View File
@@ -1,85 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Math/Color.h>
#include <AzCore/Math/MathUtils.h>
// Water level unknown.
#define WATER_LEVEL_UNKNOWN -1000000.f
#define BOTTOM_LEVEL_UNKNOWN -1000000.f
namespace AZ
{
/**
* Numeric constants that the editors should use for the ocean properties
*/
namespace OceanConstants
{
// Ocean Height consts are maintained for backwards compatibility
// @TODO: Remove height / depth related consts when feature toggle is removed.
static const float s_HeightMin = -AZ::Constants::MaxFloatBeforePrecisionLoss;
static const float s_HeightMax = AZ::Constants::MaxFloatBeforePrecisionLoss;
static const float s_HeightUnknown = WATER_LEVEL_UNKNOWN;
static const float s_BottomUnknown = BOTTOM_LEVEL_UNKNOWN;
static const float s_DefaultHeight = 16.0f;
static const float s_CausticsDistanceAttenMin = 0.0f;
static const float s_CausticsDistanceAttenDefault = 10.0f;
static const float s_CausticsDistanceAttenMax = 100.0f;
static const float s_CausticsDepthMin = 0.0f;
static const float s_CausticsDepthDefault = 8.0f;
static const float s_CausticsDepthMax = 100.0f;
static const float s_CausticsIntensityMin = 0.0f;
static const float s_CausticsIntensityDefault = 1.0f;
static const float s_CausticsIntensityMax = 10.0f;
static const float s_CausticsTilingMin = 0.10f;
static const float s_CausticsTilingDefault = 2.0f;
static const float s_CausticsTilingMax = 10.0f;
static const float s_animationWavesAmountMin = 0.2f;
static const float s_animationWavesAmountMax = 5.0f;
static const float s_animationWavesAmountDefault = 0.75f;
static const float s_animationWavesSizeMin = 0.0f;
static const float s_animationWavesSizeMax = 3.0f;
static const float s_animationWavesSizeDefault = 1.25f;
static const float s_animationWavesSpeedMin = 0.0f;
static const float s_animationWavesSpeedMax = 5.0f;
static const float s_animationWavesSpeedDefault = 1.0f;
static const float s_animationWindDirectionMin = 0.0f;
static const float s_animationWindDirectionMax = 6.2832f;
static const float s_animationWindDirectionDefault = 1;
static const float s_animationWindSpeedMin = 0.0f;
static const float s_animationWindSpeedMax = 1000.0f;
static const float s_animationWindSpeedDefault = 40.0f;
static const AZ::Color s_oceanFogColorDefault((AZ::u8)5, (AZ::u8)36, (AZ::u8)32, (AZ::u8)255);
static const AZ::Color s_oceanNearFogColorDefault((AZ::u8)1, (AZ::u8)7, (AZ::u8)5, (AZ::u8)255);
static const float s_oceanFogColorMultiplierDefault = 0.15f;
static const float s_oceanFogDensityDefault = 0.07f;
static const float s_OceanFogColorMultiplierMin = 0.0f;
static const float s_OceanFogColorMultiplierMax = 1.0f;
static const float s_OceanFogDensityMin = 0.0f;
static const float s_OceanFogDensityMax = 1.0f;
static const int s_waterTessellationAmountMin = 10;
static const int s_waterTessellationAmountMax = 500;
static const int s_waterTessellationDefault = 85;
static const bool s_UseOceanBottom = true;
static const bool s_GodRaysEnabled = true;
static const float s_UnderwaterDistortion = 1.0f;
static const float s_oceanIsVeryFarAway = 1000000.f;
};
}
-363
View File
@@ -1,363 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzFramework/Archive/IArchive.h>
//! Everybody should use fxopen instead of fopen so it opens on all platforms
inline AZ::IO::HandleType fxopen(const char* file, const char* mode, bool bGameRelativePath = false)
{
if (gEnv && gEnv->pCryPak)
{
gEnv->pCryPak->CheckFileAccessDisabled(file, mode);
}
bool bWriteAccess = false;
for (const char* s = mode; *s; s++)
{
if (*s == 'w' || *s == 'W' || *s == 'a' || *s == 'A' || *s == '+')
{
bWriteAccess = true;
break;
}
;
}
if (gEnv && gEnv->pCryPak)
{
int nAdjustFlags = 0;
if (!bGameRelativePath)
{
nAdjustFlags |= AZ::IO::IArchive::FLAGS_PATH_REAL;
}
if (bWriteAccess)
{
nAdjustFlags |= AZ::IO::IArchive::FLAGS_FOR_WRITING;
}
char path[_MAX_PATH];
const char* szAdjustedPath = gEnv->pCryPak->AdjustFileName(file, path, AZ_ARRAY_SIZE(path), nAdjustFlags);
#if !AZ_TRAIT_LEGACY_CRYPAK_UNIX_LIKE_FILE_SYSTEM
if (bWriteAccess)
{
// Make sure folder is created.
gEnv->pCryPak->MakeDir(szAdjustedPath);
}
#endif
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(szAdjustedPath, AZ::IO::GetOpenModeFromStringMode(mode), fileHandle);
return fileHandle;
}
else
{
return AZ::IO::InvalidHandle;
}
}
class CDebugAllowFileAccess
{
public:
#if defined(_RELEASE)
ILINE CDebugAllowFileAccess() { }
ILINE void End() { }
#else
CDebugAllowFileAccess()
{
m_threadId = AZStd::this_thread::get_id();
m_oldDisable = gEnv->pCryPak ? gEnv->pCryPak->DisableRuntimeFileAccess(false, m_threadId) : false;
m_active = true;
}
~CDebugAllowFileAccess()
{
End();
}
void End()
{
if (m_active)
{
if (gEnv && gEnv->pCryPak)
{
gEnv->pCryPak->DisableRuntimeFileAccess(m_oldDisable, m_threadId);
}
m_active = false;
}
}
protected:
AZStd::thread_id m_threadId;
bool m_oldDisable;
bool m_active;
#endif
};
//////////////////////////////////////////////////////////////////////////
class CInMemoryFileLoader
{
public:
CInMemoryFileLoader(AZ::IO::IArchive* pCryPak)
: m_pPak(pCryPak)
, m_fileHandle(AZ::IO::InvalidHandle)
, m_pBuffer(0)
, m_pCursor(0)
, m_nFileSize(0) {}
~CInMemoryFileLoader()
{
Close();
}
bool IsFileExists() const
{
return m_fileHandle != AZ::IO::InvalidHandle;
}
AZ::IO::HandleType GetFileHandle() const
{
return m_fileHandle;
}
bool FOpen(const char* name, const char* mode, bool bImmediateCloseFile = false)
{
if (m_pPak)
{
assert(m_fileHandle == AZ::IO::InvalidHandle);
m_fileHandle = m_pPak->FOpen(name, mode);
if (m_fileHandle == AZ::IO::InvalidHandle)
{
return false;
}
m_nFileSize = m_pPak->FGetSize(m_fileHandle);
if (m_nFileSize == 0)
{
Close();
return false;
}
m_pCursor = m_pBuffer = (char*)m_pPak->PoolMalloc(m_nFileSize);
size_t nReaded = m_pPak->FReadRawAll(m_pBuffer, m_nFileSize, m_fileHandle);
if (nReaded != m_nFileSize)
{
Close();
return false;
}
if (bImmediateCloseFile)
{
m_pPak->FClose(m_fileHandle);
m_fileHandle = AZ::IO::InvalidHandle;
}
return true;
}
return false;
}
void FClose()
{
Close();
}
size_t FReadRaw(void* data, size_t length, size_t elems)
{
ptrdiff_t dist = m_pCursor - m_pBuffer;
size_t count = length;
if (dist + count * elems > m_nFileSize)
{
count = (m_nFileSize - dist) / elems;
}
memmove(data, m_pCursor, count * elems);
m_pCursor += count * elems;
return count;
}
template<class T>
size_t FRead(T* data, size_t elems, bool bSwapEndian = eLittleEndian)
{
ptrdiff_t dist = m_pCursor - m_pBuffer;
size_t count = elems;
if (dist + count * sizeof(T) > m_nFileSize)
{
count = (m_nFileSize - dist) / sizeof(T);
}
memmove(data, m_pCursor, count * sizeof(T));
m_pCursor += count * sizeof(T);
SwapEndian(data, count, bSwapEndian);
return count;
}
size_t FTell()
{
ptrdiff_t dist = m_pCursor - m_pBuffer;
return dist;
}
int FSeek(int64_t origin, int command)
{
int retCode = -1;
int64_t newPos;
char* newPosBuf;
switch (command)
{
case SEEK_SET:
newPos = origin;
if (newPos <= (int64_t)m_nFileSize)
{
m_pCursor = m_pBuffer + newPos;
retCode = 0;
}
break;
case SEEK_CUR:
newPosBuf = m_pCursor + origin;
if (newPosBuf <= m_pBuffer + m_nFileSize)
{
m_pCursor = newPosBuf;
retCode = 0;
}
break;
case SEEK_END:
newPos = m_nFileSize - origin;
if (newPos <= (int64_t)m_nFileSize)
{
m_pCursor = m_pBuffer + newPos;
retCode = 0;
}
break;
default:
// Not valid disk operation!
AZ_Assert(false, "Invalid disk operation");
}
return retCode;
}
private:
void Close()
{
if (m_fileHandle != AZ::IO::InvalidHandle)
{
m_pPak->FClose(m_fileHandle);
}
if (m_pBuffer)
{
m_pPak->PoolFree(m_pBuffer);
}
m_pBuffer = m_pCursor = 0;
m_nFileSize = 0;
m_fileHandle = AZ::IO::InvalidHandle;
}
private:
AZ::IO::HandleType m_fileHandle;
char* m_pBuffer;
AZ::IO::IArchive* m_pPak;
char* m_pCursor;
size_t m_nFileSize;
};
//////////////////////////////////////////////////////////////////////////
// Helper class that can be used to recursively scan the directory.
//////////////////////////////////////////////////////////////////////////
struct SDirectoryEnumeratorHelper
{
public:
void ScanDirectoryRecursive(AZ::IO::IArchive* pIPak, const AZStd::string& root, const AZStd::string& pathIn, const AZStd::string& fileSpec, AZStd::vector<AZStd::string>& files)
{
auto AddSlash = [](AZStd::string_view path) -> AZStd::string
{
if (path.ends_with(AZ_CORRECT_DATABASE_SEPARATOR))
{
return path;
}
else if (path.ends_with(AZ_WRONG_DATABASE_SEPARATOR))
{
return AZStd::string{ path.substr(0, path.size() - 1) } + AZ_CORRECT_DATABASE_SEPARATOR;
}
return path.empty() ? AZStd::string(path) : AZStd::string(path) + AZ_CORRECT_DATABASE_SEPARATOR;
};
AZStd::string dir;
AZ::StringFunc::Path::Join(root.c_str(), pathIn.c_str(), dir);
dir = AddSlash(dir);
ScanDirectoryFiles(pIPak, "", dir, fileSpec, files);
AZStd::string findFilter;
AZ::StringFunc::Path::Join(dir.c_str(), "*", findFilter);
// Add all directories.
AZ::IO::ArchiveFileIterator pakFileIterator = pIPak->FindFirst(findFilter.c_str());
if (pakFileIterator)
{
do
{
// Skip back folders.
if (pakFileIterator.m_filename[0] == '.')
{
continue;
}
if (pakFileIterator.m_filename.empty())
{
AZ_Fatal("Archive", "IArchive FindFirst/FindNext returned empty name while looking for '%s'", findFilter.c_str());
continue;
}
if ((pakFileIterator.m_fileDesc.nAttrib & AZ::IO::FileDesc::Attribute::Subdirectory) == AZ::IO::FileDesc::Attribute::Subdirectory) // skip sub directories.
{
AZStd::string scanDir = AZStd::string::format("%s%.*s/", AddSlash(pathIn).c_str(), aznumeric_cast<int>(pakFileIterator.m_filename.size()), pakFileIterator.m_filename.data());
scanDir += AZ_CORRECT_DATABASE_SEPARATOR;
ScanDirectoryRecursive(pIPak, root, scanDir, fileSpec, files);
continue;
}
} while (pakFileIterator = pIPak->FindNext(pakFileIterator));
pIPak->FindClose(pakFileIterator);
}
}
private:
void ScanDirectoryFiles(AZ::IO::IArchive* pIPak, const AZStd::string& root, const AZStd::string& path, const AZStd::string& fileSpec, AZStd::vector<AZStd::string>& files)
{
AZStd::string dir;
AZ::StringFunc::Path::Join(root.c_str(), path.c_str(), dir);
AZStd::string findFilter;
AZ::StringFunc::Path::Join(dir.c_str(), fileSpec.c_str(), findFilter);
AZ::IO::ArchiveFileIterator pakFileIterator = pIPak->FindFirst(findFilter.c_str());
if (pakFileIterator)
{
do
{
// Skip back folders and subdirectories.
if (pakFileIterator.m_filename[0] == '.' || (pakFileIterator.m_fileDesc.nAttrib & AZ::IO::FileDesc::Attribute::Subdirectory) == AZ::IO::FileDesc::Attribute::Subdirectory)
{
continue;
}
AZStd::string fullPath;
AZ::StringFunc::Path::Join(path.c_str(), AZStd::string(pakFileIterator.m_filename).c_str(), fullPath);
files.push_back(fullPath);
} while (pakFileIterator = pIPak->FindNext(pakFileIterator));
pIPak->FindClose(pakFileIterator);
}
}
};
@@ -1,57 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <CryCommon/PakLoadDataUtils.h>
namespace PakLoadDataUtils
{
bool LoadDataFromFile_Seek(size_t elems, AZ::IO::HandleType& fileHandle, int& nDataSize, [[maybe_unused]] EEndian eEndian)
{
GetISystem()->GetIPak()->FSeek(fileHandle, elems, SEEK_CUR);
nDataSize -= elems;
AZ_Assert(nDataSize >= 0, "nDataSize must be equal or greater than 0");
return (nDataSize >= 0);
}
bool LoadDataFromFile_Seek(size_t elems, uint8*& f, int& nDataSize, [[maybe_unused]] EEndian eEndian)
{
nDataSize -= elems;
f += elems;
AZ_Assert(nDataSize >= 0, "nDataSize must be equal or greater than 0");
return true;
}
void LoadDataFromFile_FixAlignment(AZ::IO::HandleType& fileHandle, int& nDataSize)
{
while (nDataSize & 3)
{
[[maybe_unused]] size_t nRes = GetISystem()->GetIPak()->FSeek(fileHandle, 1, SEEK_CUR);
AZ_Assert(nRes == 0, "FSeek failed for 1 byte");
AZ_Assert(nDataSize, "nDataSize reached zero" );
nDataSize--;
}
AZ_Assert(nDataSize >= 0, "nDataSize must be equal or greater than 0");
}
void LoadDataFromFile_FixAlignment(uint8*& f, int& nDataSize)
{
while (nDataSize & 3)
{
AZ_Assert(*f == 222, "Found invalid data in buffer.");
f++;
AZ_Assert(nDataSize, "nDataSize reached zero");
nDataSize--;
}
AZ_Assert(nDataSize >= 0, "nDataSize must be equal or greater than 0");
}
} //namespace PakLoadDataUtils
@@ -1,55 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ISystem.h>
#include <AzFramework/Archive/IArchive.h>
namespace PakLoadDataUtils
{
template <class T>
static bool LoadDataFromFile(T* data, size_t elems, AZ::IO::HandleType& fileHandle, int& nDataSize, EEndian eEndian, int* pSeek = 0)
{
auto ipak = GetISystem()->GetIPak();
if (pSeek)
{
*pSeek = aznumeric_cast<int>(ipak->FTell(fileHandle));
}
if (ipak->FRead(data, elems, fileHandle, eEndian) != elems)
{
AZ_Assert(false, "Failed to read %zu elements", elems);
return false;
}
nDataSize -= sizeof(T) * elems;
AZ_Assert(nDataSize >= 0, "nDataSize must be equal or greater than 0");
return true;
}
bool LoadDataFromFile_Seek(size_t elems, AZ::IO::HandleType& fileHandle, int& nDataSize, [[maybe_unused]] EEndian eEndian);
template <class T>
static bool LoadDataFromFile(T* data, size_t elems, uint8*& f, int& nDataSize, EEndian eEndian, [[maybe_unused]] int* pSeek = 0)
{
StepDataCopy(data, f, elems, eEndian);
nDataSize -= elems * sizeof(T);
AZ_Assert(nDataSize >= 0, "nDataSize must be equal or greater than 0");
return (nDataSize >= 0);
}
bool LoadDataFromFile_Seek(size_t elems, uint8*& f, int& nDataSize, [[maybe_unused]] EEndian eEndian);
void LoadDataFromFile_FixAlignment(AZ::IO::HandleType& fileHandle, int& nDataSize);
void LoadDataFromFile_FixAlignment(uint8*& f, int& nDataSize);
} //namespace PakLoadDataUtils
@@ -40,8 +40,6 @@
#endif
#endif
#define USE_STEAM 0 // Enable this to start using Steam
// The following definitions are used by Sandbox and RC to determine which platform support is needed
#define TOOLS_SUPPORT_POWERVR
#define TOOLS_SUPPORT_ETC2COMP
@@ -244,9 +242,6 @@ typedef uint32 vtx_idx;
#endif // TESSELLATION
#endif // !defined(MOBILE)
#define USE_GEOM_CACHES
//------------------------------------------------------
// SVO GI
//------------------------------------------------------
-157
View File
@@ -1,157 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_QTANGENT_H
#define CRYINCLUDE_CRYCOMMON_QTANGENT_H
#pragma once
namespace QTangent {
// Computes a QTangent from a frame and reflection scalar representing the
// tangent space.
// Will also ensure the resulting QTangent is suitable for 16bit quantization.
ILINE Quat FromFrameReflection(Quat frame, const float reflection)
{
frame.v = -frame.v;
if (frame.w < 0.0f)
{
frame = -frame;
}
// Make sure w is never 0 by applying the smallest possible bias.
// This is needed in order to have sign() never return 0 in the shaders.
static const float BIAS_16BIT = 1.0f / 32767.0f;
static const float BIAS_SCALE_16BIT = sqrtf(1.0f - BIAS_16BIT * BIAS_16BIT);
if (frame.w < BIAS_16BIT && frame.w > -BIAS_16BIT)
{
frame *= BIAS_SCALE_16BIT;
frame.w = BIAS_16BIT;
}
if (reflection < 0.0f)
{
frame = -frame;
}
return frame;
}
ILINE Quat FromFrameReflection(const Matrix33& frame, const float reflection)
{
Quat quat(frame);
quat.Normalize();
return FromFrameReflection(quat, reflection);
}
ILINE Quat FromFrameReflection16Safe(Matrix33 frame, const float reflection)
{
frame.OrthonormalizeFast();
if (!frame.IsOrthonormalRH(0.1f))
{
frame.SetIdentity();
}
return FromFrameReflection(frame, reflection);
}
ILINE void ToTangentBitangentReflection(const Quat& qtangent, Vec3& tangent, Vec3& bitangent, float& reflection)
{
tangent = qtangent.GetColumn0();
bitangent = qtangent.GetColumn1();
reflection = qtangent.w < 0.0f ? -1.0f : +1.0f;
}
} // namespace QTangent
// Auxiliary helper functions
#include <IIndexedMesh.h> // <> required for Interfuscator
ILINE Quat MeshTangentFrameToQTangent(const SMeshTangents& tangents)
{
SMeshTangents tb = tangents;
Vec3 tangent32, bitangent32;
int16 reflection;
tb.GetTB(tangent32, bitangent32);
tb.GetR(reflection);
Matrix33 frame;
frame.SetRow(0, tangent32);
frame.SetRow(1, bitangent32);
frame.SetRow(2, tangent32.Cross(bitangent32).GetNormalized());
return QTangent::FromFrameReflection16Safe(frame, reflection);
}
ILINE Quat MeshTangentFrameToQTangent(const Vec4sf& tangent, const Vec4sf& bitangent)
{
return MeshTangentFrameToQTangent(SMeshTangents(tangent, bitangent));
}
ILINE Quat MeshTangentFrameToQTangent(const SPipTangents& tangents)
{
return MeshTangentFrameToQTangent(SMeshTangents(tangents));
}
ILINE bool MeshTangentsFrameToQTangents(
const Vec4sf* pTangent, const uint tangentStride,
const Vec4sf* pBitangent, const uint bitangentStride, const uint count,
SPipQTangents* pQTangents, const uint qtangentStride)
{
Quat qtangent;
for (uint i = 0; i < count; ++i)
{
qtangent = MeshTangentFrameToQTangent(*pTangent, *pBitangent);
SMeshQTangents(qtangent).ExportTo(*pQTangents);
pTangent = (const Vec4sf*)(((const uint8*)pTangent) + tangentStride);
pBitangent = (const Vec4sf*)(((const uint8*)pBitangent) + bitangentStride);
pQTangents = (SPipQTangents*)(((uint8*)pQTangents) + qtangentStride);
}
return true;
}
ILINE bool MeshTangentsFrameToQTangents(
const SPipTangents* pTangents, const uint tangentStride, const uint count,
SPipQTangents* pQTangents, const uint qtangentStride)
{
Quat qtangent;
for (uint i = 0; i < count; ++i)
{
qtangent = MeshTangentFrameToQTangent(*pTangents);
SMeshQTangents(qtangent).ExportTo(*pQTangents);
pTangents = (const SPipTangents*)(((const uint8*)pTangents) + tangentStride);
pQTangents = (SPipQTangents*)(((uint8*)pQTangents) + qtangentStride);
}
return true;
}
ILINE bool MeshTangentsFrameToQTangents(
const SMeshTangents* pTangents, const uint tangentStride, const uint count,
SMeshQTangents* pQTangents, const uint qtangentStride)
{
Quat qtangent;
for (uint i = 0; i < count; ++i)
{
qtangent = MeshTangentFrameToQTangent(*pTangents);
*pQTangents = SMeshQTangents(qtangent);
pTangents = (const SMeshTangents*)(((const uint8*)pTangents) + tangentStride);
pQTangents = (SMeshQTangents*)(((uint8*)pQTangents) + qtangentStride);
}
return true;
}
#endif // CRYINCLUDE_CRYCOMMON_QTANGENT_H
-8
View File
@@ -33,14 +33,6 @@ namespace AZ
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
//////////////////////////////////////////////////////////////////////////
/**
* This event gets posted at the end of CD3D9Renderer's EF_Scene3D method.
* CSystem (in SystemRenderer.cpp) uses this to render the console, aux geom and UI
* in a manner that will make sure the render calls end up as part of the scene's render.
* This is important or else those render calls won't show up properly in VR.
*/
virtual void OnScene3DEnd() {};
/**
* This event gets posted at the beginning of CD3D9Renderer's FreeResources method, before the resources have been freed.
*/
@@ -1,86 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Memory/SystemAllocator.h>
namespace AZ
{
class ReflectContext;
}
namespace AzRTT
{
typedef AZ::Uuid RenderContextId;
// various post screen effects will fail if we attempt to render the scene to very
// small render target sizes so provide a reasonable minimum (tile/icon size)
constexpr uint32_t MinRenderTargetWidth = 32;
constexpr uint32_t MinRenderTargetHeight = 32;
// this maximum recommended texture size applies to width and height
// using sizes larger than this can lead to performance issues and instability
constexpr uint32_t MaxRecommendedRenderTargetSize = 2048;
enum class AlphaMode {
ALPHA_DISABLED = 0,
ALPHA_OPAQUE,
ALPHA_DEPTH_BASED
};
// RenderContextConfig stores the render settings to use when rendering to texture.
// It also provides a more developer-friendly interface to deal with by exposing
// the most commonly used properties in one place.
struct RenderContextConfig
{
AZ_CLASS_ALLOCATOR(RenderContextConfig, AZ::SystemAllocator, 0);
AZ_RTTI(RenderContextConfig, "{6114F930-CBE4-4373-AF9D-3B5319471C8F}");
virtual ~RenderContextConfig() = default;
static void Reflect(AZ::ReflectContext* context);
//! render target width
uint32_t m_width = 256;
//! render target height
uint32_t m_height = 256;
//! write srgb or linear output
bool m_sRGBWrite = false;
//! alpha mode to use for the render target
AlphaMode m_alphaMode = AlphaMode::ALPHA_OPAQUE;
//! scene settings
bool m_oceanEnabled = true;
bool m_terrainEnabled = true;
bool m_vegetationEnabled = true;
//! shadow settings
bool m_shadowsEnabled = true;
int32_t m_shadowsNumCascades = -1;
float m_shadowsGSMRange = -1.f;
float m_shadowsGSMRangeStep = -1.f;
//! post-effects settings
bool m_depthOfFieldEnabled = false;
bool m_motionBlurEnabled = false;
int m_aaMode = 0;
//! visiblity for shadow settings
AZ::Crc32 GetShadowSettingsVisible();
//! confirm if user wants to use texture size larger than MaxRecommendedRenderTargetSize
bool ValidateTextureSize(void* newValue, const AZ::Uuid& valueType);
};
}
-273
View File
@@ -1,273 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright (C), Crytek, 1999-2015.
#pragma once
// A fixed-size type-safe ring buffer (ie, fixed-size double-ended queue).
// Note: It's possible to add support for iterators, indexing if needed.
template<typename T, size_t N, typename I = uint32>
class CRingBuffer
{
static_assert(std::is_integral<I>::value && std::is_unsigned<I>::value, "I is not unsigned integral type");
static_assert(N != 0 && N <= I(-1), "N is not a valid value (or I is too small)");
enum : I
{
kPowerOf2 = (N & (N - 1)) == 0,
kMaxSize = static_cast<I>(N),
};
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef I size_type;
// Constructs an empty ring buffer.
CRingBuffer()
: m_begin(0)
, m_count(0)
{}
// Destroy a ring buffer.
~CRingBuffer()
{
clear();
}
// Retrieve the size of the collection.
size_type size() const
{
return m_count;
}
// Retrieve the maximum size of the collection.
size_type max_size() const
{
return kMaxSize;
}
// Test if the collection is empty.
bool empty() const
{
return m_count == 0;
}
// Test if the collection is full.
bool full() const
{
return m_count == kMaxSize;
}
// Get the front-most item of the collection.
// If the collection is empty, the behavior is undefined.
reference front()
{
CRY_ASSERT_MESSAGE(m_count != 0, "Container is empty");
return *ptr(m_begin);
}
// Get the front-most item of the collection.
// If the collection is empty, the behavior is undefined.
const_reference front() const
{
CRY_ASSERT_MESSAGE(m_count != 0, "Container is empty");
return *ptr(m_begin);
}
// Get the back-most item of the collection.
// If the collection is empty, the behavior is undefined.
reference back()
{
CRY_ASSERT_MESSAGE(m_count != 0, "Container is empty");
return *ptr(wrap(m_begin + m_count - 1));
}
// Get the back-most item of the collection.
// If the collection is empty, the behavior is undefined.
const_reference back() const
{
CRY_ASSERT_MESSAGE(m_count != 0, "Container is empty");
return *ptr(wrap(m_begin + m_count - 1));
}
// Adds an item to the front of the collection.
// In case the collection is full, the function returns false and the collection remains unmodified.
template<typename X>
bool push_front(X&& value)
{
static_assert(std::is_constructible<T, X&&>::value, "T cannot be constructed from the given type");
if (full())
{
return false;
}
const I index = decrement(m_begin);
::new(static_cast<void*>(ptr(index)))T(std::forward<X>(value));
m_begin = index;
++m_count;
return true;
}
// Adds an item to the front of the collection.
// In case the collection is full, the function overwrites the last item in the collection.
template<typename X>
void push_front_overwrite(X&& value)
{
static_assert(std::is_constructible<T, X&&>::value, "T cannot be constructed from the given type");
const I index = decrement(m_begin);
if (full())
{
ptr(index)->~T();
--m_count;
}
::new(static_cast<void*>(ptr(index)))T(std::forward<X>(value));
m_begin = index;
++m_count;
}
// Removes an item from the front of the collection.
// If the collection is empty, the behavior is undefined.
void pop_front()
{
CRY_ASSERT_MESSAGE(m_count != 0, "Container is empty");
ptr(m_begin)->~T();
m_begin = increment(m_begin);
--m_count;
}
// Attempts to remove an item from the front of the collection, and assigns it to 'value'.
// Returns true if an item was removed, false if the collection was empty (and 'value' remains unmodified).
bool try_pop_front(T& value)
{
if (m_count != 0)
{
T* const pItem = ptr(m_begin);
value = std::move(*pItem);
pItem->~T();
m_begin = increment(m_begin);
--m_count;
return true;
}
return false;
}
// Adds an item to the back of the collection.
// In case the collection is full, the function returns false and the collection remains unmodified.
template<typename X>
bool push_back(X&& value)
{
static_assert(std::is_constructible<T, X&&>::value, "T cannot be constructed from the given type");
if (full())
{
return false;
}
const I index = wrap(m_begin + m_count);
::new(static_cast<void*>(ptr(index)))T(std::forward<X>(value));
++m_count;
return true;
}
// Adds an item to the back of the collection.
// In case the collection is full, the function overwrites the first item in the collection.
template<typename X>
void push_back_overwrite(X&& value)
{
static_assert(std::is_constructible<T, X&&>::value, "T cannot be constructed from the given type");
const I index = wrap(m_begin + m_count);
if (full())
{
ptr(index)->~T();
m_begin = increment(index);
--m_count;
}
::new(static_cast<void*>(ptr(index)))T(std::forward<X>(value));
++m_count;
}
// Removes an item from the back of the collection.
// If the collection is empty, the behavior is undefined.
void pop_back()
{
CRY_ASSERT_MESSAGE(m_count != 0, "Container is empty");
const I index = wrap(m_begin + m_count - 1);
ptr(index)->~T();
--m_count;
}
// Attempts to remove an item from the back of the collection, and assigns it to 'value'.
// Returns true if an item was removed, false if the collection was empty (and 'value' remains unmodified).
bool try_pop_back(T& value)
{
if (m_count != 0)
{
const I index = wrap(m_begin + m_count - 1);
T* const pItem = ptr(index);
value = std::move(*pItem);
pItem->~T();
--m_count;
return true;
}
return false;
}
// Destroy all items in a ring buffer.
void clear()
{
size_type index = m_begin;
for (size_type i = 0; i < m_count; ++i, index = increment(index))
{
ptr(index)->~T();
}
m_begin = 0;
m_count = 0;
}
private:
// Decrements a given index, wrapping it around N.
static size_type decrement(size_type index)
{
return kPowerOf2 ? ((index - 1) & (kMaxSize - 1)) : index ? index - 1 : kMaxSize - 1;
}
// Increments a given index, wrapping it around N.
static size_type increment(size_type index)
{
++index;
return kPowerOf2 ? index & (kMaxSize - 1) : index == kMaxSize ? 0 : index;
}
// Wraps an index, which has a maximum value of 2N-1.
static size_type wrap(size_type index)
{
return kPowerOf2 ? index & (kMaxSize - 1) : index >= kMaxSize ? index - kMaxSize : index;
}
// Obtain pointer to raw storage at given index.
pointer ptr(size_type index)
{
return reinterpret_cast<pointer>(&m_storage) + index;
}
// Obtain pointer to raw storage at given index.
const_pointer ptr(size_type index) const
{
return reinterpret_cast<const_pointer>(&m_storage) + index;
}
// No copy/assign supported.
CRingBuffer(const CRingBuffer&);
void operator=(const CRingBuffer&);
size_type m_begin, m_count;
typename std::aligned_storage<sizeof(T)* N, std::alignment_of<T>::value>::type m_storage;
};
-188
View File
@@ -1,188 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <type_traits>
#if defined(AZ_RESTRICTED_PLATFORM)
#undef AZ_RESTRICTED_SECTION
#define SCOPEGUARD_H_SECTION_1 1
#define SCOPEGUARD_H_SECTION_2 2
#endif
/**
This is from the c++17 working draft paper N3949 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3949.pdf
It is a new library addition targeted for c++17. I didn't feel like waiting. Only modification is as required to get the
code compiling in the yet to be c++11 compliant visual studio. It is similar to boost scope exit, but in a modern and
more feature rich form. scope_guard just executes a lambda when it goes out of scope. unique_resource is a more complete
RAII wrapper. Its stands in for a resource (i.e. overloads cast operator to the wrapped resource) and frees it when it
goes out of scope. see the paper for more examples and a better description. Get rid of this once c++17 is available.
*/
namespace std17
{
template <typename D>
struct scope_guard_t
{
// construction
explicit scope_guard_t(D&& f)
: deleter(std::move(f))
, execute_on_destruction(true)
{
}
// move
scope_guard_t(scope_guard_t&& rhs)
: deleter(std::move(rhs.deleter))
, execute_on_destruction(rhs.execute_on_destruction)
{
rhs.release();
}
// release
~scope_guard_t()
{
if (execute_on_destruction)
{
deleter();
}
}
void release() { execute_on_destruction = false; }
private:
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SCOPEGUARD_H_SECTION_1
#include AZ_RESTRICTED_FILE(ScopeGuard_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
scope_guard_t(scope_guard_t const&) = delete;
void operator=(scope_guard_t const&) = delete;
scope_guard_t& operator=(scope_guard_t&&) = delete;
#endif
D deleter;
bool execute_on_destruction;
// exposition only
};
template <typename D>
scope_guard_t<D> scope_guard(D&& deleter)
{
return scope_guard_t<D>(std::move(deleter));
// fails with curlies
}
enum class invoke_it
{
once, again
};
template<typename R, typename D>
class unique_resource_t
{
R resource;
D deleter;
bool execute_on_destruction;
// exposition only
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SCOPEGUARD_H_SECTION_2
#include AZ_RESTRICTED_FILE(ScopeGuard_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
unique_resource_t& operator=(unique_resource_t const&) = delete;
unique_resource_t(unique_resource_t const&) = delete;
#endif
// no copies!
public:
// construction
explicit unique_resource_t(R&& _resource, D&& _deleter, bool _shouldrun = true)
: resource(std::move(_resource))
, deleter(std::move(_deleter))
, execute_on_destruction(_shouldrun)
{
}
// move
unique_resource_t(unique_resource_t&& other)
: resource(std::move(other.resource))
, deleter(std::move(other.deleter))
, execute_on_destruction(other.execute_on_destruction)
{
other.release();
}
unique_resource_t& operator=(unique_resource_t&& other)
{
this->invoke(invoke_it::once);
deleter = std::move(other.deleter);
resource = std::move(other.resource);
execute_on_destruction = other.execute_on_destruction;
other.release();
return *this;
}
// resource release
~unique_resource_t()
{
this->invoke(invoke_it::once);
}
void invoke(invoke_it const strategy = invoke_it::once)
{
if (execute_on_destruction)
{
get_deleter()(resource);
}
execute_on_destruction = strategy == invoke_it::again;
}
R const& release()
{
execute_on_destruction = false;
return this->get();
}
void reset(R&& newresource)
{
invoke(invoke_it::again);
resource = std::move(newresource);
}
// resource access
R const& get() const
{
return resource;
}
operator R const& () const
{
return resource;
}
R operator->() const
{
return resource;
}
typename std::add_lvalue_reference<typename std::remove_pointer<R>::type>::type operator*() const
{
return *resource;
}
// deleter access
const D& get_deleter() const
{
return deleter;
}
};
template<typename R, typename D>
unique_resource_t<R, D> unique_resource(R&& r, D t)
{
return unique_resource_t<R, D>(std::move(r), std::move(t), true);
}
template<typename R, typename D>
unique_resource_t<R, D> unique_resource_checked(R r, R invalid, D t)
{
bool shouldrun = (r != invalid);
return unique_resource_t<R, D>(std::move(r), std::move(t), shouldrun);
}
}
@@ -1,27 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// This header is provided for backwards compatibility. Avoid including this header, instead
// include the needed smart ptr headers
#pragma once
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/smart_ptr/weak_ptr.h>
#define DECLARE_SMART_POINTERS(name) \
typedef AZStd::shared_ptr<name> name##Ptr; \
typedef AZStd::shared_ptr<const name> name##ConstPtr; \
typedef AZStd::weak_ptr<name> name##WeakPtr; \
typedef AZStd::weak_ptr<const name> name##ConstWeakPtr;
-64
View File
@@ -1,64 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Helper to enable inplace construction and destruction of objects
#ifndef CRYINCLUDE_CRYCOMMON_STACKCONTAINER_H
#define CRYINCLUDE_CRYCOMMON_STACKCONTAINER_H
#pragma once
#include <InplaceFactory.h>
// Class that contains a non-pod data type allocated on the stack via placement
// new. Constructor parameters up to an arity of 5 are forwarded over an
// inplace factory expression.
template<typename T>
class CStackContainer
{
// The backing storage
uint8 m_Storage[ sizeof (T) ];
// Constructs the object via an inplace factory
template<class Factory>
void construct (const Factory& factory)
{
factory.template apply<T>(m_Storage);
}
// Destructs the object. The destructor of the contained object is called
void destruct ()
{
reinterpret_cast<T*>(m_Storage)->~T();
}
// Prevent the object to be placed on the heap
// (.... it simply wouldn't make much sense)
void* operator new(size_t);
void operator delete(void*);
public:
// Constructs inside the object
template<class Expr>
CStackContainer (const Expr& expr)
{ construct(expr); }
// Destructs the object contained
~CStackContainer() { destruct(); }
// Accessor methods
T* get() { return reinterpret_cast<T*>(m_Storage); }
const T* get() const { return reinterpret_cast<const T*>(m_Storage); }
};
#endif // CRYINCLUDE_CRYCOMMON_STACKCONTAINER_H
-88
View File
@@ -1,88 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <CrySizer.h>
#include <CryPodArray.h>
template <class T>
class TPool
{
public:
TPool(int nPoolSize)
{
m_nPoolSize = nPoolSize;
m_pPool = new T[nPoolSize];
m_lstFree.PreAllocate(nPoolSize, 0);
m_lstUsed.PreAllocate(nPoolSize, 0);
for (int i = 0; i < nPoolSize; i++)
{
m_lstFree.Add(&m_pPool[i]);
}
}
~TPool()
{
delete[] m_pPool;
}
void ReleaseObject(T* pInst)
{
if (m_lstUsed.Delete(pInst))
{
m_lstFree.Add(pInst);
}
}
int GetUsedInstancesCount(int& nAll)
{
nAll = m_nPoolSize;
return m_lstUsed.Count();
}
T* GetObject()
{
T* pInst = NULL;
if (m_lstFree.Count())
{
pInst = m_lstFree.Last();
m_lstFree.DeleteLast();
m_lstUsed.Add(pInst);
}
else
{
assert(!"TPool::GetObject: Out of free elements error");
}
return pInst;
}
void GetMemoryUsage(class ICrySizer* pSizer) const
{
pSizer->AddObject(m_lstFree);
pSizer->AddObject(m_lstUsed);
if (m_pPool)
{
for (int i = 0; i < m_nPoolSize; i++)
{
m_pPool[i].GetMemoryUsage(pSizer);
}
}
}
PodArray<T*> m_lstFree;
PodArray<T*> m_lstUsed;
T* m_pPool;
int m_nPoolSize;
};
-141
View File
@@ -1,141 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Generic unaligned memory access helpers.
#pragma once
#include <stddef.h>
#include <type_traits>
namespace Detail
{
template<typename RealType, typename BlittedElement>
struct Blitter
{
static_assert(std::is_trivial<BlittedElement>::value, "Blittable elements should be trivial (ie, integral types)");
static_assert((std::alignment_of<BlittedElement>::value < std::alignment_of<RealType>::value), "Blittable memory has sufficient alignment, do not use unaligned store or load");
static_assert(sizeof(RealType) > sizeof(BlittedElement), "Blittable element is larger than real type");
static_assert((sizeof(RealType) % sizeof(BlittedElement)) == 0, "Blitted element has the wrong size for the real type");
typedef std::integral_constant<size_t, sizeof(RealType) / sizeof(BlittedElement)> NumElements;
static void BlitLoad(const BlittedElement* pSource, RealType& target)
{
BlittedElement* pTarget = alias_cast<BlittedElement*>(&target);
for (size_t i = 0; i < NumElements::value; ++i, ++pSource, ++pTarget)
{
* pTarget = *pSource;
}
}
static void BlitStore(const RealType& source, BlittedElement* pTarget)
{
const BlittedElement* pSource = alias_cast<const BlittedElement*>(&source);
for (size_t i = 0; i < NumElements::value; ++i, ++pSource, ++pTarget)
{
* pTarget = *pSource;
}
}
};
}
// Load RealType from unaligned memory using some blittable type.
// The source memory must be suitably aligned for accessing BlittedElement.
// If no memory alignment can be guaranteed, use char for BlittedElement.
template<typename RealType, typename BlittedElement>
inline void LoadUnaligned(const BlittedElement* pMemory, RealType& value,
typename std::enable_if<(std::alignment_of<RealType>::value > std::alignment_of<BlittedElement>::value)>::type* = nullptr)
{
Detail::Blitter<RealType, BlittedElement>::BlitLoad(pMemory, value);
}
// Load RealType from aligned memory (fallback overload).
// This is used if there is no reason to call the blitter, because sufficient alignment is guaranteed by BlittedElement.
template<typename RealType, typename BlittedElement>
inline void LoadUnaligned(const BlittedElement* pMemory, RealType& value,
typename std::enable_if<(std::alignment_of<RealType>::value <= std::alignment_of<BlittedElement>::value)>::type* = nullptr)
{
value = *alias_cast<RealType*>(pMemory);
}
// Store to unaligned memory using some blittable type.
// The target memory must be suitably aligned for accessing BlittedElement.
// If no memory alignment can be guaranteed, use char for BlittedElement.
template<typename RealType, typename BlittedElement>
inline void StoreUnaligned(BlittedElement* pMemory, const RealType& value,
typename std::enable_if<(std::alignment_of<RealType>::value > std::alignment_of<BlittedElement>::value)>::type* = nullptr)
{
Detail::Blitter<RealType, BlittedElement>::BlitStore(value, pMemory);
}
// Store to aligned memory (fallback overload).
// This is used if there is no reason to call the blitter, because sufficient alignment is guaranteed by BlittedElement.
template<typename RealType, typename BlittedElement>
inline void StoreUnaligned(BlittedElement* pMemory, const RealType& value,
typename std::enable_if<(std::alignment_of<RealType>::value <= std::alignment_of<BlittedElement>::value)>::type* = nullptr)
{
*alias_cast<RealType*>(pMemory) = value;
}
// Pads the given pointer to the next possible aligned location for RealType
// Use this to ensure RealType can be referenced in some buffer of BlittedElement's, without using LoadUnaligned/StoreUnaligned
template<typename RealType, typename BlittedElement>
inline BlittedElement* AlignPointer(BlittedElement* pMemory,
typename std::enable_if<(std::alignment_of<RealType>::value % std::alignment_of<BlittedElement>::value) == 0>::type* = nullptr)
{
const size_t align = std::alignment_of<RealType>::value;
const size_t mask = align - 1;
const size_t address = reinterpret_cast<size_t>(pMemory);
const size_t offset = (align - (address & mask)) & mask;
return pMemory + (offset / sizeof(BlittedElement));
}
// Pads the given address to the next possible aligned location for RealType
// Use this to ensure RealType can be referenced inside memory, without using LoadUnaligned/StoreUnaligned
template<typename RealType>
inline size_t AlignAddress(size_t address)
{
return reinterpret_cast<size_t>(AlignPointer<RealType>(reinterpret_cast<char*>(address)));
}
// Provides aligned storage for T, optionally aligned at a specific boundary (default being the native alignment of T)
// The specified T is not initialized automatically, use of placement new/delete is the user's responsibility
template<typename T, size_t Align = std::alignment_of<T>::value>
struct SUninitialized
{
typedef typename std::aligned_storage<sizeof(T), Align>::type Storage;
Storage storage;
void DefaultConstruct()
{
new(static_cast<void*>(&storage))T();
}
void CopyConstruct(const T& value)
{
new(static_cast<void*>(&storage))T(value);
}
void MoveConstruct(T&& value)
{
new(static_cast<void*>(&storage))T(std::move(value));
}
void Destruct()
{
alias_cast<T*>(&storage)->~T();
}
operator T& ()
{
return *alias_cast<T*>(&storage);
}
};
@@ -10,23 +10,16 @@
#
set(FILES
QTangent.h
CryCommon.cpp
FinalizingSpline.h
IAudioInterfacesCommonData.h
IAudioSystem.h
IChunkFile.h
ICmdLine.h
IColorGradingController.h
IConsole.h
IEntityRenderState.h
IEntityRenderState_info.cpp
IFont.h
IFunctorBase.h
IFuncVariable.h
IGem.h
IGeomCache.h
IImage.h
IIndexedMesh.h
IIndexedMesh_info.cpp
ILevelSystem.h
@@ -34,13 +27,10 @@ set(FILES
LocalizationManagerBus.h
LocalizationManagerBus.inl
ILog.h
ILZ4Decompressor.h
IMaterial.h
IMeshBaking.h
IMiniLog.h
IMovieSystem.h
IPhysics.h
IPhysicsDebugRenderer.h
IPostEffectGroup.h
IProcess.h
IReadWriteXMLSink.h
@@ -49,32 +39,24 @@ set(FILES
IRenderMesh.h
ISerialize.h
IShader.h
IShader_info.h
ISplines.h
IStatObj.h
StatObjBus.h
IStereoRenderer.h
ISurfaceType.h
ISystem.h
ITextModeConsole.h
ITexture.h
ITimer.h
IValidator.h
IVideoRenderer.h
IViewSystem.h
IWindowMessageHandler.h
IXml.h
IZLibCompressor.h
IZlibDecompressor.h
IZStdDecompressor.h
IProximityTriggerSystem.h
MicrophoneBus.h
physinterface.h
HMDBus.h
VRCommon.h
StereoRendererBus.h
HeightmapUpdateNotificationBus.h
IObjManager.h
INavigationSystem.h
IMNM.h
SFunctor.h
@@ -87,18 +69,15 @@ set(FILES
CryRandomInternal.h
Random.h
LCGRandom.h
MaterialUtils.h
MTPseudoRandom.cpp
CryTypeInfo.cpp
BaseTypes.h
CompileTimeAssert.h
intrusive_list.hpp
MemoryAccess.h
AnimKey.h
BitFiddling.h
Common_TypeInfo.cpp
CryArray.h
CryArray2d.h
CryAssert.h
CryCrc32.h
CryCustomTypes.h
@@ -111,44 +90,31 @@ set(FILES
CryName.h
CryPath.h
CryPodArray.h
CryPtrArray.h
CrySizer.h
CryString.h
CrySystemBus.h
CryThread.h
CryThreadImpl.h
CryTypeInfo.h
CryUtils.h
CryVersion.h
CryZlib.h
FrameProfiler.h
HashGrid.h
HeapAllocator.h
HeapContainer.h
InplaceFactory.h
LegacyAllocator.h
MetaUtils.h
MiniQueue.h
MTPseudoRandom.h
MultiThread.h
MultiThread_Containers.h
Name_TypeInfo.h
NullAudioSystem.h
PNoise3.h
PoolAllocator.h
primitives.h
primitives_info.h
ProjectDefines.h
Range.h
RenderContextConfig.h
RingBuffer.h
ScopeGuard.h
ScopedVariableSetter.h
SerializeFwd.h
SimpleSerialize.h
SmartPointersHelpers.h
smartptr.h
StackContainer.h
StlUtils.h
StringUtils.h
Synchronization.h
@@ -158,7 +124,6 @@ set(FILES
TimeValue_info.h
TypeInfo_decl.h
TypeInfo_impl.h
UnalignedBlit.h
UnicodeBinding.h
UnicodeEncoding.h
UnicodeFunctions.h
@@ -169,10 +134,6 @@ set(FILES
XMLBinaryHeaders.h
RenderBus.h
MainThreadRenderRequestBus.h
OceanConstants.h
PakLoadDataUtils.cpp
PakLoadDataUtils.h
TPool.h
Cry_Matrix33.h
Cry_Matrix34.h
Cry_Matrix44.h
@@ -191,7 +152,6 @@ set(FILES
Cry_Vector3.h
Cry_XOptimise.h
CryHalf_info.h
GeomQuery.h
CryHalf.inl
MathConversion.h
Cry_HWMatrix.h
@@ -313,6 +273,5 @@ set(FILES
Maestro/Types/AssetBlends.h
Maestro/Types/SequenceType.h
StaticInstance.h
Pak/CryPakUtils.h
WinBase.cpp
)
-180
View File
@@ -1,180 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef _INTRUSIVE_LIST_HPP
#define _INTRUSIVE_LIST_HPP
#if !defined(WIN32)
#include <stdint.h>
#endif //!defined(WIN32)
namespace util
{
// Simple lightweight intrusive list utility
//
template<typename Host>
struct list
{
typedef Host value_type;
list* next;
list* prev;
// Default (initializing) constructor
list()
{
next = this;
prev = this;
}
// Inserts this list into a given list item between
// prev and next (note: they need to be sequential!)
void insert(list* _prev, list* _next)
{
_next->prev = this;
this->next = _next;
this->prev = _prev;
_prev->next = this;
}
// Should only be called on heads
void clear() { next = prev = this; }
// Removes from a list, then inserts this list item into a given list between
// prev and next (note: they need to be sequential!)
void re_insert(list* _prev, list* _next)
{
erase();
insert(_prev, _next);
}
// Remove this list instance from a list
// Safe to be called even if not attached to a list
void erase()
{
next->prev = prev;
prev->next = next;
next = prev = this;
}
// Predicate to determine if a list structure is linked to a list
bool empty() const { return prev == this && next == this; }
bool linked() const { return !empty(); }
// Get the host instance of the instrusive list
template<list Host::* member>
Host* item()
{
return ((Host*)((uintptr_t)(this) - (uintptr_t)(&(((Host*)0)->*member))));
}
template<list Host::* member>
const Host* item() const
{
return ((Host*)((uintptr_t)(this) - (uintptr_t)(&(((Host*)0)->*member))));
}
template<list (Host::* Member)[2]>
Host * item(int threadId)
{
uintptr_t value = (uintptr_t)this - (uintptr_t)&((((Host*)(NULL))->*Member)[threadId]);
return alias_cast<Host*>(value);
}
// Insert & relink functions
void insert_tail(list* _list) { insert(_list->prev, _list); }
void insert_tail(list& _list) { insert_tail(&_list); }
void insert_head(list* _list) { insert(_list, _list->next); }
void insert_head(list& _list) { insert_head(&_list); }
void relink_tail(list* _list) { erase(); insert_tail(_list); }
void relink_tail(list& _list) { relink_tail(&_list); }
void relink_head(list* _list) { erase(); insert_head(_list); }
void relink_head(list& _list) { relink_head(&_list); }
static inline void splice(const list* _list, list* prev, list* next)
{
list* first = _list->next;
list* last = _list->prev;
first->prev = prev;
prev->next = first;
last->next = next;
next->prev = last;
}
void splice_front(const list* _list)
{
if (!_list->empty())
{
splice(_list, this, this->next);
_list->clear();
}
}
void splice_tail(list* _list)
{
if (!_list->empty())
{
splice(_list, this->prev, this);
_list->clear();
}
}
// Accessors
list<Host>* tail() { return prev; }
const list<Host>* tail() const { return prev; }
list<Host>* head() { return head; }
const list<Host>* head() const { return head; }
};
// utility to extract the host type of an intrusive list at compile time
template<typename List>
struct list_value_type
{
typedef typename List::value_type value_type;
};
// Loops over the list in forward manner, pos will be of type list<T>*
# define list_for_each(pos, head) \
for (typeof(head)pos = (head)->next; pos != (head); \
pos = pos->next)
// Loops over the list in backward manner, pos will be of type list<T>*
# define list_for_each_backwards(pos, head) \
for (typeof(head)pos = (head)->prev; pos != (head); \
pos = pos->prev)
// Loops over the list in forward manner while safeguarding
// against list removal during iteration. pos will be of type list<T>*
# define list_for_each_safe(pos, head) \
for (typeof(head)pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
// Loops over the list in forward manner. pos will be of type list<T>*
# define list_for_each_entry(pos, head, member) \
for (util::list_value_type<typeof((head))>::value_type* pos = \
(head)->next->item<member>(); \
&(pos->*(member)) != &list; \
pos = ((pos->*(member)).next->item<member>()))
// Loops over the list in forward manner while safeguarding against list
// removal during iteratation. pos will be of type T*
# define list_for_each_entry_safe(pos, head, member) \
for (util::list_value_type<typeof((head))>::value_type* pos = \
(head)->next->item<member>(), \
* n = ((pos->*(member)).next->item<member>()); \
&(pos->*(member)) != &list; \
pos = n, n = ((n->*(member)).next->item<member>()))
} // end namespace util
#endif // ifndef _INTRUSIVE_LIST_HPP
@@ -1,50 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYCOMMON_PRIMITIVES_INFO_H
#define CRYINCLUDE_CRYCOMMON_PRIMITIVES_INFO_H
#pragma once
#include "primitives.h"
STRUCT_INFO_TYPE_EMPTY(primitives::primitive)
STRUCT_INFO_BEGIN(primitives::box)
STRUCT_BASE_INFO(primitives::primitive)
STRUCT_VAR_INFO(Basis, TYPE_INFO(Matrix33))
STRUCT_VAR_INFO(bOriented, TYPE_INFO(int))
STRUCT_VAR_INFO(center, TYPE_INFO(Vec3))
STRUCT_VAR_INFO(size, TYPE_INFO(Vec3))
STRUCT_INFO_END(primitives::box)
STRUCT_INFO_BEGIN(primitives::sphere)
STRUCT_BASE_INFO(primitives::primitive)
STRUCT_VAR_INFO(center, TYPE_INFO(Vec3))
STRUCT_VAR_INFO(r, TYPE_INFO(float))
STRUCT_INFO_END(primitives::sphere)
STRUCT_INFO_BEGIN(primitives::cylinder)
STRUCT_BASE_INFO(primitives::primitive)
STRUCT_VAR_INFO(center, TYPE_INFO(Vec3))
STRUCT_VAR_INFO(axis, TYPE_INFO(Vec3))
STRUCT_VAR_INFO(r, TYPE_INFO(float))
STRUCT_VAR_INFO(hh, TYPE_INFO(float))
STRUCT_INFO_END(primitives::cylinder)
STRUCT_INFO_BEGIN(primitives::plane)
STRUCT_BASE_INFO(primitives::primitive)
STRUCT_VAR_INFO(n, TYPE_INFO(Vec3))
STRUCT_VAR_INFO(origin, TYPE_INFO(Vec3))
STRUCT_INFO_END(primitives::plane)
#endif // CRYINCLUDE_CRYCOMMON_PRIMITIVES_INFO_H
@@ -1,94 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Console implementation for Android, reports back to the main interface.
#include "CrySystem_precompiled.h"
#if defined(ANDROID)
#include "AndroidConsole.h"
#include "android/log.h"
CAndroidConsole::CAndroidConsole()
: m_isInitialized(false)
{
}
CAndroidConsole::~CAndroidConsole()
{
}
// Interface IOutputPrintSink /////////////////////////////////////////////
void CAndroidConsole::Print(const char* line)
{
__android_log_print(ANDROID_LOG_VERBOSE, "CryEngine", "MSG: %s\n", line);
}
// Interface ISystemUserCallback //////////////////////////////////////////
bool CAndroidConsole::OnError(const char* errorString)
{
__android_log_print(ANDROID_LOG_ERROR, "CryEngine", "ERR: %s\n", errorString);
return true;
}
void CAndroidConsole::OnInitProgress(const char* sProgressMsg)
{
(void) sProgressMsg;
// Do Nothing
}
void CAndroidConsole::OnInit(ISystem* pSystem)
{
if (!m_isInitialized)
{
IConsole* pConsole = pSystem->GetIConsole();
if (pConsole != 0)
{
pConsole->AddOutputPrintSink(this);
}
m_isInitialized = true;
}
}
void CAndroidConsole::OnShutdown()
{
if (m_isInitialized)
{
// remove outputprintsink
m_isInitialized = false;
}
}
void CAndroidConsole::OnUpdate()
{
// Do Nothing
}
void CAndroidConsole::GetMemoryUsage(ICrySizer* pSizer)
{
size_t size = sizeof(*this);
pSizer->AddObject(this, size);
}
// Interface ITextModeConsole /////////////////////////////////////////////
Vec2_tpl<int> CAndroidConsole::BeginDraw()
{
return Vec2_tpl<int>(0, 0);
}
void CAndroidConsole::PutText(int x, int y, const char* msg)
{
__android_log_print(ANDROID_LOG_VERBOSE, "CryEngine", "PUT: %s\n", msg);
}
void CAndroidConsole::EndDraw()
{
// Do Nothing
}
#endif // ANDROID
-62
View File
@@ -1,62 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Console implementation for Android, reports back to the main interface.
#ifndef CRYINCLUDE_CRYSYSTEM_ANDROIDCONSOLE_H
#define CRYINCLUDE_CRYSYSTEM_ANDROIDCONSOLE_H
#pragma once
#include <IConsole.h>
#include <ITextModeConsole.h>
class CAndroidConsole
: public ISystemUserCallback
, public IOutputPrintSink
, public ITextModeConsole
{
CAndroidConsole(const CAndroidConsole&);
CAndroidConsole& operator = (const CAndroidConsole&);
bool m_isInitialized;
public:
static CryCriticalSectionNonRecursive s_lock;
public:
CAndroidConsole();
~CAndroidConsole();
// Interface IOutputPrintSink /////////////////////////////////////////////
DLL_EXPORT virtual void Print(const char* line);
// Interface ISystemUserCallback //////////////////////////////////////////
virtual bool OnError(const char* errorString);
virtual bool OnSaveDocument() { return false; }
virtual void OnProcessSwitch() { }
virtual void OnInitProgress(const char* sProgressMsg);
virtual void OnInit(ISystem*);
virtual void OnShutdown();
virtual void OnUpdate();
virtual void GetMemoryUsage(ICrySizer* pSizer);
void SetRequireDedicatedServer(bool) {}
void SetHeader(const char*) {}
// Interface ITextModeConsole /////////////////////////////////////////////
virtual Vec2_tpl<int> BeginDraw();
virtual void PutText(int x, int y, const char* msg);
virtual void EndDraw();
};
#endif // CRYINCLUDE_CRYSYSTEM_ANDROIDCONSOLE_H
File diff suppressed because it is too large Load Diff
-54
View File
@@ -1,54 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_AUTODETECTSPEC_H
#define CRYINCLUDE_CRYSYSTEM_AUTODETECTSPEC_H
#pragma once
#if defined(WIN32) || defined(WIN64)
// exposed AutoDetectSpec() helper functions for reuse in CrySystem
namespace Win32SysInspect
{
enum DXFeatureLevel
{
DXFL_Undefined,
DXFL_9_1,
DXFL_9_2,
DXFL_9_3,
DXFL_10_0,
DXFL_10_1,
DXFL_11_0
};
const char* GetFeatureLevelAsString(DXFeatureLevel featureLevel);
void GetNumCPUCores(unsigned int& totAvailToSystem, unsigned int& totAvailToProcess);
bool IsDX11Supported();
bool GetGPUInfo(char* pName, size_t bufferSize, unsigned int& vendorID, unsigned int& deviceID, unsigned int& totLocalVidMem, DXFeatureLevel& featureLevel);
int GetGPURating(unsigned int vendorId, unsigned int deviceId);
void GetOS(SPlatformInfo::EWinVersion& ver, bool& is64Bit, char* pName, size_t bufferSize);
bool IsVistaKB940105Required();
inline size_t SafeMemoryThreshold(size_t memMB)
{
return (memMB * 8) / 10;
}
}
#endif // #if defined(WIN32) || defined(WIN64)
#endif // CRYINCLUDE_CRYSYSTEM_AUTODETECTSPEC_H
-63
View File
@@ -9,46 +9,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
add_subdirectory(XML)
# The following target is a 'C' file only library to work around an issue in cmake and VS generators that
# will append 'std=c++17' to both C and C++ compiler flags for clang. Do not add any .cpp files to this
# library.
ly_add_target(
NAME CrySystem.DLMalloc.C STATIC
NAMESPACE Legacy
FILES_CMAKE
crysystem_dlmalloc_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
.
PRIVATE
${pal_dir}
)
ly_get_pal_tool_dirs(pal_tool_dirs ${CMAKE_CURRENT_LIST_DIR}/Platform)
ly_add_target(
NAME CrySystem.Static STATIC
NAMESPACE Legacy
FILES_CMAKE
crysystem_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
PLATFORM_INCLUDE_FILES
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
INCLUDE_DIRECTORIES
PUBLIC
.
${pal_dir}
PRIVATE
${common_dir}
${pal_tool_dirs}
BUILD_DEPENDENCIES
PUBLIC
Legacy::CrySystem.DLMalloc.C
PRIVATE
3rdParty::expat
3rdParty::lz4
@@ -68,19 +39,11 @@ ly_add_source_properties(
VALUES ${LY_PAL_TOOLS_DEFINES}
)
ly_add_source_properties(
SOURCES SystemCFG.cpp
PROPERTY COMPILE_DEFINITIONS
VALUES LY_BUILD=${LY_VERSION_BUILD_NUMBER}
)
ly_add_target(
NAME CrySystem ${PAL_TRAIT_MONOLITHIC_DRIVEN_LIBRARY_TYPE}
NAMESPACE Legacy
FILES_CMAKE
crysystem_shared_files.cmake
PLATFORM_INCLUDE_FILES
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
INCLUDE_DIRECTORIES
PUBLIC
.
@@ -90,29 +53,3 @@ ly_add_target(
AZ::AzCore
Legacy::CryCommon
)
################################################################################
# Tests
################################################################################
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME CrySystem.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Legacy
FILES_CMAKE
crysystem_test_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
Legacy::CryCommon
Legacy::CrySystem.Static
AZ::AzFramework
)
ly_add_googletest(
NAME Legacy::CrySystem.Tests
)
endif()
File diff suppressed because it is too large Load Diff
-180
View File
@@ -1,180 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_CPUDETECT_H
#define CRYINCLUDE_CRYSYSTEM_CPUDETECT_H
#pragma once
//-------------------------------------------------------
/// Cpu class
//-------------------------------------------------------
#if defined(WIN64) || defined(LINUX)
#define MAX_CPU 96
#else
#define MAX_CPU 32
#endif
/// Cpu Features
#define CFI_FPUEMULATION 0x01
#define CFI_MMX 0x02
#define CFI_3DNOW 0x04
#define CFI_SSE 0x08
#define CFI_SSE2 0x10
#define CFI_SSE3 0x20
#define CFI_F16C 0x40
#define CFI_SSE41 0x80
/// Type of Cpu Vendor.
enum ECpuVendor
{
eCVendor_Unknown,
eCVendor_Intel,
eCVendor_Cyrix,
eCVendor_AMD,
eCVendor_Centaur,
eCVendor_NexGen,
eCVendor_UMC,
eCVendor_M68K
};
/// Type of Cpu Model.
enum ECpuModel
{
eCpu_Unknown,
eCpu_8086,
eCpu_80286,
eCpu_80386,
eCpu_80486,
eCpu_Pentium,
eCpu_PentiumPro,
eCpu_Pentium2,
eCpu_Pentium3,
eCpu_Pentium4,
eCpu_Pentium2Xeon,
eCpu_Pentium3Xeon,
eCpu_Celeron,
eCpu_CeleronA,
eCpu_Am5x86,
eCpu_AmK5,
eCpu_AmK6,
eCpu_AmK6_2,
eCpu_AmK6_3,
eCpu_AmK6_3D,
eCpu_AmAthlon,
eCpu_AmDuron,
eCpu_CyrixMediaGX,
eCpu_Cyrix6x86,
eCpu_CyrixGXm,
eCpu_Cyrix6x86MX,
eCpu_CenWinChip,
eCpu_CenWinChip2,
};
struct SCpu
{
ECpuVendor meVendor;
ECpuModel meModel;
unsigned long mFeatures;
bool mbSerialPresent;
char mSerialNumber[30];
int mFamily;
int mModel;
int mStepping;
char mVendor[64];
char mCpuType[64];
char mFpuType[64];
bool mbPhysical; // false for hyperthreaded
DWORD_PTR mAffinityMask;
// constructor
SCpu()
: meVendor(eCVendor_Unknown)
, meModel(eCpu_Unknown)
, mFeatures(0)
, mbSerialPresent(false)
, mFamily(0)
, mModel(0)
, mStepping(0)
, mbPhysical(true)
, mAffinityMask(0)
{
memset(mSerialNumber, 0, sizeof(mSerialNumber));
memset(mVendor, 0, sizeof(mVendor));
memset(mCpuType, 0, sizeof(mCpuType));
memset(mFpuType, 0, sizeof(mFpuType));
}
};
class CCpuFeatures
{
private:
int m_NumLogicalProcessors;
int m_NumSystemProcessors;
int m_NumAvailProcessors;
int m_NumPhysicsProcessors;
bool m_bOS_ISSE;
bool m_bOS_ISSE_EXCEPTIONS;
public:
SCpu m_Cpu[MAX_CPU];
public:
CCpuFeatures()
{
m_NumLogicalProcessors = 0;
m_NumSystemProcessors = 0;
m_NumAvailProcessors = 0;
m_NumPhysicsProcessors = 0;
m_bOS_ISSE = 0;
m_bOS_ISSE_EXCEPTIONS = 0;
ZeroMemory(m_Cpu, sizeof(m_Cpu));
}
void Detect(void);
bool hasSSE() { return (m_Cpu[0].mFeatures & CFI_SSE) != 0; }
bool hasSSE2() { return (m_Cpu[0].mFeatures & CFI_SSE2) != 0; }
bool hasSSE3() { return (m_Cpu[0].mFeatures & CFI_SSE3) != 0; }
bool hasSSE41() { return (m_Cpu[0].mFeatures & CFI_SSE41) != 0; }
bool has3DNow() { return (m_Cpu[0].mFeatures & CFI_3DNOW) != 0; }
bool hasMMX() { return (m_Cpu[0].mFeatures & CFI_MMX) != 0; }
bool hasF16C() { return (m_Cpu[0].mFeatures & CFI_F16C) != 0; }
unsigned int GetLogicalCPUCount() { return m_NumLogicalProcessors; }
unsigned int GetPhysCPUCount() { return m_NumPhysicsProcessors; }
unsigned int GetCPUCount() { return m_NumAvailProcessors; }
DWORD_PTR GetCPUAffinityMask(unsigned int iCPU) { assert(iCPU < MAX_CPU); return iCPU < GetCPUCount() ? m_Cpu[iCPU].mAffinityMask : 0; }
DWORD_PTR GetPhysCPUAffinityMask(unsigned int iCPU)
{
if (iCPU > GetPhysCPUCount())
{
return 0;
}
int i;
for (i = 0; (int)iCPU >= 0; i++)
{
if (m_Cpu[i].mbPhysical)
{
--iCPU;
}
}
PREFAST_ASSUME(i > 0 && i < MAX_CPU);
return m_Cpu[i - 1].mAffinityMask;
}
};
#endif // CRYINCLUDE_CRYSYSTEM_CPUDETECT_H
@@ -1,90 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "ProjectDefines.h"
#if defined(MAP_LOADING_SLICING)
#include "ClientHandler.h"
ClientHandler::ClientHandler(const char* bucket, int affinity, int clientTimeout)
: HandlerBase(bucket, affinity)
{
m_clientTimeout = clientTimeout;
Reset();
}
void ClientHandler::Reset()
{
m_srvLock.reset(0);
for (int i = 0; i < MAX_CLIENTS_NUM; i++)
{
std::unique_ptr<SSyncLock> srv(new SSyncLock(m_serverLockName, i, false));
// first get the client lock up!
if (!srv->IsValid())
{
//try to create client lock
m_clientLock.reset(new SSyncLock(m_clientLockName, i, true));
if (m_clientLock->IsValid())
{
break;
}
else
{
m_clientLock.reset(0);
}
}
}
}
bool ClientHandler::ServerIsValid()
{
if (!m_srvLock.get())
{
if (m_clientLock.get() && m_clientLock->IsValid())
{
m_srvLock.reset(new SSyncLock(m_serverLockName, m_clientLock->number, false));
if (m_srvLock->IsValid())
{
SetAffinity();
//got synched
return true;
}
m_srvLock.reset(0);
}
return false;
}
return m_srvLock->IsValid();
}
bool ClientHandler::Sync()
{
if (ServerIsValid())
{
m_clientLock->Signal();//signal that we're done and
if (m_srvLock->Wait(m_clientTimeout))//wait for server
{
//bla bla, track waiting
return true;
}
else
{
Reset();
}
}
return false;
}
#endif // defined(MAP_LOADING_SLICING)
-36
View File
@@ -1,36 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_CLIENTHANDLER_H
#define CRYINCLUDE_CRYSYSTEM_CLIENTHANDLER_H
#pragma once
#include "HandlerBase.h"
#include "SyncLock.h"
struct ClientHandler
: public HandlerBase
{
ClientHandler(const char* bucket, int affinity, int clientTimeout);
void Reset();
bool ServerIsValid();
bool Sync();
private:
int m_clientTimeout;
std::unique_ptr<SSyncLock> m_clientLock;
std::unique_ptr<SSyncLock> m_srvLock;
};
#endif
@@ -1,167 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "CrySystem_precompiled.h"
#include <AzTest/AzTest.h>
#include <MathConversion.h>
#include <Cry_Quat.h>
#include <Cry_Matrix34.h>
//namespace MathConversionUnitTests
//{
const float kEpsilon = 0.01f;
bool IsNearlyEqual(const AZ::Vector3& az, const Vec3& ly)
{
return fcmp(az.GetX(), ly.x, kEpsilon)
&& fcmp(az.GetY(), ly.y, kEpsilon)
&& fcmp(az.GetZ(), ly.z, kEpsilon);
}
bool IsNearlyEqual(const AZ::Quaternion& az, const Quat& ly)
{
return fcmp(az.GetX(), ly.v.x, kEpsilon)
&& fcmp(az.GetY(), ly.v.y, kEpsilon)
&& fcmp(az.GetZ(), ly.v.z, kEpsilon)
&& fcmp(az.GetW(), ly.w, kEpsilon);
}
bool IsNearlyEqual(const AZ::Transform& az, const Matrix34& ly)
{
float azFloats[12];
const AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(az);
matrix3x4.StoreToRowMajorFloat12(azFloats);
const float* lyFloats = ly.GetData();
for (int i = 0; i < 12; ++i)
{
if (!fcmp(azFloats[i], lyFloats[i], kEpsilon))
{
return false;
}
}
return true;
}
bool IsNearlyEqual(const AZ::Transform& az, const QuatT& ly)
{
return IsNearlyEqual(az.GetTranslation(), ly.t)
&& IsNearlyEqual(az.GetRotation(), ly.q);
}
TEST(MathConversionTests, BasicConversions)
{
{ // check vector3 comparisons
AZ::Vector3 az(1.f, 2.f, 3.f);
Vec3 ly(1.f, 2.f, 3.f);
EXPECT_TRUE(IsNearlyEqual(az, ly));
// reverse XYZ
ly = Vec3(3.f, 2.f, 1.f);
EXPECT_TRUE(!IsNearlyEqual(az, ly));
// off by 0.1
ly = Vec3(1.1f, 2.1f, 3.1f);
EXPECT_TRUE(!IsNearlyEqual(az, ly));
}
{ // check vector3 conversions
Vec3 ly1(1.f, 2.f, 3.f);
AZ::Vector3 az = LYVec3ToAZVec3(ly1);
EXPECT_TRUE(IsNearlyEqual(az, ly1));
Vec3 ly2 = AZVec3ToLYVec3(az);
EXPECT_TRUE(IsNearlyEqual(az, ly1));
EXPECT_TRUE(ly1.IsEquivalent(ly2));
}
{ // check quaternion comparisons
AZ::Quaternion az(AZ::Quaternion::CreateIdentity());
Quat ly(IDENTITY);
EXPECT_TRUE(IsNearlyEqual(az, ly));
az = AZ::Quaternion(1.f, 2.f, 3.f, 4.f);
ly = Quat(4.f, 1.f, 2.f, 3.f);
EXPECT_TRUE(IsNearlyEqual(az, ly));
// w in wrong place
ly = Quat(1.f, 2.f, 3.f, 4.f);
EXPECT_TRUE(!IsNearlyEqual(az, ly));
}
{ // check quaternion conversions
Quat ly1(4.f, 1.f, 2.f, 3.f);
AZ::Quaternion az = LYQuaternionToAZQuaternion(ly1);
EXPECT_TRUE(IsNearlyEqual(az, ly1));
Quat ly2 = AZQuaternionToLYQuaternion(az);
EXPECT_TRUE(IsNearlyEqual(az, ly2));
EXPECT_TRUE(Quat::IsEquivalent(ly1, ly2));
}
{ // check transform comparisons
AZ::Transform az = AZ::Transform::Identity();
Matrix34 ly = Matrix34::CreateIdentity();
EXPECT_TRUE(IsNearlyEqual(az, ly));
// rotating pi/2 will get us a non-symmetric matrix.
// good for testing that we're not confusing rows & columns
float rotation = gf_PI / 2.f;
ly = Matrix34::CreateRotationX(rotation, Vec3(1.f, 2.f, 3.f));
az = AZ::Transform::CreateRotationX(rotation);
az.SetTranslation(1.f, 2.f, 3.f);
EXPECT_TRUE(IsNearlyEqual(az, ly));
// rotate around different axis
ly = Matrix34::CreateRotationY(rotation, Vec3(1.f, 2.f, 3.f));
EXPECT_TRUE(!IsNearlyEqual(az, ly));
}
{ // check transform conversions
Matrix34 ly1 = Matrix34::CreateRotationXYZ(Ang3(0.1f, 0.5f, 0.9f), Vec3(1.f, 2.f, 3.f));
AZ::Transform az = LYTransformToAZTransform(ly1);
EXPECT_TRUE(IsNearlyEqual(az, ly1));
Matrix34 ly2 = AZTransformToLYTransform(az);
EXPECT_TRUE(IsNearlyEqual(az, ly2));
EXPECT_TRUE(Matrix34::IsEquivalent(ly1, ly2));
}
{ // check QuatT comparisons
AZ::Transform az = AZ::Transform::Identity();
QuatT ly(IDENTITY);
EXPECT_TRUE(IsNearlyEqual(az, ly));
az = AZ::Transform::CreateRotationX(AZ::Constants::HalfPi);
az.SetTranslation(1.f, 2.f, 3.f);
ly.q.SetRotationX(AZ::Constants::HalfPi);
ly.t.Set(1.f, 2.f, 3.f);
EXPECT_TRUE(IsNearlyEqual(az, ly));
// off by 0.1
ly.t.z += 0.1f;
EXPECT_TRUE(!IsNearlyEqual(az, ly));
}
{ // check QuatT conversions
QuatT ly1(Quat::CreateRotationX(AZ::Constants::HalfPi), Vec3(5.f, 6.f, 7.f));
AZ::Transform az = LYQuatTToAZTransform(ly1);
EXPECT_TRUE(IsNearlyEqual(az, ly1));
QuatT ly2 = AZTransformToLYQuatT(az);
EXPECT_TRUE(IsNearlyEqual(az, ly2));
EXPECT_TRUE(QuatT::IsEquivalent(ly1, ly2));
}
}
//} // namespace MathConversionUnitTests
@@ -1,38 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "System.h"
#include "CryZlib.h"
bool CSystem::CompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize, int level)
{
uLongf destLen = outputSize;
Bytef* dest = static_cast<Bytef*>(output);
uLong sourceLen = inputSize;
const Bytef* source = static_cast<const Bytef*>(input);
bool ok = Z_OK == compress2(dest, &destLen, source, sourceLen, level);
outputSize = destLen;
return ok;
}
bool CSystem::DecompressDataBlock(const void* input, size_t inputSize, void* output, size_t& outputSize)
{
uLongf destLen = outputSize;
Bytef* dest = static_cast<Bytef*>(output);
uLong sourceLen = inputSize;
const Bytef* source = static_cast<const Bytef*>(input);
bool ok = Z_OK == uncompress(dest, &destLen, source, sourceLen);
outputSize = destLen;
return ok;
}
@@ -1,58 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include <AzCore/Debug/Profiler.h>
#include <AzCore/Jobs/JobFunction.h>
namespace
{
static void cryAsyncMemcpy_Int(
void* dst
, const void* src
, size_t size
, int nFlags
, volatile int* sync)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::System);
cryMemcpy(dst, src, size, nFlags);
if (sync)
{
CryInterlockedDecrement(sync);
}
}
}
#if !defined(CRY_ASYNC_MEMCPY_DELEGATE_TO_CRYSYSTEM)
CRY_ASYNC_MEMCPY_API void cryAsyncMemcpy(
#else
CRY_ASYNC_MEMCPY_API void cryAsyncMemcpyDelegate(
#endif
void* dst
, const void* src
, size_t size
, int nFlags
, volatile int* sync)
{
AZ::Job* job = AZ::CreateJobFunction(
[dst, src, size, nFlags, sync]()
{
cryAsyncMemcpy_Int(dst, src, size, nFlags, sync);
},
true); // Auto-delete
job->Start();
}
File diff suppressed because it is too large Load Diff
-91
View File
@@ -1,91 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// German (Germany) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000904b0"
BEGIN
VALUE "CompanyName", "Amazon.com, Inc."
VALUE "FileVersion", "1, 0, 0, 1"
VALUE "LegalCopyright", "Portions of this file Copyright (c) Amazon.com, Inc. or its affiliates. All Rights Reserved. Original file Copyright (c) Crytek GMBH. Used under license by Amazon.com, Inc. and its affiliates."
VALUE "ProductName", "Lumberyard"
VALUE "ProductVersion", "1, 0, 0, 1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x9, 1200
END
END
#endif // German (Germany) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
-34
View File
@@ -1,34 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Header for adding a watermark to an exe, which can then be set
// by the external CryWaterMark program. To use, simply write:
//
// WATERMARKDATA(__blah);
//
// anywhere in the global scope in the program
#ifndef CRYINCLUDE_CRYSYSTEM_CRYWATERMARK_H
#define CRYINCLUDE_CRYSYSTEM_CRYWATERMARK_H
#pragma once
#define NUMMARKWORDS 10
#define WATERMARKDATA(name) unsigned int name[] = { 0xDEBEFECA, 0xFABECEDA, 0xADABAFBE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// (the name is such that you can have multiple watermarks in one exe, don't use
// names like "watermark" just incase you accidentally give out an exe with
// debug information).
#endif // CRYINCLUDE_CRYSYSTEM_CRYWATERMARK_H
-131
View File
@@ -1,131 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "ProjectDefines.h"
#if defined(MAP_LOADING_SLICING)
#include "HandlerBase.h"
const char* SERVER_LOCK_NAME = "SynchronizeGameServer";
const char* CLIENT_LOCK_NAME = "SynchronizeGameClient";
HandlerBase::HandlerBase(const char* bucket, int affinity)
{
m_serverLockName.Format("%s_%s", SERVER_LOCK_NAME, bucket);
m_clientLockName.Format("%s_%s", CLIENT_LOCK_NAME, bucket);
if (affinity != 0)
{
m_affinity = uint32(1) << (affinity - 1);
}
else
{
m_affinity = -1;
}
m_prevAffinity = 0;
}
HandlerBase::~HandlerBase()
{
if (m_prevAffinity)
{
if (SyncSetAffinity(m_prevAffinity))
{
CryLogAlways("Restored affinity to %d", m_prevAffinity);
}
else
{
CryLogAlways("Failed to restore affinity to %d", m_prevAffinity);
}
}
}
void HandlerBase::SetAffinity()
{
if (m_prevAffinity) //already set
{
return;
}
if (uint32 p = SyncSetAffinity(m_affinity))
{
CryLogAlways("Changed affinity to %d", m_affinity);
m_prevAffinity = p;
}
else
{
CryLogAlways("Failed to change affinity to %d", m_affinity);
}
}
#if defined(LINUX)
uint32 HandlerBase::SyncSetAffinity(uint32 cpuMask)//put -1
{
if (cpuMask != 0)
{
cpu_set_t cpuSet;
uint32 affinity = 0;
if (!sched_getaffinity(getpid(), sizeof cpuSet, &cpuSet))
{
for (int cpu = 0; cpu < sizeof(cpuMask) * 8; ++cpu)
{
if (CPU_ISSET(cpu, &cpuSet))
{
affinity |= 1 << cpu;
}
}
}
if (affinity)
{
CPU_ZERO(&cpuSet);
for (int cpu = 0; cpu < sizeof(cpuMask) * 8; ++cpu)
{
if (cpuMask & (1 << cpu))
{
CPU_SET(cpu, &cpuSet);
}
}
if (!sched_setaffinity(getpid(), sizeof(cpuSet), &cpuSet))
{
return affinity;
}
}
}
return 0;
}
#elif AZ_LEGACY_CRYSYSTEM_TRAIT_USE_HANDLER_SYNC_AFFINITY
uint32 HandlerBase::SyncSetAffinity(uint32 cpuMask)//put -1
{
uint32 p = (uint32)SetThreadAffinityMask(GetCurrentThread(), cpuMask);
if (p == 0)
{
CryLogAlways("Error updating affinity mask to %d", cpuMask);
}
return p;
}
#else
uint32 HandlerBase::SyncSetAffinity(uint32 cpuMask)//put -1
{
CryLogAlways("Updating thread affinity not supported on this platform");
return 0;
}
#endif
#endif // defined(MAP_LOADING_SLICING)
-35
View File
@@ -1,35 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_HANDLERBASE_H
#define CRYINCLUDE_CRYSYSTEM_HANDLERBASE_H
#pragma once
const int MAX_CLIENTS_NUM = 100;
struct HandlerBase
{
HandlerBase(const char* bucket, int affinity);
~HandlerBase();
void SetAffinity();
uint32 SyncSetAffinity(uint32 cpuMask);
string m_serverLockName;
string m_clientLockName;
uint32 m_affinity;
uint32 m_prevAffinity;
};
#endif // CRYINCLUDE_CRYSYSTEM_HANDLERBASE_H
-54
View File
@@ -1,54 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Console implementation for iOS, reports back to the main interface
#pragma once
#include <IConsole.h>
#include <ITextModeConsole.h>
class CIOSConsole
: public ISystemUserCallback
, public IOutputPrintSink
, public ITextModeConsole
{
CIOSConsole(const CIOSConsole&);
CIOSConsole& operator = (const CIOSConsole&);
bool m_isInitialized;
public:
static CryCriticalSectionNonRecursive s_lock;
public:
CIOSConsole();
~CIOSConsole();
// Interface IOutputPrintSink /////////////////////////////////////////////
DLL_EXPORT virtual void Print(const char* line);
// Interface ISystemUserCallback //////////////////////////////////////////
virtual bool OnError(const char* errorString);
virtual bool OnSaveDocument() { return false; }
virtual void OnProcessSwitch() { }
virtual void OnInitProgress(const char* sProgressMsg);
virtual void OnInit(ISystem*);
virtual void OnShutdown();
virtual void OnUpdate();
virtual void GetMemoryUsage(ICrySizer* pSizer);
void SetRequireDedicatedServer(bool) {}
void SetHeader(const char*) {}
// Interface ITextModeConsole /////////////////////////////////////////////
virtual Vec2_tpl<int> BeginDraw();
virtual void PutText(int x, int y, const char* msg);
virtual void EndDraw();
};
-94
View File
@@ -1,94 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#if defined(IOS)
#include "IOSConsole.h"
CIOSConsole::CIOSConsole():
m_isInitialized(false)
{
}
CIOSConsole::~CIOSConsole()
{
}
// Interface IOutputPrintSink /////////////////////////////////////////////
void CIOSConsole::Print(const char *line)
{
printf("MSG: %s\n", line);
}
// Interface ISystemUserCallback //////////////////////////////////////////
bool CIOSConsole::OnError(const char *errorString)
{
printf("ERR: %s\n", errorString);
return true;
}
void CIOSConsole::OnInitProgress(const char *sProgressMsg)
{
(void) sProgressMsg;
// Do Nothing
}
void CIOSConsole::OnInit(ISystem *pSystem)
{
if (!m_isInitialized)
{
IConsole* pConsole = pSystem->GetIConsole();
if (pConsole != 0)
{
pConsole->AddOutputPrintSink(this);
}
m_isInitialized = true;
}
}
void CIOSConsole::OnShutdown()
{
if (m_isInitialized)
{
// remove outputprintsink
m_isInitialized = false;
}
}
void CIOSConsole::OnUpdate()
{
// Do Nothing
}
void CIOSConsole::GetMemoryUsage(ICrySizer *pSizer)
{
size_t size = sizeof(*this);
pSizer->AddObject(this, size);
}
// Interface ITextModeConsole /////////////////////////////////////////////
Vec2_tpl<int> CIOSConsole::BeginDraw()
{
return Vec2_tpl<int>(0,0);
}
void CIOSConsole::PutText( int x, int y, const char * msg )
{
printf("PUT: %s\n", msg);
}
void CIOSConsole::EndDraw() {
// Do Nothing
}
#endif // IOS
@@ -1,29 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : lz4 hc decompress wrapper
#include "CrySystem_precompiled.h"
#include <lz4.h>
#include "LZ4Decompressor.h"
bool CLZ4Decompressor::DecompressData(const char* pIn, char* pOut, const uint outputSize) const
{
return LZ4_decompress_fast(pIn, pOut, outputSize) >= 0;
}
void CLZ4Decompressor::Release()
{
delete this;
}
@@ -1,35 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : lz4 hc decompress wrapper
#ifndef CRYINCLUDE_CRYSYSTEM_LZ4DECOMPRESSOR_H
#define CRYINCLUDE_CRYSYSTEM_LZ4DECOMPRESSOR_H
#pragma once
#include "ILZ4Decompressor.h"
class CLZ4Decompressor
: public ILZ4Decompressor
{
public:
virtual bool DecompressData(const char* pIn, char* pOut, const uint outputSize) const;
virtual void Release();
private:
virtual ~CLZ4Decompressor() {}
};
#endif // CRYINCLUDE_CRYSYSTEM_LZ4DECOMPRESSOR_H
@@ -19,7 +19,6 @@
#include "IMovieSystem.h"
#include <ILocalizationManager.h>
#include "CryPath.h"
#include <Pak/CryPakUtils.h>
#include <LoadScreenBus.h>
@@ -260,16 +259,6 @@ void CLevelSystem::Rescan(const char* levelsFolder)
{
if (levelsFolder)
{
if (const ICmdLineArg* pModArg = m_pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "MOD"))
{
if (m_pSystem->IsMODValid(pModArg->GetValue()))
{
m_levelsFolder.format("Mods/%s/%s", pModArg->GetValue(), levelsFolder);
m_levelInfos.clear();
ScanFolder(0, true);
}
}
m_levelsFolder = levelsFolder;
}
@@ -28,8 +28,6 @@
#include <locale.h>
#include <time.h>
#include "CryZlib.h"
#include <AzCore/std/string/conversions.h>
#include <AzFramework/StringFunc/StringFunc.h>
+1 -27
View File
@@ -22,7 +22,6 @@
#include <ISystem.h>
#include "System.h"
#include "CryPath.h" // PathUtil::ReplaceExtension()
#include <Pak/CryPakUtils.h>
#include "UnicodeFunctions.h"
#include <AzFramework/IO/FileOperations.h>
@@ -237,7 +236,6 @@ void CLog::CloseLogFile([[maybe_unused]] bool forceClose)
//////////////////////////////////////////////////////////////////////////
AZ::IO::HandleType CLog::OpenLogFile(const char* filename, const char* mode)
{
CDebugAllowFileAccess ignoreInvalidFileAccess;
using namespace AZ::IO;
AZ_Assert(m_logFileHandle == AZ::IO::InvalidHandle, "Attempt to open log file when one is already open. This would lead to a handle leak.");
@@ -417,7 +415,7 @@ void CLog::LogV(const ELogType type, const char* szFormat, va_list args)
LogV(type, 0, szFormat, args);
}
void CLog::LogV(const ELogType type, int flags, const char* szFormat, va_list args)
void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFormat, va_list args)
{
// this is here in case someone called LogV directly, with an invalid formatter.
if (!CheckLogFormatter(szFormat))
@@ -595,28 +593,6 @@ void CLog::LogV(const ELogType type, int flags, const char* szFormat, va_list ar
GetISystem()->GetIRemoteConsole()->AddLogError(szString);
break;
}
//////////////////////////////////////////////////////////////////////////
if (type == eWarningAlways || type == eWarning || type == eError || type == eErrorAlways)
{
IValidator* pValidator = m_pSystem->GetIValidator();
if (pValidator && (flags & VALIDATOR_FLAG_SKIP_VALIDATOR) == 0)
{
CryAutoCriticalSection scope_lock(m_logCriticalSection);
SValidatorRecord record;
record.text = szBuffer;
record.module = VALIDATOR_MODULE_SYSTEM;
record.severity = VALIDATOR_WARNING;
record.assetScope = GetAssetScopeString();
record.flags = flags;
if (type == eError || type == eErrorAlways)
{
record.severity = VALIDATOR_ERROR;
}
pValidator->Report(record);
}
}
}
//will log the text both to the end of file and console
@@ -1138,8 +1114,6 @@ void CLog::LogStringToFile(const char* szString, ELogType logType, bool bAdd, [[
if (logToFile)
{
CDebugAllowFileAccess dafa;
if (m_logFileHandle == AZ::IO::InvalidHandle)
{
OpenLogFile(m_szFilename, "w+t");
@@ -1,151 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include <AzCore/std/string/regex.h>
#include <AzCore/std/string/string.h>
#include <IXml.h>
#include "MobileDetectSpec.h"
namespace MobileSysInspect
{
struct GpuApiPair
{
AZStd::string gpuDescription;
AZStd::string apiDescription;
};
AZStd::vector<AZStd::pair<AZStd::string, AZStd::string>> deviceSpecMapping;
AZStd::vector<AZStd::pair<GpuApiPair, AZStd::string>> gpuSpecMapping;
const float LOW_SPEC_RAM = 1.0f;
const float MEDIUM_SPEC_RAM = 2.0f;
const float HIGH_SPEC_RAM = 3.0f;
bool GetSpecForGPUAndAPI(const AZStd::string& gpuName, const AZStd::string& apiDescription, AZStd::string& specName)
{
for (const auto& descriptionSpecPair : gpuSpecMapping)
{
const GpuApiPair& currentPair = descriptionSpecPair.first;
AZStd::regex currentRegex(currentPair.gpuDescription.c_str());
if (!AZStd::regex_search(gpuName, currentRegex))
{
continue;
}
currentRegex.assign(currentPair.apiDescription.c_str());
if (!currentRegex.Empty() && !AZStd::regex_search(apiDescription, currentRegex))
{
continue;
}
specName = descriptionSpecPair.second;
return true;
}
return false;
}
namespace Internal
{
void LoadDeviceSpecMapping_impl(const char* filename)
{
XmlNodeRef xmlNode = GetISystem()->LoadXmlFromFile(filename);
if (!xmlNode)
{
return;
}
const int fileCount = xmlNode->getChildCount();
for (int i = 0; i < fileCount; ++i)
{
XmlNodeRef fileNode = xmlNode->getChild(i);
AZStd::string file = fileNode->getAttr("file");
if (!file.empty())
{
const int mappingCount = fileNode->getChildCount();
deviceSpecMapping.reserve(mappingCount);
for (int j = 0; j < mappingCount; ++j)
{
XmlNodeRef modelNode = fileNode->getChild(j);
AZStd::string model = modelNode->getAttr("model");
if (!model.empty())
{
deviceSpecMapping.push_back(AZStd::make_pair(model, file));
}
}
}
}
}
void LoadGpuSpecMapping_impl(const char* filename)
{
XmlNodeRef xmlNode = GetISystem()->LoadXmlFromFile(filename);
if (!xmlNode)
{
return;
}
const int fileCount = xmlNode->getChildCount();
for (int i = 0; i < fileCount; ++i)
{
XmlNodeRef fileNode = xmlNode->getChild(i);
AZStd::string file = fileNode->getAttr("file");
if (!file.empty())
{
const int mappingCount = fileNode->getChildCount();
gpuSpecMapping.reserve(mappingCount);
for (int j = 0; j < mappingCount; ++j)
{
XmlNodeRef modelNode = fileNode->getChild(j);
GpuApiPair gpuApiPair;
gpuApiPair.gpuDescription = modelNode->getAttr("gpuName");
gpuApiPair.apiDescription = modelNode->getAttr("apiVersion");
if (!gpuApiPair.gpuDescription.empty() || !gpuApiPair.apiDescription.empty())
{
gpuSpecMapping.push_back(AZStd::make_pair(gpuApiPair, file));
}
}
}
}
}
bool GetSpecForModelName(const AZStd::string& modelName, AZStd::string& specName)
{
for (const auto& descriptionSpecPair : deviceSpecMapping)
{
AZStd::regex currentRegex(descriptionSpecPair.first.c_str());
if (AZStd::regex_search(modelName, currentRegex))
{
specName = descriptionSpecPair.second;
return true;
}
}
return false;
}
} // namespace Internal
} // namespace MobileSysInspect
@@ -1,35 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#pragma once
#include "AzCore/std/containers/unordered_map.h"
namespace MobileSysInspect
{
extern const float LOW_SPEC_RAM;
extern const float MEDIUM_SPEC_RAM;
extern const float HIGH_SPEC_RAM;
void LoadDeviceSpecMapping();
bool GetAutoDetectedSpecName(AZStd::string &buffer);
bool GetSpecForGPUAndAPI(const AZStd::string& gpuName, const AZStd::string& apiDescription, AZStd::string& specName);
const float GetDeviceRamInGB();
namespace Internal
{
void LoadDeviceSpecMapping_impl(const char* fileName);
void LoadGpuSpecMapping_impl(const char* filename);
bool GetSpecForModelName(const AZStd::string& modelName, AZStd::string& specName);
}
}
@@ -1,47 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include <AzCore/Android/JNI/JNI.h>
#include <AzCore/Android/JNI/Object.h>
#include <AzCore/std/string/string.h>
#include "MobileDetectSpec.h"
namespace MobileSysInspect
{
void LoadDeviceSpecMapping()
{
Internal::LoadDeviceSpecMapping_impl("@assets@/config/gpu/android_models.xml");
Internal::LoadGpuSpecMapping_impl("@assets@/config/gpu/android_gpus.xml");
}
// Returns true if device is found in the device spec mapping
bool GetAutoDetectedSpecName(AZStd::string &buffer)
{
static constexpr const char* s_javaFieldName = "MODEL";
AZ::Android::JNI::Object obj("android/os/Build");
obj.RegisterStaticField(s_javaFieldName, "Ljava/lang/String;");
AZStd::string name = obj.GetStaticStringField(s_javaFieldName);
return Internal::GetSpecForModelName(name, buffer);
}
const float GetDeviceRamInGB()
{
static constexpr const char* s_javaFuntionNameGetDeviceRamInGB = "GetDeviceRamInGB";
AZ::Android::JNI::Object obj("com/amazon/lumberyard/AndroidDeviceManager");
obj.RegisterStaticMethod(s_javaFuntionNameGetDeviceRamInGB, "()F");
return obj.InvokeStaticFloatMethod(s_javaFuntionNameGetDeviceRamInGB);
}
}
@@ -1,40 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include <AzCore/std/string/string.h>
#include "MobileDetectSpec.h"
#include <AzFramework/Utils/SystemUtilsApple.h>
namespace MobileSysInspect
{
void LoadDeviceSpecMapping()
{
Internal::LoadDeviceSpecMapping_impl("@assets@/config/gpu/ios_models.xml");
}
// Returns true if device is found in the device spec mapping
bool GetAutoDetectedSpecName(AZStd::string &buffer)
{
AZStd::string name = SystemUtilsApple::GetMachineName();
return Internal::GetSpecForModelName(name, buffer);
}
const float GetDeviceRamInGB()
{
// not supported on this platform
return 0.0f;
}
}
-22
View File
@@ -1,22 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : declaration of a simple dedicated renderer for the physics subsystem
#ifndef CRYINCLUDE_CRYSYSTEM_PHYSRENDERER_H
#define CRYINCLUDE_CRYSYSTEM_PHYSRENDERER_H
#pragma once
#endif // CRYINCLUDE_CRYSYSTEM_PHYSRENDERER_H
@@ -1,16 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Platform specific cmake file for configuring target compiler/link properties
# based on the active platform
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
@@ -1,18 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
../../MobileDetectSpec_Android.cpp
../../MobileDetectSpec.cpp
../../MobileDetectSpec.h
../../ThermalInfoAndroid.h
../../ThermalInfoAndroid.cpp
)
@@ -1,21 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Platform specific cmake file for configuring target compiler/link properties
# based on the active platform
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
set(LY_BUILD_DEPENDENCIES
PRIVATE
m
)
@@ -1,13 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
)
@@ -1,16 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Platform specific cmake file for configuring target compiler/link properties
# based on the active platform
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
@@ -1,10 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
@@ -1,16 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Platform specific cmake file for configuring target compiler/link properties
# based on the active platform
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
@@ -1,13 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
)
@@ -1,22 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(LY_COMPILE_OPTIONS
PRIVATE
-xobjective-c++
)
find_library(UI_KIT_FRAMEWORK UIKit)
set(LY_BUILD_DEPENDENCIES
PRIVATE
${UI_KIT_FRAMEWORK}
)
@@ -1,18 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
../../MobileDetectSpec_Ios.cpp
../../MobileDetectSpec.cpp
../../MobileDetectSpec.h
)
-3
View File
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:45dfbb9836e8a8ac4ed5b427528dadf9134618e6977a1eb67af067e0eaadc185
size 561936
-287
View File
@@ -1,287 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "Sampler.h"
#if defined(WIN32)
#include <ISystem.h>
#include <Mmsystem.h>
#include <AzCore/Debug/StackTracer.h>
#define MAX_SYMBOL_LENGTH 512
//////////////////////////////////////////////////////////////////////////
// Makes thread.
//////////////////////////////////////////////////////////////////////////
class CSamplingThread
{
public:
CSamplingThread(CSampler* pSampler)
{
m_hThread = NULL;
m_pSampler = pSampler;
m_bStop = false;
m_samplePeriodMs = pSampler->GetSamplePeriod();
m_hProcess = GetCurrentProcess();
m_hSampledThread = GetCurrentThread();
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &m_hSampledThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
}
// Start thread.
void Start();
void Stop();
protected:
virtual ~CSamplingThread() {};
static DWORD WINAPI ThreadFunc(void* pThreadParam);
void Run(); // Derived classes must override this.
HANDLE m_hProcess;
HANDLE m_hThread;
HANDLE m_hSampledThread;
DWORD m_ThreadId;
CSampler* m_pSampler;
bool m_bStop;
int m_samplePeriodMs;
};
//////////////////////////////////////////////////////////////////////////
void CSamplingThread::Start()
{
m_hThread = CreateThread(NULL, 0, ThreadFunc, this, 0, &m_ThreadId);
}
//////////////////////////////////////////////////////////////////////////
void CSamplingThread::Stop()
{
m_bStop = true;
}
//////////////////////////////////////////////////////////////////////////
DWORD CSamplingThread::ThreadFunc(void* pThreadParam)
{
CSamplingThread* thread = (CSamplingThread*)pThreadParam;
thread->Run();
// Auto destruct thread class.
delete thread;
return 0;
}
//////////////////////////////////////////////////////////////////////////
void CSamplingThread::Run()
{
//SetThreadPriority( m_hThread,THREAD_PRIORITY_HIGHEST );
SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
while (!m_bStop)
{
SuspendThread(m_hSampledThread);
CONTEXT context;
context.ContextFlags = CONTEXT_CONTROL;
uint64 ip = 0;
if (GetThreadContext(m_hSampledThread, &context))
{
#ifdef CONTEXT_i386
ip = context.Eip;
#else
ip = context.Rip;
#endif
}
ResumeThread(m_hSampledThread);
if (!m_pSampler->AddSample(ip))
{
break;
}
Sleep(m_samplePeriodMs);
}
}
//////////////////////////////////////////////////////////////////////////
CSampler::CSampler()
{
m_pSamplingThread = NULL;
SetMaxSamples(2000);
m_bSamplingFinished = false;
m_bSampling = false;
m_samplePeriodMs = 1; //1ms
}
//////////////////////////////////////////////////////////////////////////
CSampler::~CSampler()
{
}
//////////////////////////////////////////////////////////////////////////
void CSampler::SetMaxSamples(int nMaxSamples)
{
m_rawSamples.reserve(nMaxSamples);
m_nMaxSamples = nMaxSamples;
}
//////////////////////////////////////////////////////////////////////////
void CSampler::Start()
{
if (m_bSampling)
{
return;
}
CryLogAlways("Staring Sampling with interval %dms, max samples: %d ...", m_samplePeriodMs, m_nMaxSamples);
m_bSampling = true;
m_bSamplingFinished = false;
m_pSamplingThread = new CSamplingThread(this);
m_rawSamples.clear();
m_functionSamples.clear();
m_pSamplingThread->Start();
}
//////////////////////////////////////////////////////////////////////////
void CSampler::Stop()
{
if (m_bSamplingFinished)
{
}
if (m_bSampling)
{
m_pSamplingThread->Stop();
}
m_bSampling = false;
m_pSamplingThread = 0;
}
//////////////////////////////////////////////////////////////////////////
void CSampler::Update()
{
if (m_bSamplingFinished)
{
ProcessSampledData();
m_bSamplingFinished = false;
}
}
//////////////////////////////////////////////////////////////////////////
bool CSampler::AddSample(uint64 ip)
{
if ((int)m_rawSamples.size() >= m_nMaxSamples)
{
m_bSamplingFinished = true;
m_bSampling = false;
m_pSamplingThread = 0;
return false;
}
m_rawSamples.push_back(ip);
return true;
}
inline bool CompareFunctionSamples(const CSampler::SFunctionSample& s1, const CSampler::SFunctionSample& s2)
{
return s1.nSamples < s2.nSamples;
}
//////////////////////////////////////////////////////////////////////////
void CSampler::ProcessSampledData()
{
CryLogAlways("Processing collected samples...");
uint32 i;
// Count duplicates.
std::map<uint64, int> counts;
std::map<uint64, int>::iterator cit;
for (i = 0; i < m_rawSamples.size(); i++)
{
uint32 ip = (uint32)m_rawSamples[i];
cit = counts.find(ip);
if (cit != counts.end())
{
cit->second++;
}
else
{
counts[ip] = 0;
}
}
std::map<string, int> funcCounts;
AZ::Debug::SymbolStorage::StackLine func, file, module;
int line;
void* baseAddr;
string funcName;
for (i = 0; i < m_rawSamples.size(); i++)
{
// lookup module name here, and aggregate the results
AZ::Debug::SymbolStorage::FindFunctionFromIP((void*)m_rawSamples[i], &func, &file, &module, line, baseAddr);
// Developer note: this file was using the module name instead of the function name. There was stub code
// to use the function name instead that. This function was updated to use FindFunctionFromIP(), but
// continues to use the module instead of the function.
funcName = module;
funcCounts[funcName] += 1;
}
{
// Combine function samples.
std::map<string, int>::iterator it;
for (it = funcCounts.begin(); it != funcCounts.end(); ++it)
{
SFunctionSample fs;
fs.function = it->first;
fs.nSamples = it->second;
m_functionSamples.push_back(fs);
}
}
// Sort vector by number of samples.
std::sort(m_functionSamples.begin(), m_functionSamples.end(), CompareFunctionSamples);
LogSampledData();
}
//////////////////////////////////////////////////////////////////////////
void CSampler::LogSampledData()
{
int nTotalSamples = m_rawSamples.size();
// Log sample info.
CryLogAlways("=========================================================================");
CryLogAlways("= Profiler Output");
CryLogAlways("=========================================================================");
float fOnePercent = (float)nTotalSamples / 100;
float fPercentTotal = 0;
int nSampleSum = 0;
for (uint32 i = 0; i < m_functionSamples.size(); i++)
{
// Calculate percentage.
float fPercent = m_functionSamples[i].nSamples / fOnePercent;
const char* func = m_functionSamples[i].function;
CryLogAlways("%6.2f%% (%4d samples) : %s", fPercent, m_functionSamples[i].nSamples, func);
fPercentTotal += fPercent;
nSampleSum += m_functionSamples[i].nSamples;
}
CryLogAlways("Samples: %d / %d (%.2f%%)", nSampleSum, nTotalSamples, fPercentTotal);
CryLogAlways("=========================================================================");
}
#endif // defined(WIN32)
-82
View File
@@ -1,82 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_SAMPLER_H
#define CRYINCLUDE_CRYSYSTEM_SAMPLER_H
#pragma once
#ifdef WIN32
class CSamplingThread;
//////////////////////////////////////////////////////////////////////////
// Sampler class is running a second thread which is at regular intervals
// eg 1ms samples main thread and stores current IP in the samples buffers.
// After sampling finishes it can resolve collected IP buffer info to
// the function names and calculated where most of the execution time spent.
//////////////////////////////////////////////////////////////////////////
class CSampler
{
public:
struct SFunctionSample
{
string function;
uint32 nSamples; // Number of samples per function.
};
CSampler();
~CSampler();
void Start();
void Stop();
void Update();
// Adds a new sample to the ip buffer, return false if no more samples can be added.
bool AddSample(uint64 ip);
void SetMaxSamples(int nMaxSamples);
int GetSamplePeriod() const { return m_samplePeriodMs; }
void SetSamplePeriod(int millis) { m_samplePeriodMs = millis; }
private:
void ProcessSampledData();
void LogSampledData();
// Buffer for IP samples.
std::vector<uint64> m_rawSamples;
std::vector<SFunctionSample> m_functionSamples;
int m_nMaxSamples;
bool m_bSampling;
bool m_bSamplingFinished;
int m_samplePeriodMs;
CSamplingThread* m_pSamplingThread;
};
#else //WIN32
// Dummy sampler.
class CSampler
{
public:
void Start() {}
void Stop() {}
void Update() {}
void SetMaxSamples(int) {}
void SetSamplePeriod(int) {}
};
#endif // WIN32
#endif // CRYINCLUDE_CRYSYSTEM_SAMPLER_H
@@ -1,85 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "ProjectDefines.h"
#if defined(MAP_LOADING_SLICING)
#include "ServerHandler.h"
ServerHandler::ServerHandler(const char* bucket, int affinity, int serverTimeout)
: HandlerBase(bucket, affinity)
{
m_serverTimeout = serverTimeout;
DoScan();
}
void ServerHandler::DoScan()
{
std::set<int> gotIndices;
for (int i = 0; i < m_srvLocks.size(); ++i)
{
gotIndices.insert(m_srvLocks[i]->number);
}
for (int i = 0; i < MAX_CLIENTS_NUM; ++i)
{
if (gotIndices.find(i) == gotIndices.end())
{
std::unique_ptr<SSyncLock> lock(new SSyncLock(m_clientLockName, i, false));
if (lock->IsValid())
{
std::unique_ptr<SSyncLock> srv(new SSyncLock(m_serverLockName, i, true));
if (srv->IsValid())
{
m_srvLocks.push_back(std::move(srv));
m_clientLocks.push_back(std::move(lock));
CryLogAlways("Client %d bound", i);
}
else
{
CryLogAlways("Failed to bind client %d", i);
}
}
}
}
if (!m_clientLocks.empty())
{
SetAffinity();
}
m_lastScan = gEnv->pTimer->GetAsyncTime();
}
bool ServerHandler::Sync()
{
if ((gEnv->pTimer->GetAsyncTime() - m_lastScan).GetSeconds() > 1.0f)
{
DoScan();
}
for (int i = 0; i < m_srvLocks.size(); )
{
m_srvLocks[i]->Signal();
if (!m_clientLocks[i]->Wait(m_serverTimeout))//actually if not waited, let's kill it!
{
CryLogAlways("Dropped client %d", m_clientLocks[i]->number);
m_clientLocks[i]->Own(m_clientLockName);
m_clientLocks.erase(m_clientLocks.begin() + i);
m_srvLocks.erase(m_srvLocks.begin() + i);
continue;
}
++i;
}
return false;//!m_clientLocks.empty();
}
#endif // defined(MAP_LOADING_SLICING)
-36
View File
@@ -1,36 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_SERVERHANDLER_H
#define CRYINCLUDE_CRYSYSTEM_SERVERHANDLER_H
#pragma once
#include "HandlerBase.h"
#include "SyncLock.h"
struct ServerHandler
: public HandlerBase
{
ServerHandler(const char* bucket, int affinity, int serverTimeout);
void DoScan();
bool Sync();
private:
int m_serverTimeout;
std::vector<std::unique_ptr<SSyncLock> > m_clientLocks;
std::vector<std::unique_ptr<SSyncLock> > m_srvLocks;
CTimeValue m_lastScan;
};
#endif // CRYINCLUDE_CRYSYSTEM_SERVERHANDLER_H
-164
View File
@@ -1,164 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "ServerThrottle.h"
#include "TimeValue.h"
#include "ISystem.h"
#include "ITimer.h"
#include "IConsole.h"
#if defined(WIN32)
static float ftdiff(const FILETIME& b, const FILETIME& a)
{
uint64 aa = *reinterpret_cast<const uint64*>(&a);
uint64 bb = *reinterpret_cast<const uint64*>(&b);
return (bb - aa) * 1e-7f;
}
class CCPUMonitor
{
public:
CCPUMonitor(ISystem* pSystem, int nCPUs)
: m_lastUpdate(0.0f)
, m_pTimer(pSystem->GetITimer())
, m_nCPUs(nCPUs)
{
FILETIME notNeeded;
GetProcessTimes(GetCurrentProcess(), &notNeeded, &notNeeded, &m_lastKernel, &m_lastUser);
}
float* Update()
{
CTimeValue frameTime = gEnv->pTimer->GetFrameStartTime();
if (frameTime - m_lastUpdate > 5.0f)
{
m_lastUpdate = frameTime;
static float result = 0.0f;
FILETIME kernel, user, cur;
FILETIME notNeeded;
GetSystemTimeAsFileTime(&cur);
GetProcessTimes(GetCurrentProcess(), &notNeeded, &notNeeded, &kernel, &user);
float sKernel = ftdiff(kernel, m_lastKernel);
float sUser = ftdiff(user, m_lastUser);
float sCur = ftdiff(cur, m_lastTime);
result = 100 * (sKernel + sUser) / sCur / m_nCPUs;
m_lastTime = cur;
m_lastKernel = kernel;
m_lastUser = user;
return &result;
}
return 0;
}
private:
ITimer* m_pTimer;
CTimeValue m_lastUpdate;
FILETIME m_lastKernel, m_lastUser, m_lastTime;
int m_nCPUs;
};
#else
class CCPUMonitor
{
public:
CCPUMonitor(ISystem*, int) {}
float* Update() { return 0; }
};
#endif
CServerThrottle::CServerThrottle(ISystem* pSys, int nCPUs)
{
m_pCPUMonitor.reset(new CCPUMonitor(pSys, nCPUs));
m_pDedicatedMaxRate = pSys->GetIConsole()->GetCVar("sv_DedicatedMaxRate");
m_pDedicatedCPU = pSys->GetIConsole()->GetCVar("sv_DedicatedCPUPercent");
m_pDedicatedCPUVariance = pSys->GetIConsole()->GetCVar("sv_DedicatedCPUVariance");
m_minFPS = 20;
m_maxFPS = 60;
m_nSteps = 8;
m_nCurStep = 0;
if (m_pDedicatedCPU->GetFVal() >= 1.0f)
{
SetStep(m_nSteps / 2, 0);
}
}
CServerThrottle::~CServerThrottle()
{
}
void CServerThrottle::Update()
{
float tgtCPU = m_pDedicatedCPU->GetFVal();
if (tgtCPU < 1)
{
return;
}
if (float* pCPU = m_pCPUMonitor->Update())
{
float varCPU = m_pDedicatedCPUVariance->GetFVal();
if (tgtCPU < 5)
{
tgtCPU = 5;
}
else if (tgtCPU > 95)
{
tgtCPU = 95;
}
float minCPU = std::max(tgtCPU - varCPU, tgtCPU / 2.0f);
float maxCPU = std::min(tgtCPU + varCPU, (100.0f + tgtCPU) / 2.0f);
if (*pCPU > maxCPU)
{
SetStep(m_nCurStep - 1, pCPU);
}
else if (*pCPU < minCPU)
{
SetStep(m_nCurStep + 1, pCPU);
}
}
}
void CServerThrottle::SetStep(int step, float* pDueToCPU)
{
if (step < 0)
{
step = 0;
}
else if (step > m_nSteps)
{
step = m_nSteps;
}
if (step != m_nCurStep)
{
float fps = step * (m_maxFPS - m_minFPS) / m_nSteps + m_minFPS;
m_pDedicatedMaxRate->Set(fps);
if (pDueToCPU)
{
CryLog("ServerThrottle: Set framerate to %.1f fps [due to cpu being %d%%]", fps, int(*pDueToCPU + 0.5f));
}
else
{
CryLog("ServerThrottle: Set framerate to %.1f fps", fps);
}
m_nCurStep = step;
}
}
-48
View File
@@ -1,48 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Handle raising/lowering the frame rate on server
// based upon CPU usage
#ifndef CRYINCLUDE_CRYSYSTEM_SERVERTHROTTLE_H
#define CRYINCLUDE_CRYSYSTEM_SERVERTHROTTLE_H
#pragma once
struct ISystem;
class CCPUMonitor;
class CServerThrottle
{
public:
CServerThrottle(ISystem* pSys, int nCPUs);
~CServerThrottle();
void Update();
private:
std::unique_ptr<CCPUMonitor> m_pCPUMonitor;
void SetStep(int step, float* dueToCPU);
float m_minFPS;
float m_maxFPS;
int m_nSteps;
int m_nCurStep;
ICVar* m_pDedicatedMaxRate;
ICVar* m_pDedicatedCPU;
ICVar* m_pDedicatedCPUVariance;
};
#endif // CRYINCLUDE_CRYSYSTEM_SERVERTHROTTLE_H
-246
View File
@@ -1,246 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "CrySystem_precompiled.h"
#include "ProjectDefines.h"
#if defined(MAP_LOADING_SLICING)
#include "SyncLock.h"
SSyncLock::SSyncLock(const char* name, int id, bool own)
{
stack_string ss;
ss.Format("%s_%d", name, id);
Open(ss);
if (own)
{
if (!IsValid())
{
Create(ss);
number = id;
}
else
{
Close();
}
}
else
{
number = id;
}
}
SSyncLock::SSyncLock(const char* name, int minId, int maxId)
{
ev = 0;
stack_string ss;
for (int i = minId; i < maxId; ++i)
{
ss.Format("%s_%d", name, i);
if (Open(ss))
{
Close();
continue;
}
if (Create(ss))
{
number = i;
}
break;
}
}
SSyncLock::~SSyncLock()
{
Close();
}
void SSyncLock::Own(const char* name)
{
o_name.Format("%s_%d", name, number);
}
#if defined(LINUX) || defined(APPLE)
bool SSyncLock::Open(const char* name)
{
ev = sem_open(name, 0);
if (ev != SEM_FAILED)
{
CryLogAlways("Opened semaphore %p %s", ev, name);
}
return IsValid();
}
bool SSyncLock::Create(const char* name)
{
ev = sem_open(name, O_CREAT | O_EXCL, 0777, 0);
if (ev != SEM_FAILED)
{
CryLogAlways("Created semaphore %p %s", ev, name);
}
else
{
CryLogAlways("Failed to create semaphore %s %d", name, errno);
}
return IsValid();
}
void SSyncLock::Signal()
{
if (ev)
{
sem_post(ev);
}
}
bool SSyncLock::Wait(int ms)
{
if (!ev)
{
return false;
}
timespec t = { 0 };
#if defined(LINUX)
clock_gettime(CLOCK_REALTIME, &t);
#elif defined(APPLE)
// On OSX/iOS there is no sem_timedwait()
// We use repeated sem_trywait() instead
if (sem_trywait(ev) == 0)
{
return true;
}
#endif
static const long NANOSECS_IN_MSEC = 1000000L;
static const long NANOSECS_IN_SEC = 1000000000L;
t.tv_sec += ms / 1000;
t.tv_nsec += (ms % 1000) * NANOSECS_IN_MSEC;
if (t.tv_nsec > NANOSECS_IN_SEC)
{
t.tv_nsec -= NANOSECS_IN_SEC;
++t.tv_sec;
}
#if defined(LINUX)
return sem_timedwait(ev, &t) == 0; //ETIMEDOUT for timeout
#elif defined (APPLE)
// t = time left, interval = max time between tries, elapsed = actual time elapsed during a try
const int num_ms_interval = 50; // poll time, in ms
const timespec interval = { 0, NANOSECS_IN_MSEC * num_ms_interval };
while (t.tv_sec >= 0 || t.tv_nsec > interval.tv_nsec)
{
timespec remaining;
timespec elapsed = interval;
if (nanosleep(&interval, &remaining) == -1)
{
elapsed.tv_nsec -= remaining.tv_nsec;
}
t.tv_nsec -= elapsed.tv_nsec;
if (t.tv_nsec < 0L)
{
t.tv_nsec += NANOSECS_IN_SEC;
t.tv_sec -= 1;
}
if (sem_trywait(ev) == 0)
{
return true;
}
}
nanosleep(&t, NULL);
return sem_trywait(ev) == 0;
#else
#error Not implemented
#endif
}
void SSyncLock::Close()
{
if (ev)
{
sem_close(ev);
ev = nullptr;
if (!o_name.empty())
{
sem_unlink(o_name);
}
}
}
#else // defined(LINUX) || defined(APPLE)
bool SSyncLock::Open(const char* name)
{
ev = OpenEvent(SYNCHRONIZE, FALSE, name);
if (ev)
{
CryLogAlways("Opened event %p %s", ev, name);
}
return IsValid();
}
bool SSyncLock::Create(const char* name)
{
ev = CreateEvent(NULL, FALSE, FALSE, name);
if (ev)
{
CryLogAlways("Created event %p %s", ev, name);
}
else
{
CryLogAlways("Failed to create event %s", name);
}
return IsValid();
}
bool SSyncLock::Wait(int ms)
{
// CryLogAlways("Waiting %p", ev);
DWORD res = WaitForSingleObject(ev, ms);
if (res != WAIT_OBJECT_0)
{
CryLogAlways("WFS result %d", res);
}
return res == WAIT_OBJECT_0;
}
void SSyncLock::Signal()
{
//CryLogAlways("Signaled %p", ev);
if (!SetEvent(ev))
{
CryLogAlways("Error signalling!");
}
}
void SSyncLock::Close()
{
if (ev)
{
CryLogAlways("Closed event %p", ev);
CloseHandle(ev);
ev = 0;
}
}
#endif // defined(LINUX) || defined(APPLE)
bool SSyncLock::IsValid() const
{
return ev != 0;
}
#endif // defined(MAP_LOADING_SLICING)
-48
View File
@@ -1,48 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_CRYSYSTEM_SYNCLOCK_H
#define CRYINCLUDE_CRYSYSTEM_SYNCLOCK_H
#pragma once
#if defined(LINUX) || defined(APPLE)
#include <semaphore.h>
#endif
struct SSyncLock
{
#if defined(LINUX) || defined(APPLE)
typedef sem_t* HandleType;
#else
typedef HANDLE HandleType;
#endif
SSyncLock(const char* name, int id, bool own);
SSyncLock(const char* name, int minId, int maxId);
~SSyncLock();
void Own(const char* name);
bool Open(const char* name);
bool Create(const char* name);
void Signal();
bool Wait(int ms);
void Close();
bool IsValid() const;
HandleType ev;
int number;
string o_name;
};
#endif // CRYINCLUDE_CRYSYSTEM_SYNCLOCK_H

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