Rename Transform to Transform3D in core

This commit is contained in:
Aaron Franke 2020-10-17 01:08:21 -04:00
parent b80494e633
commit de3f6699a5
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
257 changed files with 1697 additions and 1702 deletions

View File

@ -327,7 +327,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break; } break;
case Variant::TRANSFORM: { case Variant::TRANSFORM: {
ERR_FAIL_COND_V(len < 4 * 12, ERR_INVALID_DATA); ERR_FAIL_COND_V(len < 4 * 12, ERR_INVALID_DATA);
Transform val; Transform3D val;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]); val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]);
@ -1140,7 +1140,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break; } break;
case Variant::TRANSFORM: { case Variant::TRANSFORM: {
if (buf) { if (buf) {
Transform val = p_variant; Transform3D val = p_variant;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
memcpy(&buf[(i * 3 + j) * 4], &val.basis.elements[i][j], sizeof(float)); memcpy(&buf[(i * 3 + j) * 4], &val.basis.elements[i][j], sizeof(float));

View File

@ -245,7 +245,7 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break; } break;
case VARIANT_TRANSFORM: { case VARIANT_TRANSFORM: {
Transform v; Transform3D v;
v.basis.elements[0].x = f->get_real(); v.basis.elements[0].x = f->get_real();
v.basis.elements[0].y = f->get_real(); v.basis.elements[0].y = f->get_real();
v.basis.elements[0].z = f->get_real(); v.basis.elements[0].z = f->get_real();
@ -1418,7 +1418,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break; } break;
case Variant::TRANSFORM: { case Variant::TRANSFORM: {
f->store_32(VARIANT_TRANSFORM); f->store_32(VARIANT_TRANSFORM);
Transform val = p_property; Transform3D val = p_property;
f->store_real(val.basis.elements[0].x); f->store_real(val.basis.elements[0].x);
f->store_real(val.basis.elements[0].y); f->store_real(val.basis.elements[0].y);
f->store_real(val.basis.elements[0].z); f->store_real(val.basis.elements[0].z);

View File

@ -315,8 +315,8 @@ Vector2 CameraMatrix::get_far_plane_half_extents() const {
return Vector2(res.x, res.y); return Vector2(res.x, res.y);
} }
bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const { bool CameraMatrix::get_endpoints(const Transform3D &p_transform, Vector3 *p_8points) const {
Vector<Plane> planes = get_projection_planes(Transform()); Vector<Plane> planes = get_projection_planes(Transform3D());
const Planes intersections[8][3] = { const Planes intersections[8][3] = {
{ PLANE_FAR, PLANE_LEFT, PLANE_TOP }, { PLANE_FAR, PLANE_LEFT, PLANE_TOP },
{ PLANE_FAR, PLANE_LEFT, PLANE_BOTTOM }, { PLANE_FAR, PLANE_LEFT, PLANE_BOTTOM },
@ -338,7 +338,7 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
return true; return true;
} }
Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform) const { Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform) const {
/** Fast Plane Extraction from combined modelview/projection matrices. /** Fast Plane Extraction from combined modelview/projection matrices.
* References: * References:
* https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html * https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
@ -707,8 +707,8 @@ void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
matrix[3][3] = 1; matrix[3][3] = 1;
} }
CameraMatrix::operator Transform() const { CameraMatrix::operator Transform3D() const {
Transform tr; Transform3D tr;
const real_t *m = &matrix[0][0]; const real_t *m = &matrix[0][0];
tr.basis.elements[0][0] = m[0]; tr.basis.elements[0][0] = m[0];
@ -730,8 +730,8 @@ CameraMatrix::operator Transform() const {
return tr; return tr;
} }
CameraMatrix::CameraMatrix(const Transform &p_transform) { CameraMatrix::CameraMatrix(const Transform3D &p_transform) {
const Transform &tr = p_transform; const Transform3D &tr = p_transform;
real_t *m = &matrix[0][0]; real_t *m = &matrix[0][0];
m[0] = tr.basis.elements[0][0]; m[0] = tr.basis.elements[0][0];

View File

@ -71,9 +71,9 @@ struct CameraMatrix {
real_t get_fov() const; real_t get_fov() const;
bool is_orthogonal() const; bool is_orthogonal() const;
Vector<Plane> get_projection_planes(const Transform &p_transform) const; Vector<Plane> get_projection_planes(const Transform3D &p_transform) const;
bool get_endpoints(const Transform &p_transform, Vector3 *p_8points) const; bool get_endpoints(const Transform3D &p_transform, Vector3 *p_8points) const;
Vector2 get_viewport_half_extents() const; Vector2 get_viewport_half_extents() const;
Vector2 get_far_plane_half_extents() const; Vector2 get_far_plane_half_extents() const;
@ -90,7 +90,7 @@ struct CameraMatrix {
void scale_translate_to_fit(const AABB &p_aabb); void scale_translate_to_fit(const AABB &p_aabb);
void make_scale(const Vector3 &p_scale); void make_scale(const Vector3 &p_scale);
int get_pixels_per_meter(int p_for_pixel_width) const; int get_pixels_per_meter(int p_for_pixel_width) const;
operator Transform() const; operator Transform3D() const;
void flip_y(); void flip_y();
@ -112,7 +112,7 @@ struct CameraMatrix {
float get_lod_multiplier() const; float get_lod_multiplier() const;
CameraMatrix(); CameraMatrix();
CameraMatrix(const Transform &p_transform); CameraMatrix(const Transform3D &p_transform);
~CameraMatrix(); ~CameraMatrix();
}; };

View File

@ -230,7 +230,7 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const {
real_t minA, maxA, minB, maxB; real_t minA, maxA, minB, maxB;
p_aabb.project_range_in_plane(Plane(axis, 0), minA, maxA); p_aabb.project_range_in_plane(Plane(axis, 0), minA, maxA);
project_range(axis, Transform(), minB, maxB); project_range(axis, Transform3D(), minB, maxB);
if (maxA < minB || maxB < minA) { if (maxA < minB || maxB < minA) {
return false; return false;
@ -244,7 +244,7 @@ Face3::operator String() const {
return String() + vertex[0] + ", " + vertex[1] + ", " + vertex[2]; return String() + vertex[0] + ", " + vertex[1] + ", " + vertex[2];
} }
void Face3::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { void Face3::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
Vector3 v = p_transform.xform(vertex[i]); Vector3 v = p_transform.xform(vertex[i]);
real_t d = p_normal.dot(v); real_t d = p_normal.dot(v);
@ -259,7 +259,7 @@ void Face3::project_range(const Vector3 &p_normal, const Transform &p_transform,
} }
} }
void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const { void Face3::get_support(const Vector3 &p_normal, const Transform3D &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const {
#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.98 #define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.98
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.05 #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.05

View File

@ -74,8 +74,8 @@ public:
ClockDirection get_clock_dir() const; ///< todo, test if this is returning the proper clockwisity ClockDirection get_clock_dir() const; ///< todo, test if this is returning the proper clockwisity
void get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const; void get_support(const Vector3 &p_normal, const Transform3D &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const;
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const;
AABB get_aabb() const { AABB get_aabb() const {
AABB aabb(vertex[0], Vector3()); AABB aabb(vertex[0], Vector3());

View File

@ -142,7 +142,7 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
} }
case Variant::TRANSFORM: { case Variant::TRANSFORM: {
SETUP_TYPE(Transform) SETUP_TYPE(Transform3D)
/**/ TRY_TRANSFER_FIELD("xx", basis.elements[0][0]) /**/ TRY_TRANSFER_FIELD("xx", basis.elements[0][0])
else TRY_TRANSFER_FIELD("xy", basis.elements[0][1]) else TRY_TRANSFER_FIELD("xy", basis.elements[0][1])

View File

@ -33,49 +33,49 @@
#include "core/math/math_funcs.h" #include "core/math/math_funcs.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
void Transform::affine_invert() { void Transform3D::affine_invert() {
basis.invert(); basis.invert();
origin = basis.xform(-origin); origin = basis.xform(-origin);
} }
Transform Transform::affine_inverse() const { Transform3D Transform3D::affine_inverse() const {
Transform ret = *this; Transform3D ret = *this;
ret.affine_invert(); ret.affine_invert();
return ret; return ret;
} }
void Transform::invert() { void Transform3D::invert() {
basis.transpose(); basis.transpose();
origin = basis.xform(-origin); origin = basis.xform(-origin);
} }
Transform Transform::inverse() const { Transform3D Transform3D::inverse() const {
// FIXME: this function assumes the basis is a rotation matrix, with no scaling. // FIXME: this function assumes the basis is a rotation matrix, with no scaling.
// Transform::affine_inverse can handle matrices with scaling, so GDScript should eventually use that. // Transform3D::affine_inverse can handle matrices with scaling, so GDScript should eventually use that.
Transform ret = *this; Transform3D ret = *this;
ret.invert(); ret.invert();
return ret; return ret;
} }
void Transform::rotate(const Vector3 &p_axis, real_t p_phi) { void Transform3D::rotate(const Vector3 &p_axis, real_t p_phi) {
*this = rotated(p_axis, p_phi); *this = rotated(p_axis, p_phi);
} }
Transform Transform::rotated(const Vector3 &p_axis, real_t p_phi) const { Transform3D Transform3D::rotated(const Vector3 &p_axis, real_t p_phi) const {
return Transform(Basis(p_axis, p_phi), Vector3()) * (*this); return Transform3D(Basis(p_axis, p_phi), Vector3()) * (*this);
} }
void Transform::rotate_basis(const Vector3 &p_axis, real_t p_phi) { void Transform3D::rotate_basis(const Vector3 &p_axis, real_t p_phi) {
basis.rotate(p_axis, p_phi); basis.rotate(p_axis, p_phi);
} }
Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) const { Transform3D Transform3D::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
Transform t = *this; Transform3D t = *this;
t.set_look_at(origin, p_target, p_up); t.set_look_at(origin, p_target, p_up);
return t; return t;
} }
void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) { void Transform3D::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
#ifdef MATH_CHECKS #ifdef MATH_CHECKS
ERR_FAIL_COND(p_eye == p_target); ERR_FAIL_COND(p_eye == p_target);
ERR_FAIL_COND(p_up.length() == 0); ERR_FAIL_COND(p_up.length() == 0);
@ -108,7 +108,7 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const
origin = p_eye; origin = p_eye;
} }
Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) const { Transform3D Transform3D::interpolate_with(const Transform3D &p_transform, real_t p_c) const {
/* not sure if very "efficient" but good enough? */ /* not sure if very "efficient" but good enough? */
Vector3 src_scale = basis.get_scale(); Vector3 src_scale = basis.get_scale();
@ -119,94 +119,94 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
Quat dst_rot = p_transform.basis.get_rotation_quat(); Quat dst_rot = p_transform.basis.get_rotation_quat();
Vector3 dst_loc = p_transform.origin; Vector3 dst_loc = p_transform.origin;
Transform interp; Transform3D interp;
interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.lerp(dst_scale, p_c)); interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.lerp(dst_scale, p_c));
interp.origin = src_loc.lerp(dst_loc, p_c); interp.origin = src_loc.lerp(dst_loc, p_c);
return interp; return interp;
} }
void Transform::scale(const Vector3 &p_scale) { void Transform3D::scale(const Vector3 &p_scale) {
basis.scale(p_scale); basis.scale(p_scale);
origin *= p_scale; origin *= p_scale;
} }
Transform Transform::scaled(const Vector3 &p_scale) const { Transform3D Transform3D::scaled(const Vector3 &p_scale) const {
Transform t = *this; Transform3D t = *this;
t.scale(p_scale); t.scale(p_scale);
return t; return t;
} }
void Transform::scale_basis(const Vector3 &p_scale) { void Transform3D::scale_basis(const Vector3 &p_scale) {
basis.scale(p_scale); basis.scale(p_scale);
} }
void Transform::translate(real_t p_tx, real_t p_ty, real_t p_tz) { void Transform3D::translate(real_t p_tx, real_t p_ty, real_t p_tz) {
translate(Vector3(p_tx, p_ty, p_tz)); translate(Vector3(p_tx, p_ty, p_tz));
} }
void Transform::translate(const Vector3 &p_translation) { void Transform3D::translate(const Vector3 &p_translation) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
origin[i] += basis[i].dot(p_translation); origin[i] += basis[i].dot(p_translation);
} }
} }
Transform Transform::translated(const Vector3 &p_translation) const { Transform3D Transform3D::translated(const Vector3 &p_translation) const {
Transform t = *this; Transform3D t = *this;
t.translate(p_translation); t.translate(p_translation);
return t; return t;
} }
void Transform::orthonormalize() { void Transform3D::orthonormalize() {
basis.orthonormalize(); basis.orthonormalize();
} }
Transform Transform::orthonormalized() const { Transform3D Transform3D::orthonormalized() const {
Transform _copy = *this; Transform3D _copy = *this;
_copy.orthonormalize(); _copy.orthonormalize();
return _copy; return _copy;
} }
bool Transform::is_equal_approx(const Transform &p_transform) const { bool Transform3D::is_equal_approx(const Transform3D &p_transform) const {
return basis.is_equal_approx(p_transform.basis) && origin.is_equal_approx(p_transform.origin); return basis.is_equal_approx(p_transform.basis) && origin.is_equal_approx(p_transform.origin);
} }
bool Transform::operator==(const Transform &p_transform) const { bool Transform3D::operator==(const Transform3D &p_transform) const {
return (basis == p_transform.basis && origin == p_transform.origin); return (basis == p_transform.basis && origin == p_transform.origin);
} }
bool Transform::operator!=(const Transform &p_transform) const { bool Transform3D::operator!=(const Transform3D &p_transform) const {
return (basis != p_transform.basis || origin != p_transform.origin); return (basis != p_transform.basis || origin != p_transform.origin);
} }
void Transform::operator*=(const Transform &p_transform) { void Transform3D::operator*=(const Transform3D &p_transform) {
origin = xform(p_transform.origin); origin = xform(p_transform.origin);
basis *= p_transform.basis; basis *= p_transform.basis;
} }
Transform Transform::operator*(const Transform &p_transform) const { Transform3D Transform3D::operator*(const Transform3D &p_transform) const {
Transform t = *this; Transform3D t = *this;
t *= p_transform; t *= p_transform;
return t; return t;
} }
Transform::operator String() const { Transform3D::operator String() const {
return basis.operator String() + " - " + origin.operator String(); return basis.operator String() + " - " + origin.operator String();
} }
Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) : Transform3D::Transform3D(const Basis &p_basis, const Vector3 &p_origin) :
basis(p_basis), basis(p_basis),
origin(p_origin) { origin(p_origin) {
} }
Transform::Transform(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin) : Transform3D::Transform3D(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin) :
origin(p_origin) { origin(p_origin) {
basis.set_axis(0, p_x); basis.set_axis(0, p_x);
basis.set_axis(1, p_y); basis.set_axis(1, p_y);
basis.set_axis(2, p_z); basis.set_axis(2, p_z);
} }
Transform::Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz) { Transform3D::Transform3D(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz) {
basis = Basis(xx, xy, xz, yx, yy, yz, zx, zy, zz); basis = Basis(xx, xy, xz, yx, yy, yz, zx, zy, zz);
origin = Vector3(ox, oy, oz); origin = Vector3(ox, oy, oz);
} }

View File

@ -35,31 +35,31 @@
#include "core/math/basis.h" #include "core/math/basis.h"
#include "core/math/plane.h" #include "core/math/plane.h"
class Transform { class Transform3D {
public: public:
Basis basis; Basis basis;
Vector3 origin; Vector3 origin;
void invert(); void invert();
Transform inverse() const; Transform3D inverse() const;
void affine_invert(); void affine_invert();
Transform affine_inverse() const; Transform3D affine_inverse() const;
Transform rotated(const Vector3 &p_axis, real_t p_phi) const; Transform3D rotated(const Vector3 &p_axis, real_t p_phi) const;
void rotate(const Vector3 &p_axis, real_t p_phi); void rotate(const Vector3 &p_axis, real_t p_phi);
void rotate_basis(const Vector3 &p_axis, real_t p_phi); void rotate_basis(const Vector3 &p_axis, real_t p_phi);
void set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0)); void set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0));
Transform looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0)) const; Transform3D looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0)) const;
void scale(const Vector3 &p_scale); void scale(const Vector3 &p_scale);
Transform scaled(const Vector3 &p_scale) const; Transform3D scaled(const Vector3 &p_scale) const;
void scale_basis(const Vector3 &p_scale); void scale_basis(const Vector3 &p_scale);
void translate(real_t p_tx, real_t p_ty, real_t p_tz); void translate(real_t p_tx, real_t p_ty, real_t p_tz);
void translate(const Vector3 &p_translation); void translate(const Vector3 &p_translation);
Transform translated(const Vector3 &p_translation) const; Transform3D translated(const Vector3 &p_translation) const;
const Basis &get_basis() const { return basis; } const Basis &get_basis() const { return basis; }
void set_basis(const Basis &p_basis) { basis = p_basis; } void set_basis(const Basis &p_basis) { basis = p_basis; }
@ -68,11 +68,11 @@ public:
void set_origin(const Vector3 &p_origin) { origin = p_origin; } void set_origin(const Vector3 &p_origin) { origin = p_origin; }
void orthonormalize(); void orthonormalize();
Transform orthonormalized() const; Transform3D orthonormalized() const;
bool is_equal_approx(const Transform &p_transform) const; bool is_equal_approx(const Transform3D &p_transform) const;
bool operator==(const Transform &p_transform) const; bool operator==(const Transform3D &p_transform) const;
bool operator!=(const Transform &p_transform) const; bool operator!=(const Transform3D &p_transform) const;
_FORCE_INLINE_ Vector3 xform(const Vector3 &p_vector) const; _FORCE_INLINE_ Vector3 xform(const Vector3 &p_vector) const;
_FORCE_INLINE_ Vector3 xform_inv(const Vector3 &p_vector) const; _FORCE_INLINE_ Vector3 xform_inv(const Vector3 &p_vector) const;
@ -86,14 +86,14 @@ public:
_FORCE_INLINE_ Vector<Vector3> xform(const Vector<Vector3> &p_array) const; _FORCE_INLINE_ Vector<Vector3> xform(const Vector<Vector3> &p_array) const;
_FORCE_INLINE_ Vector<Vector3> xform_inv(const Vector<Vector3> &p_array) const; _FORCE_INLINE_ Vector<Vector3> xform_inv(const Vector<Vector3> &p_array) const;
void operator*=(const Transform &p_transform); void operator*=(const Transform3D &p_transform);
Transform operator*(const Transform &p_transform) const; Transform3D operator*(const Transform3D &p_transform) const;
Transform interpolate_with(const Transform &p_transform, real_t p_c) const; Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const;
_FORCE_INLINE_ Transform inverse_xform(const Transform &t) const { _FORCE_INLINE_ Transform3D inverse_xform(const Transform3D &t) const {
Vector3 v = t.origin - origin; Vector3 v = t.origin - origin;
return Transform(basis.transpose_xform(t.basis), return Transform3D(basis.transpose_xform(t.basis),
basis.xform(v)); basis.xform(v));
} }
@ -106,20 +106,20 @@ public:
operator String() const; operator String() const;
Transform() {} Transform3D() {}
Transform(const Basis &p_basis, const Vector3 &p_origin = Vector3()); Transform3D(const Basis &p_basis, const Vector3 &p_origin = Vector3());
Transform(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin); Transform3D(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin);
Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz); Transform3D(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz);
}; };
_FORCE_INLINE_ Vector3 Transform::xform(const Vector3 &p_vector) const { _FORCE_INLINE_ Vector3 Transform3D::xform(const Vector3 &p_vector) const {
return Vector3( return Vector3(
basis[0].dot(p_vector) + origin.x, basis[0].dot(p_vector) + origin.x,
basis[1].dot(p_vector) + origin.y, basis[1].dot(p_vector) + origin.y,
basis[2].dot(p_vector) + origin.z); basis[2].dot(p_vector) + origin.z);
} }
_FORCE_INLINE_ Vector3 Transform::xform_inv(const Vector3 &p_vector) const { _FORCE_INLINE_ Vector3 Transform3D::xform_inv(const Vector3 &p_vector) const {
Vector3 v = p_vector - origin; Vector3 v = p_vector - origin;
return Vector3( return Vector3(
@ -128,7 +128,7 @@ _FORCE_INLINE_ Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
(basis.elements[0][2] * v.x) + (basis.elements[1][2] * v.y) + (basis.elements[2][2] * v.z)); (basis.elements[0][2] * v.x) + (basis.elements[1][2] * v.y) + (basis.elements[2][2] * v.z));
} }
_FORCE_INLINE_ Plane Transform::xform(const Plane &p_plane) const { _FORCE_INLINE_ Plane Transform3D::xform(const Plane &p_plane) const {
Vector3 point = p_plane.normal * p_plane.d; Vector3 point = p_plane.normal * p_plane.d;
Vector3 point_dir = point + p_plane.normal; Vector3 point_dir = point + p_plane.normal;
point = xform(point); point = xform(point);
@ -141,7 +141,7 @@ _FORCE_INLINE_ Plane Transform::xform(const Plane &p_plane) const {
return Plane(normal, d); return Plane(normal, d);
} }
_FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const { _FORCE_INLINE_ Plane Transform3D::xform_inv(const Plane &p_plane) const {
Vector3 point = p_plane.normal * p_plane.d; Vector3 point = p_plane.normal * p_plane.d;
Vector3 point_dir = point + p_plane.normal; Vector3 point_dir = point + p_plane.normal;
point = xform_inv(point); point = xform_inv(point);
@ -154,7 +154,7 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
return Plane(normal, d); return Plane(normal, d);
} }
_FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const { _FORCE_INLINE_ AABB Transform3D::xform(const AABB &p_aabb) const {
/* http://dev.theomader.com/transform-bounding-boxes/ */ /* http://dev.theomader.com/transform-bounding-boxes/ */
Vector3 min = p_aabb.position; Vector3 min = p_aabb.position;
Vector3 max = p_aabb.position + p_aabb.size; Vector3 max = p_aabb.position + p_aabb.size;
@ -179,7 +179,7 @@ _FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const {
return r_aabb; return r_aabb;
} }
_FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const { _FORCE_INLINE_ AABB Transform3D::xform_inv(const AABB &p_aabb) const {
/* define vertices */ /* define vertices */
Vector3 vertices[8] = { Vector3 vertices[8] = {
Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z), Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
@ -203,7 +203,7 @@ _FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
return ret; return ret;
} }
Vector<Vector3> Transform::xform(const Vector<Vector3> &p_array) const { Vector<Vector3> Transform3D::xform(const Vector<Vector3> &p_array) const {
Vector<Vector3> array; Vector<Vector3> array;
array.resize(p_array.size()); array.resize(p_array.size());
@ -216,7 +216,7 @@ Vector<Vector3> Transform::xform(const Vector<Vector3> &p_array) const {
return array; return array;
} }
Vector<Vector3> Transform::xform_inv(const Vector<Vector3> &p_array) const { Vector<Vector3> Transform3D::xform_inv(const Vector<Vector3> &p_array) const {
Vector<Vector3> array; Vector<Vector3> array;
array.resize(p_array.size()); array.resize(p_array.size());

View File

@ -600,7 +600,7 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count,
const Vector3 *vertexptr = vertices.ptr(); const Vector3 *vertexptr = vertices.ptr();
const BVH *bvhptr = bvh.ptr(); const BVH *bvhptr = bvh.ptr();
Transform scale(Basis().scaled(p_scale)); Transform3D scale(Basis().scaled(p_scale));
int pos = bvh.size() - 1; int pos = bvh.size() - 1;

View File

@ -125,7 +125,7 @@ MAKE_PTRARG_BY_REFERENCE(Plane);
MAKE_PTRARG(Quat); MAKE_PTRARG(Quat);
MAKE_PTRARG_BY_REFERENCE(AABB); MAKE_PTRARG_BY_REFERENCE(AABB);
MAKE_PTRARG_BY_REFERENCE(Basis); MAKE_PTRARG_BY_REFERENCE(Basis);
MAKE_PTRARG_BY_REFERENCE(Transform); MAKE_PTRARG_BY_REFERENCE(Transform3D);
MAKE_PTRARG_BY_REFERENCE(Color); MAKE_PTRARG_BY_REFERENCE(Color);
MAKE_PTRARG(StringName); MAKE_PTRARG(StringName);
MAKE_PTRARG(NodePath); MAKE_PTRARG(NodePath);

View File

@ -149,7 +149,7 @@ MAKE_TYPE_INFO(Plane, Variant::PLANE)
MAKE_TYPE_INFO(Quat, Variant::QUAT) MAKE_TYPE_INFO(Quat, Variant::QUAT)
MAKE_TYPE_INFO(AABB, Variant::AABB) MAKE_TYPE_INFO(AABB, Variant::AABB)
MAKE_TYPE_INFO(Basis, Variant::BASIS) MAKE_TYPE_INFO(Basis, Variant::BASIS)
MAKE_TYPE_INFO(Transform, Variant::TRANSFORM) MAKE_TYPE_INFO(Transform3D, Variant::TRANSFORM)
MAKE_TYPE_INFO(Color, Variant::COLOR) MAKE_TYPE_INFO(Color, Variant::COLOR)
MAKE_TYPE_INFO(StringName, Variant::STRING_NAME) MAKE_TYPE_INFO(StringName, Variant::STRING_NAME)
MAKE_TYPE_INFO(NodePath, Variant::NODE_PATH) MAKE_TYPE_INFO(NodePath, Variant::NODE_PATH)

View File

@ -101,7 +101,7 @@ MAKE_TYPED_ARRAY(Plane, Variant::PLANE)
MAKE_TYPED_ARRAY(Quat, Variant::QUAT) MAKE_TYPED_ARRAY(Quat, Variant::QUAT)
MAKE_TYPED_ARRAY(AABB, Variant::AABB) MAKE_TYPED_ARRAY(AABB, Variant::AABB)
MAKE_TYPED_ARRAY(Basis, Variant::BASIS) MAKE_TYPED_ARRAY(Basis, Variant::BASIS)
MAKE_TYPED_ARRAY(Transform, Variant::TRANSFORM) MAKE_TYPED_ARRAY(Transform3D, Variant::TRANSFORM)
MAKE_TYPED_ARRAY(Color, Variant::COLOR) MAKE_TYPED_ARRAY(Color, Variant::COLOR)
MAKE_TYPED_ARRAY(StringName, Variant::STRING_NAME) MAKE_TYPED_ARRAY(StringName, Variant::STRING_NAME)
MAKE_TYPED_ARRAY(NodePath, Variant::NODE_PATH) MAKE_TYPED_ARRAY(NodePath, Variant::NODE_PATH)
@ -199,7 +199,7 @@ MAKE_TYPED_ARRAY_INFO(Plane, Variant::PLANE)
MAKE_TYPED_ARRAY_INFO(Quat, Variant::QUAT) MAKE_TYPED_ARRAY_INFO(Quat, Variant::QUAT)
MAKE_TYPED_ARRAY_INFO(AABB, Variant::AABB) MAKE_TYPED_ARRAY_INFO(AABB, Variant::AABB)
MAKE_TYPED_ARRAY_INFO(Basis, Variant::BASIS) MAKE_TYPED_ARRAY_INFO(Basis, Variant::BASIS)
MAKE_TYPED_ARRAY_INFO(Transform, Variant::TRANSFORM) MAKE_TYPED_ARRAY_INFO(Transform3D, Variant::TRANSFORM)
MAKE_TYPED_ARRAY_INFO(Color, Variant::COLOR) MAKE_TYPED_ARRAY_INFO(Color, Variant::COLOR)
MAKE_TYPED_ARRAY_INFO(StringName, Variant::STRING_NAME) MAKE_TYPED_ARRAY_INFO(StringName, Variant::STRING_NAME)
MAKE_TYPED_ARRAY_INFO(NodePath, Variant::NODE_PATH) MAKE_TYPED_ARRAY_INFO(NodePath, Variant::NODE_PATH)

View File

@ -100,7 +100,7 @@ String Variant::get_type_name(Variant::Type p_type) {
} break; } break;
case TRANSFORM: { case TRANSFORM: {
return "Transform"; return "Transform3D";
} break; } break;
@ -882,7 +882,7 @@ bool Variant::is_zero() const {
} break; } break;
case TRANSFORM: { case TRANSFORM: {
return *_data._transform == Transform(); return *_data._transform == Transform3D();
} break; } break;
@ -1101,7 +1101,7 @@ void Variant::reference(const Variant &p_variant) {
} break; } break;
case TRANSFORM: { case TRANSFORM: {
_data._transform = memnew(Transform(*p_variant._data._transform)); _data._transform = memnew(Transform3D(*p_variant._data._transform));
} break; } break;
// misc types // misc types
@ -1683,7 +1683,7 @@ String Variant::stringify(List<const void *> &stack) const {
return mtx + ")"; return mtx + ")";
} break; } break;
case TRANSFORM: case TRANSFORM:
return operator Transform(); return operator Transform3D();
case STRING_NAME: case STRING_NAME:
return operator StringName(); return operator StringName();
case NODE_PATH: case NODE_PATH:
@ -1979,16 +1979,16 @@ Variant::operator Quat() const {
} }
} }
Variant::operator Transform() const { Variant::operator Transform3D() const {
if (type == TRANSFORM) { if (type == TRANSFORM) {
return *_data._transform; return *_data._transform;
} else if (type == BASIS) { } else if (type == BASIS) {
return Transform(*_data._basis, Vector3()); return Transform3D(*_data._basis, Vector3());
} else if (type == QUAT) { } else if (type == QUAT) {
return Transform(Basis(*reinterpret_cast<const Quat *>(_data._mem)), Vector3()); return Transform3D(Basis(*reinterpret_cast<const Quat *>(_data._mem)), Vector3());
} else if (type == TRANSFORM2D) { } else if (type == TRANSFORM2D) {
const Transform2D &t = *_data._transform2d; const Transform2D &t = *_data._transform2d;
Transform m; Transform3D m;
m.basis.elements[0][0] = t.elements[0][0]; m.basis.elements[0][0] = t.elements[0][0];
m.basis.elements[1][0] = t.elements[0][1]; m.basis.elements[1][0] = t.elements[0][1];
m.basis.elements[0][1] = t.elements[1][0]; m.basis.elements[0][1] = t.elements[1][0];
@ -1997,7 +1997,7 @@ Variant::operator Transform() const {
m.origin[1] = t.elements[2][1]; m.origin[1] = t.elements[2][1];
return m; return m;
} else { } else {
return Transform(); return Transform3D();
} }
} }
@ -2005,7 +2005,7 @@ Variant::operator Transform2D() const {
if (type == TRANSFORM2D) { if (type == TRANSFORM2D) {
return *_data._transform2d; return *_data._transform2d;
} else if (type == TRANSFORM) { } else if (type == TRANSFORM) {
const Transform &t = *_data._transform; const Transform3D &t = *_data._transform;
Transform2D m; Transform2D m;
m.elements[0][0] = t.basis.elements[0][0]; m.elements[0][0] = t.basis.elements[0][0];
m.elements[0][1] = t.basis.elements[1][0]; m.elements[0][1] = t.basis.elements[1][0];
@ -2500,9 +2500,9 @@ Variant::Variant(const Quat &p_quat) {
memnew_placement(_data._mem, Quat(p_quat)); memnew_placement(_data._mem, Quat(p_quat));
} }
Variant::Variant(const Transform &p_transform) { Variant::Variant(const Transform3D &p_transform) {
type = TRANSFORM; type = TRANSFORM;
_data._transform = memnew(Transform(p_transform)); _data._transform = memnew(Transform3D(p_transform));
} }
Variant::Variant(const Transform2D &p_transform) { Variant::Variant(const Transform2D &p_transform) {
@ -3256,8 +3256,8 @@ bool Variant::hash_compare(const Variant &p_variant) const {
} break; } break;
case TRANSFORM: { case TRANSFORM: {
const Transform *l = _data._transform; const Transform3D *l = _data._transform;
const Transform *r = p_variant._data._transform; const Transform3D *r = p_variant._data._transform;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i]))) { if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i]))) {

View File

@ -200,7 +200,7 @@ private:
Transform2D *_transform2d; Transform2D *_transform2d;
::AABB *_aabb; ::AABB *_aabb;
Basis *_basis; Basis *_basis;
Transform *_transform; Transform3D *_transform;
PackedArrayRefBase *packed_array; PackedArrayRefBase *packed_array;
void *_ptr; //generic pointer void *_ptr; //generic pointer
uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)]; uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)];
@ -322,7 +322,7 @@ public:
operator ::AABB() const; operator ::AABB() const;
operator Quat() const; operator Quat() const;
operator Basis() const; operator Basis() const;
operator Transform() const; operator Transform3D() const;
operator Transform2D() const; operator Transform2D() const;
operator Color() const; operator Color() const;
@ -395,7 +395,7 @@ public:
Variant(const Quat &p_quat); Variant(const Quat &p_quat);
Variant(const Basis &p_matrix); Variant(const Basis &p_matrix);
Variant(const Transform2D &p_transform); Variant(const Transform2D &p_transform);
Variant(const Transform &p_transform); Variant(const Transform3D &p_transform);
Variant(const Color &p_color); Variant(const Color &p_color);
Variant(const NodePath &p_node_path); Variant(const NodePath &p_node_path);
Variant(const ::RID &p_rid); Variant(const ::RID &p_rid);

View File

@ -1690,17 +1690,17 @@ static void _register_variant_builtin_methods() {
bind_methodv(AABB, intersects_segment, &AABB::intersects_segment_bind, sarray("from", "to"), varray()); bind_methodv(AABB, intersects_segment, &AABB::intersects_segment_bind, sarray("from", "to"), varray());
bind_methodv(AABB, intersects_ray, &AABB::intersects_ray_bind, sarray("from", "dir"), varray()); bind_methodv(AABB, intersects_ray, &AABB::intersects_ray_bind, sarray("from", "dir"), varray());
/* Transform */ /* Transform3D */
bind_method(Transform, inverse, sarray(), varray()); bind_method(Transform3D, inverse, sarray(), varray());
bind_method(Transform, affine_inverse, sarray(), varray()); bind_method(Transform3D, affine_inverse, sarray(), varray());
bind_method(Transform, orthonormalized, sarray(), varray()); bind_method(Transform3D, orthonormalized, sarray(), varray());
bind_method(Transform, rotated, sarray("axis", "phi"), varray()); bind_method(Transform3D, rotated, sarray("axis", "phi"), varray());
bind_method(Transform, scaled, sarray("scale"), varray()); bind_method(Transform3D, scaled, sarray("scale"), varray());
bind_method(Transform, translated, sarray("offset"), varray()); bind_method(Transform3D, translated, sarray("offset"), varray());
bind_method(Transform, looking_at, sarray("target", "up"), varray(Vector3(0, 1, 0))); bind_method(Transform3D, looking_at, sarray("target", "up"), varray(Vector3(0, 1, 0)));
bind_method(Transform, interpolate_with, sarray("xform", "weight"), varray()); bind_method(Transform3D, interpolate_with, sarray("xform", "weight"), varray());
bind_method(Transform, is_equal_approx, sarray("xform"), varray()); bind_method(Transform3D, is_equal_approx, sarray("xform"), varray());
/* Dictionary */ /* Dictionary */
@ -2019,10 +2019,10 @@ static void _register_variant_builtin_methods() {
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0)); _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0));
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0)); _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0));
Transform identity_transform = Transform(); Transform3D identity_transform = Transform3D();
Transform flip_x_transform = Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); Transform3D flip_x_transform = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
Transform flip_y_transform = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0); Transform3D flip_y_transform = Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0);
Transform flip_z_transform = Transform(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0); Transform3D flip_z_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0);
_VariantCall::add_variant_constant(Variant::TRANSFORM, "IDENTITY", identity_transform); _VariantCall::add_variant_constant(Variant::TRANSFORM, "IDENTITY", identity_transform);
_VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_X", flip_x_transform); _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_X", flip_x_transform);
_VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Y", flip_y_transform); _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Y", flip_y_transform);

View File

@ -65,7 +65,7 @@ MAKE_PTRCONSTRUCT(Plane);
MAKE_PTRCONSTRUCT(Quat); MAKE_PTRCONSTRUCT(Quat);
MAKE_PTRCONSTRUCT(AABB); MAKE_PTRCONSTRUCT(AABB);
MAKE_PTRCONSTRUCT(Basis); MAKE_PTRCONSTRUCT(Basis);
MAKE_PTRCONSTRUCT(Transform); MAKE_PTRCONSTRUCT(Transform3D);
MAKE_PTRCONSTRUCT(Color); MAKE_PTRCONSTRUCT(Color);
MAKE_PTRCONSTRUCT(StringName); MAKE_PTRCONSTRUCT(StringName);
MAKE_PTRCONSTRUCT(NodePath); MAKE_PTRCONSTRUCT(NodePath);
@ -678,10 +678,10 @@ void Variant::_register_variant_constructors() {
add_constructor<VariantConstructor<Basis, Vector3, double>>(sarray("axis", "phi")); add_constructor<VariantConstructor<Basis, Vector3, double>>(sarray("axis", "phi"));
add_constructor<VariantConstructor<Basis, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis")); add_constructor<VariantConstructor<Basis, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis"));
add_constructor<VariantConstructNoArgs<Transform>>(sarray()); add_constructor<VariantConstructNoArgs<Transform3D>>(sarray());
add_constructor<VariantConstructor<Transform, Transform>>(sarray("from")); add_constructor<VariantConstructor<Transform3D, Transform3D>>(sarray("from"));
add_constructor<VariantConstructor<Transform, Basis, Vector3>>(sarray("basis", "origin")); add_constructor<VariantConstructor<Transform3D, Basis, Vector3>>(sarray("basis", "origin"));
add_constructor<VariantConstructor<Transform, Vector3, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis", "origin")); add_constructor<VariantConstructor<Transform3D, Vector3, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis", "origin"));
add_constructor<VariantConstructNoArgs<Color>>(sarray()); add_constructor<VariantConstructNoArgs<Color>>(sarray());
add_constructor<VariantConstructor<Color, Color>>(sarray("from")); add_constructor<VariantConstructor<Color, Color>>(sarray("from"));

View File

@ -144,8 +144,8 @@ public:
_FORCE_INLINE_ static const ::AABB *get_aabb(const Variant *v) { return v->_data._aabb; } _FORCE_INLINE_ static const ::AABB *get_aabb(const Variant *v) { return v->_data._aabb; }
_FORCE_INLINE_ static Basis *get_basis(Variant *v) { return v->_data._basis; } _FORCE_INLINE_ static Basis *get_basis(Variant *v) { return v->_data._basis; }
_FORCE_INLINE_ static const Basis *get_basis(const Variant *v) { return v->_data._basis; } _FORCE_INLINE_ static const Basis *get_basis(const Variant *v) { return v->_data._basis; }
_FORCE_INLINE_ static Transform *get_transform(Variant *v) { return v->_data._transform; } _FORCE_INLINE_ static Transform3D *get_transform(Variant *v) { return v->_data._transform; }
_FORCE_INLINE_ static const Transform *get_transform(const Variant *v) { return v->_data._transform; } _FORCE_INLINE_ static const Transform3D *get_transform(const Variant *v) { return v->_data._transform; }
// Misc types. // Misc types.
_FORCE_INLINE_ static Color *get_color(Variant *v) { return reinterpret_cast<Color *>(v->_data._mem); } _FORCE_INLINE_ static Color *get_color(Variant *v) { return reinterpret_cast<Color *>(v->_data._mem); }
@ -217,7 +217,7 @@ public:
v->type = Variant::BASIS; v->type = Variant::BASIS;
} }
_FORCE_INLINE_ static void init_transform(Variant *v) { _FORCE_INLINE_ static void init_transform(Variant *v) {
v->_data._transform = memnew(Transform); v->_data._transform = memnew(Transform3D);
v->type = Variant::TRANSFORM; v->type = Variant::TRANSFORM;
} }
_FORCE_INLINE_ static void init_string_name(Variant *v) { _FORCE_INLINE_ static void init_string_name(Variant *v) {
@ -590,9 +590,9 @@ struct VariantGetInternalPtr<Transform2D> {
}; };
template <> template <>
struct VariantGetInternalPtr<Transform> { struct VariantGetInternalPtr<Transform3D> {
static Transform *get_ptr(Variant *v) { return VariantInternal::get_transform(v); } static Transform3D *get_ptr(Variant *v) { return VariantInternal::get_transform(v); }
static const Transform *get_ptr(const Variant *v) { return VariantInternal::get_transform(v); } static const Transform3D *get_ptr(const Variant *v) { return VariantInternal::get_transform(v); }
}; };
template <> template <>
@ -819,9 +819,9 @@ struct VariantInternalAccessor<Transform2D> {
}; };
template <> template <>
struct VariantInternalAccessor<Transform> { struct VariantInternalAccessor<Transform3D> {
static _FORCE_INLINE_ const Transform &get(const Variant *v) { return *VariantInternal::get_transform(v); } static _FORCE_INLINE_ const Transform3D &get(const Variant *v) { return *VariantInternal::get_transform(v); }
static _FORCE_INLINE_ void set(Variant *v, const Transform &p_value) { *VariantInternal::get_transform(v) = p_value; } static _FORCE_INLINE_ void set(Variant *v, const Transform3D &p_value) { *VariantInternal::get_transform(v) = p_value; }
}; };
template <> template <>
@ -1082,7 +1082,7 @@ struct VariantInitializer<Basis> {
}; };
template <> template <>
struct VariantInitializer<Transform> { struct VariantInitializer<Transform3D> {
static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_transform(v); } static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_transform(v); }
}; };
@ -1256,8 +1256,8 @@ struct VariantZeroAssigner<Basis> {
}; };
template <> template <>
struct VariantZeroAssigner<Transform> { struct VariantZeroAssigner<Transform3D> {
static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_transform(v) = Transform(); } static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_transform(v) = Transform3D(); }
}; };
template <> template <>

View File

@ -1465,13 +1465,13 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorXForm<Vector<Vector2>, Transform2D, Vector<Vector2>>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::PACKED_VECTOR2_ARRAY); register_op<OperatorEvaluatorXForm<Vector<Vector2>, Transform2D, Vector<Vector2>>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::PACKED_VECTOR2_ARRAY);
register_op<OperatorEvaluatorXFormInv<Vector<Vector2>, Vector<Vector2>, Transform2D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR2_ARRAY, Variant::TRANSFORM2D); register_op<OperatorEvaluatorXFormInv<Vector<Vector2>, Vector<Vector2>, Transform2D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR2_ARRAY, Variant::TRANSFORM2D);
register_op<OperatorEvaluatorMul<Transform, Transform, Transform>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::TRANSFORM); register_op<OperatorEvaluatorMul<Transform3D, Transform3D, Transform3D>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::TRANSFORM);
register_op<OperatorEvaluatorXForm<Vector3, Transform, Vector3>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::VECTOR3); register_op<OperatorEvaluatorXForm<Vector3, Transform3D, Vector3>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::VECTOR3);
register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Transform>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::TRANSFORM); register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Transform3D>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::TRANSFORM);
register_op<OperatorEvaluatorXForm<::AABB, Transform, ::AABB>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::AABB); register_op<OperatorEvaluatorXForm<::AABB, Transform3D, ::AABB>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::AABB);
register_op<OperatorEvaluatorXFormInv<::AABB, ::AABB, Transform>>(Variant::OP_MULTIPLY, Variant::AABB, Variant::TRANSFORM); register_op<OperatorEvaluatorXFormInv<::AABB, ::AABB, Transform3D>>(Variant::OP_MULTIPLY, Variant::AABB, Variant::TRANSFORM);
register_op<OperatorEvaluatorXForm<Vector<Vector3>, Transform, Vector<Vector3>>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::PACKED_VECTOR3_ARRAY); register_op<OperatorEvaluatorXForm<Vector<Vector3>, Transform3D, Vector<Vector3>>>(Variant::OP_MULTIPLY, Variant::TRANSFORM, Variant::PACKED_VECTOR3_ARRAY);
register_op<OperatorEvaluatorXFormInv<Vector<Vector3>, Vector<Vector3>, Transform>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR3_ARRAY, Variant::TRANSFORM); register_op<OperatorEvaluatorXFormInv<Vector<Vector3>, Vector<Vector3>, Transform3D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR3_ARRAY, Variant::TRANSFORM);
register_op<OperatorEvaluatorMul<Basis, Basis, Basis>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::BASIS); register_op<OperatorEvaluatorMul<Basis, Basis, Basis>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::BASIS);
register_op<OperatorEvaluatorXForm<Vector3, Basis, Vector3>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::VECTOR3); register_op<OperatorEvaluatorXForm<Vector3, Basis, Vector3>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::VECTOR3);
@ -1547,7 +1547,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorStringModT<Quat>>(Variant::OP_MODULE, Variant::STRING, Variant::QUAT); register_op<OperatorEvaluatorStringModT<Quat>>(Variant::OP_MODULE, Variant::STRING, Variant::QUAT);
register_op<OperatorEvaluatorStringModT<::AABB>>(Variant::OP_MODULE, Variant::STRING, Variant::AABB); register_op<OperatorEvaluatorStringModT<::AABB>>(Variant::OP_MODULE, Variant::STRING, Variant::AABB);
register_op<OperatorEvaluatorStringModT<Basis>>(Variant::OP_MODULE, Variant::STRING, Variant::BASIS); register_op<OperatorEvaluatorStringModT<Basis>>(Variant::OP_MODULE, Variant::STRING, Variant::BASIS);
register_op<OperatorEvaluatorStringModT<Transform>>(Variant::OP_MODULE, Variant::STRING, Variant::TRANSFORM); register_op<OperatorEvaluatorStringModT<Transform3D>>(Variant::OP_MODULE, Variant::STRING, Variant::TRANSFORM);
register_op<OperatorEvaluatorStringModT<Color>>(Variant::OP_MODULE, Variant::STRING, Variant::COLOR); register_op<OperatorEvaluatorStringModT<Color>>(Variant::OP_MODULE, Variant::STRING, Variant::COLOR);
register_op<OperatorEvaluatorStringModT<StringName>>(Variant::OP_MODULE, Variant::STRING, Variant::STRING_NAME); register_op<OperatorEvaluatorStringModT<StringName>>(Variant::OP_MODULE, Variant::STRING, Variant::STRING_NAME);
@ -1615,7 +1615,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorEqual<Quat, Quat>>(Variant::OP_EQUAL, Variant::QUAT, Variant::QUAT); register_op<OperatorEvaluatorEqual<Quat, Quat>>(Variant::OP_EQUAL, Variant::QUAT, Variant::QUAT);
register_op<OperatorEvaluatorEqual<::AABB, ::AABB>>(Variant::OP_EQUAL, Variant::AABB, Variant::AABB); register_op<OperatorEvaluatorEqual<::AABB, ::AABB>>(Variant::OP_EQUAL, Variant::AABB, Variant::AABB);
register_op<OperatorEvaluatorEqual<Basis, Basis>>(Variant::OP_EQUAL, Variant::BASIS, Variant::BASIS); register_op<OperatorEvaluatorEqual<Basis, Basis>>(Variant::OP_EQUAL, Variant::BASIS, Variant::BASIS);
register_op<OperatorEvaluatorEqual<Transform, Transform>>(Variant::OP_EQUAL, Variant::TRANSFORM, Variant::TRANSFORM); register_op<OperatorEvaluatorEqual<Transform3D, Transform3D>>(Variant::OP_EQUAL, Variant::TRANSFORM, Variant::TRANSFORM);
register_op<OperatorEvaluatorEqual<Color, Color>>(Variant::OP_EQUAL, Variant::COLOR, Variant::COLOR); register_op<OperatorEvaluatorEqual<Color, Color>>(Variant::OP_EQUAL, Variant::COLOR, Variant::COLOR);
register_op<OperatorEvaluatorEqual<StringName, String>>(Variant::OP_EQUAL, Variant::STRING_NAME, Variant::STRING); register_op<OperatorEvaluatorEqual<StringName, String>>(Variant::OP_EQUAL, Variant::STRING_NAME, Variant::STRING);
@ -1661,7 +1661,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorNotEqual<Quat, Quat>>(Variant::OP_NOT_EQUAL, Variant::QUAT, Variant::QUAT); register_op<OperatorEvaluatorNotEqual<Quat, Quat>>(Variant::OP_NOT_EQUAL, Variant::QUAT, Variant::QUAT);
register_op<OperatorEvaluatorNotEqual<::AABB, ::AABB>>(Variant::OP_NOT_EQUAL, Variant::AABB, Variant::AABB); register_op<OperatorEvaluatorNotEqual<::AABB, ::AABB>>(Variant::OP_NOT_EQUAL, Variant::AABB, Variant::AABB);
register_op<OperatorEvaluatorNotEqual<Basis, Basis>>(Variant::OP_NOT_EQUAL, Variant::BASIS, Variant::BASIS); register_op<OperatorEvaluatorNotEqual<Basis, Basis>>(Variant::OP_NOT_EQUAL, Variant::BASIS, Variant::BASIS);
register_op<OperatorEvaluatorNotEqual<Transform, Transform>>(Variant::OP_NOT_EQUAL, Variant::TRANSFORM, Variant::TRANSFORM); register_op<OperatorEvaluatorNotEqual<Transform3D, Transform3D>>(Variant::OP_NOT_EQUAL, Variant::TRANSFORM, Variant::TRANSFORM);
register_op<OperatorEvaluatorNotEqual<Color, Color>>(Variant::OP_NOT_EQUAL, Variant::COLOR, Variant::COLOR); register_op<OperatorEvaluatorNotEqual<Color, Color>>(Variant::OP_NOT_EQUAL, Variant::COLOR, Variant::COLOR);
register_op<OperatorEvaluatorNotEqual<StringName, String>>(Variant::OP_NOT_EQUAL, Variant::STRING_NAME, Variant::STRING); register_op<OperatorEvaluatorNotEqual<StringName, String>>(Variant::OP_NOT_EQUAL, Variant::STRING_NAME, Variant::STRING);
@ -1852,7 +1852,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorInDictionaryHas<Quat>>(Variant::OP_IN, Variant::QUAT, Variant::DICTIONARY); register_op<OperatorEvaluatorInDictionaryHas<Quat>>(Variant::OP_IN, Variant::QUAT, Variant::DICTIONARY);
register_op<OperatorEvaluatorInDictionaryHas<::AABB>>(Variant::OP_IN, Variant::AABB, Variant::DICTIONARY); register_op<OperatorEvaluatorInDictionaryHas<::AABB>>(Variant::OP_IN, Variant::AABB, Variant::DICTIONARY);
register_op<OperatorEvaluatorInDictionaryHas<Basis>>(Variant::OP_IN, Variant::BASIS, Variant::DICTIONARY); register_op<OperatorEvaluatorInDictionaryHas<Basis>>(Variant::OP_IN, Variant::BASIS, Variant::DICTIONARY);
register_op<OperatorEvaluatorInDictionaryHas<Transform>>(Variant::OP_IN, Variant::TRANSFORM, Variant::DICTIONARY); register_op<OperatorEvaluatorInDictionaryHas<Transform3D>>(Variant::OP_IN, Variant::TRANSFORM, Variant::DICTIONARY);
register_op<OperatorEvaluatorInDictionaryHas<Color>>(Variant::OP_IN, Variant::COLOR, Variant::DICTIONARY); register_op<OperatorEvaluatorInDictionaryHas<Color>>(Variant::OP_IN, Variant::COLOR, Variant::DICTIONARY);
register_op<OperatorEvaluatorInDictionaryHas<StringName>>(Variant::OP_IN, Variant::STRING_NAME, Variant::DICTIONARY); register_op<OperatorEvaluatorInDictionaryHas<StringName>>(Variant::OP_IN, Variant::STRING_NAME, Variant::DICTIONARY);
@ -1889,7 +1889,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorInArrayFind<Quat, Array>>(Variant::OP_IN, Variant::QUAT, Variant::ARRAY); register_op<OperatorEvaluatorInArrayFind<Quat, Array>>(Variant::OP_IN, Variant::QUAT, Variant::ARRAY);
register_op<OperatorEvaluatorInArrayFind<::AABB, Array>>(Variant::OP_IN, Variant::AABB, Variant::ARRAY); register_op<OperatorEvaluatorInArrayFind<::AABB, Array>>(Variant::OP_IN, Variant::AABB, Variant::ARRAY);
register_op<OperatorEvaluatorInArrayFind<Basis, Array>>(Variant::OP_IN, Variant::BASIS, Variant::ARRAY); register_op<OperatorEvaluatorInArrayFind<Basis, Array>>(Variant::OP_IN, Variant::BASIS, Variant::ARRAY);
register_op<OperatorEvaluatorInArrayFind<Transform, Array>>(Variant::OP_IN, Variant::TRANSFORM, Variant::ARRAY); register_op<OperatorEvaluatorInArrayFind<Transform3D, Array>>(Variant::OP_IN, Variant::TRANSFORM, Variant::ARRAY);
register_op<OperatorEvaluatorInArrayFind<Color, Array>>(Variant::OP_IN, Variant::COLOR, Variant::ARRAY); register_op<OperatorEvaluatorInArrayFind<Color, Array>>(Variant::OP_IN, Variant::COLOR, Variant::ARRAY);
register_op<OperatorEvaluatorInArrayFind<StringName, Array>>(Variant::OP_IN, Variant::STRING_NAME, Variant::ARRAY); register_op<OperatorEvaluatorInArrayFind<StringName, Array>>(Variant::OP_IN, Variant::STRING_NAME, Variant::ARRAY);

View File

