Skip to content

Commit

Permalink
Releasing LibNoise 1.3
Browse files Browse the repository at this point in the history
This version does not contain any major API changes, but it does alter
the internal member naming conventions and expands the documentation.
Making a new release so that anyone downloading it is working from the
latest stable codebase.

Merge branch 'release/1.3'
  • Loading branch information
Ricardo J. Mendez committed Jul 27, 2014
2 parents fdb2ab5 + 256d4b2 commit 794869e
Show file tree
Hide file tree
Showing 35 changed files with 1,146 additions and 1,154 deletions.
93 changes: 45 additions & 48 deletions Generator/Billow.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
namespace LibNoise.Unity.Generator
{
using System;

using UnityEngine;
using System;
using UnityEngine;

namespace LibNoise.Generator
{
/// <summary>
/// Provides a noise module that outputs a three-dimensional billowy noise. [GENERATOR]
/// </summary>
public class Billow : ModuleBase
{
#region Fields

private double m_frequency = 1.0;
private double m_lacunarity = 2.0;
private QualityMode m_quality = QualityMode.Medium;
private int m_octaveCount = 6;
private double m_persistence = 0.5;
private int m_seed = 0;
private double _frequency = 1.0;
private double _lacunarity = 2.0;
private QualityMode _quality = QualityMode.Medium;
private int _octaveCount = 6;
private double _persistence = 0.5;
private int _seed;

#endregion

Expand All @@ -39,15 +38,16 @@ public Billow()
/// <param name="octaves">The number of octaves of the billowy noise.</param>
/// <param name="seed">The seed of the billowy noise.</param>
/// <param name="quality">The quality of the billowy noise.</param>
public Billow(double frequency, double lacunarity, double persistence, int octaves, int seed, QualityMode quality)
public Billow(double frequency, double lacunarity, double persistence, int octaves, int seed,
QualityMode quality)
: base(0)
{
this.Frequency = frequency;
this.Lacunarity = lacunarity;
this.OctaveCount = octaves;
this.Persistence = persistence;
this.Seed = seed;
this.Quality = quality;
Frequency = frequency;
Lacunarity = lacunarity;
OctaveCount = octaves;
Persistence = persistence;
Seed = seed;
Quality = quality;
}

#endregion
Expand All @@ -59,53 +59,53 @@ public Billow(double frequency, double lacunarity, double persistence, int octav
/// </summary>
public double Frequency
{
get { return this.m_frequency; }
set { this.m_frequency = value; }
get { return _frequency; }
set { _frequency = value; }
}

/// <summary>
/// Gets or sets the lacunarity of the billowy noise.
/// </summary>
public double Lacunarity
{
get { return this.m_lacunarity; }
set { this.m_lacunarity = value; }
get { return _lacunarity; }
set { _lacunarity = value; }
}

/// <summary>
/// Gets or sets the quality of the billowy noise.
/// </summary>
public QualityMode Quality
{
get { return this.m_quality; }
set { this.m_quality = value; }
get { return _quality; }
set { _quality = value; }
}

/// <summary>
/// Gets or sets the number of octaves of the billowy noise.
/// </summary>
public int OctaveCount
{
get { return this.m_octaveCount; }
set { this.m_octaveCount = (int)Mathf.Clamp(value, 1, Utils.OctavesMaximum); }
get { return _octaveCount; }
set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); }
}

/// <summary>
/// Gets or sets the persistence of the billowy noise.
/// </summary>
public double Persistence
{
get { return this.m_persistence; }
set { this.m_persistence = value; }
get { return _persistence; }
set { _persistence = value; }
}

/// <summary>
/// Gets or sets the seed of the billowy noise.
/// </summary>
public int Seed
{
get { return this.m_seed; }
set { this.m_seed = value; }
get { return _seed; }
set { _seed = value; }
}

#endregion
Expand All @@ -121,27 +121,24 @@ public int Seed
/// <returns>The resulting output value.</returns>
public override double GetValue(double x, double y, double z)
{
double value = 0.0;
double signal = 0.0;
double curp = 1.0;
double nx, ny, nz;
long seed;
x *= this.m_frequency;
y *= this.m_frequency;
z *= this.m_frequency;
for (int i = 0; i < this.m_octaveCount; i++)
var value = 0.0;
var curp = 1.0;
x *= _frequency;
y *= _frequency;
z *= _frequency;
for (var i = 0; i < _octaveCount; i++)
{
nx = Utils.MakeInt32Range(x);
ny = Utils.MakeInt32Range(y);
nz = Utils.MakeInt32Range(z);
seed = (this.m_seed + i) & 0xffffffff;
signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, this.m_quality);
var nx = Utils.MakeInt32Range(x);
var ny = Utils.MakeInt32Range(y);
var nz = Utils.MakeInt32Range(z);
var seed = (_seed + i) & 0xffffffff;
var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality);
signal = 2.0 * Math.Abs(signal) - 1.0;
value += signal * curp;
x *= this.m_lacunarity;
y *= this.m_lacunarity;
z *= this.m_lacunarity;
curp *= this.m_persistence;
x *= _lacunarity;
y *= _lacunarity;
z *= _lacunarity;
curp *= _persistence;
}
return value + 0.5;
}
Expand Down
12 changes: 6 additions & 6 deletions Generator/Checker.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace LibNoise.Unity.Generator
using System;

namespace LibNoise.Generator
{
using System;

/// <summary>
/// Provides a noise module that outputs a checkerboard pattern. [GENERATOR]
/// </summary>
Expand Down Expand Up @@ -30,9 +30,9 @@ public Checker()
/// <returns>The resulting output value.</returns>
public override double GetValue(double x, double y, double z)
{
int ix = (int)(Math.Floor(Utils.MakeInt32Range(x)));
int iy = (int)(Math.Floor(Utils.MakeInt32Range(y)));
int iz = (int)(Math.Floor(Utils.MakeInt32Range(z)));
var ix = (int) (Math.Floor(Utils.MakeInt32Range(x)));
var iy = (int) (Math.Floor(Utils.MakeInt32Range(y)));
var iz = (int) (Math.Floor(Utils.MakeInt32Range(z)));
return (ix & 1 ^ iy & 1 ^ iz & 1) != 0 ? -1.0 : 1.0;
}

Expand Down
14 changes: 6 additions & 8 deletions Generator/Const.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
namespace LibNoise.Unity.Generator
namespace LibNoise.Generator
{
using System;

/// <summary>
/// Provides a noise module that outputs a constant value. [GENERATOR]
/// </summary>
public class Const : ModuleBase
{
#region Fields

private double m_value = 0.0;
private double _value;

#endregion

Expand All @@ -30,7 +28,7 @@ public Const()
public Const(double value)
: base(0)
{
this.Value = value;
Value = value;
}

#endregion
Expand All @@ -42,8 +40,8 @@ public Const(double value)
/// </summary>
public double Value
{
get { return this.m_value; }
set { this.m_value = value; }
get { return _value; }
set { _value = value; }
}

#endregion
Expand All @@ -59,7 +57,7 @@ public double Value
/// <returns>The resulting output value.</returns>
public override double GetValue(double x, double y, double z)
{
return this.m_value;
return _value;
}

#endregion
Expand Down
26 changes: 13 additions & 13 deletions Generator/Cylinders.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace LibNoise.Unity.Generator
using System;

namespace LibNoise.Generator
{
using System;

/// <summary>
/// Provides a noise module that outputs concentric cylinders. [GENERATOR]
/// </summary>
public class Cylinders : ModuleBase
{
#region Fields

private double m_frequency = 1.0;
private double _frequency = 1.0;

#endregion

Expand All @@ -30,7 +30,7 @@ public Cylinders()
public Cylinders(double frequency)
: base(0)
{
this.Frequency = frequency;
Frequency = frequency;
}

#endregion
Expand All @@ -42,8 +42,8 @@ public Cylinders(double frequency)
/// </summary>
public double Frequency
{
get { return this.m_frequency; }
set { this.m_frequency = value; }
get { return _frequency; }
set { _frequency = value; }
}

#endregion
Expand All @@ -59,12 +59,12 @@ public double Frequency
/// <returns>The resulting output value.</returns>
public override double GetValue(double x, double y, double z)
{
x *= this.m_frequency;
z *= this.m_frequency;
double dfc = Math.Sqrt(x * x + z * z);
double dfss = dfc - Math.Floor(dfc);
double dfls = 1.0 - dfss;
double nd = Math.Min(dfss, dfls);
x *= _frequency;
z *= _frequency;
var dfc = Math.Sqrt(x * x + z * z);
var dfss = dfc - Math.Floor(dfc);
var dfls = 1.0 - dfss;
var nd = Math.Min(dfss, dfls);
return 1.0 - (nd * 4.0);
}

Expand Down
Loading

0 comments on commit 794869e

Please sign in to comment.