diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2018-09-05 10:11:58 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2018-09-05 10:11:58 +0300 |
commit | 87c5c8e7f6de6e6773baa590ca43edb4fc71f5ac (patch) | |
tree | f4bf623973f08b3d8bdfbddb98b79d38fd38a1f0 /xs/src/slic3r/GUI | |
parent | 15b13405141ca7481f156d204a917fab38c30dc1 (diff) |
Renamed GLVolume member variables to match the corresponding ModelInstance ones
Diffstat (limited to 'xs/src/slic3r/GUI')
-rw-r--r-- | xs/src/slic3r/GUI/3DScene.cpp | 70 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/3DScene.hpp | 19 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3D.cpp | 22 |
3 files changed, 58 insertions, 53 deletions
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 08a1b1457..3f44b727e 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -195,9 +195,9 @@ const float GLVolume::OUTSIDE_COLOR[4] = { 0.0f, 0.38f, 0.8f, 1.0f }; const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 0.19f, 0.58f, 1.0f, 1.0f }; GLVolume::GLVolume(float r, float g, float b, float a) - : m_origin(0, 0, 0) - , m_angle_z(0.0f) - , m_scale_factor(1.0f) + : m_offset(Vec3d::Zero()) + , m_rotation(0.0) + , m_scaling_factor(1.0) , m_world_matrix(Transform3f::Identity()) , m_world_matrix_dirty(true) , m_transformed_bounding_box_dirty(true) @@ -255,43 +255,43 @@ void GLVolume::set_render_color() set_render_color(color, 4); } -const Vec3d& GLVolume::get_origin() const +double GLVolume::get_rotation() { - return m_origin; + return m_rotation; } -float GLVolume::get_angle_z() +void GLVolume::set_rotation(double rotation) { - return m_angle_z; -} - -void GLVolume::set_origin(const Vec3d& origin) -{ - if (m_origin != origin) + if (m_rotation != rotation) { - m_origin = origin; + m_rotation = rotation; m_world_matrix_dirty = true; m_transformed_bounding_box_dirty = true; m_transformed_convex_hull_bounding_box_dirty = true; } } -void GLVolume::set_angle_z(float angle_z) +const Vec3d& GLVolume::get_offset() const +{ + return m_offset; +} + +void GLVolume::set_offset(const Vec3d& offset) { - if (m_angle_z != angle_z) + if (m_offset != offset) { - m_angle_z = angle_z; + m_offset = offset; m_world_matrix_dirty = true; m_transformed_bounding_box_dirty = true; m_transformed_convex_hull_bounding_box_dirty = true; } } -void GLVolume::set_scale_factor(float scale_factor) +void GLVolume::set_scaling_factor(double factor) { - if (m_scale_factor != scale_factor) + if (m_scaling_factor != factor) { - m_scale_factor = scale_factor; + m_scaling_factor = factor; m_world_matrix_dirty = true; m_transformed_bounding_box_dirty = true; m_transformed_convex_hull_bounding_box_dirty = true; @@ -308,9 +308,9 @@ const Transform3f& GLVolume::world_matrix() const if (m_world_matrix_dirty) { m_world_matrix = Transform3f::Identity(); - m_world_matrix.translate(Vec3f((float)m_origin(0), (float)m_origin(1), (float)m_origin(2))); - m_world_matrix.rotate(Eigen::AngleAxisf(m_angle_z, Vec3f::UnitZ())); - m_world_matrix.scale(m_scale_factor); + m_world_matrix.translate(m_offset.cast<float>()); + m_world_matrix.rotate(Eigen::AngleAxisf((float)m_rotation, Vec3f::UnitZ())); + m_world_matrix.scale((float)m_scaling_factor); m_world_matrix_dirty = false; } return m_world_matrix; @@ -384,9 +384,9 @@ void GLVolume::render() const ::glCullFace(GL_BACK); ::glPushMatrix(); - ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); - ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); - ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); + ::glTranslated(m_offset(0), m_offset(1), m_offset(2)); + ::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0); + ::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor); if (this->indexed_vertex_array.indexed()) this->indexed_vertex_array.render(this->tverts_range, this->qverts_range); else @@ -510,9 +510,9 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c ::glNormalPointer(GL_FLOAT, 6 * sizeof(float), nullptr); ::glPushMatrix(); - ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); - ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); - ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); + ::glTranslated(m_offset(0), m_offset(1), m_offset(2)); + ::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0); + ::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor); if (n_triangles > 0) { @@ -555,9 +555,9 @@ void GLVolume::render_legacy() const ::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data()); ::glPushMatrix(); - ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); - ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); - ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); + ::glTranslated(m_offset(0), m_offset(1), m_offset(2)); + ::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0); + ::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor); if (n_triangles > 0) ::glDrawElements(GL_TRIANGLES, n_triangles, GL_UNSIGNED_INT, indexed_vertex_array.triangle_indices.data() + tverts_range.first); @@ -675,9 +675,9 @@ std::vector<int> GLVolumeCollection::load_object( } v.is_modifier = model_volume->modifier; v.shader_outside_printer_detection_enabled = !model_volume->modifier; - v.set_origin(Vec3d(instance->offset(0), instance->offset(1), 0.0)); - v.set_angle_z(instance->rotation); - v.set_scale_factor(instance->scaling_factor); + v.set_offset(Vec3d(instance->offset(0), instance->offset(1), 0.0)); + v.set_rotation(instance->rotation); + v.set_scaling_factor(instance->scaling_factor); } } @@ -746,7 +746,7 @@ int GLVolumeCollection::load_wipe_tower_preview( else v.indexed_vertex_array.load_mesh_flat_shading(mesh); - v.set_origin(Vec3d(pos_x, pos_y, 0.)); + v.set_offset(Vec3d(pos_x, pos_y, 0.0)); // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). v.bounding_box = v.indexed_vertex_array.bounding_box(); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 69f1e1d35..1785ecf4a 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -255,11 +255,11 @@ public: private: // Offset of the volume to be rendered. - Vec3d m_origin; + Vec3d m_offset; // Rotation around Z axis of the volume to be rendered. - float m_angle_z; + double m_rotation; // Scale factor of the volume to be rendered. - float m_scale_factor; + double m_scaling_factor; // World matrix of the volume to be rendered. mutable Transform3f m_world_matrix; // Whether or not is needed to recalculate the world matrix. @@ -327,11 +327,14 @@ public: // Sets render color in dependence of current state void set_render_color(); - float get_angle_z(); - const Vec3d& get_origin() const; - void set_origin(const Vec3d& origin); - void set_angle_z(float angle_z); - void set_scale_factor(float scale_factor); + double get_rotation(); + void set_rotation(double rotation); + + const Vec3d& get_offset() const; + void set_offset(const Vec3d& offset); + + void set_scaling_factor(double factor); + void set_convex_hull(const TriangleMesh& convex_hull); int object_idx() const { return this->composite_id / 1000000; } diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index bbc73b896..73966a7f5 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -3001,7 +3001,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) Vec3d normal = m_gizmos.get_flattening_normal(); if (normal != Vec3d::Zero()) { Vec3d axis = normal(2) > 0.999f ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ()); - float angle = -acos(-normal(2)); + float angle = acos(-normal(2)); m_on_gizmo_rotate_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2)); } } @@ -3126,7 +3126,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Apply new temporary volume origin and ignore Z. for (GLVolume* v : volumes) - v->set_origin(v->get_origin() + Vec3d(vector(0), vector(1), 0.0)); + { + v->set_offset(v->get_offset() + Vec3d(vector(0), vector(1), 0.0)); + } m_mouse.drag.start_position_3D = cur_pos; m_gizmos.refresh(); @@ -3166,7 +3168,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) float scale_factor = m_gizmos.get_scale(); for (GLVolume* v : volumes) { - v->set_scale_factor(scale_factor); + v->set_scaling_factor((double)scale_factor); } break; } @@ -3176,7 +3178,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) float angle_z = m_gizmos.get_angle_z(); for (GLVolume* v : volumes) { - v->set_angle_z(angle_z); + v->set_rotation((double)angle_z); } break; } @@ -3194,7 +3196,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) const Vec3d& size = bb.size(); m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale()); update_scale_values(size, m_gizmos.get_scale()); - update_rotation_value(volumes[0]->get_angle_z(), "z"); + update_rotation_value(volumes[0]->get_rotation(), "z"); } if ((m_gizmos.get_current_type() != Gizmos::Rotate) && (volumes.size() > 1)) @@ -5219,7 +5221,7 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs) std::set<std::string> done; // prevent moving instances twice bool object_moved = false; - Vec3d wipe_tower_origin(0.0, 0.0, 0.0); + Vec3d wipe_tower_origin = Vec3d::Zero(); for (int volume_idx : volume_idxs) { GLVolume* volume = m_volumes.volumes[volume_idx]; @@ -5238,20 +5240,20 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs) { // Move a regular object. ModelObject* model_object = m_model->objects[obj_idx]; - const Vec3d& origin = volume->get_origin(); - model_object->instances[instance_idx]->offset = Vec2d(origin(0), origin(1)); + const Vec3d& offset = volume->get_offset(); + model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1)); model_object->invalidate_bounding_box(); object_moved = true; } else if (obj_idx == 1000) // Move a wipe tower proxy. - wipe_tower_origin = volume->get_origin(); + wipe_tower_origin = volume->get_offset(); } if (object_moved) m_on_instance_moved_callback.call(); - if (wipe_tower_origin != Vec3d(0.0, 0.0, 0.0)) + if (wipe_tower_origin != Vec3d::Zero()) m_on_wipe_tower_moved_callback.call(wipe_tower_origin(0), wipe_tower_origin(1)); } |