Cut: fixed clipping plane when it is not horizonal

This commit is contained in:
Lukas Matena 2022-02-17 15:16:47 +01:00
parent af03bed094
commit 9917b8e58b
2 changed files with 5 additions and 10 deletions

View File

@ -130,9 +130,9 @@ void GLGizmoCut3D::update_clipper()
{
const Vec3d& angles = m_rotation_gizmo.get_rotation();
Matrix3d m;
m = Eigen::AngleAxisd(angles[X], Vec3d::UnitX())
m = Eigen::AngleAxisd(angles[Z], Vec3d::UnitZ())
* Eigen::AngleAxisd(angles[Y], Vec3d::UnitY())
* Eigen::AngleAxisd(angles[Z], Vec3d::UnitZ());
* Eigen::AngleAxisd(angles[X], Vec3d::UnitX());
Vec3d plane_center = m_move_gizmo.get_center();
BoundingBoxf3 box = m_move_gizmo.bounding_box();

View File

@ -458,17 +458,12 @@ void ObjectClipper::set_position_by_ratio(double pos, bool keep_normal)
void ObjectClipper::set_range_and_pos(const Vec3d& origin, const Vec3d& end, double pos)
{
std::cout << "origin:\t"<< origin.x() << "\t" << origin.y() << "\t"<< origin.z() << "\n";
std::cout << "end:\t" << end.x() << "\t" << end.y() << "\t"<< end.z() << "\n";
Vec3d normal = end-origin;
double norm = normal.norm();
pos = std::clamp(pos, 0.0001, norm);
std::cout << "NORM:\t" << norm << "\tPOS:\t" << pos << "\n\n";
m_clp.reset(new ClippingPlane(normal, pos));
m_clp_ratio = pos/norm;
normal.normalize();
m_clp.reset(new ClippingPlane(normal, normal.dot(origin)+pos));
m_clp_ratio = pos;
get_pool()->get_canvas()->set_as_dirty();
}