Tech ENABLE_GIZMO_MEASURE_WORLD_COORDINATES set as default
Fixed conflicts during rebase to master
This commit is contained in:
parent
5382f4077a
commit
075c241906
@ -47,9 +47,7 @@ public:
|
||||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d& point) const;
|
||||
std::vector<std::vector<int>> get_planes_triangle_indices() const;
|
||||
const std::vector<SurfaceFeature>& get_plane_features(unsigned int plane_id) const;
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const TriangleMesh& get_mesh() const;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
private:
|
||||
void update_planes();
|
||||
@ -57,11 +55,7 @@ private:
|
||||
|
||||
std::vector<PlaneData> m_planes;
|
||||
std::vector<size_t> m_face_to_plane;
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
TriangleMesh m_mesh;
|
||||
#else
|
||||
const indexed_triangle_set& m_its;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
};
|
||||
|
||||
|
||||
@ -70,11 +64,7 @@ private:
|
||||
|
||||
|
||||
MeasuringImpl::MeasuringImpl(const indexed_triangle_set& its)
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
: m_mesh(its)
|
||||
#else
|
||||
: m_its{its}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
{
|
||||
update_planes();
|
||||
extract_features();
|
||||
@ -87,17 +77,10 @@ void MeasuringImpl::update_planes()
|
||||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
// This part is still performed in mesh coordinate system.
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const size_t num_of_facets = m_mesh.its.indices.size();
|
||||
m_face_to_plane.resize(num_of_facets, size_t(-1));
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(m_mesh.its);
|
||||
const std::vector<Vec3i> face_neighbors = its_face_neighbors(m_mesh.its);
|
||||
#else
|
||||
const size_t num_of_facets = m_its.indices.size();
|
||||
m_face_to_plane.resize(num_of_facets, size_t(-1));
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(m_its);
|
||||
const std::vector<Vec3i> face_neighbors = its_face_neighbors(m_its);
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
@ -146,11 +129,7 @@ void MeasuringImpl::update_planes()
|
||||
assert(std::none_of(m_face_to_plane.begin(), m_face_to_plane.end(), [](size_t val) { return val == size_t(-1); }));
|
||||
|
||||
// Now we will walk around each of the planes and save vertices which form the border.
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
SurfaceMesh sm(m_mesh.its);
|
||||
#else
|
||||
SurfaceMesh sm(m_its);
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
for (int plane_id=0; plane_id < int(m_planes.size()); ++plane_id) {
|
||||
const auto& facets = m_planes[plane_id].facets;
|
||||
m_planes[plane_id].borders.clear();
|
||||
@ -532,12 +511,10 @@ const std::vector<SurfaceFeature>& MeasuringImpl::get_plane_features(unsigned in
|
||||
return m_planes[plane_id].surface_features;
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const TriangleMesh& MeasuringImpl::get_mesh() const
|
||||
{
|
||||
return this->m_mesh;
|
||||
}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
|
||||
|
||||
@ -579,12 +556,10 @@ const std::vector<SurfaceFeature>& Measuring::get_plane_features(unsigned int pl
|
||||
return priv->get_plane_features(plane_id);
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const TriangleMesh& Measuring::get_mesh() const
|
||||
{
|
||||
return priv->get_mesh();
|
||||
}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
const AngleAndEdges AngleAndEdges::Dummy = { 0.0, Vec3d::Zero(), { Vec3d::Zero(), Vec3d::Zero() }, { Vec3d::Zero(), Vec3d::Zero() }, 0.0, true };
|
||||
|
||||
@ -1184,29 +1159,6 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
return result;
|
||||
}
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void DistAndPoints::transform(const Transform3d& trafo) {
|
||||
from = trafo * from;
|
||||
to = trafo * to;
|
||||
dist = (to - from).norm();
|
||||
}
|
||||
|
||||
void AngleAndEdges::transform(const Transform3d& trafo) {
|
||||
const Vec3d old_e1 = e1.second - e1.first;
|
||||
const Vec3d old_e2 = e2.second - e2.first;
|
||||
center = trafo * center;
|
||||
e1.first = trafo * e1.first;
|
||||
e1.second = trafo * e1.second;
|
||||
e2.first = trafo * e2.first;
|
||||
e2.second = trafo * e2.second;
|
||||
angle = std::acos(std::clamp(Measure::edge_direction(e1).dot(Measure::edge_direction(e2)), -1.0, 1.0));
|
||||
const Vec3d new_e1 = e1.second - e1.first;
|
||||
const Vec3d new_e2 = e2.second - e2.first;
|
||||
const double average_scale = 0.5 * (new_e1.norm() / old_e1.norm() + new_e2.norm() / old_e2.norm());
|
||||
radius = average_scale * radius;
|
||||
}
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -13,9 +13,7 @@ struct indexed_triangle_set;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
class TriangleMesh;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
namespace Measure {
|
||||
|
||||
@ -93,10 +91,7 @@ class MeasuringImpl;
|
||||
class Measuring {
|
||||
public:
|
||||
// Construct the measurement object on a given its.
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// The its must remain valid and unchanged during the whole lifetime of the object.
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
explicit Measuring(const indexed_triangle_set& its);
|
||||
explicit Measuring(const indexed_triangle_set& its);
|
||||
~Measuring();
|
||||
|
||||
// Return a reference to a list of all features identified on the its.
|
||||
@ -115,10 +110,8 @@ public:
|
||||
// Returns the surface features of the plane with the given index
|
||||
const std::vector<SurfaceFeature>& get_plane_features(unsigned int plane_id) const;
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// Returns the mesh used for measuring
|
||||
const TriangleMesh& get_mesh() const;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
private:
|
||||
std::unique_ptr<MeasuringImpl> priv;
|
||||
@ -130,10 +123,6 @@ struct DistAndPoints {
|
||||
double dist;
|
||||
Vec3d from;
|
||||
Vec3d to;
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void transform(const Transform3d& trafo);
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
};
|
||||
|
||||
struct AngleAndEdges {
|
||||
@ -146,10 +135,6 @@ struct AngleAndEdges {
|
||||
double radius;
|
||||
bool coplanar;
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void transform(const Transform3d& trafo);
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
static const AngleAndEdges Dummy;
|
||||
};
|
||||
|
||||
@ -166,19 +151,6 @@ struct MeasurementResult {
|
||||
bool has_any_data() const {
|
||||
return angle.has_value() || distance_infinite.has_value() || distance_strict.has_value() || distance_xyz.has_value();
|
||||
}
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void transform(const Transform3d& trafo) {
|
||||
if (angle.has_value())
|
||||
angle->transform(trafo);
|
||||
if (distance_infinite.has_value())
|
||||
distance_infinite->transform(trafo);
|
||||
if (distance_strict.has_value()) {
|
||||
distance_strict->transform(trafo);
|
||||
distance_xyz = (distance_strict->to - distance_strict->from).cwiseAbs();
|
||||
}
|
||||
}
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
};
|
||||
|
||||
// Returns distance/angle between two SurfaceFeatures.
|
||||
|
@ -64,8 +64,6 @@
|
||||
// Enable picking using raytracing
|
||||
#define ENABLE_RAYCAST_PICKING (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
#define ENABLE_RAYCAST_PICKING_DEBUG (0 && ENABLE_RAYCAST_PICKING)
|
||||
// Enable gizmo measure combining volumes meshes and passing them to the backend in world coordinates
|
||||
#define ENABLE_GIZMO_MEASURE_WORLD_COORDINATES (1 && ENABLE_2_5_0_ALPHA1)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,16 +6,10 @@
|
||||
#include "slic3r/GUI/GUI_Utils.hpp"
|
||||
#include "slic3r/GUI/MeshUtils.hpp"
|
||||
#include "libslic3r/Measure.hpp"
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
#include "libslic3r/Model.hpp"
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
class ModelVolume;
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
enum class ModelVolumeType : int;
|
||||
|
||||
namespace Measure { class Measuring; }
|
||||
@ -74,7 +68,6 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
}
|
||||
};
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
struct VolumeCacheItem
|
||||
{
|
||||
const ModelObject* object{ nullptr };
|
||||
@ -89,7 +82,6 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
};
|
||||
|
||||
std::vector<VolumeCacheItem> m_volumes_cache;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
EMode m_mode{ EMode::FeatureSelection };
|
||||
Measure::MeasurementResult m_measurement_result;
|
||||
@ -108,13 +100,10 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
};
|
||||
Dimensioning m_dimensioning;
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// Uses a standalone raycaster and not the shared one because of the
|
||||
// difference in how the mesh is updated
|
||||
std::unique_ptr<MeshRaycaster> m_raycaster;
|
||||
#else
|
||||
Transform3d m_volume_matrix{ Transform3d::Identity() };
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
std::vector<GLModel> m_plane_models_cache;
|
||||
std::map<int, std::shared_ptr<SceneRaycasterItem>> m_raycasters;
|
||||
std::vector<std::shared_ptr<SceneRaycasterItem>> m_selection_raycasters;
|
||||
@ -129,21 +118,11 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
std::vector<SceneRaycasterState> m_scene_raycasters;
|
||||
|
||||
// These hold information to decide whether recalculation is necessary:
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
std::vector<Transform3d> m_volumes_matrices;
|
||||
std::vector<ModelVolumeType> m_volumes_types;
|
||||
Vec3d m_first_instance_scale{ Vec3d::Ones() };
|
||||
Vec3d m_first_instance_mirror{ Vec3d::Ones() };
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
float m_last_inv_zoom{ 0.0f };
|
||||
std::optional<Measure::SurfaceFeature> m_last_circle;
|
||||
int m_last_plane_idx{ -1 };
|
||||
|
||||
bool m_mouse_left_down{ false }; // for detection left_up of this gizmo
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const ModelObject* m_old_model_object{ nullptr };
|
||||
const ModelVolume* m_old_model_volume{ nullptr };
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
Vec2d m_mouse_pos{ Vec2d::Zero() };
|
||||
|
||||
@ -186,9 +165,6 @@ protected:
|
||||
bool on_is_activable() const override;
|
||||
void on_render() override;
|
||||
void on_set_state() override;
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
CommonGizmosDataID on_get_requirements() const override;
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||
virtual void on_register_raycasters_for_picking() override;
|
||||
|
@ -613,7 +613,6 @@ bool Selection::contains_any_volume(const std::vector<unsigned int>& volume_idxs
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
bool Selection::contains_sinking_volumes(bool ignore_modifiers) const
|
||||
{
|
||||
for (const GLVolume* v : *m_volumes) {
|
||||
@ -624,7 +623,6 @@ bool Selection::contains_sinking_volumes(bool ignore_modifiers) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
bool Selection::matches(const std::vector<unsigned int>& volume_idxs) const
|
||||
{
|
||||
|
@ -338,10 +338,8 @@ public:
|
||||
bool contains_all_volumes(const std::vector<unsigned int>& volume_idxs) const;
|
||||
// returns true if the selection contains at least one of the given indices
|
||||
bool contains_any_volume(const std::vector<unsigned int>& volume_idxs) const;
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// returns true if the selection contains any sinking volume
|
||||
bool contains_sinking_volumes(bool ignore_modifiers = true) const;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// returns true if the selection contains all and only the given indices
|
||||
bool matches(const std::vector<unsigned int>& volume_idxs) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user