Browse Source

Merge pull request #9745 from CedricGuillemet/fixCapsuleImpostorSize

Fix capsule impostor size computation for ammojs
Raanan Weber 4 năm trước cách đây
mục cha
commit
d2422bb3ea
2 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 1 0
      dist/preview release/what's new.md
  2. 4 1
      src/Physics/Plugins/ammoJSPlugin.ts

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

@@ -70,6 +70,7 @@
 - Fix issue where PBRSpecularGlossiness materials were excluded from export [#9423](https://github.com/BabylonJS/Babylon.js/issues/9423)([Drigax](https://github.com/drigax))
 - Fix issue when scaling is reapplied with BoundingBoxGizmo and GizmoManager ([CedricGuillemet](https://github.com/CedricGuillemet))
 - Fix direct loading of a glTF string that has base64-encoded URI. ([bghgary](https://github.com/bghgary))
+- Fix capsule impostor size computation for ammojs ([CedricGuillemet](https://github.com/CedricGuillemet))
 - Fix crash of some node materials using instances on iOS ([Popov72](https://github.com/Popov72))
 - Fix the code generated for the NME gradient block ([Popov72](https://github.com/Popov72))
 - Fix ssao2RenderingPipeline for orthographic cameras ([Kesshi](https://github.com/Kesshi))

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

@@ -949,7 +949,10 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
                 }
                 break;
             case PhysicsImpostor.CapsuleImpostor:
-                returnValue = new this.bjsAMMO.btCapsuleShape(extendSize.x / 2, extendSize.y / 2);
+                // https://pybullet.org/Bullet/BulletFull/classbtCapsuleShape.html#details
+                // Height is just the height between the center of each 'sphere' of the capsule caps
+                const capRadius = extendSize.x / 2;
+                returnValue = new this.bjsAMMO.btCapsuleShape(capRadius, extendSize.y - capRadius * 2);
                 break;
             case PhysicsImpostor.CylinderImpostor:
                 this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);