📄 texturebin.java
字号:
} } j++; } // make sure to disable the remaining texture units // since they could have been enabled from the previous // texture bin for (int i = j; i <= cv.getLastActiveTexUnit(); i++) { cv.resetTexture(cv.ctx, i); } cv.setLastActiveTexUnit(lastActiveTexUnitIdx); // set the active texture unit back to 0 cv.activeTextureUnit(cv.ctx, 0); } cv.canvasDirty &= ~Canvas3D.TEXTUREBIN_DIRTY; } /** * Renders this TextureBin */ void render(Canvas3D cv) { render(cv, (Object) opaqueRMList); } void render(Canvas3D cv, Object rlist) { cv.texLinearMode = false; /* System.err.println("TextureBin/render " + this + " numActiveTexUnit= " + numActiveTexUnit + " maxTextureUnits= " + cv.maxTextureUnits); */ // include this TextureBin to the to-be-updated state set in canvas cv.setStateToUpdate(Canvas3D.TEXTUREBIN_BIT, this); // For D3D - set the texLinearMode flag in the canvas if texcoord // generation is enabled in object_linear mode for any texture unit. if ((texUnitState != null) && VirtualUniverse.mc.isD3D()) { TextureUnitStateRetained tus; for (int i = 0; i < texUnitState.length; i++) { tus = texUnitState[i]; if ((tus != null) && tus.isTextureEnabled()) { if ((tus.texGen != null) && (tus.texGen.genMode == TexCoordGeneration.OBJECT_LINEAR)) { cv.texLinearMode = true; } } } } renderList(cv, USE_DISPLAYLIST, rlist); } /** * render a render list */ void renderList(Canvas3D cv, int pass, Object rlist) { assert pass < 0; if (rlist instanceof RenderMolecule) { renderList(cv, pass, (RenderMolecule) rlist); } else if (rlist instanceof TransparentRenderingInfo) { renderList(cv, pass, (TransparentRenderingInfo) rlist); } } /** * render list of RenderMolecule */ void renderList(Canvas3D cv, int pass, RenderMolecule rlist) { assert pass < 0; // bit mask of all attr fields that are equivalent across // renderMolecules thro. ORing of invisible RMs. int combinedDirtyBits = 0; boolean rmVisible = true; RenderMolecule rm = rlist; while (rm != null) { if(rmVisible) { combinedDirtyBits = rm.dirtyAttrsAcrossRms; } else { combinedDirtyBits |= rm.dirtyAttrsAcrossRms; } rmVisible = rm.render(cv, pass, combinedDirtyBits); // next render molecule or the nextmap if (rm.next == null) { rm = rm.nextMap; } else { rm = rm.next; } } } /** * render sorted transparent list */ void renderList(Canvas3D cv, int pass, TransparentRenderingInfo tinfo) { assert pass < 0; RenderMolecule rm = tinfo.rm; if (rm.isSwitchOn()) { rm.transparentSortRender(cv, pass, tinfo); } } void changeLists(RenderMolecule r) { RenderMolecule renderMoleculeList, rmlist = null, head; HashMap allMap = null; ArrayList list; int index; boolean newRM = false; // System.err.println("changeLists r = "+r+" tBin = "+this); // If its a new RM then do nothing, otherwise move lists if (r.isOpaqueOrInOG) { if (opaqueRMList == null && (r.prev == null && r.prevMap == null && r.next == null && r.nextMap == null)) { newRM = true; } else { rmlist = opaqueRMList; allMap = opaqueRenderMoleculeMap; } } else { if (transparentRMList == null && (r.prev == null && r.prevMap == null && r.next == null && r.nextMap == null) ){ newRM = true; } else { rmlist = transparentRMList; allMap = transparentRenderMoleculeMap; } } if (!newRM) { head = removeOneRM(r, allMap, rmlist); if (r.isOpaqueOrInOG) { opaqueRMList = head; } else { transparentRMList = head; if (transparentRMList == null && (renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE || environmentSet.lightBin.geometryBackground != null)) { renderBin.removeTransparentObject(this); } // Issue 129: remove the RM's render atoms from the // list of transparent render atoms if ((renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY) && (environmentSet.lightBin.geometryBackground == null)) { r.addRemoveTransparentObject(renderBin, false); } } } HashMap renderMoleculeMap; RenderMolecule startList; // Now insert in the other bin r.evalAlphaUsage(shaderBin.attributeBin.definingRenderingAttributes, texUnitState); r.isOpaqueOrInOG = r.isOpaque() ||r.inOrderedGroup; if (r.isOpaqueOrInOG) { startList = opaqueRMList; renderMoleculeMap = opaqueRenderMoleculeMap; markDlistAsDirty(r); } else { startList = transparentRMList; renderMoleculeMap = transparentRenderMoleculeMap; if ((r.primaryMoleculeType &RenderMolecule.DLIST_MOLECULE) != 0 && renderBin.transpSortMode != View.TRANSPARENCY_SORT_NONE) { renderBin.addDisplayListResourceFreeList(r); renderBin.removeDirtyRenderMolecule(r); r.vwcBounds.set(null); r.displayListId = 0; r.displayListIdObj = null; // Change the group type for all the rlistInfo in the primaryList RenderAtomListInfo rinfo = r.primaryRenderAtomList; while (rinfo != null) { rinfo.groupType = RenderAtom.SEPARATE_DLIST_PER_RINFO; if (rinfo.renderAtom.dlistIds == null) { rinfo.renderAtom.dlistIds = new int[rinfo.renderAtom.rListInfo.length]; for (int k = 0; k < rinfo.renderAtom.dlistIds.length; k++) { rinfo.renderAtom.dlistIds[k] = -1; } } if (rinfo.renderAtom.dlistIds[rinfo.index] == -1) { rinfo.renderAtom.dlistIds[rinfo.index] = VirtualUniverse.mc.getDisplayListId().intValue(); renderBin.addDlistPerRinfo.add(rinfo); } rinfo = rinfo.next; } r.primaryMoleculeType = RenderMolecule.SEPARATE_DLIST_PER_RINFO_MOLECULE; } else { markDlistAsDirty(r); } } renderMoleculeList = (RenderMolecule)renderMoleculeMap.get(r.localToVworld); if (renderMoleculeList == null) { renderMoleculeList = r; renderMoleculeMap.put(r.localToVworld, renderMoleculeList); // Add this renderMolecule at the beginning of RM list if (startList == null) { startList = r; r.nextMap = null; r.prevMap = null; } else { r.nextMap = startList; startList.prevMap = r; startList = r; startList.nextMap.checkEquivalenceWithLeftNeighbor(r,RenderMolecule.ALL_DIRTY_BITS); } // Issue 67 : since we are adding the new RM at the head, we must // set all dirty bits unconditionally startList.dirtyAttrsAcrossRms = RenderMolecule.ALL_DIRTY_BITS; } else { // Insert the renderMolecule next to a RM that has equivalent // texture unit state if ((head = insertRenderMolecule(r, renderMoleculeList)) != null) { if (renderMoleculeList.prevMap != null) { renderMoleculeList.prevMap.nextMap = head; } head.prevMap = renderMoleculeList.prevMap; renderMoleculeList.prevMap = null; renderMoleculeList = head; renderMoleculeMap.put(r.localToVworld, renderMoleculeList); if (renderMoleculeList.prevMap != null) { renderMoleculeList.checkEquivalenceWithLeftNeighbor(renderMoleculeList.prevMap, RenderMolecule.ALL_DIRTY_BITS); } else { startList.dirtyAttrsAcrossRms = RenderMolecule.ALL_DIRTY_BITS; startList = renderMoleculeList; } } } if (r.isOpaqueOrInOG) { opaqueRMList = startList; } else { // If transparent and not in bg geometry and inodepth sorted transparency if (transparentRMList == null&& (renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE || environmentSet.lightBin.geometryBackground != null)) { transparentRMList = startList; renderBin.addTransparentObject(this); } else { transparentRMList = startList; } // Issue 129: add the RM's render atoms to the list of // transparent render atoms // XXXX: do we need to resort the list after the add??? if ((renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY) && (environmentSet.lightBin.geometryBackground == null)) { r.addRemoveTransparentObject(renderBin, true); } } } RenderMolecule removeOneRM(RenderMolecule r, HashMap allMap, RenderMolecule list) { RenderMolecule rmlist = list; // In the middle, just remove and update if (r.prev != null && r.next != null) { r.prev.next = r.next; r.next.prev = r.prev; r.next.checkEquivalenceWithLeftNeighbor(r.prev,RenderMolecule.ALL_DIRTY_BITS); } // If whats is removed is at the end of an entry else if (r.prev != null && r.next == null) { r.prev.next = r.next; r.prev.nextMap = r.nextMap; if (r.nextMap != null) { r.nextMap.prevMap = r.prev; r.nextMap.checkEquivalenceWithLeftNeighbor(r.prev,RenderMolecule.ALL_DIRTY_BITS); } } else if (r.prev == null && r.next != null) { r.next.prev = null; r.next.prevMap = r.prevMap; if (r.prevMap != null) { r.prevMap.nextMap = r.next; r.next.checkEquivalenceWithLeftNeighbor(r.prevMap,RenderMolecule.ALL_DIRTY_BITS); } // Head of the rmList else { rmlist = r.next; rmlist.dirtyAttrsAcrossRms = RenderMolecule.ALL_DIRTY_BITS; } allMap.put(r.localToVworld, r.next); } // Update the maps and remove this entry from the map list else if (r.prev == null && r.next == null) { if (r.prevMap != null) { r.prevMap.nextMap = r.nextMap; } else { rmlist = r.nextMap; if (r.nextMap != null) { rmlist.dirtyAttrsAcrossRms = RenderMolecule.ALL_DIRTY_BITS; } } if (r.nextMap != null) { r.nextMap.prevMap = r.prevMap; if (r.prevMap != null) { r.nextMap.checkEquivalenceWithLeftNeighbor(r.prevMap,RenderMolecule.ALL_DIRTY_BITS); } } allMap.remove(r.localToVworld); } r.prev = null; r.next = null; r.prevMap = null; r.nextMap = null; return rmlist; } void markDlistAsDirty(RenderMolecule r) { if (r.primaryMoleculeType == RenderMolecule.DLIST_MOLECULE) { renderBin.addDirtyRenderMolecule(r); } else if (r.primaryMoleculeType == RenderMolecule.SEPARATE_DLIST_PER_RINFO_MOLECULE) { RenderAtomListInfo ra = r.primaryRenderAtomList; while (ra != null) { renderBin.addDlistPerRinfo.add(ra); ra = ra.next; } } } void decrActiveRenderMolecule() { numEditingRenderMolecules--; if (numEditingRenderMolecules == 0) { // if number of editing renderMolecules goes to 0, // inform the shaderBin that this textureBin goes to // zombie state shaderBin.decrActiveTextureBin(); } } void incrActiveRenderMolecule() { if (numEditingRenderMolecules == 0) { // if this textureBin is in zombie state, inform // the shaderBin that this textureBin is activated again. shaderBin.incrActiveTextureBin(); } numEditingRenderMolecules++; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -