/// <summary> /// Gets new distance reading if the device is on, /// and handles the toggling of the display of the laser. /// </summary> public void Update() { Debug.Log("eraseme: Update START"); double nowTime = Planetarium.GetUniversalTime(); pqsTool.tickPortionAllowed = (double)(CPUGreedyPercent / 100.0); // just in case user changed it in the slider. deltaTime = nowTime - prevTime; prevTime = nowTime; drainPower(); PhysicsRaycaster(); castUpdate(); ChangeIsDrawing(); drawUpdate(); if (doStressTest) { // This code was how I judged how many iterations I should allow the PQS // algorithm to take per update - it measures how sluggish animation // gets if I use the PQS altitude solver a lot per update. It should never // be enabled again unless you're trying to repeat that sort of test. It // bogs down KSP. int numQueries = 1000; System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); timer.Start(); pqsTool.StressTestPQS(part.vessel.GetOrbit().referenceBody, numQueries); timer.Stop(); if (debugMsg) { UnityEngine.Debug.Log("StressTestPQS: for " + numQueries + ", " + timer.Elapsed.TotalMilliseconds + "millis"); } } }
/// <summary> /// Gets new distance reading if the device is on, /// and handles the toggling of the display of the laser. /// </summary> public void Update() { if (!fixedUpdateHappened) { DebugMsg("Update: a FixedUpdate hasn't happened yet, so skipping."); return; } DebugMsg("Update: A new FixedUpdate happened, so doing the full work this time."); fixedUpdateHappened = false; double nowTime = Planetarium.GetUniversalTime(); pqsTool.tickPortionAllowed = (double)(CPUGreedyPercent / 100.0); // just in case user changed it in the slider. deltaTime = nowTime - prevTime; if (prevTime > 0) // Skips the power drain if it's the very first Update() after the scene load. { drainPower(); } prevTime = nowTime; PhysicsRaycaster(); castUpdate(); ChangeIsDrawing(); drawUpdate(); if (doStressTest) { // This code was how I judged how many iterations I should allow the PQS // algorithm to take per update - it measures how sluggish animation // gets if I use the PQS altitude solver a lot per update. It should never // be enabled again unless you're trying to repeat that sort of test. It // bogs down KSP. int numQueries = 1000; System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); timer.Start(); pqsTool.StressTestPQS(part.vessel.GetOrbit().referenceBody, numQueries); timer.Stop(); DebugMsg("StressTestPQS: for " + numQueries + ", " + timer.Elapsed.TotalMilliseconds + "millis"); } }