comparison mm7_1.cpp @ 1281:21a46b38ca24

m
author Ritor1
date Sat, 15 Jun 2013 09:55:07 +0600
parents 77ea5c5f2c0b
children 8a196c858180
comparison
equal deleted inserted replaced
1240:353cb3ad9725 1281:21a46b38ca24
9 */ 9 */
10 10
11 //#include <defs.h> 11 //#include <defs.h>
12 #include <assert.h> 12 #include <assert.h>
13 13
14 #include "Texture.h"
15 #include "mm7_data.h"
14 #include "VideoPlayer.h" 16 #include "VideoPlayer.h"
15 #include "BSPModel.h" 17 #include "BSPModel.h"
16 #include "Mouse.h" 18 #include "Mouse.h"
17 19
18 #include "Vis.h" 20 #include "Vis.h"
1486 1488
1487 //----- (00423B5D) -------------------------------------------------------- 1489 //----- (00423B5D) --------------------------------------------------------
1488 int __fastcall sub_423B5D(unsigned int uFaceID) 1490 int __fastcall sub_423B5D(unsigned int uFaceID)
1489 { 1491 {
1490 BLVFace *pFace; // ebx@1 1492 BLVFace *pFace; // ebx@1
1493 //Vec3_short_ *v2; // esi@1
1494 //int v3; // ST28_4@1
1495 //__int16 v4; // ST2C_2@1
1496 //signed int v5; // esi@1
1497 //Vec3_short_ *v6; // eax@4
1498 //signed int v7; // edi@5
1499 //signed int v8; // eax@5
1500 //signed int i_; // ecx@10
1501 //int v10; // eax@10
1502 //int v11; // edx@11
1503 //int v12; // ST28_4@12
1504 //signed int v13; // edx@12
1505 //signed __int64 v14; // qtt@12
1506 //int *v15; // ebx@12
1507 //int v16; // ST28_4@14
1508 //signed int v17; // eax@14
1509 //signed __int64 v18; // qtt@14
1510 //signed int v19; // edx@15
1511 //signed int v20; // edx@17
1512 //signed int v21; // ebx@19
1513 //signed int v22; // esi@20
1514 //int v23; // edi@21
1515 int v24; // eax@21
1516 //int v25; // eax@22
1517 int v26; // eax@22
1518 //signed int v27; // ST30_4@24
1519 //signed __int64 v28; // qtt@24
1520 //int v29; // ST18_4@25
1521 int v30; // eax@26
1522 //int v31; // eax@27
1523 int v32; // eax@27
1524 //signed int v33; // ST30_4@29
1525 //signed __int64 v34; // qtt@29
1526 //int v35; // ST30_4@30
1527 signed int for_x_num_vertices; // edi@31
1528 //unsigned int v37; // eax@31
1529 //bool v38; // edx@31
1530 //int v39; // ecx@31
1531 //int v40; // ecx@32
1532 //int v41; // esi@32
1533 int v42; // eax@34
1534 signed int for_z_num_vertices; // ebx@41
1535 //unsigned int v44; // eax@41
1536 //signed int v45; // ecx@42
1537 //int v46; // esi@42
1538 int v47; // eax@44
1539 signed int for_y_num_vertices; // edi@51
1540 //unsigned int v49; // eax@51
1541 //bool v50; // edx@51
1542 //int v51; // ecx@51
1543 //int v52; // ecx@52
1544 //signed int v53; // esi@52
1545 int v54; // eax@54
1546 int for_w_num_vertices; // ebx@61
1547 //unsigned int v56; // eax@61
1548 //signed int v57; // ecx@62
1549 //int v58; // esi@62
1550 int v59; // eax@64
1551 char v61; // zf@72
1552 signed int v62; // edx@75
1553 int v63; // ecx@76
1554 int v64; // esi@76
1555 int v65; // ecx@83
1556 //signed int v66; // [sp+14h] [bp-14h]@3
1557 int v67; // [sp+14h] [bp-14h]@34
1558 int v68; // [sp+14h] [bp-14h]@44
1559 int v69; // [sp+14h] [bp-14h]@54
1560 int v70; // [sp+14h] [bp-14h]@64
1561 signed int v71; // [sp+14h] [bp-14h]@75
1562 bool current_vertices_flag; // [sp+18h] [bp-10h]@9
1563 //int thisb; // [sp+18h] [bp-10h]@12
1564 //int thisc; // [sp+18h] [bp-10h]@20
1565 //bool thisd; // [sp+18h] [bp-10h]@41
1566 //bool thise; // [sp+18h] [bp-10h]@61
1567 int thisf; // [sp+18h] [bp-10h]@74
1568 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9
1569 int v80; // [sp+1Ch] [bp-Ch]@76
1570 bool next_vertices_flag; // [sp+20h] [bp-8h]@10
1571 //bool v82; // [sp+20h] [bp-8h]@32
1572 //bool v83; // [sp+20h] [bp-8h]@42
1573 //bool v84; // [sp+20h] [bp-8h]@52
1574 //bool v85; // [sp+20h] [bp-8h]@62
1575 //signed int i; // [sp+24h] [bp-4h]@9
1576 //unsigned int i; // [sp+24h] [bp-4h]@19
1577 //signed int ix; // [sp+24h] [bp-4h]@31
1578 //signed int iz; // [sp+24h] [bp-4h]@41
1579 //signed int iy; // [sp+24h] [bp-4h]@51
1580 //signed int iw; // [sp+24h] [bp-4h]@61
1581
1582 pFace = &pIndoor->pFaces[uFaceID];
1583 memset(&stru_50B700, 0, sizeof(stru367));
1584
1585 if ( pFace->pFacePlane.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)//check the angle of the vector and the plane
1586 + pFace->pFacePlane.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
1587 + pFace->pFacePlane.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 )
1588 {
1589 stru_50B700.field_0 = 1;
1590 }
1591 else
1592 {
1593 stru_50B700.field_0 = 0;
1594 if ( !pFace->Portal() )
1595 return 0;
1596 }
1597 for (uint i = 0; i < pFace->uNumVertices; ++i)
1598 {
1599 //перенос вершины в пространство камеры(перед камерой), определяет находятся ли она после этого в её поле зрения
1600 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x,
1601 pIndoor->pVertices[pFace->pVertexIDs[i]].y, pIndoor->pVertices[pFace->pVertexIDs[i]].z,
1602 &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0);
1603 }
1604
1605 if (pFace->uNumVertices <= 0)
1606 return 0;
1607
1608 bool bFound = false;
1609 for (uint i = 0; i < pFace->uNumVertices; ++i)
1610 if (stru_50B700._view_transformed_xs[i] >= 0x80000u)//отбраковывание по задней границе(cull for near clip plane) по z координате
1611 {
1612 bFound = true;
1613 break;
1614 }
1615 if (!bFound)
1616 return 0;
1617
1618 int t;
1619 depth_num_vertices = 0;
1620 stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0];
1621 stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0];
1622 stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0];
1623
1624 //for near clip plane
1625 current_vertices_flag = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;
1626 for ( uint i = 1; i <= pFace->uNumVertices; ++i)
1627 {
1628 next_vertices_flag = stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u;
1629 if ( current_vertices_flag ^ next_vertices_flag )
1630 {
1631 if ( next_vertices_flag )
1632 {
1633 //t = (near_clip - v0.z)/(v1.z - v0.z)
1634 t = (0x80000 - stru_50B700._view_transformed_xs[i - 1]) / (stru_50B700._view_transformed_xs[i] - stru_50B700._view_transformed_xs[i - 1]);
1635 //x = (v1.x -v0.x)*t + v1.x
1636 stru_50B700.field_38[depth_num_vertices] = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1])
1637 * t) + stru_50B700._view_transformed_ys[i];
1638 //y = (v1.y - v0.y)*t + v0.y
1639 stru_50B700.field_128[depth_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1])
1640 * t)) + stru_50B700._view_transformed_zs[i - 1];
1641 stru_50B700.field_218[depth_num_vertices] = 0x80000u;//z = 8.0
1642 }
1643 else
1644 {
1645 t = (0x80000 - stru_50B700._view_transformed_xs[i]) / (stru_50B700._view_transformed_xs[i - 1] - stru_50B700._view_transformed_xs[i]);
1646 //x = (v0.x - v1.x)*t + v1.x
1647 stru_50B700.field_38[depth_num_vertices] = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i])
1648 * t) + stru_50B700._view_transformed_ys[i];
1649 //y = (v0.y - v1.y)*t + v1.y
1650 stru_50B700.field_128[depth_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i])
1651 * t)) + stru_50B700._view_transformed_zs[i];
1652 stru_50B700.field_218[depth_num_vertices] = 0x80000u;//z = 8.0
1653 }
1654 depth_num_vertices++;
1655 }
1656 if ( next_vertices_flag )
1657 {
1658 stru_50B700.field_38[depth_num_vertices] = stru_50B700._view_transformed_ys[i];
1659 stru_50B700.field_128[depth_num_vertices] = stru_50B700._view_transformed_zs[i];
1660 stru_50B700.field_218[depth_num_vertices] = stru_50B700._view_transformed_xs[i];
1661 depth_num_vertices++;
1662 }
1663 current_vertices_flag = next_vertices_flag;
1664 }
1665 stru_50B700.field_218[depth_num_vertices] = stru_50B700.field_218[0];
1666 stru_50B700.field_128[depth_num_vertices] = stru_50B700.field_128[0];
1667 stru_50B700.field_38[depth_num_vertices] = stru_50B700.field_38[0];
1668
1669 //for far clip plane
1670 for ( uint i = 1; i <= depth_num_vertices; ++i )
1671 {
1672 if (SHIWORD(stru_50B700.field_128[i]) >= 0)
1673 {
1674 if (SHIWORD(stru_50B700.field_218[i]) >= 0)
1675 v26 = 0x400000; // 64.0
1676 else
1677 v26 = 0xFFC00000; // -63.0
1678 }
1679 else
1680 {
1681 if (SHIWORD(stru_50B700.field_218[i]) >= 0)
1682 v26 = 0xFFC00000; // -63.0
1683 else
1684 v26 = 0x400000; // 64.0
1685 }
1686 stru_50B700._xs3[i] = v26;
1687 if (SHIWORD(stru_50B700.field_38[i]) >= 0)
1688 {
1689 if (SHIWORD(stru_50B700.field_218[i]) >= 0)
1690 v26 = 0x400000; // 64.0
1691 else
1692 v26 = 0xFFC00000; // -63.0
1693 }
1694 else
1695 {
1696 if (SHIWORD(stru_50B700.field_218[i]) >= 0)
1697 v26 = 0xFFC00000; // -63.0
1698 else
1699 v26 = 0x400000; // 64.0
1700 }
1701 stru_50B700._ys2[i] = v26;
1702 stru_50B700._xs3[i] = pBLVRenderParams->uViewportCenterX -(unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)//maybe screen space x
1703 * (signed __int64)stru_50B700._xs3[i]);
1704 stru_50B700._ys2[i] = pBLVRenderParams->uViewportCenterY - (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)//screen space y
1705 * (signed __int64)stru_50B700._ys2[i]);
1706 }
1707
1708 for_x_num_vertices = 0;
1709 stru_50B700._xs3[depth_num_vertices] = stru_50B700._xs3[0];
1710 stru_50B700._ys2[depth_num_vertices] = stru_50B700._ys2[0];
1711 if ( depth_num_vertices < 1 )
1712 return 0;
1713
1714 //for left clip plane
1715 current_vertices_flag = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
1716 for ( uint i = 1; i <= depth_num_vertices; i++ )
1717 {
1718 next_vertices_flag = stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX;//координата у первой вершины >= левой границы
1719 if ( current_vertices_flag ^ next_vertices_flag )
1720 {
1721 if ( next_vertices_flag )
1722 {
1723 v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i - 1])
1724 * (signed __int64)(stru_50B700._ys2[i] - stru_50B700._ys2[i - 1]) / (stru_50B700._xs3[i] - stru_50B700._xs3[i - 1]);
1725 v42 = stru_50B700._ys2[i - 1];
1726 }
1727 else
1728 {
1729 v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i])
1730 * (signed __int64)(stru_50B700._ys2[i - 1] - stru_50B700._ys2[i]) / (stru_50B700._xs3[i - 1] - stru_50B700._xs3[i]);
1731 v42 = stru_50B700._ys2[i];
1732 }
1733 stru_50B700._ys[for_x_num_vertices] = v67 + v42;
1734 stru_50B700._xs2[for_x_num_vertices] = pBLVRenderParams->uViewportX;
1735 ++for_x_num_vertices;
1736 }
1737 current_vertices_flag = next_vertices_flag;
1738 if ( next_vertices_flag )
1739 {
1740 stru_50B700._xs2[for_x_num_vertices] = stru_50B700._xs3[i];
1741 stru_50B700._ys[for_x_num_vertices] = stru_50B700._ys2[i];
1742 ++for_x_num_vertices;
1743 }
1744 }
1745
1746 if (for_x_num_vertices < 1)
1747 return 0;
1748
1749 for_z_num_vertices = 0;
1750 stru_50B700._xs2[for_x_num_vertices] = stru_50B700._xs2[0];
1751 stru_50B700._ys[for_x_num_vertices] = stru_50B700._ys[0];
1752
1753 //for right clip plane
1754 current_vertices_flag = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
1755 for ( uint i = 1; i <= for_x_num_vertices; ++i )
1756 {
1757 next_vertices_flag = stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ;
1758 if ( current_vertices_flag ^ next_vertices_flag )
1759 {
1760 if ( next_vertices_flag )
1761 {
1762 v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i - 1])
1763 * (signed __int64)(stru_50B700._ys[i] - stru_50B700._ys[i - 1]) / (stru_50B700._xs2[i] - stru_50B700._xs2[i - 1]);
1764 v47 = stru_50B700._ys[i - 1];
1765 }
1766 else
1767 {
1768 v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i])
1769 * (signed __int64)(stru_50B700._ys[i - 1] - stru_50B700._ys[i]) / (stru_50B700._xs2[i - 1] - stru_50B700._xs2[i]);
1770 v47 = stru_50B700._ys[i];
1771 }
1772 stru_50B700.field_2F0[for_z_num_vertices] = v68 + v47;
1773 stru_50B700._xs[for_z_num_vertices] = pBLVRenderParams->uViewportZ;
1774 ++for_z_num_vertices;
1775 }
1776 if ( next_vertices_flag )
1777 {
1778 stru_50B700._xs[for_z_num_vertices] = stru_50B700._xs2[i];
1779 stru_50B700.field_2F0[for_z_num_vertices++] = stru_50B700._ys[i];
1780 }
1781 current_vertices_flag = next_vertices_flag;
1782 }
1783
1784 if (for_z_num_vertices < 1)
1785 return 0;
1786
1787 for_y_num_vertices = 0;
1788 stru_50B700._xs[for_z_num_vertices] = stru_50B700._xs[0];
1789 stru_50B700.field_2F0[for_z_num_vertices] = stru_50B700.field_2F0[0];
1790
1791 //for top clip plane
1792 current_vertices_flag = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
1793 for ( uint i = 1; i <= for_z_num_vertices; i++ )
1794 {
1795 next_vertices_flag = stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY;
1796 if ( current_vertices_flag ^ next_vertices_flag )
1797 {
1798 if ( next_vertices_flag )
1799 {
1800 v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i - 1])
1801 * (signed __int64)(stru_50B700._xs[i] - stru_50B700._xs[i - 1]) / (stru_50B700.field_2F0[i] - stru_50B700.field_2F0[i - 1]);
1802 v54 = stru_50B700._xs[i - 1];
1803 }
1804 else
1805 {
1806 v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i])
1807 * (signed __int64)(stru_50B700._xs[i - 1] - stru_50B700._xs[i]) / (stru_50B700.field_2F0[i - 1] - stru_50B700.field_2F0[i]);
1808 v54 = stru_50B700._xs[i];
1809 }
1810 stru_50B700.field_3D4[for_y_num_vertices] = v69 + v54;
1811 stru_50B700._xs[for_y_num_vertices + 1] = pBLVRenderParams->uViewportY;
1812 ++for_y_num_vertices;
1813 }
1814 current_vertices_flag = next_vertices_flag;
1815 if ( next_vertices_flag )
1816 {
1817 stru_50B700.field_3D4[for_y_num_vertices] = stru_50B700._xs[i];
1818 stru_50B700._xs[for_y_num_vertices + 1] = stru_50B700.field_2F0[i];
1819 for_y_num_vertices++;
1820 }
1821 }
1822
1823 if (for_y_num_vertices < 1)
1824 return 0;
1825
1826 for_w_num_vertices = 0;
1827 stru_50B700.field_3D4[for_y_num_vertices] = stru_50B700.field_3D4[0];
1828 stru_50B700._xs[for_y_num_vertices + 1] = stru_50B700._xs[1];
1829
1830 //for bottom clip plane
1831 current_vertices_flag = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
1832 for ( uint i = 1; i <= for_y_num_vertices; ++i )
1833 {
1834 next_vertices_flag = stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW;
1835 if ( current_vertices_flag ^ next_vertices_flag )
1836 {
1837 if ( next_vertices_flag )
1838 {
1839 v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i])
1840 * (signed __int64)(stru_50B700.field_3D4[i] - stru_50B700.field_3D4[i - 1]) / (stru_50B700._xs[i + 1] - stru_50B700._xs[i]);
1841 v59 = stru_50B700.field_3D4[i - 1];
1842 }
1843 else
1844 {
1845 v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i + 1])
1846 * (signed __int64)(stru_50B700.field_3D4[i - 1] - stru_50B700.field_3D4[i]) / (stru_50B700._xs[i] - stru_50B700._xs[i + 1]);
1847 v59 = stru_50B700.field_3D4[i];
1848 }
1849 stru_50B700._screen_space_x[for_w_num_vertices] = v70 + v59;
1850 stru_50B700._screen_space_y[for_w_num_vertices] = pBLVRenderParams->uViewportW;
1851 ++for_w_num_vertices;
1852 }
1853 if ( next_vertices_flag )
1854 {
1855 stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700.field_3D4[i];
1856 stru_50B700._screen_space_y[for_w_num_vertices++] = stru_50B700._xs[i + 1];
1857 }
1858 current_vertices_flag = next_vertices_flag;
1859 }
1860
1861 if ( !for_w_num_vertices )
1862 return 0;
1863 v61 = pRenderer->pRenderD3D == 0;
1864 stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700._screen_space_x[0];
1865 stru_50B700._screen_space_y[for_w_num_vertices] = stru_50B700._screen_space_y[0];
1866 if ( v61 && for_w_num_vertices > 3 )
1867 {
1868 stru_50B700._screen_space_x[for_w_num_vertices + 1] = stru_50B700._screen_space_x[1];
1869 stru_50B700._screen_space_y[for_w_num_vertices + 1] = stru_50B700._screen_space_y[1];
1870 thisf = 2 * (stru_50B700.field_0 != 0) - 1;
1871 if ( for_w_num_vertices > 0 )
1872 {
1873 v62 = 1;
1874 v71 = 1;
1875 do
1876 {
1877 v63 = v62 - 1;
1878 v64 = v62 + 1;
1879 v80 = v62 + 1;
1880 if ( v62 - 1 >= for_w_num_vertices )
1881 v63 -= for_w_num_vertices;
1882 if ( v62 >= for_w_num_vertices )
1883 v62 -= for_w_num_vertices;
1884 if ( v64 >= for_w_num_vertices )
1885 v64 -= for_w_num_vertices;
1886 if ( thisf * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
1887 * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
1888 - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
1889 * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
1890 {
1891 v62 = v80;
1892 v71 = v80;
1893 }
1894 else
1895 {
1896 v62 = v71;
1897 v65 = v71;
1898 if ( v71 < for_w_num_vertices || (v65 = v71 - for_w_num_vertices, v71 - for_w_num_vertices < for_w_num_vertices) )
1899 {
1900 memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (for_w_num_vertices - v65)) >> 2));
1901 memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (for_w_num_vertices - v65)) >> 2));
1902 }
1903 --for_w_num_vertices;
1904 }
1905 }
1906 while ( v62 - 1 < for_w_num_vertices );
1907 }
1908 stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700._screen_space_x[0];
1909 stru_50B700._screen_space_y[for_w_num_vertices] = stru_50B700._screen_space_y[0];
1910 }
1911 return for_w_num_vertices;
1912 }
1913
1914 //old function
1915 /*int __fastcall sub_423B5D(unsigned int uFaceID)
1916 {
1917 BLVFace *v1; // ebx@1
1491 Vec3_short_ *v2; // esi@1 1918 Vec3_short_ *v2; // esi@1
1492 //int v3; // ST28_4@1 1919 //int v3; // ST28_4@1
1493 __int16 v4; // ST2C_2@1 1920 __int16 v4; // ST2C_2@1
1494 //signed int v5; // esi@1 1921 //signed int v5; // esi@1
1495 //Vec3_short_ *v6; // eax@4 1922 //Vec3_short_ *v6; // eax@4
1575 signed int ib; // [sp+24h] [bp-4h]@31 2002 signed int ib; // [sp+24h] [bp-4h]@31
1576 signed int ic; // [sp+24h] [bp-4h]@41 2003 signed int ic; // [sp+24h] [bp-4h]@41
1577 signed int id; // [sp+24h] [bp-4h]@51 2004 signed int id; // [sp+24h] [bp-4h]@51
1578 signed int ie; // [sp+24h] [bp-4h]@61 2005 signed int ie; // [sp+24h] [bp-4h]@61
1579 2006
1580 pFace = &pIndoor->pFaces[uFaceID]; 2007 v1 = &pIndoor->pFaces[uFaceID];
1581 //this = pGame->pIndoorCameraD3D; 2008 //this = pGame->pIndoorCameraD3D;
1582 v2 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; 2009 v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
1583 //v3 = *(_DWORD *)&v2->x; 2010 //v3 = *(_DWORD *)&v2->x;
1584 v4 = v2->z; 2011 v4 = v2->z;
1585 //v5 = 0; 2012 //v5 = 0;
1586 if ( pFace->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x) 2013 if ( v1->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
1587 + pFace->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y) 2014 + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
1588 + pFace->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 ) 2015 + v1->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
1589 { 2016 {
1590 stru_50B700.field_0 = 1; 2017 dword_50B700 = 1;
1591 } 2018 }
1592 else 2019 else
1593 { 2020 {
1594 stru_50B700.field_0 = 0; 2021 dword_50B700 = 0;
1595 if ( !pFace->Portal() ) 2022 if ( !v1->Portal() )
1596 return 0; 2023 return 0;
1597 } 2024 }
1598 //v66 = v1->uNumVertices; 2025 //v66 = v1->uNumVertices;
1599 for (uint i = 0; i < pFace->uNumVertices; ++i) 2026 for (uint i = 0; i < v1->uNumVertices; ++i)
1600 { 2027 {
1601 auto v6 = &pIndoor->pVertices[pFace->pVertexIDs[i]]; 2028 auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
1602 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(v6->x, v6->y, v6->z, 2029 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
1603 &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0); 2030 v6->x,
2031 v6->y,
2032 v6->z,
2033 &_50B924_view_transformed_xs[i],
2034 &_50B834_view_transformed_zs[i],
2035 &_50B744_view_transformed_ys[i],
2036 0);
1604 } 2037 }
1605 2038
1606 //v7 = v1->uNumVertices; 2039 //v7 = v1->uNumVertices;
1607 //v8 = 0; 2040 //v8 = 0;
1608 if (pFace->uNumVertices <= 0) 2041 if (v1->uNumVertices <= 0)
1609 return 0; 2042 return 0;
1610 2043
1611 bool bFound = false; 2044 bool bFound = false;
1612 for (uint i = 0; i < pFace->uNumVertices; ++i) 2045 for (uint i = 0; i < v1->uNumVertices; ++i)
1613 if (stru_50B700._view_transformed_xs[i] >= 0x80000u) 2046 if (_50B924_view_transformed_xs[i] >= 0x80000u)
1614 { 2047 {
1615 bFound = true; 2048 bFound = true;
1616 break; 2049 break;
1617 } 2050 }
1618 if (!bFound) 2051 if (!bFound)
1619 return 0; 2052 return 0;
1620 2053
1621 v79 = 0; 2054 v79 = 0;
1622 stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0]; 2055 _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
1623 stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0]; 2056 _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
1624 stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0]; 2057 _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
1625 thisa = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u; 2058 thisa = _50B924_view_transformed_xs[0] >= (signed int)0x80000u;
1626 //int i = 1; 2059 //int i = 1;
1627 for (uint i = 1; i <= pFace->uNumVertices; ++i) 2060 for (uint i = 1; i <= v1->uNumVertices; ++i)
1628 { 2061 {
1629 v10 = stru_50B700._view_transformed_xs[i]; 2062 v10 = _50B924_view_transformed_xs[i];
1630 v81 = v10 >= (signed int)0x80000u; 2063 v81 = v10 >= (signed int)0x80000u;
1631 if ( thisa ^ v81 ) 2064 if ( thisa ^ v81 )
1632 { 2065 {
1633 v11 = stru_50B700._view_transformed_xs[i - 1]; 2066 v11 = _50B924_view_transformed_xs[i - 1];
1634 if ( v10 >= (signed int)0x80000u ) 2067 if ( v10 >= (signed int)0x80000u )
1635 { 2068 {
1636 v12 = v10 - v11; 2069 v12 = v10 - v11;
1637 v13 = 0x80000 - v11; 2070 v13 = 0x80000 - v11;
1638 LODWORD(v14) = v13 << 16; 2071 LODWORD(v14) = v13 << 16;
1639 HIDWORD(v14) = v13 >> 16; 2072 HIDWORD(v14) = v13 >> 16;
1640 v15 = &stru_50B700._view_transformed_ys[i - 1]; 2073 v15 = &_50B744_view_transformed_ys[i - 1];
1641 stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1]) * v14 / v12) >> 16) + stru_50B700._view_transformed_zs[i - 1]; 2074 dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i] - _50B834_view_transformed_zs[i - 1]) * v14 / v12) >> 16) + _50B834_view_transformed_zs[i - 1];
1642 thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1]) * v14 / v12) >> 16; 2075 thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
1643 } 2076 }
1644 else 2077 else
1645 { 2078 {
1646 v16 = v11 - v10; 2079 v16 = v11 - v10;
1647 v17 = 0x80000 - v10; 2080 v17 = 0x80000 - v10;
1648 LODWORD(v18) = v17 << 16; 2081 LODWORD(v18) = v17 << 16;
1649 HIDWORD(v18) = v17 >> 16; 2082 HIDWORD(v18) = v17 >> 16;
1650 v15 = &stru_50B700._view_transformed_ys[i]; 2083 v15 = &_50B744_view_transformed_ys[i];
1651 stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i]) * v18 / v16) >> 16) + stru_50B700._view_transformed_zs[i]; 2084 dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i]) * v18 / v16) >> 16) + _50B834_view_transformed_zs[i];
1652 thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i]) * v18 / v16) >> 16; 2085 thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
1653 } 2086 }
1654 v19 = v79++; 2087 v19 = v79++;
1655 //v7 = v66; 2088 //v7 = v66;
1656 stru_50B700.field_38[v19] = thisb + *v15; 2089 dword_50B738[v19] = thisb + *v15;
1657 stru_50B700.field_218[v19] = 0x80000u; 2090 dword_50B918[v19] = 0x80000u;
1658 } 2091 }
1659 if ( v81 ) 2092 if ( v81 )
1660 { 2093 {
1661 v20 = v79++; 2094 v20 = v79++;
1662 stru_50B700.field_218[v20] = stru_50B700._view_transformed_xs[i]; 2095 dword_50B918[v20] = _50B924_view_transformed_xs[i];
1663 stru_50B700.field_128[v20] = stru_50B700._view_transformed_zs[i]; 2096 dword_50B828[v20] = _50B834_view_transformed_zs[i];
1664 stru_50B700.field_38[v20] = stru_50B700._view_transformed_ys[i]; 2097 dword_50B738[v20] = _50B744_view_transformed_ys[i];
1665 } 2098 }
1666 //++i; 2099 //++i;
1667 thisa = v81; 2100 thisa = v81;
1668 } 2101 }
1669 v21 = v79; 2102 v21 = v79;
1670 stru_50B700.field_218[v79] = stru_50B700.field_218[0]; 2103 dword_50B918[v79] = dword_50B918[0];
1671 stru_50B700.field_128[v79] = stru_50B700.field_128[0]; 2104 dword_50B828[v79] = dword_50B828[0];
1672 stru_50B700.field_38[v79] = stru_50B700.field_38[0]; 2105 dword_50B738[v79] = dword_50B738[0];
1673 for (ia = 0; ia < v79; ++ia) 2106 for (ia = 0; ia < v79; ++ia)
1674 { 2107 {
1675 v22 = ia; 2108 v22 = ia;
1676 thisc = abs(stru_50B700.field_218[ia]); 2109 thisc = abs(dword_50B918[ia]);
1677 if ( abs(stru_50B700.field_128[ia]) >> 13 <= thisc ) 2110 if ( abs(dword_50B828[ia]) >> 13 <= thisc )
1678 { 2111 {
1679 v27 = stru_50B700.field_128[v22]; 2112 v27 = dword_50B828[v22];
1680 LODWORD(v28) = v27 << 16; 2113 LODWORD(v28) = v27 << 16;
1681 HIDWORD(v28) = v27 >> 16; 2114 HIDWORD(v28) = v27 >> 16;
1682 v26 = v28 / stru_50B700.field_218[v22]; 2115 v26 = v28 / dword_50B918[v22];
1683 v23 = 0; 2116 v23 = 0;
1684 } 2117 }
1685 else 2118 else
1686 { 2119 {
1687 v23 = 0; 2120 v23 = 0;
1688 v24 = 0; 2121 v24 = 0;
1689 if ( stru_50B700.field_128[v22] >= 0 ) 2122 if ( dword_50B828[v22] >= 0 )
1690 { 2123 {
1691 LOBYTE(v24) = stru_50B700.field_218[v22] >= 0; 2124 LOBYTE(v24) = dword_50B918[v22] >= 0;
1692 v26 = ((v24 - 1) & 0xFF800000) + 0x400000; 2125 v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
1693 } 2126 }
1694 else 2127 else
1695 { 2128 {
1696 LOBYTE(v24) = stru_50B700.field_218[v22] >= 0; 2129 LOBYTE(v24) = dword_50B918[v22] >= 0;
1697 v25 = v24 - 1; 2130 v25 = v24 - 1;
1698 v26 = (v25 & 0x800000) - 0x400000; 2131 v26 = (v25 & 0x800000) - 0x400000;
1699 } 2132 }
1700 } 2133 }
1701 v29 = stru_50B700.field_38[v22]; 2134 v29 = dword_50B738[v22];
1702 stru_50B700._xs3[v22] = v26; 2135 dword_50BAF8_xs[v22] = v26;
1703 if ( abs(v29) >> 13 <= thisc ) 2136 if ( abs(v29) >> 13 <= thisc )
1704 { 2137 {
1705 v33 = stru_50B700.field_38[v22]; 2138 v33 = dword_50B738[v22];
1706 LODWORD(v34) = v33 << 16; 2139 LODWORD(v34) = v33 << 16;
1707 HIDWORD(v34) = v33 >> 16; 2140 HIDWORD(v34) = v33 >> 16;
1708 v32 = v34 / stru_50B700.field_218[v22]; 2141 v32 = v34 / dword_50B918[v22];
1709 } 2142 }
1710 else 2143 else
1711 { 2144 {
1712 v30 = 0; 2145 v30 = 0;
1713 if ( stru_50B700.field_38[v22] >= v23 ) 2146 if ( dword_50B738[v22] >= v23 )
1714 { 2147 {
1715 LOBYTE(v30) = stru_50B700.field_218[v22] >= v23; 2148 LOBYTE(v30) = dword_50B918[v22] >= v23;
1716 v32 = ((v30 - 1) & 0xFF800000) + 0x400000; 2149 v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
1717 } 2150 }
1718 else 2151 else
1719 { 2152 {
1720 LOBYTE(v30) = stru_50B700.field_218[v22] >= v23; 2153 LOBYTE(v30) = dword_50B918[v22] >= v23;
1721 v31 = v30 - 1; 2154 v31 = v30 - 1;
1722 v32 = (v31 & 0x800000) - 0x400000; 2155 v32 = (v31 & 0x800000) - 0x400000;
1723 } 2156 }
1724 } 2157 }
1725 stru_50B700._ys2[v22] = v32; 2158 dword_50BA08_ys[v22] = v32;
1726 stru_50B700._xs3[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._xs3[v22]) >> 16; 2159 dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
1727 v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._ys2[v22]) >> 16; 2160 v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08_ys[v22]) >> 16;
1728 stru_50B700._xs3[v22] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[v22]; 2161 dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
1729 stru_50B700._ys2[v22] = pBLVRenderParams->uViewportCenterY - v35; 2162 dword_50BA08_ys[v22] = pBLVRenderParams->uViewportCenterY - v35;
1730 } 2163 }
1731 v36 = 0; 2164 v36 = 0;
1732 stru_50B700._xs3[v21] = stru_50B700._xs3[0]; 2165 dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
1733 stru_50B700._ys2[v21] = stru_50B700._ys2[0]; 2166 dword_50BA08_ys[v21] = dword_50BA08_ys[0];
1734 v37 = pBLVRenderParams->uViewportX; 2167 v37 = pBLVRenderParams->uViewportX;
1735 v38 = stru_50B700._xs3[0] < (signed int)pBLVRenderParams->uViewportX; 2168 v38 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
1736 LOBYTE(v38) = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX; 2169 LOBYTE(v38) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
1737 v39 = 1; 2170 v39 = 1;
1738 ib = 1; 2171 ib = 1;
1739 if ( v79 < 1 ) 2172 if ( v79 < 1 )
1740 return 0; 2173 return 0;
1741 do 2174 do
1742 { 2175 {
1743 v40 = v39; 2176 v40 = v39;
1744 v41 = stru_50B700._xs3[v40]; 2177 v41 = dword_50BAF8_xs[v40];
1745 v82 = v41 >= (signed int)v37; 2178 v82 = v41 >= (signed int)v37;
1746 if ( v38 ^ v82 ) 2179 if ( v38 ^ v82 )
1747 { 2180 {
1748 if ( v41 >= (signed int)v37 ) 2181 if ( v41 >= (signed int)v37 )
1749 { 2182 {
1750 v67 = (signed int)(v37 - stru_50B700._xs3[v40 - 1]) * (signed __int64)(stru_50B700._ys2[v40] - stru_50B700._ys2[v40 - 1]) / (v41 - stru_50B700._xs3[v40 - 1]); 2183 v67 = (signed int)(v37 - dword_50BAF8_xs[v40 - 1]) * (signed __int64)(dword_50BA08_ys[v40] - dword_50BA08_ys[v40 - 1]) / (v41 - dword_50BAF8_xs[v40 - 1]);
1751 v42 = stru_50B700._ys2[v40 - 1]; 2184 v42 = dword_50BA08_ys[v40 - 1];
1752 } 2185 }
1753 else 2186 else
1754 { 2187 {
1755 v67 = (signed int)(v37 - v41) * (signed __int64)(stru_50B700._ys2[v40 - 1] - stru_50B700._ys2[v40]) / (stru_50B700._xs3[v40 - 1] - v41); 2188 v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50BA08_ys[v40 - 1] - dword_50BA08_ys[v40]) / (dword_50BAF8_xs[v40 - 1] - v41);
1756 v42 = stru_50B700._ys2[v40]; 2189 v42 = dword_50BA08_ys[v40];
1757 } 2190 }
1758 stru_50B700._ys[v36] = v67 + v42; 2191 dword_50B9FC_ys[v36] = v67 + v42;
1759 v37 = pBLVRenderParams->uViewportX; 2192 v37 = pBLVRenderParams->uViewportX;
1760 stru_50B700._xs2[v36] = pBLVRenderParams->uViewportX; 2193 dword_50BAEC_xs[v36] = pBLVRenderParams->uViewportX;
1761 ++v36; 2194 ++v36;
1762 } 2195 }
1763 v38 = v82; 2196 v38 = v82;
1764 if ( v82 ) 2197 if ( v82 )
1765 { 2198 {
1766 stru_50B700._xs2[v36] = stru_50B700._xs3[v40]; 2199 dword_50BAEC_xs[v36] = dword_50BAF8_xs[v40];
1767 stru_50B700._ys[v36] = stru_50B700._ys2[v40]; 2200 dword_50B9FC_ys[v36] = dword_50BA08_ys[v40];
1768 ++v36; 2201 ++v36;
1769 } 2202 }
1770 v39 = ib++ + 1; 2203 v39 = ib++ + 1;
1771 } 2204 }
1772 while ( ib <= v79 ); 2205 while ( ib <= v79 );
1773 2206
1774 if (v36 < 1) 2207 if (v36 < 1)
1775 return 0; 2208 return 0;
1776 2209
1777 v43 = 0; 2210 v43 = 0;
1778 stru_50B700._xs2[v36] = stru_50B700._xs2[0]; 2211 dword_50BAEC_xs[v36] = dword_50BAEC_xs[0];
1779 stru_50B700._ys[v36] = stru_50B700._ys[0]; 2212 dword_50B9FC_ys[v36] = dword_50B9FC_ys[0];
1780 v44 = pBLVRenderParams->uViewportZ; 2213 v44 = pBLVRenderParams->uViewportZ;
1781 thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ; 2214 thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ;
1782 ic = 1; 2215 ic = 1;
1783 2216
1784 do 2217 do
1785 { 2218 {
1786 v45 = ic; 2219 v45 = ic;
1787 v46 = stru_50B700._xs2[ic]; 2220 v46 = dword_50BAEC_xs[ic];
1788 v83 = v46 <= (signed int)v44; 2221 v83 = v46 <= (signed int)v44;
1789 if ( thisd ^ v83 ) 2222 if ( thisd ^ v83 )
1790 { 2223 {
1791 if ( v46 <= (signed int)v44 ) 2224 if ( v46 <= (signed int)v44 )
1792 { 2225 {
1793 v68 = (signed int)(v44 - stru_50B700._xs2[v45 - 1]) * (signed __int64)(stru_50B700._ys[v45] - stru_50B700._ys[v45 - 1]) / (v46 - stru_50B700._xs2[v45 - 1]); 2226 v68 = (signed int)(v44 - dword_50BAEC_xs[v45 - 1]) * (signed __int64)(dword_50B9FC_ys[v45] - dword_50B9FC_ys[v45 - 1]) / (v46 - dword_50BAEC_xs[v45 - 1]);
1794 v47 = stru_50B700._ys[v45 - 1]; 2227 v47 = dword_50B9FC_ys[v45 - 1];
1795 } 2228 }
1796 else 2229 else
1797 { 2230 {
1798 v68 = (signed int)(v44 - v46) * (signed __int64)(stru_50B700._ys[v45 - 1] - stru_50B700._ys[v45]) / (stru_50B700._xs2[v45 - 1] - v46); 2231 v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9FC_ys[v45 - 1] - dword_50B9FC_ys[v45]) / (dword_50BAEC_xs[v45 - 1] - v46);
1799 v47 = stru_50B700._ys[v45]; 2232 v47 = dword_50B9FC_ys[v45];
1800 } 2233 }
1801 stru_50B700.field_2F0[v43] = v68 + v47; 2234 dword_50B9F0[v43] = v68 + v47;
1802 v44 = pBLVRenderParams->uViewportZ; 2235 v44 = pBLVRenderParams->uViewportZ;
1803 stru_50B700._xs[v43] = pBLVRenderParams->uViewportZ; 2236 dword_50BAE0[v43] = pBLVRenderParams->uViewportZ;
1804 ++v43; 2237 ++v43;
1805 } 2238 }
1806 if ( v83 ) 2239 if ( v83 )
1807 { 2240 {
1808 stru_50B700._xs[v43] = stru_50B700._xs2[v45]; 2241 dword_50BAE0[v43] = dword_50BAEC_xs[v45];
1809 stru_50B700.field_2F0[v43++] = stru_50B700._ys[v45]; 2242 dword_50B9F0[v43++] = dword_50B9FC_ys[v45];
1810 } 2243 }
1811 ++ic; 2244 ++ic;
1812 thisd = v83; 2245 thisd = v83;
1813 } 2246 }
1814 while ( ic <= v36 ); 2247 while ( ic <= v36 );
1815 2248
1816 if (v43 < 1) 2249 if (v43 < 1)
1817 return 0; 2250 return 0;
1818 2251
1819 v48 = 0; 2252 v48 = 0;
1820 stru_50B700._xs[v43] = stru_50B700._xs[0]; 2253 dword_50BAE0[v43] = dword_50BAE0[0];
1821 stru_50B700.field_2F0[v43] = stru_50B700.field_2F0[0]; 2254 dword_50B9F0[v43] = dword_50B9F0[0];
1822 v49 = pBLVRenderParams->uViewportY; 2255 v49 = pBLVRenderParams->uViewportY;
1823 v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY; 2256 v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY;
1824 LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY; 2257 LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY;
1825 v51 = 1; 2258 v51 = 1;
1826 id = 1; 2259 id = 1;
1827 do 2260 do
1828 { 2261 {
1829 v52 = v51; 2262 v52 = v51;
1830 v53 = stru_50B700.field_2F0[v52]; 2263 v53 = dword_50B9F0[v52];
1831 v84 = v53 >= (signed int)v49; 2264 v84 = v53 >= (signed int)v49;
1832 if ( v50 ^ v84 ) 2265 if ( v50 ^ v84 )
1833 { 2266 {
1834 if ( v53 >= (signed int)v49 ) 2267 if ( v53 >= (signed int)v49 )
1835 { 2268 {
1836 v69 = (signed int)(v49 - stru_50B700.field_2F0[v52 - 1]) * (signed __int64)(stru_50B700._xs[v52] - stru_50B700._xs[v52 - 1]) / (v53 - stru_50B700.field_2F0[v52 - 1]); 2269 v69 = (signed int)(v49 - dword_50B9F0[v52 - 1]) * (signed __int64)(dword_50BAE0[v52] - dword_50BAE0[v52 - 1]) / (v53 - dword_50B9F0[v52 - 1]);
1837 v54 = stru_50B700._xs[v52 - 1]; 2270 v54 = dword_50BAE0[v52 - 1];
1838 } 2271 }
1839 else 2272 else
1840 { 2273 {
1841 v69 = (signed int)(v49 - v53) * (signed __int64)(stru_50B700._xs[v52 - 1] - stru_50B700._xs[v52]) / (stru_50B700.field_2F0[v52 - 1] - v53); 2274 v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BAE0[v52 - 1] - dword_50BAE0[v52]) / (dword_50B9F0[v52 - 1] - v53);
1842 v54 = stru_50B700._xs[v52]; 2275 v54 = dword_50BAE0[v52];
1843 } 2276 }
1844 stru_50B700.field_3D4[v48] = v69 + v54; 2277 dword_50BAD4[v48] = v69 + v54;
1845 v49 = pBLVRenderParams->uViewportY; 2278 v49 = pBLVRenderParams->uViewportY;
1846 stru_50B700._xs[v48+1] = pBLVRenderParams->uViewportY; 2279 dword_50B9E4[v48] = pBLVRenderParams->uViewportY;
1847 ++v48; 2280 ++v48;
1848 } 2281 }
1849 v50 = v84; 2282 v50 = v84;
1850 if ( v84 ) 2283 if ( v84 )
1851 { 2284 {
1852 stru_50B700.field_3D4[v48] = stru_50B700._xs[v52]; 2285 dword_50BAD4[v48] = dword_50BAE0[v52];
1853 stru_50B700._xs[v48+1] = stru_50B700.field_2F0[v52]; 2286 dword_50B9E4[v48++] = dword_50B9F0[v52];
1854 v48++;
1855 } 2287 }
1856 v51 = id++ + 1; 2288 v51 = id++ + 1;
1857 } 2289 }
1858 while ( id <= v43 ); 2290 while ( id <= v43 );
1859 2291
1860 if (v48 < 1) 2292 if (v48 < 1)
1861 return 0; 2293 return 0;
1862 2294
1863 v55 = 0; 2295 v55 = 0;
1864 stru_50B700.field_3D4[v48] = stru_50B700.field_3D4[0]; 2296 dword_50BAD4[v48] = dword_50BAD4[0];
1865 stru_50B700._xs[v48+1] = stru_50B700._xs[1]; 2297 dword_50B9E4[v48] = dword_50B9E4[0];
1866 v56 = pBLVRenderParams->uViewportW; 2298 v56 = pBLVRenderParams->uViewportW;
1867 thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW; 2299 thise = dword_50B9E4[0] <= (signed int)pBLVRenderParams->uViewportW;
1868 ie = 1; 2300 ie = 1;
1869 do 2301 do
1870 { 2302 {
1871 v57 = ie; 2303 v57 = ie;
1872 v58 = stru_50B700._xs[ie+1]; 2304 v58 = dword_50B9E4[ie];
1873 v85 = v58 <= (signed int)v56; 2305 v85 = v58 <= (signed int)v56;
1874 if ( thise ^ v85 ) 2306 if ( thise ^ v85 )
1875 { 2307 {
1876 if ( v58 <= (signed int)v56 ) 2308 if ( v58 <= (signed int)v56 )
1877 { 2309 {
1878 v70 = (signed int)(v56 - stru_50B700._xs[v57]) * (signed __int64)(stru_50B700.field_3D4[v57] - stru_50B700.field_3D4[v57 - 1]) / (v58 - stru_50B700._xs[v57]); 2310 v70 = (signed int)(v56 - dword_50B9E4[v57 - 1]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD4[v57 - 1]) / (v58 - dword_50B9E4[v57 - 1]);
1879 v59 = stru_50B700.field_3D4[v57 - 1]; 2311 v59 = dword_50BAD4[v57 - 1];
1880 } 2312 }
1881 else 2313 else
1882 { 2314 {
1883 v70 = (signed int)(v56 - v58) * (signed __int64)(stru_50B700.field_3D4[v57 - 1] - stru_50B700.field_3D4[v57]) / (stru_50B700._xs[v57] - v58); 2315 v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD4[v57 - 1] - dword_50BAD4[v57]) / (dword_50B9E4[v57 - 1] - v58);
1884 v59 = stru_50B700.field_3D4[v57]; 2316 v59 = dword_50BAD4[v57];
1885 } 2317 }
1886 stru_50B700._screen_space_x[v55] = v70 + v59; 2318 _50BAC8_screen_space_x[v55] = v70 + v59;
1887 v56 = pBLVRenderParams->uViewportW; 2319 v56 = pBLVRenderParams->uViewportW;
1888 stru_50B700._screen_space_y[v55] = pBLVRenderParams->uViewportW; 2320 _50B9D8_screen_space_y[v55] = pBLVRenderParams->uViewportW;
1889 ++v55; 2321 ++v55;
1890 } 2322 }
1891 if ( v85 ) 2323 if ( v85 )
1892 { 2324 {
1893 stru_50B700._screen_space_x[v55] = stru_50B700.field_3D4[v57]; 2325 _50BAC8_screen_space_x[v55] = dword_50BAD4[v57];
1894 stru_50B700._screen_space_y[v55++] = stru_50B700._xs[v57+1]; 2326 _50B9D8_screen_space_y[v55++] = dword_50B9E4[v57];
1895 } 2327 }
1896 ++ie; 2328 ++ie;
1897 thise = v85; 2329 thise = v85;
1898 } 2330 }
1899 while ( ie <= v48 ); 2331 while ( ie <= v48 );
1900 2332
1901 if ( !v55 ) 2333 if ( !v55 )
1902 return 0; 2334 return 0;
1903 v61 = pRenderer->pRenderD3D == 0; 2335 v61 = pRenderer->pRenderD3D == 0;
1904 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; 2336 _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
1905 stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; 2337 _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
1906 if ( v61 && v55 > 3 ) 2338 if ( v61 && v55 > 3 )
1907 { 2339 {
1908 stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1]; 2340 _50BAC8_screen_space_x[v55 + 1] = _50BAC8_screen_space_x[1];
1909 stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1]; 2341 _50B9D8_screen_space_y[v55 + 1] = _50B9D8_screen_space_y[1];
1910 thisf = 2 * (stru_50B700.field_0 != 0) - 1; 2342 thisf = 2 * (dword_50B700 != 0) - 1;
1911 if ( v55 > 0 ) 2343 if ( v55 > 0 )
1912 { 2344 {
1913 v62 = 1; 2345 v62 = 1;
1914 v71 = 1; 2346 v71 = 1;
1915 do 2347 do
1922 if ( v62 >= v55 ) 2354 if ( v62 >= v55 )
1923 v62 -= v55; 2355 v62 -= v55;
1924 if ( v64 >= v55 ) 2356 if ( v64 >= v55 )
1925 v64 -= v55; 2357 v64 -= v55;
1926 if ( thisf 2358 if ( thisf
1927 * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63]) 2359 * ((_50B9D8_screen_space_y[v64] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v62] - _50BAC8_screen_space_x[v63])
1928 - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 ) 2360 - (_50B9D8_screen_space_y[v62] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v64] - _50BAC8_screen_space_x[v63])) < 0 )
1929 { 2361 {
1930 v62 = v80; 2362 v62 = v80;
1931 v71 = v80; 2363 v71 = v80;
1932 } 2364 }
1933 else 2365 else
1934 { 2366 {
1935 v62 = v71; 2367 v62 = v71;
1936 v65 = v71; 2368 v65 = v71;
1937 if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) ) 2369 if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
1938 { 2370 {
1939 memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); 2371 memcpy(&_50B9D8_screen_space_y[v65], &_50B9D8_screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
1940 memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); 2372 memcpy(&_50BAC8_screen_space_x[v65], &_50BAC8_screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
1941 } 2373 }
1942 --v55; 2374 --v55;
1943 } 2375 }
1944 } 2376 }
1945 while ( v62 - 1 < v55 ); 2377 while ( v62 - 1 < v55 );
1946 } 2378 }
1947 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; 2379 _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
1948 stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; 2380 _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
1949 } 2381 }
1950 return v55; 2382 return v55;
1951 } 2383 }*/
1952 2384
1953 //----- (00424579) -------------------------------------------------------- 2385 //----- (00424579) --------------------------------------------------------
1954 int __fastcall sub_424579(int uFaceID, stru320 *a2) 2386 int __fastcall sub_424579(int uFaceID, stru320 *a2)
1955 { 2387 {
1956 __debugbreak(); 2388 __debugbreak();
2365 v13 -= pNumVertices; 2797 v13 -= pNumVertices;
2366 if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) 2798 if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
2367 { 2799 {
2368 v62 = stru_50B700._screen_space_x[v55] << 16; 2800 v62 = stru_50B700._screen_space_x[v55] << 16;
2369 v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]); 2801 v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
2370 a2->array_18[min_y] = LOWORD(stru_50B700._screen_space_x[v55]); 2802 a2->viewport_left_side[min_y] = LOWORD(stru_50B700._screen_space_x[v55]);
2371 } 2803 }
2372 v15 = v65; 2804 v15 = v65;
2373 v61 = v65; 2805 v61 = v65;
2374 2806
2375 for ( v69 = 0; v69 < pNumVertices; ++v69 ) 2807 for ( v69 = 0; v69 < pNumVertices; ++v69 )
2402 v20 = v61; 2834 v20 = v61;
2403 if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] ) 2835 if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
2404 { 2836 {
2405 v61 = stru_50B700._screen_space_x[v20] << 16; 2837 v61 = stru_50B700._screen_space_x[v20] << 16;
2406 v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20]; 2838 v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
2407 a2->array_3D8[max_y] = LOWORD(stru_50B700._screen_space_x[v20]); 2839 a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]);
2408 } 2840 }
2409 v22 = min_y; 2841 v22 = min_y;
2410 if ( min_y <= max_y ) 2842 if ( min_y <= max_y )
2411 { 2843 {
2412 //v56 = &a2->array_3D8[v7]; 2844 //v56 = &a2->viewport_right_side[v7];
2413 //v23 = &a2->array_18[v7]; 2845 //v23 = &a2->viewport_left_side[v7];
2414 for ( v70 = min_y; v70 <= max_y; ++v70 ) 2846 for ( v70 = min_y; v70 <= max_y; ++v70 )
2415 { 2847 {
2416 v24 = v13; 2848 v24 = v13;
2417 if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != max_y ) 2849 if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != max_y )
2418 { 2850 {
2449 { 2881 {
2450 v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; 2882 v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
2451 v61 = stru_50B700._screen_space_x[v29] << 16; 2883 v61 = stru_50B700._screen_space_x[v29] << 16;
2452 } 2884 }
2453 } 2885 }
2454 //v34 = (char *)a2->array_18 - (char *)a2->array_3D8; 2886 //v34 = (char *)a2->viewport_left_side - (char *)a2->viewport_right_side;
2455 //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34); 2887 //v35 = *(__int16 *)((char *)&a2->viewport_right_side[v70] + v34);
2456 //v35 = HIWORD(v62); 2888 //v35 = HIWORD(v62);
2457 a2->array_18[v70] = HIWORD(v62); 2889 a2->viewport_left_side[v70] = HIWORD(v62);
2458 a2->array_3D8[v70] = HIWORD(v61); 2890 a2->viewport_right_side[v70] = HIWORD(v61);
2459 //v34 = &a2->array_3D8[v70]; 2891 //v34 = &a2->array_3D8[v70];
2460 //v35 = a2->array_3D8[v70]; 2892 //v35 = a2->array_3D8[v70];
2461 if ( a2->array_18[v70] > a2->array_3D8[v70] ) 2893 if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] )
2462 { 2894 {
2463 v36 = a2->array_18[v70] ^ a2->array_3D8[v70]; 2895 v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70];
2464 v37 = a2->array_3D8[v70]; 2896 v37 = a2->viewport_right_side[v70];
2465 a2->array_18[v70] = v36; 2897 a2->viewport_left_side[v70] = v36;
2466 v38 = v37 ^ v36; 2898 v38 = v37 ^ v36;
2467 a2->array_18[v70] ^= v38; 2899 a2->viewport_left_side[v70] ^= v38;
2468 a2->array_3D8[v70] = v38; 2900 a2->viewport_right_side[v70] = v38;
2469 } 2901 }
2470 //++v56; 2902 //++v56;
2471 v62 += v54; 2903 v62 += v54;
2472 v22 = v70 + 1; 2904 v22 = v70 + 1;
2473 v61 += v53; 2905 v61 += v53;
2483 if ( max_y > a3->_viewport_space_w ) 2915 if ( max_y > a3->_viewport_space_w )
2484 max_y = a3->_viewport_space_w; 2916 max_y = a3->_viewport_space_w;
2485 if ( min_y <= max_y ) 2917 if ( min_y <= max_y )
2486 { 2918 {
2487 //a3a = (char *)a2 - (char *)a3; 2919 //a3a = (char *)a2 - (char *)a3;
2488 //v42 = &a3->array_3D8[v7]; 2920 //v42 = &a3->viewport_right_side[v7];
2489 //v57 = *(__int16 *)((char *)v42 + a3a); 2921 //v57 = *(__int16 *)((char *)v42 + a3a);
2490 for ( v71 = min_y; v71 <= max_y; ++v71 ) 2922 for ( v71 = min_y; v71 <= max_y; ++v71 )
2491 { 2923 {
2492 if ( a2->array_18[v71] >= a3->array_18[v71] && a2->array_18[v71] <= a3->array_3D8[v71] ) 2924 if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] )
2493 break; 2925 break;
2494 //++v57; 2926 //++v57;
2495 ++min_y; 2927 ++min_y;
2496 //++v42; 2928 //++v42;
2497 } 2929 }
2498 } 2930 }
2499 if ( max_y < min_y ) 2931 if ( max_y < min_y )
2500 return false; 2932 return false;
2501 //a3a = (char *)a2 - (char *)a3; 2933 //a3a = (char *)a2 - (char *)a3;
2502 //v43 = &a3->array_3D8[v8]; 2934 //v43 = &a3->viewport_right_side[v8];
2503 //v58 = *(__int16 *)((char *)v43 + a3a); 2935 //v58 = *(__int16 *)((char *)v43 + a3a);
2504 for ( v72 = max_y; v72 >= min_y; --v72 ) 2936 for ( v72 = max_y; v72 >= min_y; --v72 )
2505 { 2937 {
2506 if ( a2->array_3D8[v72] >= a3->array_18[v72] && a2->array_18[v72] <= a3->array_3D8[v72] ) 2938 if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] )
2507 break; 2939 break;
2508 //--v58; 2940 //--v58;
2509 --max_y; 2941 --max_y;
2510 //--v43; 2942 //--v43;
2511 //v8 = v8; 2943 //v8 = v8;
2512 } 2944 }
2513 if ( min_y >= max_y ) 2945 if ( min_y >= max_y )
2514 return false; 2946 return false;
2515 //a3b = (char *)a3 - (char *)a2; 2947 //a3b = (char *)a3 - (char *)a2;
2516 v59 = min_y; 2948 v59 = min_y;
2517 //v45 = &a2->array_18[v7]; 2949 //v45 = &a2->viewport_left_side[v7];
2518 2950
2519 for ( v46 = max_y - min_y + 1; v46; --v46 ) 2951 for ( v46 = max_y - min_y + 1; v46; --v46 )
2520 { 2952 {
2521 //v47 = *(__int16 *)((char *)v45 + a3b); 2953 //v47 = *(__int16 *)((char *)v45 + a3b);
2522 if ( a2->array_18[v59] < a3->array_18[v59] ) 2954 if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] )
2523 a2->array_18[v59] = a3->array_18[v59]; 2955 a2->viewport_left_side[v59] = a3->viewport_left_side[v59];
2524 if ( a2->array_3D8[v59] > a3->array_3D8[v59] ) 2956 if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] )
2525 a2->array_3D8[v59] = a3->array_3D8[v59]; 2957 a2->viewport_right_side[v59] = a3->viewport_right_side[v59];
2526 ++v59; 2958 ++v59;
2527 //++v45; 2959 //++v45;
2528 } 2960 }
2529 a2->_viewport_space_y = min_y; 2961 a2->_viewport_space_y = min_y;
2530 a2->_viewport_space_w = max_y; 2962 a2->_viewport_space_w = max_y;
2531 a2->field_8 = a2->array_18[min_y]; 2963 a2->field_8 = a2->viewport_left_side[min_y];
2532 //v48 = a2->array_3D8[v7]; 2964 //v48 = a2->viewport_right_side[v7];
2533 a2->field_10 = min_y; 2965 a2->field_10 = min_y;
2534 a2->field_14 = min_y; 2966 a2->field_14 = min_y;
2535 a2->field_C = a2->array_3D8[min_y]; 2967 a2->field_C = a2->viewport_right_side[min_y];
2536 v49 = min_y + 1; 2968 v49 = min_y + 1;
2537 if ( v49 <= max_y ) 2969 if ( v49 <= max_y )
2538 { 2970 {
2539 //v50 = &a2->array_3D8[v49]; 2971 //v50 = &a2->viewport_right_side[v49];
2540 for ( v49; v49 <= max_y; ++v49 ) 2972 for ( v49; v49 <= max_y; ++v49 )
2541 { 2973 {
2542 //v51 = a2->array_18[v49]; 2974 //v51 = a2->viewport_left_side[v49];
2543 if ( a2->array_18[v49] < a2->field_8 ) 2975 if ( a2->viewport_left_side[v49] < a2->field_8 )
2544 { 2976 {
2545 a2->field_8 = a2->array_18[v49]; 2977 a2->field_8 = a2->viewport_left_side[v49];
2546 a2->field_10 = v49; 2978 a2->field_10 = v49;
2547 } 2979 }
2548 if ( a2->array_3D8[v49] > a2->field_C ) 2980 if ( a2->viewport_right_side[v49] > a2->field_C )
2549 { 2981 {
2550 a2->field_C = a2->array_3D8[v49]; 2982 a2->field_C = a2->viewport_right_side[v49];
2551 a2->field_14 = v49; 2983 a2->field_14 = v49;
2552 } 2984 }
2553 //++v50; 2985 //++v50;
2554 } 2986 }
2555 } 2987 }