58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "scene/SceneItemComponent.hpp"
|
|
#include "physics/2d/Box.hpp"
|
|
|
|
namespace Dawn {
|
|
enum Collider2DType {
|
|
COLLIDER2D_TYPE_BOX
|
|
};
|
|
|
|
struct Collider2DAxisAlignedCollidingResult {
|
|
glm::vec2 normal;
|
|
float_t entryTime;
|
|
float_t exitTime;
|
|
glm::vec2 entryPoint;
|
|
glm::vec2 exitPoint;
|
|
};
|
|
|
|
class Collider2D : public SceneItemComponent {
|
|
public:
|
|
Collider2D(SceneItem *item);
|
|
|
|
/**
|
|
* Returns which type of collider this is.
|
|
*
|
|
* @return The collider type that this is.
|
|
*/
|
|
virtual enum Collider2DType getColliderType() = 0;
|
|
|
|
/**
|
|
* Gets the result of checking if two collider bodies are intersecting.
|
|
* This is performed WITH movement to return entry and exit times.
|
|
*
|
|
* @param result Where to store the results of the calculation.
|
|
* @param movement Movement operation that THIS object is performing.
|
|
* @param other Other Collider that is being compared.
|
|
* @param normal Output normal of the intersection.
|
|
* @param entryTime Output entry time when the two objects will intersect.
|
|
* @param exitTime Output exit time when the object will pass through.
|
|
* @param entryPoint Output point in 2D space where object will enter.
|
|
* @param exitPoint Output point where object will have passed through.
|
|
* @return True if the two objects will intersect at move otherwise false.
|
|
*/
|
|
bool_t getCollidingResult(
|
|
glm::vec2 movement,
|
|
Collider2D *other,
|
|
glm::vec2 &normal,
|
|
float_t &entryTime,
|
|
float_t &exitTime,
|
|
glm::vec2 &entryPoint,
|
|
glm::vec2 &exitPoint
|
|
);
|
|
};
|
|
} |