瀏覽代碼

Fixed a bug with cache and probes

David Catuhe 9 年之前
父節點
當前提交
834a3b94fa

File diff suppressed because it is too large
+ 19 - 19
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 3536 - 3538
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 27 - 27
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 44 - 26
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 25 - 25
dist/preview release/babylon.noworker.js


+ 1 - 0
src/Materials/Textures/babylon.renderTargetTexture.js

@@ -161,6 +161,7 @@ var BABYLON;
                 for (var face = 0; face < 6; face++) {
                     this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
                     scene.incrementRenderId();
+                    scene.resetCachedMaterial();
                 }
             }
             else {

+ 1 - 0
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -178,6 +178,7 @@
                 for (var face = 0; face < 6; face++) {
                     this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
                     scene.incrementRenderId();
+                    scene.resetCachedMaterial();
                 }
             } else {
                 this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);

+ 18 - 10
src/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -178,6 +178,8 @@ var BABYLON;
                         localAnchorB: constraintData.pivotB
                     });
                     break;
+                case BABYLON.PhysicsJoint.PointToPointJoint:
+                case BABYLON.PhysicsJoint.BallAndSocketJoint:
                 default:
                     constraint = new CANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotA, constraintData.maxForce);
                     break;
@@ -223,37 +225,43 @@ var BABYLON;
             mesh.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
             mesh.computeWorldMatrix(true);
             var returnValue;
+            var bbox = mesh.getBoundingInfo().boundingBox;
             switch (impostor.type) {
                 case BABYLON.PhysicsEngine.SphereImpostor:
-                    var bbox = mesh.getBoundingInfo().boundingBox;
                     var radiusX = bbox.maximumWorld.x - bbox.minimumWorld.x;
                     var radiusY = bbox.maximumWorld.y - bbox.minimumWorld.y;
                     var radiusZ = bbox.maximumWorld.z - bbox.minimumWorld.z;
                     returnValue = new CANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
                     break;
                 //TMP also for cylinder - TODO Cannon supports cylinder natively.
-                case BABYLON.PhysicsEngine.CylinderImpostor:
-                    BABYLON.Tools.Warn("CylinderImposter not yet implemented, using BoxImposter instead");
-                case BABYLON.PhysicsEngine.BoxImpostor:
-                    bbox = mesh.getBoundingInfo().boundingBox;
+                case BABYLON.PhysicsImpostor.CylinderImpostor:
+                    var min = bbox.minimumWorld;
+                    var max = bbox.maximumWorld;
+                    var box = max.subtract(min);
+                    returnValue = new CANNON.Cylinder(this._checkWithEpsilon(box.x) / 2, this._checkWithEpsilon(box.x) / 2, this._checkWithEpsilon(box.y), 16);
+                    break;
+                case BABYLON.PhysicsImpostor.BoxImpostor:
                     var min = bbox.minimumWorld;
                     var max = bbox.maximumWorld;
                     var box = max.subtract(min).scale(0.5);
                     returnValue = new CANNON.Box(new CANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
                     break;
-                case BABYLON.PhysicsEngine.PlaneImpostor:
+                case BABYLON.PhysicsImpostor.PlaneImpostor:
                     BABYLON.Tools.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
                     returnValue = new CANNON.Plane();
                     break;
-                case BABYLON.PhysicsEngine.MeshImpostor:
+                case BABYLON.PhysicsImpostor.MeshImpostor:
                     var rawVerts = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
                     var rawFaces = mesh.getIndices();
                     BABYLON.Tools.Warn("MeshImpostor only collides against spheres.");
                     returnValue = new CANNON.Trimesh(rawVerts, rawFaces);
                     break;
-                case BABYLON.PhysicsEngine.HeightmapImpostor:
+                case BABYLON.PhysicsImpostor.HeightmapImpostor:
                     returnValue = this._createHeightmap(mesh);
                     break;
+                case BABYLON.PhysicsImpostor.ParticleImpostor:
+                    returnValue = new CANNON.Particle();
+                    break;
             }
             mesh.rotationQuaternion = oldQuaternion;
             return returnValue;
@@ -315,7 +323,7 @@ var BABYLON;
             var quaternion = mesh.rotationQuaternion;
             this._tmpPosition.copyFrom(mesh.getBoundingInfo().boundingBox.center);
             //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
-            if (impostor.type === BABYLON.PhysicsEngine.PlaneImpostor || impostor.type === BABYLON.PhysicsEngine.HeightmapImpostor) {
+            if (impostor.type === BABYLON.PhysicsImpostor.PlaneImpostor || impostor.type === BABYLON.PhysicsImpostor.HeightmapImpostor || impostor.type === BABYLON.PhysicsImpostor.CylinderImpostor) {
                 //-90 DEG in X, precalculated
                 quaternion = quaternion.multiply(this._minus90X);
                 //Invert! (Precalculated, 90 deg in X)
@@ -418,7 +426,7 @@ var BABYLON;
         };
         CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
             joint.physicsJoint.motorEquation.maxForce = upperLimit;
-            joint.physicsJoint.motorEquation.minForce = lowerLimit || -upperLimit;
+            joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
         };
         CannonJSPlugin.prototype.dispose = function () {
             //nothing to do, actually.

+ 20 - 8
src/Physics/Plugins/babylon.oimoJSPlugin.js

@@ -124,7 +124,9 @@ var BABYLON;
                     }
                     // register mesh
                     switch (i.type) {
-                        case BABYLON.PhysicsEngine.SphereImpostor:
+                        case BABYLON.PhysicsImpostor.ParticleImpostor:
+                            BABYLON.Tools.Warn("No Particle support in Oimo.js. using SphereImpostor instead");
+                        case BABYLON.PhysicsImpostor.SphereImpostor:
                             var radiusX = bbox.maximumWorld.x - bbox.minimumWorld.x;
                             var radiusY = bbox.maximumWorld.y - bbox.minimumWorld.y;
                             var radiusZ = bbox.maximumWorld.z - bbox.minimumWorld.z;
@@ -135,10 +137,20 @@ var BABYLON;
                             bodyConfig.size.push(size);
                             bodyConfig.size.push(size);
                             break;
-                        case BABYLON.PhysicsEngine.PlaneImpostor:
-                        //TODO Oimo now supports cylinder!
-                        case BABYLON.PhysicsEngine.CylinderImpostor:
-                        case BABYLON.PhysicsEngine.BoxImpostor:
+                        case BABYLON.PhysicsImpostor.CylinderImpostor:
+                            var min = bbox.minimumWorld;
+                            var max = bbox.maximumWorld;
+                            var box = max.subtract(min);
+                            var sizeX = checkWithEpsilon(box.x) / 2;
+                            var sizeY = checkWithEpsilon(box.y);
+                            bodyConfig.type.push('cylinder');
+                            bodyConfig.size.push(sizeX);
+                            bodyConfig.size.push(sizeY);
+                            //due to the way oimo works with compounds, add one more value.
+                            bodyConfig.size.push(sizeY);
+                            break;
+                        case BABYLON.PhysicsImpostor.PlaneImpostor:
+                        case BABYLON.PhysicsImpostor.BoxImpostor:
                         default:
                             var min = bbox.minimumWorld;
                             var max = bbox.maximumWorld;
@@ -295,16 +307,16 @@ var BABYLON;
                 joint.physicsJoint.limitMotoe.lowerLimit = minDistance;
             }
         };
