diff Engine/Graphics/IndoorCameraD3D.cpp @ 2531:f6de3e15d4a5

for light in indoor
author Ritor1
date Sun, 23 Nov 2014 15:30:17 +0600
parents 68cdef6879a0
children 9ec6b8be16fe
line wrap: on
line diff
--- a/Engine/Graphics/IndoorCameraD3D.cpp	Mon Oct 13 17:52:23 2014 +0300
+++ b/Engine/Graphics/IndoorCameraD3D.cpp	Sun Nov 23 15:30:17 2014 +0600
@@ -1056,121 +1056,77 @@
 void IndoorCameraD3D::_436F09_mess_with_lightmap__clipflag_4(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
   unsigned int *pOutNumVertices_; // ebx@1
-  double v6; // st7@2
   signed int v7; // esi@2
-  char *v8; // edx@5
-  unsigned int v9; // eax@10
-  RenderVertexSoft *v10; // ecx@11
   double v11; // st6@11
-  double v12; // st6@12
-  unsigned int v13; // edi@14
   unsigned __int8 v14; // c2@16
   unsigned __int8 v15; // c3@16
-  unsigned int v16; // edi@17
   bool a1a; // [sp+Ch] [bp+8h]@7
-  int a4a; // [sp+18h] [bp+14h]@5
 
   pOutNumVertices_ = pOutNumVertices;
   *pOutNumVertices = 0;
   if ( uNumInVertices )
   {
     memcpy(&pInVertices[uNumInVertices], pInVertices, sizeof(pInVertices[uNumInVertices]));
-    v6 = (double)pODMRenderParams->shading_dist_mist;
     v7 = 0;
-    if ( v6 >= pInVertices->vWorldViewPosition.x )
+    if ( (double)pODMRenderParams->shading_dist_mist >= pInVertices->vWorldViewPosition.x )
       v7 = 1;
-    if ( uNumInVertices + 1 > 1 )
+    for ( uint i = 0; i < uNumInVertices; i++ )
     {
-      a4a = uNumInVertices;
-      v8 = (char *)&pInVertices[1].u;
-      do
+      a1a = (double)pODMRenderParams->shading_dist_mist >= pInVertices[i + 1].vWorldViewPosition.x;
+      if ( v7 != a1a )
       {
-        a1a = v6 >= *((float *)v8 - 6);
-        if ( v7 == a1a )
+        if (a1a)
         {
-          v10 = pOutVertices;
-          //goto LABEL_23;
+          v11 = ((double)pODMRenderParams->shading_dist_mist - pInVertices[i].vWorldViewPosition.x) / (pInVertices[i + 1].vWorldViewPosition.x - pInVertices[i].vWorldViewPosition.x);
+          pOutVertices[*pOutNumVertices_].vWorldViewPosition.y = (pInVertices[i + 1].vWorldViewPosition.y - pInVertices[i].vWorldViewPosition.y) * v11 + pInVertices[i].vWorldViewPosition.y;
+          pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (pInVertices[i + 1].vWorldViewPosition.z - pInVertices[i].vWorldViewPosition.z) * v11 + pInVertices[i].vWorldViewPosition.z;
+          pOutVertices[*pOutNumVertices_].u = (pInVertices[i + 1].u - pInVertices[i].u) * v11 + pInVertices[i].u;
+          pOutVertices[*pOutNumVertices_].v = (pInVertices[i + 1].v - pInVertices[i].v) * v11 + pInVertices[i].v;
+        }
+        else
+        {
+          v11 = ((double)pODMRenderParams->shading_dist_mist - pInVertices[i + 1].vWorldViewPosition.x) / (pInVertices[i].vWorldViewPosition.x - pInVertices[i + 1].vWorldViewPosition.x);
+          pOutVertices[*pOutNumVertices_].vWorldViewPosition.y = (pInVertices[i].vWorldViewPosition.y - pInVertices[i + 1].vWorldViewPosition.y) * v11 + pInVertices[i + 1].vWorldViewPosition.y;
+          pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (pInVertices[i].vWorldViewPosition.z - pInVertices[i + 1].vWorldViewPosition.z) * v11 + pInVertices[i + 1].vWorldViewPosition.z;
+          pOutVertices[*pOutNumVertices_].u = (pInVertices[i].u - pInVertices[i + 1].u) * v11 + pInVertices[i + 1].u;
+          pOutVertices[*pOutNumVertices_].v = (pInVertices[i].v - pInVertices[i + 1].v) * v11 + pInVertices[i + 1].v;
         }
-		else
-		{
-
-			v9 = *pOutNumVertices_;
-			if (a1a)
-			{
-				v10 = pOutVertices;
-				v11 = (v6 - *((float *)v8 - 18)) / (*((float *)v8 - 6) - *((float *)v8 - 18));
-				pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 5) - *((float *)v8 - 17)) * v11 + *((float *)v8 - 17);
-				pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 4) - *((float *)v8 - 16)) * v11
-					+ *((float *)v8 - 16);
-				pOutVertices[*pOutNumVertices_].u = (*(float *)v8 - *((float *)v8 - 12)) * v11 + *((float *)v8 - 12);
-				pOutVertices[*pOutNumVertices_].v = (*((float *)v8 + 1) - *((float *)v8 - 11)) * v11 + *((float *)v8 - 11);
-			}
-			else
-			{
-				v12 = (v6 - *((float *)v8 - 6)) / (*((float *)v8 - 18) - *((float *)v8 - 6));
-				pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 17) - *((float *)v8 - 5)) * v12 + *((float *)v8 - 5);
-				pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 16) - *((float *)v8 - 4)) * v12
-					+ *((float *)v8 - 4);
-				pOutVertices[*pOutNumVertices_].u = (*((float *)v8 - 12) - *(float *)v8) * v12 + *(float *)v8;
-				pOutVertices[*pOutNumVertices_].v = (*((float *)v8 - 11) - *((float *)v8 + 1)) * v12 + *((float *)v8 + 1);
-				v10 = pOutVertices;
-			}
-			v10[*pOutNumVertices_].vWorldViewPosition.x = v6;
-			v10[*pOutNumVertices_]._rhw = 1.0 / v6;
-			if (v7)
-			{
-				v13 = (unsigned int)&v10[*pOutNumVertices_];
-				if (*(float *)(v13 + 12) != *((float *)v8 - 18) || *(float *)(v13 + 16) != *((float *)v8 - 17))
-				{
-					++*pOutNumVertices_;
-					//goto LABEL_23;
-				}
-				else
-				{
-					v14 = 0;
-					v15 = *(float *)(v13 + 20) == *((float *)v8 - 16);
-					if (!(v15 | v14))
-					{
-						//goto LABEL_21;
-						++*pOutNumVertices_;
-						//goto LABEL_23;
-					}
-				}
-			}
-			else
-			{
-				v16 = (unsigned int)&v10[*pOutNumVertices_];
-				if (*(float *)(v16 + 12) != *((float *)v8 - 6) || *(float *)(v16 + 16) != *((float *)v8 - 5))
-				{
-					//LABEL_21:
-					++*pOutNumVertices_;
-					//goto LABEL_23;
-				}
-				else
-				{
-					v14 = 0;
-					v15 = *(float *)(v16 + 20) == *((float *)v8 - 4);
-					if (!(v15 | v14))
-					{
-						//goto LABEL_21;
-						++*pOutNumVertices_;
-						//goto LABEL_23;
-					}
-				}
-			}
-		}
-		//LABEL_23:
-        if ( a1a )
+        pOutVertices[*pOutNumVertices_].vWorldViewPosition.x = (double)pODMRenderParams->shading_dist_mist;
+        pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (double)pODMRenderParams->shading_dist_mist;
+        if (v7)
+        {
+          if (pOutVertices[*pOutNumVertices_].vWorldViewPosition.x != pInVertices[i].vWorldViewPosition.x
+           || pOutVertices[*pOutNumVertices_].vWorldViewPosition.y != pInVertices[i].vWorldViewPosition.y)
+            ++*pOutNumVertices_;
+          else
+          {
+            v14 = 0;
+            v15 = pOutVertices[*pOutNumVertices_].vWorldViewPosition.z == pInVertices[i].vWorldViewPosition.z;
+            if (!(v15 | v14))
+              ++*pOutNumVertices_;
+          }
+        }
+        else
         {
-          memcpy(&v10[*pOutNumVertices_], v8 - 36, sizeof(v10[*pOutNumVertices_]));
-          pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (*((float *)v8 - 6) + 0.0000001);
-          pOutVertices[(*pOutNumVertices_)++].flt_2C = *((float *)v8 + 2);
+          if (pOutVertices[*pOutNumVertices_].vWorldViewPosition.x != pInVertices[i + 1].vWorldViewPosition.x
+           || pOutVertices[*pOutNumVertices_].vWorldViewPosition.y != pInVertices[i + 1].vWorldViewPosition.y)
+            ++*pOutNumVertices_;
+          else
+          {
+            v14 = 0;
+            v15 = pOutVertices[*pOutNumVertices_].vWorldViewPosition.z == pInVertices[i + 1].vWorldViewPosition.z;
+            if (!(v15 | v14))
+              ++*pOutNumVertices_;
+          }
         }
