mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 02:09:03 +08:00
fix transform by instance, also make it take potentially different additional trafos into account
This commit is contained in:
parent
794b3a1419
commit
852fb80555
@ -860,13 +860,31 @@ ModelObject::transform_by_instance(ModelInstance instance, bool dont_translate)
|
|||||||
{
|
{
|
||||||
// We get instance by copy because we would alter it in the loop below,
|
// We get instance by copy because we would alter it in the loop below,
|
||||||
// causing inconsistent values in subsequent instances.
|
// causing inconsistent values in subsequent instances.
|
||||||
TransformationMatrix trafo = instance.get_trafo_matrix(dont_translate);
|
TransformationMatrix temp_trafo = instance.get_trafo_matrix(dont_translate);
|
||||||
|
|
||||||
|
this->apply_transformation(temp_trafo);
|
||||||
|
|
||||||
|
temp_trafo = temp_trafo.inverse();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Let:
|
||||||
|
* I1 be the trafo of the given instance,
|
||||||
|
* V the originial volume trafo and
|
||||||
|
* I2 the trafo of the instance to be updated
|
||||||
|
|
||||||
|
Then:
|
||||||
|
previous: T = I2 * V
|
||||||
|
I1 has been applied to V:
|
||||||
|
Vnew = I1 * V
|
||||||
|
I1^-1 * I1 = eye
|
||||||
|
|
||||||
|
T = I2 * I1^-1 * I1 * V
|
||||||
|
---------- ------
|
||||||
|
I2new Vnew
|
||||||
|
*/
|
||||||
|
|
||||||
for (ModelInstance* i : this->instances) {
|
for (ModelInstance* i : this->instances) {
|
||||||
i->rotation -= instance.rotation;
|
i->set_complete_trafo(i->get_trafo_matrix().multiplyRight(temp_trafo));
|
||||||
i->scaling_factor /= instance.scaling_factor;
|
|
||||||
if (!dont_translate)
|
|
||||||
i->offset.translate(-instance.offset.x, -instance.offset.y);
|
|
||||||
}
|
}
|
||||||
this->origin_translation = Pointf3(0,0,0);
|
this->origin_translation = Pointf3(0,0,0);
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user