annotate OutdoorCamera.cpp @ 1505:6306a33af531

UIGame.cpp cleaning(continue) wizard_eye
author Ritor1
date Mon, 02 Sep 2013 12:03:25 +0600
parents cc9a3a24d61d
children 75fafd8ced59
rev   line source
1295
86a83e12d795 moving files
Ritor1
parents:
diff changeset
1 #include "OutdoorCamera.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
2 #include "IndoorCamera.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
3 #include "Outdoor_stuff.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
4 #include "Game.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
5 #include "LightmapBuilder.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
6 #include "Viewport.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
7 #include "Math.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
8 #include "mm7_data.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
9 #include "Allocator.h"
86a83e12d795 moving files
Ritor1
parents:
diff changeset
10
86a83e12d795 moving files
Ritor1
parents:
diff changeset
11 //----- (00481E55) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
12 void OutdoorCamera::Project(unsigned int uNumVertices)
86a83e12d795 moving files
Ritor1
parents:
diff changeset
13 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
14 double v1; // st7@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
15 double v2; // st6@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
16 double v3; // st5@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
17 int v4; // eax@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
18 unsigned int v5; // edx@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
19 double v6; // st4@3
86a83e12d795 moving files
Ritor1
parents:
diff changeset
20 double v7; // st3@3
86a83e12d795 moving files
Ritor1
parents:
diff changeset
21
86a83e12d795 moving files
Ritor1
parents:
diff changeset
22 if ( (signed int)uNumVertices > 0 )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
23 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
24 v1 = (double)pOutdoorCamera->int_fov_rad;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
25 v2 = (double)pViewport->uScreenCenterX;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
26 v3 = (double)pViewport->uScreenCenterY;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
27 v4 = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
28 v5 = uNumVertices;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
29 do
86a83e12d795 moving files
Ritor1
parents:
diff changeset
30 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
31 v6 = v1 * array_507D30[v4]._rhw;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
32 v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
33 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
86a83e12d795 moving files
Ritor1
parents:
diff changeset
34 array_50AC10[v4].vWorldViewProjX = v2 - v7;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
35 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
36 ++v4;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
37 --v5;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
38 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
39 while ( v5 );
86a83e12d795 moving files
Ritor1
parents:
diff changeset
40 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
41 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
42 //----- (00485F64) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
43 void OutdoorCamera::_485F64()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
44 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
45 int v1; // eax@1
86a83e12d795 moving files
Ritor1
parents:
diff changeset
46 int v2; // eax@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
47 signed __int64 v3; // qtt@4
86a83e12d795 moving files
Ritor1
parents:
diff changeset
48 int v4; // eax@4
86a83e12d795 moving files
Ritor1
parents:
diff changeset
49
86a83e12d795 moving files
Ritor1
parents:
diff changeset
50 this->uCameraFovInDegrees = 75;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
51 v1 = stru_5C6E00->uPiMask & 0xD5;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
52 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
53 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
86a83e12d795 moving files
Ritor1
parents:
diff changeset
54 else
86a83e12d795 moving files
Ritor1
parents:
diff changeset
55 v2 = stru_5C6E00->pTanTable[v1];
86a83e12d795 moving files
Ritor1
parents:
diff changeset
56 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
57 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
58 v4 = (signed int)(v3 / v2) >> 16;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
59 this->int_fov_rad = v4;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
60 this->field_4C = 360000;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
61 this->int_fov_rad_inv = 65536 / v4;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
62 this->field_50 = 115;
1391
cc9a3a24d61d Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents: 1295
diff changeset
63 //sr_6BE060[1] = 1;
1295
86a83e12d795 moving files
Ritor1
parents:
diff changeset
64 RotationToInts();
86a83e12d795 moving files
Ritor1
parents:
diff changeset
65 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
66
86a83e12d795 moving files
Ritor1
parents:
diff changeset
67 //----- (0048600E) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
68 void OutdoorCamera::RotationToInts()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
69 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
70 camera_rotation_y_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
71 camera_rotation_y_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
72 camera_rotation_x_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationX);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
73 camera_rotation_x_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationX);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
74 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
75 //----- (00486A28) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
76 void OutdoorCamera::AllocSoftwareDrawBuffers()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
77 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
78 if ( !this || !pSpans )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
79 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
80 ReleaseSoftwareDrawBuffers();
86a83e12d795 moving files
Ritor1
parents:
diff changeset
81 pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
82 pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
83 pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
84 pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
85 memset(pSpans, 0, 0x493E0u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
86 memset(pEdges, 0, 0x4C2C0u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
87 memset(pSurfs, 0, 0x11940u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
88 memset(pNewEdges, 0, 0x6180u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
89 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
90 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
91
86a83e12d795 moving files
Ritor1
parents:
diff changeset
92 //----- (00486AFC) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
93 void OutdoorCamera::ReleaseSoftwareDrawBuffers()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
94 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
95 pAllocator->FreeChunk(pSpans);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
96 pAllocator->FreeChunk(pEdges);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
97 pAllocator->FreeChunk(pSurfs);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
98 pAllocator->FreeChunk(pNewEdges);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
99 pSpans = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
100 pEdges = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
101 pSurfs = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
102 pNewEdges = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
103 }