Forgot to commit some stuff (noise+dynaterrain) from previous commit

This commit is contained in:
Remi Beges
2012-05-31 15:35:52 +02:00
parent 9008c36802
commit 4d975fa67e
21 changed files with 589 additions and 206 deletions

View File

@@ -54,6 +54,42 @@ void NzNoiseBase::ShufflePermutationTable()
perm[i] = perm[i & 255];
}
int NzNoiseBase::fastfloor(float n)
{
if(n >= 0)
return static_cast<int>(n);
else
return static_cast<int>(n-1);
}
int NzNoiseBase::JenkinsHash(int a, int b, int c)
{
a = a-b; a = a - c; a = a^(static_cast<unsigned int>(c) >> 13);
b = b-c; b = b - a; b = b^(a << 8);
c = c-a; c = c - b; c = c^(static_cast<unsigned int>(b) >> 13);
a = a-b; a = a - c; a = a^(static_cast<unsigned int>(c) >> 12);
b = b-c; b = b - a; b = b^(a << 16);
c = c-a; c = c - b; c = c^(static_cast<unsigned int>(b) >> 5);
a = a-b; a = a - c; a = a^(static_cast<unsigned int>(c) >> 3);
b = b-c; b = b - a; b = b^(a << 10);
c = c-a; c = c - b; c = c^(static_cast<unsigned int>(b) >> 15);
return c;
}
/*
//key = 64 bits
public long hash64shift(long key)
{
key = (~key) + (key << 21); // key = (key << 21) - key - 1;
key = key ^ (key >>> 24);
key = (key + (key << 3)) + (key << 8); // key * 265
key = key ^ (key >>> 14);
key = (key + (key << 2)) + (key << 4); // key * 21
key = key ^ (key >>> 28);
key = key + (key << 31);
return key;
}*/
NzNoiseBase::~NzNoiseBase()
{
//dtor