summaryrefslogtreecommitdiff
path: root/tools/editor/plugins/spatial_editor_plugin.cpp
diff options
context:
space:
mode:
authorFerenc Arn <tagcup@yahoo.com>2016-10-18 15:50:21 -0500
committerFerenc Arn <tagcup@yahoo.com>2017-01-03 17:41:04 -0600
commitbd7ba0b664fa98381db9ef8edb69ba211213d595 (patch)
tree8e313066ce55a3366cd6b972ff429372583cda28 /tools/editor/plugins/spatial_editor_plugin.cpp
parentf2e99826c0b1e8227644bfab0795d858c504d279 (diff)
Use right handed coordinate system for rotation matrices and quaternions. Also fixes Euler angles (XYZ convention, which is used as default by Blender).
Furthermore, functions which expect a rotation matrix will now give an error simply, rather than trying to orthonormalize such matrices. The documentation for such functions has be updated accordingly. This commit breaks code using 3D rotations, and is a part of the breaking changes in 2.1 -> 3.0 transition. The code affected within Godot code base is fixed in this commit.
Diffstat (limited to 'tools/editor/plugins/spatial_editor_plugin.cpp')
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp22
1 files changed, 11 insertions, 11 deletions
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);