changeset 1267:33e360a9b4bf

some fixes in normals
author Gloval
date Thu, 13 Jun 2013 23:41:42 +0400
parents 71ebff35c428
children 2929c4406d2c 24bc24b64ec2
files Arcomage.h BSPModel.h Outdoor.h SpriteObject.cpp mm7_4.cpp
diffstat 5 files changed, 105 insertions(+), 146 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.h	Thu Jun 13 07:23:54 2013 +0200
+++ b/Arcomage.h	Thu Jun 13 23:41:42 2013 +0400
@@ -3,13 +3,6 @@
 
 #include "Texture.h"
 
-#pragma pack(push, 1)
-struct am_st1
-{
-  int field_0;
-  int field_4;
-};
-#pragma pack(pop)
 
 /*  401 */
 #pragma pack(push, 1)
@@ -172,8 +165,7 @@
   struct GUIFont *pfntComic;//ptr_48;
   struct GUIFont *pfntArrus;//ptr_4C;
   int field_50;
-  __int16 field_54;
-  __int16 field_56;
+  int field_54;
   RGBTexture pGameBackground;
   RGBTexture pSprites;
   int event_timer_time;
--- a/BSPModel.h	Thu Jun 13 07:23:54 2013 +0200
+++ b/BSPModel.h	Thu Jun 13 23:41:42 2013 +0400
@@ -34,7 +34,7 @@
   char pModelName2[32];
   int field_40;
   struct BSPVertexBuffer pVertices;
-  unsigned int uNumFaces;
+  int uNumFaces;
   unsigned int uNumConvexFaces;
   struct ODMFace *pFaces;
   unsigned __int16 *pFacesOrdering;
--- a/Outdoor.h	Thu Jun 13 07:23:54 2013 +0200
+++ b/Outdoor.h	Thu Jun 13 23:41:42 2013 +0400
@@ -192,7 +192,7 @@
   char pSkyTextureName[32];
   char pGroundTileset[32];
   OutdoorLocationTileType pTileTypes[4];    // [3]  road tileset
-  unsigned int uNumBModels;
+  int uNumBModels;
   struct OutdoorLocationTerrain pTerrain;
   void *pCmap;
   BSPModel *pBModels;
--- a/SpriteObject.cpp	Thu Jun 13 07:23:54 2013 +0200
+++ b/SpriteObject.cpp	Thu Jun 13 23:41:42 2013 +0400
@@ -227,7 +227,7 @@
   int v33; // eax@62
   int v34; // ecx@62
   int v35; // eax@63
-  Actor *v36; // ecx@67
+  int v36; // ecx@67
   __int16 v37; // ax@67
   int v38; // eax@72
   int v39; // eax@72
@@ -250,8 +250,8 @@
   int v56; // [sp+94h] [bp-14h]@11
   int v57; // [sp+98h] [bp-10h]@1
   int v58; // [sp+9Ch] [bp-Ch]@1
-  int v59; // [sp+A0h] [bp-8h]@1
-  Actor *v60; // [sp+A4h] [bp-4h]@11
+  int on_water; // [sp+A0h] [bp-8h]@1
+  int v60; // [sp+A4h] [bp-4h]@11
 
   uLayingItemID_ = uLayingItemID;
   v1 = &pSpriteObjects[uLayingItemID];
@@ -262,20 +262,19 @@
   v4 = v1->vPosition.x;
   v5 = v2->uHeight;
   v55 = 0;
-  v6 = ODM_GetFloorLevel(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0);
+  v6 = ODM_GetFloorLevel(v4, v3, v1->vPosition.z, v5, &on_water, &v55, 0);
   v7 = v6;
   v54 = v6;
   v8 = v6 + 1;
   if ( v1->vPosition.z <= v6 + 1 )
   {
-    if ( v59 )
+    if ( on_water )
     {
       v9 = v6 + 60;
       if ( v55 )
         v9 = v7 + 30;
       sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9);
       SpriteObject::OnInteraction(uLayingItemID_);
-      v7 = v54;
     }
   }
   else
@@ -283,7 +282,7 @@
     v58 = 1;
   }
   v10 = v2->uFlags;
-  if ( !(v10 & 0x20) )
+  if ( !(v2->uFlags & OBJECT_DESC_NO_GRAVITY) )
   {
     if ( v58 )
     {
@@ -298,11 +297,11 @@
       ODM_GetTerrainNormalAt(v12, v11, &v51);
       v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
       v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16;
-      v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
+      v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
       v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16;
-      v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
+      v60 = ((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
       v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16;
-      v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
+      v60 = ((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
       v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16;
 LABEL_12:
       v7 = v54;
@@ -316,75 +315,64 @@
         return;
     }
     v1->vPosition.z = v8;
-    if ( !(v2->uFlags & 0x80) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) )
+    if ( !(v2->uFlags & OBJECT_DESC_BOUNCE) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) )
       v1->vVelocity.z = 0;
-    v60 = (Actor *)v1->vVelocity.x;
-    v55 = 58500;
-    v60 = (Actor *)((unsigned __int64)(58500i64 * (signed int)v60) >> 16);
-    v1->vVelocity.x = (signed __int16)v60;
-    v60 = (Actor *)v1->vVelocity.y;
-    v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16);
-    v55 = 58500;
-    v1->vVelocity.y = (signed __int16)v60;
-    v60 = (Actor *)v1->vVelocity.z;
-    v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16);
-    v22 = v1->vVelocity.x;
-    v1->vVelocity.z = (signed __int16)v60;
-    if ( v1->vVelocity.y * v1->vVelocity.y + v22 * v22 >= 400 )
-      goto LABEL_12;
+
+    v1->vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.x) >> 16);
+    v1->vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.y) >> 16);
+    v1->vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.z) >> 16);
+
+    if ( (v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x) < 400 )
+        {
+
     v1->vVelocity.y = 0;
     v1->vVelocity.x = 0;
-    if ( !(HIBYTE(v2->uFlags) & 1) )
-      return;
     memset(&Dst, 0, 0x68u);
-    v23 = v2->uFlags;
     Dst.x = (double)v1->vPosition.x;
     Dst.y = (double)v1->vPosition.y;
     Dst.z = (double)v1->vPosition.z;
     Dst.flt_10 = 0.0;
     Dst.flt_14 = 0.0;
     Dst.flt_18 = 0.0;
-    if ( HIBYTE(v23) & 2 )
+    if (v2->uFlags & OBJECT_DESC_TRIAL_FIRE )
     {
       Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
       Dst.uDiffuse = 0xFF3C1E;
-      v24 = rand();
-      v48 = (TEXTURE_TYPE)0;
-LABEL_83:
-      v47 = "effpar01";
+      Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+      Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+      Dst.flt_28 = 1.0;
+      pGame->pParticleEngine->AddParticle(&Dst);
     }
-    else
+    else if ( v2->uFlags & OBJECT_DESC_TRIAL_LINE)
     {
-      if ( HIBYTE(v23) & 4 )
-      {
+
         Dst.type = ParticleType_Line;
         Dst.uDiffuse = rand();
         Dst.timeToLive = 64;
         Dst.uTextureID = 0;
-LABEL_89:
         Dst.flt_28 = 1.0;
         pGame->pParticleEngine->AddParticle(&Dst);
-        return;
       }
+    else if ( v2->uFlags & OBJECT_DESC_TRIAL_PARTICLE )
+        {
       Dst.type = ParticleType_Bitmap | ParticleType_8;
       Dst.uDiffuse = rand();
-      v24 = rand();
-      v48 = (TEXTURE_TYPE)0;
-LABEL_87:
-      v47 = "effpar03";
+      Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+      Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+      Dst.flt_28 = 1.0;
+      pGame->pParticleEngine->AddParticle(&Dst);
     }
-    Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128;
-    Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48);
-    goto LABEL_89;
+    return;
+        }
   }
 LABEL_13:
   if ( v1->vPosition.z > v7
-    && (v13 = v1->vPosition.x, v13 >= -32768)
-    && v13 <= 32768
-    && (v14 = v1->vPosition.y, v14 >= -32768)
-    && v14 <= 32768
+    && (v13 = v1->vPosition.x, v13 >= -0x8000)
+    && v13 <= 0x8000
+    && (v14 = v1->vPosition.y, v14 >= -0x8000)
+    && v14 <= 0x8000
     && v1->vPosition.z <= 13000
-    || !(v2->uFlags & 0x40) )
+    || !(v2->uFlags & OBJECT_DESC_INTERACTABLE) )
     goto LABEL_92;
   if ( v1->vPosition.z < v7 )
     v1->vPosition.z = v8;
@@ -414,34 +402,23 @@
         return;
       _46E889_collide_against_bmodels(0);
       v16 = WorldPosToGridCellZ(v1->vPosition.y);
-      v17 = v1->vPosition.x;
-      v58 = v16;
-      v18 = WorldPosToGridCellX(v17);
-      _46E26D_collide_against_sprites(v18, v58);
+      v18 = WorldPosToGridCellX(v1->vPosition.x);
+      _46E26D_collide_against_sprites(v18, v16);
       if (PID_TYPE(v1->spell_caster_pid) != OBJECT_Player)
         _46EF01_collision_chech_player(0);
       if (PID_TYPE(v1->spell_caster_pid) == OBJECT_Actor)
       {
         v19 = PID_ID(v1->spell_caster_pid);
-        if ( v19 >= 0 )
+        if (( v19 >= 0 )&&( v19 < (signed int)(uNumActors - 1) ))
         {
-          if ( v19 < (signed int)(uNumActors - 1) )
-          {
-            v56 = 0;
-            if ( (signed int)uNumActors > 0 )
-            {
-              v60 = pActors.data();
-              v20 = &pActors[v19];
-              do
+         
+            v20 = &pActors[v19];
+           for (v56 =0; v56 < uNumActors; ++v56)            
               {
-                if ( v20->GetActorsRelation(v60) )
+                if ( v20->GetActorsRelation(&pActors[v56]) )
                   _46DF1A_collide_against_actor(v56, 0);
-                ++v56;
-                ++v60;
+
               }
-              while ( v56 < (signed int)uNumActors );
-            }
-          }
         }
       }
       else
@@ -458,7 +435,7 @@
               &v49,
               &v50,
               0);
