mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-03 01:19:38 +01:00
Bound all eligible transform methods.
This commit is contained in:
parent
bdf93bebcc
commit
007f728438
@ -148,10 +148,19 @@ void Transform::translate_local(const Vector3 &p_translation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Transform Transform::translated(const Vector3 &p_translation) const {
|
void Transform::translate_localr(real_t p_tx, real_t p_ty, real_t p_tz) {
|
||||||
// // Equivalent to left multiplication
|
translate_local(Vector3(p_tx, p_ty, p_tz));
|
||||||
// return Transform(basis, origin + p_translation);
|
}
|
||||||
//}
|
void Transform::translate_localv(const Vector3 &p_translation) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
origin[i] += basis[i].dot(p_translation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform Transform::translated(const Vector3 &p_translation) const {
|
||||||
|
// Equivalent to left multiplication
|
||||||
|
return Transform(basis, origin + p_translation);
|
||||||
|
}
|
||||||
|
|
||||||
Transform Transform::translated_local(const Vector3 &p_translation) const {
|
Transform Transform::translated_local(const Vector3 &p_translation) const {
|
||||||
// Equivalent to right multiplication
|
// Equivalent to right multiplication
|
||||||
@ -211,6 +220,25 @@ Transform Transform::operator*(const real_t p_val) const {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transform Transform::spherical_interpolate_with(const Transform &p_transform, real_t p_c) const {
|
||||||
|
/* not sure if very "efficient" but good enough? */
|
||||||
|
|
||||||
|
Transform interp;
|
||||||
|
|
||||||
|
Vector3 src_scale = basis.get_scale();
|
||||||
|
Quaternion src_rot = basis.get_rotation_quaternion();
|
||||||
|
Vector3 src_loc = origin;
|
||||||
|
|
||||||
|
Vector3 dst_scale = p_transform.basis.get_scale();
|
||||||
|
Quaternion dst_rot = p_transform.basis.get_rotation_quaternion();
|
||||||
|
Vector3 dst_loc = p_transform.origin;
|
||||||
|
|
||||||
|
interp.basis.set_quaternion_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.linear_interpolate(dst_scale, p_c));
|
||||||
|
interp.origin = src_loc.linear_interpolate(dst_loc, p_c);
|
||||||
|
|
||||||
|
return interp;
|
||||||
|
}
|
||||||
|
|
||||||
Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) const {
|
Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) const {
|
||||||
/* not sure if very "efficient" but good enough? */
|
/* not sure if very "efficient" but good enough? */
|
||||||
|
|
||||||
|
@ -64,8 +64,9 @@ public:
|
|||||||
|
|
||||||
void translate_local(real_t p_tx, real_t p_ty, real_t p_tz);
|
void translate_local(real_t p_tx, real_t p_ty, real_t p_tz);
|
||||||
void translate_local(const Vector3 &p_translation);
|
void translate_local(const Vector3 &p_translation);
|
||||||
//TODO Enable
|
void translate_localr(real_t p_tx, real_t p_ty, real_t p_tz);
|
||||||
//Transform translated(const Vector3 &p_translation) const;
|
void translate_localv(const Vector3 &p_translation);
|
||||||
|
Transform translated(const Vector3 &p_translation) const;
|
||||||
Transform translated_local(const Vector3 &p_translation) const;
|
Transform translated_local(const Vector3 &p_translation) const;
|
||||||
|
|
||||||
const Basis &get_basis() const { return basis; }
|
const Basis &get_basis() const { return basis; }
|
||||||
|
@ -1293,15 +1293,36 @@ struct _VariantCall {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VCALL_PTR0(Transform, invert);
|
||||||
VCALL_PTR0R(Transform, inverse);
|
VCALL_PTR0R(Transform, inverse);
|
||||||
|
VCALL_PTR0(Transform, affine_invert);
|
||||||
VCALL_PTR0R(Transform, affine_inverse);
|
VCALL_PTR0R(Transform, affine_inverse);
|
||||||
VCALL_PTR2R(Transform, rotated);
|
VCALL_PTR2R(Transform, rotated);
|
||||||
VCALL_PTR1R(Transform, scaled);
|
VCALL_PTR2R(Transform, rotated_local);
|
||||||
VCALL_PTR1R(Transform, translated_local);
|
VCALL_PTR2(Transform, rotate);
|
||||||
VCALL_PTR0R(Transform, orthonormalized);
|
VCALL_PTR2(Transform, rotate_local);
|
||||||
|
VCALL_PTR2(Transform, rotate_basis);
|
||||||
|
VCALL_PTR3(Transform, set_look_at);
|
||||||
VCALL_PTR2R(Transform, looking_at);
|
VCALL_PTR2R(Transform, looking_at);
|
||||||
VCALL_PTR2R(Transform, interpolate_with);
|
VCALL_PTR1(Transform, scale);
|
||||||
|
VCALL_PTR1R(Transform, scaled);
|
||||||
|
VCALL_PTR1R(Transform, scaled_local);
|
||||||
|
VCALL_PTR1(Transform, scale_basis);
|
||||||
|
VCALL_PTR3(Transform, translate_localr);
|
||||||
|
VCALL_PTR1(Transform, translate_localv);
|
||||||
|
VCALL_PTR1R(Transform, translated);
|
||||||
|
VCALL_PTR1R(Transform, translated_local);
|
||||||
|
VCALL_PTR0R(Transform, get_basis);
|
||||||
|
VCALL_PTR1(Transform, set_basis);
|
||||||
|
VCALL_PTR0R(Transform, get_origin);
|
||||||
|
VCALL_PTR1(Transform, set_origin);
|
||||||
|
VCALL_PTR0(Transform, orthonormalize);
|
||||||
|
VCALL_PTR0R(Transform, orthonormalized);
|
||||||
|
VCALL_PTR0(Transform, orthogonalize);
|
||||||
|
VCALL_PTR0R(Transform, orthogonalized);
|
||||||
VCALL_PTR1R(Transform, is_equal_approx);
|
VCALL_PTR1R(Transform, is_equal_approx);
|
||||||
|
VCALL_PTR2R(Transform, spherical_interpolate_with);
|
||||||
|
VCALL_PTR2R(Transform, interpolate_with);
|
||||||
|
|
||||||
static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
|
static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
|
||||||
switch (p_args[0]->type) {
|
switch (p_args[0]->type) {
|
||||||
@ -2788,15 +2809,36 @@ void register_variant_methods() {
|
|||||||
ADDFUNC1R(BASIS, VECTOR3, Basis, xform, NIL, "v3_or_v3i", varray());
|
ADDFUNC1R(BASIS, VECTOR3, Basis, xform, NIL, "v3_or_v3i", varray());
|
||||||
ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, NIL, "v3_or_v3i", varray());
|
ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, NIL, "v3_or_v3i", varray());
|
||||||
|
|
||||||
|
ADDFUNC0(TRANSFORM, NIL, Transform, invert, varray());
|
||||||
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
|
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
|
||||||
|
ADDFUNC0(TRANSFORM, NIL, Transform, affine_invert, varray());
|
||||||
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
|
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
|
||||||
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray());
|
|
||||||
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray());
|
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray());
|
||||||
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray());
|
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated_local, VECTOR3, "axis", REAL, "phi", varray());
|
||||||
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated_local, VECTOR3, "offset", varray());
|
ADDFUNC2(TRANSFORM, NIL, Transform, rotate, VECTOR3, "axis", REAL, "phi", varray());
|
||||||
|
ADDFUNC2(TRANSFORM, NIL, Transform, rotate_local, VECTOR3, "axis", REAL, "phi", varray());
|
||||||
|
ADDFUNC2(TRANSFORM, NIL, Transform, rotate_basis, VECTOR3, "axis", REAL, "phi", varray());
|
||||||
|
ADDFUNC3(TRANSFORM, NIL, Transform, set_look_at, VECTOR3, "eye", VECTOR3, "target", VECTOR3, "up", varray());
|
||||||
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray());
|
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray());
|
||||||
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray());
|
ADDFUNC1(TRANSFORM, NIL, Transform, scale, VECTOR3, "scale", varray());
|
||||||
|
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray());
|
||||||
|
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled_local, VECTOR3, "scale", varray());
|
||||||
|
ADDFUNC1(TRANSFORM, NIL, Transform, scale_basis, VECTOR3, "scale", varray());
|
||||||
|
ADDFUNC3(TRANSFORM, NIL, Transform, translate_localr, REAL, "tx", REAL, "ty", REAL, "tz", varray());
|
||||||
|
ADDFUNC1(TRANSFORM, NIL, Transform, translate_localv, VECTOR3, "scale", varray());
|
||||||
|
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "translation", varray());
|
||||||
|
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated_local, VECTOR3, "offset", varray());
|
||||||
|
ADDFUNC0R(TRANSFORM, BASIS, Transform, get_basis, varray());
|
||||||
|
ADDFUNC1(TRANSFORM, NIL, Transform, set_basis, BASIS, "basis", varray());
|
||||||
|
ADDFUNC0R(TRANSFORM, VECTOR3, Transform, get_origin, varray());
|
||||||
|
ADDFUNC1(TRANSFORM, NIL, Transform, set_origin, VECTOR3, "origin", varray());
|
||||||
|
ADDFUNC0(TRANSFORM, NIL, Transform, orthonormalize, varray());
|
||||||
|
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray());
|
||||||
|
ADDFUNC0(TRANSFORM, NIL, Transform, orthogonalize, varray());
|
||||||
|
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthogonalized, varray());
|
||||||
ADDFUNC1R(TRANSFORM, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray());
|
ADDFUNC1R(TRANSFORM, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray());
|
||||||
|
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, spherical_interpolate_with, TRANSFORM, "transform", REAL, "c", varray());
|
||||||
|
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray());
|
||||||
ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
|
ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
|
||||||
ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());
|
ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ public:
|
|||||||
VisualServer *vs = VisualServer::get_singleton();
|
VisualServer *vs = VisualServer::get_singleton();
|
||||||
//Transform t;
|
//Transform t;
|
||||||
//t.rotate(Vector3(0, 1, 0), ofs);
|
//t.rotate(Vector3(0, 1, 0), ofs);
|
||||||
//t.translate(Vector3(0,0,20 ));
|
//t.translate_local(Vector3(0,0,20 ));
|
||||||
//vs->camera_set_transform(camera, t);
|
//vs->camera_set_transform(camera, t);
|
||||||
|
|
||||||
ofs += p_time * 0.05;
|
ofs += p_time * 0.05;
|
||||||
|
Loading…
Reference in New Issue
Block a user