Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
Multiple cellular options, code merge/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Auburn committed Jul 1, 2016
1 parent 8e59844 commit d84f286
Show file tree
Hide file tree
Showing 3 changed files with 625 additions and 584 deletions.
26 changes: 0 additions & 26 deletions FastNoiseSIMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,6 @@ int GetFastestSIMD()
{
//https://github.com/Mysticial/FeatureDetector

//__try
//{
// _mm256_movemask_epi8(_mm256_setzero_si256());
//}
//__except (GetExceptionCode() == STATUS_ILLEGAL_INSTRUCTION || GetExceptionCode() == STATUS_PRIVILEGED_INSTRUCTION)
//{
// __try
// {
// _mm_testz_si128(_mm_setzero_si128(), _mm_setzero_si128());
// }
// __except (GetExceptionCode() == STATUS_ILLEGAL_INSTRUCTION || GetExceptionCode() == STATUS_PRIVILEGED_INSTRUCTION)
// {
// __try
// {
// _mm_lfence();
// }
// __except (GetExceptionCode() == STATUS_ILLEGAL_INSTRUCTION || GetExceptionCode() == STATUS_PRIVILEGED_INSTRUCTION)
// {
// return FN_NO_SIMD_FALLBACK;
// }
// return FN_SSE2;
// }
// return FN_SSE41;
//}
//return FN_AVX2;

int cpuInfo[4];

cpuid(cpuInfo, 0);
Expand Down
16 changes: 15 additions & 1 deletion FastNoiseSIMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class FastNoiseSIMD
enum NoiseType { Value, ValueFractal, Gradient, GradientFractal, Simplex, SimplexFractal, WhiteNoise, Cellular };
enum FractalType { FBM, Billow, RigidMulti };

enum CellularDistanceFunction { Euclidean, Manhattan, Natural };
enum CellularReturnType { CellValue, Distance, Distance2, Distance2Add, Distance2Sub, Distance2Mul, Distance2Div };

// Creates new FastNoiseSIMD for the highest supported instuction set of the CPU
static FastNoiseSIMD* NewFastNoiseSIMD(int seed = 1337);

Expand All @@ -102,7 +105,6 @@ class FastNoiseSIMD
// Caution: Setting this manually can cause crashes on CPUs that do not support that level
static void SetSIMDLevel(int level) { s_currentSIMDLevel = level; }


// Free a noise set from memory
static void FreeNoiseSet(float* noiseSet);

Expand Down Expand Up @@ -144,6 +146,15 @@ class FastNoiseSIMD
void SetFractalType(FractalType fractalType) { m_fractalType = fractalType; }


// Sets return type from cellular noise calculations
// Default: Distance
void SetCellularReturnType(CellularReturnType cellularReturnType) { m_cellularReturnType = cellularReturnType; }

// Sets distance function used in cellular noise calculations
// Default: Euclidean
void SetCellularDistanceFunction(CellularDistanceFunction cellularDistanceFunction) { m_cellularDistanceFunction = cellularDistanceFunction; }


virtual float* GetEmptySet(int size) = 0;
float* GetEmptySet(int xSize, int ySize, int zSize) { return GetEmptySet(xSize*ySize*zSize); };

Expand Down Expand Up @@ -187,6 +198,9 @@ class FastNoiseSIMD
float m_lacunarity = 2.0f;
float m_gain = 0.5f;
FractalType m_fractalType = FBM;

CellularDistanceFunction m_cellularDistanceFunction = Euclidean;
CellularReturnType m_cellularReturnType = Distance;

static int s_currentSIMDLevel;
};
Expand Down
Loading

0 comments on commit d84f286

Please sign in to comment.