From 7886eff7ad6d888f37244091c29f6ea30e3f59ed Mon Sep 17 00:00:00 2001
From: Aaron <aaron.kreuzberg@rwth-aachen.de>
Date: Fri, 2 Jul 2021 01:02:42 +0200
Subject: [PATCH] Picking Visualization fix (still buggy)

---
 extern/glow-extras           |  2 +-
 samples/basic/viewer/main.cc | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/extern/glow-extras b/extern/glow-extras
index a6d1793..e904896 160000
--- a/extern/glow-extras
+++ b/extern/glow-extras
@@ -1 +1 @@
-Subproject commit a6d17933b2b8093098386f07596c3a8cc079c406
+Subproject commit e904896aaca745dbedc2b9d2baa19eee971f6fcb
diff --git a/samples/basic/viewer/main.cc b/samples/basic/viewer/main.cc
index 9d4f26a..83de2da 100644
--- a/samples/basic/viewer/main.cc
+++ b/samples/basic/viewer/main.cc
@@ -116,6 +116,7 @@ void simple_picking(pm::vertex_attribute<tg::pos3> const& pos, pm::face_attribut
         gv::view(pos, col, gv::pick().on_left_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
             std::cout << "Something has been picked! ON_LEFT_CLICK"
                       << "ID: " << face_id << std::endl;
+            std::cout << "World_Position" << world_pos << std::endl;
             return;
         }));
     }
@@ -138,6 +139,17 @@ void simple_picking(pm::vertex_attribute<tg::pos3> const& pos, pm::face_attribut
         }));
     }
 
+	{ //DOES NOT WORK RIGHT NOW - NEEDS TO BE FIXED
+        // Access of according face_indices while picking. Enable mesh access. WARNING: Does only work when Picking IDs are automatically generated and NOT user-defined
+        gv::view(pos, col, gv::pick().on_left_click([&](pm::face_index id, tg::pos3 world_pos, tg::vec3 normal) {
+           // std::cout << "Something has been picked! ON_LEFT_CLICK"
+            //          << "Face_index achieved" << id.value << std::endl;
+            // Mesh access at this point?
+            Picking_result r;
+            return r;
+        }));
+    }
+
     {
         // On_hover, on_right_click, and on_left_click callbacks defined simultaneously
         gv::view(pos, col,
@@ -162,20 +174,20 @@ void simple_picking(pm::vertex_attribute<tg::pos3> const& pos, pm::face_attribut
     }
 
     {
-		//User defined IDs check
+        // User defined IDs check
         auto id_f = pm::face_attribute<int>(pos.mesh());
         int32_t id = 0;
         std::vector<pick_id> ids;
 
-		for (auto f : pos.mesh().all_faces())
+        for (auto f : pos.mesh().all_faces())
         {
             pick_id pid;
             pid.id = id;
             ids.push_back(pid);
-			id++;
+            id++;
         }
 
-		gv::view(pos, col, ids, gv::pick().on_left_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
+        gv::view(pos, col, ids, gv::pick().on_left_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
             std::cout << "Something has been picked! ON_LEFT_CLICK"
                       << "ID: " << face_id << std::endl;
             return;
-- 
GitLab