Mercurial > mm7
comparison ParticleEngine.cpp @ 1669:bd28d08e2c75
Merge
author | Ritor1 |
---|---|
date | Tue, 17 Sep 2013 22:55:48 +0600 |
parents | afc1c3514dd5 |
children | 8971dc85b8fb |
comparison
equal
deleted
inserted
replaced
1668:d17247968bd6 | 1669:bd28d08e2c75 |
---|---|
2 #include "Time.h" | 2 #include "Time.h" |
3 #include "Render.h" | 3 #include "Render.h" |
4 #include "Viewport.h" | 4 #include "Viewport.h" |
5 #include "Outdoor.h" | 5 #include "Outdoor.h" |
6 #include "Game.h" | 6 #include "Game.h" |
7 #include "IndoorCamera.h" | 7 #include "Outdoor_stuff.h" |
8 #include "Math.h" | 8 #include "Math.h" |
9 #include "LOD.h" | 9 #include "LOD.h" |
10 | 10 |
11 #include "Sprites.h" | 11 #include "Sprites.h" |
12 #include "OutdoorCamera.h" | |
13 #include "mm7_data.h" | 12 #include "mm7_data.h" |
14 | 13 |
15 TrailParticleGenerator trail_particle_generator; | 14 TrailParticleGenerator trail_particle_generator; |
16 | 15 |
17 | 16 |
302 //y_int_ = *(float *)&uParticleID + 6.7553994e15; | 301 //y_int_ = *(float *)&uParticleID + 6.7553994e15; |
303 y_int_ = floorf(pParticle->y + 0.5f); | 302 y_int_ = floorf(pParticle->y + 0.5f); |
304 //uParticleID = LODWORD(pParticle->z); | 303 //uParticleID = LODWORD(pParticle->z); |
305 //z_int_ = *(float *)&uParticleID + 6.7553994e15; | 304 //z_int_ = *(float *)&uParticleID + 6.7553994e15; |
306 z_int_ = floorf(pParticle->z + 0.5f); | 305 z_int_ = floorf(pParticle->z + 0.5f); |
307 if ( !pRenderer->pRenderD3D ) | 306 /*if ( !pRenderer->pRenderD3D ) |
308 { | 307 { |
309 if ( pBLVRenderParams->sPartyRotX ) | 308 if (pGame->pIndoorCameraD3D->sRotationX) |
310 { | 309 { |
311 if (pParticle->type & ParticleType_Line) | 310 if (pParticle->type & ParticleType_Line) |
312 { | 311 { |
313 //v11 = pParticle->_x + 6.7553994e15; | 312 //v11 = pParticle->_x + 6.7553994e15; |
314 int _uParticleID = (int)(floorf(pParticle->_x + 0.5f) - pBLVRenderParams->vPartyPos.x) << 16; | 313 int _uParticleID = (int)(floorf(pParticle->_x + 0.5f) - pBLVRenderParams->vPartyPos.x) << 16; |
419 pParticle->_screenspace_scale = fixpoint_sub0(fixpoint_from_float(pParticle->flt_28), pParticle->_screenspace_scale); | 418 pParticle->_screenspace_scale = fixpoint_sub0(fixpoint_from_float(pParticle->flt_28), pParticle->_screenspace_scale); |
420 pParticle->sZValue = z; | 419 pParticle->sZValue = z; |
421 return true; | 420 return true; |
422 } | 421 } |
423 return false; | 422 return false; |
424 } | 423 }*/ |
425 | 424 |
426 int x; | 425 int x; |
427 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( | 426 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible_BLV( |
428 x_int, | 427 x_int, |
429 y_int_, | 428 y_int_, |
430 z_int_, | 429 z_int_, |
431 &x, | 430 &x, |
432 &y, | 431 &y, |
505 //int uIDe; // [sp+58h] [bp+8h]@5 | 504 //int uIDe; // [sp+58h] [bp+8h]@5 |
506 //int uIDa; // [sp+58h] [bp+8h]@5 | 505 //int uIDa; // [sp+58h] [bp+8h]@5 |
507 //int uIDf; // [sp+58h] [bp+8h]@8 | 506 //int uIDf; // [sp+58h] [bp+8h]@8 |
508 //int uIDb; // [sp+58h] [bp+8h]@9 | 507 //int uIDb; // [sp+58h] [bp+8h]@9 |
509 | 508 |
510 v3 = stru_5C6E00->Cos(pIndoorCamera->sRotationX); | 509 v3 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX); |
511 v44 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); | 510 v44 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX); |
512 v4 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); | 511 v4 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY); |
513 v5 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); | 512 v5 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY); |
514 | 513 |
515 v6 = &pParticles[uID]; | 514 v6 = &pParticles[uID]; |
516 if (v6->type == ParticleType_Invalid) | 515 if (v6->type == ParticleType_Invalid) |
517 return false; | 516 return false; |
518 | 517 |
526 { | 525 { |
527 //v8 = v6->_x + 6.7553994e15; | 526 //v8 = v6->_x + 6.7553994e15; |
528 //uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16; | 527 //uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16; |
529 //v9 = v6->_y + 6.7553994e15; | 528 //v9 = v6->_y + 6.7553994e15; |
530 //v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16; | 529 //v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16; |
531 v11 = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4) + fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); | 530 v11 = fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); |
532 //HIDWORD(v8) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); | 531 //HIDWORD(v8) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); |
533 //v12 = v6->_z + 6.7553994e15; | 532 //v12 = v6->_z + 6.7553994e15; |
534 //uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16; | 533 //uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16; |
535 auto _hidword_v12 = fixpoint_sub0(v11, v3) + fixpoint_mul(v6->z - pIndoorCamera->pos.z, v44); | 534 auto _hidword_v12 = fixpoint_sub0(v11, v3) + fixpoint_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44); |
536 LODWORD(v13) = 0; | 535 LODWORD(v13) = 0; |
537 HIDWORD(v13) = SLOWORD(pOutdoorCamera->int_fov_rad); | 536 HIDWORD(v13) = SLOWORD(pODMRenderParams->int_fov_rad); |
538 //v14 = v13 / _hidword_v12; | 537 //v14 = v13 / _hidword_v12; |
539 v6->_screenspace_scale = v13 / _hidword_v12; | 538 v6->_screenspace_scale = v13 / _hidword_v12; |
540 //v15 = v6->_screenspace_scale; | 539 //v15 = v6->_screenspace_scale; |
541 v6->uScreenSpaceX = pViewport->uScreenCenterX | 540 v6->uScreenSpaceX = pViewport->uScreenCenterX |
542 - ((signed int)((unsigned __int64)(v6->_screenspace_scale | 541 - ((signed int)((unsigned __int64)(v6->_screenspace_scale |
543 * (signed __int64)(fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) | 542 * (signed __int64)(fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) |
544 - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5))) >> 16) >> 16); | 543 - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16) >> 16); |
545 v6->uScreenSpaceY = pViewport->uScreenCenterY | 544 v6->uScreenSpaceY = pViewport->uScreenCenterY |
546 - ((signed int)((unsigned __int64)(v6->_screenspace_scale | 545 - ((signed int)((unsigned __int64)(v6->_screenspace_scale |
547 * (signed __int64)(fixpoint_mul(v6->z - pIndoorCamera->pos.z, v3) | 546 * (signed __int64)(fixpoint_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) |
548 - ((unsigned __int64)(v11 * (signed __int64)v44) >> 16))) >> 16) >> 16); | 547 - ((unsigned __int64)(v11 * (signed __int64)v44) >> 16))) >> 16) >> 16); |
549 v6->sZValue = _hidword_v12; | 548 v6->sZValue = _hidword_v12; |
550 } | 549 } |
551 //uIDe = (v41 - pIndoorCamera->pos.x) << 16; | 550 //uIDe = (v41 - pIndoorCamera->pos.x) << 16; |
552 //v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; | 551 //v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; |
553 v45 = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4) + fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); | 552 v45 = fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); |
554 //HIDWORD(v42) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); | 553 //HIDWORD(v42) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); |
555 //uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16; | 554 //uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16; |
556 X_4 = fixpoint_mul(v6->z - pIndoorCamera->pos.z, v44) + fixpoint_sub0(v45, v3); | 555 X_4 = fixpoint_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_sub0(v45, v3); |
557 if ( X_4 < 0x40000 ) | 556 if ( X_4 < 0x40000 ) |
558 return 0; | 557 return 0; |
559 v16 = fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); | 558 v16 = fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); |
560 v17 = fixpoint_mul(v6->z - pIndoorCamera->pos.z, v3) - fixpoint_sub0(v45, v44); | 559 v17 = fixpoint_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_sub0(v45, v44); |
561 } | 560 } |
562 else | 561 else |
563 { | 562 { |
564 if (v6->type & ParticleType_Line) | 563 if (v6->type & ParticleType_Line) |
565 { | 564 { |
567 //uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16; | 566 //uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16; |
568 //v19 = v6->_y + 6.7553994e15; | 567 //v19 = v6->_y + 6.7553994e15; |
569 //v20 = (LODWORD(v19) - pIndoorCamera->pos.y) << 16; | 568 //v20 = (LODWORD(v19) - pIndoorCamera->pos.y) << 16; |
570 //v21 = v6->_z + 6.7553994e15; | 569 //v21 = v6->_z + 6.7553994e15; |
571 LODWORD(v22) = 0; | 570 LODWORD(v22) = 0; |
572 HIDWORD(v22) = SLOWORD(pOutdoorCamera->int_fov_rad); | 571 HIDWORD(v22) = SLOWORD(pODMRenderParams->int_fov_rad); |
573 auto _var_123 = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4) + fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); | 572 auto _var_123 = fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); |
574 //v23 = v22 / _var_123; | 573 //v23 = v22 / _var_123; |
575 v6->_screenspace_scale = v22 / _var_123; | 574 v6->_screenspace_scale = v22 / _var_123; |
576 //v24 = v6->_screenspace_scale; | 575 //v24 = v6->_screenspace_scale; |
577 v6->uScreenSpaceX = pViewport->uScreenCenterX | 576 v6->uScreenSpaceX = pViewport->uScreenCenterX |
578 - ((signed int)((unsigned __int64)(v6->_screenspace_scale | 577 - ((signed int)((unsigned __int64)(v6->_screenspace_scale |
579 * (signed __int64)(fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) | 578 * (signed __int64)(fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) |
580 - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5))) >> 16) >> 16); | 579 - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16) >> 16); |
581 v6->uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_mul(v6->z, v6->_screenspace_scale) >> 16); | 580 v6->uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_mul(v6->z, v6->_screenspace_scale) >> 16); |
582 v6->sZValue = _var_123; | 581 v6->sZValue = _var_123; |
583 } | 582 } |
584 //uIDb = (v41 - pIndoorCamera->pos.x) << 16; | 583 //uIDb = (v41 - pIndoorCamera->pos.x) << 16; |
585 //v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; | 584 //v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; |
586 v26 = fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); | 585 v26 = fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); |
587 //v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); | 586 //v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); |
588 X_4 = v26 + fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4); | 587 X_4 = v26 + fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4); |
589 if ( X_4 < 0x40000 || X_4 > (pOutdoorCamera->uPickDepth - 1000) << 16 ) | 588 if ( X_4 < 0x40000 || X_4 > (pODMRenderParams->uPickDepth - 1000) << 16 ) |
590 return 0; | 589 return 0; |
591 v17 = v6->z; | 590 v17 = v6->z; |
592 v16 = fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); | 591 v16 = fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); |
593 } | 592 } |
594 v40 = v17; | 593 v40 = v17; |
595 v28 = abs(v16); | 594 v28 = abs(v16); |
596 if ( abs(X_4) >= v28 ) | 595 if ( abs(X_4) >= v28 ) |
597 { | 596 { |
598 LODWORD(v29) = 0; | 597 LODWORD(v29) = 0; |
599 HIDWORD(v29) = SLOWORD(pOutdoorCamera->int_fov_rad); | 598 HIDWORD(v29) = SLOWORD(pODMRenderParams->int_fov_rad); |
600 //v30 = v29 / X_4; | 599 //v30 = v29 / X_4; |
601 v6->_screenspace_scale = v29 / X_4; | 600 v6->_screenspace_scale = v29 / X_4; |
602 //v31 = v6->_screenspace_scale; | 601 //v31 = v6->_screenspace_scale; |
603 v6->uScreenSpaceX = pViewport->uScreenCenterX | 602 v6->uScreenSpaceX = pViewport->uScreenCenterX |
604 - ((signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v16) >> 16) >> 16); | 603 - ((signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v16) >> 16) >> 16); |
777 { | 776 { |
778 if (pLines.uNumLines < 100) | 777 if (pLines.uNumLines < 100) |
779 { | 778 { |
780 pLines.pLineVertices[2 * pLines.uNumLines].pos.x = particle->uScreenSpaceX; | 779 pLines.pLineVertices[2 * pLines.uNumLines].pos.x = particle->uScreenSpaceX; |
781 pLines.pLineVertices[2 * pLines.uNumLines].pos.y = particle->uScreenSpaceY; | 780 pLines.pLineVertices[2 * pLines.uNumLines].pos.y = particle->uScreenSpaceY; |
782 pLines.pLineVertices[2 * pLines.uNumLines].pos.z = 1.0 - 1.0 / ((double)particle->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | 781 pLines.pLineVertices[2 * pLines.uNumLines].pos.z = 1.0 - 1.0 / ((double)particle->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
783 pLines.pLineVertices[2 * pLines.uNumLines].rhw = 1.0; | 782 pLines.pLineVertices[2 * pLines.uNumLines].rhw = 1.0; |
784 pLines.pLineVertices[2 * pLines.uNumLines].diffuse = particle->uLightColor_bgr; | 783 pLines.pLineVertices[2 * pLines.uNumLines].diffuse = particle->uLightColor_bgr; |
785 pLines.pLineVertices[2 * pLines.uNumLines].specular = 0; | 784 pLines.pLineVertices[2 * pLines.uNumLines].specular = 0; |
786 pLines.pLineVertices[2 * pLines.uNumLines].texcoord.x = 0.0; | 785 pLines.pLineVertices[2 * pLines.uNumLines].texcoord.x = 0.0; |
787 pLines.pLineVertices[2 * pLines.uNumLines].texcoord.y = 0.0; | 786 pLines.pLineVertices[2 * pLines.uNumLines].texcoord.y = 0.0; |
788 | 787 |
789 pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.x = particle->uScreenSpaceZ; | 788 pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.x = particle->uScreenSpaceZ; |
790 pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.y = particle->uScreenSpaceW; | 789 pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.y = particle->uScreenSpaceW; |
791 pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((double)particle->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | 790 pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((double)particle->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); |
792 pLines.pLineVertices[2 * pLines.uNumLines + 1].rhw = 1.0; | 791 pLines.pLineVertices[2 * pLines.uNumLines + 1].rhw = 1.0; |
793 pLines.pLineVertices[2 * pLines.uNumLines + 1].diffuse = particle->uLightColor_bgr; | 792 pLines.pLineVertices[2 * pLines.uNumLines + 1].diffuse = particle->uLightColor_bgr; |
794 pLines.pLineVertices[2 * pLines.uNumLines + 1].specular = 0; | 793 pLines.pLineVertices[2 * pLines.uNumLines + 1].specular = 0; |
795 pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.x = 0.0; | 794 pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.x = 0.0; |
796 pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.y = 0.0; | 795 pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.y = 0.0; |