Mercurial > mm7
comparison Indoor.cpp @ 676:ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
author | Nomad |
---|---|
date | Fri, 15 Mar 2013 04:13:24 +0200 |
parents | a5750c94b022 |
children | 35a97ce58790 08b6d89d6a10 |
comparison
equal
deleted
inserted
replaced
675:92c1e1250e7c | 676:ecfb1b3c9a39 |
---|---|
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 //{ |
1405 //} | 1439 //} |
1406 //while ( v23 < a2 ); | 1440 //while ( v23 < a2 ); |
1407 } | 1441 } |
1408 pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum( | 1442 pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum( |
1409 static_subAddFaceToRenderList_d3d_stru_F7AA08, | 1443 static_subAddFaceToRenderList_d3d_stru_F7AA08, |
1410 (unsigned int *)&a2, | 1444 &a2, |
1411 static_subAddFaceToRenderList_d3d_stru_F79E08, | 1445 static_subAddFaceToRenderList_d3d_stru_F79E08, |
1412 p->std__vector_0007AC, | 1446 p->std__vector_0007AC, |
1413 4, | 1447 4, |
1414 0, | 1448 0, |
1415 0); | 1449 0); |
1416 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2, | 1450 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, (int *)&a2, |
1417 pSectors[pNumSectors].std__vector_0007AC, | 1451 nodes[num_nodes].std__vector_0007AC, |
1418 pSectors[pNumSectors].pVertices); | 1452 nodes[num_nodes].pVertices); |
1419 } | 1453 } |
1420 if ( v29 ) | 1454 if ( v29 ) |
1421 { | 1455 { |
1422 pSectors[pNumSectors].std__vector_0007A8 = uFaceID; | 1456 nodes[num_nodes].std__vector_0007A8 = uFaceID; |
1423 v30 = pNumSectors; | 1457 v30 = num_nodes; |
1424 if ( v30 < 150 ) | 1458 if ( v30 < 150 ) |
1425 { | 1459 { |
1426 v31 = v30 + 1; | 1460 //v31 = v30 + 1; |
1427 pNumSectors = v31; | 1461 num_nodes = v30 + 1; |
1428 sub_440639(v31 - 1); | 1462 AddBspNodeToRenderList(v30); |
1429 } | 1463 } |
1430 } | 1464 } |
1431 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | 1465 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) |
1432 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); | 1466 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); |
1433 } | 1467 } |
1434 } | |
1435 } | |
1436 } | |
1437 else | |
1438 { | |
1439 if (uNumFaceIDs < 1000 ) | |
1440 { | |
1441 pFaceIDs[2 * uNumFaceIDs] = uFaceID; | |
1442 pFaceIDs[2 * uNumFaceIDs++ + 1] = a2; | |
1443 } | |
1444 } | |
1445 } | 1468 } |
1446 | 1469 |
1447 | 1470 |
1448 //----- (004AFB86) -------------------------------------------------------- | 1471 //----- (004AFB86) -------------------------------------------------------- |
1449 void BspRenderer::AddFaceToRenderList_sw(int a2, unsigned int uFaceID) | 1472 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) |
1450 { | 1473 { |
1451 BspRenderer *v3; // ebx@1 | 1474 BspRenderer *v3; // ebx@1 |
1452 BLVFace *v4; // eax@1 | 1475 BLVFace *v4; // eax@1 |
1453 char *v5; // ecx@2 | 1476 char *v5; // ecx@2 |
1454 unsigned __int16 v6; // ax@11 | 1477 unsigned __int16 v6; // ax@11 |
1471 signed int v23; // [sp+28h] [bp+8h]@20 | 1494 signed int v23; // [sp+28h] [bp+8h]@20 |
1472 | 1495 |
1473 v3 = this; | 1496 v3 = this; |
1474 v4 = &pIndoor->pFaces[uFaceID]; | 1497 v4 = &pIndoor->pFaces[uFaceID]; |
1475 v21 = v4; | 1498 v21 = v4; |
1476 if (v4->TwoSided()) | 1499 if (v4->Portal()) |
1477 { | 1500 { |
1478 v5 = (char *)this + 2252 * a2; | 1501 v5 = (char *)this + 2252 * node_id; |
1479 v20 = v5; | 1502 v20 = v5; |
1480 if ( uFaceID == *((short *)v5 + 2982) ) | 1503 if ( uFaceID == *((short *)v5 + 2982) ) |
1481 return; | 1504 return; |
1482 if ( !a2 | 1505 if (!node_id |
1483 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 | 1506 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 |
1484 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 | 1507 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 |
1485 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 | 1508 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 |
1486 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 | 1509 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 |
1487 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 | 1510 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 |
1490 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 |
1491 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y | 1514 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y |
1492 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) | 1515 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) |
1493 { | 1516 { |
1494 v6 = v21->uSectorID; | 1517 v6 = v21->uSectorID; |
1495 if ( v3->pSectors[0].uSectorID == v6 ) | 1518 if ( v3->nodes[0].uSectorID == v6 ) |
1496 v6 = v21->uBackSectorID; | 1519 v6 = v21->uBackSectorID; |
1497 v3->pSectors[v3->pNumSectors].uSectorID = v6; | 1520 v3->nodes[v3->num_nodes].uSectorID = v6; |
1498 v3->pSectors[v3->pNumSectors].uFaceID = uFaceID; | 1521 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
1499 v3->pSectors[v3->pNumSectors].uViewportX = LOWORD(pBLVRenderParams->uViewportX); | 1522 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
1500 v3->pSectors[v3->pNumSectors].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); | 1523 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
1501 v3->pSectors[v3->pNumSectors].uViewportY = LOWORD(pBLVRenderParams->uViewportY); | 1524 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
1502 v3->pSectors[v3->pNumSectors].uViewportW = LOWORD(pBLVRenderParams->uViewportW); | 1525 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
1503 v3->pSectors[v3->pNumSectors++].field_C._43F9E1( | 1526 v3->nodes[v3->num_nodes++].field_C._43F9E1( |
1504 SLOWORD(pBLVRenderParams->uViewportX), | 1527 SLOWORD(pBLVRenderParams->uViewportX), |
1505 pBLVRenderParams->uViewportY, | 1528 pBLVRenderParams->uViewportY, |
1506 SLOWORD(pBLVRenderParams->uViewportZ), | 1529 SLOWORD(pBLVRenderParams->uViewportZ), |
1507 pBLVRenderParams->uViewportW); | 1530 pBLVRenderParams->uViewportW); |
1508 v7 = v3->pNumSectors - 1; | 1531 v7 = v3->num_nodes - 1; |
1509 goto LABEL_14; | 1532 goto LABEL_14; |
1510 } | 1533 } |
1511 v4 = v21; | 1534 v4 = v21; |
1512 v5 = v20; | 1535 v5 = v20; |
1513 } | 1536 } |
1521 { | 1544 { |
1522 v10 = sub_423B5D(uFaceID); | 1545 v10 = sub_423B5D(uFaceID); |
1523 v19 = v10; | 1546 v19 = v10; |
1524 if ( v10 ) | 1547 if ( v10 ) |
1525 { | 1548 { |
1526 v11 = dword_50BAC8[0]; | 1549 v11 = _50BAC8_screen_space_x[0]; |
1527 v12 = dword_50B9D8_ys[0]; | 1550 v12 = _50B9D8_screen_space_y[0]; |
1528 v23 = dword_50BAC8[0]; | 1551 v23 = _50BAC8_screen_space_x[0]; |
1529 v13 = 1; | 1552 v13 = 1; |
1530 v22 = dword_50B9D8_ys[0]; | 1553 v22 = _50B9D8_screen_space_y[0]; |
1531 if ( v10 > 1 ) | 1554 if ( v10 > 1 ) |
1532 { | 1555 { |
1533 do | 1556 do |
1534 { | 1557 { |
1535 v14 = dword_50BAC8[v13]; | 1558 v14 = _50BAC8_screen_space_x[v13]; |
1536 if ( v14 < v23 ) | 1559 if ( v14 < v23 ) |
1537 v23 = dword_50BAC8[v13]; | 1560 v23 = _50BAC8_screen_space_x[v13]; |
1538 if ( v14 > v11 ) | 1561 if ( v14 > v11 ) |
1539 v11 = dword_50BAC8[v13]; | 1562 v11 = _50BAC8_screen_space_x[v13]; |
1540 v15 = dword_50B9D8_ys[v13]; | 1563 v15 = _50B9D8_screen_space_y[v13]; |
1541 if ( v15 < v22 ) | 1564 if ( v15 < v22 ) |
1542 v22 = dword_50B9D8_ys[v13]; | 1565 v22 = _50B9D8_screen_space_y[v13]; |
1543 if ( v15 > v12 ) | 1566 if ( v15 > v12 ) |
1544 v12 = dword_50B9D8_ys[v13]; | 1567 v12 = _50B9D8_screen_space_y[v13]; |
1545 v10 = v19; | 1568 v10 = v19; |
1546 ++v13; | 1569 ++v13; |
1547 } | 1570 } |
1548 while ( v13 < v19 ); | 1571 while ( v13 < v19 ); |
1549 } | 1572 } |
1550 if ( v11 >= *((short *)v20 + 2005) | 1573 if ( v11 >= *((short *)v20 + 2005) |
1551 && v23 <= *((short *)v20 + 2007) | 1574 && v23 <= *((short *)v20 + 2007) |
1552 && v12 >= *((short *)v20 + 2006) | 1575 && v12 >= *((short *)v20 + 2006) |
1553 && v22 <= *((short *)v20 + 2008) | 1576 && v22 <= *((short *)v20 + 2008) |
1554 && 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) ) |
1555 { | 1578 { |
1556 v16 = v21->uSectorID; | 1579 v16 = v21->uSectorID; |
1557 if ( *((short *)v20 + 2004) == v16 ) | 1580 if ( *((short *)v20 + 2004) == v16 ) |
1558 v16 = v21->uBackSectorID; | 1581 v16 = v21->uBackSectorID; |
1559 v3->pSectors[v3->pNumSectors].uSectorID = v16; | 1582 v3->nodes[v3->num_nodes].uSectorID = v16; |
1560 v3->pSectors[v3->pNumSectors].uFaceID = uFaceID; | 1583 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
1561 v3->pSectors[v3->pNumSectors].uViewportX = LOWORD(pBLVRenderParams->uViewportX); | 1584 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
1562 v3->pSectors[v3->pNumSectors].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); | 1585 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
1563 v3->pSectors[v3->pNumSectors].uViewportY = LOWORD(pBLVRenderParams->uViewportY); | 1586 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
1564 v3->pSectors[v3->pNumSectors].uViewportW = LOWORD(pBLVRenderParams->uViewportW); | 1587 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
1565 v17 = v3->pNumSectors; | 1588 v17 = v3->num_nodes; |
1566 if ( v17 < 150 ) | 1589 if ( v17 < 150 ) |
1567 { | 1590 { |
1568 v18 = v17 + 1; | 1591 v18 = v17 + 1; |
1569 v3->pNumSectors = v18; | 1592 v3->num_nodes = v18; |
1570 v7 = v18 - 1; | 1593 v7 = v18 - 1; |
1571 LABEL_14: | 1594 LABEL_14: |
1572 sub_440639(v7); | 1595 AddBspNodeToRenderList(v7); |
1573 return; | 1596 return; |
1574 } | 1597 } |
1575 } | 1598 } |
1576 } | 1599 } |
1577 } | 1600 } |
1578 } | 1601 } |
1579 else | 1602 else |
1580 { | 1603 { |
1581 if ( (signed int)this->uNumFaceIDs < 1000 ) | 1604 if (num_faces < 1000) |
1582 { | 1605 { |
1583 this->pFaceIDs[2 * this->uNumFaceIDs] = uFaceID; | 1606 faces[num_faces].uFaceID = uFaceID; |
1584 this->pFaceIDs[2 * this->uNumFaceIDs++ + 1] = a2; | 1607 faces[num_faces++].uNodeID = node_id; |
1585 } | 1608 } |
1586 } | 1609 } |
1587 } | 1610 } |
1588 | 1611 |
1589 //----- (004B0967) -------------------------------------------------------- | 1612 //----- (004B0967) -------------------------------------------------------- |
1596 int v4; // eax@6 | 1619 int v4; // eax@6 |
1597 unsigned __int16 *v5; // edx@6 | 1620 unsigned __int16 *v5; // edx@6 |
1598 int v6; // ecx@7 | 1621 int v6; // ecx@7 |
1599 int v7; // esi@8 | 1622 int v7; // esi@8 |
1600 | 1623 |
1601 for ( i = 0; i < (signed int)pBspRenderer->uNumFaceIDs; ++i ) | 1624 for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i ) |
1602 { | 1625 { |
1603 v1 = pBspRenderer->pFaceIDs[2 * i]; | 1626 v1 = pBspRenderer->faces[i].uFaceID; |
1604 if ( v1 >= 0 ) | 1627 if ( v1 >= 0 ) |
1605 { | 1628 { |
1606 if ( v1 < (signed int)pIndoor->uNumFaces ) | 1629 if ( v1 < (signed int)pIndoor->uNumFaces ) |
1607 { | 1630 { |
1608 v2 = pBspRenderer->pFaceIDs[2 * i]; | 1631 v2 = pBspRenderer->faces[i].uFaceID; |
1609 pBLVRenderParams->field_7C = &pBspRenderer->pSectors[pBspRenderer->pFaceIDs[2 * i + 1]].field_C; | 1632 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; |
1610 v3 = sub_423B5D(v2); | 1633 v3 = sub_423B5D(v2); |
1611 if ( v3 ) | 1634 if ( v3 ) |
1612 { | 1635 { |
1613 if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) | 1636 if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) |
1614 { | 1637 { |
2477 else | 2500 else |
2478 { | 2501 { |
2479 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); |
2480 return 0; | 2503 return 0; |
2481 } | 2504 } |
2482 | |
2483 assert(sizeof(Vec3_short_) == 6); | |
2484 assert(sizeof(BLVFace) == 96); | |
2485 assert(sizeof(BLVFaceExtra) == 36); | |
2486 assert(sizeof(BLVSector) == 116); | |
2487 assert(sizeof(LevelDecoration) == 32); | |
2488 assert(sizeof(BLVLightMM7) == 16); | |
2489 assert(sizeof(BSPNode) == 8); | |
2490 assert(sizeof(SpawnPointMM7) == 24); | |
2491 assert(sizeof(DDM_DLV_Header) == 40); | |
2492 assert(sizeof(Actor) == 836); | |
2493 assert(sizeof(SpriteObject) == 112); | |
2494 assert(sizeof(Chest) == 5324); | |
2495 assert(sizeof(stru123) == 0xC8); | |
2496 assert(sizeof(BLVMapOutline) == 12); | |
2497 | 2505 |
2498 bLoaded = true; | 2506 bLoaded = true; |
2499 | 2507 |
2500 auto pData = (char *)pRawBLV; | 2508 auto pData = (char *)pRawBLV; |
2501 | 2509 |
2521 auto pFace = pFaces + i; | 2529 auto pFace = pFaces + i; |
2522 | 2530 |
2523 pFace->pVertexIDs = ptr_2AC + j; | 2531 pFace->pVertexIDs = ptr_2AC + j; |
2524 | 2532 |
2525 j += pFace->uNumVertices + 1; | 2533 j += pFace->uNumVertices + 1; |
2526 pFace->pXInterceptDisplacements = ptr_2AC + j; | 2534 pFace->pXInterceptDisplacements = (short *)(ptr_2AC + j); |
2527 | 2535 |
2528 j += pFace->uNumVertices + 1; | 2536 j += pFace->uNumVertices + 1; |
2529 pFace->pYInterceptDisplacements = ptr_2AC + j; | 2537 pFace->pYInterceptDisplacements = (short *)(ptr_2AC + j); |
2530 | 2538 |
2531 j += pFace->uNumVertices + 1; | 2539 j += pFace->uNumVertices + 1; |
2532 pFace->pZInterceptDisplacements = ptr_2AC + j; | 2540 pFace->pZInterceptDisplacements = (short *)(ptr_2AC + j); |
2533 | 2541 |
2534 j += pFace->uNumVertices + 1; | 2542 j += pFace->uNumVertices + 1; |
2535 pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j); | 2543 pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j); |
2536 | 2544 |
2537 j += pFace->uNumVertices + 1; | 2545 j += pFace->uNumVertices + 1; |