Prechádzať zdrojové kódy

Update Ammo.js library and AmmoJS plugin to support ellipsoid

Cedric Guillemet 6 rokov pred
rodič
commit
49f77639b8

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 40 - 40
dist/ammo.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 40 - 40
dist/preview release/ammo.js


+ 1 - 0
dist/preview release/what's new.md

@@ -47,6 +47,7 @@
 ### Physics
 - Update Ammo.js library to support global collision contact callbacks ([MackeyK24](https://github.com/MackeyK24/))
 - Update AmmoJSPlugin to allow your own broadphase overlapping pair cache ([MackeyK24](https://github.com/MackeyK24/))
+- Update Ammo.js library and AmmoJS plugin to support ellipsoid ([CedricGuillemet](https://github.com/CedricGuillemet/)) 
 
 ## Bug fixes
 - Added support for `AnimationGroup` serialization ([Drigax](https://github.com/drigax/))

+ 10 - 1
src/Physics/Plugins/ammoJSPlugin.ts

@@ -900,7 +900,16 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
 
         switch (impostor.type) {
             case PhysicsImpostor.SphereImpostor:
-                returnValue = new Ammo.btSphereShape(extendSize.x / 2);
+                // 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) {
+                    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 radii = [1];
+                    returnValue = new Ammo.btMultiSphereShape(positions, radii, 1);
+                    returnValue.setLocalScaling(new Ammo.btVector3(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2));
+                }
                 break;
             case PhysicsImpostor.CylinderImpostor:
                 this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);