寻找脉冲分辨率的影响点 [英] Finding the Point of Impact for an Impulse Resolution

查看:193
本文介绍了寻找脉冲分辨率的影响点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在用C#建造一个小型赛车游戏,当涉及到汽车碰撞的汽车冲击分辨率时,我遇到了一些障碍。目前,汽车能够相互撞击和推动,但这些碰撞没有产生旋转。



我遇到的问题是确定影响点。



我用的是用于表示汽车轮廓的 Vector2 的集合。由此,我正在使用SAT来确定是否存在碰撞。在寻找分离轴时,我还跟踪最小穿透轴,这是在发生碰撞时用作脉冲分辨率法线的轴。我正在使用的轴是正在检查碰撞的汽车两侧的法线。



碰撞检测部分工作得非常好;汽车能够将其他汽车推开的方式也不算太糟糕。但是,我希望这些汽车能够以奇怪的角度旋转失控。



到目前为止,我想到的最佳解决方案就像是这个:

* CarA设置为用于确定脉冲分辨率正常的汽车。

* CarB是另一辆车。

*我把汽车推开去摆脱任何穿透(他们仍然会触碰,只是不重叠)

*我使用距离受影响的一侧最近的CarB点CarA,作为影响点。



据我所知,这个解决方案看似合理,但我有点担心。如果它是一个平坦的左右击中怎么办?两辆车玩鸡的完美碰撞将是困扰我的一个很好的例子。



有没有人对什么是最好的行动方案有任何建议?

I've been building a small racing game in C#, and I've hit a bit of a block when it comes to the impulse resolution of the car to car collisions. At the moment, the cars are able to hit and push each-other, but there's no resulting rotation from these collisions.

The problem I'm having is determining the point of impact.

I'm using a set of Vector2s to represent the outline of the car. From this, I'm using SAT to determine if there is an collision. While looking for a separating axis, I'm also keeping track of the axis of least penetration, this is the axis that gets used as the normal for the impulse resolution when there is a collision. The axes that I'm using are the normals of the sides of the cars that are being checked for collision.

The collision detection part of this is working very well; the way that the cars are able to shove other cars out of their way isn't too bad either. But, I want the cars to be able to spin out of control when hit at an odd angle.

The best solution I've thought of so far goes something like this:
* CarA is set to the car who's side is being used to determine the normal for the impulse resolution.
* CarB is the other car.
* I push the cars apart to get rid of any penetration (they will still be touching, just not overlapping)
* I use the point of CarB that is nearest to the impacted side of CarA, as the point of impact.

As far as I can tell, this solution seems sound, but I'm being bothered by one thing. What if it's a flat side-to-side hit? A perfect head-on-collision of two cars playing chicken would be a good example of what's bothering me.

Does anyone have any advice on what might be the best course of action for this?

推荐答案

我最终使用了来自CarB的法线轴上的最小范围点。这是我在问题中提到的可能的解决方案。事情有点有弹性,但我认为这更多地与我正在使用的常数有关。此外,大多数尝试游戏的人都会从中获得一点笑容,所以我想我会保持这种状态。
I ended up using the point of minimum extent along the normal axis, from CarB. It's the possible solution I mentioned in the question. Things are a little bouncy, but I think that has more to do with the constants I'm using. Besides, most people that have tried the game out tend to get a bit of a smile from that, so I think I'll be keeping it that way.


这篇关于寻找脉冲分辨率的影响点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