Mercurial > mm7
comparison Indoor.cpp @ 684:08b6d89d6a10
Слияние
author | Ritor1 |
---|---|
date | Fri, 15 Mar 2013 18:29:06 +0600 |
parents | d4497b76a863 ecfb1b3c9a39 |
children | 0f25d026acfa |
comparison
equal
deleted
inserted
replaced
683:d4497b76a863 | 684:08b6d89d6a10 |
---|---|
270 RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4 | 270 RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4 |
271 | 271 |
272 if (bD3D) | 272 if (bD3D) |
273 { | 273 { |
274 pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | 274 pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
275 for (uint i = 0; i < pBspRenderer->uNumFaceIDs; ++i) | 275 for (uint i = 0; i < pBspRenderer->num_faces; ++i) |
276 { | 276 { |
277 v2 = pBspRenderer->pFaceIDs[2 * i + 1]; | 277 v2 = pBspRenderer->faces[i].uNodeID; |
278 if ( pBspRenderer->pSectors[v2].std__vector_0007A8 == -1 ) | 278 if ( pBspRenderer->nodes[v2].std__vector_0007A8 == -1 ) |
279 { | 279 { |
280 v6 = 0; | 280 v6 = 0; |
281 v3 = 0; | 281 v3 = 0; |
282 } | 282 } |
283 else | 283 else |
284 { | 284 { |
285 v3 = pBspRenderer->pSectors[v2].std__vector_0007AC; | 285 v3 = pBspRenderer->nodes[v2].std__vector_0007AC; |
286 v6 = pBspRenderer->pSectors[v2].pVertices; | 286 v6 = pBspRenderer->nodes[v2].pVertices; |
287 } | 287 } |
288 IndoorLocation::ExecDraw_d3d(pBspRenderer->pFaceIDs[2 * i], v3, 4, v6); | 288 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, v3, 4, v6); |
289 } | 289 } |
290 } | 290 } |
291 else | 291 else |
292 { | 292 { |
293 for (uint j = 0; j < pBspRenderer->uNumFaceIDs; ++j ) | 293 for (uint j = 0; j < pBspRenderer->num_faces; ++j ) |
294 { | 294 { |
295 v5 = pBspRenderer->pFaceIDs[2 * j]; | 295 v5 = pBspRenderer->faces[j].uFaceID; |
296 pBLVRenderParams->field_7C = &pBspRenderer->pSectors[pBspRenderer->pFaceIDs[2 * j + 1]].field_C; | 296 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].field_C; |
297 IndoorLocation::ExecDraw_sw(v5); | 297 IndoorLocation::ExecDraw_sw(v5); |
298 } | 298 } |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
312 | 312 |
313 PrepareDrawLists_BLV(_this); | 313 PrepareDrawLists_BLV(_this); |
314 if (pBLVRenderParams->uPartySectorID) | 314 if (pBLVRenderParams->uPartySectorID) |
315 IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0); | 315 IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0); |
316 pRenderer->DrawBillboardList_BLV(); | 316 pRenderer->DrawBillboardList_BLV(); |
317 | |
317 if ( !pRenderer->pRenderD3D ) | 318 if ( !pRenderer->pRenderD3D ) |
318 { | 319 { |
319 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES) | 320 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES) |
320 pBspRenderer->DrawFaceOutlines(); | 321 pBspRenderer->DrawFaceOutlines(); |
321 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | 322 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) |
322 { | 323 { |
323 v1 = pBLVRenderParams->pRenderTarget; | 324 v1 = pBLVRenderParams->pRenderTarget; |
324 v6 = 0; | 325 v6 = 0; |
325 if ( (signed int)pBspRenderer->pNumSectors > 0 ) | 326 if ( (signed int)pBspRenderer->num_nodes > 0 ) |
326 { | 327 { |
327 v7 = 0; | 328 v7 = 0; |
328 v2 = (char *)&pBspRenderer->pSectors[0].field_C._viewport_space_w; | 329 v2 = (char *)&pBspRenderer->nodes[0].field_C._viewport_space_w; |
329 do | 330 do |
330 { | 331 { |
331 v3 = *((int *)v2 - 1); | 332 v3 = *((int *)v2 - 1); |
332 v4 = pRenderer->uTargetSurfacePitch * *((int *)v2 - 1); | 333 v4 = pRenderer->uTargetSurfacePitch * *((int *)v2 - 1); |
333 if ( v3 <= *(int *)v2 ) | 334 if ( v3 <= *(int *)v2 ) |
334 { | 335 { |
335 v5 = (char *)&pBspRenderer->pSectors[0].field_C.array_3D8[v3 + v7]; | 336 v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[v3 + v7]; |
336 do | 337 do |
337 { | 338 { |
338 v1[v4 + *((short *)v5 - 480)] = 255; | 339 v1[v4 + *((short *)v5 - 480)] = 255; |
339 ++v3; | 340 ++v3; |
340 v1[v4 + *(short *)v5] = 255; | 341 v1[v4 + *(short *)v5] = 255; |
345 } | 346 } |
346 ++v6; | 347 ++v6; |
347 v7 += 1126; | 348 v7 += 1126; |
348 v2 += 2252; | 349 v2 += 2252; |
349 } | 350 } |
350 while ( v6 < (signed int)pBspRenderer->pNumSectors ); | 351 while ( v6 < (signed int)pBspRenderer->num_nodes ); |
351 } | 352 } |
352 } | 353 } |
353 } | 354 } |
354 } | 355 } |
355 | 356 |
525 stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; | 526 stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; |
526 stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; | 527 stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; |
527 stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; | 528 stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; |
528 } | 529 } |
529 | 530 |
530 if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & 0x400000)) | 531 if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & FACE_DO_NOT_LIGHT)) |
531 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); | 532 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); |
532 | 533 |
533 if (pDecalBuilder->uNumDecals > 0) | 534 if (pDecalBuilder->uNumDecals > 0) |
534 pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); | 535 pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); |
535 | 536 |
562 LABEL_42: | 563 LABEL_42: |
563 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | 564 v27 = pBitmaps_LOD->pHardwareTextures[v23]; |
564 if (pFace->uAttributes & FACE_DO_NOT_LIGHT) | 565 if (pFace->uAttributes & FACE_DO_NOT_LIGHT) |
565 _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); | 566 _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); |
566 else | 567 else |
567 pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0); | 568 pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); |
568 return; | 569 return; |
569 } | 570 } |
570 //v17 = 0xFFFFFFFF; | 571 //v17 = 0xFFFFFFFF; |
571 v23 = pFace->uBitmapID; | 572 v23 = pFace->uBitmapID; |
572 goto LABEL_42; | 573 goto LABEL_42; |
1231 } | 1232 } |
1232 return result; | 1233 return result; |
1233 } | 1234 } |
1234 | 1235 |
1235 //----- (004B0EA8) -------------------------------------------------------- | 1236 //----- (004B0EA8) -------------------------------------------------------- |
1236 void BspRenderer::AddFaceToRenderList_d3d(int a2, unsigned int uFaceID) | 1237 void BspRenderer::AddFaceToRenderList_d3d(unsigned int node_id, unsigned int uFaceID) |
1237 { | 1238 { |
1238 //unsigned int v3; // edx@1 | 1239 //unsigned int v3; // edx@1 |
1239 //stru170 *v4; // ebx@1 | 1240 //stru170 *v4; // ebx@1 |
1240 //BLVFace *v5; // eax@1 | 1241 //BLVFace *v5; // eax@1 |
1241 //int v6; // ecx@2 | 1242 //int v6; // ecx@2 |
1242 unsigned __int16 v7; // ax@11 | 1243 unsigned __int16 v7; // ax@11 |
1243 Vec3_short_ *v8; // esi@15 | 1244 Vec3_short_ *v8; // esi@15 |
1244 int v9; // edx@15 | 1245 int v9; // edx@15 |
1245 signed int v10; // eax@18 | 1246 //signed int v10; // eax@18 |
1246 signed int v11; // edi@19 | 1247 //signed int v11; // edi@19 |
1247 signed int v12; // ecx@19 | 1248 //signed int v12; // ecx@19 |
1248 signed int v13; // esi@19 | 1249 //signed int v13; // esi@19 |
1249 signed int v14; // edx@20 | 1250 signed int v14; // edx@20 |
1250 int v15; // edx@24 | 1251 int v15; // edx@24 |
1251 //int v16; // esi@29 | 1252 //int v16; // esi@29 |
1252 //BLVFace *v17; // edi@34 | 1253 //BLVFace *v17; // edi@34 |
1253 unsigned __int16 v18; // ax@34 | 1254 unsigned __int16 v18; // ax@34 |
1261 //Vec3_short_ *v26; // eax@47 | 1262 //Vec3_short_ *v26; // eax@47 |
1262 //double v27; // st7@47 | 1263 //double v27; // st7@47 |
1263 //signed int v28; // ST28_4@47 | 1264 //signed int v28; // ST28_4@47 |
1264 char v29; // al@48 | 1265 char v29; // al@48 |
1265 signed int v30; // eax@51 | 1266 signed int v30; // eax@51 |
1266 int v31; // eax@52 | 1267 //int v31; // eax@52 |
1267 //unsigned int v32; // eax@55 | 1268 //unsigned int v32; // eax@55 |
1268 //__int16 v33; // cx@56 | 1269 //__int16 v33; // cx@56 |
1269 signed int v34; // [sp+Ch] [bp-14h]@18 | 1270 //signed int v34; // [sp+Ch] [bp-14h]@18 |
1270 //int a0; // [sp+14h] [bp-Ch]@2 | 1271 //int a0; // [sp+14h] [bp-Ch]@2 |
1271 //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36 | 1272 //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36 |
1272 signed int v37; // [sp+18h] [bp-8h]@19 | 1273 //signed int v37; // [sp+18h] [bp-8h]@19 |
1273 //stru10 *v38; // [sp+18h] [bp-8h]@36 | 1274 //stru10 *v38; // [sp+18h] [bp-8h]@36 |
1274 //BLVFace *v39; // [sp+1Ch] [bp-4h]@1 | 1275 //BLVFace *v39; // [sp+1Ch] [bp-4h]@1 |
1275 | 1276 |
1276 //v3 = uFaceID; | 1277 //v3 = uFaceID; |
1277 //v4 = this; | 1278 //v4 = this; |
1278 //v5 = &pIndoor->pFaces[uFaceID]; | 1279 //v5 = &pIndoor->pFaces[uFaceID]; |
1279 pSectors[pNumSectors].std__vector_0007A8 = -1; | 1280 nodes[num_nodes].std__vector_0007A8 = -1; |
1280 //v39 = &pIndoor->pFaces[uFaceID]; | 1281 //v39 = &pIndoor->pFaces[uFaceID]; |
1281 | 1282 |
1282 auto pFace = &pIndoor->pFaces[uFaceID]; | 1283 auto pFace = &pIndoor->pFaces[uFaceID]; |
1283 | 1284 |
1284 if (pFace->TwoSided()) | 1285 if (!pFace->Portal()) |
1285 { | 1286 { |
1286 auto p = &pSectors[a2]; | 1287 if (num_faces < 1000) |
1288 { | |
1289 faces[num_faces].uFaceID = uFaceID; | |
1290 faces[num_faces++].uNodeID = node_id; | |
1291 } | |
1292 return; | |
1293 } | |
1294 | |
1295 auto p = &nodes[node_id]; | |
1287 //v6 = (int)((char *)this + 2252 * a2); | 1296 //v6 = (int)((char *)this + 2252 * a2); |
1288 //a0 = v6; | 1297 //a0 = v6; |
1289 if (p->uFaceID == uFaceID) | 1298 if (p->uFaceID == uFaceID) |
1290 return; | 1299 return; |
1291 if (!a2 && | 1300 if (!node_id && |
1292 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && | 1301 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane |
1293 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && | 1302 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && |
1294 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && | 1303 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && |
1295 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && | 1304 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && |
1296 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && | 1305 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && |
1297 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) | 1306 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) |
1298 { | 1307 { |
1299 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | 1308 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x |
1300 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y | 1309 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y |
1301 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) | 1310 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane |
1302 { | 1311 { |
1303 v7 = pFace->uSectorID; | 1312 v7 = pFace->uSectorID; |
1304 if ( pSectors[0].uSectorID == v7 ) | 1313 if ( nodes[0].uSectorID == v7 ) // draw back sector |
1305 v7 = pFace->uBackSectorID; | 1314 v7 = pFace->uBackSectorID; |
1306 pSectors[pNumSectors].uSectorID = v7; | 1315 nodes[num_nodes].uSectorID = v7; |
1307 pSectors[pNumSectors].uFaceID = uFaceID; | 1316 nodes[num_nodes].uFaceID = uFaceID; |
1308 pSectors[pNumSectors].uViewportX = pBLVRenderParams->uViewportX; | 1317 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; |
1309 pSectors[pNumSectors].uViewportZ = pBLVRenderParams->uViewportZ; | 1318 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; |
1310 pSectors[pNumSectors].uViewportY = pBLVRenderParams->uViewportY; | 1319 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; |
1311 pSectors[pNumSectors].uViewportW = pBLVRenderParams->uViewportW; | 1320 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; |
1312 pSectors[pNumSectors++].field_C._43F9E1( | 1321 nodes[num_nodes++].field_C._43F9E1(pBLVRenderParams->uViewportX, |
1313 pBLVRenderParams->uViewportX, | 1322 pBLVRenderParams->uViewportY, |
1314 pBLVRenderParams->uViewportY, | 1323 pBLVRenderParams->uViewportZ, |
1315 pBLVRenderParams->uViewportZ, | 1324 pBLVRenderParams->uViewportW); |
1316 pBLVRenderParams->uViewportW); | 1325 AddBspNodeToRenderList(num_nodes - 1); |
1317 sub_440639(pNumSectors - 1); | |
1318 return; | 1326 return; |
1319 } | 1327 } |
1320 //v5 = v39; | 1328 //v5 = v39; |
1321 //v6 = a0; | 1329 //v6 = a0; |
1322 } | 1330 } |
1331 | |
1323 v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; | 1332 v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; |
1324 v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x) | 1333 v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x) |
1325 + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y) | 1334 + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y) |
1326 + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); | 1335 + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); |
1327 if (p->uSectorID != pFace->uSectorID) | 1336 if (p->uSectorID != pFace->uSectorID) |
1328 v9 = -v9; | 1337 v9 = -v9; |
1329 if ( v9 < 0 ) | 1338 if (v9 >= 0) |
1339 return; | |
1340 | |
1341 auto num_vertices = sub_423B5D(uFaceID); | |
1342 if (num_vertices < 2) | |
1343 return; | |
1344 | |
1345 auto face_min_screenspace_x = _50BAC8_screen_space_x[0], | |
1346 face_max_screenspace_x = _50BAC8_screen_space_x[0]; | |
1347 auto face_min_screenspace_y = _50B9D8_screen_space_y[0], | |
1348 face_max_screenspace_y = _50B9D8_screen_space_y[0]; | |
1349 for (uint i = 1; i < num_vertices; ++i) | |
1330 { | 1350 { |
1331 v10 = sub_423B5D(uFaceID); | 1351 if (face_min_screenspace_x > _50BAC8_screen_space_x[i]) |
1332 v34 = v10; | 1352 face_min_screenspace_x = _50BAC8_screen_space_x[i]; |
1333 if ( v10 ) | 1353 if (face_max_screenspace_x < _50BAC8_screen_space_x[i]) |
1334 { | 1354 face_max_screenspace_x = _50BAC8_screen_space_x[i]; |
1335 v11 = dword_50BAC8[0]; | 1355 |
1336 v12 = dword_50B9D8_ys[0]; | 1356 if (face_min_screenspace_y > _50B9D8_screen_space_y[i]) |
1337 a2 = dword_50BAC8[0]; | 1357 face_min_screenspace_y = _50B9D8_screen_space_y[i]; |
1358 if (face_max_screenspace_y < _50B9D8_screen_space_y[i]) | |
1359 face_max_screenspace_y = _50B9D8_screen_space_y[i]; | |
1360 } | |
1361 //v10 = sub_423B5D(uFaceID); | |
1362 //v34 = v10; | |
1363 //if ( v10 ) | |
1364 //{ | |
1365 /* v11 = _50BAC8_screen_space_x[0]; | |
1366 v12 = _50B9D8_screen_space_y[0]; | |
1367 a2 = _50BAC8_screen_space_x[0]; | |
1338 v13 = 1; | 1368 v13 = 1; |
1339 v37 = dword_50B9D8_ys[0]; | 1369 v37 = _50B9D8_screen_space_y[0]; |
1340 if ( v10 > 1 ) | 1370 if ( v10 > 1 ) |
1341 { | 1371 { |
1342 do | 1372 do |
1343 { | 1373 { |
1344 v14 = dword_50BAC8[v13]; | 1374 v14 = _50BAC8_screen_space_x[v13]; |
1345 if ( v14 < a2 ) | 1375 if ( v14 < a2 ) |
1346 a2 = dword_50BAC8[v13]; | 1376 a2 = _50BAC8_screen_space_x[v13]; |
1347 if ( v14 > v11 ) | 1377 if ( v14 > v11 ) |
1348 v11 = v14; | 1378 v11 = v14; |
1349 v15 = dword_50B9D8_ys[v13]; | 1379 v15 = _50B9D8_screen_space_y[v13]; |
1350 if ( v15 < v37 ) | 1380 if ( v15 < v37 ) |
1351 v37 = dword_50B9D8_ys[v13]; | 1381 v37 = _50B9D8_screen_space_y[v13]; |
1352 if ( v15 > v12 ) | 1382 if ( v15 > v12 ) |
1353 v12 = dword_50B9D8_ys[v13]; | 1383 v12 = _50B9D8_screen_space_y[v13]; |
1354 v10 = v34; | 1384 v10 = v34; |
1355 ++v13; | 1385 ++v13; |
1356 } | 1386 } |
1357 while ( v13 < v34 ); | 1387 while ( v13 < v34 ); |
1358 } | 1388 } |
1359 //v16 = a0; | 1389 //v16 = a0; |
1360 if (v11 >= p->uViewportX && | 1390 if (v11 >= p->uViewportX && |
1361 a2 <= p->uViewportZ && | 1391 a2 <= p->uViewportZ && |
1362 v12 >= p->uViewportY && | 1392 v12 >= p->uViewportY && |
1363 v37 <= p->uViewportW && | 1393 v37 <= p->uViewportW && |
1364 sub_424829(v10, &pSectors[pNumSectors].field_C, &p->field_C, uFaceID)) | 1394 sub_424829(v10, &nodes[num_nodes].field_C, &p->field_C, uFaceID))*/ |
1395 if (face_max_screenspace_x >= p->uViewportX && | |
1396 face_min_screenspace_x <= p->uViewportZ && | |
1397 face_max_screenspace_y >= p->uViewportY && | |
1398 face_min_screenspace_y <= p->uViewportW && | |
1399 sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID)) | |
1365 { | 1400 { |
1366 //v17 = v39; | 1401 //v17 = v39; |
1367 v18 = pFace->uSectorID; | 1402 v18 = pFace->uSectorID; |
1368 if (p->uSectorID == v18 ) | 1403 if (p->uSectorID == v18 ) |
1369 v18 = pFace->uBackSectorID; | 1404 v18 = pFace->uBackSectorID; |
1370 pSectors[pNumSectors].uSectorID = v18; | 1405 nodes[num_nodes].uSectorID = v18; |
1371 pSectors[pNumSectors].uFaceID = uFaceID; | 1406 nodes[num_nodes].uFaceID = uFaceID; |
1372 pSectors[pNumSectors].uViewportX = pBLVRenderParams->uViewportX; | 1407 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; |
1373 pSectors[pNumSectors].uViewportZ = pBLVRenderParams->uViewportZ; | 1408 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; |
1374 pSectors[pNumSectors].uViewportY = pBLVRenderParams->uViewportY; | 1409 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; |
1375 pSectors[pNumSectors].uViewportW = pBLVRenderParams->uViewportW; | 1410 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; |
1376 //v38 = pGame->pStru10Instance; | 1411 //v38 = pGame->pStru10Instance; |
1377 //a0a = pGame->pIndoorCameraD3D; | 1412 //a0a = pGame->pIndoorCameraD3D; |
1378 if (p->std__vector_0007A8 == -1 ) | 1413 if (p->std__vector_0007A8 == -1 ) |
1379 { | 1414 { |
1380 v29 = pGame->pStru10Instance->_49C681_DrawDebugStuff(pFace, pSectors[pNumSectors].std__vector_0007AC, | 1415 v29 = pGame->pStru10Instance->_49C681_DrawDebugStuff(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pVertices); |
1381 pSectors[pNumSectors].pVertices); | |
1382 } | 1416 } |
1383 else | 1417 else |
1384 { | 1418 { |
1385 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; | 1419 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; |
1386 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; | 1420 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; |
1387 | 1421 |
1388 //v23 = 0; | 1422 //v23 = 0; |
1389 a2 = pFace->uNumVertices; | 1423 unsigned int a2 = pFace->uNumVertices; |
1390 for (uint k = 0; k < pFace->uNumVertices; ++k) | 1424 for (uint k = 0; k < pFace->uNumVertices; ++k) |
1391 { | 1425 { |
1392 //v24 = (char *)&static_subAddFaceToRenderList_d3d_stru_F7AA08[0].vWorldPosition.z; | 1426 //v24 = (char *)&static_subAddFaceToRenderList_d3d_stru_F7AA08[0].vWorldPosition.z; |
1393 //do | 1427 //do |
1394 //{ | 1428 //{ |
1403 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pVertex->z; | 1437 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pVertex->z; |
1404 //v24 += 48; | 1438 //v24 += 48; |
1405 //} | 1439 //} |
1406 //while ( v23 < a2 ); | 1440 //while ( v23 < a2 ); |
1407 } | 1441 } |
1408 pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(static_subAddFaceToRenderList_d3d_stru_F7AA08, | 1442 pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum( |
1409 (unsigned int *)&a2, static_subAddFaceToRenderList_d3d_stru_F79E08, p->std__vector_0007AC, 4, 0, 0); | 1443 static_subAddFaceToRenderList_d3d_stru_F7AA08, |
1410 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2, pSectors[pNumSectors].std__vector_0007AC, | 1444 &a2, |
1411 pSectors[pNumSectors].pVertices); | 1445 static_subAddFaceToRenderList_d3d_stru_F79E08, |
1446 p->std__vector_0007AC, | |
1447 4, | |
1448 0, | |
1449 0); | |
1450 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, (int *)&a2, | |
1451 nodes[num_nodes].std__vector_0007AC, | |
1452 nodes[num_nodes].pVertices); | |
1412 } | 1453 } |
1413 if ( v29 ) | 1454 if ( v29 ) |
1414 { | 1455 { |
1415 pSectors[pNumSectors].std__vector_0007A8 = uFaceID; | 1456 nodes[num_nodes].std__vector_0007A8 = uFaceID; |
1416 v30 = pNumSectors; | 1457 v30 = num_nodes; |
1417 if ( v30 < 150 ) | 1458 if ( v30 < 150 ) |
1418 { | 1459 { |
1419 v31 = v30 + 1; | 1460 //v31 = v30 + 1; |
1420 pNumSectors = v31; | 1461 num_nodes = v30 + 1; |
1421 sub_440639(v31 - 1); | 1462 AddBspNodeToRenderList(v30); |
1422 } | 1463 } |
1423 } | 1464 } |
1424 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | 1465 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) |
1425 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); | 1466 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); |
1426 } | 1467 } |
1427 } | |
1428 } | |
1429 } | |
1430 else | |
1431 { | |
1432 if (uNumFaceIDs < 1000 ) | |
1433 { | |
1434 pFaceIDs[2 * uNumFaceIDs] = uFaceID; | |
1435 pFaceIDs[2 * uNumFaceIDs++ + 1] = a2; | |
1436 } | |
1437 } | |
1438 } | 1468 } |
1439 | 1469 |
1470 | |
1440 //----- (004AFB86) -------------------------------------------------------- | 1471 //----- (004AFB86) -------------------------------------------------------- |
1441 void BspRenderer::AddFaceToRenderList_sw(int a2, unsigned int uFaceID) | 1472 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) |
1442 { | 1473 { |
1443 BspRenderer *v3; // ebx@1 | 1474 BspRenderer *v3; // ebx@1 |
1444 BLVFace *v4; // eax@1 | 1475 BLVFace *v4; // eax@1 |
1445 char *v5; // ecx@2 | 1476 char *v5; // ecx@2 |
1446 unsigned __int16 v6; // ax@11 | 1477 unsigned __int16 v6; // ax@11 |
1463 signed int v23; // [sp+28h] [bp+8h]@20 | 1494 signed int v23; // [sp+28h] [bp+8h]@20 |
1464 | 1495 |
1465 v3 = this; | 1496 v3 = this; |
1466 v4 = &pIndoor->pFaces[uFaceID]; | 1497 v4 = &pIndoor->pFaces[uFaceID]; |
1467 v21 = v4; | 1498 v21 = v4; |
1468 if (v4->TwoSided()) | 1499 if (v4->Portal()) |
1469 { | 1500 { |
1470 v5 = (char *)this + 2252 * a2; | 1501 v5 = (char *)this + 2252 * node_id; |
1471 v20 = v5; | 1502 v20 = v5; |
1472 if ( uFaceID == *((short *)v5 + 2982) ) | 1503 if ( uFaceID == *((short *)v5 + 2982) ) |
1473 return; | 1504 return; |
1474 if ( !a2 | 1505 if (!node_id |
1475 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 | 1506 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 |
1476 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 | 1507 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 |
1477 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 | 1508 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 |
1478 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 | 1509 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 |
1479 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 | 1510 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 |
1482 if ( abs(v4->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x | 1513 if ( abs(v4->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x |
1483 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y | 1514 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y |
1484 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) | 1515 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) |
1485 { | 1516 { |
1486 v6 = v21->uSectorID; | 1517 v6 = v21->uSectorID; |
1487 if ( v3->pSectors[0].uSectorID == v6 ) | 1518 if ( v3->nodes[0].uSectorID == v6 ) |
1488 v6 = v21->uBackSectorID; | 1519 v6 = v21->uBackSectorID; |
1489 v3->pSectors[v3->pNumSectors].uSectorID = v6; | 1520 v3->nodes[v3->num_nodes].uSectorID = v6; |
1490 v3->pSectors[v3->pNumSectors].uFaceID = uFaceID; | 1521 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
1491 v3->pSectors[v3->pNumSectors].uViewportX = LOWORD(pBLVRenderParams->uViewportX); | 1522 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
1492 v3->pSectors[v3->pNumSectors].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); | 1523 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
1493 v3->pSectors[v3->pNumSectors].uViewportY = LOWORD(pBLVRenderParams->uViewportY); | 1524 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
1494 v3->pSectors[v3->pNumSectors].uViewportW = LOWORD(pBLVRenderParams->uViewportW); | 1525 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
1495 v3->pSectors[v3->pNumSectors++].field_C._43F9E1( | 1526 v3->nodes[v3->num_nodes++].field_C._43F9E1( |
1496 SLOWORD(pBLVRenderParams->uViewportX), | 1527 SLOWORD(pBLVRenderParams->uViewportX), |
1497 pBLVRenderParams->uViewportY, | 1528 pBLVRenderParams->uViewportY, |
1498 SLOWORD(pBLVRenderParams->uViewportZ), | 1529 SLOWORD(pBLVRenderParams->uViewportZ), |
1499 pBLVRenderParams->uViewportW); | 1530 pBLVRenderParams->uViewportW); |
1500 v7 = v3->pNumSectors - 1; | 1531 v7 = v3->num_nodes - 1; |
1501 goto LABEL_14; | 1532 goto LABEL_14; |
1502 } | 1533 } |
1503 v4 = v21; | 1534 v4 = v21; |
1504 v5 = v20; | 1535 v5 = v20; |
1505 } | 1536 } |
1513 { | 1544 { |
1514 v10 = sub_423B5D(uFaceID); | 1545 v10 = sub_423B5D(uFaceID); |
1515 v19 = v10; | 1546 v19 = v10; |
1516 if ( v10 ) | 1547 if ( v10 ) |
1517 { | 1548 { |
1518 v11 = dword_50BAC8[0]; | 1549 v11 = _50BAC8_screen_space_x[0]; |
1519 v12 = dword_50B9D8_ys[0]; | 1550 v12 = _50B9D8_screen_space_y[0]; |
1520 v23 = dword_50BAC8[0]; | 1551 v23 = _50BAC8_screen_space_x[0]; |
1521 v13 = 1; | 1552 v13 = 1; |
1522 v22 = dword_50B9D8_ys[0]; | 1553 v22 = _50B9D8_screen_space_y[0]; |
1523 if ( v10 > 1 ) | 1554 if ( v10 > 1 ) |
1524 { | 1555 { |
1525 do | 1556 do |
1526 { | 1557 { |
1527 v14 = dword_50BAC8[v13]; | 1558 v14 = _50BAC8_screen_space_x[v13]; |
1528 if ( v14 < v23 ) | 1559 if ( v14 < v23 ) |
1529 v23 = dword_50BAC8[v13]; | 1560 v23 = _50BAC8_screen_space_x[v13]; |
1530 if ( v14 > v11 ) | 1561 if ( v14 > v11 ) |
1531 v11 = dword_50BAC8[v13]; | 1562 v11 = _50BAC8_screen_space_x[v13]; |
1532 v15 = dword_50B9D8_ys[v13]; | 1563 v15 = _50B9D8_screen_space_y[v13]; |
1533 if ( v15 < v22 ) | 1564 if ( v15 < v22 ) |
1534 v22 = dword_50B9D8_ys[v13]; | 1565 v22 = _50B9D8_screen_space_y[v13]; |
1535 if ( v15 > v12 ) | 1566 if ( v15 > v12 ) |
1536 v12 = dword_50B9D8_ys[v13]; | 1567 v12 = _50B9D8_screen_space_y[v13]; |
1537 v10 = v19; | 1568 v10 = v19; |
1538 ++v13; | 1569 ++v13; |
1539 } | 1570 } |
1540 while ( v13 < v19 ); | 1571 while ( v13 < v19 ); |
1541 } | 1572 } |
1542 if ( v11 >= *((short *)v20 + 2005) | 1573 if ( v11 >= *((short *)v20 + 2005) |
1543 && v23 <= *((short *)v20 + 2007) | 1574 && v23 <= *((short *)v20 + 2007) |
1544 && v12 >= *((short *)v20 + 2006) | 1575 && v12 >= *((short *)v20 + 2006) |
1545 && v22 <= *((short *)v20 + 2008) | 1576 && v22 <= *((short *)v20 + 2008) |
1546 && sub_424829(v10, &v3->pSectors[v3->pNumSectors].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) ) | 1577 && sub_424829(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) ) |
1547 { | 1578 { |
1548 v16 = v21->uSectorID; | 1579 v16 = v21->uSectorID; |
1549 if ( *((short *)v20 + 2004) == v16 ) | 1580 if ( *((short *)v20 + 2004) == v16 ) |
1550 v16 = v21->uBackSectorID; | 1581 v16 = v21->uBackSectorID; |
1551 v3->pSectors[v3->pNumSectors].uSectorID = v16; | 1582 v3->nodes[v3->num_nodes].uSectorID = v16; |
1552 v3->pSectors[v3->pNumSectors].uFaceID = uFaceID; | 1583 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
1553 v3->pSectors[v3->pNumSectors].uViewportX = LOWORD(pBLVRenderParams->uViewportX); | 1584 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
1554 v3->pSectors[v3->pNumSectors].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); | 1585 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
1555 v3->pSectors[v3->pNumSectors].uViewportY = LOWORD(pBLVRenderParams->uViewportY); | 1586 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
1556 v3->pSectors[v3->pNumSectors].uViewportW = LOWORD(pBLVRenderParams->uViewportW); | 1587 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
1557 v17 = v3->pNumSectors; | 1588 v17 = v3->num_nodes; |
1558 if ( v17 < 150 ) | 1589 if ( v17 < 150 ) |
1559 { | 1590 { |
1560 v18 = v17 + 1; | 1591 v18 = v17 + 1; |
1561 v3->pNumSectors = v18; | 1592 v3->num_nodes = v18; |
1562 v7 = v18 - 1; | 1593 v7 = v18 - 1; |
1563 LABEL_14: | 1594 LABEL_14: |
1564 sub_440639(v7); | 1595 AddBspNodeToRenderList(v7); |
1565 return; | 1596 return; |
1566 } | 1597 } |
1567 } | 1598 } |
1568 } | 1599 } |
1569 } | 1600 } |
1570 } | 1601 } |
1571 else | 1602 else |
1572 { | 1603 { |
1573 if ( (signed int)this->uNumFaceIDs < 1000 ) | 1604 if (num_faces < 1000) |
1574 { | 1605 { |
1575 this->pFaceIDs[2 * this->uNumFaceIDs] = uFaceID; | 1606 faces[num_faces].uFaceID = uFaceID; |
1576 this->pFaceIDs[2 * this->uNumFaceIDs++ + 1] = a2; | 1607 faces[num_faces++].uNodeID = node_id; |
1577 } | 1608 } |
1578 } | 1609 } |
1579 } | 1610 } |
1580 | 1611 |
1581 //----- (004B0967) -------------------------------------------------------- | 1612 //----- (004B0967) -------------------------------------------------------- |
1588 int v4; // eax@6 | 1619 int v4; // eax@6 |
1589 unsigned __int16 *v5; // edx@6 | 1620 unsigned __int16 *v5; // edx@6 |
1590 int v6; // ecx@7 | 1621 int v6; // ecx@7 |
1591 int v7; // esi@8 | 1622 int v7; // esi@8 |
1592 | 1623 |
1593 for ( i = 0; i < (signed int)pBspRenderer->uNumFaceIDs; ++i ) | 1624 for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i ) |
1594 { | 1625 { |
1595 v1 = pBspRenderer->pFaceIDs[2 * i]; | 1626 v1 = pBspRenderer->faces[i].uFaceID; |
1596 if ( v1 >= 0 ) | 1627 if ( v1 >= 0 ) |
1597 { | 1628 { |
1598 if ( v1 < (signed int)pIndoor->uNumFaces ) | 1629 if ( v1 < (signed int)pIndoor->uNumFaces ) |
1599 { | 1630 { |
1600 v2 = pBspRenderer->pFaceIDs[2 * i]; | 1631 v2 = pBspRenderer->faces[i].uFaceID; |
1601 pBLVRenderParams->field_7C = &pBspRenderer->pSectors[pBspRenderer->pFaceIDs[2 * i + 1]].field_C; | 1632 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; |
1602 v3 = sub_423B5D(v2); | 1633 v3 = sub_423B5D(v2); |
1603 if ( v3 ) | 1634 if ( v3 ) |
1604 { | 1635 { |
1605 if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) | 1636 if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) |
1606 { | 1637 { |
2469 else | 2500 else |
2470 { | 2501 { |
2471 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0); | 2502 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0); |
2472 return 0; | 2503 return 0; |
2473 } | 2504 } |
2474 | |
2475 assert(sizeof(Vec3_short_) == 6); | |
2476 assert(sizeof(BLVFace) == 96); | |
2477 assert(sizeof(BLVFaceExtra) == 36); | |
2478 assert(sizeof(BLVSector) == 116); | |
2479 assert(sizeof(LevelDecoration) == 32); | |
2480 assert(sizeof(BLVLightMM7) == 16); | |
2481 assert(sizeof(BSPNode) == 8); | |
2482 assert(sizeof(SpawnPointMM7) == 24); | |
2483 assert(sizeof(DDM_DLV_Header) == 40); | |
2484 assert(sizeof(Actor) == 836); | |
2485 assert(sizeof(SpriteObject) == 112); | |
2486 assert(sizeof(Chest) == 5324); | |
2487 assert(sizeof(stru123) == 0xC8); | |
2488 assert(sizeof(BLVMapOutline) == 12); | |
2489 | 2505 |
2490 bLoaded = true; | 2506 bLoaded = true; |
2491 | 2507 |
2492 auto pData = (char *)pRawBLV; | 2508 auto pData = (char *)pRawBLV; |
2493 | 2509 |
2513 auto pFace = pFaces + i; | 2529 auto pFace = pFaces + i; |
2514 | 2530 |
2515 pFace->pVertexIDs = ptr_2AC + j; | 2531 pFace->pVertexIDs = ptr_2AC + j; |
2516 | 2532 |
2517 j += pFace->uNumVertices + 1; | 2533 j += pFace->uNumVertices + 1; |
2518 pFace->pXInterceptDisplacements = ptr_2AC + j; | 2534 pFace->pXInterceptDisplacements = (short *)(ptr_2AC + j); |
2519 | 2535 |
2520 j += pFace->uNumVertices + 1; | 2536 j += pFace->uNumVertices + 1; |
2521 pFace->pYInterceptDisplacements = ptr_2AC + j; | 2537 pFace->pYInterceptDisplacements = (short *)(ptr_2AC + j); |
2522 | 2538 |
2523 j += pFace->uNumVertices + 1; | 2539 j += pFace->uNumVertices + 1; |
2524 pFace->pZInterceptDisplacements = ptr_2AC + j; | 2540 pFace->pZInterceptDisplacements = (short *)(ptr_2AC + j); |
2525 | 2541 |
2526 j += pFace->uNumVertices + 1; | 2542 j += pFace->uNumVertices + 1; |
2527 pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j); | 2543 pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j); |
2528 | 2544 |
2529 j += pFace->uNumVertices + 1; | 2545 j += pFace->uNumVertices + 1; |