comparison mm7_3.cpp @ 638:ccf8b4815a1f

GetActorTintColor fixed Outdoor sunlight works on terrain & bmodels (not sure about billboards though)
author Nomad
date Mon, 11 Mar 2013 21:43:26 +0200
parents f6aeea3eb893
children 1ff57450f090
comparison
equal deleted inserted replaced
637:d7b14091e434 638:ccf8b4815a1f
4845 v52 = pFace->pFacePlane.vNormal.z; 4845 v52 = pFace->pFacePlane.vNormal.z;
4846 v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)v52) >> 16; 4846 v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)v52) >> 16;
4847 pLightmapBuilder = (LightmapBuilder *)(v51 + v53 + v52); 4847 pLightmapBuilder = (LightmapBuilder *)(v51 + v53 + v52);
4848 v51 = 20 * (int)pLightmapBuilder; 4848 v51 = 20 * (int)pLightmapBuilder;
4849 result = 20 - (20 * (signed int)pLightmapBuilder >> 16); 4849 result = 20 - (20 * (signed int)pLightmapBuilder >> 16);
4850 v7->field_58 = result; 4850 v7->dimming_level = result;
4851 if ( result < 0 ) 4851 if ( result < 0 )
4852 v7->field_58 = 0; 4852 v7->dimming_level = 0;
4853 if ( v7->field_58 > 31 ) 4853 if ( v7->dimming_level > 31 )
4854 v7->field_58 = 31; 4854 v7->dimming_level = 31;
4855 if ( pOutdoorCamera->numStru148s >= 1999 + 5000) 4855 if ( pOutdoorCamera->numStru148s >= 1999 + 5000)
4856 return result; 4856 return result;
4857 ++pOutdoorCamera->numStru148s; 4857 ++pOutdoorCamera->numStru148s;
4858 ++pOutdoorCamera->field_44; 4858 ++pOutdoorCamera->field_44;
4859 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) ) 4859 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) )
4910 v40 = -1; 4910 v40 = -1;
4911 v39 = v31; 4911 v39 = v31;
4912 v38 = 0; 4912 v38 = 0;
4913 v37 = array_50AC10; 4913 v37 = array_50AC10;
4914 v36 = uNumVertices; 4914 v36 = uNumVertices;
4915 pDecalBuilder->ApplyDecals( 4915 pDecalBuilder->ApplyDecals(31 - v7->dimming_level,
4916 31 - v7->field_58,
4917 2, 4916 2,
4918 &static_RenderBuildingsD3D_stru_73C834, 4917 &static_RenderBuildingsD3D_stru_73C834,
4919 uNumVertices, 4918 uNumVertices,
4920 array_50AC10, 4919 array_50AC10,
4921 0, 4920 0,
5168 if ( v13 < 0.0 ) 5167 if ( v13 < 0.0 )
5169 v13 = 0.0; 5168 v13 = 0.0;
5170 *(float *)&v84 = v13 * 31.0; 5169 *(float *)&v84 = v13 * 31.0;
5171 v14 = *(float *)&v84 + 6.7553994e15; 5170 v14 = *(float *)&v84 + 6.7553994e15;
5172 v71 = LODWORD(v14); 5171 v71 = LODWORD(v14);
5173 v15 = (int)&v12->field_58; 5172 v15 = (int)&v12->dimming_level;
5174 v12->field_58 = 31 - LOBYTE(v14); 5173 v12->dimming_level = 31 - LOBYTE(v14);
5175 if ( (char)(31 - LOBYTE(v14)) < 0 ) 5174 if ( (char)(31 - LOBYTE(v14)) < 0 )
5176 *(char *)v15 = 0; 5175 *(char *)v15 = 0;
5177 if ( *(char *)v15 > 31 ) 5176 if ( *(char *)v15 > 31 )
5178 *(char *)v15 = 31; 5177 *(char *)v15 = 31;
5179 v16 = *(short *)(v3 + 272); 5178 v16 = *(short *)(v3 + 272);
5527 double v13; // ST1C_8@19 5526 double v13; // ST1C_8@19
5528 float v14; // [sp+4h] [bp-34h]@1 5527 float v14; // [sp+4h] [bp-34h]@1
5529 float v15; // [sp+8h] [bp-30h]@1 5528 float v15; // [sp+8h] [bp-30h]@1
5530 float v16; // [sp+Ch] [bp-2Ch]@1 5529 float v16; // [sp+Ch] [bp-2Ch]@1
5531 5530
5532 v14 = (double)pOutdoor->vSunlight.x * 0.000015258789; 5531 v14 = (double)pOutdoor->vSunlight.x / 65536.0;
5533 result = 0; 5532 result = 0;
5534 v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s]; 5533 v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s];
5535 v15 = (double)pOutdoor->vSunlight.y * 0.000015258789; 5534 v15 = (double)pOutdoor->vSunlight.y / 65536.0;
5536 v16 = (double)pOutdoor->vSunlight.z * 0.000015258789; 5535 v16 = (double)pOutdoor->vSunlight.z / 65536.0;
5537 if ( v1 > (unsigned int)array_77EC08 ) 5536 if ( v1 > (unsigned int)array_77EC08 )
5538 { 5537 {
5539 v2 = (char *)&array_77EC08[0].pODMFace; 5538 v2 = (char *)&array_77EC08[0].pODMFace;
5540 while ( 1 ) 5539 while ( 1 )
5541 { 5540 {
6134 _this.uTileBitmapID = pOutdoor->uSky_TextureID; 6133 _this.uTileBitmapID = pOutdoor->uSky_TextureID;
6135 _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? &pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0); 6134 _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? &pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
6136 if (pOutdoor->uSky_TextureID == -1) 6135 if (pOutdoor->uSky_TextureID == -1)
6137 return; 6136 return;
6138 6137
6139 _this.field_58 = 0; 6138 _this.dimming_level = 0;
6140 _this.uNumVertices = 4; 6139 _this.uNumVertices = 4;
6141 _this.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); 6140 _this.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);
6142 _this.v_18.y = 0; 6141 _this.v_18.y = 0;
6143 _this.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); 6142 _this.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);
6144 _this.field_24 = 0x2000000; 6143 _this.field_24 = 0x2000000;
6402 v62.uTileBitmapID = pFace->uBitmapID; 6401 v62.uTileBitmapID = pFace->uBitmapID;
6403 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); 6402 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
6404 if ( !v62.pTexture ) 6403 if ( !v62.pTexture )
6405 return; 6404 return;
6406 v8 = pBLVRenderParams->sPartyRotX; 6405 v8 = pBLVRenderParams->sPartyRotX;
6407 v62.field_58 = 0; 6406 v62.dimming_level = 0;
6408 v62.uNumVertices = v3; 6407 v62.uNumVertices = v3;
6409 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16); 6408 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16);
6410 v62.v_18.y = 0; 6409 v62.v_18.y = 0;
6411 v62.v_18.x = -v9; 6410 v62.v_18.x = -v9;
6412 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); 6411 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16);
6902 v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); 6901 v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11);
6903 if ( v10 > 27 ) 6902 if ( v10 > 27 )
6904 v10 = 27; 6903 v10 = 27;
6905 if ( v10 < a4 ) 6904 if ( v10 < a4 )
6906 v10 = a4; 6905 v10 = a4;
6907 if ( v10 > pOutdoor->field_CBC_terrain_triangles_shade_type ) 6906 if ( v10 > pOutdoor->max_terrain_dimming_level )
6908 v10 = pOutdoor->field_CBC_terrain_triangles_shade_type; 6907 v10 = pOutdoor->max_terrain_dimming_level;
6909 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); 6908 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
6910 } 6909 }
6911 v6 = 0; 6910 v6 = 0;
6912 if ( pWeather->field_FA0 == 1 ) 6911 if ( pWeather->field_FA0 == 1 )
6913 { 6912 {
7002 if ( !v9 ) 7001 if ( !v9 )
7003 { 7002 {
7004 *a5 = 31; 7003 *a5 = 31;
7005 *a6 = -1; 7004 *a6 = -1;
7006 } 7005 }
7007 v16 = v8->field_58 - terrain_gamma; 7006 v16 = v8->dimming_level - terrain_gamma;
7008 if ( v16 >= 0 ) 7007 if ( v16 >= 0 )
7009 { 7008 {
7010 if ( v16 > 27 ) 7009 if ( v16 > 27 )
7011 v16 = 27; 7010 v16 = 27;
7012 } 7011 }
7035 v20 = *v15; 7034 v20 = *v15;
7036 if ( v16 + v29 > v20 ) 7035 if ( v16 + v29 > v20 )
7037 *v14 = v20; 7036 *v14 = v20;
7038 if ( *v14 < v16 ) 7037 if ( *v14 < v16 )
7039 *v14 = v16; 7038 *v14 = v16;
7040 if ( *v14 > pOutdoor->field_CBC_terrain_triangles_shade_type ) 7039 if ( *v14 > pOutdoor->max_terrain_dimming_level )
7041 *v14 = pOutdoor->field_CBC_terrain_triangles_shade_type; 7040 *v14 = pOutdoor->max_terrain_dimming_level;
7042 goto LABEL_45; 7041 goto LABEL_45;
7043 } 7042 }
7044 if ( v9 >= day_fogrange_1 << 16 ) 7043 if ( v9 >= day_fogrange_1 << 16 )
7045 { 7044 {
7046 if ( v9 <= day_fogrange_2 << 16 ) 7045 if ( v9 <= day_fogrange_2 << 16 )
7364 return (-1 - v7) << 24; 7363 return (-1 - v7) << 24;
7365 } 7364 }
7366 7365
7367 7366
7368 //----- (0047C4FC) -------------------------------------------------------- 7367 //----- (0047C4FC) --------------------------------------------------------
7369 signed int __fastcall GetActorTintColor(int tint, int a2, float a3, int a4, RenderBillboard *a5) 7368 signed int __fastcall GetActorTintColor(int max_dimm, int min_dimm, float distance, int a4, RenderBillboard *a5)
7370 { 7369 {
7371 //int v5; // esi@1 7370 //int v5; // esi@1
7372 signed int v6; // edx@1 7371 signed int v6; // edx@1
7373 //signed int result; // eax@2 7372 //signed int result; // eax@2
7374 int v8; // eax@3 7373 int v8; // eax@3
7383 //double v17; // ST0C_8@44 7382 //double v17; // ST0C_8@44
7384 int v18; // ST14_4@44 7383 int v18; // ST14_4@44
7385 //double v19; // ST0C_8@44 7384 //double v19; // ST0C_8@44
7386 signed int v20; // [sp+10h] [bp-4h]@10 7385 signed int v20; // [sp+10h] [bp-4h]@10
7387 float a3a; // [sp+1Ch] [bp+8h]@33 7386 float a3a; // [sp+1Ch] [bp+8h]@33
7388 float a3b; // [sp+1Ch] [bp+8h]@34 7387 //float a3b; // [sp+1Ch] [bp+8h]@34
7389 float a3c; // [sp+1Ch] [bp+8h]@44 7388 float a3c; // [sp+1Ch] [bp+8h]@44
7390 //float a3d; // [sp+1Ch] [bp+8h]@44 7389 //float a3d; // [sp+1Ch] [bp+8h]@44
7391 float a4b; // [sp+20h] [bp+Ch]@18 7390 float a4b; // [sp+20h] [bp+Ch]@18
7392 int a4a; // [sp+20h] [bp+Ch]@33 7391 //int a4a; // [sp+20h] [bp+Ch]@33
7393 //float a4c; // [sp+20h] [bp+Ch]@44 7392 //float a4c; // [sp+20h] [bp+Ch]@44
7394 //float a4d; // [sp+20h] [bp+Ch]@44 7393 //float a4d; // [sp+20h] [bp+Ch]@44
7395 int a5a; // [sp+24h] [bp+10h]@44 7394 int a5a; // [sp+24h] [bp+10h]@44
7396 7395
7397 //v5 = a2; 7396 //v5 = a2;
7398 v6 = 0; 7397 v6 = 0;
7399 7398
7400 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 7399 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
7401 return 8 * (31 - tint) | ((8 * (31 - tint) | ((31 - tint) << 11)) << 8); 7400 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8);
7401
7402 if (pParty->armageddon_timer) 7402 if (pParty->armageddon_timer)
7403 return 0xFFFF0000; 7403 return 0xFFFF0000;
7404 7404
7405 v8 = pWeather->field_FA0; 7405 v8 = pWeather->field_FA0;
7406 if ( bUnderwater == 1 ) 7406 if (bUnderwater)
7407 v8 = 0; 7407 v8 = 0;
7408 if ( v8 ) 7408 if ( v8 )
7409 { 7409 {
7410 __debugbreak(); // doubt that weather-related stuff will ever trigger, but if it suddenly does - find out what it is 7410 __debugbreak(); // doubt that weather-related stuff will ever trigger, but if it suddenly does - find out what it is
7411 if ( v8 != 1 ) 7411 if ( v8 != 1 )
7414 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) 7414 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 )
7415 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; 7415 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
7416 v9 = (double)v20 * 1024.0; 7416 v9 = (double)v20 * 1024.0;
7417 if ( a4 ) 7417 if ( a4 )
7418 goto LABEL_19; 7418 goto LABEL_19;
7419 if ( a3 <= v9 ) 7419 if ( distance <= v9 )
7420 { 7420 {
7421 if ( a3 > 0.0 ) 7421 if ( distance > 0.0 )
7422 { 7422 {
7423 a4b = a3 * 216.0 / v9; 7423 a4b = distance * 216.0 / v9;
7424 v10 = a4b + 6.7553994e15; 7424 v10 = a4b + 6.7553994e15;
7425 v6 = LODWORD(v10); 7425 v6 = LODWORD(v10);
7426 if ( SLODWORD(v10) > 216 ) 7426 if ( SLODWORD(v10) > 216 )
7427 goto LABEL_19; 7427 goto LABEL_19;
7428 } 7428 }
7429 } 7429 }
7430 else 7430 else
7431 { 7431 {
7432 v6 = 216; 7432 v6 = 216;
7433 } 7433 }
7434 if ( a3 != 0.0 ) 7434 if ( distance != 0.0 )
7435 { 7435 {
7436 LABEL_20: 7436 LABEL_20:
7437 if ( a5 ) 7437 if ( a5 )
7438 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); 7438 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
7439 if ( v6 > 216 ) 7439 if ( v6 > 216 )
7445 goto LABEL_20; 7445 goto LABEL_20;
7446 } 7446 }
7447 7447
7448 7448
7449 7449
7450 if ( a3 == 0.0 ) 7450 if (fabsf(distance) < 1.0e-6f)
7451 return 0xFFF8F8F8; 7451 return 0xFFF8F8F8;
7452 7452
7453 v11 = 8 * (tint - a2); 7453 // dim in measured in 8-steps
7454 v11 = 8 * (max_dimm - min_dimm);
7454 //v12 = v11; 7455 //v12 = v11;
7455 if ( v11 >= 0 ) 7456 if ( v11 >= 0 )
7456 { 7457 {
7457 if ( v11 > 216 ) 7458 if ( v11 > 216 )
7458 v11 = 216; 7459 v11 = 216;
7459 } 7460 }
7460 else 7461 else
7461 v11 = 0; 7462 v11 = 0;
7462 7463
7463 if ( a4 ) 7464 float fog_density_mult = 216.0f;
7464 { 7465 if (a4)
7465 a3b = pOutdoor->fFogDensity * 216.0; 7466 fog_density_mult += distance / (double)pOutdoorCamera->shading_dist_shade * 32.0;
7467
7468 v6 = v11 + floorf(pOutdoor->fFogDensity * fog_density_mult + 0.5f);
7469 /*if ( a4 )
7470 {
7471 //a3b = pOutdoor->fFogDensity * 216.0;
7466 //v14 = a3b + 6.7553994e15; 7472 //v14 = a3b + 6.7553994e15;
7467 a4a = floorf(a3b + 0.5f);//LODWORD(v14); 7473 //a4a = floorf(a3b + 0.5f);//LODWORD(v14);
7468 } 7474 }
7469 else 7475 else
7470 { 7476 {
7471 a3a = (a3 / (double)pOutdoorCamera->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity; 7477 //a3a = (distance / (double)pOutdoorCamera->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity;
7472 //v13 = a3a + 6.7553994e15; 7478 //v13 = a3a + 6.7553994e15;
7473 a4a = floorf(a3a + 0.5f);//LODWORD(v13); 7479 //a4a = floorf(a3a + 0.5f);//LODWORD(v13);
7474 } 7480 }
7475 v6 = a4a + v11; 7481 v6 = a4a + v11;*/
7476 if ( a5 ) 7482 if ( a5 )
7477 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); 7483 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
7478 if ( v6 > 216 ) 7484 if ( v6 > 216 )
7479 v6 = 216; 7485 v6 = 216;
7480 if ( v6 < v11 ) 7486 if ( v6 < v11 )
7481 v6 = v11; 7487 v6 = v11;
7482 if ( v6 > 8 * pOutdoor->field_CBC_terrain_triangles_shade_type ) 7488 if ( v6 > 8 * pOutdoor->max_terrain_dimming_level )
7483 v6 = 8 * pOutdoor->field_CBC_terrain_triangles_shade_type; 7489 v6 = 8 * pOutdoor->max_terrain_dimming_level;
7484 if ( !bUnderwater ) 7490 if ( !bUnderwater )
7485 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); 7491 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
7486 else 7492 else
7487 { 7493 {
7488 v15 = (double)(255 - v6) * 0.0039215689; 7494 v15 = (double)(255 - v6) * 0.0039215689;