Forráskód Böngészése

LinesMesh updates

David Catuhe 11 éve
szülő
commit
e4af63f4b9

+ 3 - 1
Babylon/Mesh/babylon.abstractMesh.js

@@ -33,6 +33,7 @@ var BABYLON;
             this._physicImpostor = BABYLON.PhysicsEngine.NoImpostor;
             this._physicImpostor = BABYLON.PhysicsEngine.NoImpostor;
             // Collisions
             // Collisions
             this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
             this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
+            this.ellipsoidOffset = new BABYLON.Vector3(0, 0, 0);
             this._collider = new BABYLON.Collider();
             this._collider = new BABYLON.Collider();
             this._oldPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
             this._oldPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
             this._diffPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
             this._diffPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
@@ -534,9 +535,10 @@ var BABYLON;
             var globalPosition = this.getAbsolutePosition();
             var globalPosition = this.getAbsolutePosition();
 
 
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
+            this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset);
             this._collider.radius = this.ellipsoid;
             this._collider.radius = this.ellipsoid;
 
 
-            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions);
+            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions, this);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
 
 
             if (this._diffPositionForCollisions.length() > BABYLON.Engine.CollisionsEpsilon) {
             if (this._diffPositionForCollisions.length() > BABYLON.Engine.CollisionsEpsilon) {

+ 3 - 1
Babylon/Mesh/babylon.abstractMesh.ts

@@ -61,6 +61,7 @@
 
 
         // Collisions
         // Collisions
         public ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
         public ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
+        public ellipsoidOffset = new BABYLON.Vector3(0, 0, 0);
         private _collider = new Collider();
         private _collider = new Collider();
         private _oldPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
         private _oldPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
         private _diffPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
         private _diffPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
@@ -530,9 +531,10 @@
             var globalPosition = this.getAbsolutePosition();
             var globalPosition = this.getAbsolutePosition();
 
 
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
+            this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset);
             this._collider.radius = this.ellipsoid;
             this._collider.radius = this.ellipsoid;
 
 
-            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions);
+            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions, this);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
 
 
             if (this._diffPositionForCollisions.length() > Engine.CollisionsEpsilon) {
             if (this._diffPositionForCollisions.length() > Engine.CollisionsEpsilon) {

+ 20 - 0
Babylon/Mesh/babylon.linesMesh.js

@@ -27,6 +27,22 @@ var BABYLON;
             configurable: true
             configurable: true
         });
         });
 
 
+        Object.defineProperty(LinesMesh.prototype, "isPickable", {
+            get: function () {
+                return false;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
+            get: function () {
+                return false;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
         LinesMesh.prototype._bind = function (subMesh, effect, wireframe) {
         LinesMesh.prototype._bind = function (subMesh, effect, wireframe) {
             var engine = this.getScene().getEngine();
             var engine = this.getScene().getEngine();
 
 
@@ -50,6 +66,10 @@ var BABYLON;
             engine.draw(false, subMesh.indexStart, subMesh.indexCount);
             engine.draw(false, subMesh.indexStart, subMesh.indexCount);
         };
         };
 
 
+        LinesMesh.prototype.intersects = function (ray, fastCheck) {
+            return null;
+        };
+
         LinesMesh.prototype.dispose = function (doNotRecurse) {
         LinesMesh.prototype.dispose = function (doNotRecurse) {
             this._colorShader.dispose();
             this._colorShader.dispose();
 
 

+ 12 - 0
Babylon/Mesh/babylon.linesMesh.ts

@@ -22,6 +22,14 @@
             return this._colorShader;
             return this._colorShader;
         }
         }
 
 
+        public get isPickable(): boolean {
+            return false;
+        }
+
+        public get checkCollisions(): boolean {
+            return false;
+        }
+
         public _bind(subMesh: SubMesh, effect: Effect, wireframe?: boolean): void {
         public _bind(subMesh: SubMesh, effect: Effect, wireframe?: boolean): void {
             var engine = this.getScene().getEngine();
             var engine = this.getScene().getEngine();
 
 
@@ -45,6 +53,10 @@
             engine.draw(false, subMesh.indexStart, subMesh.indexCount);
             engine.draw(false, subMesh.indexStart, subMesh.indexCount);
         }
         }
 
 
+        public intersects(ray: Ray, fastCheck?: boolean) {
+            return null;
+        }
+
         public dispose(doNotRecurse?: boolean): void {
         public dispose(doNotRecurse?: boolean): void {
             this._colorShader.dispose();
             this._colorShader.dispose();
 
 

+ 1 - 1
Babylon/Mesh/babylon.mesh.ts

@@ -768,7 +768,7 @@
         }
         }
 
 
         // Torus  (Code from SharpDX.org)
         // Torus  (Code from SharpDX.org)
-        public static CreateTorus(name: string, diameter, thickness: number, tessellation: number, scene: Scene, updatable?: boolean): Mesh {
+        public static CreateTorus(name: string, diameter:number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean): Mesh {
             var torus = new BABYLON.Mesh(name, scene);
             var torus = new BABYLON.Mesh(name, scene);
             var vertexData = BABYLON.VertexData.CreateTorus(diameter, thickness, tessellation);
             var vertexData = BABYLON.VertexData.CreateTorus(diameter, thickness, tessellation);
 
 

+ 4 - 0
Babylon/Physics/babylon.physicsEngine.js

@@ -58,6 +58,10 @@
         PhysicsEngine.PlaneImpostor = 3;
         PhysicsEngine.PlaneImpostor = 3;
         PhysicsEngine.CompoundImpostor = 4;
         PhysicsEngine.CompoundImpostor = 4;
         PhysicsEngine.MeshImpostor = 4;
         PhysicsEngine.MeshImpostor = 4;
+        PhysicsEngine.CapsuleImpostor = 5;
+        PhysicsEngine.ConeImpostor = 6;
+        PhysicsEngine.CylinderImpostor = 7;
+        PhysicsEngine.ConvexHullImpostor = 8;
         PhysicsEngine.Epsilon = 0.001;
         PhysicsEngine.Epsilon = 0.001;
         return PhysicsEngine;
         return PhysicsEngine;
     })();
     })();

+ 4 - 0
Babylon/Physics/babylon.physicsEngine.ts

@@ -89,6 +89,10 @@
         public static PlaneImpostor = 3;
         public static PlaneImpostor = 3;
         public static CompoundImpostor = 4;
         public static CompoundImpostor = 4;
         public static MeshImpostor = 4;
         public static MeshImpostor = 4;
+        public static CapsuleImpostor = 5;
+        public static ConeImpostor = 6;
+        public static CylinderImpostor = 7;
+        public static ConvexHullImpostor = 8;
         public static Epsilon = 0.001;
         public static Epsilon = 0.001;
     }
     }
 }
 }

+ 2 - 2
Babylon/Tools/babylon.database.js

@@ -9,7 +9,7 @@ var BABYLON = BABYLON || {};
         var fileName = url.substring(url.lastIndexOf("/") + 1, url.length);
         var fileName = url.substring(url.lastIndexOf("/") + 1, url.length);
         var absLocation = url.substring(0, url.indexOf(fileName, 0));
         var absLocation = url.substring(0, url.indexOf(fileName, 0));
         return absLocation;
         return absLocation;
-    };
+    }
 
 
     // Handling various flavors of prefixed version of IndexedDB
     // Handling various flavors of prefixed version of IndexedDB
     var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB ||
     var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB ||
@@ -45,7 +45,7 @@ var BABYLON = BABYLON || {};
             BABYLON.Tools.Log("Valid manifest file not found. Scene & textures will be loaded directly from the web server.");
             BABYLON.Tools.Log("Valid manifest file not found. Scene & textures will be loaded directly from the web server.");
             that.enableSceneOffline = false;
             that.enableSceneOffline = false;
             that.enableTexturesOffline = false;
             that.enableTexturesOffline = false;
-        };
+        }
 
 
         var that = this;
         var that = this;
         var manifestURL = this.currentSceneUrl + ".manifest";
         var manifestURL = this.currentSceneUrl + ".manifest";

+ 0 - 1
Babylon/Tools/babylon.tools.js

@@ -580,7 +580,6 @@ var BABYLON;
         Object.defineProperty(Tools, "AllLogLevel", {
         Object.defineProperty(Tools, "AllLogLevel", {
             get: function () {
             get: function () {
                 return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;
                 return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;
-                ;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true

+ 1 - 1
Babylon/Tools/babylon.tools.ts

@@ -611,7 +611,7 @@ module BABYLON {
         }
         }
 
 
         static get AllLogLevel(): number {
         static get AllLogLevel(): number {
-            return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;;
+            return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;
         }
         }
 
 
         private static _FormatMessage(message: string): string {
         private static _FormatMessage(message: string): string {

+ 7 - 0
Babylon/babylon.engine.js

@@ -1358,6 +1358,13 @@
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
             }
             }
 
 
+            for (var i in this._vertexAttribArrays) {
+                if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArrays[i]) {
+                    continue;
+                }
+                this._gl.disableVertexAttribArray(i);
+            }
+
             // Events
             // Events
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("focus", this._onFocus);
             window.removeEventListener("focus", this._onFocus);

+ 8 - 0
Babylon/babylon.engine.ts

@@ -1386,6 +1386,14 @@
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
             }
             }
 
 
+            // Unbind
+            for (var i in this._vertexAttribArrays) {
+                if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArrays[i]) {
+                    continue;
+                }
+                this._gl.disableVertexAttribArray(i);
+            }
+
             // Events
             // Events
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("focus", this._onFocus);
             window.removeEventListener("focus", this._onFocus);

+ 11 - 5
Babylon/babylon.scene.js

@@ -1004,6 +1004,10 @@
             this._boundingBoxRenderer.dispose();
             this._boundingBoxRenderer.dispose();
 
 
             // Events
             // Events
+            if (this.onDispose) {
+                this.onDispose();
+            }
+
             this.detachControl();
             this.detachControl();
 
 
             // Detach cameras
             // Detach cameras
@@ -1061,19 +1065,21 @@
         };
         };
 
 
         // Collisions
         // Collisions
