Lagrange
mesh_picking.h
1/*
2 * Copyright 2021 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/ui/api.h>
15#include <lagrange/ui/Entity.h>
16#include <lagrange/ui/types/Frustum.h>
17#include <lagrange/ui/utils/mesh.h>
18
19
20namespace lagrange {
21namespace ui {
22
23struct MeshSelectionRender;
24
25
28LA_UI_API std::optional<RayFacetHit>
29intersect_ray(Registry& r, Entity e, const Eigen::Vector3f& origin, const Eigen::Vector3f& dir);
30
31/*
32 Element selection
33*/
34
43LA_UI_API bool select_visible_elements(
44 Registry& r,
45 StringID element_type,
46 SelectionBehavior sel_behavior,
47 Entity selected_entity,
48 Entity active_viewport,
49 Frustum local_frustum);
50
58LA_UI_API bool select_elements_in_frustum(
59 Registry& r,
60 StringID element_type,
61 SelectionBehavior sel_behavior,
62 Entity selected_entity,
63 Frustum local_frustum);
64
65/*
66 Mesh element selection visualization utilities
67*/
68
69LA_UI_API void clear_element_selection_render(Registry& r, bool exclude_selected);
70
71LA_UI_API MeshSelectionRender& ensure_selection_render(Registry& r, Entity e);
72
74LA_UI_API void update_selection_render(
75 Registry& r,
76 MeshSelectionRender& sel_render,
77 const Entity& selected_mesh_entity,
78 const StringID& current_element_type);
79
80LA_UI_API void mark_selection_dirty(Registry& r, MeshSelectionRender& sel_render);
81
82/*
83 Accelerated picking
84*/
85
89LA_UI_API bool enable_accelerated_picking(Registry& r, Entity e);
90
91LA_UI_API bool has_accelerated_picking(Registry& r, Entity e);
92
93
94} // namespace ui
95} // namespace lagrange
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
LA_UI_API bool enable_accelerated_picking(Registry &r, Entity e)
Computes acceleration structure (igl::AABB) for faster ray-triangle intersection Entity can be entity...
Definition: mesh_picking.cpp:383
LA_UI_API bool select_visible_elements(Registry &r, StringID element_type, SelectionBehavior sel_behavior, Entity selected_entity, Entity active_viewport, Frustum local_frustum)
Selects visible mesh elements (sets is_selected attribute)
Definition: mesh_picking.cpp:74
LA_UI_API bool select_elements_in_frustum(Registry &r, StringID element_type, SelectionBehavior sel_behavior, Entity selected_entity, Frustum local_frustum)
Selects mesh elements intersecting a frustum (sets is_selected attribute)
Definition: mesh_picking.cpp:137
LA_UI_API std::optional< std::pair< Entity, RayFacetHit > > intersect_ray(Registry &r, const Eigen::Vector3f &origin, const Eigen::Vector3f &dir, ui::Entity root=ui::NullEntity, Layer visible_layers=Layer(true), Layer hidden_layers=Layer(false))
Intersect ray with meshes in root's hierarchy Returns a pair of intersected entity and the correspond...
Definition: default_entities.cpp:502
LA_UI_API void update_selection_render(Registry &r, MeshSelectionRender &sel_render, const Entity &selected_mesh_entity, const StringID &current_element_type)
Update materials and visibility of different mesh elements.
Definition: mesh_picking.cpp:323
Main namespace for Lagrange.
Definition: AABBIGL.h:30