-        v7 = a1a;
-        v8 += 48;
-        --a4a;
       }
-      while ( a4a );
+      if ( a1a )
+      {
+        memcpy(&pOutVertices[*pOutNumVertices_], &pInVertices[i + 1], sizeof(pOutVertices[*pOutNumVertices_]));
+        pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (pInVertices[i + 1].vWorldViewPosition.x + 0.0000001);
+        pOutVertices[(*pOutNumVertices_)++].flt_2C = pInVertices[i + 1].flt_2C;
+      }
+      v7 = a1a;
     }
     if ( (signed int)*pOutNumVertices_ < 3 )
       *pOutNumVertices_ = 0;
@@ -1181,15 +1137,10 @@
 void IndoorCameraD3D::_436CDC_mess_with_lightmap__clipflag_2(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
   signed int v5; // esi@2
-  char *v6; // edx@5
-  unsigned int v7; // eax@10
-  RenderVertexSoft *v8; // ecx@11
   double v9; // st6@11
   double v10; // st6@12
-  unsigned int v11; // edi@14
   unsigned __int8 v12; // c2@16
   unsigned __int8 v13; // c3@16
-  unsigned int v14; // edi@17
   bool a1a; // [sp+Ch] [bp+8h]@7
 
   if ( uNumInVertices )
@@ -1201,71 +1152,61 @@
       v5 = 1;
     if ( uNumInVertices + 1 > 1 )
     {
-      v6 = (char *)&pInVertices[1].u;
-      do
+      for ( uint i = 1; i <= uNumInVertices; i++ )
       {
-        a1a = *((float *)v6 - 6) >= 8.0;
+        a1a = pInVertices[i].vWorldViewPosition.x >= 8.0;
         if ( v5 == a1a )
-        {
-          v8 = pOutVertices;
           goto LABEL_23;
-        }
-        v7 = *pOutNumVertices;
         if ( a1a )
         {
-          v8 = pOutVertices;
-          v9 = (8.0 - *((float *)v6 - 18)) / (*((float *)v6 - 6) - *((float *)v6 - 18));
-          pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 5) - *((float *)v6 - 17)) * v9 + *((float *)v6 - 17);
-          pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 4) - *((float *)v6 - 16)) * v9
-                                                              + *((float *)v6 - 16);
-          pOutVertices[*pOutNumVertices].u = (*(float *)v6 - *((float *)v6 - 12)) * v9 + *((float *)v6 - 12);
-          pOutVertices[*pOutNumVertices].v = (*((float *)v6 + 1) - *((float *)v6 - 11)) * v9 + *((float *)v6 - 11);
+          v9 = (8.0 - pInVertices[i - 1].vWorldViewPosition.x) / (pInVertices[i].vWorldViewPosition.x - pInVertices[i - 1].vWorldViewPosition.x);
+          pOutVertices[*pOutNumVertices].vWorldViewPosition.y = (pInVertices[i].vWorldViewPosition.y - pInVertices[i - 1].vWorldViewPosition.y) * v9 + pInVertices[i - 1].vWorldViewPosition.y;
+          pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (pInVertices[i].vWorldViewPosition.z - pInVertices[i - 1].vWorldViewPosition.z) * v9 + pInVertices[i - 1].vWorldViewPosition.z;
+          pOutVertices[*pOutNumVertices].u = (pInVertices[i].u - pInVertices[i - 1].u) * v9 + pInVertices[i - 1].u;
+          pOutVertices[*pOutNumVertices].v = (pInVertices[i].v - pInVertices[i - 1].v) * v9 + pInVertices[i - 1].v;
         }
         else
         {
-          v10 = (8.0 - *((float *)v6 - 6)) / (*((float *)v6 - 18) - *((float *)v6 - 6));
-          pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 17) - *((float *)v6 - 5)) * v10 + *((float *)v6 - 5);
-          pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 16) - *((float *)v6 - 4)) * v10
-                                                              + *((float *)v6 - 4);
-          pOutVertices[*pOutNumVertices].u = (*((float *)v6 - 12) - *(float *)v6) * v10 + *(float *)v6;
-          pOutVertices[*pOutNumVertices].v = (*((float *)v6 - 11) - *((float *)v6 + 1)) * v10 + *((float *)v6 + 1);
-          v8 = pOutVertices;
+          v10 = (8.0 - pInVertices[i].vWorldViewPosition.x) / (pInVertices[i - 1].vWorldViewPosition.x - pInVertices[i].vWorldViewPosition.x);
+          pOutVertices[*pOutNumVertices].vWorldViewPosition.y = (pInVertices[i - 1].vWorldViewPosition.y - pInVertices[i].vWorldViewPosition.y) * v10 + pInVertices[i].vWorldViewPosition.y;
+          pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (pInVertices[i - 1].vWorldViewPosition.z - pInVertices[i].vWorldViewPosition.z) * v10 + pInVertices[i].vWorldViewPosition.z;
+          pOutVertices[*pOutNumVertices].u = (pInVertices[i - 1].u - pInVertices[i].u) * v10 + pInVertices[i].u;
+          pOutVertices[*pOutNumVertices].v = (pInVertices[i - 1].v - pInVertices[i].v) * v10 + pInVertices[i].v;
         }
-        v8[*pOutNumVertices].vWorldViewPosition.x = 8.0;
-        v8[*pOutNumVertices]._rhw = 0.125;
+        pOutVertices[*pOutNumVertices].vWorldViewPosition.x = 8.0;
+        pOutVertices[*pOutNumVertices]._rhw = 0.125;
         if ( v5 )
         {
-          v11 = (unsigned int)&v8[*pOutNumVertices];
-          if ( *(float *)(v11 + 12) != *((float *)v6 - 18) || *(float *)(v11 + 16) != *((float *)v6 - 17) )
-            goto LABEL_21;
-          v12 = 0;
-          v13 = *(float *)(v11 + 20) == *((float *)v6 - 16);
-        }
-        else
-        {
-          v14 = (unsigned int)&v8[*pOutNumVertices];
-          if ( *(float *)(v14 + 12) != *((float *)v6 - 6) || *(float *)(v14 + 16) != *((float *)v6 - 5) )
+          if ( pOutVertices[*pOutNumVertices].vWorldViewPosition.x != pInVertices[i - 1].vWorldViewPosition.x
+            || pOutVertices[*pOutNumVertices].vWorldViewPosition.y != pInVertices[i - 1].vWorldViewPosition.y )
           {
-LABEL_21:
             ++*pOutNumVertices;
             goto LABEL_23;
           }
           v12 = 0;
-          v13 = *(float *)(v14 + 20) == *((float *)v6 - 4);
+          v13 = pOutVertices[*pOutNumVertices].vWorldViewPosition.z == pInVertices[i - 1].vWorldViewPosition.z;
+        }
+        else
+        {
+          if ( pOutVertices[*pOutNumVertices].vWorldViewPosition.x != pInVertices[i].vWorldViewPosition.x
+            || pOutVertices[*pOutNumVertices].vWorldViewPosition.y != pInVertices[i].vWorldViewPosition.y )
+          {
+            ++*pOutNumVertices;
+            goto LABEL_23;
+          }
+          v12 = 0;
+          v13 = pOutVertices[*pOutNumVertices].vWorldViewPosition.z == pInVertices[i].vWorldViewPosition.z;
         }
         if ( !(v13 | v12) )
