public void SetData(IList <T> list) { dirty = DirtyFlag.Data; count = list.Count; EnsureCapacity(count); list.CopyTo(data, 0); }
private void UpdateInfoText() { if ((dirtyFlags & DirtyFlag.Information) == 0) { return; } const int maxLength = 8; const string suffix = " recoded frames"; if (builder == null) { builder = new StringBuilder(suffix.Length + maxLength); } int frameCount = m_Recorder.FrameCount; builder.Length = 0; builder.Append(frameCount); builder.Append(suffix); infoText.text = builder.ToString(); dirtyFlags &= ~DirtyFlag.Information; }
private void UpdatePreview() { if ((dirtyFlags & DirtyFlag.Preview) == 0) { return; } RenderTexture texture; if (Recording) { texture = m_Recorder.RecordingUnit.ScratchBuffer; } else { UpdatePreviewTexture(); RenderPreviewTexture(); texture = previewTexture; } previewImage.texture = texture; if (texture != null) { const float MaxXScale = 1.8f; float s = (float)texture.width / texture.height; float xs = Mathf.Min(s, MaxXScale); float ys = MaxXScale / s; previewImage.rectTransform.localScale = new Vector3(xs, ys, 1.0f); } dirtyFlags &= ~DirtyFlag.Preview; }
private void BeginRecording() { if (m_Recorder.BeginRecording()) { dirtyFlags |= DirtyFlag.Background; } }
private void BeginRecording() { if (m_Recorder.BeginRecording()) { dirtyFlags |= DirtyFlag.All; } }
/// <summary> /// Sorts the event listeners. /// </summary> /// <param name="listenerID">Listener ID</param> void SortEventListeners(string listenerID) { DirtyFlag dirtyFlag = DirtyFlag.NONE; bool exists = false; if (priorityDirtyFlagMap.ContainsKey(listenerID)) { dirtyFlag = priorityDirtyFlagMap[listenerID]; exists = true; } if (dirtyFlag != DirtyFlag.NONE) { if (dirtyFlag.HasFlag(DirtyFlag.FIXED_PRIORITY)) { SortEventListenersOfFixedPriority(listenerID); } if (dirtyFlag.HasFlag(DirtyFlag.SCENE_GRAPH_PRIORITY)) { SortEventListenersOfSceneGraphPriority(listenerID); } if (exists) { priorityDirtyFlagMap [listenerID] = DirtyFlag.NONE; } } }
public void SetData(T[] array) { dirty = DirtyFlag.Data; count = array.Length; EnsureCapacity(count); System.Array.Copy(array, 0, data, 0, count); }
private void CleanupAlSource() { if (this.alSource <= AlSource_NotAvailable) { return; } lock (this.strLock) { // Do not reuse before-streamed sources, since OpenAL doesn't seem to like that. if (this.isStreamed) { AL.DeleteSource(this.alSource); this.alSource = AL.GenSource(); } // Reuse other OpenAL sources else { AL.SourceStop(this.alSource); AL.Source(this.alSource, ALSourcei.Buffer, 0); AL.SourceRewind(this.alSource); } this.dirtyState = DirtyFlag.All; } }
public DirtyValue(DirtyFlag dirtyFlag, string name, float val, float min, float max) { Name = name; Min = min; Max = max; this.dirtyFlag = dirtyFlag; this.val = val; }
private void ResetFrames() { currentFrame = 0; beginFrame = 0; endFrame = -1; dirtyFlags = DirtyFlag.FrameChange | DirtyFlag.RangeChange; }
public void Insert(int index, T item) { dirty = DirtyFlag.Data; EnsureCapacity(count + 1); System.Array.Copy(data, index, data, index + 1, count - index); data[index] = item; count++; }
public T this[int index] { get { return(data[index]); } set { dirty = DirtyFlag.Data; count = (index >= count ? (index + 1) : count); data[index] = value; } }
/// <summary> /// Initializes a new instance of the <see cref="FirstPerson"/> class. /// </summary> /// <param name="position">The position of the camera.</param> /// <param name="heading">The heading.</param> /// <param name="tilt">The tilt.</param> public FirstPerson(Vector3 position, float heading = 0f, float tilt = 0f) { cachedMatrixView = new DirtyFlag <Matrix4x4>(CalcViewMatrix); PropertyChanged += (s, a) => cachedMatrixView.Invalidate(); Position = position; Heading = heading; Tilt = tilt; }
public void Download() { if (dirty == DirtyFlag.Buffer) { dirty = DirtyFlag.Clean; buffer.GetData(data); } }
/// <summary> /// Initializes a new instance of the <see cref="Camera{VIEW, PROJECTION}"/> class. /// </summary> /// <param name="view">The view.</param> /// <param name="projection">The projection.</param> public Camera(VIEW view, PROJECTION projection) { View = view; Projection = projection; cachedMatrix = new DirtyFlag <Matrix4x4>(CalcCombinedTransform); View.PropertyChanged += (s, e) => OnPropertyChanged(this, nameof(View)); Projection.PropertyChanged += (s, e) => OnPropertyChanged(this, nameof(Projection)); }
private void EndRecording() { if (m_Recorder.EndRecording()) { ResetFrames(); dirtyFlags |= DirtyFlag.Background; } }
/// <summary> /// Initializes a new instance of the <see cref="Orbit"/> class. /// </summary> /// <param name="distance">The distance to the target.</param> /// <param name="azimuth">The azimuth or heading.</param> /// <param name="elevation">The elevation or tilt.</param> public Orbit(float distance = 1f, float azimuth = 0f, float elevation = 0f) { cachedMatrixView = new DirtyFlag<Matrix4x4>(CalcViewMatrix); PropertyChanged += (s, a) => cachedMatrixView.Invalidate(); Azimuth = azimuth; Distance = distance; Elevation = elevation; }
/// <summary> /// Initializes a new instance of the <see cref="Perspective"/> class. /// </summary> /// <param name="fieldOfViewY">The field-of-view in y-direction.</param> /// <param name="aspect">The aspect ratio.</param> /// <param name="nearClip">The near clip plane distance.</param> /// <param name="farClip">The far clip plane distance.</param> public Perspective(float fieldOfViewY = 90f, float nearClip = 0.1f, float farClip = 1f, float aspect = 1f) { cachedMatrix = new DirtyFlag <Matrix4x4>(CalculateProjectionMatrix); PropertyChanged += (s, a) => cachedMatrix.Invalidate(); Aspect = aspect; FarClip = farClip; FieldOfViewY = fieldOfViewY; NearClip = nearClip; }
private void EndRecording() { if (m_Recorder.EndRecording()) { string path; m_Recorder.Save(out path); dirtyFlags |= DirtyFlag.All; } }
/// <summary> /// Moves the object by a specific amount. /// </summary> /// <param name="delta"></param> public virtual void Move(Vector3 delta) { if (delta.LengthSquared() <= float.Epsilon) { return; } Position += delta; _dirty |= DirtyFlag.Translation; }
public GPUList( int capacity = DEFAULT_CAPACITY, ComputeBufferType cbtype = ComputeBufferType.Default) { this.count = 0; this.capacity = 0; this.dirty = DirtyFlag.Data; this.cbtype = cbtype; Resize(capacity); }
/// <summary> /// Creates a <c>RoxObject</c> with name, position, and rotation. /// </summary> /// <param name="name"></param> /// <param name="position"></param> /// <param name="rotation"></param> public RoxObject(string name, Vector3 position, Quaternion rotation) { Name = name; Position = position; Rotation = rotation; _dirty = DirtyFlag.Rotation | DirtyFlag.Translation; UpdateRotation(); UpdateTransform(true); }
public bool Upload() { if (dirty == DirtyFlag.Data) { dirty = DirtyFlag.Clean; buffer.SetData(data); //buffer.SetCounterValue((uint)count); return(true); } return(false); }
private void UpdateCurrentFrame() { if ((dirtyFlags & DirtyFlag.CurrentFrame) == 0) { return; } currentFrameInputField.text = currentFrame.ToString(); dirtyFlags &= ~DirtyFlag.CurrentFrame; }
protected void Update() { if (Recording) { dirtyFlags |= DirtyFlag.Information; } UpdateBackground(); UpdateInfoText(); UpdatePreviewImage(); }
/// <summary> /// Updates the transform for the current object. /// </summary> /// <param name="force"></param> /// <returns></returns> protected virtual bool UpdateTransform(bool force = false) { if (!force && !IsTranslationDirty) { return(false); } LookAt(Position + Forward, Vector3.UnitY); _dirty &= ~DirtyFlag.Translation; return(true); }
/// <summary> /// Sets the dirty flag for a specified listener ID /// </summary> /// <param name="listenerID">Listener I.</param> /// <param name="flag">Flag.</param> void SetDirty(string listenerID, DirtyFlag flag) { if (!priorityDirtyFlagMap.ContainsKey(listenerID)) { priorityDirtyFlagMap.Add(listenerID, flag); } else { DirtyFlag ret = flag | priorityDirtyFlagMap[listenerID]; priorityDirtyFlagMap[listenerID] = ret; } }
public T this[int index] { get { return(data[index]); } set { try { dirty = DirtyFlag.Data; count = (index >= count ? (index + 1) : count); data[index] = value; } catch (System.Exception e) { Debug.LogWarning($"Exception at index={index} count={count} capacity={capacity} data.Length={data.Length}\n{e}"); } } }
public FilterParam() { Dirty = new DirtyFlag(); Hue = new DirtyValue(Dirty, HueRange, HueRange.Min); Saturation = new DirtyValue(Dirty, SaturRange, SaturRange.Max * 0.5f); Lightness = new DirtyValue(Dirty, LightRange, LightRange.Max * 0.5f); InputMin = new DirtyValue(Dirty, InpMinRange, InpMinRange.Min); InputMax = new DirtyValue(Dirty, InpMaxRange, InpMaxRange.Max); InputMid = new DirtyValue(Dirty, InpMidRange, InpMidRange.Max * 0.5f); OutputMin = new DirtyValue(Dirty, OutMinRange, OutMinRange.Min); OutputMax = new DirtyValue(Dirty, OutMaxRange, OutMaxRange.Max); }
public FilterParam(FilterParam filter) { Dirty = new DirtyFlag(); Hue = new DirtyValue(Dirty, HueRange, filter.Hue.Value); Saturation = new DirtyValue(Dirty, SaturRange, filter.Saturation.Value); Lightness = new DirtyValue(Dirty, LightRange, filter.Lightness.Value); InputMin = new DirtyValue(Dirty, InpMinRange, filter.InputMin.Value); InputMax = new DirtyValue(Dirty, InpMaxRange, filter.InputMax.Value); InputMid = new DirtyValue(Dirty, InpMidRange, filter.InputMid.Value); OutputMin = new DirtyValue(Dirty, OutMinRange, filter.OutputMin.Value); OutputMax = new DirtyValue(Dirty, OutMaxRange, filter.OutputMax.Value); }
private void CleanupAlSource() { if (this.alSource <= AlSource_NotAvailable) return; lock (this.strLock) { // Do not reuse before-streamed sources, since OpenAL doesn't seem to like that. if (this.isStreamed) { AL.DeleteSource(this.alSource); this.alSource = AL.GenSource(); } // Reuse other OpenAL sources else { AL.SourceStop(this.alSource); AL.Source(this.alSource, ALSourcei.Buffer, 0); AL.SourceRewind(this.alSource); } this.dirtyState = DirtyFlag.All; } }
public DirtyValue(DirtyFlag dirtyFlag, NamedRange range, float val ) { this.range = range; this.dirtyFlag = dirtyFlag; this.val = val; }
public void Clear() { Dirty = new DirtyFlag(); Hue = new DirtyValue(Dirty, "色相", 0f, 0f, 360f); Saturation = new DirtyValue(Dirty, "彩度", 100f, 0f, 200f); Lightness = new DirtyValue(Dirty, "明度", 100f, 0f, 200f); InputMin = new DirtyValue(Dirty, "InpMin", 0f, 0f, 100f); InputMax = new DirtyValue(Dirty, "InpMax", 100f, 0f, 100f); InputMid = new DirtyValue(Dirty, "InpMid", 50f, 0f, 100f); OutputMin = new DirtyValue(Dirty, "OutMin", 0f, 0f, 100f); OutputMax = new DirtyValue(Dirty, "OutMax", 100f, 0f, 100f); }
private void CleanupAlSource() { if (this.alSource <= AlSource_NotAvailable) return; lock (this.strLock) { // Do not reuse before-streamed sources OpenAL doesn't seem to like that. if (this.strStreamed) { AL.DeleteSource(this.alSource); this.alSource = AL.GenSource(); } // Reuse other OpenAL sources else { //int num = 0; AL.SourceStop(this.alSource); AL.Source(this.alSource, ALSourcei.Buffer, 0); /*Al.alGetSourcei(this.alSource, Al.AL_BUFFERS_PROCESSED, out num); if (num > 0) { unsafe { int[] buffers = new int[num]; fixed (int* result = &buffers[0]) { Al.alSourceUnqueueBuffers(this.alSource, num, result); } } }*/ AL.SourceRewind(this.alSource); } this.dirtyState = DirtyFlag.All; } }
/// <summary> /// Updates the SoundInstance /// </summary> public void Update() { lock (this.strLock) { // Check existence of attachTo object if (this.attachedTo != null && this.attachedTo.Disposed) this.attachedTo = null; // Retrieve sound resource values Sound res = this.snd.Res; if (res == null) { DualityApp.Sound.UnregisterPlaying(this.snd, this.is3D); this.Dispose(); return; } float optVolFactor = this.GetTypeVolFactor(); float minDistTemp = res.MinDist; float maxDistTemp = res.MaxDist; float volTemp = optVolFactor * res.VolumeFactor * this.vol * this.curFade * this.pauseFade; float pitchTemp = res.PitchFactor * this.pitch; float priorityTemp = 1000.0f; priorityTemp *= volTemp; // Calculate 3D source values, distance and priority Vector3 posAbs = this.pos; Vector3 velAbs = this.vel; if (this.is3D) { Components.Transform attachTransform = this.attachedTo != null ? this.attachedTo.Transform : null; // Attach to object if (this.attachedTo != null && this.attachedTo != DualityApp.Sound.Listener) { MathF.TransformCoord(ref posAbs.X, ref posAbs.Y, attachTransform.Angle); MathF.TransformCoord(ref velAbs.X, ref velAbs.Y, attachTransform.Angle); posAbs += attachTransform.Pos; velAbs += attachTransform.Vel; } // Distance check Vector3 listenerPos = DualityApp.Sound.ListenerPos; float dist; if (this.attachedTo != DualityApp.Sound.Listener) dist = MathF.Sqrt( (posAbs.X - listenerPos.X) * (posAbs.X - listenerPos.X) + (posAbs.Y - listenerPos.Y) * (posAbs.Y - listenerPos.Y) + (posAbs.Z - listenerPos.Z) * (posAbs.Z - listenerPos.Z) * 0.25f); else dist = MathF.Sqrt( posAbs.X * posAbs.X + posAbs.Y * posAbs.Y + posAbs.Z * posAbs.Z * 0.25f); if (dist > maxDistTemp) { DualityApp.Sound.UnregisterPlaying(this.snd, this.is3D); this.Dispose(); return; } else priorityTemp *= Math.Max(0.0f, 1.0f - (dist - minDistTemp) / (maxDistTemp - minDistTemp)); } // Grab an OpenAL source, if not yet assigned if (this.alSource == AlSource_NotYetAssigned) { if (this.GrabAlSource()) { DualityApp.Sound.RegisterPlaying(this.snd, this.is3D); } else { this.Dispose(); return; } } // Determine source state, if available ALSourceState stateTemp = ALSourceState.Stopped; if (this.alSource > AlSource_NotAvailable) stateTemp = AL.GetSourceState(this.alSource); // If the source is stopped / finished, dispose and return if (stateTemp == ALSourceState.Stopped) { if (!this.snd.Res.IsStreamed || this.strStopReq) { DualityApp.Sound.UnregisterPlaying(this.snd, this.is3D); this.Dispose(); return; } } else if (stateTemp == ALSourceState.Initial && this.strStopReq) { DualityApp.Sound.UnregisterPlaying(this.snd, this.is3D); this.Dispose(); return; } // Fading in and out bool fadeOut = this.fadeTarget <= 0.0f; if (!this.paused) { if (this.fadeTarget != this.curFade) { float fadeTemp = Time.TimeMult * Time.SPFMult / Math.Max(0.05f, this.fadeTimeSec); if (this.fadeTarget > this.curFade) this.curFade += fadeTemp; else this.curFade -= fadeTemp; if (Math.Abs(this.curFade - this.fadeTarget) < fadeTemp * 2.0f) this.curFade = this.fadeTarget; this.dirtyState |= DirtyFlag.Vol; } } // Special paused-fading if (this.paused && this.pauseFade > 0.0f) { this.pauseFade = MathF.Max(0.0f, this.pauseFade - Time.TimeMult * Time.SPFMult * 5.0f); this.dirtyState |= DirtyFlag.Paused | DirtyFlag.Vol; } else if (!this.paused && this.pauseFade < 1.0f) { this.pauseFade = MathF.Min(1.0f, this.pauseFade + Time.TimeMult * Time.SPFMult * 5.0f); this.dirtyState |= DirtyFlag.Paused | DirtyFlag.Vol; } // SlowMotion //if (this.type == SoundType.EffectWorld) //{ // pitchTemp *= (float)Math.Max(0.5d, SteApp.Current.SlowMotion); // volTemp *= 2.0f * (float)Math.Min(0.5d, SteApp.Current.SlowMotion); // // Hack: Pitch always dirty // this.dirtyState |= DirtyFlag.Pitch; //} //else if (this.type == SoundType.Speech) //{ // volTemp *= (float)Math.Sqrt(SteApp.Current.SlowMotion); //} // Hack: Volume always dirty - just to be sure this.dirtyState |= DirtyFlag.Vol; if (this.is3D) { // Hack: Relative always dirty to support switching listeners without establishing a notifier-event this.dirtyState |= DirtyFlag.Relative; if (this.attachedTo != null) this.dirtyState |= DirtyFlag.AttachedTo; if ((this.dirtyState & DirtyFlag.Relative) != DirtyFlag.None) AL.Source(this.alSource, ALSourceb.SourceRelative, this.attachedTo == DualityApp.Sound.Listener); if ((this.dirtyState & DirtyFlag.Pos) != DirtyFlag.None) AL.Source(this.alSource, ALSource3f.Position, posAbs.X, -posAbs.Y, -posAbs.Z * 0.5f); if ((this.dirtyState & DirtyFlag.Vel) != DirtyFlag.None) AL.Source(this.alSource, ALSource3f.Velocity, velAbs.X, -velAbs.Y, -velAbs.Z); } else { if ((this.dirtyState & DirtyFlag.Relative) != DirtyFlag.None) AL.Source(this.alSource, ALSourceb.SourceRelative, true); if ((this.dirtyState & DirtyFlag.Pos) != DirtyFlag.None) AL.Source(this.alSource, ALSource3f.Position, 0.0f, 0.0f, 0.0f); if ((this.dirtyState & DirtyFlag.Vel) != DirtyFlag.None) AL.Source(this.alSource, ALSource3f.Velocity, 0.0f, 0.0f, 0.0f); } if ((this.dirtyState & DirtyFlag.MaxDist) != DirtyFlag.None) AL.Source(this.alSource, ALSourcef.MaxDistance, maxDistTemp); if ((this.dirtyState & DirtyFlag.RefDist) != DirtyFlag.None) AL.Source(this.alSource, ALSourcef.ReferenceDistance, minDistTemp); if ((this.dirtyState & DirtyFlag.Loop) != DirtyFlag.None) AL.Source(this.alSource, ALSourceb.Looping, (this.looped && !res.IsStreamed)); if ((this.dirtyState & DirtyFlag.Vol) != DirtyFlag.None) AL.Source(this.alSource, ALSourcef.Gain, volTemp); if ((this.dirtyState & DirtyFlag.Pitch) != DirtyFlag.None) AL.Source(this.alSource, ALSourcef.Pitch, pitchTemp); if ((this.dirtyState & DirtyFlag.Paused) != DirtyFlag.None) { if (this.paused && this.pauseFade == 0.0f && stateTemp == ALSourceState.Playing) AL.SourcePause(this.alSource); else if ((!this.paused || this.pauseFade > 0.0f) && stateTemp == ALSourceState.Paused) AL.SourcePlay(this.alSource); } this.dirtyState = DirtyFlag.None; // Update play time if (!this.paused) { this.playTime += MathF.Max(0.5f, pitchTemp) * Time.TimeMult * Time.SPFMult; if (this.snd.Res.FadeOutAt > 0.0f && this.playTime >= this.snd.Res.FadeOutAt) this.FadeOut(this.snd.Res.FadeOutTime); } // Finish priority calculation this.curPriority = (int)Math.Round(priorityTemp / Math.Sqrt(DualityApp.Sound.GetNumPlaying(this.snd))); // Initially play the source if (stateTemp == ALSourceState.Initial && !this.paused) { if (res.IsStreamed) { this.strStreamed = true; this.strWorker = new Thread(ThreadStreamFunc); this.strWorker.Start(this); } else { AL.SourceQueueBuffer(this.alSource, res.AlBuffer); AL.SourcePlay(this.alSource); } } // Remove faded out sources if (fadeOut && volTemp <= 0.0f) { this.fadeWaitEnd += Time.TimeMult * Time.MsPFMult; // After fading out entirely, wait 50 ms before actually stopping the source to prevent unpleasant audio tick / glitch noises if (this.fadeWaitEnd > 50.0f) { this.Dispose(); DualityApp.Sound.UnregisterPlaying(this.snd, this.is3D); return; } } else this.fadeWaitEnd = 0.0f; } }
public FilterParam() { Dirty = new DirtyFlag(); Hue = new DirtyValue(Dirty, HueRange, HueRange.Min); Saturation = new DirtyValue(Dirty, SaturRange, SaturRange.Max*0.5f); Lightness = new DirtyValue(Dirty, LightRange, LightRange.Max*0.5f); InputMin = new DirtyValue(Dirty, InpMinRange, InpMinRange.Min); InputMax = new DirtyValue(Dirty, InpMaxRange, InpMaxRange.Max); InputMid = new DirtyValue(Dirty, InpMidRange, InpMidRange.Max*0.5f); OutputMin = new DirtyValue(Dirty, OutMinRange, OutMinRange.Min); OutputMax = new DirtyValue(Dirty, OutMaxRange, OutMaxRange.Max); }