Mercurial > mm7
changeset 1050:4b329bf2d197
intersect_face_vertex_coords_list
author | Ritor1 |
---|---|
date | Thu, 23 May 2013 16:36:08 +0600 |
parents | efe228ab5003 |
children | 05c62d166182 958c7372f2d4 |
files | Vis.cpp Vis.h mm7_data.cpp mm7_data.h |
diffstat | 4 files changed, 66 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/Vis.cpp Thu May 23 13:00:29 2013 +0600 +++ b/Vis.cpp Thu May 23 16:36:08 2013 +0600 @@ -369,6 +369,8 @@ auto bmodel = &pOutdoor->pBModels[i]; for (uint j = 0; j < bmodel->uNumFaces; ++j) { + //if ( i == 1 && j == 30 )// + //__debugbreak();// auto face = &bmodel->pFaces[j]; if (is_part_of_selection(face, filter)) { @@ -588,7 +590,7 @@ IntersectPoint.y = (signed __int64)Intersection->vWorldPosition.y; IntersectPoint.z = (signed __int64)Intersection->vWorldPosition.z; - if ( !IntersectBModel_sub(pFace, IntersectPoint, pBModelID) ) + if ( !CheckIntersectBModel(pFace, IntersectPoint, pBModelID) ) return false; *pDepth = t;//Record the distance from the origin of the ray (Записываем дистанцию от начала луча) @@ -596,7 +598,7 @@ } //----- (004C1D2B) -------------------------------------------------------- -bool Vis::IntersectBModel_sub(BLVFace *pFace, Vec3_short_ IntersectPoint, unsigned int uModelID) +bool Vis::CheckIntersectBModel(BLVFace *pFace, Vec3_short_ IntersectPoint, unsigned int uModelID) { int v5; // esi@10 bool v6; // edi@10 @@ -608,7 +610,7 @@ int v15; // [sp+10h] [bp-Ch]@10 signed int v16; // [sp+18h] [bp-4h]@10 - int a1 = 0, a2 = 0; + int a = 0, b = 0; if (IntersectPoint.x < pFace->pBounding.x1 || IntersectPoint.x > pFace->pBounding.x2 || IntersectPoint.y < pFace->pBounding.y1 || IntersectPoint.y > pFace->pBounding.y2 || @@ -618,151 +620,143 @@ pFace->uAttributes |= 0x80000000; if (uModelID != -1) - ODM_IntersectBModel(&a1, &a2, word_F8BC48_displaced_face_intersect_plane_coords_a, word_F8BD18_displaced_face_intersect_plane_coords_b, + ODM_CreateIntersectFacesVertexCoordList(&a, &b, intersect_face_vertex_coords_list_a, intersect_face_vertex_coords_list_b, &IntersectPoint, pFace, uModelID); else - BLV_IntersectBModel(&a1, &a2, word_F8BC48_displaced_face_intersect_plane_coords_a, word_F8BD18_displaced_face_intersect_plane_coords_b, + BLV_CreateIntersectFacesVertexCoordList(&a, &b, intersect_face_vertex_coords_list_a, intersect_face_vertex_coords_list_b, &IntersectPoint, pFace); v5 = 2 * pFace->uNumVertices; v16 = 0; - word_F8BC48_displaced_face_intersect_plane_coords_a[v5] = word_F8BC48_displaced_face_intersect_plane_coords_a[0]; - word_F8BD18_displaced_face_intersect_plane_coords_b[v5] = word_F8BD18_displaced_face_intersect_plane_coords_b[0]; - v6 = word_F8BD18_displaced_face_intersect_plane_coords_b[0] >= a2; + intersect_face_vertex_coords_list_a[v5] = intersect_face_vertex_coords_list_a[0]; + intersect_face_vertex_coords_list_b[v5] = intersect_face_vertex_coords_list_b[0]; + v6 = intersect_face_vertex_coords_list_b[0] >= b; if (v5 <= 0) return false; for ( uint i = 0; i < v5; ++i ) { if ( v16 >= 2 ) break; - if ( v6 ^ word_F8BD18_displaced_face_intersect_plane_coords_b[i + 1] >= a2 ) + if ( v6 ^ intersect_face_vertex_coords_list_b[i + 1] >= b ) { - if ( word_F8BC48_displaced_face_intersect_plane_coords_a[i + 1] >= a1 ) + if ( intersect_face_vertex_coords_list_a[i + 1] >= a ) v10 = 0; else v10 = 2; - v11 = v10 | word_F8BC48_displaced_face_intersect_plane_coords_a[i] < a1; + v11 = v10 | intersect_face_vertex_coords_list_a[i] < a; if ( v11 != 3 ) { if ( !v11 - || (v12 = word_F8BC48_displaced_face_intersect_plane_coords_a[i + 1] - word_F8BC48_displaced_face_intersect_plane_coords_a[i], + || (v12 = intersect_face_vertex_coords_list_a[i + 1] - intersect_face_vertex_coords_list_a[i], LODWORD(v13) = v12 << 16, HIDWORD(v13) = v12 >> 16, - word_F8BC48_displaced_face_intersect_plane_coords_a[i] - + ((signed int)(((unsigned __int64)(v13 / (word_F8BD18_displaced_face_intersect_plane_coords_b[i + 1] - word_F8BD18_displaced_face_intersect_plane_coords_b[i]) - * (signed int)((a2 - word_F8BD18_displaced_face_intersect_plane_coords_b[i]) << 16)) >> 16) + 32768) >> 16) >= a1) ) + intersect_face_vertex_coords_list_a[i] + + ((signed int)(((unsigned __int64)(v13 / (intersect_face_vertex_coords_list_b[i + 1] - intersect_face_vertex_coords_list_b[i]) + * (signed int)((b - intersect_face_vertex_coords_list_b[i]) << 16)) >> 16) + 32768) >> 16) >= a) ) ++v16; } } - v6 = word_F8BD18_displaced_face_intersect_plane_coords_b[i + 1] >= a2; + v6 = intersect_face_vertex_coords_list_b[i + 1] >= b; } - result = 1; + result = true; if ( v16 != 1 ) - result = 0; + result = false; return result; } //----- (004C1EE5) -------------------------------------------------------- -bool Vis::BLV_IntersectBModel(int *a1, int *a2, __int16 *displaced_face_intersect_plane_coords_a, __int16 *displaced_face_intersect_plane_coords_b, Vec3_short_ *IntersectPoint, BLVFace *pFace) +void Vis::BLV_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace) { if (pFace->uAttributes & FACE_XY_PLANE) { - *a1 = IntersectPoint->x; - *a2 = IntersectPoint->y; + *a = IntersectPoint->x; + *b = IntersectPoint->y; for (uint i = 0; i < pFace->uNumVertices; ++i) { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].x; - displaced_face_intersect_plane_coords_a[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].x; + intersect_face_vertex_coords_list_a[2 * i] = pFace->pXInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].x; + intersect_face_vertex_coords_list_a[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].x; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].y; - displaced_face_intersect_plane_coords_b[2 * i + 1] = pFace->pYInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].y; + intersect_face_vertex_coords_list_b[2 * i] = pFace->pYInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].y; + intersect_face_vertex_coords_list_b[2 * i + 1] = pFace->pYInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].y; } } else if (pFace->uAttributes & FACE_XZ_PLANE) { - *a1 = IntersectPoint->x; - *a2 = IntersectPoint->z; + *a = IntersectPoint->x; + *b = IntersectPoint->z; for (uint i = 0; i < pFace->uNumVertices; ++i) { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].x; - displaced_face_intersect_plane_coords_a[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].x; + intersect_face_vertex_coords_list_a[2 * i] = pFace->pXInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].x; + intersect_face_vertex_coords_list_a[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].x; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].z; - displaced_face_intersect_plane_coords_b[2 * i + 1] = pFace->pZInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].z; + intersect_face_vertex_coords_list_b[2 * i] = pFace->pZInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].z; + intersect_face_vertex_coords_list_b[2 * i + 1] = pFace->pZInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].z; } } else if (pFace->uAttributes & FACE_YZ_PLANE) { - *a1 = IntersectPoint->y; - *a2 = IntersectPoint->z; + *a = IntersectPoint->y; + *b = IntersectPoint->z; for (uint i = 0; i < pFace->uNumVertices; ++i) { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].y; - displaced_face_intersect_plane_coords_a[2 * i + 1] = pFace->pYInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].y; + intersect_face_vertex_coords_list_a[2 * i] = pFace->pYInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].y; + intersect_face_vertex_coords_list_a[2 * i + 1] = pFace->pYInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].y; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].z; - displaced_face_intersect_plane_coords_b[2 * i + 1] = pFace->pZInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].z; + intersect_face_vertex_coords_list_b[2 * i] = pFace->pZInterceptDisplacements[i] + pIndoor->pVertices[pFace->pVertexIDs[i]].z; + intersect_face_vertex_coords_list_b[2 * i + 1] = pFace->pZInterceptDisplacements[i + 1] + pIndoor->pVertices[pFace->pVertexIDs[i + 1]].z; } } - else - { - assert(false); - return false; - } - - return true; + else assert(false); } //----- (004C2186) -------------------------------------------------------- -bool Vis::ODM_IntersectBModel(int *a1, int *a2, __int16 *displaced_face_intersect_plane_coords_a, __int16 *displaced_face_intersect_plane_coords_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID) +void Vis::ODM_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID) { if (pFace->uAttributes & FACE_XY_PLANE) { - *a1 = IntersectPoint->x; - *a2 = IntersectPoint->y; + *a = IntersectPoint->x; + *b = IntersectPoint->y; for (int i = 0; i < pFace->uNumVertices; ++i) { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; - displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + intersect_face_vertex_coords_list_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; + intersect_face_vertex_coords_list_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + intersect_face_vertex_coords_list_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + intersect_face_vertex_coords_list_b[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; } } else if (pFace->uAttributes & FACE_XZ_PLANE) { - *a1 = IntersectPoint->x; - *a2 = IntersectPoint->z; + *a = IntersectPoint->x; + *b = IntersectPoint->z; for (int i = 0; i < pFace->uNumVertices; ++i) { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; - displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + intersect_face_vertex_coords_list_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; + intersect_face_vertex_coords_list_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; - displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; + intersect_face_vertex_coords_list_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + intersect_face_vertex_coords_list_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; } } else if (pFace->uAttributes & FACE_YZ_PLANE) { - *a1 = IntersectPoint->y; - *a2 = IntersectPoint->z; + *a = IntersectPoint->y; + *b = IntersectPoint->z; for (int i = 0; i < pFace->uNumVertices; ++i) { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + intersect_face_vertex_coords_list_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + intersect_face_vertex_coords_list_a[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; - displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; + intersect_face_vertex_coords_list_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + intersect_face_vertex_coords_list_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; } } else assert(false); - - return true; } //----- (0046A0A1) --------------------------------------------------------
--- a/Vis.h Thu May 23 13:00:29 2013 +0600 +++ b/Vis.h Thu May 23 16:36:08 2013 +0600 @@ -111,9 +111,9 @@ int get_object_zbuf_val(Vis_ObjectInfo *info); int get_picked_object_zbuf_val(); bool Intersect_Ray_Face(struct RenderVertexSoft *pRayStart, struct RenderVertexSoft *pRayEnd, float *pDepth, RenderVertexSoft *Intersection, BLVFace *pFace, unsigned int pBModelID); - bool IntersectBModel_sub(BLVFace *pFace, Vec3_short_ IntersectPoint, unsigned int uModelID); - bool BLV_IntersectBModel(int *a1, int *a2, __int16 *displaced_face_intersect_plane_coords_a, __int16 *displaced_face_intersect_plane_coords_b, Vec3_short_ *IntersectPoint, BLVFace *pFace); - bool ODM_IntersectBModel(int *a1, int *a2, __int16 *displaced_face_intersect_plane_coords_a, __int16 *displaced_face_intersect_plane_coords_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID); + bool CheckIntersectBModel(BLVFace *pFace, Vec3_short_ IntersectPoint, unsigned int uModelID); + void BLV_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace); + void ODM_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID); void CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth); void sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right); bool SortVerticesByX(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd);
--- a/mm7_data.cpp Thu May 23 13:00:29 2013 +0600 +++ b/mm7_data.cpp Thu May 23 16:36:08 2013 +0600 @@ -1631,8 +1631,8 @@ //_UNKNOWN unk_F8BA50; // weak char byte_F8BC0C; // weak int bGameoverLoop = 0; // weak -__int16 word_F8BC48_displaced_face_intersect_plane_coords_a[104]; // idb -__int16 word_F8BD18_displaced_face_intersect_plane_coords_b[104]; // idb +__int16 intersect_face_vertex_coords_list_a[104]; // word_F8BC48 +__int16 intersect_face_vertex_coords_list_b[104]; // word_F8BD18 int dword_F93F20; // weak int dword_F93F70; // weak
--- a/mm7_data.h Thu May 23 13:00:29 2013 +0600 +++ b/mm7_data.h Thu May 23 16:36:08 2013 +0600 @@ -1135,8 +1135,8 @@ //extern _UNKNOWN unk_F8BA50; // weak extern char byte_F8BC0C; // weak extern int bGameoverLoop; // weak -extern __int16 word_F8BC48_displaced_face_intersect_plane_coords_a[]; // idb -extern __int16 word_F8BD18_displaced_face_intersect_plane_coords_b[]; // idb +extern __int16 intersect_face_vertex_coords_list_a[]; // word_F8BC48 +extern __int16 intersect_face_vertex_coords_list_b[]; // word_F8BD18 //extern _UNKNOWN unk_F8EA04; // weak //extern _UNKNOWN unk_F8F8F8; // weak extern int dword_F93F20; // weak