Преглед изворни кода

Handle case where a LOD is null

Popov72 пре 4 година
родитељ
комит
a92c9ff907
3 измењених фајлова са 14 додато и 10 уклоњено
  1. 10 9
      src/Materials/Textures/renderTargetTexture.ts
  2. 1 0
      src/Meshes/abstractMesh.ts
  3. 3 1
      src/scene.ts

+ 10 - 9
src/Materials/Textures/renderTargetTexture.ts

@@ -753,6 +753,16 @@ export class RenderTargetTexture extends Texture {
                     continue;
                 }
 
+                if (!mesh._internalAbstractMeshDataInfo._currentLODIsUpToDate && scene.activeCamera) {
+                    mesh._internalAbstractMeshDataInfo._currentLOD = scene.customLODSelector ? scene.customLODSelector(mesh, scene.activeCamera) : mesh.getLOD(scene.activeCamera);
+                    mesh._internalAbstractMeshDataInfo._currentLODIsUpToDate = true;
+                }
+                if (!mesh._internalAbstractMeshDataInfo._currentLOD) {
+                    continue;
+                }
+
+                let meshToRender = mesh._internalAbstractMeshDataInfo._currentLOD;
+
                 mesh._preActivateForIntermediateRendering(sceneRenderId);
 
                 let isMasked;
@@ -762,15 +772,6 @@ export class RenderTargetTexture extends Texture {
                     isMasked = false;
                 }
 
-                if (!mesh._internalAbstractMeshDataInfo._currentLOD && scene.activeCamera) {
-                    mesh._internalAbstractMeshDataInfo._currentLOD = scene.customLODSelector ? scene.customLODSelector(mesh, scene.activeCamera) : mesh.getLOD(scene.activeCamera);
-                }
-                if (!mesh._internalAbstractMeshDataInfo._currentLOD) {
-                    mesh._internalAbstractMeshDataInfo._currentLOD = mesh;
-                }
-
-                let meshToRender = mesh._internalAbstractMeshDataInfo._currentLOD;
-
                 if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
                     if (meshToRender !== mesh) {
                         meshToRender._activate(sceneRenderId, true);

+ 1 - 0
src/Meshes/abstractMesh.ts

@@ -88,6 +88,7 @@ class _InternalAbstractMeshDataInfo {
     public _onlyForInstancesIntermediate = false;
     public _actAsRegularMesh = false;
     public _currentLOD: Nullable<AbstractMesh> = null;
+    public _currentLODIsUpToDate: boolean = false;
 }
 
 /**

+ 3 - 1
src/scene.ts

@@ -3548,6 +3548,7 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
         const len = meshes.length;
         for (let i = 0; i < len; i++) {
             const mesh = meshes.data[i];
+            mesh._internalAbstractMeshDataInfo._currentLODIsUpToDate = false;
             if (mesh.isBlocked) {
                 continue;
             }
@@ -3567,10 +3568,11 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
 
             // Switch to current LOD
             let meshToRender = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
+            mesh._internalAbstractMeshDataInfo._currentLOD = meshToRender;
+            mesh._internalAbstractMeshDataInfo._currentLODIsUpToDate = true;
             if (meshToRender === undefined || meshToRender === null) {
                 continue;
             }
-            mesh._internalAbstractMeshDataInfo._currentLOD = meshToRender;
 
             // Compute world matrix if LOD is billboard
             if (meshToRender !== mesh && meshToRender.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {