diff Engine/Graphics/ParticleEngine.cpp @ 2541:a902abdfc7f2

1. Renamed class Game to class Engine. 2. Separated game logic as state of FSM from game logic as engine. 3. Found out that many UI screen initializers were optimized away, intially they all returned newly created window as separate object like it is done in CharacterUI_Initialize.
author a.parshin
date Sun, 10 May 2015 01:29:11 +0200
parents 68cdef6879a0
children b6140dfeac27
line wrap: on
line diff
--- a/Engine/Graphics/ParticleEngine.cpp	Sat May 09 12:55:58 2015 +0200
+++ b/Engine/Graphics/ParticleEngine.cpp	Sun May 10 01:29:11 2015 +0200
@@ -3,13 +3,13 @@
 #include <crtdbg.h>
 
 #define _CRT_SECURE_NO_WARNINGS
+#include "Engine/Engine.h"
 #include "ParticleEngine.h"
-#include "../Timer.h"
+#include "Engine/Timer.h"
 #include "Viewport.h"
 #include "Outdoor.h"
-#include "../Game.h"
-#include "../OurMath.h"
-#include "../LOD.h"
+#include "Engine/OurMath.h"
+#include "Engine/LOD.h"
 
 #include "Sprites.h"
 
@@ -308,7 +308,7 @@
   z_int_ = floorf(pParticle->z + 0.5f);
   /*if ( !pRenderer->pRenderD3D )
   {
-    if (pGame->pIndoorCameraD3D->sRotationX)
+    if (pEngine->pIndoorCameraD3D->sRotationX)
     {
       if (pParticle->type & ParticleType_Line)
       {
@@ -316,22 +316,22 @@
         int _uParticleID = (int)(floorf(pParticle->_x + 0.5f) - pBLVRenderParams->vPartyPos.x) << 16;
         //v12 = pParticle->_y + 6.7553994e15;
         y = (int)(floorf(pParticle->_y + 0.5f) - pBLVRenderParams->vPartyPos.y) << 16;
-        z = (unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-        HIDWORD(a5) = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16)
+        z = (unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
+        HIDWORD(a5) = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16)
                     - z;
-        a6 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
+        a6 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
         //v13 = pParticle->_z + 6.7553994e15;
         _uParticleID = (int)(floorf(pParticle->_z + 0.5f) - pBLVRenderParams->vPartyPos.z) << 16;
-        z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16)
-          - ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16);
+        z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_x) >> 16)
+          - ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_x) >> 16);
         v14 = z;
-        HIDWORD(v13) = (unsigned __int64)(SHIDWORD(a5) * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16;
-        HIDWORD(a5) = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16;
+        HIDWORD(v13) = (unsigned __int64)(SHIDWORD(a5) * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_x) >> 16;
+        HIDWORD(a5) = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_x) >> 16;
         //LODWORD(v15) = pBLVRenderParams->field_40 << 16;
         //HIDWORD(v15) = pBLVRenderParams->field_40 >> 16;
         //v16 = v15 / z;
         v16 = fixpoint_div(pBLVRenderParams->field_40, z);
-        v17 = (unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16;
+        v17 = (unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16;
         pParticle->_screenspace_scale = v16;
         _uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16;
         LODWORD(v18) = pBLVRenderParams->uViewportCenterX
@@ -346,20 +346,20 @@
       }
       int _uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
       y = (y_int_ - pBLVRenderParams->vPartyPos.y) << 16;
-      HIDWORD(a5) = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16)
-                  - ((unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16);
-      a6 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-      z_int_4 = (unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16;
+      HIDWORD(a5) = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16)
+                  - ((unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16);
+      a6 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
+      z_int_4 = (unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16;
       _uParticleID = (z_int_ - pBLVRenderParams->vPartyPos.z) << 16;
-      v21 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16;
-      v22 = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16) - v21;
-      z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16) - v21;
+      v21 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_x) >> 16;
+      v22 = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_x) >> 16) - v21;
+      z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_x) >> 16) - v21;
       if ( v22 < (signed int)0x40000u || v22 > (signed int)0x1F400000u )
         return 0;
       v23 = a6 + z_int_4;
       a2 = a6 + z_int_4;
-      v24 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16)
-          + ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16);
+      v24 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_x) >> 16)
+          + ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_x) >> 16);
     }
     else
     {
@@ -369,17 +369,17 @@
         int _uParticleID = ((int)floorf(pParticle->_x + 0.5f) - pBLVRenderParams->vPartyPos.x) << 16;
         //v26 = pParticle->_y + 6.7553994e15;
         y = ((int)floorf(pParticle->_y + 0.5f) - pBLVRenderParams->vPartyPos.y) << 16;
-        auto _hiword_v25 = (__int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-        v27 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - _hiword_v25;
-        z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - _hiword_v25;
-        v28 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
+        auto _hiword_v25 = (__int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
+        v27 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16) - _hiword_v25;
+        z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16) - _hiword_v25;
+        v28 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
         //a5 = pParticle->_z + 6.7553994e15;
         v29 = ((int)floorf(pParticle->_z + 0.5f) - pBLVRenderParams->vPartyPos.z) << 16;
         //LODWORD(v30) = pBLVRenderParams->field_40 << 16;
         //HIDWORD(v30) = pBLVRenderParams->field_40 >> 16;
         //v31 = v30 / z;
         v31 = fixpoint_div(pBLVRenderParams->field_40, z);
-        v32 = (unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16;
+        v32 = (unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16;
         pParticle->_screenspace_scale = v31;
         _uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16;
         LODWORD(v33) = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16);
@@ -391,15 +391,15 @@
       }
       int _uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
       y = (y_int_ - pBLVRenderParams->vPartyPos.y) << 16;
-      v36 = (unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-      v22 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - v36;
-      z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - v36;
+      v36 = (unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
+      v22 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16) - v36;
+      z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16) - v36;
       if ( v22 < 262144 || v22 > 524288000 )
         return 0;
-      v37 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16;
-      _uParticleID = (unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16;
-      v23 = v37 + ((unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16);
-      a2 = v37 + ((unsigned __int64)(y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16);
+      v37 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) >> 16;
+      _uParticleID = (unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16;
+      v23 = v37 + ((unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16);
+      a2 = v37 + ((unsigned __int64)(y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) >> 16);
       v24 = (z_int_ - pBLVRenderParams->vPartyPos.z) << 16;
     }
     int _uParticleID = abs(v23);
@@ -426,7 +426,7 @@
   }*/
 
   int x;
-  if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible_BLV(
+  if ( !pEngine->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible_BLV(
           x_int,
           y_int_,
           z_int_,
@@ -435,10 +435,10 @@
           &z,
           1) )
     return false;
-  pGame->pIndoorCameraD3D->Project(x, y, z, &pParticle->uScreenSpaceX, &pParticle->uScreenSpaceY);
-  pParticle->flt_5C = pGame->pIndoorCameraD3D->fov_x;
+  pEngine->pIndoorCameraD3D->Project(x, y, z, &pParticle->uScreenSpaceX, &pParticle->uScreenSpaceY);
+  pParticle->flt_5C = pEngine->pIndoorCameraD3D->fov_x;
   //v4 = pParticle->flt_5C;
-  pParticle->flt_60 = pGame->pIndoorCameraD3D->fov_y;
+  pParticle->flt_60 = pEngine->pIndoorCameraD3D->fov_y;
   //v5 = v4 + 6.7553994e15;
   LODWORD(v6) = 0;
   HIDWORD(v6) = floorf(pParticle->flt_5C + 0.5f);
@@ -472,10 +472,10 @@
   int v45; // [sp+40h] [bp-10h]@5
   int X_4; // [sp+48h] [bp-8h]@5
 
-  v3 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX);
-  v44 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
-  v4 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY);
-  v5 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
+  v3 = stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationX);
+  v44 = stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationX);
+  v4 = stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationY);
+  v5 = stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationY);
 
   if (pParticles[uID].type == ParticleType_Invalid)
     return false;
@@ -484,30 +484,30 @@
   {
     if (pParticles[uID].type & ParticleType_Line)
     {
-      v11 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4)
-          + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-      long long _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44);
+      v11 = fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v4)
+          + fixpoint_sub_unknown(pParticles[uID].y - pEngine->pIndoorCameraD3D->vPartyPos.y, v5);
+      long long _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(pParticles[uID].z - pEngine->pIndoorCameraD3D->vPartyPos.z, v44);
       LODWORD(v13) = 0;
       HIDWORD(v13) = SLOWORD(pODMRenderParams->int_fov_rad);
       pParticles[uID]._screenspace_scale = v13 / _hidword_v12;
       pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX
                                     - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y
-                                    - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-                                    - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
+                                    - pEngine->pIndoorCameraD3D->vPartyPos.y, v4)
+                                    - fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
       pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY
                                     - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].z
-                                    - pGame->pIndoorCameraD3D->vPartyPos.z, v3)
+                                    - pEngine->pIndoorCameraD3D->vPartyPos.z, v3)
                                     - fixpoint_mul(v11, v44))) >> 16);
       pParticles[uID].sZValue = _hidword_v12;
     }
-    v45 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(pParticles[uID].y
-                                                 - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-    X_4 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3);
+    v45 = fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(pParticles[uID].y
+                                                 - pEngine->pIndoorCameraD3D->vPartyPos.y, v5);
+    X_4 = fixpoint_sub_unknown(pParticles[uID].z - pEngine->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3);
     if ( X_4 < 0x40000 )
       return 0;
-    v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-        - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5);
-    v17 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_mul(v45, v44);
+    v16 = fixpoint_sub_unknown(pParticles[uID].y - pEngine->pIndoorCameraD3D->vPartyPos.y, v4)
+        - fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v5);
+    v17 = fixpoint_sub_unknown(pParticles[uID].z - pEngine->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_mul(v45, v44);
   }
   else
   {
@@ -515,23 +515,23 @@
     {
       LODWORD(v22) = 0;
       HIDWORD(v22) = SLOWORD(pODMRenderParams->int_fov_rad);
-      long long _var_123 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4)
-                         + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
+      long long _var_123 = fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v4)
+                         + fixpoint_sub_unknown(pParticles[uID].y - pEngine->pIndoorCameraD3D->vPartyPos.y, v5);
       pParticles[uID]._screenspace_scale = v22 / _var_123;
       pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX
                         - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y
-                        - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-                        - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
+                        - pEngine->pIndoorCameraD3D->vPartyPos.y, v4)
+                        - fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
       pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_sub_unknown(pParticles[uID].z, pParticles[uID]._screenspace_scale) >> 16);
       pParticles[uID].sZValue = _var_123;
     }
-    v26 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-    X_4 = v26 + fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4);
+    v26 = fixpoint_sub_unknown(pParticles[uID].y - pEngine->pIndoorCameraD3D->vPartyPos.y, v5);
+    X_4 = v26 + fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v4);
     if ( X_4 < 0x40000 || X_4 > (pODMRenderParams->uPickDepth - 1000) << 16 )
       return 0;
     v17 = pParticles[uID].z;
-    v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-        - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5);
+    v16 = fixpoint_sub_unknown(pParticles[uID].y - pEngine->pIndoorCameraD3D->vPartyPos.y, v4)
+        - fixpoint_sub_unknown(pParticles[uID].x - pEngine->pIndoorCameraD3D->vPartyPos.x, v5);
   }
   v40 = v17;
   v28 = abs(v16);