wren
Vulkan-based game engine
Loading...
Searching...
No Matches
collider.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <flecs.h>
4
5#include <memory>
6#include <optional>
9
10#include "../components.hpp"
11
13
14struct Collider : public Base {
15 using Ptr = std::shared_ptr<Collider>;
16
17 [[nodiscard]] virtual auto raycast(const Transform& transform,
18 const math::Vec3f& origin,
19 const math::Vec3f& direction) const
20 -> std::optional<math::Vec3f> = 0;
21};
22
23struct BoxCollider2D : public Collider {
24 static void init(const flecs::world& world) {
25 static bool inited = false;
26 if (!inited) {
27 inited = true;
28 world.component<BoxCollider2D::Ptr>().is_a<Collider>();
29 }
30 }
31
32 [[nodiscard]] auto raycast(const Transform& transform,
33 const math::Vec3f& origin,
34 const math::Vec3f& direction) const
35 -> std::optional<math::Vec3f> override;
36
38};
39
40} // namespace wren::scene::components
Definition collider.cpp:3
Definition vector.hpp:142
Definition vector.hpp:153
Definition components.hpp:7
Definition collider.hpp:23
auto raycast(const Transform &transform, const math::Vec3f &origin, const math::Vec3f &direction) const -> std::optional< math::Vec3f > override
Definition collider.cpp:5
static void init(const flecs::world &world)
Definition collider.hpp:24
math::Vec2f size
Definition collider.hpp:37
Definition collider.hpp:14
virtual auto raycast(const Transform &transform, const math::Vec3f &origin, const math::Vec3f &direction) const -> std::optional< math::Vec3f >=0
std::shared_ptr< Collider > Ptr
Definition collider.hpp:15
Definition transform.hpp:10