From f1aa5e15f23e676868b86306f4fbc939fa8bcfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 11 Sep 2015 21:29:33 +0200 Subject: [PATCH] remove an automatic invalidate_buffers and replace them by manually placed ones --- .../Polyhedron_demo_self_intersection_plugin.cpp | 1 + Polyhedron/demo/Polyhedron/Scene.cpp | 1 - Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp | 1 + .../demo/Polyhedron/Scene_points_with_normal_item.cpp | 7 +++---- Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h | 2 +- .../demo/Polyhedron/Scene_polyhedron_selection_item.h | 2 ++ .../Polyhedron/Scene_polyhedron_shortest_path_item.cpp | 2 ++ 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp index 87d12a14d18..259d65073a8 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp @@ -72,6 +72,7 @@ void Polyhedron_demo_self_intersection_plugin::on_actionSelfIntersection_trigger selection_item->selected_facets.insert(fb->first); selection_item->selected_facets.insert(fb->second); } + selection_item->invalidate_buffers(); selection_item->setName(tr("%1 (selection) (intersecting triangles)").arg(item->name())); scene->addItem(selection_item); item->setRenderingMode(Wireframe); diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index da7ba71b2fd..184c9926adf 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -652,7 +652,6 @@ void Scene::itemChanged(Item_id i) if(i < 0 || i >= m_entries.size()) return; - m_entries[i]->invalidate_buffers(); Q_EMIT dataChanged(this->createIndex(i, 0), this->createIndex(i, LastColumn)); } diff --git a/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp index 62f39a69e0b..bb243537932 100644 --- a/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp @@ -443,6 +443,7 @@ void Scene_edit_polyhedron_item::timerEvent(QTimerEvent* /*event*/) { // just handle deformation - paint like selection is handled in eventFilter() if(state.ctrl_pressing && (state.left_button_pressing || state.right_button_pressing)) { if(!ui_widget->ActivatePivotingCheckBox->isChecked()) { + invalidate_buffers(); deform(); } else { diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index 1d0281260a3..e583cbb6cf5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -93,6 +93,7 @@ Scene_points_with_normal_item::~Scene_points_with_normal_item() void Scene_points_with_normal_item::initialize_buffers(Viewer_interface *viewer) const { + compute_normals_and_vertices(); //vao for the edges { program = getShaderProgram(PROGRAM_WITHOUT_LIGHT, viewer); @@ -150,10 +151,9 @@ void Scene_points_with_normal_item::initialize_buffers(Viewer_interface *viewer) program->release(); } are_buffers_filled = true; - - } -void Scene_points_with_normal_item::compute_normals_and_vertices(void) + +void Scene_points_with_normal_item::compute_normals_and_vertices() const { positions_points.resize(0); positions_lines.resize(0); @@ -579,7 +579,6 @@ void Scene_points_with_normal_item::set_has_normals(bool b) { void Scene_points_with_normal_item::invalidate_buffers() { - compute_normals_and_vertices(); are_buffers_filled = false; } diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h index ed44444a8ba..23a1a6f8cea 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h @@ -105,7 +105,7 @@ private: using Scene_item::initialize_buffers; void initialize_buffers(Viewer_interface *viewer) const; - void compute_normals_and_vertices(void); + void compute_normals_and_vertices() const; }; // end class Scene_points_with_normal_item diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index bbca4f84acb..e928fd9a545 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -604,6 +604,7 @@ public: polyhedron()->erase_facet((*fb)->halfedge()); } selected_facets.clear(); + invalidate_buffers(); changed_with_poly_item(); } @@ -670,6 +671,7 @@ public: void changed_with_poly_item() { // no need to update indices poly_item->invalidate_buffers(); + Q_EMIT poly_item->itemChanged(); Q_EMIT itemChanged(); } diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_shortest_path_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_shortest_path_item.cpp index 990a2340049..13db5c398c5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_shortest_path_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_shortest_path_item.cpp @@ -177,6 +177,8 @@ void Scene_polyhedron_shortest_path_item::ensure_shortest_paths_tree() void Scene_polyhedron_shortest_path_item::poly_item_changed() { recreate_shortest_path_object(); + invalidate_buffers(); + Q_EMIT itemChanged(); } void Scene_polyhedron_shortest_path_item::invalidate_buffers()