DS Racer项目之后

DS Racer项目之后,忽然又想起一些东西:

1. 在计算碰撞时,在游戏运行中尽量减少对图形正确性的判断。图形正确性验证的工作在工具中进行。就是说游戏在运行时三角形就是三角形,不会是一条直线上的3个点的“三角形”。当然这样做也只能把效率提高一点点。

2.读《3D Math Primer for Graphics and Game Development.pdf》第8页有感,

The bottom line in choosing to count and measure in your virtual world using ints, floats, or

doubles is not, as some misguided people would have it, a matter of choosing between discrete

shorts and ints versus continuous floats and doubles. It is more a matter of precision. They are all

discrete in the end. Older books on computer graphics will advise you to use integers because

floating-point hardware is slower than integer hardware, but this is no longer the case. So which

should you choose? At this point, it is probably best to introduce you to the First Law of Computer

Graphics and leave you to think about it:

The First Law of Computer Graphics: If it looks right, it is right.

We will be doing a large amount of trigonometry in this book. Trigonometry involves real

numbers, such as , and real-valued functions, such as sine and cosine (which we’ll get to later).

Real numbers are a convenient fiction, so we will continue to use them. How do you know this is

true?You know because, Descartes notwithstanding, we told you so, because it would be nice, and

because it makes sense.

2.1 The First Law of Computer Graphics: If it looks right, it is right.

老实说之前我一直对在碰撞计算中引入误差这个做法不是特别的放心(总觉得这是一种“不正确”的方法或是“对付”事的做法),但是按照第一准则的说法,只要“看起来没问题那就是没问题。”这里找到了理论支撑。当然,如何让她看起来没问题是我们需要解决的。

2.2 “一定要使用整数代替浮点数吗?”

是的。在DS Racer做报告总结时,我被问的最多的就是这个问题(老实说我当时回答的一塌糊涂)。因为这是平台的限制造成的,做软件的人一定不能脱离硬件平台的限制的。起码实践已经证明如果在DS平台上大量使用浮点几乎是不能完成3D碰撞计算的(说“几乎”就是不排出在使用浮点计算的同时,在使用一个比现在使用的算法更快的算法这种情况,毕竟算法是有可能有这个能力的)。所以,按照我们已经实践的结果,在DS上碰撞计算只能使用定点数。

但是不论是浮点也好,整数定点也好,按照第一准则,只要看到的是好的就可以了。这是最重要的。

在前面结论基础上,如果只能使用定点整数,那任何(我们知道的)碰撞算法都几乎需要使用引入误差这个做法(这个说“几乎”同样是不想把自己的方法说的唯一)。

因为我们知道定点整数是离散的,而我们知道的碰撞算法都是基于精度的,可以想象,在精度点落在离散“空洞”的情况下,地平面上的法拉利(呵呵)一定会慢慢陷到地里的。

你可能感兴趣的:(DS Racer项目之后)