Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
trs:fundamentals [2020/05/19 12:02] – [Rectangular (Quad) Face Definition] zdimension | trs:fundamentals [2020/05/19 12:16] (current) – [Fixed Point Data Types] zdimension | ||
---|---|---|---|
Line 60: | Line 60: | ||
|'' | |'' | ||
|'' | |'' | ||
+ | |'' | ||
All multi-byte integers ('' | All multi-byte integers ('' | ||
- | ==== 32 bit Fixed Point Data Type ==== | + | ==== Fixed Point Data Types ==== |
- | This is a 32 bit integer, where a unit (i.e., the 1 in the normal numerical sense) | + | These very specific data types mimic floating-point behaviour, //while remaining integer//. It is done by splitting floating-point value into whole and fractional parts, and keeping each part as '' |
- | There are certain cases where special caution must be paid. A multiplication | + | $F_{real} |
- | $f = f_1 \cdot f_2 \Leftrightarrow | + | Formula to calculate floating-point from '' |
+ | |||
+ | $F_{real} | ||
+ | |||
+ | ...where $P_{whole}$ is whole part of mixed float (signed for '' | ||
+ | |||
+ | < | ||
+ | The reason why such complicated setup was invented is to avoid using floating-point numbers. In 90% of all cases, Tomb Raider engines use integer numbers, even | ||
+ | for geometry calculations and animation interpolations. The root of this setup lies in multi-platform nature of the code, which was simultaneously written for PC and PlayStation. While PCs had enough computational power to deal with floats at that time, PlayStation relied only on integers. | ||
+ | |||
+ | However, some internal variables and constants (like drawing distance, fog distance constants and some light properties) are PC-specific and stored in floating | ||
+ | point numbers. Also, last game in series, TR5, extensively used floating-point numbers for certain data types – like colours, vertices and coordinates. | ||
+ | </ | ||
==== Data Alignment ==== | ==== Data Alignment ==== |