-          goto LABEL_21;
+          ++*pOutNumVertices;
 LABEL_23:
         if ( a1a )
         {
-          memcpy(&v8[*pOutNumVertices], v6 - 36, sizeof(v8[*pOutNumVertices]));
-          pOutVertices[(*pOutNumVertices)++]._rhw = 1.0 / (*((float *)v6 - 6) + 0.0000001);
+          memcpy(&pOutVertices[*pOutNumVertices], &pInVertices[i], sizeof(pOutVertices[*pOutNumVertices]));
+          pOutVertices[(*pOutNumVertices)++]._rhw = 1.0 / (pInVertices[i].vWorldViewPosition.x + 0.0000001);
         }
         v5 = a1a;
-        v6 += 48;
-        --uNumInVertices;
       }
-      while ( uNumInVertices );
     }
     if ( (signed int)*pOutNumVertices < 3 )
       *pOutNumVertices = 0;
@@ -1391,23 +1332,13 @@
 //----- (00436A6D) --------------------------------------------------------
 double IndoorCameraD3D::GetPolygonMinZ(RenderVertexSoft *pVertices, unsigned int uStripType)
 {
-  unsigned int v3; // edx@1
   double result; // st7@1
-  float *v5; // ecx@2
 
-  v3 = uStripType;
-  result = 3.402823466385289e38;
-  if ( (signed int)uStripType > 0 )
+  result = FLT_MAX;
+  for ( uint i = 0; i < uStripType; i++ )
   {
-    v5 = &pVertices->vWorldPosition.z;
-    do
-    {
-      if ( *v5 < result )
-        result = *v5;
-      v5 += 12;
-      --v3;
-    }
-    while ( v3 );
+    if ( pVertices[i].vWorldPosition.z < FLT_MAX )
+      result = pVertices[i].vWorldPosition.z;
   }
   return result;
 }