diff options
Diffstat (limited to 'modules/gdnative/godot/godot_basis.cpp')
-rw-r--r-- | modules/gdnative/godot/godot_basis.cpp | 287 |
1 files changed, 172 insertions, 115 deletions
diff --git a/modules/gdnative/godot/godot_basis.cpp b/modules/gdnative/godot/godot_basis.cpp index 474cd3d448..46464932c5 100644 --- a/modules/gdnative/godot/godot_basis.cpp +++ b/modules/gdnative/godot/godot_basis.cpp @@ -28,188 +28,245 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "godot_basis.h" +#include "core/variant.h" -#include "math/matrix3.h" +#include "core/math/matrix3.h" #ifdef __cplusplus extern "C" { #endif -void _basis_api_anchor() { +void _basis_api_anchor() {} + +void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis) { + const Vector3 *x_axis = (const Vector3 *)p_x_axis; + const Vector3 *y_axis = (const Vector3 *)p_y_axis; + const Vector3 *z_axis = (const Vector3 *)p_z_axis; + Basis *dest = (Basis *)r_dest; + *dest = Basis(*x_axis, *y_axis, *z_axis); } -void GDAPI godot_basis_new(godot_basis *p_v) { - Basis *v = (Basis *)p_v; - *v = Basis(); +void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi) { + const Vector3 *axis = (const Vector3 *)p_axis; + Basis *dest = (Basis *)r_dest; + *dest = Basis(*axis, p_phi); } -void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_v, const godot_quat *p_euler) { - Basis *v = (Basis *)p_v; - Quat *euler = (Quat *)p_euler; - *v = Basis(*euler); +void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler) { + const Vector3 *euler = (const Vector3 *)p_euler; + Basis *dest = (Basis *)r_dest; + *dest = Basis(*euler); } -void GDAPI godot_basis_new_with_euler(godot_basis *p_v, const godot_vector3 p_euler) { - Basis *v = (Basis *)p_v; - Vector3 *euler = (Vector3 *)&p_euler; - *v = Basis(*euler); +godot_string GDAPI godot_basis_as_string(const godot_basis *p_self) { + godot_string ret; + const Basis *self = (const Basis *)p_self; + memnew_placement(&ret, String(*self)); + return ret; } -void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *p_v, const godot_vector3 p_axis, const godot_real p_phi) { - Basis *v = (Basis *)p_v; - const Vector3 *axis = (Vector3 *)&p_axis; - *v = Basis(*axis, p_phi); +godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + *((Basis *)&dest) = self->inverse(); + return dest; } -void GDAPI godot_basis_new_with_rows(godot_basis *p_v, const godot_vector3 p_row0, const godot_vector3 p_row1, const godot_vector3 p_row2) { - Basis *v = (Basis *)p_v; - const Vector3 *row0 = (Vector3 *)&p_row0; - const Vector3 *row1 = (Vector3 *)&p_row1; - const Vector3 *row2 = (Vector3 *)&p_row2; - *v = Basis(*row0, *row1, *row2); +godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + *((Basis *)&dest) = self->transposed(); + return dest; } -godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_v) { - const Basis *v = (const Basis *)p_v; - godot_quat quat; - Quat *p_quat = (Quat *)&quat; - *p_quat = v->operator Quat(); - return quat; +godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + *((Basis *)&dest) = self->orthonormalized(); + return dest; } -/* - * p_elements is a pointer to an array of 3 (!!) vector3 - */ -void GDAPI godot_basis_get_elements(godot_basis *p_v, godot_vector3 *p_elements) { - Basis *v = (Basis *)p_v; - Vector3 *elements = (Vector3 *)p_elements; - elements[0] = v->elements[0]; - elements[1] = v->elements[1]; - elements[2] = v->elements[2]; +godot_real GDAPI godot_basis_determinant(const godot_basis *p_self) { + const Basis *self = (const Basis *)p_self; + return self->determinant(); } -godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_v, const godot_int p_axis) { - godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *v = (Basis *)p_v; - *d = v->get_axis(p_axis); +godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *axis = (const Vector3 *)p_axis; + *((Basis *)&dest) = self->rotated(*axis, p_phi); return dest; } -void GDAPI godot_basis_set_axis(godot_basis *p_v, const godot_int p_axis, const godot_vector3 p_value) { - Basis *v = (Basis *)p_v; - const Vector3 *value = (Vector3 *)&p_value; - v->set_axis(p_axis, *value); +godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *scale = (const Vector3 *)p_scale; + *((Basis *)&dest) = self->scaled(*scale); + return dest; } -godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_v, const godot_int p_row) { - godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *v = (Basis *)p_v; - *d = v->get_row(p_row); - return dest; +void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale) { + Basis *self = (Basis *)p_self; + const Vector3 *scale = (const Vector3 *)p_scale; + self->set_scale(*scale); } -void GDAPI godot_basis_set_row(godot_basis *p_v, const godot_int p_row, const godot_vector3 p_value) { - Basis *v = (Basis *)p_v; - const Vector3 *value = (Vector3 *)&p_value; - v->set_row(p_row, *value); +void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler) { + Basis *self = (Basis *)p_self; + const Vector3 *euler = (const Vector3 *)p_euler; + self->set_rotation_euler(*euler); } -godot_real godot_basis_determinant(const godot_basis *p_v) { - Basis *v = (Basis *)p_v; - return v->determinant(); +void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle) { + Basis *self = (Basis *)p_self; + const Vector3 *axis = (const Vector3 *)p_axis; + self->set_rotation_axis_angle(*axis, p_angle); } -godot_vector3 godot_basis_get_euler(const godot_basis *p_v) { +godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) { godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *v = (Basis *)p_v; - *d = v->get_euler(); + const Basis *self = (const Basis *)p_self; + *((Vector3 *)&dest) = self->get_scale(); return dest; } -godot_int godot_basis_get_orthogonal_index(const godot_basis *p_v) { - const Basis *v = (Basis *)p_v; - return v->get_orthogonal_index(); -} - -godot_vector3 godot_basis_get_scale(const godot_basis *p_v) { +godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self) { godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *v = (Basis *)p_v; - *d = v->get_scale(); + const Basis *self = (const Basis *)p_self; + *((Vector3 *)&dest) = self->get_euler(); return dest; } -void godot_basis_inverse(godot_basis *p_dest, const godot_basis *p_v) { - Basis *d = (Basis *)p_dest; - const Basis *v = (Basis *)p_v; - *d = v->inverse(); +godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with) { + const Basis *self = (const Basis *)p_self; + const Vector3 *with = (const Vector3 *)p_with; + return self->tdotx(*with); +} + +godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with) { + const Basis *self = (const Basis *)p_self; + const Vector3 *with = (const Vector3 *)p_with; + return self->tdoty(*with); } -void godot_basis_orthonormalized(godot_basis *p_dest, const godot_basis *p_v) { - Basis *d = (Basis *)p_dest; - const Basis *v = (Basis *)p_v; - *d = v->orthonormalized(); +godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with) { + const Basis *self = (const Basis *)p_self; + const Vector3 *with = (const Vector3 *)p_with; + return self->tdotz(*with); } -void godot_basis_rotated(godot_basis *p_dest, const godot_basis *p_v, const godot_vector3 p_axis, const godot_real p_phi) { - Basis *d = (Basis *)p_dest; - const Basis *v = (Basis *)p_v; - const Vector3 *axis = (Vector3 *)&p_axis; - *d = v->rotated(*axis, p_phi); +godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v) { + godot_vector3 dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *((Vector3 *)&dest) = self->xform(*v); + return dest; } -void godot_basis_scaled(godot_basis *p_dest, const godot_basis *p_v, const godot_vector3 p_scale) { - Basis *d = (Basis *)p_dest; - const Basis *v = (Basis *)p_v; - const Vector3 *scale = (Vector3 *)&p_scale; - *d = v->scaled(*scale); +godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v) { + godot_vector3 dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *((Vector3 *)&dest) = self->xform_inv(*v); + return dest; } -godot_real godot_basis_tdotx(const godot_basis *p_v, const godot_vector3 p_with) { - const Basis *v = (Basis *)p_v; - const Vector3 *with = (Vector3 *)&p_with; - return v->tdotx(*with); +godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self) { + const Basis *self = (const Basis *)p_self; + return self->get_orthogonal_index(); } -godot_real godot_basis_tdoty(const godot_basis *p_v, const godot_vector3 p_with) { - const Basis *v = (Basis *)p_v; - const Vector3 *with = (Vector3 *)&p_with; - return v->tdoty(*with); +void GDAPI godot_basis_new(godot_basis *r_dest) { + Basis *dest = (Basis *)r_dest; + *dest = Basis(); } -godot_real godot_basis_tdotz(const godot_basis *p_v, const godot_vector3 p_with) { - const Basis *v = (Basis *)p_v; - const Vector3 *with = (Vector3 *)&p_with; - return v->tdotz(*with); +void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler) { + Basis *dest = (Basis *)r_dest; + const Quat *euler = (const Quat *)p_euler; + *dest = Basis(*euler); } -void godot_basis_transposed(godot_basis *p_dest, const godot_basis *p_v) { - Basis *d = (Basis *)p_dest; - const Basis *v = (Basis *)p_v; - *d = v->transposed(); +// p_elements is a pointer to an array of 3 (!!) vector3 +void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements) { + const Basis *self = (const Basis *)p_self; + Vector3 *elements = (Vector3 *)p_elements; + elements[0] = self->elements[0]; + elements[1] = self->elements[1]; + elements[2] = self->elements[2]; } -godot_vector3 godot_basis_xform(const godot_basis *p_v, const godot_vector3 p_vect) { +godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) { godot_vector3 dest; Vector3 *d = (Vector3 *)&dest; - const Basis *v = (Basis *)p_v; - const Vector3 *vect = (Vector3 *)&p_vect; - *d = v->xform(*vect); + const Basis *self = (const Basis *)p_self; + *d = self->get_axis(p_axis); return dest; } -godot_vector3 godot_basis_xform_inv(const godot_basis *p_v, const godot_vector3 p_vect) { +void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value) { + Basis *self = (Basis *)p_self; + const Vector3 *value = (const Vector3 *)p_value; + self->set_axis(p_axis, *value); +} + +godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row) { godot_vector3 dest; Vector3 *d = (Vector3 *)&dest; - const Basis *v = (Basis *)p_v; - const Vector3 *vect = (Vector3 *)&p_vect; - *d = v->xform_inv(*vect); + const Basis *self = (const Basis *)p_self; + *d = self->get_row(p_row); return dest; } +void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value) { + Basis *self = (Basis *)p_self; + const Vector3 *value = (const Vector3 *)p_value; + self->set_row(p_row, *value); +} + +godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b) { + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + return *self == *b; +} + +godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + *dest = *self * p_b; + return raw_dest; +} + #ifdef __cplusplus } #endif |