annotate DecalBuilder.cpp @ 674:c508daac2c07

A bit of minimap cleaning
author Nomad
date Thu, 14 Mar 2013 23:26:01 +0200
parents ccf8b4815a1f
children 346f7069676a
rev   line source
0
Ritor1
parents:
diff changeset
1 #include "DecalBuilder.h"
Ritor1
parents:
diff changeset
2 #include "Game.h"
Ritor1
parents:
diff changeset
3 #include "Time.h"
Ritor1
parents:
diff changeset
4 #include "stru314.h"
Ritor1
parents:
diff changeset
5 #include "Outdoor.h"
Ritor1
parents:
diff changeset
6 #include "Log.h"
Ritor1
parents:
diff changeset
7
Ritor1
parents:
diff changeset
8 #include "mm7_data.h"
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13
Ritor1
parents:
diff changeset
14 struct DecalBuilder *pDecalBuilder = new DecalBuilder;
Ritor1
parents:
diff changeset
15 struct BloodsplatContainer *pBloodsplatContainer = new BloodsplatContainer;
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18 //----- (0043B570) --------------------------------------------------------
Ritor1
parents:
diff changeset
19 double DecalBuilder_stru0::_43B570_get_color_mult_by_time()
Ritor1
parents:
diff changeset
20 {
Ritor1
parents:
diff changeset
21 double result; // st7@3
Ritor1
parents:
diff changeset
22
Ritor1
parents:
diff changeset
23 if (field_1C_flags & 1)
Ritor1
parents:
diff changeset
24 {
Ritor1
parents:
diff changeset
25 if ((field_20_time - pEventTimer->Time() + 384) / 384.0 >= 0.0)
Ritor1
parents:
diff changeset
26 result = (field_20_time - pEventTimer->Time() + 384) / 384.0;
Ritor1
parents:
diff changeset
27 else
Ritor1
parents:
diff changeset
28 result = 0.0;
Ritor1
parents:
diff changeset
29 }
Ritor1
parents:
diff changeset
30 else
Ritor1
parents:
diff changeset
31 {
Ritor1
parents:
diff changeset
32 result = 1.0;
Ritor1
parents:
diff changeset
33 }
Ritor1
parents:
diff changeset
34 return result;
Ritor1
parents:
diff changeset
35 }
Ritor1
parents:
diff changeset
36
Ritor1
parents:
diff changeset
37
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39
Ritor1
parents:
diff changeset
40
Ritor1
parents:
diff changeset
41 //----- (0043B6EF) --------------------------------------------------------
Ritor1
parents:
diff changeset
42 bool BloodsplatContainer::AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b)
Ritor1
parents:
diff changeset
43 {
Ritor1
parents:
diff changeset
44 int *v8; // esi@1
Ritor1
parents:
diff changeset
45 int v9; // eax@3
Ritor1
parents:
diff changeset
46 Bloodsplat *v10; // eax@3
Ritor1
parents:
diff changeset
47 int *result; // eax@3
Ritor1
parents:
diff changeset
48 int v12; // ecx@3
Ritor1
parents:
diff changeset
49
Ritor1
parents:
diff changeset
50 v8 = &this->uNumBloodsplats;
Ritor1
parents:
diff changeset
51 if ( this->uNumBloodsplats == 64 )
Ritor1
parents:
diff changeset
52 *v8 = 0;
Ritor1
parents:
diff changeset
53 v9 = 5 * (*v8)++;
Ritor1
parents:
diff changeset
54 v10 = &this->std__vector_pBloodsplats[8 * v9 / 0x28u];
Ritor1
parents:
diff changeset
55 v10->x = x;
Ritor1
parents:
diff changeset
56 v10->y = y;
Ritor1
parents:
diff changeset
57 v10->z = z;
Ritor1
parents:
diff changeset
58 v10->radius = radius;
Ritor1
parents:
diff changeset
59 v10->r = r;
Ritor1
parents:
diff changeset
60 v10->g = g;
Ritor1
parents:
diff changeset
61 v10->b = b;
Ritor1
parents:
diff changeset
62 result = (int *)&this->std__vector_pBloodsplats_size;
Ritor1
parents:
diff changeset
63 v12 = this->std__vector_pBloodsplats_size + 1;
Ritor1
parents:
diff changeset
64 if ( v12 > 64 )
Ritor1
parents:
diff changeset
65 v12 = 64;
Ritor1
parents:
diff changeset
66 *result = v12;
Ritor1
parents:
diff changeset
67 LOBYTE(result) = 1;
Ritor1
parents:
diff changeset
68 return (bool)result;
Ritor1
parents:
diff changeset
69 }
Ritor1
parents:
diff changeset
70
Ritor1
parents:
diff changeset
71 //----- (0049B490) --------------------------------------------------------
Ritor1
parents:
diff changeset
72 bool DecalBuilder::AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9)
Ritor1
parents:
diff changeset
73 {
Ritor1
parents:
diff changeset
74 //double v10; // ST1C_8@1
Ritor1
parents:
diff changeset
75 char v11; // ST24_1@1
Ritor1
parents:
diff changeset
76 //double v12; // ST1C_8@1
Ritor1
parents:
diff changeset
77 //double v13; // ST1C_8@1
Ritor1
parents:
diff changeset
78 int a7a; // [sp+40h] [bp+18h]@1
Ritor1
parents:
diff changeset
79 //float arg14a; // [sp+44h] [bp+1Ch]@1
Ritor1
parents:
diff changeset
80 //float arg14b; // [sp+44h] [bp+1Ch]@1
Ritor1
parents:
diff changeset
81 //float arg14c; // [sp+44h] [bp+1Ch]@1
Ritor1
parents:
diff changeset
82
Ritor1
parents:
diff changeset
83 /*arg14a = b * 255.0;
Ritor1
parents:
diff changeset
84 v10 = arg14a + 6.7553994e15;
Ritor1
parents:
diff changeset
85 v11 = LOBYTE(v10);
Ritor1
parents:
diff changeset
86 arg14b = g * 255.0;
Ritor1
parents:
diff changeset
87 v12 = arg14b + 6.7553994e15;
Ritor1
parents:
diff changeset
88 a7a = LODWORD(v12);
Ritor1
parents:
diff changeset
89 arg14c = r * 255.0;
Ritor1
parents:
diff changeset
90 v13 = arg14c + 6.7553994e15;*/
Ritor1
parents:
diff changeset
91 return pBloodsplatContainer->AddBloodsplat(x, y, z, radius,
Ritor1
parents:
diff changeset
92 //SLOBYTE(v13), a7a, v11);
Ritor1
parents:
diff changeset
93 r * 255.0f,
Ritor1
parents:
diff changeset
94 g * 255.0f,
Ritor1
parents:
diff changeset
95 b * 255.0f);
Ritor1
parents:
diff changeset
96 }
Ritor1
parents:
diff changeset
97
Ritor1
parents:
diff changeset
98 //----- (0049B525) --------------------------------------------------------
Ritor1
parents:
diff changeset
99 void DecalBuilder::Reset(unsigned int bPreserveBloodsplats)
Ritor1
parents:
diff changeset
100 {
Ritor1
parents:
diff changeset
101 if ( !bPreserveBloodsplats )
Ritor1
parents:
diff changeset
102 {
Ritor1
parents:
diff changeset
103 pBloodsplatContainer->std__vector_pBloodsplats_size = 0;
Ritor1
parents:
diff changeset
104 pBloodsplatContainer->uNumBloodsplats = 0;
Ritor1
parents:
diff changeset
105 }
Ritor1
parents:
diff changeset
106 std__vector_pDecals_size = 0;
Ritor1
parents:
diff changeset
107 }
Ritor1
parents:
diff changeset
108
Ritor1
parents:
diff changeset
109 //----- (0049B540) --------------------------------------------------------
638
ccf8b4815a1f GetActorTintColor fixed
Nomad
parents: 186
diff changeset
110 char DecalBuilder::ApplyDecals(int light_level, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID)
0
Ritor1
parents:
diff changeset
111 {
Ritor1
parents:
diff changeset
112 char *v9; // eax@3
Ritor1
parents:
diff changeset
113 signed int v10; // ecx@3
Ritor1
parents:
diff changeset
114 RenderVertexSoft *v11; // eax@10
Ritor1
parents:
diff changeset
115 unsigned int v12; // edx@10
Ritor1
parents:
diff changeset
116 RenderVertexSoft *v13; // esi@11
Ritor1
parents:
diff changeset
117 RenderVertexSoft *v14; // edi@11
Ritor1
parents:
diff changeset
118 char v15; // zf@11
Ritor1
parents:
diff changeset
119 stru154 *v16; // esi@12
Ritor1
parents:
diff changeset
120 double v18; // st7@17
Ritor1
parents:
diff changeset
121 double v19; // st6@17
Ritor1
parents:
diff changeset
122 float v20; // eax@17
Ritor1
parents:
diff changeset
123 Bloodsplat *v21; // esi@21
Ritor1
parents:
diff changeset
124 int v22; // eax@21
Ritor1
parents:
diff changeset
125 int v23; // ecx@21
Ritor1
parents:
diff changeset
126 double v24; // st7@21
Ritor1
parents:
diff changeset
127 int v25; // ebx@21
Ritor1
parents:
diff changeset
128 double v26; // st7@21
Ritor1
parents:
diff changeset
129 int v27; // edi@21
Ritor1
parents:
diff changeset
130 double v28; // st7@21
Ritor1
parents:
diff changeset
131 int v29; // ST10_4@21
Ritor1
parents:
diff changeset
132 int v30; // ST08_4@21
Ritor1
parents:
diff changeset
133 DecalBuilder *v31; // esi@21
Ritor1
parents:
diff changeset
134 int v32; // [sp+4h] [bp-44h]@18
Ritor1
parents:
diff changeset
135 RenderVertexSoft *v33; // [sp+8h] [bp-40h]@21
Ritor1
parents:
diff changeset
136 stru314 *v34; // [sp+Ch] [bp-3Ch]@21
Ritor1
parents:
diff changeset
137 float v35; // [sp+10h] [bp-38h]@21
Ritor1
parents:
diff changeset
138 float v36; // [sp+14h] [bp-34h]@17
Ritor1
parents:
diff changeset
139 int v37; // [sp+18h] [bp-30h]@17
Ritor1
parents:
diff changeset
140 int a5a; // [sp+28h] [bp-20h]@21
Ritor1
parents:
diff changeset
141 int v39; // [sp+2Ch] [bp-1Ch]@21
Ritor1
parents:
diff changeset
142 int v40; // [sp+30h] [bp-18h]@21
Ritor1
parents:
diff changeset
143 int v41; // [sp+34h] [bp-14h]@22
Ritor1
parents:
diff changeset
144 int v42; // [sp+38h] [bp-10h]@21
Ritor1
parents:
diff changeset
145 int v43; // [sp+3Ch] [bp-Ch]@21
Ritor1
parents:
diff changeset
146 DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
Ritor1
parents:
diff changeset
147 RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
Ritor1
parents:
diff changeset
148
Ritor1
parents:
diff changeset
149 __debugbreak();
Ritor1
parents:
diff changeset
150
638
ccf8b4815a1f GetActorTintColor fixed
Nomad
parents: 186
diff changeset
151 auto a2 = light_level;
0
Ritor1
parents:
diff changeset
152 auto a9 = uSectorID;
Ritor1
parents:
diff changeset
153
Ritor1
parents:
diff changeset
154 thisa = this;
Ritor1
parents:
diff changeset
155 if ( !a5 )
Ritor1
parents:
diff changeset
156 return 0;
Ritor1
parents:
diff changeset
157
Ritor1
parents:
diff changeset
158 static RenderVertexSoft static_AE4F90[64];
Ritor1
parents:
diff changeset
159 static bool __init_flag1 = false;
Ritor1
parents:
diff changeset
160 if (!__init_flag1)
Ritor1
parents:
diff changeset
161 {
Ritor1
parents:
diff changeset
162 __init_flag1 = true;
Ritor1
parents:
diff changeset
163
Ritor1
parents:
diff changeset
164 for (uint i = 0; i < 64; ++i)
Ritor1
parents:
diff changeset
165 static_AE4F90[i].flt_2C = 0.0f;
Ritor1
parents:
diff changeset
166 }
Ritor1
parents:
diff changeset
167
Ritor1
parents:
diff changeset
168 static stru314 static_AE4F60; // idb
Ritor1
parents:
diff changeset
169 /*static bool __init_flag2 = false;
Ritor1
parents:
diff changeset
170 if (!__init_flag2)
Ritor1
parents:
diff changeset
171 {
Ritor1
parents:
diff changeset
172 __init_flag2 = true;
Ritor1
parents:
diff changeset
173
Ritor1
parents:
diff changeset
174 stru314::stru314(&static_AE4F60);
Ritor1
parents:
diff changeset
175 }*/
Ritor1
parents:
diff changeset
176
Ritor1
parents:
diff changeset
177 a11 = a6;
Ritor1
parents:
diff changeset
178 if ( a7 )
Ritor1
parents:
diff changeset
179 {
Ritor1
parents:
diff changeset
180 if ( a5 > 0 )
Ritor1
parents:
diff changeset
181 {
Ritor1
parents:
diff changeset
182 v11 = static_AE4F90;
Ritor1
parents:
diff changeset
183 v12 = (char *)a6 - (char *)static_AE4F90;
Ritor1
parents:
diff changeset
184 a6 = (RenderVertexSoft *)a5;
Ritor1
parents:
diff changeset
185 do
Ritor1
parents:
diff changeset
186 {
Ritor1
parents:
diff changeset
187 v13 = (RenderVertexSoft *)((char *)v11 + v12);
Ritor1
parents:
diff changeset
188 v14 = v11;
Ritor1
parents:
diff changeset
189 ++v11;
Ritor1
parents:
diff changeset
190 v15 = a6 == (RenderVertexSoft *)1;
Ritor1
parents:
diff changeset
191 a6 = (RenderVertexSoft *)((char *)a6 - 1);
Ritor1
parents:
diff changeset
192 memcpy(v14, v13, 0x30u);
Ritor1
parents:
diff changeset
193 }
Ritor1
parents:
diff changeset
194 while ( !v15 );
Ritor1
parents:
diff changeset
195 }
Ritor1
parents:
diff changeset
196 v16 = a4;
Ritor1
parents:
diff changeset
197 if ( pGame->pIndoorCameraD3D->_437376(a4, static_AE4F90, (unsigned int *)&a5) == 1 )
Ritor1
parents:
diff changeset
198 {
Ritor1
parents:
diff changeset
199 if ( !a5 )
Ritor1
parents:
diff changeset
200 return 0;
Ritor1
parents:
diff changeset
201 a11 = static_AE4F90;
Ritor1
parents:
diff changeset
202 }
Ritor1
parents:
diff changeset
203 }
Ritor1
parents:
diff changeset
204 else
Ritor1
parents:
diff changeset
205 {
Ritor1
parents:
diff changeset
206 v16 = a4;
Ritor1
parents:
diff changeset
207 }
Ritor1
parents:
diff changeset
208 v18 = v16->face_plane.vNormal.z;
Ritor1
parents:
diff changeset
209 v19 = v16->face_plane.vNormal.y;
Ritor1
parents:
diff changeset
210 v20 = v16->face_plane.vNormal.x;
Ritor1
parents:
diff changeset
211 v37 = (int)&static_AE4F60.field_1C;
Ritor1
parents:
diff changeset
212 static_AE4F60.field_4.y = v19;
Ritor1
parents:
diff changeset
213 static_AE4F60.field_4.x = v20;
Ritor1
parents:
diff changeset
214 LODWORD(v36) = (DWORD)&static_AE4F60.field_10;
Ritor1
parents:
diff changeset
215 static_AE4F60.field_4.z = v18;
Ritor1
parents:
diff changeset
216 static_AE4F60.dist = v16->face_plane.dist;
Ritor1
parents:
diff changeset
217 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
Ritor1
parents:
diff changeset
218 v16->polygonType,
Ritor1
parents:
diff changeset
219 &static_AE4F60.field_4,
Ritor1
parents:
diff changeset
220 &static_AE4F60.field_10,
Ritor1
parents:
diff changeset
221 &static_AE4F60.field_1C) )
Ritor1
parents:
diff changeset
222 {
Ritor1
parents:
diff changeset
223 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
Ritor1
parents:
diff changeset
224 }
Ritor1
parents:
diff changeset
225 int _a7 = 0;
Ritor1
parents:
diff changeset
226 if ( thisa->uNumDecals > 0 )
Ritor1
parents:
diff changeset
227 {
Ritor1
parents:
diff changeset
228 a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
Ritor1
parents:
diff changeset
229 do
Ritor1
parents:
diff changeset
230 {
Ritor1
parents:
diff changeset
231 v21 = &pBloodsplatContainer->std__vector_pBloodsplats[LODWORD(a6->vWorldPosition.x)];
Ritor1
parents:
diff changeset
232 *(float *)&v37 = v21->z;
Ritor1
parents:
diff changeset
233 v36 = v21->y;
Ritor1
parents:
diff changeset
234 v35 = v21->x;
Ritor1
parents:
diff changeset
235 v22 = _43F5C8_get_point_light_level_with_respect_to_lights(a2, a9, v35, v36, *(float *)&v37);
Ritor1
parents:
diff changeset
236 v23 = v21->b;
Ritor1
parents:
diff changeset
237 v24 = v21->x;
Ritor1
parents:
diff changeset
238 v42 = v22;
Ritor1
parents:
diff changeset
239 BYTE3(v22) = 0;
Ritor1
parents:
diff changeset
240 *(short *)((char *)&v22 + 1) = v21->r;
Ritor1
parents:
diff changeset
241 LOBYTE(v22) = v21->g;
Ritor1
parents:
diff changeset
242 v43 = v23 | (v22 << 8);
Ritor1
parents:
diff changeset
243 v25 = (signed __int64)v24;
Ritor1
parents:
diff changeset
244 v26 = v21->z;
Ritor1
parents:
diff changeset
245 v27 = (signed __int64)v21->y;
Ritor1
parents:
diff changeset
246 v37 = a8;
Ritor1
parents:
diff changeset
247 v40 = (signed __int64)v26;
Ritor1
parents:
diff changeset
248 v28 = v21->dot_dist;
Ritor1
parents:
diff changeset
249 LODWORD(v36) = (uint32)a11;
Ritor1
parents:
diff changeset
250 a5a = v25;
Ritor1
parents:
diff changeset
251 v39 = v27;
Ritor1
parents:
diff changeset
252 LODWORD(v35) = a5;
Ritor1
parents:
diff changeset
253 v34 = &static_AE4F60;
Ritor1
parents:
diff changeset
254 *(float *)&v33 = v28;
Ritor1
parents:
diff changeset
255 v32 = v23 | (v22 << 8);
Ritor1
parents:
diff changeset
256 *(float *)&v29 = v21->radius;
Ritor1
parents:
diff changeset
257 v30 = (int)v21;
Ritor1
parents:
diff changeset
258 v31 = thisa;
Ritor1
parents:
diff changeset
259 if ( !thisa->_49B790_build_decal_geometry(
Ritor1
parents:
diff changeset
260 v42,
Ritor1
parents:
diff changeset
261 a3,
Ritor1
parents:
diff changeset
262 v30,
Ritor1
parents:
diff changeset
263 (int)&a5a,
Ritor1
parents:
diff changeset
264 v29,
Ritor1
parents:
diff changeset
265 v43,
Ritor1
parents:
diff changeset
266 v33,
Ritor1
parents:
diff changeset
267 &static_AE4F60,
Ritor1
parents:
diff changeset
268 a5,
Ritor1
parents:
diff changeset
269 a11,
Ritor1
parents:
diff changeset
270 a8) )
Ritor1
parents:
diff changeset
271 {
Ritor1
parents:
diff changeset
272 MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
Ritor1
parents:
diff changeset
273 }
Ritor1
parents:
diff changeset
274 ++_a7;
Ritor1
parents:
diff changeset
275 a6 = (RenderVertexSoft *)((char *)a6 + 4);
Ritor1
parents:
diff changeset
276 }
Ritor1
parents:
diff changeset
277 while ( _a7 < v31->uNumDecals );
Ritor1
parents:
diff changeset
278 }
Ritor1
parents:
diff changeset
279 return 1;
Ritor1
parents:
diff changeset
280 }
Ritor1
parents:
diff changeset
281
Ritor1
parents:
diff changeset
282 //----- (0049B790) --------------------------------------------------------
Ritor1
parents:
diff changeset
283 char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
Ritor1
parents:
diff changeset
284 {
Ritor1
parents:
diff changeset
285 DecalBuilder *v12; // esi@1
Ritor1
parents:
diff changeset
286 Decal *v13; // edi@2
Ritor1
parents:
diff changeset
287 char *v14; // eax@2
Ritor1
parents:
diff changeset
288 double v15; // st7@4
Ritor1
parents:
diff changeset
289 double v16; // st7@4
Ritor1
parents:
diff changeset
290 int v17; // eax@4
Ritor1
parents:
diff changeset
291 stru314 *v18; // ebx@4
Ritor1
parents:
diff changeset
292 double v19; // st7@4
Ritor1
parents:
diff changeset
293 double v20; // st7@4
Ritor1
parents:
diff changeset
294 double v21; // st7@4
Ritor1
parents:
diff changeset
295 double v22; // st6@4
Ritor1
parents:
diff changeset
296 double v23; // st6@4
Ritor1
parents:
diff changeset
297 double v24; // st5@4
Ritor1
parents:
diff changeset
298 char *v25; // eax@4
Ritor1
parents:
diff changeset
299 signed int v26; // ecx@4
Ritor1
parents:
diff changeset
300 double v27; // st5@4
Ritor1
parents:
diff changeset
301 double v28; // st7@5
Ritor1
parents:
diff changeset
302 double v29; // st7@6
Ritor1
parents:
diff changeset
303 char result; // al@6
Ritor1
parents:
diff changeset
304 unsigned int *v31; // edi@7
Ritor1
parents:
diff changeset
305 RenderVertexSoft *v32; // ebx@8
Ritor1
parents:
diff changeset
306 std::string *v33; // ecx@15
Ritor1
parents:
diff changeset
307 int v34; // eax@19
Ritor1
parents:
diff changeset
308 const char *v35; // [sp-Ch] [bp-2Ch]@15
Ritor1
parents:
diff changeset
309 int v36; // [sp-8h] [bp-28h]@15
Ritor1
parents:
diff changeset
310 std::string v37; // [sp-4h] [bp-24h]@15
Ritor1
parents:
diff changeset
311 float v38; // [sp+8h] [bp-18h]@6
Ritor1
parents:
diff changeset
312 RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
Ritor1
parents:
diff changeset
313 unsigned int *v40; // [sp+10h] [bp-10h]@6
Ritor1
parents:
diff changeset
314
Ritor1
parents:
diff changeset
315 v12 = this;
Ritor1
parents:
diff changeset
316 if ( *(float *)&a6 == 0.0 )
Ritor1
parents:
diff changeset
317 goto LABEL_24;
Ritor1
parents:
diff changeset
318 v13 = &this->std__vector_pDecals[this->field_308008];
Ritor1
parents:
diff changeset
319 v14 = (char *)&this->std__vector_pDecals[this->field_308008].field_C1C;
Ritor1
parents:
diff changeset
320 this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
Ritor1
parents:
diff changeset
321 *(int *)v14 = 0;
Ritor1
parents:
diff changeset
322 if ( a3 & 2 )
Ritor1
parents:
diff changeset
323 *(int *)v14 = 1;
Ritor1
parents:
diff changeset
324 v15 = *(float *)&a6 - *(float *)&a8;
Ritor1
parents:
diff changeset
325 *(float *)&this->field_30C028 = v15;
Ritor1
parents:
diff changeset
326 v16 = sqrt((*(float *)&a6 + *(float *)&a6 - v15) * v15);
Ritor1
parents:
diff changeset
327 *(float *)&v12->field_30C02C = v16;
Ritor1
parents:
diff changeset
328 v17 = a5;
Ritor1
parents:
diff changeset
329 v18 = a9;
Ritor1
parents:
diff changeset
330 v12->flt_30C030 = 1.0 - (*(float *)&a6 - v16) / *(float *)&a6;
Ritor1
parents:
diff changeset
331 v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - *(float *)&a8 * v18->field_4.x);
Ritor1
parents:
diff changeset
332 v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - *(float *)&a8 * v18->field_4.y);
Ritor1
parents:
diff changeset
333 v19 = *(float *)&a6;
Ritor1
parents:
diff changeset
334 v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - *(float *)&a8 * v18->field_4.z);
Ritor1
parents:
diff changeset
335 v20 = v19 * v12->flt_30C030;
Ritor1
parents:
diff changeset
336 a8 = v13->pVertices;
Ritor1
parents:
diff changeset
337 v12->field_30C034 = v20;
Ritor1
parents:
diff changeset
338 v12->field_30C010 = v20 * v18->field_10.x;
Ritor1
parents:
diff changeset
339 v12->field_30C014 = v20 * v18->field_10.y;
Ritor1
parents:
diff changeset
340 v12->field_30C018 = v20 * v18->field_10.z;
Ritor1
parents:
diff changeset
341 v12->field_30C01C = v20 * v18->field_1C.x;
Ritor1
parents:
diff changeset
342 v12->field_30C020 = v20 * v18->field_1C.y;
Ritor1
parents:
diff changeset
343 v12->field_30C024 = v20 * v18->field_1C.z;
Ritor1
parents:
diff changeset
344 a6 = v13->field_C08;
Ritor1
parents:
diff changeset
345 v21 = (double)a6;
Ritor1
parents:
diff changeset
346 v22 = v21 - v12->field_30C01C;
Ritor1
parents:
diff changeset
347 a6 = v13->field_C0A;
Ritor1
parents:
diff changeset
348 v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
Ritor1
parents:
diff changeset
349 v23 = (double)a6;
Ritor1
parents:
diff changeset
350 v24 = v23 - v12->field_30C020 + v12->field_30C014;
Ritor1
parents:
diff changeset
351 v25 = (char *)&v13->pVertices[0].vWorldPosition.y;
Ritor1
parents:
diff changeset
352 a6 = v13->field_C0C;
Ritor1
parents:
diff changeset
353 v26 = 4;
Ritor1
parents:
diff changeset
354 v13->pVertices[0].vWorldPosition.y = v24;
Ritor1
parents:
diff changeset
355 v27 = (double)a6;
Ritor1
parents:
diff changeset
356 *(float *)&a6 = v27;
Ritor1
parents:
diff changeset
357 v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018;
Ritor1
parents:
diff changeset
358 v13->pVertices[0].u = 0.0;
Ritor1
parents:
diff changeset
359 v13->pVertices[0].v = 0.0;
Ritor1
parents:
diff changeset
360 v13->pVertices[1].vWorldPosition.x = v21 - v12->field_30C01C - v12->field_30C010;
Ritor1
parents:
diff changeset
361 v13->pVertices[1].vWorldPosition.y = v23 - v12->field_30C020 - v12->field_30C014;
Ritor1
parents:
diff changeset
362 v13->pVertices[1].vWorldPosition.z = v27 - v12->field_30C024 - v12->field_30C018;
Ritor1
parents:
diff changeset
363 v13->pVertices[1].u = 0.0;
Ritor1
parents:
diff changeset
364 v13->pVertices[1].v = 1.0;
Ritor1
parents:
diff changeset
365 v13->pVertices[2].vWorldPosition.x = v21 + v12->field_30C01C - v12->field_30C010;
Ritor1
parents:
diff changeset
366 v13->pVertices[2].vWorldPosition.y = v23 + v12->field_30C020 - v12->field_30C014;
Ritor1
parents:
diff changeset
367 v13->pVertices[2].vWorldPosition.z = v27 + v12->field_30C024 - v12->field_30C018;
Ritor1
parents:
diff changeset
368 v13->pVertices[2].u = 1.0;
Ritor1
parents:
diff changeset
369 v13->pVertices[2].v = 1.0;
Ritor1
parents:
diff changeset
370 v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010;
Ritor1
parents:
diff changeset
371 v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014;
Ritor1
parents:
diff changeset
372 v13->pVertices[3].vWorldPosition.z = *(float *)&a6 + v12->field_30C024 + v12->field_30C018;
Ritor1
parents:
diff changeset
373 v13->pVertices[3].u = 1.0;
Ritor1
parents:
diff changeset
374 v13->pVertices[3].v = 0.0;
Ritor1
parents:
diff changeset
375 do
Ritor1
parents:
diff changeset
376 {
Ritor1
parents:
diff changeset
377 v28 = v18->field_4.y * *(float *)v25
Ritor1
parents:
diff changeset
378 + *((float *)v25 - 1) * v18->field_4.x
Ritor1
parents:
diff changeset
379 + *((float *)v25 + 1) * v18->field_4.z
Ritor1
parents:
diff changeset
380 + v18->dist;
Ritor1
parents:
diff changeset
381 *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
Ritor1
parents:
diff changeset
382 *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
Ritor1
parents:
diff changeset
383 v25 += 48;
Ritor1
parents:
diff changeset
384 --v26;
Ritor1
parents:
diff changeset
385 *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z;
Ritor1
parents:
diff changeset
386 }
Ritor1
parents:
diff changeset
387 while ( v26 );
Ritor1
parents:
diff changeset
388 v13->uColorMultiplier = uColorMultiplier;
Ritor1
parents:
diff changeset
389 v40 = (unsigned int *)&v13->uNumVertices;
Ritor1
parents:
diff changeset
390 v39 = v13->pVertices;
Ritor1
parents:
diff changeset
391 v13->uNumVertices = 4;
Ritor1
parents:
diff changeset
392 v13->field_C14 = a2;
Ritor1
parents:
diff changeset
393 v29 = v18->field_4.z;
Ritor1
parents:
diff changeset
394 a6 = (int)&v13->uNumVertices;
Ritor1
parents:
diff changeset
395 v38 = v29;
Ritor1
parents:
diff changeset
396 result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, v40);
Ritor1
parents:
diff changeset
397 if ( result )
Ritor1
parents:
diff changeset
398 {
Ritor1
parents:
diff changeset
399 v31 = (unsigned int *)a6;
Ritor1
parents:
diff changeset
400 if ( !*(int *)a6 )
Ritor1
parents:
diff changeset
401 goto LABEL_24;
Ritor1
parents:
diff changeset
402 v32 = a8;
Ritor1
parents:
diff changeset
403 v40 = *(unsigned int **)a6;
Ritor1
parents:
diff changeset
404 v39 = a8;
Ritor1
parents:
diff changeset
405 pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
Ritor1
parents:
diff changeset
406 v40 = 0;
Ritor1
parents:
diff changeset
407 pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
Ritor1
parents:
diff changeset
408 if ( !(uClipFlags & 1) )
Ritor1
parents:
diff changeset
409 {
Ritor1
parents:
diff changeset
410 LABEL_19:
Ritor1
parents:
diff changeset
411 ++v12->field_308008;
Ritor1
parents:
diff changeset
412 v34 = 1024;
Ritor1
parents:
diff changeset
413 if ( v12->field_308008 == 1024 )
Ritor1
parents:
diff changeset
414 v12->field_308008 = 0;
Ritor1
parents:
diff changeset
415 if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
Ritor1
parents:
diff changeset
416 v34 = v12->std__vector_pDecals_size + 1;
Ritor1
parents:
diff changeset
417 v12->std__vector_pDecals_size = v34;
Ritor1
parents:
diff changeset
418 goto LABEL_24;
Ritor1
parents:
diff changeset
419 }
Ritor1
parents:
diff changeset
420 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
Ritor1
parents:
diff changeset
421 {
Ritor1
parents:
diff changeset
422 if ( uClipFlags & 2 )
Ritor1
parents:
diff changeset
423 {
Ritor1
parents:
diff changeset
424 v40 = (unsigned int *)&a8;
Ritor1
parents:
diff changeset
425 v39 = v12->pVertices;
Ritor1
parents:
diff changeset
426 pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
Ritor1
parents:
diff changeset
427 LABEL_14:
Ritor1
parents:
diff changeset
428 v40 = v31;
Ritor1
parents:
diff changeset
429 v39 = v12->pVertices;
Ritor1
parents:
diff changeset
430 pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31);
Ritor1
parents:
diff changeset
431 goto LABEL_18;
Ritor1
parents:
diff changeset
432 }
Ritor1
parents:
diff changeset
433 if ( uClipFlags & 4 )
Ritor1
parents:
diff changeset
434 {
Ritor1
parents:
diff changeset
435 v40 = (unsigned int *)&a8;
Ritor1
parents:
diff changeset
436 v39 = v12->pVertices;
Ritor1
parents:
diff changeset
437 pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
Ritor1
parents:
diff changeset
438 goto LABEL_14;
Ritor1
parents:
diff changeset
439 }
Ritor1
parents:
diff changeset
440 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
Ritor1
parents:
diff changeset
441 v35 = "Undefined clip flag specified";
Ritor1
parents:
diff changeset
442 }
Ritor1
parents:
diff changeset
443 else
Ritor1
parents:
diff changeset
444 {
Ritor1
parents:
diff changeset
445 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263";
Ritor1
parents:
diff changeset
446 v35 = "Lightpoly builder native indoor clipping not implemented";
Ritor1
parents:
diff changeset
447 }
Ritor1
parents:
diff changeset
448 MessageBoxA(nullptr, v35, (const char *)v39, 0);
Ritor1
parents:
diff changeset
449 LABEL_18:
Ritor1
parents:
diff changeset
450 if ( *(float *)&a8 != 0.0 )
Ritor1
parents:
diff changeset
451 goto LABEL_19;
Ritor1
parents:
diff changeset
452 LABEL_24:
Ritor1
parents:
diff changeset
453 result = 1;
Ritor1
parents:
diff changeset
454 }
Ritor1
parents:
diff changeset
455 return result;
Ritor1
parents:
diff changeset
456 }
Ritor1
parents:
diff changeset
457
Ritor1
parents:
diff changeset
458 //----- (0049BBBD) --------------------------------------------------------
Ritor1
parents:
diff changeset
459 bool DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
Ritor1
parents:
diff changeset
460 {
Ritor1
parents:
diff changeset
461 double v7; // st7@12
Ritor1
parents:
diff changeset
462
Ritor1
parents:
diff changeset
463 if (!pBloodsplatContainer->std__vector_pBloodsplats_size)
Ritor1
parents:
diff changeset
464 return true;
Ritor1
parents:
diff changeset
465
Ritor1
parents:
diff changeset
466 auto pFace = &pIndoor->pFaces[uFaceID];
Ritor1
parents:
diff changeset
467
Ritor1
parents:
diff changeset
468 if (pFace->uAttributes & 0x400000)
Ritor1
parents:
diff changeset
469 return true;
Ritor1
parents:
diff changeset
470 if (pFace->Animated())
Ritor1
parents:
diff changeset
471 return true;
Ritor1
parents:
diff changeset
472
Ritor1
parents:
diff changeset
473 for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
Ritor1
parents:
diff changeset
474 {
Ritor1
parents:
diff changeset
475 auto pBloodsplat = pBloodsplatContainer->std__vector_pBloodsplats + i;
Ritor1
parents:
diff changeset
476 if (pFace->pBounding.x1 - pBloodsplat->radius < pBloodsplat->x &&
Ritor1
parents:
diff changeset
477 pFace->pBounding.x2 + pBloodsplat->radius > pBloodsplat->x &&
Ritor1
parents:
diff changeset
478 pFace->pBounding.y1 - pBloodsplat->radius < pBloodsplat->y &&
Ritor1
parents:
diff changeset
479 pFace->pBounding.y2 + pBloodsplat->radius > pBloodsplat->y &&
Ritor1
parents:
diff changeset
480 pFace->pBounding.z1 - pBloodsplat->radius < pBloodsplat->z &&
Ritor1
parents:
diff changeset
481 pFace->pBounding.z2 + pBloodsplat->radius > pBloodsplat->z)
Ritor1
parents:
diff changeset
482 {
Ritor1
parents:
diff changeset
483 v7 = pFace->pFacePlane.vNormal.z * pBloodsplat->z +
Ritor1
parents:
diff changeset
484 pFace->pFacePlane.vNormal.y * pBloodsplat->y +
Ritor1
parents:
diff changeset
485 pFace->pFacePlane.vNormal.x * pBloodsplat->x +
Ritor1
parents:
diff changeset
486 pFace->pFacePlane.dist;
Ritor1
parents:
diff changeset
487 if (v7 <= pBloodsplat->radius)
Ritor1
parents:
diff changeset
488 {
Ritor1
parents:
diff changeset
489 pBloodsplat->dot_dist = v7;
Ritor1
parents:
diff changeset
490 std__vector_30B00C[uNumDecals++] = i;
Ritor1
parents:
diff changeset
491 }
Ritor1
parents:
diff changeset
492 }
Ritor1
parents:
diff changeset
493 }
Ritor1
parents:
diff changeset
494
Ritor1
parents:
diff changeset
495 return true;
Ritor1
parents:
diff changeset
496 }
Ritor1
parents:
diff changeset
497
Ritor1
parents:
diff changeset
498 //----- (0049BCEB) --------------------------------------------------------
Ritor1
parents:
diff changeset
499 char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace)
Ritor1
parents:
diff changeset
500 {
Ritor1
parents:
diff changeset
501 int v2; // edi@1
Ritor1
parents:
diff changeset
502 unsigned int v3; // eax@2
Ritor1
parents:
diff changeset
503 char *v4; // edx@5
Ritor1
parents:
diff changeset
504 double v5; // ST1C_8@12
Ritor1
parents:
diff changeset
505 double v6; // ST14_8@12
Ritor1
parents:
diff changeset
506 double v7; // ST0C_8@12
Ritor1
parents:
diff changeset
507 double v8; // st7@12
Ritor1
parents:
diff changeset
508 unsigned int v10; // [sp+20h] [bp-1Ch]@1
Ritor1
parents:
diff changeset
509
Ritor1
parents:
diff changeset
510 v2 = 0;
Ritor1
parents:
diff changeset
511 this->uNumDecals = 0;
Ritor1
parents:
diff changeset
512 v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
Ritor1
parents:
diff changeset
513 if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
Ritor1
parents:
diff changeset
514 {
Ritor1
parents:
diff changeset
515 v3 = pFace->uAttributes;
Ritor1
parents:
diff changeset
516 if ( !(v3 & 0x400000) )
Ritor1
parents:
diff changeset
517 {
Ritor1
parents:
diff changeset
518 if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
Ritor1
parents:
diff changeset
519 {
Ritor1
parents:
diff changeset
520 v4 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
Ritor1
parents:
diff changeset
521 do
Ritor1
parents:
diff changeset
522 {
Ritor1
parents:
diff changeset
523 if ( (double)pFace->pBoundingBox.x1 - *((float *)v4 + 2) < *((float *)v4 - 1) )
Ritor1
parents:
diff changeset
524 {
Ritor1
parents:
diff changeset
525 if ( (double)pFace->pBoundingBox.x2 + *((float *)v4 + 2) > *((float *)v4 - 1) )
Ritor1
parents:
diff changeset
526 {
Ritor1
parents:
diff changeset
527 if ( (double)pFace->pBoundingBox.y1 - *((float *)v4 + 2) < *(float *)v4 )
Ritor1
parents:
diff changeset
528 {
Ritor1
parents:
diff changeset
529 if ( (double)pFace->pBoundingBox.y2 + *((float *)v4 + 2) > *(float *)v4 )
Ritor1
parents:
diff changeset
530 {
Ritor1
parents:
diff changeset
531 if ( (double)pFace->pBoundingBox.z1 - *((float *)v4 + 2) < *((float *)v4 + 1) )
Ritor1
parents:
diff changeset
532 {
Ritor1
parents:
diff changeset
533 if ( (double)pFace->pBoundingBox.z2 + *((float *)v4 + 2) > *((float *)v4 + 1) )
Ritor1
parents:
diff changeset
534 {
Ritor1
parents:
diff changeset
535 v5 = *((float *)v4 - 1) + 6.7553994e15;
Ritor1
parents:
diff changeset
536 v6 = *(float *)v4 + 6.7553994e15;
Ritor1
parents:
diff changeset
537 v7 = *((float *)v4 + 1) + 6.7553994e15;
Ritor1
parents:
diff changeset
538 v8 = (double)((pFace->pFacePlane.dist
Ritor1
parents:
diff changeset
539 + LODWORD(v5) * pFace->pFacePlane.vNormal.x
Ritor1
parents:
diff changeset
540 + LODWORD(v6) * pFace->pFacePlane.vNormal.y
Ritor1
parents:
diff changeset
541 + LODWORD(v7) * pFace->pFacePlane.vNormal.z) >> 16);
Ritor1
parents:
diff changeset
542 if ( v8 <= *((float *)v4 + 2) )
Ritor1
parents:
diff changeset
543 {
Ritor1
parents:
diff changeset
544 *((float *)v4 + 3) = v8;
Ritor1
parents:
diff changeset
545 this->std__vector_30B00C[this->uNumDecals++] = v2;
Ritor1
parents:
diff changeset
546 }
Ritor1
parents:
diff changeset
547 }
Ritor1
parents:
diff changeset
548 }
Ritor1
parents:
diff changeset
549 }
Ritor1
parents:
diff changeset
550 }
Ritor1
parents:
diff changeset
551 }
Ritor1
parents:
diff changeset
552 }
Ritor1
parents:
diff changeset
553 ++v2;
Ritor1
parents:
diff changeset
554 v4 += 40;
Ritor1
parents:
diff changeset
555 }
Ritor1
parents:
diff changeset
556 while ( v2 < (signed int)v10 );
Ritor1
parents:
diff changeset
557 }
Ritor1
parents:
diff changeset
558 }
Ritor1
parents:
diff changeset
559 }
Ritor1
parents:
diff changeset
560 return 1;
Ritor1
parents:
diff changeset
561 }
Ritor1
parents:
diff changeset
562
Ritor1
parents:
diff changeset
563 //----- (0049BE8A) --------------------------------------------------------
Ritor1
parents:
diff changeset
564 bool DecalBuilder::_49BE8A(struct stru148 *a2, float a3, int a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
Ritor1
parents:
diff changeset
565 {
Ritor1
parents:
diff changeset
566 bool result; // eax@1
Ritor1
parents:
diff changeset
567 RenderVertexSoft *v8; // edi@3
Ritor1
parents:
diff changeset
568 float v9; // ebx@3
Ritor1
parents:
diff changeset
569 char *v10; // esi@3
Ritor1
parents:
diff changeset
570 float v11; // eax@5
Ritor1
parents:
diff changeset
571 float v12; // eax@6
Ritor1
parents:
diff changeset
572 double v13; // st7@13
Ritor1
parents:
diff changeset
573 double v14; // st7@19
Ritor1
parents:
diff changeset
574 int v15; // eax@20
Ritor1
parents:
diff changeset
575 int v16; // eax@22
Ritor1
parents:
diff changeset
576 int v17; // edx@24
Ritor1
parents:
diff changeset
577 DecalBuilder *v18; // eax@24
Ritor1
parents:
diff changeset
578 std::string v19; // [sp-18h] [bp-54h]@12
Ritor1
parents:
diff changeset
579 const char *v20; // [sp-8h] [bp-44h]@12
Ritor1
parents:
diff changeset
580 int v21; // [sp-4h] [bp-40h]@12
Ritor1
parents:
diff changeset
581 double v22; // [sp+Ch] [bp-30h]@19
Ritor1
parents:
diff changeset
582 unsigned int v23; // [sp+14h] [bp-28h]@1
Ritor1
parents:
diff changeset
583 DecalBuilder *v24; // [sp+18h] [bp-24h]@1
Ritor1
parents:
diff changeset
584 int v25; // [sp+1Ch] [bp-20h]@19
Ritor1
parents:
diff changeset
585 float v26; // [sp+20h] [bp-1Ch]@12
Ritor1
parents:
diff changeset
586 int v27; // [sp+24h] [bp-18h]@12
Ritor1
parents:
diff changeset
587 float v28; // [sp+28h] [bp-14h]@13
Ritor1
parents:
diff changeset
588 float v29; // [sp+2Ch] [bp-10h]@7
Ritor1
parents:
diff changeset
589 float v30; // [sp+30h] [bp-Ch]@6
Ritor1
parents:
diff changeset
590 float v31; // [sp+34h] [bp-8h]@6
Ritor1
parents:
diff changeset
591 bool v32; // [sp+38h] [bp-4h]@2
Ritor1
parents:
diff changeset
592
Ritor1
parents:
diff changeset
593 this->uNumDecals = 0;
Ritor1
parents:
diff changeset
594 result = pBloodsplatContainer->std__vector_pBloodsplats_size;
Ritor1
parents:
diff changeset
595 v24 = this;
Ritor1
parents:
diff changeset
596 v23 = pBloodsplatContainer->std__vector_pBloodsplats_size;
Ritor1
parents:
diff changeset
597 if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
Ritor1
parents:
diff changeset
598 {
Ritor1
parents:
diff changeset
599 v32 = 0;
Ritor1
parents:
diff changeset
600 if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
Ritor1
parents:
diff changeset
601 {
Ritor1
parents:
diff changeset
602 v8 = a5;
Ritor1
parents:
diff changeset
603 v9 = a3;
Ritor1
parents:
diff changeset
604 v10 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
Ritor1
parents:
diff changeset
605 while ( uStripType != 4 )
Ritor1
parents:
diff changeset
606 {
Ritor1
parents:
diff changeset
607 if ( uStripType == 3 )
Ritor1
parents:
diff changeset
608 {
Ritor1
parents:
diff changeset
609 if ( a7 )
Ritor1
parents:
diff changeset
610 {
Ritor1
parents:
diff changeset
611 a3 = v8->vWorldPosition.x;
Ritor1
parents:
diff changeset
612 v31 = v8[2].vWorldPosition.x;
Ritor1
parents:
diff changeset
613 v30 = v8[1].vWorldPosition.y;
Ritor1
parents:
diff changeset
614 v12 = v8[2].vWorldPosition.y;
Ritor1
parents:
diff changeset
615 goto LABEL_7;
Ritor1
parents:
diff changeset
616 }
Ritor1
parents:
diff changeset
617 a3 = v8[1].vWorldPosition.x;
Ritor1
parents:
diff changeset
618 v11 = v8[2].vWorldPosition.x;
Ritor1
parents:
diff changeset
619 LABEL_6:
Ritor1
parents:
diff changeset
620 v31 = v11;
Ritor1
parents:
diff changeset
621 v30 = v8[1].vWorldPosition.y;
Ritor1
parents:
diff changeset
622 v12 = v8->vWorldPosition.y;
Ritor1
parents:
diff changeset
623 LABEL_7:
Ritor1
parents:
diff changeset
624 v29 = v12;
Ritor1
parents:
diff changeset
625 goto LABEL_13;
Ritor1
parents:
diff changeset
626 }
Ritor1
parents:
diff changeset
627 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
Ritor1
parents:
diff changeset
628 LABEL_13:
Ritor1
parents:
diff changeset
629 v21 = uStripType;
Ritor1
parents:
diff changeset
630 v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType);
Ritor1
parents:
diff changeset
631 v21 = uStripType;
Ritor1
parents:
diff changeset
632 v28 = v13;
Ritor1
parents:
diff changeset
633 v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v8, uStripType);
Ritor1
parents:
diff changeset
634 if ( a3 - *((float *)v10 + 2) < *((float *)v10 - 1) )
Ritor1
parents:
diff changeset
635 {
Ritor1
parents:
diff changeset
636 if ( v31 + *((float *)v10 + 2) > *((float *)v10 - 1) )
Ritor1
parents:
diff changeset
637 {
Ritor1
parents:
diff changeset
638 if ( v30 - *((float *)v10 + 2) < *(float *)v10 )
Ritor1
parents:
diff changeset
639 {
Ritor1
parents:
diff changeset
640 if ( v29 + *((float *)v10 + 2) > *(float *)v10 )
Ritor1
parents:
diff changeset
641 {
Ritor1
parents:
diff changeset
642 if ( v28 - *((float *)v10 + 2) < *((float *)v10 + 1) )
Ritor1
parents:
diff changeset
643 {
Ritor1
parents:
diff changeset
644 if ( v26 + *((float *)v10 + 2) > *((float *)v10 + 1) )
Ritor1
parents:
diff changeset
645 {
Ritor1
parents:
diff changeset
646 Vec3_float_::NegDot(&v8->vWorldPosition, (Vec3_float_ *)LODWORD(v9), (float *)a4);
Ritor1
parents:
diff changeset
647 v26 = *(float *)(LODWORD(v9) + 4) * *(float *)v10
Ritor1
parents:
diff changeset
648 + *(float *)(LODWORD(v9) + 8) * *((float *)v10 + 1)
Ritor1
parents:
diff changeset
649 + *(unsigned int *)LODWORD(v9) * *((float *)v10 - 1)
Ritor1
parents:
diff changeset
650 + *(float *)a4;
Ritor1
parents:
diff changeset
651 v22 = v26 + 6.7553994e15;
Ritor1
parents:
diff changeset
652 v25 = LODWORD(v22);
Ritor1
parents:
diff changeset
653 v14 = (double)SLODWORD(v22);
Ritor1
parents:
diff changeset
654 v28 = v14;
Ritor1
parents:
diff changeset
655 if ( v14 <= *((float *)v10 + 2) )
Ritor1
parents:
diff changeset
656 {
Ritor1
parents:
diff changeset
657 v15 = *(int *)&a2->flags;
Ritor1
parents:
diff changeset
658 if ( v15 & 2 || BYTE1(v15) & 1 )
Ritor1
parents:
diff changeset
659 {
Ritor1
parents:
diff changeset
660 v16 = *((int *)v10 + 5);
Ritor1
parents:
diff changeset
661 if ( !(v16 & 1) )
Ritor1
parents:
diff changeset
662 {
Ritor1
parents:
diff changeset
663 LOBYTE(v16) = v16 | 1;
Ritor1
parents:
diff changeset
664 *((int *)v10 + 5) = v16;
Ritor1
parents:
diff changeset
665 *((_QWORD *)v10 + 3) = pEventTimer->Time();
Ritor1
parents:
diff changeset
666 }
Ritor1
parents:
diff changeset
667 }
Ritor1
parents:
diff changeset
668 v17 = v32;
Ritor1
parents:
diff changeset
669 *((int *)v10 + 3) = LODWORD(v28);
Ritor1
parents:
diff changeset
670 v18 = v24;
Ritor1
parents:
diff changeset
671 v24->std__vector_30B00C[v24->uNumDecals] = v17;
Ritor1
parents:
diff changeset
672 ++v18->uNumDecals;
Ritor1
parents:
diff changeset
673 }
Ritor1
parents:
diff changeset
674 }
Ritor1
parents:
diff changeset
675 }
Ritor1
parents:
diff changeset
676 }
Ritor1
parents:
diff changeset
677 }
Ritor1
parents:
diff changeset
678 }
Ritor1
parents:
diff changeset
679 }
Ritor1
parents:
diff changeset
680 ++v32;
Ritor1
parents:
diff changeset
681 v10 += 40;
Ritor1
parents:
diff changeset
682 result = v32;
Ritor1
parents:
diff changeset
683 if ( v32 >= (signed int)v23 )
Ritor1
parents:
diff changeset
684 goto LABEL_26;
Ritor1
parents:
diff changeset
685 }
Ritor1
parents:
diff changeset
686 a3 = v8->vWorldPosition.x;
Ritor1
parents:
diff changeset
687 v11 = v8[3].vWorldPosition.x;
Ritor1
parents:
diff changeset
688 goto LABEL_6;
Ritor1
parents:
diff changeset
689 }
Ritor1
parents:
diff changeset
690 }
Ritor1
parents:
diff changeset
691 LABEL_26:
Ritor1
parents:
diff changeset
692 LOBYTE(result) = 1;
Ritor1
parents:
diff changeset
693 return result;
Ritor1
parents:
diff changeset
694 }
Ritor1
parents:
diff changeset
695
Ritor1
parents:
diff changeset
696 //----- (0049C095) --------------------------------------------------------
Ritor1
parents:
diff changeset
697 void DecalBuilder::DrawDecal(Decal *pDecal, float z_bias)
Ritor1
parents:
diff changeset
698 {
Ritor1
parents:
diff changeset
699 signed int v21; // [sp+Ch] [bp-864h]@15
Ritor1
parents:
diff changeset
700 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
Ritor1
parents:
diff changeset
701
Ritor1
parents:
diff changeset
702 if (pDecal->uNumVertices < 3)
Ritor1
parents:
diff changeset
703 {
Ritor1
parents:
diff changeset
704 Log::Warning(L"Decal has < 3 vertices");
Ritor1
parents:
diff changeset
705 return;
Ritor1
parents:
diff changeset
706 }
Ritor1
parents:
diff changeset
707
Ritor1
parents:
diff changeset
708 float color_mult;
Ritor1
parents:
diff changeset
709 if ( pDecal->field_C1C & 1 )
Ritor1
parents:
diff changeset
710 color_mult = 1.0;
Ritor1
parents:
diff changeset
711 else
Ritor1
parents:
diff changeset
712 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
Ritor1
parents:
diff changeset
713
Ritor1
parents:
diff changeset
714 for (uint i = 0; i < pDecal->uNumVertices; ++i)
Ritor1
parents:
diff changeset
715 {
Ritor1
parents:
diff changeset
716 uint uTint = pRenderer->GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
Ritor1
parents:
diff changeset
717
Ritor1
parents:
diff changeset
718 uint uTintR = (uTint >> 16) & 0xFF,
Ritor1
parents:
diff changeset
719 uTintG = (uTint >> 8) & 0xFF,
Ritor1
parents:
diff changeset
720 uTintB = uTint & 0xFF;
Ritor1
parents:
diff changeset
721
Ritor1
parents:
diff changeset
722 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
Ritor1
parents:
diff changeset
723 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
Ritor1
parents:
diff changeset
724 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
Ritor1
parents:
diff changeset
725
Ritor1
parents:
diff changeset
726 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
Ritor1
parents:
diff changeset
727 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
Ritor1
parents:
diff changeset
728 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
Ritor1
parents:
diff changeset
729
Ritor1
parents:
diff changeset
730
Ritor1
parents:
diff changeset
731 float v15;
Ritor1
parents:
diff changeset
732 if (fabs(z_bias) < 1e-5)
Ritor1
parents:
diff changeset
733 v15 = 1.0 - 1.0 / ((1.0f / get_shading_dist_mist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
Ritor1
parents:
diff changeset
734 else
Ritor1
parents:
diff changeset
735 {
Ritor1
parents:
diff changeset
736 v15 = 1.0 - 1.0 / ((1.0f / get_shading_dist_mist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
Ritor1
parents:
diff changeset
737 if (v15 < 0.000099999997)
Ritor1
parents:
diff changeset
738 v15 = 0.000099999997;
Ritor1
parents:
diff changeset
739 }
Ritor1
parents:
diff changeset
740
Ritor1
parents:
diff changeset
741 pVerticesD3D[i].pos.z = v15;
Ritor1
parents:
diff changeset
742
Ritor1
parents:
diff changeset
743 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
Ritor1
parents:
diff changeset
744 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
Ritor1
parents:
diff changeset
745 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
Ritor1
parents:
diff changeset
746 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
Ritor1
parents:
diff changeset
747 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
Ritor1
parents:
diff changeset
748 pVerticesD3D[i].specular = 0;
Ritor1
parents:
diff changeset
749 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
Ritor1
parents:
diff changeset
750 }
Ritor1
parents:
diff changeset
751
Ritor1
parents:
diff changeset
752 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
Ritor1
parents:
diff changeset
753 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
Ritor1
parents:
diff changeset
754 else
Ritor1
parents:
diff changeset
755 v21 = D3DDP_DONOTLIGHT;
Ritor1
parents:
diff changeset
756
Ritor1
parents:
diff changeset
757 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
Ritor1
parents:
diff changeset
758 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
Ritor1
parents:
diff changeset
759 pVerticesD3D,
Ritor1
parents:
diff changeset
760 pDecal->uNumVertices,
Ritor1
parents:
diff changeset
761 v21));
Ritor1
parents:
diff changeset
762 }
Ritor1
parents:
diff changeset
763
Ritor1
parents:
diff changeset
764 //----- (0049C2CD) --------------------------------------------------------
Ritor1
parents:
diff changeset
765 void DecalBuilder::DrawDecals(float z_bias)
Ritor1
parents:
diff changeset
766 {
Ritor1
parents:
diff changeset
767 for (uint i = 0; i < std__vector_pDecals_size; ++i)
Ritor1
parents:
diff changeset
768 DrawDecal(std__vector_pDecals + i, z_bias);
Ritor1
parents:
diff changeset
769 }
Ritor1
parents:
diff changeset
770
Ritor1
parents:
diff changeset
771 //----- (0049C304) --------------------------------------------------------
Ritor1
parents:
diff changeset
772 void DecalBuilder::DrawBloodsplats()
Ritor1
parents:
diff changeset
773 {
Ritor1
parents:
diff changeset
774 if (!std__vector_pDecals_size)
Ritor1
parents:
diff changeset
775 return;
Ritor1
parents:
diff changeset
776
Ritor1
parents:
diff changeset
777 if (pRenderer->bUsingSpecular)
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
778 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
779 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
0
Ritor1
parents:
diff changeset
780
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
781 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
782 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
783 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
784 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
785 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
786 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
0
Ritor1
parents:
diff changeset
787
Ritor1
parents:
diff changeset
788 auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04");
Ritor1
parents:
diff changeset
789 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
Ritor1
parents:
diff changeset
790
Ritor1
parents:
diff changeset
791 DrawDecals(0.00039999999);
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
792 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
793 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
794 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
795 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
796 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
0
Ritor1
parents:
diff changeset
797
Ritor1
parents:
diff changeset
798 if (pRenderer->bUsingSpecular)
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 0
diff changeset
799 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
0
Ritor1
parents:
diff changeset
800 }
Ritor1
parents:
diff changeset
801
Ritor1
parents:
diff changeset
802 //----- (0049C550) --------------------------------------------------------
Ritor1
parents:
diff changeset
803 void DecalBuilder::DrawDecalDebugOutlines()
Ritor1
parents:
diff changeset
804 {
Ritor1
parents:
diff changeset
805 DecalBuilder *v1; // esi@1
Ritor1
parents:
diff changeset
806 signed int v2; // ebx@1
Ritor1
parents:
diff changeset
807 RenderVertexSoft *v3; // edi@2
Ritor1
parents:
diff changeset
808
Ritor1
parents:
diff changeset
809 v1 = this;
Ritor1
parents:
diff changeset
810 v2 = 0;
Ritor1
parents:
diff changeset
811 if ( (signed int)this->std__vector_pDecals_size > 0 )
Ritor1
parents:
diff changeset
812 {
Ritor1
parents:
diff changeset
813 v3 = this->std__vector_pDecals[0].pVertices;
Ritor1
parents:
diff changeset
814 do
Ritor1
parents:
diff changeset
815 {
Ritor1
parents:
diff changeset
816 pGame->pIndoorCameraD3D->debug_outline_sw(v3, *((int *)v3 - 1), 0xC86400u, 0.0);
Ritor1
parents:
diff changeset
817 ++v2;
Ritor1
parents:
diff changeset
818 v3 = (RenderVertexSoft *)((char *)v3 + 3104);
Ritor1
parents:
diff changeset
819 }
Ritor1
parents:
diff changeset
820 while ( v2 < (signed int)v1->std__vector_pDecals_size );
Ritor1
parents:
diff changeset
821 }
Ritor1
parents:
diff changeset
822 }
Ritor1
parents:
diff changeset
823
Ritor1
parents:
diff changeset
824 //----- (0040E4C2) --------------------------------------------------------
Ritor1
parents:
diff changeset
825 void Decal::Decal_base_ctor()
Ritor1
parents:
diff changeset
826 {
Ritor1
parents:
diff changeset
827 uNumVertices = -1;
Ritor1
parents:
diff changeset
828 for (uint i = 0; i < 64; ++i)
Ritor1
parents:
diff changeset
829 pVertices[i].flt_2C = 0.0f;
Ritor1
parents:
diff changeset
830 }