comparison mm7_4.cpp @ 1267:33e360a9b4bf

some fixes in normals
author Gloval
date Thu, 13 Jun 2013 23:41:42 +0400
parents 0aeac0b9ca30
children 7569c88d9cb0 8a196c858180
comparison
equal deleted inserted replaced
1266:71ebff35c428 1267:33e360a9b4bf
473 473
474 v46 = 1; 474 v46 = 1;
475 dword_721160[0] = -1; 475 dword_721160[0] = -1;
476 dword_721110[0] = -1; 476 dword_721110[0] = -1;
477 odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, pIsOnWater, bWaterWalk); 477 odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, pIsOnWater, bWaterWalk);
478 if ( (signed int)pOutdoor->uNumBModels <= 0 ) 478
479 { 479 for ( pBModelNum = 0; pBModelNum < pOutdoor->uNumBModels; ++pBModelNum )
480 *a6 = 0; 480 {
481 return odm_floor_level[0]; 481 pBModel = &pOutdoor->pBModels[pBModelNum];
482 } 482 if ( X <= pBModel->sMaxX && X >= pBModel->sMinX &&
483 v38 = 0; 483 Y <= pBModel->sMaxY && Y >= pBModel->sMinY )
484 for ( pBModelNum = 0; pBModelNum < (signed int)pOutdoor->uNumBModels; ++pBModelNum ) 484 {
485 { 485 if ( pBModel->uNumFaces > 0 )
486 pBModel = &pOutdoor->pBModels[v38];
487 if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && Y <= pBModel->sMaxY && Y >= pBModel->sMinY )
488 {
489 if ( (signed int)pBModel->uNumFaces > 0 )
490 { 486 {
491 v39 = 0; 487 v39 = 0;
492 for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) 488 for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum )
493 { 489 {
494 pFace = &pBModel->pFaces[v39]; 490 pFace = &pBModel->pFaces[pFaceNum];
495 if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) 491 if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall)
496 && !(pFace->uAttributes & 0x20000000) 492 && !(pFace->uAttributes & 0x20000000)
497 && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1 493 && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1
498 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 ) 494 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 )
499 { 495 {
500 if ( pFace->uNumVertices ) 496
501 {
502 for ( uint i = 0; i < pFace->uNumVertices; ++i) 497 for ( uint i = 0; i < pFace->uNumVertices; ++i)
503 { 498 {
504 word_721040[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; 499 word_721040[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x;
505 word_720F70[2 * i] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; 500 word_720F70[2 * i] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y;
506 word_721040[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; 501 word_721040[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x;
507 word_720F70[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; 502 word_720F70[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y;
508 } 503 }
509 }
510 word_721040[2 * pFace->uNumVertices] = word_721040[0]; 504 word_721040[2 * pFace->uNumVertices] = word_721040[0];
511 word_720F70[2 * pFace->uNumVertices] = word_720F70[0]; 505 word_720F70[2 * pFace->uNumVertices] = word_720F70[0];
512 v43 = word_720F70[0] >= Y; 506 v43 = word_720F70[0] >= Y;
513 v48 = 0; 507 v48 = 0;
514 if ( 2 * pFace->uNumVertices > 0 ) 508 if ( 2 * pFace->uNumVertices > 0 )
553 dword_721160[v25] = pBModelNum; 547 dword_721160[v25] = pBModelNum;
554 dword_721110[v25] = pFaceNum; 548 dword_721110[v25] = pFaceNum;
555 } 549 }
556 } 550 }
557 } 551 }
558 ++v39; 552
559 } 553 }
560 } 554 }
561 } 555 }
562 ++v38;
563 } 556 }
564 if ( v46 == 1 ) 557 if ( v46 == 1 )
565 { 558 {
566 *a6 = 0; 559 *a6 = 0;
567 return odm_floor_level[0]; 560 return odm_floor_level[0];
852 if (dz >= dx) 845 if (dz >= dx)
853 { 846 {
854 side1_dy = (double)(x1z1_y - x1z2_y); 847 side1_dy = (double)(x1z1_y - x1z2_y);
855 side2_dy = (double)(x2z2_y - x1z2_y); 848 side2_dy = (double)(x2z2_y - x1z2_y);
856 side2_dx = (double)(grid_pos_x2 - grid_pos_x1); 849 side2_dx = (double)(grid_pos_x2 - grid_pos_x1);
857 side1_dx = (double)(grid_pos_x1 - grid_pos_x1); 850 side1_dx = (double)(grid_pos_x1 - grid_pos_x2);
858 side2_dz = (double)(grid_pos_z2 - grid_pos_z2); // bug? z2 - z2 851 side2_dz = 0.0;//(double)(grid_pos_z2 - grid_pos_z2); // bug? z2 - z2
859 side1_dz = (double)(grid_pos_z2 - grid_pos_z2); // z1 - z2 852 side1_dz = (double)(grid_pos_z1 - grid_pos_z2); // z1 - z2 yes
860 Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__); 853 //Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__);
861 /* |\ 854 /* |\
862 side1 | \ 855 side1 | \
863 |____\ 856 |____\
864 side 2 */ 857 side 2 */
865 } 858 }
866 else 859 else
867 { 860 {
868 side1_dy = (double)(x2z2_y - x2z1_y); 861 side1_dy = (double)(x2z2_y - x2z1_y);
869 side2_dy = (double)(x1z1_y - x2z1_y); 862 side2_dy = (double)(x1z1_y - x2z1_y);
870 side2_dx = (double)(grid_pos_x1 - grid_pos_x2); 863 side2_dx = (double)(grid_pos_x1 - grid_pos_x2);
871 side1_dx = (double)(grid_pos_x2 - grid_pos_x2); 864 side1_dx = (double)(grid_pos_x2 - grid_pos_x1);
872 side2_dz = (double)(grid_pos_z1 - grid_pos_z1); 865 side2_dz = 0.0;//(double)(grid_pos_z1 - grid_pos_z1);
873 side1_dz = (double)(grid_pos_z2 - grid_pos_z1); 866 side1_dz = (double)(grid_pos_z2 - grid_pos_z1);
874 867
875 /* side 2 868 /* side 2
876 _____ 869 _____
877 \ | 870 \ |