/// <summary> /// Merge this state with another one. /// </summary> /// <param name="state"> /// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state. /// </param> public override void Merge(IGraphicsState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } try { TransformState otherState = (TransformState)state; if (otherState.Projection.HasValue) { Projection = otherState.Projection.Value; } ModelView = ModelView * otherState.ModelView; if (_ModelViewProjection.HasValue && !otherState.Projection.HasValue) { _ModelViewProjection = _ModelViewProjection.Value * otherState.ModelView; } else { _ModelViewProjection = otherState.ModelViewProjection.Value; } Debug.Assert(_ModelViewProjection.HasValue); Debug.Assert(_ModelViewProjection.Value.Equals((Matrix4x4f)(Projection * ModelView), 1e-3f)); } catch (InvalidCastException) { throw new ArgumentException("not a TransformState", nameof(state)); } }
/// <summary> /// Performs a deep copy of this <see cref="IGraphicsState"/>. /// </summary> /// <returns> /// It returns the equivalent of this <see cref="IGraphicsState"/>, but all objects referenced /// are not referred by both instances. /// </returns> public override IGraphicsState Push() { TransformState copiedState = (TransformState)base.Push(); if (_LocalProjection != null) { copiedState._LocalProjection = (ProjectionMatrix)_LocalProjection.Clone(); } copiedState._LocalModel = new ModelMatrix(_LocalModel); return(copiedState); }
/// <summary> /// Merge this state with another one. /// </summary> /// <param name="state"> /// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state. /// </param> public override void Merge(IGraphicsState state) { if (state == null) { throw new ArgumentNullException("state"); } TransformState otherState = state as TransformState; if (otherState == null) { throw new ArgumentException("not a TransformState", "state"); } }