Mercurial > mm7
comparison Indoor.cpp @ 1319:2ddb0af0f437
m
author | Ritor1 |
---|---|
date | Fri, 28 Jun 2013 11:34:09 +0600 |
parents | 995d2f8ad71b |
children | 22cb507446a4 65379a50e4eb |
comparison
equal
deleted
inserted
replaced
1318:0ec2f944fccc | 1319:2ddb0af0f437 |
---|---|
1260 { | 1260 { |
1261 //unsigned int v3; // edx@1 | 1261 //unsigned int v3; // edx@1 |
1262 //stru170 *v4; // ebx@1 | 1262 //stru170 *v4; // ebx@1 |
1263 //BLVFace *v5; // eax@1 | 1263 //BLVFace *v5; // eax@1 |
1264 //int v6; // ecx@2 | 1264 //int v6; // ecx@2 |
1265 unsigned __int16 v7; // ax@11 | 1265 unsigned __int16 pTransitionSector; // ax@11 |
1266 Vec3_short_ *v8; // esi@15 | 1266 Vec3_short_ *v8; // esi@15 |
1267 int v9; // edx@15 | 1267 int v9; // edx@15 |
1268 //signed int v10; // eax@18 | 1268 //signed int v10; // eax@18 |
1269 //signed int v11; // edi@19 | 1269 //signed int v11; // edi@19 |
1270 //signed int v12; // ecx@19 | 1270 //signed int v12; // ecx@19 |
1271 //signed int v13; // esi@19 | 1271 //signed int v13; // esi@19 |
1272 signed int v14; // edx@20 | 1272 signed int v14; // edx@20 |
1273 int v15; // edx@24 | 1273 int v15; // edx@24 |
1274 //int v16; // esi@29 | 1274 //int v16; // esi@29 |
1275 //BLVFace *v17; // edi@34 | 1275 //BLVFace *v17; // edi@34 |
1276 unsigned __int16 v18; // ax@34 | 1276 //unsigned __int16 v18; // ax@34 |
1277 char *v19; // eax@38 | 1277 char *v19; // eax@38 |
1278 signed int v20; // ecx@38 | 1278 signed int v20; // ecx@38 |
1279 char *v21; // eax@42 | 1279 char *v21; // eax@42 |
1280 signed int v22; // ecx@42 | 1280 signed int v22; // ecx@42 |
1281 //signed int v23; // edx@45 | 1281 //signed int v23; // edx@45 |
1301 //v5 = &pIndoor->pFaces[uFaceID]; | 1301 //v5 = &pIndoor->pFaces[uFaceID]; |
1302 nodes[num_nodes].viewing_portal_id = -1; | 1302 nodes[num_nodes].viewing_portal_id = -1; |
1303 //v39 = &pIndoor->pFaces[uFaceID]; | 1303 //v39 = &pIndoor->pFaces[uFaceID]; |
1304 | 1304 |
1305 auto pFace = &pIndoor->pFaces[uFaceID]; | 1305 auto pFace = &pIndoor->pFaces[uFaceID]; |
1306 auto p = &nodes[node_id]; | |
1307 | 1306 |
1308 if (!pFace->Portal()) | 1307 if (!pFace->Portal()) |
1309 { | 1308 { |
1310 if (num_faces < 1000) | 1309 if (num_faces < 1000) |
1311 { | 1310 { |
1313 faces[num_faces++].uNodeID = node_id; | 1312 faces[num_faces++].uNodeID = node_id; |
1314 } | 1313 } |
1315 return; | 1314 return; |
1316 } | 1315 } |
1317 | 1316 |
1318 if (p->uFaceID == uFaceID) | 1317 if (nodes[node_id].uFaceID == uFaceID) |
1318 return; | |
1319 if (!node_id && | |
1320 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane | |
1321 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && | |
1322 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && | |
1323 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && | |
1324 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && | |
1325 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) | |
1326 { | |
1327 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
1328 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y | |
1329 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane | |
1330 { | |
1331 pTransitionSector = pFace->uSectorID; | |
1332 if ( nodes[0].uSectorID == pTransitionSector ) // draw back sector | |
1333 pTransitionSector = pFace->uBackSectorID; | |
1334 nodes[num_nodes].uSectorID = pTransitionSector; | |
1335 nodes[num_nodes].uFaceID = uFaceID; | |
1336 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | |
1337 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | |
1338 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | |
1339 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | |
1340 nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, | |
1341 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); | |
1342 AddBspNodeToRenderList(++num_nodes - 1); | |
1319 return; | 1343 return; |
1320 if (!node_id && | 1344 } |
1321 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane | 1345 } |
1322 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && | 1346 |
1323 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && | 1347 v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) |
1324 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && | 1348 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) |
1325 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && | 1349 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z); |
1326 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) | 1350 if (nodes[node_id].uSectorID != pFace->uSectorID) |
1327 { | 1351 v9 = -v9; |
1328 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | 1352 if (v9 >= 0) |
1329 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y | 1353 return; |
1330 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane | 1354 |
1331 { | 1355 auto num_vertices = sub_423B5D(uFaceID); |
1332 v7 = pFace->uSectorID; | 1356 if (num_vertices < 2) |
1333 if ( nodes[0].uSectorID == v7 ) // draw back sector | 1357 return; |
1334 v7 = pFace->uBackSectorID; | 1358 |
1335 nodes[num_nodes].uSectorID = v7; | 1359 auto face_min_screenspace_x = stru_50B700._screen_space_x[0], |
1336 nodes[num_nodes].uFaceID = uFaceID; | 1360 face_max_screenspace_x = stru_50B700._screen_space_x[0]; |
1337 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | 1361 auto face_min_screenspace_y = stru_50B700._screen_space_y[0], |
1338 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | 1362 face_max_screenspace_y = stru_50B700._screen_space_y[0]; |
1339 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | 1363 for (uint i = 1; i < num_vertices; ++i) |
1340 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | 1364 { |
1341 nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, | 1365 if (face_min_screenspace_x > stru_50B700._screen_space_x[i]) |
1342 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); | 1366 face_min_screenspace_x = stru_50B700._screen_space_x[i]; |
1343 AddBspNodeToRenderList(++num_nodes - 1); | 1367 if (face_max_screenspace_x < stru_50B700._screen_space_x[i]) |
1344 return; | 1368 face_max_screenspace_x = stru_50B700._screen_space_x[i]; |
1345 } | 1369 |
1346 //v5 = v39; | 1370 if (face_min_screenspace_y > stru_50B700._screen_space_y[i]) |
1347 //v6 = a0; | 1371 face_min_screenspace_y = stru_50B700._screen_space_y[i]; |
1348 } | 1372 if (face_max_screenspace_y < stru_50B700._screen_space_y[i]) |
1349 | 1373 face_max_screenspace_y = stru_50B700._screen_space_y[i]; |
1350 v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; | 1374 } |
1351 v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x) | |
1352 + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y) | |
1353 + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); | |
1354 if (p->uSectorID != pFace->uSectorID) | |
1355 v9 = -v9; | |
1356 if (v9 >= 0) | |
1357 return; | |
1358 | |
1359 auto num_vertices = sub_423B5D(uFaceID); | |
1360 if (num_vertices < 2) | |
1361 return; | |
1362 | |
1363 auto face_min_screenspace_x = stru_50B700._screen_space_x[0], | |
1364 face_max_screenspace_x = stru_50B700._screen_space_x[0]; | |
1365 auto face_min_screenspace_y = stru_50B700._screen_space_y[0], | |
1366 face_max_screenspace_y = stru_50B700._screen_space_y[0]; | |
1367 for (uint i = 1; i < num_vertices; ++i) | |
1368 { | |
1369 if (face_min_screenspace_x > stru_50B700._screen_space_x[i]) | |
1370 face_min_screenspace_x = stru_50B700._screen_space_x[i]; | |
1371 if (face_max_screenspace_x < stru_50B700._screen_space_x[i]) | |
1372 face_max_screenspace_x = stru_50B700._screen_space_x[i]; | |
1373 | |
1374 if (face_min_screenspace_y > stru_50B700._screen_space_y[i]) | |
1375 face_min_screenspace_y = stru_50B700._screen_space_y[i]; | |
1376 if (face_max_screenspace_y < stru_50B700._screen_space_y[i]) | |
1377 face_max_screenspace_y = stru_50B700._screen_space_y[i]; | |
1378 } | |
1379 //_screen_space_x = 719, 568, 493 | 1375 //_screen_space_x = 719, 568, 493 |
1380 //savegame: qw , 0Bh and 0x1D4h | 1376 //savegame: qw , 0Bh and 0x1D4h |
1381 //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ | 1377 //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ |
1382 if (face_max_screenspace_x >= p->uViewportX && | 1378 if (face_max_screenspace_x >= nodes[node_id].uViewportX && |
1383 face_min_screenspace_x <= p->uViewportZ && | 1379 face_min_screenspace_x <= nodes[node_id].uViewportZ && |
1384 face_max_screenspace_y >= p->uViewportY && | 1380 face_max_screenspace_y >= nodes[node_id].uViewportY && |
1385 face_min_screenspace_y <= p->uViewportW && | 1381 face_min_screenspace_y <= nodes[node_id].uViewportW && |
1386 sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID)) | 1382 sub_424829(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID)) |
1387 { | 1383 { |
1388 //v17 = v39; | 1384 pTransitionSector = pFace->uSectorID; |
1389 v18 = pFace->uSectorID; | 1385 if (nodes[node_id].uSectorID == pTransitionSector ) |
1390 if (p->uSectorID == v18 ) | 1386 pTransitionSector = pFace->uBackSectorID; |
1391 v18 = pFace->uBackSectorID; | 1387 nodes[num_nodes].uSectorID = pTransitionSector; |
1392 nodes[num_nodes].uSectorID = v18; | 1388 nodes[num_nodes].uFaceID = uFaceID; |
1393 nodes[num_nodes].uFaceID = uFaceID; | 1389 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; |
1394 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | 1390 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; |
1395 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | 1391 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; |
1396 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | 1392 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; |
1397 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | 1393 v29 = false; |
1398 //v38 = pGame->pStru10Instance; | 1394 if (nodes[node_id].viewing_portal_id == -1)//первый портал на который я смотрю |
1399 //a0a = pGame->pIndoorCameraD3D; | 1395 v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); |
1400 v29 = false; | 1396 else//следующие порталы в портале |
1401 if (p->viewing_portal_id == -1) | 1397 { |
1402 { | 1398 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; |
1403 v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); | 1399 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; |
1404 } | 1400 |
1405 else | 1401 for (uint k = 0; k < pFace->uNumVertices; ++k) |
1406 { | 1402 { |
1407 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; | 1403 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; |
1408 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; | 1404 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; |
1409 | 1405 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; |
1410 for (uint k = 0; k < pFace->uNumVertices; ++k) | 1406 } |
1411 { | 1407 |
1412 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; | 1408 unsigned int pNewNumVertices = pFace->uNumVertices; |
1413 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; | 1409 pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices, |
1414 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; | 1410 static_subAddFaceToRenderList_d3d_stru_F79E08, nodes[node_id].std__vector_0007AC, 4, 0, 0); |
1415 } | 1411 |
1416 | 1412 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &pNewNumVertices, |
1417 | 1413 nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); |
1418 unsigned int a2 = pFace->uNumVertices; | 1414 } |
1419 pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, | 1415 if ( 1 ) |
1420 &a2, | 1416 { |
1421 static_subAddFaceToRenderList_d3d_stru_F79E08, | 1417 assert(num_nodes < 150); |
1422 p->std__vector_0007AC, 4, 0, 0); | 1418 |
1423 | 1419 nodes[num_nodes].viewing_portal_id = uFaceID; |
1424 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2, | 1420 AddBspNodeToRenderList(++num_nodes - 1); |
1425 nodes[num_nodes].std__vector_0007AC, | 1421 } |
1426 nodes[num_nodes].pPortalBounding); | 1422 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) |
1427 } | 1423 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); |
1428 if ( 1 ) | 1424 //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); |
1429 { | 1425 } |
1430 assert(num_nodes < 150); | |
1431 | |
1432 nodes[num_nodes].viewing_portal_id = uFaceID; | |
1433 AddBspNodeToRenderList(++num_nodes - 1); | |
1434 } | |
1435 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | |
1436 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); | |
1437 //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); | |
1438 } | |
1439 } | 1426 } |
1440 | 1427 |
1441 | 1428 |
1442 //----- (004AFB86) -------------------------------------------------------- | 1429 //----- (004AFB86) -------------------------------------------------------- |
1443 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) | 1430 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) |