annotate OurMath.h @ 2457:17ac6a47f8fb

speed actors
author Ritor1
date Sat, 26 Jul 2014 10:42:29 +0600
parents dc822157c98d
children
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);
2340
dc822157c98d Moving functions from unsorted_subs.h pt4
Grumpy7
parents: 2314
diff changeset
33 int integer_sqrt(int val);
dc822157c98d Moving functions from unsorted_subs.h pt4
Grumpy7
parents: 2314
diff changeset
34 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb
dc822157c98d Moving functions from unsorted_subs.h pt4
Grumpy7
parents: 2314
diff changeset
35 inline int round_to_int(float x) { return (int)floor(x + 0.5f); }
2037
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
36
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
37 template <typename FloatType>
2314
8e9be4fa33a8 for Bloodsplat
Ritor1
parents: 2037
diff changeset
38 inline int bankersRounding(const FloatType& value)
8e9be4fa33a8 for Bloodsplat
Ritor1
parents: 2037
diff changeset
39 {
2037
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
40 assert("Method unsupported for this type" && false);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
41 return value;
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
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
44 template<> inline int bankersRounding<float>(const float& inValue)
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
45 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
46 union Cast
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 double d;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
49 long l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
50 };
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
51 volatile Cast c;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
52 c.d = inValue + 6755399441055744.0;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
53 return c.l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
54 }
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
55
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
56 #pragma push_macro("max")
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
57 #undef max
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
58 template<> inline int bankersRounding<double>(const double& inValue)
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
59 {
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
60 double maxValue = std::numeric_limits<int>::max();
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
61 assert(maxValue - 6755399441055744.0 >= inValue);
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
62 union Cast
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 double d;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
65 long l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
66 };
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
67 volatile Cast c;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
68 c.d = inValue + 6755399441055744.0;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
69 return c.l;
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
70 }
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
71 #pragma pop_macro("max")
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
72
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
diff changeset
73 extern struct stru193_math *stru_5C6E00;