diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-09-23 20:12:48 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-09-23 20:12:48 +0100 |
commit | dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c (patch) | |
tree | 0a880b2d14ac152014649d32088b73f17bf77297 /gfx/models/mesh.cpp | |
parent | Merge branch 'sunpos' (diff) | |
parent | Populate all layers of shadow stencil with view from all around (diff) | |
download | ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.tar.bz2 ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.tar.xz ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.zip |
Psycho-rebased branch billboard-shadows on top of main
Diffstat (limited to 'gfx/models/mesh.cpp')
-rw-r--r-- | gfx/models/mesh.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index e7474ca..2eae160 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -1,6 +1,32 @@ #include "mesh.h" -MeshBase::MeshBase(GLsizei m_numIndices, GLenum mode) : m_numIndices {m_numIndices}, mode {mode} { } +MeshBase::MeshBase(GLsizei m_numIndices, GLenum mode, const std::vector<RelativePosition3D> & positions) : + m_numIndices {m_numIndices}, mode {mode}, dimensions {positions} +{ +} + +MeshBase::Dimensions::Dimensions(const std::span<const RelativePosition3D> positions) : + Dimensions {positions, {extents(positions, 0), extents(positions, 1), extents(positions, 2)}} +{ +} + +MeshBase::Dimensions::Dimensions( + const std::span<const RelativePosition3D> positions, const std::array<Extents1D, 3> & extents1ds) : + minExtent(extents1ds[0].min, extents1ds[1].min, extents1ds[2].min), + maxExtent(extents1ds[0].max, extents1ds[1].max, extents1ds[2].max), centre {(minExtent + maxExtent) / 2.0F}, + size {std::ranges::max(positions | std::views::transform([this](const auto & v) { + return glm::distance(v, centre); + }))} +{ +} + +MeshBase::Dimensions::Extents1D +MeshBase::Dimensions::extents(const std::span<const RelativePosition3D> positions, glm::length_t D) +{ + return std::ranges::minmax(positions | std::views::transform([D](const auto & v) { + return v[D]; + })); +} void MeshBase::Draw() const |