Note that there are some explanatory texts on larger screens.

plurals
  1. POIs event recording on time-sensitive possible?
    primarykey
    data
    text
    <p><strong>Basic Question</strong></p> <p>Is there any way to event recording an playback within a time-sensitive (framerate independent) system?</p> <p>Any help - including a simple "No sorry it is impossible" - would be greatly appreciated. I have spent almost 20 hours working on this over the past few weekends and am driving myself crazy.</p> <p><strong>Full Details</strong></p> <p>This is being currently aimed at a game but the libraries I'm writing are designed to be more general and this concept applies to more than just my C++ coding.</p> <p>I have some code that looks functionally similar this... (it is written in C++0x but I'm taking some liberties to make it more compact)</p> <pre><code>void InputThread() { InputAxisReturn AxisState[IA_SIZE]; while (Continue) { Threading()-&gt;EventWait(InputEvent); Threading()-&gt;EventReset(InputEvent); pInput-&gt;GetChangedAxis(AxisState); //REF ALPHA if (AxisState[IA_GAMEPAD_0_X].Changed) { X_Axis = AxisState[IA_GAMEPAD_0_X].Value; } } } </code></pre> <p>And I have a separate thread that looks like this...</p> <pre><code>//REF BETA while (Continue) { //Is there a message to process? StandardWindowsPeekMessageProcessing(); //GetElapsedTime() returns a float of time in seconds since its last call UpdateAll(LoopTimer.GetElapsedTime()); } </code></pre> <p>Now I'd like to record input events for playback for testing and some limited replay functionality.</p> <p>I can easily record the events with precision timing by simply inserting the following code where I marked //REF ALPHA</p> <pre><code>//REF ALPHA EventRecordings.pushback(EventRecording(TimeSinceRecordingBegan, AxisState)); </code></pre> <p>The real issue is playing these back. My LoopTimer is extremely high precision using the High Performance Counter (QueryPreformanceCounter). This means that it is nearly impossible to hit the same time difference using code like below in place of //REF BETA</p> <pre><code>// REF BETA NextEvent = EventRecordings.pop_back() Time TimeSincePlaybackBegan; while (Continue) { //Is there a message to process? StandardWindowsPeekMessageProcessing(); //Did we reach the next event? if (TimeSincePlaybackBegan &gt;= NextEvent.TimeSinceRecordingBegan) { if (NextEvent.AxisState[IA_GAMEPAD_0_X].Changed) { X_Axis = NextEvent.AxisState[IA_GAMEPAD_0_X].Value; } NextEvent = EventRecordings.pop_back(); } //GetElapsedTime() returns a float of time in seconds since its last call Time elapsed = LoopTimer.GetElapsedTime() UpdateAll(elapsed); TimeSincePlabackBegan += elapsed; } </code></pre> <p>The issue with this approach is that you will almost never hit the exact same time so you will have a few microseconds where the playback doesn't match the recording.</p> <p>I also tried event snapping. Kind of a confusing term but basically if the TimeSincePlaybackBegan > NextEvent.TimeSinceRecordingBegan then TimeSincePlaybackBegan = NextEvent.TimeSinceRecordingBegan and ElapsedTime was altered to suit. </p> <p>It had some interesting side effects which you would expect (like some slowdown) but it unfortunately still resulted in the playback de-synchronizing.</p> <p><strong>For some more background</strong> - and possibly a reason why my time snapping approach didn't work - I'm using BulletPhysics somewhere down that UpdateAll call. Kind of like this...</p> <pre><code>void Update(float diff) { static const float m_FixedTimeStep = 0.005f; static const uint32 MaxSteps = 200; //Updates the fps cWorldInternal::Update(diff); if (diff &gt; MaxSteps * m_FixedTimeStep) { Warning("cBulletWorld::Update() diff &gt; MaxTimestep. Determinism will be lost"); } pBulletWorld-&gt;stepSimulation(diff, MaxSteps, m_FixedTimeStep); } </code></pre> <p>But I also tried with pBulletWorkd->stepSimulation(diff, 0, 0) which according to <a href="http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_the_World" rel="nofollow">http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_the_World</a> should have done the trick but still with no avail.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload