public void Finish(Guid id, int[] iframe) { ComputationRequest request = null; lock (_Sync) { if (_Package == null) { return; } request = _Package.Finish(id, iframe); if (request == null) { return; } byte[] buffer = new byte[iframe.Length * sizeof(int)]; Buffer.BlockCopy(iframe, 0, buffer, 0, buffer.Length); File.WriteAllBytes(GetPartialFramePath(Name, _FrameCount, request), buffer); } if (_Package.IsDone) { FrameFinished?.Invoke(this, _Package.Frame); } else { FrameChanged?.Invoke(this, new EventArgs()); } }
public void Update(double deltaTime) { if (deltaTime == 0) { return; } foreach (IBody body in Bodies) { if (body.Dynamics.IsFixed) { continue; } // enact forces on the body foreach (ForceField field in ForceFields) { // maybe dont apply forces if we are currently inside another object? body.Dynamics.ThrustSingleFrame(field.GetForceOnBody(body), field.GetTorqueOnBody(body)); } // find and resolve contacts ContactResolver.ResolveContacts(ContactFinder.FindContacts(body, Bodies)); // update body state body.Dynamics.Update(deltaTime); } UniversalTime += deltaTime; FrameFinished?.Invoke(this, new FrameLengthArgs(deltaTime)); }
private void Clock_OneSecondTick() { for (int i = 0; i < tickProviders.Length; i++) { ulong newTickCount = tickProviders[i].TotalTickCount; ticksInOneSecond[i] = newTickCount - prevTickCount[i]; prevTickCount[i] = newTickCount; } FrameFinished?.Invoke(); }
public BasicBody(IDynamicBody dynamics, IElectroMag eMProps, BasicMaterial material, IEdgeIntersector collisionShape, IVolume shape, IOverlapable boundVolume) { Dynamics = dynamics; EMProps = eMProps; Material = material; CollisionShape = collisionShape; Shape = shape; BoundVolume = boundVolume; Dynamics.FrameFinished += (sender, e) => FrameFinished?.Invoke(sender, e); }
public void Update(double deltaTime) { // update dynamics P += deltaTime * NetCurrentForce; L += deltaTime * NetCurrentTorque; // update kinematics UpdateKinematics(); // update positions kinematicBody.UpdateTransform(deltaTime); UpdateTempForces(deltaTime); FrameFinished?.Invoke(this, new FrameLengthArgs(deltaTime)); }
private IEnumerable <ClockTick> RenderFrame(bool isOddFrame) { if (!isOddFrame) { yield return(new ClockTick()); // even frames have an extra tick } // Scanlines 0 to 239 do the drawing of the visible portion of the screen pixelByteOffset = 0; for (int scanLine = 0; scanLine <= 239; scanLine++) { foreach (ClockTick tick in ScanLineVisible(scanLine)) { yield return(tick); } } // The frame is effectively finished (240 scanlines are finished), // so let the emulator draw it during the blank period. SwapBuffers(); FrameFinished?.Invoke(); // Scanline 240 does nothing for (int cycle = 0; cycle <= 340; cycle++) { yield return(new ClockTick()); } // Scanline 241 sets the vertical-blank flag foreach (ClockTick tick in ScanLineSetVerticalBlank()) { yield return(tick); } // Scanlines 242 to 260 do nothing for (int scanLine = 242; scanLine <= 260; scanLine++) { for (int cycle = 0; cycle <= 340; cycle++) { yield return(new ClockTick()); } } // Scanline 261 clears the vertical-blank flag foreach (ClockTick tick in ScanLineClearVerticalBlank()) { yield return(tick); } }