Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
run: |
scons target=release generate_bindings=yes -j $(nproc)

- name: Build test project
run: |
cd test
scons target=release -j $(nproc)

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -55,6 +60,11 @@ jobs:
run: |
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS

- name: Build test project
run: |
cd test
scons target=release -j $env:NUMBER_OF_PROCESSORS

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -89,6 +99,11 @@ jobs:
gcc --version
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS

#- name: Build test project (TODO currently not supported, leaving uncommented as a reminder to fix this)
# run: |
# cd test
# scons target=release use_mingw=yes -j $env:NUMBER_OF_PROCESSORS

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -118,6 +133,11 @@ jobs:
run: |
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)

- name: Build test project
run: |
cd test
scons target=release -j $(sysctl -n hw.logicalcpu)

static-checks:
name: Static Checks (clang-format)
runs-on: ubuntu-20.04
Expand Down
24 changes: 12 additions & 12 deletions include/godot_cpp/core/binder_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G
#ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif

int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;

int32_t dvs = default_values.size();
int32_t dvs = (int32_t)default_values.size();
#ifdef DEBUG_ENABLED
if (missing > dvs) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif
Expand All @@ -274,18 +274,18 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
#ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif

int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;

int32_t dvs = default_values.size();
int32_t dvs = (int32_t)default_values.size();
#ifdef DEBUG_ENABLED
if (missing > dvs) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif
Expand All @@ -309,18 +309,18 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
#ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif

int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;

int32_t dvs = default_values.size();
int32_t dvs = (int32_t)default_values.size();
#ifdef DEBUG_ENABLED
if (missing > dvs) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif
Expand All @@ -344,18 +344,18 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
#ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif

int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount;

int32_t dvs = default_values.size();
int32_t dvs = (int32_t)default_values.size();
#ifdef DEBUG_ENABLED
if (missing > dvs) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = sizeof...(P);
r_error.argument = (int32_t)sizeof...(P);
return;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/godot_cpp/core/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ inline double sinc(double p_x) {
}

