comparison Render.cpp @ 1638:ccde94f02b75

class IndoorCamera split into BLVRenderParams and ODMRenderParams
author Nomad
date Tue, 17 Sep 2013 15:40:09 +0200
parents 2c71fa8913d2
children afc1c3514dd5
comparison
equal deleted inserted replaced
1637:2c71fa8913d2 1638:ccde94f02b75
10 #include "stru6.h" 10 #include "stru6.h"
11 #include "GUIWindow.h" 11 #include "GUIWindow.h"
12 #include "DecalBuilder.h" 12 #include "DecalBuilder.h"
13 #include "ParticleEngine.h" 13 #include "ParticleEngine.h"
14 #include "Render.h" 14 #include "Render.h"
15 #include "IndoorCamera.h"
16 #include "Outdoor.h" 15 #include "Outdoor.h"
17 #include "Party.h" 16 #include "Party.h"
18 #include "LOD.h" 17 #include "LOD.h"
19 #include "Viewport.h" 18 #include "Viewport.h"
20 #include "Math.h" 19 #include "Math.h"
515 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); 514 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID);
516 //v5 = v4; 515 //v5 = v4;
517 //v28 = v4; 516 //v28 = v4;
518 v36 = v4->uFlags; 517 v36 = v4->uFlags;
519 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; 518 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier;
520 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); 519 v6 = stru_5C6E00->Atan2(object->vPosition.x - pODMRenderParams->vPartyPos.x, object->vPosition.y - pODMRenderParams->vPartyPos.y);
521 //LOWORD(v7) = object->uFacing; 520 //LOWORD(v7) = object->uFacing;
522 //v8 = v36; 521 //v8 = v36;
523 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; 522 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7;
524 v10 = v4->pHwSpriteIDs[v9]; 523 v10 = v4->pHwSpriteIDs[v9];
525 v3->uHwSpriteID = v10; 524 v3->uHwSpriteID = v10;
541 if ( a6 ) 540 if ( a6 )
542 { 541 {
543 //LOBYTE(v11) = byte_4E94D3; 542 //LOBYTE(v11) = byte_4E94D3;
544 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); 543 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
545 } 544 }
546 v12 = (x - pIndoorCamera->pos.x) << 16; 545 v12 = (x - pODMRenderParams->vPartyPos.x) << 16;
547 if ( pIndoorCamera->sRotationX ) 546 if (pODMRenderParams->rotation_x)
548 { 547 {
549 v13 = (y - pIndoorCamera->pos.y) << 16; 548 v13 = (y - pODMRenderParams->vPartyPos.y) << 16;
550 v30 = ((unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) 549 v30 = ((unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16)
551 + ((unsigned __int64)(v13 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); 550 + ((unsigned __int64)(v13 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16);
552 v37 = (unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; 551 v37 = (unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16;
553 a6a = (unsigned __int64)(v13 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; 552 a6a = (unsigned __int64)(v13 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16;
554 v33 = (z - pIndoorCamera->pos.z) << 16; 553 v33 = (z - pODMRenderParams->vPartyPos.z) << 16;
555 v14 = (unsigned __int64)(v30 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16; 554 v14 = (unsigned __int64)(v30 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16;
556 v15 = (unsigned __int64)(v33 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16; 555 v15 = (unsigned __int64)(v33 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16;
557 v16 = v15 + v14; 556 v16 = v15 + v14;
558 v42 = v15 + v14; 557 v42 = v15 + v14;
559 if ( v15 + v14 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 ) 558 if ( v15 + v14 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 )
565 goto LABEL_29; 564 goto LABEL_29;
566 } 565 }
567 } 566 }
568 else 567 else
569 { 568 {
570 v34 = (y - pIndoorCamera->pos.y) << 16; 569 v34 = (y - pODMRenderParams->vPartyPos.y) << 16;
571 v19 = (unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; 570 v19 = (unsigned __int64)(v12 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16;
572 v20 = (unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; 571 v20 = (unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16;
573 v16 = v20 + v19; 572 v16 = v20 + v19;
574 v42 = v20 + v19; 573 v42 = v20 + v19;
575 if ( v20 + v19 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 ) 574 if ( v20 + v19 >= 262144 && v16 <= pODMRenderParams->shading_dist_mist << 16 )
576 { 575 {
577 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; 576 v21 = (unsigned __int64)(((x - pODMRenderParams->vPartyPos.x) << 16) * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16;
578 v17 = ((unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v21; 577 v17 = ((unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v21;
579 v40 = ((unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v21; 578 v40 = ((unsigned __int64)(v34 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v21;
580 v18 = (z - pIndoorCamera->pos.z) << 16; 579 v18 = (z - pODMRenderParams->vPartyPos.z) << 16;
581 LABEL_29: 580 LABEL_29:
582 v31 = v18; 581 v31 = v18;
583 v22 = abs(v17); 582 v22 = abs(v17);
584 if ( abs(v16) >= v22 ) 583 if ( abs(v16) >= v22 )
585 { 584 {
634 //v0 += 112; 633 //v0 += 112;
635 //} 634 //}
636 //while ( v41 < (signed int)uNumSpriteObjects ); 635 //while ( v41 < (signed int)uNumSpriteObjects );
637 } 636 }
638 } 637 }
639 // 4E94D3: using guessed type char byte_4E94D3;
640 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame;
641 638
642 //----- (0049D9BC) -------------------------------------------------------- 639 //----- (0049D9BC) --------------------------------------------------------
643 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) 640 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut)
644 { 641 {
645 size_t v4; // eax@1 642 size_t v4; // eax@1
997 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); 994 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
998 995
999 //v9 = v8; 996 //v9 = v8;
1000 v42 = v8->uFlags; 997 v42 = v8->uFlags;
1001 a5 = v8->uGlowRadius; 998 a5 = v8->uGlowRadius;
1002 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, 999 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pODMRenderParams->vPartyPos.x,
1003 decor->vPosition.y - pIndoorCamera->pos.y); 1000 decor->vPosition.y - pODMRenderParams->vPartyPos.y);
1004 v11 = *((int *)v0 + 2); 1001 v11 = *((int *)v0 + 2);
1005 v37 = v10; 1002 v37 = v10;
1006 v12 = v42; 1003 v12 = v42;
1007 v38 = 0; 1004 v38 = 0;
1008 v13 = ((signed int)(stru_5C6E00->uIntegerPi 1005 v13 = ((signed int)(stru_5C6E00->uIntegerPi
1041 v14, 1038 v14,
1042 v15, 1039 v15,
1043 v16, 1040 v16,
1044 byte_4E94D0); 1041 byte_4E94D0);
1045 } 1042 }
1046 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; 1043 v17 = (decor->vPosition.x - pODMRenderParams->vPartyPos.x) << 16;
1047 if ( pIndoorCamera->sRotationX ) 1044 if (pODMRenderParams->rotation_x)
1048 { 1045 {
1049 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; 1046 v40 = (decor->vPosition.y - pODMRenderParams->vPartyPos.y) << 16;
1050 v18 = ((unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) 1047 v18 = ((unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16)
1051 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); 1048 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16);
1052 v42 = v18; 1049 v42 = v18;
1053 b = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; 1050 b = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16;
1054 a5 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; 1051 a5 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16;
1055 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; 1052 v40 = (decor->vPosition.z - pODMRenderParams->vPartyPos.z) << 16;
1056 v41 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16; 1053 v41 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16;
1057 v19 = (unsigned __int64)(v18 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16; 1054 v19 = (unsigned __int64)(v18 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16;
1058 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16); 1055 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16);
1059 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16); 1056 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16);
1060 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) 1057 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
1126 goto LABEL_38; 1123 goto LABEL_38;
1127 } 1124 }
1128 } 1125 }
1129 else 1126 else
1130 { 1127 {
1131 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; 1128 v42 = (decor->vPosition.x - pODMRenderParams->vPartyPos.x) << 16;
1132 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; 1129 v40 = (decor->vPosition.y - pODMRenderParams->vPartyPos.y) << 16;
1133 b = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; 1130 b = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16;
1134 a5 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; 1131 a5 = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16;
1135 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); 1132 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16);
1136 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); 1133 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16);
1137 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) 1134 if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
1138 { 1135 {
1139 a5 = (unsigned __int64)(v42 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; 1136 a5 = (unsigned __int64)(v42 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16;
1140 b = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; 1137 b = (unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16;
1141 v21 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - a5; 1138 v21 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - a5;
1142 v41 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - a5; 1139 v41 = ((unsigned __int64)(v40 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - a5;
1143 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; 1140 v22 = (decor->vPosition.z - pODMRenderParams->vPartyPos.z) << 16;
1144 goto LABEL_30; 1141 goto LABEL_30;
1145 } 1142 }
1146 } 1143 }
1147 } 1144 }
1148 } 1145 }
1169 //++v35; 1166 //++v35;
1170 //v0 += 32; 1167 //v0 += 32;
1171 } 1168 }
1172 //while ( v35 < (signed int)uNumLevelDecorations ); 1169 //while ( v35 < (signed int)uNumLevelDecorations );
1173 } 1170 }
1174 // 4E94D0: using guessed type char byte_4E94D0;
1175 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame;
1176 1171
1177 //----- (0049D717) -------------------------------------------------------- 1172 //----- (0049D717) --------------------------------------------------------
1178 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) 1173 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst)
1179 { 1174 {
1180 HRESULT v2; // esi@2 1175 HRESULT v2; // esi@2
4918 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); 4913 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
4919 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); 4914 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8));
4920 } 4915 }
4921 } 4916 }
4922 4917
4923 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) 4918 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES)
4919 if (pODMRenderParams->flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES)
4924 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); 4920 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0);
4925 } 4921 }
4926 // 4A26BC: could not find valid save-restore pair for esi 4922 // 4A26BC: could not find valid save-restore pair for esi
4927 // 4D864C: using guessed type char byte_4D864C; 4923 // 4D864C: using guessed type char byte_4D864C;
4928 4924
5123 v57 = v56; 5119 v57 = v56;
5124 v58 = pFace->GetTexture(); 5120 v58 = pFace->GetTexture();
5125 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); 5121 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
5126 return; 5122 return;
5127 } 5123 }
5128 HIDWORD(v69) = pIndoorCamera->sRotationX; 5124 HIDWORD(v69) = pBLVRenderParams->sPartyRotX;
5129 HIDWORD(v68) = pIndoorCamera->pos.z; 5125 HIDWORD(v68) = pBLVRenderParams->vPartyPos.z;
5130 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; 5126 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
5131 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z) 5127 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z)
5132 / (((double)pBLVRenderParams->field_40 + 16192.0) 5128 / (((double)pBLVRenderParams->field_40 + 16192.0)
5133 * 65536.0) 5129 * 65536.0)
5134 + *(float *)&v74); 5130 + *(float *)&v74);
5135 v5 = (double)pIndoorCamera->sRotationX * 0.0030664064; 5131 v5 = (double)pBLVRenderParams->sPartyRotX * 0.0030664064;
5136 *(float *)&v75 = v5; 5132 *(float *)&v75 = v5;
5137 v80 = cos(v5) * 16192.0; 5133 v80 = cos(v5) * 16192.0;
5138 v6 = (signed __int64)(*(float *)&v74 5134 v6 = (signed __int64)(*(float *)&v74
5139 - (double)pBLVRenderParams->field_40 5135 - (double)pBLVRenderParams->field_40
5140 / ((v80 + 0.0000001) 5136 / ((v80 + 0.0000001)