Mercurial > mm7
diff Engine/Graphics/Render.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 | 407263babde8 |
children | b6140dfeac27 |
line wrap: on
line diff
--- a/Engine/Graphics/Render.cpp Sat May 09 12:55:58 2015 +0200 +++ b/Engine/Graphics/Render.cpp Sun May 10 01:29:11 2015 +0200 @@ -4,9 +4,9 @@ #define _CRT_SECURE_NO_WARNINGS -#include "../ZlibWrapper.h" -#include "../ErrorHandling.h" - +#include "Engine/Engine.h" + +#include "Engine/ZlibWrapper.h" #include "Render.h" #include "Media/MediaPlayer.h" #include "Sprites.h" @@ -17,26 +17,23 @@ #include "DecalBuilder.h" #include "ParticleEngine.h" #include "Outdoor.h" -#include "../Party.h" -#include "../LOD.h" +#include "Engine/Party.h" +#include "Engine/LOD.h" #include "Viewport.h" -#include "../OurMath.h" +#include "Engine/OurMath.h" #include "PaletteManager.h" -#include "../Timer.h" -#include "../Game.h" +#include "Engine/Timer.h" #include "LightmapBuilder.h" -#include "../Objects/ObjectList.h" -#include "../Objects/SpriteObject.h" +#include "Engine/Objects/ObjectList.h" +#include "Engine/Objects/SpriteObject.h" #include "DecorationList.h" -#include "../Objects/Actor.h" -#include "../Log.h" -#include "../MM7.h" +#include "Engine/Objects/Actor.h" #include "Lights.h" #include "Level/Decoration.h" #include "Vis.h" -#include "../Registry.h" +#include "Engine/Registry.h" #include "Weather.h" -#include "../MMT.h" +#include "Engine/MMT.h" //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") @@ -262,12 +259,12 @@ pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; - pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); - pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); + pEngine->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); + pEngine->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); } } //-------(Отсечение невидимой части карты)------------------------------------------------------------------------------------------ - float direction = (float)(pGame->pIndoorCameraD3D->sRotationY / 256);//direction of the camera(напрвление камеры) + float direction = (float)(pEngine->pIndoorCameraD3D->sRotationY / 256);//direction of the camera(напрвление камеры) //0-East(B) //1-NorthEast(CB) //2-North(C) @@ -391,7 +388,7 @@ //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); //__debugbreak(); - pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows + pEngine->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); } unsigned int a5 = 4; @@ -411,7 +408,7 @@ int v33 = 0; static stru154 static_sub_0048034E_stru_154; - pGame->pLightmapBuilder->std__vector_000004_size = 0; + pEngine->pLightmapBuilder->std__vector_000004_size = 0; if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) { if ( neer_clip ) @@ -422,10 +419,10 @@ if ( pDecalBuilder->uNumDecals > 0 ) pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); - } - - if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) + pEngine->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); + } + + if ( !byte_4D864C || ~pEngine->uFlags & 0x80 ) { //if ( neer_clip ) //Ritor1: Даёт искажения на подъёме, возможно требуется ф-ция Безье //{ @@ -607,7 +604,7 @@ //v2 = *((short *)v0 - 14) //v2 = object->uType; if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) - || pGame->pStru6Instance->_4A81CA(object) ) + || pEngine->pStru6Instance->_4A81CA(object) ) { //a5 = *(short *)v0; x = object->vPosition.x; @@ -615,7 +612,7 @@ z = object->vPosition.z; frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); a6 = frame->uGlowRadius * object->field_22_glow_radius_multiplier; - v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); + v6 = stru_5C6E00->Atan2(object->vPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y); //LOWORD(v7) = object->uFacing; //v8 = v36; v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; @@ -640,18 +637,18 @@ //LOBYTE(v11) = _4E94D3_light_type; pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFF, 0xFF, 0xFF, _4E94D3_light_type); } - if (pGame->pIndoorCameraD3D->sRotationX) - { - v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y); - v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y); - v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x) - + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x); + if (pEngine->pIndoorCameraD3D->sRotationX) + { + v30 = fixpoint_mul((x - pEngine->pIndoorCameraD3D->vPartyPos.x) << 16, pEngine->pIndoorCameraD3D->int_cosine_y) + + fixpoint_mul((y - pEngine->pIndoorCameraD3D->vPartyPos.y) << 16, pEngine->pIndoorCameraD3D->int_sine_y); + v37 = fixpoint_mul((x - pEngine->pIndoorCameraD3D->vPartyPos.x) << 16, pEngine->pIndoorCameraD3D->int_sine_y); + v42 = fixpoint_mul((z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, pEngine->pIndoorCameraD3D->int_sine_x) + + fixpoint_mul(v30, pEngine->pIndoorCameraD3D->int_cosine_x); if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) { - v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37; - v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x); + v17 = fixpoint_mul((y - pEngine->pIndoorCameraD3D->vPartyPos.y) << 16, pEngine->pIndoorCameraD3D->int_cosine_y) - v37; + v18 = fixpoint_mul((z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, pEngine->pIndoorCameraD3D->int_cosine_x) + - fixpoint_mul(v30, pEngine->pIndoorCameraD3D->int_sine_x); if ( abs(v42) >= abs(v17) ) { LODWORD(v23) = 0; @@ -692,13 +689,13 @@ } else { - v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y) - + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y); + v42 = fixpoint_mul((y - pEngine->pIndoorCameraD3D->vPartyPos.y) << 16, pEngine->pIndoorCameraD3D->int_sine_y) + + fixpoint_mul((x - pEngine->pIndoorCameraD3D->vPartyPos.x) << 16, pEngine->pIndoorCameraD3D->int_cosine_y); if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) { - v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y); - v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; + v17 = fixpoint_mul((y - pEngine->pIndoorCameraD3D->vPartyPos.y) << 16, pEngine->pIndoorCameraD3D->int_cosine_y) + - fixpoint_mul(((x - pEngine->pIndoorCameraD3D->vPartyPos.x) << 16), pEngine->pIndoorCameraD3D->int_sine_y); + v18 = (z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16; if ( abs(v42) >= abs(v17) ) { LODWORD(v23) = 0; @@ -1028,8 +1025,8 @@ #pragma endregion //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, - pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); + v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x, + pLevelDecorations[i].vPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y); v38 = 0; v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7; v37 = (unsigned __int16 *)v13; @@ -1060,18 +1057,18 @@ frame->uGlowRadius, r, g, b_, _4E94D0_light_type); }//for light - v17 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; - if (pGame->pIndoorCameraD3D->sRotationX) + v17 = (pLevelDecorations[i].vPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x) << 16; + if (pEngine->pIndoorCameraD3D->sRotationX) { - v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; - v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); - v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); - v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); - v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); + v40 = (pLevelDecorations[i].vPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y) << 16; + v18 = fixpoint_mul(v17, pEngine->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pEngine->pIndoorCameraD3D->int_sine_y); + v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, pEngine->pIndoorCameraD3D->int_sine_x); + v19 = fixpoint_mul(v18, pEngine->pIndoorCameraD3D->int_cosine_x); + v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, pEngine->pIndoorCameraD3D->int_sine_x); if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) { - v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); - v22 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_x); + v21 = fixpoint_mul(v40, pEngine->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pEngine->pIndoorCameraD3D->int_sine_y); + v22 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, pEngine->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pEngine->pIndoorCameraD3D->int_sine_x); if ( 2 * abs(v20) >= abs(v21) ) { LODWORD(v24) = 0; @@ -1119,13 +1116,13 @@ } else { - v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; - v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; - v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); + v42 = (pLevelDecorations[i].vPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x) << 16; + v40 = (pLevelDecorations[i].vPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y) << 16; + v20 = fixpoint_mul(v17, pEngine->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pEngine->pIndoorCameraD3D->int_sine_y); if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) { - v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); - v22 = (pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; + v21 = fixpoint_mul(v40, pEngine->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pEngine->pIndoorCameraD3D->int_sine_y); + v22 = (pLevelDecorations[i].vPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16; v42 = v22; if ( 2 * abs(v20) >= abs(v21) ) { @@ -1188,7 +1185,7 @@ local_0.flt_28 = 1.0; local_0.timeToLive = (rand() & 0x80) + 128; local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); - pGame->pParticleEngine->AddParticle(&local_0); + pEngine->pParticleEngine->AddParticle(&local_0); } } } @@ -1989,18 +1986,18 @@ v6 = 0; if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) { - //v54 = pGame->pLightmapBuilder->std__vector_000004_size; - if ( pGame->pLightmapBuilder->std__vector_000004_size) + //v54 = pEngine->pLightmapBuilder->std__vector_000004_size; + if ( pEngine->pLightmapBuilder->std__vector_000004_size) a2 = -1; - pGame->AlterGamma_ODM(a4, &a2); - if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) + pEngine->AlterGamma_ODM(a4, &a2); + if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) { v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); - pGame->pLightmapBuilder->DrawLightmaps(/*v8, 0*/); + pEngine->pLightmapBuilder->DrawLightmaps(/*v8, 0*/); } else { - if ( !pGame->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pGame->uFlags & 2 ) + if ( !pEngine->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pEngine->uFlags & 2 ) { ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); @@ -2018,7 +2015,7 @@ d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); - pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); + pEngine->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); if ( this->bUsingSpecular ) d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x); @@ -2080,7 +2077,7 @@ //v50 = (const char *)v5->pRenderD3D->pDevice; ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); //(*(void (**)(void))(*(int *)v50 + 88))(); - pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); + pEngine->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); for (uint i = 0; i < uNumVertices; ++i) { d3d_vertex_buffer[i].diffuse = a2; @@ -4450,13 +4447,13 @@ if (pRenderD3D) { - pGame->draw_debug_outlines(); + pEngine->draw_debug_outlines(); DoRenderBillboards_D3D(); - pGame->pStru6Instance->RenderSpecialEffects(); + pEngine->pStru6Instance->RenderSpecialEffects(); pRenderD3D->pDevice->EndScene(); } else - pGame->pStru6Instance->RenderSpecialEffects(); + pEngine->pStru6Instance->RenderSpecialEffects(); } //----- (004A2031) -------------------------------------------------------- @@ -4596,18 +4593,18 @@ //v61 = pVertices; - /* v9 = pGame->pLightmapBuilder; + /* v9 = pEngine->pLightmapBuilder; v65 = v9; v10 = v9->std__vector_000004_size;*/ - if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) + if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) { v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); - pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); + pEngine->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); } else { - if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || - byte_4D864C && pGame->uFlags & 2 ) + if (transparent || !pEngine->pLightmapBuilder->std__vector_000004_size || + byte_4D864C && pEngine->uFlags & 2 ) { if (clampAtTextureBorders) this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); @@ -4697,7 +4694,7 @@ //v63 = (const char *)v7->pRenderD3D->pDevice; ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); //(*(void (**)(void))(*(int *)v63 + 88))(); - pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); + pEngine->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); for (uint i = 0; i < uNumVertices; ++i) { d3d_vertex_buffer[i].diffuse = -1; @@ -4748,8 +4745,8 @@ } //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) - if (pGame->pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES) - pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); + if (pEngine->pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES) + pEngine->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); } // 4A26BC: could not find valid save-restore pair for esi // 4D864C: using guessed type char byte_4D864C; @@ -4873,8 +4870,8 @@ //for floor and wall(for example Selesta)------------------- if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) { - int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x; - int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y; + int v69 = (GetTickCount() / 32) - pEngine->pIndoorCameraD3D->vPartyPos.x; + int v55 = (GetTickCount() / 32) + pEngine->pIndoorCameraD3D->vPartyPos.y; for (uint i = 0; i < uNumVertices; ++i) { array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; @@ -4884,16 +4881,16 @@ return; } //--------------------------------------- - v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179 + v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pEngine->pIndoorCameraD3D->vPartyPos.z)//179 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) * 65536.0) + (double)pBLVRenderParams->uViewportCenterY); - v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 + v5 = (double)pEngine->pIndoorCameraD3D->sRotationX * 0.0030664064;//0 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 - (double)pBLVRenderParams->fov_rad_fixpoint / ((cos(v5) * 16192.0 + 0.0000001) * 65535.0) - * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); + * (sin(v5) * -16192.0 - (double)pEngine->pIndoorCameraD3D->vPartyPos.z)); stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); pSkyPolygon.Create_48607B(&stru_8019C8); @@ -4906,9 +4903,9 @@ pSkyPolygon.dimming_level = 0; pSkyPolygon.uNumVertices = uNumVertices; - pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); + pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationX + 16); pSkyPolygon.v_18.y = 0; - pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); + pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationX + 16); memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); pSkyPolygon.field_24 = 0x2000000; @@ -5158,9 +5155,9 @@ int sCorrectedColor = uColor; - if (pGame->pLightmapBuilder->std__vector_000004_size) + if (pEngine->pLightmapBuilder->std__vector_000004_size) sCorrectedColor = -1; - pGame->AlterGamma_BLV(pFace, &sCorrectedColor); + pEngine->AlterGamma_BLV(pFace, &sCorrectedColor); if (pFace->uAttributes & FACE_OUTLINED) { @@ -5170,7 +5167,7 @@ uColor = sCorrectedColor = 0xFF109010; } - if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) + if (byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) { __debugbreak(); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); @@ -5192,11 +5189,11 @@ ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 28)); - pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); + pEngine->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); } else { - if (!pGame->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pGame->uFlags & 2) + if (!pEngine->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pEngine->uFlags & 2) { for (uint i = 0; i < uNumVertices; ++i) { @@ -5237,7 +5234,7 @@ d3d_vertex_buffer, uNumVertices, 28)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); - pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); + pEngine->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); for (uint i = 0; i < uNumVertices; ++i) d3d_vertex_buffer[i].diffuse = sCorrectedColor; @@ -8502,7 +8499,7 @@ { if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) ++v53; - pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); + pEngine->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) { if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) @@ -8511,7 +8508,7 @@ v50 = 1; } else - pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); + pEngine->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); } } if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) @@ -8553,9 +8550,9 @@ }*/ v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; - pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); + pEngine->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); - pGame->pLightmapBuilder->std__vector_000004_size = 0; + pEngine->pLightmapBuilder->std__vector_000004_size = 0; int v31 = 0; if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) { @@ -8569,7 +8566,7 @@ } } if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); + pEngine->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); if ( v50 ) { array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); @@ -8627,16 +8624,16 @@ int v38; // [sp+158h] [bp-Ch]@1 int v39; // [sp+15Ch] [bp-8h]@4 - v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) + v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pEngine->pIndoorCameraD3D->vPartyPos.z) / ((double)pODMRenderParams->int_fov_rad + 8192.0) + (double)(pViewport->uScreenCenterY)); - v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 + v34 = cos((double)pEngine->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) - (double)pODMRenderParams->int_fov_rad / (v34 + 0.0000001) - * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) + * (sin((double)pEngine->pIndoorCameraD3D->sRotationX * 0.0030664064) * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist - - (double)pGame->pIndoorCameraD3D->vPartyPos.z)); + - (double)pEngine->pIndoorCameraD3D->vPartyPos.z)); pSkyPolygon.Create_48607B(&stru_8019C8);//заполняется ptr_38 pSkyPolygon.ptr_38->_48694B_frustum_sky(); @@ -8650,9 +8647,9 @@ pSkyPolygon.dimming_level = 0; pSkyPolygon.uNumVertices = 4; //centering(центруем)----------------------------------------------------------------- - pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16); + pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationX + 16); pSkyPolygon.v_18.y = 0; - pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16); + pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationX + 16); //sky wiew position(положение неба на экране)------------------------------------------ // X @@ -8748,13 +8745,13 @@ //----- (004226C2) -------------------------------------------------------- bool PauseGameDrawing() { - if ( pCurrentScreen != SCREEN_GAME - && pCurrentScreen != SCREEN_NPC_DIALOGUE - && pCurrentScreen != SCREEN_CHANGE_LOCATION ) - { - if (pCurrentScreen == SCREEN_INPUT_BLV) + if ( current_screen_type != SCREEN_GAME + && current_screen_type != SCREEN_NPC_DIALOGUE + && current_screen_type != SCREEN_CHANGE_LOCATION ) + { + if (current_screen_type == SCREEN_INPUT_BLV) return pMovie_Track;//pSmackerMovie != 0; - if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) + if ( current_screen_type != SCREEN_BRANCHLESS_NPC_DIALOG ) return true; } return false; @@ -8863,7 +8860,7 @@ && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) { - if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) + if ( pEngine->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) { if ( mon_num < 100 ) { @@ -8891,7 +8888,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); - ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); + ErrD3D(pRenderD3D->pDevice->SetTexture(0, pEngine->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); } @@ -8921,7 +8918,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); - ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); + ErrD3D(pRenderD3D->pDevice->SetTexture(0, pEngine->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); } @@ -9012,7 +9009,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); - ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); + ErrD3D(pRenderD3D->pDevice->SetTexture(0, pEngine->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); } @@ -9067,10 +9064,10 @@ float v15; if (fabs(z_bias) < 1e-5) - v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); + v15 = 1.0 - 1.0 / ((1.0f / pEngine->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); else { - v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; + v15 = 1.0 - 1.0 / ((1.0f / pEngine->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; if (v15 < 0.000099999997) v15 = 0.000099999997; } @@ -10516,13 +10513,13 @@ int angle; // [sp+24h] [bp-8h]@1 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2; - v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x; - v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y; - stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX); - v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY); - if (pGame->pIndoorCameraD3D->sRotationX) - v17 = fixpoint_mul(v17, stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX)); - v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY); + v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pEngine->pIndoorCameraD3D->vPartyPos.x; + v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pEngine->pIndoorCameraD3D->vPartyPos.y; + stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationX); + v17 = v3 * stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationY); + if (pEngine->pIndoorCameraD3D->sRotationX) + v17 = fixpoint_mul(v17, stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationX)); + v19 = v4 * stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationY); v9 = int_get_vector_length(abs(v3), abs(v4), 0); //v10 = v14 * 188; //v22 = v9; @@ -11119,29 +11116,29 @@ int v25; // [sp+18h] [bp-10h]@1 int v27; // [sp+24h] [bp-4h]@1 - v25 = pGame->pIndoorCameraD3D->int_cosine_x; - v7 = pGame->pIndoorCameraD3D->int_sine_y; - v27 = pGame->pIndoorCameraD3D->int_sine_x; + v25 = pEngine->pIndoorCameraD3D->int_cosine_x; + v7 = pEngine->pIndoorCameraD3D->int_sine_y; + v27 = pEngine->pIndoorCameraD3D->int_sine_x; //v8 = -pIndoorCamera->pos.y; - v9 = pGame->pIndoorCameraD3D->int_cosine_y; + v9 = pEngine->pIndoorCameraD3D->int_cosine_y; //v26 = -pIndoorCamera->pos.z; - v11 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.x + pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.y; - v24 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.y - pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.x; - if (pGame->pIndoorCameraD3D->sRotationX) + v11 = pEngine->pIndoorCameraD3D->int_cosine_y * -pEngine->pIndoorCameraD3D->vPartyPos.x + pEngine->pIndoorCameraD3D->int_sine_y * -pEngine->pIndoorCameraD3D->vPartyPos.y; + v24 = pEngine->pIndoorCameraD3D->int_cosine_y * -pEngine->pIndoorCameraD3D->vPartyPos.y - pEngine->pIndoorCameraD3D->int_sine_y * -pEngine->pIndoorCameraD3D->vPartyPos.x; + if (pEngine->pIndoorCameraD3D->sRotationX) { - this->field_0_party_dir_x = fixpoint_mul(v11, pGame->pIndoorCameraD3D->int_cosine_x) + - fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); + this->field_0_party_dir_x = fixpoint_mul(v11, pEngine->pIndoorCameraD3D->int_cosine_x) + + fixpoint_mul((-pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, pEngine->pIndoorCameraD3D->int_sine_x); this->field_4_party_dir_y = v24; - this->field_8_party_dir_z = fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27); + this->field_8_party_dir_z = fixpoint_mul((-pEngine->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27); } else { this->field_0_party_dir_x = v11; this->field_4_party_dir_y = v24; - this->field_8_party_dir_z = (-pGame->pIndoorCameraD3D->vPartyPos.z) << 16; + this->field_8_party_dir_z = (-pEngine->pIndoorCameraD3D->vPartyPos.z) << 16; } - if (pGame->pIndoorCameraD3D->sRotationX) + if (pEngine->pIndoorCameraD3D->sRotationX) { v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); @@ -11156,7 +11153,7 @@ this->viewing_angle_from_west_east = a4; } - if (pGame->pIndoorCameraD3D->sRotationX) + if (pEngine->pIndoorCameraD3D->sRotationX) { v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);