Tech ENABLE_WORLD_COORDINATE - Fixed sizing of volumes

This commit is contained in:
enricoturri1966 2022-12-09 11:12:48 +01:00
parent c0ab834519
commit 0aa88e1dea
2 changed files with 20 additions and 10 deletions

View File

@ -1219,13 +1219,24 @@ void ObjectManipulation::change_size_value(int axis, double value)
#else #else
if (selection.is_single_volume() || selection.is_single_modifier()) { if (selection.is_single_volume() || selection.is_single_modifier()) {
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
const GLVolume* v = selection.get_first_volume();
const Vec3d local_size = size.cwiseQuotient(v->get_instance_scaling_factor());
const Vec3d local_ref_size = v->bounding_box().size().cwiseProduct(v->get_volume_scaling_factor());
const Vec3d local_change = local_size.cwiseQuotient(local_ref_size);
size = local_change.cwiseProduct(v->get_volume_scaling_factor()); #if ENABLE_WORLD_COORDINATE
ref_size = Vec3d::Ones(); if (is_world_coordinates()) {
size = size.cwiseQuotient(ref_size);
ref_size = Vec3d::Ones();
}
else {
#endif // ENABLE_WORLD_COORDINATE
const GLVolume* v = selection.get_first_volume();
const Vec3d local_size = size.cwiseQuotient(v->get_instance_scaling_factor());
const Vec3d local_ref_size = v->bounding_box().size().cwiseProduct(v->get_volume_scaling_factor());
const Vec3d local_change = local_size.cwiseQuotient(local_ref_size);
size = local_change.cwiseProduct(v->get_volume_scaling_factor());
ref_size = Vec3d::Ones();
#if ENABLE_WORLD_COORDINATE
}
#endif // ENABLE_WORLD_COORDINATE
} }
else if (selection.is_single_full_instance()) else if (selection.is_single_full_instance())
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
@ -1243,8 +1254,8 @@ void ObjectManipulation::change_size_value(int axis, double value)
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
m_cache.size = size; m_cache.size = size;
m_cache.size_rounded(axis) = DBL_MAX; m_cache.size_rounded(axis) = DBL_MAX;
this->UpdateAndShow(true); this->UpdateAndShow(true);
} }
void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const

View File

@ -1344,8 +1344,7 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation
if (!is_single_volume_or_modifier()) if (!is_single_volume_or_modifier())
original_box = get_bounding_box(); original_box = get_bounding_box();
else if (transformation_type.world()) else if (transformation_type.world())
original_box = v.transformed_convex_hull_bounding_box((volume_data.get_instance_transform() * original_box = get_bounding_box();
volume_data.get_volume_transform()).get_matrix_no_scaling_factor());
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_no_scaling_factor()); original_box = v.transformed_convex_hull_bounding_box(volume_data.get_volume_transform().get_matrix_no_scaling_factor());
else else