| 177 | } |
| 178 | |
| 179 | void SDFGrid::removePrimitives(const std::vector<uint32_t>& primitiveIDs) |
| 180 | { |
| 181 | for (uint32_t primitiveID : primitiveIDs) |
| 182 | { |
| 183 | auto idxIt = mPrimitiveIDToIndex.find(primitiveID); |
| 184 | |
| 185 | if (idxIt == mPrimitiveIDToIndex.end()) |
| 186 | { |
| 187 | logWarning("Primitive with ID {} does not exist!", primitiveID); |
| 188 | continue; |
| 189 | } |
| 190 | |
| 191 | // Mark as dirty. |
| 192 | mPrimitivesDirty = true; |
| 193 | |
| 194 | // Baked primitives cannot be removed. |
| 195 | uint32_t idx = idxIt->second; |
| 196 | if (idx < mBakedPrimitiveCount) |
| 197 | { |
| 198 | logWarning("Primitive with ID {} has been baked, cannot remove it!", primitiveID); |
| 199 | continue; |
| 200 | } |
| 201 | |
| 202 | // Erase the index from the indirection map. |
| 203 | mPrimitiveIDToIndex.erase(idxIt); |
| 204 | |
| 205 | // Compactify the primitive list. |
| 206 | mPrimitives.erase(mPrimitives.begin() + idx); |
| 207 | |
| 208 | if (idx < mPrimitives.size()) |
| 209 | { |
| 210 | // Update larger IDs as the primitive list must be compact. |
| 211 | for (auto& [id, index] : mPrimitiveIDToIndex) |
| 212 | { |
| 213 | if (index > idx) |
| 214 | { |
| 215 | --index; |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | std::unordered_set<uint32_t> indexSet; |
| 222 | for (const auto& [id, index] : mPrimitiveIDToIndex) |
| 223 | { |
| 224 | if (!indexSet.insert(index).second) |
| 225 | { |
| 226 | FALCOR_THROW("Multiple copies of index {}!", index); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | updatePrimitivesBuffer(); |
| 231 | } |
| 232 | |
| 233 | void SDFGrid::updatePrimitives(const std::vector<std::pair<uint32_t, SDF3DPrimitive>>& primitives) |
| 234 | { |
no test coverage detected