From a007ffeed3cfa6af2cbe1053c330ad11927d58de Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 18 Dec 2024 17:24:02 +0000 Subject: Add sanity checking logic to GeoData --- game/geoData.cpp | 10 ++++++++++ game/geoData.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'game') diff --git a/game/geoData.cpp b/game/geoData.cpp index 8e662b3..eef5dc7 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -601,3 +601,13 @@ GeoData::setHeights(const std::span triangleStrip, const updateAllVertexNormals(newOrChangedVerts); } + +void +GeoData::sanityCheck() const +{ + if (!std::ranges::all_of(faces(), [this](const auto face) { + return triangle<2>(face).isUp(); + })) { + throw std::logic_error("Upside down faces detected"); + } +} diff --git a/game/geoData.h b/game/geoData.h index 79924d3..01582a6 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -98,6 +98,8 @@ public: return property(surface, h); } + void sanityCheck() const; + protected: template [[nodiscard]] Triangle -- cgit v1.2.3