comparison stru10.cpp @ 1317:66c625fd1113

m
author Ritor1
date Wed, 26 Jun 2013 14:21:55 +0600
parents ad97fdea66ac
children 2ddb0af0f437
comparison
equal deleted inserted replaced
1316:a2be48c661f6 1317:66c625fd1113
678 float _dp = (v25.vWorldPosition.x - pBLVRenderParams->vPartyPos.x) * a1.x + 678 float _dp = (v25.vWorldPosition.x - pBLVRenderParams->vPartyPos.x) * a1.x +
679 (v25.vWorldPosition.y - pBLVRenderParams->vPartyPos.y) * a1.y + 679 (v25.vWorldPosition.y - pBLVRenderParams->vPartyPos.y) * a1.y +
680 (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z; 680 (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z;
681 if (fabs(_dp) < 1e-6f) 681 if (fabs(_dp) < 1e-6f)
682 { 682 {
683 memcpy(&v25, pOutBounding + 1, sizeof(RenderVertexSoft)); 683 memcpy(&v25, &pOutBounding[1], sizeof(RenderVertexSoft));
684 memcpy(pOutBounding + 1, pOutBounding + 3, sizeof(RenderVertexSoft)); 684 memcpy(&pOutBounding[1], &pOutBounding[3], sizeof(RenderVertexSoft));
685 memcpy(pOutBounding + 3, &v25, sizeof(RenderVertexSoft)); 685 memcpy(&pOutBounding[3], &v25, sizeof(RenderVertexSoft));
686 } 686 }
687 687
688 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) 688 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
689 //{ 689 //{
690 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20 690 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
692 { 692 {
693 v26.vWorldPosition.x = pParty->vPosition.x; 693 v26.vWorldPosition.x = pParty->vPosition.x;
694 v26.vWorldPosition.y = pParty->vPosition.y; 694 v26.vWorldPosition.y = pParty->vPosition.y;
695 v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum 695 v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum
696 696
697 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, pOutBounding, 0xFF0000u, 0, 0); 697 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0);
698 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, pOutBounding + 1, 0xFF00u, 0, 0); 698 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0);
699 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, pOutBounding + 2, 0xFFu, 0, 0); 699 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0);
700 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, pOutBounding + 3, 0xFFFFFFu, 0, 0); 700 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0);
701 bDoNotDrawPortalFrustum = true; 701 bDoNotDrawPortalFrustum = true;
702 } 702 }
703 pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding 703 pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding
704 //} 704 //}
705 705
765 return false; 765 return false;
766 } 766 }
767 // 4D864C: using guessed type char byte_4D864C; 767 // 4D864C: using guessed type char byte_4D864C;
768 768
769 //----- (0049C681) -------------------------------------------------------- 769 //----- (0049C681) --------------------------------------------------------
770 bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pOutBounding) 770 bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *pPortalDataFrustum, RenderVertexSoft *pOutBounding)
771 { 771 {
772 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1 772 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1
773 773
774 CalcPolygonLimits(pFace, pLimits); 774 CalcPolygonLimits(pFace, pLimits);
775 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) 775 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
776 // pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997); 776 // pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997);
777 if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding)) 777 if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
778 return _49C720(pOutBounding, a3) != 0; 778 return _49C720(pOutBounding, pPortalDataFrustum) != 0;
779 return false; 779 return false;
780 } 780 }
781 781
782 // 4D864C: using guessed type char byte_4D864C; 782 // 4D864C: using guessed type char byte_4D864C;
783 783
784 //----- (0049C720) -------------------------------------------------------- 784 //----- (0049C720) --------------------------------------------------------
785 char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *a4) 785 char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *pPortalDataFrustum)
786 { 786 {
787 Vec3_float_ a3; // [sp+4h] [bp-34h]@1 787 Vec3_float_ pRayStart; // [sp+4h] [bp-34h]@1
788 a3.x = (double)pBLVRenderParams->vPartyPos.x; 788 pRayStart.x = (double)pBLVRenderParams->vPartyPos.x;
789 a3.y = (double)pBLVRenderParams->vPartyPos.y; 789 pRayStart.y = (double)pBLVRenderParams->vPartyPos.y;
790 a3.z = (double)pBLVRenderParams->vPartyPos.z; 790 pRayStart.z = (double)pBLVRenderParams->vPartyPos.z;
791 791
792 if (FindFaceNormal(pFaceBounding, pFaceBounding + 1, &a3, a4) && 792 if (FindFaceNormal(&pFaceBounding[0], &pFaceBounding[1], &pRayStart, &pPortalDataFrustum[0]) &&
793 FindFaceNormal(pFaceBounding + 1, pFaceBounding + 2, &a3, a4 + 1) && 793 FindFaceNormal(&pFaceBounding[1], &pFaceBounding[2], &pRayStart, &pPortalDataFrustum[1]) &&
794 FindFaceNormal(pFaceBounding + 2, pFaceBounding + 3, &a3, a4 + 2) && 794 FindFaceNormal(&pFaceBounding[2], &pFaceBounding[3], &pRayStart, &pPortalDataFrustum[2]) &&
795 FindFaceNormal(pFaceBounding + 3, pFaceBounding, &a3, a4 + 3)) 795 FindFaceNormal(&pFaceBounding[3], &pFaceBounding[0], &pRayStart, &pPortalDataFrustum[3]))
796 return true; 796 return true;
797 return false; 797 return false;
798 } 798 }
799 799
800 //----- (0049C7C5) -------------------------------------------------------- 800 //----- (0049C7C5) --------------------------------------------------------
801 bool stru10::FindFaceNormal(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4) 801 bool stru10::FindFaceNormal(RenderVertexSoft *pFaceBounding1, RenderVertexSoft *pFaceBounding2, Vec3_float_ *pRayStart, IndoorCameraD3D_Vec4 *pPortalDataFrustum)
802 { 802 {
803 Vec3_float_ v1; // [sp+4h] [bp-48h]@1 803 Vec3_float_ ray_dir; // [sp+4h] [bp-48h]@1
804 Vec3_float_ v2; // [sp+10h] [bp-3Ch]@1 804 Vec3_float_ pRay2; // [sp+10h] [bp-3Ch]@1
805 805
806 v1.x = a1->vWorldPosition.x - a3->x; 806 ray_dir.x = pFaceBounding1->vWorldPosition.x - pRayStart->x;//get ray for cmera to bounding1
807 v1.y = a1->vWorldPosition.y - a3->y; 807 ray_dir.y = pFaceBounding1->vWorldPosition.y - pRayStart->y;
808 v1.z = a1->vWorldPosition.z - a3->z; 808 ray_dir.z = pFaceBounding1->vWorldPosition.z - pRayStart->z;
809 Vec3_float_::Cross(&v1, &v2, a2->vWorldPosition.x - a1->vWorldPosition.x, 809 Vec3_float_::Cross(&ray_dir, &pRay2, pFaceBounding2->vWorldPosition.x - pFaceBounding1->vWorldPosition.x,
810 a2->vWorldPosition.y - a1->vWorldPosition.y, 810 pFaceBounding2->vWorldPosition.y - pFaceBounding1->vWorldPosition.y,
811 a2->vWorldPosition.z - a1->vWorldPosition.z); 811 pFaceBounding2->vWorldPosition.z - pFaceBounding1->vWorldPosition.z);
812 812
813 float sqr_mag = v2.x * v2.x + v2.y * v2.y + v2.z * v2.z; 813 float sqr_mag = pRay2.x * pRay2.x + pRay2.y * pRay2.y + pRay2.z * pRay2.z;
814 if (fabsf(sqr_mag) > 1e-6f) 814 if (fabsf(sqr_mag) > 1e-6f)
815 { 815 {
816 float inv_mag = 1.0f / sqrtf(sqr_mag); 816 float inv_mag = 1.0f / sqrtf(sqr_mag);
817 v2.x *= inv_mag; 817 pRay2.x *= inv_mag;
818 v2.y *= inv_mag; 818 pRay2.y *= inv_mag;
819 v2.z *= inv_mag; 819 pRay2.z *= inv_mag;
820 //v2.Normalize(); 820 pRay2.Normalize();
821 821
822 a4->x = v2.x; 822 pPortalDataFrustum->x = pRay2.x;
823 a4->y = v2.y; 823 pPortalDataFrustum->y = pRay2.y;
824 a4->z = v2.z; 824 pPortalDataFrustum->z = pRay2.z;
825 a4->dot = a3->z * v2.z + a3->y * v2.y + a3->x * v2.x; 825 pPortalDataFrustum->dot = pRayStart->z * pRay2.z + pRayStart->y * pRay2.y + pRayStart->x * pRay2.x;
826 return true; 826 return true;
827 } 827 }
828 return false; 828 return false;
829 } 829 }
830 830