Bullet physics(ammo.js in asm.js) 如何获得碰撞冲击力

Bullet physics(ammo.js in asm.js) how to get collision impact force

所以我设法让碰撞检测在 ammo.js 中工作,就像他们在 Physijs 中所做的那样。这是有效的代码

var i,
    dp = this.dispatcher,
    num = dp.getNumManifolds(),
    manifold, num_contacts, j, pt;

for (i = 0; i < num; i++) {
    manifold = dp.getManifoldByIndexInternal(i);

    num_contacts = manifold.getNumContacts();
    if (num_contacts === 0) {
        continue;
    }

    for (j = 0; j < num_contacts; j++) {
        pt = manifold.getContactPoint(j);

        //console.log('body 1: ', manifold.getBody0());
        //console.log('body 2: ', manifold.getBody1());

        console.log('COLLISION DETECTED!');
        // HERE: how to get impact force details?
        // pt.getAppliedImpulse() is not working
    }
}

在一些论坛上我发现这个函数提供了关于冲击力的信息:

getAppliedImpulse()

但是ammo.js中没有这个功能。我用文本搜索了代码,但它不存在。也许 API 更新了,或者阅读力的方法完全不同?

编辑:

这是我定制的弹药,带有 getAppliedImpulse() 并启用了许多基本功能。 https://github.com/DVLP/ammo.js/tree/master/builds

ammo.idl 添加绑定描述,并重建 ammo.js。

interface btManifoldPoint {
    ...
    [Const] double getAppliedImpulse();
}