mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 15:15:54 +08:00
WIP fixing trafos
This commit is contained in:
parent
0fa9bcc63b
commit
9ee71ddd92
@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
#include <libslic3r/Point.hpp>
|
#include <libslic3r/Point.hpp>
|
||||||
|
|
||||||
namespace Slic3r { namespace sla {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
class ModelObject;
|
||||||
|
|
||||||
|
namespace sla {
|
||||||
|
|
||||||
// An enum to keep track of where the current points on the ModelObject came from.
|
// An enum to keep track of where the current points on the ModelObject came from.
|
||||||
enum class PointsStatus {
|
enum class PointsStatus {
|
||||||
@ -62,6 +66,9 @@ struct SupportPoint
|
|||||||
|
|
||||||
using SupportPoints = std::vector<SupportPoint>;
|
using SupportPoints = std::vector<SupportPoint>;
|
||||||
|
|
||||||
|
SupportPoints transformed_support_points(const ModelObject &mo,
|
||||||
|
const Transform3d &trafo);
|
||||||
|
|
||||||
}} // namespace Slic3r::sla
|
}} // namespace Slic3r::sla
|
||||||
|
|
||||||
#endif // SUPPORTPOINT_HPP
|
#endif // SUPPORTPOINT_HPP
|
||||||
|
@ -661,5 +661,17 @@ void SupportPointGenerator::output_expolygons(const ExPolygons& expolys, const s
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SupportPoints transformed_support_points(const ModelObject &mo,
|
||||||
|
const Transform3d &trafo)
|
||||||
|
{
|
||||||
|
auto spts = mo.sla_support_points;
|
||||||
|
Transform3f tr = trafo.cast<float>();
|
||||||
|
for (sla::SupportPoint& suppt : spts) {
|
||||||
|
suppt.pos = tr * suppt.pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
return spts;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sla
|
} // namespace sla
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -1051,20 +1051,16 @@ SLAPrintObject::get_parts_to_slice(SLAPrintObjectStep untilstep) const
|
|||||||
|
|
||||||
sla::SupportPoints SLAPrintObject::transformed_support_points() const
|
sla::SupportPoints SLAPrintObject::transformed_support_points() const
|
||||||
{
|
{
|
||||||
assert(m_model_object != nullptr);
|
assert(model_object());
|
||||||
auto spts = m_model_object->sla_support_points;
|
|
||||||
const Transform3d& vol_trafo = m_model_object->volumes.front()->get_transformation().get_matrix();
|
|
||||||
const Transform3f& tr = (trafo() * vol_trafo).cast<float>();
|
|
||||||
for (sla::SupportPoint& suppt : spts) {
|
|
||||||
suppt.pos = tr * suppt.pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
return spts;
|
return sla::transformed_support_points(*model_object(), trafo());
|
||||||
}
|
}
|
||||||
|
|
||||||
sla::DrainHoles SLAPrintObject::transformed_drainhole_points() const
|
sla::DrainHoles SLAPrintObject::transformed_drainhole_points() const
|
||||||
{
|
{
|
||||||
return sla::transformed_drainhole_points(*this->model_object(), trafo());
|
assert(model_object());
|
||||||
|
|
||||||
|
return sla::transformed_drainhole_points(*model_object(), trafo());
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicConfig SLAPrintStatistics::config() const
|
DynamicConfig SLAPrintStatistics::config() const
|
||||||
|
@ -123,7 +123,7 @@ void GLGizmoHollow::render_points(const Selection& selection)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
double shift_z = m_c->selection_info()->print_object()->get_current_elevation();
|
double shift_z = m_c->selection_info()->print_object()->get_current_elevation();
|
||||||
Transform3d trafo(inst->get_transformation().get_matrix() * inst->get_object()->volumes.front()->get_matrix());
|
Transform3d trafo(inst->get_transformation().get_matrix());
|
||||||
trafo.translation()(2) += shift_z;
|
trafo.translation()(2) += shift_z;
|
||||||
const Geometry::Transformation transformation{trafo};
|
const Geometry::Transformation transformation{trafo};
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
double shift_z = m_c->selection_info()->print_object()->get_current_elevation();
|
double shift_z = m_c->selection_info()->print_object()->get_current_elevation();
|
||||||
Transform3d trafo(inst->get_transformation().get_matrix() * inst->get_object()->volumes.front()->get_matrix());
|
Transform3d trafo = inst->get_transformation().get_matrix();
|
||||||
trafo.translation()(2) += shift_z;
|
trafo.translation()(2) += shift_z;
|
||||||
const Geometry::Transformation transformation{trafo};
|
const Geometry::Transformation transformation{trafo};
|
||||||
|
|
||||||
@ -1084,7 +1084,7 @@ void GLGizmoSlaSupports::get_data_from_backend()
|
|||||||
if (po->model_object()->id() == mo->id()) {
|
if (po->model_object()->id() == mo->id()) {
|
||||||
m_normal_cache.clear();
|
m_normal_cache.clear();
|
||||||
const std::vector<sla::SupportPoint>& points = po->get_support_points();
|
const std::vector<sla::SupportPoint>& points = po->get_support_points();
|
||||||
auto mat = (po->trafo() * po->model_object()->volumes.front()->get_transformation().get_matrix()).inverse().cast<float>();
|
auto mat = po->trafo().inverse().cast<float>();
|
||||||
for (unsigned int i=0; i<points.size();++i)
|
for (unsigned int i=0; i<points.size();++i)
|
||||||
m_normal_cache.emplace_back(sla::SupportPoint(mat * points[i].pos, points[i].head_front_radius, points[i].is_new_island));
|
m_normal_cache.emplace_back(sla::SupportPoint(mat * points[i].pos, points[i].head_front_radius, points[i].is_new_island));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user