Mercurial > mm7
comparison Engine/Graphics/Render.cpp @ 2531:f6de3e15d4a5
for light in indoor
author | Ritor1 |
---|---|
date | Sun, 23 Nov 2014 15:30:17 +0600 |
parents | b1c516bf1102 |
children | 9ec6b8be16fe |
comparison
equal
deleted
inserted
replaced
2530:dc6f29bb0ec4 | 2531:f6de3e15d4a5 |
---|---|
277 //6-South(Ю) | 277 //6-South(Ю) |
278 //7-SouthEast(ЮВ) | 278 //7-SouthEast(ЮВ) |
279 unsigned int Start_X, End_X, Start_Z, End_Z; | 279 unsigned int Start_X, End_X, Start_Z, End_Z; |
280 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) | 280 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) |
281 { | 281 { |
282 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; | 282 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128; |
283 Start_Z = 0, End_Z = 127; | 283 Start_Z = 0, End_Z = 128; |
284 } | 284 } |
285 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CЗ) | 285 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CЗ) |
286 { | 286 { |
287 Start_X = 0, End_X = 127; | 287 Start_X = 0, End_X = 128; |
288 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1; | 288 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1; |
289 } | 289 } |
290 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CЗ) - SouthWest(ЮЗ) | 290 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CЗ) - SouthWest(ЮЗ) |
291 { | 291 { |
292 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; | 292 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; |
293 Start_Z = 0, End_Z = 127; | 293 Start_Z = 0, End_Z = 128; |
294 } | 294 } |
295 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ЮЗ) - //SouthEast(ЮВ) | 295 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ЮЗ) - //SouthEast(ЮВ) |
296 { | 296 { |
297 Start_X = 0, End_X = 127; | 297 Start_X = 0, End_X = 128; |
298 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 127; | 298 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 128; |
299 } | 299 } |
300 else//SouthEast(ЮВ) - East(B) | 300 else//SouthEast(ЮВ) - East(B) |
301 { | 301 { |
302 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; | 302 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128; |
303 Start_Z = 0, End_Z = 127; | 303 Start_Z = 0, End_Z = 128; |
304 } | 304 } |
305 for (unsigned int z = Start_Z; z < End_Z; ++z) | 305 for (unsigned int z = Start_Z; z < End_Z; ++z) |
306 { | 306 { |
307 for (unsigned int x = Start_X; x < End_X; ++x) | 307 for (unsigned int x = Start_X; x < End_X; ++x) |
308 { | 308 { |
346 //pTile->field_32 |= 0x0001; | 346 //pTile->field_32 |= 0x0001; |
347 pTilePolygon->pODMFace = nullptr; | 347 pTilePolygon->pODMFace = nullptr; |
348 pTilePolygon->uNumVertices = 4; | 348 pTilePolygon->uNumVertices = 4; |
349 pTilePolygon->field_59 = 5; | 349 pTilePolygon->field_59 = 5; |
350 | 350 |
351 if ( array_73D150[0].vWorldViewPosition.x < 8.0 | |
352 && array_73D150[1].vWorldViewPosition.x < 8.0 | |
353 && array_73D150[2].vWorldViewPosition.x < 8.0 | |
354 && array_73D150[3].vWorldViewPosition.x < 8.0 ) | |
355 continue; | |
356 if ( (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
357 && (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
358 && (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
359 && (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x ) | |
360 continue; | |
361 //---------------------------------------------------------------------------- | |
362 | |
363 ++pODMRenderParams->uNumPolygons; | |
364 ++pODMRenderParams->field_44; | |
365 assert(pODMRenderParams->uNumPolygons < 20000); | |
366 | |
367 pTilePolygon->uBModelID = 0; | |
368 pTilePolygon->uBModelFaceID = 0; | |
369 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
370 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
371 { | |
372 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
373 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); | |
374 } | |
351 //shading (затенение)---------------------------------------------------------------------------- | 375 //shading (затенение)---------------------------------------------------------------------------- |
352 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | 376 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; |
353 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; | 377 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1]; |
354 assert(norm_idx < uNumTerrainNormals); | 378 assert(norm_idx < uNumTerrainNormals); |
355 | 379 |
356 Vec3_float_* norm = &pTerrainNormals[norm_idx]; | 380 Vec3_float_* norm = &pTerrainNormals[norm_idx]; |
357 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - | 381 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - |
358 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | 382 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - |
362 norm = 0; | 386 norm = 0; |
363 else | 387 else |
364 norm = &pTerrainNormals[norm_idx]; | 388 norm = &pTerrainNormals[norm_idx]; |
365 if (for_refactoring) | 389 if (for_refactoring) |
366 { | 390 { |
367 MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); | 391 //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); |
368 __debugbreak(); | 392 //__debugbreak(); |
369 } | 393 |
370 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows | 394 pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows |
371 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); | 395 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); |
372 //unsigned int a5 = 4; | 396 } |
373 //---------------------------------------------------------------------------- | 397 unsigned int a5 = 4; |
374 | 398 |
375 ++pODMRenderParams->uNumPolygons; | |
376 ++pODMRenderParams->field_44; | |
377 assert(pODMRenderParams->uNumPolygons < 20000); | |
378 | |
379 pTilePolygon->uBModelID = 0; | |
380 pTilePolygon->uBModelFaceID = 0; | |
381 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
382 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
383 { | |
384 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
385 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); | |
386 } | |
387 //---------Draw distance(Дальность отрисовки)------------------------------- | 399 //---------Draw distance(Дальность отрисовки)------------------------------- |
388 int temp = pODMRenderParams->shading_dist_mist; | 400 int temp = pODMRenderParams->shading_dist_mist; |
389 if ( draw_terrain_dist_mist ) | 401 if ( draw_terrain_dist_mist ) |
390 pODMRenderParams->shading_dist_mist = 0x5000; | 402 pODMRenderParams->shading_dist_mist = 0x5000; |
391 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 | 403 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 |
395 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | 407 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x |
396 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | 408 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x |
397 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | 409 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x |
398 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; | 410 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; |
399 | 411 |
400 /* int v33 = 0; | 412 int v33 = 0; |
401 static stru154 static_sub_0048034E_stru_154; | 413 static stru154 static_sub_0048034E_stru_154; |
402 pGame->pLightmapBuilder->std__vector_000004_size = 0; | 414 pGame->pLightmapBuilder->std__vector_000004_size = 0; |
403 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | 415 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) |
404 { | 416 { |
405 if ( neer_clip ) | 417 if ( neer_clip ) |
406 v33 = 3; | 418 v33 = 3; |
407 else | 419 else |
408 v33 = far_clip != 0 ? 5 : 0; | 420 v33 = far_clip != 0 ? 5 : 0; |
409 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist); | 421 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist); |
410 if ( pDecalBuilder->uNumDecals > 0 ) | 422 if ( pDecalBuilder->uNumDecals > 0 ) |
411 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); | 423 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
412 } | 424 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
413 if ( stru_F8AD28.uNumLightsApplied > 0 ) | 425 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); |
414 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);*/ | 426 } |
415 | 427 |
416 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | 428 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) |
417 { | 429 { |
418 //if ( neer_clip ) //Ritor1: Даёт искажения на подъёме, возможно требуется ф-ция Безье | 430 //if ( neer_clip ) //Ritor1: Даёт искажения на подъёме, возможно требуется ф-ция Безье |
419 //{ | 431 //{ |
4662 } | 4674 } |
4663 else | 4675 else |
4664 { | 4676 { |
4665 d3d_vertex_buffer[i].specular = 0; | 4677 d3d_vertex_buffer[i].specular = 0; |
4666 } | 4678 } |
4667 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used | 4679 //__debugbreak(); // warning C4700: uninitialized local variable 'v20' used |
4668 d3d_vertex_buffer[i].specular = v20; | 4680 //d3d_vertex_buffer[i].specular = v20; |
4669 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | 4681 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; |
4670 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | 4682 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; |
4671 } | 4683 } |
4672 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | 4684 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4673 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | 4685 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |