diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-02-14 12:37:53 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-02-14 12:37:53 +0000 |
| commit | 66ba8d76cf83e0e1875f13749833d95cb831f4b9 (patch) | |
| tree | 1eb7147212f1fb6ddd7f9ff6b4b2b9914b7746d2 | |
| parent | Ensure ANALYSIS_DIRECTORY root folder is created up front (diff) | |
| download | ilt-66ba8d76cf83e0e1875f13749833d95cb831f4b9.tar.bz2 ilt-66ba8d76cf83e0e1875f13749833d95cb831f4b9.tar.xz ilt-66ba8d76cf83e0e1875f13749833d95cb831f4b9.zip | |
Return indices instead of iterates from InstanceVertices::partition
More useful in the context of passing them to OpenGL.
| -rw-r--r-- | gfx/gl/instanceVertices.h | 10 | ||||
| -rw-r--r-- | test/test-instancing.cpp | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gfx/gl/instanceVertices.h b/gfx/gl/instanceVertices.h index 28e11ee..629c664 100644 --- a/gfx/gl/instanceVertices.h +++ b/gfx/gl/instanceVertices.h @@ -127,16 +127,22 @@ public: } template<typename Pred> - glContainer<T>::iterator + base::size_type partition(Pred pred) { - return partition(base::begin(), base::end(), pred); + return indexOf(partition(base::begin(), base::end(), pred)); } protected: static constexpr auto npos = static_cast<size_t>(-1); friend InstanceProxy; + base::size_type + indexOf(base::iterator iter) + { + return static_cast<base::size_type>(iter - base::begin()); + } + void release(const size_t pidx) { diff --git a/test/test-instancing.cpp b/test/test-instancing.cpp index 21d78e1..f303a15 100644 --- a/test/test-instancing.cpp +++ b/test/test-instancing.cpp @@ -250,8 +250,8 @@ BOOST_AUTO_TEST_CASE(PartitionBy, *boost::unit_test::timeout(1)) // The external view of the data is unchanged... BOOST_CHECK_EQUAL_COLLECTIONS(values.cbegin(), values.cend(), instances.cbegin(), instances.cend()); // The partition point is right... - BOOST_CHECK(!pred(*matchedEnd)); - BOOST_CHECK(pred(*--matchedEnd)); + BOOST_CHECK(!pred(at(matchedEnd))); + BOOST_CHECK(pred(at(matchedEnd - 1))); checkReverseIndex(); } |
