本帖最后由 君剑 于 2014-8-2 23:24 编辑
原帖:
HDT Physics Extension 开发者预览版【pre-α】
http://bbs.3dmgame.com/thread-3939772-1-1.html
我琢磨很久了,关于CollisionFilterInfo 的算法和碰撞条件始终看不懂,恰好,今天有时间,在网路上找到了一些资料,也翻出了氢姐当年的帖子,有了一些想法,虽然还不是很明白= =!
原帖中,有这么一段文字:
CollisionFilterInfo 计算:(GroupID<<24)|(GroupMask);
碰撞条件:若 (1<<IDA)&MaskB 且 (1<<IDB)&MaskA 则不碰撞
-1则不与任何物体碰撞
有点基础的话,(GroupID<<24)|(GroupMask) 还是很简单的。
简单说明一下
GroupID、GroupMask是两个变量,至于是怎么定义的,碰撞规则是怎样的我还不是很清楚= =!
这里我用a、b代替(十进制)
(a<<24)|(b):将a化成二进制数,然后"<<"的作用是将a左移两位右边补0,然后再和b的二进制数做或(|)运算,再化为十进制。这个十进制数就是CollisionFilterInfo的参数值。
(1<<IDA)&MaskB 则运用的是与运算。
以下摘自氢姐的帖子,个人翻译(由于这段英语很怪,翻译的不准确请见谅):
It's not decidedyet.
它尚未决定。
for now I just use abitfield. The highest 8 bits means which group it belong to(0-23, group>24means no collide with anything), and the lowest 24 bits means whether itcollide with a group(1=no collide).
现在我只使用一个位。高8位意味着某事物属于哪个group(0-23,group>24意味着与任何事物没有碰撞),而低24位意味着某事物是否与一个group发生碰撞(1 =无碰撞)。
you can use a win7build-in calcurator (program mode) to calcurate what you want.
你可以使用win7内置的程序计算器来计算你需要的参数。
it's calcurate underprogrammer mode(the 3rd mod, alt+3)
计算器第三型(程序计算器),快捷键是alt+3
if sth belongs to group 1 and will not collide with group 2 and 3:
如果某事物属于group 1,不会与group2、group3发生碰撞:
| 2.input group id |
|
|
|
| 输入groupid |
1 Lsh 24
Binary mode:
| 7.input 24 bits mask |
|
|
|
| 输入24位mask |
| (the rightest is group 0 and leftest is group 23) |
| (最右端为group0和最左边是group23) |
Or 0000 0000 0000 0000 0000 1100
And this is what weneed:
and that is what youwant.
这就是你想要的。
The filter is the same as the one in MMD. if sth masked as no collide with group x, then it will no collide will all things belongs to group x.(x can be the group it belongs).
这个过滤器和MMD中的一样。如果事物被隐藏,与group x没有任何碰撞,那么它与group x.的所有事物都不会发生碰撞。(X可以是它所属的group)
the default filter(hkpGroupFilter) has 4 fields(5 bit per field) which make it much more difficult to calcurate, and it's really difficult to design.(because of the collision relationship between layers are fixed)
默认过滤器(hkpGroupFilter)有4个场(每个场有5位),这使得它更难以计算,这真的很难设计。(因为曾与层之间的碰撞关系是固定的)
那么,它的碰撞条件到底是怎么理解的呢?我不是很明白。
|