Example #1
0
        public static void BlendOne(Surface dst, Surface src, ref SlotStruct slot)
        {
            if (Sse41.IsSupported && (dst.Width & 3) == 0)
            {
                BlendOneSse41(dst, src, ref slot);
                return;
            }

            for (int y = 0; y < dst.Height; y++)
            {
                for (int x = 0; x < dst.Width; x++)
                {
                    int inR = src.GetR(x, y);
                    int inG = src.GetG(x, y);
                    int inB = src.GetB(x, y);

                    MatrixMultiply(ref slot.ColorMatrixStruct, inR, inG, inB, out int r, out int g, out int b);

                    r = Math.Clamp(r, slot.SlotConfig.SoftClampLow, slot.SlotConfig.SoftClampHigh);
                    g = Math.Clamp(g, slot.SlotConfig.SoftClampLow, slot.SlotConfig.SoftClampHigh);
                    b = Math.Clamp(b, slot.SlotConfig.SoftClampLow, slot.SlotConfig.SoftClampHigh);

                    dst.SetR(x, y, (ushort)r);
                    dst.SetG(x, y, (ushort)g);
                    dst.SetB(x, y, (ushort)b);
                    dst.SetA(x, y, src.GetA(x, y));
                }
            }
        }
Example #2
0
        private void Execute(int data)
        {
            ConfigStruct config = ReadIndirect <ConfigStruct>(_state.State.SetConfigStructOffset);

            using Surface output = new Surface(
                      _rm.SurfacePool,
                      config.OutputSurfaceConfig.OutSurfaceWidth + 1,
                      config.OutputSurfaceConfig.OutSurfaceHeight + 1);

            for (int i = 0; i < config.SlotStruct.Length; i++)
            {
                ref SlotStruct slot = ref config.SlotStruct[i];

                if (!slot.SlotConfig.SlotEnable)
                {
                    continue;
                }

                var offsets = _state.State.SetSurfacexSlotx[i][0];

                if (_hasOverride)
                {
                    offsets = _overrideOffsets;
                }

                using Surface src = SurfaceReader.Read(_rm, ref slot.SlotSurfaceConfig, ref offsets);

                Blender.BlendOne(output, src, ref slot);
            }
Example #3
0
        public static void BlendOne(Surface dst, Surface src, ref SlotStruct slot, Rectangle targetRect)
        {
            int x1 = targetRect.X;
            int y1 = targetRect.Y;
            int x2 = Math.Min(src.Width, x1 + targetRect.Width);
            int y2 = Math.Min(src.Height, y1 + targetRect.Height);

            if (Sse41.IsSupported && ((x1 | x2) & 3) == 0)
            {
                BlendOneSse41(dst, src, ref slot, x1, y1, x2, y2);
                return;
            }

            for (int y = y1; y < y2; y++)
            {
                for (int x = x1; x < x2; x++)
                {
                    int inR = src.GetR(x, y);
                    int inG = src.GetG(x, y);
                    int inB = src.GetB(x, y);

                    MatrixMultiply(ref slot.ColorMatrixStruct, inR, inG, inB, out int r, out int g, out int b);

                    r = Math.Clamp(r, slot.SlotConfig.SoftClampLow, slot.SlotConfig.SoftClampHigh);
                    g = Math.Clamp(g, slot.SlotConfig.SoftClampLow, slot.SlotConfig.SoftClampHigh);
                    b = Math.Clamp(b, slot.SlotConfig.SoftClampLow, slot.SlotConfig.SoftClampHigh);

                    dst.SetR(x, y, (ushort)r);
                    dst.SetG(x, y, (ushort)g);
                    dst.SetB(x, y, (ushort)b);
                    dst.SetA(x, y, src.GetA(x, y));
                }
            }
        }
Example #4
0
        private void Execute(int data)
        {
            ConfigStruct config = ReadIndirect <ConfigStruct>(_state.State.SetConfigStructOffset);

            using Surface output = new Surface(
                      _rm.SurfacePool,
                      config.OutputSurfaceConfig.OutSurfaceWidth + 1,
                      config.OutputSurfaceConfig.OutSurfaceHeight + 1);

            for (int i = 0; i < config.SlotStruct.Length; i++)
            {
                ref SlotStruct slot = ref config.SlotStruct[i];

                if (!slot.SlotConfig.SlotEnable)
                {
                    continue;
                }

                ref var offsets = ref _state.State.SetSurfacexSlotx[i];
    public FormationBehaviour(Trash trash, Robot LeaderRobot)
    {
        MB = UnityEngine.Object.FindObjectsOfType <RobotController>()[0].GetComponent <MonoBehaviour>();

        this.trash = trash;

        SlotList = new SlotStruct[3];

        for (int i = 0; i < SlotList.Length; i++)
        {
            SlotList[i] = new SlotStruct("FormationSlot" + i);
            SlotList[i].target.position = SlotPosition(i);
        }

        LiftTrash();

        AddRobot(LeaderRobot);

        float timeout = 10;

        MB.StartCoroutine(StartTimer(timeout));
    }
Example #6
0
        private unsafe static void BlendOneSse41(Surface dst, Surface src, ref SlotStruct slot)
        {
            Debug.Assert((dst.Width & 3) == 0);

            ref MatrixStruct mtx = ref slot.ColorMatrixStruct;
Example #7
0
        private unsafe static void BlendOneSse41(Surface dst, Surface src, ref SlotStruct slot, int x1, int y1, int x2, int y2)
        {
            Debug.Assert(((x1 | x2) & 3) == 0);

            ref MatrixStruct mtx = ref slot.ColorMatrixStruct;