Codestyle.

This commit is contained in:
Relintai 2023-10-23 19:24:53 +02:00
parent 0a7e5d0f4a
commit 990db21277
45 changed files with 115 additions and 238 deletions

View File

@ -30,13 +30,11 @@
#include "array.h" #include "array.h"
#include "pandemonium_global.h" #include "pandemonium_global.h"
#include "variant.h"
#include "ustring.h" #include "ustring.h"
#include "variant.h"
#include <cstdlib> #include <cstdlib>
class Object; class Object;
Array::Array() { Array::Array() {
@ -223,5 +221,3 @@ void Array::shuffle() {
Array::~Array() { Array::~Array() {
Pandemonium::api->pandemonium_array_destroy(&_pandemonium_array); Pandemonium::api->pandemonium_array_destroy(&_pandemonium_array);
} }

View File

@ -1,3 +1,8 @@
#ifndef ARRAY_H
#define ARRAY_H
#include <gdn/array.h>
/*************************************************************************/ /*************************************************************************/
/* array.h */ /* array.h */
/*************************************************************************/ /*************************************************************************/
@ -28,13 +33,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef ARRAY_H
#define ARRAY_H
#include <gdn/array.h>
class String; class String;
namespace helpers { namespace helpers {
@ -186,6 +184,4 @@ public:
~Array(); ~Array();
}; };
#endif // ARRAY_H #endif // ARRAY_H

View File

@ -1,3 +1,6 @@
#ifndef BASIS_H
#define BASIS_H
/*************************************************************************/ /*************************************************************************/
/* basis.h */ /* basis.h */
/*************************************************************************/ /*************************************************************************/
@ -28,17 +31,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef BASIS_H
#define BASIS_H
#include <gdn/basis.h> #include <gdn/basis.h>
#include "defs.h" #include "defs.h"
#include "vector3.h" #include "vector3.h"
class Quaternion; class Quaternion;
class Basis { class Basis {
@ -453,6 +451,4 @@ public:
operator Quaternion() const; operator Quaternion() const;
}; };
#endif // BASIS_H #endif // BASIS_H

View File

@ -1,3 +1,6 @@
#ifndef COLOR_H
#define COLOR_H
/*************************************************************************/ /*************************************************************************/
/* color.h */ /* color.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef COLOR_H
#define COLOR_H
#include <gdn/color.h> #include <gdn/color.h>
#include <cmath> #include <cmath>
@ -38,8 +38,6 @@
#include "defs.h" #include "defs.h"
#include "ustring.h" #include "ustring.h"
struct Color { struct Color {
private: private:
// static float _parse_col(const String& p_str, int p_ofs); // static float _parse_col(const String& p_str, int p_ofs);
@ -141,7 +139,7 @@ public:
String to_html(bool p_alpha = true) const; String to_html(bool p_alpha = true) const;
bool operator<(const Color &p_color) const; //used in set keys bool operator<(const Color &p_color) const; // used in set keys
operator String() const; operator String() const;
@ -166,6 +164,4 @@ public:
} }
}; };
#endif // COLOR_H #endif // COLOR_H

View File

@ -1,3 +1,6 @@
#ifndef CORETYPES_H
#define CORETYPES_H
/*************************************************************************/ /*************************************************************************/
/* core_types.h */ /* core_types.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef CORETYPES_H
#define CORETYPES_H
#include "defs.h" #include "defs.h"
#include "aabb.h" #include "aabb.h"
@ -41,15 +41,15 @@
#include "node_path.h" #include "node_path.h"
#include "plane.h" #include "plane.h"
#include "pool_arrays.h" #include "pool_arrays.h"
#include "projection.h"
#include "quaternion.h" #include "quaternion.h"
#include "rid.h"
#include "rect2.h" #include "rect2.h"
#include "rect2i.h" #include "rect2i.h"
#include "ustring.h" #include "rid.h"
#include "string_name.h" #include "string_name.h"
#include "transform.h" #include "transform.h"
#include "transform_2d.h" #include "transform_2d.h"
#include "projection.h" #include "ustring.h"
#include "variant.h" #include "variant.h"
#include "vector2.h" #include "vector2.h"
#include "vector2i.h" #include "vector2i.h"

View File

@ -33,8 +33,6 @@
#include "pandemonium_global.h" #include "pandemonium_global.h"
#include "variant.h" #include "variant.h"
Dictionary::Dictionary() { Dictionary::Dictionary() {
Pandemonium::api->pandemonium_dictionary_new(&_pandemonium_dictionary); Pandemonium::api->pandemonium_dictionary_new(&_pandemonium_dictionary);
} }
@ -106,5 +104,3 @@ Array Dictionary::values() const {
Dictionary::~Dictionary() { Dictionary::~Dictionary() {
Pandemonium::api->pandemonium_dictionary_destroy(&_pandemonium_dictionary); Pandemonium::api->pandemonium_dictionary_destroy(&_pandemonium_dictionary);
} }

View File

@ -1,3 +1,6 @@
#ifndef DICTIONARY_H
#define DICTIONARY_H
/*************************************************************************/ /*************************************************************************/
/* dictionary.h */ /* dictionary.h */
/*************************************************************************/ /*************************************************************************/
@ -28,16 +31,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef DICTIONARY_H
#define DICTIONARY_H
#include "array.h" #include "array.h"
#include "variant.h" #include "variant.h"
#include <gdn/dictionary.h> #include <gdn/dictionary.h>
class Variant; class Variant;
class Dictionary { class Dictionary {
@ -85,6 +83,4 @@ public:
~Dictionary(); ~Dictionary();
}; };
#endif // DICTIONARY_H #endif // DICTIONARY_H

View File

@ -1,3 +1,6 @@
#ifndef PANDEMONIUM_MATH_H
#define PANDEMONIUM_MATH_H
/*************************************************************************/ /*************************************************************************/
/* Math.h */ /* Math.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef PANDEMONIUM_MATH_H
#define PANDEMONIUM_MATH_H
#include "defs.h" #include "defs.h"
#include <float.h> #include <float.h>

View File

@ -1,3 +1,6 @@
#ifndef PANDEMONIUM_H
#define PANDEMONIUM_H
/*************************************************************************/ /*************************************************************************/
/* Pandemonium.h */ /* Pandemonium.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef PANDEMONIUM_H
#define PANDEMONIUM_H
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>

View File

@ -30,8 +30,8 @@
#include "pandemonium_global.h" #include "pandemonium_global.h"
#include "ustring.h"
#include "array.h" #include "array.h"
#include "ustring.h"
#include "wrapped.h" #include "wrapped.h"
@ -51,8 +51,6 @@ static GDCALLINGCONV void wrapper_destroy(void *data, void *wrapper) {
Pandemonium::api->pandemonium_free(wrapper); Pandemonium::api->pandemonium_free(wrapper);
} }
void *_RegisterState::nativescript_handle; void *_RegisterState::nativescript_handle;
int _RegisterState::language_index; int _RegisterState::language_index;
@ -203,5 +201,3 @@ void Pandemonium::nativescript_init(void *handle) {
void Pandemonium::nativescript_terminate(void *handle) { void Pandemonium::nativescript_terminate(void *handle) {
Pandemonium::nativescript_api->pandemonium_nativescript_unregister_instance_binding_data_functions(_RegisterState::language_index); Pandemonium::nativescript_api->pandemonium_nativescript_unregister_instance_binding_data_functions(_RegisterState::language_index);
} }

View File

@ -1,3 +1,6 @@
#ifndef PANDEMONIUM_GLOBAL_H
#define PANDEMONIUM_GLOBAL_H
/*************************************************************************/ /*************************************************************************/
/* pandemonium_global.h */ /* pandemonium_global.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef PANDEMONIUM_GLOBAL_H
#define PANDEMONIUM_GLOBAL_H
#include <gdnative_api_struct.gen.h> #include <gdnative_api_struct.gen.h>
#include "array.h" #include "array.h"

View File

@ -5,8 +5,6 @@
#include <cstdio> #include <cstdio>
FunctionProfiling::FunctionProfiling(const char *p_function, const int p_line) { FunctionProfiling::FunctionProfiling(const char *p_function, const int p_line) {
snprintf(signature, 1024, "::%d::%s", p_line, p_function); snprintf(signature, 1024, "::%d::%s", p_line, p_function);
ticks = OS::get_singleton()->get_ticks_usec(); ticks = OS::get_singleton()->get_ticks_usec();
@ -18,4 +16,3 @@ FunctionProfiling::~FunctionProfiling() {
Pandemonium::gdnative_profiling_add_data(signature, t); Pandemonium::gdnative_profiling_add_data(signature, t);
} }
} }

View File

@ -1,3 +1,6 @@
#ifndef PANDEMONIUM_PROFILING_H
#define PANDEMONIUM_PROFILING_H
/*************************************************************************/ /*************************************************************************/
/* pandemonium_profiling.h */ /* pandemonium_profiling.h */
/*************************************************************************/ /*************************************************************************/
@ -28,13 +31,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef PANDEMONIUM_PROFILING_H
#define PANDEMONIUM_PROFILING_H
#include "defs.h" #include "defs.h"
class FunctionProfiling { class FunctionProfiling {
char signature[1024]; char signature[1024];
uint64_t ticks; uint64_t ticks;
@ -44,8 +42,6 @@ public:
~FunctionProfiling(); ~FunctionProfiling();
}; };
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
#define PANDEMONIUM_PROFILING_FUNCTION FunctionProfiling __function_profiling(__FUNCTION__, __LINE__); #define PANDEMONIUM_PROFILING_FUNCTION FunctionProfiling __function_profiling(__FUNCTION__, __LINE__);
#else #else

View File

@ -34,8 +34,6 @@
#include <cmath> #include <cmath>
void Plane::set_normal(const Vector3 &p_normal) { void Plane::set_normal(const Vector3 &p_normal) {
this->normal = p_normal; this->normal = p_normal;
} }
@ -107,15 +105,15 @@ bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersectio
Vector3 segment = p_dir; Vector3 segment = p_dir;
real_t den = normal.dot(segment); real_t den = normal.dot(segment);
//printf("den is %i\n",den); // printf("den is %i\n",den);
if (::fabs(den) <= CMP_EPSILON) { if (::fabs(den) <= CMP_EPSILON) {
return false; return false;
} }
real_t dist = (normal.dot(p_from) - d) / den; real_t dist = (normal.dot(p_from) - d) / den;
//printf("dist is %i\n",dist); // printf("dist is %i\n",dist);
if (dist > CMP_EPSILON) { //this is a ray, before the emiting pos (p_from) doesnt exist if (dist > CMP_EPSILON) { // this is a ray, before the emiting pos (p_from) doesnt exist
return false; return false;
} }
@ -130,13 +128,13 @@ bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_inters
Vector3 segment = p_begin - p_end; Vector3 segment = p_begin - p_end;
real_t den = normal.dot(segment); real_t den = normal.dot(segment);
//printf("den is %i\n",den); // printf("den is %i\n",den);
if (::fabs(den) <= CMP_EPSILON) { if (::fabs(den) <= CMP_EPSILON) {
return false; return false;
} }
real_t dist = (normal.dot(p_begin) - d) / den; real_t dist = (normal.dot(p_begin) - d) / den;
//printf("dist is %i\n",dist); // printf("dist is %i\n",dist);
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) { if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
return false; return false;
@ -200,5 +198,3 @@ bool Plane::operator==(const Plane &p_plane) const {
bool Plane::operator!=(const Plane &p_plane) const { bool Plane::operator!=(const Plane &p_plane) const {
return normal != p_plane.normal || d != p_plane.d; return normal != p_plane.normal || d != p_plane.d;
} }

View File

@ -1,3 +1,6 @@
#ifndef PLANE_H
#define PLANE_H
/*************************************************************************/ /*************************************************************************/
/* Plane.h */ /* Plane.h */
/*************************************************************************/ /*************************************************************************/
@ -28,15 +31,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef PLANE_H
#define PLANE_H
#include "vector3.h" #include "vector3.h"
#include <cmath> #include <cmath>
enum ClockDirection { enum ClockDirection {
CLOCKWISE, CLOCKWISE,
@ -50,7 +48,7 @@ public:
void set_normal(const Vector3 &p_normal); void set_normal(const Vector3 &p_normal);
inline Vector3 get_normal() const { return normal; } ///Point is coplanar, CMP_EPSILON for precision inline Vector3 get_normal() const { return normal; } /// Point is coplanar, CMP_EPSILON for precision
void normalize(); void normalize();
@ -93,6 +91,4 @@ public:
Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir = CLOCKWISE); Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir = CLOCKWISE);
}; };
#endif // PLANE_H #endif // PLANE_H

View File

@ -39,8 +39,6 @@
#include <gdn/pool_arrays.h> #include <gdn/pool_arrays.h>
PoolByteArray::PoolByteArray() { PoolByteArray::PoolByteArray() {
Pandemonium::api->pandemonium_pool_byte_array_new(&_pandemonium_array); Pandemonium::api->pandemonium_pool_byte_array_new(&_pandemonium_array);
} }
@ -644,5 +642,3 @@ int PoolColorArray::size() const {
PoolColorArray::~PoolColorArray() { PoolColorArray::~PoolColorArray() {
Pandemonium::api->pandemonium_pool_color_array_destroy(&_pandemonium_array); Pandemonium::api->pandemonium_pool_color_array_destroy(&_pandemonium_array);
} }

View File

@ -1,3 +1,6 @@
#ifndef POOLARRAYS_H
#define POOLARRAYS_H
/*************************************************************************/ /*************************************************************************/
/* PoolArrays.h */ /* PoolArrays.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef POOLARRAYS_H
#define POOLARRAYS_H
#include "defs.h" #include "defs.h"
#include "color.h" #include "color.h"
@ -42,8 +42,6 @@
#include <gdn/pool_arrays.h> #include <gdn/pool_arrays.h>
class Array; class Array;
class PoolByteArray { class PoolByteArray {
@ -864,6 +862,4 @@ public:
~PoolColorArray(); ~PoolColorArray();
}; };
#endif // POOLARRAYS_H #endif // POOLARRAYS_H

View File

@ -1,3 +1,6 @@
#ifndef PROJECTION_H
#define PROJECTION_H
/*************************************************************************/ /*************************************************************************/
/* Projection.h */ /* Projection.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef CAMERA_MATRIX_H
#define CAMERA_MATRIX_H
#include "defs.h" #include "defs.h"
#include "math_funcs.h" #include "math_funcs.h"
#include "plane.h" #include "plane.h"

View File

@ -35,8 +35,6 @@
#include <cmath> #include <cmath>
const Quaternion Quaternion::IDENTITY = Quaternion(); const Quaternion Quaternion::IDENTITY = Quaternion();
// set_euler_xyz expects a vector containing the Euler angles in the format // set_euler_xyz expects a vector containing the Euler angles in the format
@ -192,7 +190,7 @@ Quaternion Quaternion::slerpni(const Quaternion &q, const real_t &t) const {
} }
Quaternion Quaternion::cubic_slerp(const Quaternion &q, const Quaternion &prep, const Quaternion &postq, const real_t &t) const { Quaternion Quaternion::cubic_slerp(const Quaternion &q, const Quaternion &prep, const Quaternion &postq, const real_t &t) const {
//the only way to do slerp :| // the only way to do slerp :|
real_t t2 = (1.0 - t) * t * 2; real_t t2 = (1.0 - t) * t * 2;
Quaternion sp = this->slerp(q, t); Quaternion sp = this->slerp(q, t);
Quaternion sq = prep.slerpni(postq, t); Quaternion sq = prep.slerpni(postq, t);
@ -348,5 +346,3 @@ bool Quaternion::operator==(const Quaternion &p_quaternion) const {
bool Quaternion::operator!=(const Quaternion &p_quaternion) const { bool Quaternion::operator!=(const Quaternion &p_quaternion) const {
return x != p_quaternion.x || y != p_quaternion.y || z != p_quaternion.z || w != p_quaternion.w; return x != p_quaternion.x || y != p_quaternion.y || z != p_quaternion.z || w != p_quaternion.w;
} }

View File

@ -1,3 +1,6 @@
#ifndef QUATERNION_H
#define QUATERNION_H
/*************************************************************************/ /*************************************************************************/
/* Quaternion.h */ /* Quaternion.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef QUATERNION_H
#define QUATERNION_H
#include <cmath> #include <cmath>
#include "vector3.h" #include "vector3.h"

View File

@ -29,14 +29,12 @@
/*************************************************************************/ /*************************************************************************/
#include "rect2.h" #include "rect2.h"
#include "ustring.h"
#include "transform_2d.h" #include "transform_2d.h"
#include "ustring.h"
#include "vector2.h" #include "vector2.h"
#include <cmath> #include <cmath>
#ifndef MAX #ifndef MAX
#define MAX(a, b) (a > b ? a : b) #define MAX(a, b) (a > b ? a : b)
#endif #endif
@ -106,7 +104,7 @@ Rect2 Rect2::merge(const Rect2 &p_rect) const { ///< return a merged rect
new_rect.size.x = MAX(p_rect.position.x + p_rect.size.x, position.x + size.x); new_rect.size.x = MAX(p_rect.position.x + p_rect.size.x, position.x + size.x);
new_rect.size.y = MAX(p_rect.position.y + p_rect.size.y, position.y + size.y); new_rect.size.y = MAX(p_rect.position.y + p_rect.size.y, position.y + size.y);
new_rect.size = new_rect.size - new_rect.position; //make relative again new_rect.size = new_rect.size - new_rect.position; // make relative again
return new_rect; return new_rect;
} }
@ -171,7 +169,7 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
} }
bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const { bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const {
//SAT intersection between local and transformed rect2 // SAT intersection between local and transformed rect2
Vector2 xf_points[4] = { Vector2 xf_points[4] = {
p_xform.xform(p_rect.position), p_xform.xform(p_rect.position),
@ -182,7 +180,7 @@ bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_re
real_t low_limit; real_t low_limit;
//base rect2 first (faster) // base rect2 first (faster)
if (xf_points[0].y > position.y) if (xf_points[0].y > position.y)
goto next1; goto next1;
@ -319,5 +317,3 @@ next4:
return true; return true;
} }

View File

@ -1,3 +1,6 @@
#ifndef RECT2_H
#define RECT2_H
/*************************************************************************/ /*************************************************************************/
/* Rect2.h */ /* Rect2.h */
/*************************************************************************/ /*************************************************************************/
@ -28,17 +31,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef RECT2_H
#define RECT2_H
#include "vector2.h" #include "vector2.h"
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
class String; class String;
typedef Vector2 Size2; typedef Vector2 Size2;
@ -123,7 +121,7 @@ struct Rect2 {
return r; return r;
} }
inline void expand_to(const Vector2 &p_vector) { //in place function for speed inline void expand_to(const Vector2 &p_vector) { // in place function for speed
Vector2 begin = position; Vector2 begin = position;
Vector2 end = position + size; Vector2 end = position + size;
@ -155,6 +153,4 @@ struct Rect2 {
} }
}; };
#endif // RECT2_H #endif // RECT2_H

View File

@ -32,10 +32,6 @@
#include "ustring.h" #include "ustring.h"
#include "vector2i.h" #include "vector2i.h"
Rect2i::operator String() const { Rect2i::operator String() const {
return String(position) + ", " + String(size); return String(position) + ", " + String(size);
} }

View File

@ -1,3 +1,6 @@
#ifndef REF_H
#define REF_H
/*************************************************************************/ /*************************************************************************/
/* Ref.h */ /* Ref.h */
/*************************************************************************/ /*************************************************************************/
@ -28,15 +31,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef REF_H
#define REF_H
#include "pandemonium_global.h" #include "pandemonium_global.h"
#include "reference.h" #include "reference.h"
#include "variant.h" #include "variant.h"
// Replicates Pandemonium's Ref<T> behavior // Replicates Pandemonium's Ref<T> behavior
// Rewritten from f5234e70be7dec4930c2d5a0e829ff480d044b1d. // Rewritten from f5234e70be7dec4930c2d5a0e829ff480d044b1d.
template <class T> template <class T>
@ -178,19 +176,19 @@ public:
inline bool is_null() const { return reference == nullptr; } inline bool is_null() const { return reference == nullptr; }
void unref() { void unref() {
//TODO this should be moved to mutexes, since this engine does not really // TODO this should be moved to mutexes, since this engine does not really
// do a lot of referencing on references and stuff // do a lot of referencing on references and stuff
// mutexes will avoid more crashes? // mutexes will avoid more crashes?
if (reference && reference->unreference()) { if (reference && reference->unreference()) {
//memdelete(reference); // memdelete(reference);
reference->free(); reference->free();
} }
reference = nullptr; reference = nullptr;
} }
void instance() { void instance() {
//ref(memnew(T)); // ref(memnew(T));
ref(T::_new()); ref(T::_new());
} }
@ -211,6 +209,4 @@ public:
} }
}; };
#endif #endif