@ -653,7 +653,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
} }
value = Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); value = Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
} else if (id == "Transform") { } else if (id == "Transform3D") {
Vector<real_t> args; Vector<real_t> args;
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str); Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
if (err) { if (err) {
@ -665,7 +665,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
value = Transform(Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]), Vector3(args[9], args[10], args[11])); value = Transform3D(Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]), Vector3(args[9], args[10], args[11]));
} else if (id == "Color") { } else if (id == "Color") {
Vector<float> args; Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str); Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
@ -1490,8 +1490,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break; } break;
case Variant::TRANSFORM: { case Variant::TRANSFORM: {
String s = "Transform( "; String s = "Transform3D( ";
Transform t = p_variant; Transform3D t = p_variant;
Basis &m3 = t.basis; Basis &m3 = t.basis;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {

View File

@ -288,8 +288,8 @@ SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_axis, get_axis, 0)
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1) SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1)
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2) SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2)
SETGET_STRUCT(Transform, Basis, basis) SETGET_STRUCT(Transform3D, Basis, basis)
SETGET_STRUCT(Transform, Vector3, origin) SETGET_STRUCT(Transform3D, Vector3, origin)
SETGET_NUMBER_STRUCT(Color, double, r) SETGET_NUMBER_STRUCT(Color, double, r)
SETGET_NUMBER_STRUCT(Color, double, g) SETGET_NUMBER_STRUCT(Color, double, g)
@ -383,8 +383,8 @@ void register_named_setters_getters() {
REGISTER_MEMBER(Basis, y); REGISTER_MEMBER(Basis, y);
REGISTER_MEMBER(Basis, z); REGISTER_MEMBER(Basis, z);
REGISTER_MEMBER(Transform, basis); REGISTER_MEMBER(Transform3D, basis);
REGISTER_MEMBER(Transform, origin); REGISTER_MEMBER(Transform3D, origin);
REGISTER_MEMBER(Color, r); REGISTER_MEMBER(Color, r);
REGISTER_MEMBER(Color, g); REGISTER_MEMBER(Color, g);
@ -2304,7 +2304,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
} }
return; return;
case BASIS: { case BASIS: {
r_dst = Transform(*a._data._basis).interpolate_with(Transform(*b._data._basis), c).basis; r_dst = Transform3D(*a._data._basis).interpolate_with(Transform3D(*b._data._basis), c).basis;
} }
return; return;
case TRANSFORM: { case TRANSFORM: {

View File

@ -3459,7 +3459,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi
insert_queue = false; insert_queue = false;
} }
void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) { void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform3D &p_xform) {
if (!keying) { if (!keying) {
return; return;
} }
@ -3946,7 +3946,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
} break; } break;
case Animation::TYPE_TRANSFORM: { case Animation::TYPE_TRANSFORM: {
Transform tr = p_id.value; Transform3D tr = p_id.value;
Dictionary d; Dictionary d;
d["location"] = tr.origin; d["location"] = tr.origin;
d["scale"] = tr.basis.get_scale(); d["scale"] = tr.basis.get_scale();
@ -4560,7 +4560,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
return; return;
} }
Transform xf = base->get_transform(); Transform3D xf = base->get_transform();
Vector3 loc = xf.get_origin(); Vector3 loc = xf.get_origin();
Vector3 scale = xf.basis.get_scale_local(); Vector3 scale = xf.basis.get_scale_local();

View File

@ -526,7 +526,7 @@ public:
void set_anim_pos(float p_pos); void set_anim_pos(float p_pos);
void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false); void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false);
void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance); void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance);
void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform); void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform3D &p_xform);
void show_select_node_warning(bool p_show); void show_select_node_warning(bool p_show);

View File

@ -213,7 +213,7 @@ void ConnectDialog::_add_bind() {
value = Basis(); value = Basis();
break; break;
case Variant::TRANSFORM: case Variant::TRANSFORM:
value = Transform(); value = Transform3D();
break; break;
case Variant::COLOR: case Variant::COLOR:
value = Color(); value = Color();

View File

@ -60,7 +60,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_
return ret; return ret;
} }
Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size) {
int size = p_preview_size; int size = p_preview_size;
RID scenario = RS::get_singleton()->scenario_create(); RID scenario = RS::get_singleton()->scenario_create();
@ -94,7 +94,7 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
continue; continue;
} }
Transform mesh_xform; Transform3D mesh_xform;
if (p_transforms != nullptr) { if (p_transforms != nullptr) {
mesh_xform = (*p_transforms)[i]; mesh_xform = (*p_transforms)[i];
} }
@ -105,7 +105,7 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
AABB aabb = mesh->get_aabb(); AABB aabb = mesh->get_aabb();
Vector3 ofs = aabb.position + aabb.size * 0.5; Vector3 ofs = aabb.position + aabb.size * 0.5;
aabb.position -= ofs; aabb.position -= ofs;
Transform xform; Transform3D xform;
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6); xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis; xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
AABB rot_aabb = xform.xform(aabb); AABB rot_aabb = xform.xform(aabb);
@ -119,11 +119,11 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
xform.invert(); xform.invert();
xform = mesh_xform * xform; xform = mesh_xform * xform;
RS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); RS::get_singleton()->camera_set_transform(camera, xform * Transform3D(Basis(), Vector3(0, 0, 3)));
RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
RS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); RS::get_singleton()->instance_set_transform(light_instance, xform * Transform3D().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
ep.step(TTR("Thumbnail..."), i); ep.step(TTR("Thumbnail..."), i);
Main::iteration(); Main::iteration();

View File

@ -113,7 +113,7 @@ public:
Error save_scene(); Error save_scene();
void save_scene_as(const String &p_scene, bool p_with_preview = true); void save_scene_as(const String &p_scene, bool p_with_preview = true);
Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size);
void set_main_screen_editor(const String &p_name); void set_main_screen_editor(const String &p_name);
void set_distraction_free_mode(bool p_enter); void set_distraction_free_mode(bool p_enter);

View File

@ -2083,7 +2083,7 @@ void EditorPropertyTransform::_value_changed(double val, const String &p_name) {
return; return;
} }
Transform p; Transform3D p;
p.basis[0][0] = spin[0]->get_value(); p.basis[0][0] = spin[0]->get_value();
p.basis[1][0] = spin[1]->get_value(); p.basis[1][0] = spin[1]->get_value();
p.basis[2][0] = spin[2]->get_value(); p.basis[2][0] = spin[2]->get_value();
@ -2104,7 +2104,7 @@ void EditorPropertyTransform::update_property() {
update_using_transform(get_edited_object()->get(get_edited_property())); update_using_transform(get_edited_object()->get(get_edited_property()));
} }
void EditorPropertyTransform::update_using_transform(Transform p_transform) { void EditorPropertyTransform::update_using_transform(Transform3D p_transform) {
setting = true; setting = true;
spin[0]->set_value(p_transform.basis[0][0]); spin[0]->set_value(p_transform.basis[0][0]);
spin[1]->set_value(p_transform.basis[1][0]); spin[1]->set_value(p_transform.basis[1][0]);

View File

@ -541,7 +541,7 @@ protected:
public: public:
virtual void update_property() override; virtual void update_property() override;
virtual void update_using_transform(Transform p_transform); virtual void update_using_transform(Transform3D p_transform);
void setup(double p_min, double p_max, double p_step, bool p_no_slider); void setup(double p_min, double p_max, double p_step, bool p_no_slider);
EditorPropertyTransform(); EditorPropertyTransform();
}; };

View File

