Mercurial > mm7
diff Vis.cpp @ 1047:76ce871b0076
m
author | Ritor1 |
---|---|
date | Thu, 23 May 2013 11:16:46 +0600 |
parents | d3f4c6584ada |
children | d36681a9e4f8 |
line wrap: on
line diff
--- a/Vis.cpp Tue May 21 16:13:48 2013 +0600 +++ b/Vis.cpp Thu May 23 11:16:46 2013 +0600 @@ -552,7 +552,7 @@ if (pFace->Portal() || pFace->Invisible()) return false; - int ray_dir_x = pRayEnd->vWorldPosition.x - pRayStart->vWorldPosition.x, + int ray_dir_x = pRayEnd->vWorldPosition.x - pRayStart->vWorldPosition.x,//calculate the direction vector of the line(вычислим вектор направления линий) ray_dir_y = pRayEnd->vWorldPosition.y - pRayStart->vWorldPosition.y, ray_dir_z = pRayEnd->vWorldPosition.z - pRayStart->vWorldPosition.z; @@ -565,20 +565,20 @@ #define EPSILON 1e-6 //c2 = n*u - c2 = pFace->pFacePlane.vNormal.x * ray_dir_y + c2 = pFace->pFacePlane.vNormal.x * ray_dir_y// get length of the line(Это дает нам длину линии) + pFace->pFacePlane.vNormal.y * ray_dir_x + pFace->pFacePlane.vNormal.z * ray_dir_z; if (c2 > -EPSILON && c2 < EPSILON) // ray faces face's normal ( > 0) or parallel ( == 0) return false; //t = -d-(n*p0)/n*u - float t = c1 / c2; + float t = c1 / c2;//How far is crossing the line in percent for 0 to 1(Как далеко пересечение линии в процентах от 0 до 1 ) if (t < 0 || t > 1) return false; // p(t) = p0 + tu; - Intersection->vWorldPosition.x = pRayStart->vWorldPosition.x + t * ray_dir_y; + Intersection->vWorldPosition.x = pRayStart->vWorldPosition.x + t * ray_dir_y;// add the interest to the start line(прибавляем процент линии к линии старта) Intersection->vWorldPosition.y = pRayStart->vWorldPosition.y + t * ray_dir_x; Intersection->vWorldPosition.z = pRayStart->vWorldPosition.z + t * ray_dir_z; @@ -586,22 +586,22 @@ IntersectPoint.y = (signed __int64)Intersection->vWorldPosition.y; IntersectPoint.z = (signed __int64)Intersection->vWorldPosition.z; - if ( !_4C1D2B(pFace, IntersectPoint, pBModelID) ) + if ( !IntersectBModel_sub(pFace, IntersectPoint, pBModelID) ) return false; - //*pDepth = t; + *pDepth = t;//Record the distance from the origin of the ray (Записываем дистанцию от начала луча ) return true; } //----- (004C1D2B) -------------------------------------------------------- -bool Vis::_4C1D2B(BLVFace *pFace, Vec3_short_ a2, unsigned int uModelID) +bool Vis::IntersectBModel_sub(BLVFace *pFace, Vec3_short_ IntersectPoint, unsigned int uModelID) { //BLVFace *v4; // esi@1 int v5; // esi@10 bool v6; // edi@10 - int v7; // ecx@12 - signed int v8; // edx@12 - signed int v9; // eax@13 + //int v7; // ecx@12 + //signed int v8; // edx@12 + //signed int v9; // eax@13 signed int v10; // ebx@14 int v11; // edi@16 signed int v12; // ST28_4@18 @@ -610,67 +610,55 @@ int v15; // [sp+10h] [bp-Ch]@10 signed int v16; // [sp+18h] [bp-4h]@10 - //v4 = pFace; - if (a2.x < pFace->pBounding.x1 || a2.x > pFace->pBounding.x2 || - a2.y < pFace->pBounding.y1 || a2.y > pFace->pBounding.y2 || - a2.z < pFace->pBounding.z1 || a2.z > pFace->pBounding.z2 ) + if (IntersectPoint.x < pFace->pBounding.x1 || IntersectPoint.x > pFace->pBounding.x2 || + IntersectPoint.y < pFace->pBounding.y1 || IntersectPoint.y > pFace->pBounding.y2 || + IntersectPoint.z < pFace->pBounding.z1 || IntersectPoint.z > pFace->pBounding.z2 ) return false; pFace->uAttributes |= 0x80000000; return true; if (uModelID != -1) - _4C2186_BLV_IntersectBModel(pFace, uModelID, - word_F8BC48_displaced_face_intersect_plane_coords_a, - word_F8BD18_displaced_face_intersect_plane_coords_b, - &a2, pFace, uModelID); + _4C2186_BLV_IntersectBModel(pFace, uModelID, word_F8BC48_displaced_face_intersect_plane_coords_a, + word_F8BD18_displaced_face_intersect_plane_coords_b, &IntersectPoint, pFace, uModelID); else - _4C1EE5_BLV_IntersectBModel_2((int *)&pFace, (int *)&uModelID, - word_F8BC48_displaced_face_intersect_plane_coords_a, - word_F8BD18_displaced_face_intersect_plane_coords_b, - &a2, pFace); + _4C1EE5_BLV_IntersectBModel_2((int *)&pFace, (int *)&uModelID, word_F8BC48_displaced_face_intersect_plane_coords_a, + word_F8BD18_displaced_face_intersect_plane_coords_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]; - v15 = 0; v6 = word_F8BD18_displaced_face_intersect_plane_coords_b[0] >= (signed int)uModelID; if (v5 <= 0) return false; - do + for ( v15 = 0; v15 < v5; ++v15 ) { if ( v16 >= 2 ) break; - v7 = 2 * v15; - v8 = word_F8BD18_displaced_face_intersect_plane_coords_b[ + v15 + 1]; - if ( v6 ^ v8 >= (signed int)uModelID ) + if ( v6 ^ word_F8BD18_displaced_face_intersect_plane_coords_b[v15 + 1] >= (signed int)uModelID ) { - v9 = word_F8BC48_displaced_face_intersect_plane_coords_a[v7/2 + 1]; - if ( v9 >= (signed int)pFace ) + if ( word_F8BC48_displaced_face_intersect_plane_coords_a[v15 + 1] >= (signed int)pFace ) v10 = 0; else v10 = 2; - v11 = v10 | word_F8BC48_displaced_face_intersect_plane_coords_a[v7/2] < (signed int)pFace; + v11 = v10 | word_F8BC48_displaced_face_intersect_plane_coords_a[v15] < (signed int)pFace; if ( v11 != 3 ) { if ( !v11 - || (v12 = v9 - word_F8BC48_displaced_face_intersect_plane_coords_a[v7/2], + || (v12 = word_F8BC48_displaced_face_intersect_plane_coords_a[v15 + 1] - word_F8BC48_displaced_face_intersect_plane_coords_a[v15], LODWORD(v13) = v12 << 16, HIDWORD(v13) = v12 >> 16, - word_F8BC48_displaced_face_intersect_plane_coords_a[v7/2] - + ((signed int)(((unsigned __int64)(v13 / (v8 - word_F8BD18_displaced_face_intersect_plane_coords_b[v7/2]) - * (signed int)((uModelID - word_F8BD18_displaced_face_intersect_plane_coords_b[v7/2]) << 16)) >> 16) + 32768) >> 16) >= (signed int)pFace) ) + word_F8BC48_displaced_face_intersect_plane_coords_a[v15] + + ((signed int)(((unsigned __int64)(v13 / (word_F8BD18_displaced_face_intersect_plane_coords_b[v15 + 1] - word_F8BD18_displaced_face_intersect_plane_coords_b[v15]) + * (signed int)((uModelID - word_F8BD18_displaced_face_intersect_plane_coords_b[v15]) << 16)) >> 16) + 32768) >> 16) >= (signed int)pFace) ) ++v16; } } - ++v15; - v6 = v8 >= (signed int)uModelID; + v6 = word_F8BD18_displaced_face_intersect_plane_coords_b[v15 + 1] >= (signed int)uModelID; } - while ( v15 < v5 ); result = 1; if ( v16 != 1 ) -LABEL_25: result = 0; return result; } @@ -776,7 +764,7 @@ } //----- (004C2186) -------------------------------------------------------- -bool Vis::_4C2186_BLV_IntersectBModel(BLVFace *pFace, unsigned int ModelID, __int16 *displaced_face_intersect_plane_coords_a, __int16 *displaced_face_intersect_plane_coords_b, Vec3_short_ *a5, BLVFace *face, unsigned int uModelID) +bool Vis::_4C2186_BLV_IntersectBModel(BLVFace *pFace, unsigned int ModelID, __int16 *displaced_face_intersect_plane_coords_a, __int16 *displaced_face_intersect_plane_coords_b, Vec3_short_ *IntersectPoint, BLVFace *face, unsigned int uModelID) { bool result; // eax@1 //int *v9; // esi@1 @@ -804,8 +792,8 @@ //a1a = 0; if ( BYTE1(pFace->uAttributes) & 1 ) { - pFace->pFacePlane.vNormal.x = a5->x; - pFace->pFacePlane.vNormal.y = a5->y; + pFace->pFacePlane.vNormal.x = IntersectPoint->x; + pFace->pFacePlane.vNormal.y = IntersectPoint->y; if ( pFace->uNumVertices ) { //v11 = 188 * ModelID + 72; @@ -827,8 +815,8 @@ { if ( BYTE1(pFace->uAttributes) & 2 ) { - pFace->pFacePlane.vNormal.x = a5->x; - pFace->pFacePlane.vNormal.z = a5->z; + pFace->pFacePlane.vNormal.x = IntersectPoint->x; + pFace->pFacePlane.vNormal.z = IntersectPoint->z; if ( pFace->uNumVertices ) { v15 = 188 * uModelID + 72; @@ -836,7 +824,7 @@ for ( uint 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; - *(a5b - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; *(__int16 *)((char *)a5b + (int)displaced_face_intersect_plane_coords_a - (int)displaced_face_intersect_plane_coords_b) = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; v17 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; @@ -848,8 +836,8 @@ } else { - pFace->pFacePlane.vNormal.y = a5->y; - pFace->pFacePlane.vNormal.z = a5->z; + pFace->pFacePlane.vNormal.y = IntersectPoint->y; + pFace->pFacePlane.vNormal.z = IntersectPoint->z; if ( pFace->uNumVertices ) { v19 = 188 * uModelID + 72; @@ -857,7 +845,7 @@ for ( uint 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; - *(a5c - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; *(__int16 *)((char *)a5c + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; v21 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z;