-      if ( v59 && v26 < v27 + 60 )
+      if ( on_water && v26 < v27 + 60 )
       {
         if ( v50 )
           v44 = v27 + 30;
@@ -474,50 +451,55 @@
         v1->vPosition.y = stru_721530.normal2.y;
         v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
         v1->uSectorID = LOWORD(stru_721530.uSectorID);
-        if ( !(HIBYTE(v2->uFlags) & 1) )
-          return;
         memset(&Dst, 0, 0x68u);
-        v45 = v2->uFlags;
         Dst.x = (double)v1->vPosition.x;
         Dst.y = (double)v1->vPosition.y;
         Dst.z = (double)v1->vPosition.z;
         Dst.flt_10 = 0.0;
         Dst.flt_14 = 0.0;
         Dst.flt_18 = 0.0;
-        if ( HIBYTE(v45) & 2 )
+        if ( v2->uFlags & OBJECT_DESC_TRIAL_FIRE )
         {
           Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
           Dst.uDiffuse = 0xFF3C1E;
-          v24 = rand();
-          v48 = (TEXTURE_TYPE)0;
-          goto LABEL_83;
+          Dst.timeToLive = (unsigned __int8)( rand() & 0x80) + 128;
+          Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
+          return;
         }
-        if ( HIBYTE(v45) & 4 )
+        else if ( v2->uFlags & OBJECT_DESC_TRIAL_LINE )
         {
           Dst.type = ParticleType_Line;
-          v46 = rand();
           Dst.uTextureID = 0;
-          Dst.uDiffuse = v46;
+          Dst.uDiffuse = rand();
           Dst.timeToLive = 64;
-          goto LABEL_89;
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
+          return;
         }
-        Dst.type = ParticleType_Bitmap | ParticleType_8;
-        Dst.uDiffuse = rand();
-        v24 = rand();
-        v48 = (TEXTURE_TYPE)0;
-        goto LABEL_87;
+        else if ( v2->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+            { 
+            Dst.type = ParticleType_Bitmap | ParticleType_8;
+            Dst.uDiffuse = rand();         
+            Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+            Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+            Dst.flt_28 = 1.0;
+            pGame->pParticleEngine->AddParticle(&Dst);
+            }
+        return;
       }
-      v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
+      v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
       v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-      v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
+      v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
       v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
+      v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
       v28 = LOWORD(stru_721530.uSectorID);
       v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
       v29 = v1->vPosition.z;
       v1->uSectorID = v28;
       stru_721530.field_70 += stru_721530.field_7C;
-      if ( v2->uFlags & 0x40 )
+      if ( v2->uFlags & OBJECT_DESC_INTERACTABLE )
       {
         if ( v29 < v54 )
           v1->vPosition.z = v54 + 1;
@@ -541,8 +523,8 @@
           v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16;
           v58 = v32->pFacePlane.vNormal.y;
           v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16;
-          v60 = (Actor *)v32->pFacePlane.vNormal.z;
-          v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16);
+          v60 = v32->pFacePlane.vNormal.z;
+          v60 = ((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16);
           v1->vVelocity.x += 2 * v57;
           v1->vVelocity.y += 2 * v58;
           if ( v32->pFacePlane.vNormal.z <= 32000 )
@@ -552,10 +534,9 @@
           else
           {
             v36 = v60;
-            v57 = 32000;
             v1->vVelocity.z += (signed __int16)v60;
-            v58 = (unsigned __int64)(v57 * (signed __int64)(signed int)v36) >> 16;
-            v37 = (unsigned int)(v57 * (int)v36) >> 16;
+            v58 = (unsigned __int64)(32000 * (signed __int64)(signed int)v36) >> 16;
+            v37 = (unsigned int)(32000 * v36) >> 16;
           }
           v1->vVelocity.z += v37;
 LABEL_70:
@@ -574,21 +555,14 @@
         goto LABEL_73;
       }
 LABEL_74:
-      v58 = v1->vVelocity.x;
-      v57 = 58500;
-      v58 = (unsigned __int64)(58500i64 * v58) >> 16;
-      v1->vVelocity.x = v58;
-      v58 = v1->vVelocity.y;
-      v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16;
-      v57 = 58500;
-      v1->vVelocity.y = v58;
-      v58 = v1->vVelocity.z;
-      v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16;
+      v1->vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.x) >> 16);
+      v1->vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.y) >> 16);
+      v1->vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.z) >> 16);
+
       ++v55;
-      v43 = __OFSUB__(v55, 100);
-      v42 = v55 - 100 < 0;
-      v1->vVelocity.z = v58;
-      if ( !(v42 ^ v43) )
+      //v43 = __OFSUB__(v55, 100);
+   //   v42 = v55 - 100 < 0;
+      if (v55>=100 )//!(v42 ^ v43) 
         return;
     }
     v57 = integer_sqrt(v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x);
@@ -597,12 +571,12 @@
             v1->vPosition.y - pLevelDecorations[v30].vPosition.y);
     v56 = v38;
     v39 = stru_5C6E00->Cos(v38);
-    v60 = (Actor *)v39;
+   // v60 = v39;
     v40 = v39 * (signed __int64)v57;
     v58 = v40 >> 16;
     v1->vVelocity.x = WORD1(v40);
     v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi);
-    v60 = (Actor *)v41;
+   // v60 = v41;
     v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16;
     v58 = v35;
 LABEL_73:
