Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[collision] Second generation of octree collision detection: account for vertex collisions #423

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
set(INEXOR_BENCHMARKING_SOURCE_FILES
engine_benchmark_main.cpp

world/cube_collision.cpp
)

add_executable(inexor-vulkan-renderer-benchmarks ${INEXOR_BENCHMARKING_SOURCE_FILES})
Expand Down
23 changes: 0 additions & 23 deletions benchmarks/world/cube_collision.cpp

This file was deleted.

1 change: 0 additions & 1 deletion include/inexor/vulkan-renderer/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "inexor/vulkan-renderer/input/keyboard_mouse_data.hpp"
#include "inexor/vulkan-renderer/renderer.hpp"
#include "inexor/vulkan-renderer/world/collision_query.hpp"
#include "inexor/vulkan-renderer/world/cube.hpp"

#include <GLFW/glfw3.h>
Expand Down
60 changes: 0 additions & 60 deletions include/inexor/vulkan-renderer/world/collision.hpp

This file was deleted.

39 changes: 0 additions & 39 deletions include/inexor/vulkan-renderer/world/collision_query.hpp

This file was deleted.

7 changes: 4 additions & 3 deletions include/inexor/vulkan-renderer/world/cube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Cube : public std::enable_shared_from_this<Cube> {
Type m_type{Type::EMPTY};
float m_size{32};
glm::vec3 m_position{0.0f, 0.0f, 0.0f};
glm::vec3 m_center{};

/// Root cube is empty.
std::weak_ptr<Cube> m_parent{};
Expand All @@ -75,11 +76,11 @@ class Cube : public std::enable_shared_from_this<Cube> {
std::uint8_t m_index_in_parent{};

/// Indentations, should only be used if it is a geometry cube.
std::array<Indentation, Cube::EDGES> m_indentations;
std::array<Indentation, Cube::EDGES> m_indentations{};
std::array<std::shared_ptr<Cube>, Cube::SUB_CUBES> m_children;

/// Only geometry cube (Type::SOLID and Type::Normal) have a polygon cache.
mutable PolygonCache m_polygon_cache;
mutable PolygonCache m_polygon_cache{};
mutable bool m_polygon_cache_valid{false};

/// Removes all children recursive.
Expand Down Expand Up @@ -126,7 +127,7 @@ class Cube : public std::enable_shared_from_this<Cube> {
[[nodiscard]] std::size_t count_geometry_cubes() const noexcept;

[[nodiscard]] glm::vec3 center() const noexcept {
return m_position + 0.5f * m_size;
return m_center;
}

[[nodiscard]] glm::vec3 position() const noexcept {
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ set(INEXOR_SOURCE_FILES
vulkan-renderer/wrapper/window.cpp
vulkan-renderer/wrapper/window_surface.cpp

vulkan-renderer/world/collision.cpp
vulkan-renderer/world/collision_query.cpp
vulkan-renderer/world/cube.cpp
vulkan-renderer/world/indentation.cpp)

Expand Down
22 changes: 1 addition & 21 deletions src/vulkan-renderer/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "inexor/vulkan-renderer/standard_ubo.hpp"
#include "inexor/vulkan-renderer/tools/cla_parser.hpp"
#include "inexor/vulkan-renderer/vk_tools/enumerate.hpp"
#include "inexor/vulkan-renderer/world/collision.hpp"
#include "inexor/vulkan-renderer/world/cube.hpp"
#include "inexor/vulkan-renderer/wrapper/cpu_texture.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptor_builder.hpp"
Expand Down Expand Up @@ -584,26 +583,7 @@ void Application::process_mouse_input() {
m_camera->set_movement_state(CameraMovement::RIGHT, m_input_data->is_key_pressed(GLFW_KEY_D));
}

void Application::check_octree_collisions() {
// Check for collision between camera ray and every octree
for (const auto &world : m_worlds) {
const auto collision = ray_cube_collision_check(*world, m_camera->position(), m_camera->front());

if (collision) {
const auto intersection = collision.value().intersection();
const auto face_normal = collision.value().face();
const auto corner = collision.value().corner();
const auto edge = collision.value().edge();

spdlog::trace("pos {} {} {} | face {} {} {} | corner {} {} {} | edge {} {} {}", intersection.x,
intersection.y, intersection.z, face_normal.x, face_normal.y, face_normal.z, corner.x,
corner.y, corner.z, edge.x, edge.y, edge.z);

// Break after one collision.
break;
}
}
}
void Application::check_octree_collisions() {}

void Application::run() {
spdlog::trace("Running Application");
Expand Down
Loading