@ -50,8 +50,8 @@ String Collada::Effect::get_texture_path(const String &p_source, Collada &state)
return state.state.image_map[image].path; return state.state.image_map[image].path;
} }
Transform Collada::get_root_transform() const { Transform3D Collada::get_root_transform() const {
Transform unit_scale_transform; Transform3D unit_scale_transform;
#ifndef COLLADA_IMPORT_SCALE_SCENE #ifndef COLLADA_IMPORT_SCALE_SCENE
unit_scale_transform.scale(Vector3(state.unit_scale, state.unit_scale, state.unit_scale)); unit_scale_transform.scale(Vector3(state.unit_scale, state.unit_scale, state.unit_scale));
#endif #endif
@ -74,8 +74,8 @@ static String _uri_to_id(const String &p_uri) {
/** HELPER FUNCTIONS **/ /** HELPER FUNCTIONS **/
Transform Collada::fix_transform(const Transform &p_transform) { Transform3D Collada::fix_transform(const Transform3D &p_transform) {
Transform tr = p_transform; Transform3D tr = p_transform;
#ifndef NO_UP_AXIS_SWAP #ifndef NO_UP_AXIS_SWAP
@ -102,8 +102,8 @@ Transform Collada::fix_transform(const Transform &p_transform) {
//return state.matrix_fix * p_transform; //return state.matrix_fix * p_transform;
} }
static Transform _read_transform_from_array(const Vector<float> &array, int ofs = 0) { static Transform3D _read_transform_from_array(const Vector<float> &array, int ofs = 0) {
Transform tr; Transform3D tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl.. // i wonder why collada matrices are transposed, given that's opposed to opengl..
tr.basis.elements[0][0] = array[0 + ofs]; tr.basis.elements[0][0] = array[0 + ofs];
tr.basis.elements[0][1] = array[1 + ofs]; tr.basis.elements[0][1] = array[1 + ofs];
@ -122,11 +122,11 @@ static Transform _read_transform_from_array(const Vector<float> &array, int ofs
/* STRUCTURES */ /* STRUCTURES */
Transform Collada::Node::compute_transform(Collada &state) const { Transform3D Collada::Node::compute_transform(Collada &state) const {
Transform xform; Transform3D xform;
for (int i = 0; i < xform_list.size(); i++) { for (int i = 0; i < xform_list.size(); i++) {
Transform xform_step; Transform3D xform_step;
const XForm &xf = xform_list[i]; const XForm &xf = xform_list[i];
switch (xf.op) { switch (xf.op) {
case XForm::OP_ROTATE: { case XForm::OP_ROTATE: {
@ -165,11 +165,11 @@ Transform Collada::Node::compute_transform(Collada &state) const {
return xform; return xform;
} }
Transform Collada::Node::get_transform() const { Transform3D Collada::Node::get_transform() const {
return default_transform; return default_transform;
} }
Transform Collada::Node::get_global_transform() const { Transform3D Collada::Node::get_global_transform() const {
if (parent) { if (parent) {
return parent->get_global_transform() * default_transform; return parent->get_global_transform() * default_transform;
} else { } else {
@ -201,14 +201,14 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const {
if (keys[i].data.size() == 16) { if (keys[i].data.size() == 16) {
//interpolate a matrix //interpolate a matrix
Transform src = _read_transform_from_array(keys[i - 1].data); Transform3D src = _read_transform_from_array(keys[i - 1].data);
Transform dst = _read_transform_from_array(keys[i].data); Transform3D dst = _read_transform_from_array(keys[i].data);
Transform interp = c < 0.001 ? src : src.interpolate_with(dst, c); Transform3D interp = c < 0.001 ? src : src.interpolate_with(dst, c);
Vector<float> ret; Vector<float> ret;
ret.resize(16); ret.resize(16);
Transform tr; Transform3D tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl.. // i wonder why collada matrices are transposed, given that's opposed to opengl..
ret.write[0] = interp.basis.elements[0][0]; ret.write[0] = interp.basis.elements[0][0];
ret.write[1] = interp.basis.elements[0][1]; ret.write[1] = interp.basis.elements[0][1];
@ -410,10 +410,9 @@ Vector<String> Collada::_read_string_array(XMLParser &parser) {
return array; return array;
} }
Transform Collada::_read_transform(XMLParser &parser) { Transform3D Collada::_read_transform(XMLParser &parser) {
if (parser.is_empty()) { if (parser.is_empty())
return Transform(); return Transform3D();
}
Vector<String> array; Vector<String> array;
while (parser.read() == OK) { while (parser.read() == OK) {
@ -429,7 +428,7 @@ Transform Collada::_read_transform(XMLParser &parser) {
} }
} }
ERR_FAIL_COND_V(array.size() != 16, Transform()); ERR_FAIL_COND_V(array.size() != 16, Transform3D());
Vector<float> farr; Vector<float> farr;
farr.resize(16); farr.resize(16);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
@ -1197,7 +1196,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
/* STORE REST MATRICES */ /* STORE REST MATRICES */
Vector<Transform> rests; Vector<Transform3D> rests;
ERR_FAIL_COND(!skindata.joints.sources.has("JOINT")); ERR_FAIL_COND(!skindata.joints.sources.has("JOINT"));
ERR_FAIL_COND(!skindata.joints.sources.has("INV_BIND_MATRIX")); ERR_FAIL_COND(!skindata.joints.sources.has("INV_BIND_MATRIX"));
@ -1214,7 +1213,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
for (int i = 0; i < joint_source.sarray.size(); i++) { for (int i = 0; i < joint_source.sarray.size(); i++) {
String name = joint_source.sarray[i]; String name = joint_source.sarray[i];
Transform xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices Transform3D xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices
xform.affine_invert(); // inverse for rest, because it's an inverse xform.affine_invert(); // inverse for rest, because it's an inverse
#ifdef COLLADA_IMPORT_SCALE_SCENE #ifdef COLLADA_IMPORT_SCALE_SCENE
xform.origin *= state.unit_scale; xform.origin *= state.unit_scale;
@ -2096,7 +2095,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
NodeSkeleton *skeleton = nullptr; NodeSkeleton *skeleton = nullptr;
for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { for (Map<String, Transform3D>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) {
String name; String name;
if (!state.sid_to_node_map.has(F->key())) { if (!state.sid_to_node_map.has(F->key())) {
@ -2240,11 +2239,11 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
//this should be correct //this should be correct
ERR_FAIL_COND_V(!state.skin_controller_data_map.has(ng->source), false); ERR_FAIL_COND_V(!state.skin_controller_data_map.has(ng->source), false);
SkinControllerData &skin = state.skin_controller_data_map[ng->source]; SkinControllerData &skin = state.skin_controller_data_map[ng->source];
Transform skel_inv = sk->get_global_transform().affine_inverse(); Transform3D skel_inv = sk->get_global_transform().affine_inverse();
p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it
//make rests relative to the skeleton (they seem to be always relative to world) //make rests relative to the skeleton (they seem to be always relative to world)
for (Map<String, Transform>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) { for (Map<String, Transform3D>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) {
E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton
state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative
} }
@ -2252,7 +2251,7 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
//but most exporters seem to work only if i do this.. //but most exporters seem to work only if i do this..
//p_node->default_transform = p_node->get_global_transform(); //p_node->default_transform = p_node->get_global_transform();
//p_node->default_transform=Transform(); //this seems to be correct, because bind shape makes the object local to the skeleton //p_node->default_transform=Transform3D(); //this seems to be correct, because bind shape makes the object local to the skeleton
p_node->ignore_anim = true; // collada may animate this later, if it does, then this is not supported (redo your original asset and don't animate the base mesh) p_node->ignore_anim = true; // collada may animate this later, if it does, then this is not supported (redo your original asset and don't animate the base mesh)
p_node->parent = sk; p_node->parent = sk;
//sk->children.push_back(0,p_node); //avoid INFINITE loop //sk->children.push_back(0,p_node); //avoid INFINITE loop

View File

@ -182,7 +182,7 @@ public:
String base; String base;
bool use_idrefs = false; bool use_idrefs = false;
Transform bind_shape; Transform3D bind_shape;
struct Source { struct Source {
Vector<String> sarray; //maybe for names Vector<String> sarray; //maybe for names
@ -210,7 +210,7 @@ public:
int count = 0; int count = 0;
} weights; } weights;
Map<String, Transform> bone_rest_map; Map<String, Transform3D> bone_rest_map;
SkinControllerData() {} SkinControllerData() {}
}; };
@ -342,15 +342,15 @@ public:
String empty_draw_type; String empty_draw_type;
bool noname = false; bool noname = false;
Vector<XForm> xform_list; Vector<XForm> xform_list;
Transform default_transform; Transform3D default_transform;
Transform post_transform; Transform3D post_transform;
Vector<Node *> children; Vector<Node *> children;
Node *parent = nullptr; Node *parent = nullptr;
Transform compute_transform(Collada &state) const; Transform3D compute_transform(Collada &state) const;
Transform get_global_transform() const; Transform3D get_global_transform() const;
Transform get_transform() const; Transform3D get_transform() const;
bool ignore_anim = false; bool ignore_anim = false;
@ -497,7 +497,7 @@ public:
Map<String, String> sid_to_node_map; Map<String, String> sid_to_node_map;
//Map<String,NodeJoint*> bone_map; //Map<String,NodeJoint*> bone_map;
Map<String, Transform> bone_rest_map; Map<String, Transform3D> bone_rest_map;
String local_path; String local_path;
String root_visual_scene; String root_visual_scene;
@ -517,9 +517,9 @@ public:
Collada(); Collada();
Transform fix_transform(const Transform &p_transform); Transform3D fix_transform(const Transform3D &p_transform);
Transform get_root_transform() const; Transform3D get_root_transform() const;
int get_uv_channel(String p_name); int get_uv_channel(String p_name);
@ -557,7 +557,7 @@ private: // private stuff
Variant _parse_param(XMLParser &parser); Variant _parse_param(XMLParser &parser);
Vector<float> _read_float_array(XMLParser &parser); Vector<float> _read_float_array(XMLParser &parser);
Vector<String> _read_string_array(XMLParser &parser); Vector<String> _read_string_array(XMLParser &parser);
Transform _read_transform(XMLParser &parser); Transform3D _read_transform(XMLParser &parser);
String _read_empty_draw_type(XMLParser &parser); String _read_empty_draw_type(XMLParser &parser);
void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner); void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner);

View File

@ -87,7 +87,7 @@ struct ColladaImport {
Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_scene(Collada::Node *p_node, Node3D *p_parent);
Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_resources(Collada::Node *p_node, bool p_use_compression);
Error _create_material(const String &p_target); Error _create_material(const String &p_target);
Error _create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<EditorSceneImporterMesh>> p_morph_meshes = Vector<Ref<EditorSceneImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); Error _create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<EditorSceneImporterMesh>> p_morph_meshes = Vector<Ref<EditorSceneImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false);
Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false); Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false);
void _fix_param_animation_tracks(); void _fix_param_animation_tracks();
void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks); void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
@ -300,7 +300,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
nm.node = node; nm.node = node;
node_map[p_node->id] = nm; node_map[p_node->id] = nm;
node_name_map[node->get_name()] = p_node->id; node_name_map[node->get_name()] = p_node->id;
Transform xf = p_node->default_transform; Transform3D xf = p_node->default_transform;
xf = collada.fix_transform(xf) * p_node->post_transform; xf = collada.fix_transform(xf) * p_node->post_transform;
node->set_transform(xf); node->set_transform(xf);
@ -457,7 +457,7 @@ Error ColladaImport::_create_material(const String &p_target) {
return OK; return OK;
} }
Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<EditorSceneImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<EditorSceneImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) {
bool local_xform_mirror = p_local_xform.basis.determinant() < 0; bool local_xform_mirror = p_local_xform.basis.determinant() < 0;
if (p_morph_data) { if (p_morph_data) {
@ -811,7 +811,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor
if (has_weights) { if (has_weights) {
//if skeleton, localize //if skeleton, localize
Transform local_xform = p_local_xform; Transform3D local_xform = p_local_xform;
for (int i = 0; i < vertex_array.size(); i++) { for (int i = 0; i < vertex_array.size(); i++) {
vertex_array.write[i].vertex = local_xform.xform(vertex_array[i].vertex); vertex_array.write[i].vertex = local_xform.xform(vertex_array[i].vertex);
vertex_array.write[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized(); vertex_array.write[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized();
@ -1037,7 +1037,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
Collada::SkinControllerData *skin = nullptr; Collada::SkinControllerData *skin = nullptr;
Collada::MorphControllerData *morph = nullptr; Collada::MorphControllerData *morph = nullptr;
String meshid; String meshid;
Transform apply_xform; Transform3D apply_xform;
Vector<int> bone_remap; Vector<int> bone_remap;
Vector<Ref<EditorSceneImporterMesh>> morphs; Vector<Ref<EditorSceneImporterMesh>> morphs;
@ -1073,9 +1073,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
if (apply_mesh_xform_to_vertices) { if (apply_mesh_xform_to_vertices) {
apply_xform = collada.fix_transform(p_node->default_transform); apply_xform = collada.fix_transform(p_node->default_transform);
node->set_transform(Transform()); node->set_transform(Transform3D());
} else { } else {
apply_xform = Transform(); apply_xform = Transform3D();
} }
ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"), ERR_INVALID_DATA); ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"), ERR_INVALID_DATA);
@ -1530,7 +1530,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
} }
} }
Transform xform = cn->compute_transform(collada); Transform3D xform = cn->compute_transform(collada);
xform = collada.fix_transform(xform) * cn->post_transform; xform = collada.fix_transform(xform) * cn->post_transform;
if (nm.bone >= 0) { if (nm.bone >= 0) {
@ -1589,7 +1589,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->track_set_path(track, path); animation->track_set_path(track, path);
animation->track_set_imported(track, true); //helps merging later animation->track_set_imported(track, true); //helps merging later
Transform xform = cn->compute_transform(collada); Transform3D xform = cn->compute_transform(collada);
xform = collada.fix_transform(xform) * cn->post_transform; xform = collada.fix_transform(xform) * cn->post_transform;
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;

View File

@ -433,7 +433,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
p_node->replace_by(rigid_body); p_node->replace_by(rigid_body);
rigid_body->set_transform(mi->get_transform()); rigid_body->set_transform(mi->get_transform());
p_node = rigid_body; p_node = rigid_body;
mi->set_transform(Transform()); mi->set_transform(Transform3D());
rigid_body->add_child(mi); rigid_body->add_child(mi);
mi->set_owner(rigid_body->get_owner()); mi->set_owner(rigid_body->get_owner());
@ -632,7 +632,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
p_node->replace_by(rigid_body); p_node->replace_by(rigid_body);
rigid_body->set_transform(mi->get_transform()); rigid_body->set_transform(mi->get_transform());
p_node = rigid_body; p_node = rigid_body;
mi->set_transform(Transform()); mi->set_transform(Transform3D());
rigid_body->add_child(mi); rigid_body->add_child(mi);
mi->set_owner(rigid_body->get_owner()); mi->set_owner(rigid_body->get_owner());
base = rigid_body; base = rigid_body;
@ -1209,7 +1209,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
} }
if (bake_lightmaps) { if (bake_lightmaps) {
Transform xf; Transform3D xf;
Node3D *n = src_mesh_node; Node3D *n = src_mesh_node;
while (n) { while (n) {
xf = n->get_transform() * xf; xf = n->get_transform() * xf;

View File

@ -317,7 +317,7 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) {
if (mesh_node && mesh_node->get_mesh().is_valid()) { if (mesh_node && mesh_node->get_mesh().is_valid()) {
_fill_mesh(scene_tree, mesh_node->get_mesh(), item); _fill_mesh(scene_tree, mesh_node->get_mesh(), item);
Transform accum_xform; Transform3D accum_xform;
Node3D *base = mesh_node; Node3D *base = mesh_node;
while (base) { while (base) {
accum_xform = base->get_transform() * accum_xform; accum_xform = base->get_transform() * accum_xform;
@ -379,7 +379,7 @@ void SceneImportSettings::_update_camera() {
camera->set_orthogonal(camera_size * zoom, 0.0001, camera_size * 2); camera->set_orthogonal(camera_size * zoom, 0.0001, camera_size * 2);
Transform xf; Transform3D xf;
xf.basis = Basis(Vector3(0, 1, 0), rot_y) * Basis(Vector3(1, 0, 0), rot_x); xf.basis = Basis(Vector3(0, 1, 0), rot_y) * Basis(Vector3(1, 0, 0), rot_x);
xf.origin = center; xf.origin = center;
xf.translate(0, 0, camera_size); xf.translate(0, 0, camera_size);
@ -493,7 +493,7 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) {
Ref<Mesh> base_mesh = mi->get_mesh(); Ref<Mesh> base_mesh = mi->get_mesh();
if (base_mesh.is_valid()) { if (base_mesh.is_valid()) {
AABB aabb = base_mesh->get_aabb(); AABB aabb = base_mesh->get_aabb();
Transform aabb_xf; Transform3D aabb_xf;
aabb_xf.basis.scale(aabb.size); aabb_xf.basis.scale(aabb.size);
aabb_xf.origin = aabb.position; aabb_xf.origin = aabb.position;
@ -1099,7 +1099,7 @@ SceneImportSettings::SceneImportSettings() {
camera->make_current(); camera->make_current();
light = memnew(DirectionalLight3D); light = memnew(DirectionalLight3D);
light->set_transform(Transform().looking_at(Vector3(-1, -2, -0.6), Vector3(0, 1, 0))); light->set_transform(Transform3D().looking_at(Vector3(-1, -2, -0.6), Vector3(0, 1, 0)));
base_viewport->add_child(light); base_viewport->add_child(light);
light->set_shadow(true); light->set_shadow(true);

View File

@ -612,7 +612,7 @@ struct EditorSceneImporterMeshLightmapSurface {
String name; String name;
}; };
Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache) { Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache) {
ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED); ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes."); ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes.");
@ -628,7 +628,7 @@ Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform &p_base_tr
Basis basis = p_base_transform.get_basis(); Basis basis = p_base_transform.get_basis();
Vector3 scale = Vector3(basis.get_axis(0).length(), basis.get_axis(1).length(), basis.get_axis(2).length()); Vector3 scale = Vector3(basis.get_axis(0).length(), basis.get_axis(1).length(), basis.get_axis(2).length());
Transform transform; Transform3D transform;
transform.scale(scale); transform.scale(scale);
Basis normal_basis = transform.basis.inverse().transposed(); Basis normal_basis = transform.basis.inverse().transposed();

View File

@ -106,7 +106,7 @@ public:
Vector<Ref<Shape3D>> convex_decompose() const; Vector<Ref<Shape3D>> convex_decompose() const;
Ref<Shape3D> create_trimesh_shape() const; Ref<Shape3D> create_trimesh_shape() const;
Ref<NavigationMesh> create_navigation_mesh(); Ref<NavigationMesh> create_navigation_mesh();
Error lightmap_unwrap_cached(const Transform &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache); Error lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache);
void set_lightmap_size_hint(const Size2i &p_size); void set_lightmap_size_hint(const Size2i &p_size);
Size2i get_lightmap_size_hint() const; Size2i get_lightmap_size_hint() const;

View File

@ -313,7 +313,7 @@ void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_valu
AnimationPlayerEditor::singleton->get_track_editor()->insert_value_key(p_keyed, p_value, p_advance); AnimationPlayerEditor::singleton->get_track_editor()->insert_value_key(p_keyed, p_value, p_advance);
} }
void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) { void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform3D &p_key) {
Node3D *s = Object::cast_to<Node3D>(sp); Node3D *s = Object::cast_to<Node3D>(sp);
if (!s) { if (!s) {
return; return;

View File

@ -112,7 +112,7 @@ class InspectorDock : public VBoxContainer {
void _prepare_history(); void _prepare_history();
void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance); void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance);
void _transform_keyed(Object *sp, const String &p_sub, const Transform &p_key); void _transform_keyed(Object *sp, const String &p_sub, const Transform3D &p_key);
protected: protected:
static void _bind_methods(); static void _bind_methods();

View File

@ -455,7 +455,7 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
int vc = collision_segments.size(); int vc = collision_segments.size();
const Vector3 *vptr = collision_segments.ptr(); const Vector3 *vptr = collision_segments.ptr();
Transform t = spatial_node->get_global_transform(); Transform3D t = spatial_node->get_global_transform();
bool any_out = false; bool any_out = false;
for (int j = 0; j < fc; j++) { for (int j = 0; j < fc; j++) {
@ -477,12 +477,12 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
} }
if (collision_mesh.is_valid()) { if (collision_mesh.is_valid()) {
Transform t = spatial_node->get_global_transform(); Transform3D t = spatial_node->get_global_transform();
Vector3 mesh_scale = t.get_basis().get_scale(); Vector3 mesh_scale = t.get_basis().get_scale();
t.orthonormalize(); t.orthonormalize();
Transform it = t.affine_inverse(); Transform3D it = t.affine_inverse();
Vector<Plane> transformed_frustum; Vector<Plane> transformed_frustum;
@ -508,7 +508,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
} }
if (r_gizmo_handle && !hidden) { if (r_gizmo_handle && !hidden) {
Transform t = spatial_node->get_global_transform(); Transform3D t = spatial_node->get_global_transform();
if (billboard_handle) { if (billboard_handle) {
t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
} }
@ -560,7 +560,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
} }
if (selectable_icon_size > 0.0f) { if (selectable_icon_size > 0.0f) {
Transform t = spatial_node->get_global_transform(); Transform3D t = spatial_node->get_global_transform();
Vector3 camera_position = p_camera->get_camera_transform().origin; Vector3 camera_position = p_camera->get_camera_transform().origin;
if (camera_position.distance_squared_to(t.origin) > 0.01) { if (camera_position.distance_squared_to(t.origin) > 0.01) {
t.set_look_at(t.origin, camera_position); t.set_look_at(t.origin, camera_position);
@ -576,7 +576,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
Point2 center = p_camera->unproject_position(t.origin); Point2 center = p_camera->unproject_position(t.origin);
Transform orig_camera_transform = p_camera->get_camera_transform(); Transform3D orig_camera_transform = p_camera->get_camera_transform();
if (orig_camera_transform.origin.distance_squared_to(t.origin) > 0.01 && if (orig_camera_transform.origin.distance_squared_to(t.origin) > 0.01 &&
ABS(orig_camera_transform.basis.get_axis(Vector3::AXIS_Z).dot(Vector3(0, 1, 0))) < 0.99) { ABS(orig_camera_transform.basis.get_axis(Vector3::AXIS_Z).dot(Vector3(0, 1, 0))) < 0.99) {
@ -609,7 +609,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
int vc = collision_segments.size(); int vc = collision_segments.size();
const Vector3 *vptr = collision_segments.ptr(); const Vector3 *vptr = collision_segments.ptr();
Transform t = spatial_node->get_global_transform(); Transform3D t = spatial_node->get_global_transform();
if (billboard_handle) { if (billboard_handle) {
t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
} }
@ -657,13 +657,13 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
} }
if (collision_mesh.is_valid()) { if (collision_mesh.is_valid()) {
Transform gt = spatial_node->get_global_transform(); Transform3D gt = spatial_node->get_global_transform();
if (billboard_handle) { if (billboard_handle) {
gt.set_look_at(gt.origin, gt.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); gt.set_look_at(gt.origin, gt.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
} }
Transform ai = gt.affine_inverse(); Transform3D ai = gt.affine_inverse();
Vector3 ray_from = ai.xform(p_camera->project_ray_origin(p_point)); Vector3 ray_from = ai.xform(p_camera->project_ray_origin(p_point));
Vector3 ray_dir = ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized(); Vector3 ray_dir = ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized();
Vector3 rpos, rnorm; Vector3 rpos, rnorm;
@ -826,7 +826,7 @@ Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_i
return Variant(); return Variant();
} }
static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform &p_arc_xform) { static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform3D &p_arc_xform) {
//bleh, discrete is simpler //bleh, discrete is simpler
static const int arc_test_points = 64; static const int arc_test_points = 64;
float min_d = 1e20; float min_d = 1e20;
@ -855,8 +855,8 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec
void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
Transform gt = light->get_global_transform(); Transform3D gt = light->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@ -1084,8 +1084,8 @@ Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gi
void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
Transform gt = player->get_global_transform(); Transform3D gt = player->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@ -1230,8 +1230,8 @@ Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_
void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
Transform gt = camera->get_global_transform(); Transform3D gt = camera->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@ -1239,7 +1239,7 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came
Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
Transform gt2 = camera->get_global_transform(); Transform3D gt2 = camera->get_global_transform();
float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2); float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2);
camera->set("fov", CLAMP(a * 2.0, 1, 179)); camera->set("fov", CLAMP(a * 2.0, 1, 179));
} else { } else {
@ -1418,7 +1418,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
lines.push_back(cam_pos); lines.push_back(cam_pos);
} }
Transform local = camera->get_global_transform().affine_inverse(); Transform3D local = camera->get_global_transform().affine_inverse();
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
lines.write[i] = local.xform(lines[i]); lines.write[i] = local.xform(lines[i]);
} }
@ -1617,7 +1617,7 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
surface_tool->begin(Mesh::PRIMITIVE_LINES); surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(material); surface_tool->set_material(material);
Vector<Transform> grests; Vector<Transform3D> grests;
grests.resize(skel->get_bone_count()); grests.resize(skel->get_bone_count());
Vector<int> bones; Vector<int> bones;
@ -1749,7 +1749,7 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
bones.write[0] = i; bones.write[0] = i;
} }
/* /*
Transform t = grests[i]; Transform3D t = grests[i];
t.orthonormalize(); t.orthonormalize();
for (int i=0;i<6;i++) { for (int i=0;i<6;i++) {
@ -2196,9 +2196,9 @@ Variant VisibilityNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_g
void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
Transform gt = notifier->get_global_transform(); Transform3D gt = notifier->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
bool move = p_idx >= 3; bool move = p_idx >= 3;
p_idx = p_idx % 3; p_idx = p_idx % 3;
@ -2388,8 +2388,8 @@ Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo,
void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
Transform gt = particles->get_global_transform(); Transform3D gt = particles->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
bool move = p_idx >= 3; bool move = p_idx >= 3;
p_idx = p_idx % 3; p_idx = p_idx % 3;
@ -2555,8 +2555,8 @@ Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *
void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Node3D *sn = p_gizmo->get_spatial_node(); Node3D *sn = p_gizmo->get_spatial_node();
Transform gt = sn->get_global_transform(); Transform3D gt = sn->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@ -2814,9 +2814,9 @@ Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo,
void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform(); Transform3D gt = probe->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
if (p_idx < 3) { if (p_idx < 3) {
Vector3 extents = probe->get_extents(); Vector3 extents = probe->get_extents();
@ -2993,9 +2993,9 @@ Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx
void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
Transform gt = decal->get_global_transform(); Transform3D gt = decal->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 extents = decal->get_extents(); Vector3 extents = decal->get_extents();
@ -3135,8 +3135,8 @@ Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_i
void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform(); Transform3D gt = probe->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 extents = probe->get_extents(); Vector3 extents = probe->get_extents();
@ -3583,7 +3583,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
co->get_shape_owners(&owners); co->get_shape_owners(&owners);
for (List<uint32_t>::Element *E = owners.front(); E; E = E->next()) { for (List<uint32_t>::Element *E = owners.front(); E; E = E->next()) {
uint32_t owner_id = E->get(); uint32_t owner_id = E->get();
Transform xform = co->shape_owner_get_transform(owner_id); Transform3D xform = co->shape_owner_get_transform(owner_id);
Object *owner = co->shape_owner_get_owner(owner_id); Object *owner = co->shape_owner_get_owner(owner_id);
// Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo.
if (!Object::cast_to<CollisionShape3D>(owner) && !Object::cast_to<CollisionPolygon3D>(owner)) { if (!Object::cast_to<CollisionShape3D>(owner) && !Object::cast_to<CollisionPolygon3D>(owner)) {
@ -3701,8 +3701,8 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i
return; return;
} }
Transform gt = cs->get_global_transform(); Transform3D gt = cs->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@ -4369,7 +4369,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
#define BODY_A_RADIUS 0.25 #define BODY_A_RADIUS 0.25
#define BODY_B_RADIUS 0.27 #define BODY_B_RADIUS 0.27
Basis JointGizmosDrawer::look_body(const Transform &p_joint_transform, const Transform &p_body_transform) { Basis JointGizmosDrawer::look_body(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) {
const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin); const Vector3 &p_target(p_body_transform.origin);
@ -4394,7 +4394,7 @@ Basis JointGizmosDrawer::look_body(const Transform &p_joint_transform, const Tra
return base; return base;
} }
Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform) { Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform3D &joint_transform, const Transform3D &body_transform) {
switch (p_axis) { switch (p_axis) {
case Vector3::AXIS_X: case Vector3::AXIS_X:
return look_body_toward_x(joint_transform, body_transform); return look_body_toward_x(joint_transform, body_transform);
@ -4407,7 +4407,7 @@ Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform
} }
} }
Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform) { Basis JointGizmosDrawer::look_body_toward_x(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) {
const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin); const Vector3 &p_target(p_body_transform.origin);
@ -4438,7 +4438,7 @@ Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform,
return base; return base;
} }
Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform) { Basis JointGizmosDrawer::look_body_toward_y(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) {
const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin); const Vector3 &p_target(p_body_transform.origin);
@ -4469,7 +4469,7 @@ Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform,
return base; return base;
} }
Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform) { Basis JointGizmosDrawer::look_body_toward_z(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) {
const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin); const Vector3 &p_target(p_body_transform.origin);
@ -4500,7 +4500,7 @@ Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform,
return base; return base;
} }
void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse) { void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse) {
if (p_limit_lower == p_limit_upper) { if (p_limit_lower == p_limit_upper) {
r_points.push_back(p_offset.translated(Vector3()).origin); r_points.push_back(p_offset.translated(Vector3()).origin);
r_points.push_back(p_offset.translated(p_base.xform(Vector3(0.5, 0, 0))).origin); r_points.push_back(p_offset.translated(p_base.xform(Vector3(0.5, 0, 0))).origin);
@ -4562,7 +4562,7 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const
} }
} }
void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points) { void JointGizmosDrawer::draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points) {
float r = 1.0; float r = 1.0;
float w = r * Math::sin(p_swing); float w = r * Math::sin(p_swing);
float d = r * Math::cos(p_swing); float d = r * Math::cos(p_swing);
@ -4666,7 +4666,7 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> body_b_points; Vector<Vector3> body_b_points;
if (Object::cast_to<PinJoint3D>(joint)) { if (Object::cast_to<PinJoint3D>(joint)) {
CreatePinJointGizmo(Transform(), points); CreatePinJointGizmo(Transform3D(), points);
p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(points);
p_gizmo->add_lines(points, common_material); p_gizmo->add_lines(points, common_material);
} }
@ -4674,10 +4674,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint); HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint);
if (hinge) { if (hinge) {
CreateHingeJointGizmo( CreateHingeJointGizmo(
Transform(), Transform3D(),
hinge->get_global_transform(), hinge->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_a ? node_body_a->get_global_transform() : Transform3D(),
node_body_b ? node_body_b->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform3D(),
hinge->get_param(HingeJoint3D::PARAM_LIMIT_LOWER), hinge->get_param(HingeJoint3D::PARAM_LIMIT_LOWER),
hinge->get_param(HingeJoint3D::PARAM_LIMIT_UPPER), hinge->get_param(HingeJoint3D::PARAM_LIMIT_UPPER),
hinge->get_flag(HingeJoint3D::FLAG_USE_LIMIT), hinge->get_flag(HingeJoint3D::FLAG_USE_LIMIT),
@ -4697,10 +4697,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint); SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint);
if (slider) { if (slider) {
CreateSliderJointGizmo( CreateSliderJointGizmo(
Transform(), Transform3D(),
slider->get_global_transform(), slider->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_a ? node_body_a->get_global_transform() : Transform3D(),
node_body_b ? node_body_b->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform3D(),
slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_LOWER), slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_LOWER),
slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_UPPER), slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_UPPER),
slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_LOWER), slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_LOWER),
@ -4721,10 +4721,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint); ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint);
if (cone) { if (cone) {
CreateConeTwistJointGizmo( CreateConeTwistJointGizmo(
Transform(), Transform3D(),
cone->get_global_transform(), cone->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_a ? node_body_a->get_global_transform() : Transform3D(),
node_body_b ? node_body_b->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform3D(),
cone->get_param(ConeTwistJoint3D::PARAM_SWING_SPAN), cone->get_param(ConeTwistJoint3D::PARAM_SWING_SPAN),
cone->get_param(ConeTwistJoint3D::PARAM_TWIST_SPAN), cone->get_param(ConeTwistJoint3D::PARAM_TWIST_SPAN),
node_body_a ? &body_a_points : nullptr, node_body_a ? &body_a_points : nullptr,
@ -4740,10 +4740,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint); Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint);
if (gen) { if (gen) {
CreateGeneric6DOFJointGizmo( CreateGeneric6DOFJointGizmo(
Transform(), Transform3D(),
gen->get_global_transform(), gen->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_a ? node_body_a->get_global_transform() : Transform3D(),
node_body_b ? node_body_b->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform3D(),
gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT), gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT),
gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT), gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT),
@ -4780,7 +4780,7 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
} }
} }
void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points) { void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points) {
float cs = 0.25; float cs = 0.25;
r_cursor_points.push_back(p_offset.translated(Vector3(+cs, 0, 0)).origin); r_cursor_points.push_back(p_offset.translated(Vector3(+cs, 0, 0)).origin);
@ -4791,7 +4791,7 @@ void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<V
r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, -cs)).origin); r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, -cs)).origin);
} }
void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin); r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin);
r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin); r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin);
@ -4821,7 +4821,7 @@ void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const
} }
} }
void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
p_linear_limit_lower = -p_linear_limit_lower; p_linear_limit_lower = -p_linear_limit_lower;
p_linear_limit_upper = -p_linear_limit_upper; p_linear_limit_upper = -p_linear_limit_upper;
@ -4880,7 +4880,7 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const
} }
} }
void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
if (r_body_a_points) { if (r_body_a_points) {
JointGizmosDrawer::draw_cone( JointGizmosDrawer::draw_cone(
p_offset, p_offset,
@ -4901,10 +4901,10 @@ void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, co
} }
void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
const Transform &p_offset, const Transform3D &p_offset,
const Transform &p_trs_joint, const Transform3D &p_trs_joint,
const Transform &p_trs_body_a, const Transform3D &p_trs_body_a,
const Transform &p_trs_body_b, const Transform3D &p_trs_body_b,
real_t p_angular_limit_lower_x, real_t p_angular_limit_lower_x,
real_t p_angular_limit_upper_x, real_t p_angular_limit_upper_x,
real_t p_linear_limit_lower_x, real_t p_linear_limit_lower_x,

View File

@ -428,17 +428,17 @@ public:
class JointGizmosDrawer { class JointGizmosDrawer {
public: public:
static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform); static Basis look_body(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform); static Basis look_body_toward(Vector3::Axis p_axis, const Transform3D &joint_transform, const Transform3D &body_transform);
static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform); static Basis look_body_toward_x(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform); static Basis look_body_toward_y(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
/// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis
/// with axis X and Y that are looking toward the body and oriented toward up /// with axis X and Y that are looking toward the body and oriented toward up
static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform); static Basis look_body_toward_z(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
// Draw circle around p_axis // Draw circle around p_axis
static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false);
static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points); static void draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points);
}; };
class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin { class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin {
@ -455,15 +455,15 @@ public:
int get_priority() const override; int get_priority() const override;
void redraw(EditorNode3DGizmo *p_gizmo) override; void redraw(EditorNode3DGizmo *p_gizmo) override;
static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points); static void CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points);
static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); static void CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); static void CreateSliderJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); static void CreateConeTwistJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
static void CreateGeneric6DOFJointGizmo( static void CreateGeneric6DOFJointGizmo(
const Transform &p_offset, const Transform3D &p_offset,
const Transform &p_trs_joint, const Transform3D &p_trs_joint,
const Transform &p_trs_body_a, const Transform3D &p_trs_body_a,
const Transform &p_trs_body_b, const Transform3D &p_trs_body_b,
real_t p_angular_limit_lower_x, real_t p_angular_limit_lower_x,
real_t p_angular_limit_upper_x, real_t p_angular_limit_upper_x,
real_t p_linear_limit_lower_x, real_t p_linear_limit_lower_x,

View File

@ -108,8 +108,8 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
return false; return false;
} }
Transform gt = node->get_global_transform(); Transform3D gt = node->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
float depth = _get_depth() * 0.5; float depth = _get_depth() * 0.5;
Vector3 n = gt.basis.get_axis(2).normalized(); Vector3 n = gt.basis.get_axis(2).normalized();
Plane p(gt.origin + n * depth, n); Plane p(gt.origin + n * depth, n);
@ -516,7 +516,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
mode = MODE_EDIT; mode = MODE_EDIT;
wip_active = false; wip_active = false;
imgeom = memnew(ImmediateGeometry3D); imgeom = memnew(ImmediateGeometry3D);
imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); imgeom->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001)));
line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@ -539,7 +539,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
imgeom->add_child(pointsm); imgeom->add_child(pointsm);
m.instance(); m.instance();
pointsm->set_mesh(m); pointsm->set_mesh(m);
pointsm->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); pointsm->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001)));
snap_ignore = false; snap_ignore = false;
} }

View File

@ -359,12 +359,12 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
camera = RS::get_singleton()->camera_create(); camera = RS::get_singleton()->camera_create();
RS::get_singleton()->viewport_attach_camera(viewport, camera); RS::get_singleton()->viewport_attach_camera(viewport, camera);
RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); RS::get_singleton()->camera_set_transform(camera, Transform3D(Basis(), Vector3(0, 0, 3)));
RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10);
light = RS::get_singleton()->directional_light_create(); light = RS::get_singleton()->directional_light_create();
light_instance = RS::get_singleton()->instance_create2(light, scenario); light_instance = RS::get_singleton()->instance_create2(light, scenario);
RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); RS::get_singleton()->instance_set_transform(light_instance, Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
light2 = RS::get_singleton()->directional_light_create(); light2 = RS::get_singleton()->directional_light_create();
RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
@ -372,7 +372,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); RS::get_singleton()->instance_set_transform(light_instance2, Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
sphere = RS::get_singleton()->mesh_create(); sphere = RS::get_singleton()->mesh_create();
sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario); sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario);
@ -720,7 +720,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
AABB aabb = mesh->get_aabb(); AABB aabb = mesh->get_aabb();
Vector3 ofs = aabb.position + aabb.size * 0.5; Vector3 ofs = aabb.position + aabb.size * 0.5;
aabb.position -= ofs; aabb.position -= ofs;
Transform xform; Transform3D xform;
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125); xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125);
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis; xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis;
AABB rot_aabb = xform.xform(aabb); AABB rot_aabb = xform.xform(aabb);
@ -780,20 +780,20 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
camera = RS::get_singleton()->camera_create(); camera = RS::get_singleton()->camera_create();
RS::get_singleton()->viewport_attach_camera(viewport, camera); RS::get_singleton()->viewport_attach_camera(viewport, camera);
RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); RS::get_singleton()->camera_set_transform(camera, Transform3D(Basis(), Vector3(0, 0, 3)));
//RS::get_singleton()->camera_set_perspective(camera,45,0.1,10); //RS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
RS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); RS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0);
light = RS::get_singleton()->directional_light_create(); light = RS::get_singleton()->directional_light_create();
light_instance = RS::get_singleton()->instance_create2(light, scenario); light_instance = RS::get_singleton()->instance_create2(light, scenario);
RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); RS::get_singleton()->instance_set_transform(light_instance, Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
light2 = RS::get_singleton()->directional_light_create(); light2 = RS::get_singleton()->directional_light_create();
RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
//RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); //RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); RS::get_singleton()->instance_set_transform(light_instance2, Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
//sphere = RS::get_singleton()->mesh_create(); //sphere = RS::get_singleton()->mesh_create();
mesh_instance = RS::get_singleton()->instance_create(); mesh_instance = RS::get_singleton()->instance_create();

View File

@ -177,7 +177,7 @@ void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) {
return; return;
} }
Transform geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform(); Transform3D geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform();
int gc = geometry.size(); int gc = geometry.size();
Face3 *w = geometry.ptrw(); Face3 *w = geometry.ptrw();

View File

@ -119,17 +119,17 @@ MaterialEditor::MaterialEditor() {
viewport->set_msaa(Viewport::MSAA_4X); viewport->set_msaa(Viewport::MSAA_4X);
camera = memnew(Camera3D); camera = memnew(Camera3D);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 3))); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3)));
camera->set_perspective(45, 0.1, 10); camera->set_perspective(45, 0.1, 10);
camera->make_current(); camera->make_current();
viewport->add_child(camera); viewport->add_child(camera);
light1 = memnew(DirectionalLight3D); light1 = memnew(DirectionalLight3D);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); light1->set_transform(Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1); viewport->add_child(light1);
light2 = memnew(DirectionalLight3D); light2 = memnew(DirectionalLight3D);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); light2->set_transform(Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7)); light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2); viewport->add_child(light2);
@ -139,7 +139,7 @@ MaterialEditor::MaterialEditor() {
box_instance = memnew(MeshInstance3D); box_instance = memnew(MeshInstance3D);
viewport->add_child(box_instance); viewport->add_child(box_instance);
Transform box_xform; Transform3D box_xform;
box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0)); box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0));
box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0)); box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0));
box_xform.basis.scale(Vector3(0.8, 0.8, 0.8)); box_xform.basis.scale(Vector3(0.8, 0.8, 0.8));

View File

@ -65,7 +65,7 @@ void MeshEditor::_notification(int p_what) {
} }
void MeshEditor::_update_rotation() { void MeshEditor::_update_rotation() {
Transform t; Transform3D t;
t.basis.rotate(Vector3(0, 1, 0), -rot_y); t.basis.rotate(Vector3(0, 1, 0), -rot_y);
t.basis.rotate(Vector3(1, 0, 0), -rot_x); t.basis.rotate(Vector3(1, 0, 0), -rot_x);
rotation->set_transform(t); rotation->set_transform(t);
@ -85,7 +85,7 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) {
if (m != 0) { if (m != 0) {
m = 1.0 / m; m = 1.0 / m;
m *= 0.5; m *= 0.5;
Transform xform; Transform3D xform;
xform.basis.scale(Vector3(m, m, m)); xform.basis.scale(Vector3(m, m, m));
xform.origin = -xform.basis.xform(ofs); //-ofs*m; xform.origin = -xform.basis.xform(ofs); //-ofs*m;
//xform.origin.z -= aabb.get_longest_axis_size() * 2; //xform.origin.z -= aabb.get_longest_axis_size() * 2;
@ -117,16 +117,16 @@ MeshEditor::MeshEditor() {
viewport->set_msaa(Viewport::MSAA_2X); viewport->set_msaa(Viewport::MSAA_2X);
set_stretch(true); set_stretch(true);
camera = memnew(Camera3D); camera = memnew(Camera3D);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1))); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 1.1)));
camera->set_perspective(45, 0.1, 10); camera->set_perspective(45, 0.1, 10);
viewport->add_child(camera); viewport->add_child(camera);
light1 = memnew(DirectionalLight3D); light1 = memnew(DirectionalLight3D);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); light1->set_transform(Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1); viewport->add_child(light1);
light2 = memnew(DirectionalLight3D); light2 = memnew(DirectionalLight3D);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); light2->set_transform(Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7)); light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2); viewport->add_child(light2);

View File

@ -127,7 +127,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue; continue;
} }
//Transform shape_transform = sb->shape_owner_get_transform(E->get()); //Transform3D shape_transform = sb->shape_owner_get_transform(E->get());
//shape_transform.set_origin(shape_transform.get_origin() - phys_offset); //shape_transform.set_origin(shape_transform.get_origin() - phys_offset);
@ -147,7 +147,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
p_library->set_item_shapes(id, collisions); p_library->set_item_shapes(id, collisions);
Ref<NavigationMesh> navmesh; Ref<NavigationMesh> navmesh;
Transform navmesh_transform; Transform3D navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) { for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j); Node *child2 = mi->get_child(j);
if (!Object::cast_to<NavigationRegion3D>(child2)) { if (!Object::cast_to<NavigationRegion3D>(child2)) {
@ -170,7 +170,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
if (true) { if (true) {
Vector<Ref<Mesh>> meshes; Vector<Ref<Mesh>> meshes;
Vector<Transform> transforms; Vector<Transform3D> transforms;
Vector<int> ids = p_library->get_item_list(); Vector<int> ids = p_library->get_item_list();
for (int i = 0; i < ids.size(); i++) { for (int i = 0; i < ids.size(); i++) {
if (mesh_instances.find(ids[i])) { if (mesh_instances.find(ids[i])) {

View File

@ -111,7 +111,7 @@ void MultiMeshEditor::_populate() {
return; return;
} }
Transform geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform(); Transform3D geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform();
Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID); Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID);
@ -167,7 +167,7 @@ void MultiMeshEditor::_populate() {
float _scale = populate_scale->get_value(); float _scale = populate_scale->get_value();
int axis = populate_axis->get_selected(); int axis = populate_axis->get_selected();
Transform axis_xform; Transform3D axis_xform;
if (axis == Vector3::AXIS_Z) { if (axis == Vector3::AXIS_Z) {
axis_xform.rotate(Vector3(1, 0, 0), -Math_PI * 0.5); axis_xform.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
} }
@ -191,7 +191,7 @@ void MultiMeshEditor::_populate() {
Vector3 normal = face.get_plane().normal; Vector3 normal = face.get_plane().normal;
Vector3 op_axis = (face.vertex[0] - face.vertex[1]).normalized(); Vector3 op_axis = (face.vertex[0] - face.vertex[1]).normalized();
Transform xform; Transform3D xform;
xform.set_look_at(pos, pos + op_axis, normal); xform.set_look_at(pos, pos + op_axis, normal);
xform = xform * axis_xform; xform = xform * axis_xform;

View File

@ -361,8 +361,8 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) {
} }
} }
Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const { Transform3D Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const {
Transform camera_transform; Transform3D camera_transform;
camera_transform.translate(p_cursor.pos); camera_transform.translate(p_cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot); camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot);
camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot); camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot);
@ -410,7 +410,7 @@ float Node3DEditorViewport::get_fov() const {
return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV); return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV);
} }
Transform Node3DEditorViewport::_get_camera_transform() const { Transform3D Node3DEditorViewport::_get_camera_transform() const {
return camera->get_global_transform(); return camera->get_global_transform();
} }
@ -631,7 +631,7 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
} }
Vector2 screen_he = cm.get_viewport_half_extents(); Vector2 screen_he = cm.get_viewport_half_extents();
Transform camera_transform; Transform3D camera_transform;
camera_transform.translate(cursor.pos); camera_transform.translate(cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot); camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
@ -829,7 +829,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
Vector3 ray_pos = _get_ray_pos(Vector2(p_screenpos.x, p_screenpos.y)); Vector3 ray_pos = _get_ray_pos(Vector2(p_screenpos.x, p_screenpos.y));
Vector3 ray = _get_ray(Vector2(p_screenpos.x, p_screenpos.y)); Vector3 ray = _get_ray(Vector2(p_screenpos.x, p_screenpos.y));
Transform gt = spatial_editor->get_gizmo_transform(); Transform3D gt = spatial_editor->get_gizmo_transform();
float gs = gizmo_scale; float gs = gizmo_scale;
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) { if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
@ -1579,10 +1579,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
continue; continue;
} }
Transform original = se->original; Transform3D original = se->original;
Transform original_local = se->original_local; Transform3D original_local = se->original_local;
Transform base = Transform(Basis(), _edit.center); Transform3D base = Transform3D(Basis(), _edit.center);
Transform t; Transform3D t;
Vector3 local_scale; Vector3 local_scale;
if (local_coords) { if (local_coords) {
@ -1608,7 +1608,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
motion.snap(Vector3(snap, snap, snap)); motion.snap(Vector3(snap, snap, snap));
} }
Transform r; Transform3D r;
r.basis.scale(motion + Vector3(1, 1, 1)); r.basis.scale(motion + Vector3(1, 1, 1));
t = base * (r * (base.inverse() * original)); t = base * (r * (base.inverse() * original));
@ -1701,8 +1701,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
continue; continue;
} }
Transform original = se->original; Transform3D original = se->original;
Transform t; Transform3D t;
if (local_coords) { if (local_coords) {
if (_edit.snap || spatial_editor->is_snap_enabled()) { if (_edit.snap || spatial_editor->is_snap_enabled()) {
@ -1797,10 +1797,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
continue; continue;
} }
Transform t; Transform3D t;
if (local_coords) { if (local_coords) {
Transform original_local = se->original_local; Transform3D original_local = se->original_local;
Basis rot = Basis(axis, angle); Basis rot = Basis(axis, angle);
t.basis = original_local.get_basis().orthonormalized() * rot; t.basis = original_local.get_basis().orthonormalized() * rot;
@ -1811,9 +1811,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
sp->set_scale(original_local.basis.get_scale()); // re-apply original scale sp->set_scale(original_local.basis.get_scale()); // re-apply original scale
} else { } else {
Transform original = se->original; Transform3D original = se->original;
Transform r; Transform3D r;
Transform base = Transform(Basis(), _edit.center); Transform3D base = Transform3D(Basis(), _edit.center);
r.basis.rotate(plane.normal, angle); r.basis.rotate(plane.normal, angle);
t = base * r * base.inverse() * original; t = base * r * base.inverse() * original;
@ -2057,7 +2057,7 @@ void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const
pan_speed *= pan_speed_modifier; pan_speed *= pan_speed_modifier;
} }
Transform camera_transform; Transform3D camera_transform;
camera_transform.translate(cursor.pos); camera_transform.translate(cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
@ -2145,7 +2145,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const
const bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis"); const bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis");
// Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag". // Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag".
const Transform prev_camera_transform = to_camera_transform(cursor); const Transform3D prev_camera_transform = to_camera_transform(cursor);
if (invert_y_axis) { if (invert_y_axis) {
cursor.x_rot -= p_relative.y * radians_per_pixel; cursor.x_rot -= p_relative.y * radians_per_pixel;
@ -2158,7 +2158,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const
cursor.y_rot += p_relative.x * radians_per_pixel; cursor.y_rot += p_relative.x * radians_per_pixel;
// Look is like the opposite of Orbit: the focus point rotates around the camera // Look is like the opposite of Orbit: the focus point rotates around the camera
Transform camera_transform = to_camera_transform(cursor); Transform3D camera_transform = to_camera_transform(cursor);
Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); Vector3 pos = camera_transform.xform(Vector3(0, 0, 0));
Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0)); Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0));
Vector3 diff = prev_pos - pos; Vector3 diff = prev_pos - pos;
@ -2444,7 +2444,7 @@ void Node3DEditorViewport::_notification(int p_what) {
continue; continue;
} }
Transform t = sp->get_global_gizmo_transform(); Transform3D t = sp->get_global_gizmo_transform();
VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp); VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp);
AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp); AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp);
@ -2878,7 +2878,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
break; break;
} }
Transform camera_transform = camera->get_global_transform(); Transform3D camera_transform = camera->get_global_transform();
List<Node *> &selection = editor_selection->get_selected_node_list(); List<Node *> &selection = editor_selection->get_selected_node_list();
@ -2895,7 +2895,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
continue; continue;
} }
Transform xform; Transform3D xform;
if (orthogonal) { if (orthogonal) {
xform = sp->get_global_transform(); xform = sp->get_global_transform();
xform.basis.set_euler(camera_transform.basis.get_euler()); xform.basis.set_euler(camera_transform.basis.get_euler());
@ -2915,7 +2915,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
break; break;
} }
Transform camera_transform = camera->get_global_transform(); Transform3D camera_transform = camera->get_global_transform();
List<Node *> &selection = editor_selection->get_selected_node_list(); List<Node *> &selection = editor_selection->get_selected_node_list();
@ -3315,9 +3315,9 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
return; return;
} }
Transform xform = spatial_editor->get_gizmo_transform(); Transform3D xform = spatial_editor->get_gizmo_transform();
Transform camera_xform = camera->get_transform(); Transform3D camera_xform = camera->get_transform();
if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) { if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -3800,7 +3800,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
Node3D *node3d = Object::cast_to<Node3D>(instanced_scene); Node3D *node3d = Object::cast_to<Node3D>(instanced_scene);
if (node3d) { if (node3d) {
Transform global_transform; Transform3D global_transform;
Node3D *parent_node3d = Object::cast_to<Node3D>(parent); Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
if (parent_node3d) { if (parent_node3d) {
global_transform = parent_node3d->get_global_gizmo_transform(); global_transform = parent_node3d->get_global_gizmo_transform();
@ -3900,7 +3900,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
} }
if (can_instance) { if (can_instance) {
Transform global_transform = Transform(Basis(), _get_instance_position(p_point)); Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point));
preview_node->set_global_transform(global_transform); preview_node->set_global_transform(global_transform);
} }
@ -4574,7 +4574,7 @@ void Node3DEditor::update_transform_gizmo() {
continue; continue;
} }
Transform xf = se->sp->get_global_gizmo_transform(); Transform3D xf = se->sp->get_global_gizmo_transform();
if (first) { if (first) {
center.position = xf.origin; center.position = xf.origin;
@ -4955,7 +4955,7 @@ void Node3DEditor::_snap_update() {
} }
void Node3DEditor::_xform_dialog_action() { void Node3DEditor::_xform_dialog_action() {
Transform t; Transform3D t;
//translation //translation
Vector3 scale; Vector3 scale;
Vector3 rotate; Vector3 rotate;
@ -4988,7 +4988,7 @@ void Node3DEditor::_xform_dialog_action() {
bool post = xform_type->get_selected() > 0; bool post = xform_type->get_selected() > 0;
Transform tr = sp->get_global_gizmo_transform(); Transform3D tr = sp->get_global_gizmo_transform();
if (post) { if (post) {
tr = tr * t; tr = tr * t;
} else { } else {
@ -6180,7 +6180,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
if (ss->intersect_ray(from, to, result, excluded)) { if (ss->intersect_ray(from, to, result, excluded)) {
Vector3 position_offset = d["position_offset"]; Vector3 position_offset = d["position_offset"];
Transform new_transform = sp->get_global_transform(); Transform3D new_transform = sp->get_global_transform();
new_transform.origin.y = result.position.y; new_transform.origin.y = result.position.y;
new_transform.origin = new_transform.origin - position_offset; new_transform.origin = new_transform.origin - position_offset;
@ -6556,7 +6556,7 @@ void Node3DEditor::_preview_settings_changed() {
} }
{ // preview sun { // preview sun
Transform t; Transform3D t;
t.basis = sun_rotation; t.basis = sun_rotation;
preview_sun->set_transform(t); preview_sun->set_transform(t);
sun_direction->update(); sun_direction->update();

View File

@ -322,7 +322,7 @@ private:
Vector3 _get_ray_pos(const Vector2 &p_pos) const; Vector3 _get_ray_pos(const Vector2 &p_pos) const;
Vector3 _get_ray(const Vector2 &p_pos) const; Vector3 _get_ray(const Vector2 &p_pos) const;
Point2 _point_to_screen(const Vector3 &p_point); Point2 _point_to_screen(const Vector3 &p_point);
Transform _get_camera_transform() const; Transform3D _get_camera_transform() const;
int get_selected_count() const; int get_selected_count() const;
Vector3 _get_camera_position() const; Vector3 _get_camera_position() const;
@ -380,7 +380,7 @@ private:
struct EditData { struct EditData {
TransformMode mode; TransformMode mode;
TransformPlane plane; TransformPlane plane;
Transform original; Transform3D original;
Vector3 click_ray; Vector3 click_ray;
Vector3 click_ray_pos; Vector3 click_ray_pos;
Vector3 center; Vector3 center;
@ -432,7 +432,7 @@ private:
// //
void _update_camera(float p_interp_delta); void _update_camera(float p_interp_delta);
Transform to_camera_transform(const Cursor &p_cursor) const; Transform3D to_camera_transform(const Cursor &p_cursor) const;
void _draw(); void _draw();
void _surface_mouse_enter(); void _surface_mouse_enter();
@ -505,9 +505,9 @@ class Node3DEditorSelectedItem : public Object {
public: public:
AABB aabb; AABB aabb;
Transform original; // original location when moving Transform3D original; // original location when moving
Transform original_local; Transform3D original_local;
Transform last_xform; // last transform Transform3D last_xform; // last transform
bool last_xform_dirty; bool last_xform_dirty;
Node3D *sp; Node3D *sp;
RID sbox_instance; RID sbox_instance;
@ -641,7 +641,7 @@ private:
struct Gizmo { struct Gizmo {
bool visible = false; bool visible = false;
float scale = 0; float scale = 0;
Transform transform; Transform3D transform;
} gizmo; } gizmo;
enum MenuOption { enum MenuOption {
@ -824,7 +824,7 @@ public:
float get_zfar() const { return settings_zfar->get_value(); } float get_zfar() const { return settings_zfar->get_value(); }
float get_fov() const { return settings_fov->get_value(); } float get_fov() const { return settings_fov->get_value(); }
Transform get_gizmo_transform() const { return gizmo.transform; } Transform3D get_gizmo_transform() const { return gizmo.transform; }
bool is_gizmo_visible() const { return gizmo.visible; } bool is_gizmo_visible() const { return gizmo.visible; }
ToolMode get_tool_mode() const { return tool_mode; } ToolMode get_tool_mode() const { return tool_mode; }

View File

@ -94,8 +94,8 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
return; return;
} }
Transform gt = path->get_global_transform(); Transform3D gt = path->get_global_transform();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@ -302,8 +302,8 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
if (c.is_null()) { if (c.is_null()) {
return false; return false;
} }
Transform gt = path->get_global_transform(); Transform3D gt = path->get_global_transform();
Transform it = gt.affine_inverse(); Transform3D it = gt.affine_inverse();
static const int click_dist = 10; //should make global static const int click_dist = 10; //should make global

View File

@ -171,7 +171,7 @@ void BoneTransformEditor::_value_changed(const double p_value) {
return; return;
} }
Transform tform = compute_transform_from_vector3s(); Transform3D tform = compute_transform_from_vector3s();
_change_transform(tform); _change_transform(tform);
} }
@ -179,30 +179,30 @@ void BoneTransformEditor::_value_changed_vector3(const String p_property_name, c
if (updating) { if (updating) {
return; return;
} }
Transform tform = compute_transform_from_vector3s(); Transform3D tform = compute_transform_from_vector3s();
_change_transform(tform); _change_transform(tform);
} }
Transform BoneTransformEditor::compute_transform_from_vector3s() const { Transform3D BoneTransformEditor::compute_transform_from_vector3s() const {
// Convert rotation from degrees to radians. // Convert rotation from degrees to radians.
Vector3 prop_rotation = rotation_property->get_vector(); Vector3 prop_rotation = rotation_property->get_vector();
prop_rotation.x = Math::deg2rad(prop_rotation.x); prop_rotation.x = Math::deg2rad(prop_rotation.x);
prop_rotation.y = Math::deg2rad(prop_rotation.y); prop_rotation.y = Math::deg2rad(prop_rotation.y);
prop_rotation.z = Math::deg2rad(prop_rotation.z); prop_rotation.z = Math::deg2rad(prop_rotation.z);
return Transform( return Transform3D(
Basis(prop_rotation, scale_property->get_vector()), Basis(prop_rotation, scale_property->get_vector()),
translation_property->get_vector()); translation_property->get_vector());
} }
void BoneTransformEditor::_value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean) { void BoneTransformEditor::_value_changed_transform(const String p_property_name, const Transform3D p_transform, const StringName p_edited_property_name, const bool p_boolean) {
if (updating) { if (updating) {
return; return;
} }
_change_transform(p_transform); _change_transform(p_transform);
} }
void BoneTransformEditor::_change_transform(Transform p_new_transform) { void BoneTransformEditor::_change_transform(Transform3D p_new_transform) {
if (property.get_slicec('/', 0) == "bones" && property.get_slicec('/', 2) == "custom_pose") { if (property.get_slicec('/', 0) == "bones" && property.get_slicec('/', 2) == "custom_pose") {
undo_redo->create_action(TTR("Set Custom Bone Pose Transform"), UndoRedo::MERGE_ENDS); undo_redo->create_action(TTR("Set Custom Bone Pose Transform"), UndoRedo::MERGE_ENDS);
undo_redo->add_undo_method(skeleton, "set_bone_custom_pose", property.get_slicec('/', 1).to_int(), skeleton->get_bone_custom_pose(property.get_slicec('/', 1).to_int())); undo_redo->add_undo_method(skeleton, "set_bone_custom_pose", property.get_slicec('/', 1).to_int(), skeleton->get_bone_custom_pose(property.get_slicec('/', 1).to_int()));
@ -235,7 +235,7 @@ void BoneTransformEditor::_update_properties() {
updating = true; updating = true;
Transform tform = skeleton->get(property); Transform3D tform = skeleton->get(property);
_update_transform_properties(tform); _update_transform_properties(tform);
} }
@ -250,11 +250,11 @@ void BoneTransformEditor::_update_custom_pose_properties() {
updating = true; updating = true;
Transform tform = skeleton->get_bone_custom_pose(property.to_int()); Transform3D tform = skeleton->get_bone_custom_pose(property.to_int());
_update_transform_properties(tform); _update_transform_properties(tform);
} }
void BoneTransformEditor::_update_transform_properties(Transform tform) { void BoneTransformEditor::_update_transform_properties(Transform3D tform) {
Basis rotation_basis = tform.get_basis(); Basis rotation_basis = tform.get_basis();
Vector3 rotation_radians = rotation_basis.get_rotation_euler(); Vector3 rotation_radians = rotation_basis.get_rotation_euler();
Vector3 rotation_degrees = Vector3(Math::rad2deg(rotation_radians.x), Math::rad2deg(rotation_radians.y), Math::rad2deg(rotation_radians.z)); Vector3 rotation_degrees = Vector3(Math::rad2deg(rotation_radians.x), Math::rad2deg(rotation_radians.y), Math::rad2deg(rotation_radians.z));
@ -306,7 +306,7 @@ void BoneTransformEditor::_key_button_pressed() {
} }
// Need to normalize the basis before you key it // Need to normalize the basis before you key it
Transform tform = compute_transform_from_vector3s(); Transform3D tform = compute_transform_from_vector3s();
tform.orthonormalize(); tform.orthonormalize();
AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(skeleton, name, tform); AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(skeleton, name, tform);
} }
@ -380,7 +380,7 @@ void Skeleton3DEditor::create_physical_skeleton() {
} }
PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) { PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) {
const Transform child_rest = skeleton->get_bone_rest(bone_child_id); const Transform3D child_rest = skeleton->get_bone_rest(bone_child_id);
const real_t half_height(child_rest.origin.length() * 0.5); const real_t half_height(child_rest.origin.length() * 0.5);
const real_t radius(half_height * 0.2); const real_t radius(half_height * 0.2);
@ -392,15 +392,15 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi
CollisionShape3D *bone_shape = memnew(CollisionShape3D); CollisionShape3D *bone_shape = memnew(CollisionShape3D);
bone_shape->set_shape(bone_shape_capsule); bone_shape->set_shape(bone_shape_capsule);
Transform capsule_transform; Transform3D capsule_transform;
capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0)); capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0));
bone_shape->set_transform(capsule_transform); bone_shape->set_transform(capsule_transform);
Transform body_transform; Transform3D body_transform;
body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin); body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin);
body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height)); body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height));
Transform joint_transform; Transform3D joint_transform;
joint_transform.origin = Vector3(0, 0, half_height); joint_transform.origin = Vector3(0, 0, half_height);
PhysicalBone3D *physical_bone = memnew(PhysicalBone3D); PhysicalBone3D *physical_bone = memnew(PhysicalBone3D);

View File

@ -78,11 +78,11 @@ class BoneTransformEditor : public VBoxContainer {
// Called when the one of the EditorPropertyVector3 are updated. // Called when the one of the EditorPropertyVector3 are updated.
void _value_changed_vector3(const String p_property_name, const Vector3 p_vector, const StringName p_edited_property_name, const bool p_boolean); void _value_changed_vector3(const String p_property_name, const Vector3 p_vector, const StringName p_edited_property_name, const bool p_boolean);
// Called when the transform_property is updated. // Called when the transform_property is updated.
void _value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean); void _value_changed_transform(const String p_property_name, const Transform3D p_transform, const StringName p_edited_property_name, const bool p_boolean);
// Changes the transform to the given transform and updates the UI accordingly. // Changes the transform to the given transform and updates the UI accordingly.
void _change_transform(Transform p_new_transform); void _change_transform(Transform3D p_new_transform);
// Creates a Transform using the EditorPropertyVector3 properties. // Creates a Transform using the EditorPropertyVector3 properties.
Transform compute_transform_from_vector3s() const; Transform3D compute_transform_from_vector3s() const;
void update_enabled_checkbox(); void update_enabled_checkbox();
@ -98,7 +98,7 @@ public:
void _update_properties(); void _update_properties();
void _update_custom_pose_properties(); void _update_custom_pose_properties();
void _update_transform_properties(Transform p_transform); void _update_transform_properties(Transform3D p_transform);
// Can/cannot modify the spinner values for the Transform // Can/cannot modify the spinner values for the Transform
void set_read_only(const bool p_read_only); void set_read_only(const bool p_read_only);
@ -127,7 +127,7 @@ class Skeleton3DEditor : public VBoxContainer {
struct BoneInfo { struct BoneInfo {
PhysicalBone3D *physical_bone = nullptr; PhysicalBone3D *physical_bone = nullptr;
Transform relative_rest; // Relative to skeleton node Transform3D relative_rest; // Relative to skeleton node
}; };
EditorNode *editor; EditorNode *editor;

View File

@ -806,7 +806,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
field_names.push_back("zo"); field_names.push_back("zo");
config_value_editors(12, 4, 16, field_names); config_value_editors(12, 4, 16, field_names);
Transform tr = v; Transform3D tr = v;
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3])); value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3]));
} }
@ -1569,7 +1569,7 @@ void CustomPropertyEditor::_modified(String p_string) {
origin.y = _parse_real_expression(value_editor[7]->get_text()); origin.y = _parse_real_expression(value_editor[7]->get_text());
origin.z = _parse_real_expression(value_editor[11]->get_text()); origin.z = _parse_real_expression(value_editor[11]->get_text());
v = Transform(basis, origin); v = Transform3D(basis, origin);
_emit_changed_whole_or_field(); _emit_changed_whole_or_field();
} break; } break;

View File

@ -326,7 +326,7 @@ static Variant create_var(RS::GlobalVariableType p_type) {
return Transform2D(); return Transform2D();
} }
case RS::GLOBAL_VAR_TYPE_TRANSFORM: { case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
return Transform(); return Transform3D();
} }
case RS::GLOBAL_VAR_TYPE_MAT4: { case RS::GLOBAL_VAR_TYPE_MAT4: {
Vector<real_t> xform; Vector<real_t> xform;

View File

@ -268,7 +268,7 @@ PhysicsServer3D::AreaSpaceOverrideMode BulletPhysicsServer3D::area_get_space_ove
return area->get_spOv_mode(); return area->get_spOv_mode();
} }
void BulletPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) { void BulletPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform, bool p_disabled) {
AreaBullet *area = area_owner.getornull(p_area); AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area); ERR_FAIL_COND(!area);
@ -288,7 +288,7 @@ void BulletPhysicsServer3D::area_set_shape(RID p_area, int p_shape_idx, RID p_sh
area->set_shape(p_shape_idx, shape); area->set_shape(p_shape_idx, shape);
} }
void BulletPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) { void BulletPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) {
AreaBullet *area = area_owner.getornull(p_area); AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area); ERR_FAIL_COND(!area);
@ -309,9 +309,9 @@ RID BulletPhysicsServer3D::area_get_shape(RID p_area, int p_shape_idx) const {
return area->get_shape(p_shape_idx)->get_self(); return area->get_shape(p_shape_idx)->get_self();
} }
Transform BulletPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const { Transform3D BulletPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const {
AreaBullet *area = area_owner.getornull(p_area); AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform()); ERR_FAIL_COND_V(!area, Transform3D());
return area->get_shape_transform(p_shape_idx); return area->get_shape_transform(p_shape_idx);
} }
@ -382,15 +382,15 @@ Variant BulletPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param)
} }
} }
void BulletPhysicsServer3D::area_set_transform(RID p_area, const Transform &p_transform) { void BulletPhysicsServer3D::area_set_transform(RID p_area, const Transform3D &p_transform) {
AreaBullet *area = area_owner.getornull(p_area); AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area); ERR_FAIL_COND(!area);
area->set_transform(p_transform); area->set_transform(p_transform);
} }
Transform BulletPhysicsServer3D::area_get_transform(RID p_area) const { Transform3D BulletPhysicsServer3D::area_get_transform(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area); AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform()); ERR_FAIL_COND_V(!area, Transform3D());
return area->get_transform(); return area->get_transform();
} }
@ -484,7 +484,7 @@ PhysicsServer3D::BodyMode BulletPhysicsServer3D::body_get_mode(RID p_body) const
return body->get_mode(); return body->get_mode();
} }
void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform, bool p_disabled) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body); RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body); ERR_FAIL_COND(!body);
@ -504,7 +504,7 @@ void BulletPhysicsServer3D::body_set_shape(RID p_body, int p_shape_idx, RID p_sh
body->set_shape(p_shape_idx, shape); body->set_shape(p_shape_idx, shape);
} }
void BulletPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) { void BulletPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform3D &p_transform) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body); RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body); ERR_FAIL_COND(!body);
@ -527,9 +527,9 @@ RID BulletPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const {
return shape->get_self(); return shape->get_self();
} }
Transform BulletPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const { Transform3D BulletPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body); RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform()); ERR_FAIL_COND_V(!body, Transform3D());
return body->get_shape_transform(p_shape_idx); return body->get_shape_transform(p_shape_idx);
} }
@ -842,7 +842,7 @@ PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_bod
return BulletPhysicsDirectBodyState3D::get_singleton(body); return BulletPhysicsDirectBodyState3D::get_singleton(body);
} }
bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) { bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform3D &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body); RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false); ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false); ERR_FAIL_COND_V(!body->get_space(), false);
@ -850,7 +850,7 @@ bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes); return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes);
} }
int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) { int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform3D &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body); RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0); ERR_FAIL_COND_V(!body, 0);
ERR_FAIL_COND_V(!body->get_space(), 0); ERR_FAIL_COND_V(!body->get_space(), 0);
@ -990,7 +990,7 @@ Variant BulletPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state
return Variant(); return Variant();
} }
void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform &p_transform) { void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform3D &p_transform) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body); SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body); ERR_FAIL_COND(!body);
@ -1205,7 +1205,7 @@ Vector3 BulletPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
return pin_joint->getPivotInB(); return pin_joint->getPivotInB();
} }
RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) { RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform3D &p_hinge_A, RID p_body_B, const Transform3D &p_hinge_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID()); ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID()); JointAssertSpace(body_A, "A", RID());
@ -1277,7 +1277,7 @@ bool BulletPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_f
return hinge_joint->get_flag(p_flag); return hinge_joint->get_flag(p_flag);
} }
RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID()); ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID()); JointAssertSpace(body_A, "A", RID());
@ -1313,7 +1313,7 @@ real_t BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointPar
return slider_joint->get_param(p_param); return slider_joint->get_param(p_param);
} }
RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID()); ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID()); JointAssertSpace(body_A, "A", RID());
@ -1347,7 +1347,7 @@ real_t BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJ
return coneTwist_joint->get_param(p_param); return coneTwist_joint->get_param(p_param);
} }
RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID()); ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID()); JointAssertSpace(body_A, "A", RID());

View File

@ -134,12 +134,12 @@ public:
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) override; virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) override;
virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const override; virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const override;
virtual void area_add_shape(RID p_area, RID p_shape, const Transform &p_transform = Transform(), bool p_disabled = false) override; virtual void area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) override;
virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) override; virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) override;
virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) override; virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) override;
virtual int area_get_shape_count(RID p_area) const override; virtual int area_get_shape_count(RID p_area) const override;
virtual RID area_get_shape(RID p_area, int p_shape_idx) const override; virtual RID area_get_shape(RID p_area, int p_shape_idx) const override;
virtual Transform area_get_shape_transform(RID p_area, int p_shape_idx) const override; virtual Transform3D area_get_shape_transform(RID p_area, int p_shape_idx) const override;
virtual void area_remove_shape(RID p_area, int p_shape_idx) override; virtual void area_remove_shape(RID p_area, int p_shape_idx) override;
virtual void area_clear_shapes(RID p_area) override; virtual void area_clear_shapes(RID p_area) override;
virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) override; virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) override;
@ -153,8 +153,8 @@ public:
virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) override; virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) override;
virtual Variant area_get_param(RID p_area, AreaParameter p_param) const override; virtual Variant area_get_param(RID p_area, AreaParameter p_param) const override;
virtual void area_set_transform(RID p_area, const Transform &p_transform) override; virtual void area_set_transform(RID p_area, const Transform3D &p_transform) override;
virtual Transform area_get_transform(RID p_area) const override; virtual Transform3D area_get_transform(RID p_area) const override;
virtual void area_set_collision_mask(RID p_area, uint32_t p_mask) override; virtual void area_set_collision_mask(RID p_area, uint32_t p_mask) override;
virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) override; virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) override;
@ -174,14 +174,14 @@ public:
virtual void body_set_mode(RID p_body, BodyMode p_mode) override; virtual void body_set_mode(RID p_body, BodyMode p_mode) override;
virtual BodyMode body_get_mode(RID p_body) const override; virtual BodyMode body_get_mode(RID p_body) const override;
virtual void body_add_shape(RID p_body, RID p_shape, const Transform &p_transform = Transform(), bool p_disabled = false) override; virtual void body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) override;
// Not supported, Please remove and add new shape // Not supported, Please remove and add new shape
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override; virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override;
virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) override; virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform3D &p_transform) override;
virtual int body_get_shape_count(RID p_body) const override; virtual int body_get_shape_count(RID p_body) const override;
virtual RID body_get_shape(RID p_body, int p_shape_idx) const override; virtual RID body_get_shape(RID p_body, int p_shape_idx) const override;
virtual Transform body_get_shape_transform(RID p_body, int p_shape_idx) const override; virtual Transform3D body_get_shape_transform(RID p_body, int p_shape_idx) const override;
virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) override; virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) override;
@ -253,8 +253,8 @@ public:
// this function only works on physics process, errors and returns null otherwise // this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override; virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override;
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override; virtual bool body_test_motion(RID p_body, const Transform3D &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override;
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) override; virtual int body_test_ray_separation(RID p_body, const Transform3D &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) override;
/* SOFT BODY API */ /* SOFT BODY API */
@ -283,7 +283,7 @@ public:
virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const override; virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const override;
/// Special function. This function has bad performance /// Special function. This function has bad performance
virtual void soft_body_set_transform(RID p_body, const Transform &p_transform) override; virtual void soft_body_set_transform(RID p_body, const Transform3D &p_transform) override;
virtual void soft_body_set_ray_pickable(RID p_body, bool p_enable) override; virtual void soft_body_set_ray_pickable(RID p_body, bool p_enable) override;
@ -333,7 +333,7 @@ public:
virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) override; virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) override;
virtual Vector3 pin_joint_get_local_b(RID p_joint) const override; virtual Vector3 pin_joint_get_local_b(RID p_joint) const override;
virtual RID joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) override; virtual RID joint_create_hinge(RID p_body_A, const Transform3D &p_hinge_A, RID p_body_B, const Transform3D &p_hinge_B) override;
virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) override; virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) override;
virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) override; virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) override;
@ -343,19 +343,19 @@ public:
virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const override; virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const override;
/// Reference frame is A /// Reference frame is A
virtual RID joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override; virtual RID joint_create_slider(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override;
virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) override; virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) override;
virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override; virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override;
/// Reference frame is A /// Reference frame is A
virtual RID joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override; virtual RID joint_create_cone_twist(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override;
virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) override; virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) override;
virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override; virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override;
/// Reference frame is A /// Reference frame is A
virtual RID joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override; virtual RID joint_create_generic_6dof(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override;
virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) override; virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) override;
virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) override; virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) override;

View File

@ -59,7 +59,7 @@ void INVERT_B_TO_G(btMatrix3x3 const &inVal, Basis &outVal) {
INVERT_B_TO_G(inVal[2], outVal[2]); INVERT_B_TO_G(inVal[2], outVal[2]);
} }
void B_TO_G(btTransform const &inVal, Transform &outVal) { void B_TO_G(btTransform const &inVal, Transform3D &outVal) {
B_TO_G(inVal.getBasis(), outVal.basis); B_TO_G(inVal.getBasis(), outVal.basis);
B_TO_G(inVal.getOrigin(), outVal.origin); B_TO_G(inVal.getOrigin(), outVal.origin);
} }
@ -89,7 +89,7 @@ void INVERT_G_TO_B(Basis const &inVal, btMatrix3x3 &outVal) {
INVERT_G_TO_B(inVal[2], outVal[2]); INVERT_G_TO_B(inVal[2], outVal[2]);
} }
void G_TO_B(Transform const &inVal, btTransform &outVal) { void G_TO_B(Transform3D const &inVal, btTransform &outVal) {
G_TO_B(inVal.basis, outVal.getBasis()); G_TO_B(inVal.basis, outVal.getBasis());
G_TO_B(inVal.origin, outVal.getOrigin()); G_TO_B(inVal.origin, outVal.getOrigin());
} }

View File

@ -49,14 +49,14 @@ extern void B_TO_G(btVector3 const &inVal, Vector3 &outVal);
extern void INVERT_B_TO_G(btVector3 const &inVal, Vector3 &outVal); extern void INVERT_B_TO_G(btVector3 const &inVal, Vector3 &outVal);
extern void B_TO_G(btMatrix3x3 const &inVal, Basis &outVal); extern void B_TO_G(btMatrix3x3 const &inVal, Basis &outVal);
extern void INVERT_B_TO_G(btMatrix3x3 const &inVal, Basis &outVal); extern void INVERT_B_TO_G(btMatrix3x3 const &inVal, Basis &outVal);
extern void B_TO_G(btTransform const &inVal, Transform &outVal); extern void B_TO_G(btTransform const &inVal, Transform3D &outVal);
// Godot TO Bullet // Godot TO Bullet
extern void G_TO_B(Vector3 const &inVal, btVector3 &outVal); extern void G_TO_B(Vector3 const &inVal, btVector3 &outVal);
extern void INVERT_G_TO_B(Vector3 const &inVal, btVector3 &outVal); extern void INVERT_G_TO_B(Vector3 const &inVal, btVector3 &outVal);
extern void G_TO_B(Basis const &inVal, btMatrix3x3 &outVal); extern void G_TO_B(Basis const &inVal, btMatrix3x3 &outVal);
extern void INVERT_G_TO_B(Basis const &inVal, btMatrix3x3 &outVal); extern void INVERT_G_TO_B(Basis const &inVal, btMatrix3x3 &outVal);
extern void G_TO_B(Transform const &inVal, btTransform &outVal); extern void G_TO_B(Transform3D const &inVal, btTransform &outVal);
extern void UNSCALE_BT_BASIS(btTransform &scaledBasis); extern void UNSCALE_BT_BASIS(btTransform &scaledBasis);
#endif #endif

View File

@ -49,7 +49,7 @@
CollisionObjectBullet::ShapeWrapper::~ShapeWrapper() {} CollisionObjectBullet::ShapeWrapper::~ShapeWrapper() {}
void CollisionObjectBullet::ShapeWrapper::set_transform(const Transform &p_transform) { void CollisionObjectBullet::ShapeWrapper::set_transform(const Transform3D &p_transform) {
G_TO_B(p_transform.get_basis().get_scale_abs(), scale); G_TO_B(p_transform.get_basis().get_scale_abs(), scale);
G_TO_B(p_transform, transform); G_TO_B(p_transform, transform);
UNSCALE_BT_BASIS(transform); UNSCALE_BT_BASIS(transform);
@ -193,7 +193,7 @@ int CollisionObjectBullet::get_godot_object_flags() const {
return bt_collision_object->getUserIndex2(); return bt_collision_object->getUserIndex2();
} }
void CollisionObjectBullet::set_transform(const Transform &p_global_transform) { void CollisionObjectBullet::set_transform(const Transform3D &p_global_transform) {
set_body_scale(p_global_transform.basis.get_scale_abs()); set_body_scale(p_global_transform.basis.get_scale_abs());
btTransform bt_transform; btTransform bt_transform;
@ -203,8 +203,8 @@ void CollisionObjectBullet::set_transform(const Transform &p_global_transform) {
set_transform__bullet(bt_transform); set_transform__bullet(bt_transform);
} }
Transform CollisionObjectBullet::get_transform() const { Transform3D CollisionObjectBullet::get_transform() const {
Transform t; Transform3D t;
B_TO_G(get_transform__bullet(), t); B_TO_G(get_transform__bullet(), t);
t.basis.scale(body_scale); t.basis.scale(body_scale);
return t; return t;
@ -230,7 +230,7 @@ RigidCollisionObjectBullet::~RigidCollisionObjectBullet() {
} }
} }
void RigidCollisionObjectBullet::add_shape(ShapeBullet *p_shape, const Transform &p_transform, bool p_disabled) { void RigidCollisionObjectBullet::add_shape(ShapeBullet *p_shape, const Transform3D &p_transform, bool p_disabled) {
shapes.push_back(ShapeWrapper(p_shape, p_transform, !p_disabled)); shapes.push_back(ShapeWrapper(p_shape, p_transform, !p_disabled));
p_shape->add_owner(this); p_shape->add_owner(this);
reload_shapes(); reload_shapes();
@ -296,7 +296,7 @@ void RigidCollisionObjectBullet::remove_all_shapes(bool p_permanentlyFromThisBod
} }
} }
void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transform &p_transform) { void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transform3D &p_transform) {
ERR_FAIL_INDEX(p_index, get_shape_count()); ERR_FAIL_INDEX(p_index, get_shape_count());
shapes.write[p_index].set_transform(p_transform); shapes.write[p_index].set_transform(p_transform);
@ -307,8 +307,8 @@ const btTransform &RigidCollisionObjectBullet::get_bt_shape_transform(int p_inde
return shapes[p_index].transform; return shapes[p_index].transform;
} }
Transform RigidCollisionObjectBullet::get_shape_transform(int p_index) const { Transform3D RigidCollisionObjectBullet::get_shape_transform(int p_index) const {
Transform trs; Transform3D trs;
B_TO_G(shapes[p_index].transform, trs); B_TO_G(shapes[p_index].transform, trs);
return trs; return trs;
} }

View File

@ -83,7 +83,7 @@ public:
set_transform(p_transform); set_transform(p_transform);
} }
ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) : ShapeWrapper(ShapeBullet *p_shape, const Transform3D &p_transform, bool p_active) :
shape(p_shape), shape(p_shape),
active(p_active) { active(p_active) {
set_transform(p_transform); set_transform(p_transform);
@ -102,7 +102,7 @@ public:
active = otherShape.active; active = otherShape.active;
} }
void set_transform(const Transform &p_transform); void set_transform(const Transform3D &p_transform);
void set_transform(const btTransform &p_transform); void set_transform(const btTransform &p_transform);
btTransform get_adjusted_transform() const; btTransform get_adjusted_transform() const;
@ -202,8 +202,8 @@ public:
void set_godot_object_flags(int flags); void set_godot_object_flags(int flags);
int get_godot_object_flags() const; int get_godot_object_flags() const;
void set_transform(const Transform &p_global_transform); void set_transform(const Transform3D &p_global_transform);
Transform get_transform() const; Transform3D get_transform() const;
virtual void set_transform__bullet(const btTransform &p_global_transform); virtual void set_transform__bullet(const btTransform &p_global_transform);
virtual const btTransform &get_transform__bullet() const; virtual const btTransform &get_transform__bullet() const;
@ -225,7 +225,7 @@ public:
_FORCE_INLINE_ btCollisionShape *get_main_shape() const { return mainShape; } _FORCE_INLINE_ btCollisionShape *get_main_shape() const { return mainShape; }
void add_shape(ShapeBullet *p_shape, const Transform &p_transform = Transform(), bool p_disabled = false); void add_shape(ShapeBullet *p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false);
void set_shape(int p_index, ShapeBullet *p_shape); void set_shape(int p_index, ShapeBullet *p_shape);
int get_shape_count() const; int get_shape_count() const;
@ -238,10 +238,10 @@ public:
void remove_shape_full(int p_index); void remove_shape_full(int p_index);
void remove_all_shapes(bool p_permanentlyFromThisBody = false, bool p_force_not_reload = false); void remove_all_shapes(bool p_permanentlyFromThisBody = false, bool p_force_not_reload = false);
void set_shape_transform(int p_index, const Transform &p_transform); void set_shape_transform(int p_index, const Transform3D &p_transform);
const btTransform &get_bt_shape_transform(int p_index) const; const btTransform &get_bt_shape_transform(int p_index) const;
Transform get_shape_transform(int p_index) const; Transform3D get_shape_transform(int p_index) const;
void set_shape_disabled(int p_index, bool p_disabled); void set_shape_disabled(int p_index, bool p_disabled);
bool is_shape_disabled(int p_index); bool is_shape_disabled(int p_index);

View File

@ -40,16 +40,16 @@
@author AndreaCatania @author AndreaCatania
*/ */
ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &rbAFrame, const Transform3D &rbBFrame) :
JointBullet() { JointBullet() {
Transform scaled_AFrame(rbAFrame.scaled(rbA->get_body_scale())); Transform3D scaled_AFrame(rbAFrame.scaled(rbA->get_body_scale()));
scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis);
btTransform btFrameA; btTransform btFrameA;
G_TO_B(scaled_AFrame, btFrameA); G_TO_B(scaled_AFrame, btFrameA);
if (rbB) { if (rbB) {
Transform scaled_BFrame(rbBFrame.scaled(rbB->get_body_scale())); Transform3D scaled_BFrame(rbBFrame.scaled(rbB->get_body_scale()));
scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis);
btTransform btFrameB; btTransform btFrameB;

View File

@ -43,7 +43,7 @@ class ConeTwistJointBullet : public JointBullet {
class btConeTwistConstraint *coneConstraint; class btConeTwistConstraint *coneConstraint;
public: public:
ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame); ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &rbAFrame, const Transform3D &rbBFrame);
virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; } virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; }

View File

@ -40,7 +40,7 @@
@author AndreaCatania @author AndreaCatania
*/ */
Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameInA, const Transform3D &frameInB) :
JointBullet() { JointBullet() {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) { for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) {
@ -48,7 +48,7 @@ Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBu
} }
} }
Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale())); Transform3D scaled_AFrame(frameInA.scaled(rbA->get_body_scale()));
scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis);
@ -56,7 +56,7 @@ Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBu
G_TO_B(scaled_AFrame, btFrameA); G_TO_B(scaled_AFrame, btFrameA);
if (rbB) { if (rbB) {
Transform scaled_BFrame(frameInB.scaled(rbB->get_body_scale())); Transform3D scaled_BFrame(frameInB.scaled(rbB->get_body_scale()));
scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis);
@ -71,30 +71,30 @@ Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBu
setup(sixDOFConstraint); setup(sixDOFConstraint);
} }
Transform Generic6DOFJointBullet::getFrameOffsetA() const { Transform3D Generic6DOFJointBullet::getFrameOffsetA() const {
btTransform btTrs = sixDOFConstraint->getFrameOffsetA(); btTransform btTrs = sixDOFConstraint->getFrameOffsetA();
Transform gTrs; Transform3D gTrs;
B_TO_G(btTrs, gTrs); B_TO_G(btTrs, gTrs);
return gTrs; return gTrs;
} }
Transform Generic6DOFJointBullet::getFrameOffsetB() const { Transform3D Generic6DOFJointBullet::getFrameOffsetB() const {
btTransform btTrs = sixDOFConstraint->getFrameOffsetB(); btTransform btTrs = sixDOFConstraint->getFrameOffsetB();
Transform gTrs; Transform3D gTrs;
B_TO_G(btTrs, gTrs); B_TO_G(btTrs, gTrs);
return gTrs; return gTrs;
} }
Transform Generic6DOFJointBullet::getFrameOffsetA() { Transform3D Generic6DOFJointBullet::getFrameOffsetA() {
btTransform btTrs = sixDOFConstraint->getFrameOffsetA(); btTransform btTrs = sixDOFConstraint->getFrameOffsetA();
Transform gTrs; Transform3D gTrs;
B_TO_G(btTrs, gTrs); B_TO_G(btTrs, gTrs);
return gTrs; return gTrs;
} }
Transform Generic6DOFJointBullet::getFrameOffsetB() { Transform3D Generic6DOFJointBullet::getFrameOffsetB() {
btTransform btTrs = sixDOFConstraint->getFrameOffsetB(); btTransform btTrs = sixDOFConstraint->getFrameOffsetB();
Transform gTrs; Transform3D gTrs;
B_TO_G(btTrs, gTrs); B_TO_G(btTrs, gTrs);
return gTrs; return gTrs;
} }

