mirror of
https://github.com/Relintai/gdnative_cpp.git
synced 2024-11-20 10:57:23 +01:00
Include cleanups, and various fixes.
This commit is contained in:
parent
6b167533d6
commit
cbb15f8b7d
@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
|
|
||||||
#include "Plane.hpp"
|
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
|
class Plane;
|
||||||
|
|
||||||
class AABB {
|
class AABB {
|
||||||
public:
|
public:
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
#include <gdn/array.h>
|
#include <gdn/array.h>
|
||||||
|
|
||||||
#include "String.hpp"
|
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
|
class String;
|
||||||
|
|
||||||
namespace helpers {
|
namespace helpers {
|
||||||
template <typename T, typename ValueT>
|
template <typename T, typename ValueT>
|
||||||
T append_all(T appendable, ValueT value) {
|
T append_all(T appendable, ValueT value) {
|
||||||
|
@ -332,7 +332,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis(const Quat &p_quat); // euler
|
Basis(const Quat &p_quaternion); // euler
|
||||||
Basis(const Vector3 &p_euler); // euler
|
Basis(const Vector3 &p_euler); // euler
|
||||||
Basis(const Vector3 &p_axis, real_t p_phi);
|
Basis(const Vector3 &p_axis, real_t p_phi);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define CAMERA_MATRIX_H
|
#define CAMERA_MATRIX_H
|
||||||
|
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
#include "Math.hpp"
|
#include "Mathp.hpp"
|
||||||
#include "Plane.hpp"
|
#include "Plane.hpp"
|
||||||
#include "Rect2.hpp"
|
#include "Rect2.hpp"
|
||||||
#include "Transform.hpp"
|
#include "Transform.hpp"
|
||||||
@ -68,7 +68,7 @@ struct CameraMatrix {
|
|||||||
void set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov = false);
|
void set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov = false);
|
||||||
|
|
||||||
static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
|
static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
|
||||||
return Math::rad2deg(atan(p_aspect * tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0);
|
return Mathp::rad2deg(atan(p_aspect * tan(Mathp::deg2rad(p_fovx) * 0.5)) * 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double absd(double g) {
|
static inline double absd(double g) {
|
||||||
|
@ -31,14 +31,15 @@
|
|||||||
#ifndef DICTIONARY_H
|
#ifndef DICTIONARY_H
|
||||||
#define DICTIONARY_H
|
#define DICTIONARY_H
|
||||||
|
|
||||||
#include "Variant.hpp"
|
|
||||||
|
|
||||||
#include "Array.hpp"
|
#include "Array.hpp"
|
||||||
|
#include "Variant.hpp"
|
||||||
|
|
||||||
#include <gdn/dictionary.h>
|
#include <gdn/dictionary.h>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
|
class Variant;
|
||||||
|
|
||||||
class Dictionary {
|
class Dictionary {
|
||||||
pandemonium_dictionary _pandemonium_dictionary;
|
pandemonium_dictionary _pandemonium_dictionary;
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ __pandemonium_wrapper_method ___get_wrapper_function(R (T::*f)(A...) const) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
void register_method(const char *name, M method_ptr, pandemonium_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED) {
|
void register_method(const char *name, M method_ptr, pandemonium_method_rpc_mode rpc_type = PANDEMONIUM_METHOD_RPC_MODE_DISABLED) {
|
||||||
pandemonium_instance_method method = {};
|
pandemonium_instance_method method = {};
|
||||||
method.method_data = ___make_wrapper_function(method_ptr);
|
method.method_data = ___make_wrapper_function(method_ptr);
|
||||||
method.free_func = godot::api->pandemonium_free;
|
method.free_func = godot::api->pandemonium_free;
|
||||||
@ -352,7 +352,7 @@ void register_method(const char *name, M method_ptr, pandemonium_method_rpc_mode
|
|||||||
// User can specify a derived class D to register the method for, instead of it being inferred.
|
// User can specify a derived class D to register the method for, instead of it being inferred.
|
||||||
template <class D, class B, class R, class... As>
|
template <class D, class B, class R, class... As>
|
||||||
void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
|
void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
|
||||||
pandemonium_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED) {
|
pandemonium_method_rpc_mode rpc_type = PANDEMONIUM_METHOD_RPC_MODE_DISABLED) {
|
||||||
static_assert(std::is_base_of<B, D>::value, "Explicit class must derive from method class");
|
static_assert(std::is_base_of<B, D>::value, "Explicit class must derive from method class");
|
||||||
register_method(name, static_cast<R (D::*)(As...)>(method_ptr), rpc_type);
|
register_method(name, static_cast<R (D::*)(As...)>(method_ptr), rpc_type);
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ struct _PropertyDefaultGetFunc {
|
|||||||
|
|
||||||
template <class T, class P>
|
template <class T, class P>
|
||||||
void register_property(const char *name, P(T::*var), P default_value,
|
void register_property(const char *name, P(T::*var), P default_value,
|
||||||
pandemonium_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
pandemonium_method_rpc_mode rpc_mode = PANDEMONIUM_METHOD_RPC_MODE_DISABLED,
|
||||||
pandemonium_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
pandemonium_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||||
pandemonium_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
pandemonium_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
||||||
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||||
@ -478,7 +478,7 @@ void register_property(const char *name, P(T::*var), P default_value,
|
|||||||
|
|
||||||
template <class T, class P>
|
template <class T, class P>
|
||||||
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(), P default_value,
|
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(), P default_value,
|
||||||
pandemonium_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
pandemonium_method_rpc_mode rpc_mode = PANDEMONIUM_METHOD_RPC_MODE_DISABLED,
|
||||||
pandemonium_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
pandemonium_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||||
pandemonium_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
pandemonium_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
||||||
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||||
@ -521,7 +521,7 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(),
|
|||||||
|
|
||||||
template <class T, class P>
|
template <class T, class P>
|
||||||
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)() const, P default_value,
|
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)() const, P default_value,
|
||||||
pandemonium_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
pandemonium_method_rpc_mode rpc_mode = PANDEMONIUM_METHOD_RPC_MODE_DISABLED,
|
||||||
pandemonium_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
pandemonium_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||||
pandemonium_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
pandemonium_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);
|
register_property(name, setter, (P(T::*)())getter, default_value, rpc_mode, usage, hint, hint_string);
|
||||||
|
@ -31,12 +31,16 @@
|
|||||||
#ifndef GODOT_GLOBAL_HPP
|
#ifndef GODOT_GLOBAL_HPP
|
||||||
#define GODOT_GLOBAL_HPP
|
#define GODOT_GLOBAL_HPP
|
||||||
|
|
||||||
#include "Array.hpp"
|
|
||||||
#include "String.hpp"
|
|
||||||
#include <gdnative_api_struct.gen.h>
|
#include <gdnative_api_struct.gen.h>
|
||||||
|
|
||||||
|
#include "Array.hpp"
|
||||||
|
#include "String.hpp"
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
|
class Array;
|
||||||
|
class String;
|
||||||
|
|
||||||
extern "C" const pandemonium_gdnative_core_api_struct *api;
|
extern "C" const pandemonium_gdnative_core_api_struct *api;
|
||||||
|
|
||||||
extern "C" const pandemonium_gdnative_ext_nativescript_api_struct *nativescript_api;
|
extern "C" const pandemonium_gdnative_ext_nativescript_api_struct *nativescript_api;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef GODOT_PROFILING_HPP
|
#ifndef GODOT_PROFILING_HPP
|
||||||
#define GODOT_PROFILING_HPP
|
#define GODOT_PROFILING_HPP
|
||||||
|
|
||||||
#include "OS.hpp"
|
#include "Defs.hpp"
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
@ -40,16 +40,8 @@ class FunctionProfiling {
|
|||||||
uint64_t ticks;
|
uint64_t ticks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FunctionProfiling(const char *p_function, const int p_line) {
|
FunctionProfiling(const char *p_function, const int p_line);
|
||||||
snprintf(signature, 1024, "::%d::%s", p_line, p_function);
|
~FunctionProfiling();
|
||||||
ticks = OS::get_singleton()->get_ticks_usec();
|
|
||||||
}
|
|
||||||
~FunctionProfiling() {
|
|
||||||
uint64_t t = OS::get_singleton()->get_ticks_usec() - ticks;
|
|
||||||
if (t > 0) {
|
|
||||||
Godot::gdnative_profiling_add_data(signature, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace godot
|
} // namespace godot
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
namespace Math {
|
namespace Mathp {
|
||||||
|
|
||||||
// Functions reproduced as in Godot's source code `math_funcs.h`.
|
// Functions reproduced as in Godot's source code `math_funcs.h`.
|
||||||
// Some are overloads to automatically support changing real_t into either double or float in the way Godot does.
|
// Some are overloads to automatically support changing real_t into either double or float in the way Godot does.
|
||||||
@ -183,10 +183,10 @@ inline float inverse_lerp(float p_from, float p_to, float p_value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) {
|
inline double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) {
|
||||||
return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value));
|
return Mathp::lerp(p_ostart, p_ostop, Mathp::inverse_lerp(p_istart, p_istop, p_value));
|
||||||
}
|
}
|
||||||
inline float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) {
|
inline float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) {
|
||||||
return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value));
|
return Mathp::lerp(p_ostart, p_ostop, Mathp::inverse_lerp(p_istart, p_istop, p_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_equal_approx(real_t a, real_t b) {
|
inline bool is_equal_approx(real_t a, real_t b) {
|
@ -31,12 +31,12 @@
|
|||||||
#ifndef NODEPATH_H
|
#ifndef NODEPATH_H
|
||||||
#define NODEPATH_H
|
#define NODEPATH_H
|
||||||
|
|
||||||
#include "String.hpp"
|
|
||||||
|
|
||||||
#include <gdn/node_path.h>
|
#include <gdn/node_path.h>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
|
class String;
|
||||||
|
|
||||||
class NodePath {
|
class NodePath {
|
||||||
pandemonium_node_path _node_path;
|
pandemonium_node_path _node_path;
|
||||||
|
|
||||||
|
@ -93,8 +93,8 @@ public:
|
|||||||
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_quaternion) const;
|
||||||
bool operator!=(const Quat &p_quat) const;
|
bool operator!=(const Quat &p_quaternion) const;
|
||||||
|
|
||||||
operator String() const;
|
operator String() const;
|
||||||
|
|
||||||
|
@ -201,9 +201,9 @@ public:
|
|||||||
|
|
||||||
Variant(const Plane &p_plane);
|
Variant(const Plane &p_plane);
|
||||||
|
|
||||||
Variant(const ::AABB &p_aabb);
|
Variant(const godot::AABB &p_aabb);
|
||||||
|
|
||||||
Variant(const Quat &p_quat);
|
Variant(const Quat &p_quaternion);
|
||||||
|
|
||||||
Variant(const Basis &p_transform);
|
Variant(const Basis &p_transform);
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ public:
|
|||||||
|
|
||||||
Variant(const NodePath &p_path);
|
Variant(const NodePath &p_path);
|
||||||
|
|
||||||
Variant(const ::RID &p_rid);
|
Variant(const godot::RID &p_rid);
|
||||||
|
|
||||||
Variant(const Object *p_object);
|
Variant(const Object *p_object);
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ public:
|
|||||||
operator Rect2() const;
|
operator Rect2() const;
|
||||||
operator Vector3() const;
|
operator Vector3() const;
|
||||||
operator Plane() const;
|
operator Plane() const;
|
||||||
operator ::AABB() const;
|
operator godot::AABB() const;
|
||||||
operator Quat() const;
|
operator Quat() const;
|
||||||
operator Basis() const;
|
operator Basis() const;
|
||||||
operator Transform() const;
|
operator Transform() const;
|
||||||
@ -269,7 +269,7 @@ public:
|
|||||||
operator Color() const;
|
operator Color() const;
|
||||||
|
|
||||||
operator NodePath() const;
|
operator NodePath() const;
|
||||||
operator ::RID() const;
|
operator godot::RID() const;
|
||||||
operator pandemonium_object *() const;
|
operator pandemonium_object *() const;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
|
|
||||||
#include <Math.hpp>
|
#include <Mathp.hpp>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
@ -267,13 +267,13 @@ struct Vector2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Vector2 floor() const {
|
inline Vector2 floor() const {
|
||||||
return Vector2(Math::floor(x), Math::floor(y));
|
return Vector2(Mathp::floor(x), Mathp::floor(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector2 snapped(const Vector2 &p_by) const {
|
inline Vector2 snapped(const Vector2 &p_by) const {
|
||||||
return Vector2(
|
return Vector2(
|
||||||
Math::stepify(x, p_by.x),
|
Mathp::stepify(x, p_by.x),
|
||||||
Math::stepify(y, p_by.y));
|
Mathp::stepify(y, p_by.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline real_t aspect() const { return width / height; }
|
inline real_t aspect() const { return width / height; }
|
||||||
@ -290,13 +290,13 @@ namespace Math {
|
|||||||
// Convenience, since they exist in GDScript
|
// Convenience, since they exist in GDScript
|
||||||
|
|
||||||
inline Vector2 cartesian2polar(Vector2 v) {
|
inline Vector2 cartesian2polar(Vector2 v) {
|
||||||
return Vector2(Math::sqrt(v.x * v.x + v.y * v.y), Math::atan2(v.y, v.x));
|
return Vector2(Mathp::sqrt(v.x * v.x + v.y * v.y), Mathp::atan2(v.y, v.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector2 polar2cartesian(Vector2 v) {
|
inline Vector2 polar2cartesian(Vector2 v) {
|
||||||
// x == radius
|
// x == radius
|
||||||
// y == angle
|
// y == angle
|
||||||
return Vector2(v.x * Math::cos(v.y), v.x * Math::sin(v.y));
|
return Vector2(v.x * Mathp::cos(v.y), v.x * Mathp::sin(v.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Math
|
} // namespace Math
|
||||||
|
@ -35,13 +35,12 @@
|
|||||||
|
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
|
|
||||||
#include "String.hpp"
|
#include <Mathp.hpp>
|
||||||
|
|
||||||
#include <Math.hpp>
|
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
class Basis;
|
class Basis;
|
||||||
|
class String;
|
||||||
|
|
||||||
struct Vector3 {
|
struct Vector3 {
|
||||||
enum Axis {
|
enum Axis {
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "Array.hpp"
|
#include "Array.hpp"
|
||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
#include "Variant.hpp"
|
#include "Variant.hpp"
|
||||||
|
#include "String.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ Variant Array::back() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Array::find(const Variant &what, const int from) const {
|
int Array::find(const Variant &what, const int from) const {
|
||||||
return godot::api->pandemonium_array_find(&_pandemonium_array, (pandemonium_variant *)&what, from);
|
return godot::api->pandemonium_array_find_from(&_pandemonium_array, (pandemonium_variant *)&what, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Array::find_last(const Variant &what) const {
|
int Array::find_last(const Variant &what) const {
|
||||||
@ -179,7 +180,7 @@ void Array::resize(const int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Array::rfind(const Variant &what, const int from) const {
|
int Array::rfind(const Variant &what, const int from) const {
|
||||||
return godot::api->pandemonium_array_rfind(&_pandemonium_array, (pandemonium_variant *)&what, from);
|
return godot::api->pandemonium_array_rfind_from(&_pandemonium_array, (pandemonium_variant *)&what, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Array::sort() {
|
void Array::sort() {
|
||||||
@ -201,7 +202,7 @@ int Array::bsearch_custom(const Variant &value, const Object *obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Array Array::duplicate(const bool deep) const {
|
Array Array::duplicate(const bool deep) const {
|
||||||
pandemonium_array arr = godot::api->pandemonium_array_duplicate(&_pandemonium_array, deep);
|
pandemonium_array arr = godot::api->pandemonium_array_duplicate_deep(&_pandemonium_array, deep);
|
||||||
return Array(arr);
|
return Array(arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,13 +640,13 @@ Basis::Basis(const Vector3 &p_euler) {
|
|||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
Basis::Basis(const Quat &p_quat) {
|
Basis::Basis(const Quat &p_quaternion) {
|
||||||
real_t d = p_quat.length_squared();
|
real_t d = p_quaternion.length_squared();
|
||||||
real_t s = 2.0 / d;
|
real_t s = 2.0 / d;
|
||||||
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
real_t xs = p_quaternion.x * s, ys = p_quaternion.y * s, zs = p_quaternion.z * s;
|
||||||
real_t wx = p_quat.w * xs, wy = p_quat.w * ys, wz = p_quat.w * zs;
|
real_t wx = p_quaternion.w * xs, wy = p_quaternion.w * ys, wz = p_quaternion.w * zs;
|
||||||
real_t xx = p_quat.x * xs, xy = p_quat.x * ys, xz = p_quat.x * zs;
|
real_t xx = p_quaternion.x * xs, xy = p_quaternion.x * ys, xz = p_quaternion.x * zs;
|
||||||
real_t yy = p_quat.y * ys, yz = p_quat.y * zs, zz = p_quat.z * zs;
|
real_t yy = p_quaternion.y * ys, yz = p_quaternion.y * zs, zz = p_quaternion.z * zs;
|
||||||
set(1.0 - (yy + zz), xy - wz, xz + wy,
|
set(1.0 - (yy + zz), xy - wz, xz + wy,
|
||||||
xy + wz, 1.0 - (xx + zz), yz - wx,
|
xy + wz, 1.0 - (xx + zz), yz - wx,
|
||||||
xz - wy, yz + wx, 1.0 - (xx + yy));
|
xz - wy, yz + wx, 1.0 - (xx + yy));
|
||||||
|
@ -561,7 +561,7 @@ real_t CameraMatrix::get_fov() const {
|
|||||||
right_plane.normalize();
|
right_plane.normalize();
|
||||||
|
|
||||||
if ((matrix[8] == 0) && (matrix[9] == 0)) {
|
if ((matrix[8] == 0) && (matrix[9] == 0)) {
|
||||||
return Math::rad2deg(acos(std::abs(right_plane.normal.x))) * 2.0;
|
return Mathp::rad2deg(acos(std::abs(right_plane.normal.x))) * 2.0;
|
||||||
} else {
|
} else {
|
||||||
// our frustum is asymmetrical need to calculate the left planes angle separately..
|
// our frustum is asymmetrical need to calculate the left planes angle separately..
|
||||||
Plane left_plane = Plane(matrix[3] + matrix[0],
|
Plane left_plane = Plane(matrix[3] + matrix[0],
|
||||||
@ -570,7 +570,7 @@ real_t CameraMatrix::get_fov() const {
|
|||||||
matrix[15] + matrix[12]);
|
matrix[15] + matrix[12]);
|
||||||
left_plane.normalize();
|
left_plane.normalize();
|
||||||
|
|
||||||
return Math::rad2deg(acos(std::abs(left_plane.normal.x))) + Math::rad2deg(acos(std::abs(right_plane.normal.x)));
|
return Mathp::rad2deg(acos(std::abs(left_plane.normal.x))) + Mathp::rad2deg(acos(std::abs(right_plane.normal.x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
|
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
|
#include "Array.hpp"
|
||||||
|
|
||||||
#include "Wrapped.hpp"
|
#include "Wrapped.hpp"
|
||||||
|
|
||||||
|
22
src/core/GodotProfiling.cpp
Normal file
22
src/core/GodotProfiling.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
#include "GodotProfiling.hpp"
|
||||||
|
|
||||||
|
#include "OS.hpp"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
namespace godot {
|
||||||
|
|
||||||
|
FunctionProfiling::FunctionProfiling(const char *p_function, const int p_line) {
|
||||||
|
snprintf(signature, 1024, "::%d::%s", p_line, p_function);
|
||||||
|
ticks = OS::get_singleton()->get_ticks_usec();
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionProfiling::~FunctionProfiling() {
|
||||||
|
uint64_t t = OS::get_singleton()->get_ticks_usec() - ticks;
|
||||||
|
if (t > 0) {
|
||||||
|
Godot::gdnative_profiling_add_data(signature, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace godot
|
@ -29,7 +29,8 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "Plane.hpp"
|
#include "Plane.hpp"
|
||||||
#include "Vector3.hpp"
|
|
||||||
|
#include "Mathp.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -341,12 +341,12 @@ Quat Quat::operator/(const real_t &s) const {
|
|||||||
return *this * (1.0 / s);
|
return *this * (1.0 / s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Quat::operator==(const Quat &p_quat) const {
|
bool Quat::operator==(const Quat &p_quaternion) const {
|
||||||
return x == p_quat.x && y == p_quat.y && z == p_quat.z && w == p_quat.w;
|
return x == p_quaternion.x && y == p_quaternion.y && z == p_quaternion.z && w == p_quaternion.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Quat::operator!=(const Quat &p_quat) const {
|
bool Quat::operator!=(const Quat &p_quaternion) const {
|
||||||
return x != p_quat.x || y != p_quat.y || z != p_quat.z || w != p_quat.w;
|
return x != p_quaternion.x || y != p_quaternion.y || z != p_quaternion.z || w != p_quaternion.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace godot
|
} // namespace godot
|
||||||
|
@ -92,11 +92,11 @@ String::String(const char *contents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String::String(const wchar_t *contents) {
|
String::String(const wchar_t *contents) {
|
||||||
godot::api->pandemonium_string_new_with_wide_string(&_pandemonium_string, contents, wcslen(contents));
|
godot::api->pandemonium_string_new_wchar_clip_to_len(&_pandemonium_string, contents, wcslen(contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
String::String(const wchar_t c) {
|
String::String(const wchar_t c) {
|
||||||
godot::api->pandemonium_string_new_with_wide_string(&_pandemonium_string, &c, 1);
|
godot::api->pandemonium_string_new_wchar_clip_to_len(&_pandemonium_string, &c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String::String(const String &other) {
|
String::String(const String &other) {
|
||||||
|
@ -116,12 +116,12 @@ Variant::Variant(const Plane &p_plane) {
|
|||||||
godot::api->pandemonium_variant_new_plane(&_pandemonium_variant, (pandemonium_plane *)&p_plane);
|
godot::api->pandemonium_variant_new_plane(&_pandemonium_variant, (pandemonium_plane *)&p_plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const ::AABB &p_aabb) {
|
Variant::Variant(const godot::AABB &p_aabb) {
|
||||||
godot::api->pandemonium_variant_new_aabb(&_pandemonium_variant, (pandemonium_aabb *)&p_aabb);
|
godot::api->pandemonium_variant_new_aabb(&_pandemonium_variant, (pandemonium_aabb *)&p_aabb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Quat &p_quat) {
|
Variant::Variant(const Quat &p_quaternion) {
|
||||||
godot::api->pandemonium_variant_new_quat(&_pandemonium_variant, (pandemonium_quat *)&p_quat);
|
godot::api->pandemonium_variant_new_quaternion(&_pandemonium_variant, (pandemonium_quaternion *)&p_quaternion);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Basis &p_transform) {
|
Variant::Variant(const Basis &p_transform) {
|
||||||
@ -144,7 +144,7 @@ Variant::Variant(const NodePath &p_path) {
|
|||||||
godot::api->pandemonium_variant_new_node_path(&_pandemonium_variant, (pandemonium_node_path *)&p_path);
|
godot::api->pandemonium_variant_new_node_path(&_pandemonium_variant, (pandemonium_node_path *)&p_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const ::RID &p_rid) {
|
Variant::Variant(const godot::RID &p_rid) {
|
||||||
godot::api->pandemonium_variant_new_rid(&_pandemonium_variant, (pandemonium_rid *)&p_rid);
|
godot::api->pandemonium_variant_new_rid(&_pandemonium_variant, (pandemonium_rid *)&p_rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,12 +261,12 @@ Variant::operator Plane() const {
|
|||||||
pandemonium_plane s = godot::api->pandemonium_variant_as_plane(&_pandemonium_variant);
|
pandemonium_plane s = godot::api->pandemonium_variant_as_plane(&_pandemonium_variant);
|
||||||
return *(Plane *)&s;
|
return *(Plane *)&s;
|
||||||
}
|
}
|
||||||
Variant::operator ::AABB() const {
|
Variant::operator godot::AABB() const {
|
||||||
pandemonium_aabb s = godot::api->pandemonium_variant_as_aabb(&_pandemonium_variant);
|
pandemonium_aabb s = godot::api->pandemonium_variant_as_aabb(&_pandemonium_variant);
|
||||||
return *(::AABB *)&s;
|
return *(godot::AABB *)&s;
|
||||||
}
|
}
|
||||||
Variant::operator Quat() const {
|
Variant::operator Quat() const {
|
||||||
pandemonium_quat s = godot::api->pandemonium_variant_as_quat(&_pandemonium_variant);
|
pandemonium_quaternion s = godot::api->pandemonium_variant_as_quaternion(&_pandemonium_variant);
|
||||||
return *(Quat *)&s;
|
return *(Quat *)&s;
|
||||||
}
|
}
|
||||||
Variant::operator Basis() const {
|
Variant::operator Basis() const {
|
||||||
@ -290,9 +290,9 @@ Variant::operator NodePath() const {
|
|||||||
pandemonium_node_path ret = godot::api->pandemonium_variant_as_node_path(&_pandemonium_variant);
|
pandemonium_node_path ret = godot::api->pandemonium_variant_as_node_path(&_pandemonium_variant);
|
||||||
return NodePath(ret);
|
return NodePath(ret);
|
||||||
}
|
}
|
||||||
Variant::operator ::RID() const {
|
Variant::operator godot::RID() const {
|
||||||
pandemonium_rid s = godot::api->pandemonium_variant_as_rid(&_pandemonium_variant);
|
pandemonium_rid s = godot::api->pandemonium_variant_as_rid(&_pandemonium_variant);
|
||||||
return *(::RID *)&s;
|
return *(godot::RID *)&s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Dictionary() const {
|
Variant::operator Dictionary() const {
|
||||||
|
@ -109,9 +109,9 @@ void Vector3::rotate(const Vector3 &p_axis, real_t p_phi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::snap(real_t p_val) {
|
void Vector3::snap(real_t p_val) {
|
||||||
x = Math::stepify(x, p_val);
|
x = Mathp::stepify(x, p_val);
|
||||||
y = Math::stepify(y, p_val);
|
y = Mathp::stepify(y, p_val);
|
||||||
z = Math::stepify(z, p_val);
|
z = Mathp::stepify(z, p_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3::operator String() const {
|
Vector3::operator String() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user