Verified Commit 5c95c090 authored by Sebastian Höffner's avatar Sebastian Höffner
Browse files

Fixing memory issues by not recording the trajectories while not running the simulation.

parent 304e44bf
......@@ -19,7 +19,8 @@ public class SceneController : MonoBehaviour
private List<string> metaLog;
string metaLogPhase = "UNDEFINED";
public bool captureVideo = true;
public bool captureVideo = false;
public static bool recordTrajectories = false;
public int timeoutAfterSeconds = 20;
private int timeToTimeout = 0;
......@@ -138,10 +139,12 @@ public class SceneController : MonoBehaviour
public IEnumerator RunSimulation(JSONArray instructions, Func<JSONObject, JSONObject, IEnumerator> replyToRequest, JSONObject originalRequest)
{
recordTrajectories = true;
JSONObject response = new JSONObject();
response.Add("trajectories.log", GetSchemasimLog());
response.Add("context", JSONHandler.instance.GenerateContextJSON());
response.Add("result", "Success!");
recordTrajectories = false;
yield return replyToRequest(response, originalRequest);
}
......
......@@ -11,11 +11,7 @@ public class InstanceIdentifier : MonoBehaviour
protected List<Vector3> positionHistory;
protected List<Quaternion> rotationHistory;
protected void Awake()
{
positionHistory = new List<Vector3>();
rotationHistory = new List<Quaternion>();
}
private bool recording = false;
public (List<Vector3>, List<Quaternion>) GetLog()
{
......@@ -24,8 +20,18 @@ public class InstanceIdentifier : MonoBehaviour
protected void Update()
{
positionHistory.Add(transform.position);
rotationHistory.Add(transform.rotation);
if (!recording && SceneController.recordTrajectories) {
recording = true;
positionHistory = new List<Vector3>();
rotationHistory = new List<Quaternion>();
}
if (recording) {
positionHistory.Add(transform.position);
rotationHistory.Add(transform.rotation);
}
if (recording && !SceneController.recordTrajectories) {
recording = false;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment