comparison Render.cpp @ 105:56e11be29db1

Слияние
author Ritor1
date Tue, 05 Feb 2013 19:08:52 +0600
parents 41145af69341 7bdf8f1150eb
children efece1632349
comparison
equal deleted inserted replaced
104:41145af69341 105:56e11be29db1
906 float Render::DrawBezierTerrain() 906 float Render::DrawBezierTerrain()
907 { 907 {
908 //__debugbreak();Ritor1: it's temporarily 908 //__debugbreak();Ritor1: it's temporarily
909 //return 0; 909 //return 0;
910 910
911 unsigned int v0; // ebx@1 911 unsigned int pDirectionIndicator1; // ebx@1
912 unsigned int v1; // edi@1 912 unsigned int pDirectionIndicator2; // edi@1
913 unsigned int v2; // eax@1 913 unsigned int v2; // eax@1
914 int v3; // eax@3 914 int v3; // eax@3
915 int v4; // edi@3 915 int v4; // edi@3
916 int v5; // ebx@3 916 int v5; // ebx@3
917 int v6; // esi@3 917 int v6; // esi@3
979 int v68; // ecx@167 979 int v68; // ecx@167
980 int v69; // eax@173 980 int v69; // eax@173
981 int v70; // edi@178 981 int v70; // edi@178
982 int v71; // eax@178 982 int v71; // eax@178
983 int v72; // ecx@178 983 int v72; // ecx@178
984 int v73; // ebx@180 984 int x; // ebx@180
985 int v74; // eax@182 985 int v74; // eax@182
986 int v75; // eax@184 986 int v75; // eax@184
987 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 987 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184
988 int v77; // ecx@184 988 int uStartZ; // ecx@184
989 int v79; // ebx@185 989 int v79; // ebx@185
990 int v127; // esi@185 990 int v127; // esi@185
991 int v86; // edi@196 991 int v86; // edi@196
992 int v87; // eax@196 992 int v87; // eax@196
993 int v88; // ecx@196 993 int v88; // ecx@196
1003 __int16 v103; // [sp+10h] [bp-64h]@190 1003 __int16 v103; // [sp+10h] [bp-64h]@190
1004 __int16 v104; // [sp+12h] [bp-62h]@190 1004 __int16 v104; // [sp+12h] [bp-62h]@190
1005 } v102; 1005 } v102;
1006 int v105; // [sp+1Ch] [bp-58h]@1 1006 int v105; // [sp+1Ch] [bp-58h]@1
1007 int v106; // [sp+20h] [bp-54h]@3 1007 int v106; // [sp+20h] [bp-54h]@3
1008 int v107; // [sp+24h] [bp-50h]@3 1008 int uEndZ; // [sp+24h] [bp-50h]@3
1009 int v108; // [sp+28h] [bp-4Ch]@9 1009 int v108; // [sp+28h] [bp-4Ch]@9
1010 int v109; // [sp+2Ch] [bp-48h]@9 1010 int v109; // [sp+2Ch] [bp-48h]@9
1011 int v110; // [sp+30h] [bp-44h]@9 1011 int v110; // [sp+30h] [bp-44h]@9
1012 int v111; // [sp+34h] [bp-40h]@3 1012 int v111; // [sp+34h] [bp-40h]@3
1013 int v112; // [sp+38h] [bp-3Ch]@6 1013 int v112; // [sp+38h] [bp-3Ch]@6
1024 int v123; // [sp+64h] [bp-10h]@1 1024 int v123; // [sp+64h] [bp-10h]@1
1025 int v124; // [sp+68h] [bp-Ch]@1 1025 int v124; // [sp+68h] [bp-Ch]@1
1026 int v125; // [sp+6Ch] [bp-8h]@9 1026 int v125; // [sp+6Ch] [bp-8h]@9
1027 int v126; // [sp+70h] [bp-4h]@9 1027 int v126; // [sp+70h] [bp-4h]@9
1028 1028
1029 v105 = pIndoorCamera->sRotationY / (stru_5C6E00->uIntegerHalfPi / 2); 1029 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);
1030 v0 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 1030 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536
1031 v1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + v0);//512 1031 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512
1032 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->SinCos( 1032 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->SinCos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;
1033 stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + v0))) >> 16; 1033 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->SinCos(pDirectionIndicator2 - stru_5C6E00->uIntegerHalfPi)) >> 16;
1034 v123 = ((pIndoorCamera->uMapGridCellZ << 16)
1035 + 3 * stru_5C6E00->SinCos(v1 - stru_5C6E00->uIntegerHalfPi)) >> 16;
1036 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X 1034 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X
1037 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; 1035 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123;
1038 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; 1036 v2 = pOutdoorCamera->uCameraFovInDegrees + 15;
1039 i = v124 - pOutdoorCamera->outdoor_grid_band_3; 1037 i = v124 - pOutdoorCamera->outdoor_grid_band_3;
1040 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; 1038 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3;
1041 1039
1042 if ( v2 > 90 ) 1040 if ( v2 > 90 )
1043 v2 = 90; 1041 v2 = 90;
1044 v3 = (v2 << 11) / 720; 1042 v3 = (v2 << 11) / 720;
1045 v4 = stru_5C6E00->uDoublePiMask & (v0 - v3); 1043 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3);
1046 v5 = stru_5C6E00->uDoublePiMask & (v3 + v0); 1044 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1);
1047 v106 = stru_5C6E00->SinCos(v4); 1045 v106 = stru_5C6E00->SinCos(v4);
1048 v107 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi); 1046 uEndZ = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi);
1049 v111 = stru_5C6E00->SinCos(v5); 1047 v111 = stru_5C6E00->SinCos(v5);
1050 v6 = stru_5C6E00->SinCos(v5 - stru_5C6E00->uIntegerHalfPi); 1048 v6 = stru_5C6E00->SinCos(v5 - stru_5C6E00->uIntegerHalfPi);
1051 v7 = v4 & stru_5C6E00->uPiMask; 1049 v7 = v4 & stru_5C6E00->uPiMask;
1052 1050
1053 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) 1051 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi )
1068 pIndoorCameraD3D_4 = 0; 1066 pIndoorCameraD3D_4 = 0;
1069 v125 = 0; 1067 v125 = 0;
1070 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; 1068 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1;
1071 v126 = v124; 1069 v126 = v124;
1072 v118 = v123; 1070 v118 = v123;
1073 v109 = (v107 >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; 1071 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1;
1074 v107 = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; 1072 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1;
1075 terrain_76E1C8[0] = 65535; 1073 terrain_76E1C8[0] = 65535;
1076 //v116 = 1; 1074 //v116 = 1;
1077 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; 1075 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1;
1078 //v117 = 1; 1076 //v117 = 1;
1079 terrain_76E3C8[0] = 65535; 1077 terrain_76E3C8[0] = 65535;
1116 { 1114 {
1117 v111 = 4294967296i64 / v108; 1115 v111 = 4294967296i64 / v108;
1118 v114 += v111;// 1116 v114 += v111;//
1119 if ( v111 + v114 >= 65536 ) 1117 if ( v111 + v114 >= 65536 )
1120 { 1118 {
1121 v126 += v107; 1119 v126 += uEndZ;
1122 v114 = (unsigned __int16)v114;// 1120 v114 = (unsigned __int16)v114;//
1123 } 1121 }
1124 v118 += v106; 1122 v118 += v106;
1125 } 1123 }
1126 else 1124 else
1127 { 1125 {
1128 v125 += v108; 1126 v125 += v108;
1129 v126 += v107; 1127 v126 += uEndZ;
1130 if ( v125 >= 65536 ) 1128 if ( v125 >= 65536 )
1131 { 1129 {
1132 v118 += v106; 1130 v118 += v106;
1133 v125 = (unsigned __int16)v125; 1131 v125 = (unsigned __int16)v125;
1134 } 1132 }
1571 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 ) 1569 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )
1572 { 1570 {
1573 for ( i = v69; i >= 1; --i ) 1571 for ( i = v69; i >= 1; --i )
1574 { 1572 {
1575 //v70 = i; 1573 //v70 = i;
1576 v71 = terrain_76D7C8[i]; 1574 v71 = terrain_76D7C8[i];//88
1577 v72 = terrain_76DBC8[i]; 1575 v72 = terrain_76DBC8[i];//0
1578 if ( v71 < v72 )//swap 1576 if ( v71 < v72 )//swap
1579 { 1577 {
1580 terrain_76DBC8[i] = v71; 1578 terrain_76DBC8[i] = v71;
1581 terrain_76D7C8[i] = v72; 1579 terrain_76D7C8[i] = v72;
1582 } 1580 }
1583 v73 = terrain_76DBC8[i]; 1581 x = terrain_76DBC8[i];//0
1584 v111 = 0; 1582 v111 = 0;
1585 if ( v73 <= 0 ) 1583 if ( x <= 0 )
1586 v73 = -v73; 1584 x = -x;
1587 v74 = terrain_76D7C8[i]; 1585 v74 = terrain_76D7C8[i];
1588 if ( v74 <= 0 ) 1586 if ( v74 <= 0 )
1589 v74 = -v74; 1587 v74 = -v74;
1590 v75 = v74 + 2; 1588 v75 = v74 + 2;
1591 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; 1589 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D;
1592 v107 = v75; 1590 uEndZ = v75;
1593 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; 1591 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3;
1594 v77 = v73 - 2; 1592 uStartZ = x - 2;
1595 if ( v73 - 2 < v75 ) 1593 if ( x - 2 < v75 )
1596 { 1594 {
1597 v127 = 0; 1595 v127 = 0;
1598 //v79 = (v73 - 66) << 9; 1596 //v79 = (v73 - 66) << 9;
1599 //v116 = v77; 1597 //v116 = v77;
1600 //pHeight = v79; 1598 //pHeight = v79;
1601 v111 = v75 - v77; 1599 v111 = v75 - uStartZ;
1602 for (int j = v77; j < v107; ++j) 1600 for (int z = uStartZ; z < uEndZ; ++z)
1603 {// 1601 {
1604 /* *(float *)&v106 = (double)pHeight; 1602 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;
1605 *(float *)((char *)&ptr_801A08->vWorldPosition.x + v127) = *(float *)&v106;//x
1606 pHeight = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
1607 *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)pHeight;//y
1608 pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
1609 *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)pHeight;//z*/
1610 ptr_801A08[v127].vWorldPosition.x = (v73 - 66 + v127) * 512;
1611 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; 1603 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512;
1612 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( j, terrain_76D9C8[i]); 1604 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]);
1613 1605
1614 /* *(float *)((char *)&ptr_801A04->vWorldPosition.x + v127) = *(float *)&v106;//x 1606 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512;
1615 pHeight = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
1616 *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)pHeight;//y
1617 pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
1618 *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)pHeight;//z */
1619 ptr_801A04[v127].vWorldPosition.x = (v73 - 66 + v127) * 512;
1620 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; 1607 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512;
1621 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( j, terrain_76D9C8[i] + 1); 1608 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1);
1622 1609
1623 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) 1610 if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
1624 { 1611 {
1625 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); 1612 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1);
1626 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); 1613 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1);
1635 //while ( v116 < v107 ); 1622 //while ( v116 < v107 );
1636 } 1623 }
1637 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); 1624 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
1638 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); 1625 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]);
1639 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test 1626 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
1640 Render::DrawTerrainD3D(v111, 1, (int)&v102); 1627 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102);
1641 else 1628 else
1642 Render::DrawTerrainSW(v111, 0, (int)&v102); 1629 Render::DrawTerrainSW(v111, 0, (int)&v102);
1643 } 1630 }
1644 } 1631 }
1645 /* else 1632 /* else
1712 return result; 1699 return result;
1713 } 1700 }
1714 // 47FFC4: inconsistent fpu stack 1701 // 47FFC4: inconsistent fpu stack
1715 // 4D864C: using guessed type char byte_4D864C; 1702 // 4D864C: using guessed type char byte_4D864C;
1716 1703
1717 1704 void Render::RenderTerrainD3D() // New function. It's temporary
1705 {
1706 char result; // al@3
1707 //int v1; // eax@3
1708 //int v2; // ebx@4
1709 //struct ODMFace *v4; // esi@6
1710 int v6; // ecx@8
1711 //int v7; // ecx@8
1712 struct stru148 *v8; // ebx@8
1713 //char v11; // zf@8
1714 struct stru148 *v16;
1715 unsigned int v18; // edi@22
1716 //int v20; // edi@34
1717 //int v28; // eax@50
1718 //int v29; // ecx@55
1719 //int v30; // eax@57
1720 int v31; // eax@57
1721 int v35; // edi@63
1722 int v37; // eax@73
1723 int v39; // eax@80
1724 char v40; // [sp-18h] [bp-70h]@2
1725 int v41; // [sp-14h] [bp-6Ch]@2
1726 int v42; // [sp-10h] [bp-68h]@2
1727 int v43; // [sp-Ch] [bp-64h]@2
1728 const char *v44; // [sp-8h] [bp-60h]@2
1729 int v45; // [sp-4h] [bp-5Ch]@2
1730 //float v48; // [sp+14h] [bp-44h]@8
1731 //void *v52; // [sp+24h] [bp-34h]@3
1732 bool v54; // [sp+2Ch] [bp-2Ch]@10
1733 int v55; // [sp+30h] [bp-28h]@34
1734 int v56;
1735 int v57; // [sp+38h] [bp-20h]@36
1736 int v58; // [sp+3Ch] [bp-1Ch]@8
1737 int v63; // [sp+50h] [bp-8h]@3
1738 int v64; // [sp+57h] [bp-1h]@2
1739 int v62;
1740
1741 v63 = 0;
1742
1743 // basic optimizations
1744 unsigned int uStartX, uEndX,
1745 uStartZ, uEndZ;
1746 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024)
1747 {
1748 /* CAMERA
1749 /2 512
1750 ^
1751 \ | /
1752 \ | /
1753 _____\|/______ + 0
1754 1024 | x 0
1755 |
1756 - y
1757 3/2 1536
1758 */
1759 uStartX = 0, uEndX = 128;
1760 uStartZ = 0, uEndZ = 64 + 16;
1761 }
1762 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536)
1763 {
1764 /* /2 512
1765 + y
1766 \ |
1767 \ |
1768 CAMERA _____\| ______ + 0
1769 1024 /| x 0
1770 / |
1771 / - y
1772 3/2 1536
1773 */
1774 uStartX = 0, uEndX = 64 + 16;
1775 uStartZ = 0, uEndZ = 128;
1776 }
1777 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512)
1778 {
1779 /* /2 512
1780 + y
1781 | /
1782 | /
1783 _____ |/______ + 0 CAMERA
1784 1024 |\ x 0
1785 | \
1786 - y \
1787 3/2 1536
1788 */
1789 uStartX = 64 - 16, uEndX = 128;
1790 uStartZ = 0, uEndZ = 128;
1791 }
1792 else
1793 {
1794 uStartX = 0, uEndX = 128;
1795 uStartZ = 64 - 16, uEndZ = 128;
1796 }
1797
1798 // uStartX = 0, uEndX = 128;
1799 // uStartZ = 0, uEndZ = 128;
1800
1801
1802 static RenderVertexSoft pTerrainVertices[128 * 128];
1803 for (unsigned int z = uStartZ; z < uEndZ; ++z)
1804 for (unsigned int x = uStartX; x < uEndX; ++x)
1805 {
1806 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
1807 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512;
1808 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x];
1809
1810 struct IndoorCameraD3D *pIndoorCameraD3D = pGame->pIndoorCameraD3D;
1811 pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1);
1812 pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0);
1813 }
1814
1815
1816
1817 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z)
1818 for (unsigned int x = uStartX; x < uEndX - 1; ++x)
1819 {
1820 v8 = &array_77EC08[pOutdoorCamera->numStru148s];
1821 v8->flags = 0;
1822 v8->field_32 = 0;
1823
1824 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x];
1825 //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID);
1826 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
1827 /*if (uTileID == 1 || //dirttyl BitmapID 88
1828 uTileID == 2 || //dirt1 BitmapID 126
1829 uTileID == 3 || //dirttyl BitmapID 88
1830 uTileID == 4 || //dirt2 BitmapID 127
1831 uTileID == 11 || //dirttyl BitmapID 127
1832
1833 uTileID == 90 || //grastyl BitmapID 110
1834 uTileID == 92 || //grastyl BitmapID 110
1835
1836 uTileID == 102 || //grdrtNE BitmapID 128
1837 uTileID == 104 || //grdrtNW BitmapID 130
1838 uTileID == 105 || //grdrtSW BitmapID 131
1839 uTileID == 106 || //grdrtE BitmapID 132
1840 uTileID == 107 || //grdrtW BitmapID 133
1841 uTileID == 108 || //grdrtN BitmapID 134
1842 uTileID == 109 || //grdrtS BitmapID 135
1843 uTileID == 110 || //grdrtXNE BitmapID 136
1844 uTileID == 112 || //grdrtXNW BitmapID 138
1845 uTileID == 113 || //grdrtXSW BitmapID 139
1846
1847 uTileID == 126 || uTileID == 127 || uTileID == 128 || uTileID == 129 ||
1848 uTileID == 130 || //wtrtyl BitmapID 89
1849 uTileID == 131 || //wtrtyl BitmapID 89
1850 uTileID == 132 || //wtrtyl BitmapID 89
1851 uTileID == 133 || //wtrtyl BitmapID 89
1852 uTileID == 134 || //wtrtyl BitmapID 89
1853 uTileID == 135 || //wtrtyl BitmapID 89
1854 uTileID == 136 || //wtrtyl BitmapID 89
1855 uTileID == 137 || //wtrtyl BitmapID 89
1856
1857 uTileID == 139 || //wtrdrSE BitmapID 141
1858 uTileID == 141 || //wrtdrSW BitmapID 143
1859 uTileID == 142 || //wrtdrE BitmapID 144
1860 uTileID == 143 || //wrtdrW BitmapID 145
1861 uTileID == 145 || //wtrdrS BitmapID 147
1862 uTileID == 147 || //wtrdrXSE BitmapID 149
1863 uTileID == 149 ) //wtrdrXSW BitmapID 151
1864 continue;*/
1865
1866 /*if (uTileID == 199 || //dirttyl BitmapID 0
1867 uTileID == 200 || //dirttyl BitmapID 0
1868 uTileID == 201 || //dirttyl BitmapID 0
1869 uTileID == 202 || //dirttyl BitmapID 0
1870 uTileID == 203 || //dirttyl BitmapID 0
1871 uTileID == 204 || //dirttyl BitmapID 0
1872 uTileID == 212 || //dirttyl BitmapID 0
1873 uTileID == 217) //dirttyl BitmapID 0
1874 continue;*/
1875
1876 v6 = v8->uTileBitmapID;
1877 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6];
1878
1879 if (v8->uTileBitmapID == 0xFFFF)
1880 continue;
1881
1882 v8->sTextureDeltaU = 0;
1883 v8->sTextureDeltaV = 0;
1884
1885
1886 /* world coordinates, z -> height
1887 32767
1888 +y
1889
1890 -32768 -x +x 32767
1891
1892 -y
1893 -32768
1894 */
1895
1896 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));
1897 array_73D150[0].u = 0;
1898 array_73D150[0].v = 0;
1899
1900 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));
1901 array_73D150[1].u = 1;
1902 array_73D150[1].v = 0;
1903
1904 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));
1905 array_73D150[2].u = 1;
1906 array_73D150[2].v = 1;
1907
1908 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));
1909 array_73D150[3].u = 0;
1910 array_73D150[3].v = 1;
1911
1912
1913 v55 = 0;
1914 v54 = false;
1915 v58 = 0;
1916
1917 if (v58 == 4) // if all y == first y; primitive in xz plane
1918 v8->field_32 |= 0x0001;
1919
1920 v8->pODMFace = nullptr;
1921 v8->uNumVertices = 4;
1922 v8->field_59 = 5;
1923
1924 v8->field_58 = 0;
1925
1926 ++pOutdoorCamera->numStru148s;
1927 ++pOutdoorCamera->field_44;
1928
1929
1930
1931 v8->uBModelID = 0;
1932 v8->uBModelFaceID = 0;
1933 v31 = (8 * (0 | (0 << 6)));
1934 v8->field_50 = v31 | 6;
1935
1936 for (unsigned int k = 0; k < 4; ++k)
1937 {
1938 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
1939 array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
1940 }
1941
1942
1943 pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]);
1944
1945 --pOutdoorCamera->numStru148s;
1946 --pOutdoorCamera->field_44;
1947
1948 }
1949
1950 }
1718 1951
1719 //----- (0048034E) -------------------------------------------------------- 1952 //----- (0048034E) --------------------------------------------------------
1720 void Render::DrawTerrainD3D(int a1, int a2, int a3) 1953 void Render::DrawTerrainD3D(int a1, int a2, int a3)
1721 { 1954 {
1722 int v3; // esi@1 1955 int v3; // esi@1
1756 unsigned int v36; // eax@50 1989 unsigned int v36; // eax@50
1757 int v37; // eax@54 1990 int v37; // eax@54
1758 stru148 *v38; // ecx@55 1991 stru148 *v38; // ecx@55
1759 unsigned int v39; // eax@59 1992 unsigned int v39; // eax@59
1760 stru148 *v40; // ebx@62 1993 stru148 *v40; // ebx@62
1761 unsigned __int16 v41; // ax@62 1994 unsigned __int16 pTileBitmapsID; // ax@62
1762 int v42; // eax@63 1995 int v42; // eax@63
1763 LightmapBuilder *v43; // ecx@63 1996 LightmapBuilder *v43; // ecx@63
1764 int v44; // eax@63 1997 int v44; // eax@63
1765 int v45; // eax@63 1998 int v45; // eax@63
1766 int v46; // eax@63 1999 int v46; // eax@63
1786 double v66; // st5@120 2019 double v66; // st5@120
1787 double v67; // st5@120 2020 double v67; // st5@120
1788 double v68; // st5@120 2021 double v68; // st5@120
1789 double v69; // st7@133 2022 double v69; // st7@133
1790 int v70; // edi@138 2023 int v70; // edi@138
1791 RenderVertexSoft *v71; // esi@147 2024 stru148 *v71; // esi@147
1792 unsigned int v72; // ecx@147 2025 unsigned int v72; // ecx@147
1793 unsigned int v73; // eax@150 2026 unsigned int v73; // eax@150
1794 int v74; // eax@154 2027 int v74; // eax@154
1795 unsigned int v75; // eax@158 2028 unsigned int v75; // eax@158
1796 unsigned int v76; // [sp-10h] [bp-E0h]@61 2029 unsigned int v76; // [sp-10h] [bp-E0h]@61
1879 !byte_4D864C) 2112 !byte_4D864C)
1880 || !(pGame->uFlags & 0x80)) 2113 || !(pGame->uFlags & 0x80))
1881 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ 2114 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/
1882 if ( !&stru_76E5C8[(v5 << 7) + v6] ) 2115 if ( !&stru_76E5C8[(v5 << 7) + v6] )
1883 goto LABEL_162; 2116 goto LABEL_162;
1884
1885 v8 = &pVerticesSR_806210[v4]; 2117 v8 = &pVerticesSR_806210[v4];
1886 pVertices2 = &pVerticesSR_801A10[v4 + 1]; 2118 pVertices2 = &pVerticesSR_801A10[v4 + 1];
1887 v102 = v8; 2119 v102 = v8;
1888 if (!v82) 2120 if (!v82)
1889 { 2121 {
1890 pVertices = &pVerticesSR_801A10[v4]; 2122 pVertices = &pVerticesSR_801A10[v4];
1891 v101 = &pVerticesSR_806210[v4 + 1]; 2123 v101 = &pVerticesSR_806210[v4 + 1];
1892 } 2124 }
1893 else 2125 else
1894 { 2126 {
1895 pVertices = &pVerticesSR_801A10[v4 + 1]; 2127 pVertices = &pVerticesSR_801A10[v4 + 1];
1896 v101 = &pVerticesSR_806210[v4]; 2128 v101 = &pVerticesSR_806210[v4];
1897 } 2129 }
1898
1899 sX = floorf(v8->vWorldPosition.x + 0.5f); 2130 sX = floorf(v8->vWorldPosition.x + 0.5f);
1900 sY = floorf(v8->vWorldPosition.z + 0.5f); 2131 sY = floorf(v8->vWorldPosition.z + 0.5f);
1901
1902 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); 2132 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));
1903 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); 2133 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f));
1904 WorldPosToGridCellX(sX); 2134 WorldPosToGridCellX(sX);
1905 WorldPosToGridCellZ(sY); 2135 WorldPosToGridCellZ(sY);
1906
1907 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) 2136 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1))
1908 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) 2137 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y
2138 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y )
1909 break; 2139 break;
1910 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; 2140 v16 = &array_77EC08[pOutdoorCamera->numStru148s];
1911 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); 2141 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
1912 if ( v16->uTileBitmapID != -1 ) 2142 if ( v16->uTileBitmapID != -1 )
1913 { 2143 {
1914 v19 = v97; 2144 v19 = v97;
1915 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); 2145 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY);
1916 v16->field_32 = 0; 2146 v16->field_32 = 0;
1917 v20 = v93; 2147 v20 = v93;
1918 v16->field_59 = 1; 2148 v16->field_59 = 1;
1919 v16->field_5D = (char)v19; 2149 v16->field_5D = (char)v19;
1920 v16->field_34 = *(_WORD *)(v20 + 2); 2150 v16->field_34 = *(_WORD *)(v20 + 2);
1921 v21 = v89; 2151 v21 = v89;
1922 v16->field_5C = v89; 2152 v16->field_5C = v89;
1923 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; 2153 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1];
1924 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) 2154 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 )
1925 v23 = 0; 2155 v23 = 0;
1926 else 2156 else
1927 v23 = &pTerrainNormals[v22]; 2157 v23 = &pTerrainNormals[v22];
1928 v24 = v92 * v23->y; 2158 v24 = v92 * v23->y;
1929 //v99 = v23; 2159 //v99 = v23;
1930 thisf = 20.0 - (-v24 - v91 * v23->z - v90 * v23->x) * 20.0; 2160 thisf = 20.0 - (-v24 - v91 * v23->z - v90 * v23->x) * 20.0;
1931 //v25 = thisf + 6.7553994e15; 2161 //v25 = thisf + 6.7553994e15;
1932 //v27 = pOutdoorCamera->numStru148s > 1999; 2162 //v27 = pOutdoorCamera->numStru148s > 1999;
1933 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; 2163 //v26 = pOutdoorCamera->numStru148s - 1999 < 0;
1934 v16->field_58 = floorf(thisf + 0.5f); 2164 v16->field_58 = floorf(thisf + 0.5f);
1935 if ( pOutdoorCamera->numStru148s >= 1999 ) 2165 if ( pOutdoorCamera->numStru148s >= 1999 )
1936 return; 2166 return;
1937 ++pOutdoorCamera->numStru148s; 2167 ++pOutdoorCamera->numStru148s;
1938 if ( !sub_481FC9(v8, pVertices, v101, v16) ) 2168 if ( !sub_481FC9(v8, pVertices, v101, v16) )
1939 //goto LABEL_126; 2169 //goto LABEL_126;
1940 { 2170 {
1941 --pOutdoorCamera->numStru148s; 2171 --pOutdoorCamera->numStru148s;
1942 goto LABEL_162; 2172 goto LABEL_162;
1943 } 2173 }
1944 v28 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); 2174 memcpy(&array_50AC10[0], v102, 0x30u);
1945 memcpy(&array_50AC10[0], v102, 0x30u); 2175 array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
1946 array_50AC10[0].flt_20 = v28; 2176 array_50AC10[0].u = 0.0;
1947 array_50AC10[0].u = 0.0; 2177 array_50AC10[0].v = 0.0;
1948 array_50AC10[0].v = 0.0; 2178 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1]));
1949 v29 = pVertices->vWorldViewPosition.x + 0.0000001000000011686097; 2179 array_50AC10[1].flt_20 = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097);
1950 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); 2180 array_50AC10[1].u = 0.0;
1951 array_50AC10[1].flt_20 = 1.0 / v29; 2181 array_50AC10[1].v = 1.0;
1952 array_50AC10[1].u = 0.0; 2182 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2]));
1953 array_50AC10[1].v = 1.0; 2183 array_50AC10[2].flt_20 = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097);
1954 v30 = pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; 2184 array_50AC10[2].u = 1.0;
1955 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); 2185 array_50AC10[2].v = 1.0;
1956 array_50AC10[2].flt_20 = 1.0 / v30; 2186 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3]));
1957 array_50AC10[2].u = 1.0; 2187 array_50AC10[3].flt_20 = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097);
1958 array_50AC10[2].v = 1.0; 2188 array_50AC10[3].u = 1.0;
1959 v31 = v101->vWorldViewPosition.x + 0.0000001000000011686097; 2189 array_50AC10[3].v = 0.0;
1960 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); 2190 /*if ( !(byte_76D5C0 & 1) )
1961 array_50AC10[3].flt_20 = 1.0 / v31; 2191 {
1962 array_50AC10[3].u = 1.0; 2192 byte_76D5C0 |= 1u;
1963 array_50AC10[3].v = 0.0; 2193 stru154(stru_76D5A8);
1964 2194 atexit(loc_481199);
1965 /*if ( !(byte_76D5C0 & 1) ) 2195 }*/
1966 { 2196 v32 = (struct8 *)array_50AC10;
1967 byte_76D5C0 |= 1u; 2197 v97 = (int)pGame->pLightmapBuilder;
1968 stru154(stru_76D5A8); 2198 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1);
1969 atexit(loc_481199); 2199 pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1);
2200 a5 = 4;
2201 if ( byte_4D864C && pGame->uFlags & 0x80 )
2202 {
2203 thisa = pGame->pIndoorCameraD3D;
2204 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 )
2205 goto LABEL_162;
2206 thisa->ViewTransform(array_50AC10, a5);
2207 thisa->Project(array_50AC10, a5, 0);
2208 }
2209 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0
2210 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0;
2211 v3a = (double)pOutdoorCamera->shading_dist_mist;
2212 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x
2213 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x;
2214 v33 = 0;
2215 pGame->pLightmapBuilder->std__vector_000004_size = 0;
2216 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
2217 {
2218 if ( this_3 )
2219 v33 = 3;
2220 else
2221 v33 = v108 != 0 ? 5 : 0;
2222 static_sub_0048034E_stru_154._49B0C9(v23, v95);
2223 if ( pDecalBuilder->uNumDecals > 0 )
2224 pDecalBuilder->ApplyDecals(31 - v16->field_58, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1);
2225 }
2226 if ( stru_F8AD28.uNumLightsApplied > 0 )
2227 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
2228 v34 = a5;
2229 //v35 = byte_4D864C == 0;
2230 v16->uNumVertices = a5;
2231 if ( !byte_4D864C || ~pGame->uFlags & 0x80 )
2232 {
2233 if ( this_3 )
2234 {
2235 v36 = sr_424CD7(v34);
2236 v16->uNumVertices = v36;
2237 OutdoorCamera::Project(v36);
2238 }
2239 if ( v108 )
2240 {
2241 v36 = sr_424EE0_MakeFanFromTriangle(v34);
2242 v16->uNumVertices = v36;
2243 OutdoorCamera::Project(v36);
2244 }
2245 }
2246 //v37 = *(int *)&v16->flags;
2247 if ( ~v16->flags & 1 )
2248 {
2249 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
2250 {
2251 v80 = false;
2252 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
2253 }
2254 else
2255 {
2256 v39 = v16->uTileBitmapID;
2257 v80 = true;
2258 }
2259 //v79 = 0;
2260 //v78 = pBitmaps_LOD->pHardwareTextures[v39];
2261 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary
2262 v77 = (int)v16;
2263 //v76 = v16->uNumVertices;
2264 //LABEL_161:
2265 pRenderer->DrawTerrainPolygon(v16, pBitmaps_LOD->pHardwareTextures[v39]);//pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80);
2266 goto LABEL_162;
2267 }
2268 v38 = v16;
2269 LABEL_56:
2270 v38->_4811A3();
2271 }
2272 LABEL_162:
2273 v4 = v88 + 1;
2274 if ( ++v88 >= v84 )
2275 return;
2276 }
2277 v40 = &array_77EC08[pOutdoorCamera->numStru148s];
2278 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
2279 if ( v40->uTileBitmapID == -1 )
2280 goto LABEL_162;
2281 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY);
2282 BYTE1(v42) |= 0x80u;
2283 v43 = pGame->pLightmapBuilder;
2284 *(int *)&v40->flags = v42;
2285 v44 = v93;
2286 v40->field_59 = 1;
2287 v40->field_5D = (char)v43;
2288 v40->field_34 = *(_WORD *)(v44 + 2);
2289 v45 = v89;
2290 v40->field_5C = v89;
2291 v46 = 4 * ((char)v43 + (v45 << 7));
2292 v85 = v46;
2293 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1];
2294 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) )
2295 v48 = 0;
2296 else
2297 v48 = &pTerrainNormals[v47];
2298 v49 = v92 * v48->y;
2299 //v99 = v48;
2300 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0;
2301 v50 = thisg + 6.755399441055744e15;
2302 v40->field_58 = LOBYTE(v50);
2303 if ( LOBYTE(v50) < 0 )
2304 v40->field_58 = 0;
2305 if ( pOutdoorCamera->numStru148s >= 1999 )
2306 return;
2307 ++pOutdoorCamera->numStru148s;
2308 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary
2309 //goto LABEL_77;
2310 {
2311 --pOutdoorCamera->numStru148s;
2312 goto LABEL_112;
1970 }*/ 2313 }*/
1971 v32 = (struct8 *)array_50AC10; 2314 memcpy(&array_50AC10[0], v102, 0x30u);
1972 v97 = (int)pGame->pLightmapBuilder; 2315 array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
1973 pGame->pLightmapBuilder->StackLights_TerrainFace(v99, &v95, array_50AC10, 4, 1); 2316 array_50AC10[0].u = 0.0;
1974 pDecalBuilder->_49BE8A(v16, *(float *)&v99, (int)&v95, array_50AC10, 4u, 1); 2317 array_50AC10[0].v = 0.0;
1975 a5 = 4; 2318 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1]));
1976 if ( byte_4D864C && pGame->uFlags & 0x80 ) 2319 array_50AC10[1].flt_20 = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097;
1977 { 2320 array_50AC10[1].u = 0.0;
1978 thisa = pGame->pIndoorCameraD3D; 2321 array_50AC10[1].v = 1.0;
1979 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) 2322 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2]));
2323 array_50AC10[2].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
2324 array_50AC10[2].u = 1.0;
2325 array_50AC10[2].v = 1.0;
2326 static stru154 static_sub_0048034E_stru_76D590;
2327 /*static bool __init_flag2 = false;
2328 if (!__init_flag2)
2329 {
2330 __init_flag2 = true;
2331 stru154::stru154(&static_sub_0048034E_stru_76D590);
2332 }*/
2333 /*if ( !(byte_76D5C0 & 2) )
2334 {
2335 byte_76D5C0 |= 2;
2336 stru148(stru_76D590);
2337 atexit(loc_48118F);
2338 }*/
2339 v96 = pGame->pLightmapBuilder;
2340 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0);
2341 pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0);
2342 uNumVertices = 3;
2343 if ( byte_4D864C && pGame->uFlags & 0x80 )
2344 {
2345 thisb = pGame->pIndoorCameraD3D;
2346 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices )
2347 {
2348 //LABEL_77:
2349 --pOutdoorCamera->numStru148s;
2350 goto LABEL_112;
2351 }
2352 thisb->ViewTransform(array_50AC10, uNumVertices);
2353 thisb->Project(array_50AC10, uNumVertices, 0);
2354 }
2355 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0;
2356 v54 = (double)pOutdoorCamera->shading_dist_mist;
2357 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x;
2358 pVertices = 0;
2359 v96->std__vector_000004_size = 0;
2360 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
2361 {
2362 if ( this_3a )
2363 pVertices = (RenderVertexSoft *)3;
2364 else
2365 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0);
2366 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0);
2367 static_sub_0048034E_stru_76D590._49B0C9(v48, *(float *)&a4);
2368 if ( pDecalBuilder->uNumDecals > 0 )
2369 pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1);
2370 }
2371 if ( stru_F8AD28.uNumLightsApplied > 0 )
2372 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices);
2373 v55 = uNumVertices;
2374 //v35 = byte_4D864C == 0;
2375 v40->uNumVertices = uNumVertices;
2376 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) )
2377 {
2378 if ( this_3a )
2379 {
2380 v56 = sr_424CD7(v55);
2381 }
2382 else
2383 {
2384 if ( !v108 )
2385 goto LABEL_105;
2386 v56 = sr_424EE0_MakeFanFromTriangle(v55);
2387 }
2388 v40->uNumVertices = v56;
2389 OutdoorCamera::Project(v56);
2390 }
2391 LABEL_105:
2392 v57 = *(int *)&v40->flags;
2393 if ( BYTE1(v57) & 1 )
2394 {
2395 v40->_4811A3();
2396 }
2397 else
2398 {
2399 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
2400 {
2401 v81 = 0;
2402 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
2403 }
2404 else
2405 {
2406 v58 = v40->uTileBitmapID;
2407 v81 = 1;
2408 }
2409 pRenderer->DrawTerrainPolygon(v40, pBitmaps_LOD->pHardwareTextures[v58]);
2410 }
2411 LABEL_112:
2412 v59 = &array_77EC08[pOutdoorCamera->numStru148s];
2413 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s];
2414 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
2415 if ( v59->uTileBitmapID == -1 )
2416 goto LABEL_162;
2417 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY);
2418 v61 = v93;
2419 v59->field_59 = 1;
2420 v59->field_34 = *(_WORD *)(v61 + 2);
2421 v59->field_5C = v89;
2422 v59->field_5D = v97;
2423 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85);
2424 if ( v62 > (signed int)(uNumTerrainNormals - 1) )
2425 v63 = 0;
2426 else
2427 v63 = &pTerrainNormals[v62];
2428 v64 = v92 * v63->y;
2429 //v99 = v63;
2430 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0;
2431 v59->field_58 = floorf(thish + 0.5f);
2432 if ( v59->field_58 < 0 )
2433 v59->field_58 = 0;
2434 if ( pOutdoorCamera->numStru148s >= 1999 )
2435 return;
2436 ++pOutdoorCamera->numStru148s;
2437 if ( !sub_481FC9(v101, v102, pVertices2, v59) )
2438 {
2439 //LABEL_126:
2440 --pOutdoorCamera->numStru148s;
2441 goto LABEL_162;
2442 }
2443 memcpy(&array_50AC10[0], v102, 0x30u);
2444 array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
2445 array_50AC10[0].u = 0.0;
2446 array_50AC10[0].v = 0.0;
2447 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1]));
2448 array_50AC10[1].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
2449 array_50AC10[1].u = 1.0;
2450 array_50AC10[1].v = 1.0;
2451 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2]));
2452 array_50AC10[2].flt_20 = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097;
2453 array_50AC10[2].u = 1.0;
2454 array_50AC10[2].v = 0.0;
2455 static stru154 static_sub_0048034E_stru_76D578;
2456 /*static bool __init_flag1 = false;
2457 if (!__init_flag1)
2458 {
2459 __init_flag1 = true;
2460 stru154::stru154(&static_sub_0048034E_stru_76D578);
2461 }*/
2462 v96 = pGame->pLightmapBuilder;
2463 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1);
2464 pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1);
2465 v100 = 3;
2466 if ( byte_4D864C && pGame->uFlags & 0x80 )
2467 {
2468 thisc = pGame->pIndoorCameraD3D;
2469 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 )
2470 //goto LABEL_126;
2471 {
2472 --pOutdoorCamera->numStru148s;
2473 goto LABEL_162;
2474 }
2475 thisc->ViewTransform(array_50AC10, v100);
2476 thisc->Project(array_50AC10, v100, 0);
2477 }
2478 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0
2479 || v101->vWorldViewPosition.x < 8.0;
2480 v69 = (double)pOutdoorCamera->shading_dist_mist;
2481 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x;
2482 v70 = 0;
2483 v96->std__vector_000004_size = 0;
2484 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
2485 {
2486 if ( this_3b )
2487 v70 = 3;
2488 else
2489 v70 = v108 != 0 ? 5 : 0;
2490 static_sub_0048034E_stru_76D578._49B0C9(v63, v87);
2491 if ( pDecalBuilder->uNumDecals > 0 )
2492 pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1);
2493 }
2494 if ( stru_F8AD28.uNumLightsApplied > 0 )
2495 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
2496 v71 = v59;
2497 v72 = v100;
2498 //v35 = byte_4D864C == 0;
2499 v59->uNumVertices = v100;//???
2500 if ( !byte_4D864C && pGame->uFlags & 0x80 )
2501 goto LABEL_154;
2502 if ( this_3b )
2503 {
2504 v73 = sr_424CD7(v72);
2505 }
2506 else
2507 {
2508 if ( !v108 )
2509 {
2510 LABEL_154:
2511 v74 = v71->flags;
2512 if ( !(BYTE1(v74) & 1) )
2513 {
2514 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
2515 {
2516 v80 = false;
2517 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
2518 }
2519 else
2520 {
2521 v75 = v71->uTileBitmapID;
2522 v80 = true;
2523 }
2524 //v79 = 0;
2525 //v78 = pBitmaps_LOD->pHardwareTextures[v75];
2526 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary
2527 //v77 = (int)v71;
2528 //v76 = v71->uNumVertices;
2529 //goto LABEL_161;
2530 pRenderer->DrawTerrainPolygon(v71, pBitmaps_LOD->pHardwareTextures[v75]);//pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80);
1980 goto LABEL_162; 2531 goto LABEL_162;
1981 thisa->ViewTransform(array_50AC10, a5);
1982 thisa->Project(array_50AC10, a5, 0);
1983 }
1984 this_3 = v102->vWorldViewPosition.x < 8.0
1985 || pVertices->vWorldViewPosition.x < 8.0
1986 || v101->vWorldViewPosition.x < 8.0
1987 || pVertices2->vWorldViewPosition.x < 8.0;
1988 v3a = (double)pOutdoorCamera->shading_dist_mist;
1989 v108 = v3a < v102->vWorldViewPosition.x
1990 || v3a < pVertices->vWorldViewPosition.x
1991 || v3a < v101->vWorldViewPosition.x
1992 || v3a < pVertices2->vWorldViewPosition.x;
1993 v33 = 0;
1994 pGame->pLightmapBuilder->std__vector_000004_size = 0;
1995 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
1996 {
1997 if ( this_3 )
1998 v33 = 3;
1999 else
2000 v33 = v108 != 0 ? 5 : 0;
2001 static_sub_0048034E_stru_154._49B0C9(v99, v95);
2002 if ( pDecalBuilder->uNumDecals > 0 )
2003 pDecalBuilder->ApplyDecals(31 - v16->field_58,
2004 4,
2005 &static_sub_0048034E_stru_154,
2006 a5,
2007 array_50AC10,
2008 0,
2009 *(float *)&v33,
2010 -1);
2011 }
2012 if ( stru_F8AD28.uNumLightsApplied > 0 )
2013 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
2014 v34 = a5;
2015 //v35 = byte_4D864C == 0;
2016 v16->uNumVertices = a5;
2017 if ( !byte_4D864C || ~pGame->uFlags & 0x80 )
2018 {
2019 if ( this_3 )
2020 {
2021 v36 = sr_424CD7(v34);
2022 v16->uNumVertices = v36;
2023 OutdoorCamera::Project(v36);
2024 } 2532 }
2025 if ( v108 ) 2533 v38 = (stru148 *)v71;
2026 { 2534 goto LABEL_56;
2027 v36 = sr_424EE0_MakeFanFromTriangle(v34); 2535 }
2028 v16->uNumVertices = v36; 2536 v73 = sr_424EE0_MakeFanFromTriangle(v72);
2029 OutdoorCamera::Project(v36); 2537 }
2030 } 2538 v71->uNumVertices = v73;
2031 } 2539 OutdoorCamera::Project(v73);
2032 //v37 = *(int *)&v16->flags;
2033 if ( ~v16->flags & 1 )
2034 {
2035 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
2036 {
2037 v80 = false;
2038 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
2039 }
2040 else
2041 {
2042 v39 = v16->uTileBitmapID;
2043 v80 = true;
2044 }
2045 //v79 = 0;
2046 v78 = pBitmaps_LOD->pHardwareTextures[v39];
2047 v77 = (int)v16;
2048 v76 = v16->uNumVertices;
2049 //LABEL_161:
2050 pRenderer->DrawTerrainPolygon(v76, v16, v78, false, v80);
2051 goto LABEL_162;
2052 }
2053 v38 = v16;
2054 LABEL_56:
2055 v38->_4811A3();
2056 }
2057 LABEL_162:
2058 v4 = v88 + 1;
2059 if ( ++v88 >= v84 )
2060 return;
2061 }
2062 v40 = &array_77EC08[pOutdoorCamera->numStru148s];
2063 v41 = pOutdoor->GetTileTexture(sX, sY);
2064 v40->uTileBitmapID = v41;
2065 if ( v41 == -1 )
2066 goto LABEL_162;
2067 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY);
2068 BYTE1(v42) |= 0x80u;
2069 v43 = pGame->pLightmapBuilder;
2070 *(int *)&v40->flags = v42;
2071 v44 = v93;
2072 v40->field_59 = 1;
2073 v40->field_5D = (char)v43;
2074 v40->field_34 = *(_WORD *)(v44 + 2);
2075 v45 = v89;
2076 v40->field_5C = v89;
2077 v46 = 4 * ((char)v43 + (v45 << 7));
2078 v85 = v46;
2079 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1];
2080 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) )
2081 v48 = 0;
2082 else
2083 v48 = &pTerrainNormals[v47];
2084 v49 = v92 * v48->y;
2085 //v99 = v48;
2086 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0;
2087 v50 = thisg + 6.755399441055744e15;
2088 v40->field_58 = LOBYTE(v50);
2089 if ( LOBYTE(v50) < 0 )
2090 v40->field_58 = 0;
2091 if ( pOutdoorCamera->numStru148s >= 1999 )
2092 return;
2093 ++pOutdoorCamera->numStru148s;
2094 if ( !sub_481FC9(pVertices, pVertices2, v8, v40) )
2095 //goto LABEL_77;
2096 {
2097 --pOutdoorCamera->numStru148s;
2098 goto LABEL_112;
2099 }
2100 v51 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
2101 memcpy(&array_50AC10[0], v102, 0x30u);
2102 array_50AC10[0].flt_20 = v51;
2103 array_50AC10[0].u = 0.0;
2104 array_50AC10[0].v = 0.0;
2105 v52 = pVertices->vWorldViewPosition.x + 0.0000001000000011686097;
2106 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1]));
2107 array_50AC10[1].flt_20 = 1.0 / v52;
2108 array_50AC10[1].u = 0.0;
2109 array_50AC10[1].v = 1.0;
2110 v53 = pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
2111 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2]));
2112 array_50AC10[2].flt_20 = 1.0 / v53;
2113 array_50AC10[2].u = 1.0;
2114 array_50AC10[2].v = 1.0;
2115
2116 static stru154 static_sub_0048034E_stru_76D590;
2117 /*static bool __init_flag2 = false;
2118 if (!__init_flag2)
2119 {
2120 __init_flag2 = true;
2121
2122 stru154::stru154(&static_sub_0048034E_stru_76D590);
2123 }*/
2124 /*if ( !(byte_76D5C0 & 2) )
2125 {
2126 byte_76D5C0 |= 2;
2127 stru148(stru_76D590);
2128 atexit(loc_48118F);
2129 }*/
2130 v96 = pGame->pLightmapBuilder;
2131 pGame->pLightmapBuilder->StackLights_TerrainFace(v99, (float *)&a4, array_50AC10, 3, 0);
2132 pDecalBuilder->_49BE8A(v40, *(float *)&v99, (int)&a4, array_50AC10, 3, 0);
2133 uNumVertices = 3;
2134 if ( byte_4D864C && pGame->uFlags & 0x80 )
2135 {
2136 thisb = pGame->pIndoorCameraD3D;
2137 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices )
2138 {
2139 //LABEL_77:
2140 --pOutdoorCamera->numStru148s;
2141 goto LABEL_112;
2142 }
2143 thisb->ViewTransform(array_50AC10, uNumVertices);
2144 thisb->Project(array_50AC10, uNumVertices, 0);
2145 }
2146 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0;
2147 v54 = (double)pOutdoorCamera->shading_dist_mist;
2148 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x;
2149 pVertices = 0;
2150 v96->std__vector_000004_size = 0;
2151 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
2152 {
2153 if ( this_3a )
2154 pVertices = (RenderVertexSoft *)3;
2155 else
2156 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0);
2157 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0);
2158 static_sub_0048034E_stru_76D590._49B0C9(v99, *(float *)&a4);
2159 if ( pDecalBuilder->uNumDecals > 0 )
2160 pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1);
2161 }
2162 if ( stru_F8AD28.uNumLightsApplied > 0 )
2163 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices);
2164 v55 = uNumVertices;
2165 //v35 = byte_4D864C == 0;
2166 v40->uNumVertices = uNumVertices;
2167 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) )
2168 {
2169 if ( this_3a )
2170 {
2171 v56 = sr_424CD7(v55);
2172 }
2173 else
2174 {
2175 if ( !v108 )
2176 goto LABEL_105;
2177 v56 = sr_424EE0_MakeFanFromTriangle(v55);
2178 }
2179 v40->uNumVertices = v56;
2180 OutdoorCamera::Project(v56);
2181 }
2182 LABEL_105:
2183 v57 = *(int *)&v40->flags;
2184 if ( BYTE1(v57) & 1 )
2185 {
2186 v40->_4811A3();
2187 }
2188 else
2189 {
2190 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
2191 {
2192 v81 = 0;
2193 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
2194 }
2195 else
2196 {
2197 v58 = v40->uTileBitmapID;
2198 v81 = 1;
2199 }
2200 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81);
2201 }
2202 LABEL_112:
2203 v59 = &array_77EC08[pOutdoorCamera->numStru148s];
2204 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s];
2205 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
2206 if ( v59->uTileBitmapID == -1 )
2207 goto LABEL_162;
2208 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY);
2209 v61 = v93;
2210 v59->field_59 = 1;
2211 v59->field_34 = *(_WORD *)(v61 + 2);
2212 v59->field_5C = v89;
2213 v59->field_5D = v97;
2214 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85);
2215 if ( v62 > (signed int)(uNumTerrainNormals - 1) )
2216 v63 = 0;
2217 else
2218 v63 = &pTerrainNormals[v62];
2219 v64 = v92 * v63->y;
2220 //v99 = v63;
2221 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0;
2222 v59->field_58 = floorf(thish + 0.5f);
2223 if ( v59->field_58 < 0 )
2224 v59->field_58 = 0;
2225 if ( pOutdoorCamera->numStru148s >= 1999 )
2226 return;
2227 ++pOutdoorCamera->numStru148s;
2228 if ( !sub_481FC9(v101, v102, pVertices2, v59) )
2229 {
2230 //LABEL_126:
2231 --pOutdoorCamera->numStru148s;
2232 goto LABEL_162;
2233 }
2234 v66 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
2235 memcpy(&array_50AC10[0], v102, 0x30u);
2236 array_50AC10[0].flt_20 = v66;
2237 array_50AC10[0].u = 0.0;
2238 array_50AC10[0].v = 0.0;
2239 v67 = pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
2240 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1]));
2241 array_50AC10[1].flt_20 = 1.0 / v67;
2242 array_50AC10[1].u = 1.0;
2243 array_50AC10[1].v = 1.0;
2244 v68 = v101->vWorldViewPosition.x + 0.0000001000000011686097;
2245 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2]));
2246 array_50AC10[2].flt_20 = 1.0 / v68;
2247 array_50AC10[2].u = 1.0;
2248 array_50AC10[2].v = 0.0;
2249
2250 static stru154 static_sub_0048034E_stru_76D578;
2251 /*static bool __init_flag1 = false;
2252 if (!__init_flag1)
2253 {
2254 __init_flag1 = true;
2255
2256 stru154::stru154(&static_sub_0048034E_stru_76D578);
2257 }*/
2258
2259 v96 = pGame->pLightmapBuilder;
2260 pGame->pLightmapBuilder->StackLights_TerrainFace(v99, &v87, array_50AC10, 3u, 1);
2261 pDecalBuilder->_49BE8A(v40, *(float *)&v99, (int)&v87, array_50AC10, 3u, 1);
2262 v100 = 3;
2263 if ( byte_4D864C && pGame->uFlags & 0x80 )
2264 {
2265 thisc = pGame->pIndoorCameraD3D;
2266 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 )
2267 //goto LABEL_126;
2268 {
2269 --pOutdoorCamera->numStru148s;
2270 goto LABEL_162;
2271 }
2272 thisc->ViewTransform(array_50AC10, v100);
2273 thisc->Project(array_50AC10, v100, 0);
2274 }
2275 this_3b = v102->vWorldViewPosition.x < 8.0
2276 || pVertices2->vWorldViewPosition.x < 8.0
2277 || v101->vWorldViewPosition.x < 8.0;
2278 v69 = (double)pOutdoorCamera->shading_dist_mist;
2279 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x;
2280 v70 = 0;
2281 v96->std__vector_000004_size = 0;
2282 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
2283 {
2284 if ( this_3b )
2285 v70 = 3;
2286 else
2287 v70 = v108 != 0 ? 5 : 0;
2288 static_sub_0048034E_stru_76D578._49B0C9(v99, v87);
2289 if ( pDecalBuilder->uNumDecals > 0 )
2290 pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1);
2291 }
2292 if ( stru_F8AD28.uNumLightsApplied > 0 )
2293 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
2294 v71 = (RenderVertexSoft *)v59;
2295 v72 = v100;
2296 //v35 = byte_4D864C == 0;
2297 v59->uNumVertices = v100;//???
2298 if ( !byte_4D864C && pGame->uFlags & 0x80 )
2299 goto LABEL_154; 2540 goto LABEL_154;
2300 if ( this_3b ) 2541 }
2301 { 2542 }
2302 v73 = sr_424CD7(v72);
2303 }
2304 else
2305 {
2306 if ( !v108 )
2307 {
2308 LABEL_154:
2309 v74 = v71[1].vWorldPosition.x;
2310 if ( !(BYTE1(v74) & 1) )
2311 {
2312 if ( v74 & 2 && LOWORD(v71[1].vWorldViewProjY) == pRenderer->field_1036AC_bitmapid )
2313 {
2314 v80 = false;
2315 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
2316 }
2317 else
2318 {
2319 v75 = v71[1].vWorldViewProjY;
2320 v80 = true;
2321 }
2322 //v79 = 0;
2323 v78 = pBitmaps_LOD->pHardwareTextures[v75];
2324 v77 = (int)v71;
2325 v76 = v71->vWorldViewPosition.z;
2326 //goto LABEL_161;
2327 {
2328 pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80);
2329 goto LABEL_162;
2330 }
2331 }
2332 v38 = (stru148 *)v71;
2333 goto LABEL_56;
2334 }
2335 v73 = sr_424EE0_MakeFanFromTriangle(v72);
2336 }
2337 v71->vWorldViewPosition.z = v73;
2338 OutdoorCamera::Project(v73);
2339 goto LABEL_154;
2340 }
2341 }
2342 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); 2543 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
2343 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); 2544 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
2344 // 4D864C: using guessed type char byte_4D864C; 2545 // 4D864C: using guessed type char byte_4D864C;
2345 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; 2546 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag;
2346 2547
7124 unsigned int Render::GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6) 7325 unsigned int Render::GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6)
7125 { 7326 {
7126 return ::GetActorTintColor(a3, a4, a2, a5, a6); 7327 return ::GetActorTintColor(a3, a4, a2, a5, a6);
7127 } 7328 }
7128 7329
7129 7330 void Render::DrawTerrainPolygon(stru148 *a3, IDirect3DTexture2 *pTexture)//new function
7331 {
7332 int v5; // ebx@1
7333 int v6; // edi@1
7334 int v8; // eax@7
7335 float v9; // eax@12
7336 float *v10; // esi@12
7337 float v11; // ecx@14
7338 double v12; // st7@14
7339 double v13; // st7@14
7340 double v14; // st7@14
7341 signed int v15; // eax@14
7342 int v16; // eax@15
7343 float v17; // ST48_4@15
7344 char v18; // zf@17
7345 int v19; // eax@18
7346 int v20; // eax@18
7347 int v21; // edx@20
7348 signed int v22; // ecx@20
7349 int v23; // eax@20
7350 const char *v24; // ST4C_4@20
7351 unsigned int v25; // ST50_4@20
7352 int v26; // ST54_4@20
7353 int v27; // eax@20
7354 _UNKNOWN *v28; // eax@21
7355 int v29; // ecx@23
7356 int v30; // eax@23
7357 int v31; // eax@23
7358 int v32; // eax@24
7359 int v33; // eax@25
7360 int v34; // eax@25
7361 int v35; // eax@25
7362 int v36; // eax@25
7363 signed int v37; // ecx@26
7364 int v38; // eax@26
7365 _UNKNOWN *v39; // eax@27
7366 int v40; // edx@28
7367 int v41; // eax@29
7368 int v42; // eax@29
7369 int v43; // eax@29
7370 int v44; // eax@29
7371 unsigned int v46; // eax@29
7372 int v47; // eax@30
7373 int v48; // eax@30
7374 int v49; // eax@30
7375 double v52; // st6@35
7376 const char *v55; // [sp+4Ch] [bp-1Ch]@20
7377 int v57; // [sp+5Ch] [bp-Ch]@3
7378 signed int v59; // [sp+60h] [bp-8h]@12
7379 int v61; // [sp+64h] [bp-4h]@4
7380 int i;
7381
7382 v6 = (int)this;
7383 v5 = 0;
7384 if (!this->uNumD3DSceneBegins)
7385 return;
7386
7387
7388
7389
7390 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1);
7391 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
7392 if (this->bUsingSpecular)
7393 {
7394 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
7395 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2);
7396 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1);
7397 }
7398
7399 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX;
7400 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY;
7401 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist);
7402 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097);
7403 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
7404 pVertices[0].specular = 0;
7405 pVertices[0].texcoord.x = array_50AC10[0].u;
7406 pVertices[0].texcoord.y = array_50AC10[0].v;
7407
7408 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX;
7409 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY;
7410 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist);
7411 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097);
7412 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0);
7413 pVertices[1].specular = 0;
7414 pVertices[1].texcoord.x = array_50AC10[3].u;
7415 pVertices[1].texcoord.y = array_50AC10[3].v;
7416
7417 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX;
7418 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY;
7419 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist);
7420 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097);
7421 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0);
7422 pVertices[2].specular = 0;
7423 pVertices[2].texcoord.x = array_50AC10[1].u;
7424 pVertices[2].texcoord.y = array_50AC10[1].v;
7425
7426 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3));
7427 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3));
7428
7429 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX;
7430 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY;
7431 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist);
7432 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097);
7433 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0);
7434 pVertices[5].specular = 0;
7435 pVertices[5].texcoord.x = array_50AC10[2].u;
7436 pVertices[5].texcoord.y = array_50AC10[2].v;
7437
7438
7439 this->pRenderD3D->pDevice->SetTexture(0, pTexture);
7440 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT);
7441
7442 }
7130 //----- (004A26BC) -------------------------------------------------------- 7443 //----- (004A26BC) --------------------------------------------------------
7131 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7) 7444 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7)
7132 { 7445 {
7133 RenderVertexSoft *pVertices; // esi@0 7446 RenderVertexSoft *pVertices; // esi@0
7134 int v7; // edi@1 7447 int v7; // edi@1
7274 if ( v21 ) 7587 if ( v21 )
7275 break; 7588 break;
7276 v51 = a7; 7589 v51 = a7;
7277 } 7590 }
7278 } 7591 }
7279 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); 7592 this->pRenderD3D->pDevice->SetTexture(0, a5);
7280 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( 7593 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
7281 D3DPT_TRIANGLEFAN, 7594 arary_77E5C8, uNumVertices, 16);
7282 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
7283 arary_77E5C8,
7284 uNumVertices,
7285 16));
7286 if ( a6 ) 7595 if ( a6 )
7287 { 7596 {
7288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); 7597 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
7289 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); 7598 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
7290 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); 7599 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));