Add ptr() / ptrw() to the arrays, add missing String methods, add missing CharString method implementations.

This commit is contained in:
bruvzg
2022-02-09 12:36:22 +02:00
parent be34bcfff1
commit bf8fc4c53d
20 changed files with 380 additions and 158 deletions

View File

@@ -44,9 +44,11 @@
namespace godot {
class AABB {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
Vector3 position;
Vector3 size;
@@ -73,8 +75,8 @@ public:
inline 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
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;
inline bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;

View File

@@ -38,9 +38,11 @@
namespace godot {
class Basis {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
Vector3 elements[3] = {
Vector3(1, 0, 0),
Vector3(0, 1, 0),

View File

@@ -48,6 +48,9 @@ public:
int length() const;
const char *get_data() const;
CharString(CharString &&p_str);
void operator=(CharString &&p_str);
CharString() {}
~CharString();
};
@@ -63,6 +66,9 @@ public:
int length() const;
const char16_t *get_data() const;
Char16String(Char16String &&p_str);
void operator=(Char16String &&p_str);
Char16String() {}
~Char16String();
};
@@ -78,6 +84,9 @@ public:
int length() const;
const char32_t *get_data() const;
Char32String(Char32String &&p_str);
void operator=(Char32String &&p_str);
Char32String() {}
~Char32String();
};
@@ -93,6 +102,9 @@ public:
int length() const;
const wchar_t *get_data() const;
CharWideString(CharWideString &&p_str);
void operator=(CharWideString &&p_str);
CharWideString() {}
~CharWideString();
};

View File

@@ -38,9 +38,11 @@ namespace godot {
class String;
class Color {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
union {
struct {
float r;
@@ -198,7 +200,7 @@ public:
static Color from_hsv(float p_h, float p_s, float p_v, float p_a);
static Color from_rgbe9995(uint32_t p_rgbe);
inline bool operator<(const Color &p_color) const; //used in set keys
inline bool operator<(const Color &p_color) const; // used in set keys
operator String() const;
// For the binder.

View File

@@ -38,14 +38,16 @@
namespace godot {
class Plane {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
Vector3 normal;
real_t d = 0;
void set_normal(const Vector3 &p_normal);
inline Vector3 get_normal() const { return normal; }; ///Point is coplanar, CMP_EPSILON for precision
inline Vector3 get_normal() const { return normal; }; /// Point is coplanar, CMP_EPSILON for precision
void normalize();
Plane normalized() const;

View File

@@ -37,9 +37,11 @@
namespace godot {
class Quaternion {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
union {
struct {
real_t x;

View File

@@ -40,9 +40,11 @@ namespace godot {
class Transform2D;
class Rect2 {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
Point2 position;
Size2 size;
@@ -161,7 +163,7 @@ public:
new_rect.size.x = Math::max(p_rect.position.x + p_rect.size.x, position.x + size.x);
new_rect.size.y = Math::max(p_rect.position.y + p_rect.size.y, position.y + size.y);
new_rect.size = new_rect.size - new_rect.position; //make relative again
new_rect.size = new_rect.size - new_rect.position; // make relative again
return new_rect;
}
@@ -225,7 +227,7 @@ public:
return r;
}
inline void expand_to(const Vector2 &p_vector) { //in place function for speed
inline void expand_to(const Vector2 &p_vector) { // in place function for speed
Vector2 begin = position;
Vector2 end = position + size;
@@ -279,7 +281,7 @@ public:
continue;
}
//check inside
// check inside
Vector2 tg = r.orthogonal();
float s = tg.dot(center) - tg.dot(a);
if (s < 0.0) {
@@ -288,7 +290,7 @@ public:
side_minus++;
}
//check ray box
// check ray box
r /= l;
Vector2 ir((real_t)1.0 / r.x, (real_t)1.0 / r.y);
@@ -309,7 +311,7 @@ public:
}
if (side_plus * side_minus == 0) {
return true; //all inside
return true; // all inside
} else {
return false;
}

View File

@@ -37,9 +37,11 @@
namespace godot {
class Rect2i {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
Point2i position;
Size2i size;
@@ -107,7 +109,7 @@ public:
new_rect.size.x = Math::max(p_rect.position.x + p_rect.size.x, position.x + size.x);
new_rect.size.y = Math::max(p_rect.position.y + p_rect.size.y, position.y + size.y);
new_rect.size = new_rect.size - new_rect.position; //make relative again
new_rect.size = new_rect.size - new_rect.position; // make relative again
return new_rect;
}

View File

@@ -40,9 +40,11 @@
namespace godot {
class Transform2D {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
// M = (elements[0][0] elements[1][0])
// (elements[0][1] elements[1][1])

View File

@@ -40,9 +40,11 @@
namespace godot {
class Transform3D {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
Basis basis;
Vector3 origin;

View File

@@ -45,7 +45,7 @@ namespace godot {
class Variant {
uint8_t opaque[GODOT_CPP_VARIANT_SIZE]{ 0 };
_FORCE_INLINE_ GDNativeVariantPtr ptr() const { return const_cast<uint8_t(*)[GODOT_CPP_VARIANT_SIZE]>(&opaque); }
_FORCE_INLINE_ GDNativeVariantPtr _native_ptr() const { return const_cast<uint8_t(*)[GODOT_CPP_VARIANT_SIZE]>(&opaque); }
friend class GDExtensionBinding;
friend class MethodBind;

View File

@@ -39,9 +39,11 @@ namespace godot {
class Vector2i;
class Vector2 {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
enum Axis {
AXIS_X,
AXIS_Y,

View File

@@ -38,9 +38,11 @@
namespace godot {
class Vector2i {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
enum Axis {
AXIS_X,
AXIS_Y,

View File

@@ -40,9 +40,11 @@ class Basis;
class Vector3i;
class Vector3 {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
enum Axis {
AXIS_X,
AXIS_Y,

View File

@@ -37,9 +37,11 @@
namespace godot {
class Vector3i {
public:
_FORCE_INLINE_ GDNativeTypePtr ptr() const { return (void *)this; }
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
friend class Variant;
public:
enum Axis {
AXIS_X,
AXIS_Y,