mirror of
https://github.com/Relintai/gdnative.git
synced 2025-01-30 18:39:20 +01:00
Transform2D initial pass.
This commit is contained in:
parent
9638352bf4
commit
fdcd047f8e
@ -39,27 +39,6 @@ extern "C" {
|
||||
|
||||
static_assert(sizeof(pandemonium_transform2d) == sizeof(Transform2D), "Transform2D size mismatch");
|
||||
|
||||
void GDAPI pandemonium_transform2d_new(pandemonium_transform2d *r_dest, const pandemonium_real p_rot, const pandemonium_vector2 *p_pos) {
|
||||
const Vector2 *pos = (const Vector2 *)p_pos;
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
*dest = Transform2D(p_rot, *pos);
|
||||
}
|
||||
|
||||
void GDAPI pandemonium_transform2d_new_axis_origin(pandemonium_transform2d *r_dest, const pandemonium_vector2 *p_x_axis, const pandemonium_vector2 *p_y_axis, const pandemonium_vector2 *p_origin) {
|
||||
const Vector2 *x_axis = (const Vector2 *)p_x_axis;
|
||||
const Vector2 *y_axis = (const Vector2 *)p_y_axis;
|
||||
const Vector2 *origin = (const Vector2 *)p_origin;
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
*dest = Transform2D(x_axis->x, x_axis->y, y_axis->x, y_axis->y, origin->x, origin->y);
|
||||
}
|
||||
|
||||
pandemonium_string GDAPI pandemonium_transform2d_as_string(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_string ret;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
memnew_placement(&ret, String(*self));
|
||||
return ret;
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_inverse(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
@ -79,11 +58,9 @@ pandemonium_real GDAPI pandemonium_transform2d_get_rotation(const pandemonium_tr
|
||||
return self->get_rotation();
|
||||
}
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_get_origin(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_vector2 dest;
|
||||
pandemonium_real GDAPI pandemonium_transform2d_basis_determinant(const pandemonium_transform2d *p_self) {
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
*((Vector2 *)&dest) = self->get_origin();
|
||||
return dest;
|
||||
return self->basis_determinant();
|
||||
}
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_get_scale(const pandemonium_transform2d *p_self) {
|
||||
@ -93,23 +70,10 @@ pandemonium_vector2 GDAPI pandemonium_transform2d_get_scale(const pandemonium_tr
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_real GDAPI pandemonium_transform2d_determinant(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_get_origin(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_vector2 dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
return self->basis_determinant();
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_orthonormalized(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
*((Transform2D *)&dest) = self->orthonormalized();
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_rotated(const pandemonium_transform2d *p_self, const pandemonium_real p_phi) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
|
||||
*((Transform2D *)&dest) = self->rotated(p_phi);
|
||||
*((Vector2 *)&dest) = self->get_origin();
|
||||
return dest;
|
||||
}
|
||||
|
||||
@ -120,7 +84,6 @@ pandemonium_transform2d GDAPI pandemonium_transform2d_scaled(const pandemonium_t
|
||||
*((Transform2D *)&dest) = self->scaled(*scale);
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_translated(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_offset) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
@ -128,23 +91,41 @@ pandemonium_transform2d GDAPI pandemonium_transform2d_translated(const pandemoni
|
||||
*((Transform2D *)&dest) = self->translated(*offset);
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v) {
|
||||
pandemonium_vector2 raw_dest;
|
||||
Vector2 *dest = (Vector2 *)&raw_dest;
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_rotated(const pandemonium_transform2d *p_self, const pandemonium_real p_phi) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Vector2 *v = (const Vector2 *)p_v;
|
||||
*dest = self->xform(*v);
|
||||
|
||||
*((Transform2D *)&dest) = self->rotated(p_phi);
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_orthonormalized(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
*((Transform2D *)&dest) = self->orthonormalized();
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_bool GDAPI pandemonium_transform2d_operator_equal(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b) {
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Transform2D *b = (const Transform2D *)p_b;
|
||||
return *self == *b;
|
||||
}
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_operator_multiply(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b) {
|
||||
pandemonium_transform2d raw_dest;
|
||||
Transform2D *dest = (Transform2D *)&raw_dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Transform2D *b = (const Transform2D *)p_b;
|
||||
*dest = *self * *b;
|
||||
return raw_dest;
|
||||
}
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_inv_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v) {
|
||||
pandemonium_vector2 raw_dest;
|
||||
Vector2 *dest = (Vector2 *)&raw_dest;
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_interpolate_with(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_m, const pandemonium_real p_c) {
|
||||
pandemonium_transform2d dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Vector2 *v = (const Vector2 *)p_v;
|
||||
*dest = self->xform_inv(*v);
|
||||
return raw_dest;
|
||||
const Transform2D *m = (const Transform2D *)p_m;
|
||||
*((Transform2D *)&dest) = self->interpolate_with(*m, p_c);
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_basis_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v) {
|
||||
@ -165,32 +146,22 @@ pandemonium_vector2 GDAPI pandemonium_transform2d_basis_xform_inv_vector2(const
|
||||
return raw_dest;
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_interpolate_with(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_m, const pandemonium_real p_c) {
|
||||
pandemonium_transform2d dest;
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v) {
|
||||
pandemonium_vector2 raw_dest;
|
||||
Vector2 *dest = (Vector2 *)&raw_dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Transform2D *m = (const Transform2D *)p_m;
|
||||
*((Transform2D *)&dest) = self->interpolate_with(*m, p_c);
|
||||
return dest;
|
||||
}
|
||||
|
||||
pandemonium_bool GDAPI pandemonium_transform2d_operator_equal(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b) {
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Transform2D *b = (const Transform2D *)p_b;
|
||||
return *self == *b;
|
||||
}
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_operator_multiply(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b) {
|
||||
pandemonium_transform2d raw_dest;
|
||||
Transform2D *dest = (Transform2D *)&raw_dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Transform2D *b = (const Transform2D *)p_b;
|
||||
*dest = *self * *b;
|
||||
const Vector2 *v = (const Vector2 *)p_v;
|
||||
*dest = self->xform(*v);
|
||||
return raw_dest;
|
||||
}
|
||||
|
||||
void GDAPI pandemonium_transform2d_new_identity(pandemonium_transform2d *r_dest) {
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
*dest = Transform2D();
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_inv_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v) {
|
||||
pandemonium_vector2 raw_dest;
|
||||
Vector2 *dest = (Vector2 *)&raw_dest;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
const Vector2 *v = (const Vector2 *)p_v;
|
||||
*dest = self->xform_inv(*v);
|
||||
return raw_dest;
|
||||
}
|
||||
|
||||
pandemonium_rect2 GDAPI pandemonium_transform2d_xform_rect2(const pandemonium_transform2d *p_self, const pandemonium_rect2 *p_v) {
|
||||
@ -211,6 +182,32 @@ pandemonium_rect2 GDAPI pandemonium_transform2d_xform_inv_rect2(const pandemoniu
|
||||
return raw_dest;
|
||||
}
|
||||
|
||||
pandemonium_string GDAPI pandemonium_transform2d_as_string(const pandemonium_transform2d *p_self) {
|
||||
pandemonium_string ret;
|
||||
const Transform2D *self = (const Transform2D *)p_self;
|
||||
memnew_placement(&ret, String(*self));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void GDAPI pandemonium_transform2d_new(pandemonium_transform2d *r_dest, const pandemonium_real p_rot, const pandemonium_vector2 *p_pos) {
|
||||
const Vector2 *pos = (const Vector2 *)p_pos;
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
*dest = Transform2D(p_rot, *pos);
|
||||
}
|
||||
|
||||
void GDAPI pandemonium_transform2d_new_axis_origin(pandemonium_transform2d *r_dest, const pandemonium_vector2 *p_x_axis, const pandemonium_vector2 *p_y_axis, const pandemonium_vector2 *p_origin) {
|
||||
const Vector2 *x_axis = (const Vector2 *)p_x_axis;
|
||||
const Vector2 *y_axis = (const Vector2 *)p_y_axis;
|
||||
const Vector2 *origin = (const Vector2 *)p_origin;
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
*dest = Transform2D(x_axis->x, x_axis->y, y_axis->x, y_axis->y, origin->x, origin->y);
|
||||
}
|
||||
|
||||
void GDAPI pandemonium_transform2d_new_identity(pandemonium_transform2d *r_dest) {
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
*dest = Transform2D();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -59,51 +59,98 @@ typedef struct {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void GDAPI pandemonium_transform2d_new(pandemonium_transform2d *r_dest, const pandemonium_real p_rot, const pandemonium_vector2 *p_pos);
|
||||
void GDAPI pandemonium_transform2d_new_axis_origin(pandemonium_transform2d *r_dest, const pandemonium_vector2 *p_x_axis, const pandemonium_vector2 *p_y_axis, const pandemonium_vector2 *p_origin);
|
||||
/*
|
||||
_FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return columns[0][0] * v.x + columns[1][0] * v.y; }
|
||||
_FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return columns[0][1] * v.x + columns[1][1] * v.y; }
|
||||
|
||||
pandemonium_string GDAPI pandemonium_transform2d_as_string(const pandemonium_transform2d *p_self);
|
||||
_FORCE_INLINE_ Vector2 get_axis(int p_axis) const {
|
||||
_FORCE_INLINE_ void set_axis(int p_axis, const Vector2 &p_vec) {
|
||||
|
||||
_FORCE_INLINE_ Vector2 get_column(int p_colum) const {
|
||||
_FORCE_INLINE_ void set_column(int p_colum, const Vector2 &p_vec) {
|
||||
|
||||
*/
|
||||
|
||||
//void invert();
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_inverse(const pandemonium_transform2d *p_self);
|
||||
|
||||
//void affine_invert();
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_affine_inverse(const pandemonium_transform2d *p_self);
|
||||
|
||||
//void set_rotation(real_t p_rot);
|
||||
pandemonium_real GDAPI pandemonium_transform2d_get_rotation(const pandemonium_transform2d *p_self);
|
||||
//real_t get_skew() const;
|
||||
//void set_skew(const real_t p_angle);
|
||||
//_FORCE_INLINE_ void set_rotation_and_scale(real_t p_rot, const Size2 &p_scale);
|
||||
//_FORCE_INLINE_ void set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew);
|
||||
//void rotate(real_t p_phi);
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_get_origin(const pandemonium_transform2d *p_self);
|
||||
//void scale(const Size2 &p_scale);
|
||||
//void scale_basis(const Size2 &p_scale);
|
||||
//void translate(real_t p_tx, real_t p_ty);
|
||||
//void translate(const Vector2 &p_offset);
|
||||
//void translate_local(real_t p_tx, real_t p_ty);
|
||||
//void translate_local(const Vector2 &p_translation);
|
||||
|
||||
//void translater(real_t p_tx, real_t p_ty);
|
||||
//void translatev(const Vector2 &p_offset);
|
||||
//void translate_localr(real_t p_tx, real_t p_ty);
|
||||
//void translate_localv(const Vector2 &p_translation);
|
||||
|
||||
pandemonium_real GDAPI pandemonium_transform2d_basis_determinant(const pandemonium_transform2d *p_self);
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_get_scale(const pandemonium_transform2d *p_self);
|
||||
//void set_scale(const Size2 &p_scale);
|
||||
|
||||
pandemonium_real GDAPI pandemonium_transform2d_determinant(const pandemonium_transform2d *p_self);
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_orthonormalized(const pandemonium_transform2d *p_self);
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_rotated(const pandemonium_transform2d *p_self, const pandemonium_real p_phi);
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_get_origin(const pandemonium_transform2d *p_self);
|
||||
//_FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { columns[2] = p_origin; }
|
||||
|
||||
//Transform2D basis_scaled(const Size2 &p_scale) const;
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_scaled(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_scale);
|
||||
|
||||
//Transform2D scaled_local(const Size2 &p_scale) const;
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_translated(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_offset);
|
||||
//Transform2D translated_local(const Vector2 &p_offset) const;
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_rotated(const pandemonium_transform2d *p_self, const pandemonium_real p_phi);
|
||||
//Transform2D rotated_local(const real_t p_angle) const;
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
//Transform2D untranslated() const;
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_inv_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
//void orthonormalize();
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_orthonormalized(const pandemonium_transform2d *p_self);
|
||||
//bool is_equal_approx(const Transform2D &p_transform) const;
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_basis_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
//Transform2D looking_at(const Vector2 &p_target) const;
|
||||
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_basis_xform_inv_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
pandemonium_bool GDAPI pandemonium_transform2d_operator_equal(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b);
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_operator_multiply(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b);
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_interpolate_with(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_m, const pandemonium_real p_c);
|
||||
|
||||
pandemonium_bool GDAPI pandemonium_transform2d_operator_equal(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b);
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_basis_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_basis_xform_inv_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
|
||||
pandemonium_transform2d GDAPI pandemonium_transform2d_operator_multiply(const pandemonium_transform2d *p_self, const pandemonium_transform2d *p_b);
|
||||
|
||||
void GDAPI pandemonium_transform2d_new_identity(pandemonium_transform2d *r_dest);
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
pandemonium_vector2 GDAPI pandemonium_transform2d_xform_inv_vector2(const pandemonium_transform2d *p_self, const pandemonium_vector2 *p_v);
|
||||
|
||||
pandemonium_rect2 GDAPI pandemonium_transform2d_xform_rect2(const pandemonium_transform2d *p_self, const pandemonium_rect2 *p_v);
|
||||
|
||||
pandemonium_rect2 GDAPI pandemonium_transform2d_xform_inv_rect2(const pandemonium_transform2d *p_self, const pandemonium_rect2 *p_v);
|
||||
|
||||
//_FORCE_INLINE_ Vector2i basis_xform(const Vector2i &p_vec) const;
|
||||
//_FORCE_INLINE_ Vector2i basis_xform_inv(const Vector2i &p_vec) const;
|
||||
//_FORCE_INLINE_ Vector2i xform(const Vector2i &p_vec) const;
|
||||
//_FORCE_INLINE_ Vector2i xform_inv(const Vector2i &p_vec) const;
|
||||
|
||||
//_FORCE_INLINE_ PoolVector<Vector2> xform(const PoolVector<Vector2> &p_array) const;
|
||||
//_FORCE_INLINE_ PoolVector<Vector2> xform_inv(const PoolVector<Vector2> &p_array) const;
|
||||
//_FORCE_INLINE_ PoolVector<Vector2i> xform(const PoolVector<Vector2i> &p_array) const;
|
||||
//_FORCE_INLINE_ PoolVector<Vector2i> xform_inv(const PoolVector<Vector2i> &p_array) const;
|
||||
|
||||
pandemonium_string GDAPI pandemonium_transform2d_as_string(const pandemonium_transform2d *p_self);
|
||||
|
||||
void GDAPI pandemonium_transform2d_new(pandemonium_transform2d *r_dest, const pandemonium_real p_rot, const pandemonium_vector2 *p_pos);
|
||||
void GDAPI pandemonium_transform2d_new_axis_origin(pandemonium_transform2d *r_dest, const pandemonium_vector2 *p_x_axis, const pandemonium_vector2 *p_y_axis, const pandemonium_vector2 *p_origin);
|
||||
void GDAPI pandemonium_transform2d_new_identity(pandemonium_transform2d *r_dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user