| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #ifndef DEPTHGUIDE_CURSOR_GUIDE_IMPL_H
- #define DEPTHGUIDE_CURSOR_GUIDE_IMPL_H
- #include "module/guidance/cursor_guide.h"
- #include "core/math_helper.hpp"
- namespace cursor_guide_impl {
- struct point_set {
- struct point_type {
- glm::vec3 position;
- float radius;
- bool is_picked = false;
- };
- using container_type =
- std::list<point_type>;
- using iterator_type =
- container_type::iterator;
- container_type c;
- // object observed in world
- glm::mat4 transform = glm::mat4(1.0f);
- // p: in world coordinate
- void emplace(const glm::vec3 &p, float r);
- // tp: point in world coordinate
- // return true if some point is picked.
- bool try_picking(const glm::vec3 &tp);
- void remove_picked();
- };
- using mesh_cache_type =
- std::unordered_map<float, mesh_ptr>;
- extern mesh_cache_type mesh_cache;
- mesh_ptr get_mesh(float radius);
- }
- using namespace cursor_guide_impl;
- struct cursor_guide::impl {
- static constexpr auto amb_factor = 0.9f;
- static constexpr auto color_free = glm::vec3(0, 1, 0);
- static constexpr auto color_picked = glm::vec3(1, 0, 0);
- static constexpr auto color_fixed = glm::vec3(0, 0, 1);
- sophiar_conn_type *sophiar_conn = nullptr;
- float current_radius = 5.f;
- std::optional<glm::vec3> free_pos; // in world coordinate
- using binding_store_base_type
- = create_config::item_type;
- struct binding_store_type
- : public binding_store_base_type {
- using base_type = binding_store_base_type;
- impl *pimpl = nullptr;
- point_set points;
- explicit binding_store_type(impl *_pimpl, const base_type &base)
- : binding_store_base_type(base) {
- pimpl = _pimpl;
- }
- void update_transform();
- };
- using binding_list_type =
- std::vector<binding_store_type>;
- binding_list_type binding_list;
- size_t current_binding = 0;
- explicit impl(const create_config &conf);
- void update(const guide_info &info);
- void show();
- void pre_render_slot(const scene_ptr &info);
- };
- #endif //DEPTHGUIDE_CURSOR_GUIDE_IMPL_H
|