Mercurial > mm7
comparison mm7_4.cpp @ 734:2f4e33c1ed24
stru154
author | Nomad |
---|---|
date | Fri, 22 Mar 2013 16:16:40 +0200 |
parents | de482c901171 |
children | 6daaa2f18d0d cd9ae9a2c99c |
comparison
equal
deleted
inserted
replaced
733:700b58aac975 | 734:2f4e33c1ed24 |
---|---|
4768 | 4768 |
4769 | 4769 |
4770 | 4770 |
4771 | 4771 |
4772 //----- (0049B04D) -------------------------------------------------------- | 4772 //----- (0049B04D) -------------------------------------------------------- |
4773 int stru154::_49B04D(ODMFace *a2, BSPVertexBuffer *a3) | 4773 void stru154::GetFacePlaneAndClassify(ODMFace *a2, BSPVertexBuffer *a3) |
4774 { | 4774 { |
4775 stru154 *v3; // edi@1 | 4775 //stru154 *v3; // edi@1 |
4776 signed int v4; // eax@1 | 4776 //signed int v4; // eax@1 |
4777 signed int result; // eax@9 | 4777 //signed int result; // eax@9 |
4778 signed int v6; // [sp-8h] [bp-18h]@8 | 4778 //signed int v6; // [sp-8h] [bp-18h]@8 |
4779 Vec3_float_ v; // [sp+4h] [bp-Ch]@1 | 4779 Vec3_float_ v; // [sp+4h] [bp-Ch]@1 |
4780 float v7; | |
4780 | 4781 |
4781 v.x = 0.0; | 4782 v.x = 0.0; |
4782 v3 = this; | |
4783 v.y = 0.0; | 4783 v.y = 0.0; |
4784 v.z = 0.0; | 4784 v.z = 0.0; |
4785 _49B13D(a2, a3, &v, (float *)&a3); | 4785 GetFacePlane(a2, a3, &v, &v7); |
4786 v4 = 2; | 4786 |
4787 if ( a2->pFacePlane.vNormal.z ) | 4787 if (fabsf(a2->pFacePlane.vNormal.z) < 1e-6f) |
4788 { | 4788 polygonType = POLYGON_VerticalWall; |
4789 if ( !a2->pFacePlane.vNormal.x && !a2->pFacePlane.vNormal.y ) | 4789 else if (fabsf(a2->pFacePlane.vNormal.x) < 1e-6f && |
4790 v4 = 1; | 4790 fabsf(a2->pFacePlane.vNormal.y) < 1e-6f) |
4791 } | 4791 polygonType = POLYGON_Floor; |
4792 else | 4792 else |
4793 { | 4793 polygonType = POLYGON_InBetweenFloorAndWall; |
4794 v4 = 0; | 4794 |
4795 } | 4795 face_plane.vNormal.x = v.x; |
4796 if ( v4 ) | 4796 face_plane.vNormal.y = v.y; |
4797 { | 4797 face_plane.vNormal.z = v.z; |
4798 if ( v4 == 1 ) | 4798 face_plane.dist = v7; |
4799 v6 = 3; | 4799 } |
4800 else | 4800 |
4801 v6 = 4; | 4801 //----- (0049B0C9) -------------------------------------------------------- |
4802 result = v6; | 4802 void stru154::ClassifyPolygon(Vec3_float_ *pNormal, float dist) |
4803 } | 4803 { |
4804 if (fabsf(pNormal->z) < 1e-6f) | |
4805 polygonType = POLYGON_VerticalWall; | |
4806 else if (fabsf(pNormal->x) < 1e-6f && | |
4807 fabsf(pNormal->y) < 1e-6f) | |
4808 polygonType = POLYGON_Floor; | |
4804 else | 4809 else |
4805 { | 4810 polygonType = POLYGON_InBetweenFloorAndWall; |
4806 result = 1; | 4811 |
4807 } | 4812 face_plane.vNormal.x = pNormal->x; |
4808 v3->face_plane.vNormal.x = v.x; | 4813 face_plane.dist = dist; |
4809 v3->face_plane.vNormal.y = v.y; | 4814 face_plane.vNormal.y = pNormal->y; |
4810 v3->face_plane.vNormal.z = v.z; | 4815 face_plane.vNormal.z = pNormal->z; |
4811 v3->face_plane.dist = *(float *)&a3; | |
4812 v3->polygonType = (PolygonType)result; | |
4813 return result; | |
4814 } | 4816 } |
4815 | 4817 |
4816 //----- (0049B0C9) -------------------------------------------------------- | |
4817 int stru154::_49B0C9(Vec3_float_ *pNormal, float dist) | |
4818 { | |
4819 signed int v3; // esi@1 | |
4820 signed int result; // eax@9 | |
4821 double v5; // st7@12 | |
4822 double v6; // st6@12 | |
4823 double v7; // st5@12 | |
4824 signed int v8; // [sp+0h] [bp-4h]@8 | |
4825 | |
4826 v3 = 2; | |
4827 if ( pNormal->z == 0.0 ) | |
4828 { | |
4829 v3 = 0; | |
4830 } | |
4831 else | |
4832 { | |
4833 if ( pNormal->x == 0.0 && pNormal->y == 0.0 ) | |
4834 v3 = 1; | |
4835 } | |
4836 if ( v3 ) | |
4837 { | |
4838 if ( v3 == 1 ) | |
4839 v8 = 3; | |
4840 else | |
4841 v8 = 4; | |
4842 result = v8; | |
4843 } | |
4844 else | |
4845 { | |
4846 result = 1; | |
4847 } | |
4848 v5 = pNormal->z; | |
4849 v6 = pNormal->y; | |
4850 v7 = pNormal->x; | |
4851 this->polygonType = (PolygonType)result; | |
4852 this->face_plane.vNormal.x = v7; | |
4853 this->face_plane.dist = dist; | |
4854 this->face_plane.vNormal.y = v6; | |
4855 this->face_plane.vNormal.z = v5; | |
4856 return result; | |
4857 } | |
4858 | |
4859 //----- (0049B13D) -------------------------------------------------------- | 4818 //----- (0049B13D) -------------------------------------------------------- |
4860 int stru154::_49B13D(ODMFace *pFace, BSPVertexBuffer *pVertices, Vec3_float_ *a3, float *a4) | 4819 void stru154::GetFacePlane(ODMFace *pFace, BSPVertexBuffer *pVertices, Vec3_float_ *pOutNormal, float *pOutDist) |
4861 { | 4820 { |
4862 ODMFace *v5; // ebx@1 | 4821 ODMFace *v5; // ebx@1 |
4863 int v6; // eax@1 | 4822 //int v6; // eax@1 |
4864 unsigned __int16 *v7; // ebx@2 | 4823 //unsigned __int16 *v7; // ebx@2 |
4865 Vec3_int_ *v8; // eax@3 | 4824 //Vec3_int_ *v8; // eax@3 |
4866 Vec3_int_ *v9; // ecx@3 | 4825 Vec3_int_ *v9; // ecx@3 |
4867 double v10; // st7@3 | 4826 //double v10; // st7@3 |
4868 int v11; // ecx@3 | 4827 //int v11; // ecx@3 |
4869 Vec3_int_ *v12; // ecx@3 | 4828 Vec3_int_ *v12; // ecx@3 |
4870 double v13; // st7@3 | 4829 //double v13; // st7@3 |
4871 double v14; // st6@3 | 4830 //double v14; // st6@3 |
4872 double v15; // st5@3 | 4831 //double v15; // st5@3 |
4873 int v16; // ecx@3 | 4832 //int v16; // ecx@3 |
4874 Vec3_int_ *v17; // eax@3 | 4833 Vec3_int_ *v17; // eax@3 |
4875 double v18; // st5@3 | 4834 //double v18; // st5@3 |
4876 Vec3_float_ *v19; // eax@3 | 4835 Vec3_float_ *v19; // eax@3 |
4877 int result; // eax@8 | 4836 //int result; // eax@8 |
4878 float v21; // ecx@10 | 4837 //float v21; // ecx@10 |
4879 double v22; // st7@10 | 4838 //double v22; // st7@10 |
4880 double v23; // st6@10 | 4839 //double v23; // st6@10 |
4881 Vec3_float_ v2; // [sp+4h] [bp-64h]@3 | 4840 Vec3_float_ v2; // [sp+4h] [bp-64h]@3 |
4882 float v25; // [sp+18h] [bp-50h]@3 | 4841 //float v25; // [sp+18h] [bp-50h]@3 |
4883 float v26; // [sp+1Ch] [bp-4Ch]@3 | 4842 float v26; // [sp+1Ch] [bp-4Ch]@3 |
4884 float v27; // [sp+20h] [bp-48h]@3 | 4843 float v27; // [sp+20h] [bp-48h]@3 |
4885 float v28; // [sp+24h] [bp-44h]@3 | 4844 float v28; // [sp+24h] [bp-44h]@3 |
4886 float v29; // [sp+2Ch] [bp-3Ch]@3 | 4845 //float v29; // [sp+2Ch] [bp-3Ch]@3 |
4887 float v30; // [sp+30h] [bp-38h]@3 | 4846 //float v30; // [sp+30h] [bp-38h]@3 |
4888 float v31; // [sp+34h] [bp-34h]@3 | 4847 //float v31; // [sp+34h] [bp-34h]@3 |
4889 float v32; // [sp+38h] [bp-30h]@3 | 4848 //float v32; // [sp+38h] [bp-30h]@3 |
4890 float v33; // [sp+3Ch] [bp-2Ch]@3 | 4849 //float v33; // [sp+3Ch] [bp-2Ch]@3 |
4891 Vec3_float_ v1; // [sp+40h] [bp-28h]@1 | 4850 Vec3_float_ v1; // [sp+40h] [bp-28h]@1 |
4892 float v35; // [sp+4Ch] [bp-1Ch]@3 | 4851 //float v35; // [sp+4Ch] [bp-1Ch]@3 |
4893 float v36; // [sp+50h] [bp-18h]@3 | 4852 //float v36; // [sp+50h] [bp-18h]@3 |
4894 float v37; // [sp+54h] [bp-14h]@3 | 4853 //float v37; // [sp+54h] [bp-14h]@3 |
4895 Vec3_float_ v38; // [sp+58h] [bp-10h]@3 | 4854 Vec3_float_ v38; // [sp+58h] [bp-10h]@3 |
4896 int v39; // [sp+64h] [bp-4h]@1 | 4855 //int v39; // [sp+64h] [bp-4h]@1 |
4897 | 4856 |
4898 v39 = 0; | 4857 //v39 = 0; |
4899 v1.x = 0.0; | 4858 v1.x = 0.0; |
4900 v5 = pFace; | 4859 v5 = pFace; |
4901 v6 = pFace->uNumVertices; | 4860 //v6 = pFace->uNumVertices; |
4902 v1.y = 0.0; | 4861 v1.y = 0.0; |
4903 v1.z = 0.0; | 4862 v1.z = 0.0; |
4904 if ( v6 - 1 <= 0 ) | 4863 |
4905 { | 4864 if (pFace->uNumVertices >= 2) |
4906 LABEL_8: | 4865 { |
4907 a3->x = (double)(v5->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.x >> 16); | 4866 int i = 0; |
4908 a3->y = (double)(v5->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.y >> 16); | 4867 while ( i < pFace->uNumVertices - 2 ) |
4909 a3->z = (double)(v5->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.z >> 16); | 4868 { |
4910 result = (int)a4; | 4869 v9 = &pVertices->pVertices[pFace->pVertexIDs[i]]; |
4911 *a4 = (double)(v5->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.dist >> 16); | 4870 v12 = &pVertices->pVertices[pFace->pVertexIDs[i + 1]]; |
4912 } | 4871 v17 = &pVertices->pVertices[pFace->pVertexIDs[i + 2]]; |
4913 else | 4872 |
4914 { | 4873 v1.x = v12->x - v9->x; |
4915 v7 = &pFace->pVertexIDs[1]; | 4874 v26 = v17->x - v12->x; |
4916 while ( 1 ) | 4875 v1.y = v12->y - v9->y; |
4917 { | 4876 v27 = v17->y - v12->y; |
4918 v8 = pVertices->pVertices; | 4877 v1.z = v12->z - v9->z; |
4919 v9 = &v8[*(v7 - 1)]; | 4878 v28 = v17->z - v12->z; |
4920 v35 = (double)v9->x; | |
4921 v36 = (double)v9->y; | |
4922 v10 = (double)v9->z; | |
4923 v11 = *v7; | |
4924 v37 = v10; | |
4925 v12 = &v8[v11]; | |
4926 v13 = (double)v12->x; | |
4927 v14 = (double)v12->y; | |
4928 v15 = (double)v12->z; | |
4929 v16 = v7[1]; | |
4930 v25 = v15; | |
4931 v17 = &v8[v16]; | |
4932 v18 = (double)v17->x; | |
4933 v29 = (double)v17->y; | |
4934 v30 = (double)v17->z; | |
4935 v31 = v13 - v35; | |
4936 v32 = v14 - v36; | |
4937 v33 = v25 - v37; | |
4938 v1.x = v31; | |
4939 v26 = v18 - v13; | |
4940 v1.y = v32; | |
4941 v27 = v29 - v14; | |
4942 v1.z = v33; | |
4943 v28 = v30 - v25; | |
4944 v19 = Vec3_float_::Cross(&v1, &v2, v26, v27, v28); | 4879 v19 = Vec3_float_::Cross(&v1, &v2, v26, v27, v28); |
4945 v38.x = v19->x; | 4880 v38.x = v19->x; |
4946 v38.y = v19->y; | 4881 v38.y = v19->y; |
4947 v38.z = v19->z; | 4882 v38.z = v19->z; |
4948 if ( v38.x != 0.0 ) | 4883 if ( v38.x != 0.0 || v38.y != 0.0 || v38.z != 0.0) |
4949 break; | 4884 { |
4950 if ( v38.y != 0.0 || v38.z != 0.0 ) | 4885 v38.Normalize(); |
4951 break; | 4886 |
4952 ++v39; | 4887 pOutNormal->x = v38.x; |
4953 ++v7; | 4888 pOutNormal->y = v38.y; |
4954 if ( v39 >= pFace->uNumVertices - 1 ) | 4889 pOutNormal->z = v38.z; |
4955 { | 4890 |
4956 v5 = pFace; | 4891 *pOutDist = -(v9->x * v38.x + v9->y * v38.y + v9->z * v38.z); |
4957 goto LABEL_8; | 4892 return; |
4958 } | 4893 } |
4959 } | 4894 } |
4960 v38.Normalize(); | 4895 } |
4961 v21 = v38.y; | 4896 |
4962 a3->x = v38.x; | 4897 pOutNormal->x = (double)(v5->pFacePlane.vNormal.x & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.x >> 16); |
4963 v22 = v37 * v38.z; | 4898 pOutNormal->y = (double)(v5->pFacePlane.vNormal.y & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.y >> 16); |
4964 v23 = v36 * v38.y; | 4899 pOutNormal->z = (double)(v5->pFacePlane.vNormal.z & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.z >> 16); |
4965 a3->y = v21; | 4900 *pOutDist = (double)(v5->pFacePlane.dist & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.dist >> 16); |
4966 a3->z = v38.z; | |
4967 result = (int)a4; | |
4968 *a4 = -(v22 + v23 + v35 * v38.x); | |
4969 } | |
4970 return result; | |
4971 } | 4901 } |
4972 | 4902 |
4973 | 4903 |
4974 | 4904 |
4975 | 4905 |