Esempio n. 1
0
  protected override void OnRedo() {
    AudioManager.m_Instance.PlayRedoSound(CommandAudioPosition);
    switch (m_Stroke.m_Type) {
    case Stroke.Type.BrushStroke: {
      GameObject gameObj = m_Stroke.m_Object;
      if (gameObj) {
        BaseBrushScript rBrushScript = gameObj.GetComponent<BaseBrushScript>();
        if (rBrushScript) {
          rBrushScript.HideBrush(false);
        }
      }
      break;
    }
    case Stroke.Type.BatchedBrushStroke: {
      var batch = m_Stroke.m_BatchSubset.m_ParentBatch;
      batch.EnableSubset(m_Stroke.m_BatchSubset);
      break;
    }
    case Stroke.Type.NotCreated:
      Debug.LogError("Unexpected: redo NotCreated stroke");
      m_Stroke.Recreate();
      break;
    }

    if (m_Widget != null) {
      m_Widget.AdjustLift(m_LineLength_CS);
    }

    TiltMeterScript.m_Instance.AdjustMeter(m_Stroke, up: true);
  }
Esempio n. 2
0
        /// Non-playback case:
        /// - Update the stroke based on the object's position.
        /// - Save off control points
        /// - Play audio.
        public void UpdateLineFromObject()
        {
            var xf_LS = GetTransformForLine(m_CurrentLine.transform, Coords.AsRoom[transform]);

            if (!PointerManager.m_Instance.IsMainPointerProcessingLine() && m_CurrentCreator != null)
            {
                var straightEdgeGuide = PointerManager.m_Instance.StraightEdgeGuide;

                if (straightEdgeGuide.SnapEnabled)
                {
                    // Snapping should be applied before symmetry, and lift is applied
                    // after symmetry, so redo both.

                    TrTransform xfMain_RS = Coords.AsRoom[PointerManager.m_Instance.MainPointer.transform];
                    xfMain_RS.translation = Coords.CanvasPose * straightEdgeGuide.GetTargetPos();
                    TrTransform xfSymmetry_RS = PointerManager.m_Instance.GetSymmetryTransformFor(
                        this, xfMain_RS);
                    xf_LS = GetTransformForLine(m_CurrentLine.transform, xfSymmetry_RS);
                }

                m_ControlPoints.Clear();
                m_ControlPoints.AddRange(m_CurrentCreator.GetPoints(xf_LS));
                float scale = xf_LS.scale;
                m_CurrentLine.ResetBrushForPreview(
                    TrTransform.TRS(m_ControlPoints[0].m_Pos, m_ControlPoints[0].m_Orient, scale));
                for (int i = 0; i < m_ControlPoints.Count; ++i)
                {
                    if (m_CurrentLine.IsOutOfVerts())
                    {
                        m_ControlPoints.RemoveRange(i, m_ControlPoints.Count - i);
                        break;
                    }
                    m_CurrentLine.UpdatePosition_LS(
                        TrTransform.TRS(m_ControlPoints[i].m_Pos, m_ControlPoints[i].m_Orient, scale),
                        m_ControlPoints[i].m_Pressure);
                }
                UpdateLineVisuals();
                return;
            }

            bool bQuadCreated = m_CurrentLine.UpdatePosition_LS(xf_LS, m_CurrentPressure);

            // TODO: let brush take care of storing control points, not us
            SetControlPoint(xf_LS, isKeeper: bQuadCreated);

            // TODO: Pointers should hold a reference to the stencil they're painting on.  This
            // is a hacky temporary check to ensure mirrored pointers don't add to the lift of
            // the active stencil.
            if (PointerManager.m_Instance.MainPointer == this)
            {
                // Increase stencil lift if we're painting on one.
                StencilWidget stencil = WidgetManager.m_Instance.ActiveStencil;
                if (stencil != null && m_CurrentCreator == null)
                {
                    float fPointerMovement_CS = GetMovementDelta() / Coords.CanvasPose.scale;
                    stencil.AdjustLift(fPointerMovement_CS);
                    m_LineLength_CS += fPointerMovement_CS;
                }
            }

            UpdateLineVisuals();

            /* Update desired brush audio
             * if (m_AudioSources.Length > 0) {
             * float fMovementSpeed = Vector3.Distance(m_PreviousPosition, transform.position) /
             *  Time.deltaTime;
             *
             * float fVelRangeRange = m_BrushAudioVolumeVelocityRange.y - m_BrushAudioVolumeVelocityRange.x;
             * float fVolumeRatio = Mathf.Clamp01((fMovementSpeed - m_BrushAudioVolumeVelocityRange.x) / fVelRangeRange);
             * m_AudioVolumeDesired = fVolumeRatio;
             *
             * float fPitchRangeRange = m_BrushAudioPitchVelocityRange.y - m_BrushAudioPitchVelocityRange.x;
             * float fPitchRatio = Mathf.Clamp01((fMovementSpeed - m_BrushAudioPitchVelocityRange.x) / fPitchRangeRange);
             * m_AudioPitchDesired = m_BrushAudioBasePitch + (fPitchRatio * m_BrushAudioMaxPitchShift);
             * } */
        }