Selaa lähdekoodia

Merge pull request #6109 from TrevorDev/noImpostorCompoundViewer

support debug view for compound impostors
David Catuhe 6 vuotta sitten
vanhempi
commit
86ee6648e8
2 muutettua tiedostoa jossa 16 lisäystä ja 1 poistoa
  1. 1 1
      dist/preview release/what's new.md
  2. 15 0
      src/Debug/physicsViewer.ts

+ 1 - 1
dist/preview release/what's new.md

@@ -57,7 +57,7 @@
   - Added an option `useClonedMeshhMap` in the `Scene` constructor options. When set to true, each `Mesh` will have and will keep up-to-date a map of cloned meshes. This is to avoid browsing all the meshes of the scene to retrieve the ones that have the current mesh as source mesh. Disabled by default
   - Added `blockfreeActiveMeshesAndRenderingGroups` property in the `Scene`, following the same model as `blockMaterialDirtyMechanism`. This is to avoid calling `Scene.freeActiveMeshes` and `Scene.freeRenderingGroups` for each disposed mesh when we dispose several meshes in a row. One have to set `blockfreeActiveMeshesAndRenderingGroups` to `true` just before disposing the meshes, and set it back to `false` just after
   - Prevented code from doing useless and possible time consuming computation when disposing the `ShaderMaterial` of a `LinesMesh`
-  - Make a better use of the `isIdentity` cached value wihtin a `Matrix`
+  - Make a better use of the `isIdentity` cached value within a `Matrix`
   - Make sure we browse all the submeshes only once in `Material.markAsDirty` function
   - Added an `Vector3.UnprojectRayToRef` static function to avoid computing and inverting the projection matrix twice when updating a Ray.
 - Added per mesh culling strategy ([jerome](https://github.com/jbousquie))

+ 15 - 0
src/Debug/physicsViewer.ts

@@ -212,6 +212,11 @@ export class PhysicsViewer {
             return null;
         }
 
+        // Only create child impostor debug meshes when evaluating the parent
+        if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {
+            return null;
+        }
+
         var mesh: Nullable<AbstractMesh> = null;
         const utilityLayerScene = this._utilityLayer.utilityLayerScene;
 
@@ -232,6 +237,16 @@ export class PhysicsViewer {
                     mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
                 }
                 break;
+            case PhysicsImpostor.NoImpostor:
+                if (targetMesh) {
+                    // Handle compound impostors
+                    var childMeshes = targetMesh.getChildMeshes().filter((c) => {return c.physicsImpostor ? 1 : 0; });
+                    childMeshes.forEach((m) => {
+                        var a = this._getDebugBoxMesh(utilityLayerScene);
+                        a.parent = m;
+                    });
+                }
+                break;
         }
         return mesh;
     }