Merge remote-tracking branch 'origin/dev2' into dev_native

This commit is contained in:
bubnikv 2018-09-25 15:33:51 +02:00
commit 6260e43f61
30 changed files with 785 additions and 443 deletions

View file

@ -196,12 +196,13 @@ 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_offset(Vec3d::Zero())
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
, m_rotation(Vec3d::Zero())
, m_scaling_factor(Vec3d::Ones())
#else
, m_rotation(0.0)
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
, m_scaling_factor(1.0)
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
, m_world_matrix(Transform3f::Identity())
, m_world_matrix_dirty(true)
, m_transformed_bounding_box_dirty(true)
@ -259,7 +260,7 @@ void GLVolume::set_render_color()
set_render_color(color, 4);
}
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& GLVolume::get_rotation() const
{
return m_rotation;
@ -291,7 +292,7 @@ void GLVolume::set_rotation(double rotation)
m_transformed_convex_hull_bounding_box_dirty = true;
}
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& GLVolume::get_offset() const
{
@ -309,6 +310,18 @@ void GLVolume::set_offset(const Vec3d& offset)
}
}
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLVolume::set_scaling_factor(const Vec3d& scaling_factor)
{
if (m_scaling_factor != scaling_factor)
{
m_scaling_factor = scaling_factor;
m_world_matrix_dirty = true;
m_transformed_bounding_box_dirty = true;
m_transformed_convex_hull_bounding_box_dirty = true;
}
}
#else
void GLVolume::set_scaling_factor(double factor)
{
if (m_scaling_factor != factor)
@ -319,6 +332,7 @@ void GLVolume::set_scaling_factor(double factor)
m_transformed_convex_hull_bounding_box_dirty = true;
}
}
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLVolume::set_convex_hull(const TriangleMesh& convex_hull)
{
@ -349,14 +363,15 @@ const Transform3f& GLVolume::world_matrix() const
{
m_world_matrix = Transform3f::Identity();
m_world_matrix.translate(m_offset.cast<float>());
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_world_matrix.rotate(Eigen::AngleAxisf((float)m_rotation(2), Vec3f::UnitZ()));
m_world_matrix.rotate(Eigen::AngleAxisf((float)m_rotation(1), Vec3f::UnitY()));
m_world_matrix.rotate(Eigen::AngleAxisf((float)m_rotation(0), Vec3f::UnitX()));
m_world_matrix.scale(m_scaling_factor.cast<float>());
#else
m_world_matrix.rotate(Eigen::AngleAxisf((float)m_rotation, Vec3f::UnitZ()));
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
m_world_matrix.scale((float)m_scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_world_matrix_dirty = false;
}
return m_world_matrix;
@ -430,15 +445,14 @@ void GLVolume::render() const
::glCullFace(GL_BACK);
::glPushMatrix();
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
#if ENABLE_MODELINSTANCE_3D_ROTATION
::glRotated(m_rotation(2) * 180.0 / (double)PI, 0.0, 0.0, 1.0);
::glRotated(m_rotation(1) * 180.0 / (double)PI, 0.0, 1.0, 0.0);
::glRotated(m_rotation(0) * 180.0 / (double)PI, 1.0, 0.0, 0.0);
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
::glMultMatrixf(world_matrix().data());
#else
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
if (this->indexed_vertex_array.indexed())
this->indexed_vertex_array.render(this->tverts_range, this->qverts_range);
else
@ -562,15 +576,14 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c
::glNormalPointer(GL_FLOAT, 6 * sizeof(float), nullptr);
::glPushMatrix();
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
#if ENABLE_MODELINSTANCE_3D_ROTATION
::glRotated(m_rotation(2) * 180.0 / (double)PI, 0.0, 0.0, 1.0);
::glRotated(m_rotation(1) * 180.0 / (double)PI, 0.0, 1.0, 0.0);
::glRotated(m_rotation(0) * 180.0 / (double)PI, 1.0, 0.0, 0.0);
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
::glMultMatrixf(world_matrix().data());
#else
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
if (n_triangles > 0)
{
@ -613,15 +626,14 @@ void GLVolume::render_legacy() const
::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data());
::glPushMatrix();
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
#if ENABLE_MODELINSTANCE_3D_ROTATION
::glRotated(m_rotation(2) * 180.0 / (double)PI, 0.0, 0.0, 1.0);
::glRotated(m_rotation(1) * 180.0 / (double)PI, 0.0, 1.0, 0.0);
::glRotated(m_rotation(0) * 180.0 / (double)PI, 1.0, 0.0, 0.0);
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
::glMultMatrixf(world_matrix().data());
#else
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
if (n_triangles > 0)
::glDrawElements(GL_TRIANGLES, n_triangles, GL_UNSIGNED_INT, indexed_vertex_array.triangle_indices.data() + tverts_range.first);
@ -739,17 +751,15 @@ std::vector<int> GLVolumeCollection::load_object(
}
v.is_modifier = ! model_volume->is_model_part();
v.shader_outside_printer_detection_enabled = model_volume->is_model_part();
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
v.set_offset(instance->get_offset());
v.set_rotation(instance->get_rotation());
v.set_scaling_factor(instance->get_scaling_factor());
#else
v.set_offset(Vec3d(instance->offset(0), instance->offset(1), 0.0));
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
v.set_rotation(instance->get_rotation());
#else
v.set_rotation(instance->rotation);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
v.set_scaling_factor(instance->scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
}
@ -2112,40 +2122,58 @@ void _3DScene::register_on_enable_action_buttons_callback(wxGLCanvas* canvas, vo
void _3DScene::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback)
{
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_gizmo_scale_uniformly_callback(canvas, callback);
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback)
{
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_gizmo_scale_3D_callback(canvas, callback);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback)
{
#if !ENABLE_MODELINSTANCE_3D_ROTATION
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_gizmo_rotate_callback(canvas, callback);
#endif // !ENABLE_MODELINSTANCE_3D_ROTATION
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback)
{
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_gizmo_rotate_3D_callback(canvas, callback);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
{
#if !ENABLE_MODELINSTANCE_3D_ROTATION
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_gizmo_flatten_callback(canvas, callback);
#endif // !ENABLE_MODELINSTANCE_3D_ROTATION
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback)
{
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_gizmo_flatten_3D_callback(canvas, callback);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
{
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_update_geometry_info_callback(canvas, callback);
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback)
{
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
s_canvas_mgr.register_on_update_geometry_3D_info_callback(canvas, callback);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void _3DScene::register_action_add_callback(wxGLCanvas* canvas, void* callback)

View file

@ -256,15 +256,17 @@ public:
private:
// Offset of the volume to be rendered.
Vec3d m_offset;
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// Rotation around three axes of the volume to be rendered.
Vec3d m_rotation;
// Scale factor along the three axes of the volume to be rendered.
Vec3d m_scaling_factor;
#else
// Rotation around Z axis of the volume to be rendered.
double m_rotation;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
// Scale factor of the volume to be rendered.
double m_scaling_factor;
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// World matrix of the volume to be rendered.
mutable Transform3f m_world_matrix;
// Whether or not is needed to recalculate the world matrix.
@ -332,19 +334,21 @@ public:
// Sets render color in dependence of current state
void set_render_color();
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& get_rotation() const;
void set_rotation(const Vec3d& rotation);
void set_scaling_factor(const Vec3d& scaling_factor);
#else
double get_rotation() const;
void set_rotation(double rotation);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
void set_scaling_factor(double factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
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);
void set_select_group_id(const std::string& select_by);
@ -567,11 +571,13 @@ public:
static void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
static void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
static void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
static void register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback);
static void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
static void register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback);
static void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
static void register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback);
static void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
static void register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback);
static void register_action_add_callback(wxGLCanvas* canvas, void* callback);
static void register_action_delete_callback(wxGLCanvas* canvas, void* callback);

View file

@ -1145,10 +1145,10 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
if (!gizmo->init())
return false;
#if !ENABLE_MODELINSTANCE_3D_OFFSET
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// temporary disable z grabber
gizmo->disable_grabber(2);
#endif // !ENABLE_MODELINSTANCE_3D_OFFSET
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
@ -1159,6 +1159,7 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
if (!gizmo->init())
return false;
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// temporary disable x grabbers
gizmo->disable_grabber(0);
gizmo->disable_grabber(1);
@ -1168,6 +1169,7 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
// temporary disable z grabbers
gizmo->disable_grabber(4);
gizmo->disable_grabber(5);
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.insert(GizmosMap::value_type(Scale, gizmo));
@ -1184,11 +1186,11 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
return false;
}
#if !ENABLE_MODELINSTANCE_3D_ROTATION
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// temporary disable x and y grabbers
gizmo->disable_grabber(0);
gizmo->disable_grabber(1);
#endif // !ENABLE_MODELINSTANCE_3D_ROTATION
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.insert(GizmosMap::value_type(Rotate, gizmo));
@ -1419,16 +1421,17 @@ void GLCanvas3D::Gizmos::set_position(const Vec3d& position)
reinterpret_cast<GLGizmoMove3D*>(it->second)->set_position(position);
}
float GLCanvas3D::Gizmos::get_scale() const
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d GLCanvas3D::Gizmos::get_scale() const
{
if (!m_enabled)
return 1.0f;
return Vec3d::Ones();
GizmosMap::const_iterator it = m_gizmos.find(Scale);
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoScale3D*>(it->second)->get_scale_x() : 1.0f;
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoScale3D*>(it->second)->get_scale() : Vec3d::Ones();
}
void GLCanvas3D::Gizmos::set_scale(float scale)
void GLCanvas3D::Gizmos::set_scale(const Vec3d& scale)
{
if (!m_enabled)
return;
@ -1438,7 +1441,6 @@ void GLCanvas3D::Gizmos::set_scale(float scale)
reinterpret_cast<GLGizmoScale3D*>(it->second)->set_scale(scale);
}
#if ENABLE_MODELINSTANCE_3D_ROTATION
Vec3d GLCanvas3D::Gizmos::get_rotation() const
{
if (!m_enabled)
@ -1467,6 +1469,25 @@ Vec3d GLCanvas3D::Gizmos::get_flattening_rotation() const
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoFlatten*>(it->second)->get_flattening_rotation() : Vec3d::Zero();
}
#else
float GLCanvas3D::Gizmos::get_scale() const
{
if (!m_enabled)
return 1.0f;
GizmosMap::const_iterator it = m_gizmos.find(Scale);
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoScale3D*>(it->second)->get_scale_x() : 1.0f;
}
void GLCanvas3D::Gizmos::set_scale(float scale)
{
if (!m_enabled)
return;
GizmosMap::const_iterator it = m_gizmos.find(Scale);
if (it != m_gizmos.end())
reinterpret_cast<GLGizmoScale3D*>(it->second)->set_scale(scale);
}
float GLCanvas3D::Gizmos::get_angle_z() const
{
if (!m_enabled)
@ -1494,7 +1515,7 @@ Vec3d GLCanvas3D::Gizmos::get_flattening_normal() const
GizmosMap::const_iterator it = m_gizmos.find(Flatten);
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoFlatten*>(it->second)->get_flattening_normal() : Vec3d::Zero();
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLCanvas3D::Gizmos::set_flattening_data(const ModelObject* model_object)
{
@ -2426,17 +2447,15 @@ void GLCanvas3D::update_gizmos_data()
ModelInstance* model_instance = model_object->instances[0];
if (model_instance != nullptr)
{
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.set_position(model_instance->get_offset());
#else
m_gizmos.set_position(Vec3d(model_instance->offset(0), model_instance->offset(1), 0.0));
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
m_gizmos.set_scale(model_instance->scaling_factor);
#if ENABLE_MODELINSTANCE_3D_ROTATION
m_gizmos.set_scale(model_instance->get_scaling_factor());
m_gizmos.set_rotation(model_instance->get_rotation());
#else
m_gizmos.set_position(Vec3d(model_instance->offset(0), model_instance->offset(1), 0.0));
m_gizmos.set_scale(model_instance->scaling_factor);
m_gizmos.set_angle_z(model_instance->rotation);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.set_flattening_data(model_object);
}
}
@ -2444,12 +2463,13 @@ void GLCanvas3D::update_gizmos_data()
else
{
m_gizmos.set_position(Vec3d::Zero());
m_gizmos.set_scale(1.0f);
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.set_scale(Vec3d::Ones());
m_gizmos.set_rotation(Vec3d::Zero());
#else
m_gizmos.set_scale(1.0f);
m_gizmos.set_angle_z(0.0f);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_gizmos.set_flattening_data(nullptr);
}
}
@ -2806,13 +2826,13 @@ void GLCanvas3D::register_on_enable_action_buttons_callback(void* callback)
m_on_enable_action_buttons_callback.register_callback(callback);
}
void GLCanvas3D::register_on_gizmo_scale_uniformly_callback(void* callback)
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLCanvas3D::register_on_gizmo_scale_3D_callback(void* callback)
{
if (callback != nullptr)
m_on_gizmo_scale_uniformly_callback.register_callback(callback);
m_on_gizmo_scale_3D_callback.register_callback(callback);
}
#if ENABLE_MODELINSTANCE_3D_ROTATION
void GLCanvas3D::register_on_gizmo_rotate_3D_callback(void* callback)
{
if (callback != nullptr)
@ -2824,7 +2844,19 @@ void GLCanvas3D::register_on_gizmo_flatten_3D_callback(void* callback)
if (callback != nullptr)
m_on_gizmo_flatten_3D_callback.register_callback(callback);
}
void GLCanvas3D::register_on_update_geometry_3D_info_callback(void* callback)
{
if (callback != nullptr)
m_on_update_geometry_3D_info_callback.register_callback(callback);
}
#else
void GLCanvas3D::register_on_gizmo_scale_uniformly_callback(void* callback)
{
if (callback != nullptr)
m_on_gizmo_scale_uniformly_callback.register_callback(callback);
}
void GLCanvas3D::register_on_gizmo_rotate_callback(void* callback)
{
if (callback != nullptr)
@ -2836,13 +2868,13 @@ void GLCanvas3D::register_on_gizmo_flatten_callback(void* callback)
if (callback != nullptr)
m_on_gizmo_flatten_callback.register_callback(callback);
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
void GLCanvas3D::register_on_update_geometry_info_callback(void* callback)
{
if (callback != nullptr)
m_on_update_geometry_info_callback.register_callback(callback);
}
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLCanvas3D::register_action_add_callback(void* callback)
{
@ -3115,27 +3147,30 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
#if ENABLE_GIZMOS_RESET
else if (evt.LeftDClick() && m_gizmos.grabber_contains_mouse())
{
#if ENABLE_GIZMOS_RESET
m_mouse.ignore_up_event = true;
#endif // ENABLE_GIZMOS_RESET
m_gizmos.process_double_click();
switch (m_gizmos.get_current_type())
{
case Gizmos::Scale:
{
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& scale = m_gizmos.get_scale();
m_on_gizmo_scale_3D_callback.call(scale(0), scale(1), scale(2));
#else
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
update_scale_values();
m_dirty = true;
break;
}
case Gizmos::Rotate:
{
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& rotation = m_gizmos.get_rotation();
m_on_gizmo_rotate_3D_callback.call(rotation(0), rotation(1), rotation(2));
#else
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
update_rotation_values();
m_dirty = true;
break;
@ -3187,7 +3222,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_mouse.drag.gizmo_volume_idx = _get_first_selected_volume_id(selected_object_idx);
if (m_gizmos.get_current_type() == Gizmos::Flatten) {
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// Rotate the object so the normal points downward:
const Vec3d& rotation = m_gizmos.get_flattening_rotation();
m_on_gizmo_flatten_3D_callback.call(rotation(0), rotation(1), rotation(2));
@ -3199,7 +3234,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
float angle = acos(clamp(-1.0, 1.0, -normal(2)));
m_on_gizmo_flatten_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2));
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
m_dirty = true;
@ -3371,6 +3406,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
case Gizmos::Scale:
{
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// Apply new temporary scale factors
const Vec3d& scale = m_gizmos.get_scale();
for (GLVolume* v : volumes)
{
v->set_scaling_factor(scale);
}
update_scale_values(scale);
#else
// Apply new temporary scale factor
float scale_factor = m_gizmos.get_scale();
for (GLVolume* v : volumes)
@ -3378,13 +3422,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
v->set_scaling_factor((double)scale_factor);
}
update_scale_values((double)scale_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
break;
}
case Gizmos::Rotate:
{
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// Apply new temporary rotation
Vec3d rotation = m_gizmos.get_rotation();
const Vec3d& rotation = m_gizmos.get_rotation();
for (GLVolume* v : volumes)
{
v->set_rotation(rotation);
@ -3398,7 +3443,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
v->set_rotation((double)angle_z);
}
update_rotation_value((double)angle_z, Z);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
break;
}
default:
@ -3413,7 +3458,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
bb.merge(volume->transformed_bounding_box());
}
const Vec3d& size = bb.size();
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& scale = m_gizmos.get_scale();
m_on_update_geometry_3D_info_callback.call(size(0), size(1), size(2), scale(0), scale(1), scale(2));
#else
m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale());
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
m_dirty = true;
@ -3539,17 +3589,22 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
case Gizmos::Scale:
{
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& scale = m_gizmos.get_scale();
m_on_gizmo_scale_3D_callback.call(scale(0), scale(1), scale(2));
#else
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
break;
}
case Gizmos::Rotate:
{
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& rotation = m_gizmos.get_rotation();
m_on_gizmo_rotate_3D_callback.call(rotation(0), rotation(1), rotation(2));
#else
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
break;
}
default:
@ -3995,15 +4050,17 @@ void GLCanvas3D::_deregister_callbacks()
m_on_instance_moved_callback.deregister_callback();
m_on_wipe_tower_moved_callback.deregister_callback();
m_on_enable_action_buttons_callback.deregister_callback();
m_on_gizmo_scale_uniformly_callback.deregister_callback();
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_on_gizmo_scale_3D_callback.deregister_callback();
m_on_gizmo_rotate_3D_callback.deregister_callback();
m_on_gizmo_flatten_3D_callback.deregister_callback();
m_on_update_geometry_3D_info_callback.deregister_callback();
#else
m_on_gizmo_scale_uniformly_callback.deregister_callback();
m_on_gizmo_rotate_callback.deregister_callback();
m_on_gizmo_flatten_callback.deregister_callback();
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
m_on_update_geometry_info_callback.deregister_callback();
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_action_add_callback.deregister_callback();
m_action_delete_callback.deregister_callback();
@ -5510,12 +5567,12 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
ModelObject* model_object = m_model->objects[obj_idx];
if (model_object != nullptr)
{
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
model_object->instances[instance_idx]->set_offset(volume->get_offset());
#else
const Vec3d& offset = volume->get_offset();
model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1));
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
model_object->invalidate_bounding_box();
update_position_values();
object_moved = true;

View file

@ -384,22 +384,24 @@ class GLCanvas3D
Vec3d get_position() const;
void set_position(const Vec3d& position);
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d get_scale() const;
void set_scale(const Vec3d& scale);
Vec3d get_rotation() const;
void set_rotation(const Vec3d& rotation);
Vec3d get_flattening_rotation() const;
#else
float get_scale() const;
void set_scale(float scale);
#if ENABLE_MODELINSTANCE_3D_ROTATION
Vec3d get_rotation() const;
void set_rotation(const Vec3d& rotation);
#else
float get_angle_z() const;
void set_angle_z(float angle_z);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_ROTATION
Vec3d get_flattening_rotation() const;
#else
Vec3d get_flattening_normal() const;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void set_flattening_data(const ModelObject* model_object);
void render_current_gizmo(const BoundingBoxf3& box) const;
@ -515,15 +517,17 @@ class GLCanvas3D
PerlCallback m_on_instance_moved_callback;
PerlCallback m_on_wipe_tower_moved_callback;
PerlCallback m_on_enable_action_buttons_callback;
PerlCallback m_on_gizmo_scale_uniformly_callback;
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
PerlCallback m_on_gizmo_rotate_3D_callback;
PerlCallback m_on_gizmo_flatten_3D_callback;
PerlCallback m_on_gizmo_scale_3D_callback;
PerlCallback m_on_update_geometry_3D_info_callback;
#else
PerlCallback m_on_gizmo_scale_uniformly_callback;
PerlCallback m_on_gizmo_rotate_callback;
PerlCallback m_on_gizmo_flatten_callback;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
PerlCallback m_on_update_geometry_info_callback;
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
PerlCallback m_action_add_callback;
PerlCallback m_action_delete_callback;
@ -645,15 +649,17 @@ public:
void register_on_instance_moved_callback(void* callback);
void register_on_wipe_tower_moved_callback(void* callback);
void register_on_enable_action_buttons_callback(void* callback);
void register_on_gizmo_scale_uniformly_callback(void* callback);
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void register_on_gizmo_scale_3D_callback(void* callback);
void register_on_gizmo_rotate_3D_callback(void* callback);
void register_on_gizmo_flatten_3D_callback(void* callback);
void register_on_update_geometry_3D_info_callback(void* callback);
#else
void register_on_gizmo_scale_uniformly_callback(void* callback);
void register_on_gizmo_rotate_callback(void* callback);
void register_on_gizmo_flatten_callback(void* callback);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
void register_on_update_geometry_info_callback(void* callback);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void register_action_add_callback(void* callback);
void register_action_delete_callback(void* callback);

View file

@ -692,14 +692,14 @@ void GLCanvas3DManager::register_on_enable_action_buttons_callback(wxGLCanvas* c
it->second->register_on_enable_action_buttons_callback(callback);
}
void GLCanvas3DManager::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback)
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLCanvas3DManager::register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback)
{
CanvasesMap::iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->register_on_gizmo_scale_uniformly_callback(callback);
it->second->register_on_gizmo_scale_3D_callback(callback);
}
#if ENABLE_MODELINSTANCE_3D_ROTATION
void GLCanvas3DManager::register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback)
{
CanvasesMap::iterator it = _get_canvas(canvas);
@ -713,7 +713,21 @@ void GLCanvas3DManager::register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas
if (it != m_canvases.end())
it->second->register_on_gizmo_flatten_3D_callback(callback);
}
void GLCanvas3DManager::register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback)
{
CanvasesMap::iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->register_on_update_geometry_3D_info_callback(callback);
}
#else
void GLCanvas3DManager::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback)
{
CanvasesMap::iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->register_on_gizmo_scale_uniformly_callback(callback);
}
void GLCanvas3DManager::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback)
{
CanvasesMap::iterator it = _get_canvas(canvas);
@ -727,7 +741,6 @@ void GLCanvas3DManager::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, v
if (it != m_canvases.end())
it->second->register_on_gizmo_flatten_callback(callback);
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
void GLCanvas3DManager::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
{
@ -735,6 +748,7 @@ void GLCanvas3DManager::register_on_update_geometry_info_callback(wxGLCanvas* ca
if (it != m_canvases.end())
it->second->register_on_update_geometry_info_callback(callback);
}
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void GLCanvas3DManager::register_action_add_callback(wxGLCanvas* canvas, void* callback)
{

View file

@ -162,15 +162,17 @@ public:
void register_on_instance_moved_callback(wxGLCanvas* canvas, void* callback);
void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void register_on_gizmo_scale_3D_callback(wxGLCanvas* canvas, void* callback);
void register_on_gizmo_rotate_3D_callback(wxGLCanvas* canvas, void* callback);
void register_on_gizmo_flatten_3D_callback(wxGLCanvas* canvas, void* callback);
void register_on_update_geometry_3D_info_callback(wxGLCanvas* canvas, void* callback);
#else
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void register_action_add_callback(wxGLCanvas* canvas, void* callback);
void register_action_delete_callback(wxGLCanvas* canvas, void* callback);

View file

@ -336,10 +336,9 @@ const unsigned int GLGizmoRotate::AngleResolution = 64;
const unsigned int GLGizmoRotate::ScaleStepsCount = 72;
const float GLGizmoRotate::ScaleStepRad = 2.0f * (float)PI / GLGizmoRotate::ScaleStepsCount;
const unsigned int GLGizmoRotate::ScaleLongEvery = 2;
const float GLGizmoRotate::ScaleLongTooth = 2.0f;
const float GLGizmoRotate::ScaleShortTooth = 1.0f;
const float GLGizmoRotate::ScaleLongTooth = 0.1f; // in percent of radius
const unsigned int GLGizmoRotate::SnapRegionsCount = 8;
const float GLGizmoRotate::GrabberOffset = 5.0f;
const float GLGizmoRotate::GrabberOffset = 0.15f; // in percent of radius
GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
: GLGizmoBase(parent)
@ -347,6 +346,10 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
, m_angle(0.0)
, m_center(0.0, 0.0, 0.0)
, m_radius(0.0f)
, m_snap_coarse_in_radius(0.0f)
, m_snap_coarse_out_radius(0.0f)
, m_snap_fine_in_radius(0.0f)
, m_snap_fine_out_radius(0.0f)
{
}
@ -368,6 +371,10 @@ void GLGizmoRotate::on_start_dragging(const BoundingBoxf3& box)
{
m_center = box.center();
m_radius = Offset + box.radius();
m_snap_coarse_in_radius = m_radius / 3.0f;
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
m_snap_fine_in_radius = m_radius;
m_snap_fine_out_radius = m_snap_fine_in_radius + m_radius * ScaleLongTooth;
}
void GLGizmoRotate::on_update(const Linef3& mouse_ray)
@ -383,20 +390,16 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
double len = mouse_pos.norm();
// snap to snap region
double in_radius = (double)m_radius / 3.0;
double out_radius = 2.0 * (double)in_radius;
if ((in_radius <= len) && (len <= out_radius))
// snap to coarse snap region
if ((m_snap_coarse_in_radius <= len) && (len <= m_snap_coarse_out_radius))
{
double step = 2.0 * (double)PI / (double)SnapRegionsCount;
theta = step * (double)std::round(theta / step);
}
else
{
// snap to scale
in_radius = (double)m_radius;
out_radius = in_radius + (double)ScaleLongTooth;
if ((in_radius <= len) && (len <= out_radius))
// snap to fine snap region (scale)
if ((m_snap_fine_in_radius <= len) && (len <= m_snap_fine_out_radius))
{
double step = 2.0 * (double)PI / (double)ScaleStepsCount;
theta = step * (double)std::round(theta / step);
@ -420,6 +423,10 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
{
m_center = box.center();
m_radius = Offset + box.radius();
m_snap_coarse_in_radius = m_radius / 3.0f;
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
m_snap_fine_in_radius = m_radius;
m_snap_fine_out_radius = m_radius * (1.0f + ScaleLongTooth);
}
::glEnable(GL_DEPTH_TEST);
@ -477,8 +484,8 @@ void GLGizmoRotate::render_circle() const
void GLGizmoRotate::render_scale() const
{
float out_radius_long = m_radius + ScaleLongTooth;
float out_radius_short = m_radius + ScaleShortTooth;
float out_radius_long = m_snap_fine_out_radius;
float out_radius_short = m_radius * (1.0f + 0.5f * ScaleLongTooth);
::glBegin(GL_LINES);
for (unsigned int i = 0; i < ScaleStepsCount; ++i)
@ -527,14 +534,14 @@ void GLGizmoRotate::render_reference_radius() const
{
::glBegin(GL_LINES);
::glVertex3f(0.0f, 0.0f, 0.0f);
::glVertex3f((GLfloat)(m_radius + GrabberOffset), 0.0f, 0.0f);
::glVertex3f((GLfloat)(m_radius * (1.0f + GrabberOffset)), 0.0f, 0.0f);
::glEnd();
}
void GLGizmoRotate::render_angle() const
{
float step_angle = (float)m_angle / AngleResolution;
float ex_radius = m_radius + GrabberOffset;
float ex_radius = m_radius * (1.0f + GrabberOffset);
::glBegin(GL_LINE_STRIP);
for (unsigned int i = 0; i <= AngleResolution; ++i)
@ -550,7 +557,7 @@ void GLGizmoRotate::render_angle() const
void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
{
double grabber_radius = (double)(m_radius + GrabberOffset);
double grabber_radius = (double)m_radius * (1.0 + (double)GrabberOffset);
m_grabbers[0].center = Vec3d(::cos(m_angle) * grabber_radius, ::sin(m_angle) * grabber_radius, 0.0);
m_grabbers[0].angles(2) = m_angle;
@ -762,13 +769,7 @@ void GLGizmoScale3D::on_update(const Linef3& mouse_ray)
#if ENABLE_GIZMOS_RESET
void GLGizmoScale3D::on_process_double_click()
{
if ((m_hover_id == 0) || (m_hover_id == 1))
m_scale(0) = 1.0;
else if ((m_hover_id == 2) || (m_hover_id == 3))
m_scale(1) = 1.0;
else if ((m_hover_id == 4) || (m_hover_id == 5))
m_scale(2) = 1.0;
else if (m_hover_id >= 6)
if (m_hover_id >= 6)
m_scale = Vec3d::Ones();
}
#endif // ENABLE_GIZMOS_RESET
@ -980,8 +981,11 @@ void GLGizmoScale3D::do_scale_y(const Linef3& mouse_ray)
double ratio = calc_ratio(2, mouse_ray, m_starting_box.center());
if (ratio > 0.0)
m_scale(0) = m_starting_scale(1) * ratio; // << this is temporary
// m_scale(1) = m_starting_scale(1) * ratio;
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_scale(1) = m_starting_scale(1) * ratio;
#else
m_scale(0) = m_starting_scale(1) * ratio;
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
@ -989,8 +993,11 @@ void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
double ratio = calc_ratio(1, mouse_ray, m_starting_box.center());
if (ratio > 0.0)
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_scale(2) = m_starting_scale(2) * ratio;
#else
m_scale(0) = m_starting_scale(2) * ratio; // << this is temporary
// m_scale(2) = m_starting_scale(2) * ratio;
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void GLGizmoScale3D::do_scale_uniform(const Linef3& mouse_ray)
@ -1250,32 +1257,18 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
else
::glColor4f(0.9f, 0.9f, 0.9f, 0.5f);
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
for (const InstanceData& inst : m_instances) {
Vec3d position = inst.position + dragged_offset;
#else
for (Vec3d offset : m_instances_positions) {
offset += dragged_offset;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
Transform3d m = inst.matrix;
m.pretranslate(dragged_offset);
::glPushMatrix();
::glMultMatrixd(m.data());
#else
for (Vec2d offset : m_instances_positions) {
offset += to_2d(dragged_offset);
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
::glPushMatrix();
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
::glTranslated(position(0), position(1), position(2));
::glRotated(inst.rotation(2) * 180.0 / (double)PI, 0.0, 0.0, 1.0);
::glRotated(inst.rotation(1) * 180.0 / (double)PI, 0.0, 1.0, 0.0);
::glRotated(inst.rotation(0) * 180.0 / (double)PI, 1.0, 0.0, 0.0);
::glScaled(inst.scaling_factor, inst.scaling_factor, inst.scaling_factor);
#else
::glTranslated(offset(0), offset(1), offset(2));
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#else
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
::glBegin(GL_POLYGON);
for (const Vec3d& vertex : m_planes[i].vertices)
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
@ -1294,29 +1287,15 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
for (unsigned int i = 0; i < m_planes.size(); ++i)
{
::glColor3f(1.0f, 1.0f, picking_color_component(i));
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
for (const InstanceData& inst : m_instances) {
#else
for (const Vec3d& offset : m_instances_positions) {
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
::glPushMatrix();
::glMultMatrixd(inst.matrix.data());
#else
for (const Vec2d& offset : m_instances_positions) {
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
::glPushMatrix();
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
::glTranslated(inst.position(0), inst.position(1), inst.position(2));
::glRotated(inst.rotation(2) * 180.0 / (double)PI, 0.0, 0.0, 1.0);
::glRotated(inst.rotation(1) * 180.0 / (double)PI, 0.0, 1.0, 0.0);
::glRotated(inst.rotation(0) * 180.0 / (double)PI, 1.0, 0.0, 0.0);
::glScaled(inst.scaling_factor, inst.scaling_factor, inst.scaling_factor);
#else
::glTranslated(offset(0), offset(1), offset(2));
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#else
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
::glBegin(GL_POLYGON);
for (const Vec3d& vertex : m_planes[i].vertices)
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
@ -1332,21 +1311,17 @@ void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
// ...and save the updated positions of the object instances:
if (m_model_object && !m_model_object->instances.empty()) {
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_instances.clear();
#else
m_instances_positions.clear();
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
for (const auto* instance : m_model_object->instances)
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
m_instances.emplace_back(instance->get_offset(), instance->get_rotation(), instance->scaling_factor);
#else
m_instances_positions.emplace_back(instance->get_offset());
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_instances.emplace_back(instance->world_matrix());
#else
m_instances_positions.emplace_back(instance->offset);
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
if (is_plane_update_necessary())
@ -1358,11 +1333,15 @@ void GLGizmoFlatten::update_planes()
TriangleMesh ch;
for (const ModelVolume* vol : m_model_object->volumes)
ch.merge(vol->get_convex_hull());
ch = ch.convex_hull_3d();
#if !ENABLE_MODELINSTANCE_3D_ROTATION
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
ch.scale(m_model_object->instances.front()->scaling_factor);
ch.rotate_z(m_model_object->instances.front()->rotation);
#endif // !ENABLE_MODELINSTANCE_3D_ROTATION
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& bb_size = ch.bounding_box().size();
double min_bb_face_area = std::min(bb_size(0) * bb_size(1), std::min(bb_size(0) * bb_size(2), bb_size(1) * bb_size(2)));
m_planes.clear();
@ -1392,7 +1371,7 @@ void GLGizmoFlatten::update_planes()
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
stl_vertex* first_vertex = ch.stl.facet_start[facet_idx].vertex;
for (int j=0; j<3; ++j)
m_planes.back().vertices.emplace_back(first_vertex[j](0), first_vertex[j](1), first_vertex[j](2));
m_planes.back().vertices.emplace_back((double)first_vertex[j](0), (double)first_vertex[j](1), (double)first_vertex[j](2));
facet_visited[facet_idx] = true;
for (int j = 0; j < 3; ++ j) {
@ -1406,49 +1385,63 @@ void GLGizmoFlatten::update_planes()
// if this is a just a very small triangle, remove it to speed up further calculations (it would be rejected anyway):
if (m_planes.back().vertices.size() == 3 &&
(m_planes.back().vertices[0] - m_planes.back().vertices[1]).norm() < 1.f
|| (m_planes.back().vertices[0] - m_planes.back().vertices[2]).norm() < 1.f)
m_planes.pop_back();
((m_planes.back().vertices[0] - m_planes.back().vertices[1]).norm() < 1.0
|| (m_planes.back().vertices[0] - m_planes.back().vertices[2]).norm() < 1.0
|| (m_planes.back().vertices[1] - m_planes.back().vertices[2]).norm() < 1.0))
m_planes.pop_back();
}
const float minimal_area = 0.01f * (float)min_bb_face_area;
// Now we'll go through all the polygons, transform the points into xy plane to process them:
for (unsigned int polygon_id=0; polygon_id < m_planes.size(); ++polygon_id) {
Pointf3s& polygon = m_planes[polygon_id].vertices;
const Vec3d& normal = m_planes[polygon_id].normal;
// We are going to rotate about z and y to flatten the plane
float angle_z = 0.f;
float angle_y = 0.f;
if (std::abs(normal(1)) > 0.001)
angle_z = -atan2(normal(1), normal(0)); // angle to rotate so that normal ends up in xz-plane
if (std::abs(normal(0)*cos(angle_z) - normal(1)*sin(angle_z)) > 0.001)
angle_y = -atan2(normal(0)*cos(angle_z) - normal(1)*sin(angle_z), normal(2)); // angle to rotate to make normal point upwards
else {
// In case it already was in z-direction, we must ensure it is not the wrong way:
angle_y = normal(2) > 0.f ? 0.f : -PI;
}
// Rotate all points to the xy plane:
Eigen::Quaterniond q;
Transform3d m = Transform3d::Identity();
m.rotate(Eigen::AngleAxisd((double)angle_y, Vec3d::UnitY()));
m.rotate(Eigen::AngleAxisd((double)angle_z, Vec3d::UnitZ()));
m.matrix().block(0, 0, 3, 3) = q.setFromTwoVectors(normal, Vec3d::UnitZ()).toRotationMatrix();
polygon = transform(polygon, m);
polygon = Slic3r::Geometry::convex_hull(polygon); // To remove the inner points
// We will calculate area of the polygon and discard ones that are too small
// We will calculate area of the polygons and discard ones that are too small
// The limit is more forgiving in case the normal is in the direction of the coordinate axes
const float minimal_area = (std::abs(normal(0)) > 0.999f || std::abs(normal(1)) > 0.999f || std::abs(normal(2)) > 0.999f) ? 1.f : 20.f;
float area_threshold = (std::abs(normal(0)) > 0.999f || std::abs(normal(1)) > 0.999f || std::abs(normal(2)) > 0.999f) ? minimal_area : 10.0f * minimal_area;
float& area = m_planes[polygon_id].area;
area = 0.f;
for (unsigned int i = 0; i < polygon.size(); i++) // Shoelace formula
area += polygon[i](0)*polygon[i + 1 < polygon.size() ? i + 1 : 0](1) - polygon[i + 1 < polygon.size() ? i + 1 : 0](0)*polygon[i](1);
area = std::abs(area / 2.f);
if (area < minimal_area) {
area = 0.5f * std::abs(area);
if (area < area_threshold) {
m_planes.erase(m_planes.begin()+(polygon_id--));
continue;
}
// We check the inner angles and discard polygons with angles smaller than the following threshold
const double angle_threshold = ::cos(10.0 * (double)PI / 180.0);
bool discard = false;
for (unsigned int i = 0; i < polygon.size(); ++i)
{
const Vec3d& prec = polygon[(i == 0) ? polygon.size() - 1 : i - 1];
const Vec3d& curr = polygon[i];
const Vec3d& next = polygon[(i == polygon.size() - 1) ? 0 : i + 1];
if ((prec - curr).normalized().dot((next - curr).normalized()) > angle_threshold)
{
discard = true;
break;
}
}
if (discard)
{
m_planes.erase(m_planes.begin() + (polygon_id--));
continue;
}
// We will shrink the polygon a little bit so it does not touch the object edges:
Vec3d centroid = std::accumulate(polygon.begin(), polygon.end(), Vec3d(0.0, 0.0, 0.0));
centroid /= (double)polygon.size();
@ -1511,10 +1504,10 @@ void GLGizmoFlatten::update_planes()
m_source_data.bounding_boxes.clear();
for (const auto& vol : m_model_object->volumes)
m_source_data.bounding_boxes.push_back(vol->get_convex_hull().bounding_box());
#if !ENABLE_MODELINSTANCE_3D_ROTATION
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
m_source_data.scaling_factor = m_model_object->instances.front()->scaling_factor;
m_source_data.rotation = m_model_object->instances.front()->rotation;
#endif // !ENABLE_MODELINSTANCE_3D_ROTATION
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex();
m_source_data.mesh_first_point = Vec3d((double)first_vertex[0], (double)first_vertex[1], (double)first_vertex[2]);
}
@ -1526,13 +1519,13 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
if (m_state != On || !m_model_object || m_model_object->instances.empty())
return false;
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
if (m_model_object->volumes.size() != m_source_data.bounding_boxes.size())
#else
if (m_model_object->volumes.size() != m_source_data.bounding_boxes.size()
|| m_model_object->instances.front()->scaling_factor != m_source_data.scaling_factor
|| m_model_object->instances.front()->rotation != m_source_data.rotation)
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
return true;
// now compare the bounding boxes:
@ -1548,12 +1541,13 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
return false;
}
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d GLGizmoFlatten::get_flattening_rotation() const
{
// calculates the rotations in model space
// calculates the rotations in model space, taking in account the scaling factors
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> m = m_model_object->instances.front()->world_matrix(true, true).matrix().block(0, 0, 3, 3).inverse().transpose();
Eigen::Quaterniond q;
Vec3d angles = q.setFromTwoVectors(m_normal, -Vec3d::UnitZ()).toRotationMatrix().eulerAngles(2, 1, 0);
Vec3d angles = q.setFromTwoVectors(m * m_normal, -Vec3d::UnitZ()).toRotationMatrix().eulerAngles(2, 1, 0);
m_normal = Vec3d::Zero();
return Vec3d(angles(2), angles(1), angles(0));
}
@ -1563,7 +1557,7 @@ Vec3d GLGizmoFlatten::get_flattening_normal() const {
m_normal = Vec3d::Zero();
return normal.normalized();
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
} // namespace GUI
} // namespace Slic3r

View file

@ -133,7 +133,6 @@ class GLGizmoRotate : public GLGizmoBase
static const float ScaleStepRad;
static const unsigned int ScaleLongEvery;
static const float ScaleLongTooth;
static const float ScaleShortTooth;
static const unsigned int SnapRegionsCount;
static const float GrabberOffset;
@ -152,6 +151,11 @@ private:
mutable Vec3d m_center;
mutable float m_radius;
mutable float m_snap_coarse_in_radius;
mutable float m_snap_coarse_out_radius;
mutable float m_snap_fine_in_radius;
mutable float m_snap_fine_out_radius;
public:
GLGizmoRotate(GLCanvas3D& parent, Axis axis);
@ -188,7 +192,7 @@ class GLGizmoRotate3D : public GLGizmoBase
public:
explicit GLGizmoRotate3D(GLCanvas3D& parent);
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); }
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation(0)); m_gizmos[Y].set_angle(rotation(1)); m_gizmos[Z].set_angle(rotation(2)); }
#else
@ -200,7 +204,7 @@ public:
double get_angle_z() const { return m_gizmos[Z].get_angle(); }
void set_angle_z(double angle) { m_gizmos[Z].set_angle(angle); }
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
protected:
virtual bool on_init();
@ -271,6 +275,10 @@ class GLGizmoScale3D : public GLGizmoBase
public:
explicit GLGizmoScale3D(GLCanvas3D& parent);
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
const Vec3d& get_scale() const { return m_scale; }
void set_scale(const Vec3d& scale) { m_starting_scale = scale; }
#else
double get_scale_x() const { return m_scale(0); }
void set_scale_x(double scale) { m_starting_scale(0) = scale; }
@ -281,6 +289,7 @@ public:
void set_scale_z(double scale) { m_starting_scale(2) = scale; }
void set_scale(double scale) { m_starting_scale = scale * Vec3d::Ones(); }
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
protected:
virtual bool on_init();
@ -345,10 +354,10 @@ private:
};
struct SourceDataSummary {
std::vector<BoundingBoxf3> bounding_boxes; // bounding boxes of convex hulls of individual volumes
#if !ENABLE_MODELINSTANCE_3D_ROTATION
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
float scaling_factor;
float rotation;
#endif // !ENABLE_MODELINSTANCE_3D_ROTATION
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d mesh_first_point;
};
@ -356,23 +365,16 @@ private:
SourceDataSummary m_source_data;
std::vector<PlaneData> m_planes;
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
struct InstanceData
{
Vec3d position;
Vec3d rotation;
double scaling_factor;
InstanceData(const Vec3d& position, const Vec3d& rotation, double scaling_factor) : position(position), rotation(rotation), scaling_factor(scaling_factor) {}
Transform3d matrix;
InstanceData(const Transform3d& matrix) : matrix(matrix) {}
};
std::vector<InstanceData> m_instances;
#else
Pointf3s m_instances_positions;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#else
std::vector<Vec2d> m_instances_positions;
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d m_starting_center;
const ModelObject* m_model_object = nullptr;
@ -383,11 +385,11 @@ public:
explicit GLGizmoFlatten(GLCanvas3D& parent);
void set_flattening_data(const ModelObject* model_object);
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
Vec3d get_flattening_rotation() const;
#else
Vec3d get_flattening_normal() const;
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
protected:
virtual bool on_init();

View file

@ -1221,7 +1221,13 @@ void load_part( ModelObject* model_object,
}
for ( auto object : model.objects) {
for (auto volume : object->volumes) {
Vec3d delta = Vec3d::Zero();
if (model_object->origin_translation != Vec3d::Zero())
{
object->center_around_origin();
delta = model_object->origin_translation - object->origin_translation;
}
for (auto volume : object->volumes) {
auto new_volume = model_object->add_volume(*volume);
new_volume->set_type(is_modifier ? ModelVolume::PARAMETER_MODIFIER : ModelVolume::MODEL_PART);
boost::filesystem::path(input_file).filename().string();
@ -1229,12 +1235,11 @@ void load_part( ModelObject* model_object,
part_names.Add(new_volume->name);
// apply the same translation we applied to the object
new_volume->mesh.translate( model_object->origin_translation(0),
model_object->origin_translation(1),
model_object->origin_translation(2) );
// set a default extruder value, since user can't add it manually
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
if (delta != Vec3d::Zero())
new_volume->mesh.translate((float)delta(0), (float)delta(1), (float)delta(2));
// set a default extruder value, since user can't add it manually
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
m_parts_changed = true;
}
@ -1447,12 +1452,12 @@ bool is_splittable_object(const bool split_part)
return false;
TriangleMeshPtrs meshptrs = volume->mesh.split();
if (meshptrs.size() <= 1) {
delete meshptrs.front();
return false;
bool splittable = meshptrs.size() > 1;
for (TriangleMesh* m : meshptrs)
{
delete m;
}
return true;
return splittable;
}
void on_btn_split(const bool split_part)
@ -1746,6 +1751,18 @@ void update_scale_values()
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
auto size = (*m_objects)[m_selected_object_id]->instance_bounding_box(0).size();
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
if (g_is_percent_scale) {
og->set_value("scale_x", int(instance->get_scaling_factor(X) * 100));
og->set_value("scale_y", int(instance->get_scaling_factor(Y) * 100));
og->set_value("scale_z", int(instance->get_scaling_factor(Z) * 100));
}
else {
og->set_value("scale_x", int(instance->get_scaling_factor(X) * size(0) + 0.5));
og->set_value("scale_y", int(instance->get_scaling_factor(Y) * size(1) + 0.5));
og->set_value("scale_z", int(instance->get_scaling_factor(Z) * size(2) + 0.5));
}
#else
if (g_is_percent_scale) {
auto scale = instance->scaling_factor * 100.0;
og->set_value("scale_x", int(scale));
@ -1757,6 +1774,7 @@ void update_scale_values()
og->set_value("scale_y", int(instance->scaling_factor * size(1) + 0.5));
og->set_value("scale_z", int(instance->scaling_factor * size(2) + 0.5));
}
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void update_position_values()
@ -1764,7 +1782,7 @@ void update_position_values()
auto og = get_optgroup(ogFrequentlyObjectSettings);
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
#if ENABLE_MODELINSTANCE_3D_OFFSET
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
og->set_value("position_x", int(instance->get_offset(X)));
og->set_value("position_y", int(instance->get_offset(Y)));
og->set_value("position_z", int(instance->get_offset(Z)));
@ -1772,7 +1790,7 @@ void update_position_values()
og->set_value("position_x", int(instance->offset(0)));
og->set_value("position_y", int(instance->offset(1)));
og->set_value("position_z", 0);
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void update_position_values(const Vec3d& position)
@ -1784,6 +1802,24 @@ void update_position_values(const Vec3d& position)
og->set_value("position_z", int(position(2)));
}
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void update_scale_values(const Vec3d& scaling_factor)
{
auto og = get_optgroup(ogFrequentlyObjectSettings);
// this is temporary
// to be able to update the values as size
// we need to store somewhere the original size
// or have it passed as parameter
if (!g_is_percent_scale)
og->set_value("scale_unit", _("%"));
auto scale = scaling_factor * 100.0;
og->set_value("scale_x", int(scale(0)));
og->set_value("scale_y", int(scale(1)));
og->set_value("scale_z", int(scale(2)));
}
#else
void update_scale_values(double scaling_factor)
{
auto og = get_optgroup(ogFrequentlyObjectSettings);
@ -1800,10 +1836,11 @@ void update_scale_values(double scaling_factor)
og->set_value("scale_y", int(scale));
og->set_value("scale_z", int(scale));
}
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void update_rotation_values()
{
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
update_rotation_value((*m_objects)[m_selected_object_id]->instances.front()->get_rotation());
#else
auto og = get_optgroup(ogFrequentlyObjectSettings);
@ -1811,7 +1848,7 @@ void update_rotation_values()
og->set_value("rotation_x", 0);
og->set_value("rotation_y", 0);
og->set_value("rotation_z", int(Geometry::rad2deg(instance->rotation)));
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
}
void update_rotation_value(double angle, Axis axis)
@ -1838,18 +1875,18 @@ void update_rotation_value(double angle, Axis axis)
}
}
og->set_value(axis_str, int(Geometry::rad2deg(angle)));
og->set_value(axis_str, round_nearest(int(Geometry::rad2deg(angle)), 0));
}
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void update_rotation_value(const Vec3d& rotation)
{
auto og = get_optgroup(ogFrequentlyObjectSettings);
og->set_value("rotation_x", int(Geometry::rad2deg(rotation(0))));
og->set_value("rotation_y", int(Geometry::rad2deg(rotation(1))));
og->set_value("rotation_z", int(Geometry::rad2deg(rotation(2))));
og->set_value("rotation_x", int(round_nearest(Geometry::rad2deg(rotation(0)), 0)));
og->set_value("rotation_y", int(round_nearest(Geometry::rad2deg(rotation(1)), 0)));
og->set_value("rotation_z", int(round_nearest(Geometry::rad2deg(rotation(2)), 0)));
}
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void set_uniform_scaling(const bool uniform_scale)
{

View file

@ -119,14 +119,18 @@ void update_position_values();
void update_position_values(const Vec3d& position);
// update scale values after scale unit changing or "gizmos"
void update_scale_values();
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void update_scale_values(const Vec3d& scaling_factor);
#else
void update_scale_values(double scaling_factor);
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
// update rotation values object selection changing
void update_rotation_values();
// update rotation value after "gizmos"
void update_rotation_value(double angle, Axis axis);
#if ENABLE_MODELINSTANCE_3D_ROTATION
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void update_rotation_value(const Vec3d& rotation);
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
void set_uniform_scaling(const bool uniform_scale);
void on_begin_drag(wxDataViewEvent &event);

View file

@ -22,6 +22,8 @@ public:
void call(double, double) const {}
void call(double, double, double) const {}
void call(double, double, double, double) const {}
void call(double, double, double, double, double) const {}
void call(double, double, double, double, double, double) const {}
void call(bool b) const {}
};