annotate OutdoorCamera.cpp @ 1345:b99aeb077d4f

Слияние
author Ritor1
date Thu, 11 Jul 2013 17:47:33 +0600
parents 86a83e12d795
children cc9a3a24d61d
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 //----- (00487355) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
12 bool OutdoorCamera::_487355()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
13 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
14 int v0; // esi@1
86a83e12d795 moving files
Ritor1
parents:
diff changeset
15 stru148 *v1; // edi@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
16 bool result; // eax@3
86a83e12d795 moving files
Ritor1
parents:
diff changeset
17
86a83e12d795 moving files
Ritor1
parents:
diff changeset
18 v0 = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
19 if ( pOutdoorCamera->numStru148s > 0 )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
20 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
21 v1 = array_77EC08.data();
86a83e12d795 moving files
Ritor1
parents:
diff changeset
22 do
86a83e12d795 moving files
Ritor1
parents:
diff changeset
23 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
24 result = pGame->pLightmapBuilder->_45D3C7(v1);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
25 ++v0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
26 ++v1;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
27 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
28 while ( v0 < pOutdoorCamera->numStru148s );
86a83e12d795 moving files
Ritor1
parents:
diff changeset
29 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
30 return result;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
31 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
32 //----- (00481E55) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
33 void OutdoorCamera::Project(unsigned int uNumVertices)
86a83e12d795 moving files
Ritor1
parents:
diff changeset
34 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
35 double v1; // st7@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
36 double v2; // st6@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
37 double v3; // st5@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
38 int v4; // eax@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
39 unsigned int v5; // edx@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
40 double v6; // st4@3
86a83e12d795 moving files
Ritor1
parents:
diff changeset
41 double v7; // st3@3
86a83e12d795 moving files
Ritor1
parents:
diff changeset
42
86a83e12d795 moving files
Ritor1
parents:
diff changeset
43 if ( (signed int)uNumVertices > 0 )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
44 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
45 v1 = (double)pOutdoorCamera->int_fov_rad;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
46 v2 = (double)pViewport->uScreenCenterX;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
47 v3 = (double)pViewport->uScreenCenterY;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
48 v4 = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
49 v5 = uNumVertices;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
50 do
86a83e12d795 moving files
Ritor1
parents:
diff changeset
51 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
52 v6 = v1 * array_507D30[v4]._rhw;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
53 v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
54 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
86a83e12d795 moving files
Ritor1
parents:
diff changeset
55 array_50AC10[v4].vWorldViewProjX = v2 - v7;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
56 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
57 ++v4;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
58 --v5;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
59 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
60 while ( v5 );
86a83e12d795 moving files
Ritor1
parents:
diff changeset
61 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
62 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
63 //----- (00485F64) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
64 void OutdoorCamera::_485F64()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
65 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
66 int v1; // eax@1
86a83e12d795 moving files
Ritor1
parents:
diff changeset
67 int v2; // eax@2
86a83e12d795 moving files
Ritor1
parents:
diff changeset
68 signed __int64 v3; // qtt@4
86a83e12d795 moving files
Ritor1
parents:
diff changeset
69 int v4; // eax@4
86a83e12d795 moving files
Ritor1
parents:
diff changeset
70
86a83e12d795 moving files
Ritor1
parents:
diff changeset
71 this->uCameraFovInDegrees = 75;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
72 v1 = stru_5C6E00->uPiMask & 0xD5;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
73 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
74 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
86a83e12d795 moving files
Ritor1
parents:
diff changeset
75 else
86a83e12d795 moving files
Ritor1
parents:
diff changeset
76 v2 = stru_5C6E00->pTanTable[v1];
86a83e12d795 moving files
Ritor1
parents:
diff changeset
77 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
78 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
79 v4 = (signed int)(v3 / v2) >> 16;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
80 this->int_fov_rad = v4;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
81 this->field_4C = 360000;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
82 this->int_fov_rad_inv = 65536 / v4;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
83 this->field_50 = 115;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
84 unnamed_6BE060[1] = 1;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
85 RotationToInts();
86a83e12d795 moving files
Ritor1
parents:
diff changeset
86 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
87
86a83e12d795 moving files
Ritor1
parents:
diff changeset
88 //----- (0048600E) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
89 void OutdoorCamera::RotationToInts()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
90 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
91 camera_rotation_y_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
92 camera_rotation_y_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
93 camera_rotation_x_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationX);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
94 camera_rotation_x_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationX);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
95 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
96 //----- (00486A28) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
97 void OutdoorCamera::AllocSoftwareDrawBuffers()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
98 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
99 if ( !this || !pSpans )
86a83e12d795 moving files
Ritor1
parents:
diff changeset
100 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
101 ReleaseSoftwareDrawBuffers();
86a83e12d795 moving files
Ritor1
parents:
diff changeset
102 pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
103 pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
104 pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
105 pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES");
86a83e12d795 moving files
Ritor1
parents:
diff changeset
106 memset(pSpans, 0, 0x493E0u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
107 memset(pEdges, 0, 0x4C2C0u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
108 memset(pSurfs, 0, 0x11940u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
109 memset(pNewEdges, 0, 0x6180u);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
110 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
111 }
86a83e12d795 moving files
Ritor1
parents:
diff changeset
112
86a83e12d795 moving files
Ritor1
parents:
diff changeset
113 //----- (00486AFC) --------------------------------------------------------
86a83e12d795 moving files
Ritor1
parents:
diff changeset
114 void OutdoorCamera::ReleaseSoftwareDrawBuffers()
86a83e12d795 moving files
Ritor1
parents:
diff changeset
115 {
86a83e12d795 moving files
Ritor1
parents:
diff changeset
116 pAllocator->FreeChunk(pSpans);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
117 pAllocator->FreeChunk(pEdges);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
118 pAllocator->FreeChunk(pSurfs);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
119 pAllocator->FreeChunk(pNewEdges);
86a83e12d795 moving files
Ritor1
parents:
diff changeset
120 pSpans = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
121 pEdges = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
122 pSurfs = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
123 pNewEdges = 0;
86a83e12d795 moving files
Ritor1
parents:
diff changeset
124 }