Esempio n. 1
0
        private void UpdateBuffer()
        {
            uint packSize = AnnotationVariable.DataType.GetPackSizeScalar();

            if (AnnotationVariable.IsMatrix && Values[0] is SerializableColor)
            {
                for (int i = 0; i < Values.Count; ++i)
                {
                    uint stepOffset = packSize * AnnotationVariable.Rows;
                    stepOffset = stepOffset.RoundUpMultiple16();
                    AnnotationVariable.CopyColorToBuffer((SerializableColor)Values.ElementAt(i), stepOffset, packSize * (uint)i);
                }
            }
            else
            {
                uint startOffset = 0;
                for (int column = 0; column < AnnotationVariable.Columns; ++column)
                {
                    for (int row = 0; row < AnnotationVariable.Rows; ++row)
                    {
                        if (Values[row * column + column] != null)
                        {
                            AnnotationVariable.CopyToBuffer(PropertyHelpers.ConvertToCorrectType(AnnotationVariable.DataType, Values[row * (int)AnnotationVariable.Columns + column]), startOffset);
                        }
                        startOffset += packSize;
                    }
                    startOffset = startOffset.RoundUpMultiple16();
                }
            }
            ITempHelper helper = ((App)Application.Current).ActiveViewport;

            AnnotationVariable.AnnotationGroup.MarshalBuffer(helper.ViewportHost, helper.IsStandardShaderActive);
        }
        public void UpdateBuffer(bool marshalBuffer = true)
        {
            ITempHelper helper = ((App)Application.Current).ActiveViewport;

            if (helper == null || helper.ViewportHost == null)
            {
                return;
            }

            if (IsTexture)
            {
                if (helper.IsStandardShaderActive)
                {
                    helper.ViewportHost.UpdateShaderImage(uint.Parse(Regex.Match(AnnotationGroup.Register, @"\d+").Value), (int)AnnotationGroup.AnnotationShaderGroup.Type, Value?.ToString() ?? "");
                }
                else
                {
                    helper.ViewportHost.UpdatePPShaderImage(uint.Parse(Regex.Match(AnnotationGroup.Register, @"\d+").Value), Value?.ToString() ?? "");
                }
                return;
            }

            if (Value == null)
            {
                return;
            }
            if (IsScalar)
            {
                if (IsScalar)
                {
                    CopyToBuffer(PropertyHelpers.ConvertToCorrectType(DataType, Value));
                }
            }
            else if (IsVector)
            {
                if (Value is SerializableColor)
                {
                    CopyColorToBuffer((SerializableColor)Value, DataType.GetPackSizeScalar());
                }
            }
            if (marshalBuffer)
            {
                AnnotationGroup.MarshalBuffer(helper.ViewportHost, helper.IsStandardShaderActive);
            }
        }