View File

@ -48,14 +48,14 @@ class Generic6DOFJointBullet : public JointBullet {
bool flags[3][PhysicsServer3D::G6DOF_JOINT_FLAG_MAX]; bool flags[3][PhysicsServer3D::G6DOF_JOINT_FLAG_MAX];
public: public:
Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB); Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameInA, const Transform3D &frameInB);
virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; } virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; }
Transform getFrameOffsetA() const; Transform3D getFrameOffsetA() const;
Transform getFrameOffsetB() const; Transform3D getFrameOffsetB() const;
Transform getFrameOffsetA(); Transform3D getFrameOffsetA();
Transform getFrameOffsetB(); Transform3D getFrameOffsetB();
void set_linear_lower_limit(const Vector3 &linearLower); void set_linear_lower_limit(const Vector3 &linearLower);
void set_linear_upper_limit(const Vector3 &linearUpper); void set_linear_upper_limit(const Vector3 &linearUpper);

View File

@ -40,16 +40,16 @@
@author AndreaCatania @author AndreaCatania
*/ */
HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB) : HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameA, const Transform3D &frameB) :
JointBullet() { JointBullet() {
Transform scaled_AFrame(frameA.scaled(rbA->get_body_scale())); Transform3D scaled_AFrame(frameA.scaled(rbA->get_body_scale()));
scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis);
btTransform btFrameA; btTransform btFrameA;
G_TO_B(scaled_AFrame, btFrameA); G_TO_B(scaled_AFrame, btFrameA);
if (rbB) { if (rbB) {
Transform scaled_BFrame(frameB.scaled(rbB->get_body_scale())); Transform3D scaled_BFrame(frameB.scaled(rbB->get_body_scale()));
scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis);
btTransform btFrameB; btTransform btFrameB;

View File

@ -41,7 +41,7 @@ class HingeJointBullet : public JointBullet {
class btHingeConstraint *hingeConstraint; class btHingeConstraint *hingeConstraint;
public: public:
HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB); HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameA, const Transform3D &frameB);
HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB); HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);
virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; } virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; }

