Browse Source

Allow picking to work with GPU bones

David Catuhe 6 years ago
parent
commit
a28bf37f17
2 changed files with 13 additions and 4 deletions
  1. 6 1
      src/Meshes/abstractMesh.ts
  2. 7 3
      src/Meshes/subMesh.ts

+ 6 - 1
src/Meshes/abstractMesh.ts

@@ -1158,7 +1158,7 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
 
 
         if (this.subMeshes) {
         if (this.subMeshes) {
             for (var index = 0; index < this.subMeshes.length; index++) {
             for (var index = 0; index < this.subMeshes.length; index++) {
-                this.subMeshes[index].refreshBoundingInfo();
+                this.subMeshes[index].refreshBoundingInfo(data);
             }
             }
         }
         }
 
 
@@ -1171,6 +1171,7 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
 
 
         if (data && applySkeleton && this.skeleton) {
         if (data && applySkeleton && this.skeleton) {
             data = Tools.Slice(data);
             data = Tools.Slice(data);
+            this._generatePointsArray();
 
 
             var matricesIndicesData = this.getVerticesData(VertexBuffer.MatricesIndicesKind);
             var matricesIndicesData = this.getVerticesData(VertexBuffer.MatricesIndicesKind);
             var matricesWeightsData = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
             var matricesWeightsData = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
@@ -1211,6 +1212,10 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
 
 
                     Vector3.TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
                     Vector3.TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
                     tempVector.toArray(data, index);
                     tempVector.toArray(data, index);
+
+                    if (this._positions) {
+                        this._positions[index / 3].copyFrom(tempVector);
+                    }
                 }
                 }
             }
             }
         }
         }

+ 7 - 3
src/Meshes/subMesh.ts

@@ -1,5 +1,5 @@
 import { Tools } from "../Misc/tools";
 import { Tools } from "../Misc/tools";
-import { Nullable, IndicesArray, DeepImmutable } from "../types";
+import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "../types";
 import { Matrix, Vector3, Plane } from "../Maths/math";
 import { Matrix, Vector3, Plane } from "../Maths/math";
 import { Engine } from "../Engines/engine";
 import { Engine } from "../Engines/engine";
 import { VertexBuffer } from "./buffer";
 import { VertexBuffer } from "./buffer";
@@ -205,15 +205,19 @@ export class SubMesh extends BaseSubMesh implements ICullable {
 
 
     /**
     /**
      * Sets a new updated BoundingInfo object to the submesh
      * Sets a new updated BoundingInfo object to the submesh
+     * @param data defines an optional position array to use to determine the bounding info
      * @returns the SubMesh
      * @returns the SubMesh
      */
      */
-    public refreshBoundingInfo(): SubMesh {
+    public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {
         this._lastColliderWorldVertices = null;
         this._lastColliderWorldVertices = null;
 
 
         if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
         if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
             return this;
             return this;
         }
         }
-        var data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);
+
+        if (!data) {
+            data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);
+        }
 
 
         if (!data) {
         if (!data) {
             this._boundingInfo = this._mesh.getBoundingInfo();
             this._boundingInfo = this._mesh.getBoundingInfo();