opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
scene_helpers.h
Go to the documentation of this file.
1#pragma once
2
13
14#include <functional>
15#include <optional>
16#include <span>
17
18namespace osc { class BVH; }
19namespace osc { class Camera; }
20namespace osc { class Mesh; }
21namespace osc { class Rect; }
22namespace osc { class SceneCache; }
23namespace osc { struct AABB; }
24namespace osc { struct LineSegment; }
25namespace osc { struct Ray; }
26namespace osc { struct Transform; }
27
28namespace osc
29{
32 const BVH&,
33 const std::function<void(SceneDecoration&&)>& out
34 );
35
38 const AABB&,
39 const std::function<void(SceneDecoration&&)>& out
40 );
41
44 std::span<const AABB>,
45 const std::function<void(SceneDecoration&&)>& out
46 );
47
50 const BVH&,
51 const std::function<void(SceneDecoration&&)>& out
52 );
53
56 const std::function<void(SceneDecoration&&)>& out,
57 float scale = 5.0f
58 );
59
62 const std::function<void(SceneDecoration&&)>& out
63 );
64
67 const std::function<void(SceneDecoration&&)>& out
68 );
69
72 const std::function<void(SceneDecoration&&)>& out
73 );
74
86 const ArrowProperties&,
87 const std::function<void(SceneDecoration&&)>& out
88 );
89
92 const LineSegment&,
93 const Color&,
94 float radius,
95 const std::function<void(SceneDecoration&&)>& out
96 );
97
98 // updates the given BVH with the given component decorations
100 std::span<const SceneDecoration>,
101 BVH&
102 );
103
104 // calls `out` with each `SceneCollision` found along `world_space_ray`
106 const BVH& scene_bvh,
107 SceneCache&,
108 std::span<const SceneDecoration>,
109 const Ray& world_space_ray,
110 const std::function<void(SceneCollision&&)>& out
111 );
112
113 // returns all collisions along `world_space_ray`
114 std::vector<SceneCollision> get_all_ray_collisions_with_scene(
115 const BVH& scene_bvh,
116 SceneCache&,
117 std::span<const SceneDecoration>,
118 const Ray& world_space_ray
119 );
120
121 // returns closest ray-triangle collision along `world_space_ray`
123 const Mesh&,
124 const BVH& triangle_bvh,
125 const Transform&,
126 const Ray& world_space_ray
127 );
128
129 // returns closest ray-triangle collision in world space for a given mouse position
130 // within the given render rectangle
132 const Camera&,
133 const Mesh&,
134 const BVH& triangle_bvh,
135 const Rect& screen_render_rect,
136 Vector2 mouse_screen_position
137 );
138
139 // returns scene rendering parameters for an generic panel
141 const Camera&,
143 Vector2 dimensions,
144 float device_pixel_ratio
145 );
146
147 // returns a triangle BVH for the given triangle mesh, or an empty BVH if the mesh is non-triangular or empty
149
150 // returns `FrustumPlanes` that represent the clipping planes of `camera` when rendering to an
151 // output that has an aspect ratio of `aspect_ratio`
152 FrustumPlanes calc_frustum_planes(const Camera& camera, float aspect_ratio);
153
154 // Returns a vector that points in a direction that nicely lights
155 // the scene with a directional light from the perspective of `camera`.
157}
Definition anti_aliasing_level.h:11
Definition bvh.h:23
Definition camera.h:21
Definition mesh.h:33
Definition rect.h:17
Definition scene_cache.h:25
Definition custom_decoration_generator.h:5
void draw_aabbs(SceneCache &, std::span< const AABB >, const std::function< void(SceneDecoration &&)> &out)
void update_scene_bvh(std::span< const SceneDecoration >, BVH &)
SceneRendererParams calc_standard_dark_scene_render_params(const Camera &, AntiAliasingLevel, Vector2 dimensions, float device_pixel_ratio)
void draw_arrow(SceneCache &, const ArrowProperties &, const std::function< void(SceneDecoration &&)> &out)
void draw_xz_floor_lines(SceneCache &, const std::function< void(SceneDecoration &&)> &out, float scale=5.0f)
void draw_line_segment(SceneCache &, const LineSegment &, const Color &, float radius, const std::function< void(SceneDecoration &&)> &out)
void for_each_ray_collision_with_scene(const BVH &scene_bvh, SceneCache &, std::span< const SceneDecoration >, const Ray &world_space_ray, const std::function< void(SceneCollision &&)> &out)
void draw_bvh(SceneCache &, const BVH &, const std::function< void(SceneDecoration &&)> &out)
Vector3 recommended_light_direction(const Camera &camera)
BVH create_triangle_bvh(const Mesh &)
void draw_xz_grid(SceneCache &, const std::function< void(SceneDecoration &&)> &out)
std::optional< RayCollision > get_closest_world_space_ray_triangle_collision(const Mesh &, const BVH &triangle_bvh, const Transform &, const Ray &world_space_ray)
void draw_xy_grid(SceneCache &, const std::function< void(SceneDecoration &&)> &out)
void draw_bvh_leaf_nodes(SceneCache &, const BVH &, const std::function< void(SceneDecoration &&)> &out)
FrustumPlanes calc_frustum_planes(const Camera &camera, float aspect_ratio)
std::vector< SceneCollision > get_all_ray_collisions_with_scene(const BVH &scene_bvh, SceneCache &, std::span< const SceneDecoration >, const Ray &world_space_ray)
Matrix< T, 4, 4 > scale(const Matrix< T, 4, 4 > &m, const Vector< T, 3 > &v)
Definition matrix_functions.h:78
void draw_aabb(SceneCache &, const AABB &, const std::function< void(SceneDecoration &&)> &out)
void draw_yz_grid(SceneCache &, const std::function< void(SceneDecoration &&)> &out)
Definition aabb.h:14
Definition scene_helpers.h:75
float neck_thickness
Definition scene_helpers.h:79
Vector3 start
Definition scene_helpers.h:76
float tip_length
Definition scene_helpers.h:78
Vector3 end
Definition scene_helpers.h:77
Color color
Definition scene_helpers.h:81
SceneDecorationFlags decoration_flags
Definition scene_helpers.h:82
float head_thickness
Definition scene_helpers.h:80
Definition frustum_planes.h:10
Definition line_segment.h:13
Definition ray.h:17
static constexpr Rgba black()
Definition rgba.h:38
Definition scene_collision.h:12
Definition scene_decoration.h:15
Definition scene_renderer_params.h:13
Definition transform.h:11