Mercurial > mm7
comparison Outdoor.cpp @ 2368:91b6c0a338ad
ODMFace::IsBackfaceCulled to ODMFace::IsBackfaceNotCulled, cleaned up a bit
author | Grumpy7 |
---|---|
date | Mon, 12 May 2014 00:13:39 +0200 |
parents | 7942b5727708 |
children | bddcaf5d5db2 |
comparison
equal
deleted
inserted
replaced
2367:7942b5727708 | 2368:91b6c0a338ad |
---|---|
574 pOutdoor->loc_time.day_fogrange_2 = ::day_fogrange_2; | 574 pOutdoor->loc_time.day_fogrange_2 = ::day_fogrange_2; |
575 pOutdoor->loc_time.day_attrib = ::day_attrib; | 575 pOutdoor->loc_time.day_attrib = ::day_attrib; |
576 } | 576 } |
577 | 577 |
578 //----- (00482170) -------------------------------------------------------- | 578 //----- (00482170) -------------------------------------------------------- |
579 bool ODMFace::IsBackfaceCulled(RenderVertexSoft *a2, struct Polygon *polygon) | 579 bool ODMFace::IsBackfaceNotCulled(RenderVertexSoft *a2, struct Polygon *polygon) |
580 { | 580 { |
581 unsigned int v5; // edx@1 | 581 unsigned int numOfVertices; // edx@1 |
582 RenderVertexSoft *v6; // ecx@2 | 582 RenderVertexSoft *currVertex; // ecx@2 |
583 double v7; // st7@5 | 583 double v7; // st7@5 |
584 double v8; // st6@5 | 584 double v8; // st6@5 |
585 double v9; // st5@5 | 585 double v9; // st5@5 |
586 double v10; // st6@9 | |
587 double v11; // st5@9 | |
588 double v12; // st4@9 | |
589 double v14; // ST2C_8@17 | |
590 double v15; // ST20_8@17 | |
591 double v16; // ST0C_8@17 | |
592 double v17; // ST0C_8@17 | |
593 float v18; // [sp+8h] [bp-38h]@5 | 586 float v18; // [sp+8h] [bp-38h]@5 |
594 float v19; // [sp+10h] [bp-30h]@5 | 587 float v19; // [sp+10h] [bp-30h]@5 |
595 float v20; // [sp+14h] [bp-2Ch]@5 | 588 float v20; // [sp+14h] [bp-2Ch]@5 |
596 float v21; // [sp+18h] [bp-28h]@5 | 589 float v21; // [sp+18h] [bp-28h]@5 |
597 float v22; // [sp+1Ch] [bp-24h]@5 | 590 float v22; // [sp+1Ch] [bp-24h]@5 |
605 float a3b; // [sp+48h] [bp+8h]@17 | 598 float a3b; // [sp+48h] [bp+8h]@17 |
606 float a3c; // [sp+48h] [bp+8h]@17 | 599 float a3c; // [sp+48h] [bp+8h]@17 |
607 float a3d; // [sp+48h] [bp+8h]@17 | 600 float a3d; // [sp+48h] [bp+8h]@17 |
608 float a3e; // [sp+48h] [bp+8h]@17 | 601 float a3e; // [sp+48h] [bp+8h]@17 |
609 | 602 |
610 v5 = polygon->uNumVertices; | 603 numOfVertices = polygon->uNumVertices; |
611 if ( (signed int)v5 < 3 ) | 604 if ( numOfVertices < 3 ) |
612 return false; | 605 return false; |
613 v6 = &a2[v5 - 1]; | 606 currVertex = &a2[numOfVertices - 1]; |
614 if ( a2->vWorldPosition.z == a2[1].vWorldPosition.z && a2[1].vWorldPosition.z == v6->vWorldPosition.z ) | 607 if ( a2->vWorldPosition.z == a2[1].vWorldPosition.z && a2[1].vWorldPosition.z == currVertex->vWorldPosition.z ) |
615 *(int *)&polygon->flags |= 0x10u; | 608 polygon->flags |= 0x10u; |
616 v19 = a2[1].vWorldViewPosition.x - a2->vWorldViewPosition.x; | 609 |
617 v18 = a2[1].vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
618 v20 = a2[1].vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
619 v21 = v6->vWorldViewPosition.x - a2->vWorldViewPosition.x; | |
620 v22 = v6->vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
621 v23 = v6->vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
622 v28 = a2[1].vWorldPosition.x - a2->vWorldPosition.x; | 610 v28 = a2[1].vWorldPosition.x - a2->vWorldPosition.x; |
623 v27 = a2[1].vWorldPosition.y - a2->vWorldPosition.y; | 611 v27 = a2[1].vWorldPosition.y - a2->vWorldPosition.y; |
624 a3a = a2[1].vWorldPosition.z - a2->vWorldPosition.z; | 612 a3a = a2[1].vWorldPosition.z - a2->vWorldPosition.z; |
625 v7 = v6->vWorldPosition.x - a2->vWorldPosition.x; | 613 |
626 v8 = v6->vWorldPosition.y - a2->vWorldPosition.y; | 614 |
627 v9 = v6->vWorldPosition.z - a2->vWorldPosition.z; | 615 for (int i = 0; i < numOfVertices; i++) |
628 v26 = v27 * v9 - v8 * a3a; | 616 { |
629 v24 = v7 * a3a - v9 * v28; | 617 v7 = currVertex->vWorldPosition.x - a2->vWorldPosition.x; |
630 v25 = v8 * v28 - v7 * v27; | 618 v8 = currVertex->vWorldPosition.y - a2->vWorldPosition.y; |
631 if ( v26 == 0.0 && v24 == 0.0 && v25 == 0.0 ) | 619 v9 = currVertex->vWorldPosition.z - a2->vWorldPosition.z; |
632 { | 620 v26 = v27 * v9 - v8 * a3a; |
633 while ( 1 ) | 621 v24 = v7 * a3a - v9 * v28; |
634 { | 622 v25 = v8 * v28 - v7 * v27; |
635 --v5; | 623 if ( v24 != 0.0 || v25 != 0.0 || v26 != 0.0 ) |
636 if ( (signed int)v5 < 2 ) | 624 break; |
637 break; | 625 currVertex--; |
638 v10 = v6->vWorldPosition.x - a2->vWorldPosition.x; | 626 } |
639 v11 = v6->vWorldPosition.y - a2->vWorldPosition.y; | 627 |
640 v12 = v6->vWorldPosition.z - a2->vWorldPosition.z; | |
641 v26 = v27 * v12 - v11 * a3a; | |
642 v24 = v10 * a3a - v12 * v28; | |
643 v25 = v11 * v28 - v10 * v27; | |
644 if ( v26 != 0.0 ) | |
645 break; | |
646 if ( v24 != 0.0 || v25 != 0.0 ) | |
647 break; | |
648 --v6; | |
649 } | |
650 v21 = v6->vWorldViewPosition.x - a2->vWorldViewPosition.x; | |
651 v22 = v6->vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
652 v23 = v6->vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
653 } | |
654 if ( ((double)pGame->pIndoorCameraD3D->vPartyPos.x - a2->vWorldPosition.x) * v26 | 628 if ( ((double)pGame->pIndoorCameraD3D->vPartyPos.x - a2->vWorldPosition.x) * v26 |
655 + ((double)pGame->pIndoorCameraD3D->vPartyPos.z - a2->vWorldPosition.z) * v25 | 629 + ((double)pGame->pIndoorCameraD3D->vPartyPos.z - a2->vWorldPosition.z) * v25 |
656 + ((double)pGame->pIndoorCameraD3D->vPartyPos.y - a2->vWorldPosition.y) * v24 > 0.0 ) | 630 + ((double)pGame->pIndoorCameraD3D->vPartyPos.y - a2->vWorldPosition.y) * v24 > 0.0 ) |
657 { | 631 { |
632 | |
633 v19 = a2[1].vWorldViewPosition.x - a2->vWorldViewPosition.x; | |
634 v18 = a2[1].vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
635 v20 = a2[1].vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
636 v21 = currVertex->vWorldViewPosition.x - a2->vWorldViewPosition.x; | |
637 v22 = currVertex->vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
638 v23 = currVertex->vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
639 | |
658 a3b = v23 * v18 - v22 * v20; | 640 a3b = v23 * v18 - v22 * v20; |
659 v14 = a3b + 6.7553994e15; | 641 polygon->v_18.x = bankersRounding(a3b); |
660 polygon->v_18.x = LODWORD(v14); | |
661 a3c = v21 * v20 - v23 * v19; | 642 a3c = v21 * v20 - v23 * v19; |
662 v15 = a3c + 6.7553994e15; | 643 polygon->v_18.y = bankersRounding(a3c); |
663 polygon->v_18.y = LODWORD(v15); | |
664 a3d = v22 * v19 - v21 * v18; | 644 a3d = v22 * v19 - v21 * v18; |
665 v16 = a3d + 6.7553994e15; | 645 polygon->v_18.z = bankersRounding(a3d); |
666 polygon->v_18.z = LODWORD(v16); | |
667 polygon->_normalize_v_18(); | 646 polygon->_normalize_v_18(); |
668 a3e = -((double)polygon->v_18.x * a2->vWorldViewPosition.x) | 647 a3e = -((double)polygon->v_18.x * a2->vWorldViewPosition.x) |
669 - (double)polygon->v_18.y * a2->vWorldViewPosition.y | 648 - (double)polygon->v_18.y * a2->vWorldViewPosition.y |
670 - (double)polygon->v_18.z * a2->vWorldViewPosition.z; | 649 - (double)polygon->v_18.z * a2->vWorldViewPosition.z; |
671 v17 = a3e + 6.7553994e15; | 650 polygon->field_24 = bankersRounding(a3e); |
672 polygon->field_24 = LODWORD(v17); | |
673 return true; | 651 return true; |
674 } | 652 } |
675 else | 653 else |
676 return false; | 654 return false; |
677 } | 655 } |