Include typedefs.h in defs.h.

This commit is contained in:
Relintai 2023-10-23 17:54:30 +02:00
parent 6ea7b53e5a
commit 3e2e07a056
5 changed files with 13 additions and 42 deletions

View File

@ -34,8 +34,6 @@
#include <algorithm> #include <algorithm>
bool AABB::intersects(const AABB &p_aabb) const { bool AABB::intersects(const AABB &p_aabb) const {
if (position.x >= (p_aabb.position.x + p_aabb.size.x)) if (position.x >= (p_aabb.position.x + p_aabb.size.x))
return false; return false;
@ -600,5 +598,3 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
AABB::operator String() const { AABB::operator String() const {
return String() + position + " - " + size; return String() + position + " - " + size;
} }

View File

@ -35,8 +35,6 @@
#include <algorithm> #include <algorithm>
const Basis Basis::IDENTITY = Basis(); const Basis Basis::IDENTITY = Basis();
const Basis Basis::FLIP_X = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1); const Basis Basis::FLIP_X = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1);
const Basis Basis::FLIP_Y = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1); const Basis Basis::FLIP_Y = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1);
@ -258,7 +256,7 @@ void Basis::set_euler_xyz(const Vector3 &p_euler) {
s = ::sin(p_euler.z); s = ::sin(p_euler.z);
Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0); Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
//optimizer will optimize away all this anyway // optimizer will optimize away all this anyway
*this = xmat * (ymat * zmat); *this = xmat * (ymat * zmat);
} }
@ -325,7 +323,7 @@ void Basis::set_euler_yxz(const Vector3 &p_euler) {
s = ::sin(p_euler.z); s = ::sin(p_euler.z);
Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0); Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
//optimizer will optimize away all this anyway // optimizer will optimize away all this anyway
*this = ymat * xmat * zmat; *this = ymat * xmat * zmat;
} }
@ -599,7 +597,7 @@ static const Basis _ortho_bases[24] = {
}; };
int Basis::get_orthogonal_index() const { int Basis::get_orthogonal_index() const {
//could be sped up if i come up with a way // could be sped up if i come up with a way
Basis orth = *this; Basis orth = *this;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
@ -624,7 +622,7 @@ int Basis::get_orthogonal_index() const {
} }
void Basis::set_orthogonal_index(int p_index) { void Basis::set_orthogonal_index(int p_index) {
//there only exist 24 orthogonal bases in r3 // there only exist 24 orthogonal bases in r3
ERR_FAIL_COND(p_index >= 24); ERR_FAIL_COND(p_index >= 24);
*this = _ortho_bases[p_index]; *this = _ortho_bases[p_index];
@ -634,12 +632,8 @@ Basis::Basis(const Vector3 &p_euler) {
set_euler(p_euler); set_euler(p_euler);
} }
#include "quaternion.h" #include "quaternion.h"
Basis::Basis(const Quaternion &p_quaternion) { Basis::Basis(const Quaternion &p_quaternion) {
real_t d = p_quaternion.length_squared(); real_t d = p_quaternion.length_squared();
real_t s = 2.0 / d; real_t s = 2.0 / d;
@ -674,8 +668,8 @@ Basis::Basis(const Vector3 &p_axis, real_t p_phi) {
} }
Basis::operator Quaternion() const { Basis::operator Quaternion() const {
//commenting this check because precision issues cause it to fail when it shouldn't // commenting this check because precision issues cause it to fail when it shouldn't
//ERR_FAIL_COND_V(is_rotation() == false, Quaternion()); // ERR_FAIL_COND_V(is_rotation() == false, Quaternion());
real_t trace = elements[0][0] + elements[1][1] + elements[2][2]; real_t trace = elements[0][0] + elements[1][1] + elements[2][2];
real_t temp[4]; real_t temp[4];
@ -690,8 +684,8 @@ Basis::operator Quaternion() const {
temp[2] = ((elements[1][0] - elements[0][1]) * s); temp[2] = ((elements[1][0] - elements[0][1]) * s);
} else { } else {
int i = elements[0][0] < elements[1][1] ? int i = elements[0][0] < elements[1][1] ?
(elements[1][1] < elements[2][2] ? 2 : 1) : (elements[1][1] < elements[2][2] ? 2 : 1) :
(elements[0][0] < elements[2][2] ? 2 : 0); (elements[0][0] < elements[2][2] ? 2 : 0);
int j = (i + 1) % 3; int j = (i + 1) % 3;
int k = (i + 2) % 3; int k = (i + 2) % 3;
@ -706,5 +700,3 @@ Basis::operator Quaternion() const {
return Quaternion(temp[0], temp[1], temp[2], temp[3]); return Quaternion(temp[0], temp[1], temp[2], temp[3]);
} }

View File

@ -35,11 +35,6 @@
#include <gdn/color.h> #include <gdn/color.h>
#include <cmath> #include <cmath>
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
static String _to_hex(float p_val); static String _to_hex(float p_val);
static float _parse_col(const String &p_str, int p_ofs) { static float _parse_col(const String &p_str, int p_ofs) {
@ -651,5 +646,3 @@ Color Color::operator-() const {
1.0 - b, 1.0 - b,
1.0 - a); 1.0 - a);
} }

View File

@ -1,3 +1,6 @@
#ifndef DEFS_H
#define DEFS_H
/*************************************************************************/ /*************************************************************************/
/* defs.h */ /* defs.h */
/*************************************************************************/ /*************************************************************************/
@ -28,11 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef DEFS_H
#define DEFS_H
enum class Error { enum class Error {
OK, OK,
FAILED, ///< Generic fail error FAILED, ///< Generic fail error
@ -85,8 +83,6 @@ enum class Error {
ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
}; };
#include <pandemonium_global.h> #include <pandemonium_global.h>
// alloca() is non-standard. When using MSVC, it's in malloc.h. // alloca() is non-standard. When using MSVC, it's in malloc.h.
@ -119,6 +115,8 @@ typedef float real_t;
#define unlikely(x) x #define unlikely(x) x
#endif #endif
#include "typedefs.h"
// Don't use this directly; instead, use any of the CRASH_* macros // Don't use this directly; instead, use any of the CRASH_* macros
#ifdef _MSC_VER #ifdef _MSC_VER
#define GENERATE_TRAP \ #define GENERATE_TRAP \

View File

@ -343,14 +343,6 @@ struct _GlobalLock {
#define __STRX(m_index) #m_index #define __STRX(m_index) #m_index
#define __STR(m_index) __STRX(m_index) #define __STR(m_index) __STRX(m_index)
#ifdef __GNUC__
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define likely(x) x
#define unlikely(x) x
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
#define _PRINTF_FORMAT_ATTRIBUTE_2_0 __attribute__((format(printf, 2, 0))) #define _PRINTF_FORMAT_ATTRIBUTE_2_0 __attribute__((format(printf, 2, 0)))
#define _PRINTF_FORMAT_ATTRIBUTE_2_3 __attribute__((format(printf, 2, 3))) #define _PRINTF_FORMAT_ATTRIBUTE_2_3 __attribute__((format(printf, 2, 3)))