| 145 | } |
| 146 | |
| 147 | uint32_t SDFGrid::addPrimitives(const std::vector<SDF3DPrimitive>& primitives) |
| 148 | { |
| 149 | // Copy primitives. |
| 150 | uint32_t primitivesStartOffset = (uint32_t)mPrimitives.size(); |
| 151 | mPrimitives.reserve(mPrimitives.size() + primitives.size()); |
| 152 | mPrimitives.insert(mPrimitives.end(), primitives.begin(), primitives.end()); |
| 153 | |
| 154 | // Assign indirection. |
| 155 | mPrimitiveIDToIndex.reserve(mPrimitives.size()); |
| 156 | uint32_t basePrimitiveID = mNextPrimitiveID; |
| 157 | |
| 158 | for (uint32_t idx = primitivesStartOffset; idx < mPrimitives.size(); idx++) |
| 159 | { |
| 160 | mPrimitiveIDToIndex[mNextPrimitiveID++] = idx; |
| 161 | } |
| 162 | |
| 163 | std::unordered_set<uint32_t> indexSet; |
| 164 | for (const auto& [id, index] : mPrimitiveIDToIndex) |
| 165 | { |
| 166 | if (!indexSet.insert(index).second) |
| 167 | { |
| 168 | FALCOR_THROW("Multiple copies of index {}!", index); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | mPrimitivesDirty = true; |
| 173 | |
| 174 | updatePrimitivesBuffer(); |
| 175 | |
| 176 | return basePrimitiveID; |
| 177 | } |
| 178 | |
| 179 | void SDFGrid::removePrimitives(const std::vector<uint32_t>& primitiveIDs) |
| 180 | { |
no test coverage detected