Phyzix
Loading...
Searching...
No Matches
Boundary.h
1//
2// Created by shams on 8/7/24.
3//
4
5#ifndef PHYZIX_BOUNDARY_H
6#define PHYZIX_BOUNDARY_H
7
8
9#include <cstdint>
10#include "Vector.h"
11#include "app/lib/rtti.h"
12
13class Boundary;
14
21struct Boundaries {
23 uint16_t count;
24};
25
40
46public:
47 float e = 0.8;
49 RuntimeBaseType getBaseType() const override {
50 return RuntimeBaseType::BOUNDARY;
51 }
52
59
68 for(int i = 0; i < b1.count; ++i) {
69 for (int j = i; j < b2.count; ++j) {
70 auto intersection = b1.list[i]->intersects(b2.list[j]);
71 if (intersection.intersected)
72 return intersection;
73 }
74 }
75
76 return {false, Vector(0,0)};
77 }
78};
79
80#endif //PHYZIX_BOUNDARY_H
An abstract class to represent a boundary.
Definition Boundary.h:45
static BoundaryIntersectionResult intersects(Boundaries b1, Boundaries b2)
A static function to check if two boundaries (list) intersect.
Definition Boundary.h:67
float e
Definition Boundary.h:47
virtual BoundaryIntersectionResult intersects(Boundary *other)=0
A pure virtual function to check if the boundary intersects with another boundary.
Base class for runtime type identification.
Definition rtti.h:38
Enum class to identify the base type of a class for runtime type identification.
Definition Vector.h:12
A struct to hold a list of boundaries.
Definition Boundary.h:21
Boundary ** list
Definition Boundary.h:22
uint16_t count
Definition Boundary.h:23
A struct to hold the result of a possible intersection between two boundaries.
Definition Boundary.h:30
bool intersected
Definition Boundary.h:32
Boundary * it
Definition Boundary.h:36
Boundary * other
Definition Boundary.h:38
Vector normal
Definition Boundary.h:34