--- a/mm7_4.cpp	Thu Jun 13 07:23:54 2013 +0200
+++ b/mm7_4.cpp	Thu Jun 13 23:41:42 2013 +0400
@@ -475,30 +475,25 @@
   dword_721160[0] = -1;
   dword_721110[0] = -1;
   odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, pIsOnWater, bWaterWalk);
-  if ( (signed int)pOutdoor->uNumBModels <= 0 )
-  {
-    *a6 = 0;
-    return odm_floor_level[0];
-  }
-  v38 = 0;
-  for ( pBModelNum = 0; pBModelNum < (signed int)pOutdoor->uNumBModels; ++pBModelNum )
-  {
-    pBModel = &pOutdoor->pBModels[v38];
-    if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && Y <= pBModel->sMaxY && Y >= pBModel->sMinY )
-    {
-      if ( (signed int)pBModel->uNumFaces > 0 )
+  
+  for ( pBModelNum = 0; pBModelNum < pOutdoor->uNumBModels; ++pBModelNum )
+  {
+    pBModel = &pOutdoor->pBModels[pBModelNum];
+    if ( X <= pBModel->sMaxX && X >= pBModel->sMinX &&
+         Y <= pBModel->sMaxY && Y >= pBModel->sMinY )
+    {
+      if ( pBModel->uNumFaces > 0 )
       {
         v39 = 0;
         for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum )
         {
-          pFace = &pBModel->pFaces[v39];
+          pFace = &pBModel->pFaces[pFaceNum];
           if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall)
             && !(pFace->uAttributes & 0x20000000)
             && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1
             && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 )
           {
-            if ( pFace->uNumVertices )
-            {
+            
               for ( uint i = 0; i < pFace->uNumVertices; ++i)
               {
                 word_721040[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x;
@@ -506,7 +501,6 @@
                 word_721040[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x;
                 word_720F70[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y;
               }
-            }
             word_721040[2 * pFace->uNumVertices] = word_721040[0];
             word_720F70[2 * pFace->uNumVertices] = word_720F70[0];
             v43 = word_720F70[0] >= Y;
@@ -555,11 +549,10 @@
               }
             }
           }
-          ++v39;
+
         }
       }
     }
-    ++v38;
   }
   if ( v46 == 1 )
   {
@@ -854,10 +847,10 @@
     side1_dy = (double)(x1z1_y - x1z2_y);
     side2_dy = (double)(x2z2_y - x1z2_y);
     side2_dx = (double)(grid_pos_x2 - grid_pos_x1);
-    side1_dx = (double)(grid_pos_x1 - grid_pos_x1);
-    side2_dz = (double)(grid_pos_z2 - grid_pos_z2);  // bug?  z2 - z2
-    side1_dz = (double)(grid_pos_z2 - grid_pos_z2);  //       z1 - z2
-    Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__);
+    side1_dx = (double)(grid_pos_x1 - grid_pos_x2);
+    side2_dz = 0.0;//(double)(grid_pos_z2 - grid_pos_z2);  // bug?  z2 - z2 
+    side1_dz = (double)(grid_pos_z1 - grid_pos_z2);  //       z1 - z2 yes
+    //Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__);
     /*       |\
        side1 |  \
              |____\
@@ -868,8 +861,8 @@
     side1_dy = (double)(x2z2_y - x2z1_y);
     side2_dy = (double)(x1z1_y - x2z1_y);
     side2_dx = (double)(grid_pos_x1 - grid_pos_x2);
-    side1_dx = (double)(grid_pos_x2 - grid_pos_x2);
-    side2_dz = (double)(grid_pos_z1 - grid_pos_z1);
+    side1_dx = (double)(grid_pos_x2 - grid_pos_x1);
+    side2_dz = 0.0;//(double)(grid_pos_z1 - grid_pos_z1); 
     side1_dz = (double)(grid_pos_z2 - grid_pos_z1);
 
     /*   side 2