فهرست منبع

improve fluid model builder

Kolja Strohm 8 ماه پیش
والد
کامیت
286349936b
1فایلهای تغییر یافته به همراه16 افزوده شده و 5 حذف شده
  1. 16 5
      FactoryCraft/ChunkFluidModel.cpp

+ 16 - 5
FactoryCraft/ChunkFluidModel.cpp

@@ -98,10 +98,12 @@ bool ChunkFluidModel::isPartOfGroundModel(
     else
     {
         int naighborIndex = Chunk::index(neighborLocation);
-        if (!blocks()[naighborIndex]
-            || !blocks()[naighborIndex]
-                    ->zBlockType()
-                    ->isFluid())
+        int currIndex = Chunk::index(location);
+        if (!blocks()[naighborIndex] || !isPartOfModel(blocks()[naighborIndex])
+            || blocks()[currIndex]->zBlockType()
+                   != blocks()[naighborIndex]->zBlockType()
+            || blocks()[naighborIndex]->getDistanceToSource()
+                   > blocks()[currIndex]->getDistanceToSource())
         {
             needed = 1;
         }
@@ -139,6 +141,14 @@ void ChunkFluidModel::buildModel()
                         (i / WORLD_HEIGHT) / CHUNK_SIZE,
                         (i / WORLD_HEIGHT) % CHUNK_SIZE,
                         i % WORLD_HEIGHT);
+                    Framework::Vec3<int> aboveLocation
+                        = location
+                        + getDirection(Direction::TOP);
+                    int aboveIndex = Chunk::index(aboveLocation);
+                    bool sameAbove = aboveLocation.z < WORLD_HEIGHT
+						&& blocks()[aboveIndex]
+						&& blocks()[aboveIndex]->zBlockType()
+							   == blocks()[i]->zBlockType();
                     if (isPartOfGroundModel(location, index))
                     {
                         if (!groundModelBuidler.get(
@@ -196,7 +206,8 @@ void ChunkFluidModel::buildModel()
                                 = groundVertexCount;
                             groundVerticies[groundVertexCount++]
                                 = vBuffer[polygon->indexList[vi]];
-                            if (groundVerticies[groundVertexCount - 1].pos.z > 0)
+                            if (groundVerticies[groundVertexCount - 1].pos.z > 0
+                                && !sameAbove)
                             {
                                 char maxFlowDist = blocks()[i]
                                                        ->zBlockType()