From 68a23b27925142fed3b1e53b2f17ad2c90878e21 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 12 Feb 2024 23:25:00 +0000 Subject: Add helpers for testing for triangle overlap/containedness --- game/geoData.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index e234bfe..2fd3aa5 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -103,6 +103,8 @@ protected: [[nodiscard]] static bool triangleContainsPoint(const GlobalPosition2D, const Triangle<2> &); [[nodiscard]] bool triangleContainsPoint(const GlobalPosition2D, FaceHandle) const; + [[nodiscard]] static bool triangleOverlapsTriangle(const Triangle<2> &, const Triangle<2> &); + [[nodiscard]] static bool triangleContainsTriangle(const Triangle<2> &, const Triangle<2> &); [[nodiscard]] HalfedgeHandle findBoundaryStart() const; void update_vertex_normals_only(); -- cgit v1.2.3 From 849f4aa735352704995ffb51bf23dadf795bb119 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 13 Feb 2024 01:36:42 +0000 Subject: Include face handle in intersectRay result --- game/geoData.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index 2fd3aa5..f599552 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -74,8 +74,10 @@ public: [[nodiscard]] FaceHandle findPoint(GlobalPosition2D, FaceHandle start) const; [[nodiscard]] GlobalPosition3D positionAt(const PointFace &) const; - [[nodiscard]] std::optional intersectRay(const Ray &) const; - [[nodiscard]] std::optional intersectRay(const Ray &, FaceHandle start) const; + using IntersectionLocation = std::pair; + using IntersectionResult = std::optional; + [[nodiscard]] IntersectionResult intersectRay(const Ray &) const; + [[nodiscard]] IntersectionResult intersectRay(const Ray &, FaceHandle start) const; void walk(const PointFace & from, const GlobalPosition2D to, const std::function & op) const; void walkUntil(const PointFace & from, const GlobalPosition2D to, const std::function & op) const; -- cgit v1.2.3 From 6535a9c7f4e8fec978c079d45c0349a004b73241 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 14 Feb 2024 02:04:44 +0000 Subject: Fix getting cartesian coords from triangle baripos --- game/geoData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index f599552..6c6ae26 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -66,7 +66,7 @@ public: { const auto & t {*this}; return t[0] + GlobalPosition(RelativePosition(t[1] - t[0]) * bari.x) - + GlobalPosition(RelativePosition(t[2] - t[1]) * bari.y); + + GlobalPosition(RelativePosition(t[2] - t[0]) * bari.y); } }; -- cgit v1.2.3 From 3770b101cfc5ad37a069850b422f0098ade7fc08 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 22 Feb 2024 01:16:29 +0000 Subject: First cut of terrain deformation This "works" for some definition of works... But it's flawed in many ways, not least the following: * It's glitchy for no obvious reason * It's unreliable; fails if you tweak the parameters * The sides of the modified area are triangulated in the dumbest possible fashion, which results in ill-formed polygons * Probably other things, but... It works, remember... --- game/geoData.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index 6c6ae26..4d8e11c 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -89,6 +89,8 @@ public: [[nodiscard]] HalfedgeHandle findEntry(const GlobalPosition2D from, const GlobalPosition2D to) const; + void setHeights(const std::span triangleStrip); + [[nodiscard]] auto getExtents() const { -- cgit v1.2.3