summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-03 23:20:20 -0300
committerGitHub <noreply@github.com>2017-01-03 23:20:20 -0300
commit3a0c19d3f6ddb26359c95d84c376a8e6b1afd04d (patch)
tree8e313066ce55a3366cd6b972ff429372583cda28 /tools/editor
parentf2e99826c0b1e8227644bfab0795d858c504d279 (diff)
parentbd7ba0b664fa98381db9ef8edb69ba211213d595 (diff)
Merge pull request #6865 from tagcup/godot_issue_6816
Use right handed coordinate system for rotation matrices and quaternions. Also fixed Euler angles (XYZ convention).
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/plugins/cube_grid_theme_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp4
-rw-r--r--tools/editor/plugins/material_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/mesh_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/multimesh_editor_plugin.cpp10
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp22
6 files changed, 24 insertions, 24 deletions
diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
index 0c2ec15367..a5f447cfd9 100644
--- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -179,8 +179,8 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Vector3 ofs = aabb.pos + aabb.size*0.5;
aabb.pos-=ofs;
Transform xform;
- xform.basis=Matrix3().rotated(Vector3(0,1,0),Math_PI*0.25);
- xform.basis = Matrix3().rotated(Vector3(1,0,0),-Math_PI*0.25)*xform.basis;
+ xform.basis=Matrix3().rotated(Vector3(0,1,0),-Math_PI*0.25);
+ xform.basis = Matrix3().rotated(Vector3(1,0,0),Math_PI*0.25)*xform.basis;
AABB rot_aabb = xform.xform(aabb);
print_line("rot_aabb: "+rot_aabb);
float m = MAX(rot_aabb.size.x,rot_aabb.size.y)*0.5;
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index fbda0776b0..c07eacf69e 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -807,8 +807,8 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES& p_from) {
Vector3 ofs = aabb.pos + aabb.size*0.5;
aabb.pos-=ofs;
Transform xform;
- xform.basis=Matrix3().rotated(Vector3(0,1,0),Math_PI*0.125);
- xform.basis = Matrix3().rotated(Vector3(1,0,0),-Math_PI*0.125)*xform.basis;
+ xform.basis=Matrix3().rotated(Vector3(0,1,0),-Math_PI*0.125);
+ xform.basis = Matrix3().rotated(Vector3(1,0,0),Math_PI*0.125)*xform.basis;
AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x,rot_aabb.size.y)*0.5;
if (m==0)
diff --git a/tools/editor/plugins/material_editor_plugin.cpp b/tools/editor/plugins/material_editor_plugin.cpp
index 9c279fa967..3ef1818135 100644
--- a/tools/editor/plugins/material_editor_plugin.cpp
+++ b/tools/editor/plugins/material_editor_plugin.cpp
@@ -129,8 +129,8 @@ MaterialEditor::MaterialEditor() {
viewport->add_child(box_instance);
Transform box_xform;
- box_xform.basis.rotate(Vector3(1,0,0),Math::deg2rad(-25));
- box_xform.basis = box_xform.basis * Matrix3().rotated(Vector3(0,1,0),Math::deg2rad(-25));
+ box_xform.basis.rotate(Vector3(1,0,0),Math::deg2rad(25));
+ box_xform.basis = box_xform.basis * Matrix3().rotated(Vector3(0,1,0),Math::deg2rad(25));
box_xform.basis.scale(Vector3(0.8,0.8,0.8));
box_instance->set_transform(box_xform);
diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp
index 785efebfc8..13f3204a05 100644
--- a/tools/editor/plugins/mesh_editor_plugin.cpp
+++ b/tools/editor/plugins/mesh_editor_plugin.cpp
@@ -82,8 +82,8 @@ void MeshEditor::_notification(int p_what) {
void MeshEditor::_update_rotation() {
Transform t;
- t.basis.rotate(Vector3(0, 1, 0), rot_y);
- t.basis.rotate(Vector3(1, 0, 0), rot_x);
+ t.basis.rotate(Vector3(0, 1, 0), -rot_y);
+ t.basis.rotate(Vector3(1, 0, 0), -rot_x);
mesh_instance->set_transform(t);
}
diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp
index 22981a2877..a548f26f1e 100644
--- a/tools/editor/plugins/multimesh_editor_plugin.cpp
+++ b/tools/editor/plugins/multimesh_editor_plugin.cpp
@@ -207,10 +207,10 @@ void MultiMeshEditor::_populate() {
Transform axis_xform;
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);
}
if (axis==Vector3::AXIS_X) {
- axis_xform.rotate(Vector3(0,0,1),Math_PI*0.5);
+ axis_xform.rotate(Vector3(0,0,1),-Math_PI*0.5);
}
for(int i=0;i<instance_count;i++) {
@@ -238,9 +238,9 @@ void MultiMeshEditor::_populate() {
Matrix3 post_xform;
- post_xform.rotate(xform.basis.get_axis(0),Math::random(-_tilt_random,_tilt_random)*Math_PI);
- post_xform.rotate(xform.basis.get_axis(2),Math::random(-_tilt_random,_tilt_random)*Math_PI);
- post_xform.rotate(xform.basis.get_axis(1),Math::random(-_rotate_random,_rotate_random)*Math_PI);
+ post_xform.rotate(xform.basis.get_axis(0),-Math::random(-_tilt_random,_tilt_random)*Math_PI);
+ post_xform.rotate(xform.basis.get_axis(2),-Math::random(-_tilt_random,_tilt_random)*Math_PI);
+ post_xform.rotate(xform.basis.get_axis(1),-Math::random(-_rotate_random,_rotate_random)*Math_PI);
xform.basis = post_xform * xform.basis;
//xform.basis.orthonormalize();
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 44d3b63335..70a256fd2c 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -61,8 +61,8 @@ void SpatialEditorViewport::_update_camera() {
Transform camera_transform;
camera_transform.translate(cursor.pos);
- camera_transform.basis.rotate(Vector3(0, 1, 0), cursor.y_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(1, 0, 0), -cursor.x_rot);
if (orthogonal)
camera_transform.translate(0, 0, 4096);
@@ -474,8 +474,8 @@ Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3& p_pos) {
Transform camera_transform;
camera_transform.translate( cursor.pos );
- camera_transform.basis.rotate(Vector3(0,1,0),cursor.y_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(1,0,0),-cursor.x_rot);
camera_transform.translate(0,0,cursor.distance);
return camera_transform.xform(Vector3( ((p_pos.x/get_size().width)*2.0-1.0)*screen_w, ((1.0-(p_pos.y/get_size().height))*2.0-1.0)*screen_h,-get_znear()));
@@ -1484,7 +1484,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
Transform r;
- r.basis.rotate(plane.normal,-angle);
+ r.basis.rotate(plane.normal,angle);
List<Node*> &selection = editor_selection->get_selected_node_list();
@@ -1591,8 +1591,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
Transform camera_transform;
camera_transform.translate(cursor.pos);
- camera_transform.basis.rotate(Vector3(0,1,0),cursor.y_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(1,0,0),-cursor.x_rot);
Vector3 translation(-m.relative_x*pan_speed,m.relative_y*pan_speed,0);
translation*=cursor.distance/DISTANCE_DEFAULT;
camera_transform.translate(translation);
@@ -2810,7 +2810,7 @@ void SpatialEditor::_xform_dialog_action() {
continue;
Vector3 axis;
axis[i]=1.0;
- t.basis.rotate(axis,rotate[i]);
+ t.basis.rotate(axis,rotate[i]); // BUG(?): Angle not flipped; please check during the review of PR #6865.
}
for(int i=0;i<3;i++) {
@@ -3160,7 +3160,7 @@ void SpatialEditor::_init_indicators() {
- light_transform.rotate(Vector3(1,0,0),Math_PI/5.0);
+ light_transform.rotate(Vector3(1,0,0),-Math_PI/5.0);
VisualServer::get_singleton()->instance_set_transform(light_instance,light_transform);
@@ -3773,8 +3773,8 @@ void SpatialEditor::_update_ambient_light_color(const Color& p_color) {
void SpatialEditor::_update_default_light_angle() {
Transform t;
- t.basis.rotate(Vector3(1,0,0),settings_default_light_rot_x);
- t.basis.rotate(Vector3(0,1,0),settings_default_light_rot_y);
+ t.basis.rotate(Vector3(1,0,0),-settings_default_light_rot_x);
+ t.basis.rotate(Vector3(0,1,0),-settings_default_light_rot_y);
settings_dlight->set_transform(t);
if (light_instance.is_valid()) {
VS::get_singleton()->instance_set_transform(light_instance,t);