Пример #1
0
        public static int PickupObject(Ray ray)
        {
            int[] ids = SpriteManager.GetLayersID();

            foreach (int id in ids)
            {
                SpriteLayer layer = SpriteManager.GetLayer(id);

                for (int i = 0, e = layer.size; i < e; i++)
                {
                    SpritePrimitiveGroup group = layer[i];

                    for (int idx = 0; idx < group.count.value; idx++)
                    {
                        SpritePrimitive pri = group.primitives[idx];
                        if (pri.visible)
                        {
                            bool ret = IntersectTriangle(ray.origin, ray.direction, pri.position[0], pri.position[1], pri.position[2], 0, 0, 0) ||
                                       IntersectTriangle(ray.origin, ray.direction, pri.position[0], pri.position[2], pri.position[3], 0, 0, 0);

                            if (ret)
                            {
                                return(pri.ownerID);
                            }
                        }
                    }
                }
            }

            return(0);
        }
Пример #2
0
        void ResetManager()
        {
            for (int i = 0; i < 32; i++)
            {
                layerIDs[i] = i;

                layers[i] = new SpriteLayer();
                layers[i].Reset(512);
                layers[i].SetId(i);
            }
        }
Пример #3
0
        public static void EnumSpriteInSpriteManager(
            SpriteLayerDelegate beginLayer, SpriteLayerDelegate endLayer,
            PrimitiveGroupDelegate beginGroup, PrimitiveGroupDelegate endGroup,
            PrimitiveDelegate primitive)
        {
            int[] ids = SpriteManager.GetLayersID();

            foreach (int id in ids)
            {
                SpriteLayer layer = SpriteManager.GetLayer(id);

                if (beginLayer != null)
                {
                    beginLayer(id, layer.size);
                }


                for (int i = 0, e = layer.size; i < e; i++)
                {
                    SpritePrimitiveGroup group = layer[i];

                    if (beginGroup != null)
                    {
                        beginGroup(group, i, group.owner);
                    }


                    if (primitive != null)
                    {
                        primitive(group.primitives, group.count.value, group);
                    }


                    if (endGroup != null)
                    {
                        endGroup(group, i, group.owner);
                    }
                }

                if (endLayer != null)
                {
                    endLayer(id, layer.size);
                }
            }
        }
        void ResetManager()
        {
            for (int i = 0; i < 32; i++)
            {
                layerIDs[i] = i;

                layers[i] = new SpriteLayer();
                layers[i].Reset(512);
                layers[i].SetId(i);
            }
        }
Пример #5
0
        void _RemovePrimitiveGroupFromLayer(int id, SpritePrimitiveGroup primitive)
        {
            SpriteLayer layer = _GetLayer(id);

            layer.Remove(primitive);
        }
Пример #6
0
        void _AddPrimitiveGroupToLayer(int id, SpritePrimitiveGroup group)
        {
            SpriteLayer layer = _GetLayer(id);

            layer.Add(group);
        }
        virtual protected int getPrimitive(int priCount, bool isClipping, Vector3 cameraPos, float radius)
        {
            int[] layerid = SpriteManager.GetLayersID();


            if (_primitives == null)
            {
                Init(maxPrimitiveCount);
            }

            int queueMaxLength = _primitives.Length;


            for (int layerIdx = 0, e = layerid.Length; layerIdx < e; layerIdx++)
            {
                int id = layerid[layerIdx];
                int t  = cullingMask.value & (1 << id);

                if (t != 0)
                {
                    SpriteLayer layer = SpriteManager.GetLayer(id);

                    int l = layer.size;
                    if (l == 0)
                    {
                        continue;
                    }

                    if (isClipping)
                    {
                        int ls = layer.size;
                        for (int ri = 0; ri < l; ri++)
                        {
                            layer[ri].renderable.DoClipping(cameraPos, radius);
                        }
                    }

                    for (int gourpIdx = 0; gourpIdx < l; gourpIdx++)
                    {
                        SpritePrimitiveGroup group = layer.baseContainer[gourpIdx];

                        if (!group.visible)
                        {
                            continue;
                        }

                        for (int pi = 0; pi < group.count.value; pi++)
                        {
                            SpritePrimitive pri = group.primitives[pi];
                            if (pri.visible == false || pri.texId == 0)
                            {
                                continue;
                            }

                            _primitives[priCount] = pri;
                            priCount++;

                            if (priCount >= queueMaxLength)
                            {
                                Debug.Log("Commited SpritePrimitive's count is more than " + queueMaxLength + "!.\n" +
                                          "if in editor, you should disable some layer.\n" +
                                          "if in runtime, you should enable Camera2D clipping..\n");

                                return(priCount);
                            }
                        }
                    }
                }
            }

            return(priCount);
        }
Пример #8
0
        SetIndexer <SpritePrimitiveGroup> _AddPrimitiveGroupToLayer(int id, SetIndexer <SpritePrimitiveGroup> group)
        {
            SpriteLayer layer = _GetLayer(id);

            return(layer.Add(group));
        }