I am having trouble finding where in the code a Snapshot is taken (for undo/redo). I am assuming the game takes one after every user interaction. I am using pointers to vectors as a property, so I want to make a function that runs every time a snapshot is taken. My goal is to make a new copy of every existing vector and assign its pointer to the particle. That way, if the snapshot needs to be rolled back, the old vector still exists unchanged, and I can just reassign the saved pointer. Any ideas?
Edit: actually looks like I found it, HistorySnapshot() is called on mouse down, and CreateSnapshot() is called when ctrl-z is pressed in HistoryRestore(). I think HistorySnapshot() is also called a few other places but I haven't looked into that yet. I still am not sure how to make a function that copies all those vectors though...
Snapshot data format:
src/simulation/Snapshot.h
https://github.com/The-Powder-Toy/The-Powder-Toy/blob/master/src/simulation/Snapshot.h
src/simulation/Simulation.cpp: Actual snapshot taking / restoring
Creating snapshot:
https://github.com/The-Powder-Toy/The-Powder-Toy/blob/master/src/simulation/Simulation.cpp#L513
Restoring snapshot:
https://github.com/The-Powder-Toy/The-Powder-Toy/blob/master/src/simulation/Simulation.cpp#L538
If you notice, history snapshot calls gameModel->GetSimulation()->CreateSnapshot();