World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
IndoorCameraD3D.cpp
См. документацию.
2 
3 #include <cstdlib>
4 
5 #include "Engine/Engine.h"
6 #include "Engine/LOD.h"
7 #include "Engine/Log.h"
8 #include "Engine/OurMath.h"
9 
10 #include "Engine/Graphics/Indoor.h"
12 
13 #include "Engine/Graphics/stru9.h"
14 
15 // calculates FOV (Field of View) angle in radians for IndoorCamera::Initialize
16 // and BLVRenderParams::Reset
17 float _calc_fov(int viewport_width, int angle_degree) {
18  return viewport_width * 0.5 / tan(angle_degree / 2 * 0.01745329) + 0.5;
19 }
20 
22 
23 //----- (004361EF) --------------------------------------------------------
25  this->field_108 = 0.0;
26  this->field_138 = 0.0;
27  this->field_168 = 0.0;
28  this->field_198 = 0.0;
29  this->field_1C8 = 0.0;
30  this->field_1F8 = 0.0;
31  this->field_228 = 0.0;
32  this->field_258 = 0.0;
33  this->field_288 = 0.0;
34  this->field_2B8 = 0.0;
35  this->field_2E8 = 0.0;
36  this->field_2BC = 0.0;
37  this->field_2C0 = 0.0;
38  this->field_2C4 = 0.0;
39  this->field_318 = 0.0;
40  this->field_2EC = 0.0;
41  this->field_2F0 = 0.0;
42  this->field_2F4 = 0.0;
43  this->field_348 = 0.0;
44  this->field_31C = 0.0;
45  this->field_320 = 0.0;
46  this->field_324 = 0.0;
47  this->field_378 = 0.0;
48  this->field_34C = 0.0;
49  this->field_350 = 0.0;
50  this->field_354 = 0.0;
51  for (uint i = 0; i < 16384; ++i) {
52  list_0037C[i].field_0 = 0;
53  list_0037C[i].flt_30 = 0.0f;
54  }
55  list_0037C_size = 0;
56  for (uint i = 0; i < 256; ++i) list_E0380[i].mm7__vector_000004_size = 0;
57  list_E0380_size = 0;
58 }
59 
60 //----- (0043643E) --------------------------------------------------------
64  else
65  return 16192.0;
66 }
67 
68 //----- (004364C5) --------------------------------------------------------
70  unsigned int uNumVertices,
71  RenderVertexSoft *pOutVertices,
72  LightsData *a5) {
73  for (uint i = 0; i < uNumVertices; ++i) {
74  pOutVertices[i].vWorldPosition.x = pVertices[i].vWorldPosition.x;
75  pOutVertices[i].vWorldPosition.y = pVertices[i].vWorldPosition.y;
76  pOutVertices[i].vWorldPosition.z = pVertices[i].vWorldPosition.z;
77 
78  pOutVertices[i].u = pVertices[i].u + a5->pDeltaUV[0];
79  pOutVertices[i].v = pVertices[i].v + a5->pDeltaUV[1];
80  }
81  ViewTransform(pOutVertices, uNumVertices);
82 }
83 
84 //----- (0043669D) --------------------------------------------------------
85 
86 // remove this func ??
87 
89  int x, int y, int z, fixed *pOutX, fixed *pOutY, fixed *pOutZ,
90  bool do_clip_test) {
91  int to_x = x - pIndoorCameraD3D->vPartyPos.x;
92  int to_y = y - pIndoorCameraD3D->vPartyPos.y;
93  int to_z = (z - pIndoorCameraD3D->vPartyPos.z) << 16;
94 
96  int v14 = (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_cosine_y) +
97  (unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_sine_y);
98 
99 
102 
103  *pOutY = fixed::Raw((unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_cosine_y) -
104  (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_sine_y));
105 
106  *pOutZ = fixed::Raw(fixpoint_mul(to_z, pIndoorCameraD3D->int_cosine_x) /*-*/+
108 
109  } else {
110  *pOutX = fixed::Raw((unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_cosine_y) +
111  (unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_sine_y));
112 
113  *pOutY = fixed::Raw((unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_cosine_y) -
114  (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_sine_y));
115 
116  *pOutZ = fixed::Raw(to_z);
117  }
118 
119  if (!do_clip_test) return false;
120 
121  // return *pOutX >= fixpoint_from_int(4, 0) &&
122  // *pOutX <= fixpoint_from_int(8000, 0);
123  return *pOutX >= fixed::FromFloat(this->GetNearClip()) &&
124  *pOutX <= fixed::FromFloat(this->GetFarClip());
125 }
126 
127 //----- (00436455) --------------------------------------------------------
129  RenderVertexSoft v; // [sp+8h] [bp-30h]@1
130 
131  //----- (0043648F) --------------------------------------------------------
132  auto Vec3_short__to_RenderVertexSoft = [](RenderVertexSoft *_this,
133  Vec3_short_ *a2) -> void {
134  _this->flt_2C = 0.0;
135 
136  _this->vWorldPosition.x = a2->x;
137  _this->vWorldPosition.y = a2->y;
138  _this->vWorldPosition.z = a2->z;
139  };
140 
141  Vec3_short__to_RenderVertexSoft(&v,
142  &pIndoor->pVertices[*pFace->pVertexIDs]);
143  return is_face_faced_to_camera(pFace, &v);
144 }
145 
148  if (pODMRenderParams) {
149  return pODMRenderParams->near_clip;
150  }
151 
152  return 4.0f;
153  } else {
154  // return (double)pBLVRenderParams->fov_rad_fixpoint / 65536.0f;
155  return 4.0f;
156  }
157 }
158 
161  if (pODMRenderParams) {
162  return pODMRenderParams->far_clip;
163  }
164 
165  return (float)0x2000;
166  } else {
167  return 16192.0f;
168  }
169 }
170 
171 // ViewTransformAndClipTest
172 bool IndoorCameraD3D::ViewClip(int x, int y, int z, int *transformed_x,
173  int *transformed_y, int *transformed_z,
174  bool dont_show) {
175  this->ViewTransform(x, y, z, transformed_x, transformed_y, transformed_z);
176 
177  if (dont_show) {
178  return false;
179  }
180  return *transformed_x >= this->GetNearClip() &&
181  *transformed_x <= this->GetFarClip();
182 }
183 
184 void IndoorCameraD3D::ViewTransform(int x, int y, int z, int *transformed_x,
185  int *transformed_y, int *transformed_z) {
187  v.vWorldPosition.x = x;
188  v.vWorldPosition.y = y;
189  v.vWorldPosition.z = z;
190 
191  this->ViewTransform(&v, 1);
192  if (transformed_x) {
193  *transformed_x = floorf(v.vWorldViewPosition.x + 0.5f);
194  }
195 
196  if (transformed_y) {
197  *transformed_y = floorf(v.vWorldViewPosition.y + 0.5f);
198  }
199 
200  if (transformed_z) {
201  *transformed_z = floorf(v.vWorldViewPosition.z + 0.5f);
202  }
203 }
204 
205 //----- (00436523) --------------------------------------------------------
206 void IndoorCameraD3D::ViewTransform(RenderVertexSoft *a1a, unsigned int uNumVertices) {
207  for (uint i = 0; i < uNumVertices; ++i) {
208  RenderVertexSoft *a1 = &a1a[i];
209 
210  double vCamToVertexX = a1->vWorldPosition.x - (double)pIndoorCameraD3D->vPartyPos.x;
211  double vCamToVertexY = a1->vWorldPosition.y - (double)pIndoorCameraD3D->vPartyPos.y;
212  double vCamToVertexZ = a1->vWorldPosition.z - (double)pIndoorCameraD3D->vPartyPos.z;
213 
215  double v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
216 
217  a1->vWorldViewPosition.x = v5 * fRotationXCosine /*+*/ - fRotationXSine * vCamToVertexZ;
218  a1->vWorldViewPosition.y = fRotationYCosine * vCamToVertexY - fRotationYSine * vCamToVertexX;
219  a1->vWorldViewPosition.z = fRotationXCosine * vCamToVertexZ /*-*/ + v5 * fRotationXSine;
220  } else {
221  a1->vWorldViewPosition.x = fRotationYSine * vCamToVertexY + fRotationYCosine * vCamToVertexX;
222  a1->vWorldViewPosition.y = fRotationYCosine * vCamToVertexY - fRotationYSine * vCamToVertexX;
223  a1->vWorldViewPosition.z = vCamToVertexZ;
224  }
225  }
226 
227  // this tranforms to odd axis
228  // x would usually be z (depth)
229  // y would usually be x
230  // z would usually be y
231 
232  // above is corrected back to normal during projection - sort later
233  // invert xrotation in calc rotations rather than transform
234 }
235 
236 //----- (00436932) --------------------------------------------------------
238  Vec3_float_ *a3, Vec3_float_ *a4) {
239  switch ((PolygonType)polyType) {
240  case POLYGON_VerticalWall: {
241  a4->x = -a2->y;
242  a4->y = a2->x;
243  a4->z = 0.0;
244 
245  a3->x = 0.0;
246  a3->y = 0.0;
247  a3->z = 1.0f;
248  }
249  return true;
250 
251  case POLYGON_Floor:
252  case POLYGON_Ceiling: {
253  a4->x = 1.0;
254  a4->y = 0.0;
255  a4->z = 0.0;
256 
257  a3->x = 0.0;
258  a3->y = 1.0;
259  a3->z = 0.0;
260  }
261  return true;
262 
265  if (fabs(a2->z) < 0.70811361) {
266  a4->x = -a2->y;
267  a4->y = a2->x;
268  a4->z = 0.0;
269  a4->Normalize();
270 
271  a3->x = 0.0;
272  a3->y = 0.0;
273  a3->z = 1.0;
274  } else {
275  a4->x = 1.0;
276  a4->y = 0.0;
277  a4->z = 0.0;
278 
279  a3->x = 0.0;
280  a3->y = 1.0;
281  a3->z = 0.0;
282  }
283  }
284  return true;
285 
286  default:
287  return false;
288  }
289 }
290 
291 //----- (00438258) --------------------------------------------------------
293  RenderVertexSoft *a2) {
294  if (pFace->Portal()) return false;
295 
296  // really strange cull; dot(to_cam, normal) < 0 means we see the BACK face,
297  // not font %_%
298  if ((a2->vWorldPosition.z - (double)pIndoorCameraD3D->vPartyPos.z) *
299  (double)pFace->pFacePlane_old.vNormal.z +
300  (a2->vWorldPosition.y - (double)pIndoorCameraD3D->vPartyPos.y) *
301  (double)pFace->pFacePlane_old.vNormal.y +
302  (a2->vWorldPosition.x - (double)pIndoorCameraD3D->vPartyPos.x) *
303  (double)pFace->pFacePlane_old.vNormal.x <
304  0.0)
305  return false;
306 
307  return true;
308 }
309 
310 //----- (00437AB5) --------------------------------------------------------
312  signed int sStartDiffuse,
313  RenderVertexSoft *pLineEnd,
314  signed int sEndDiffuse,
315  unsigned int uOutNumVertices,
316  float z_stuff) {
317  RenderVertexSoft a1[20]; // [sp+8h] [bp-7C4h]@6
318  RenderVertexSoft pVertices[20]; // [sp+3C8h] [bp-404h]@2
319  RenderVertexD3D3 v24[2]; // [sp+788h] [bp-44h]@11
320 
321  // if ( render->pRenderD3D )
322  //{
323  for (uint i = 0; i < 20; i++) pVertices[i].flt_2C = 0.0;
324  if ((char)uOutNumVertices) {
325  pVertices[0].vWorldViewProjX = pLineBegin->vWorldViewProjX;
326  pVertices[0].vWorldViewProjY = pLineBegin->vWorldViewProjY;
327 
328  pVertices[1].vWorldViewProjX = pLineEnd->vWorldViewProjX;
329  pVertices[1].vWorldViewProjY = pLineEnd->vWorldViewProjY;
330  v24[0].specular = 0;
331  v24[0].pos.x = pVertices[0].vWorldViewProjX;
332  v24[0].pos.y = pVertices[0].vWorldViewProjY;
333  v24[0].pos.z = 0.001 - z_stuff;
334  v24[0].diffuse = sStartDiffuse;
335  v24[0].rhw = 0.001;
336  v24[0].texcoord.x = 0.0;
337  v24[0].texcoord.y = 0.0;
338 
339  v24[1].pos.x = pVertices[1].vWorldViewProjX;
340  v24[1].pos.y = pVertices[1].vWorldViewProjY;
341  v24[1].diffuse = sEndDiffuse;
342  v24[1].pos.z = 0.001 - z_stuff;
343  v24[1].specular = 0;
344  v24[1].rhw = 0.001;
345  v24[1].texcoord.x = 0.0;
346  v24[1].texcoord.y = 0.0;
347  // v19 = render->pRenderD3D->pDevice;
348  render->DrawLines(v24, 2);
349  return;
350  }
351  for (uint i = 0; i < 20; i++) a1[i].flt_2C = 0.0;
352  uOutNumVertices = 2;
353  a1[0].vWorldPosition.x = pLineBegin->vWorldPosition.x;
354  a1[0].vWorldPosition.y = pLineBegin->vWorldPosition.y;
355  a1[0].vWorldPosition.z = pLineBegin->vWorldPosition.z;
356  a1[1].vWorldPosition.x = pLineEnd->vWorldPosition.x;
357  a1[1].vWorldPosition.y = pLineEnd->vWorldPosition.y;
358  a1[1].vWorldPosition.z = pLineEnd->vWorldPosition.z;
359  if (CalcPortalShape(a1, &uOutNumVertices, pVertices,
361  0) != 1 ||
362  (signed int)uOutNumVertices >= 2) {
364  Project(pVertices, 2, 0);
365  v24[0].specular = 0;
366  v24[0].pos.x = pVertices[0].vWorldViewProjX;
367  v24[0].pos.y = pVertices[0].vWorldViewProjY;
368  v24[0].pos.z = 0.001 - z_stuff;
369  v24[0].diffuse = sStartDiffuse;
370  v24[0].rhw = 0.001;
371  v24[0].texcoord.x = 0.0;
372  v24[0].texcoord.y = 0.0;
373 
374  v24[1].pos.x = pVertices[1].vWorldViewProjX;
375  v24[1].pos.y = pVertices[1].vWorldViewProjY;
376  v24[1].diffuse = sEndDiffuse;
377  v24[1].pos.z = 0.001 - z_stuff;
378  v24[1].specular = 0;
379  v24[1].rhw = 0.001;
380  v24[1].texcoord.x = 0.0;
381  v24[1].texcoord.y = 0.0;
382  // v19 = render->pRenderD3D->pDevice;
383  render->DrawLines(v24, 2);
384  return;
385  }
386  //}
387 }
388 
389 //----- (00437A55) --------------------------------------------------------
391  unsigned int uNumLines, int uDiffuse,
392  float z_stuff) {
393  for (int i = 0; i < uNumLines - 1; ++i)
394  render->do_draw_debug_line_d3d(&pLineVertices[i], uDiffuse,
395  &pLineVertices[i + 1], uDiffuse,
396  z_stuff);
397  render->do_draw_debug_line_d3d(&pLineVertices[uNumLines - 1], uDiffuse,
398  pLineVertices, uDiffuse, z_stuff);
399 }
400 
401 //----- (004379EE) --------------------------------------------------------
403  unsigned int uNumVertices,
404  unsigned int uDiffuse, float a5) {
405  if (!uNumVertices) return;
406  if ((signed int)(uNumVertices - 1) > 0) {
407  for (uint i = 0; i < uNumVertices - 1; i++)
408  do_draw_debug_line_sw(&a2[i], uDiffuse, &a2[i + 1], uDiffuse, 0,
409  a5);
410  }
411  do_draw_debug_line_sw(&a2[uNumVertices - 1], uDiffuse, a2, uDiffuse, 0, a5);
412 }
413 
415  Assert(pFace->uNumVertices <= 32);
416 
417  RenderVertexSoft sw[32];
418  for (uint i = 0; i < pFace->uNumVertices; ++i) {
419  sw[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x;
420  sw[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y;
421  sw[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z;
422  }
423  ViewTransform(sw, pFace->uNumVertices);
424  Project(sw, pFace->uNumVertices, 0);
425 
426  RenderVertexD3D3 v[32];
427  for (uint i = 0; i < pFace->uNumVertices; ++i) {
428  v[i].pos.x = sw[i].vWorldViewProjX;
429  v[i].pos.y = sw[i].vWorldViewProjY;
430  v[i].pos.z = 1.0 - 1.0 / (sw[i].vWorldViewPosition.x * 0.061758894);
431  v[i].rhw = 1.0 / sw[i].vWorldViewPosition.x;
432  v[i].diffuse = 0x80F020F0;
433  v[i].specular = 0;
434  // v[i].texcoord.x = pFace->pVertexUIDs[i] /
435  // (double)pTex->uTextureWidth; v[i].texcoord.y = pFace->pVertexUIDs[i] /
436  // (double)pTex->uTextureHeight;
437  v[i].texcoord.x = 0;
438  v[i].texcoord.y = 0;
439  }
440 
441  render->DrawFansTransparent(v, pFace->uNumVertices);
442 }
443 
444 //----- (00437906) --------------------------------------------------------
446  unsigned int uDiffuse) {
447  static RenderVertexSoft static_sub_437906_array_50CDD0[64];
448  static bool __init_flag1 = false;
449  if (!__init_flag1) {
450  __init_flag1 = true;
451 
452  for (uint i = 0; i < 64; ++i)
453  static_sub_437906_array_50CDD0[i].flt_2C = 0.0f;
454  }
455  if (pFace->uNumVertices) {
456  for (uint i = 0; i < pFace->uNumVertices; i++) {
457  static_sub_437906_array_50CDD0[i].vWorldPosition.x =
458  (double)pIndoor->pVertices[pFace->pVertexIDs[i]].x;
459  static_sub_437906_array_50CDD0[i].vWorldPosition.y =
460  (double)pIndoor->pVertices[pFace->pVertexIDs[i]].y;
461  static_sub_437906_array_50CDD0[i].vWorldPosition.z =
462  (double)pIndoor->pVertices[pFace->pVertexIDs[i]].z;
463  static_sub_437906_array_50CDD0[i].u = (double)pFace->pVertexUIDs[i];
464  static_sub_437906_array_50CDD0[i].v = (double)pFace->pVertexVIDs[i];
465  }
466  }
467  if (engine->config->debug_portal_outlines)
468  debug_outline_sw(static_sub_437906_array_50CDD0, pFace->uNumVertices,
469  uDiffuse, 0.0);
470 }
471 // 50D9D0: using guessed type char static_sub_437906_byte_50D9D0_init_flag;
472 
473 //----- (004378BA) --------------------------------------------------------
475  Matrix3x3_float_ *m_out) {
476  float sum;
477 
478  for (uint row = 0; row < 3; row++) {
479  for (uint col = 0; col < 3; col++) {
480  sum = 0;
481  for (int index = 0; index < 3; index++)
482  sum += ma->v[row][index] * mb->v[index][col];
483  m_out->v[row][col] = sum;
484  }
485  }
486 }
487 
488 //----- (004376E7) --------------------------------------------------------
490  Matrix3x3_float_ m1; // [sp+10h] [bp-B8h]@1
491  Matrix3x3_float_ m2; // [sp+34h] [bp-94h]@1
492  Matrix3x3_float_ m3; // [sp+58h] [bp-70h]@1
493  Matrix3x3_float_ m4; // [sp+7Ch] [bp-4Ch]@1
494  Matrix3x3_float_ m5; // [sp+A0h] [bp-28h]@1
495 
496  // RotationZ(0) - roll
497  m5._11 = cosf(0);
498  m5._12 = sinf(0);
499  m5._13 = 0;
500  m5._21 = -sinf(0);
501  m5._22 = cosf(0);
502  m5._23 = 0;
503  m5._31 = 0;
504  m5._32 = 0;
505  m5._33 = 1;
506 
507  float cos_x1 = fRotationXCosine, sin_x1 = fRotationXSine;
508  // RotationX(x) - pitch
509  m4._11 = 1;
510  m4._12 = 0;
511  m4._13 = 0;
512  m4._21 = 0;
513  m4._22 = cos_x1;
514  m4._23 = sin_x1;
515  m4._31 = 0;
516  m4._32 = -sin_x1;
517  m4._33 = cos_x1;
518 
519  float cos_y1 = fRotationYCosine, sin_y1 = fRotationYSine;
520  // RotationY(some_angle) - yaw
521  m3._11 = cos_y1;
522  m3._12 = 0;
523  m3._13 = -sin_y1;
524  m3._21 = 0;
525  m3._22 = 1;
526  m3._23 = 0;
527  m3._31 = sin_y1;
528  m3._32 = 0;
529  m3._33 = cos_y1;
530 
531  MatrixMultiply(&m5, &m3, &m1);
532  MatrixMultiply(&m4, &m1, &m2);
533 
534  for (uint i = 0; i < 3; ++i) {
535  field_4[0].v[i] = m2.v[1][i];
536  field_4[1].v[i] = m2.v[0][i];
537  field_4[2].v[i] = m2.v[2][i];
538  }
539 
540  // indoor outdoor fov different
541  fov = 0.8814736;
542  inv_fov = 1.0 / fov;
543 
544  fov_x = (double)pViewport->uScreenWidth * fov;
545  fov_y = (double)pViewport->uScreenHeight * fov;
546 
547  fov = fov_y;
548  if (fov_x > fov) fov = fov_x;
549 
551  screenCenterY = (double)pViewport->uScreenCenterY - pViewport->uScreen_TL_Y; //- pViewport->uScreen_TL_Y);
552 }
553 
554 //----- (00437691) --------------------------------------------------------
556  IndoorCameraD3D_Vec3 *pOut) {
557  pOut->y = field_4[1].x * pVector->x + field_4[0].x * pVector->y +
558  field_4[2].x * pVector->z;
559  pOut->z = field_4[1].y * pVector->x + field_4[0].y * pVector->y +
560  field_4[2].y * pVector->z;
561  pOut->x = field_4[1].z * pVector->x + field_4[0].z * pVector->y +
562  field_4[2].z * pVector->z;
563 }
564 
565 //----- (00437607) --------------------------------------------------------
567  IndoorCameraD3D_Vec4 *a2) {
568  double v4; // st7@1
569  IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1
570 
571  v8.x = (double)pIndoorCameraD3D->vPartyPos.x;
572  v8.y = (double)pIndoorCameraD3D->vPartyPos.y;
573  v8.z = (double)pIndoorCameraD3D->vPartyPos.z;
574  Vec3Transform(a1, a2);
575 
576  v4 = v8.x * a2->x + v8.y * a2->y + v8.z * a2->z;
577  a2->dot = v4 + 0.000099999997;
578 }
579 
580 //----- (004374E8) --------------------------------------------------------
582  // IndoorCameraD3D *v1; // esi@1
583  // double v2; // st7@1
584  double v3; // st7@1
585  // double v4; // st7@1
586  double v5; // st7@1
587  // double v6; // st7@1
588  IndoorCameraD3D_Vec3 v7; // [sp+Ch] [bp-24h]@1
589  // float v8; // [sp+10h] [bp-20h]@1
590  // float v9; // [sp+14h] [bp-1Ch]@1
591  // float v10; // [sp+18h] [bp-18h]@1
592  // float v11; // [sp+1Ch] [bp-14h]@1
593  // float v12; // [sp+20h] [bp-10h]@1
594  // int v13; // [sp+2Ch] [bp-4h]@1
595 
596  // v1 = this;
597  // IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v7);
598  // v2 = 2.0 / inv_fov;
599  // v13 = 0;
600  v3 = atan(2.0 / inv_fov * fov / fov_x);
601  // v12 = v3;
602  // v11 = sin(v3);
603  // v4 = cos(v3);
604  v7.x = -sin(v3);
605  v7.y = 0.0;
606  v7.z = cos(v3);
608 
609  v7.x = sin(v3);
611 
612  v5 = atan(2.0 / inv_fov * fov / (fov_y + 0.5));
613  // v12 = v5;
614  // v11 = sin(v5);
615  // v6 = cos(v5);
616  v7.y = sin(v5);
617  v7.x = 0.0;
618  v7.z = cos(v5);
620 
621  v7.y = -sin(v5);
623 
624  // v13 = -1;
625  // IndoorCameraD3D_Vec3::dtor(&v7);
626 }
627 
628 //----- (00437376) --------------------------------------------------------
630  unsigned int *pOutNumVertices) {
631  double v6; // st7@3
632  int previous; // esi@6
633  int current; // ebx@8
634  int next; // eax@8
635  int v13; // eax@15
636  signed int v14; // ebx@17
637  RenderVertexSoft v18; // [sp+Ch] [bp-34h]@2
638  // signed int thisb; // [sp+48h] [bp+8h]@6
639  bool result; // [sp+4Fh] [bp+Fh]@5
640 
641  memcpy(&v18, a2, sizeof(v18));
642  result = false;
643  memcpy(&a2[*pOutNumVertices], a2, sizeof(a2[*pOutNumVertices]));
644  memcpy(&a2[*pOutNumVertices + 1], &a2[1], sizeof(a2[*pOutNumVertices + 1]));
645 
646  if ((signed int)*pOutNumVertices <= 3 ||
647  (((v18.vWorldPosition.z - (double)pIndoorCameraD3D->vPartyPos.z) *
648  thisa->face_plane.vNormal.z +
649  (v18.vWorldPosition.y - (double)pIndoorCameraD3D->vPartyPos.y) *
650  thisa->face_plane.vNormal.y +
651  (v18.vWorldPosition.x - (double)pIndoorCameraD3D->vPartyPos.x) *
652  thisa->face_plane.vNormal.x <
653  0.0)
654  ? (v6 = 1.0)
655  : (v6 = -1.0),
656  (signed int)*pOutNumVertices <= 0))
657  return 0;
658 
659  for (int i = 1; i - 1 < (signed int)*pOutNumVertices; i++) {
660  current = i;
661  next = i + 1;
662 
663  previous = i - 1;
664  if (previous >= (signed int)*pOutNumVertices)
665  previous -= *pOutNumVertices;
666 
667  if (current >= (signed int)*pOutNumVertices)
668  current -= *pOutNumVertices;
669 
670  if (next >= (signed int)*pOutNumVertices) next -= *pOutNumVertices;
671 
672  if (-0.009999999776482582 <
673  ((a2[current].vWorldViewProjX - a2[previous].vWorldViewProjX) *
674  (a2[next].vWorldViewProjY - a2[previous].vWorldViewProjY) -
675  (a2[current].vWorldViewProjY - a2[previous].vWorldViewProjY) *
676  (a2[next].vWorldViewProjX - a2[previous].vWorldViewProjX)) *
677  v6) {
678  v13 = next;
679  if (next >= (signed int)*pOutNumVertices)
680  v13 = next - *pOutNumVertices;
681 
682  if (v13 < (signed int)*pOutNumVertices) {
683  for (v14 = v13; v14 < (signed int)*pOutNumVertices; ++v14)
684  memcpy(&a2[v14], &a2[v14 + 1], sizeof(a2[v14]));
685  }
686  result = true;
687  --*pOutNumVertices;
688  }
689  }
690  if (result)
691  return true;
692  else
693  return false;
694 }
695 
696 //----- (00437285) --------------------------------------------------------
698  unsigned int *pOutNumVertices,
700  IndoorCameraD3D_Vec4 *CameraFrustrum,
701  signed int NumFrustumPlanes, char DebugLines,
702  int _unused) {
703  // NumFrustumPlanes usually 4 - top, bottom, left, right - near and far done elsewhere
704  // DebugLines 0 or 1 - 1 when debug lines
705 
706  // char *v8; // eax@2
707  // signed int v9; // ecx@2
708  // bool result; // eax@5
709  // int MinVertsAllowed; // ecx@5
710  // signed int v12; // ecx@6
711  // char *v13; // esi@6
712  RenderVertexSoft *v14; // eax@8
713  RenderVertexSoft *v15; // edx@8
714  Vec3_float_ FrustumPlaneVec; // [sp+18h] [bp-3Ch]@12
715  // float v17; // [sp+44h] [bp-10h]@1
716  // int v18; // [sp+48h] [bp-Ch]@5
717  // stru9 *thisa; // [sp+4Ch] [bp-8h]@1
718  int VertsAdjusted = 0; // [sp+53h] [bp-1h]@5
719  // bool a6a; // [sp+70h] [bp+1Ch]@5
720 
721  // v17 = 0.0;
722  // thisa = engine->pStru9Instance;
723 
724  static RenderVertexSoft sr_vertices_50D9D8[64];
725 
726  // result = 0;
727  // VertsAdjusted = 0;
728  int MinVertsAllowed = 2 * (DebugLines == 0) + 1; // 3 normally 1 for debuglines
729  // a6a = 0;
730  // v18 = MinVertsAllowed;
731  if (NumFrustumPlanes <= 0) return false;
732 
733  // v12 = *pOutNumVertices;
734  // v13 = (char *)&a4->y;
735 
736  // while ( 1 )
737  for (uint i = 0; i < NumFrustumPlanes; ++i) { // cycle through left,right, top, bottom planes
738  if (i % 2) {
739  v14 = pInVertices;
740  v15 = sr_vertices_50D9D8;
741  } else {
742  v15 = pInVertices;
743  v14 = sr_vertices_50D9D8;
744  }
745  if (i == NumFrustumPlanes - 1) v14 = pVertices;
746  FrustumPlaneVec.x = CameraFrustrum[i].x;
747  FrustumPlaneVec.y = CameraFrustrum[i].y;
748  FrustumPlaneVec.z = CameraFrustrum[i].z;
749 
750  engine->pStru9Instance->AdjustVerticesToFrustumPlane(
751  v15, *pOutNumVertices, v14, pOutNumVertices, &FrustumPlaneVec, CameraFrustrum[i].dot,
752  (char *)&VertsAdjusted, _unused);
753 
754  // v12 = *pOutNumVertices;
755  if (*pOutNumVertices < MinVertsAllowed) {
756  *pOutNumVertices = 0;
757  return true;
758  }
759  // result = a6a;
760  // v13 += 24;
761  // if (++i >= FrustumPlanes)
762  //
763  }
764  return VertsAdjusted;
765 }
766 
767 //----- (004371C3) --------------------------------------------------------
768 bool IndoorCameraD3D::_4371C3(RenderVertexSoft *pVertices, // function appears unsued
769  unsigned int *pOutNumVertices, int _unused) {
770  __debugbreak();
771 
772  // char *v4; // eax@2
773  // signed int v5; // ecx@2
774  RenderVertexSoft *v6; // esi@5
775  unsigned int *v7; // edi@5
776  char *v8; // ecx@6
777  int v9; // eax@6
778  IndoorCameraD3D *thisa; // [sp+0h] [bp-Ch]@1
779  signed int v12; // [sp+4h] [bp-8h]@5
780  unsigned int pVerticesa; // [sp+14h] [bp+8h]@6
781  unsigned int pOutNumVerticesa; // [sp+18h] [bp+Ch]@6
782 
783  thisa = this;
784 
785  static RenderVertexSoft static_4371C3_array_50E5E0[64];
786  static bool __init_flag1 = false;
787  if (!__init_flag1) {
788  __init_flag1 = true;
789 
790  for (uint i = 0; i < 64; ++i)
791  static_4371C3_array_50E5E0[i].flt_2C = 0.0f;
792  }
793 
794  v12 = 0;
795  v6 = pVertices;
796  v7 = pOutNumVertices;
797  if ((int)*pOutNumVertices > 0) {
798  pOutNumVerticesa =
799  (char *)static_4371C3_array_50E5E0 - (char *)pVertices;
800  pVerticesa = (char *)&static_4371C3_array_50E5E0[0].vWorldViewProjY -
801  (char *)pVertices;
802  v8 = (char *)&static_4371C3_array_50E5E0[0].vWorldPosition.y;
803  v9 = (int)&v6->vWorldPosition.z;
804  do {
805  ++v12;
806  *((int *)v8 - 1) = *(int *)(v9 - 8);
807  *(int *)v8 = *(int *)(v9 - 4);
808  v8 += 48;
809  *(float *)(pOutNumVerticesa + v9) = *(float *)v9;
810  *(float *)(pVerticesa + v9) = *(float *)(v9 + 28);
811  *(float *)((char *)&static_4371C3_array_50E5E0[0]._rhw -
812  (char *)v6 + v9) = *(float *)(v9 + 32);
813  v9 += 48;
814  } while (v12 < (signed int)*v7);
815  }
816  return CalcPortalShape(static_4371C3_array_50E5E0, v7, v6,
818  _unused);
819 }
820 // 50F1E0: using guessed type char static_sub_4371C3_byte_50F1E0_init_flags;
821 
822 //----- (00437143) --------------------------------------------------------
823 void IndoorCameraD3D::_437143(unsigned int uNumInVertices, // lightmap project
824  RenderVertexSoft *pOutVertices,
825  RenderVertexSoft *pInVertices,
826  signed int *pOutNumVertices) {
827  double v9; // st7@3
828 
829  uint i = 0;
830 
831  for (; i < uNumInVertices; ++i) {
832  pInVertices[i]._rhw =
833  1.0 / (pInVertices[i].vWorldViewPosition.x + 0.0000001);
834  memcpy(&pOutVertices[i], &pInVertices[i], sizeof(pOutVertices[i]));
835  v9 = (double)pODMRenderParams->int_fov_rad * pInVertices[i]._rhw;
836  pOutVertices[i].vWorldViewProjX =
837  (double)pViewport->uScreenCenterX -
838  v9 * pInVertices[i].vWorldViewPosition.y;
839  pOutVertices[i].vWorldViewProjY =
840  (double)pViewport->uScreenCenterY -
841  v9 * pInVertices[i].vWorldViewPosition.z;
842  }
843  *pOutNumVertices = i;
844  return;
845 }
846 
847 //----- (00436F09) --------------------------------------------------------
849  int uNumInVertices,
850  RenderVertexSoft *pOutVertices,
851  unsigned int *pOutNumVertices) {
852  bool current_vertices_flag;
853  bool next_vertices_flag;
854  double t;
855  signed int depth_num_vertices;
856 
857  memcpy(&pInVertices[uNumInVertices], &pInVertices[0],
858  sizeof(pInVertices[uNumInVertices]));
859  depth_num_vertices = 0;
860  current_vertices_flag = false;
861  if (pInVertices[0].vWorldViewPosition.x >= pIndoorCameraD3D->GetFarClip())
862  current_vertices_flag =
863  true; //настоящая вершина больше границы видимости
864  if ((signed int)uNumInVertices <= 0) return;
865  // check for far clip plane(проверка по дальней границе)
866  //
867  // v3.__________________. v0
868  // | |
869  // | |
870  // | |
871  // ----------------------- 8192.0(far_clip - 0x2000)
872  // | |
873  // .__________________.
874  // v2 v1
875 
876  for (uint i = 0; i < uNumInVertices; ++i) {
877  next_vertices_flag = pInVertices[i + 1].vWorldViewPosition.x >=
879  if (current_vertices_flag ^
880  next_vertices_flag) { // одна из граней за границей видимости
881  if (next_vertices_flag) { // следующая вершина больше границы
882  // видимости(настоящая вершина меньше
883  // границы видимости) - v3
884  // t = far_clip - v2.x / v3.x - v2.x (формула получения точки
885  // пересечения отрезка с плоскостью)
887  pInVertices[i].vWorldViewPosition.x) /
888  (pInVertices[i].vWorldViewPosition.x -
889  pInVertices[i + 1].vWorldViewPosition.x);
890  pOutVertices[depth_num_vertices].vWorldViewPosition.x =
892  // New_y = v2.y + (v3.y - v2.y)*t
893  pOutVertices[depth_num_vertices].vWorldViewPosition.y =
894  pInVertices[i].vWorldViewPosition.y +
895  (pInVertices[i].vWorldViewPosition.y -
896  pInVertices[i + 1].vWorldViewPosition.y) *
897  t;
898  // New_z = v2.z + (v3.z - v2.z)*t
899  pOutVertices[depth_num_vertices].vWorldViewPosition.z =
900  pInVertices[i].vWorldViewPosition.z +
901  (pInVertices[i].vWorldViewPosition.z -
902  pInVertices[i + 1].vWorldViewPosition.z) *
903  t;
904  pOutVertices[depth_num_vertices].u =
905  pInVertices[i].u +
906  (pInVertices[i].u - pInVertices[i + 1].u) * t;
907  pOutVertices[depth_num_vertices].v =
908  pInVertices[i].v +
909  (pInVertices[i].v - pInVertices[i + 1].v) * t;
910  pOutVertices[depth_num_vertices]._rhw =
911  1.0 / pIndoorCameraD3D->GetFarClip();
912  } else { // настоящая вершина больше границы видимости(следующая
913  // вершина меньше границы видимости) - v0
914  // t = far_clip - v1.x / v0.x - v1.x
916  pInVertices[i].vWorldViewPosition.x) /
917  (pInVertices[i + 1].vWorldViewPosition.x -
918  pInVertices[i].vWorldViewPosition.x);
919  pOutVertices[depth_num_vertices].vWorldViewPosition.x =
921  // New_y = (v0.y - v1.y)*t + v1.y
922  pOutVertices[depth_num_vertices].vWorldViewPosition.y =
923  pInVertices[i].vWorldViewPosition.y +
924  (pInVertices[i + 1].vWorldViewPosition.y -
925  pInVertices[i].vWorldViewPosition.y) *
926  t;
927  // New_z = (v0.z - v1.z)*t + v1.z
928  pOutVertices[depth_num_vertices].vWorldViewPosition.z =
929  pInVertices[i].vWorldViewPosition.z +
930  (pInVertices[i + 1].vWorldViewPosition.z -
931  pInVertices[i].vWorldViewPosition.z) *
932  t;
933  pOutVertices[depth_num_vertices].u =
934  pInVertices[i].u +
935  (pInVertices[i + 1].u - pInVertices[i].u) * t;
936  pOutVertices[depth_num_vertices].v =
937  pInVertices[i].v +
938  (pInVertices[i + 1].v - pInVertices[i].v) * t;
939  pOutVertices[depth_num_vertices]._rhw =
940  1.0 / pIndoorCameraD3D->GetFarClip();
941  }
942  ++depth_num_vertices;
943  }
944  if (!next_vertices_flag) { // оба в границе видимости
945  memcpy(&pOutVertices[depth_num_vertices], &pInVertices[i + 1],
946  sizeof(pOutVertices[depth_num_vertices]));
947  depth_num_vertices++;
948  }
949  current_vertices_flag = next_vertices_flag;
950  }
951  if (depth_num_vertices >= 3)
952  *pOutNumVertices = depth_num_vertices;
953  else
954  *pOutNumVertices = 0;
955 }
956 
957 //----- (00436CDC) --------------------------------------------------------
959  int uNumInVertices,
960  RenderVertexSoft *pOutVertices,
961  unsigned int *pOutNumVertices) {
962  float nearclip = pIndoorCameraD3D->GetNearClip();
963 
964  double t; // st6@11
965  bool current_vertices_flag; // esi@2
966  bool next_vertices_flag; // [sp+Ch] [bp+8h]@7
967 
968  // check for near clip plane(проверка по ближней границе)
969  //
970  // v3.__________________. v0
971  // | |
972  // | |
973  // | |
974  // ----------------------- 8.0(near_clip - 8.0)
975  // | |
976  // .__________________.
977  // v2 v1
978 
979  int out_num_vertices = 0;
980 
981  if (uNumInVertices) {
982  memcpy(&pInVertices[uNumInVertices], &pInVertices[0],
983  sizeof(pInVertices[0]));
984  next_vertices_flag = false;
985  current_vertices_flag = false;
986  if (pInVertices[0].vWorldViewPosition.x <= nearclip)
987  current_vertices_flag = true;
988  for (uint i = 0; i < uNumInVertices; ++i) {
989  next_vertices_flag =
990  pInVertices[i + 1].vWorldViewPosition.x <= nearclip; //
991  if (current_vertices_flag ^ next_vertices_flag) { // XOR
992  if (next_vertices_flag) { // следующая вершина за ближней границей
993  // t = near_clip - v0.x / v1.x - v0.x (формула получения
994  // точки пересечения отрезка с плоскостью)
995  t = (nearclip - pInVertices[i].vWorldViewPosition.x) /
996  (pInVertices[i + 1].vWorldViewPosition.x -
997  pInVertices[i].vWorldViewPosition.x);
998  pOutVertices[out_num_vertices].vWorldViewPosition.x = nearclip;
999  pOutVertices[out_num_vertices].vWorldViewPosition.y =
1000  pInVertices[i].vWorldViewPosition.y +
1001  (pInVertices[i + 1].vWorldViewPosition.y -
1002  pInVertices[i].vWorldViewPosition.y) *
1003  t;
1004  pOutVertices[out_num_vertices].vWorldViewPosition.z =
1005  pInVertices[i].vWorldViewPosition.z +
1006  (pInVertices[i + 1].vWorldViewPosition.z -
1007  pInVertices[i].vWorldViewPosition.z) *
1008  t;
1009  pOutVertices[out_num_vertices].u =
1010  pInVertices[i].u +
1011  (pInVertices[i + 1].u - pInVertices[i].u) * t;
1012  pOutVertices[out_num_vertices].v =
1013  pInVertices[i].v +
1014  (pInVertices[i + 1].v - pInVertices[i].v) * t;
1015  pOutVertices[out_num_vertices]._rhw = 1.0 / 8.0;
1016  // pOutVertices[*pOutNumVertices]._rhw = 0.125;
1017  } else { // текущая вершина за ближней границей
1018  t = (nearclip - pInVertices[i].vWorldViewPosition.x) /
1019  (pInVertices[i].vWorldViewPosition.x -
1020  pInVertices[i + 1].vWorldViewPosition.x);
1021  pOutVertices[out_num_vertices].vWorldViewPosition.x = nearclip;
1022  pOutVertices[out_num_vertices].vWorldViewPosition.y =
1023  pInVertices[i].vWorldViewPosition.y +
1024  (pInVertices[i].vWorldViewPosition.y -
1025  pInVertices[i + 1].vWorldViewPosition.y) *
1026  t;
1027  pOutVertices[out_num_vertices].vWorldViewPosition.z =
1028  pInVertices[i].vWorldViewPosition.z +
1029  (pInVertices[i].vWorldViewPosition.z -
1030  pInVertices[i + 1].vWorldViewPosition.z) *
1031  t;
1032  pOutVertices[out_num_vertices].u =
1033  pInVertices[i].u +
1034  (pInVertices[i].u - pInVertices[i + 1].u) * t;
1035  pOutVertices[out_num_vertices].v =
1036  pInVertices[i].v +
1037  (pInVertices[i].v - pInVertices[i + 1].v) * t;
1038  pOutVertices[out_num_vertices]._rhw = 1.0 / nearclip;
1039  }
1040  ++out_num_vertices;
1041  }
1042  if (!next_vertices_flag) {
1043  memcpy(&pOutVertices[out_num_vertices], &pInVertices[i + 1],
1044  sizeof(pInVertices[i + 1]));
1045  // pOutVertices[out_num_vertices]._rhw = 1.0 /
1046  // (pInVertices[i].vWorldViewPosition.x + 0.0000001);
1047  out_num_vertices++;
1048  }
1049  current_vertices_flag = next_vertices_flag;
1050  }
1051  if (out_num_vertices >= 3)
1052  *pOutNumVertices = out_num_vertices;
1053  else
1054  *pOutNumVertices = 0;
1055  }
1056 }
1057 
1058 //----- (00436BB7) --------------------------------------------------------
1060  unsigned int uNumVertices,
1061  bool fit_into_viewport) {
1062  // double v7; // st7@7
1063  double v8; // st7@9
1064  double v9; // st6@10
1065  double v10; // st5@12
1066  double v11; // st7@16
1067  double v12; // st6@17
1068  double v13; // st5@19
1069  double v1;
1070  double v2;
1071 
1072  for (uint i = 0; i < uNumVertices; ++i) {
1073  /*if (_4D864C_force_sw_render_rules && engine->config->ForceLegacyProjection() ||
1074  uCurrentlyLoadedLevelType == LEVEL_Indoor) {
1075 
1076  v1 = 1.0 / pVertices[i].vWorldViewPosition.x;
1077 
1078  pVertices[i].vWorldViewProjX =
1079  pVertices[i].vWorldViewPosition.y * fov * v1 + screenCenterX;
1080 
1081  pVertices[i].vWorldViewProjY =
1082  (signed int)pViewport->uViewportBR_Y -
1083  (pVertices[i].vWorldViewPosition.z * fov * v1 + screenCenterY);
1084 
1085  } else {*/
1086  auto v = pVertices + i;
1087 
1088 
1089  v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001);
1090  v->_rhw = v1;
1091 
1092  // if indoors use fov - if outdoors use as below - fix later
1094  v2 = v1 * fov;
1095  } else {
1096  v2 = v1 * (double)pODMRenderParams->int_fov_rad;
1097  }
1098 
1099  v->vWorldViewProjX = (double)pViewport->uScreenCenterX -
1100  v2 * v->vWorldViewPosition.y;
1101  v->vWorldViewProjY = (double)pViewport->uScreenCenterY -
1102  v2 * v->vWorldViewPosition.z;
1103  //}
1104 
1105  if (fit_into_viewport) {
1106  // __debugbreak();
1107  v8 = (double)(signed int)pViewport->uViewportBR_X;
1108  if (v8 >= pVertices[i].vWorldViewProjX)
1109  v9 = pVertices[i].vWorldViewProjX;
1110  else
1111  v9 = v8;
1112  v10 = (double)(signed int)pViewport->uViewportTL_X;
1113  if (v10 <= v9) {
1114  if (v8 >= pVertices[i].vWorldViewProjX)
1115  v8 = pVertices[i].vWorldViewProjX;
1116  } else {
1117  v8 = v10;
1118  }
1119  pVertices[i].vWorldViewProjX = v8;
1120  v11 = (double)(signed int)pViewport->uViewportBR_Y;
1121  if (v11 >= pVertices[i].vWorldViewProjY)
1122  v12 = pVertices[i].vWorldViewProjY;
1123  else
1124  v12 = v11;
1125  v13 = (double)(signed int)pViewport->uViewportTL_Y;
1126  if (v13 <= v12) {
1127  if (v11 >= pVertices[i].vWorldViewProjY)
1128  v11 = pVertices[i].vWorldViewProjY;
1129  } else {
1130  v11 = v13;
1131  }
1132  pVertices[i].vWorldViewProjY = v11;
1133  }
1134  }
1135 }
1136 
1137 void IndoorCameraD3D::Project(int x, int y, int z, int *screenspace_x,
1138  int *screenspace_y) {
1140  v.vWorldViewPosition.x = x;
1141  v.vWorldViewPosition.y = y;
1142  v.vWorldViewPosition.z = z;
1143 
1144  this->Project(&v, 1, false);
1145 
1146  if (screenspace_x) {
1147  *screenspace_x = floorf(v.vWorldViewProjX + 0.5f);
1148  }
1149 
1150  if (screenspace_y) {
1151  *screenspace_y = floorf(v.vWorldViewProjY + 0.5f);
1152  }
1153 }
1154 
1155 //----- (00436A6D) --------------------------------------------------------
1157  unsigned int uStripType) {
1158  double result = FLT_MAX;
1159  for (uint i = 0; i < uStripType; i++) {
1160  if (pVertices[i].vWorldPosition.z < result) {
1161  result = pVertices[i].vWorldPosition.z;
1162  }
1163  }
1164  return result;
1165 }
1166 
1167 //----- (00436A40) --------------------------------------------------------
1169  unsigned int uStripType) {
1170  double result; // st7@1
1171 
1172  result = 1.1754944e-38;
1173  for (uint i = 0; i < uStripType; i++) {
1174  if (pVertex[i].vWorldPosition.z > result)
1175  result = pVertex[i].vWorldPosition.z;
1176  }
1177  return result;
1178 }
1179 
1180 // -- new
1181 // merged from IndoorCamera::Initialize2
1182 // and ODMRenderParams::RotationToInts
1183 // and BLVRenderParams::Reset
1184 void IndoorCameraD3D::CalculateRotations(int camera_rot_x, int camera_rot_y) {
1185  sRotationX = camera_rot_x + 20; // pitch
1186  sRotationY = camera_rot_y; // yaw
1187 
1188  fRotationYSine = sin((pi_double + pi_double) * (double)sRotationY / 2048.0);
1189  fRotationYCosine = cos((pi_double + pi_double) * (double)sRotationY / 2048.0);
1190 
1191  fRotationXSine = sin((pi_double + pi_double) * (double)sRotationX / 2048.0);
1192  fRotationXCosine = cos((pi_double + pi_double) * (double)sRotationX / 2048.0);
1193 
1198 }
LightsData::pDeltaUV
int pDeltaUV[2]
Definition: Indoor.h:25
IndoorCameraD3D::CalcPortalShape
bool CalcPortalShape(struct RenderVertexSoft *a1, unsigned int *pOutNumVertices, struct RenderVertexSoft *pVertices, IndoorCameraD3D_Vec4 *a4, signed int uNumVertices, char a6, int _unused)
Definition: IndoorCameraD3D.cpp:697
IndoorCameraD3D::field_288
float field_288
Definition: IndoorCameraD3D.h:218
Vec3_float_
Definition: VectorTypes.h:74
IndoorCameraD3D::_437607
void _437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2)
Definition: IndoorCameraD3D.cpp:566
BLVFace::Portal
bool Portal() const
Definition: Indoor.h:448
Viewport::uScreenWidth
int uScreenWidth
Definition: Viewport.h:26
stru154
Definition: Indoor.h:229
IndoorCameraD3D::Vec3Transform
void Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut)
Definition: IndoorCameraD3D.cpp:555
fixed::FromFloat
static fixed FromFloat(float f)
Definition: OurMath.h:25
IndoorCameraD3D::DebugDrawPortal
void DebugDrawPortal(struct BLVFace *pFace)
Definition: IndoorCameraD3D.cpp:414
Viewport.h
IndoorCameraD3D::list_0037C_size
unsigned int list_0037C_size
Definition: IndoorCameraD3D.h:242
BLVFace::uNumVertices
uint8_t uNumVertices
Definition: Indoor.h:488
IndoorCameraD3D::sRotationY
int sRotationY
Definition: IndoorCameraD3D.h:247
IndoorCameraD3D::field_258
float field_258
Definition: IndoorCameraD3D.h:216
v
const GLdouble * v
Definition: SDL_opengl.h:2064
IndoorCameraD3D::screenCenterX
float screenCenterX
Definition: IndoorCameraD3D.h:190
LOD.h
IndoorCameraD3D::do_draw_debug_line_sw
void do_draw_debug_line_sw(struct RenderVertexSoft *pLineBegin, signed int sStartDiffuse, struct RenderVertexSoft *pLineEnd, signed int sEndDiffuse, unsigned int uOutNumVertices, float z_stuff)
Definition: IndoorCameraD3D.cpp:311
IndoorCameraD3D_Vec3::x
float x
Definition: IndoorCameraD3D.h:21
IndoorCameraD3D::field_2F0
float field_2F0
Definition: IndoorCameraD3D.h:227
fixed::Raw
static fixed Raw(int value)
Definition: OurMath.h:31
BLVFace::pFacePlane_old
struct Plane_int_ pFacePlane_old
Definition: Indoor.h:471
IndoorCameraD3D::is_face_faced_to_camera
bool is_face_faced_to_camera(struct BLVFace *pFace, struct RenderVertexSoft *a2)
Definition: IndoorCameraD3D.cpp:292
Vec2::x
T x
Definition: VectorTypes.h:12
Matrix3x3_float_::_12
float _12
Definition: VectorTypes.h:147
Matrix3x3_float_::v
float v[3][3]
Definition: VectorTypes.h:156
BLVFace::pVertexIDs
uint16_t * pVertexIDs
Definition: Indoor.h:476
Viewport::uViewportTL_Y
int uViewportTL_Y
Definition: Viewport.h:23
Vec3_float_::x
float x
Definition: VectorTypes.h:89
IndoorCameraD3D::field_320
float field_320
Definition: IndoorCameraD3D.h:232
Matrix3x3_float_::_13
float _13
Definition: VectorTypes.h:148
RenderVertexD3D3::pos
Vec3_float_ pos
Definition: IRender.h:130
z
GLdouble GLdouble z
Definition: SDL_opengl_glext.h:407
RenderVertexSoft::u
float u
Definition: IRender.h:121
IndoorCameraD3D::field_108
float field_108
Definition: IndoorCameraD3D.h:199
POLYGON_InBetweenFloorAndWall
@ POLYGON_InBetweenFloorAndWall
Definition: Indoor.h:221
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
Matrix3x3_float_::_23
float _23
Definition: VectorTypes.h:151
IndoorCameraD3D::GetPickDepth
float GetPickDepth()
Definition: IndoorCameraD3D.cpp:61
IndoorCameraD3D_stru3::flt_30
float flt_30
Definition: IndoorCameraD3D.h:60
IndoorCameraD3D::sRotationX
int sRotationX
Definition: IndoorCameraD3D.h:248
RenderVertexD3D3
Definition: IRender.h:129
IndoorCameraD3D::IndoorCameraD3D
IndoorCameraD3D()
Definition: IndoorCameraD3D.cpp:24
Matrix3x3_float_::_11
float _11
Definition: VectorTypes.h:146
stru9.h
IndoorCameraD3D_Vec4
Definition: IndoorCameraD3D.h:32
IndoorCameraD3D::field_2BC
float field_2BC
Definition: IndoorCameraD3D.h:221
POLYGON_Floor
@ POLYGON_Floor
Definition: Indoor.h:220
Vec3_float_::y
float y
Definition: VectorTypes.h:90
Vec3_float_::z
float z
Definition: VectorTypes.h:91
index
GLuint index
Definition: SDL_opengl_glext.h:663
RenderVertexSoft::vWorldViewProjY
float vWorldViewProjY
Definition: IRender.h:119
IndoorCameraD3D::ViewTransfrom_OffsetUV
void ViewTransfrom_OffsetUV(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pOutVertices, struct LightsData *a5)
Definition: IndoorCameraD3D.cpp:69
IndoorCameraD3D::field_318
float field_318
Definition: IndoorCameraD3D.h:230
pIndoor
IndoorLocation * pIndoor
Definition: Indoor.cpp:49
Engine.h
Vec3_float_::Normalize
void Normalize()
Definition: VectorTypes.cpp:22
Plane_float_::vNormal
struct Vec3_float_ vNormal
Definition: VectorTypes.h:136
Plane_int_::vNormal
Vec3_int_ vNormal
Definition: VectorTypes.h:107
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
IndoorCameraD3D
Definition: IndoorCameraD3D.h:104
RenderVertexD3D3::texcoord
Vec2_float_ texcoord
Definition: IRender.h:134
row
GLenum GLenum void * row
Definition: SDL_opengl_glext.h:3141
IndoorCameraD3D::int_cosine_x
int int_cosine_x
Definition: IndoorCameraD3D.h:263
Matrix3x3_float_::_32
float _32
Definition: VectorTypes.h:153
IndoorCameraD3D::screenCenterY
float screenCenterY
Definition: IndoorCameraD3D.h:191
Viewport::uScreen_TL_Y
int uScreen_TL_Y
Definition: Viewport.h:19
RenderVertexSoft::vWorldViewPosition
Vec3_float_ vWorldViewPosition
Definition: IRender.h:117
pVertices
struct RenderVertexD3D3 pVertices[50]
Definition: Render.cpp:50
Matrix3x3_float_
Definition: VectorTypes.h:143
y
EGLSurface EGLint EGLint y
Definition: SDL_egl.h:1596
RenderVertexD3D3::rhw
float rhw
Definition: IRender.h:131
IndoorCameraD3D::CalculateRotations
void CalculateRotations(int camera_rot_x, int camera_rot_y)
Definition: IndoorCameraD3D.cpp:1184
IndoorCameraD3D::vPartyPos
Vec3< int > vPartyPos
Definition: IndoorCameraD3D.h:253
IndoorCameraD3D::field_4
IndoorCameraD3D_Vec3 field_4[3]
Definition: IndoorCameraD3D.h:185
Vec2::y
T y
Definition: VectorTypes.h:13
IndoorCameraD3D::MatrixMultiply
void MatrixMultiply(struct Matrix3x3_float_ *a1, struct Matrix3x3_float_ *a2, struct Matrix3x3_float_ *a3)
Definition: IndoorCameraD3D.cpp:474
IndoorCameraD3D::fRotationYSine
float fRotationYSine
Definition: IndoorCameraD3D.h:249
IndoorCameraD3D::_4371C3
bool _4371C3(struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused)
Definition: IndoorCameraD3D.cpp:768
IndoorCameraD3D::field_378
float field_378
Definition: IndoorCameraD3D.h:240
IndoorCameraD3D::field_31C
float field_31C
Definition: IndoorCameraD3D.h:231
RenderVertexSoft::vWorldViewProjX
float vWorldViewProjX
Definition: IRender.h:118
IndoorCameraD3D::LightmapNeerClip
void LightmapNeerClip(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:958
x
EGLSurface EGLint x
Definition: SDL_egl.h:1596
Viewport::uScreenHeight
int uScreenHeight
Definition: Viewport.h:27
IndoorCameraD3D::field_2B8
float field_2B8
Definition: IndoorCameraD3D.h:220
IndoorCameraD3D::int_cosine_y
int int_cosine_y
Definition: IndoorCameraD3D.h:259
IndoorCameraD3D_Vec3::y
float y
Definition: IndoorCameraD3D.h:22
IndoorCameraD3D::field_1C8
float field_1C8
Definition: IndoorCameraD3D.h:210
IndoorCameraD3D::debug_outline_sw
void debug_outline_sw(struct RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5)
Definition: IndoorCameraD3D.cpp:402
IndoorCameraD3D::field_138
float field_138
Definition: IndoorCameraD3D.h:204
IndoorCameraD3D_Vec3
Definition: IndoorCameraD3D.h:9
Indoor.h
BLVFace
Definition: Indoor.h:424
IndoorCameraD3D::field_34C
float field_34C
Definition: IndoorCameraD3D.h:236
IndoorCameraD3D::inv_fov
float inv_fov
Definition: IndoorCameraD3D.h:194
IndoorCameraD3D::ViewClip
bool ViewClip(int x, int y, int z, int *transformed_x, int *transformed_y, int *transformed_z, bool dont_show=false)
Definition: IndoorCameraD3D.cpp:172
IndoorCameraD3D::field_2C4
float field_2C4
Definition: IndoorCameraD3D.h:223
v1
GLfloat GLfloat v1
Definition: SDL_opengl_glext.h:694
BLVFace::pVertexVIDs
int16_t * pVertexVIDs
Definition: Indoor.h:481
RenderVertexD3D3::diffuse
unsigned int diffuse
Definition: IRender.h:132
IndoorCameraD3D::Project
void Project(int x, int y, int z, int *screenspace_x, int *screenspace_y)
Definition: IndoorCameraD3D.cpp:1137
fixpoint_mul
__int64 fixpoint_mul(int a1, int a2)
Definition: OurMath.cpp:138
IndoorCameraD3D::CreateWorldMatrixAndSomeStuff
void CreateWorldMatrixAndSomeStuff()
Definition: IndoorCameraD3D.cpp:489
IndoorCameraD3D_Vec4::dot
float dot
Definition: IndoorCameraD3D.h:39
Viewport::uViewportBR_X
int uViewportBR_X
Definition: Viewport.h:24
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
ODMRenderParams::near_clip
int near_clip
Definition: IRender.h:76
IndoorCameraD3D::int_sine_x
int int_sine_x
Definition: IndoorCameraD3D.h:261
LEVEL_Outdoor
@ LEVEL_Outdoor
Definition: Indoor.h:287
Viewport::uScreenCenterY
int uScreenCenterY
Definition: Viewport.h:29
IndoorCameraD3D::field_228
float field_228
Definition: IndoorCameraD3D.h:214
IndoorCameraD3D::_437143
void _437143(unsigned int uNumInVertices, struct RenderVertexSoft *pOutVertices, struct RenderVertexSoft *pInVertices, signed int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:823
IndoorCameraD3D::field_348
float field_348
Definition: IndoorCameraD3D.h:235
IndoorCameraD3D::fRotationXCosine
float fRotationXCosine
Definition: IndoorCameraD3D.h:252
IndoorCameraD3D::field_1F8
float field_1F8
Definition: IndoorCameraD3D.h:212
IndoorCameraD3D::fov_y
float fov_y
Definition: IndoorCameraD3D.h:193
IndoorCameraD3D::GetPolygonMinZ
double GetPolygonMinZ(struct RenderVertexSoft *pVertices, unsigned int uStripType)
Definition: IndoorCameraD3D.cpp:1156
IndoorCameraD3D_stru3::field_0
int field_0
Definition: IndoorCameraD3D.h:48
Matrix3x3_float_::_21
float _21
Definition: VectorTypes.h:149
IndoorCameraD3D::field_324
float field_324
Definition: IndoorCameraD3D.h:233
RenderVertexSoft::flt_2C
float flt_2C
Definition: IRender.h:123
Viewport::uViewportBR_Y
int uViewportBR_Y
Definition: Viewport.h:25
stru154::face_plane
Plane_float_ face_plane
Definition: Indoor.h:243
t
GLdouble GLdouble t
Definition: SDL_opengl.h:2071
LEVEL_Indoor
@ LEVEL_Indoor
Definition: Indoor.h:286
IndoorCameraD3D::ApplyViewTransform_TrueIfStillVisible_BLV
bool ApplyViewTransform_TrueIfStillVisible_BLV(int x, int y, int z, fixed *pOutX, fixed *pOutZ, fixed *pOutY, bool clip_plane_test)
Definition: IndoorCameraD3D.cpp:88
IndoorCameraD3D::GetFacetOrientation
bool GetFacetOrientation(char polyType, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4)
Definition: IndoorCameraD3D.cpp:237
pViewport
struct Viewport * pViewport
Definition: mm7_data.cpp:21
ODMRenderParams::uPickDepth
int uPickDepth
Definition: IRender.h:73
pODMRenderParams
ODMRenderParams * pODMRenderParams
Definition: Outdoor.cpp:49
LightsData
Definition: Indoor.h:16
IndoorCameraD3D::field_350
float field_350
Definition: IndoorCameraD3D.h:237
IndoorCameraD3D_Vec3::z
float z
Definition: IndoorCameraD3D.h:23
IndoorCameraD3D::field_168
float field_168
Definition: IndoorCameraD3D.h:206
Matrix3x3_float_::_33
float _33
Definition: VectorTypes.h:154
Viewport::uScreenCenterX
int uScreenCenterX
Definition: Viewport.h:28
IndoorCameraD3D::IsCulled
bool IsCulled(struct BLVFace *pFace)
Definition: IndoorCameraD3D.cpp:128
IndoorCameraD3D::std__vector_000034_prolly_frustrum
IndoorCameraD3D_Vec4 std__vector_000034_prolly_frustrum[6]
Definition: IndoorCameraD3D.h:188
Matrix3x3_float_::_22
float _22
Definition: VectorTypes.h:150
v2
GLfloat GLfloat GLfloat v2
Definition: SDL_opengl_glext.h:695
IndoorCameraD3D::fRotationYCosine
float fRotationYCosine
Definition: IndoorCameraD3D.h:250
RenderVertexSoft::v
float v
Definition: IRender.h:122
IndoorCameraD3D::_437376
char _437376(struct stru154 *thisa, struct RenderVertexSoft *a2, unsigned int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:629
RenderVertexSoft::_rhw
float _rhw
Definition: IRender.h:120
uint
unsigned int uint
Definition: MM7.h:4
IndoorCameraD3D::fov
float fov
Definition: IndoorCameraD3D.h:189
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
IndoorCameraD3D.h
__debugbreak
void __cdecl __debugbreak(void)
IndoorCameraD3D::field_2F4
float field_2F4
Definition: IndoorCameraD3D.h:228
RenderVertexSoft::vWorldPosition
Vec3_float_ vWorldPosition
Definition: IRender.h:116
stru193_math::Cos
int Cos(int angle)
Definition: OurMath.cpp:28
stru_5C6E00
struct stru193_math * stru_5C6E00
Definition: mm7_data.cpp:19
IndoorCameraD3D::list_0037C
IndoorCameraD3D_stru3 list_0037C[16384]
Definition: IndoorCameraD3D.h:241
IndoorCameraD3D::list_E0380
IndoorCameraD3D_stru2 list_E0380[256]
Definition: IndoorCameraD3D.h:243
IndoorLocation::pVertices
struct Vec3_short_ * pVertices
Definition: Indoor.h:628
OurMath.h
uCurrentlyLoadedLevelType
LEVEL_TYPE uCurrentlyLoadedLevelType
Definition: Indoor.cpp:52
POLYGON_InBetweenCeilingAndWall
@ POLYGON_InBetweenCeilingAndWall
Definition: Indoor.h:223
IndoorCameraD3D::fov_x
float fov_x
Definition: IndoorCameraD3D.h:192
ODMRenderParams::int_fov_rad
int int_fov_rad
Definition: IRender.h:79
IndoorCameraD3D::list_E0380_size
int list_E0380_size
Definition: IndoorCameraD3D.h:244
ODMRenderParams::far_clip
int far_clip
Definition: IRender.h:77
IndoorCameraD3D::field_354
float field_354
Definition: IndoorCameraD3D.h:238
IndoorCameraD3D::GetFarClip
float GetFarClip() const
Definition: IndoorCameraD3D.cpp:159
stru193_math::Sin
int Sin(int angle)
Definition: OurMath.cpp:133
IndoorCameraD3D::ViewTransform
void ViewTransform(int x, int y, int z, int *transformed_x, int *transformed_y, int *transformed_z)
Definition: IndoorCameraD3D.cpp:184
_calc_fov
float _calc_fov(int viewport_width, int angle_degree)
Definition: IndoorCameraD3D.cpp:17
fixed
Definition: OurMath.h:21
RenderVertexSoft
Definition: IRender.h:113
IndoorCameraD3D::GetNearClip
float GetNearClip() const
Definition: IndoorCameraD3D.cpp:146
IndoorCameraD3D::field_2E8
float field_2E8
Definition: IndoorCameraD3D.h:225
IndoorCameraD3D_Vec3::v
float v[3]
Definition: IndoorCameraD3D.h:25
IndoorCameraD3D::field_198
float field_198
Definition: IndoorCameraD3D.h:208
IndoorCameraD3D::field_2C0
float field_2C0
Definition: IndoorCameraD3D.h:222
RenderVertexD3D3::specular
unsigned int specular
Definition: IRender.h:133
IndoorCameraD3D::_4374E8_ProllyBuildFrustrum
void _4374E8_ProllyBuildFrustrum()
Definition: IndoorCameraD3D.cpp:581
IndoorCameraD3D::debug_outline_d3d
void debug_outline_d3d(const struct RenderVertexD3D3 *pLineVertices, unsigned int uNumLines, int uDiffuse, float z_stuff)
Definition: IndoorCameraD3D.cpp:390
pIndoorCameraD3D
IndoorCameraD3D * pIndoorCameraD3D
Definition: IndoorCameraD3D.cpp:21
IndoorCameraD3D::LightmapFarClip
void LightmapFarClip(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:848
Viewport::uViewportTL_X
int uViewportTL_X
Definition: Viewport.h:22
IndoorCameraD3D::PrepareAndDrawDebugOutline
void PrepareAndDrawDebugOutline(struct BLVFace *pFace, unsigned int uDiffuse)
Definition: IndoorCameraD3D.cpp:445
IndoorCameraD3D::int_sine_y
int int_sine_y
Definition: IndoorCameraD3D.h:257
IndoorCameraD3D::field_2EC
float field_2EC
Definition: IndoorCameraD3D.h:226
Log.h
POLYGON_Ceiling
@ POLYGON_Ceiling
Definition: Indoor.h:222
PolygonType
PolygonType
Definition: Indoor.h:216
BLVFace::pVertexUIDs
int16_t * pVertexUIDs
Definition: Indoor.h:480
Matrix3x3_float_::_31
float _31
Definition: VectorTypes.h:152
Vec3::z
T z
Definition: VectorTypes.h:27
POLYGON_VerticalWall
@ POLYGON_VerticalWall
Definition: Indoor.h:218
IndoorCameraD3D::GetPolygonMaxZ
double GetPolygonMaxZ(struct RenderVertexSoft *pVertex, unsigned int uStripType)
Definition: IndoorCameraD3D.cpp:1168
IndoorCameraD3D::fRotationXSine
float fRotationXSine
Definition: IndoorCameraD3D.h:251
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52