# HG changeset patch # User Ritor1 # Date 1372234915 -21600 # Node ID 66c625fd111351bc9255b2abd7a584c3ffd65940 # Parent a2be48c661f67826a187ad06bc55b4a67806444a m diff -r a2be48c661f6 -r 66c625fd1113 IndoorCameraD3D.cpp --- a/IndoorCameraD3D.cpp Tue Jun 25 11:31:22 2013 +0600 +++ b/IndoorCameraD3D.cpp Wed Jun 26 14:21:55 2013 +0600 @@ -1373,13 +1373,13 @@ RenderVertexSoft *v14; // eax@8 RenderVertexSoft *v15; // edx@8 Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12 - float v17; // [sp+44h] [bp-10h]@1 - int v18; // [sp+48h] [bp-Ch]@5 + //float v17; // [sp+44h] [bp-10h]@1 + //int v18; // [sp+48h] [bp-Ch]@5 //stru9 *thisa; // [sp+4Ch] [bp-8h]@1 int a7a; // [sp+53h] [bp-1h]@5 //bool a6a; // [sp+70h] [bp+1Ch]@5 - v17 = 0.0; + //v17 = 0.0; //thisa = pGame->pStru9Instance; static RenderVertexSoft sr_vertices_50D9D8[64]; @@ -1388,41 +1388,44 @@ a7a = 0; v11 = 2 * (a6 == 0) + 1; //a6a = 0; - v18 = v11; + //v18 = v11; if (uNumVertices <= 0) return false; //v12 = *pOutNumVertices; //v13 = (char *)&a4->y; - uint i = 0; - while ( 1 ) + + //while ( 1 ) + for ( uint i = 0; i < uNumVertices; ++i ) + { + if (i % 2) + { + v14 = a1; + v15 = sr_vertices_50D9D8; + } + else { - if (i % 2) - { - v14 = a1; - v15 = sr_vertices_50D9D8; - } - else - { - v15 = a1; - v14 = sr_vertices_50D9D8; - } - if (i == uNumVertices - 1) - v14 = pVertices; - a5.x = a4[i].x; - a5.y = a4[i].y; - a5.z = a4[i].z; - pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused); - //v12 = *pOutNumVertices; - if (*pOutNumVertices < v18) - break; - //result = a6a; - //v13 += 24; - if (++i >= uNumVertices) - return a7a; + v15 = a1; + v14 = sr_vertices_50D9D8; } - *pOutNumVertices = 0; - return true; + if (i == uNumVertices - 1) + v14 = pVertices; + a5.x = a4[i].x; + a5.y = a4[i].y; + a5.z = a4[i].z; + pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused); + //v12 = *pOutNumVertices; + if (*pOutNumVertices < v11) + { + *pOutNumVertices = 0; + return true; + } + //result = a6a; + //v13 += 24; + //if (++i >= uNumVertices) + // + } + return a7a; } //----- (004371C3) -------------------------------------------------------- diff -r a2be48c661f6 -r 66c625fd1113 stru10.cpp --- 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; diff -r a2be48c661f6 -r 66c625fd1113 stru10.h --- a/stru10.h Tue Jun 25 11:31:22 2013 +0600 +++ b/stru10.h Wed Jun 26 14:21:55 2013 +0600 @@ -8,9 +8,9 @@ stru10(); virtual ~stru10(); char _49C5DA(struct BLVFace *pFace, struct RenderVertexSoft *pVertices, unsigned int *pNumVertices, struct IndoorCameraD3D_Vec4 *a5, struct RenderVertexSoft *pOutBounding); - bool CalcPortalShape(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pOutBounding); - char _49C720(struct RenderVertexSoft *pFaceBounding, struct IndoorCameraD3D_Vec4 *a4); - bool FindFaceNormal(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct Vec3_float_ *a3, struct IndoorCameraD3D_Vec4 *a4); + bool CalcPortalShape(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum, struct RenderVertexSoft *pOutBounding); + char _49C720(struct RenderVertexSoft *pFaceBounding, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum); + bool FindFaceNormal(struct RenderVertexSoft *pFaceBounding1, struct RenderVertexSoft *pFaceBounding2, struct Vec3_float_ *pRayStart, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum); bool FindFacePlane(struct RenderVertexSoft *face, struct Vec3_float_ *out_normal, float *out_distance); bool CalcFaceBounding(struct BLVFace *pFace, struct RenderVertexSoft *pFaceLimits, unsigned int uNumVertices, struct RenderVertexSoft *pOutBounding); void CalcPolygonLimits(struct BLVFace *pFace, struct RenderVertexSoft pOutVertices[4]);