Mercurial > mm7
diff stru10.cpp @ 1317:66c625fd1113
m
author | Ritor1 |
---|---|
date | Wed, 26 Jun 2013 14:21:55 +0600 |
parents | ad97fdea66ac |
children | 2ddb0af0f437 |
line wrap: on
line diff
--- a/stru10.cpp Tue Jun 25 11:31:22 2013 +0600 +++ b/stru10.cpp Wed Jun 26 14:21:55 2013 +0600 @@ -680,9 +680,9 @@ (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z; if (fabs(_dp) < 1e-6f) { - memcpy(&v25, pOutBounding + 1, sizeof(RenderVertexSoft)); - memcpy(pOutBounding + 1, pOutBounding + 3, sizeof(RenderVertexSoft)); - memcpy(pOutBounding + 3, &v25, sizeof(RenderVertexSoft)); + memcpy(&v25, &pOutBounding[1], sizeof(RenderVertexSoft)); + memcpy(&pOutBounding[1], &pOutBounding[3], sizeof(RenderVertexSoft)); + memcpy(&pOutBounding[3], &v25, sizeof(RenderVertexSoft)); } //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) @@ -694,10 +694,10 @@ v26.vWorldPosition.y = pParty->vPosition.y; v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, pOutBounding, 0xFF0000u, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, pOutBounding + 1, 0xFF00u, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, pOutBounding + 2, 0xFFu, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, pOutBounding + 3, 0xFFFFFFu, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0); bDoNotDrawPortalFrustum = true; } pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding @@ -767,7 +767,7 @@ // 4D864C: using guessed type char byte_4D864C; //----- (0049C681) -------------------------------------------------------- -bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pOutBounding) +bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *pPortalDataFrustum, RenderVertexSoft *pOutBounding) { RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1 @@ -775,54 +775,54 @@ //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) // pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997); if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding)) - return _49C720(pOutBounding, a3) != 0; + return _49C720(pOutBounding, pPortalDataFrustum) != 0; return false; } // 4D864C: using guessed type char byte_4D864C; //----- (0049C720) -------------------------------------------------------- -char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *a4) +char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *pPortalDataFrustum) { - Vec3_float_ a3; // [sp+4h] [bp-34h]@1 - a3.x = (double)pBLVRenderParams->vPartyPos.x; - a3.y = (double)pBLVRenderParams->vPartyPos.y; - a3.z = (double)pBLVRenderParams->vPartyPos.z; + Vec3_float_ pRayStart; // [sp+4h] [bp-34h]@1 + pRayStart.x = (double)pBLVRenderParams->vPartyPos.x; + pRayStart.y = (double)pBLVRenderParams->vPartyPos.y; + pRayStart.z = (double)pBLVRenderParams->vPartyPos.z; - if (FindFaceNormal(pFaceBounding, pFaceBounding + 1, &a3, a4) && - FindFaceNormal(pFaceBounding + 1, pFaceBounding + 2, &a3, a4 + 1) && - FindFaceNormal(pFaceBounding + 2, pFaceBounding + 3, &a3, a4 + 2) && - FindFaceNormal(pFaceBounding + 3, pFaceBounding, &a3, a4 + 3)) + if (FindFaceNormal(&pFaceBounding[0], &pFaceBounding[1], &pRayStart, &pPortalDataFrustum[0]) && + FindFaceNormal(&pFaceBounding[1], &pFaceBounding[2], &pRayStart, &pPortalDataFrustum[1]) && + FindFaceNormal(&pFaceBounding[2], &pFaceBounding[3], &pRayStart, &pPortalDataFrustum[2]) && + FindFaceNormal(&pFaceBounding[3], &pFaceBounding[0], &pRayStart, &pPortalDataFrustum[3])) return true; return false; } //----- (0049C7C5) -------------------------------------------------------- -bool stru10::FindFaceNormal(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4) +bool stru10::FindFaceNormal(RenderVertexSoft *pFaceBounding1, RenderVertexSoft *pFaceBounding2, Vec3_float_ *pRayStart, IndoorCameraD3D_Vec4 *pPortalDataFrustum) { - Vec3_float_ v1; // [sp+4h] [bp-48h]@1 - Vec3_float_ v2; // [sp+10h] [bp-3Ch]@1 + Vec3_float_ ray_dir; // [sp+4h] [bp-48h]@1 + Vec3_float_ pRay2; // [sp+10h] [bp-3Ch]@1 - v1.x = a1->vWorldPosition.x - a3->x; - v1.y = a1->vWorldPosition.y - a3->y; - v1.z = a1->vWorldPosition.z - a3->z; - Vec3_float_::Cross(&v1, &v2, a2->vWorldPosition.x - a1->vWorldPosition.x, - a2->vWorldPosition.y - a1->vWorldPosition.y, - a2->vWorldPosition.z - a1->vWorldPosition.z); + ray_dir.x = pFaceBounding1->vWorldPosition.x - pRayStart->x;//get ray for cmera to bounding1 + ray_dir.y = pFaceBounding1->vWorldPosition.y - pRayStart->y; + ray_dir.z = pFaceBounding1->vWorldPosition.z - pRayStart->z; + Vec3_float_::Cross(&ray_dir, &pRay2, pFaceBounding2->vWorldPosition.x - pFaceBounding1->vWorldPosition.x, + pFaceBounding2->vWorldPosition.y - pFaceBounding1->vWorldPosition.y, + pFaceBounding2->vWorldPosition.z - pFaceBounding1->vWorldPosition.z); - float sqr_mag = v2.x * v2.x + v2.y * v2.y + v2.z * v2.z; + float sqr_mag = pRay2.x * pRay2.x + pRay2.y * pRay2.y + pRay2.z * pRay2.z; if (fabsf(sqr_mag) > 1e-6f) { float inv_mag = 1.0f / sqrtf(sqr_mag); - v2.x *= inv_mag; - v2.y *= inv_mag; - v2.z *= inv_mag; - //v2.Normalize(); + pRay2.x *= inv_mag; + pRay2.y *= inv_mag; + pRay2.z *= inv_mag; + pRay2.Normalize(); - a4->x = v2.x; - a4->y = v2.y; - a4->z = v2.z; - a4->dot = a3->z * v2.z + a3->y * v2.y + a3->x * v2.x; + pPortalDataFrustum->x = pRay2.x; + pPortalDataFrustum->y = pRay2.y; + pPortalDataFrustum->z = pRay2.z; + pPortalDataFrustum->dot = pRayStart->z * pRay2.z + pRayStart->y * pRay2.y + pRayStart->x * pRay2.x; return true; } return false;