summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Generating/ComposableGenerator.cpp32
-rw-r--r--src/Generating/RoughRavines.cpp51
-rw-r--r--src/Generating/RoughRavines.h30
-rw-r--r--src/Noise.h6
4 files changed, 99 insertions, 20 deletions
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index 3326dda36..0d9bedf45 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -410,18 +410,30 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "RoughRavines") == 0)
{
- int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256);
- int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128);
- int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 128);
- int MinSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMinSize", 64);
- double MaxCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCenterWidth", 8);
- double MinCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCenterWidth", 2);
- double MaxRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxRoughness", 0.2);
- double MinRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinRoughness", 0.05);
+ int GridSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesGridSize", 256);
+ int MaxOffset = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxOffset", 128);
+ int MaxSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMaxSize", 128);
+ int MinSize = a_IniFile.GetValueSetI("Generator", "RoughRavinesMinSize", 64);
+ double MaxCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCenterWidth", 8);
+ double MinCenterWidth = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCenterWidth", 2);
+ double MaxRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxRoughness", 0.2);
+ double MinRoughness = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinRoughness", 0.05);
+ double MaxFloorHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxFloorHeightEdge", 8);
+ double MinFloorHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinFloorHeightEdge", 30);
+ double MaxFloorHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxFloorHeightCenter", 20);
+ double MinFloorHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinFloorHeightCenter", 6);
+ double MaxCeilingHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCeilingHeightEdge", 56);
+ double MinCeilingHeightEdge = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCeilingHeightEdge", 38);
+ double MaxCeilingHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMaxCeilingHeightCenter", 58);
+ double MinCeilingHeightCenter = a_IniFile.GetValueSetF("Generator", "RoughRavinesMinCeilingHeightCenter", 36);
m_FinishGens.push_back(new cRoughRavines(
Seed, MaxSize, MinSize,
- (float)MaxCenterWidth, (float)MinCenterWidth,
- (float)MaxRoughness, (float)MinRoughness,
+ (float)MaxCenterWidth, (float)MinCenterWidth,
+ (float)MaxRoughness, (float)MinRoughness,
+ (float)MaxFloorHeightEdge, (float)MinFloorHeightEdge,
+ (float)MaxFloorHeightCenter, (float)MinFloorHeightCenter,
+ (float)MaxCeilingHeightEdge, (float)MinCeilingHeightEdge,
+ (float)MaxCeilingHeightCenter, (float)MinCeilingHeightCenter,
GridSize, MaxOffset
));
}
diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp
index 8dec791c9..badc7768e 100644
--- a/src/Generating/RoughRavines.cpp
+++ b/src/Generating/RoughRavines.cpp
@@ -20,7 +20,13 @@ class cRoughRavine :
typedef cGridStructGen::cStructure super;
public:
- cRoughRavine(int a_Seed, int a_Size, float a_CenterWidth, float a_Roughness, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) :
+ cRoughRavine(
+ int a_Seed, int a_Size,
+ float a_CenterWidth, float a_Roughness,
+ float a_FloorHeightEdge1, float a_FloorHeightEdge2, float a_FloorHeightCenter,
+ float a_CeilingHeightEdge1, float a_CeilingHeightEdge2, float a_CeilingHeightCenter,
+ int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ
+ ) :
super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
m_Seed(a_Seed + 100),
m_Noise(a_Seed + 100),
@@ -35,9 +41,9 @@ public:
float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations
float OfsX = sin(Angle) * Len;
float OfsZ = cos(Angle) * Len;
- m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, 42, 34);
- m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, 62, 16);
- m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, 44, 32);
+ m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, a_CeilingHeightEdge1, a_FloorHeightEdge1);
+ m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, a_CeilingHeightCenter, a_FloorHeightCenter);
+ m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, a_CeilingHeightEdge2, a_FloorHeightEdge2);
// Calculate the points in between, recursively:
SubdivideLine(0, Half);
@@ -235,7 +241,11 @@ cRoughRavines::cRoughRavines(
int a_Seed,
int a_MaxSize, int a_MinSize,
float a_MaxCenterWidth, float a_MinCenterWidth,
- float a_MaxRoughness, float a_MinRoughness,
+ float a_MaxRoughness, float a_MinRoughness,
+ float a_MaxFloorHeightEdge, float a_MinFloorHeightEdge,
+ float a_MaxFloorHeightCenter, float a_MinFloorHeightCenter,
+ float a_MaxCeilingHeightEdge, float a_MinCeilingHeightEdge,
+ float a_MaxCeilingHeightCenter, float a_MinCeilingHeightCenter,
int a_GridSize, int a_MaxOffset
) :
super(a_Seed, a_GridSize, a_GridSize, a_MaxOffset, a_MaxOffset, a_MaxSize, a_MaxSize, 64),
@@ -245,7 +255,15 @@ cRoughRavines::cRoughRavines(
m_MaxCenterWidth(a_MaxCenterWidth),
m_MinCenterWidth(a_MinCenterWidth),
m_MaxRoughness(a_MaxRoughness),
- m_MinRoughness(a_MinRoughness)
+ m_MinRoughness(a_MinRoughness),
+ m_MaxFloorHeightEdge(a_MaxFloorHeightEdge),
+ m_MinFloorHeightEdge(a_MinFloorHeightEdge),
+ m_MaxFloorHeightCenter(a_MaxFloorHeightCenter),
+ m_MinFloorHeightCenter(a_MinFloorHeightCenter),
+ m_MaxCeilingHeightEdge(a_MaxCeilingHeightEdge),
+ m_MinCeilingHeightEdge(a_MinCeilingHeightEdge),
+ m_MaxCeilingHeightCenter(a_MaxCeilingHeightCenter),
+ m_MinCeilingHeightCenter(a_MinCeilingHeightCenter)
{
if (m_MinSize > m_MaxSize)
{
@@ -274,10 +292,25 @@ cRoughRavines::cRoughRavines(
cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
+ // Pick a random value for each of the ravine's parameters:
int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize); // Random int from m_MinSize to m_MaxSize
- float CenterWidth = m_MinCenterWidth + abs(m_Noise.IntNoise2D(a_GridX, a_GridZ + 10)) * (m_MaxCenterWidth - m_MinCenterWidth); // Random float from m_MinCenterWidth to m_MaxCenterWidth
- float Roughness = m_MinRoughness + abs(m_Noise.IntNoise2D(a_GridX + 10, a_GridZ)) * (m_MaxRoughness - m_MinRoughness); // Random float from m_MinRoughness to m_MaxRoughness
- return cStructurePtr(new cRoughRavine(m_Seed, Size, CenterWidth, Roughness, a_GridX, a_GridZ, a_OriginX, a_OriginZ));
+ float CenterWidth = m_Noise.IntNoise2DInRange(a_GridX + 10, a_GridZ, m_MinCenterWidth, m_MaxCenterWidth);
+ float Roughness = m_Noise.IntNoise2DInRange(a_GridX + 20, a_GridZ, m_MinRoughness, m_MaxRoughness);
+ float FloorHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 30, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge);
+ float FloorHeightEdge2 = m_Noise.IntNoise2DInRange(a_GridX + 40, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge);
+ float FloorHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 50, a_GridZ, m_MinFloorHeightCenter, m_MaxFloorHeightCenter);
+ float CeilingHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 60, a_GridZ, m_MinCeilingHeightEdge, m_MaxCeilingHeightEdge);
+ float CeilingHeightEdge2 = m_Noise.IntNoise2DInRange(a_GridX + 70, a_GridZ, m_MinCeilingHeightEdge, m_MaxCeilingHeightEdge);
+ float CeilingHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 80, a_GridZ, m_MinCeilingHeightCenter, m_MaxCeilingHeightCenter);
+
+ // Create a ravine:
+ return cStructurePtr(new cRoughRavine(
+ m_Seed,
+ Size, CenterWidth, Roughness,
+ FloorHeightEdge1, FloorHeightEdge2, FloorHeightCenter,
+ CeilingHeightEdge1, CeilingHeightEdge2, CeilingHeightCenter,
+ a_GridX, a_GridZ, a_OriginX, a_OriginZ
+ ));
}
diff --git a/src/Generating/RoughRavines.h b/src/Generating/RoughRavines.h
index dce2f9ba7..4c905b641 100644
--- a/src/Generating/RoughRavines.h
+++ b/src/Generating/RoughRavines.h
@@ -24,7 +24,11 @@ public:
int a_Seed,
int a_MaxSize, int a_MinSize,
float a_MaxCenterWidth, float a_MinCenterWidth,
- float a_MaxRoughness, float a_MinRoughness,
+ float a_MaxRoughness, float a_MinRoughness,
+ float a_MaxFloorHeightEdge, float a_MinFloorHeightEdge,
+ float a_MaxFloorHeightCenter, float a_MinFloorHeightCenter,
+ float a_MaxCeilingHeightEdge, float a_MinCeilingHeightEdge,
+ float a_MaxCeilingHeightCenter, float a_MinCeilingHeightCenter,
int a_GridSize, int a_MaxOffset
);
@@ -49,6 +53,30 @@ protected:
/** Minimum roughness of the ravine */
float m_MinRoughness;
+ /** Maximum floor height at the ravine's edge */
+ float m_MaxFloorHeightEdge;
+
+ /** Minimum floor height at the ravine's edge */
+ float m_MinFloorHeightEdge;
+
+ /** Maximum floor height at the ravine's center */
+ float m_MaxFloorHeightCenter;
+
+ /** Minimum floor height at the ravine's center */
+ float m_MinFloorHeightCenter;
+
+ /** Maximum ceiling height at the ravine's edge */
+ float m_MaxCeilingHeightEdge;
+
+ /** Minimum ceiling height at the ravine's edge */
+ float m_MinCeilingHeightEdge;
+
+ /** Maximum ceiling height at the ravine's center */
+ float m_MaxCeilingHeightCenter;
+
+ /** Minimum ceiling height at the ravine's center */
+ float m_MinCeilingHeightCenter;
+
// cGridStructGen overrides:
virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override;
};
diff --git a/src/Noise.h b/src/Noise.h
index 48a1c73f7..e69e5cdad 100644
--- a/src/Noise.h
+++ b/src/Noise.h
@@ -33,6 +33,12 @@ public:
INLINE NOISE_DATATYPE IntNoise2D(int a_X, int a_Y) const;
INLINE NOISE_DATATYPE IntNoise3D(int a_X, int a_Y, int a_Z) const;
+ // Return a float number in the specified range:
+ INLINE NOISE_DATATYPE IntNoise2DInRange(int a_X, int a_Y, float a_Min, float a_Max) const
+ {
+ return a_Min + std::abs(IntNoise2D(a_X, a_Y)) * (a_Max - a_Min);
+ }
+
// Note: These functions have a mod8-irregular chance - each of the mod8 remainders has different chance of occurrence. Divide by 8 to rectify.
INLINE int IntNoise1DInt(int a_X) const;
INLINE int IntNoise2DInt(int a_X, int a_Y) const;