Beispiel #1
0
        /// Bulk control point addition
        public void UpdateLineFromStroke(Stroke stroke)
        {
            RdpStrokeSimplifier simplifier = App.Instance.IsLoading()
        ? QualityControls.m_Instance.StrokeSimplifier
        : QualityControls.m_Instance.UserStrokeSimplifier;

            if (simplifier.Level > 0.0f)
            {
                simplifier.CalculatePointsToDrop(stroke, CurrentBrushScript);
            }
            float scale = m_CurrentLine.StrokeScale;

            foreach (var cp in stroke.m_ControlPoints.Where((x, i) => !stroke.m_ControlPointsToDrop[i]))
            {
                m_CurrentLine.UpdatePosition_LS(TrTransform.TRS(cp.m_Pos, cp.m_Orient, scale), cp.m_Pressure);
            }
        }
Beispiel #2
0
        // Continue drawing stroke for this frame.
        public void Update()
        {
            if (m_isDone)
            {
                return;
            }

            var rPointerScript = m_pointer;
            var rPointerObject = m_pointer.gameObject;

            bool needMeshUpdate    = false;
            bool needPointerUpdate = false;
            bool strokeFinished    = false;
            var  lastCp            = new PointerManager.ControlPoint();

            OverlayManager.m_Instance.UpdateProgress(SketchMemoryScript.m_Instance.GetDrawnPercent());

            RdpStrokeSimplifier simplifier = QualityControls.m_Instance.StrokeSimplifier;

            if (simplifier.Level > 0.0f)
            {
                simplifier.CalculatePointsToDrop(m_stroke, m_pointer.CurrentBrushScript);
            }

            while (true)
            {
                if (m_nextControlPoint >= m_stroke.m_ControlPoints.Length)
                {
                    needMeshUpdate = true; // Is this really necessary?
                    strokeFinished = true;
                    break;
                }
                var cp = m_stroke.m_ControlPoints[m_nextControlPoint];
                if (!IsControlPointReady(cp))
                {
                    break;
                }

                if (!m_stroke.m_ControlPointsToDrop[m_nextControlPoint])
                {
                    rPointerScript.UpdateLineFromControlPoint(cp);
                    needMeshUpdate    = true;
                    lastCp            = cp;
                    needPointerUpdate = true;
                }
                ++m_nextControlPoint;
            }

            if (needMeshUpdate)
            {
                rPointerScript.UpdateLineVisuals();
            }
            if (needPointerUpdate)
            {
                // This is only really done for visual reasons
                var xf_GS = Coords.CanvasPose * TrTransform.TR(lastCp.m_Pos, lastCp.m_Orient);
                xf_GS.scale = rPointerObject.transform.GetUniformScale();
                Coords.AsGlobal[rPointerObject.transform] = xf_GS;
                rPointerScript.SetPressure(lastCp.m_Pressure);
            }

            if (strokeFinished)
            {
                rPointerScript.EndLineFromMemory(m_stroke);
                m_isDone = true;
            }
        }