Mercurial > mm7
comparison mm7_6.cpp @ 1784:d73f4668ef94
BuildingVerticesClipping
author | Ritor1 |
---|---|
date | Thu, 03 Oct 2013 18:07:55 +0600 |
parents | 53c0453f4eb2 |
children | 11f36943e818 |
comparison
equal
deleted
inserted
replaced
1765:53c0453f4eb2 | 1784:d73f4668ef94 |
---|---|
41 #include "mm7_data.h" | 41 #include "mm7_data.h" |
42 | 42 |
43 | 43 |
44 | 44 |
45 //----- (00424EE0) -------------------------------------------------------- | 45 //----- (00424EE0) -------------------------------------------------------- |
46 int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID) | 46 int BuildingVerticesClipping(unsigned int uNumVertices) |
47 { | 47 { |
48 //unsigned int v1; // edx@1 | 48 signed int previous_vertices_flag; // edi@1 |
49 double v2; // st7@1 | 49 double t; // st6@10 |
50 signed int v3; // edi@1 | 50 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 |
51 char *v4; // esi@4 | 51 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 |
52 char *v5; // ecx@4 | 52 int pNextVertices; |
53 //unsigned int v6; // eax@4 | 53 //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 |
54 char *v7; // edx@4 | 54 |
55 double v8; // st6@10 | 55 memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); |
56 double v9; // st5@10 | 56 depth_num_vertices = 0; |
57 double v10; // st6@11 | 57 previous_vertices_flag = 0; |
58 unsigned __int8 v11; // c2@15 | 58 if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) |
59 unsigned __int8 v12; // c3@15 | 59 previous_vertices_flag = 1;//предыдущая грань меньше границы видимости |
60 void *v13; // edi@22 | 60 if ( (signed int)uNumVertices <= 0 ) |
61 char *v14; // eax@22 | |
62 double v15; // st6@22 | |
63 char *v16; // ecx@22 | |
64 signed int result; // eax@24 | |
65 unsigned int v18; // [sp+8h] [bp-2Ch]@4 | |
66 bool v19; // [sp+Ch] [bp-28h]@6 | |
67 char *v20; // [sp+10h] [bp-24h]@4 | |
68 char *v21; // [sp+14h] [bp-20h]@4 | |
69 signed int v22; // [sp+18h] [bp-1Ch]@1 | |
70 char *v23; // [sp+1Ch] [bp-18h]@4 | |
71 RenderVertexSoft *v24; // [sp+20h] [bp-14h]@4 | |
72 char *v25; // [sp+24h] [bp-10h]@4 | |
73 char *v26; // [sp+28h] [bp-Ch]@4 | |
74 char *v27; // [sp+2Ch] [bp-8h]@4 | |
75 char *v28; // [sp+30h] [bp-4h]@4 | |
76 | |
77 v2 = (double)pODMRenderParams->shading_dist_mist; | |
78 memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); | |
79 v3 = 0; | |
80 v22 = 0; | |
81 if ( array_50AC10[0].vWorldViewPosition.x <= (double)pODMRenderParams->shading_dist_mist ) | |
82 v3 = 1; | |
83 if ( (signed int)(uVertexID + 1) <= 1 ) | |
84 return 0; | 61 return 0; |
85 v4 = (char *)&array_507D30[0].vWorldViewPosition.z; | 62 for ( uint i = 1; i <= uNumVertices; ++i ) |
86 v5 = (char *)&array_507D30[0].vWorldViewPosition.y; | 63 { |
87 v23 = (char *)&array_507D30[0].flt_2C; | 64 current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; |
88 v26 = (char *)&array_507D30[0]._rhw; | 65 if ( previous_vertices_flag != current_vertices_flag )//одна из граней за границей видимости |
89 v24 = array_507D30; | 66 { |
90 v20 = (char *)&array_507D30[0].vWorldViewPosition.z; | 67 if ( current_vertices_flag )//текущая грань меньше границы видимости(предыдущая грань за пределами видимости) |
91 v21 = (char *)&array_507D30[0].vWorldViewPosition.y; | 68 { |
92 v25 = (char *)&array_507D30[0].vWorldViewPosition; | 69 //t = far_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) |
93 v27 = (char *)&array_507D30[0].v; | 70 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); |
94 v28 = (char *)&array_507D30[0].u; | 71 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; |
95 v7 = (char *)&array_50AC10[0].v; | 72 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; |
96 for ( v18 = 1; v18 <= uVertexID; ++v18 ) | 73 array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; |
97 { | 74 array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; |
98 v19 = v2 >= array_50AC10[v18].vWorldViewPosition.x; | 75 } |
99 if ( v3 != v19 ) | 76 else//предыдущая грань меньше границы видимости(текущая грань вышла за пределы видимости) |
100 { | 77 { |
101 if ( v19 ) | 78 //t = far_clip - v1.x / v0.x - v1.x |
102 { | 79 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
103 v8 = (v2 - array_50AC10[v18 - 1].vWorldViewPosition.x) / (array_50AC10[v18].vWorldViewPosition.x - array_50AC10[v18 - 1].vWorldViewPosition.x); | 80 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; |
104 *(float *)v5 = (array_50AC10[v18].vWorldViewPosition.y - array_50AC10[v18 - 1].vWorldViewPosition.y) * v8 + array_50AC10[v18 - 1].vWorldViewPosition.y; | 81 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; |
105 *(float *)v4 = (array_50AC10[v18].vWorldViewPosition.z - array_50AC10[v18 - 1].vWorldViewPosition.z) * v8 + array_50AC10[v18 - 1].vWorldViewPosition.z; | 82 array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; |
106 *(float *)v28 = (array_50AC10[v18].u - array_50AC10[v18 - 1].u) * v8 + array_50AC10[v18 - 1].u; | 83 array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; |
107 v9 = (array_50AC10[v18].v - array_50AC10[v18 - 1].v) * v8 + array_50AC10[v18 - 1].v; | 84 } |
108 } | 85 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
109 else | 86 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
110 { | 87 ++depth_num_vertices; |
111 v10 = (v2 - array_50AC10[v18].vWorldViewPosition.x) / (array_50AC10[v18 - 1].vWorldViewPosition.x - array_50AC10[v18].vWorldViewPosition.x); | 88 } |
112 *(float *)v5 = (array_50AC10[v18 - 1].vWorldViewPosition.y - array_50AC10[v18].vWorldViewPosition.y) * v10 + array_50AC10[v18].vWorldViewPosition.y; | 89 if ( current_vertices_flag )//оба в границе видимости |
113 *(float *)v4 = (array_50AC10[v18 - 1].vWorldViewPosition.z - array_50AC10[v18].vWorldViewPosition.z) * v10 + array_50AC10[v18].vWorldViewPosition.z; | 90 { |
114 *(float *)v28 = (array_50AC10[v18 - 1].u - array_50AC10[v18].u) * v10 + array_50AC10[v18].u; | 91 pNextVertices = depth_num_vertices++; |
115 v9 = (array_50AC10[v18 - 1].v - array_50AC10[v18].v) * v10 + array_50AC10[v18].v; | 92 memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); |
116 } | 93 } |
117 *(float *)v27 = v9; | 94 previous_vertices_flag = current_vertices_flag; |
118 *(float *)v25 = v2; | 95 } |
119 *(float *)v26 = 1.0 / v2; | 96 if ( depth_num_vertices < 3 ) |
120 if ( v3 ) | |
121 { | |
122 if ( v2 == *((float *)v7 - 7) && *(float *)v5 == *((float *)v7 - 6) ) | |
123 { | |
124 v11 = 0; | |
125 v12 = *(float *)v4 == *((float *)v7 - 5); | |
126 if ( ! (v12 | v11) ) | |
127 { | |
128 v26 += 48; | |
129 ++v24; | |
130 v25 += 48; | |
131 v27 += 48; | |
132 v28 += 48; | |
133 v5 += 48; | |
134 v4 += 48; | |
135 ++v22; | |
136 v23 += 48; | |
137 v21 = v5; | |
138 v20 = v4; | |
139 } | |
140 } | |
141 } | |
142 else | |
143 { | |
144 if ( v2 == *((float *)v7 + 5) && *(float *)v5 == *((float *)v7 + 6) ) | |
145 { | |
146 v11 = 0; | |
147 v12 = *(float *)v4 == *((float *)v7 + 7); | |
148 if ( !(v12 | v11) ) | |
149 { | |
150 v26 += 48; | |
151 ++v24; | |
152 v25 += 48; | |
153 v27 += 48; | |
154 v28 += 48; | |
155 v5 += 48; | |
156 v4 += 48; | |
157 ++v22; | |
158 v23 += 48; | |
159 v21 = v5; | |
160 v20 = v4; | |
161 } | |
162 } | |
163 } | |
164 v26 += 48; | |
165 ++v24; | |
166 v25 += 48; | |
167 v27 += 48; | |
168 v28 += 48; | |
169 v5 += 48; | |
170 v4 += 48; | |
171 ++v22; | |
172 v23 += 48; | |
173 v21 = v5; | |
174 v20 = v4; | |
175 } | |
176 if ( v19 ) | |
177 { | |
178 v13 = v24; | |
179 v14 = v26; | |
180 v21 += 48; | |
181 v15 = 1.0 / (*((float *)v7 + 5) + 0.0000001); | |
182 v20 += 48; | |
183 ++v22; | |
184 v28 += 48; | |
185 v27 += 48; | |
186 v25 += 48; | |
187 ++v24; | |
188 v26 += 48; | |
189 memcpy(v13, v7 + 8, 0x30u); | |
190 v16 = v23; | |
191 v23 += 48; | |
192 v4 = v20; | |
193 *(float *)v14 = v15; | |
194 *(int *)v16 = *((int *)v7 + 13); | |
195 v5 = v21; | |
196 } | |
197 v3 = v19; | |
198 v7 += 48; | |
199 //--v18; | |
200 } | |
201 //while ( v18 ); | |
202 result = v22; | |
203 if ( v22 < 3 ) | |
204 return 0; | 97 return 0; |
205 return result; | 98 return depth_num_vertices; |
206 } | 99 } |
207 | |
208 | 100 |
209 //----- (00426A5A) -------------------------------------------------------- | 101 //----- (00426A5A) -------------------------------------------------------- |
210 void stru319::LootActor(Actor *pActor) | 102 void stru319::LootActor(Actor *pActor) |
211 { | 103 { |
212 signed int v2; // edi@1 | 104 signed int v2; // edi@1 |