comparison Engine/Graphics/Vis.cpp @ 2541:a902abdfc7f2

1. Renamed class Game to class Engine. 2. Separated game logic as state of FSM from game logic as engine. 3. Found out that many UI screen initializers were optimized away, intially they all returned newly created window as separate object like it is done in CharacterUI_Initialize.
author a.parshin
date Sun, 10 May 2015 01:29:11 +0200
parents 68cdef6879a0
children b6140dfeac27
comparison
equal deleted inserted replaced
2540:abc6a9d079b9 2541:a902abdfc7f2
1 #define _CRTDBG_MAP_ALLOC 1 #define _CRTDBG_MAP_ALLOC
2 #include <stdlib.h> 2 #include <stdlib.h>
3 #include <crtdbg.h> 3 #include <crtdbg.h>
4 4
5 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6
7 #include "Engine/Engine.h"
8
6 #include "Vis.h" 9 #include "Vis.h"
7 #include "Sprites.h" 10 #include "Sprites.h"
8 #include "../Lod.h" 11 #include "../Lod.h"
9 #include "Outdoor.h" 12 #include "Outdoor.h"
10 #include "../Game.h" 13 #include "Engine/Objects/Actor.h"
11 #include "../Objects/Actor.h"
12 #include "Viewport.h" 14 #include "Viewport.h"
13 #include "../OurMath.h" 15 #include "Engine/OurMath.h"
14 #include "../Log.h"
15 #include "../ErrorHandling.h"
16
17 #include "../MM7.h"
18 #include "Level/Decoration.h" 16 #include "Level/Decoration.h"
19 17
20 18
21 static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8; 19 static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8;
22 20
72 static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z; 70 static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z;
73 } 71 }
74 } 72 }
75 else assert(false); 73 else assert(false);
76 74
77 pGame->pIndoorCameraD3D->ViewTransform(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices); 75 pEngine->pIndoorCameraD3D->ViewTransform(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices);
78 pGame->pIndoorCameraD3D->Project(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, 1); 76 pEngine->pIndoorCameraD3D->Project(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, 1);
79 77
80 SortVectors_x(static_DetermineFacetIntersection_array_F8F200, 0, face->uNumVertices - 1); 78 SortVectors_x(static_DetermineFacetIntersection_array_F8F200, 0, face->uNumVertices - 1);
81 if (static_DetermineFacetIntersection_array_F8F200[0].vWorldViewPosition.x > pick_depth) 79 if (static_DetermineFacetIntersection_array_F8F200[0].vWorldViewPosition.x > pick_depth)
82 return nullptr; 80 return nullptr;
83 81
294 if ( pFaceID < (signed int)pIndoor->uNumFaces ) 292 if ( pFaceID < (signed int)pIndoor->uNumFaces )
295 { 293 {
296 BLVFace* face = &pIndoor->pFaces[pFaceID]; 294 BLVFace* face = &pIndoor->pFaces[pFaceID];
297 if ( is_part_of_selection(face, filter) ) 295 if ( is_part_of_selection(face, filter) )
298 { 296 {
299 if ( !pGame->pIndoorCameraD3D->IsCulled(face) ) 297 if ( !pEngine->pIndoorCameraD3D->IsCulled(face) )
300 { 298 {
301 if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, face, 0xFFFFFFFFu) ) 299 if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, face, 0xFFFFFFFFu) )
302 { 300 {
303 pGame->pIndoorCameraD3D->ViewTransform(&a1, 1); 301 pEngine->pIndoorCameraD3D->ViewTransform(&a1, 1);
304 v9 = fixpoint_from_float(/*v8, */a1.vWorldViewPosition.x); 302 v9 = fixpoint_from_float(/*v8, */a1.vWorldViewPosition.x);
305 LOWORD(v9) = 0; 303 LOWORD(v9) = 0;
306 v15 = (void *)((PID(OBJECT_BModel,pFaceID)) + v9); 304 v15 = (void *)((PID(OBJECT_BModel,pFaceID)) + v9);
307 pNumPointers = &list->uNumPointers; 305 pNumPointers = &list->uNumPointers;
308 v12 = &list->object_pool[list->uNumPointers]; 306 v12 = &list->object_pool[list->uNumPointers];
350 blv_face.FromODM(face); 348 blv_face.FromODM(face);
351 349
352 RenderVertexSoft intersection; 350 RenderVertexSoft intersection;
353 if (Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &intersection, &blv_face, i)) 351 if (Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &intersection, &blv_face, i))
354 { 352 {
355 pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1); 353 pEngine->pIndoorCameraD3D->ViewTransform(&intersection, 1);
356 int v13 = fixpoint_from_float(/*v12, */intersection.vWorldViewPosition.x); 354 int v13 = fixpoint_from_float(/*v12, */intersection.vWorldViewPosition.x);
357 v13 &= 0xFFFF0000; 355 v13 &= 0xFFFF0000;
358 v13 += PID(OBJECT_BModel, j | (i << 6)); 356 v13 += PID(OBJECT_BModel, j | (i << 6));
359 357
360 list->AddObject(face, VisObjectType_Face, v13); 358 list->AddObject(face, VisObjectType_Face, v13);
777 int v3; // [sp-4h] [bp-8h]@5 775 int v3; // [sp-4h] [bp-8h]@5
778 776
779 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 777 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
780 { 778 {
781 //if ( pRenderer->pRenderD3D ) 779 //if ( pRenderer->pRenderD3D )
782 v3 = pGame->pIndoorCameraD3D->fov; 780 v3 = pEngine->pIndoorCameraD3D->fov;
783 //else 781 //else
784 // v3 = pIndoorCamera->fov_rad; 782 // v3 = pIndoorCamera->fov_rad;
785 } 783 }
786 else 784 else
787 { 785 {
796 int v3; // [sp-4h] [bp-8h]@5 794 int v3; // [sp-4h] [bp-8h]@5
797 795
798 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 796 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
799 { 797 {
800 //if ( pRenderer->pRenderD3D ) 798 //if ( pRenderer->pRenderD3D )
801 v3 = pGame->pIndoorCameraD3D->fov; 799 v3 = pEngine->pIndoorCameraD3D->fov;
802 //else 800 //else
803 // v3 = pIndoorCamera->fov_rad; 801 // v3 = pIndoorCamera->fov_rad;
804 } 802 }
805 else 803 else
806 { 804 {
819 RenderVertexSoft v11[2]; // [sp+2Ch] [bp-74h]@1 817 RenderVertexSoft v11[2]; // [sp+2Ch] [bp-74h]@1
820 int outx; 818 int outx;
821 int outz; // [sp+94h] [bp-Ch]@1 819 int outz; // [sp+94h] [bp-Ch]@1
822 int outy; // [sp+98h] [bp-8h]@1 820 int outy; // [sp+98h] [bp-8h]@1
823 821
824 pRotY = pGame->pIndoorCameraD3D->sRotationY + UnprojectX(fMouseX); 822 pRotY = pEngine->pIndoorCameraD3D->sRotationY + UnprojectX(fMouseX);
825 pRotX = pGame->pIndoorCameraD3D->sRotationX + UnprojectY(fMouseY); 823 pRotX = pEngine->pIndoorCameraD3D->sRotationX + UnprojectY(fMouseY);
826 824
827 pStartR.z = pGame->pIndoorCameraD3D->vPartyPos.z; 825 pStartR.z = pEngine->pIndoorCameraD3D->vPartyPos.z;
828 pStartR.x = pGame->pIndoorCameraD3D->vPartyPos.x; 826 pStartR.x = pEngine->pIndoorCameraD3D->vPartyPos.x;
829 pStartR.y = pGame->pIndoorCameraD3D->vPartyPos.y; 827 pStartR.y = pEngine->pIndoorCameraD3D->vPartyPos.y;
830 828
831 v11[1].vWorldPosition.x = (double)pGame->pIndoorCameraD3D->vPartyPos.x; 829 v11[1].vWorldPosition.x = (double)pEngine->pIndoorCameraD3D->vPartyPos.x;
832 v11[1].vWorldPosition.y = (double)pGame->pIndoorCameraD3D->vPartyPos.y; 830 v11[1].vWorldPosition.y = (double)pEngine->pIndoorCameraD3D->vPartyPos.y;
833 v11[1].vWorldPosition.z = (double)pGame->pIndoorCameraD3D->vPartyPos.z; 831 v11[1].vWorldPosition.z = (double)pEngine->pIndoorCameraD3D->vPartyPos.z;
834 832
835 pDepth = fixpoint_from_float(fPickDepth); 833 pDepth = fixpoint_from_float(fPickDepth);
836 Vec3_int_::Rotate(pDepth, pRotY, pRotX, pStartR, &outx, &outy, &outz); 834 Vec3_int_::Rotate(pDepth, pRotY, pRotX, pStartR, &outx, &outy, &outz);
837 835
838 v11[0].vWorldPosition.x = (double)outx; 836 v11[0].vWorldPosition.x = (double)outx;
1509 if ( pFaceID >= 0 ) 1507 if ( pFaceID >= 0 )
1510 { 1508 {
1511 if ( pFaceID < (signed int)pIndoor->uNumFaces ) 1509 if ( pFaceID < (signed int)pIndoor->uNumFaces )
1512 { 1510 {
1513 pFace = &pIndoor->pFaces[pFaceID]; 1511 pFace = &pIndoor->pFaces[pFaceID];
1514 if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[pFaceID]) ) 1512 if ( !pEngine->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[pFaceID]) )
1515 { 1513 {
1516 if ( is_part_of_selection(pFace, filter) ) 1514 if ( is_part_of_selection(pFace, filter) )
1517 { 1515 {
1518 v8 = DetermineFacetIntersection(pFace, PID(OBJECT_BModel, pFaceID), pick_depth); 1516 v8 = DetermineFacetIntersection(pFace, PID(OBJECT_BModel, pFaceID), pick_depth);
1519 if ( v8 ) 1517 if ( v8 )