View File

@ -106,11 +106,11 @@ Vector3 BulletPhysicsDirectBodyState3D::get_angular_velocity() const {
return body->get_angular_velocity(); return body->get_angular_velocity();
} }
void BulletPhysicsDirectBodyState3D::set_transform(const Transform &p_transform) { void BulletPhysicsDirectBodyState3D::set_transform(const Transform3D &p_transform) {
body->set_transform(p_transform); body->set_transform(p_transform);
} }
Transform BulletPhysicsDirectBodyState3D::get_transform() const { Transform3D BulletPhysicsDirectBodyState3D::get_transform() const {
return body->get_transform(); return body->get_transform();
} }

View File

@ -107,8 +107,8 @@ public:
virtual void set_angular_velocity(const Vector3 &p_velocity) override; virtual void set_angular_velocity(const Vector3 &p_velocity) override;
virtual Vector3 get_angular_velocity() const override; virtual Vector3 get_angular_velocity() const override;
virtual void set_transform(const Transform &p_transform) override; virtual void set_transform(const Transform3D &p_transform) override;
virtual Transform get_transform() const override; virtual Transform3D get_transform() const override;
virtual void add_central_force(const Vector3 &p_force) override; virtual void add_central_force(const Vector3 &p_force) override;
virtual void add_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) override; virtual void add_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) override;

View File

@ -40,16 +40,16 @@
@author AndreaCatania @author AndreaCatania
*/ */
SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameInA, const Transform3D &frameInB) :
JointBullet() { JointBullet() {
Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale())); Transform3D scaled_AFrame(frameInA.scaled(rbA->get_body_scale()));
scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis);
btTransform btFrameA; btTransform btFrameA;
G_TO_B(scaled_AFrame, btFrameA); G_TO_B(scaled_AFrame, btFrameA);
if (rbB) { if (rbB) {
Transform scaled_BFrame(frameInB.scaled(rbB->get_body_scale())); Transform3D scaled_BFrame(frameInB.scaled(rbB->get_body_scale()));
scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis);
btTransform btFrameB; btTransform btFrameB;
@ -70,44 +70,44 @@ const RigidBodyBullet *SliderJointBullet::getRigidBodyB() const {
return static_cast<RigidBodyBullet *>(sliderConstraint->getRigidBodyB().getUserPointer()); return static_cast<RigidBodyBullet *>(sliderConstraint->getRigidBodyB().getUserPointer());
} }
const Transform SliderJointBullet::getCalculatedTransformA() const { const Transform3D SliderJointBullet::getCalculatedTransformA() const {
btTransform btTransform = sliderConstraint->getCalculatedTransformA(); btTransform btTransform = sliderConstraint->getCalculatedTransformA();
Transform gTrans; Transform3D gTrans;
B_TO_G(btTransform, gTrans); B_TO_G(btTransform, gTrans);
return gTrans; return gTrans;
} }
const Transform SliderJointBullet::getCalculatedTransformB() const { const Transform3D SliderJointBullet::getCalculatedTransformB() const {
btTransform btTransform = sliderConstraint->getCalculatedTransformB(); btTransform btTransform = sliderConstraint->getCalculatedTransformB();
Transform gTrans; Transform3D gTrans;
B_TO_G(btTransform, gTrans); B_TO_G(btTransform, gTrans);
return gTrans; return gTrans;
} }
const Transform SliderJointBullet::getFrameOffsetA() const { const Transform3D SliderJointBullet::getFrameOffsetA() const {
btTransform btTransform = sliderConstraint->getFrameOffsetA(); btTransform btTransform = sliderConstraint->getFrameOffsetA();
Transform gTrans; Transform3D gTrans;
B_TO_G(btTransform, gTrans); B_TO_G(btTransform, gTrans);
return gTrans; return gTrans;
} }
const Transform SliderJointBullet::getFrameOffsetB() const { const Transform3D SliderJointBullet::getFrameOffsetB() const {
btTransform btTransform = sliderConstraint->getFrameOffsetB(); btTransform btTransform = sliderConstraint->getFrameOffsetB();
Transform gTrans; Transform3D gTrans;
B_TO_G(btTransform, gTrans); B_TO_G(btTransform, gTrans);
return gTrans; return gTrans;
} }
Transform SliderJointBullet::getFrameOffsetA() { Transform3D SliderJointBullet::getFrameOffsetA() {
btTransform btTransform = sliderConstraint->getFrameOffsetA(); btTransform btTransform = sliderConstraint->getFrameOffsetA();
Transform gTrans; Transform3D gTrans;
B_TO_G(btTransform, gTrans); B_TO_G(btTransform, gTrans);
return gTrans; return gTrans;
} }
Transform SliderJointBullet::getFrameOffsetB() { Transform3D SliderJointBullet::getFrameOffsetB() {
btTransform btTransform = sliderConstraint->getFrameOffsetB(); btTransform btTransform = sliderConstraint->getFrameOffsetB();
Transform gTrans; Transform3D gTrans;
B_TO_G(btTransform, gTrans); B_TO_G(btTransform, gTrans);
return gTrans; return gTrans;
} }

View File

@ -44,18 +44,18 @@ class SliderJointBullet : public JointBullet {
public: public:
/// Reference frame is A /// Reference frame is A
SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB); SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameInA, const Transform3D &frameInB);
virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; } virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; }
const RigidBodyBullet *getRigidBodyA() const; const RigidBodyBullet *getRigidBodyA() const;
const RigidBodyBullet *getRigidBodyB() const; const RigidBodyBullet *getRigidBodyB() const;
const Transform getCalculatedTransformA() const; const Transform3D getCalculatedTransformA() const;
const Transform getCalculatedTransformB() const; const Transform3D getCalculatedTransformB() const;
const Transform getFrameOffsetA() const; const Transform3D getFrameOffsetA() const;
const Transform getFrameOffsetB() const; const Transform3D getFrameOffsetB() const;
Transform getFrameOffsetA(); Transform3D getFrameOffsetA();
Transform getFrameOffsetB(); Transform3D getFrameOffsetB();
real_t getLowerLinLimit() const; real_t getLowerLinLimit() const;
void setLowerLinLimit(real_t lowerLimit); void setLowerLinLimit(real_t lowerLimit);
real_t getUpperLinLimit() const; real_t getUpperLinLimit() const;

View File

@ -136,7 +136,7 @@ void SoftBodyBullet::destroy_soft_body() {
bt_soft_body = nullptr; bt_soft_body = nullptr;
} }
void SoftBodyBullet::set_soft_transform(const Transform &p_transform) { void SoftBodyBullet::set_soft_transform(const Transform3D &p_transform) {
reset_all_node_positions(); reset_all_node_positions();
move_all_nodes(p_transform); move_all_nodes(p_transform);
} }
@ -159,7 +159,7 @@ AABB SoftBodyBullet::get_bounds() const {
return aabb; return aabb;
} }
void SoftBodyBullet::move_all_nodes(const Transform &p_transform) { void SoftBodyBullet::move_all_nodes(const Transform3D &p_transform) {
if (!bt_soft_body) { if (!bt_soft_body) {
return; return;
} }

View File

@ -104,11 +104,11 @@ public:
void destroy_soft_body(); void destroy_soft_body();
// Special function. This function has bad performance // Special function. This function has bad performance
void set_soft_transform(const Transform &p_transform); void set_soft_transform(const Transform3D &p_transform);
AABB get_bounds() const; AABB get_bounds() const;
void move_all_nodes(const Transform &p_transform); void move_all_nodes(const Transform3D &p_transform);
void set_node_position(int node_index, const Vector3 &p_global_position); void set_node_position(int node_index, const Vector3 &p_global_position);
void set_node_position(int node_index, const btVector3 &p_global_position); void set_node_position(int node_index, const btVector3 &p_global_position);
void get_node_position(int node_index, Vector3 &r_position) const; void get_node_position(int node_index, Vector3 &r_position) const;

View File

@ -117,7 +117,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
} }
} }
int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform3D &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (p_result_max <= 0) { if (p_result_max <= 0) {
return 0; return 0;
} }
@ -152,7 +152,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
return btQuery.m_count; return btQuery.m_count;
} }
bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) { bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform3D &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
r_closest_safe = 0.0f; r_closest_safe = 0.0f;
r_closest_unsafe = 0.0f; r_closest_unsafe = 0.0f;
btVector3 bt_motion; btVector3 bt_motion;
@ -214,7 +214,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
} }
/// Returns the list of contacts pairs in this order: Local contact, other body contact /// Returns the list of contacts pairs in this order: Local contact, other body contact
bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform3D &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (p_result_max <= 0) { if (p_result_max <= 0) {
return false; return false;
} }
@ -250,7 +250,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
return btQuery.m_count; return btQuery.m_count;
} }
bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform3D &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
ERR_FAIL_COND_V(!shape, false); ERR_FAIL_COND_V(!shape, false);
@ -908,7 +908,7 @@ static Ref<StandardMaterial3D> red_mat;
static Ref<StandardMaterial3D> blue_mat; static Ref<StandardMaterial3D> blue_mat;
#endif #endif
bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) { bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform3D &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
#if debug_test_motion #if debug_test_motion
/// Yes I know this is not good, but I've used it as fast debugging hack. /// Yes I know this is not good, but I've used it as fast debugging hack.
/// I'm leaving it here just for speedup the other eventual debugs /// I'm leaving it here just for speedup the other eventual debugs
@ -1062,7 +1062,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
return has_penetration; return has_penetration;
} }
int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) { int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform3D &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) {
btTransform body_transform; btTransform body_transform;
G_TO_B(p_transform, body_transform); G_TO_B(p_transform, body_transform);
UNSCALE_BT_BASIS(body_transform); UNSCALE_BT_BASIS(body_transform);

View File

@ -78,11 +78,11 @@ public:
virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false) override; virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false) override;
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; virtual int intersect_shape(const RID &p_shape, const Transform3D &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) override; virtual bool cast_motion(const RID &p_shape, const Transform3D &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) override;
/// Returns the list of contacts pairs in this order: Local contact, other body contact /// Returns the list of contacts pairs in this order: Local contact, other body contact
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; virtual bool collide_shape(RID p_shape, const Transform3D &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; virtual bool rest_info(RID p_shape, const Transform3D &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override; virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override;
}; };
@ -188,8 +188,8 @@ public:
real_t get_linear_damp() const { return linear_damp; } real_t get_linear_damp() const { return linear_damp; }
real_t get_angular_damp() const { return angular_damp; } real_t get_angular_damp() const { return angular_damp; }
bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes); bool test_body_motion(RigidBodyBullet *p_body, const Transform3D &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes);
int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin); int test_ray_separation(RigidBodyBullet *p_body, const Transform3D &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin);
private: private:
void create_empty_world(bool p_create_soft_world); void create_empty_world(bool p_create_soft_world);

View File

@ -265,7 +265,7 @@ void CSGBrush::build_from_faces(const Vector<Vector3> &p_vertices, const Vector<
_regen_face_aabbs(); _regen_face_aabbs();
} }
void CSGBrush::copy_from(const CSGBrush &p_brush, const Transform &p_xform) { void CSGBrush::copy_from(const CSGBrush &p_brush, const Transform3D &p_xform) {
faces = p_brush.faces; faces = p_brush.faces;
materials = p_brush.materials; materials = p_brush.materials;

View File

@ -60,7 +60,7 @@ struct CSGBrush {
// Create a brush from faces. // Create a brush from faces.
void build_from_faces(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uvs, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials, const Vector<bool> &p_invert_faces); void build_from_faces(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uvs, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials, const Vector<bool> &p_invert_faces);
void copy_from(const CSGBrush &p_brush, const Transform &p_xform); void copy_from(const CSGBrush &p_brush, const Transform3D &p_xform);
}; };
struct CSGBrushOperation { struct CSGBrushOperation {
@ -165,8 +165,8 @@ struct CSGBrushOperation {
Vector<Vertex2D> vertices; Vector<Vertex2D> vertices;
Vector<Face2D> faces; Vector<Face2D> faces;
Plane plane; Plane plane;
Transform to_2D; Transform3D to_2D;
Transform to_3D; Transform3D to_3D;
float vertex_snap2 = 0.0; float vertex_snap2 = 0.0;
inline int _get_point_idx(const Vector2 &p_point); inline int _get_point_idx(const Vector2 &p_point);

View File

@ -99,9 +99,9 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int
void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
Transform gt = cs->get_global_transform(); Transform3D gt = cs->get_global_transform();
//gt.orthonormalize(); //gt.orthonormalize();
Transform gi = gt.affine_inverse(); Transform3D gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point);

View File

@ -578,7 +578,7 @@ Array CSGShape3D::get_meshes() const {
if (root_mesh.is_valid()) { if (root_mesh.is_valid()) {
Array arr; Array arr;
arr.resize(2); arr.resize(2);
arr[0] = Transform(); arr[0] = Transform3D();
arr[1] = root_mesh; arr[1] = root_mesh;
return arr; return arr;
} }
@ -1978,13 +1978,13 @@ CSGBrush *CSGPolygon3D::_build_brush() {
float u1 = 0.0; float u1 = 0.0;
float u2 = path_continuous_u ? 0.0 : 1.0; float u2 = path_continuous_u ? 0.0 : 1.0;
Transform path_to_this; Transform3D path_to_this;
if (!path_local) { if (!path_local) {
// center on paths origin // center on paths origin
path_to_this = get_global_transform().affine_inverse() * path->get_global_transform(); path_to_this = get_global_transform().affine_inverse() * path->get_global_transform();
} }
Transform prev_xf; Transform3D prev_xf;
Vector3 lookat_dir; Vector3 lookat_dir;
@ -2006,7 +2006,7 @@ CSGBrush *CSGPolygon3D::_build_brush() {
ofs = 0.0; ofs = 0.0;
} }
Transform xf; Transform3D xf;
xf.origin = curve->interpolate_baked(ofs); xf.origin = curve->interpolate_baked(ofs);
Vector3 local_dir; Vector3 local_dir;

View File

@ -79,23 +79,23 @@ enum RotOrder {
// references: ComputePivotTransform / run the calculation // references: ComputePivotTransform / run the calculation
// This is the local pivot transform for the node, not the global transforms // This is the local pivot transform for the node, not the global transforms
Transform ComputePivotTransform( Transform ComputePivotTransform(
Transform chain[TransformationComp_MAXIMUM], Transform3D chain[TransformationComp_MAXIMUM],
Transform &geometric_transform) { Transform3D &geometric_transform) {
// Maya pivots // Maya pivots
Transform T = chain[TransformationComp_Translation]; Transform3D T = chain[TransformationComp_Translation];
Transform Roff = chain[TransformationComp_RotationOffset]; Transform3D Roff = chain[TransformationComp_RotationOffset];
Transform Rp = chain[TransformationComp_RotationPivot]; Transform3D Rp = chain[TransformationComp_RotationPivot];
Transform Rpre = chain[TransformationComp_PreRotation]; Transform3D Rpre = chain[TransformationComp_PreRotation];
Transform R = chain[TransformationComp_Rotation]; Transform3D R = chain[TransformationComp_Rotation];
Transform Rpost = chain[TransformationComp_PostRotation]; Transform3D Rpost = chain[TransformationComp_PostRotation];
Transform Soff = chain[TransformationComp_ScalingOffset]; Transform3D Soff = chain[TransformationComp_ScalingOffset];
Transform Sp = chain[TransformationComp_ScalingPivot]; Transform3D Sp = chain[TransformationComp_ScalingPivot];
Transform S = chain[TransformationComp_Scaling]; Transform3D S = chain[TransformationComp_Scaling];
// 3DS Max Pivots // 3DS Max Pivots
Transform OT = chain[TransformationComp_GeometricTranslation]; Transform3D OT = chain[TransformationComp_GeometricTranslation];
Transform OR = chain[TransformationComp_GeometricRotation]; Transform3D OR = chain[TransformationComp_GeometricRotation];
Transform OS = chain[TransformationComp_GeometricScaling]; Transform3D OS = chain[TransformationComp_GeometricScaling];
// Calculate 3DS max pivot transform - use geometric space (e.g doesn't effect children nodes only the current node) // Calculate 3DS max pivot transform - use geometric space (e.g doesn't effect children nodes only the current node)
geometric_transform = OT * OR * OS; geometric_transform = OT * OR * OS;

View File

@ -116,8 +116,8 @@ void PivotTransform::ReadTransformChain() {
} }
} }
Transform PivotTransform::ComputeLocalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const { Transform3D PivotTransform::ComputeLocalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const {
Transform T, Roff, Rp, Soff, Sp, S; Transform3D T, Roff, Rp, Soff, Sp, S;
// Here I assume this is the operation which needs done. // Here I assume this is the operation which needs done.
// Its WorldTransform * V // Its WorldTransform * V
@ -132,29 +132,29 @@ Transform PivotTransform::ComputeLocalTransform(Vector3 p_translation, Quat p_ro
// Scaling node // Scaling node
S.scale(p_scaling); S.scale(p_scaling);
// Rotation pivots // Rotation pivots
Transform Rpre = Transform(pre_rotation); Transform3D Rpre = Transform3D(pre_rotation);
Transform R = Transform(p_rotation); Transform3D R = Transform3D(p_rotation);
Transform Rpost = Transform(post_rotation); Transform3D Rpost = Transform3D(post_rotation);
return T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse(); return T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
} }
Transform PivotTransform::ComputeGlobalTransform(Transform t) const { Transform3D PivotTransform::ComputeGlobalTransform(Transform3D t) const {
Vector3 pos = t.origin; Vector3 pos = t.origin;
Vector3 scale = t.basis.get_scale(); Vector3 scale = t.basis.get_scale();
Quat rot = t.basis.get_rotation_quat(); Quat rot = t.basis.get_rotation_quat();
return ComputeGlobalTransform(pos, rot, scale); return ComputeGlobalTransform(pos, rot, scale);
} }
Transform PivotTransform::ComputeLocalTransform(Transform t) const { Transform3D PivotTransform::ComputeLocalTransform(Transform3D t) const {
Vector3 pos = t.origin; Vector3 pos = t.origin;
Vector3 scale = t.basis.get_scale(); Vector3 scale = t.basis.get_scale();
Quat rot = t.basis.get_rotation_quat(); Quat rot = t.basis.get_rotation_quat();
return ComputeLocalTransform(pos, rot, scale); return ComputeLocalTransform(pos, rot, scale);
} }
Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const { Transform3D PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const {
Transform T, Roff, Rp, Soff, Sp, S; Transform3D T, Roff, Rp, Soff, Sp, S;
// Here I assume this is the operation which needs done. // Here I assume this is the operation which needs done.
// Its WorldTransform * V // Its WorldTransform * V
@ -170,26 +170,26 @@ Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_r
S.scale(p_scaling); S.scale(p_scaling);
// Rotation pivots // Rotation pivots
Transform Rpre = Transform(pre_rotation); Transform3D Rpre = Transform3D(pre_rotation);
Transform R = Transform(p_rotation); Transform3D R = Transform3D(p_rotation);
Transform Rpost = Transform(post_rotation); Transform3D Rpost = Transform3D(post_rotation);
Transform parent_global_xform; Transform3D parent_global_xform;
Transform parent_local_scaling_m; Transform3D parent_local_scaling_m;
if (parent_transform.is_valid()) { if (parent_transform.is_valid()) {
parent_global_xform = parent_transform->GlobalTransform; parent_global_xform = parent_transform->GlobalTransform;
parent_local_scaling_m = parent_transform->Local_Scaling_Matrix; parent_local_scaling_m = parent_transform->Local_Scaling_Matrix;
} }
Transform local_rotation_m, parent_global_rotation_m; Transform3D local_rotation_m, parent_global_rotation_m;
Quat parent_global_rotation = parent_global_xform.basis.get_rotation_quat(); Quat parent_global_rotation = parent_global_xform.basis.get_rotation_quat();
parent_global_rotation_m.basis.set_quat(parent_global_rotation); parent_global_rotation_m.basis.set_quat(parent_global_rotation);
local_rotation_m = Rpre * R * Rpost; local_rotation_m = Rpre * R * Rpost;
//Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quat().normalized()); //Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quat().normalized());
Transform local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation; Transform3D local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation;
Vector3 parent_translation = parent_global_xform.get_origin(); Vector3 parent_translation = parent_global_xform.get_origin();
parent_shear_translation.origin = parent_translation; parent_shear_translation.origin = parent_translation;
parent_shear_rotation = parent_shear_translation.affine_inverse() * parent_global_xform; parent_shear_rotation = parent_shear_translation.affine_inverse() * parent_global_xform;
@ -197,26 +197,26 @@ Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_r
local_shear_scaling = S; local_shear_scaling = S;
// Inherit type handler - we don't care about T here, just reordering RSrs etc. // Inherit type handler - we don't care about T here, just reordering RSrs etc.
Transform global_rotation_scale; Transform3D global_rotation_scale;
if (inherit_type == FBXDocParser::Transform_RrSs) { if (inherit_type == FBXDocParser::Transform_RrSs) {
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_shear_scaling * local_shear_scaling; global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_shear_scaling * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_RSrs) { } else if (inherit_type == FBXDocParser::Transform_RSrs) {
global_rotation_scale = parent_global_rotation_m * parent_shear_scaling * local_rotation_m * local_shear_scaling; global_rotation_scale = parent_global_rotation_m * parent_shear_scaling * local_rotation_m * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_Rrs) { } else if (inherit_type == FBXDocParser::Transform_Rrs) {
Transform parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.affine_inverse(); Transform3D parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.affine_inverse();
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_global_shear_m_noLocal * local_shear_scaling; global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_global_shear_m_noLocal * local_shear_scaling;
} }
Transform local_transform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse(); Transform3D local_transform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
//Transform local_translation_pivoted = Transform(Basis(), LocalTransform.origin); //Transform3D local_translation_pivoted = Transform3D(Basis(), LocalTransform.origin);
ERR_FAIL_COND_V_MSG(local_transform.basis.determinant() == 0, Transform(), "Det == 0 prevented in scene file"); ERR_FAIL_COND_V_MSG(local_transform.basis.determinant() == 0, Transform3D(), "Det == 0 prevented in scene file");
// manual hack to force SSC not to be compensated for - until we can handle it properly with tests // manual hack to force SSC not to be compensated for - until we can handle it properly with tests
return parent_global_xform * local_transform; return parent_global_xform * local_transform;
} }
void PivotTransform::ComputePivotTransform() { void PivotTransform::ComputePivotTransform() {
Transform T, Roff, Rp, Soff, Sp, S; Transform3D T, Roff, Rp, Soff, Sp, S;
// Here I assume this is the operation which needs done. // Here I assume this is the operation which needs done.
// Its WorldTransform * V // Its WorldTransform * V
@ -237,26 +237,26 @@ void PivotTransform::ComputePivotTransform() {
Local_Scaling_Matrix = S; // copy for when node / child is looking for the value of this. Local_Scaling_Matrix = S; // copy for when node / child is looking for the value of this.
// Rotation pivots // Rotation pivots
Transform Rpre = Transform(pre_rotation); Transform3D Rpre = Transform3D(pre_rotation);
Transform R = Transform(rotation); Transform3D R = Transform3D(rotation);
Transform Rpost = Transform(post_rotation); Transform3D Rpost = Transform3D(post_rotation);
Transform parent_global_xform; Transform3D parent_global_xform;
Transform parent_local_scaling_m; Transform3D parent_local_scaling_m;
if (parent_transform.is_valid()) { if (parent_transform.is_valid()) {
parent_global_xform = parent_transform->GlobalTransform; parent_global_xform = parent_transform->GlobalTransform;
parent_local_scaling_m = parent_transform->Local_Scaling_Matrix; parent_local_scaling_m = parent_transform->Local_Scaling_Matrix;
} }
Transform local_rotation_m, parent_global_rotation_m; Transform3D local_rotation_m, parent_global_rotation_m;
Quat parent_global_rotation = parent_global_xform.basis.get_rotation_quat(); Quat parent_global_rotation = parent_global_xform.basis.get_rotation_quat();
parent_global_rotation_m.basis.set_quat(parent_global_rotation); parent_global_rotation_m.basis.set_quat(parent_global_rotation);
local_rotation_m = Rpre * R * Rpost; local_rotation_m = Rpre * R * Rpost;
//Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quat().normalized()); //Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quat().normalized());
Transform local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation; Transform3D local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation;
Vector3 parent_translation = parent_global_xform.get_origin(); Vector3 parent_translation = parent_global_xform.get_origin();
parent_shear_translation.origin = parent_translation; parent_shear_translation.origin = parent_translation;
parent_shear_rotation = parent_shear_translation.affine_inverse() * parent_global_xform; parent_shear_rotation = parent_shear_translation.affine_inverse() * parent_global_xform;
@ -264,24 +264,24 @@ void PivotTransform::ComputePivotTransform() {
local_shear_scaling = S; local_shear_scaling = S;
// Inherit type handler - we don't care about T here, just reordering RSrs etc. // Inherit type handler - we don't care about T here, just reordering RSrs etc.
Transform global_rotation_scale; Transform3D global_rotation_scale;
if (inherit_type == FBXDocParser::Transform_RrSs) { if (inherit_type == FBXDocParser::Transform_RrSs) {
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_shear_scaling * local_shear_scaling; global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_shear_scaling * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_RSrs) { } else if (inherit_type == FBXDocParser::Transform_RSrs) {
global_rotation_scale = parent_global_rotation_m * parent_shear_scaling * local_rotation_m * local_shear_scaling; global_rotation_scale = parent_global_rotation_m * parent_shear_scaling * local_rotation_m * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_Rrs) { } else if (inherit_type == FBXDocParser::Transform_Rrs) {
Transform parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.inverse(); Transform3D parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.inverse();
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_global_shear_m_noLocal * local_shear_scaling; global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_global_shear_m_noLocal * local_shear_scaling;
} }
LocalTransform = Transform(); LocalTransform = Transform3D();
LocalTransform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse(); LocalTransform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
ERR_FAIL_COND_MSG(LocalTransform.basis.determinant() == 0, "invalid scale reset"); ERR_FAIL_COND_MSG(LocalTransform.basis.determinant() == 0, "invalid scale reset");
Transform local_translation_pivoted = Transform(Basis(), LocalTransform.origin); Transform3D local_translation_pivoted = Transform3D(Basis(), LocalTransform.origin);
GlobalTransform = Transform(); GlobalTransform = Transform3D();
//GlobalTransform = parent_global_xform * LocalTransform; //GlobalTransform = parent_global_xform * LocalTransform;
Transform global_origin = Transform(Basis(), parent_translation); Transform3D global_origin = Transform3D(Basis(), parent_translation);
GlobalTransform = (global_origin * local_translation_pivoted) * global_rotation_scale; GlobalTransform = (global_origin * local_translation_pivoted) * global_rotation_scale;
ImportUtils::debug_xform("local xform calculation", LocalTransform); ImportUtils::debug_xform("local xform calculation", LocalTransform);

View File

@ -85,10 +85,10 @@ struct PivotTransform : Reference, ModelAbstraction {
print_verbose("raw post_rotation " + raw_post_rotation * (180 / Math_PI)); print_verbose("raw post_rotation " + raw_post_rotation * (180 / Math_PI));
} }
Transform ComputeGlobalTransform(Transform t) const; Transform3D ComputeGlobalTransform(Transform3D t) const;
Transform ComputeLocalTransform(Transform t) const; Transform3D ComputeLocalTransform(Transform3D t) const;
Transform ComputeGlobalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const; Transform3D ComputeGlobalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const;
Transform ComputeLocalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const; Transform3D ComputeLocalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const;
/* Extract into xforms and calculate once */ /* Extract into xforms and calculate once */
void ComputePivotTransform(); void ComputePivotTransform();
@ -105,10 +105,10 @@ struct PivotTransform : Reference, ModelAbstraction {
//Transform chain[TransformationComp_MAXIMUM]; //Transform chain[TransformationComp_MAXIMUM];
// cached for later use // cached for later use
Transform GlobalTransform = Transform(); Transform3D GlobalTransform = Transform3D();
Transform LocalTransform = Transform(); Transform3D LocalTransform = Transform3D();
Transform Local_Scaling_Matrix = Transform(); // used for inherit type. Transform3D Local_Scaling_Matrix = Transform3D(); // used for inherit type.
Transform GeometricTransform = Transform(); // 3DS max only Transform3D GeometricTransform = Transform3D(); // 3DS max only
FBXDocParser::TransformInheritance inherit_type = FBXDocParser::TransformInheritance_MAX; // maya fbx requires this - sorry <3 FBXDocParser::TransformInheritance inherit_type = FBXDocParser::TransformInheritance_MAX; // maya fbx requires this - sorry <3
}; };

View File

@ -1023,7 +1023,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
bone = state.fbx_bone_map[target_id]; bone = state.fbx_bone_map[target_id];
} }
Transform target_transform; Transform3D target_transform;
if (state.fbx_target_map.has(target_id)) { if (state.fbx_target_map.has(target_id)) {
Ref<FBXNode> node_ref = state.fbx_target_map[target_id]; Ref<FBXNode> node_ref = state.fbx_target_map[target_id];
@ -1165,7 +1165,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
} }
bool valid_rest = false; bool valid_rest = false;
Transform bone_rest; Transform3D bone_rest;
int skeleton_bone = -1; int skeleton_bone = -1;
if (state.fbx_bone_map.has(target_id)) { if (state.fbx_bone_map.has(target_id)) {
if (bone.is_valid() && bone->fbx_skeleton.is_valid()) { if (bone.is_valid() && bone->fbx_skeleton.is_valid()) {
@ -1208,10 +1208,10 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// node animations must also include pivots // node animations must also include pivots
if (skeleton_bone >= 0) { if (skeleton_bone >= 0) {
Transform xform = Transform(); Transform3D xform = Transform3D();
xform.basis.set_quat_scale(rot, scale); xform.basis.set_quat_scale(rot, scale);
xform.origin = pos; xform.origin = pos;
const Transform t = bone_rest.affine_inverse() * xform; const Transform3D t = bone_rest.affine_inverse() * xform;
// populate this again // populate this again
rot = t.basis.get_rotation_quat(); rot = t.basis.get_rotation_quat();

View File

@ -242,13 +242,13 @@ public:
return target_id; return target_id;
} }
Transform GetBindPose() const { Transform3D GetBindPose() const {
return transform; return transform;
} }
private: private:
uint64_t target_id = 0; uint64_t target_id = 0;
Transform transform; Transform3D transform;
}; };
/** DOM base class for FBX cameras attached to a node */ /** DOM base class for FBX cameras attached to a node */
@ -905,11 +905,11 @@ public:
} }
/** */ /** */
const Transform &GetTransform() const { const Transform3D &GetTransform() const {
return transform; return transform;
} }
const Transform &TransformLink() const { const Transform3D &TransformLink() const {
return transformLink; return transformLink;
} }
@ -917,7 +917,7 @@ public:
return node; return node;
} }
const Transform &TransformAssociateModel() const { const Transform3D &TransformAssociateModel() const {
return transformAssociateModel; return transformAssociateModel;
} }
@ -941,9 +941,9 @@ private:
std::vector<float> weights; std::vector<float> weights;
std::vector<unsigned int> indices; std::vector<unsigned int> indices;
Transform transform; Transform3D transform;
Transform transformLink; Transform3D transformLink;
Transform transformAssociateModel; Transform3D transformAssociateModel;
SkinLinkMode link_mode; SkinLinkMode link_mode;
bool valid_transformAssociateModel = false; bool valid_transformAssociateModel = false;
const Model *node = nullptr; const Model *node = nullptr;

View File

@ -1157,7 +1157,7 @@ void ParseVectorDataArray(std::vector<int64_t> &out, const ElementPtr el) {
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Transform ReadMatrix(const ElementPtr element) { Transform3D ReadMatrix(const ElementPtr element) {
std::vector<float> values; std::vector<float> values;
ParseVectorDataArray(values, element); ParseVectorDataArray(values, element);
@ -1172,7 +1172,7 @@ Transform ReadMatrix(const ElementPtr element) {
} }
} }
Transform xform; Transform3D xform;
Basis basis; Basis basis;
basis.set( basis.set(

View File

@ -264,7 +264,7 @@ TokenPtr GetRequiredToken(const ElementPtr el, unsigned int index);
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// read a 4x4 matrix from an array of 16 floats // read a 4x4 matrix from an array of 16 floats
Transform ReadMatrix(const ElementPtr element); Transform3D ReadMatrix(const ElementPtr element);
} // namespace FBXDocParser } // namespace FBXDocParser
#endif // FBX_PARSER_H #endif // FBX_PARSER_H

View File

@ -121,9 +121,9 @@ Vector3 ImportUtils::QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const
return BasisToEuler(mode, p_rotation); return BasisToEuler(mode, p_rotation);
} }
Transform get_unscaled_transform(const Transform &p_initial, real_t p_scale) { Transform3D get_unscaled_transform(const Transform3D &p_initial, real_t p_scale) {
Transform unscaled = Transform(p_initial.basis, p_initial.origin * p_scale); Transform3D unscaled = Transform3D(p_initial.basis, p_initial.origin * p_scale);
ERR_FAIL_COND_V_MSG(unscaled.basis.determinant() == 0, Transform(), "det is zero unscaled?"); ERR_FAIL_COND_V_MSG(unscaled.basis.determinant() == 0, Transform3D(), "det is zero unscaled?");
return unscaled; return unscaled;
} }

View File

@ -64,7 +64,7 @@ public:
/// Converts quaternion into rotation order vector (in rad). /// Converts quaternion into rotation order vector (in rad).
static Vector3 QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const Quat &p_rotation); static Vector3 QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const Quat &p_rotation);
static void debug_xform(String name, const Transform &t) { static void debug_xform(String name, const Transform3D &t) {
print_verbose(name + " " + t.origin + " rotation: " + (t.basis.get_euler() * (180 / Math_PI))); print_verbose(name + " " + t.origin + " rotation: " + (t.basis.get_euler() * (180 / Math_PI)));
} }
@ -391,7 +391,7 @@ public:
}; };
// Apply the transforms so the basis will have scale 1. // Apply the transforms so the basis will have scale 1.
Transform get_unscaled_transform(const Transform &p_initial, real_t p_scale); Transform3D get_unscaled_transform(const Transform3D &p_initial, real_t p_scale);
/// Uses the Newell's method to compute any polygon normal. /// Uses the Newell's method to compute any polygon normal.
/// The polygon must be at least size of 3 or bigger. /// The polygon must be at least size of 3 or bigger.

View File

@ -32,18 +32,18 @@
#include "core/math/transform.h" #include "core/math/transform.h"
static_assert(sizeof(godot_transform) == sizeof(Transform), "Transform size mismatch"); static_assert(sizeof(godot_transform) == sizeof(Transform3D), "Transform3D size mismatch");
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void GDAPI godot_transform_new(godot_transform *p_self) { void GDAPI godot_transform_new(godot_transform *p_self) {
memnew_placement(p_self, Transform); memnew_placement(p_self, Transform3D);
} }
void GDAPI godot_transform_new_copy(godot_transform *r_dest, const godot_transform *p_src) { void GDAPI godot_transform_new_copy(godot_transform *r_dest, const godot_transform *p_src) {
memnew_placement(r_dest, Transform(*(Transform *)p_src)); memnew_placement(r_dest, Transform3D(*(Transform3D *)p_src));
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -163,7 +163,7 @@ void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_b
void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans) { void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans) {
Variant *dest = (Variant *)r_dest; Variant *dest = (Variant *)r_dest;
const Transform *trans = (const Transform *)p_trans; const Transform3D *trans = (const Transform3D *)p_trans;
memnew_placement_custom(dest, Variant, Variant(*trans)); memnew_placement_custom(dest, Variant, Variant(*trans));
} }
@ -405,7 +405,7 @@ godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self) {
godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self) { godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self) {
godot_transform raw_dest; godot_transform raw_dest;
const Variant *self = (const Variant *)p_self; const Variant *self = (const Variant *)p_self;
Transform *dest = (Transform *)&raw_dest; Transform3D *dest = (Transform3D *)&raw_dest;
*dest = *self; *dest = *self;
return raw_dest; return raw_dest;
} }

View File

