Example #1
0
        private void Update()
        {
            if (_didBrushingBegin)
            {
                _shouldUpdateBrush = true;
                _maybeLastPose     = Maybe.None;

                strokeGenerator.Open();

                _didBrushingBegin = false;
            }

            if (_shouldUpdateBrush)
            {
                var targetPose = pose;

                var effPosition = targetPose.position;
                //var effRotation = targetPose.rotation;

                if (_maybeLastPose.hasValue)
                {
                    if (Vector3.Distance(_maybeLastPose.valueOrDefault.position,
                                         effPosition) > MIN_BRUSH_DISTANCE)
                    {
                        strokeGenerator.Receive(new StrokePoint()
                        {
                            pose          = pose,
                            color         = color,
                            radius        = size,
                            temp_refFrame = Matrix4x4.identity
                        });
                        _maybeLastPose = pose;
                    }
                }
                else
                {
                    strokeGenerator.Receive(new StrokePoint()
                    {
                        pose          = pose,
                        color         = color,
                        radius        = size,
                        temp_refFrame = Matrix4x4.identity
                    });
                    _maybeLastPose = pose;
                }
            }

            if (_didBrushingEnd)
            {
                _shouldUpdateBrush = false;
                _maybeLastPose     = Maybe.None;

                strokeGenerator.Close();

                _didBrushingEnd = false;
            }
        }
Example #2
0
        /// <summary>
        /// Invokes the receiver.
        /// </summary>
        /// <param name="receiver">Receiver.</param>
        /// <param name="grid">Grid.</param>
        /// <param name="cache">Cache.</param>
        /// <param name="stream">Stream.</param>
        /// <param name="keepBinary">Binary flag.</param>
        public static void InvokeReceiver <TK, TV>(IStreamReceiver <TK, TV> receiver, Ignite grid,
                                                   IPlatformTargetInternal cache, IBinaryStream stream, bool keepBinary)
        {
            var reader = grid.Marshaller.StartUnmarshal(stream, keepBinary);

            var size = reader.ReadInt();

            var entries = new List <ICacheEntry <TK, TV> >(size);

            for (var i = 0; i < size; i++)
            {
                entries.Add(new CacheEntry <TK, TV>(reader.ReadObject <TK>(), reader.ReadObject <TV>()));
            }

            receiver.Receive(Ignite.GetCache <TK, TV>(cache, keepBinary), entries);
        }
Example #3
0
        /// <summary>
        /// Invokes the receiver.
        /// </summary>
        /// <param name="receiver">Receiver.</param>
        /// <param name="grid">Grid.</param>
        /// <param name="cache">Cache.</param>
        /// <param name="stream">Stream.</param>
        /// <param name="keepPortable">Portable flag.</param>
        public static void InvokeReceiver <TK, TV>(IStreamReceiver <TK, TV> receiver, Ignite grid, IUnmanagedTarget cache,
                                                   IPortableStream stream, bool keepPortable)
        {
            var reader = grid.Marshaller.StartUnmarshal(stream, keepPortable);

            var size = reader.ReadInt();

            var entries = new List <ICacheEntry <TK, TV> >(size);

            for (var i = 0; i < size; i++)
            {
                entries.Add(new CacheEntry <TK, TV>(reader.ReadObject <TK>(), reader.ReadObject <TV>()));
            }

            receiver.Receive(grid.Cache <TK, TV>(cache, keepPortable), entries);
        }