summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/godot_cpp')
-rw-r--r--include/godot_cpp/classes/wrapped.hpp5
-rw-r--r--include/godot_cpp/core/class_db.hpp4
-rw-r--r--include/godot_cpp/core/math.hpp8
-rw-r--r--include/godot_cpp/core/method_ptrcall.hpp8
-rw-r--r--include/godot_cpp/core/property_info.hpp38
-rw-r--r--include/godot_cpp/core/type_info.hpp10
-rw-r--r--include/godot_cpp/variant/aabb.hpp1
-rw-r--r--include/godot_cpp/variant/basis.hpp1
-rw-r--r--include/godot_cpp/variant/plane.hpp1
-rw-r--r--include/godot_cpp/variant/quaternion.hpp1
-rw-r--r--include/godot_cpp/variant/rect2.hpp1
-rw-r--r--include/godot_cpp/variant/transform2d.hpp1
-rw-r--r--include/godot_cpp/variant/transform3d.hpp1
-rw-r--r--include/godot_cpp/variant/vector2.hpp1
-rw-r--r--include/godot_cpp/variant/vector3.hpp1
-rw-r--r--include/godot_cpp/variant/vector4.hpp1
16 files changed, 77 insertions, 6 deletions
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp
index 97f9a6e..ce8c968 100644
--- a/include/godot_cpp/classes/wrapped.hpp
+++ b/include/godot_cpp/classes/wrapped.hpp
@@ -214,6 +214,7 @@ protected:
\
public: \
typedef m_class self_type; \
+ typedef m_inherits parent_type; \
\
static void initialize_class() { \
static bool initialized = false; \
@@ -381,6 +382,7 @@ private:
private: \
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
void operator=(const m_class &p_rval) {} \
+ friend class ::godot::ClassDB; \
\
protected: \
virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
@@ -390,6 +392,8 @@ protected:
m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
\
+ static void _bind_methods() {} \
+ \
static void (*_get_bind_methods())() { \
return nullptr; \
} \
@@ -432,6 +436,7 @@ protected:
\
public: \
typedef m_class self_type; \
+ typedef m_inherits parent_type; \
\
static void initialize_class() {} \
\
diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp
index e240193..31ebddc 100644
--- a/include/godot_cpp/core/class_db.hpp
+++ b/include/godot_cpp/core/class_db.hpp
@@ -203,6 +203,8 @@ public:
template <typename T, bool is_abstract>
void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
+ static_assert(!FunctionsAreSame<T::self_type::_bind_methods, T::parent_type::_bind_methods>::value, "Class must declare 'static void _bind_methods'.");
+ static_assert(!std::is_abstract_v<T> || is_abstract, "Class is abstract, please use GDREGISTER_ABSTRACT_CLASS.");
instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks;
// Register this class within our plugin
@@ -337,4 +339,6 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p
} // namespace godot
+CLASSDB_SINGLETON_VARIANT_CAST;
+
#endif // GODOT_CLASS_DB_HPP
diff --git a/include/godot_cpp/core/math.hpp b/include/godot_cpp/core/math.hpp
index 2cbbe27..1949360 100644
--- a/include/godot_cpp/core/math.hpp
+++ b/include/godot_cpp/core/math.hpp
@@ -613,6 +613,14 @@ inline bool is_inf(double p_val) {
return std::isinf(p_val);
}
+inline bool is_finite(float p_val) {
+ return std::isfinite(p_val);
+}
+
+inline bool is_finite(double p_val) {
+ return std::isfinite(p_val);
+}
+
inline bool is_equal_approx(float a, float b) {
// Check for exact equality first, required to handle "infinity" values.
if (a == b) {
diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp
index ca3327e..b12a7e6 100644
--- a/include/godot_cpp/core/method_ptrcall.hpp
+++ b/include/godot_cpp/core/method_ptrcall.hpp
@@ -170,11 +170,11 @@ template <typename T>
struct PtrToArg<T *> {
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
- return reinterpret_cast<T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
+ return likely(p_ptr) ? reinterpret_cast<T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)))) : nullptr;
}
typedef Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
- *reinterpret_cast<const void **>(p_ptr) = p_var ? p_var->_owner : nullptr;
+ *reinterpret_cast<const void **>(p_ptr) = likely(p_var) ? p_var->_owner : nullptr;
}
};
@@ -182,11 +182,11 @@ template <typename T>
struct PtrToArg<const T *> {
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
- return reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
+ return likely(p_ptr) ? reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)))) : nullptr;
}
typedef const Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
- *reinterpret_cast<const void **>(p_ptr) = p_var ? p_var->_owner : nullptr;
+ *reinterpret_cast<const void **>(p_ptr) = likely(p_var) ? p_var->_owner : nullptr;
}
};
diff --git a/include/godot_cpp/core/property_info.hpp b/include/godot_cpp/core/property_info.hpp
index f610f3f..dd71d48 100644
--- a/include/godot_cpp/core/property_info.hpp
+++ b/include/godot_cpp/core/property_info.hpp
@@ -47,9 +47,9 @@ struct PropertyInfo {
Variant::Type type = Variant::NIL;
StringName name;
StringName class_name;
- uint32_t hint = 0;
+ uint32_t hint = PROPERTY_HINT_NONE;
String hint_string;
- uint32_t usage = 7;
+ uint32_t usage = PROPERTY_USAGE_DEFAULT;
PropertyInfo() = default;
@@ -72,6 +72,40 @@ struct PropertyInfo {
PropertyInfo(const GDExtensionPropertyInfo *p_info) :
PropertyInfo(p_info->type, *reinterpret_cast<StringName *>(p_info->name), (PropertyHint)p_info->hint, *reinterpret_cast<String *>(p_info->hint_string), p_info->usage, *reinterpret_cast<StringName *>(p_info->class_name)) {}
+ operator Dictionary() const {
+ Dictionary dict;
+ dict["name"] = name;
+ dict["class_name"] = class_name;
+ dict["type"] = type;
+ dict["hint"] = hint;
+ dict["hint_string"] = hint_string;
+ dict["usage"] = usage;
+ return dict;
+ }
+
+ static PropertyInfo from_dict(const Dictionary &p_dict) {
+ PropertyInfo pi;
+ if (p_dict.has("type")) {
+ pi.type = Variant::Type(int(p_dict["type"]));
+ }
+ if (p_dict.has("name")) {
+ pi.name = p_dict["name"];
+ }
+ if (p_dict.has("class_name")) {
+ pi.class_name = p_dict["class_name"];
+ }
+ if (p_dict.has("hint")) {
+ pi.hint = PropertyHint(int(p_dict["hint"]));
+ }
+ if (p_dict.has("hint_string")) {
+ pi.hint_string = p_dict["hint_string"];
+ }
+ if (p_dict.has("usage")) {
+ pi.usage = p_dict["usage"];
+ }
+ return pi;
+ }
+
void _update(GDExtensionPropertyInfo *p_info) {
p_info->type = (GDExtensionVariantType)type;
*(reinterpret_cast<StringName *>(p_info->name)) = name;
diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp
index 5896651..096e0ec 100644
--- a/include/godot_cpp/core/type_info.hpp
+++ b/include/godot_cpp/core/type_info.hpp
@@ -58,6 +58,16 @@ struct TypesAreSame<A, A> {
static bool const value = true;
};
+template <auto A, auto B>
+struct FunctionsAreSame {
+ static bool const value = false;
+};
+
+template <auto A>
+struct FunctionsAreSame<A, A> {
+ static bool const value = true;
+};
+
template <typename B, typename D>
struct TypeInherits {
static D *get_d();
diff --git a/include/godot_cpp/variant/aabb.hpp b/include/godot_cpp/variant/aabb.hpp
index 8f2bce7..b827112 100644
--- a/include/godot_cpp/variant/aabb.hpp
+++ b/include/godot_cpp/variant/aabb.hpp
@@ -65,6 +65,7 @@ struct _NO_DISCARD_ AABB {
bool operator!=(const AABB &p_rval) const;
bool is_equal_approx(const AABB &p_aabb) const;
+ bool is_finite() const;
_FORCE_INLINE_ bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap
_FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
_FORCE_INLINE_ bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this
diff --git a/include/godot_cpp/variant/basis.hpp b/include/godot_cpp/variant/basis.hpp
index a365b02..e740a64 100644
--- a/include/godot_cpp/variant/basis.hpp
+++ b/include/godot_cpp/variant/basis.hpp
@@ -128,6 +128,7 @@ struct _NO_DISCARD_ Basis {
}
bool is_equal_approx(const Basis &p_basis) const;
+ bool is_finite() const;
bool operator==(const Basis &p_matrix) const;
bool operator!=(const Basis &p_matrix) const;
diff --git a/include/godot_cpp/variant/plane.hpp b/include/godot_cpp/variant/plane.hpp
index 727f4f5..829f801 100644
--- a/include/godot_cpp/variant/plane.hpp
+++ b/include/godot_cpp/variant/plane.hpp
@@ -77,6 +77,7 @@ struct _NO_DISCARD_ Plane {
Plane operator-() const { return Plane(-normal, -d); }
bool is_equal_approx(const Plane &p_plane) const;
bool is_equal_approx_any_side(const Plane &p_plane) const;
+ bool is_finite() const;
_FORCE_INLINE_ bool operator==(const Plane &p_plane) const;
_FORCE_INLINE_ bool operator!=(const Plane &p_plane) const;
diff --git a/include/godot_cpp/variant/quaternion.hpp b/include/godot_cpp/variant/quaternion.hpp
index 3816b66..5de91b2 100644
--- a/include/godot_cpp/variant/quaternion.hpp
+++ b/include/godot_cpp/variant/quaternion.hpp
@@ -55,6 +55,7 @@ struct _NO_DISCARD_ Quaternion {
}
_FORCE_INLINE_ real_t length_squared() const;
bool is_equal_approx(const Quaternion &p_quaternion) const;
+ bool is_finite() const;
real_t length() const;
void normalize();
Quaternion normalized() const;
diff --git a/include/godot_cpp/variant/rect2.hpp b/include/godot_cpp/variant/rect2.hpp
index 201e02b..e643035 100644
--- a/include/godot_cpp/variant/rect2.hpp
+++ b/include/godot_cpp/variant/rect2.hpp
@@ -205,6 +205,7 @@ struct _NO_DISCARD_ Rect2 {
}
bool is_equal_approx(const Rect2 &p_rect) const;
+ bool is_finite() const;
bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; }
bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
diff --git a/include/godot_cpp/variant/transform2d.hpp b/include/godot_cpp/variant/transform2d.hpp
index 5a48398..d73323f 100644
--- a/include/godot_cpp/variant/transform2d.hpp
+++ b/include/godot_cpp/variant/transform2d.hpp
@@ -99,6 +99,7 @@ struct _NO_DISCARD_ Transform2D {
void orthonormalize();
Transform2D orthonormalized() const;
bool is_equal_approx(const Transform2D &p_transform) const;
+ bool is_finite() const;
Transform2D looking_at(const Vector2 &p_target) const;
diff --git a/include/godot_cpp/variant/transform3d.hpp b/include/godot_cpp/variant/transform3d.hpp
index 3a54c0b..6fa5999 100644
--- a/include/godot_cpp/variant/transform3d.hpp
+++ b/include/godot_cpp/variant/transform3d.hpp
@@ -78,6 +78,7 @@ struct _NO_DISCARD_ Transform3D {
void orthogonalize();
Transform3D orthogonalized() const;
bool is_equal_approx(const Transform3D &p_transform) const;
+ bool is_finite() const;
bool operator==(const Transform3D &p_transform) const;
bool operator!=(const Transform3D &p_transform) const;
diff --git a/include/godot_cpp/variant/vector2.hpp b/include/godot_cpp/variant/vector2.hpp
index 51dd8cc..8f08985 100644
--- a/include/godot_cpp/variant/vector2.hpp
+++ b/include/godot_cpp/variant/vector2.hpp
@@ -131,6 +131,7 @@ struct _NO_DISCARD_ Vector2 {
bool is_equal_approx(const Vector2 &p_v) const;
bool is_zero_approx() const;
+ bool is_finite() const;
Vector2 operator+(const Vector2 &p_v) const;
void operator+=(const Vector2 &p_v);
diff --git a/include/godot_cpp/variant/vector3.hpp b/include/godot_cpp/variant/vector3.hpp
index 0d3ad62..f256c38 100644
--- a/include/godot_cpp/variant/vector3.hpp
+++ b/include/godot_cpp/variant/vector3.hpp
@@ -157,6 +157,7 @@ struct _NO_DISCARD_ Vector3 {
bool is_equal_approx(const Vector3 &p_v) const;
bool is_zero_approx() const;
+ bool is_finite() const;
/* Operators */
diff --git a/include/godot_cpp/variant/vector4.hpp b/include/godot_cpp/variant/vector4.hpp
index a2e8fae..866e522 100644
--- a/include/godot_cpp/variant/vector4.hpp
+++ b/include/godot_cpp/variant/vector4.hpp
@@ -89,6 +89,7 @@ struct _NO_DISCARD_ Vector4 {
_FORCE_INLINE_ real_t length_squared() const;
bool is_equal_approx(const Vector4 &p_vec4) const;
bool is_zero_approx() const;
+ bool is_finite() const;
real_t length() const;
void normalize();
Vector4 normalized() const;