armory3d / haxebullet

Bullet 3D Physics for Haxe
http://bulletphysics.org
zlib License
94 stars 21 forks source link

Updated ammo.js and added some functions #15

Closed guzzard closed 6 years ago

guzzard commented 6 years ago

All tested in JS and C++

guzzard commented 6 years ago

While testing I used cast(_shapeConvex, BtCapsuleShapePointer), and it worked fine in JS. But in C++ I had to force a static_cast in order to cast BtConvexShapePointer into BtCapsuleShapePointer. Is this normal or am I missing something?

else if (shape == ControllerShape.Capsule) {
    var r = transform.dim.x / 2;
    _shapeConvex = BtCapsuleShapeZ.create(
        withMargin(r), // Radius
        withMargin(transform.dim.z - r * 2)); // Height between 2 sphere centers

    #if cpp
    var capsule:BtCapsuleShapePointer = null;
    untyped __cpp__('capsule = static_cast<btCapsuleShape*>(_shapeConvex)');
    trace("capsule: " + capsule.getUpAxis() + " " + capsule.getRadius() + " " + capsule.getHalfHeight());
    #end
}