inline float sincn(float p_x) {
return sinc(Math_PI * p_x);
return (float)sinc(Math_PI * p_x);
}
inline double sincn(double p_x) {
return sinc(Math_PI * p_x);
Expand Down
18 changes: 9 additions & 9 deletions include/godot_cpp/core/method_bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class MethodBind {
public:
const char *get_name() const;
void set_name(const char *p_name);
_FORCE_INLINE_ int get_default_argument_count() const { return default_arguments.size(); }
_FORCE_INLINE_ int get_default_argument_count() const { return (int)default_arguments.size(); }
_FORCE_INLINE_ const std::vector<Variant> &get_default_arguments() const { return default_arguments; }
_FORCE_INLINE_ Variant has_default_argument(int p_arg) const {
int idx = p_arg - (argument_count - default_arguments.size());
int idx = p_arg - (argument_count - (int)default_arguments.size());

if (idx < 0 || idx >= default_arguments.size()) {
return false;
Expand All @@ -83,7 +83,7 @@ class MethodBind {
}
}
_FORCE_INLINE_ Variant get_default_argument(int p_arg) const {
int idx = p_arg - (argument_count - default_arguments.size());
int idx = p_arg - (argument_count - (int)default_arguments.size());

if (idx < 0 || idx >= default_arguments.size()) {
return Variant();
Expand Down Expand Up @@ -159,7 +159,7 @@ class MethodBindVarArg : public MethodBind {
}

void set_method_info(const MethodInfo &p_info, bool p_return_nil_is_variant) {
set_argument_count(p_info.arguments.size());
set_argument_count((int)p_info.arguments.size());
if (p_info.arguments.size()) {
std::vector<std::string> names;
names.reserve(p_info.arguments.size());
Expand All @@ -175,7 +175,7 @@ class MethodBindVarArg : public MethodBind {
if (p_return_nil_is_variant) {
arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
}
generate_argument_types(p_info.arguments.size());
generate_argument_types((int)p_info.arguments.size());
}

virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) const {
Expand Down Expand Up @@ -252,7 +252,7 @@ class MethodBindT : public MethodBind {

virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
#ifdef TYPED_METHOD_BIND
call_with_variant_args_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
call_with_variant_args_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments());
#else
call_with_variant_args_dv(reinterpret_cast<MB_T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
#endif
Expand Down Expand Up @@ -330,7 +330,7 @@ class MethodBindTC : public MethodBind {

virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
#ifdef TYPED_METHOD_BIND
call_with_variant_argsc_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
call_with_variant_argsc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments());
#else
call_with_variant_argsc_dv(reinterpret_cast<MB_T *>(p_instance), method, p_args, p_argument_count, r_error, get_default_arguments());
#endif
Expand Down Expand Up @@ -414,7 +414,7 @@ class MethodBindTR : public MethodBind {
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
Variant ret;
#ifdef TYPED_METHOD_BIND
call_with_variant_args_ret_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, ret, r_error, get_default_arguments());
call_with_variant_args_ret_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments());
#else
call_with_variant_args_ret_dv((MB_T *)p_instance, method, p_args, p_argument_count, ret, r_error, get_default_arguments());
#endif
Expand Down Expand Up @@ -499,7 +499,7 @@ class MethodBindTRC : public MethodBind {
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
Variant ret;
#ifdef TYPED_METHOD_BIND
call_with_variant_args_retc_dv(static_cast<T *>(p_instance), method, p_args, p_argument_count, ret, r_error, get_default_arguments());
call_with_variant_args_retc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments());
#else
call_with_variant_args_retc_dv((MB_T *)p_instance, method, p_args, p_argument_count, ret, r_error, get_default_arguments());
#endif
Expand Down
14 changes: 7 additions & 7 deletions include/godot_cpp/variant/aabb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ inline void AABB::expand_to(const Vector3 &p_vector) {
}

void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
Vector3 half_extents(size.x * (real_t)0.5, size.y * (real_t)0.5, size.z * (real_t)0.5);
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);

real_t length = p_plane.normal.abs().dot(half_extents);
Expand Down Expand Up @@ -374,9 +374,9 @@ inline real_t AABB::get_shortest_axis_size() const {
}

bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
real_t divx = 1.0 / p_dir.x;
real_t divy = 1.0 / p_dir.y;
real_t divz = 1.0 / p_dir.z;
real_t divx = (real_t)1.0 / p_dir.x;
real_t divy = (real_t)1.0 / p_dir.y;
real_t divz = (real_t)1.0 / p_dir.z;

Vector3 upbound = position + size;
real_t tmin, tmax, tymin, tymax, tzmin, tzmax;
Expand Down Expand Up @@ -426,9 +426,9 @@ void AABB::grow_by(real_t p_amount) {
position.x -= p_amount;
position.y -= p_amount;
position.z -= p_amount;
size.x += 2.0 * p_amount;
size.y += 2.0 * p_amount;
size.z += 2.0 * p_amount;
size.x += (real_t)2.0 * p_amount;
size.y += (real_t)2.0 * p_amount;
size.z += (real_t)2.0 * p_amount;
}

void AABB::quantize(real_t p_unit) {
Expand Down
30 changes: 15 additions & 15 deletions include/godot_cpp/variant/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Color {

inline Color blend(const Color &p_over) const {
Color res;
float sa = 1.0 - p_over.a;
float sa = (real_t)1.0 - p_over.a;
res.a = a * sa + p_over.a;
if (res.a == 0) {
return Color(0, 0, 0, 0);
Expand All @@ -171,16 +171,16 @@ class Color {

inline Color to_linear() const {
return Color(
r < 0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
g < 0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
b < 0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055) * (1.0 / (1 + 0.055)), 2.4),
r < (real_t)0.04045 ? r * (real_t)(1.0 / 12.92) : Math::pow((r + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
g < (real_t)0.04045 ? g * (real_t)(1.0 / 12.92) : Math::pow((g + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
b < (real_t)0.04045 ? b * (real_t)(1.0 / 12.92) : Math::pow((b + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
a);
}
inline Color to_srgb() const {
return Color(
r < 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math::pow(r, 1.0f / 2.4f) - 0.055,
g < 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math::pow(g, 1.0f / 2.4f) - 0.055,
b < 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math::pow(b, 1.0f / 2.4f) - 0.055, a);
r < (real_t)0.0031308 ? (real_t)12.92 * r : (real_t)(1.0 + 0.055) * Math::pow(r, (real_t)(1.0 / 2.4)) - (real_t)0.055,
g < (real_t)0.0031308 ? (real_t)12.92 * g : (real_t)(1.0 + 0.055) * Math::pow(g, (real_t)(1.0 / 2.4)) - (real_t)0.055,
b < (real_t)0.0031308 ? (real_t)12.92 * b : (real_t)(1.0 + 0.055) * Math::pow(b, (real_t)(1.0 / 2.4)) - (real_t)0.055, a);
}

static Color hex(uint32_t p_hex);
Expand All @@ -202,14 +202,14 @@ class Color {
operator String() const;

// For the binder.
inline void set_r8(int32_t r8) { r = (Math::clamp(r8, 0, 255) / 255.0); }
inline int32_t get_r8() const { return int32_t(Math::clamp(r * 255.0, 0.0, 255.0)); }
inline void set_g8(int32_t g8) { g = (Math::clamp(g8, 0, 255) / 255.0); }
inline int32_t get_g8() const { return int32_t(Math::clamp(g * 255.0, 0.0, 255.0)); }
inline void set_b8(int32_t b8) { b = (Math::clamp(b8, 0, 255) / 255.0); }
inline int32_t get_b8() const { return int32_t(Math::clamp(b * 255.0, 0.0, 255.0)); }
inline void set_a8(int32_t a8) { a = (Math::clamp(a8, 0, 255) / 255.0); }
inline int32_t get_a8() const { return int32_t(Math::clamp(a * 255.0, 0.0, 255.0)); }
inline void set_r8(int32_t r8) { r = (Math::clamp(r8, 0, 255) / (real_t)255.0); }
inline int32_t get_r8() const { return int32_t(Math::clamp(r * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
inline void set_g8(int32_t g8) { g = (Math::clamp(g8, 0, 255) / (real_t)255.0); }
inline int32_t get_g8() const { return int32_t(Math::clamp(g * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
inline void set_b8(int32_t b8) { b = (Math::clamp(b8, 0, 255) / (real_t)255.0); }
inline int32_t get_b8() const { return int32_t(Math::clamp(b * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
inline void set_a8(int32_t a8) { a = (Math::clamp(a8, 0, 255) / (real_t)255.0); }
inline int32_t get_a8() const { return int32_t(Math::clamp(a * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }

inline void set_h(float p_h) { set_hsv(p_h, get_s(), get_v()); }
inline void set_s(float p_s) { set_hsv(get_h(), p_s, get_v()); }
Expand Down
20 changes: 10 additions & 10 deletions include/godot_cpp/variant/quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,19 @@ class Quaternion {
Vector3 c = v0.cross(v1);
real_t d = v0.dot(v1);

if (d < -1.0 + CMP_EPSILON) {
x = 0;
y = 1;
z = 0;
w = 0;
if (d < (real_t)-1.0 + CMP_EPSILON) {
x = (real_t)0.0;
y = (real_t)1.0;
z = (real_t)0.0;
w = (real_t)0.0;
} else {
real_t s = Math::sqrt((1.0 + d) * 2.0);
real_t rs = 1.0 / s;
real_t s = Math::sqrt(((real_t)1.0 + d) * (real_t)2.0);
real_t rs = (real_t)1.0 / s;

x = c.x * rs;
y = c.y * rs;
z = c.z * rs;
w = s * 0.5;
w = s * (real_t)0.5;
}
}
};
Expand Down Expand Up @@ -199,7 +199,7 @@ void Quaternion::operator*=(const real_t &s) {
}

void Quaternion::operator/=(const real_t &s) {
*this *= 1.0 / s;
*this *= (real_t)1.0 / s;
}

Quaternion Quaternion::operator+(const Quaternion &q2) const {
Expand All @@ -222,7 +222,7 @@ Quaternion Quaternion::operator*(const real_t &s) const {
}

Quaternion Quaternion::operator/(const real_t &s) const {
return *this * (1.0 / s);
return *this * ((real_t)1.0 / s);
}

bool Quaternion::operator==(const Quaternion &p_quat) const {
Expand Down
4 changes: 2 additions & 2 deletions include/godot_cpp/variant/rect2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

namespace godot {

struct Transform2D;
class Transform2D;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a struct, right? Why change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's defined as a class. Look up Transform2D.hpp, unless that is our real issue here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does godot-cpp use class Transform2D but the engine uses struct?

I apologize if this is off-topic, but this change seems very weird to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, no idea, probably because we just generate everything as classes, @vnen is this something we should change?


class Rect2 {
public:
Expand Down Expand Up @@ -290,7 +290,7 @@ class Rect2 {

//check ray box
r /= l;
Vector2 ir(1.0 / r.x, 1.0 / r.y);
Vector2 ir((real_t)1.0 / r.x, (real_t)1.0 / r.y);

// lb is the corner of AABB with minimal coordinates - left bottom, rt is maximal corner
// r.org is origin of ray
Expand Down
8 changes: 4 additions & 4 deletions include/godot_cpp/variant/vector2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ inline Vector2 Vector2::plane_project(real_t p_d, const Vector2 &p_vec) const {
}

inline Vector2 operator*(float p_scalar, const Vector2 &p_vec) {
return p_vec * p_scalar;
return p_vec * (real_t)p_scalar;
}

inline Vector2 operator*(double p_scalar, const Vector2 &p_vec) {
return p_vec * p_scalar;
return p_vec * (real_t)p_scalar;
}

inline Vector2 operator*(int32_t p_scalar, const Vector2 &p_vec) {
return p_vec * p_scalar;
return p_vec * (real_t)p_scalar;
}

inline Vector2 operator*(int64_t p_scalar, const Vector2 &p_vec) {
return p_vec * p_scalar;
return p_vec * (real_t)p_scalar;
}

inline Vector2 Vector2::operator+(const Vector2 &p_v) const {
Expand Down
Loading