Browse Source

Documentation

Raanan Weber 10 years ago
parent
commit
c6632695ae
2 changed files with 14 additions and 78 deletions
  1. 7 36
      Babylon/Mesh/babylon.mesh.js
  2. 7 42
      Babylon/Mesh/babylon.mesh.ts

+ 7 - 36
Babylon/Mesh/babylon.mesh.js

@@ -878,7 +878,7 @@ var BABYLON;
          * @param settings a collection of simplification settings.
          * @param parallelProcessing should all levels calculate parallel or one after the other.
          * @param type the type of simplification to run.
-         * successCallback optional success callback to be called after the simplification finished processing all settings.
+         * @param successCallback optional success callback to be called after the simplification finished processing all settings.
          */
         Mesh.prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
             if (parallelProcessing === void 0) { parallelProcessing = true; }
@@ -891,7 +891,12 @@ var BABYLON;
                 successCallback: successCallback
             });
         };
-        //The function doesn't delete unused vertex data, it simply restructure the indices to ignore them.
+        /**
+         * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
+         * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
+         * This should be used together with the simplification to avoid disappearing triangles.
+         * @param successCallback an optional success callback to be called after the optimization finished.
+         */
         Mesh.prototype.optimize = function (successCallback) {
             var _this = this;
             var indices = this.getIndices();
@@ -923,40 +928,6 @@ var BABYLON;
                     successCallback(_this);
                 }
             });
-            //for (var i = vectorPositions.length - 1; i >= 1; --i) {
-            //    var testedPosition = vectorPositions[i];
-            //    for (var j = 0; j < i; ++j) {
-            //        var againstPosition = vectorPositions[j];
-            //        if (testedPosition.equals(againstPosition)) {
-            //            dupes[i] = j;
-            //            break;
-            //        }
-            //    }
-            //}
-            //optimize each submesh individually.
-            //this.subMeshes.forEach(subMesh => {
-            //    var total = subMesh.indexStart + subMesh.indexCount;
-            //    var i;
-            //    var subMeshPositions: Array<Vector3> = []
-            //    for (i = subMesh.indexStart; i < total; ++i) {
-            //        subMeshPositions[indices[i]] = subMeshPositions[indices[i]] || (BABYLON.Vector3.FromArray(positions, indices[i]));
-            //    }
-            //    var dupes = [];
-            //    //find duplicates
-            //    for (i = subMeshPositions.length - 1; i >= 1; --i) {
-            //        var testedPosition = subMeshPositions[i];
-            //        for (var j = 0; j < i; ++j) {
-            //            var againstPosition = subMeshPositions[j];
-            //            if (testedPosition.equals(againstPosition)) {
-            //                dupes[i] = j;
-            //                break;
-            //            }
-            //        }
-            //    }
-            //    for (i = subMesh.indexStart; i < total; ++i) {
-            //        indices[i] = dupes[indices[i]] || indices[i];
-            //    }
-            //});
         };
         // Statics
         Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation) {

+ 7 - 42
Babylon/Mesh/babylon.mesh.ts

@@ -1078,7 +1078,7 @@
          * @param settings a collection of simplification settings.
          * @param parallelProcessing should all levels calculate parallel or one after the other.
          * @param type the type of simplification to run.
-         * successCallback optional success callback to be called after the simplification finished processing all settings.
+         * @param successCallback optional success callback to be called after the simplification finished processing all settings.
          */
         public simplify(settings: Array<ISimplificationSettings>, parallelProcessing: boolean = true, simplificationType: SimplificationType = SimplificationType.QUADRATIC, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void) {
             this.getScene().simplificationQueue.addTask({
@@ -1090,7 +1090,12 @@
             });
         }
 
-        //The function doesn't delete unused vertex data, it simply restructure the indices to ignore them.
+        /**
+         * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
+         * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
+         * This should be used together with the simplification to avoid disappearing triangles.
+         * @param successCallback an optional success callback to be called after the optimization finished.
+         */
         public optimize(successCallback?: (mesh?: Mesh) => void) {
             var indices = this.getIndices();
             var positions = this.getVerticesData(VertexBuffer.PositionKind);
@@ -1123,46 +1128,6 @@
                     successCallback(this);
                 }
             });
-
-            //for (var i = vectorPositions.length - 1; i >= 1; --i) {
-            //    var testedPosition = vectorPositions[i];
-            //    for (var j = 0; j < i; ++j) {
-            //        var againstPosition = vectorPositions[j];
-            //        if (testedPosition.equals(againstPosition)) {
-            //            dupes[i] = j;
-            //            break;
-            //        }
-            //    }
-            //}
-            
-            //optimize each submesh individually.
-            //this.subMeshes.forEach(subMesh => {
-            //    var total = subMesh.indexStart + subMesh.indexCount;
-            //    var i;
-            //    var subMeshPositions: Array<Vector3> = []
-            //    for (i = subMesh.indexStart; i < total; ++i) {
-            //        subMeshPositions[indices[i]] = subMeshPositions[indices[i]] || (BABYLON.Vector3.FromArray(positions, indices[i]));
-            //    }
-            //    var dupes = [];
-            //    //find duplicates
-            //    for (i = subMeshPositions.length - 1; i >= 1; --i) {
-            //        var testedPosition = subMeshPositions[i];
-            //        for (var j = 0; j < i; ++j) {
-            //            var againstPosition = subMeshPositions[j];
-            //            if (testedPosition.equals(againstPosition)) {
-            //                dupes[i] = j;
-            //                break;
-            //            }
-            //        }
-            //    }
-
-                
-            //    for (i = subMesh.indexStart; i < total; ++i) {
-            //        indices[i] = dupes[indices[i]] || indices[i];
-            //    }
-            //});
-
-            
         }
 
         // Statics