Tech ENABLE_WORLD_COORDINATE - Fixed scaling using sidebar panel
This commit is contained in:
parent
010c12612c
commit
9cc5659e50
@ -712,25 +712,29 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
|
|||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
if (is_world_coordinates()) {
|
if (is_world_coordinates()) {
|
||||||
m_new_position = volume->get_instance_offset();
|
m_new_position = volume->get_instance_offset();
|
||||||
|
m_new_scale_label_string = L("Scale");
|
||||||
|
m_new_scale = Vec3d(100.0, 100.0, 100.0);
|
||||||
#else
|
#else
|
||||||
if (m_world_coordinates) {
|
if (m_world_coordinates) {
|
||||||
|
m_new_scale = m_new_size.cwiseQuotient(selection.get_unscaled_instance_bounding_box().size()) * 100.0;
|
||||||
#endif // ENABLE_WORLD_COORDINATE
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
m_new_rotate_label_string = L("Rotate");
|
m_new_rotate_label_string = L("Rotate");
|
||||||
m_new_rotation = Vec3d::Zero();
|
m_new_rotation = Vec3d::Zero();
|
||||||
m_new_size = selection.get_scaled_instance_bounding_box().size();
|
m_new_size = selection.get_scaled_instance_bounding_box().size();
|
||||||
m_new_scale = m_new_size.cwiseQuotient(selection.get_unscaled_instance_bounding_box().size()) * 100.0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
m_new_move_label_string = L("Translate");
|
m_new_move_label_string = L("Translate");
|
||||||
m_new_rotate_label_string = L("Rotate");
|
m_new_rotate_label_string = L("Rotate");
|
||||||
|
m_new_scale_label_string = L("Scale");
|
||||||
m_new_position = Vec3d::Zero();
|
m_new_position = Vec3d::Zero();
|
||||||
m_new_rotation = Vec3d::Zero();
|
m_new_rotation = Vec3d::Zero();
|
||||||
|
m_new_scale = Vec3d(100.0, 100.0, 100.0);
|
||||||
#else
|
#else
|
||||||
m_new_rotation = volume->get_instance_rotation() * (180.0 / M_PI);
|
m_new_rotation = volume->get_instance_rotation() * (180.0 / M_PI);
|
||||||
|
m_new_scale = volume->get_instance_scaling_factor() * 100.0;
|
||||||
#endif // ENABLE_WORLD_COORDINATE
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
m_new_size = volume->get_instance_scaling_factor().cwiseProduct(wxGetApp().model().objects[volume->object_idx()]->raw_mesh_bounding_box().size());
|
m_new_size = volume->get_instance_scaling_factor().cwiseProduct(wxGetApp().model().objects[volume->object_idx()]->raw_mesh_bounding_box().size());
|
||||||
m_new_scale = volume->get_instance_scaling_factor() * 100.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_new_enabled = true;
|
m_new_enabled = true;
|
||||||
@ -760,9 +764,10 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
|
|||||||
|
|
||||||
m_new_position = offset;
|
m_new_position = offset;
|
||||||
m_new_rotate_label_string = L("Rotate");
|
m_new_rotate_label_string = L("Rotate");
|
||||||
|
m_new_scale_label_string = L("Scale");
|
||||||
|
m_new_scale = Vec3d(100.0, 100.0, 100.0);
|
||||||
m_new_rotation = Vec3d::Zero();
|
m_new_rotation = Vec3d::Zero();
|
||||||
m_new_size = volume->transformed_convex_hull_bounding_box(trafo.get_matrix()).size();
|
m_new_size = volume->transformed_convex_hull_bounding_box(trafo.get_matrix()).size();
|
||||||
m_new_scale = m_new_size.cwiseQuotient(volume->transformed_convex_hull_bounding_box(volume->get_instance_transformation().get_matrix() * volume->get_volume_transformation().get_matrix_no_scaling_factor()).size()) * 100.0;
|
|
||||||
}
|
}
|
||||||
else if (is_local_coordinates()) {
|
else if (is_local_coordinates()) {
|
||||||
m_new_move_label_string = L("Translate");
|
m_new_move_label_string = L("Translate");
|
||||||
@ -778,8 +783,9 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
|
|||||||
m_new_rotate_label_string = L("Rotate");
|
m_new_rotate_label_string = L("Rotate");
|
||||||
m_new_rotation = Vec3d::Zero();
|
m_new_rotation = Vec3d::Zero();
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
m_new_scale_label_string = L("Scale");
|
||||||
m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size();
|
m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size();
|
||||||
m_new_scale = m_new_size.cwiseQuotient(volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix_no_scaling_factor()).size()) * 100.0;
|
m_new_scale = Vec3d(100.0, 100.0, 100.0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
m_new_scale = volume->get_volume_scaling_factor() * 100.0;
|
m_new_scale = volume->get_volume_scaling_factor() * 100.0;
|
||||||
@ -1270,7 +1276,7 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
|
|||||||
else if (is_instance_coordinates())
|
else if (is_instance_coordinates())
|
||||||
transformation_type.set_instance();
|
transformation_type.set_instance();
|
||||||
|
|
||||||
if (!selection.is_single_full_instance() && !selection.is_single_volume_or_modifier())
|
if (!(selection.is_single_volume_or_modifier() && is_local_coordinates()))
|
||||||
transformation_type.set_relative();
|
transformation_type.set_relative();
|
||||||
|
|
||||||
const Vec3d scaling_factor = m_uniform_scale ? scale(axis) * Vec3d::Ones() : scale;
|
const Vec3d scaling_factor = m_uniform_scale ? scale(axis) * Vec3d::Ones() : scale;
|
||||||
|
@ -835,10 +835,8 @@ void Selection::translate(const Vec3d& displacement, TransformationType transfor
|
|||||||
else
|
else
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
assert(transformation_type.relative());
|
|
||||||
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(displacement), m_cache.dragging_center);
|
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(displacement), m_cache.dragging_center);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DISABLE_INSTANCES_SYNCH
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
@ -935,7 +933,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||||||
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(transformation_type.relative());
|
|
||||||
transformation_type.set_independent();
|
transformation_type.set_independent();
|
||||||
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
||||||
}
|
}
|
||||||
@ -1331,6 +1328,7 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation
|
|||||||
if (transformation_type.absolute()) {
|
if (transformation_type.absolute()) {
|
||||||
// convert from absolute scaling to relative scaling
|
// convert from absolute scaling to relative scaling
|
||||||
BoundingBoxf3 original_box;
|
BoundingBoxf3 original_box;
|
||||||
|
BoundingBoxf3 reference_box = m_box.get_bounding_box();
|
||||||
if (m_mode == Instance) {
|
if (m_mode == Instance) {
|
||||||
if (is_single_full_instance()) {
|
if (is_single_full_instance()) {
|
||||||
if (transformation_type.world())
|
if (transformation_type.world())
|
||||||
@ -1348,11 +1346,14 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation
|
|||||||
original_box = get_bounding_box();
|
original_box = get_bounding_box();
|
||||||
else if (transformation_type.instance())
|
else if (transformation_type.instance())
|
||||||
original_box = v.transformed_convex_hull_bounding_box(volume_data.get_volume_transform().get_matrix());
|
original_box = v.transformed_convex_hull_bounding_box(volume_data.get_volume_transform().get_matrix());
|
||||||
else
|
else {
|
||||||
original_box = v.bounding_box();
|
original_box = v.bounding_box();
|
||||||
|
reference_box = v.bounding_box().transformed(volume_data.get_volume_transform().get_scaling_factor_matrix());
|
||||||
|
}
|
||||||
|
transformation_type.set_relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
relative_scale = original_box.size().cwiseProduct(scale).cwiseQuotient(m_box.get_bounding_box().size());
|
relative_scale = original_box.size().cwiseProduct(scale).cwiseQuotient(reference_box.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_mode == Instance) {
|
if (m_mode == Instance) {
|
||||||
@ -1389,7 +1390,6 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation
|
|||||||
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center);
|
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(transformation_type.relative());
|
|
||||||
transformation_type.set_independent();
|
transformation_type.set_independent();
|
||||||
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center);
|
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user