summaryrefslogtreecommitdiff
path: root/lib/geometricPlane.h
blob: dc8df50336316731987f9d2016a8e930a0dbd882 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

#include <glm/vec3.hpp>
#include <optional>

class Ray;

class GeometricPlane {
public:
	struct DistAndPosition {
		float dist;
		glm::vec3 position;
	};
	enum class PlaneRelation { Above, Below, On };

	glm::vec3 origin, normal;

	PlaneRelation getRelation(glm::vec3 point) const;
	std::optional<DistAndPosition> getRayIntersectPosition(const Ray &) const;

	static bool isIntersect(PlaneRelation a, PlaneRelation b);
};