Tech ENABLE_GLBEGIN_GLEND_REMOVAL - Added method void init_from(const TriangleMesh& mesh) to GLModel
This commit is contained in:
parent
9d764bfeac
commit
5db3c66cf7
4 changed files with 18 additions and 7 deletions
|
@ -416,6 +416,11 @@ void GLModel::init_from(const Geometry& data)
|
|||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLModel::init_from(const TriangleMesh& mesh)
|
||||
{
|
||||
init_from(mesh.its);
|
||||
}
|
||||
|
||||
void GLModel::init_from(const indexed_triangle_set& its)
|
||||
#else
|
||||
void GLModel::init_from(const indexed_triangle_set& its, const BoundingBoxf3 &bbox)
|
||||
|
@ -488,7 +493,7 @@ void GLModel::init_from(const indexed_triangle_set& its, const BoundingBoxf3 &bb
|
|||
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
void GLModel::init_from(const indexed_triangle_set& its)
|
||||
{
|
||||
this->init_from(its, bounding_box(its));
|
||||
init_from(its, bounding_box(its));
|
||||
}
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
|
@ -574,11 +579,10 @@ bool GLModel::init_from_file(const std::string& filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
const TriangleMesh mesh = model.mesh();
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
init_from(mesh.its);
|
||||
init_from(model.mesh());
|
||||
#else
|
||||
init_from(mesh.its, mesh.bounding_box());
|
||||
init_from(model.mesh().its, mesh.bounding_box());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
m_filename = filename;
|
||||
|
|
|
@ -188,6 +188,7 @@ namespace GUI {
|
|||
size_t indices_size_bytes() const { return indices_count() * Geometry::index_stride_bytes(m_render_data.geometry.format); }
|
||||
|
||||
void init_from(Geometry&& data);
|
||||
void init_from(const TriangleMesh& mesh);
|
||||
#else
|
||||
void init_from(const Geometry& data);
|
||||
void init_from(const indexed_triangle_set& its, const BoundingBoxf3& bbox);
|
||||
|
|
|
@ -39,7 +39,7 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
|
|||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
m_cube.init_from(its);
|
||||
#else
|
||||
const_cast<GLModel&>(m_cube).init_from(its, BoundingBoxf3{ { -0.5, -0.5, -0.5 }, { 0.5, 0.5, 0.5 } });
|
||||
m_cube.init_from(its, BoundingBoxf3{ { -0.5, -0.5, -0.5 }, { 0.5, 0.5, 0.5 } });
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
|
|||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
m_cube.set_color(render_color);
|
||||
#else
|
||||
const_cast<GLModel*>(&m_cube)->set_color(-1, render_color);
|
||||
m_cube.set_color(-1, render_color);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
|
|
|
@ -651,17 +651,23 @@ void GLGizmoSimplify::init_model()
|
|||
}
|
||||
assert(volume != nullptr);
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
// set actual triangle count
|
||||
m_triangle_count += volume->mesh().its.indices.size();
|
||||
#else
|
||||
const indexed_triangle_set &its = volume->mesh().its;
|
||||
|
||||
// set actual triangle count
|
||||
m_triangle_count += its.indices.size();
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
assert(m_glmodels.find(id) == m_glmodels.end());
|
||||
GLModel &glmodel = m_glmodels[id]; // create new glmodel
|
||||
glmodel.init_from(its);
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
glmodel.init_from(volume->mesh());
|
||||
glmodel.set_color(selected_volume->color);
|
||||
#else
|
||||
glmodel.init_from(its);
|
||||
glmodel.set_color(-1,selected_volume->color);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
|
||||
|
|
Loading…
Reference in a new issue