From 745719c6cc032a8fd157f6f9259d54f462ea258d Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Tue, 30 Jan 2024 14:32:09 +0800 Subject: [PATCH] FIX: rendering: fix the assert under debug mode when using shared index object we don't need to load mesh again Change-Id: I085a7afc8c40508050ab523f43c76ecbdf8d6372 --- src/slic3r/GUI/3DScene.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 41c847148..bf36690dd 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -1094,6 +1094,7 @@ int GLVolumeCollection::load_object_volume( const TriangleMesh* mesh_ptr = model_volume->mesh_ptr(); new_volume->ori_mesh = mesh_ptr; std::map>::iterator iter = g_mesh_volumes_map.find(mesh_ptr); + bool need_create_mesh = true; if (iter != g_mesh_volumes_map.end()) { std::set & volume_set = iter->second; @@ -1103,6 +1104,7 @@ int GLVolumeCollection::load_object_volume( else { GLVolume* first_volume = *(volume_set.begin()); new_volume->indexed_vertex_array = first_volume->indexed_vertex_array; + need_create_mesh = false; } volume_set.emplace(new_volume); } @@ -1113,12 +1115,14 @@ int GLVolumeCollection::load_object_volume( volume_set.emplace(new_volume); g_mesh_volumes_map.emplace(mesh_ptr, std::move(volume_set)); } + if (need_create_mesh) { #if ENABLE_SMOOTH_NORMALS - v.indexed_vertex_array->load_mesh(mesh, true); + v.indexed_vertex_array->load_mesh(mesh, true); #else - v.indexed_vertex_array->load_mesh(mesh); + v.indexed_vertex_array->load_mesh(mesh); #endif // ENABLE_SMOOTH_NORMALS - v.indexed_vertex_array->finalize_geometry(opengl_initialized); + v.indexed_vertex_array->finalize_geometry(opengl_initialized); + } v.composite_id = GLVolume::CompositeID(obj_idx, volume_idx, instance_idx); if (model_volume->is_model_part()) {