View File

@ -34,8 +34,6 @@
#include "pandemonium_global.h" #include "pandemonium_global.h"
RID::RID() { RID::RID() {
Pandemonium::api->pandemonium_rid_new(&_pandemonium_rid); Pandemonium::api->pandemonium_rid_new(&_pandemonium_rid);
} }
@ -75,5 +73,3 @@ bool RID::operator<=(const RID &p_other) const {
bool RID::operator>=(const RID &p_other) const { bool RID::operator>=(const RID &p_other) const {
return !(*this < p_other); return !(*this < p_other);
} }

View File

@ -1,3 +1,6 @@
#ifndef STRING_NAME_H
#define STRING_NAME_H
/*************************************************************************/ /*************************************************************************/
/* string.h */ /* string.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef STRING_NAME_H
#define STRING_NAME_H
#include <gdn/string_name.h> #include <gdn/string_name.h>
class String; class String;

View File

@ -1,3 +1,6 @@
#ifndef TAGDB_H
#define TAGDB_H
/*************************************************************************/ /*************************************************************************/
/* TagDB.h */ /* TagDB.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef TAGDB_H
#define TAGDB_H
#include <stddef.h> #include <stddef.h>
namespace _TagDB { namespace _TagDB {

View File

@ -37,8 +37,6 @@
#include "quaternion.h" #include "quaternion.h"
const Transform Transform::IDENTITY = Transform(); const Transform Transform::IDENTITY = Transform();
const Transform Transform::FLIP_X = Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); const Transform Transform::FLIP_X = Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
const Transform Transform::FLIP_Y = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0); const Transform Transform::FLIP_Y = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0);
@ -111,7 +109,7 @@ AABB Transform::xform(const AABB &p_aabb) const {
Vector3 y = basis.get_axis(1) * p_aabb.size.y; Vector3 y = basis.get_axis(1) * p_aabb.size.y;
Vector3 z = basis.get_axis(2) * p_aabb.size.z; Vector3 z = basis.get_axis(2) * p_aabb.size.z;
Vector3 pos = xform(p_aabb.position); Vector3 pos = xform(p_aabb.position);
//could be even further optimized // could be even further optimized
AABB new_aabb; AABB new_aabb;
new_aabb.position = pos; new_aabb.position = pos;
new_aabb.expand_to(pos + x); new_aabb.expand_to(pos + x);
@ -301,5 +299,3 @@ Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) {
basis = p_basis; basis = p_basis;
origin = p_origin; origin = p_origin;
} }

View File

@ -1,3 +1,6 @@
#ifndef TRANSFORM_H
#define TRANSFORM_H
/*************************************************************************/ /*************************************************************************/
/* Transform.h */ /* Transform.h */
/*************************************************************************/ /*************************************************************************/
@ -28,16 +31,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include "basis.h" #include "basis.h"
#include "aabb.h" #include "aabb.h"
#include "plane.h" #include "plane.h"
class Transform { class Transform {
public: public:
static const Transform IDENTITY; static const Transform IDENTITY;
@ -116,6 +114,4 @@ public:
inline Transform() {} inline Transform() {}
}; };
#endif // TRANSFORM_H #endif // TRANSFORM_H

View File

@ -1,3 +1,6 @@
#ifndef TRANSFORM2D_H
#define TRANSFORM2D_H
/*************************************************************************/ /*************************************************************************/
/* Transform2D.h */ /* Transform2D.h */
/*************************************************************************/ /*************************************************************************/
@ -28,13 +31,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef TRANSFORM2D_H
#define TRANSFORM2D_H
#include "vector2.h" #include "vector2.h"
typedef Vector2 Size2; typedef Vector2 Size2;
struct Rect2; struct Rect2;
@ -131,6 +129,4 @@ struct Transform2D {
} }
}; };
#endif // TRANSFORM2D_H #endif // TRANSFORM2D_H

