Mercurial > mm7
comparison LightmapBuilder.cpp @ 2157:c6d8253d4cbc
Слияние
author | Ritor1 |
---|---|
date | Fri, 10 Jan 2014 17:42:57 +0600 |
parents | 0a1438c16c2b |
children | 6ab7d7c112bb |
comparison
equal
deleted
inserted
replaced
2156:eaaaa50d34e9 | 2157:c6d8253d4cbc |
---|---|
585 if (uNumLightsApplied >= 20 ) | 585 if (uNumLightsApplied >= 20 ) |
586 break; | 586 break; |
587 | 587 |
588 BLVLightMM7* pLight = &pIndoor->pLights[pSector->pLights[i]]; | 588 BLVLightMM7* pLight = &pIndoor->pLights[pSector->pLights[i]]; |
589 if (~pLight->uAtributes & 0x08) | 589 if (~pLight->uAtributes & 0x08) |
590 ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &byte_4E94D0); | 590 ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &_4E94D0_light_type); |
591 } | 591 } |
592 | 592 |
593 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | 593 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) |
594 { | 594 { |
595 if (uNumLightsApplied >= 20) | 595 if (uNumLightsApplied >= 20) |
596 break; | 596 break; |
597 | 597 |
598 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &byte_4E94D0); | 598 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type); |
599 } | 599 } |
600 | 600 |
601 stru_F8AD28.uNumLightsApplied = uNumLightsApplied; | 601 stru_F8AD28.uNumLightsApplied = uNumLightsApplied; |
602 return true; | 602 return true; |
603 } | 603 } |
1002 v12 = pRenderer->bUsingSpecular; | 1002 v12 = pRenderer->bUsingSpecular; |
1003 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11; | 1003 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11; |
1004 stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; | 1004 stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; |
1005 //v13 = pRenderer->pRenderD3D; | 1005 //v13 = pRenderer->pRenderD3D; |
1006 v14 = stru_F8AD28._blv_lights_types[*pSlot]; | 1006 v14 = stru_F8AD28._blv_lights_types[*pSlot]; |
1007 if ( pRenderer->pRenderD3D && v12 && v14 & 4 ) | 1007 if ( /*pRenderer->pRenderD3D &&*/ v12 && v14 & 4 ) |
1008 v14 = _4E94D2_light_type; | 1008 v14 = _4E94D2_light_type; |
1009 stru_F8AD28._blv_lights_types[*pSlot] = v14; | 1009 stru_F8AD28._blv_lights_types[*pSlot] = v14; |
1010 result = 4 * *pSlot; | 1010 result = 4 * *pSlot; |
1011 if ( /*v13*/true && v12 ) | 1011 if ( /*v13*/true && v12 ) |
1012 { | 1012 { |
1153 double v51; // st6@17 | 1153 double v51; // st6@17 |
1154 signed int v52; // ecx@17 | 1154 signed int v52; // ecx@17 |
1155 unsigned int *v53; // esi@18 | 1155 unsigned int *v53; // esi@18 |
1156 int v54; // eax@18 | 1156 int v54; // eax@18 |
1157 unsigned int v55; // ebx@18 | 1157 unsigned int v55; // ebx@18 |
1158 RenderD3D *v56; // ecx@18 | 1158 //RenderD3D *v56; // ecx@18 |
1159 char v57; // dl@18 | 1159 char v57; // dl@18 |
1160 std::string v58; // [sp-18h] [bp-38h]@10 | 1160 std::string v58; // [sp-18h] [bp-38h]@10 |
1161 const char *v59; // [sp-8h] [bp-28h]@10 | 1161 const char *v59; // [sp-8h] [bp-28h]@10 |
1162 signed int v60; // [sp-4h] [bp-24h]@10 | 1162 signed int v60; // [sp-4h] [bp-24h]@10 |
1163 double v61; // [sp+Ch] [bp-14h]@11 | 1163 double v61; // [sp+Ch] [bp-14h]@11 |
1288 stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.003921568859368563; | 1288 stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.003921568859368563; |
1289 v54 = abs(v60); | 1289 v54 = abs(v60); |
1290 v55 = pRenderer->bUsingSpecular; | 1290 v55 = pRenderer->bUsingSpecular; |
1291 stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54; | 1291 stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54; |
1292 stru_F8AD28._blv_lights_types[*v53] = v8->uLightType; | 1292 stru_F8AD28._blv_lights_types[*v53] = v8->uLightType; |
1293 v56 = pRenderer->pRenderD3D; | 1293 //v56 = pRenderer->pRenderD3D; |
1294 v57 = stru_F8AD28._blv_lights_types[*v53]; | 1294 v57 = stru_F8AD28._blv_lights_types[*v53]; |
1295 if ( pRenderer->pRenderD3D && v55 && v57 & 4 ) | 1295 if ( /*pRenderer->pRenderD3D &&*/ v55 && v57 & 4 ) |
1296 v57 = _4E94D2_light_type; | 1296 v57 = _4E94D2_light_type; |
1297 stru_F8AD28._blv_lights_types[*v53] = v57; | 1297 stru_F8AD28._blv_lights_types[*v53] = v57; |
1298 result = 4 * *v53; | 1298 result = 4 * *v53; |
1299 if ( v56 && v55 ) | 1299 if ( /*v56 &&*/ v55 ) |
1300 { | 1300 { |
1301 if ( stru_F8AD28._blv_lights_types[*v53] & 4 ) | 1301 if ( stru_F8AD28._blv_lights_types[*v53] & 4 ) |
1302 { | 1302 { |
1303 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) | 1303 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) |
1304 * 0.3300000131130219; | 1304 * 0.3300000131130219; |
1374 { | 1374 { |
1375 //char v3; // zf@1 | 1375 //char v3; // zf@1 |
1376 IDirect3DDevice3 *v4; // eax@2 | 1376 IDirect3DDevice3 *v4; // eax@2 |
1377 HRESULT v5; // eax@2 | 1377 HRESULT v5; // eax@2 |
1378 //char *v6; // eax@2 | 1378 //char *v6; // eax@2 |
1379 struct IDirect3DTexture2 *v7; // edi@4 | 1379 //struct IDirect3DTexture2 *v7; // edi@4 |
1380 HRESULT v8; // eax@8 | 1380 HRESULT v8; // eax@8 |
1381 HRESULT v9; // eax@8 | 1381 HRESULT v9; // eax@8 |
1382 HRESULT v10; // eax@8 | 1382 HRESULT v10; // eax@8 |
1383 HRESULT v11; // eax@8 | 1383 HRESULT v11; // eax@8 |
1384 HRESULT v12; // eax@8 | 1384 HRESULT v12; // eax@8 |
1408 //int *v36; // [sp+7Ch] [bp-Ch]@10 | 1408 //int *v36; // [sp+7Ch] [bp-Ch]@10 |
1409 //int a1; // [sp+80h] [bp-8h]@12 | 1409 //int a1; // [sp+80h] [bp-8h]@12 |
1410 //float v38; // [sp+84h] [bp-4h]@1 | 1410 //float v38; // [sp+84h] [bp-4h]@1 |
1411 | 1411 |
1412 if (std__vector_000004_size == 0) | 1412 if (std__vector_000004_size == 0) |
1413 return 1; | 1413 return true; |
1414 | 1414 |
1415 | 1415 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) |
1416 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | 1416 return true; |
1417 | 1417 |
1418 v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"); | 1418 pRenderer->BeginLightmaps(); |
1419 if ( pRenderer->bUsingSpecular ) | |
1420 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
1421 | |
1422 if ( !byte_4D864C || !(pGame->uFlags & GAME_FLAGS_1_01) ) | |
1423 { | |
1424 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1425 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
1426 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7)); | |
1427 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1428 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
1429 | 1419 |
1430 arg4.x = 1.0f; | 1420 arg4.x = 1.0f; |
1431 arg4.y = 1.0f; | 1421 arg4.y = 1.0f; |
1432 arg4.z = 1.0f; | 1422 arg4.z = 1.0f; |
1433 if (indices) | 1423 if (indices) |
1434 { | 1424 { |
1435 for (int* i = indices; *i != -1; ++i) | 1425 for (int* i = indices; *i != -1; ++i) |
1436 { | 1426 { |
1437 v28 = &std__vector_000004[*i]; | 1427 v28 = &std__vector_000004[*i]; |
1438 if ( !DrawLightmap(v28, &arg4, 0.0) ) | 1428 if ( !pRenderer->DrawLightmap(v28, &arg4, 0.0) ) |
1439 Error("Invalid lightmap detected! (%u)", *i); | 1429 Error("Invalid lightmap detected! (%u)", *i); |
1440 } | 1430 } |
1441 } | 1431 } |
1442 else | 1432 else |
1443 { | 1433 { |
1444 for (unsigned int i = 0; i < std__vector_000004_size; ++i) | 1434 for (unsigned int i = 0; i < std__vector_000004_size; ++i) |
1445 { | 1435 { |
1446 Lightmap* _a1 = &std__vector_000004[(int)i]; | 1436 Lightmap* _a1 = &std__vector_000004[(int)i]; |
1447 if ( !DrawLightmap(_a1, &arg4, 0.0) ) | 1437 if ( !pRenderer->DrawLightmap(_a1, &arg4, 0.0) ) |
1448 { | 1438 Error("Invalid lightmap detected! (%u)", i); |
1449 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0); | |
1450 v35 = 5080812; | |
1451 } | |
1452 } | 1439 } |
1453 } | 1440 } |
1454 | 1441 |
1455 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | 1442 pRenderer->EndLightmaps(); |
1456 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | 1443 |
1457 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
1458 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
1459 } | |
1460 | |
1461 if ( pRenderer->bUsingSpecular ) | |
1462 { | |
1463 //LODWORD(v30) = 1; | |
1464 //v29 = 28; | |
1465 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; | |
1466 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
1467 //v30 = pRenderer->uFogColor; | |
1468 //v23 = pRenderer->pRenderD3D->pDevice; | |
1469 //v29 = 34; | |
1470 //v28 = (Lightmap *)v23; | |
1471 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, pRenderer->uFogColor)); | |
1472 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; | |
1473 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
1474 } | |
1475 | |
1476 return true; | 1444 return true; |
1477 } | 1445 } |
1478 | 1446 |
1479 | 1447 |
1480 //----- (0045DA56) -------------------------------------------------------- | 1448 //----- (0045DA56) -------------------------------------------------------- |
1484 v.z = 1.0; | 1452 v.z = 1.0; |
1485 v.y = 1.0; | 1453 v.y = 1.0; |
1486 v.x = 1.0; | 1454 v.x = 1.0; |
1487 | 1455 |
1488 for (uint i = 0; i < std__vector_183808_size; ++i) | 1456 for (uint i = 0; i < std__vector_183808_size; ++i) |
1489 if (!DrawLightmap(std__vector_183808 + i, &v, z_bias)) | 1457 if (!pRenderer->DrawLightmap(std__vector_183808 + i, &v, z_bias)) |
1490 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0); | 1458 Error("Invalid lightmap detected! (%u)", i); |
1491 | 1459 |
1492 return true; | 1460 return true; |
1493 } | 1461 } |
1494 | 1462 |
1495 //----- (0045DAE8) -------------------------------------------------------- | 1463 //----- (0045DAE8) -------------------------------------------------------- |
1496 bool LightmapBuilder::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias) | 1464 bool Render::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias) |
1497 { | 1465 { |
1498 double v10; // st7@4 | 1466 double v10; // st7@4 |
1499 double v14; // st7@7 | 1467 double v14; // st7@7 |
1500 __int16 v15; // fps@8 | 1468 __int16 v15; // fps@8 |
1501 double v18; // st3@8 | 1469 double v18; // st3@8 |
1566 void LightmapBuilder::Draw_183808_Lightmaps() | 1534 void LightmapBuilder::Draw_183808_Lightmaps() |
1567 { | 1535 { |
1568 if (!std__vector_183808_size) | 1536 if (!std__vector_183808_size) |
1569 return; | 1537 return; |
1570 | 1538 |
1571 if (pRenderer->bUsingSpecular) | 1539 pRenderer->BeginLightmaps2(); |
1572 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
1573 | |
1574 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
1575 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
1576 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
1577 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
1578 | |
1579 IDirect3DTexture2* pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"); | |
1580 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex)); | |
1581 | |
1582 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
1583 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
1584 | 1540 |
1585 DoDraw_183808_Lightmaps(0.00050000002); | 1541 DoDraw_183808_Lightmaps(0.00050000002); |
1586 | 1542 |
1587 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | 1543 pRenderer->EndLightmaps2(); |
1588 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | 1544 } |
1589 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
1590 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
1591 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
1592 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
1593 | |
1594 if (pRenderer->bUsingSpecular) | |
1595 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
1596 } |