A little refactoring of loading meshes in VBO / non VBO case.
This commit is contained in:
parent
4904359399
commit
1fffae4e0b
@ -594,10 +594,7 @@ int GLVolumeCollection::load_object_volume(
|
|||||||
this->volumes.emplace_back(new GLVolume(color));
|
this->volumes.emplace_back(new GLVolume(color));
|
||||||
GLVolume &v = *this->volumes.back();
|
GLVolume &v = *this->volumes.back();
|
||||||
v.set_color_from_model_volume(model_volume);
|
v.set_color_from_model_volume(model_volume);
|
||||||
if (use_VBOs)
|
v.indexed_vertex_array.load_mesh(mesh, use_VBOs);
|
||||||
v.indexed_vertex_array.load_mesh_full_shading(mesh);
|
|
||||||
else
|
|
||||||
v.indexed_vertex_array.load_mesh_flat_shading(mesh);
|
|
||||||
|
|
||||||
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
||||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||||
@ -642,10 +639,7 @@ void GLVolumeCollection::load_object_auxiliary(
|
|||||||
const ModelInstance &model_instance = *print_object->model_object()->instances[instance_idx.first];
|
const ModelInstance &model_instance = *print_object->model_object()->instances[instance_idx.first];
|
||||||
this->volumes.emplace_back(new GLVolume((milestone == slaposBasePool) ? GLVolume::SLA_PAD_COLOR : GLVolume::SLA_SUPPORT_COLOR));
|
this->volumes.emplace_back(new GLVolume((milestone == slaposBasePool) ? GLVolume::SLA_PAD_COLOR : GLVolume::SLA_SUPPORT_COLOR));
|
||||||
GLVolume &v = *this->volumes.back();
|
GLVolume &v = *this->volumes.back();
|
||||||
if (use_VBOs)
|
v.indexed_vertex_array.load_mesh(mesh, use_VBOs);
|
||||||
v.indexed_vertex_array.load_mesh_full_shading(mesh);
|
|
||||||
else
|
|
||||||
v.indexed_vertex_array.load_mesh_flat_shading(mesh);
|
|
||||||
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
||||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||||
@ -716,14 +710,8 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||||||
|
|
||||||
this->volumes.emplace_back(new GLVolume(color));
|
this->volumes.emplace_back(new GLVolume(color));
|
||||||
GLVolume &v = *this->volumes.back();
|
GLVolume &v = *this->volumes.back();
|
||||||
|
v.indexed_vertex_array.load_mesh(mesh, use_VBOs);
|
||||||
if (use_VBOs)
|
|
||||||
v.indexed_vertex_array.load_mesh_full_shading(mesh);
|
|
||||||
else
|
|
||||||
v.indexed_vertex_array.load_mesh_flat_shading(mesh);
|
|
||||||
|
|
||||||
v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0));
|
v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0));
|
||||||
|
|
||||||
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
||||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||||
@ -1854,12 +1842,7 @@ bool GLArrow::on_init(bool useVBOs)
|
|||||||
triangles.emplace_back(7, 13, 6);
|
triangles.emplace_back(7, 13, 6);
|
||||||
|
|
||||||
m_useVBOs = useVBOs;
|
m_useVBOs = useVBOs;
|
||||||
|
m_volume.indexed_vertex_array.load_mesh(TriangleMesh(vertices, triangles), useVBOs);
|
||||||
if (m_useVBOs)
|
|
||||||
m_volume.indexed_vertex_array.load_mesh_full_shading(TriangleMesh(vertices, triangles));
|
|
||||||
else
|
|
||||||
m_volume.indexed_vertex_array.load_mesh_flat_shading(TriangleMesh(vertices, triangles));
|
|
||||||
|
|
||||||
m_volume.finalize_geometry(m_useVBOs);
|
m_volume.finalize_geometry(m_useVBOs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1974,12 +1957,7 @@ bool GLCurvedArrow::on_init(bool useVBOs)
|
|||||||
triangles.emplace_back(vertices_per_level, 2 * vertices_per_level + 1, vertices_per_level + 1);
|
triangles.emplace_back(vertices_per_level, 2 * vertices_per_level + 1, vertices_per_level + 1);
|
||||||
|
|
||||||
m_useVBOs = useVBOs;
|
m_useVBOs = useVBOs;
|
||||||
|
m_volume.indexed_vertex_array.load_mesh(TriangleMesh(vertices, triangles), useVBOs);
|
||||||
if (m_useVBOs)
|
|
||||||
m_volume.indexed_vertex_array.load_mesh_full_shading(TriangleMesh(vertices, triangles));
|
|
||||||
else
|
|
||||||
m_volume.indexed_vertex_array.load_mesh_flat_shading(TriangleMesh(vertices, triangles));
|
|
||||||
|
|
||||||
m_volume.bounding_box = m_volume.indexed_vertex_array.bounding_box();
|
m_volume.bounding_box = m_volume.indexed_vertex_array.bounding_box();
|
||||||
m_volume.finalize_geometry(m_useVBOs);
|
m_volume.finalize_geometry(m_useVBOs);
|
||||||
return true;
|
return true;
|
||||||
@ -2014,10 +1992,7 @@ bool GLBed::on_init_from_file(const std::string& filename, bool useVBOs)
|
|||||||
TriangleMesh mesh = model.mesh();
|
TriangleMesh mesh = model.mesh();
|
||||||
mesh.repair();
|
mesh.repair();
|
||||||
|
|
||||||
if (m_useVBOs)
|
m_volume.indexed_vertex_array.load_mesh(mesh, useVBOs);
|
||||||
m_volume.indexed_vertex_array.load_mesh_full_shading(mesh);
|
|
||||||
else
|
|
||||||
m_volume.indexed_vertex_array.load_mesh_flat_shading(mesh);
|
|
||||||
|
|
||||||
float color[4] = { 0.235f, 0.235f, 0.235f, 1.0f };
|
float color[4] = { 0.235f, 0.235f, 0.235f, 1.0f };
|
||||||
set_color(color, 4);
|
set_color(color, 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user