Box2d 碰撞脉冲
我想使用碰撞的冲量来计算碰撞中每个物体所造成的损坏。到目前为止,我有以下内容:
void FMContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) {
// Can be up to 2 for polygon collision
int count = contact->GetManifold()->pointCount;
// My two sprites in the collision
CCSprite *spriteA = (CCSprite*)contact->GetFixtureA()->GetBody()->GetUserData();
CCSprite *spriteB = (CCSprite*)contact->GetFixtureB()->GetBody()->GetUserData();
for (int i = 0; i < count; ++i) {
b2ManifoldPoint point = contact->GetManifold()->points[i];
// This is the impulse at this point
float impulse = point.normalImpulse;
}
}
这给了我每次调用 PostSolve 碰撞中每个点时的冲动。
我不是物理系的学生,但是每个物体不是都有自己的冲量作为其动量随 box2d 步骤的时间变化(例如 1/60 秒)吗?如果我从两个物体的碰撞中得到一个脉冲,这意味着什么?
I would like to use the impulse of a collision in order to calculate the damage each object in the collision undertakes. So far I have the following:
void FMContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) {
// Can be up to 2 for polygon collision
int count = contact->GetManifold()->pointCount;
// My two sprites in the collision
CCSprite *spriteA = (CCSprite*)contact->GetFixtureA()->GetBody()->GetUserData();
CCSprite *spriteB = (CCSprite*)contact->GetFixtureB()->GetBody()->GetUserData();
for (int i = 0; i < count; ++i) {
b2ManifoldPoint point = contact->GetManifold()->points[i];
// This is the impulse at this point
float impulse = point.normalImpulse;
}
}
This gives me the impulse at each call to PostSolve for each point in the collision.
I'm no physics student, but doesn't each object have their own impulse as the change in its momentum over the time of the box2d step (say 1/60th of a second)? If I'm getting a single impulse from the collision of two objects, what does this imply?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论