Tech ENABLE_TRANSFORMATIONS_BY_MATRICES - Improved detection and removal of skew in matrices

Fixed conflicts during rebase with master
This commit is contained in:
enricoturri1966 2022-05-19 12:19:18 +02:00
parent b76f9fc2ee
commit 4846b504a2
2 changed files with 43 additions and 37 deletions

View File

@ -944,18 +944,12 @@ void ObjectManipulation::update_reset_buttons_visibility()
const Geometry::Transformation& trafo = volume->get_instance_transformation();
rotation = trafo.get_rotation_matrix();
scale = trafo.get_scaling_factor_matrix();
if (trafo.has_skew())
// the instance transform contains skew
skew = trafo;
else {
// the world transform contains skew
const Selection::IndicesList& idxs = selection.get_volume_idxs();
for (unsigned int id : idxs) {
const Geometry::Transformation world_trafo(selection.get_volume(id)->world_matrix());
if (world_trafo.has_skew()) {
skew = world_trafo;
break;
}
const Selection::IndicesList& idxs = selection.get_volume_idxs();
for (unsigned int id : idxs) {
const Geometry::Transformation world_trafo(selection.get_volume(id)->world_matrix());
if (world_trafo.has_skew()) {
skew = world_trafo;
break;
}
}
#else
@ -971,15 +965,9 @@ void ObjectManipulation::update_reset_buttons_visibility()
const Geometry::Transformation& trafo = volume->get_volume_transformation();
rotation = trafo.get_rotation_matrix();
scale = trafo.get_scaling_factor_matrix();
if (trafo.has_skew())
// the volume transform contains skew
skew = trafo;
else {
// the world transform contains skew
const Geometry::Transformation world_trafo(volume->world_matrix());
if (world_trafo.has_skew())
skew = world_trafo;
}
const Geometry::Transformation world_trafo(volume->world_matrix());
if (world_trafo.has_skew())
skew = world_trafo;
#else
rotation = volume->get_volume_rotation();
scale = volume->get_volume_scaling_factor();

View File

@ -1495,23 +1495,41 @@ void Selection::reset_skew()
for (unsigned int i : m_list) {
GLVolume& v = *(*m_volumes)[i];
const VolumeCache& volume_data = m_cache.volumes_data[i];
const Geometry::Transformation& inst_trafo = volume_data.get_instance_transform();
const Geometry::Transformation& vol_trafo = volume_data.get_volume_transform();
const Geometry::Transformation world_trafo = inst_trafo * vol_trafo;
if (!inst_trafo.has_skew() && !vol_trafo.has_skew() && world_trafo.has_skew()) {
Geometry::Transformation mod_world_trafo = Geometry::Transformation(world_trafo.get_matrix_no_offset());
mod_world_trafo.reset_skew();
v.set_volume_transformation(vol_trafo.get_offset_matrix() * inst_trafo.get_matrix_no_offset().inverse() * mod_world_trafo.get_matrix());
Geometry::Transformation inst_trafo = volume_data.get_instance_transform();
Geometry::Transformation vol_trafo = volume_data.get_volume_transform();
Geometry::Transformation world_trafo = inst_trafo * vol_trafo;
if (world_trafo.has_skew()) {
if (!inst_trafo.has_skew() && !vol_trafo.has_skew()) {
// <W> = [I][V]
world_trafo.reset_offset();
world_trafo.reset_skew();
v.set_volume_transformation(vol_trafo.get_offset_matrix() * inst_trafo.get_matrix_no_offset().inverse() * world_trafo.get_matrix());
}
else {
// <W> = <I><V>
// <W> = <I>[V]
// <W> = [I]<V>
if (inst_trafo.has_skew()) {
inst_trafo.reset_skew();
v.set_instance_transformation(inst_trafo);
}
if (vol_trafo.has_skew()) {
vol_trafo.reset_skew();
v.set_volume_transformation(vol_trafo);
}
}
}
else if (m_mode == Instance && inst_trafo.has_skew()) {
Geometry::Transformation trafo = inst_trafo;
trafo.reset_skew();
v.set_instance_transformation(trafo);
}
else if (m_mode == Volume && vol_trafo.has_skew()) {
Geometry::Transformation trafo = vol_trafo;
trafo.reset_skew();
v.set_volume_transformation(trafo);
else {
// [W] = [I][V]
// [W] = <I><V>
if (inst_trafo.has_skew()) {
inst_trafo.reset_skew();
v.set_instance_transformation(inst_trafo);
}
if (vol_trafo.has_skew()) {
vol_trafo.reset_skew();
v.set_volume_transformation(vol_trafo);
}
}
}