From 64a740ce284dfe10af7610383fd88f1e5bad0b81 Mon Sep 17 00:00:00 2001
From: 8vogt <8vogt@informatik.uni-hamburg.de>
Date: Thu, 18 Mar 2021 20:04:13 +0100
Subject: [PATCH] Bugfix: Asteroids now generate at larger distances. Therer
was an integer overflow happening, which caused asteroids not to generate at
large distances from the center.
---
.../MyAbstractProceduralCellModule.cs | 2 --
.../MyProceduralAsteroidsModule.cs | 12 +++++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/SEWorldGenPlugin/Generator/ProceduralGeneration/MyAbstractProceduralCellModule.cs b/SEWorldGenPlugin/Generator/ProceduralGeneration/MyAbstractProceduralCellModule.cs
index 7eefa45..a0bc350 100644
--- a/SEWorldGenPlugin/Generator/ProceduralGeneration/MyAbstractProceduralCellModule.cs
+++ b/SEWorldGenPlugin/Generator/ProceduralGeneration/MyAbstractProceduralCellModule.cs
@@ -101,8 +101,6 @@ public void MarkToLoadCellsInBounds(BoundingSphereD bounds)
{
if (m_toLoadCells.Contains(cellId)) continue;
- //MyPluginLog.Debug("Mark Loading cell " + cellId);
-
BoundingBoxD cellBounds = new BoundingBoxD(cellId * m_cellSize, (cellId + 1) * m_cellSize);
if (bounds.Contains(cellBounds) == ContainmentType.Disjoint) continue;
diff --git a/SEWorldGenPlugin/Generator/ProceduralGeneration/MyProceduralAsteroidsModule.cs b/SEWorldGenPlugin/Generator/ProceduralGeneration/MyProceduralAsteroidsModule.cs
index 3eb1e10..81b14f1 100644
--- a/SEWorldGenPlugin/Generator/ProceduralGeneration/MyProceduralAsteroidsModule.cs
+++ b/SEWorldGenPlugin/Generator/ProceduralGeneration/MyProceduralAsteroidsModule.cs
@@ -27,8 +27,8 @@ public class MyProceduralAsteroidsModule : MyAbstractProceduralCellModule
///
/// Cell size parameters
///
- private const int OBJECT_SIZE_MAX = 1024;
- private const int CELL_SIZE = OBJECT_SIZE_MAX * 10;
+ private const double OBJECT_SIZE_MAX = 1024;
+ private const double CELL_SIZE = OBJECT_SIZE_MAX * 10;
///
/// Reflexion of asteroid creation method of SE
@@ -257,8 +257,8 @@ protected override MyProceduralCell GenerateCellSeeds(Vector3I cellId)
MyProceduralCell cell = new MyProceduralCell(cellId, CELL_SIZE);
int cellSeed = CalculateCellSeed(cellId);
int index = 0;
- int subCellSize = (int)(OBJECT_SIZE_MAX * 1.5f / settings.AsteroidDensity);
- int subcells = CELL_SIZE / subCellSize;
+ double subCellSize = OBJECT_SIZE_MAX * 1.5f / settings.AsteroidDensity;
+ int subcells = (int)(CELL_SIZE / subCellSize);
using (MyRandom.Instance.PushSeed(cellSeed))
{
@@ -270,7 +270,7 @@ protected override MyProceduralCell GenerateCellSeeds(Vector3I cellId)
Vector3D position = new Vector3D(MyRandom.Instance.NextDouble(), MyRandom.Instance.NextDouble(), MyRandom.Instance.NextDouble());
position += (Vector3D)subcellId;
position *= subCellSize;
- position += cellId * CELL_SIZE;
+ position += ((Vector3D)cellId) * CELL_SIZE;
if (!MyEntities.IsInsideWorld(position) || (settings.WorldSize >= 0 && position.Length() > settings.WorldSize)) continue;
@@ -285,6 +285,8 @@ protected override MyProceduralCell GenerateCellSeeds(Vector3I cellId)
cellObjectSeed.Params.GeneratorSeed = m_definition.UseGeneratorSeed ? MyRandom.Instance.Next() : 0;
cell.AddObject(cellObjectSeed);
+
+ MyPluginLog.Debug("Adding seed");
}
}