diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-03-18 02:42:19 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-03-18 02:42:19 +0000 |
commit | e513257354cfc53adef0f5f4e8dd896acd184f16 (patch) | |
tree | b9067ad807ae6afe47e173adfc4f6d6b07e2c3bd /game/geoData.cpp | |
parent | maybe_unused return from cut point search (diff) | |
download | ilt-e513257354cfc53adef0f5f4e8dd896acd184f16.tar.bz2 ilt-e513257354cfc53adef0f5f4e8dd896acd184f16.tar.xz ilt-e513257354cfc53adef0f5f4e8dd896acd184f16.zip |
Simplify creation of planes
Uses limit directions instead of fake triangles
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r-- | game/geoData.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index e29fb93..f4d9f65 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -412,7 +412,7 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip) // Extrude corners struct Extrusion { VertexHandle boundaryVertex, extrusionVertex; - GlobalPosition3D lowerLimit, upperLimit; + Direction3D lowerLimit, upperLimit; }; std::vector<Extrusion> extrusionExtents; @@ -450,8 +450,7 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip) } } - const auto extrusion = extrusionDir * 1000.F * MAX_SLOPE; - return boundaryVertex + extrusion; + return extrusionDir; }; // Previous half edge end to current half end start arc tangents const Arc arc {p1, p1 + (e0 || 0.F), p1 + (e1 || 0.F)}; @@ -481,25 +480,20 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip) [this, &boundaryFaces](const auto & first, const auto & second) { const auto p0 = point(first.boundaryVertex); const auto p1 = point(second.boundaryVertex); - const auto make_normal = [](auto x, auto y, auto z) { - const auto cp = crossProduct(z - x, y - x); - const auto rcp = RelativePosition3D(cp); - const auto nrcp = glm::normalize(rcp); - return nrcp; + const auto bdir = RelativePosition3D(p1 - p0); + const auto make_plane = [p0](auto y, auto z) { + return GeometricPlaneT<GlobalPosition3D> {p0, crossProduct(y, z)}; }; - const auto normals = ((first.boundaryVertex == second.boundaryVertex) - ? std::array {make_normal(p0, first.lowerLimit, second.lowerLimit), - make_normal(p0, first.upperLimit, second.upperLimit), + const auto planes = ((first.boundaryVertex == second.boundaryVertex) + ? std::array {make_plane(second.lowerLimit, first.lowerLimit), + make_plane(second.upperLimit, first.upperLimit), } : std::array { - make_normal(p0, second.lowerLimit, p1), - make_normal(p0, second.upperLimit, p1), + make_plane(bdir, second.lowerLimit), + make_plane(bdir, second.upperLimit), }); - assert(normals.front().z > 0.F); - assert(normals.back().z > 0.F); - const auto planes = normals * [p0](const auto & normal) { - return GeometricPlaneT<GlobalPosition3D> {p0, normal}; - }; + assert(planes.front().normal.z > 0.F); + assert(planes.back().normal.z > 0.F); auto & out = boundaryFaces.emplace_back(); out.emplace_back(first.boundaryVertex); |