Browse Source

Fix bbrender for instances

David Catuhe 4 năm trước cách đây
mục cha
commit
0cbe7d8704
3 tập tin đã thay đổi với 14 bổ sung13 xóa
  1. 5 4
      src/Rendering/boundingBoxRenderer.ts
  2. 6 6
      src/scene.ts
  3. 3 3
      src/sceneComponent.ts

+ 5 - 4
src/Rendering/boundingBoxRenderer.ts

@@ -156,7 +156,7 @@ export class BoundingBoxRenderer implements ISceneComponent {
     public register(): void {
         this.scene._beforeEvaluateActiveMeshStage.registerStep(SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
 
-        this.scene._activeMeshStage.registerStep(SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
+        this.scene._preActiveMeshStage.registerStep(SceneComponentConstants.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh);
 
         this.scene._evaluateSubMeshStage.registerStep(SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
 
@@ -173,9 +173,9 @@ export class BoundingBoxRenderer implements ISceneComponent {
         }
     }
 
-    private _activeMesh(sourceMesh: AbstractMesh, mesh: AbstractMesh): void {
-        if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
-            let boundingInfo = sourceMesh.getBoundingInfo();
+    private _preActiveMesh(mesh: AbstractMesh): void {
+        if (mesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
+            let boundingInfo = mesh.getBoundingInfo();
             boundingInfo.boundingBox._tag = mesh.renderingGroupId;
             this.renderList.push(boundingInfo.boundingBox);
         }
@@ -244,6 +244,7 @@ export class BoundingBoxRenderer implements ISceneComponent {
         var engine = this.scene.getEngine();
         engine.setDepthWrite(false);
         this._colorShader._preBind();
+
         for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
             var boundingBox = this.renderList.data[boundingBoxIndex];
             if (boundingBox._tag !== renderingGroupId) {

+ 6 - 6
src/scene.ts

@@ -1301,7 +1301,7 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
      * @hidden
      * Defines the actions happening during the active mesh stage.
      */
-    public _activeMeshStage = Stage.Create<ActiveMeshStageAction>();
+    public _preActiveMeshStage = Stage.Create<PreActiveMeshStageAction>();
     /**
      * @hidden
      * Defines the actions happening during the per camera render target step.
@@ -3572,6 +3572,10 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
                     meshToRender._activate(this._renderId, false);
                 }
 
+                for (let step of this._preActiveMeshStage) {
+                    step.action(mesh);
+                }
+
                 if (mesh._activate(this._renderId, false)) {
                     if (!mesh.isAnInstance) {
                         meshToRender._internalAbstractMeshDataInfo._onlyForInstances = false;
@@ -3622,10 +3626,6 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
             }
         }
 
-        for (let step of this._activeMeshStage) {
-            step.action(sourceMesh, mesh);
-        }
-
         if (
             mesh !== undefined && mesh !== null
             && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0
@@ -4154,7 +4154,7 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
         this._isReadyForMeshStage.clear();
         this._beforeEvaluateActiveMeshStage.clear();
         this._evaluateSubMeshStage.clear();
-        this._activeMeshStage.clear();
+        this._preActiveMeshStage.clear();
         this._cameraDrawRenderTargetStage.clear();
         this._beforeCameraDrawStage.clear();
         this._beforeRenderTargetDrawStage.clear();

+ 3 - 3
src/sceneComponent.ts

@@ -42,7 +42,7 @@ export class SceneComponentConstants {
 
     public static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
 
-    public static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
+    public static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0;
 
     public static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
 
@@ -159,9 +159,9 @@ export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: b
 export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
 
 /**
- * Strong typing of a Active Mesh related stage step action
+ * Strong typing of a pre active Mesh related stage step action
  */
-export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
+export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
 
 /**
  * Strong typing of a Camera related stage step action