Legacy code cleanup - part 3 (#3903)

* Legacy cleanup - part 3

Not much is left that can be easily removed,
so I think this will be last cleanup before the legacy functionality is replaced.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* fix windows build, remove a few more things, re-add one file

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove legacy RenderBus + more cleanups

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove MaterialOwnerBus.h

Clean-up in Cry_Matrix34/33

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
This commit is contained in:
Artur K
2021-09-07 20:14:16 +02:00
committed by GitHub
parent 4d5b047c1b
commit 2a2847b15d
161 changed files with 894 additions and 16076 deletions
+1 -187
View File
@@ -8,8 +8,6 @@
// Description : Common math class
#pragma once
//========================================================================================
@@ -18,7 +16,6 @@
#include "Cry_ValidNumber.h"
#include <CryEndian.h> // eLittleEndian
#include <CryHalf.inl>
//#include <MetaUtils.h>
#include <float.h>
///////////////////////////////////////////////////////////////////////////////
// Forward declarations //
@@ -27,8 +24,7 @@ template <typename F>
struct Vec2_tpl;
template <typename F>
struct Vec3_tpl;
template <typename F>
struct Vec4_tpl;
struct Vec4;
template <typename F>
struct Ang3_tpl;
@@ -38,14 +34,6 @@ template <typename F>
struct AngleAxis_tpl;
template <typename F>
struct Quat_tpl;
template <typename F>
struct QuatT_tpl;
template <typename F>
struct DualQuat_tpl;
template <typename F>
struct QuatTS_tpl;
template <typename F>
struct QuatTNS_tpl;
template <typename F>
struct Diag33_tpl;
@@ -94,14 +82,8 @@ const f32 gf_halfPI = f32(1.57079632679489661923132169163975144209858469968755);
#define TANGENT30_2 0.57735026918962576450914878050196f * 2 // 2*tan(30)
#define LN2 0.69314718055994530941723212145818f // ln(2)
ILINE f32 fsel(const f32 _a, const f32 _b, const f32 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f64 fsel(const f64 _a, const f64 _b, const f64 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f32 fself(const f32 _a, const f32 _b, const f32 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f32 fsels(const f32 _a, const f32 _b, const f32 _c) { return (_a < 0.0f) ? _c : _b; }
ILINE f32 fres(const f32 _a) { return 1.f / _a; }
template<class T>
ILINE T isel(int c, T a, T b) { return (c < 0) ? b : a; }
@@ -319,13 +301,6 @@ ILINE int64 pos_round(f64 f) { return int64(f + 0.5); }
ILINE int32 int_ceil(f32 f) { int32 i = int32(f); return (f > f32(i)) ? i + 1 : i; }
ILINE int64 int_ceil(f64 f) { int64 i = int64(f); return (f > f64(i)) ? i + 1 : i; }
ILINE float ufrac8_to_float(float u) { return u * (1.f / 255.f); }
ILINE float ifrac8_to_float(float i) { return i * (1.f / 127.f); }
ILINE uint8 float_to_ufrac8(float f) { int i = pos_round(f * 255.f); assert(i >= 0 && i < 256); return uint8(i); }
ILINE int8 float_to_ifrac8(float f) { int i = int_round(f * 127.f); assert(abs(i) <= 127); return int8(i); }
template<class F>
ILINE F sqr(const F& op) { return op * op; }
template<class F>
@@ -490,11 +465,8 @@ ILINE int64 iszero(long int x) { return -(x >> 63 ^ (x - 1) >> 63); }
#endif
ILINE float if_neg_else(float test, float val_neg, float val_nonneg) { return (float)fsel(test, val_nonneg, val_neg); }
ILINE float if_pos_else(float test, float val_pos, float val_nonpos) { return (float)fsel(-test, val_nonpos, val_pos); }
template<class F>
ILINE int32 inrange(F x, F end1, F end2) { return isneg(fabs_tpl(end1 + end2 - x * (F)2) - fabs_tpl(end1 - end2)); }
template<class F>
ILINE F cond_select(int32 bFirst, F op1, F op2) { F arg[2] = { op1, op2 }; return arg[bFirst ^ 1]; }
template<class F>
ILINE int32 idxmax3(const F* pdata)
@@ -510,56 +482,6 @@ ILINE int32 idxmax3(const Vec3_tpl<F>& vec)
imax |= isneg(vec[imax] - vec.z) << 1;
return imax & (2 | (imax >> 1 ^ 1));
}
template<class F>
ILINE int32 idxmin3(const F* pdata)
{
int32 imin = isneg(pdata[1] - pdata[0]);
imin |= isneg(pdata[2] - pdata[imin]) << 1;
return imin & (2 | (imin >> 1 ^ 1));
}
template<class F>
ILINE int32 idxmin3(const Vec3_tpl<F>& vec)
{
int32 imin = isneg(vec.y - vec.x);
imin |= isneg(vec.z - vec[imin]) << 1;
return imin & (2 | (imin >> 1 ^ 1));
}
// Approximation of exp(-x)
ILINE float approxExp(float x) { return fres(1.f + x); }
// Approximation of 1.f - exp(-x)
ILINE float approxOneExp(float x) { return x * fres(1.f + x); }
ILINE int ilog2(uint64 x) // if x==1<<i (i=0..63), returns i
{
#if defined(CRY_PLATFORM_X64)
# if defined(AZ_RESTRICTED_PLATFORM)
# include AZ_RESTRICTED_FILE(Cry_Math_h)
# endif
# if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
# undef AZ_RESTRICTED_SECTION_IMPLEMENTED
# elif defined(CRY_PLATFORM_LINUX)
# define HAS_BIT_SCAN_FORWARD64 0
# else
# define HAS_BIT_SCAN_FORWARD64 1
# endif
#endif
#if HAS_BIT_SCAN_FORWARD64
unsigned long i;
_BitScanForward64(&i, x);
return i;
#else
union
{
float f;
uint i;
} u;
u.f = (float)x;
return (u.i >> 23) - 127;
#endif
}
static int32 inc_mod3[] = {1, 2, 0}, dec_mod3[] = {2, 0, 1};
#ifdef PHYSICS_EXPORTS
@@ -596,114 +518,6 @@ enum type_identity
#include "Cry_Matrix34.h"
#include "Cry_Matrix44.h"
#include "Cry_Quat.h"
#include "Cry_HWVector3.h"
#include "Cry_HWMatrix.h"
//////////////////////////////////////////////////////////////////////////
/// This function relaxes a value (val) towards a desired value (to) whilst maintaining continuity
/// of val and its rate of change (valRate). timeDelta is the time between this call and the previous one.
/// The caller would normally keep val and valRate as working variables, and smoothTime is normally
/// a fixed parameter. The to/timeDelta values can change.
///
/// Implementation details:
///
/// This is a critically damped spring system. A linear spring is attached between "val" and "to" that
/// drags "val" to "to". At the same time a damper between the two removes oscillations; it's tweaked
/// so it doesn't dampen more than necessary. In combination this gives smooth ease-in and ease-out behavior.
///
/// smoothTime can be interpreted in a couple of ways:
/// - it's the "expected time to reach the target when at maximum velocity" (the target will, however, not be reached
/// in that time because the speed will decrease the closer it gets to the target)
/// - it's the 'lag time', how many seconds "val" lags behind "to". If your
/// target has a certain speed, the lag distance is simply the smoothTime times that speed.
/// - it's 2/omega, where omega is the spring's natural frequency (or less formally a measure of the spring stiffness)
///
/// The implementation is stable for varying timeDelta, but for performance reasons it uses a polynomial approximation
/// to the exponential function. The approximation works well (within 0.1% of accuracy) when smoothTime > 2*deltaTime,
/// which is usually the case. (but it might be troublesome when you want a stiff spring or have frame hikes!)
/// The implementation handles cases where smoothTime==0 separately and reliably. In that case the target will be
/// reached immediately, and valRate is updated appropriately.
///
/// Based on "Critically Damped Ease-In/Ease-Out Smoothing", Thomas Lowe, Game Programming Gems IV
///
template <typename T>
ILINE void SmoothCD(
T& val, ///< in/out: value to be smoothed
T& valRate, ///< in/out: rate of change of the value
const float timeDelta, ///< in: time interval
const T& to, ///< in: the target value
const float smoothTime) ///< in: timescale for smoothing
{
if (smoothTime > 0.0f)
{
const float omega = 2.0f / smoothTime;
const float x = omega * timeDelta;
const float exp = 1.0f / (1.0f + x + 0.48f * x * x + 0.235f * x * x * x);
const T change = (val - to);
const T temp = (T)((valRate + change * omega) * timeDelta);
valRate = (T)((valRate - temp * omega) * exp);
val = (T)(to + (change + temp) * exp);
}
else if (timeDelta > 0.0f)
{
valRate = (T)((to - val) / timeDelta);
val = to;
}
else
{
val = to;
T zeroizeAmount = valRate;
valRate -= zeroizeAmount; // zero it...
}
}
template <typename T>
ILINE void SmoothCDWithMaxRate(
T& val, ///< in/out: value to be smoothed
T& valRate, ///< in/out: rate of change of the value
const float timeDelta, ///< in: time interval
const T& to, ///< in: the target value
const float smoothTime, ///< in: timescale for smoothing
const T& maxValRate) ///< in: maximum allowed rate of change
{
if (smoothTime > 0.0f)
{
const float omega = 2.0f / smoothTime;
const float x = omega * timeDelta;
const float exp = 1.0f / (1.0f + x + 0.48f * x * x + 0.235f * x * x * x);
const T unclampedChange = val - to;
const T maxChange = maxValRate * smoothTime;
const T clampedChange = clamp_tpl<T>(unclampedChange, -maxChange, maxChange);
const T clampedTo = val - clampedChange;
const T temp = (T)((valRate + clampedChange * omega) * timeDelta);
valRate = (T)((valRate - temp * omega) * exp);
val = (T)(clampedTo + (clampedChange + temp) * exp);
}
else if (timeDelta > 0.0f)
{
const T unclampedRate = (T)((to - val) / timeDelta);
valRate = clamp_tpl<T>(unclampedRate, -maxValRate, maxValRate);
val += valRate * timeDelta;
}
else
{
val = to;
T zeroizeAmount = valRate;
valRate -= zeroizeAmount; // zero it...
}
}
// Smoothes linear blending into cubic (b-spline) with 0-derivatives
// near 0 and 1
inline f32 SmoothBlendValue (const f32 fBlend)
{
const f32 fBlendAdj = fBlend - 0.5f;
return (f32)fsel(-fBlend, 0.f, fsel(fBlend - 1.f, 1.f, 0.5f - 2.f * (fBlendAdj * fBlendAdj * fBlendAdj) + 1.5f * fBlendAdj));
}
// function for safe comparsion of floating point values
ILINE bool fcmp(f32 fA, f32 fB, f32 fEpsilon = FLT_EPSILON)