Update bindings to use new Api extensions and rename Rect3->AABB

This commit is contained in:
BastiaanOlij
2017-11-23 22:50:05 +11:00
parent e72f4beec1
commit 0f773c2d72
16 changed files with 154 additions and 95 deletions

View File

@@ -1,5 +1,5 @@
#ifndef RECT3_H
#define RECT3_H
#ifndef AABB_H
#define AABB_H
#include "Vector3.hpp"
@@ -9,7 +9,7 @@
namespace godot {
class Rect3 {
class AABB {
public:
Vector3 pos;
Vector3 size;
@@ -31,16 +31,16 @@ public:
inline void set_size(const Vector3& p_size) { size=p_size; }
bool operator==(const Rect3& p_rval) const;
bool operator!=(const Rect3& p_rval) const;
bool operator==(const AABB& p_rval) const;
bool operator!=(const AABB& p_rval) const;
bool intersects(const Rect3& p_aabb) const; /// Both AABBs overlap
bool intersects_inclusive(const Rect3& p_aabb) const; /// Both AABBs (or their faces) overlap
bool encloses(const Rect3 & 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
Rect3 merge(const Rect3& p_with) const;
void merge_with(const Rect3& p_aabb); ///merge with another AABB
Rect3 intersection(const Rect3& p_aabb) const; ///get box where two intersect, empty if no intersection occurs
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=NULL,Vector3* r_normal=NULL) const;
bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const;
bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, real_t t0, real_t t1) const;
@@ -60,20 +60,20 @@ public:
int get_shortest_axis_index() const;
real_t get_shortest_axis_size() const;
Rect3 grow(real_t p_by) const;
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;
Vector3 get_endpoint(int p_point) const;
Rect3 expand(const Vector3& p_vector) 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 */
operator String() const;
inline Rect3() {}
inline Rect3(const Vector3 &p_pos,const Vector3& p_size) { pos=p_pos; size=p_size; }
inline AABB() {}
inline AABB(const Vector3 &p_pos,const Vector3& p_size) { pos=p_pos; size=p_size; }
};

View File

@@ -3,6 +3,7 @@
#include "Defs.hpp"
#include "AABB.hpp"
#include "Array.hpp"
#include "Basis.hpp"
#include "Color.hpp"
@@ -12,7 +13,6 @@
#include "PoolArrays.hpp"
#include "Quat.hpp"
#include "Rect2.hpp"
#include "Rect3.hpp"
#include "RID.hpp"
#include "String.hpp"
#include "Transform.hpp"

View File

@@ -87,7 +87,7 @@ typedef float real_t;
#ifndef ERR_PRINT
#define ERR_PRINT(msg) fprintf(stderr, "ERROR: %s\n", (msg).c_string())
#define ERR_PRINT(msg) fprintf(stderr, "ERROR: %S\n", (msg).unicode_str())
#endif
#ifndef ERR_FAIL_INDEX_V

View File

@@ -86,7 +86,7 @@ struct _ArgCast<Variant> {
template<class T>
T *as(Object *obj)
{
return (T *) godot::api->godot_nativescript_get_userdata(obj);
return (T *) godot::nativescript_api->godot_nativescript_get_userdata(obj);
}
// instance and destroy funcs
@@ -118,7 +118,7 @@ void register_class()
destroy.destroy_func = _godot_class_destroy_func<T>;
godot::api->godot_nativescript_register_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
godot::nativescript_api->godot_nativescript_register_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
T::_register_methods();
}
@@ -132,7 +132,7 @@ void register_tool_class()
destroy.destroy_func = _godot_class_destroy_func<T>;
godot::api->godot_nativescript_register_tool_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
godot::nativescript_api->godot_nativescript_register_tool_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
T::_register_methods();
}
@@ -285,7 +285,7 @@ void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_t
godot_method_attributes attr = {};
attr.rpc_type = rpc_type;
godot::api->godot_nativescript_register_method(godot::_RegisterState::nativescript_handle, ___get_method_class_name(method_ptr), name, attr, method);
godot::nativescript_api->godot_nativescript_register_method(godot::_RegisterState::nativescript_handle, ___get_method_class_name(method_ptr), name, attr, method);
}
@@ -403,7 +403,7 @@ void register_property(const char *name, P (T::*var), P default_value, godot_met
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyDefaultGetFunc<T, P>::_wrapped_getter;
godot::api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
godot::nativescript_api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
}
@@ -437,7 +437,7 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(),
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyGetFunc<T, P>::_wrapped_getter;
godot::api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
godot::nativescript_api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
}
@@ -466,7 +466,7 @@ void register_signal(String name, Dictionary args = Dictionary())
signal.args[i].type = args.values()[i];
}
godot::api->godot_nativescript_register_signal(godot::_RegisterState::nativescript_handle, T::___get_type_name(), &signal);
godot::nativescript_api->godot_nativescript_register_signal(godot::_RegisterState::nativescript_handle, T::___get_type_name(), &signal);
for (int i = 0; i < signal.num_args; i++) {
godot::api->godot_string_destroy(&signal.args[i].name);

View File

@@ -7,7 +7,8 @@
namespace godot {
extern "C" const godot_gdnative_api_struct *api;
extern "C" const godot_gdnative_core_api_struct *api;
extern "C" const godot_gdnative_ext_nativescript_api_struct *nativescript_api;
class Godot {

View File

@@ -24,8 +24,6 @@ public:
int get_name_count() const;
String get_property() const;
String get_subname(const int idx) const;
int get_subname_count() const;

View File

@@ -40,7 +40,8 @@ public:
operator NodePath() const;
int length() const;
const char *c_string() const;
const wchar_t *unicode_str() const;
void get_c_string(char *p_dest, int *p_size) const;
int64_t find(String p_what) const;
int64_t find_from(String p_what, int64_t p_from) const;
@@ -106,6 +107,8 @@ public:
};
String operator+(const char *a, const String &b);
String operator+(const wchar_t *a, const String &b);
}
#endif // STRING_H

View File

@@ -4,7 +4,7 @@
#include "Basis.hpp"
#include "Plane.hpp"
#include "Rect3.hpp"
#include "AABB.hpp"
namespace godot {
@@ -53,8 +53,8 @@ public:
Plane xform(const Plane& p_plane) const;
Plane xform_inv(const Plane& p_plane) const;
Rect3 xform(const Rect3& p_aabb) const;
Rect3 xform_inv(const Rect3& 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;

View File

@@ -5,6 +5,7 @@
#include "Defs.hpp"
#include "AABB.hpp"
#include "Basis.hpp"
#include "Color.hpp"
#include "NodePath.hpp"
@@ -12,7 +13,6 @@
#include "PoolArrays.hpp"
#include "Quat.hpp"
#include "Rect2.hpp"
#include "Rect3.hpp"
#include "RID.hpp"
#include "String.hpp"
#include "Transform.hpp"
@@ -154,7 +154,7 @@ public:
Variant(const Plane& p_plane);
Variant(const Rect3& p_aabb);
Variant(const AABB& p_aabb);
Variant(const Quat& p_quat);
@@ -215,7 +215,7 @@ public:
operator Rect2() const;
operator Vector3() const;
operator Plane() const;
operator Rect3() const;
operator AABB() const;
operator Quat() const;
operator Basis() const;
operator Transform() const;