MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / handleUndo

Method handleUndo

Source/RenderPasses/SDFEditor/SDFEditor.cpp:963–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

961}
962
963void SDFEditor::handleUndo()
964{
965 uint32_t primitivesAffectedCount = calcPrimitivesAffectedCount(mUndoPressedCount++);
966
967 // Undo - Go though the performed SDF edits, removed them and put them in the mUndoneSDFEdits list.
968 std::unordered_map<SdfGridID, std::vector<uint32_t>> primitiveIDsToRemovePerSDF;
969
970 if (mNonBakedPrimitiveCount > 0)
971 {
972 uint32_t editsToUndoCount = std::min(primitivesAffectedCount, uint32_t(mPerformedSDFEdits.size()));
973 editsToUndoCount = std::min(editsToUndoCount, mNonBakedPrimitiveCount);
974 for (uint32_t i = 0; i < editsToUndoCount; i++)
975 {
976 SDFEdit& sdfEdit = mPerformedSDFEdits.back();
977 primitiveIDsToRemovePerSDF[sdfEdit.gridID].push_back(sdfEdit.primitiveID);
978 mPerformedSDFEdits.pop_back();
979 }
980
981 for (auto& pair : primitiveIDsToRemovePerSDF)
982 {
983 SdfGridID gridID = pair.first;
984 const std::vector<uint32_t>& primitiveIDsToRemove = pair.second;
985
986 const ref<SDFGrid>& pSDFGrid = mpScene->getSDFGrid(gridID);
987
988 UndoneSDFEdit undoEdit;
989 undoEdit.gridID = gridID;
990 for (uint32_t primitiveToRemove : primitiveIDsToRemove)
991 {
992 undoEdit.primitive = pSDFGrid->getPrimitive(primitiveToRemove);
993 mUndoneSDFEdits.push_back(undoEdit);
994 mNonBakedPrimitiveCount--;
995 }
996 pSDFGrid->removePrimitives(primitiveIDsToRemove);
997 }
998 }
999}
1000
1001void SDFEditor::handleRedo()
1002{

Callers

nothing calls this directly

Calls 5

backMethod · 0.80
removePrimitivesMethod · 0.80
minFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected