Beispiel #1
0
        public void updateQuadInRenderList(QuickGUIQuad q)
        {
            // minor optimization, where only the quad's dimensions have changed.
            if (!q.zOrderChanged() && !q.textureChanged())
            {
                foreach (QuickGUIQuad iq in mRenderList)
                {
                    if (iq.getID() == q.getID())
                    {
                        // update all vertices
                        for (int vertIndex = 0; vertIndex < QuickGUIQuad.VERTEX_PER_QUAD; ++vertIndex)
                        {
                            iq.setVertex(vertIndex, q.getVertex(vertIndex));
                        }
                        q._notifyChangesHandled();
                        break;
                    }
                }
            }
            // otherwise its easier/more efficient to remove the quad and re-add it into the list.
            else
            {
                removeQuadFromRenderList(q);
                addQuadToRenderList(q);
            }

            mRenderListDirty = true;
        }
Beispiel #2
0
        /*
         * Quads are kept sorted by zOrder, and within zOrder, by Texture.  In this way, we will
         * minimized batches.
         */
        public void addQuadToRenderList(QuickGUIQuad q)
        {
            bool added = false;

            for (int it = 0; it < mRenderList.Count; it++)
            {
                QuickGUIQuad iq = mRenderList[it];
                // quad is already in the list! update quad instead
                if (iq.getID() == q.getID())
                {
                    updateQuadInRenderList(q);
                    added = true;
                    break;
                }

                // zOrders are the same, now we want to group by texture
                if (iq.getZOrder() == q.getZOrder())
                {
                    // iterate until texture name found, or end of zOrder grouping
                    while (!iq.getTextureName().Equals(iq.getTextureName()) && (iq.getZOrder() == q.getZOrder()) && (it < mRenderList.Count))
                    {
                        ++it;
                    }

                    // it is pointing to the end of the list, a quad with the same texture name, or a quad of another zOrder
                    mRenderList.Insert(it, q);
                    q._notifyChangesHandled();
                    added = true;
                }
            }

            if (!added)
            {
                mRenderList.Remove(q);
            }

            mRenderListDirty = true;
        }