-        Scene.prototype._getNewPosition = function (position, velocity, collider, maximumRetry, finalPosition) {
+        Scene.prototype._getNewPosition = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
+            if (typeof excludedMesh === "undefined") { excludedMesh = null; }
             position.divideToRef(collider.radius, this._scaledPosition);
             position.divideToRef(collider.radius, this._scaledPosition);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
 
 
             collider.retry = 0;
             collider.retry = 0;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialPosition = this._scaledPosition;
             collider.initialPosition = this._scaledPosition;
-            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition, excludedMesh);
 
 
             finalPosition.multiplyInPlace(collider.radius);
             finalPosition.multiplyInPlace(collider.radius);
         };
         };
 
 
-        Scene.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition) {
+        Scene.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
+            if (typeof excludedMesh === "undefined") { excludedMesh = null; }
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
 
 
             if (collider.retry >= maximumRetry) {
             if (collider.retry >= maximumRetry) {
@@ -1085,7 +1091,7 @@
 
 
             for (var index = 0; index < this.meshes.length; index++) {
             for (var index = 0; index < this.meshes.length; index++) {
                 var mesh = this.meshes[index];
                 var mesh = this.meshes[index];
-                if (mesh.isEnabled() && mesh.checkCollisions) {
+                if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {
                     mesh._checkCollision(collider);
                     mesh._checkCollision(collider);
                 }
                 }
             }
             }
@@ -1105,7 +1111,7 @@
             }
             }
 
 
             collider.retry++;
             collider.retry++;
-            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
         };
         };
 
 
         // Octrees
         // Octrees

+ 10 - 5
Babylon/babylon.scene.ts

@@ -19,6 +19,7 @@
         public ambientColor = new BABYLON.Color3(0, 0, 0);
         public ambientColor = new BABYLON.Color3(0, 0, 0);
         public beforeRender: () => void;
         public beforeRender: () => void;
         public afterRender: () => void;
         public afterRender: () => void;
+        public onDispose: () => void;
         public beforeCameraRender: (camera: Camera) => void;
         public beforeCameraRender: (camera: Camera) => void;
         public afterCameraRender: (camera: Camera) => void;
         public afterCameraRender: (camera: Camera) => void;
         public forceWireframe = false;
         public forceWireframe = false;
@@ -1077,6 +1078,10 @@
             this._boundingBoxRenderer.dispose();
             this._boundingBoxRenderer.dispose();
 
 
             // Events
             // Events
+            if (this.onDispose) {
+                this.onDispose();
+            }
+
             this.detachControl();
             this.detachControl();
 
 
             // Detach cameras
             // Detach cameras
@@ -1142,19 +1147,19 @@
         }
         }
 
 
         // Collisions
         // Collisions
-        public _getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3): void {
+        public _getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3, excludedMesh: AbstractMesh = null): void {
             position.divideToRef(collider.radius, this._scaledPosition);
             position.divideToRef(collider.radius, this._scaledPosition);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
 
 
             collider.retry = 0;
             collider.retry = 0;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialPosition = this._scaledPosition;
             collider.initialPosition = this._scaledPosition;
-            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition, excludedMesh);
 
 
             finalPosition.multiplyInPlace(collider.radius);
             finalPosition.multiplyInPlace(collider.radius);
         }
         }
 
 
-        private _collideWithWorld(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3): void {
+        private _collideWithWorld(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3, excludedMesh: AbstractMesh = null): void {
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
 
 
             if (collider.retry >= maximumRetry) {
             if (collider.retry >= maximumRetry) {
@@ -1167,7 +1172,7 @@
             // Check all meshes
             // Check all meshes
             for (var index = 0; index < this.meshes.length; index++) {
             for (var index = 0; index < this.meshes.length; index++) {
                 var mesh = this.meshes[index];
                 var mesh = this.meshes[index];
-                if (mesh.isEnabled() && mesh.checkCollisions) {
+                if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {
                     mesh._checkCollision(collider);
                     mesh._checkCollision(collider);
                 }
                 }
             }
             }
@@ -1187,7 +1192,7 @@
             }
             }
 
 
             collider.retry++;
             collider.retry++;
-            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
         }
         }
 
 
         // Octrees
         // Octrees

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 2 - 2
babylon.1.13-beta-debug.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 10 - 10
babylon.1.13-beta.js