Mercurial > mm7
changeset 1047:76ce871b0076
m
author | Ritor1 |
---|---|
date | Thu, 23 May 2013 11:16:46 +0600 |
parents | 5758ddc56127 |
children | d36681a9e4f8 |
files | Vis.cpp Vis.h mm7_1.cpp |
diffstat | 3 files changed, 40 insertions(+), 63 deletions(-) [+] |
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;
--- a/Vis.h Tue May 21 16:13:48 2013 +0600 +++ b/Vis.h Thu May 23 11:16:46 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 _4C1D2B(BLVFace *pFace, Vec3_short_ a2, unsigned int uModelID); + bool IntersectBModel_sub(BLVFace *pFace, Vec3_short_ IntersectPoint, unsigned int uModelID); bool _4C1EE5_BLV_IntersectBModel_2(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *pFace); - bool _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 _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); 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_1.cpp Tue May 21 16:13:48 2013 +0600 +++ b/mm7_1.cpp Thu May 23 11:16:46 2013 +0600 @@ -1015,9 +1015,7 @@ POINT a2; // [sp+84h] [bp-8h]@3 if ( pRenderer->pRenderD3D ) - { v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); - } else { v1 = pMouse->GetCursorPos(&a2); @@ -1027,9 +1025,7 @@ { a2.y = (signed int)(unsigned __int16)v0 >> 3; v21 = (signed int)(unsigned __int16)v0 >> 3; - if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) - && a2.y < 1000 - && pSpriteObjects[v21].uObjectDescID + if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID && (unsigned int)v0 < 0x2000000 ) { v22 = &pSpriteObjects[v21].stru_24; @@ -1113,9 +1109,7 @@ v6 = 0; a1.uType = v5; if ( (signed int)pObjectList->uNumObjects <= 0 ) - { LOWORD(v6) = 0; - } else { v7 = (char *)&pObjectList->pObjects->uObjectID; @@ -1138,18 +1132,13 @@ a1.uSoundID = 0; a1.uFacing = 0; a1.uAttributes = 8; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); a1.uSpriteFrameID = 0; memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); v8 = (int *)pMouse->GetCursorPos(&v25); v9 = UnprojectX(*v8); a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, - TEXTURE_16BIT_PALETTE); + v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); if (v10 != -1) pIcons_LOD->pTextures[v10].Release(); pMouse->RemoveHoldingItem();