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; }
/** Returns a pointer to the Listener singleton object */ //static Renderer* getSingletonPtr(); public void removeQuadFromRenderList(QuickGUIQuad q) { QuickGUIQuad qr = null; foreach (QuickGUIQuad iq in mRenderList) { // quad is already in the list! update quad instead if (iq.getID() == q.getID()) { qr = iq; mRenderListDirty = true; break; } } if (qr != null) { mRenderList.Remove(qr); } }
/* * 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; }