mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Renamed looking_at to create_looking_at, and from_scale to create_from_scale in Basis.
This commit is contained in:
parent
820f9d79d3
commit
ee1e40f1b0
@ -217,7 +217,25 @@ Basis Basis::transposed() const {
|
|||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis Basis::from_scale(const Vector3 &p_scale) {
|
Basis Basis::create_looking_at(const Vector3 &p_target, const Vector3 &p_up) {
|
||||||
|
#ifdef MATH_CHECKS
|
||||||
|
ERR_FAIL_COND_V_MSG(p_target.is_equal_approx(Vector3()), Basis(), "The target vector can't be zero.");
|
||||||
|
ERR_FAIL_COND_V_MSG(p_up.is_equal_approx(Vector3()), Basis(), "The up vector can't be zero.");
|
||||||
|
#endif
|
||||||
|
Vector3 v_z = -p_target.normalized();
|
||||||
|
Vector3 v_x = p_up.cross(v_z);
|
||||||
|
#ifdef MATH_CHECKS
|
||||||
|
ERR_FAIL_COND_V_MSG(v_x.is_equal_approx(Vector3()), Basis(), "The target vector and up vector can't be parallel to each other.");
|
||||||
|
#endif
|
||||||
|
v_x.normalize();
|
||||||
|
Vector3 v_y = v_z.cross(v_x);
|
||||||
|
|
||||||
|
Basis basis;
|
||||||
|
basis.set_columns(v_x, v_y, v_z);
|
||||||
|
return basis;
|
||||||
|
}
|
||||||
|
|
||||||
|
Basis Basis::create_from_scale(const Vector3 &p_scale) {
|
||||||
return Basis(p_scale.x, 0, 0, 0, p_scale.y, 0, 0, 0, p_scale.z);
|
return Basis(p_scale.x, 0, 0, 0, p_scale.y, 0, 0, 0, p_scale.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,20 +1203,3 @@ void Basis::rotate_sh(real_t *p_values) {
|
|||||||
p_values[8] = d4 * s_scale_dst4;
|
p_values[8] = d4 * s_scale_dst4;
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up) {
|
|
||||||
#ifdef MATH_CHECKS
|
|
||||||
ERR_FAIL_COND_V_MSG(p_target.is_equal_approx(Vector3()), Basis(), "The target vector can't be zero.");
|
|
||||||
ERR_FAIL_COND_V_MSG(p_up.is_equal_approx(Vector3()), Basis(), "The up vector can't be zero.");
|
|
||||||
#endif
|
|
||||||
Vector3 v_z = -p_target.normalized();
|
|
||||||
Vector3 v_x = p_up.cross(v_z);
|
|
||||||
#ifdef MATH_CHECKS
|
|
||||||
ERR_FAIL_COND_V_MSG(v_x.is_equal_approx(Vector3()), Basis(), "The target vector and up vector can't be parallel to each other.");
|
|
||||||
#endif
|
|
||||||
v_x.normalize();
|
|
||||||
Vector3 v_y = v_z.cross(v_x);
|
|
||||||
|
|
||||||
Basis basis;
|
|
||||||
basis.set_columns(v_x, v_y, v_z);
|
|
||||||
return basis;
|
|
||||||
}
|
|
||||||
|
@ -286,8 +286,8 @@ struct _NO_DISCARD_CLASS_ Basis {
|
|||||||
// only be used in cases of single normals, or when the basis changes each time.
|
// only be used in cases of single normals, or when the basis changes each time.
|
||||||
Vector3 xform_normal(const Vector3 &p_vector) const { return get_normal_xform_basis().xform_normal_fast(p_vector); }
|
Vector3 xform_normal(const Vector3 &p_vector) const { return get_normal_xform_basis().xform_normal_fast(p_vector); }
|
||||||
|
|
||||||
static Basis looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0));
|
static Basis create_looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0));
|
||||||
static Basis from_scale(const Vector3 &p_scale);
|
static Basis create_from_scale(const Vector3 &p_scale);
|
||||||
|
|
||||||
operator Quaternion() const { return get_quaternion(); }
|
operator Quaternion() const { return get_quaternion(); }
|
||||||
|
|
||||||
|
@ -691,23 +691,23 @@ pandemonium_vector3 GDAPI pandemonium_basis_xform_normal(const pandemonium_basis
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandemonium_basis GDAPI pandemonium_basis_looking_at(const pandemonium_vector3 *p_target) {
|
pandemonium_basis GDAPI pandemonium_basis_create_looking_at(const pandemonium_vector3 *p_target) {
|
||||||
pandemonium_basis dest;
|
pandemonium_basis dest;
|
||||||
const Vector3 *target = (const Vector3 *)p_target;
|
const Vector3 *target = (const Vector3 *)p_target;
|
||||||
*((Basis *)&dest) = Basis::looking_at(*target);
|
*((Basis *)&dest) = Basis::create_looking_at(*target);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
pandemonium_basis GDAPI pandemonium_basis_looking_at_up(const pandemonium_vector3 *p_target, const pandemonium_vector3 *p_up) {
|
pandemonium_basis GDAPI pandemonium_basis_looking_at_up(const pandemonium_vector3 *p_target, const pandemonium_vector3 *p_up) {
|
||||||
pandemonium_basis dest;
|
pandemonium_basis dest;
|
||||||
const Vector3 *target = (const Vector3 *)p_target;
|
const Vector3 *target = (const Vector3 *)p_target;
|
||||||
const Vector3 *up = (const Vector3 *)p_up;
|
const Vector3 *up = (const Vector3 *)p_up;
|
||||||
*((Basis *)&dest) = Basis::looking_at(*target, *up);
|
*((Basis *)&dest) = Basis::create_looking_at(*target, *up);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
pandemonium_basis GDAPI pandemonium_basis_from_scale(const pandemonium_vector3 *p_scale) {
|
pandemonium_basis GDAPI pandemonium_basis_create_from_scale(const pandemonium_vector3 *p_scale) {
|
||||||
pandemonium_basis dest;
|
pandemonium_basis dest;
|
||||||
const Vector3 *scale = (const Vector3 *)p_scale;
|
const Vector3 *scale = (const Vector3 *)p_scale;
|
||||||
*((Basis *)&dest) = Basis::from_scale(*scale);
|
*((Basis *)&dest) = Basis::create_from_scale(*scale);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1696,7 +1696,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pandemonium_basis_looking_at",
|
"name": "pandemonium_basis_create_looking_at",
|
||||||
"return_type": "pandemonium_basis",
|
"return_type": "pandemonium_basis",
|
||||||
"arguments": [
|
"arguments": [
|
||||||
["const pandemonium_vector3 *", "p_target"]
|
["const pandemonium_vector3 *", "p_target"]
|
||||||
@ -1711,7 +1711,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pandemonium_basis_from_scale",
|
"name": "pandemonium_basis_create_from_scale",
|
||||||
"return_type": "pandemonium_basis",
|
"return_type": "pandemonium_basis",
|
||||||
"arguments": [
|
"arguments": [
|
||||||
["const pandemonium_vector3 *", "p_scale"]
|
["const pandemonium_vector3 *", "p_scale"]
|
||||||
@ -13911,4 +13911,4 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -213,9 +213,9 @@ pandemonium_basis GDAPI pandemonium_basis_get_normal_xform_basis(const pandemoni
|
|||||||
pandemonium_vector3 GDAPI pandemonium_basis_xform_normal_fast(const pandemonium_basis *p_self, const pandemonium_vector3 *p_vector);
|
pandemonium_vector3 GDAPI pandemonium_basis_xform_normal_fast(const pandemonium_basis *p_self, const pandemonium_vector3 *p_vector);
|
||||||
pandemonium_vector3 GDAPI pandemonium_basis_xform_normal(const pandemonium_basis *p_self, const pandemonium_vector3 *p_vector);
|
pandemonium_vector3 GDAPI pandemonium_basis_xform_normal(const pandemonium_basis *p_self, const pandemonium_vector3 *p_vector);
|
||||||
|
|
||||||
pandemonium_basis GDAPI pandemonium_basis_looking_at(const pandemonium_vector3 *p_target);
|
pandemonium_basis GDAPI pandemonium_basis_create_looking_at(const pandemonium_vector3 *p_target);
|
||||||
pandemonium_basis GDAPI pandemonium_basis_looking_at_up(const pandemonium_vector3 *p_target, const pandemonium_vector3 *p_up);
|
pandemonium_basis GDAPI pandemonium_basis_looking_at_up(const pandemonium_vector3 *p_target, const pandemonium_vector3 *p_up);
|
||||||
pandemonium_basis GDAPI pandemonium_basis_from_scale(const pandemonium_vector3 *p_scale);
|
pandemonium_basis GDAPI pandemonium_basis_create_from_scale(const pandemonium_vector3 *p_scale);
|
||||||
|
|
||||||
// p_elements is a pointer to an array of 3 (!!) vector3
|
// p_elements is a pointer to an array of 3 (!!) vector3
|
||||||
void GDAPI pandemonium_basis_get_elements(const pandemonium_basis *p_self, pandemonium_vector3 *p_elements);
|
void GDAPI pandemonium_basis_get_elements(const pandemonium_basis *p_self, pandemonium_vector3 *p_elements);
|
||||||
|
Loading…
Reference in New Issue
Block a user