📄 renderbin.java
字号:
if (transformMsg) { processTransformChanged(referenceTime); transformMsg = false; } if (lightMessageList.size() > 0) { processLightChanged(); lightMessageList.clear(); } VirtualUniverse.mc.addMirrorObject(this); // clear the array to prevent memory leaks Arrays.fill(messages, 0, nMsg, null); } if (reEvaluateBg) { currentActiveBackground = universe.renderingEnvironmentStructure. getApplicationBackground(vpSchedSphereInVworld, locale, view); } if (visQuery) { GeometryAtom[] bgGeometryAtoms; boolean allEnComp; // computeViewFrustumBox in VisibilityStructure. computeViewFrustumBBox(viewFrustumBBox); // System.err.println("viewFrustumBBox = " + this); ViewPlatform vp = view.getViewPlatform(); if (vp != null) { allEnComp = universe.geometryStructure. getVisibleBHTrees(this, viewFrustumBBox, locale, referenceTime, visGAIsDirty || reactivateView || localeChanged || ((view.viewCache.vcDirtyMask & View.VISIBILITY_POLICY_DIRTY) != 0), view.viewCache.visibilityPolicy); reactivateView = false; // process background geometry atoms if (currentActiveBackground != null && currentActiveBackground.geometryBranch != null) { bgGeometryAtoms = currentActiveBackground.getBackgroundGeometryAtoms(); if (bgGeometryAtoms != null) { processBgGeometryAtoms(bgGeometryAtoms, referenceTime); } } if(!allEnComp) { // Increment the framecount for compaction ... frameCount++; if (frameCount > frameCountCutoff) { frameCount = 0; checkForCompaction(); } else if (frameCount == notVisibleCount) { removeCutoffTime = referenceTime; } } } // Reset dirty bits. visGAIsDirty = false; visQuery = false; } // Two environments are dirty // If lights, fog or model clip have been added/removed, then // reEvaluate RenderAtoms and mark the lightbin and // env set dirty if applicable if (envDirty == REEVALUATE_ALL_ENV || envDirty == 3 || envDirty > 4) { reEvaluateEnv(changedLts, changedFogs, changedModelClips, true, altAppearanceDirty); } else if (envDirty == 0 && altAppearanceDirty) { reEvaluateAlternateAppearance(); } else { if ((envDirty & REEVALUATE_LIGHTS) != 0) { reEvaluateLights(altAppearanceDirty); } else if ((envDirty & REEVALUATE_FOG) != 0) reEvaluateFog(changedFogs, (changedFogs.size() > 0), altAppearanceDirty); else if ((envDirty & REEVALUATE_MCLIP) != 0) reEvaluateModelClip(changedModelClips, (changedModelClips.size() > 0), altAppearanceDirty); } // do any pre-update node component screening if (updateCheckList.size() > 0) { int size = updateCheckList.size(); NodeComponentUpdate bin; for (int k = 0; k < size; k++) { bin = (NodeComponentUpdate) updateCheckList.get(k); bin.updateNodeComponentCheck(); } updateCheckList.clear(); } changedLts.clear(); changedFogs.clear(); changedModelClips.clear(); envDirty = 0; altAppearanceDirty = false; view.renderBinReady = true; VirtualUniverse.mc.sendRunMessage(view, J3dThread.RENDER_THREAD); } void processSwitchChanged(J3dMessage m, long refTime) { int i; UnorderList arrList; int size; Object[] nodes, nodesArr; LeafRetained leaf; RenderingEnvironmentStructure rdrEnvStr = universe.renderingEnvironmentStructure; UpdateTargets targets = (UpdateTargets)m.args[0]; arrList = targets.targetList[Targets.ENV_TARGETS]; if (arrList != null) { size = arrList.size(); nodesArr = arrList.toArray(false); for (int h=0; h<size; h++) { nodes = (Object[])nodesArr[h]; for (i=0; i<nodes.length; i++) { if (nodes[i] instanceof LightRetained && rdrEnvStr.isLightScopedToThisView(nodes[i], view)) { envDirty |= REEVALUATE_LIGHTS; } else if (nodes[i] instanceof FogRetained && rdrEnvStr.isFogScopedToThisView(nodes[i], view)) { envDirty |= REEVALUATE_FOG; } else if (nodes[i] instanceof ModelClipRetained && rdrEnvStr.isMclipScopedToThisView(nodes[i], view)) { envDirty |= REEVALUATE_MCLIP; } else if (nodes[i] instanceof BackgroundRetained && rdrEnvStr.isBgScopedToThisView(nodes[i], view)) { reEvaluateBg = true; } else if (nodes[i] instanceof ClipRetained && rdrEnvStr.isClipScopedToThisView(nodes[i], view)) { reEvaluateClip = true; } else if (nodes[i] instanceof AlternateAppearanceRetained && rdrEnvStr.isAltAppScopedToThisView(nodes[i], view)) { altAppearanceDirty = true; } } } } arrList = targets.targetList[Targets.BLN_TARGETS]; if (arrList != null) { size = arrList.size(); nodesArr = arrList.toArray(false); Object[] objArr = (Object[])m.args[1]; Object[] obj, users; BoundingLeafRetained mbleaf; for (int h=0; h<size; h++) { nodes = (Object[])nodesArr[h]; obj = (Object[])objArr[h]; for (i=0; i<nodes.length; i++) { users = (Object[])obj[i]; mbleaf = (BoundingLeafRetained)nodes[i]; for (int j = 0; j < users.length; j++) { if (users[j] instanceof FogRetained && rdrEnvStr.isFogScopedToThisView(users[j], view)) { envDirty |= REEVALUATE_FOG; } else if (users[j] instanceof LightRetained && rdrEnvStr.isLightScopedToThisView(users[j], view)) { envDirty |= REEVALUATE_LIGHTS; } else if (users[j] instanceof ModelClipRetained && rdrEnvStr.isMclipScopedToThisView(users[j], view)) { envDirty |= REEVALUATE_MCLIP; } else if (users[j] instanceof AlternateAppearanceRetained && rdrEnvStr.isAltAppScopedToThisView(users[j], view)) { altAppearanceDirty = true; } else if (users[j] instanceof BackgroundRetained && rdrEnvStr.isBgScopedToThisView(users[j], view)) { reEvaluateBg = true; } else if (users[j] instanceof ClipRetained && rdrEnvStr.isClipScopedToThisView(users[j], view)) { reEvaluateClip = true; } } } } } } /** * Transparency/Line/point/Poly attributes is different from other renderMolecule * attributes since the renderatom could move from opaque bin * to transparent bin */ void processPossibleBinChanged(Object[] args) { int i; GeometryAtom[] gaArr = (GeometryAtom[])args[3]; for (i = 0; i < gaArr.length; i++) { RenderAtom ra = gaArr[i].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) continue; // If renderAtom is in orderedGroup or with this // change continues to be in the same higher level // lightBin(transparent or opaque) then reInsert at // the textureBin level, other Insert at the lightBin // level TextureBin tb = ra.renderMolecule.textureBin; ra.renderMolecule.removeRenderAtom(ra); reInsertRenderAtom(tb, ra); } } /** * This processes a materiala and other rendermolecule node comp change. */ void processRenderMoleculeNodeComponentChanged(Object[] args, int mask, int start, boolean restructure) { int i; NodeComponentRetained nc = (NodeComponentRetained) args[0]; GeometryAtom[] gaArr = (GeometryAtom[])args[3]; for (i = start; i < gaArr.length; i++) { RenderAtom ra = gaArr[i].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) continue; // Check if the changed renderAtom is already in // a separate bin - this is to handle the case // when it has been changed to frequent, then to // infrequent and then to frequent again! // If the bin is in soleUser case and one of the components // has been changed to frequent then remove the clone // and point to the mirror // System.err.println("restructure = "+restructure+" ra.renderMolecule.soleUser ="+ra.renderMolecule.soleUser); if (restructure && !ra.renderMolecule.soleUser) { TextureBin tb = ra.renderMolecule.textureBin; ra.renderMolecule.removeRenderAtom(ra); reInsertRenderAtom(tb, ra); /* if (nc.mirror.changedFrequent != 0) { if ((ra.renderMolecule.soleUserCompDirty& RenderMolecule.ALL_DIRTY_BITS) == 0 ) { rmUpdateList.add(ra.renderMolecule); } ra.renderMolecule.soleUserCompDirty |= mask; } */ } else { if ((ra.renderMolecule.soleUserCompDirty& RenderMolecule.ALL_DIRTY_BITS) == 0 ) { rmUpdateList.add(ra.renderMolecule); } ra.renderMolecule.soleUserCompDirty |= mask; } } } void processTextureAttributesChanged(NodeComponentRetained nc, GeometryAtom[] gaArr) { RenderAtom ra = null; TextureBin tb; ShaderBin sb; boolean reInsertNeeded = false; if (nc.mirror.changedFrequent == 0) { reInsertNeeded = true; } for (int k = 0; k < gaArr.length; k++) { ra = gaArr[k].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) { continue; } tb = ra.renderMolecule.textureBin; if (!reInsertNeeded) { // if changedFrequent is not zero, then need // to check if the node component is currently // in an equivalent bin or not. If it is in an // equivalent bin, then the affected ra needs to // be reinserted to a bin with a soleUser // TextureAttributes for (int t = 0; t < tb.texUnitState.length; t++) { if (tb.texUnitState[t] == null) { continue; } else if (tb.texUnitState[t].texAttrs == nc.mirror) { // the TextureAttributes is already in // a sole user position, no need to do anything; // can bail out now return; } } } if ((tb.tbFlag & TextureBin.SOLE_USER) != 0) { // if the TextureBin is a sole user, then // no need to reInsert, just simply update the // TextureAttributes references @update if (tb.soleUserCompDirty == 0) { tbUpdateList.add(tb); } tb.soleUserCompDirty |= TextureBin.SOLE_USER_DIRTY_TA; } else { sb= ra.renderMolecule.textureBin.shaderBin; ra.renderMolecule.removeRenderAtom(ra); reInsertTextureBin(sb, ra); } } } void processTexCoordGenerationChanged(NodeComponentRetained nc, GeometryAtom[] gaArr) { RenderAtom ra = null; TextureBin tb; ShaderBin sb; boolean reInsertNeeded = false; if (nc.mirror.changedFrequent == 0) { reInsertNeeded = true; } for (int k = 0; k < gaArr.length; k++) { ra = gaArr[k].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) { continue; } tb = ra.renderMolecule.textureBin; if (!reInsertNeeded) { // if changedFrequent is not zero, then need // to check if the node component is currently // in an equivalent bin or not. If it is in an // equivalent bin, then the affected ra needs to // be reinserted to a bin with a soleUser // TexCoordGeneration for (int t = 0; t < tb.texUnitState.length; t++) { if (tb.texUnitState[t] == null) { continue; } else if (tb.texUnitState[t].texGen == nc.mirror) { // the TexCoordGeneration is already in // a sole user position, no need to do anything; // can bail out now return; } } } if ((tb.tbFlag & TextureBin.SOLE_USER) != 0) { // if the TextureBin is a sole user, then // no need to reInsert, just simply update the // TexCoordGeneration references @update if (tb.soleUserCompDirty == 0) { tbUpdateList.add(tb); } tb.soleUserCompDirty |= TextureBin.SOLE_USER_DIRTY_TC; } else { sb= ra.renderMolecule.textureBin.shaderBin; ra.renderMolecule.removeRenderAtom(ra); reInsertTextureBin(sb, ra); } } } void processTextureChanged(NodeComponentRetained nc, GeometryAtom[] gaArr, Object args[]) { RenderAtom ra = null; TextureBin tb; ShaderBin sb; boolean reInsertNeeded = false; int command = ((Integer)args[1]).intValue(); switch (command) { case TextureRetained.ENABLE_CHANGED: { for (int i = 0; i < gaArr.length; i++) { ra = gaArr[i].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) continue; tb = ra.renderMolecule.textureBin; if (tb.soleUserCompDirty == 0) { // put this texture unit state on the sole user // update list if it's not already there tbUpdateList.add(tb); } tb.soleUserCompDirty |= TextureBin.SOLE_USER_DIRTY_TEXTURE; } break; } case TextureRetained.IMAGE_CHANGED: { TextureRetained texture = (TextureRetained)nc.mirror; Object imgChangedArgs[] = (Object[])args[2]; int level = ((Integer)imgChangedArgs[0]).intValue(); int face = ((Integer)imgChangedArgs[2]).intValue(); ImageComponent newImage = (ImageComponent)imgChangedArgs[1]; ImageComponentRetained old
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -