Переглянути джерело

ammo js build with add_func
scalar within epsilon for extent comparison

Cedric Guillemet 6 роки тому
батько
коміт
dd57997d9c
3 змінених файлів з 25 додано та 24 видалено
  1. 11 11
      dist/ammo.js
  2. 11 11
      dist/preview release/ammo.js
  3. 3 2
      src/Physics/Plugins/ammoJSPlugin.ts

Різницю між файлами не показано, бо вона завелика
+ 11 - 11
dist/ammo.js


Різницю між файлами не показано, бо вона завелика
+ 11 - 11
dist/preview release/ammo.js


+ 3 - 2
src/Physics/Plugins/ammoJSPlugin.ts

@@ -12,6 +12,7 @@ import { ShapeBuilder } from "../../Meshes/Builders/shapeBuilder";
 import { LinesBuilder } from "../../Meshes/Builders/linesBuilder";
 import { LinesMesh } from '../../Meshes/linesMesh';
 import { PhysicsRaycastResult } from "../physicsRaycastResult";
+import { Scalar } from "../../Maths/math.scalar"
 
 declare var Ammo: any;
 
@@ -901,11 +902,11 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
         switch (impostor.type) {
             case PhysicsImpostor.SphereImpostor:
                 // Is there a better way to compare floats number? With an epsylon or with a Math function
-                if (extendSize.x === extendSize.y && extendSize.x === extendSize.z) {
+                if (Scalar.WithinEpsilon(extendSize.x, extendSize.y, 0.0001) && Scalar.WithinEpsilon(extendSize.x, extendSize.z, 0.0001)) {
                     returnValue = new Ammo.btSphereShape(extendSize.x / 2);
                 } else {
                     // create a btMultiSphereShape because it's not possible to set a local scaling on a btSphereShape
-                    var positions = [new Ammo.btVector3(0,0,0)];
+                    var positions = [new Ammo.btVector3(0, 0, 0)];
                     var radii = [1];
                     returnValue = new Ammo.btMultiSphereShape(positions, radii, 1);
                     returnValue.setLocalScaling(new Ammo.btVector3(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2));