annotate Math.h @ 1962:39a68477ead3

pActorBuffs[18] to pActorBuffs[ACTOR_BUFF_HEROISM]
author Grumpy7
date Fri, 25 Oct 2013 11:21:37 -0700
parents 7182930263b3
children
rev   line source
0
Ritor1
parents:
diff changeset
1 #pragma once
1527
f0551cd4cbc9 Clean Math.
yoctozepto
parents: 1262
diff changeset
2
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
3 #include <cassert>
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
4 #include <limits>
0
Ritor1
parents:
diff changeset
5
Ritor1
parents:
diff changeset
6 /* 186 */
Ritor1
parents:
diff changeset
7 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
8 struct stru193_math
Ritor1
parents:
diff changeset
9 {
Ritor1
parents:
diff changeset
10 stru193_math();
323
d720a13e2273 Very basic picking & entering houses
Nomad
parents: 0
diff changeset
11 int Cos(int angle);
0
Ritor1
parents:
diff changeset
12 unsigned int Atan2(int x, int y);
323
d720a13e2273 Very basic picking & entering houses
Nomad
parents: 0
diff changeset
13 int Sin(int angle);
0
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15 int pTanTable[520];
Ritor1
parents:
diff changeset
16 int pCosTable[520];
Ritor1
parents:
diff changeset
17 int pInvCosTable[520];
1214
0d6c7ff3cddd simplified stru193_math constructor and class definition
Grumpy7
parents: 1131
diff changeset
18 static const unsigned int uIntegerPi = 1024;
0d6c7ff3cddd simplified stru193_math constructor and class definition
Grumpy7
parents: 1131
diff changeset
19 static const unsigned int uIntegerHalfPi = 512;
0d6c7ff3cddd simplified stru193_math constructor and class definition
Grumpy7
parents: 1131
diff changeset
20 static const unsigned int uIntegerDoublePi = 2048;
0d6c7ff3cddd simplified stru193_math constructor and class definition
Grumpy7
parents: 1131
diff changeset
21 static const unsigned int uDoublePiMask = 2047;
0d6c7ff3cddd simplified stru193_math constructor and class definition
Grumpy7
parents: 1131
diff changeset
22 static const unsigned int uPiMask = 1023;
0d6c7ff3cddd simplified stru193_math constructor and class definition
Grumpy7
parents: 1131
diff changeset
23 static const unsigned int uHalfPiMask = 511;
0
Ritor1
parents:
diff changeset
24 };
Ritor1
parents:
diff changeset
25 #pragma pack(pop)
Ritor1
parents:
diff changeset
26
1643
7182930263b3 fixpoint functions renaming
zipi
parents: 1640
diff changeset
27 __int64 fixpoint_mul(int, int);
1556
e668660457dc Some more cleaning
Nomad
parents: 1544
diff changeset
28 __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2);
e668660457dc Some more cleaning
Nomad
parents: 1544
diff changeset
29 __int64 fixpoint_div(int, int);
1643
7182930263b3 fixpoint functions renaming
zipi
parents: 1640
diff changeset
30 __int64 fixpoint_sub_unknown(int, int);
1051
05c62d166182 004C1D2B cleaned
Nomad
parents: 323
diff changeset
31 int fixpoint_from_float(float value);
1640
afc1c3514dd5 Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents: 1615
diff changeset
32 int fixpoint_from_int(int lhv, int rhv);
1051
05c62d166182 004C1D2B cleaned
Nomad
parents: 323
diff changeset
33
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
34 template <typename FloatType>
1527
f0551cd4cbc9 Clean Math.
yoctozepto
parents: 1262
diff changeset
35 inline int bankersRounding(
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
36 const FloatType& value
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
37 ) {
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
38 assert("Method unsupported for this type" && false);
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
39 return value;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
40 }
1130
d98415be04ca banker's rounding template
Grumpy7
parents: 1051
diff changeset
41
1527
f0551cd4cbc9 Clean Math.
yoctozepto
parents: 1262
diff changeset
42 template<> inline int bankersRounding<float>(const float& inValue)
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
43 {
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
44 union Cast
1130
d98415be04ca banker's rounding template
Grumpy7
parents: 1051
diff changeset
45 {
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
46 double d;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
47 long l;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
48 };
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
49 volatile Cast c;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
50 c.d = inValue + 6755399441055744.0;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
51 return c.l;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
52 }
1130
d98415be04ca banker's rounding template
Grumpy7
parents: 1051
diff changeset
53
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
54 #pragma push_macro("max")
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
55 #undef max
1527
f0551cd4cbc9 Clean Math.
yoctozepto
parents: 1262
diff changeset
56 template<> inline int bankersRounding<double>(const double& inValue)
1131
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
57 {
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
58 double maxValue = std::numeric_limits<int>::max();
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
59 assert(maxValue - 6755399441055744.0 >= inValue);
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
60 union Cast
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
61 {
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
62 double d;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
63 long l;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
64 };
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
65 volatile Cast c;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
66 c.d = inValue + 6755399441055744.0;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
67 return c.l;
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
68 }
71ba92960bc5 banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents: 1130
diff changeset
69 #pragma pop_macro("max")
1130
d98415be04ca banker's rounding template
Grumpy7
parents: 1051
diff changeset
70
1527
f0551cd4cbc9 Clean Math.
yoctozepto
parents: 1262
diff changeset
71 extern struct stru193_math *stru_5C6E00;