mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 07:34:03 -06:00
parent
30d2c3787f
commit
9d29eddf16
11 changed files with 61 additions and 43 deletions
|
@ -171,7 +171,7 @@ void GLIndexedVertexArray::load_its_flat_shading(const indexed_triangle_set &its
|
|||
for (int i = 0; i < int(its.indices.size()); ++ i) {
|
||||
stl_triangle_vertex_indices face = its.indices[i];
|
||||
stl_vertex vertex[3] = { its.vertices[face[0]], its.vertices[face[1]], its.vertices[face[2]] };
|
||||
stl_vertex n = (vertex[2] - vertex[1]).cross(vertex[3] - vertex[2]).normalized();
|
||||
stl_vertex n = face_normal_normalized(vertex);
|
||||
for (int j = 0; j < 3; ++j)
|
||||
this->push_geometry(vertex[j](0), vertex[j](1), vertex[j](2), n(0), n(1), n(2));
|
||||
this->push_triangle(vertices_count, vertices_count + 1, vertices_count + 2);
|
||||
|
|
|
@ -93,7 +93,7 @@ void GLModel::init_from(const indexed_triangle_set& its, const BoundingBoxf3 &bb
|
|||
for (uint32_t i = 0; i < its.indices.size(); ++i) {
|
||||
stl_triangle_vertex_indices face = its.indices[i];
|
||||
stl_vertex vertex[3] = { its.vertices[face[0]], its.vertices[face[1]], its.vertices[face[2]] };
|
||||
stl_vertex n = (vertex[2] - vertex[1]).cross(vertex[3] - vertex[2]).normalized();
|
||||
stl_vertex n = face_normal_normalized(vertex);
|
||||
for (size_t j = 0; j < 3; ++ j) {
|
||||
size_t offset = i * 18 + j * 6;
|
||||
::memcpy(static_cast<void*>(&vertices[offset]), static_cast<const void*>(vertex[j].data()), 3 * sizeof(float));
|
||||
|
@ -111,6 +111,11 @@ void GLModel::init_from(const indexed_triangle_set& its, const BoundingBoxf3 &bb
|
|||
m_render_data.emplace_back(data);
|
||||
}
|
||||
|
||||
void GLModel::init_from(const indexed_triangle_set& its)
|
||||
{
|
||||
this->init_from(its, bounding_box(its));
|
||||
}
|
||||
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
void GLModel::init_from(const Polygons& polygons, float z)
|
||||
{
|
||||
|
@ -158,7 +163,9 @@ bool GLModel::init_from_file(const std::string& filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
init_from(model.mesh());
|
||||
TriangleMesh mesh = model.mesh();
|
||||
mesh.require_shared_vertices();
|
||||
init_from(mesh.its, mesh.bounding_box());
|
||||
|
||||
m_filename = filename;
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ namespace GUI {
|
|||
virtual ~GLModel() { reset(); }
|
||||
|
||||
void init_from(const InitializationData& data);
|
||||
void init_from(const TriangleMesh& mesh) { this->init_from(mesh.its, mesh.bounding_box()); }
|
||||
void init_from(const indexed_triangle_set& its, const BoundingBoxf3& bbox);
|
||||
void init_from(const indexed_triangle_set& its);
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
void init_from(const Polygons& polygons, float z);
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
|
|
|
@ -53,9 +53,9 @@ void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render
|
|||
if (! cube_initialized) {
|
||||
// This cannot be done in constructor, OpenGL is not yet
|
||||
// initialized at that point (on Linux at least).
|
||||
TriangleMesh mesh = make_cube(1., 1., 1.);
|
||||
mesh.translate(Vec3f(-0.5, -0.5, -0.5));
|
||||
const_cast<GLModel&>(cube).init_from(mesh);
|
||||
indexed_triangle_set mesh = its_make_cube(1., 1., 1.);
|
||||
its_translate(mesh, Vec3f(-0.5, -0.5, -0.5));
|
||||
const_cast<GLModel&>(cube).init_from(mesh, BoundingBoxf3{ { -0.5, -0.5, -0.5 }, { 0.5, 0.5, 0.5 } });
|
||||
const_cast<bool&>(cube_initialized) = true;
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,9 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, u
|
|||
m_base_color = DEFAULT_BASE_COLOR;
|
||||
m_drag_color = DEFAULT_DRAG_COLOR;
|
||||
m_highlight_color = DEFAULT_HIGHLIGHT_COLOR;
|
||||
m_cone.init_from(make_cone(1., 1., 2 * PI / 24));
|
||||
m_sphere.init_from(make_sphere(1., (2 * M_PI) / 24.));
|
||||
m_cylinder.init_from(make_cylinder(1., 1., 2 * PI / 24.));
|
||||
m_cone.init_from(its_make_cone(1., 1., 2 * PI / 24));
|
||||
m_sphere.init_from(its_make_sphere(1., (2 * M_PI) / 24.));
|
||||
m_cylinder.init_from(its_make_cylinder(1., 1., 2 * PI / 24.));
|
||||
}
|
||||
|
||||
void GLGizmoBase::set_hover_id(int id)
|
||||
|
|
|
@ -287,16 +287,14 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
|
|||
float dot_limit = limit.dot(down);
|
||||
|
||||
// Now calculate dot product of vert_direction and facets' normals.
|
||||
int idx = -1;
|
||||
int idx = 0;
|
||||
const indexed_triangle_set &its = mv->mesh().its;
|
||||
for (stl_triangle_vertex_indices face : its.indices) {
|
||||
stl_vertex vertex[3] = { its.vertices[face[0]], its.vertices[face[1]], its.vertices[face[2]] };
|
||||
stl_vertex n = (vertex[2] - vertex[1]).cross(vertex[3] - vertex[2]).normalized();
|
||||
++ idx;
|
||||
if (n.dot(down) > dot_limit) {
|
||||
if (its_face_normal(its, face).dot(down) > dot_limit) {
|
||||
m_triangle_selectors[mesh_id]->set_facet(idx, block ? EnforcerBlockerType::BLOCKER : EnforcerBlockerType::ENFORCER);
|
||||
m_triangle_selectors.back()->request_update_render_data();
|
||||
}
|
||||
++ idx;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace GUI {
|
|||
GLGizmoHollow::GLGizmoHollow(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
{
|
||||
m_vbo_cylinder.init_from(make_cylinder(1., 1.));
|
||||
m_vbo_cylinder.init_from(its_make_cylinder(1., 1.));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filenam
|
|||
, m_starting_box_center(Vec3d::Zero())
|
||||
, m_starting_box_bottom_center(Vec3d::Zero())
|
||||
{
|
||||
m_vbo_cone.init_from(make_cone(1., 1., 2*PI/36));
|
||||
m_vbo_cone.init_from(its_make_cone(1., 1., 2*PI/36));
|
||||
}
|
||||
|
||||
std::string GLGizmoMove3D::get_tooltip() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue