World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл OurMath.h

См. исходные тексты.

Классы

struct  fixed
 
struct  stru193_math
 

Функции

int64_t fixpoint_mul (int, int)
 
int64_t fixpoint_dot (int x1, int x2, int y1, int y2, int z1, int z2)
 
int64_t fixpoint_div (int, int)
 
int64_t fixpoint_sub_unknown (int, int)
 
int fixpoint_from_float (float value)
 
int fixpoint_from_int (int lhv, int rhv)
 
int integer_sqrt (int val)
 
int GetDiceResult (unsigned int uNumDice, unsigned int uDiceSides)
 
int round_to_int (float x)
 
template<typename FloatType >
int bankersRounding (const FloatType &value)
 
template<>
int bankersRounding< float > (const float &inValue)
 
template<>
int bankersRounding< double > (const double &inValue)
 

Переменные

struct stru193_mathstru_5C6E00
 

Функции

◆ fixpoint_mul()

int64_t fixpoint_mul ( int  ,
int   
)

См. определение в файле OurMath.cpp строка 138

138  {
139  return ((__int64)a1 * (__int64)a2) >> 16;
140 }

Используется в CastSpellInfoHelpers::_427E01_cast_spell(), _45063B_spawn_some_monster(), Actor::_46DF1A_collide_against_actor(), _46E0B2_collide_against_decorations(), _46E26D_collide_against_sprites(), _46EF01_collision_chech_player(), Actor::ActorDamageFromMonster(), Actor::AI_Pursue1(), IndoorCameraD3D::ApplyViewTransform_TrueIfStillVisible_BLV(), BLV_GetFloorLevel(), BLV_ProcessPartyActions(), BLV_UpdateDoors(), stru141_actor_collision_object::CalcMovementExtents(), SkyBillboardStruct::CalcSkyFrustumVec(), Vis::CheckIntersectBModel(), SpriteObject::Create(), Actor::DamageMonsterFromParty(), DrawBook_Map_sub(), RenderOpenGL::DrawBuildingsD3D(), Render::DrawBuildingsD3D(), Render::DrawIndoorSky(), RenderOpenGL::DrawOutdoorSkyD3D(), Render::DrawOutdoorSkyD3D(), RenderBase::DrawSpriteObjects_ODM(), fixpoint_dot(), GameUI_DrawMinimap(), GetCeilingHeight(), GetPortalScreenCoord(), IndoorLocation::GetSector(), GetTerrainHeightsAroundParty2(), IsBModelVisible(), ItemDamageFromActor(), ODM_GetFloorLevel(), ODM_ProcessPartyActions(), IndoorLocation::PrepareItemsRenderList_BLV(), SpawnEncounter(), sub_4070EF_prolly_detect_player(), sub_4075DB(), sub_407A1C(), sub_44FA4C_spawn_light_elemental(), sub_47531C(), sub_4754BF(), sub_475D85(), sub_475F30(), Actor::SummonMinion(), UpdateActors_BLV(), UpdateActors_ODM(), SpriteObject::UpdateObject_fn0_BLV() и SpriteObject::UpdateObject_fn0_ODM().

+ Граф вызова функции:

◆ fixpoint_dot()

int64_t fixpoint_dot ( int  x1,
int  x2,
int  y1,
int  y2,
int  z1,
int  z2 
)

См. определение в файле OurMath.cpp строка 142

142  {
143  return fixpoint_mul(x1, x2) + fixpoint_mul(y1, y2) + fixpoint_mul(z1, z2);
144 }

Перекрестные ссылки fixpoint_mul().

Используется в SkyBillboardStruct::CalcSkyFrustumVec().

+ Граф вызовов:
+ Граф вызова функции:

◆ fixpoint_div()

int64_t fixpoint_div ( int  ,
int   
)

См. определение в файле OurMath.cpp строка 147

147 { return ((__int64)a1 << 16) / a2; }

Используется в BLV_GetFloorLevel(), Vis::CheckIntersectBModel(), GetPortalScreenCoord(), IndoorLocation::GetSector(), BLVRenderParams::Reset(), sub_4070EF_prolly_detect_player(), sub_4075DB() и sub_407A1C().

+ Граф вызова функции:

◆ fixpoint_sub_unknown()

int64_t fixpoint_sub_unknown ( int  ,
int   
)

См. определение в файле OurMath.cpp строка 149

149  {
150  return (((__int64)a1 << 16) * a2) >> 16;
151 }

◆ fixpoint_from_float()

int fixpoint_from_float ( float  value)

См. определение в файле OurMath.cpp строка 154

154  {
155  // float X.Yf -> int XXXX YYYY
156  int left = floorf((val - 0.5f) + 0.5f);
157  int right = floorf((val - left) * 65536.0f);
158  return (left << 16) | right;
159 }

Используется в Vis::CastPickRay() и fixed::FromFloat().

+ Граф вызова функции:

◆ fixpoint_from_int()

int fixpoint_from_int ( int  lhv,
int  rhv 
)

См. определение в файле OurMath.cpp строка 161

161 { return (lhv << 16) | rhv; }

Используется в BLVRenderParams::Reset().

+ Граф вызова функции:

◆ integer_sqrt()

int integer_sqrt ( int  val)

См. определение в файле OurMath.cpp строка 164

164  {
166  //Получение квадратного корня//
168 
169  int result; // eax@2
170  unsigned int v2; // edx@3
171  unsigned int v3; // edi@3
172  int v5; // esi@4
173 
174  if (val < 1) return val;
175 
176  v2 = 0;
177  v3 = val;
178  result = 0;
179  for (unsigned int i = 0; i < 16; ++i) {
180  result *= 2;
181  v2 = (v3 >> 30) | 4 * v2;
182  v5 = 2 * result + 1;
183  v3 *= 4;
184  if (v2 >= v5) {
185  ++result;
186  v2 -= v5;
187  }
188  }
189  if (val - result * result >= (unsigned int)(result - 1)) ++result;
190  return result;
191 }

Используется в Player::_42ECB5_PlayerAttacksActor(), Actor::_46DF1A_collide_against_actor(), _46E0B2_collide_against_decorations(), _46E26D_collide_against_sprites(), _46EF01_collision_chech_player(), BLV_ProcessPartyActions(), stru141_actor_collision_object::CalcMovementExtents(), Vec3< int >::Normalize(), ODM_ProcessPartyActions(), sub_4070EF_prolly_detect_player(), sub_407A1C(), sub_4088E9(), UpdateActors_BLV(), UpdateActors_ODM(), SpriteObject::UpdateObject_fn0_BLV() и SpriteObject::UpdateObject_fn0_ODM().

+ Граф вызова функции:

◆ GetDiceResult()

int GetDiceResult ( unsigned int  uNumDice,
unsigned int  uDiceSides 
)

См. определение в файле OurMath.cpp строка 194

194  {
195  int v3 = 0;
196  if (uDiceSides) {
197  for (unsigned int i = 0; i < uNumDice; ++i)
198  v3 += rand() % uDiceSides + 1;
199  return v3;
200  }
201  return 0;
202 }

Используется в ItemGen::_439DF3_get_additional_damage() и _43AFE3_calc_spell_damage().

+ Граф вызова функции:

◆ round_to_int()

int round_to_int ( float  x)
inline

См. определение в файле OurMath.h строка 18

18 { return (int)floor(x + 0.5f); }

Используется в Polygon::_normalize_v_18(), DecalBuilder::ApplyDecals_OutdoorFace(), ReplaceHSV() и SpellFX_Billboard::SpellFXProject().

+ Граф вызова функции:

◆ bankersRounding()

template<typename FloatType >
int bankersRounding ( const FloatType &  value)
inline

См. определение в файле OurMath.h строка 98

98  {
99  assert("Method unsupported for this type" && false);
100  return value;
101 }

Используется в DecalBuilder::AddBloodsplat(), Render::DrawProjectile(), Random::GetInRange(), ODMFace::IsBackfaceNotCulled() и Vec3< int >::Normalize_float().

+ Граф вызова функции:

◆ bankersRounding< float >()

template<>
int bankersRounding< float > ( const float &  inValue)
inline

См. определение в файле OurMath.h строка 104

104  {
105  union Cast {
106  double d;
107  long l;
108  };
109  volatile Cast c;
110  c.d = inValue + 6755399441055744.0;
111  return c.l;
112 }

Перекрестные ссылки l.

◆ bankersRounding< double >()

template<>
int bankersRounding< double > ( const double &  inValue)
inline

См. определение в файле OurMath.h строка 117

117  {
118  double maxValue = std::numeric_limits<int>::max();
119  assert(maxValue - 6755399441055744.0 >= inValue);
120  union Cast {
121  double d;
122  long l;
123  };
124  volatile Cast c;
125  c.d = inValue + 6755399441055744.0;
126  return c.l;
127 }

Перекрестные ссылки l.

Переменные

◆ stru_5C6E00

right
GLdouble GLdouble right
Definition: SDL_opengl_glext.h:6106
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8586
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
x
EGLSurface EGLint x
Definition: SDL_egl.h:1596
fixpoint_mul
__int64 fixpoint_mul(int a1, int a2)
Definition: OurMath.cpp:138
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
l
uint64_t l
Definition: intreadwrite.h:1
value
EGLSyncKHR EGLint EGLint * value
Definition: SDL_egl.h:899
val
GLuint GLfloat * val
Definition: SDL_opengl_glext.h:1495
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4586
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11096
v2
GLfloat GLfloat GLfloat v2
Definition: SDL_opengl_glext.h:695
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4586
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4586
left
GLint left
Definition: SDL_opengl_glext.h:1952