@ -363,7 +363,7 @@ void unregister_gdnative_types() {
print_line(String("aabb:\t") + itos(sizeof(AABB))); print_line(String("aabb:\t") + itos(sizeof(AABB)));
print_line(String("rid:\t") + itos(sizeof(RID))); print_line(String("rid:\t") + itos(sizeof(RID)));
print_line(String("string:\t") + itos(sizeof(String))); print_line(String("string:\t") + itos(sizeof(String)));
print_line(String("transform:\t") + itos(sizeof(Transform))); print_line(String("transform:\t") + itos(sizeof(Transform3D)));
print_line(String("transfo2D:\t") + itos(sizeof(Transform2D))); print_line(String("transfo2D:\t") + itos(sizeof(Transform2D)));
print_line(String("variant:\t") + itos(sizeof(Variant))); print_line(String("variant:\t") + itos(sizeof(Variant)));
print_line(String("vector2:\t") + itos(sizeof(Vector2))); print_line(String("vector2:\t") + itos(sizeof(Vector2)));

View File

@ -173,14 +173,14 @@ Size2 XRInterfaceGDNative::get_render_targetsize() {
return *vec; return *vec;
} }
Transform XRInterfaceGDNative::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) { Transform3D XRInterfaceGDNative::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) {
Transform *ret; Transform3D *ret;
ERR_FAIL_COND_V(interface == nullptr, Transform()); ERR_FAIL_COND_V(interface == nullptr, Transform3D());
godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform); godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform);
ret = (Transform *)&t; ret = (Transform3D *)&t;
return *ret; return *ret;
} }
@ -243,13 +243,13 @@ godot_float GDAPI godot_xr_get_worldscale() {
godot_transform GDAPI godot_xr_get_reference_frame() { godot_transform GDAPI godot_xr_get_reference_frame() {
godot_transform reference_frame; godot_transform reference_frame;
Transform *reference_frame_ptr = (Transform *)&reference_frame; Transform3D *reference_frame_ptr = (Transform3D *)&reference_frame;
XRServer *xr_server = XRServer::get_singleton(); XRServer *xr_server = XRServer::get_singleton();
if (xr_server != nullptr) { if (xr_server != nullptr) {
*reference_frame_ptr = xr_server->get_reference_frame(); *reference_frame_ptr = xr_server->get_reference_frame();
} else { } else {
memnew_placement(&reference_frame, Transform); memnew_placement(&reference_frame, Transform3D);
} }
return reference_frame; return reference_frame;
@ -362,7 +362,7 @@ void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_tr
Ref<XRPositionalTracker> tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id); Ref<XRPositionalTracker> tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
if (tracker.is_valid()) { if (tracker.is_valid()) {
Transform *transform = (Transform *)p_transform; Transform3D *transform = (Transform3D *)p_transform;
if (p_tracks_orientation) { if (p_tracks_orientation) {
tracker->set_orientation(transform->basis); tracker->set_orientation(transform->basis);
} }

View File

@ -73,7 +73,7 @@ public:
/** rendering and internal **/ /** rendering and internal **/
virtual Size2 get_render_targetsize() override; virtual Size2 get_render_targetsize() override;
virtual bool is_stereo() override; virtual bool is_stereo() override;
virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) override; virtual Transform3D get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) override;
// we expose a Vector<float> version of this function to GDNative // we expose a Vector<float> version of this function to GDNative
Vector<float> _get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far); Vector<float> _get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);

View File

@ -270,7 +270,7 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
} }
} }
COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) { COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform) {
NavRegion *region = region_owner.getornull(p_region); NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND(region == nullptr); ERR_FAIL_COND(region == nullptr);

View File

@ -113,7 +113,7 @@ public:
COMMAND_2(region_set_map, RID, p_region, RID, p_map); COMMAND_2(region_set_map, RID, p_region, RID, p_map);
COMMAND_2(region_set_layers, RID, p_region, uint32_t, p_layers); COMMAND_2(region_set_layers, RID, p_region, uint32_t, p_layers);
virtual uint32_t region_get_layers(RID p_region) const; virtual uint32_t region_get_layers(RID p_region) const;
COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform); COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform);
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh); COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh);
virtual void region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const; virtual void region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const;
virtual int region_get_connections_count(RID p_region) const; virtual int region_get_connections_count(RID p_region) const;

View File

@ -52,7 +52,7 @@ uint32_t NavRegion::get_layers() const {
return layers; return layers;
} }
void NavRegion::set_transform(Transform p_transform) { void NavRegion::set_transform(Transform3D p_transform) {
transform = p_transform; transform = p_transform;
polygons_dirty = true; polygons_dirty = true;
} }

View File

@ -46,7 +46,7 @@ class NavRegion;
class NavRegion : public NavRid { class NavRegion : public NavRid {
NavMap *map = nullptr; NavMap *map = nullptr;
Transform transform; Transform3D transform;
Ref<NavigationMesh> mesh; Ref<NavigationMesh> mesh;
uint32_t layers = 1; uint32_t layers = 1;
Vector<gd::Edge::Connection> connections; Vector<gd::Edge::Connection> connections;
@ -71,8 +71,8 @@ public:
void set_layers(uint32_t p_layers); void set_layers(uint32_t p_layers);
uint32_t get_layers() const; uint32_t get_layers() const;
void set_transform(Transform transform); void set_transform(Transform3D transform);
const Transform &get_transform() const { const Transform3D &get_transform() const {
return transform; return transform;
} }

View File

@ -68,7 +68,7 @@ void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &
p_verticies.push_back(p_vec3.z); p_verticies.push_back(p_vec3.z);
} }
void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) { void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
int current_vertex_count; int current_vertex_count;
for (int i = 0; i < p_mesh->get_surface_count(); i++) { for (int i = 0; i < p_mesh->get_surface_count(); i++) {
@ -123,7 +123,7 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
} }
} }
void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) { void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
int face_count = p_faces.size() / 3; int face_count = p_faces.size() / 3;
int current_vertex_count = p_verticies.size() / 3; int current_vertex_count = p_verticies.size() / 3;
@ -138,7 +138,7 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
} }
} }
void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) { void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node); MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh(); Ref<Mesh> mesh = mesh_instance->get_mesh();
@ -169,7 +169,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
if (Object::cast_to<CollisionShape3D>(child)) { if (Object::cast_to<CollisionShape3D>(child)) {
CollisionShape3D *col_shape = Object::cast_to<CollisionShape3D>(child); CollisionShape3D *col_shape = Object::cast_to<CollisionShape3D>(child);
Transform transform = p_accumulated_transform * static_body->get_transform() * col_shape->get_transform(); Transform3D transform = p_accumulated_transform * static_body->get_transform() * col_shape->get_transform();
Ref<Mesh> mesh; Ref<Mesh> mesh;
Ref<Shape3D> s = col_shape->get_shape(); Ref<Shape3D> s = col_shape->get_shape();
@ -251,7 +251,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
if (Object::cast_to<GridMap>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { if (Object::cast_to<GridMap>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
GridMap *gridmap_instance = Object::cast_to<GridMap>(p_node); GridMap *gridmap_instance = Object::cast_to<GridMap>(p_node);
Array meshes = gridmap_instance->get_meshes(); Array meshes = gridmap_instance->get_meshes();
Transform xform = gridmap_instance->get_transform(); Transform3D xform = gridmap_instance->get_transform();
for (int i = 0; i < meshes.size(); i += 2) { for (int i = 0; i < meshes.size(); i += 2) {
Ref<Mesh> mesh = meshes[i + 1]; Ref<Mesh> mesh = meshes[i + 1];
if (mesh.is_valid()) { if (mesh.is_valid()) {
@ -513,7 +513,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
p_node->get_tree()->get_nodes_in_group(p_nav_mesh->get_source_group_name(), &parse_nodes); p_node->get_tree()->get_nodes_in_group(p_nav_mesh->get_source_group_name(), &parse_nodes);
} }
Transform navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse(); Transform3D navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse();
for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) { for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) {
int geometry_type = p_nav_mesh->get_parsed_geometry_type(); int geometry_type = p_nav_mesh->get_parsed_geometry_type();
uint32_t collision_mask = p_nav_mesh->get_collision_mask(); uint32_t collision_mask = p_nav_mesh->get_collision_mask();

View File

@ -50,9 +50,9 @@ protected:
static void _bind_methods(); static void _bind_methods();
static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies); static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies);
static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices); static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
static void _add_faces(const PackedVector3Array &p_faces, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices); static void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
static void _parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children); static void _parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children);
static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh); static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh);
static void _build_recast_navigation_mesh( static void _build_recast_navigation_mesh(

View File

@ -169,7 +169,7 @@ void (*type_init_function_table[])(Variant *) = {
&VariantInitializer<Quat>::init, // QUAT. &VariantInitializer<Quat>::init, // QUAT.
&VariantInitializer<AABB>::init, // AABB. &VariantInitializer<AABB>::init, // AABB.
&VariantInitializer<Basis>::init, // BASIS. &VariantInitializer<Basis>::init, // BASIS.
&VariantInitializer<Transform>::init, // TRANSFORM. &VariantInitializer<Transform3D>::init, // TRANSFORM3D.
&VariantInitializer<Color>::init, // COLOR. &VariantInitializer<Color>::init, // COLOR.
&VariantInitializer<StringName>::init, // STRING_NAME. &VariantInitializer<StringName>::init, // STRING_NAME.
&VariantInitializer<NodePath>::init, // NODE_PATH. &VariantInitializer<NodePath>::init, // NODE_PATH.
@ -3153,7 +3153,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_TYPE_ADJUST(QUAT, Quat); OPCODE_TYPE_ADJUST(QUAT, Quat);
OPCODE_TYPE_ADJUST(AABB, AABB); OPCODE_TYPE_ADJUST(AABB, AABB);
OPCODE_TYPE_ADJUST(BASIS, Basis); OPCODE_TYPE_ADJUST(BASIS, Basis);
OPCODE_TYPE_ADJUST(TRANSFORM, Transform); OPCODE_TYPE_ADJUST(TRANSFORM, Transform3D);
OPCODE_TYPE_ADJUST(COLOR, Color); OPCODE_TYPE_ADJUST(COLOR, Color);
OPCODE_TYPE_ADJUST(STRING_NAME, StringName); OPCODE_TYPE_ADJUST(STRING_NAME, StringName);
OPCODE_TYPE_ADJUST(NODE_PATH, NodePath); OPCODE_TYPE_ADJUST(NODE_PATH, NodePath);

View File

@ -357,10 +357,10 @@ static Quat _arr_to_quat(const Array &p_array) {
return Quat(p_array[0], p_array[1], p_array[2], p_array[3]); return Quat(p_array[0], p_array[1], p_array[2], p_array[3]);
} }
static Transform _arr_to_xform(const Array &p_array) { static Transform3D _arr_to_xform(const Array &p_array) {
ERR_FAIL_COND_V(p_array.size() != 16, Transform()); ERR_FAIL_COND_V(p_array.size() != 16, Transform3D());
Transform xform; Transform3D xform;
xform.basis.set_axis(Vector3::AXIS_X, Vector3(p_array[0], p_array[1], p_array[2])); xform.basis.set_axis(Vector3::AXIS_X, Vector3(p_array[0], p_array[1], p_array[2]));
xform.basis.set_axis(Vector3::AXIS_Y, Vector3(p_array[4], p_array[5], p_array[6])); xform.basis.set_axis(Vector3::AXIS_Y, Vector3(p_array[4], p_array[5], p_array[6]));
xform.basis.set_axis(Vector3::AXIS_Z, Vector3(p_array[8], p_array[9], p_array[10])); xform.basis.set_axis(Vector3::AXIS_Z, Vector3(p_array[8], p_array[9], p_array[10]));
@ -369,7 +369,7 @@ static Transform _arr_to_xform(const Array &p_array) {
return xform; return xform;
} }
static Vector<real_t> _xform_to_array(const Transform p_transform) { static Vector<real_t> _xform_to_array(const Transform3D p_transform) {
Vector<real_t> array; Vector<real_t> array;
array.resize(16); array.resize(16);
Vector3 axis_x = p_transform.get_basis().get_axis(Vector3::AXIS_X); Vector3 axis_x = p_transform.get_basis().get_axis(Vector3::AXIS_X);
@ -421,7 +421,7 @@ Error GLTFDocument::_serialize_nodes(Ref<GLTFState> state) {
} }
if (n->skeleton != -1 && n->skin < 0) { if (n->skeleton != -1 && n->skin < 0) {
} }
if (n->xform != Transform()) { if (n->xform != Transform3D()) {
node["matrix"] = _xform_to_array(n->xform); node["matrix"] = _xform_to_array(n->xform);
} }
@ -1939,7 +1939,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> state, c
return state->accessors.size() - 1; return state->accessors.size() - 1;
} }
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> state, const Vector<Transform> p_attribs, const bool p_for_vertex) { GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> state, const Vector<Transform3D> p_attribs, const bool p_for_vertex) {
if (p_attribs.size() == 0) { if (p_attribs.size() == 0) {
return -1; return -1;
} }
@ -1953,7 +1953,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> state,
Vector<double> type_min; Vector<double> type_min;
type_min.resize(element_count); type_min.resize(element_count);
for (int i = 0; i < p_attribs.size(); i++) { for (int i = 0; i < p_attribs.size(); i++) {
Transform attrib = p_attribs[i]; Transform3D attrib = p_attribs[i];
Basis basis = attrib.get_basis(); Basis basis = attrib.get_basis();
Vector3 axis_0 = basis.get_axis(Vector3::AXIS_X); Vector3 axis_0 = basis.get_axis(Vector3::AXIS_X);
@ -2107,9 +2107,9 @@ Vector<Basis> GLTFDocument::_decode_accessor_as_basis(Ref<GLTFState> state, cons
return ret; return ret;
} }
Vector<Transform> GLTFDocument::_decode_accessor_as_xform(Ref<GLTFState> state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { Vector<Transform3D> GLTFDocument::_decode_accessor_as_xform(Ref<GLTFState> state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Transform> ret; Vector<Transform3D> ret;
if (attribs.size() == 0) { if (attribs.size() == 0) {
return ret; return ret;
@ -4279,7 +4279,7 @@ Error GLTFDocument::_create_skins(Ref<GLTFState> state) {
GLTFNodeIndex node = gltf_skin->joints_original[joint_i]; GLTFNodeIndex node = gltf_skin->joints_original[joint_i];
String bone_name = state->nodes[node]->get_name(); String bone_name = state->nodes[node]->get_name();
Transform xform; Transform3D xform;
if (has_ibms) { if (has_ibms) {
xform = gltf_skin->inverse_binds[joint_i]; xform = gltf_skin->inverse_binds[joint_i];
} }
@ -4323,8 +4323,8 @@ bool GLTFDocument::_skins_are_same(const Ref<Skin> skin_a, const Ref<Skin> skin_
return false; return false;
} }
Transform a_xform = skin_a->get_bind_pose(i); Transform3D a_xform = skin_a->get_bind_pose(i);
Transform b_xform = skin_b->get_bind_pose(i); Transform3D b_xform = skin_b->get_bind_pose(i);
if (a_xform != b_xform) { if (a_xform != b_xform) {
return false; return false;
@ -5075,7 +5075,7 @@ GLTFSkeletonIndex GLTFDocument::_convert_skeleton(Ref<GLTFState> state, Skeleton
} }
void GLTFDocument::_convert_spatial(Ref<GLTFState> state, Node3D *p_spatial, Ref<GLTFNode> p_node) { void GLTFDocument::_convert_spatial(Ref<GLTFState> state, Node3D *p_spatial, Ref<GLTFNode> p_node) {
Transform xform = p_spatial->get_transform(); Transform3D xform = p_spatial->get_transform();
p_node->scale = xform.basis.get_scale(); p_node->scale = xform.basis.get_scale();
p_node->rotation = xform.basis.get_rotation_quat(); p_node->rotation = xform.basis.get_rotation_quat();
p_node->translation = xform.origin; p_node->translation = xform.origin;
@ -5240,7 +5240,7 @@ void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNod
Vector3(cell_location.x, cell_location.y, cell_location.z)); Vector3(cell_location.x, cell_location.y, cell_location.z));
EditorSceneImporterMeshNode3D *import_mesh_node = memnew(EditorSceneImporterMeshNode3D); EditorSceneImporterMeshNode3D *import_mesh_node = memnew(EditorSceneImporterMeshNode3D);
import_mesh_node->set_mesh(grid_map->get_mesh_library()->get_item_mesh(cell)); import_mesh_node->set_mesh(grid_map->get_mesh_library()->get_item_mesh(cell));
Transform cell_xform; Transform3D cell_xform;
cell_xform.basis.set_orthogonal_index( cell_xform.basis.set_orthogonal_index(
grid_map->get_cell_item_orientation( grid_map->get_cell_item_orientation(
Vector3(cell_location.x, cell_location.y, cell_location.z))); Vector3(cell_location.x, cell_location.y, cell_location.z)));
@ -5268,7 +5268,7 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, con
for (int32_t instance_i = 0; instance_i < multi_mesh->get_instance_count(); for (int32_t instance_i = 0; instance_i < multi_mesh->get_instance_count();
instance_i++) { instance_i++) {
GLTFNode *new_gltf_node = memnew(GLTFNode); GLTFNode *new_gltf_node = memnew(GLTFNode);
Transform transform; Transform3D transform;
if (multi_mesh->get_transform_format() == MultiMesh::TRANSFORM_2D) { if (multi_mesh->get_transform_format() == MultiMesh::TRANSFORM_2D) {
Transform2D xform_2d = multi_mesh->get_instance_transform_2d(instance_i); Transform2D xform_2d = multi_mesh->get_instance_transform_2d(instance_i);
transform.origin = transform.origin =
@ -5715,7 +5715,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
} }
if (gltf_node->skeleton >= 0) { if (gltf_node->skeleton >= 0) {
Transform xform; Transform3D xform;
xform.basis.set_quat_scale(rot, scale); xform.basis.set_quat_scale(rot, scale);
xform.origin = pos; xform.origin = pos;
@ -5808,7 +5808,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
} }
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get()); MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get());
ERR_CONTINUE(!mi); ERR_CONTINUE(!mi);
Transform mi_xform = mi->get_transform(); Transform3D mi_xform = mi->get_transform();
node->scale = mi_xform.basis.get_scale(); node->scale = mi_xform.basis.get_scale();
node->rotation = mi_xform.basis.get_rotation_quat(); node->rotation = mi_xform.basis.get_rotation_quat();
node->translation = mi_xform.origin; node->translation = mi_xform.origin;
@ -5872,7 +5872,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
String gltf_bone_name = _gen_unique_bone_name(state, skeleton_gltf_i, godot_bone_name); String gltf_bone_name = _gen_unique_bone_name(state, skeleton_gltf_i, godot_bone_name);
joint_node->set_name(gltf_bone_name); joint_node->set_name(gltf_bone_name);
Transform bone_rest_xform = skeleton->get_bone_rest(bone_index); Transform3D bone_rest_xform = skeleton->get_bone_rest(bone_index);
joint_node->scale = bone_rest_xform.basis.get_scale(); joint_node->scale = bone_rest_xform.basis.get_scale();
joint_node->rotation = bone_rest_xform.basis.get_rotation_quat(); joint_node->rotation = bone_rest_xform.basis.get_rotation_quat();
joint_node->translation = bone_rest_xform.origin; joint_node->translation = bone_rest_xform.origin;
@ -5995,12 +5995,12 @@ void GLTFDocument::_process_mesh_instances(Ref<GLTFState> state, Node *scene_roo
mi->set_skin(state->skins.write[skin_i]->godot_skin); mi->set_skin(state->skins.write[skin_i]->godot_skin);
mi->set_skeleton_path(mi->get_path_to(skeleton)); mi->set_skeleton_path(mi->get_path_to(skeleton));
mi->set_transform(Transform()); mi->set_transform(Transform3D());
} }
} }
} }
GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state, GLTFAnimation::Track p_track, Ref<Animation> p_animation, Transform p_bone_rest, int32_t p_track_i, GLTFNodeIndex p_node_i) { GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state, GLTFAnimation::Track p_track, Ref<Animation> p_animation, Transform3D p_bone_rest, int32_t p_track_i, GLTFNodeIndex p_node_i) {
Animation::InterpolationType interpolation = p_animation->track_get_interpolation_type(p_track_i); Animation::InterpolationType interpolation = p_animation->track_get_interpolation_type(p_track_i);
GLTFAnimation::Interpolation gltf_interpolation = GLTFAnimation::INTERP_LINEAR; GLTFAnimation::Interpolation gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
@ -6040,7 +6040,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
Vector3 scale; Vector3 scale;
Error err = p_animation->transform_track_get_key(p_track_i, key_i, &translation, &rotation, &scale); Error err = p_animation->transform_track_get_key(p_track_i, key_i, &translation, &rotation, &scale);
ERR_CONTINUE(err != OK); ERR_CONTINUE(err != OK);
Transform xform; Transform3D xform;
xform.basis.set_quat_scale(rotation, scale); xform.basis.set_quat_scale(rotation, scale);
xform.origin = translation; xform.origin = translation;
xform = p_bone_rest * xform; xform = p_bone_rest * xform;
@ -6063,7 +6063,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
p_track.rotation_track.values.resize(key_count); p_track.rotation_track.values.resize(key_count);
p_track.rotation_track.interpolation = gltf_interpolation; p_track.rotation_track.interpolation = gltf_interpolation;
for (int32_t key_i = 0; key_i < key_count; key_i++) { for (int32_t key_i = 0; key_i < key_count; key_i++) {
Transform xform = p_animation->track_get_key_value(p_track_i, key_i); Transform3D xform = p_animation->track_get_key_value(p_track_i, key_i);
p_track.translation_track.values.write[key_i] = xform.get_origin(); p_track.translation_track.values.write[key_i] = xform.get_origin();
p_track.rotation_track.values.write[key_i] = xform.basis.get_rotation_quat(); p_track.rotation_track.values.write[key_i] = xform.basis.get_rotation_quat();
p_track.scale_track.values.write[key_i] = xform.basis.get_scale(); p_track.scale_track.values.write[key_i] = xform.basis.get_scale();
@ -6210,7 +6210,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
if (translation_track_i) { if (translation_track_i) {
track = translation_track_i->get(); track = translation_track_i->get();
} }
track = _convert_animation_track(state, track, animation, Transform(), track_i, node_index); track = _convert_animation_track(state, track, animation, Transform3D(), track_i, node_index);
gltf_animation->get_tracks().insert(node_index, track); gltf_animation->get_tracks().insert(node_index, track);
} }
} }
@ -6226,7 +6226,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
if (rotation_degree_track_i) { if (rotation_degree_track_i) {
track = rotation_degree_track_i->get(); track = rotation_degree_track_i->get();
} }
track = _convert_animation_track(state, track, animation, Transform(), track_i, node_index); track = _convert_animation_track(state, track, animation, Transform3D(), track_i, node_index);
gltf_animation->get_tracks().insert(node_index, track); gltf_animation->get_tracks().insert(node_index, track);
} }
} }
@ -6242,7 +6242,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
if (scale_track_i) { if (scale_track_i) {
track = scale_track_i->get(); track = scale_track_i->get();
} }
track = _convert_animation_track(state, track, animation, Transform(), track_i, node_index); track = _convert_animation_track(state, track, animation, Transform3D(), track_i, node_index);
gltf_animation->get_tracks().insert(node_index, track); gltf_animation->get_tracks().insert(node_index, track);
} }
} }
@ -6253,7 +6253,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
for (Map<GLTFNodeIndex, Node *>::Element *transform_track_i = state->scene_nodes.front(); transform_track_i; transform_track_i = transform_track_i->next()) { for (Map<GLTFNodeIndex, Node *>::Element *transform_track_i = state->scene_nodes.front(); transform_track_i; transform_track_i = transform_track_i->next()) {
if (transform_track_i->get() == node) { if (transform_track_i->get() == node) {
GLTFAnimation::Track track; GLTFAnimation::Track track;
track = _convert_animation_track(state, track, animation, Transform(), track_i, transform_track_i->key()); track = _convert_animation_track(state, track, animation, Transform3D(), track_i, transform_track_i->key());
gltf_animation->get_tracks().insert(transform_track_i->key(), track); gltf_animation->get_tracks().insert(transform_track_i->key(), track);
} }
} }
@ -6341,7 +6341,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
Ref<GLTFSkeleton> skeleton_gltf = state->skeletons[skeleton_gltf_i]; Ref<GLTFSkeleton> skeleton_gltf = state->skeletons[skeleton_gltf_i];
int32_t bone = skeleton->find_bone(suffix); int32_t bone = skeleton->find_bone(suffix);
ERR_CONTINUE(bone == -1); ERR_CONTINUE(bone == -1);
Transform xform = skeleton->get_bone_rest(bone); Transform3D xform = skeleton->get_bone_rest(bone);
if (!skeleton_gltf->godot_bone_node.has(bone)) { if (!skeleton_gltf->godot_bone_node.has(bone)) {
continue; continue;
} }
@ -6368,7 +6368,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
if (node_track_i) { if (node_track_i) {
track = node_track_i->get(); track = node_track_i->get();
} }
track = _convert_animation_track(state, track, animation, Transform(), track_i, node_index); track = _convert_animation_track(state, track, animation, Transform3D(), track_i, node_index);
gltf_animation->get_tracks().insert(node_index, track); gltf_animation->get_tracks().insert(node_index, track);
break; break;
} }

View File

@ -214,7 +214,7 @@ private:
Vector<Basis> _decode_accessor_as_basis(Ref<GLTFState> state, Vector<Basis> _decode_accessor_as_basis(Ref<GLTFState> state,
const GLTFAccessorIndex p_accessor, const GLTFAccessorIndex p_accessor,
const bool p_for_vertex); const bool p_for_vertex);
Vector<Transform> _decode_accessor_as_xform(Ref<GLTFState> state, Vector<Transform3D> _decode_accessor_as_xform(Ref<GLTFState> state,
const GLTFAccessorIndex p_accessor, const GLTFAccessorIndex p_accessor,
const bool p_for_vertex); const bool p_for_vertex);
Error _parse_meshes(Ref<GLTFState> state); Error _parse_meshes(Ref<GLTFState> state);
@ -317,7 +317,7 @@ private:
const Vector<int32_t> p_attribs, const Vector<int32_t> p_attribs,
const bool p_for_vertex); const bool p_for_vertex);
GLTFAccessorIndex _encode_accessor_as_xform(Ref<GLTFState> state, GLTFAccessorIndex _encode_accessor_as_xform(Ref<GLTFState> state,
const Vector<Transform> p_attribs, const Vector<Transform3D> p_attribs,
const bool p_for_vertex); const bool p_for_vertex);
Error _encode_buffer_view(Ref<GLTFState> state, const double *src, Error _encode_buffer_view(Ref<GLTFState> state, const double *src,
const int count, const GLTFType type, const int count, const GLTFType type,
@ -333,7 +333,7 @@ private:
String interpolation_to_string(const GLTFAnimation::Interpolation p_interp); String interpolation_to_string(const GLTFAnimation::Interpolation p_interp);
GLTFAnimation::Track _convert_animation_track(Ref<GLTFState> state, GLTFAnimation::Track _convert_animation_track(Ref<GLTFState> state,
GLTFAnimation::Track p_track, GLTFAnimation::Track p_track,
Ref<Animation> p_animation, Transform p_bone_rest, Ref<Animation> p_animation, Transform3D p_bone_rest,
int32_t p_track_i, int32_t p_track_i,
GLTFNodeIndex p_node_i); GLTFNodeIndex p_node_i);
Error _encode_buffer_bins(Ref<GLTFState> state, const String &p_path); Error _encode_buffer_bins(Ref<GLTFState> state, const String &p_path);

Some files were not shown because too many files have changed in this diff Show More