Fix building sfwl.

This commit is contained in:
Relintai 2024-01-20 12:47:33 +01:00
parent 13807c1292
commit a4b364ea3f
11 changed files with 38 additions and 4523 deletions

1
.gitignore vendored
View File

@ -35,4 +35,5 @@ game
game.exe
game-vc.*
vc140.pdb
sfwl_app

View File

@ -12,8 +12,8 @@ ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/safe_refcount.cpp -o sfwl/c
ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/ustring.cpp -o sfwl/core/ustring.o
ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/string_name.cpp -o sfwl/core/string_name.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfwl/core/rect2i.cpp -o sfwl/core/rect2i.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfwl/core/vector2i.cpp -o sfwl/core/vector2i.o
ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/rect2i.cpp -o sfwl/core/rect2i.o
ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/vector2i.cpp -o sfwl/core/vector2i.o
ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/file_access.cpp -o sfwl/core/file_access.o
ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/dir_access.cpp -o sfwl/core/dir_access.o

View File

@ -139,6 +139,10 @@ Vector2i Vector2i::linear_interpolate(const Vector2i &p_to, real_t p_weight) con
return res;
}
_FORCE_INLINE_ Vector2i operator*(int p_scalar, const Vector2i &p_vec) {
return p_vec * p_scalar;
}
typedef Vector2i Size2i;
typedef Vector2i Point2i;

View File

