annotate OurMath.h @ 2325:846e28e41fb4

for bloodsplat
author Ritor1
date Fri, 28 Mar 2014 12:32:18 +0600
parents 8e9be4fa33a8
children dc822157c98d
rev   line source
2037
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
1 #pragma once
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
2
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
3 #include <cassert>
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
4 #include <limits>
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
5
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
6 /* 186 */
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
7 #pragma pack(push, 1)
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
8 struct stru193_math
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
9 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
10 stru193_math();
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
11 int Cos(int angle);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
12 unsigned int Atan2(int x, int y);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
13 int Sin(int angle);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
14
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
15 int pTanTable[520];
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
16 int pCosTable[520];
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
17 int pInvCosTable[520];
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
18 static const unsigned int uIntegerPi = 1024;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
19 static const unsigned int uIntegerHalfPi = 512;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
20 static const unsigned int uIntegerDoublePi = 2048;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
21 static const unsigned int uDoublePiMask = 2047;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
22 static const unsigned int uPiMask = 1023;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
23 static const unsigned int uHalfPiMask = 511;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
24 };
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
25 #pragma pack(pop)
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
26
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
27 __int64 fixpoint_mul(int, int);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
28 __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
29 __int64 fixpoint_div(int, int);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
30 __int64 fixpoint_sub_unknown(int, int);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
31 int fixpoint_from_float(float value);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
32 int fixpoint_from_int(int lhv, int rhv);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
33
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
34 template <typename FloatType>
2314
8e9be4fa33a8 for Bloodsplat
Ritor1
parents: 2037
diff changeset
35 inline int bankersRounding(const FloatType& value)
8e9be4fa33a8 for Bloodsplat
Ritor1
parents: 2037
diff changeset
36 {
2037
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
37 assert("Method unsupported for this type" && false);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
38 return value;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
39 }
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
40
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
41 template<> inline int bankersRounding<float>(const float& inValue)
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
42 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
43 union Cast
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
44 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
45 double d;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
46 long l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
47 };
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
48 volatile Cast c;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
49 c.d = inValue + 6755399441055744.0;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
50 return c.l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
51 }
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
52
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
53 #pragma push_macro("max")
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
54 #undef max
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
55 template<> inline int bankersRounding<double>(const double& inValue)
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
56 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
57 double maxValue = std::numeric_limits<int>::max();
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
58 assert(maxValue - 6755399441055744.0 >= inValue);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
59 union Cast
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
60 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
61 double d;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
62 long l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
63 };
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
64 volatile Cast c;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
65 c.d = inValue + 6755399441055744.0;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
66 return c.l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
67 }
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
68 #pragma pop_macro("max")
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
69
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
70 extern struct stru193_math *stru_5C6E00;