render/prim_rows.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | /// @file prim_rows.h | ||
| 3 | /// @brief Each bucket's prims by row as a reader last saw them, kept in step by replaying the | ||
| 4 | /// buckets' row logs, so the device scene's managers learn which prims came, went and moved | ||
| 5 | /// without scanning the scene. | ||
| 6 | #pragma once | ||
| 7 | |||
| 8 | #include "ernie/scene/storage.h" | ||
| 9 | |||
| 10 | #include <span> | ||
| 11 | #include <vector> | ||
| 12 | |||
| 13 | namespace ernie { | ||
| 14 | |||
| 15 | 63 | class PrimRows { | |
| 16 | public: | ||
| 17 | /// @brief The prims a change set brought, took and moved to other rows. | ||
| 18 | struct Changes { | ||
| 19 | std::vector<PrimId> removed; | ||
| 20 | /// Sorted by path, so parents come before their children. | ||
| 21 | std::vector<PrimId> added; | ||
| 22 | std::vector<PrimId> moved; | ||
| 23 | }; | ||
| 24 | |||
| 25 | /// @brief Replays the change set's row logs onto the rows last seen. | ||
| 26 | Changes Follow(const PrimStore& store, const ChangeSet& changes); | ||
| 27 | |||
| 28 | /// @return A bucket's prims by row as last followed; empty for a bucket not seen yet. | ||
| 29 | 6 | std::span<const PrimId> Bucket(BucketId bucket) const { | |
| 30 | 6 | return bucket < rows_.size() ? std::span<const PrimId>(rows_[bucket]) | |
| 31 | 6 | : std::span<const PrimId>(); | |
| 32 | } | ||
| 33 | |||
| 34 | private: | ||
| 35 | std::vector<std::vector<PrimId>> rows_; | ||
| 36 | }; | ||
| 37 | |||
| 38 | } // namespace ernie | ||
| 39 |