Mercurial > mm7
comparison Render.cpp @ 2318:133882370e83
far_clip and near_clip for draw terrain
author | Ritor1 |
---|---|
date | Thu, 20 Mar 2014 17:38:29 +0600 |
parents | 25f771e528f0 |
children | 847aba0b7f82 |
comparison
equal
deleted
inserted
replaced
2317:345b1ff000bb | 2318:133882370e83 |
---|---|
261 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | 261 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; |
262 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | 262 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
263 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | 263 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); |
264 } | 264 } |
265 } | 265 } |
266 //-------------------------------------------------------------------------------------------------------------------- | 266 //-------(Отсечение невидимой части карты)------------------------------------------------------------------------------------------ |
267 int direction = pGame->pIndoorCameraD3D->sRotationY / 256;//direction of the camera(напрвление камеры), не могу округлить :( | 267 float direction = pGame->pIndoorCameraD3D->sRotationY / 256;//direction of the camera(напрвление камеры) |
268 //0-East(B) | 268 //0-East(B) |
269 //1-NorthEast(CB) | 269 //1-NorthEast(CB) |
270 //2-North(C) | 270 //2-North(C) |
271 //3-WestNorth(CЗ) | 271 //3-WestNorth(CЗ) |
272 //4-West(З) | 272 //4-West(З) |
273 //5-SouthWest(ЮЗ) | 273 //5-SouthWest(ЮЗ) |
274 //6-South(Ю) | 274 //6-South(Ю) |
275 //7-SouthEast(ЮВ) | 275 //7-SouthEast(ЮВ) |
276 int Start_X, End_X, Start_Z, End_Z; | 276 int Start_X, End_X, Start_Z, End_Z; |
277 switch ( direction ) | 277 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) |
278 { | 278 { |
279 case 0://East(B) | 279 Start_X = pODMRenderParams->uMapGridCellX, End_X = 127; |
280 Start_X = pODMRenderParams->uMapGridCellX, End_X = 127; | 280 Start_Z = 0, End_Z = 127; |
281 Start_Z = 0, End_Z = 127; | 281 } |
282 break; | 282 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CЗ) |
283 case 1://NorthEast(CB) | 283 { |
284 Start_X = 0,/*pODMRenderParams->uMapGridCellX - 1,*/ End_X = 127; | |
285 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ; | |
286 break; | |
287 case 2://North(C) | |
288 Start_X = 0, End_X = 127; | 284 Start_X = 0, End_X = 127; |
289 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ; | 285 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ; |
290 break; | 286 } |
291 case 3://WestNorth(CЗ) | 287 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CЗ) - SouthWest(ЮЗ) |
292 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1; | 288 { |
293 Start_Z = 0, End_Z = 127;//pODMRenderParams->uMapGridCellZ + 2; | 289 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1; |
294 break; | 290 Start_Z = 0, End_Z = 127; |
295 case 4://West(З) | 291 } |
296 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1; | 292 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ЮЗ) - //SouthEast(ЮВ) |
297 Start_Z = 0, End_Z = 127; | 293 { |
298 break; | 294 Start_X = 0, End_X = 127; |
299 case 5://SouthWest(ЮЗ) | 295 Start_Z = pODMRenderParams->uMapGridCellZ - 1, End_Z = 127; |
300 Start_X = 0, End_X = 127;//pODMRenderParams->uMapGridCellX + 2; | 296 } |
301 Start_Z = pODMRenderParams->uMapGridCellZ - 1, End_Z = 127; | 297 else//SouthEast(ЮВ) - East(B) |
302 break; | 298 { |
303 case 6://South(Ю) | 299 Start_X = pODMRenderParams->uMapGridCellX, End_X = 127; |
304 Start_X = 0, End_X = 127; | 300 Start_Z = 0, End_Z = 127; |
305 Start_Z = pODMRenderParams->uMapGridCellZ - 1, End_Z = 127; | |
306 break; | |
307 case 7://SouthEast(ЮВ) | |
308 Start_X = pODMRenderParams->uMapGridCellX, End_X = 127; | |
309 Start_Z = 0,/*pODMRenderParams->uMapGridCellZ,*/ End_Z = 127; | |
310 break; | |
311 default: | |
312 __debugbreak();//Ritor1: error | |
313 } | 301 } |
314 for (unsigned int z = Start_Z; z < End_Z; ++z) | 302 for (unsigned int z = Start_Z; z < End_Z; ++z) |
315 { | 303 { |
316 for (unsigned int x = Start_X; x < End_X; ++x) | 304 for (unsigned int x = Start_X; x < End_X; ++x) |
317 { | 305 { |
369 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | 357 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); |
370 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) | 358 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) |
371 norm = 0; | 359 norm = 0; |
372 else | 360 else |
373 norm = &pTerrainNormals[norm_idx]; | 361 norm = &pTerrainNormals[norm_idx]; |
374 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows | 362 pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows |
375 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1); | 363 pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1); |
376 //----------------------------------------------------------------------------------------------- | 364 //----------------------------------------------------------------------------------------------- |
377 | 365 |
378 ++pODMRenderParams->uNumPolygons; | 366 ++pODMRenderParams->uNumPolygons; |
379 ++pODMRenderParams->field_44; | 367 ++pODMRenderParams->field_44; |
380 assert(pODMRenderParams->uNumPolygons < 20000); | 368 assert(pODMRenderParams->uNumPolygons < 20000); |
385 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | 373 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) |
386 { | 374 { |
387 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | 375 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); |
388 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); | 376 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
389 } | 377 } |
378 //---------Draw distance(Дальность отрисовки)------------------------------- | |
379 pODMRenderParams->shading_dist_mist = 0x5000; | |
380 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 | |
381 || array_73D150[1].vWorldViewPosition.x < 8.0 | |
382 || array_73D150[2].vWorldViewPosition.x < 8.0 | |
383 || array_73D150[3].vWorldViewPosition.x < 8.0; | |
384 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
385 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
386 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
387 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; | |
388 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
389 { | |
390 if ( neer_clip ) | |
391 { | |
392 pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices); | |
393 //ODM_Project(pTilePolygon->uNumVertices); | |
394 } | |
395 if ( far_clip ) | |
396 { | |
397 | |
398 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices); | |
399 //ODM_Project(pTilePolygon->uNumVertices); | |
400 } | |
401 } | |
402 pODMRenderParams->shading_dist_mist = 0x2000; | |
390 | 403 |
391 // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))---------------------- | 404 // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))---------------------- |
392 bool transparent = false; | 405 bool transparent = false; |
393 if ( !( pTilePolygon->flags & 1 ) ) // не поддерживается TextureFrameTable | 406 if ( !( pTilePolygon->flags & 1 ) ) // не поддерживается TextureFrameTable |
394 { | 407 { |
8509 int ODM_NearClip(unsigned int num_vertices) | 8522 int ODM_NearClip(unsigned int num_vertices) |
8510 { | 8523 { |
8511 bool current_vertices_flag; // edi@1 | 8524 bool current_vertices_flag; // edi@1 |
8512 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | 8525 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 |
8513 double t; // st6@10 | 8526 double t; // st6@10 |
8514 int pNextVertices; | 8527 //int pNextVertices; |
8515 | 8528 |
8516 if (!num_vertices) | 8529 if (!num_vertices) |
8517 return 0; | 8530 return 0; |
8518 | 8531 |
8519 memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); | 8532 memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0])); |
8520 current_vertices_flag = 0; | 8533 current_vertices_flag = false; |
8521 if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) | 8534 next_vertices_flag = false; |
8522 current_vertices_flag = 1; | 8535 if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 ) |
8536 current_vertices_flag = true; | |
8523 | 8537 |
8524 int out_num_vertices = 0; | 8538 int out_num_vertices = 0; |
8525 for (int i = 0; i < num_vertices; ++i) | 8539 for (int i = 0; i < num_vertices; ++i) |
8526 { | 8540 { |
8527 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= 8.0; | 8541 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x <= 8.0;// |
8528 if ( current_vertices_flag != next_vertices_flag ) | 8542 if ( current_vertices_flag ^ next_vertices_flag ) |
8529 { | 8543 { |
8530 if ( next_vertices_flag ) | 8544 if ( next_vertices_flag )//следующая вершина за ближней границей |
8531 { | 8545 { |
8532 //t = near_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) | 8546 //t = near_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) |
8533 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | 8547 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
8534 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | 8548 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
8535 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | 8549 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t; |
8536 array_507D30[out_num_vertices].u = (array_50AC10[i + 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | 8550 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; |
8537 array_507D30[out_num_vertices].v = (array_50AC10[i + 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | 8551 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; |
8538 } | 8552 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; |
8539 else | 8553 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; |
8540 { | 8554 } |
8541 t = (8.0 - array_50AC10[i + 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); | 8555 else// текущая вершина за ближней границей |
8542 array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t + array_50AC10[i + 1].vWorldViewPosition.y; | 8556 { |
8543 array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t + array_50AC10[i + 1].vWorldViewPosition.z; | 8557 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); |
8544 array_507D30[out_num_vertices].u = (array_50AC10[i].u - array_50AC10[i + 1].u) * t + array_50AC10[i + 1].u; | 8558 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
8545 array_507D30[out_num_vertices].v = (array_50AC10[i].v - array_50AC10[i + 1].v) * t + array_50AC10[i + 1].v; | 8559 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t; |
8546 } | 8560 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; |
8547 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; | 8561 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; |
8548 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | 8562 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; |
8563 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; | |
8564 } | |
8549 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; | 8565 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; |
8550 ++out_num_vertices; | 8566 ++out_num_vertices; |
8551 } | 8567 } |
8552 if ( next_vertices_flag ) | 8568 if ( !next_vertices_flag ) |
8553 { | 8569 { |
8554 pNextVertices = out_num_vertices++; | 8570 memcpy(&array_507D30[out_num_vertices], &array_50AC10[i + 1], sizeof(array_50AC10[i + 1])); |
8555 memcpy(&array_507D30[pNextVertices], &array_50AC10[i + 1], 0x30); | 8571 out_num_vertices++; |
8556 } | 8572 } |
8557 current_vertices_flag = next_vertices_flag; | 8573 current_vertices_flag = next_vertices_flag; |
8558 } | 8574 } |
8559 return out_num_vertices >= 3 ? out_num_vertices : 0; | 8575 return out_num_vertices >= 3 ? out_num_vertices : 0; |
8560 } | 8576 } |
8561 //----- (00424EE0) -------------------------------------------------------- | 8577 //----- (00424EE0) -------------------------------------------------------- |
8562 int ODM_FarClip(unsigned int uNumVertices) | 8578 int ODM_FarClip(unsigned int uNumVertices) |
8563 { | 8579 { |
8564 signed int previous_vertices_flag; // edi@1 | 8580 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 |
8581 bool next_vertices_flag; // edi@1 | |
8565 double t; // st6@10 | 8582 double t; // st6@10 |
8566 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 | |
8567 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | 8583 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 |
8568 int pNextVertices; | 8584 //int pNextVertices; |
8585 bool bFound; | |
8569 //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 | 8586 //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 |
8570 | 8587 |
8571 memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); | 8588 bFound = false; |
8589 | |
8590 memcpy(&array_50AC10[uNumVertices], &array_50AC10[0], sizeof(array_50AC10[uNumVertices])); | |
8572 depth_num_vertices = 0; | 8591 depth_num_vertices = 0; |
8573 previous_vertices_flag = 0; | 8592 current_vertices_flag = false; |
8574 if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) | 8593 if ( array_50AC10[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist ) |
8575 previous_vertices_flag = 1;//предыдущая грань меньше границы видимости | 8594 current_vertices_flag = true;//настоящая вершина больше границы видимости |
8576 if ( (signed int)uNumVertices <= 0 ) | 8595 if ( (signed int)uNumVertices <= 0 ) |
8577 return 0; | 8596 return 0; |
8578 for ( uint i = 1; i <= uNumVertices; ++i ) | 8597 for (uint i = 0; i < uNumVertices; ++i)// есть ли пограничные вершины |
8579 { | 8598 { |
8580 current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; | 8599 if ( array_50AC10[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist ) |
8581 if ( previous_vertices_flag != current_vertices_flag )//одна из граней за границей видимости | 8600 { |
8582 { | 8601 bFound = true; |
8583 if ( current_vertices_flag )//текущая грань меньше границы видимости(предыдущая грань за пределами видимости) | 8602 break; |
8584 { | 8603 } |
8585 //t = far_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) | 8604 } |
8586 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); | 8605 if ( !bFound ) |
8587 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; | 8606 return 0; |
8588 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; | 8607 //check for far clip plane(проверка по дальней границе) |
8589 array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; | 8608 // |
8590 array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; | 8609 // v3.__________________. v0 |
8591 } | 8610 // | | |
8592 else//предыдущая грань меньше границы видимости(текущая грань вышла за пределы видимости) | 8611 // | | |
8612 // | | | |
8613 // ----------------------- 8192.0(far_clip - 0x2000) | |
8614 // | | | |
8615 // .__________________. | |
8616 // v2 v1 | |
8617 | |
8618 for ( uint i = 0; i < uNumVertices; ++i ) | |
8619 { | |
8620 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist; | |
8621 if ( current_vertices_flag ^ next_vertices_flag )//одна из граней за границей видимости | |
8622 { | |
8623 if ( next_vertices_flag )//следующая вершина больше границы видимости(настоящая вершина меньше границы видимости) - v3 | |
8624 { | |
8625 //t = far_clip - v2.x / v3.x - v2.x (формула получения точки пересечения отрезка с плоскостью) | |
8626 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | |
8627 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | |
8628 //New_y = v2.y + (v3.y - v2.y)*t | |
8629 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t; | |
8630 //New_z = v2.z + (v3.z - v2.z)*t | |
8631 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t; | |
8632 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t; | |
8633 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t; | |
8634 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; | |
8635 } | |
8636 else//настоящая вершина больше границы видимости(следующая вершина меньше границы видимости) - v0 | |
8593 { | 8637 { |
8594 //t = far_clip - v1.x / v0.x - v1.x | 8638 //t = far_clip - v1.x / v0.x - v1.x |
8595 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); | 8639 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); |
8596 array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; | 8640 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
8597 array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; | 8641 //New_y = (v0.y - v1.y)*t + v1.y |
8598 array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; | 8642 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i + 1].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t; |
8599 array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; | 8643 //New_z = (v0.z - v1.z)*t + v1.z |
8600 } | 8644 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i + 1].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t; |
8601 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; | 8645 array_507D30[depth_num_vertices].u = array_50AC10[i + 1].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t; |
8602 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; | 8646 array_507D30[depth_num_vertices].v = array_50AC10[i + 1].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t; |
8647 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; | |
8648 } | |
8603 ++depth_num_vertices; | 8649 ++depth_num_vertices; |
8604 } | 8650 } |
8605 if ( current_vertices_flag )//оба в границе видимости | 8651 if ( !next_vertices_flag )//оба в границе видимости |
8606 { | 8652 { |
8607 pNextVertices = depth_num_vertices++; | 8653 memcpy(&array_507D30[depth_num_vertices], &array_50AC10[i + 1], sizeof(array_507D30[depth_num_vertices])); |
8608 memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); | 8654 depth_num_vertices++; |
8609 //array_507D30[pNextVertices]._rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | 8655 } |
8610 //array_507D30[pNextVertices].flt_2C = array_50AC10[i].flt_2C; | 8656 current_vertices_flag = next_vertices_flag; |
8611 } | 8657 } |
8612 previous_vertices_flag = current_vertices_flag; | 8658 for (uint i = 0; i < depth_num_vertices; ++i)// есть ли пограничные вершины |
8613 } | 8659 { |
8614 if ( depth_num_vertices < 3 ) | 8660 if ( array_507D30[i].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) |
8615 return 0; | 8661 { |
8616 return depth_num_vertices; | 8662 __debugbreak(); |
8663 } | |
8664 } | |
8665 return depth_num_vertices >= 3 ? depth_num_vertices : 0; | |
8617 } | 8666 } |
8618 | 8667 |
8619 //----- (0047840D) -------------------------------------------------------- | 8668 //----- (0047840D) -------------------------------------------------------- |
8620 void Render::DrawBuildingsD3D() | 8669 void Render::DrawBuildingsD3D() |
8621 { | 8670 { |