mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-18 22:31:13 -06:00
Tech ENABLE_RAYCAST_PICKING - Raytraced picking of volumes
This commit is contained in:
parent
02f83f29c7
commit
3577a259d5
19 changed files with 690 additions and 152 deletions
|
@ -6233,7 +6233,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
continue;
|
||||
volume_count++;
|
||||
if (m_share_mesh) {
|
||||
auto iter = m_shared_meshes.find(volume->mesh_ptr());
|
||||
auto iter = m_shared_meshes.find(volume->mesh_ptr().get());
|
||||
if (iter != m_shared_meshes.end())
|
||||
{
|
||||
const ModelVolume* shared_volume = iter->second.second;
|
||||
|
@ -6248,7 +6248,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
const_cast<_BBS_3MF_Exporter *>(this)->m_shared_meshes.insert({volume->mesh_ptr(), {&object_data, volume}});
|
||||
const_cast<_BBS_3MF_Exporter *>(this)->m_shared_meshes.insert({volume->mesh_ptr().get(), {&object_data, volume}});
|
||||
}
|
||||
if (m_from_backup_save)
|
||||
volume_id = (volume_count << 16 | backup_id);
|
||||
|
|
|
@ -320,6 +320,67 @@ Transform3d assemble_transform(const Vec3d& translation, const Vec3d& rotation,
|
|||
return transform;
|
||||
}
|
||||
|
||||
void assemble_transform(Transform3d& transform, const Transform3d& translation, const Transform3d& rotation, const Transform3d& scale, const Transform3d& mirror)
|
||||
{
|
||||
transform = translation * rotation * scale * mirror;
|
||||
}
|
||||
|
||||
Transform3d assemble_transform(const Transform3d& translation, const Transform3d& rotation, const Transform3d& scale, const Transform3d& mirror)
|
||||
{
|
||||
Transform3d transform;
|
||||
assemble_transform(transform, translation, rotation, scale, mirror);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void translation_transform(Transform3d& transform, const Vec3d& translation)
|
||||
{
|
||||
transform = Transform3d::Identity();
|
||||
transform.translate(translation);
|
||||
}
|
||||
|
||||
Transform3d translation_transform(const Vec3d& translation)
|
||||
{
|
||||
Transform3d transform;
|
||||
translation_transform(transform, translation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void rotation_transform(Transform3d& transform, const Vec3d& rotation)
|
||||
{
|
||||
transform = Transform3d::Identity();
|
||||
transform.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()) * Eigen::AngleAxisd(rotation.y(), Vec3d::UnitY()) * Eigen::AngleAxisd(rotation.x(), Vec3d::UnitX()));
|
||||
}
|
||||
|
||||
Transform3d rotation_transform(const Vec3d& rotation)
|
||||
{
|
||||
Transform3d transform;
|
||||
rotation_transform(transform, rotation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void scale_transform(Transform3d& transform, double scale)
|
||||
{
|
||||
return scale_transform(transform, scale * Vec3d::Ones());
|
||||
}
|
||||
|
||||
void scale_transform(Transform3d& transform, const Vec3d& scale)
|
||||
{
|
||||
transform = Transform3d::Identity();
|
||||
transform.scale(scale);
|
||||
}
|
||||
|
||||
Transform3d scale_transform(double scale)
|
||||
{
|
||||
return scale_transform(scale * Vec3d::Ones());
|
||||
}
|
||||
|
||||
Transform3d scale_transform(const Vec3d& scale)
|
||||
{
|
||||
Transform3d transform;
|
||||
scale_transform(transform, scale);
|
||||
return transform;
|
||||
}
|
||||
|
||||
Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& rotation_matrix)
|
||||
{
|
||||
// reference: http://www.gregslabaugh.net/publications/euler.pdf
|
||||
|
@ -405,20 +466,6 @@ void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, doubl
|
|||
}
|
||||
}
|
||||
|
||||
Transform3d translation_transform(const Vec3d &translation)
|
||||
{
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
transform.translate(translation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
Transform3d rotation_transform(const Vec3d& rotation)
|
||||
{
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
transform.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()) * Eigen::AngleAxisd(rotation.y(), Vec3d::UnitY()) * Eigen::AngleAxisd(rotation.x(), Vec3d::UnitX()));
|
||||
return transform;
|
||||
}
|
||||
|
||||
bool Transformation::Flags::needs_update(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
||||
{
|
||||
return (this->dont_translate != dont_translate) || (this->dont_rotate != dont_rotate) || (this->dont_scale != dont_scale) || (this->dont_mirror != dont_mirror);
|
||||
|
|
|
@ -324,7 +324,8 @@ bool arrange(
|
|||
// 4) rotate Y
|
||||
// 5) rotate Z
|
||||
// 6) translate
|
||||
void assemble_transform(Transform3d& transform, const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(), const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
void assemble_transform(Transform3d& transform, const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(),
|
||||
const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
|
||||
// Returns the transform obtained by assembling the given transformations in the following order:
|
||||
// 1) mirror
|
||||
|
@ -333,7 +334,45 @@ void assemble_transform(Transform3d& transform, const Vec3d& translation = Vec3d
|
|||
// 4) rotate Y
|
||||
// 5) rotate Z
|
||||
// 6) translate
|
||||
Transform3d assemble_transform(const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(), const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
Transform3d assemble_transform(const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(),
|
||||
const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
|
||||
// Sets the given transform by multiplying the given transformations in the following order:
|
||||
// T = translation * rotation * scale * mirror
|
||||
void assemble_transform(Transform3d& transform, const Transform3d& translation = Transform3d::Identity(),
|
||||
const Transform3d& rotation = Transform3d::Identity(), const Transform3d& scale = Transform3d::Identity(),
|
||||
const Transform3d& mirror = Transform3d::Identity());
|
||||
|
||||
// Returns the transform obtained by multiplying the given transformations in the following order:
|
||||
// T = translation * rotation * scale * mirror
|
||||
Transform3d assemble_transform(const Transform3d& translation = Transform3d::Identity(), const Transform3d& rotation = Transform3d::Identity(),
|
||||
const Transform3d& scale = Transform3d::Identity(), const Transform3d& mirror = Transform3d::Identity());
|
||||
|
||||
// Sets the given transform by assembling the given translation
|
||||
void translation_transform(Transform3d& transform, const Vec3d& translation);
|
||||
|
||||
// Returns the transform obtained by assembling the given translation
|
||||
Transform3d translation_transform(const Vec3d& translation);
|
||||
|
||||
// Sets the given transform by assembling the given rotations in the following order:
|
||||
// 1) rotate X
|
||||
// 2) rotate Y
|
||||
// 3) rotate Z
|
||||
void rotation_transform(Transform3d& transform, const Vec3d& rotation);
|
||||
|
||||
// Returns the transform obtained by assembling the given rotations in the following order:
|
||||
// 1) rotate X
|
||||
// 2) rotate Y
|
||||
// 3) rotate Z
|
||||
Transform3d rotation_transform(const Vec3d& rotation);
|
||||
|
||||
// Sets the given transform by assembling the given scale factors
|
||||
void scale_transform(Transform3d& transform, double scale);
|
||||
void scale_transform(Transform3d& transform, const Vec3d& scale);
|
||||
|
||||
// Returns the transform obtained by assembling the given scale factors
|
||||
Transform3d scale_transform(double scale);
|
||||
Transform3d scale_transform(const Vec3d& scale);
|
||||
|
||||
// Returns the euler angles extracted from the given rotation matrix
|
||||
// Warning -> The matrix should not contain any scale or shear !!!
|
||||
|
@ -346,16 +385,7 @@ Vec3d extract_euler_angles(const Transform3d& transform);
|
|||
// get rotation from two vectors.
|
||||
// Default output is axis-angle. If rotation_matrix pointer is provided, also output rotation matrix
|
||||
// Euler angles can be obtained by extract_euler_angles()
|
||||
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, double& phi, Matrix3d* rotation_matrix = nullptr);
|
||||
|
||||
// Returns the transform obtained by assembling the given translation
|
||||
Transform3d translation_transform(const Vec3d &translation);
|
||||
|
||||
// Returns the transform obtained by assembling the given rotations in the following order:
|
||||
// 1) rotate X
|
||||
// 2) rotate Y
|
||||
// 3) rotate Z
|
||||
Transform3d rotation_transform(const Vec3d &rotation);
|
||||
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d &rotation_axis, double &phi, Matrix3d *rotation_matrix = nullptr);
|
||||
|
||||
class Transformation
|
||||
{
|
||||
|
|
|
@ -883,7 +883,7 @@ public:
|
|||
|
||||
// The triangular model.
|
||||
const TriangleMesh& mesh() const { return *m_mesh.get(); }
|
||||
const TriangleMesh* mesh_ptr() const { return m_mesh.get(); }
|
||||
std::shared_ptr<const TriangleMesh> mesh_ptr() const { return m_mesh; }
|
||||
void set_mesh(const TriangleMesh &mesh) { m_mesh = std::make_shared<const TriangleMesh>(mesh); }
|
||||
void set_mesh(TriangleMesh &&mesh) { m_mesh = std::make_shared<const TriangleMesh>(std::move(mesh)); }
|
||||
void set_mesh(const indexed_triangle_set &mesh) { m_mesh = std::make_shared<const TriangleMesh>(mesh); }
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
#define ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT (1 && ENABLE_2_4_0_BETA2)
|
||||
// Enable fit print volume command for circular printbeds
|
||||
#define ENABLE_ENHANCED_PRINT_VOLUME_FIT (1 && ENABLE_2_4_0_BETA2)
|
||||
// Enable picking using raytracing
|
||||
#define ENABLE_RAYCAST_PICKING_DEBUG (1)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue