41 auto e = var.cast<entt::handle>();
48 const auto& world_transform = transform_comp.get_transform_global();
54 auto& selected_camera = selected_camera_comp.
get_camera();
55 const auto view_proj = selected_camera.get_view_projection();
56 const auto bounds = selected_camera.get_local_bounding_box();
68 aabb.min = vec3_to_bx(bounds.min);
69 aabb.max = vec3_to_bx(bounds.max);
80 const auto&
light = light_comp.get_light();
88 auto oposite = tan_angle * adjacent;
93 math::vec3 from = transform_comp.get_position_global();
94 math::vec3 to = from + transform_comp.get_z_axis_local() * adjacent;
100 auto oposite = tan_angle * adjacent;
105 math::vec3 from = transform_comp.get_position_global();
106 math::vec3 to = from + transform_comp.get_z_axis_local() * adjacent;
116 math::vec3
center = transform_comp.get_position_global();
127 math::vec3 from1 = transform_comp.get_position_global();
128 math::vec3 to1 = from1 + transform_comp.get_z_axis_local() * 1.0f;
130 bx::Cylinder cylinder = {vec3_to_bx(from1), vec3_to_bx(to1), 0.1f};
133 math::vec3 from2 = to1;
134 math::vec3 to2 = from2 + transform_comp.get_z_axis_local() * 0.5f;
136 bx::Cone cone = {vec3_to_bx(from2), vec3_to_bx(to2), 0.25f};
144 const auto& probe = probe_comp.
get_probe();
153 aabb.min = vec3_to_bx(-probe.box_data.extents);
154 aabb.max = vec3_to_bx(probe.box_data.extents);
162 auto radius = probe.get_face_extents(0, world_transform);
163 auto transform = world_transform;
164 transform.reset_scale();
182 const auto& volume = volume_comp.get_local_bounds();
193 aabb.min = vec3_to_bx(volume.min);
194 aabb.max = vec3_to_bx(volume.max);
202 aabb.min = vec3_to_bx(volume.min);
203 aabb.max = vec3_to_bx(volume.max);
211 aabb.min = vec3_to_bx(volume.min - volume_comp.blend_distance);
212 aabb.max = vec3_to_bx(volume.max + volume_comp.blend_distance);
226 const auto&
model = model_comp.get_model();
236 current_lod_data.calculate_screen_rect(cam);
240 if(em.gizmos.show_model_bounds && frustum.test_aabb(model_comp.get_world_bounds()))
242 static constexpr std::array<uint32_t, 5> lod_colors_abgr = {
249 static constexpr std::array<ImU32, 5> lod_colors_im = {
250 IM_COL32(0, 255, 0, 255),
251 IM_COL32(255, 255, 0, 255),
252 IM_COL32(255, 128, 0, 255),
253 IM_COL32(255, 0, 0, 255),
254 IM_COL32(255, 0, 255, 255),
257 const auto color_index = std::min<size_t>(current_lod_data.current_lod_index, lod_colors_abgr.size() - 1);
259 auto world_bounds = model_comp.get_world_bounds();
266 aabb.min = vec3_to_bx(world_bounds.min);
267 aabb.max = vec3_to_bx(world_bounds.max);
294 if(em.gizmos.show_model_submesh_bounds)
297 const auto& proxies = model_comp.get_render_proxies();
298 const uint32_t base_lod = current_lod_data.current_lod_index;
305 const auto&
mesh = lod.get();
307 auto draw_submesh_lod = [&](uint32_t submesh_index,
const math::bbox& bounds) ->
void
309 if(!bounds.is_populated() || !frustum.test_aabb(bounds))
314 const uint32_t effective_lod =
316 const auto color_index = std::min<size_t>(effective_lod, lod_colors_abgr.size() - 1);
322 aabb.min = vec3_to_bx(bounds.min);
323 aabb.max = vec3_to_bx(bounds.max);
329 const auto label_color = lod_colors_im[color_index];
331 [screen_pos, effective_lod, label_color]() ->
void
333 auto window = ImGui::GetCurrentWindow();
334 auto draw_list = window->DrawList;
335 const auto text = fmt::format(
"LOD: {}", effective_lod);
336 const auto text_size = ImGui::CalcTextSize(text.c_str());
337 const ImVec2 pos(screen_pos.x - text_size.x * 0.5f,
338 screen_pos.y - text_size.y * 0.5f);
339 draw_list->AddText(pos, label_color, text.c_str());
346 for(
size_t submesh_index = 0; submesh_index < proxies.instance_bounds.size(); ++submesh_index)
348 for(
const auto& bounds : proxies.instance_bounds[submesh_index])
350 draw_submesh_lod(
static_cast<uint32_t
>(submesh_index), bounds);
353 for(
size_t submesh_index = 0; submesh_index < proxies.skinned_bounds.size(); ++submesh_index)
355 draw_submesh_lod(
static_cast<uint32_t
>(submesh_index), proxies.skinned_bounds[submesh_index]);
368 if(frustum.test_obb(bbox, world_transform))
375 aabb.min = vec3_to_bx(bbox.min);
376 aabb.max = vec3_to_bx(bbox.max);
388 if(em.gizmos.show_particle_emitter_bounds)
390 const auto& bounds = particle_emitter_comp.get_world_bounds();
391 if(frustum.test_aabb(bounds))
397 aabb.min = vec3_to_bx(bounds.min);
398 aabb.max = vec3_to_bx(bounds.max);
404 if(em.gizmos.show_particle_emitter_shape)
411 const auto shape = particle_emitter_comp.get_shape();
412 const auto scale = particle_emitter_comp.get_emission_shape_scale();
413 const auto position = particle_emitter_comp.get_emission_shape_position();
414 const auto direction = particle_emitter_comp.get_direction();
415 const float shape_size = 1.0f;
421 auto transform = math::translate(math::mat4(1.0f),
position) * math::scale(math::mat4(1.0f),
scale);
425 math::vec3
center{0.0f, 0.0f, 0.0f};
435 auto transform = math::translate(math::mat4(1.0f),
position) * math::scale(math::mat4(1.0f),
scale);
439 math::vec3
center{0.0f, 0.0f, 0.0f};
446 const int num_arcs = 8;
447 for(
int i = 0; i < num_arcs; ++i)
449 const float angle = (3.14159265f *
static_cast<float>(i)) /
static_cast<float>(num_arcs);
450 const float cos_a = math::cos(angle);
451 const float sin_a = math::sin(angle);
455 const float x_pos = cos_a * shape_size;
456 const float z_pos = sin_a * shape_size;
460 const int arc_segments = 16;
461 bool first_point =
true;
463 for(
int j = 0; j <= arc_segments; ++j)
465 const float arc_angle = (3.14159265f *
static_cast<float>(j)) /
static_cast<float>(arc_segments);
466 const float y = shape_size * math::sin(arc_angle);
467 const float radius_at_height = shape_size * math::cos(arc_angle);
469 const float x = cos_a * radius_at_height;
470 const float z = sin_a * radius_at_height;
485 const int num_horizontal_circles = 2;
486 for(
int i = 1; i <= num_horizontal_circles; ++i)
488 const float height_ratio =
static_cast<float>(i) /
static_cast<float>(num_horizontal_circles + 1);
489 const float y_pos = shape_size * height_ratio;
490 const float radius_at_height = shape_size * math::sqrt(1.0f - height_ratio * height_ratio);
501 auto transform = math::translate(math::mat4(1.0f),
position) * math::scale(math::mat4(1.0f),
scale);
505 math::vec3
center{0.0f, 0.0f, 0.0f};
514 const float half_size = shape_size;
524 const float half_size = shape_size;
535 if(em.gizmos.show_particle_emitter_direction)
539 const float arrow_length = shape_size * 0.5f;
540 const float arrow_head_size = arrow_length * 0.2f;
551 dd.
encoder.
lineTo(-arrow_head_size, arrow_length - arrow_head_size, 0.0f);
553 dd.
encoder.
lineTo(arrow_head_size, arrow_length - arrow_head_size, 0.0f);
555 dd.
encoder.
lineTo(0.0f, arrow_length - arrow_head_size, -arrow_head_size);
557 dd.
encoder.
lineTo(0.0f, arrow_length - arrow_head_size, arrow_head_size);
563 const int num_arrows = 6;
564 for(
int i = 0; i < num_arrows; ++i)
567 (2.0f * 3.14159265f *
static_cast<float>(i)) /
static_cast<float>(num_arrows);
568 const float cos_a = math::cos(angle);
569 const float sin_a = math::sin(angle);
572 dd.
encoder.
moveTo(cos_a * shape_size * 0.3f, 0.0f, sin_a * shape_size * 0.3f);
573 dd.
encoder.
lineTo(cos_a * arrow_length, 0.0f, sin_a * arrow_length);
576 const float head_x = cos_a * arrow_length;
577 const float head_z = sin_a * arrow_length;
578 const float back_x = cos_a * (arrow_length - arrow_head_size);
579 const float back_z = sin_a * (arrow_length - arrow_head_size);
584 back_z + cos_a * arrow_head_size * 0.5f);
588 back_z - cos_a * arrow_head_size * 0.5f);
597 const int num_arrows = 6;
598 for(
int i = 0; i < num_arrows; ++i)
601 (2.0f * 3.14159265f *
static_cast<float>(i)) /
static_cast<float>(num_arrows);
602 const float cos_a = math::cos(angle);
603 const float sin_a = math::sin(angle);
606 dd.
encoder.
moveTo(cos_a * shape_size * 0.3f, 0.0f, sin_a * shape_size * 0.3f);
607 dd.
encoder.
lineTo(cos_a * arrow_length, 0.0f, sin_a * arrow_length);
610 const float head_x = cos_a * arrow_length;
611 const float head_z = sin_a * arrow_length;
612 const float back_x = cos_a * (arrow_length - arrow_head_size);
613 const float back_z = sin_a * (arrow_length - arrow_head_size);
618 back_z + cos_a * arrow_head_size * 0.5f);
622 back_z - cos_a * arrow_head_size * 0.5f);
637 if(em.gizmos.show_component_gizmos)
639 hpp::for_each_tuple_type<all_inspectable_components>(
643 auto component = e.try_get<ctype>();
648 auto var_comp = entt::forward_as_meta(*component);