-        OimoJSPlugin.prototype.setMotor = function (joint, force, maxForce, motorIndex) {
+        OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
             var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.limitMotor;
             if (motor) {
-                motor.setMotor(force, maxForce);
+                motor.setMotor(speed, maxForce);
             }
         };
         OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
             var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.limitMotor;
             if (motor) {
-                motor.setLimit(upperLimit, lowerLimit || -upperLimit);
+                motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
             }
         };
         OimoJSPlugin.prototype.dispose = function () {

+ 3 - 3
src/Physics/babylon.physicsEngine.js

@@ -132,11 +132,11 @@ var BABYLON;
         PhysicsEngine.BoxImpostor = BABYLON.PhysicsImpostor.BoxImpostor;
         PhysicsEngine.PlaneImpostor = BABYLON.PhysicsImpostor.PlaneImpostor;
         PhysicsEngine.MeshImpostor = BABYLON.PhysicsImpostor.MeshImpostor;
-        PhysicsEngine.CapsuleImpostor = BABYLON.PhysicsImpostor.CapsuleImpostor;
-        PhysicsEngine.ConeImpostor = BABYLON.PhysicsImpostor.ConeImpostor;
         PhysicsEngine.CylinderImpostor = BABYLON.PhysicsImpostor.CylinderImpostor;
-        PhysicsEngine.ConvexHullImpostor = BABYLON.PhysicsImpostor.ConvexHullImpostor;
         PhysicsEngine.HeightmapImpostor = BABYLON.PhysicsImpostor.HeightmapImpostor;
+        PhysicsEngine.CapsuleImpostor = -1;
+        PhysicsEngine.ConeImpostor = -1;
+        PhysicsEngine.ConvexHullImpostor = -1;
         PhysicsEngine.Epsilon = 0.001;
         return PhysicsEngine;
     })();

+ 1 - 3
src/Physics/babylon.physicsImpostor.js

@@ -316,10 +316,8 @@ var BABYLON;
         PhysicsImpostor.BoxImpostor = 2;
         PhysicsImpostor.PlaneImpostor = 3;
         PhysicsImpostor.MeshImpostor = 4;
-        PhysicsImpostor.CapsuleImpostor = 5;
-        PhysicsImpostor.ConeImpostor = 6;
         PhysicsImpostor.CylinderImpostor = 7;
-        PhysicsImpostor.ConvexHullImpostor = 8;
+        PhysicsImpostor.ParticleImpostor = 8;
         PhysicsImpostor.HeightmapImpostor = 9;
         return PhysicsImpostor;
     })();

+ 0 - 1
src/Physics/babylon.physicsJoint.js

@@ -56,7 +56,6 @@ var BABYLON;
         PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
         //Cannon
         //Similar to a Ball-Joint. Different in params
-        //TODO check!!
         PhysicsJoint.PointToPointJoint = 8;
         //Cannon only at the moment
         PhysicsJoint.SpringJoint = 9;