View File

@ -41,7 +41,7 @@
#define _MKSTR(m_x) _STR(m_x) #define _MKSTR(m_x) _STR(m_x)
#endif #endif
//should always inline no matter what // should always inline no matter what
#ifndef _ALWAYS_INLINE_ #ifndef _ALWAYS_INLINE_
#if defined(__GNUC__) && (__GNUC__ >= 4) #if defined(__GNUC__) && (__GNUC__ >= 4)
@ -107,7 +107,7 @@
#endif #endif
#endif #endif
//custom, gcc-safe offsetof, because gcc complains a lot. // custom, gcc-safe offsetof, because gcc complains a lot.
template <class T> template <class T>
T *_nullptr() { T *_nullptr() {
T *t = NULL; T *t = NULL;
@ -179,7 +179,7 @@ inline void __swap_tmpl(T &x, T &y) {
y = aux; y = aux;
} }
#endif //swap #endif // swap
/* clang-format off */ /* clang-format off */
#define HEX2CHR(m_hex) \ #define HEX2CHR(m_hex) \
@ -381,7 +381,7 @@ struct _GlobalLock {
// Limit the depth of recursive algorithms when dealing with Array/Dictionary // Limit the depth of recursive algorithms when dealing with Array/Dictionary
#define MAX_RECURSION 100 #define MAX_RECURSION 100
//HAS_TRIVIAL_CONSTRUCTOR // HAS_TRIVIAL_CONSTRUCTOR
#if defined(__llvm__) && _llvm_has_builtin(__is_trivially_constructible) #if defined(__llvm__) && _llvm_has_builtin(__is_trivially_constructible)
#define HAS_TRIVIAL_CONSTRUCTOR(T) __is_trivially_constructible(T) #define HAS_TRIVIAL_CONSTRUCTOR(T) __is_trivially_constructible(T)
@ -391,7 +391,7 @@ struct _GlobalLock {
#define HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T) #define HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
#endif #endif
//HAS_TRIVIAL_DESTRUCTOR // HAS_TRIVIAL_DESTRUCTOR
#if defined(__llvm__) && _llvm_has_builtin(__is_trivially_destructible) #if defined(__llvm__) && _llvm_has_builtin(__is_trivially_destructible)
#define HAS_TRIVIAL_DESTRUCTOR(T) __is_trivially_destructible(T) #define HAS_TRIVIAL_DESTRUCTOR(T) __is_trivially_destructible(T)
@ -401,7 +401,7 @@ struct _GlobalLock {
#define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) #define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
#endif #endif
//HAS_TRIVIAL_COPY // HAS_TRIVIAL_COPY
#if defined(__llvm__) && _llvm_has_builtin(__is_trivially_copyable) #if defined(__llvm__) && _llvm_has_builtin(__is_trivially_copyable)
#define HAS_TRIVIAL_COPY(T) __is_trivially_copyable(T) #define HAS_TRIVIAL_COPY(T) __is_trivially_copyable(T)

View File

@ -1,3 +1,6 @@
#ifndef STRING_H
#define STRING_H
/*************************************************************************/ /*************************************************************************/
/* String.h */ /* String.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef STRING_H
#define STRING_H
#include <gdn/string.h> #include <gdn/string.h>
class NodePath; class NodePath;

View File

@ -1,3 +1,6 @@
#ifndef VARIANT_H
#define VARIANT_H
/*************************************************************************/ /*************************************************************************/
/* Variant.h */ /* Variant.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VARIANT_H
#define VARIANT_H
#include <gdn/variant.h> #include <gdn/variant.h>
#include "defs.h" #include "defs.h"

View File

@ -34,8 +34,6 @@
#include "ustring.h" #include "ustring.h"
const Vector2 Vector2::ZERO = Vector2(); const Vector2 Vector2::ZERO = Vector2();
const Vector2 Vector2::ONE = Vector2(1, 1); const Vector2 Vector2::ONE = Vector2(1, 1);
const Vector2 Vector2::INF = Vector2(INFINITY, INFINITY); const Vector2 Vector2::INF = Vector2(INFINITY, INFINITY);
@ -96,5 +94,3 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c
Vector2::operator String() const { Vector2::operator String() const {
return String::num(x) + ", " + String::num(y); return String::num(x) + ", " + String::num(y);
} }

View File

@ -1,3 +1,6 @@
#ifndef VECTOR2_H
#define VECTOR2_H
/*************************************************************************/ /*************************************************************************/
/* Vector2.h */ /* Vector2.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VECTOR2_H
#define VECTOR2_H
#include <gdn/vector2.h> #include <gdn/vector2.h>
#include "defs.h" #include "defs.h"

View File

@ -34,10 +34,6 @@
#include "ustring.h" #include "ustring.h"
Vector2i::operator String() const { Vector2i::operator String() const {
return String::num(x) + ", " + String::num(y); return String::num(x) + ", " + String::num(y);
} }

View File

@ -1,3 +1,6 @@
#ifndef VECTOR2I_H
#define VECTOR2I_H
/*************************************************************************/ /*************************************************************************/
/* vector2.h */ /* vector2.h */
/*************************************************************************/ /*************************************************************************/
@ -28,17 +31,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VECTOR2I_H
#define VECTOR2I_H
#include <gdn/vector2i.h> #include <gdn/vector2i.h>
#include "defs.h" #include "defs.h"
#include <math_funcs.h> #include <math_funcs.h>
class String; class String;
struct Vector2i { struct Vector2i {
@ -64,6 +62,4 @@ struct Vector2i {
operator String() const; operator String() const;
}; };
#endif // VECTOR2_H #endif // VECTOR2_H

View File

@ -36,8 +36,6 @@
#include "basis.h" #include "basis.h"
const Vector3 Vector3::ZERO = Vector3(); const Vector3 Vector3::ZERO = Vector3();
const Vector3 Vector3::ONE = Vector3(1, 1, 1); const Vector3 Vector3::ONE = Vector3(1, 1, 1);
const Vector3 Vector3::INF = Vector3(INFINITY, INFINITY, INFINITY); const Vector3 Vector3::INF = Vector3(INFINITY, INFINITY, INFINITY);
@ -117,5 +115,3 @@ void Vector3::snap(real_t p_val) {
Vector3::operator String() const { Vector3::operator String() const {
return String::num(x) + ", " + String::num(y) + ", " + String::num(z); return String::num(x) + ", " + String::num(y) + ", " + String::num(z);
} }

View File

@ -1,3 +1,6 @@
#ifndef VECTOR3_H
#define VECTOR3_H
/*************************************************************************/ /*************************************************************************/
/* vector3.h */ /* vector3.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VECTOR3_H
#define VECTOR3_H
#include <gdn/vector3.h> #include <gdn/vector3.h>
#include "defs.h" #include "defs.h"

View File

@ -34,10 +34,6 @@
#include "ustring.h" #include "ustring.h"
Vector3i::operator String() const { Vector3i::operator String() const {
return String::num(x) + ", " + String::num(y) + ", " + String::num(z) ; return String::num(x) + ", " + String::num(y) + ", " + String::num(z);
} }

View File

@ -1,3 +1,6 @@
#ifndef VECTOR3I_H
#define VECTOR3I_H
/*************************************************************************/ /*************************************************************************/
/* vector2.h */ /* vector2.h */
/*************************************************************************/ /*************************************************************************/
@ -28,17 +31,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VECTOR3I_H
#define VECTOR3I_H
#include <gdn/vector3i.h> #include <gdn/vector3i.h>
#include "defs.h" #include "defs.h"
#include <math_funcs.h> #include <math_funcs.h>
class String; class String;
struct Vector3i { struct Vector3i {
@ -67,6 +65,4 @@ struct Vector3i {
operator String() const; operator String() const;
}; };
#endif // VECTOR2_H #endif // VECTOR2_H

View File

@ -34,10 +34,6 @@
#include "ustring.h" #include "ustring.h"
Vector4::operator String() const { Vector4::operator String() const {
return String::num(x) + ", " + String::num(y) + ", " + String::num(z) + ", " + String::num(w); return String::num(x) + ", " + String::num(y) + ", " + String::num(z) + ", " + String::num(w);
} }

View File

@ -1,3 +1,6 @@
#ifndef VECTOR4_H
#define VECTOR4_H
/*************************************************************************/ /*************************************************************************/
/* vector2.h */ /* vector2.h */
/*************************************************************************/ /*************************************************************************/
@ -28,17 +31,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VECTOR4_H
#define VECTOR4_H
#include <gdn/vector4.h> #include <gdn/vector4.h>
#include "defs.h" #include "defs.h"
#include <math_funcs.h> #include <math_funcs.h>
class String; class String;
struct Vector4 { struct Vector4 {
@ -70,6 +68,4 @@ struct Vector4 {
operator String() const; operator String() const;
}; };
#endif // VECTOR2_H #endif // VECTOR2_H

View File

@ -34,10 +34,6 @@
#include "ustring.h" #include "ustring.h"
Vector4i::operator String() const { Vector4i::operator String() const {
return String::num(x) + ", " + String::num(y) + ", " + String::num(z) + ", " + String::num(w); return String::num(x) + ", " + String::num(y) + ", " + String::num(z) + ", " + String::num(w);
} }

View File

@ -1,3 +1,6 @@
#ifndef VECTOR4I_H
#define VECTOR4I_H
/*************************************************************************/ /*************************************************************************/
/* vector2.h */ /* vector2.h */
/*************************************************************************/ /*************************************************************************/
@ -28,9 +31,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef VECTOR4I_H
#define VECTOR4I_H
#include <gdn/vector4i.h> #include <gdn/vector4i.h>
#include "defs.h" #include "defs.h"