comparison Render.cpp @ 1982:2647e2f820a6

Слияние
author Ritor1
date Fri, 01 Nov 2013 14:44:06 +0600
parents d9ea00250e2e c1c74df0a33e
children 5cd26f2c6904
comparison
equal deleted inserted replaced
1981:d9ea00250e2e 1982:2647e2f820a6
145 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; 145 soft_billboard.uViewportW = pBLVRenderParams->uViewportW;
146 146
147 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; 147 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw;
148 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) 148 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i)
149 { 149 {
150 auto p = pBillboardRenderList + i; 150 RenderBillboard* p = &pBillboardRenderList[i];
151 151
152 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; 152 soft_billboard.uScreenSpaceX = p->uScreenSpaceX;
153 soft_billboard.uParentBillboardID = i; 153 soft_billboard.uParentBillboardID = i;
154 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; 154 soft_billboard.uScreenSpaceY = p->uScreenSpaceY;
155 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; 155 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat;
297 //shading ()---------------------------------------------------------------------------- 297 //shading ()----------------------------------------------------------------------------
298 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; 298 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1];
299 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; 299 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2];
300 assert(norm_idx < uNumTerrainNormals); 300 assert(norm_idx < uNumTerrainNormals);
301 301
302 auto norm = pTerrainNormals + norm_idx; 302 Vec3_float_* norm = &pTerrainNormals[norm_idx];
303 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - 303 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
304 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - 304 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
305 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); 305 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
306 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); 306 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
307 //----------------------------------------------------------------------------------------------- 307 //-----------------------------------------------------------------------------------------------
388 billboard.uViewportW = pViewport->uViewportBR_Y; 388 billboard.uViewportW = pViewport->uViewportBR_Y;
389 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; 389 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw;
390 390
391 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) 391 for (int i = 0; i < ::uNumBillboardsToDraw; ++i)
392 { 392 {
393 auto pBillboard = pBillboardRenderList + i; 393 RenderBillboard* pBillboard = &pBillboardRenderList[i];
394 394
395 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; 395 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX;
396 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; 396 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY;
397 billboard.uParentBillboardID = i; 397 billboard.uParentBillboardID = i;
398 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; 398 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat;
487 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 487 signed __int16 v46; // [sp+3Ch] [bp-4h]@12
488 488
489 //v41 = 0; 489 //v41 = 0;
490 for (int i = 0; i < uNumSpriteObjects; ++i) 490 for (int i = 0; i < uNumSpriteObjects; ++i)
491 { 491 {
492 auto object = &pSpriteObjects[i]; 492 SpriteObject* object = &pSpriteObjects[i];
493 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; 493 //auto v0 = (char *)&pSpriteObjects[i].uSectorID;
494 //v0 = (char *)&pSpriteObjects[0].uSectorID; 494 //v0 = (char *)&pSpriteObjects[0].uSectorID;
495 //do 495 //do
496 //{ 496 //{
497 if (!object->uObjectDescID) // item probably pciked up 497 if (!object->uObjectDescID) // item probably pciked up
498 continue; 498 continue;
499 499
500 assert(object->uObjectDescID < pObjectList->uNumObjects); 500 assert(object->uObjectDescID < pObjectList->uNumObjects);
501 auto object_desc = pObjectList->pObjects + object->uObjectDescID; 501 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID];
502 if (object_desc->NoSprite()) 502 if (object_desc->NoSprite())
503 continue; 503 continue;
504 504
505 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; 505 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)];
506 //if ( !(v1->uFlags & 1) ) 506 //if ( !(v1->uFlags & 1) )
906 //{ 906 //{
907 //v0 = (char *)&pLevelDecorations[0].vPosition.y; 907 //v0 = (char *)&pLevelDecorations[0].vPosition.y;
908 //do 908 //do
909 for (int i = 0; i < uNumLevelDecorations; ++i) 909 for (int i = 0; i < uNumLevelDecorations; ++i)
910 { 910 {
911 auto decor = &pLevelDecorations[i]; 911 LevelDecoration* decor = &pLevelDecorations[i];
912 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; 912 char* v0 = (char *)&pLevelDecorations[i].vPosition.y;
913 913
914 if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) 914 if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE))
915 { 915 {
916 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; 916 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID];
917 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; 917 DecorationDesc* decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID;
918 v2 = decor_desc->uFlags; 918 v2 = decor_desc->uFlags;
919 if ( (char)v2 >= 0 ) 919 if ( (char)v2 >= 0 )
920 { 920 {
921 if ( !(v2 & 0x22) ) 921 if ( !(v2 & 0x22) )
922 { 922 {
2111 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); 2111 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0);
2112 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); 2112 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1);
2113 2113
2114 this->bTinting = bTinting; 2114 this->bTinting = bTinting;
2115 2115
2116 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); 2116 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl");
2117 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); 2117 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl");
2118 2118
2119 return r1 && r2; 2119 return r1 && r2;
2120 } 2120 }
2121 2121
2122 //----- (0049EBF1) -------------------------------------------------------- 2122 //----- (0049EBF1) --------------------------------------------------------
2947 Render *v2; // esi@1 2947 Render *v2; // esi@1
2948 IDirectDrawSurface4 *v3; // eax@6 2948 IDirectDrawSurface4 *v3; // eax@6
2949 IDirectDrawSurface4 *v4; // ST0C_4@6 2949 IDirectDrawSurface4 *v4; // ST0C_4@6
2950 RECT v5; // [sp+8h] [bp-10h]@6 2950 RECT v5; // [sp+8h] [bp-10h]@6
2951 2951
2952 auto a1 = this; 2952 Render* a1 = this;
2953 v2 = a1; 2953 v2 = a1;
2954 if ( a1->pRenderD3D ) 2954 if ( a1->pRenderD3D )
2955 { 2955 {
2956 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) 2956 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST)
2957 pFrontBuffer4->Restore(); 2957 pFrontBuffer4->Restore();
4300 IDirectDrawSurface *pFront; // eax@3 4300 IDirectDrawSurface *pFront; // eax@3
4301 HRESULT v2; // eax@5 4301 HRESULT v2; // eax@5
4302 signed int v3; // [sp-8h] [bp-Ch]@3 4302 signed int v3; // [sp-8h] [bp-Ch]@3
4303 int v4; // [sp-4h] [bp-8h]@3 4303 int v4; // [sp-4h] [bp-8h]@3
4304 4304
4305 auto a5 = this; 4305 Render* a5 = this;
4306 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) 4306 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
4307 { 4307 {
4308 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; 4308 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4;
4309 v4 = 0; 4309 v4 = 0;
4310 v3 = 2615; 4310 v3 = 2615;
5436 //auto a3 = pFace; 5436 //auto a3 = pFace;
5437 //auto a6 = uPackedID; 5437 //auto a6 = uPackedID;
5438 //v59 = pGame->pLightmapBuilder; 5438 //v59 = pGame->pLightmapBuilder;
5439 //v9 = v59->std__vector_000004_size; 5439 //v9 = v59->std__vector_000004_size;
5440 5440
5441 auto uCorrectedColor = uColor; 5441 uint uCorrectedColor = uColor;
5442 if (pGame->pLightmapBuilder->std__vector_000004_size) 5442 if (pGame->pLightmapBuilder->std__vector_000004_size)
5443 uCorrectedColor = 0xFFFFFFFF; 5443 uCorrectedColor = 0xFFFFFFFF;
5444 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); 5444 pGame->AlterGamma_BLV(pFace, &uCorrectedColor);
5445 5445
5446 5446
6392 unsigned __int16 *v14; // eax@19 6392 unsigned __int16 *v14; // eax@19
6393 DWORD v15; // edx@20 6393 DWORD v15; // edx@20
6394 HRESULT v16; // eax@23 6394 HRESULT v16; // eax@23
6395 stru350 Dst; // [sp+Ch] [bp-F8h]@12 6395 stru350 Dst; // [sp+Ch] [bp-F8h]@12
6396 6396
6397 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); 6397 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
6398 if ( pHWLTexture ) 6398 if ( pHWLTexture )
6399 { 6399 {
6400 bMipMaps = !strncmp(pName, "HDWTR", 5); 6400 bMipMaps = !strncmp(pName, "HDWTR", 5);
6401 if ( !pRenderD3D->CreateTexture( 6401 if ( !pRenderD3D->CreateTexture(
6402 pHWLTexture->uWidth, 6402 pHWLTexture->uWidth,
6653 double v39; // [sp+94h] [bp-Ch]@6 6653 double v39; // [sp+94h] [bp-Ch]@6
6654 float v40; // [sp+9Ch] [bp-4h]@6 6654 float v40; // [sp+9Ch] [bp-4h]@6
6655 6655
6656 __debugbreak(); 6656 __debugbreak();
6657 6657
6658 auto ecx0 = this; 6658 Render* ecx0 = this;
6659 v3 = 0; 6659 v3 = 0;
6660 6660
6661 if (!this->pRenderD3D) 6661 if (!this->pRenderD3D)
6662 __debugbreak(); // sw render 6662 __debugbreak(); // sw render
6663 6663
7170 return; 7170 return;
7171 7171
7172 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; 7172 unsigned __int32 twoColors = (uColor16 << 16) | uColor16;
7173 for (uint y = 0; y < uHeight; ++y) 7173 for (uint y = 0; y < uHeight; ++y)
7174 { 7174 {
7175 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; 7175 ushort* pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch];
7176 7176
7177 memset32(pDst, twoColors, uWidth / 2); 7177 memset32(pDst, twoColors, uWidth / 2);
7178 if (uWidth & 1) 7178 if (uWidth & 1)
7179 pDst[uWidth - 1] = uColor16; 7179 pDst[uWidth - 1] = uColor16;
7180 } 7180 }
7315 int v27; // [sp+1Ch] [bp+Ch]@33 7315 int v27; // [sp+1Ch] [bp+Ch]@33
7316 unsigned int v28; // [sp+20h] [bp+10h]@30 7316 unsigned int v28; // [sp+20h] [bp+10h]@30
7317 unsigned int v29; // [sp+24h] [bp+14h]@22 7317 unsigned int v29; // [sp+24h] [bp+14h]@22
7318 unsigned int v30; // [sp+24h] [bp+14h]@31 7318 unsigned int v30; // [sp+24h] [bp+14h]@31
7319 7319
7320 auto a2 = x; 7320 int a2 = x;
7321 auto a3 = y; 7321 int a3 = y;
7322 auto a6 = uFontHeight; 7322 uint a6 = uFontHeight;
7323 if ( this->uNumSceneBegins ) 7323 if ( this->uNumSceneBegins )
7324 { 7324 {
7325 v8 = a5; 7325 v8 = a5;
7326 v9 = a6; 7326 v9 = a6;
7327 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; 7327 v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
8432 //v5 = 0, pDesta = uNumItems; 8432 //v5 = 0, pDesta = uNumItems;
8433 uint idx1 = 0, 8433 uint idx1 = 0,
8434 idx2 = uNumItems; 8434 idx2 = uNumItems;
8435 while (true) 8435 while (true)
8436 { 8436 {
8437 auto i = idx1 + (idx2 - idx1) / 2; 8437 uint i = idx1 + (idx2 - idx1) / 2;
8438 8438
8439 auto res = _stricmp(pName, pSpriteNames[i]); 8439 int res = _stricmp(pName, pSpriteNames[i]);
8440 if (!res) 8440 if (!res)
8441 { 8441 {
8442 fseek(pFile, pSpriteOffsets[i], SEEK_SET); 8442 fseek(pFile, pSpriteOffsets[i], SEEK_SET);
8443 break; 8443 break;
8444 } 8444 }
8453 8453
8454 8454
8455 uint uCompressedSize = 0; 8455 uint uCompressedSize = 0;
8456 fread(&uCompressedSize, 4, 1, pFile); 8456 fread(&uCompressedSize, 4, 1, pFile);
8457 8457
8458 auto pTex = new HWLTexture; 8458 HWLTexture* pTex = new HWLTexture;
8459 fread(&pTex->uBufferWidth, 4, 1, pFile); 8459 fread(&pTex->uBufferWidth, 4, 1, pFile);
8460 fread(&pTex->uBufferHeight, 4, 1, pFile); 8460 fread(&pTex->uBufferHeight, 4, 1, pFile);
8461 fread(&pTex->uAreaWidth, 4, 1, pFile); 8461 fread(&pTex->uAreaWidth, 4, 1, pFile);
8462 fread(&pTex->uAreaHeigth, 4, 1, pFile); 8462 fread(&pTex->uAreaHeigth, 4, 1, pFile);
8463 fread(&pTex->uWidth, 4, 1, pFile); 8463 fread(&pTex->uWidth, 4, 1, pFile);
8466 fread(&pTex->uAreaY, 4, 1, pFile); 8466 fread(&pTex->uAreaY, 4, 1, pFile);
8467 8467
8468 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; 8468 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight];
8469 if (uCompressedSize) 8469 if (uCompressedSize)
8470 { 8470 {
8471 auto pCompressedData = new char[uCompressedSize]; 8471 char* pCompressedData = new char[uCompressedSize];
8472 { 8472 {
8473 fread(pCompressedData, 1, uCompressedSize, pFile); 8473 fread(pCompressedData, 1, uCompressedSize, pFile);
8474 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); 8474 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short);
8475 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); 8475 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize);
8476 } 8476 }
8477 delete [] pCompressedData; 8477 delete [] pCompressedData;
8478 } 8478 }
8479 else 8479 else
8642 8642
8643 }*/ 8643 }*/
8644 8644
8645 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) 8645 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i)
8646 { 8646 {
8647 auto p = &pRenderer->pBillboardRenderListD3D[i]; 8647 RenderBillboardD3D* p = &pRenderer->pBillboardRenderListD3D[i];
8648 8648
8649 if (p->uOpacity != RenderBillboardD3D::NoBlend) 8649 if (p->uOpacity != RenderBillboardD3D::NoBlend)
8650 SetBillboardBlendOptions(p->uOpacity); 8650 SetBillboardBlendOptions(p->uOpacity);
8651 8651
8652 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); 8652 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture);