A few notes on the design of Scene class, concerning the ability to "reset" the scene to its initial state how it was at the beginning of a simulation:
At first I thought we will have scene factories, i.e. a preset will not contain a scene but rather a function to create a new scene from scratch. This works fine, except when we want to have an "editable scene" functionality in the future;
Then I wanted scenes to be clone-able, so that at the start of the simulation we would clone the currently selected preset, and run simulation on the clone. Unfortunately, cloning proved to be hard, especially for entities that have behaviors targeting other entities. The targets for behaviors are declared final so cannot be reassigned, and for a good reason: a behavior may need to perform some initialization work depending on the target;
The final solution is to save the "state" of each entity at the start of a simulation, and then later revert to that state. So far I don't see any problems with this approach.
LightEntity
(withLightKinematics
)Scene
s can now be explicitly saved/restoredA few notes on the design of
Scene
class, concerning the ability to "reset" the scene to its initial state how it was at the beginning of a simulation: