Implementing clang-format and applying it to all classes

This commit is contained in:
Bastiaan Olij
2018-11-24 09:09:41 +11:00
parent 0a6f5d052a
commit fc20fa3fce
49 changed files with 2923 additions and 3172 deletions

View File

@@ -17,40 +17,38 @@ public:
real_t get_area() const; /// get area
inline bool has_no_area() const {
return (size.x<=CMP_EPSILON || size.y<=CMP_EPSILON || size.z<=CMP_EPSILON);
return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
}
inline bool has_no_surface() const {
return (size.x<=CMP_EPSILON && size.y<=CMP_EPSILON && size.z<=CMP_EPSILON);
return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
}
inline const Vector3& get_position() const { return position; }
inline void set_position(const Vector3& p_position) { position=p_position; }
inline const Vector3& get_size() const { return size; }
inline void set_size(const Vector3& p_size) { size=p_size; }
inline const Vector3 &get_position() const { return position; }
inline void set_position(const Vector3 &p_position) { position = p_position; }
inline const Vector3 &get_size() const { return size; }
inline void set_size(const Vector3 &p_size) { size = p_size; }
bool operator==(const AABB &p_rval) const;
bool operator!=(const AABB &p_rval) const;
bool operator==(const AABB& p_rval) const;
bool operator!=(const AABB& p_rval) const;
bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap
bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this
bool intersects(const AABB& p_aabb) const; /// Both AABBs overlap
bool intersects_inclusive(const AABB& p_aabb) const; /// Both AABBs (or their faces) overlap
bool encloses(const AABB & p_aabb) const; /// p_aabb is completely inside this
AABB merge(const AABB& p_with) const;
void merge_with(const AABB& p_aabb); ///merge with another AABB
AABB intersection(const AABB& p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip=nullptr,Vector3* r_normal=nullptr) const;
bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=nullptr,Vector3* r_normal=nullptr) const;
bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, real_t t0, real_t t1) const;
AABB merge(const AABB &p_with) const;
void merge_with(const AABB &p_aabb); ///merge with another AABB
AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
bool smits_intersect_ray(const Vector3 &from, const Vector3 &p_dir, real_t t0, real_t t1) const;
bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const;
bool intersects_plane(const Plane &p_plane) const;
bool has_point(const Vector3& p_point) const;
Vector3 get_support(const Vector3& p_normal) const;
bool has_point(const Vector3 &p_point) const;
Vector3 get_support(const Vector3 &p_normal) const;
Vector3 get_longest_axis() const;
int get_longest_axis_index() const;
@@ -63,21 +61,22 @@ public:
AABB grow(real_t p_by) const;
void grow_by(real_t p_amount);
void get_edge(int p_edge,Vector3& r_from,Vector3& r_to) const;
void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const;
Vector3 get_endpoint(int p_point) const;
AABB expand(const Vector3& p_vector) const;
void project_range_in_plane(const Plane& p_plane,real_t &r_min,real_t& r_max) const;
void expand_to(const Vector3& p_vector); /** expand to contain a point if necesary */
AABB expand(const Vector3 &p_vector) const;
void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const;
void expand_to(const Vector3 &p_vector); /** expand to contain a point if necesary */
operator String() const;
inline AABB() {}
inline AABB(const Vector3 &p_pos,const Vector3& p_size) { position=p_pos; size=p_size; }
inline AABB(const Vector3 &p_pos, const Vector3 &p_size) {
position = p_pos;
size = p_size;
}
};
}
} // namespace godot
#endif // RECT3_H

View File

@@ -21,57 +21,58 @@ class Object;
class Array {
godot_array _godot_array;
public:
Array();
Array(const Array & other);
Array & operator=(const Array & other);
Array(const Array &other);
Array &operator=(const Array &other);
Array(const PoolByteArray& a);
Array(const PoolByteArray &a);
Array(const PoolIntArray& a);
Array(const PoolIntArray &a);
Array(const PoolRealArray& a);
Array(const PoolRealArray &a);
Array(const PoolStringArray& a);
Array(const PoolStringArray &a);
Array(const PoolVector2Array& a);
Array(const PoolVector2Array &a);
Array(const PoolVector3Array& a);
Array(const PoolVector3Array &a);
Array(const PoolColorArray& a);
Array(const PoolColorArray &a);
template <class... Args>
static Array make(Args... args) {
return helpers::append_all(Array(), args...);
}
Variant& operator [](const int idx);
Variant &operator[](const int idx);
Variant operator [](const int idx) const;
Variant operator[](const int idx) const;
void append(const Variant& v);
void append(const Variant &v);
void clear();
int count(const Variant& v);
int count(const Variant &v);
bool empty() const;
void erase(const Variant& v);
void erase(const Variant &v);
Variant front() const;
Variant back() const;
int find(const Variant& what, const int from = 0);
int find(const Variant &what, const int from = 0);
int find_last(const Variant& what);
int find_last(const Variant &what);
bool has(const Variant& what) const;
bool has(const Variant &what) const;
uint32_t hash() const;
void insert(const int pos, const Variant& value);
void insert(const int pos, const Variant &value);
void invert();
@@ -81,9 +82,9 @@ public:
Variant pop_front();
void push_back(const Variant& v);
void push_back(const Variant &v);
void push_front(const Variant& v);
void push_front(const Variant &v);
void remove(const int idx);
@@ -91,16 +92,15 @@ public:
void resize(const int size);
int rfind(const Variant& what, const int from = -1);
int rfind(const Variant &what, const int from = -1);
void sort();
void sort_custom(Object *obj, const String& func);
void sort_custom(Object *obj, const String &func);
~Array();
};
}
} // namespace godot
#endif // ARRAY_H

View File

@@ -16,27 +16,22 @@ public:
Vector3 x, y, z;
};
Basis(const Quat& p_quat); // euler
Basis(const Vector3& p_euler); // euler
Basis(const Vector3& p_axis, real_t p_phi);
Basis(const Quat &p_quat); // euler
Basis(const Vector3 &p_euler); // euler
Basis(const Vector3 &p_axis, real_t p_phi);
Basis(const Vector3& row0, const Vector3& row1, const Vector3& row2);
Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2);
Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz);
Basis();
const Vector3& operator[](int axis) const;
Vector3& operator[](int axis);
const Vector3 &operator[](int axis) const;
Vector3 &operator[](int axis);
void invert();
bool isequal_approx(const Basis& a, const Basis& b) const;
bool isequal_approx(const Basis &a, const Basis &b) const;
bool is_orthogonal() const;
@@ -52,15 +47,15 @@ public:
Vector3 get_axis(int p_axis) const;
void set_axis(int p_axis, const Vector3& p_value);
void set_axis(int p_axis, const Vector3 &p_value);
void rotate(const Vector3& p_axis, real_t p_phi);
void rotate(const Vector3 &p_axis, real_t p_phi);
Basis rotated(const Vector3& p_axis, real_t p_phi) const;
Basis rotated(const Vector3 &p_axis, real_t p_phi) const;
void scale( const Vector3& p_scale );
void scale(const Vector3 &p_scale);
Basis scaled( const Vector3& p_scale ) const;
Basis scaled(const Vector3 &p_scale) const;
Vector3 get_scale() const;
@@ -70,32 +65,31 @@ public:
void set_euler_yxz(const Vector3 &p_euler);
inline Vector3 get_euler() const { return get_euler_yxz(); }
inline void set_euler(const Vector3& p_euler) { set_euler_yxz(p_euler); }
inline void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
// transposed dot products
real_t tdotx(const Vector3& v) const;
real_t tdoty(const Vector3& v) const;
real_t tdotz(const Vector3& v) const;
real_t tdotx(const Vector3 &v) const;
real_t tdoty(const Vector3 &v) const;
real_t tdotz(const Vector3 &v) const;
bool operator==(const Basis& p_matrix) const;
bool operator==(const Basis &p_matrix) const;
bool operator!=(const Basis& p_matrix) const;
bool operator!=(const Basis &p_matrix) const;
Vector3 xform(const Vector3& p_vector) const;
Vector3 xform(const Vector3 &p_vector) const;
Vector3 xform_inv(const Vector3& p_vector) const;
void operator*=(const Basis& p_matrix);
Vector3 xform_inv(const Vector3 &p_vector) const;
void operator*=(const Basis &p_matrix);
Basis operator*(const Basis& p_matrix) const;
Basis operator*(const Basis &p_matrix) const;
void operator+=(const Basis &p_matrix);
void operator+=(const Basis& p_matrix);
Basis operator+(const Basis &p_matrix) const;
Basis operator+(const Basis& p_matrix) const;
void operator-=(const Basis &p_matrix);
void operator-=(const Basis& p_matrix);
Basis operator-(const Basis& p_matrix) const;
Basis operator-(const Basis &p_matrix) const;
void operator*=(real_t p_val);
@@ -105,14 +99,12 @@ public:
void set_orthogonal_index(int p_index); // down below
operator String() const;
void get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const;
void get_axis_and_angle(Vector3 &r_axis, real_t &r_angle) const;
/* create / set */
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz);
Vector3 get_column(int i) const;
@@ -120,9 +112,9 @@ public:
Vector3 get_row(int i) const;
Vector3 get_main_diagonal() const;
void set_row(int i, const Vector3& p_row);
void set_row(int i, const Vector3 &p_row);
Basis transpose_xform(const Basis& m) const;
Basis transpose_xform(const Basis &m) const;
void orthonormalize();
@@ -133,10 +125,8 @@ public:
Basis diagonalize();
operator Quat() const;
};
}
} // namespace godot
#endif // BASIS_H

View File

@@ -9,14 +9,11 @@
namespace godot {
struct Color {
private:
// static float _parse_col(const String& p_str, int p_ofs);
public:
union {
struct {
@@ -28,8 +25,8 @@ public:
float components[4];
};
inline bool operator==(const Color &p_color) const { return (r==p_color.r && g==p_color.g && b==p_color.b && a==p_color.a ); }
inline bool operator!=(const Color &p_color) const { return (r!=p_color.r || g!=p_color.g || b!=p_color.b || a!=p_color.a ); }
inline bool operator==(const Color &p_color) const { return (r == p_color.r && g == p_color.g && b == p_color.b && a == p_color.a); }
inline bool operator!=(const Color &p_color) const { return (r != p_color.r || g != p_color.g || b != p_color.b || a != p_color.a); }
uint32_t to_32() const;
@@ -43,12 +40,12 @@ public:
float get_v() const;
void set_hsv(float p_h, float p_s, float p_v, float p_alpha=1.0);
void set_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0);
inline float& operator[](int idx) {
inline float &operator[](int idx) {
return components[idx];
}
inline const float& operator[](int idx) const {
inline const float &operator[](int idx) const {
return components[idx];
}
@@ -60,21 +57,21 @@ public:
Color contrasted() const;
Color linear_interpolate(const Color& p_b, float p_t) const;
Color linear_interpolate(const Color &p_b, float p_t) const;
Color blend(const Color& p_over) const;
Color blend(const Color &p_over) const;
Color to_linear() const;
static Color hex(uint32_t p_hex);
static Color html(const String& p_color);
static Color html(const String &p_color);
static bool html_is_valid(const String& p_color);
static bool html_is_valid(const String &p_color);
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;
@@ -82,15 +79,23 @@ public:
* No construct parameters, r=0, g=0, b=0. a=255
*/
inline Color() {
r=0; g=0; b=0; a=1.0;
r = 0;
g = 0;
b = 0;
a = 1.0;
}
/**
* RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0
*/
inline Color(float p_r,float p_g,float p_b,float p_a=1.0) { r=p_r; g=p_g; b=p_b; a=p_a; }
inline Color(float p_r, float p_g, float p_b, float p_a = 1.0) {
r = p_r;
g = p_g;
b = p_b;
a = p_a;
}
};
}
} // namespace godot
#endif // COLOR_H

View File

@@ -12,8 +12,8 @@
#include "Plane.hpp"
#include "PoolArrays.hpp"
#include "Quat.hpp"
#include "Rect2.hpp"
#include "RID.hpp"
#include "Rect2.hpp"
#include "String.hpp"
#include "Transform.hpp"
#include "Transform2D.hpp"
@@ -23,5 +23,4 @@
#include "Wrapped.hpp"
#endif // CORETYPES_H

View File

@@ -1,7 +1,6 @@
#ifndef DEFS_H
#define DEFS_H
namespace godot {
enum class Error {
@@ -15,7 +14,7 @@ enum class Error {
ERR_FILE_NOT_FOUND,
ERR_FILE_BAD_DRIVE,
ERR_FILE_BAD_PATH,
ERR_FILE_NO_PERMISSION, // (10)
ERR_FILE_NO_PERMISSION, // (10)
ERR_FILE_ALREADY_IN_USE,
ERR_FILE_CANT_OPEN,
ERR_FILE_CANT_WRITE,
@@ -25,12 +24,12 @@ enum class Error {
ERR_FILE_MISSING_DEPENDENCIES,
ERR_FILE_EOF,
ERR_CANT_OPEN, ///< Can't open a resource/socket/file
ERR_CANT_CREATE, // (20)
ERR_CANT_CREATE, // (20)
ERR_QUERY_FAILED,
ERR_ALREADY_IN_USE,
ERR_LOCKED, ///< resource is locked
ERR_TIMEOUT,
ERR_CANT_CONNECT, // (25)
ERR_CANT_CONNECT, // (25)
ERR_CANT_RESOLVE,
ERR_CONNECTION_ERROR,
ERR_CANT_AQUIRE_RESOURCE,
@@ -45,12 +44,12 @@ enum class Error {
ERR_METHOD_NOT_FOUND,
ERR_LINK_FAILED,
ERR_SCRIPT_FAILED,
ERR_CYCLIC_LINK, // (40)
ERR_CYCLIC_LINK, // (40)
ERR_INVALID_DECLARATION,
ERR_DUPLICATE_SYMBOL,
ERR_PARSE_ERROR,
ERR_BUSY,
ERR_SKIP, // (45)
ERR_SKIP, // (45)
ERR_HELP, ///< user requested help!!
ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
@@ -58,50 +57,50 @@ enum class Error {
ERR_WTF = ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
};
namespace helpers {
template <typename T, typename ValueT>
T append_all (T appendable, ValueT value) {
appendable.append(value);
return appendable;
}
template <typename T, typename ValueT, typename... Args>
T append_all (T appendable, ValueT value, Args... args) {
appendable.append(value);
return append_all(appendable, args...);
}
template <typename T>
T append_all (T appendable) {
return appendable;
}
template <typename KV, typename KeyT, typename ValueT>
KV add_all (KV kv, KeyT key, ValueT value) {
kv[key] = value;
return kv;
}
template <typename KV, typename KeyT, typename ValueT, typename... Args>
KV add_all (KV kv, KeyT key, ValueT value, Args... args) {
kv[key] = value;
return add_all(kv, args...);
}
template <typename KV>
KV add_all (KV kv) {
return kv;
}
}
namespace helpers {
template <typename T, typename ValueT>
T append_all(T appendable, ValueT value) {
appendable.append(value);
return appendable;
}
template <typename T, typename ValueT, typename... Args>
T append_all(T appendable, ValueT value, Args... args) {
appendable.append(value);
return append_all(appendable, args...);
}
template <typename T>
T append_all(T appendable) {
return appendable;
}
template <typename KV, typename KeyT, typename ValueT>
KV add_all(KV kv, KeyT key, ValueT value) {
kv[key] = value;
return kv;
}
template <typename KV, typename KeyT, typename ValueT, typename... Args>
KV add_all(KV kv, KeyT key, ValueT value, Args... args) {
kv[key] = value;
return add_all(kv, args...);
}
template <typename KV>
KV add_all(KV kv) {
return kv;
}
} // namespace helpers
} // namespace godot
#include <stdio.h>
typedef float real_t;
#define CMP_EPSILON 0.00001
#define CMP_EPSILON2 (CMP_EPSILON*CMP_EPSILON)
#define CMP_EPSILON2 (CMP_EPSILON * CMP_EPSILON)
#define Math_PI 3.14159265358979323846
#define _PLANE_EQ_DOT_EPSILON 0.999
@@ -109,7 +108,9 @@ typedef float real_t;
// ERR/WARN macros
#ifndef WARN_PRINT
#define WARN_PRINT(msg) fprintf(stdout, "ERROR: %s\n", msg); fflush(stdout)
#define WARN_PRINT(msg) \
fprintf(stdout, "ERROR: %s\n", msg); \
fflush(stdout)
#endif
#ifndef WARN_PRINTS
@@ -129,24 +130,51 @@ typedef float real_t;
#endif
#ifndef ERR_FAIL_V
#define ERR_FAIL_V(a) { ERR_FAIL(); return a; }
#define ERR_FAIL_V(a) \
{ \
ERR_FAIL(); \
return a; \
}
#endif
#ifndef ERR_FAIL_COND
#define ERR_FAIL_COND(a) do { if (a) { ERR_PRINT(#a); return; } } while(0)
#define ERR_FAIL_COND(a) \
do { \
if (a) { \
ERR_PRINT(#a); \
return; \
} \
} while (0)
#endif
#ifndef ERR_FAIL_COND_V
#define ERR_FAIL_COND_V(cond, ret) do { if (cond) { ERR_PRINT(#cond); return ret; } } while(0)
#define ERR_FAIL_COND_V(cond, ret) \
do { \
if (cond) { \
ERR_PRINT(#cond); \
return ret; \
} \
} while (0)
#endif
#ifndef ERR_FAIL_INDEX
#define ERR_FAIL_INDEX(a, b) do { if (a < 0 || a >= b) { ERR_FAIL(); return; } } while(0)
#define ERR_FAIL_INDEX(a, b) \
do { \
if (a < 0 || a >= b) { \
ERR_FAIL(); \
return; \
} \
} while (0)
#endif
#ifndef ERR_FAIL_INDEX_V
#define ERR_FAIL_INDEX_V(a, b, c) do { if (a < 0 || a >= b) { ERR_FAIL(); return c; } } while(0)
#define ERR_FAIL_INDEX_V(a, b, c) \
do { \
if (a < 0 || a >= b) { \
ERR_FAIL(); \
return c; \
} \
} while (0)
#endif
#endif // DEFS_H

View File

@@ -11,10 +11,11 @@ namespace godot {
class Dictionary {
godot_dictionary _godot_dictionary;
public:
Dictionary();
Dictionary(const Dictionary & other);
Dictionary & operator=(const Dictionary & other);
Dictionary(const Dictionary &other);
Dictionary &operator=(const Dictionary &other);
template <class... Args>
static Dictionary make(Args... args) {
@@ -25,19 +26,19 @@ public:
bool empty() const;
void erase(const Variant& key);
void erase(const Variant &key);
bool has(const Variant& key) const;
bool has(const Variant &key) const;
bool has_all(const Array& keys) const;
bool has_all(const Array &keys) const;
uint32_t hash() const;
Array keys() const;
Variant &operator [](const Variant& key);
Variant &operator[](const Variant &key);
const Variant &operator [](const Variant& key) const;
const Variant &operator[](const Variant &key) const;
int size() const;
@@ -46,9 +47,8 @@ public:
Array values() const;
~Dictionary();
};
}
} // namespace godot
#endif // DICTIONARY_H

View File

@@ -9,82 +9,90 @@
#include <typeinfo>
#include "CoreTypes.hpp"
#include "Variant.hpp"
#include "Ref.hpp"
#include "TagDB.hpp"
#include "Variant.hpp"
#include "Object.hpp"
#include "GodotGlobal.hpp"
#include <NativeScript.hpp>
#include <GDNativeLibrary.hpp>
#include <NativeScript.hpp>
namespace godot {
template<class T>
T *as(const Object *obj)
{
return (T *) godot::nativescript_api->godot_nativescript_get_userdata(obj->_owner);
template <class T>
T *as(const Object *obj) {
return (T *)godot::nativescript_api->godot_nativescript_get_userdata(obj->_owner);
}
template<class T>
T *get_wrapper(godot_object *obj)
{
return (T *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, obj);
template <class T>
T *get_wrapper(godot_object *obj) {
return (T *)godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, obj);
}
#define GODOT_CLASS(Name, Base) \
\
public: \
inline static const char *___get_type_name() { return static_cast<const char *>(#Name); } \
enum { ___CLASS_IS_SCRIPT = 1, \
}; \
inline static Name *_new() { \
godot::NativeScript *script = godot::NativeScript::_new(); \
script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *)godot::gdnlib)); \
script->set_class_name(#Name); \
Name *instance = godot::as<Name>(script->new_()); \
return instance; \
} \
inline static const char *___get_base_type_name() { return Base::___get_class_name(); } \
inline static Object *___get_from_variant(godot::Variant a) { return (godot::Object *)godot::as<Name>(godot::Object::___get_from_variant(a)); } \
\
private:
#define GODOT_CLASS(Name, Base) \
public: inline static const char *___get_type_name() { return static_cast<const char *>(#Name); } \
enum { ___CLASS_IS_SCRIPT = 1, }; \
inline static Name *_new() { godot::NativeScript *script = godot::NativeScript::_new(); script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *) godot::gdnlib)); script->set_class_name(#Name); Name *instance = godot::as<Name>(script->new_()); return instance; } \
inline static const char *___get_base_type_name() { return Base::___get_class_name(); } \
inline static Object *___get_from_variant(godot::Variant a) { return (godot::Object *) godot::as<Name>(godot::Object::___get_from_variant(a)); } \
private:
#define GODOT_SUBCLASS(Name, Base) \
\
public: \
inline static const char *___get_type_name() { return static_cast<const char *>(#Name); } \
enum { ___CLASS_IS_SCRIPT = 1, \
}; \
inline static Name *_new() { \
godot::NativeScript *script = godot::NativeScript::_new(); \
script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *)godot::gdnlib)); \
script->set_class_name(#Name); \
Name *instance = godot::as<Name>(script->new_()); \
return instance; \
} \
inline static const char *___get_base_type_name() { return #Base; } \
inline static Object *___get_from_variant(godot::Variant a) { return (godot::Object *)godot::as<Name>(godot::Object::___get_from_variant(a)); } \
\
private:
#define GODOT_SUBCLASS(Name, Base) \
public: inline static const char *___get_type_name() { return static_cast<const char *>(#Name); } \
enum { ___CLASS_IS_SCRIPT = 1, }; \
inline static Name *_new() { godot::NativeScript *script = godot::NativeScript::_new(); script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *) godot::gdnlib)); script->set_class_name(#Name); Name *instance = godot::as<Name>(script->new_()); return instance; } \
inline static const char *___get_base_type_name() { return #Base; } \
inline static Object *___get_from_variant(godot::Variant a) { return (godot::Object *) godot::as<Name>(godot::Object::___get_from_variant(a)); } \
private:
template<class T>
template <class T>
struct _ArgCast {
static T _arg_cast(Variant a)
{
static T _arg_cast(Variant a) {
return a;
}
};
template<class T>
struct _ArgCast<T*> {
static T *_arg_cast(Variant a)
{
return (T *) T::___get_from_variant(a);
template <class T>
struct _ArgCast<T *> {
static T *_arg_cast(Variant a) {
return (T *)T::___get_from_variant(a);
}
};
template<>
template <>
struct _ArgCast<Variant> {
static Variant _arg_cast(Variant a)
{
static Variant _arg_cast(Variant a) {
return a;
}
};
// instance and destroy funcs
template<class T>
void *_godot_class_instance_func(godot_object *p, void *method_data)
{
template <class T>
void *_godot_class_instance_func(godot_object *p, void *method_data) {
T *d = new T();
d->_owner = p;
d->_type_tag = typeid(T).hash_code();
@@ -92,17 +100,14 @@ void *_godot_class_instance_func(godot_object *p, void *method_data)
return d;
}
template<class T>
void _godot_class_destroy_func(godot_object *p, void *method_data, void *data)
{
T *d = (T *) data;
template <class T>
void _godot_class_destroy_func(godot_object *p, void *method_data, void *data) {
T *d = (T *)data;
delete d;
}
template<class T>
void register_class()
{
template <class T>
void register_class() {
godot_instance_create_func create = {};
create.create_func = _godot_class_instance_func<T>;
@@ -112,13 +117,12 @@ void register_class()
_TagDB::register_type(typeid(T).hash_code(), typeid(T).hash_code());
godot::nativescript_api->godot_nativescript_register_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
godot::nativescript_1_1_api->godot_nativescript_set_type_tag(godot::_RegisterState::nativescript_handle, T::___get_type_name(), (const void *) typeid(T).hash_code());
godot::nativescript_1_1_api->godot_nativescript_set_type_tag(godot::_RegisterState::nativescript_handle, T::___get_type_name(), (const void *)typeid(T).hash_code());
T::_register_methods();
}
template<class T>
void register_tool_class()
{
template <class T>
void register_tool_class() {
godot_instance_create_func create = {};
create.create_func = _godot_class_instance_func<T>;
@@ -128,155 +132,109 @@ void register_tool_class()
_TagDB::register_type(typeid(T).hash_code(), typeid(T).hash_code());
godot::nativescript_api->godot_nativescript_register_tool_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
godot::nativescript_1_1_api->godot_nativescript_set_type_tag(godot::_RegisterState::nativescript_handle, T::___get_type_name(), (const void *) typeid(T).hash_code());
godot::nativescript_1_1_api->godot_nativescript_set_type_tag(godot::_RegisterState::nativescript_handle, T::___get_type_name(), (const void *)typeid(T).hash_code());
T::_register_methods();
}
// method registering
typedef godot_variant (*__godot_wrapper_method)(godot_object *, void *, void *, int, godot_variant **);
template<class T, class R, class ...args>
const char *___get_method_class_name(R (T::*p)(args... a))
{
template <class T, class R, class... args>
const char *___get_method_class_name(R (T::*p)(args... a)) {
return T::___get_type_name();
}
template<class T, class R, class ...args>
const char *___get_method_class_name(R (T::*p)(args... a) const)
{
template <class T, class R, class... args>
const char *___get_method_class_name(R (T::*p)(args... a) const) {
return T::___get_type_name();
}
// Okay, time for some template magic.
// Many thanks to manpat from the GDL Discord Server.
// This is stuff that's available in C++14 I think, but whatever.
template<int... I>
struct __Sequence{};
template <int... I>
struct __Sequence {};
template<int N, int... I>
template <int N, int... I>
struct __construct_sequence {
using type = typename __construct_sequence<N-1, N-1, I...>::type;
using type = typename __construct_sequence<N - 1, N - 1, I...>::type;
};
template<int... I>
template <int... I>
struct __construct_sequence<0, I...> {
using type = __Sequence<I...>;
};
// Now the wrapping part.
template<class T, class R, class... As>
template <class T, class R, class... As>
struct _WrappedMethod {
R (T::*f)(As...);
R(T::*f)
(As...);
template<int... I>
void apply(Variant* ret, T* obj, Variant** args, __Sequence<I...>) {
*ret = (obj->*f)( _ArgCast<As>::_arg_cast(*args[I])... );
template <int... I>
void apply(Variant *ret, T *obj, Variant **args, __Sequence<I...>) {
*ret = (obj->*f)(_ArgCast<As>::_arg_cast(*args[I])...);
}
};
template<class T, class... As>
template <class T, class... As>
struct _WrappedMethod<T, void, As...> {
void (T::*f)(As...);
template<int... I>
void apply(Variant* ret, T* obj, Variant** args, __Sequence<I...>) {
(obj->*f)( _ArgCast<As>::_arg_cast(*args[I])... );
template <int... I>
void apply(Variant *ret, T *obj, Variant **args, __Sequence<I...>) {
(obj->*f)(_ArgCast<As>::_arg_cast(*args[I])...);
}
};
template<class T, class R, class... As>
godot_variant __wrapped_method(godot_object *, void *method_data, void *user_data, int num_args, godot_variant **args)
{
template <class T, class R, class... As>
godot_variant __wrapped_method(godot_object *, void *method_data, void *user_data, int num_args, godot_variant **args) {
godot_variant v;
godot::api->godot_variant_new_nil(&v);
T *obj = (T *) user_data;
_WrappedMethod<T, R, As...> *method = (_WrappedMethod<T, R, As...>*) method_data;
T *obj = (T *)user_data;
_WrappedMethod<T, R, As...> *method = (_WrappedMethod<T, R, As...> *)method_data;
Variant *var = (Variant *) &v;
Variant **arg = (Variant **) args;
Variant *var = (Variant *)&v;
Variant **arg = (Variant **)args;
method->apply(var, obj, arg, typename __construct_sequence<sizeof...(As)>::type {});
method->apply(var, obj, arg, typename __construct_sequence<sizeof...(As)>::type{});
return v;
}
template<class T, class R, class... As>
void *___make_wrapper_function(R (T::*f)(As...))
{
template <class T, class R, class... As>
void *___make_wrapper_function(R (T::*f)(As...)) {
using MethodType = _WrappedMethod<T, R, As...>;
MethodType *p = (MethodType *) godot::api->godot_alloc(sizeof(MethodType));
MethodType *p = (MethodType *)godot::api->godot_alloc(sizeof(MethodType));
p->f = f;
return (void *) p;
return (void *)p;
}
template<class T, class R, class... As>
__godot_wrapper_method ___get_wrapper_function(R (T::*f)(As...))
{
return (__godot_wrapper_method) &__wrapped_method<T, R, As...>;
template <class T, class R, class... As>
__godot_wrapper_method ___get_wrapper_function(R (T::*f)(As...)) {
return (__godot_wrapper_method)&__wrapped_method<T, R, As...>;
}
template<class T, class R, class ...A>
void *___make_wrapper_function(R (T::*f)(A...) const)
{
return ___make_wrapper_function((R (T::*)(A...)) f);
template <class T, class R, class... A>
void *___make_wrapper_function(R (T::*f)(A...) const) {
return ___make_wrapper_function((R(T::*)(A...))f);
}
template<class T, class R, class ...A>
__godot_wrapper_method ___get_wrapper_function(R (T::*f)(A...) const)
{
return ___get_wrapper_function((R (T::*)(A...)) f);
template <class T, class R, class... A>
__godot_wrapper_method ___get_wrapper_function(R (T::*f)(A...) const) {
return ___get_wrapper_function((R(T::*)(A...))f);
}
template<class M>
void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED)
{
template <class M>
void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED) {
godot_instance_method method = {};
method.method_data = ___make_wrapper_function(method_ptr);
method.free_func = godot::api->godot_free;
method.method = (__godot_wrapper_method) ___get_wrapper_function(method_ptr);
method.method = (__godot_wrapper_method)___get_wrapper_function(method_ptr);
godot_method_attributes attr = {};
attr.rpc_type = rpc_type;
@@ -284,34 +242,31 @@ void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_t
godot::nativescript_api->godot_nativescript_register_method(godot::_RegisterState::nativescript_handle, ___get_method_class_name(method_ptr), name, attr, method);
}
template<class T, class P>
template <class T, class P>
struct _PropertySetFunc {
void (T::*f)(P);
static void _wrapped_setter(godot_object *object, void *method_data, void *user_data, godot_variant *value)
{
_PropertySetFunc<T, P> *set_func = (_PropertySetFunc<T, P> *) method_data;
T *obj = (T *) user_data;
static void _wrapped_setter(godot_object *object, void *method_data, void *user_data, godot_variant *value) {
_PropertySetFunc<T, P> *set_func = (_PropertySetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
Variant *v = (Variant *) value;
Variant *v = (Variant *)value;
(obj->*(set_func->f))(_ArgCast<P>::_arg_cast(*v));
}
};
template<class T, class P>
template <class T, class P>
struct _PropertyGetFunc {
P (T::*f)();
static godot_variant _wrapped_getter(godot_object *object, void *method_data, void *user_data)
{
_PropertyGetFunc<T, P> *get_func = (_PropertyGetFunc<T, P> *) method_data;
T *obj = (T *) user_data;
P(T::*f)
();
static godot_variant _wrapped_getter(godot_object *object, void *method_data, void *user_data) {
_PropertyGetFunc<T, P> *get_func = (_PropertyGetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
godot_variant var;
godot::api->godot_variant_new_nil(&var);
Variant *v = (Variant *) &var;
Variant *v = (Variant *)&var;
*v = (obj->*(get_func->f))();
@@ -319,37 +274,30 @@ struct _PropertyGetFunc {
}
};
template<class T, class P>
template <class T, class P>
struct _PropertyDefaultSetFunc {
P (T::*f);
static void _wrapped_setter(godot_object *object, void *method_data, void *user_data, godot_variant *value)
{
_PropertyDefaultSetFunc<T, P> *set_func = (_PropertyDefaultSetFunc<T, P> *) method_data;
T *obj = (T *) user_data;
P(T::*f);
static void _wrapped_setter(godot_object *object, void *method_data, void *user_data, godot_variant *value) {
_PropertyDefaultSetFunc<T, P> *set_func = (_PropertyDefaultSetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
Variant *v = (Variant *) value;
Variant *v = (Variant *)value;
(obj->*(set_func->f)) = _ArgCast<P>::_arg_cast(*v);
}
};
template<class T, class P>
template <class T, class P>
struct _PropertyDefaultGetFunc {
P (T::*f);
static godot_variant _wrapped_getter(godot_object *object, void *method_data, void *user_data)
{
_PropertyDefaultGetFunc<T, P> *get_func = (_PropertyDefaultGetFunc<T, P> *) method_data;
T *obj = (T *) user_data;
P(T::*f);
static godot_variant _wrapped_getter(godot_object *object, void *method_data, void *user_data) {
_PropertyDefaultGetFunc<T, P> *get_func = (_PropertyDefaultGetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
godot_variant var;
godot::api->godot_variant_new_nil(&var);
Variant *v = (Variant *) &var;
Variant *v = (Variant *)&var;
*v = (obj->*(get_func->f));
@@ -357,27 +305,25 @@ struct _PropertyDefaultGetFunc {
}
};
template<class T, class P>
void register_property(const char *name, P (T::*var), P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "")
{
template <class T, class P>
void register_property(const char *name, P(T::*var), P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
Variant def_val = default_value;
usage = (godot_property_usage_flags) ((int) usage | GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE);
usage = (godot_property_usage_flags)((int)usage | GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE);
if (def_val.get_type() == Variant::OBJECT) {
Object *o = get_wrapper<Object>(def_val.operator godot_object*());
Object *o = get_wrapper<Object>(def_val.operator godot_object *());
if (o && o->is_class("Resource")) {
hint = (godot_property_hint) ((int) hint | GODOT_PROPERTY_HINT_RESOURCE_TYPE);
hint = (godot_property_hint)((int)hint | GODOT_PROPERTY_HINT_RESOURCE_TYPE);
hint_string = o->get_class();
}
}
godot_string *_hint_string = (godot_string*) &hint_string;
godot_string *_hint_string = (godot_string *)&hint_string;
godot_property_attributes attr = {};
attr.type = def_val.get_type();
attr.default_value = *(godot_variant *) &def_val;
attr.default_value = *(godot_variant *)&def_val;
attr.hint = hint;
attr.rset_type = rpc_mode;
attr.usage = usage;
@@ -386,75 +332,68 @@ void register_property(const char *name, P (T::*var), P default_value, godot_met
_PropertyDefaultSetFunc<T, P> *wrapped_set = (_PropertyDefaultSetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertyDefaultSetFunc<T, P>));
wrapped_set->f = var;
_PropertyDefaultGetFunc<T, P> *wrapped_get = (_PropertyDefaultGetFunc<T, P> *) godot::api->godot_alloc(sizeof(_PropertyDefaultGetFunc<T, P>));
_PropertyDefaultGetFunc<T, P> *wrapped_get = (_PropertyDefaultGetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertyDefaultGetFunc<T, P>));
wrapped_get->f = var;
godot_property_set_func set_func = {};
set_func.method_data = (void *) wrapped_set;
set_func.free_func = godot::api->godot_free;
set_func.set_func = &_PropertyDefaultSetFunc<T, P>::_wrapped_setter;
set_func.method_data = (void *)wrapped_set;
set_func.free_func = godot::api->godot_free;
set_func.set_func = &_PropertyDefaultSetFunc<T, P>::_wrapped_setter;
godot_property_get_func get_func = {};
get_func.method_data = (void *) wrapped_get;
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyDefaultGetFunc<T, P>::_wrapped_getter;
get_func.method_data = (void *)wrapped_get;
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyDefaultGetFunc<T, P>::_wrapped_getter;
godot::nativescript_api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
}
template<class T, class P>
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(), P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "")
{
template <class T, class P>
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(), P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
Variant def_val = default_value;
godot_property_attributes attr = {};
attr.type = def_val.get_type();
attr.default_value = *(godot_variant *) &def_val;
attr.default_value = *(godot_variant *)&def_val;
attr.hint = hint;
attr.rset_type = rpc_mode;
attr.usage = usage;
_PropertySetFunc<T, P> *wrapped_set = (_PropertySetFunc<T, P> *) godot::api->godot_alloc(sizeof(_PropertySetFunc<T, P>));
_PropertySetFunc<T, P> *wrapped_set = (_PropertySetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertySetFunc<T, P>));
wrapped_set->f = setter;
_PropertyGetFunc<T, P> *wrapped_get = (_PropertyGetFunc<T, P> *) godot::api->godot_alloc(sizeof(_PropertyGetFunc<T, P>));
_PropertyGetFunc<T, P> *wrapped_get = (_PropertyGetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertyGetFunc<T, P>));
wrapped_get->f = getter;
godot_property_set_func set_func = {};
set_func.method_data = (void *) wrapped_set;
set_func.free_func = godot::api->godot_free;
set_func.set_func = &_PropertySetFunc<T, P>::_wrapped_setter;
set_func.method_data = (void *)wrapped_set;
set_func.free_func = godot::api->godot_free;
set_func.set_func = &_PropertySetFunc<T, P>::_wrapped_setter;
godot_property_get_func get_func = {};
get_func.method_data = (void *) wrapped_get;
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyGetFunc<T, P>::_wrapped_getter;
get_func.method_data = (void *)wrapped_get;
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyGetFunc<T, P>::_wrapped_getter;
godot::nativescript_api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
}
template<class T, class P>
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)() const, P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "")
{
register_property(name, setter, (P (T::*)()) getter, default_value, rpc_mode, usage, hint, hint_string);
template <class T, class P>
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)() const, P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
register_property(name, setter, (P(T::*)())getter, default_value, rpc_mode, usage, hint, hint_string);
}
template<class T>
void register_signal(String name, Dictionary args = Dictionary())
{
template <class T>
void register_signal(String name, Dictionary args = Dictionary()) {
godot_signal signal = {};
signal.name = *(godot_string *)&name;
signal.num_args = args.size();
signal.num_default_args = 0;
// Need to check because malloc(0) is platform-dependent. Zero arguments will leave args to nullptr.
if(signal.num_args != 0) {
signal.args = (godot_signal_argument*) godot::api->godot_alloc(sizeof(godot_signal_argument) * signal.num_args);
memset((void *) signal.args, 0, sizeof(godot_signal_argument) * signal.num_args);
if (signal.num_args != 0) {
signal.args = (godot_signal_argument *)godot::api->godot_alloc(sizeof(godot_signal_argument) * signal.num_args);
memset((void *)signal.args, 0, sizeof(godot_signal_argument) * signal.num_args);
}
for (int i = 0; i < signal.num_args; i++) {
@@ -476,29 +415,23 @@ void register_signal(String name, Dictionary args = Dictionary())
godot::api->godot_string_destroy(&signal.args[i].name);
}
if(signal.args) {
if (signal.args) {
godot::api->godot_free(signal.args);
}
}
template<class T, class... Args>
void register_signal(String name, Args... varargs)
{
template <class T, class... Args>
void register_signal(String name, Args... varargs) {
register_signal<T>(name, Dictionary::make(varargs...));
}
#ifndef GODOT_CPP_NO_OBJECT_CAST
template<class T>
T *Object::cast_to(const Object *obj)
{
size_t have_tag = (size_t) godot::nativescript_1_1_api->godot_nativescript_get_type_tag(obj->_owner);
template <class T>
T *Object::cast_to(const Object *obj) {
size_t have_tag = (size_t)godot::nativescript_1_1_api->godot_nativescript_get_type_tag(obj->_owner);
if (have_tag) {
if (!godot::_TagDB::is_type_known((size_t) have_tag)) {
if (!godot::_TagDB::is_type_known((size_t)have_tag)) {
have_tag = 0;
}
}
@@ -508,14 +441,13 @@ T *Object::cast_to(const Object *obj)
}
if (godot::_TagDB::is_type_compatible(typeid(T).hash_code(), have_tag)) {
return (T::___CLASS_IS_SCRIPT) ? godot::as<T>(obj) : (T *) obj;
return (T::___CLASS_IS_SCRIPT) ? godot::as<T>(obj) : (T *)obj;
} else {
return nullptr;
}
}
#endif
}
} // namespace godot
#endif // GODOT_H

View File

@@ -1,9 +1,9 @@
#ifndef GODOT_GLOBAL_HPP
#define GODOT_GLOBAL_HPP
#include <gdnative_api_struct.gen.h>
#include "String.hpp"
#include "Array.hpp"
#include "String.hpp"
#include <gdnative_api_struct.gen.h>
namespace godot {
@@ -16,9 +16,9 @@ extern "C" const void *gdnlib;
class Godot {
public:
static void print(const String& message);
static void print_warning(const String& description, const String& function, const String& file, int line);
static void print_error(const String& description, const String& function, const String& file, int line);
static void print(const String &message);
static void print_warning(const String &description, const String &function, const String &file, int line);
static void print_error(const String &description, const String &function, const String &file, int line);
static void gdnative_init(godot_gdnative_init_options *o);
static void gdnative_terminate(godot_gdnative_terminate_options *o);
@@ -26,18 +26,16 @@ public:
static void nativescript_terminate(void *handle);
template <class... Args>
static void print(const String& fmt, Args... values) {
static void print(const String &fmt, Args... values) {
print(fmt.format(Array::make(values...)));
}
};
struct _RegisterState {
static void *nativescript_handle;
static int language_index;
};
}
} // namespace godot
#endif

View File

@@ -7,16 +7,15 @@
namespace godot {
class NodePath
{
class NodePath {
godot_node_path _node_path;
public:
NodePath();
NodePath(const NodePath &other);
NodePath(const String& from);
NodePath(const String &from);
NodePath(const char *contents);
@@ -34,15 +33,13 @@ public:
operator String() const;
void operator =(const NodePath& other);
void operator=(const NodePath &other);
bool operator ==(const NodePath& other);
bool operator==(const NodePath &other);
~NodePath();
};
}
} // namespace godot
#endif // NODEPATH_H

View File

@@ -5,10 +5,8 @@
#include <cmath>
namespace godot {
enum ClockDirection {
CLOCKWISE,
@@ -20,7 +18,7 @@ public:
Vector3 normal;
real_t d;
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
@@ -30,40 +28,41 @@ public:
/* Plane-Point operations */
inline Vector3 center() const { return normal*d; }
inline Vector3 center() const { return normal * d; }
Vector3 get_any_point() const;
Vector3 get_any_perpendicular_normal() const;
bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
real_t distance_to(const Vector3 &p_point) const;
bool has_point(const Vector3 &p_point,real_t _epsilon=CMP_EPSILON) const;
bool has_point(const Vector3 &p_point, real_t _epsilon = CMP_EPSILON) const;
/* intersections */
bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result=0) const;
bool intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3* p_intersection) const;
bool intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3* p_intersection) const;
bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = 0) const;
bool intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const;
bool intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const;
Vector3 project(const Vector3& p_point) const;
Vector3 project(const Vector3 &p_point) const;
/* misc */
inline Plane operator-() const { return Plane(-normal,-d); }
bool is_almost_like(const Plane& p_plane) const;
inline Plane operator-() const { return Plane(-normal, -d); }
bool is_almost_like(const Plane &p_plane) const;
bool operator==(const Plane& p_plane) const;
bool operator!=(const Plane& p_plane) const;
bool operator==(const Plane &p_plane) const;
bool operator!=(const Plane &p_plane) const;
operator String() const;
inline Plane() { d=0; }
inline Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) : normal(p_a,p_b,p_c), d(p_d) { }
inline Plane() { d = 0; }
inline Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) :
normal(p_a, p_b, p_c),
d(p_d) {}
Plane(const Vector3 &p_normal, real_t p_d);
Plane(const Vector3 &p_point, const Vector3& p_normal);
Plane(const Vector3 &p_point1, const Vector3 &p_point2,const Vector3 &p_point3,ClockDirection p_dir = CLOCKWISE);
Plane(const Vector3 &p_point, const Vector3 &p_normal);
Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir = CLOCKWISE);
};
}
} // namespace godot
#endif // PLANE_H

View File

@@ -3,11 +3,11 @@
#include "Defs.hpp"
#include "String.hpp"
#include "Color.hpp"
#include "GodotGlobal.hpp"
#include "String.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include "GodotGlobal.hpp"
#include <gdnative/pool_arrays.h>
@@ -17,18 +17,19 @@ class Array;
class PoolByteArray {
godot_pool_byte_array _godot_array;
public:
public:
class Read {
friend class PoolByteArray;
godot_pool_byte_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_byte_array_read_access_copy(p_other._read_access);
}
@@ -44,7 +45,7 @@ public:
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_byte_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -52,12 +53,13 @@ public:
class Write {
friend class PoolByteArray;
godot_pool_byte_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_byte_array_write_access_copy(p_other._write_access);
}
@@ -73,16 +75,16 @@ public:
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_byte_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
PoolByteArray();
PoolByteArray(const PoolByteArray &p_other);
PoolByteArray &operator=(const PoolByteArray & p_other);
PoolByteArray &operator=(const PoolByteArray &p_other);
PoolByteArray(const Array& array);
PoolByteArray(const Array &array);
Read read() const;
@@ -90,7 +92,7 @@ public:
void append(const uint8_t data);
void append_array(const PoolByteArray& array);
void append_array(const PoolByteArray &array);
int insert(const int idx, const uint8_t data);
@@ -104,27 +106,27 @@ public:
void set(const int idx, const uint8_t data);
uint8_t operator [](const int idx);
uint8_t operator[](const int idx);
int size() const;
~PoolByteArray();
};
class PoolIntArray {
godot_pool_int_array _godot_array;
public:
public:
class Read {
friend class PoolIntArray;
godot_pool_int_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_int_array_read_access_copy(p_other._read_access);
}
@@ -140,7 +142,7 @@ public:
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_int_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -148,12 +150,13 @@ public:
class Write {
friend class PoolIntArray;
godot_pool_int_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_int_array_write_access_copy(p_other._write_access);
}
@@ -169,7 +172,7 @@ public:
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_int_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
@@ -178,7 +181,7 @@ public:
PoolIntArray(const PoolIntArray &p_other);
PoolIntArray &operator=(const PoolIntArray &p_other);
PoolIntArray(const Array& array);
PoolIntArray(const Array &array);
Read read() const;
@@ -186,7 +189,7 @@ public:
void append(const int data);
void append_array(const PoolIntArray& array);
void append_array(const PoolIntArray &array);
int insert(const int idx, const int data);
@@ -200,27 +203,27 @@ public:
void set(const int idx, const int data);
int operator [](const int idx);
int operator[](const int idx);
int size() const;
~PoolIntArray();
};
class PoolRealArray {
godot_pool_real_array _godot_array;
public:
public:
class Read {
friend class PoolRealArray;
godot_pool_real_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_real_array_read_access_copy(p_other._read_access);
}
@@ -236,7 +239,7 @@ public:
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_real_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -244,12 +247,13 @@ public:
class Write {
friend class PoolRealArray;
godot_pool_real_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_real_array_write_access_copy(p_other._write_access);
}
@@ -265,7 +269,7 @@ public:
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_real_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
@@ -274,7 +278,7 @@ public:
PoolRealArray(const PoolRealArray &p_other);
PoolRealArray &operator=(const PoolRealArray &p_other);
PoolRealArray(const Array& array);
PoolRealArray(const Array &array);
Read read() const;
@@ -282,7 +286,7 @@ public:
void append(const real_t data);
void append_array(const PoolRealArray& array);
void append_array(const PoolRealArray &array);
int insert(const int idx, const real_t data);
@@ -296,27 +300,27 @@ public:
void set(const int idx, const real_t data);
real_t operator [](const int idx);
real_t operator[](const int idx);
int size() const;
~PoolRealArray();
};
class PoolStringArray {
godot_pool_string_array _godot_array;
public:
public:
class Read {
friend class PoolStringArray;
godot_pool_string_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_string_array_read_access_copy(p_other._read_access);
}
@@ -325,14 +329,14 @@ public:
}
inline const String *ptr() const {
return (const String *) godot::api->godot_pool_string_array_read_access_ptr(_read_access);
return (const String *)godot::api->godot_pool_string_array_read_access_ptr(_read_access);
}
inline const String &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_string_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -340,12 +344,13 @@ public:
class Write {
friend class PoolStringArray;
godot_pool_string_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_string_array_write_access_copy(p_other._write_access);
}
@@ -354,14 +359,14 @@ public:
}
inline String *ptr() const {
return (String *) godot::api->godot_pool_string_array_write_access_ptr(_write_access);
return (String *)godot::api->godot_pool_string_array_write_access_ptr(_write_access);
}
inline String &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_string_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
@@ -370,50 +375,49 @@ public:
PoolStringArray(const PoolStringArray &p_other);
PoolStringArray &operator=(const PoolStringArray &p_other);
PoolStringArray(const Array& array);
PoolStringArray(const Array &array);
Read read() const;
Write write();
void append(const String& data);
void append(const String &data);
void append_array(const PoolStringArray& array);
void append_array(const PoolStringArray &array);
int insert(const int idx, const String& data);
int insert(const int idx, const String &data);
void invert();
void push_back(const String& data);
void push_back(const String &data);
void remove(const int idx);
void resize(const int size);
void set(const int idx, const String& data);
void set(const int idx, const String &data);
const String operator [](const int idx);
const String operator[](const int idx);
int size() const;
~PoolStringArray();
};
class PoolVector2Array {
godot_pool_vector2_array _godot_array;
public:
public:
class Read {
friend class PoolVector2Array;
godot_pool_vector2_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_vector2_array_read_access_copy(p_other._read_access);
}
@@ -422,14 +426,14 @@ public:
}
inline const Vector2 *ptr() const {
return (const Vector2 *) godot::api->godot_pool_vector2_array_read_access_ptr(_read_access);
return (const Vector2 *)godot::api->godot_pool_vector2_array_read_access_ptr(_read_access);
}
inline const Vector2 &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_vector2_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -437,12 +441,13 @@ public:
class Write {
friend class PoolVector2Array;
godot_pool_vector2_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_vector2_array_write_access_copy(p_other._write_access);
}
@@ -451,14 +456,14 @@ public:
}
inline Vector2 *ptr() const {
return (Vector2 *) godot::api->godot_pool_vector2_array_write_access_ptr(_write_access);
return (Vector2 *)godot::api->godot_pool_vector2_array_write_access_ptr(_write_access);
}
inline Vector2 &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_vector2_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
@@ -467,49 +472,49 @@ public:
PoolVector2Array(const PoolVector2Array &p_other);
PoolVector2Array &operator=(const PoolVector2Array &p_other);
PoolVector2Array(const Array& array);
PoolVector2Array(const Array &array);
Read read() const;
Write write();
void append(const Vector2& data);
void append(const Vector2 &data);
void append_array(const PoolVector2Array& array);
void append_array(const PoolVector2Array &array);
int insert(const int idx, const Vector2& data);
int insert(const int idx, const Vector2 &data);
void invert();
void push_back(const Vector2& data);
void push_back(const Vector2 &data);
void remove(const int idx);
void resize(const int size);
void set(const int idx, const Vector2& data);
void set(const int idx, const Vector2 &data);
const Vector2 operator [](const int idx);
const Vector2 operator[](const int idx);
int size() const;
~PoolVector2Array();
};
class PoolVector3Array {
godot_pool_vector3_array _godot_array;
public:
public:
class Read {
friend class PoolVector3Array;
godot_pool_vector3_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_vector3_array_read_access_copy(p_other._read_access);
}
@@ -518,14 +523,14 @@ public:
}
inline const Vector3 *ptr() const {
return (const Vector3 *) godot::api->godot_pool_vector3_array_read_access_ptr(_read_access);
return (const Vector3 *)godot::api->godot_pool_vector3_array_read_access_ptr(_read_access);
}
inline const Vector3 &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_vector3_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -533,12 +538,13 @@ public:
class Write {
friend class PoolVector3Array;
godot_pool_vector3_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_vector3_array_write_access_copy(p_other._write_access);
}
@@ -547,14 +553,14 @@ public:
}
inline Vector3 *ptr() const {
return (Vector3 *) godot::api->godot_pool_vector3_array_write_access_ptr(_write_access);
return (Vector3 *)godot::api->godot_pool_vector3_array_write_access_ptr(_write_access);
}
inline Vector3 &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_vector3_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
@@ -563,49 +569,49 @@ public:
PoolVector3Array(const PoolVector3Array &p_other);
PoolVector3Array &operator=(const PoolVector3Array &p_other);
PoolVector3Array(const Array& array);
PoolVector3Array(const Array &array);
Read read() const;
Write write();
void append(const Vector3& data);
void append(const Vector3 &data);
void append_array(const PoolVector3Array& array);
void append_array(const PoolVector3Array &array);
int insert(const int idx, const Vector3& data);
int insert(const int idx, const Vector3 &data);
void invert();
void push_back(const Vector3& data);
void push_back(const Vector3 &data);
void remove(const int idx);
void resize(const int size);
void set(const int idx, const Vector3& data);
void set(const int idx, const Vector3 &data);
const Vector3 operator [](const int idx);
const Vector3 operator[](const int idx);
int size() const;
~PoolVector3Array();
};
class PoolColorArray {
godot_pool_color_array _godot_array;
public:
public:
class Read {
friend class PoolColorArray;
godot_pool_color_array_read_access *_read_access;
public:
inline Read() {
_read_access = nullptr;
}
inline Read(const Read & p_other) {
inline Read(const Read &p_other) {
_read_access = godot::api->godot_pool_color_array_read_access_copy(p_other._read_access);
}
@@ -614,14 +620,14 @@ public:
}
inline const Color *ptr() const {
return (const Color *) godot::api->godot_pool_color_array_read_access_ptr(_read_access);
return (const Color *)godot::api->godot_pool_color_array_read_access_ptr(_read_access);
}
inline const Color &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Read& p_other) {
inline void operator=(const Read &p_other) {
godot::api->godot_pool_color_array_read_access_operator_assign(_read_access, p_other._read_access);
}
};
@@ -629,12 +635,13 @@ public:
class Write {
friend class PoolColorArray;
godot_pool_color_array_write_access *_write_access;
public:
inline Write() {
_write_access = nullptr;
}
inline Write(const Write & p_other) {
inline Write(const Write &p_other) {
_write_access = godot::api->godot_pool_color_array_write_access_copy(p_other._write_access);
}
@@ -643,14 +650,14 @@ public:
}
inline Color *ptr() const {
return (Color *) godot::api->godot_pool_color_array_write_access_ptr(_write_access);
return (Color *)godot::api->godot_pool_color_array_write_access_ptr(_write_access);
}
inline Color &operator[](int p_idx) const {
return ptr()[p_idx];
}
inline void operator=(const Write& p_other) {
inline void operator=(const Write &p_other) {
godot::api->godot_pool_color_array_write_access_operator_assign(_write_access, p_other._write_access);
}
};
@@ -659,38 +666,35 @@ public:
PoolColorArray(const PoolColorArray &p_other);
PoolColorArray &operator=(const PoolColorArray &p_other);
PoolColorArray(const Array& array);
PoolColorArray(const Array &array);
Read read() const;
Write write();
void append(const Color& data);
void append(const Color &data);
void append_array(const PoolColorArray& array);
void append_array(const PoolColorArray &array);
int insert(const int idx, const Color& data);
int insert(const int idx, const Color &data);
void invert();
void push_back(const Color& data);
void push_back(const Color &data);
void remove(const int idx);
void resize(const int size);
void set(const int idx, const Color& data);
void set(const int idx, const Color &data);
const Color operator [](const int idx);
const Color operator[](const int idx);
int size() const;
~PoolColorArray();
};
}
} // namespace godot
#endif // POOLARRAYS_H

View File

@@ -9,10 +9,9 @@
namespace godot {
class Quat{
class Quat {
public:
real_t x,y,z,w;
real_t x, y, z, w;
real_t length_squared() const;
real_t length() const;
@@ -23,65 +22,68 @@ public:
Quat inverse() const;
void set_euler_xyz(const Vector3& p_euler);
void set_euler_xyz(const Vector3 &p_euler);
Vector3 get_euler_xyz() const;
void set_euler_yxz(const Vector3& p_euler);
void set_euler_yxz(const Vector3 &p_euler);
Vector3 get_euler_yxz() const;
inline void set_euler(const Vector3& p_euler) { set_euler_yxz(p_euler); }
inline void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
inline Vector3 get_euler() const { return get_euler_yxz(); }
real_t dot(const Quat& q) const;
real_t dot(const Quat &q) const;
Quat slerp(const Quat& q, const real_t& t) const;
Quat slerp(const Quat &q, const real_t &t) const;
Quat slerpni(const Quat& q, const real_t& t) const;
Quat slerpni(const Quat &q, const real_t &t) const;
Quat cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const real_t& t) const;
Quat cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const;
void get_axis_and_angle(Vector3& r_axis, real_t &r_angle) const;
void get_axis_and_angle(Vector3 &r_axis, real_t &r_angle) const;
void operator*=(const Quat& q);
Quat operator*(const Quat& q) const;
void operator*=(const Quat &q);
Quat operator*(const Quat &q) const;
Quat operator*(const Vector3 &v) const;
Vector3 xform(const Vector3 &v) const;
Quat operator*(const Vector3& v) const;
Vector3 xform(const Vector3& v) const;
void operator+=(const Quat& q);
void operator-=(const Quat& q);
void operator*=(const real_t& s);
void operator/=(const real_t& s);
Quat operator+(const Quat& q2) const;
Quat operator-(const Quat& q2) const;
void operator+=(const Quat &q);
void operator-=(const Quat &q);
void operator*=(const real_t &s);
void operator/=(const real_t &s);
Quat operator+(const Quat &q2) const;
Quat operator-(const Quat &q2) const;
Quat operator-() const;
Quat operator*(const real_t& s) const;
Quat operator/(const real_t& s) const;
Quat operator*(const real_t &s) const;
Quat operator/(const real_t &s) const;
bool operator==(const Quat& p_quat) const;
bool operator!=(const Quat& p_quat) const;
bool operator==(const Quat &p_quat) const;
bool operator!=(const Quat &p_quat) const;
operator String() const;
inline void set( real_t p_x, real_t p_y, real_t p_z, real_t p_w) {
x=p_x; y=p_y; z=p_z; w=p_w;
inline void set(real_t p_x, real_t p_y, real_t p_z, real_t p_w) {
x = p_x;
y = p_y;
z = p_z;
w = p_w;
}
inline Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) {
x=p_x; y=p_y; z=p_z; w=p_w;
x = p_x;
y = p_y;
z = p_z;
w = p_w;
}
Quat(const Vector3& axis, const real_t& angle);
Quat(const Vector3 &axis, const real_t &angle);
Quat(const Vector3& v0, const Vector3& v1) ;
inline Quat() {x=y=z=0; w=1; }
Quat(const Vector3 &v0, const Vector3 &v1);
inline Quat() {
x = y = z = 0;
w = 1;
}
};
}
} // namespace godot
#endif // QUAT_H

View File

@@ -9,8 +9,8 @@ class Object;
class RID {
godot_rid _godot_rid;
public:
public:
RID();
RID(Object *p);
@@ -22,15 +22,14 @@ public:
return *this != RID();
}
bool operator==(const RID & p_other) const;
bool operator!=(const RID & p_other) const;
bool operator<(const RID & p_other) const;
bool operator>(const RID & p_other) const;
bool operator<=(const RID & p_other) const;
bool operator>=(const RID & p_other) const;
bool operator==(const RID &p_other) const;
bool operator!=(const RID &p_other) const;
bool operator<(const RID &p_other) const;
bool operator>(const RID &p_other) const;
bool operator<=(const RID &p_other) const;
bool operator>=(const RID &p_other) const;
};
}
} // namespace godot
#endif // RID_H

View File

@@ -21,113 +21,115 @@ struct Rect2 {
Point2 pos;
Size2 size;
inline const Vector2& get_pos() const { return pos; }
inline void set_pos(const Vector2& p_pos) { pos=p_pos; }
inline const Vector2& get_size() const { return size; }
inline void set_size(const Vector2& p_size) { size=p_size; }
inline const Vector2 &get_pos() const { return pos; }
inline void set_pos(const Vector2 &p_pos) { pos = p_pos; }
inline const Vector2 &get_size() const { return size; }
inline void set_size(const Vector2 &p_size) { size = p_size; }
inline real_t get_area() const { return size.width*size.height; }
inline real_t get_area() const { return size.width * size.height; }
inline bool intersects(const Rect2& p_rect) const {
if ( pos.x >= (p_rect.pos.x + p_rect.size.width) )
inline bool intersects(const Rect2 &p_rect) const {
if (pos.x >= (p_rect.pos.x + p_rect.size.width))
return false;
if ( (pos.x+size.width) <= p_rect.pos.x )
if ((pos.x + size.width) <= p_rect.pos.x)
return false;
if ( pos.y >= (p_rect.pos.y + p_rect.size.height) )
if (pos.y >= (p_rect.pos.y + p_rect.size.height))
return false;
if ( (pos.y+size.height) <= p_rect.pos.y )
if ((pos.y + size.height) <= p_rect.pos.y)
return false;
return true;
}
real_t distance_to(const Vector2& p_point) const;
real_t distance_to(const Vector2 &p_point) const;
bool intersects_transformed(const Transform2D& p_xform, const Rect2& p_rect) const;
bool intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const;
bool intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos=nullptr, Point2* r_normal=nullptr) const;
bool intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos = nullptr, Point2 *r_normal = nullptr) const;
inline bool encloses(const Rect2& p_rect) const {
return (p_rect.pos.x>=pos.x) && (p_rect.pos.y>=pos.y) &&
((p_rect.pos.x+p_rect.size.x)<(pos.x+size.x)) &&
((p_rect.pos.y+p_rect.size.y)<(pos.y+size.y));
inline bool encloses(const Rect2 &p_rect) const {
return (p_rect.pos.x >= pos.x) && (p_rect.pos.y >= pos.y) &&
((p_rect.pos.x + p_rect.size.x) < (pos.x + size.x)) &&
((p_rect.pos.y + p_rect.size.y) < (pos.y + size.y));
}
inline bool has_no_area() const {
return (size.x<=0 || size.y<=0);
return (size.x <= 0 || size.y <= 0);
}
Rect2 clip(const Rect2& p_rect) const;
Rect2 clip(const Rect2 &p_rect) const;
Rect2 merge(const Rect2& p_rect) const;
Rect2 merge(const Rect2 &p_rect) const;
inline bool has_point(const Point2& p_point) const {
inline bool has_point(const Point2 &p_point) const {
if (p_point.x < pos.x)
return false;
if (p_point.y < pos.y)
return false;
if (p_point.x >= (pos.x+size.x) )
if (p_point.x >= (pos.x + size.x))
return false;
if (p_point.y >= (pos.y+size.y) )
if (p_point.y >= (pos.y + size.y))
return false;
return true;
}
inline bool no_area() const { return (size.width<=0 || size.height<=0 ); }
inline bool no_area() const { return (size.width <= 0 || size.height <= 0); }
inline bool operator==(const Rect2& p_rect) const { return pos==p_rect.pos && size==p_rect.size; }
inline bool operator!=(const Rect2& p_rect) const { return pos!=p_rect.pos || size!=p_rect.size; }
inline bool operator==(const Rect2 &p_rect) const { return pos == p_rect.pos && size == p_rect.size; }
inline bool operator!=(const Rect2 &p_rect) const { return pos != p_rect.pos || size != p_rect.size; }
inline Rect2 grow(real_t p_by) const {
Rect2 g=*this;
g.pos.x-=p_by;
g.pos.y-=p_by;
g.size.width+=p_by*2;
g.size.height+=p_by*2;
Rect2 g = *this;
g.pos.x -= p_by;
g.pos.y -= p_by;
g.size.width += p_by * 2;
g.size.height += p_by * 2;
return g;
}
inline Rect2 expand(const Vector2& p_vector) const {
inline Rect2 expand(const Vector2 &p_vector) const {
Rect2 r = *this;
r.expand_to(p_vector);
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=pos;
Vector2 end=pos+size;
Vector2 begin = pos;
Vector2 end = pos + size;
if (p_vector.x<begin.x)
begin.x=p_vector.x;
if (p_vector.y<begin.y)
begin.y=p_vector.y;
if (p_vector.x < begin.x)
begin.x = p_vector.x;
if (p_vector.y < begin.y)
begin.y = p_vector.y;
if (p_vector.x>end.x)
end.x=p_vector.x;
if (p_vector.y>end.y)
end.y=p_vector.y;
if (p_vector.x > end.x)
end.x = p_vector.x;
if (p_vector.y > end.y)
end.y = p_vector.y;
pos=begin;
size=end-begin;
pos = begin;
size = end - begin;
}
operator String() const;
inline Rect2() {}
inline Rect2( real_t p_x, real_t p_y, real_t p_width, real_t p_height) { pos=Point2(p_x,p_y); size=Size2( p_width, p_height ); }
inline Rect2( const Point2& p_pos, const Size2& p_size ) { pos=p_pos; size=p_size; }
inline Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) {
pos = Point2(p_x, p_y);
size = Size2(p_width, p_height);
}
inline Rect2(const Point2 &p_pos, const Size2 &p_size) {
pos = p_pos;
size = p_size;
}
};
}
} // namespace godot
#endif // RECT2_H

View File

@@ -1,9 +1,9 @@
#ifndef REF_H
#define REF_H
#include "Variant.hpp"
#include "GodotGlobal.hpp"
#include "Reference.hpp"
#include "Variant.hpp"
namespace godot {
@@ -80,7 +80,7 @@ public:
operator Variant() const {
// Note: the C API handles the cases where the object is a Reference,
// so the Variant will be correctly constructed with a RefPtr engine-side
return Variant((Object*)reference);
return Variant((Object *)reference);
}
void operator=(const Ref &p_from) {
@@ -99,7 +99,7 @@ public:
}
Ref r;
//r.reference = Object::cast_to<T>(refb);
r.reference = (T*)refb;
r.reference = (T *)refb;
ref(r);
r.reference = nullptr;
}
@@ -107,7 +107,7 @@ public:
void operator=(const Variant &p_variant) {
// TODO We need a safe cast
Reference *refb = (Reference *) T::___get_from_variant(p_variant);
Reference *refb = (Reference *)T::___get_from_variant(p_variant);
if (!refb) {
unref();
return;
@@ -156,7 +156,7 @@ public:
reference = nullptr;
// TODO We need a safe cast
Reference *refb = (Reference *) T::___get_from_variant(p_variant);
Reference *refb = (Reference *)T::___get_from_variant(p_variant);
if (!refb) {
unref();
return;
@@ -202,14 +202,13 @@ public:
// Used exclusively in the bindings to recreate the Ref Godot encapsulates in return values,
// without adding to the refcount.
inline static Ref<T> __internal_constructor(Object *obj)
{
inline static Ref<T> __internal_constructor(Object *obj) {
Ref<T> r;
r.reference = (T*)obj;
r.reference = (T *)obj;
return r;
}
};
}
} // namespace godot
#endif

View File

@@ -132,12 +132,11 @@ public:
signed char casecmp_to(String p_str) const;
signed char nocasecmp_to(String p_str) const;
signed char naturalnocasecmp_to(String p_str) const;
};
String operator+(const char *a, const String &b);
String operator+(const wchar_t *a, const String &b);
}
} // namespace godot
#endif // STRING_H

View File

@@ -12,8 +12,8 @@ bool is_type_known(size_t type_tag);
void register_global_type(const char *name, size_t type_tag, size_t base_type_tag);
bool is_type_compatible(size_t type_tag, size_t base_type_tag);
}
} // namespace _TagDB
}
} // namespace godot
#endif // TAGDB_HPP

View File

@@ -3,14 +3,13 @@
#include "Basis.hpp"
#include "Plane.hpp"
#include "AABB.hpp"
#include "Plane.hpp"
namespace godot {
class Transform {
public:
Basis basis;
Vector3 origin;
@@ -20,62 +19,61 @@ public:
void affine_invert();
Transform affine_inverse() const;
Transform rotated(const Vector3& p_axis,real_t p_phi) const;
Transform rotated(const Vector3 &p_axis, real_t p_phi) const;
void rotate(const Vector3& p_axis,real_t p_phi);
void rotate_basis(const Vector3& p_axis,real_t p_phi);
void rotate(const Vector3 &p_axis, real_t p_phi);
void rotate_basis(const Vector3 &p_axis, real_t p_phi);
void set_look_at( const Vector3& p_eye, const Vector3& p_target, const Vector3& p_up );
Transform looking_at( const Vector3& p_target, const Vector3& p_up ) const;
void set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up);
Transform looking_at(const Vector3 &p_target, const Vector3 &p_up) const;
void scale(const Vector3& p_scale);
Transform scaled(const Vector3& p_scale) const;
void scale_basis(const Vector3& p_scale);
void translate( real_t p_tx, real_t p_ty, real_t p_tz );
void translate( const Vector3& p_translation );
Transform translated( const Vector3& p_translation ) const;
void scale(const Vector3 &p_scale);
Transform scaled(const Vector3 &p_scale) const;
void scale_basis(const Vector3 &p_scale);
void translate(real_t p_tx, real_t p_ty, real_t p_tz);
void translate(const Vector3 &p_translation);
Transform translated(const Vector3 &p_translation) const;
inline const Basis& get_basis() const { return basis; }
inline void set_basis(const Basis& p_basis) { basis=p_basis; }
inline const Basis &get_basis() const { return basis; }
inline void set_basis(const Basis &p_basis) { basis = p_basis; }
inline const Vector3& get_origin() const { return origin; }
inline void set_origin(const Vector3& p_origin) { origin=p_origin; }
inline const Vector3 &get_origin() const { return origin; }
inline void set_origin(const Vector3 &p_origin) { origin = p_origin; }
void orthonormalize();
Transform orthonormalized() const;
bool operator==(const Transform& p_transform) const;
bool operator!=(const Transform& p_transform) const;
bool operator==(const Transform &p_transform) const;
bool operator!=(const Transform &p_transform) const;
Vector3 xform(const Vector3& p_vector) const;
Vector3 xform_inv(const Vector3& p_vector) const;
Vector3 xform(const Vector3 &p_vector) const;
Vector3 xform_inv(const Vector3 &p_vector) const;
Plane xform(const Plane& p_plane) const;
Plane xform_inv(const Plane& p_plane) const;
Plane xform(const Plane &p_plane) const;
Plane xform_inv(const Plane &p_plane) const;
AABB xform(const AABB& p_aabb) const;
AABB xform_inv(const AABB& p_aabb) const;
AABB xform(const AABB &p_aabb) const;
AABB xform_inv(const AABB &p_aabb) const;
void operator*=(const Transform& p_transform);
Transform operator*(const Transform& p_transform) const;
void operator*=(const Transform &p_transform);
Transform operator*(const Transform &p_transform) const;
Transform interpolate_with(const Transform& p_transform, real_t p_c) const;
Transform interpolate_with(const Transform &p_transform, real_t p_c) const;
Transform inverse_xform(const Transform& t) const;
Transform inverse_xform(const Transform &t) const;
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz,real_t tx, real_t ty, real_t tz);
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t tx, real_t ty, real_t tz);
operator String() const;
inline Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz,real_t tx, real_t ty, real_t tz) {
set(xx, xy, xz, yx, yy, yz, zx, zy, zz,tx, ty, tz);
inline Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t tx, real_t ty, real_t tz) {
set(xx, xy, xz, yx, yy, yz, zx, zy, zz, tx, ty, tz);
}
Transform(const Basis& p_basis, const Vector3& p_origin=Vector3());
Transform(const Basis &p_basis, const Vector3 &p_origin = Vector3());
inline Transform() {}
};
}
} // namespace godot
#endif // TRANSFORM_H

View File

@@ -3,7 +3,6 @@
#include "Vector2.hpp"
namespace godot {
typedef Vector2 Size2;
@@ -24,14 +23,20 @@ struct Transform2D {
Vector2 elements[3];
inline real_t tdotx(const Vector2& v) const { return elements[0][0] * v.x + elements[1][0] * v.y; }
inline real_t tdoty(const Vector2& v) const { return elements[0][1] * v.x + elements[1][1] * v.y; }
inline real_t tdotx(const Vector2 &v) const { return elements[0][0] * v.x + elements[1][0] * v.y; }
inline real_t tdoty(const Vector2 &v) const { return elements[0][1] * v.x + elements[1][1] * v.y; }
inline const Vector2& operator[](int p_idx) const { return elements[p_idx]; }
inline Vector2& operator[](int p_idx) { return elements[p_idx]; }
inline const Vector2 &operator[](int p_idx) const { return elements[p_idx]; }
inline Vector2 &operator[](int p_idx) { return elements[p_idx]; }
inline Vector2 get_axis(int p_axis) const { ERR_FAIL_INDEX_V(p_axis,3,Vector2()); return elements[p_axis]; }
inline void set_axis(int p_axis,const Vector2& p_vec) { ERR_FAIL_INDEX(p_axis,3); elements[p_axis]=p_vec; }
inline Vector2 get_axis(int p_axis) const {
ERR_FAIL_INDEX_V(p_axis, 3, Vector2());
return elements[p_axis];
}
inline void set_axis(int p_axis, const Vector2 &p_vec) {
ERR_FAIL_INDEX(p_axis, 3);
elements[p_axis] = p_vec;
}
void invert();
Transform2D inverse() const;
@@ -41,24 +46,24 @@ struct Transform2D {
void set_rotation(real_t p_phi);
real_t get_rotation() const;
void set_rotation_and_scale(real_t p_phi,const Size2& p_scale);
void set_rotation_and_scale(real_t p_phi, const Size2 &p_scale);
void rotate(real_t p_phi);
void scale(const Size2& p_scale);
void scale_basis(const Size2& p_scale);
void translate( real_t p_tx, real_t p_ty);
void translate( const Vector2& p_translation );
void scale(const Size2 &p_scale);
void scale_basis(const Size2 &p_scale);
void translate(real_t p_tx, real_t p_ty);
void translate(const Vector2 &p_translation);
real_t basis_determinant() const;
Size2 get_scale() const;
inline const Vector2& get_origin() const { return elements[2]; }
inline void set_origin(const Vector2& p_origin) { elements[2]=p_origin; }
inline const Vector2 &get_origin() const { return elements[2]; }
inline void set_origin(const Vector2 &p_origin) { elements[2] = p_origin; }
Transform2D scaled(const Size2& p_scale) const;
Transform2D basis_scaled(const Size2& p_scale) const;
Transform2D translated(const Vector2& p_offset) const;
Transform2D scaled(const Size2 &p_scale) const;
Transform2D basis_scaled(const Size2 &p_scale) const;
Transform2D translated(const Vector2 &p_offset) const;
Transform2D rotated(real_t p_phi) const;
Transform2D untranslated() const;
@@ -66,29 +71,32 @@ struct Transform2D {
void orthonormalize();
Transform2D orthonormalized() const;
bool operator==(const Transform2D& p_transform) const;
bool operator!=(const Transform2D& p_transform) const;
bool operator==(const Transform2D &p_transform) const;
bool operator!=(const Transform2D &p_transform) const;
void operator*=(const Transform2D& p_transform);
Transform2D operator*(const Transform2D& p_transform) const;
void operator*=(const Transform2D &p_transform);
Transform2D operator*(const Transform2D &p_transform) const;
Transform2D interpolate_with(const Transform2D& p_transform, real_t p_c) const;
Transform2D interpolate_with(const Transform2D &p_transform, real_t p_c) const;
Vector2 basis_xform(const Vector2& p_vec) const;
Vector2 basis_xform_inv(const Vector2& p_vec) const;
Vector2 xform(const Vector2& p_vec) const;
Vector2 xform_inv(const Vector2& p_vec) const;
Rect2 xform(const Rect2& p_vec) const;
Rect2 xform_inv(const Rect2& p_vec) const;
Vector2 basis_xform(const Vector2 &p_vec) const;
Vector2 basis_xform_inv(const Vector2 &p_vec) const;
Vector2 xform(const Vector2 &p_vec) const;
Vector2 xform_inv(const Vector2 &p_vec) const;
Rect2 xform(const Rect2 &p_vec) const;
Rect2 xform_inv(const Rect2 &p_vec) const;
operator String() const;
Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy);
Transform2D(real_t p_rot, const Vector2& p_pos);
inline Transform2D() { elements[0][0]=1.0; elements[1][1]=1.0; }
Transform2D(real_t p_rot, const Vector2 &p_pos);
inline Transform2D() {
elements[0][0] = 1.0;
elements[1][1] = 1.0;
}
};
}
} // namespace godot
#endif // TRANSFORM2D_H

View File

@@ -12,8 +12,8 @@
#include "Plane.hpp"
#include "PoolArrays.hpp"
#include "Quat.hpp"
#include "Rect2.hpp"
#include "RID.hpp"
#include "Rect2.hpp"
#include "String.hpp"
#include "Transform.hpp"
#include "Transform2D.hpp"
@@ -30,6 +30,7 @@ class Array;
class Variant {
godot_variant _godot_variant;
public:
enum Type {
@@ -43,31 +44,31 @@ public:
// math types
VECTOR2, // 5
VECTOR2, // 5
RECT2,
VECTOR3,
TRANSFORM2D,
PLANE,
QUAT, // 10
QUAT, // 10
RECT3, //sorry naming convention fail :( not like it's used often
BASIS,
TRANSFORM,
// misc types
COLOR,
NODE_PATH, // 15
NODE_PATH, // 15
_RID,
OBJECT,
DICTIONARY,
ARRAY,
// arrays
POOL_BYTE_ARRAY, // 20
POOL_BYTE_ARRAY, // 20
POOL_INT_ARRAY,
POOL_REAL_ARRAY,
POOL_STRING_ARRAY,
POOL_VECTOR2_ARRAY,
POOL_VECTOR3_ARRAY, // 25
POOL_VECTOR3_ARRAY, // 25
POOL_COLOR_ARRAY,
VARIANT_MAX
@@ -116,7 +117,7 @@ public:
Variant();
Variant(const Variant& v);
Variant(const Variant &v);
Variant(bool p_bool);
@@ -126,11 +127,14 @@ public:
Variant(signed short p_short);
inline Variant(unsigned short p_short) : Variant((unsigned int) p_short) {}
inline Variant(unsigned short p_short) :
Variant((unsigned int)p_short) {}
inline Variant(signed char p_char) : Variant((signed int) p_char) {}
inline Variant(signed char p_char) :
Variant((signed int)p_char) {}
inline Variant(unsigned char p_char) : Variant((unsigned int) p_char) {}
inline Variant(unsigned char p_char) :
Variant((unsigned int)p_char) {}
Variant(int64_t p_char);
Variant(uint64_t p_char);
@@ -139,64 +143,61 @@ public:
Variant(double p_double);
Variant(const String& p_string);
Variant(const String &p_string);
Variant(const char * const p_cstring);
Variant(const char *const p_cstring);
Variant(const wchar_t * p_wstring);
Variant(const wchar_t *p_wstring);
Variant(const Vector2& p_vector2);
Variant(const Vector2 &p_vector2);
Variant(const Rect2& p_rect2);
Variant(const Rect2 &p_rect2);
Variant(const Vector3& p_vector3);
Variant(const Vector3 &p_vector3);
Variant(const Plane& p_plane);
Variant(const Plane &p_plane);
Variant(const AABB &p_aabb);
Variant(const AABB& p_aabb);
Variant(const Quat &p_quat);
Variant(const Quat& p_quat);
Variant(const Basis &p_transform);
Variant(const Basis& p_transform);
Variant(const Transform2D &p_transform);
Variant(const Transform2D& p_transform);
Variant(const Transform &p_transform);
Variant(const Transform& p_transform);
Variant(const Color &p_color);
Variant(const Color& p_color);
Variant(const NodePath &p_path);
Variant(const NodePath& p_path);
Variant(const RID &p_rid);
Variant(const RID& p_rid);
Variant(const Object *p_object);
Variant(const Object* p_object);
Variant(const Dictionary &p_dictionary);
Variant(const Dictionary& p_dictionary);
Variant(const Array &p_array);
Variant(const Array& p_array);
Variant(const PoolByteArray &p_raw_array);
Variant(const PoolByteArray& p_raw_array);
Variant(const PoolIntArray &p_int_array);
Variant(const PoolIntArray& p_int_array);
Variant(const PoolRealArray &p_real_array);
Variant(const PoolRealArray& p_real_array);
Variant(const PoolStringArray &p_string_array);
Variant(const PoolStringArray& p_string_array);
Variant(const PoolVector2Array &p_vector2_array);
Variant(const PoolVector2Array& p_vector2_array);
Variant(const PoolVector3Array &p_vector3_array);
Variant(const PoolVector3Array& p_vector3_array);
Variant(const PoolColorArray& p_color_array);
Variant &operator =(const Variant& v);
Variant(const PoolColorArray &p_color_array);
Variant &operator=(const Variant &v);
operator bool() const;
operator signed int() const;
operator unsigned int() const ;
operator unsigned int() const;
operator signed short() const;
operator unsigned short() const;
operator signed char() const;
@@ -204,7 +205,6 @@ public:
operator int64_t() const;
operator uint64_t() const;
operator wchar_t() const;
operator float() const;
@@ -225,7 +225,7 @@ public:
operator NodePath() const;
operator RID() const;
operator godot_object*() const;
operator godot_object *() const;
operator Dictionary() const;
operator Array() const;
@@ -240,32 +240,29 @@ public:
Type get_type() const;
Variant call(const String &method, const Variant **args, const int arg_count);
Variant call(const String& method, const Variant **args, const int arg_count);
bool has_method(const String &method);
bool has_method(const String& method);
bool operator==(const Variant &b) const;
bool operator ==(const Variant& b) const;
bool operator!=(const Variant &b) const;
bool operator !=(const Variant& b) const;
bool operator<(const Variant &b) const;
bool operator <(const Variant& b) const;
bool operator<=(const Variant &b) const;
bool operator <=(const Variant& b) const;
bool operator>(const Variant &b) const;
bool operator >(const Variant& b) const;
bool operator>=(const Variant &b) const;
bool operator >=(const Variant& b) const;
bool hash_compare(const Variant& b) const;
bool hash_compare(const Variant &b) const;
bool booleanize() const;
~Variant();
};
}
} // namespace godot
#endif // VARIANT_H

View File

@@ -20,21 +20,20 @@ struct Vector2 {
real_t height;
};
inline real_t& operator[](int p_idx) {
return p_idx?y:x;
inline real_t &operator[](int p_idx) {
return p_idx ? y : x;
}
inline const real_t& operator[](int p_idx) const {
return p_idx?y:x;
inline const real_t &operator[](int p_idx) const {
return p_idx ? y : x;
}
Vector2 operator+(const Vector2& p_v) const;
Vector2 operator+(const Vector2 &p_v) const;
void operator+=(const Vector2& p_v);
void operator+=(const Vector2 &p_v);
Vector2 operator-(const Vector2& p_v) const;
Vector2 operator-(const Vector2 &p_v) const;
void operator-=(const Vector2& p_v);
void operator-=(const Vector2 &p_v);
Vector2 operator*(const Vector2 &p_v1) const;
@@ -52,13 +51,12 @@ struct Vector2 {
Vector2 operator-() const;
bool operator==(const Vector2& p_vec2) const;
bool operator==(const Vector2 &p_vec2) const;
bool operator!=(const Vector2& p_vec2) const;
inline bool operator<(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<p_vec2.y):(x<p_vec2.x); }
inline 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;
inline bool operator<(const Vector2 &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
inline bool operator<=(const Vector2 &p_vec2) const { return (x == p_vec2.x) ? (y <= p_vec2.y) : (x <= p_vec2.x); }
void normalize();
@@ -67,32 +65,31 @@ struct Vector2 {
real_t length() const;
real_t length_squared() const;
real_t distance_to(const Vector2& p_vector2) const;
real_t distance_squared_to(const Vector2& p_vector2) const;
real_t distance_to(const Vector2 &p_vector2) const;
real_t distance_squared_to(const Vector2 &p_vector2) const;
real_t angle_to(const Vector2& p_vector2) const;
real_t angle_to_point(const Vector2& p_vector2) const;
real_t angle_to(const Vector2 &p_vector2) const;
real_t angle_to_point(const Vector2 &p_vector2) const;
real_t dot(const Vector2& p_other) const;
real_t dot(const Vector2 &p_other) const;
real_t cross(const Vector2& p_other) const;
real_t cross(const Vector2 &p_other) const;
Vector2 cross(real_t p_other) const;
Vector2 project(const Vector2& p_vec) const;
Vector2 project(const Vector2 &p_vec) const;
Vector2 plane_project(real_t p_d, const Vector2& p_vec) const;
Vector2 plane_project(real_t p_d, const Vector2 &p_vec) const;
Vector2 clamped(real_t p_len) const;
static Vector2 linear_interpolate(const Vector2& p_a, const Vector2& p_b,real_t p_t);
static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t);
Vector2 linear_interpolate(const Vector2& p_b,real_t p_t) const;
Vector2 cubic_interpolate(const Vector2& p_b,const Vector2& p_pre_a, const Vector2& p_post_b,real_t p_t) const;
Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const;
Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
Vector2 slide(const Vector2 &p_vec) const;
Vector2 slide(const Vector2& p_vec) const;
Vector2 reflect(const Vector2& p_vec) const;
Vector2 reflect(const Vector2 &p_vec) const;
real_t angle() const;
@@ -105,24 +102,25 @@ struct Vector2 {
Vector2 floor() const;
Vector2 snapped(const Vector2& p_by) const;
inline real_t aspect() const { return width/height; }
Vector2 snapped(const Vector2 &p_by) const;
inline real_t aspect() const { return width / height; }
operator String() const;
inline Vector2(real_t p_x,real_t p_y) { x=p_x; y=p_y; }
inline Vector2() { x=0; y=0; }
inline Vector2(real_t p_x, real_t p_y) {
x = p_x;
y = p_y;
}
inline Vector2() {
x = 0;
y = 0;
}
};
inline Vector2 operator*(real_t p_scalar, const Vector2& p_vec)
{
return p_vec*p_scalar;
inline Vector2 operator*(real_t p_scalar, const Vector2 &p_vec) {
return p_vec * p_scalar;
}
}
} // namespace godot
#endif // VECTOR2_H

View File

@@ -31,68 +31,67 @@ struct Vector3 {
Vector3();
const real_t& operator[](int p_axis) const;
const real_t &operator[](int p_axis) const;
real_t& operator[](int p_axis);
real_t &operator[](int p_axis);
Vector3& operator+=(const Vector3& p_v);
Vector3 &operator+=(const Vector3 &p_v);
Vector3 operator+(const Vector3& p_v) const;
Vector3 operator+(const Vector3 &p_v) const;
Vector3& operator-=(const Vector3& p_v);
Vector3 &operator-=(const Vector3 &p_v);
Vector3 operator-(const Vector3& p_v) const;
Vector3 operator-(const Vector3 &p_v) const;
Vector3& operator*=(const Vector3& p_v);
Vector3 &operator*=(const Vector3 &p_v);
Vector3 operator*(const Vector3& p_v) const;
Vector3 operator*(const Vector3 &p_v) const;
Vector3& operator/=(const Vector3& p_v);
Vector3 &operator/=(const Vector3 &p_v);
Vector3 operator/(const Vector3& p_v) const;
Vector3 operator/(const Vector3 &p_v) const;
Vector3& operator*=(real_t p_scalar);
Vector3 &operator*=(real_t p_scalar);
Vector3 operator*(real_t p_scalar) const;
Vector3& operator/=(real_t p_scalar);
Vector3 &operator/=(real_t p_scalar);
Vector3 operator/(real_t p_scalar) const;
Vector3 operator-() const;
bool operator==(const Vector3& p_v) const;
bool operator==(const Vector3 &p_v) const;
bool operator!=(const Vector3& p_v) const;
bool operator!=(const Vector3 &p_v) const;
bool operator<(const Vector3& p_v) const;
bool operator<(const Vector3 &p_v) const;
bool operator<=(const Vector3& p_v) const;
bool operator<=(const Vector3 &p_v) const;
Vector3 abs() const;
Vector3 ceil() const;
Vector3 cross(const Vector3& b) const;
Vector3 cross(const Vector3 &b) const;
Vector3 linear_interpolate(const Vector3& p_b,real_t p_t) const;
Vector3 linear_interpolate(const Vector3 &p_b, real_t p_t) const;
Vector3 cubic_interpolate(const Vector3& b, const Vector3& pre_a, const Vector3& post_b, const real_t t) const;
Vector3 cubic_interpolate(const Vector3 &b, const Vector3 &pre_a, const Vector3 &post_b, const real_t t) const;
Vector3 bounce(const Vector3& p_normal) const;
Vector3 bounce(const Vector3 &p_normal) const;
real_t length() const;
real_t length_squared() const;
real_t distance_squared_to(const Vector3& b) const;
real_t distance_squared_to(const Vector3 &b) const;
real_t distance_to(const Vector3& b) const;
real_t distance_to(const Vector3 &b) const;
real_t dot(const Vector3& b) const;
real_t dot(const Vector3 &b) const;
real_t angle_to(const Vector3& b) const;
real_t angle_to(const Vector3 &b) const;
Vector3 floor() const;
@@ -100,9 +99,7 @@ struct Vector3 {
bool is_normalized() const;
Basis outer(const Vector3& b) const;
Basis outer(const Vector3 &b) const;
int max_axis() const;
@@ -112,13 +109,13 @@ struct Vector3 {
Vector3 normalized() const;
Vector3 reflect(const Vector3& by) const;
Vector3 reflect(const Vector3 &by) const;
Vector3 rotated(const Vector3& axis, const real_t phi) const;
Vector3 rotated(const Vector3 &axis, const real_t phi) const;
void rotate(const Vector3& p_axis,real_t p_phi);
void rotate(const Vector3 &p_axis, real_t p_phi);
Vector3 slide(const Vector3& by) const;
Vector3 slide(const Vector3 &by) const;
void snap(real_t p_val);
@@ -127,16 +124,15 @@ struct Vector3 {
operator String() const;
};
inline Vector3 operator*(real_t p_scalar, const Vector3& p_vec)
{
inline Vector3 operator*(real_t p_scalar, const Vector3 &p_vec) {
return p_vec * p_scalar;
}
inline Vector3 vec3_cross(const Vector3& p_a, const Vector3& p_b) {
inline Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {
return p_a.cross(p_b);
}
}
} // namespace godot
#endif // VECTOR3_H

View File

@@ -11,6 +11,6 @@ public:
size_t _type_tag;
};
}
} // namespace godot
#endif // WRAPPED_HPP