mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
fixed trace line, improved collision
This commit is contained in:
22
include/omath/collision/Cube.h
Normal file
22
include/omath/collision/Cube.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by vlad on 11/15/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "ICollidable.h"
|
||||
|
||||
namespace omath::collision
|
||||
{
|
||||
class Cube final : public ICollidable
|
||||
{
|
||||
public:
|
||||
|
||||
[[nodiscard]]
|
||||
bool IsCollideWith(const std::shared_ptr<ICollidable>& other) override;
|
||||
|
||||
private:
|
||||
[[nodiscard]]
|
||||
bool IsCollideWithCube(const Cube& other);
|
||||
bool IsCollideWithCapsule(const Cube& other);
|
||||
|
||||
};
|
||||
}
|
||||
20
include/omath/collision/ICollidable.h
Normal file
20
include/omath/collision/ICollidable.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Created by vlad on 11/15/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "ICollidable.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
||||
namespace omath::collision
|
||||
{
|
||||
class ICollidable
|
||||
{
|
||||
public:
|
||||
virtual ~ICollidable() = default;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual bool IsCollideWith(const std::shared_ptr<ICollidable>& other) = 0;
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
// Created by Orange on 11/13/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include <optional>
|
||||
|
||||
#include "omath/Vector3.hpp"
|
||||
#include "omath/Triangle3d.hpp"
|
||||
@@ -34,6 +33,6 @@ namespace omath::collision
|
||||
// Realization of Möller–Trumbore intersection algorithm
|
||||
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
|
||||
[[nodiscard]]
|
||||
static std::optional<Vector3> GetRayHitPoint(const Ray& ray, const Triangle3d& triangle);
|
||||
static Vector3 GetRayHitPoint(const Ray& ray, const Triangle3d& triangle);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user