@ -9,17 +9,10 @@
/*************************************************************************/
//--STRIP
#include "core/aabb.h"
#include "core/math_defs.h"
#include "core/math_funcs.h"
#include "core/rect2.h"
#include "core/rect2i.h"
#include "core/vector2.h"
#include "core/vector2i.h"
#include "core/vector3.h"
#include "core/vector3i.h"
#include "core/vector4.h"
#include "core/vector4i.h"
#include "core/string_name.h"
#include "core/ustring.h"
#include "core/typedefs.h"
@ -314,37 +307,6 @@ struct HashMapHasherDefault {
h = hash_murmur3_one_32(p_vec.y, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Vector3i &p_vec) {
uint32_t h = hash_murmur3_one_32(p_vec.x);
h = hash_murmur3_one_32(p_vec.y, h);
h = hash_murmur3_one_32(p_vec.z, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Vector4i &p_vec) {
uint32_t h = hash_murmur3_one_32(p_vec.x);
h = hash_murmur3_one_32(p_vec.y, h);
h = hash_murmur3_one_32(p_vec.z, h);
h = hash_murmur3_one_32(p_vec.w, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Vector2 &p_vec) {
uint32_t h = hash_murmur3_one_real(p_vec.x);
h = hash_murmur3_one_real(p_vec.y, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Vector3 &p_vec) {
uint32_t h = hash_murmur3_one_real(p_vec.x);
h = hash_murmur3_one_real(p_vec.y, h);
h = hash_murmur3_one_real(p_vec.z, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Vector4 &p_vec) {
uint32_t h = hash_murmur3_one_real(p_vec.x);
h = hash_murmur3_one_real(p_vec.y, h);
h = hash_murmur3_one_real(p_vec.z, h);
h = hash_murmur3_one_real(p_vec.w, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Rect2i &p_rect) {
uint32_t h = hash_murmur3_one_32(p_rect.position.x);
h = hash_murmur3_one_32(p_rect.position.y, h);
@ -352,22 +314,6 @@ struct HashMapHasherDefault {
h = hash_murmur3_one_32(p_rect.size.y, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const Rect2 &p_rect) {
uint32_t h = hash_murmur3_one_real(p_rect.position.x);
h = hash_murmur3_one_real(p_rect.position.y, h);
h = hash_murmur3_one_real(p_rect.size.x, h);
h = hash_murmur3_one_real(p_rect.size.y, h);
return hash_fmix32(h);
}
static _FORCE_INLINE_ uint32_t hash(const AABB &p_aabb) {
uint32_t h = hash_murmur3_one_real(p_aabb.position.x);
h = hash_murmur3_one_real(p_aabb.position.y, h);
h = hash_murmur3_one_real(p_aabb.position.z, h);
h = hash_murmur3_one_real(p_aabb.size.x, h);
h = hash_murmur3_one_real(p_aabb.size.y, h);
h = hash_murmur3_one_real(p_aabb.size.z, h);
return hash_fmix32(h);
}
};
template <typename T>
@ -391,20 +337,6 @@ struct HashMapComparatorDefault<double> {
}
};
template <>
struct HashMapComparatorDefault<Vector2> {
static bool compare(const Vector2 &p_lhs, const Vector2 &p_rhs) {
return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y)));
}
};
template <>
struct HashMapComparatorDefault<Vector3> {
static bool compare(const Vector3 &p_lhs, const Vector3 &p_rhs) {
return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y))) && ((p_lhs.z == p_rhs.z) || (Math::is_nan(p_lhs.z) && Math::is_nan(p_rhs.z)));
}
};
constexpr uint32_t HASH_TABLE_SIZE_MAX = 29;
const uint32_t hash_table_size_primes[HASH_TABLE_SIZE_MAX] = {

View File

@ -4,7 +4,8 @@
/*************************************************************************/
//--STRIP
#include "core/transform_2d.h" // Includes rect2.h but Rect2 needs Transform2D
#include "core/rect2i.h"
#include "core/ustring.h"
//--STRIP
Rect2i::operator String() const {

View File

@ -10,7 +10,6 @@
//--STRIP
#include "core/vector2i.h" // also includes math_funcs and ustring
#include "core/rect2.h"
//--STRIP
struct _NO_DISCARD_CLASS_ Rect2i {
@ -64,8 +63,8 @@ struct _NO_DISCARD_CLASS_ Rect2i {
new_rect.position.x = MAX(p_rect.position.x, position.x);
new_rect.position.y = MAX(p_rect.position.y, position.y);
Point2 p_rect_end = p_rect.position + p_rect.size;
Point2 end = position + size;
Point2i p_rect_end = p_rect.position + p_rect.size;
Point2i end = position + size;
new_rect.size.x = (int)(MIN(p_rect_end.x, end.x) - new_rect.position.x);
new_rect.size.y = (int)(MIN(p_rect_end.y, end.y) - new_rect.position.y);
@ -213,21 +212,14 @@ struct _NO_DISCARD_CLASS_ Rect2i {
return position + size;
}
Rect2 to_rect2() const { return Rect2(position, size); }
operator String() const;
operator Rect2() const { return Rect2(position, size); }
Rect2i(const Rect2 &p_r2) :
position(p_r2.position),
size(p_r2.size) {
}
Rect2i() {}
Rect2i(int p_x, int p_y, int p_width, int p_height) :
position(Point2(p_x, p_y)),
size(Size2(p_width, p_height)) {
position(Point2i(p_x, p_y)),
size(Size2i(p_width, p_height)) {
}
Rect2i(const Point2 &p_pos, const Size2 &p_size) :
Rect2i(const Point2i &p_pos, const Size2i &p_size) :
position(p_pos),
size(p_size) {
}

View File

@ -11,8 +11,6 @@
//--STRIP
#include "core/error_macros.h"
#include "core/math_funcs.h"
#include "core/vector2.h"
//--STRIP
class String;
@ -88,8 +86,8 @@ struct _NO_DISCARD_CLASS_ Vector2i {
Vector2i operator-() const;
bool operator<(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
bool operator>(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y > p_vec2.y) : (x > p_vec2.x); }
bool operator<=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); }
bool operator>=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); }
bool operator<=(const Vector2i &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); }
bool operator>=(const Vector2i &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); }
bool operator==(const Vector2i &p_vec2) const;
bool operator!=(const Vector2i &p_vec2) const;
@ -102,14 +100,11 @@ struct _NO_DISCARD_CLASS_ Vector2i {
Vector2i abs() const { return Vector2i(ABS(x), ABS(y)); }
Vector2i clamp(const Vector2i &p_min, const Vector2i &p_max) const;
Vector2 to_vector2() const { return Vector2(x, y); }
operator String() const;
operator Vector2() const { return Vector2(x, y); }
inline Vector2i(const Vector2 &p_vec2) {
x = (int)p_vec2.x;
y = (int)p_vec2.y;
inline Vector2i(const Vector2i &p_vec2) {
x = p_vec2.x;
y = p_vec2.y;
}
inline Vector2i(int p_x, int p_y) {
x = p_x;
@ -131,12 +126,13 @@ Vector2i Vector2i::linear_interpolate(const Vector2i &p_a, const Vector2i &p_b,
}
Vector2i Vector2i::linear_interpolate(const Vector2i &p_to, real_t p_weight) const {
Vector2 res = *this;
real_t res_x = x;
real_t res_y = y;
res.x += (p_weight * (p_to.x - x));
res.y += (p_weight * (p_to.y - y));
res_x += (p_weight * (p_to.x - x));
res_y += (p_weight * (p_to.y - y));
return res;
return Vector2i(res_x, res_y);
}
typedef Vector2i Size2i;

View File

@ -1,9 +1,9 @@
//--STRIP
#ifndef SFW_VERSION_H
#define SFW_VERSION_H
#ifndef SFWL_VERSION_H
#define SFWL_VERSION_H
//--STRIP
#define SFW_VERSION 1
#define SFWL_VERSION 1
//--STRIP
#endif

File diff suppressed because it is too large Load Diff

View File

@ -9,21 +9,11 @@
/*************************************************************************/
//--STRIP
#include "core/aabb.h"
#include "core/basis.h"
#include "core/color.h"
#include "core/face3.h"
#include "core/plane.h"
#include "core/pool_vector.h"
#include "core/projection.h"
#include "core/quaternion.h"
#include "core/transform.h"
#include "core/transform_2d.h"
#include "core/ustring.h"
#include "core/vector3.h"
#include "core/vector3i.h"
#include "core/vector4.h"
#include "core/vector4i.h"
#include "core/vector2i.h"
#include "core/rect2i.h"
#include "object/array.h"
#include "object/dictionary.h"
#include "object/ref_ptr.h"
@ -37,12 +27,7 @@ typedef PoolVector<uint8_t> PoolByteArray;
typedef PoolVector<int> PoolIntArray;
typedef PoolVector<real_t> PoolRealArray;
typedef PoolVector<String> PoolStringArray;
typedef PoolVector<Vector2> PoolVector2Array;
typedef PoolVector<Vector2i> PoolVector2iArray;
typedef PoolVector<Vector3> PoolVector3Array;
typedef PoolVector<Vector3i> PoolVector3iArray;
typedef PoolVector<Vector4> PoolVector4Array;
typedef PoolVector<Vector4i> PoolVector4iArray;
typedef PoolVector<Color> PoolColorArray;
// Temporary workaround until c++11 alignas()
@ -73,22 +58,8 @@ public:
STRING,
// math types
RECT2,
RECT2I,
VECTOR2,
VECTOR2I,
VECTOR3,
VECTOR3I,
VECTOR4,
VECTOR4I,
PLANE,
QUATERNION,
AABB,
BASIS,
TRANSFORM,
TRANSFORM2D,
PROJECTION,
// misc types
COLOR,
@ -102,15 +73,10 @@ public:
POOL_INT_ARRAY,
POOL_REAL_ARRAY,
POOL_STRING_ARRAY,
POOL_VECTOR2_ARRAY,
POOL_VECTOR2I_ARRAY,
POOL_VECTOR3_ARRAY,
POOL_VECTOR3I_ARRAY,
POOL_VECTOR4_ARRAY,
POOL_VECTOR4I_ARRAY,
POOL_COLOR_ARRAY,
VARIANT_MAX // 38
VARIANT_MAX
};
@ -141,11 +107,6 @@ private:
bool _bool;
int64_t _int;
double _real;
Transform2D *_transform2d;
::AABB *_aabb;
Basis *_basis;
Transform *_transform;
Projection *_projection;
void *_ptr; //generic pointer
uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)];
} _data GCC_ALIGNED_8;
@ -190,21 +151,8 @@ public:
operator double() const;
operator String() const;
operator StringName() const;
operator Rect2() const;
operator Rect2i() const;
operator Vector2() const;
operator Vector2i() const;
operator Vector3() const;
operator Vector3i() const;
operator Vector4() const;
operator Vector4i() const;
operator Plane() const;
operator ::AABB() const;
operator Quaternion() const;
operator Basis() const;
operator Transform() const;
operator Transform2D() const;
operator Projection() const;
operator Color() const;
operator RefPtr() const;
@ -218,15 +166,8 @@ public:
operator PoolVector<int>() const;
operator PoolVector<real_t>() const;
operator PoolVector<String>() const;
operator PoolVector<Vector2>() const;
operator PoolVector<Vector2i>() const;
operator PoolVector<Vector3>() const;
operator PoolVector<Vector3i>() const;
operator PoolVector<Vector4>() const;
operator PoolVector<Vector4i>() const;
operator PoolVector<Color>() const;
operator PoolVector<Plane>() const;
operator PoolVector<Face3>() const;
operator Vector<Variant>() const;
operator Vector<uint8_t>() const;
@ -234,16 +175,9 @@ public:
operator Vector<real_t>() const;
operator Vector<String>() const;
operator Vector<StringName>() const;
operator Vector<Vector3>() const;
operator Vector<Vector3i>() const;
operator Vector<Vector4>() const;
operator Vector<Vector4i>() const;
operator Vector<Color>() const;
operator Vector<Vector2>() const;
operator Vector<Vector2i>() const;
operator Vector<Plane>() const;
// some core type enums to convert to
operator Margin() const;
operator Side() const;
@ -269,40 +203,20 @@ public:
Variant(const StringName &p_string);
Variant(const char *const p_cstring);
Variant(const CharType *p_wstring);
Variant(const Vector2 &p_vector2);
Variant(const Vector2i &p_vector2);
Variant(const Rect2 &p_rect2);
Variant(const Rect2i &p_rect2);
Variant(const Vector3 &p_vector3);
Variant(const Vector3i &p_vector3);
Variant(const Vector4 &p_vector4);
Variant(const Vector4i &p_vector4);
Variant(const Projection &p_projection);
Variant(const Plane &p_plane);
Variant(const ::AABB &p_aabb);
Variant(const Quaternion &p_quat);
Variant(const Basis &p_matrix);
Variant(const Transform2D &p_transform);
Variant(const Transform &p_transform);
Variant(const Color &p_color);
Variant(const RefPtr &p_resource);
Variant(const Object *p_object);
Variant(const Dictionary &p_dictionary);
Variant(const Array &p_array);
Variant(const PoolVector<Plane> &p_array);
Variant(const PoolVector<uint8_t> &p_raw_array);
Variant(const PoolVector<int> &p_int_array);
Variant(const PoolVector<real_t> &p_real_array);
Variant(const PoolVector<String> &p_string_array);
Variant(const PoolVector<Vector3> &p_vector3_array);
Variant(const PoolVector<Vector3i> &p_vector3_array);
Variant(const PoolVector<Color> &p_color_array);
Variant(const PoolVector<Face3> &p_face_array);
Variant(const PoolVector<Vector2> &p_vector2_array);
Variant(const PoolVector<Vector2i> &p_vector2_array);
Variant(const PoolVector<Vector4> &p_vector4_array);
Variant(const PoolVector<Vector4i> &p_vector4_array);
Variant(const Vector<Variant> &p_array);
Variant(const Vector<uint8_t> &p_array);
@ -310,14 +224,8 @@ public:
Variant(const Vector<real_t> &p_array);
Variant(const Vector<String> &p_array);
Variant(const Vector<StringName> &p_array);
Variant(const Vector<Vector3> &p_array);
Variant(const Vector<Vector3i> &p_array);
Variant(const Vector<Color> &p_array);
Variant(const Vector<Plane> &p_array);
Variant(const Vector<Vector2> &p_array);
Variant(const Vector<Vector2i> &p_array);
Variant(const Vector<Vector4> &p_array);
Variant(const Vector<Vector4i> &p_array);
// If this changes the table in variant_op must be updated
enum Operator {

File diff suppressed because it is too large Load Diff