From 625c30d8bdee4f60c8437dc6004368f685435775 Mon Sep 17 00:00:00 2001 From: faketruth Date: Tue, 25 Oct 2011 18:57:38 +0000 Subject: Using SSE instructions for noise (terrain generation) Unfortunately the noise functions is only like 7% faster, so you won't even notice git-svn-id: http://mc-server.googlecode.com/svn/trunk@9 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunk.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/cChunk.cpp') diff --git a/source/cChunk.cpp b/source/cChunk.cpp index a8e8938a0..8e03ff6c7 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -678,13 +678,13 @@ void cChunk::SpreadLight(char* a_LightBuffer) float GetNoise( float x, float y, cNoise & a_Noise ) { - float oct1 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq1, y*cGenSettings::HeightFreq1 )*cGenSettings::HeightAmp1; - float oct2 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq2, y*cGenSettings::HeightFreq2 )*cGenSettings::HeightAmp2; - float oct3 = a_Noise.CubicNoise2D( x*cGenSettings::HeightFreq3, y*cGenSettings::HeightFreq3 )*cGenSettings::HeightAmp3; + float oct1 = a_Noise.SSE_CubicNoise2D( x*cGenSettings::HeightFreq1, y*cGenSettings::HeightFreq1 )*cGenSettings::HeightAmp1; + float oct2 = a_Noise.SSE_CubicNoise2D( x*cGenSettings::HeightFreq2, y*cGenSettings::HeightFreq2 )*cGenSettings::HeightAmp2; + float oct3 = a_Noise.SSE_CubicNoise2D( x*cGenSettings::HeightFreq3, y*cGenSettings::HeightFreq3 )*cGenSettings::HeightAmp3; - float height = a_Noise.CubicNoise2D( x*0.1f, y*0.1f )*2; + float height = a_Noise.SSE_CubicNoise2D( x*0.1f, y*0.1f )*2; - float flatness = ((a_Noise.CubicNoise2D( x*0.5f, y*0.5f ) + 1.f ) * 0.5f) * 1.1f; // 0 ... 1.5 + float flatness = ((a_Noise.SSE_CubicNoise2D( x*0.5f, y*0.5f ) + 1.f ) * 0.5f) * 1.1f; // 0 ... 1.5 flatness *= flatness * flatness; return (oct1 + oct2 + oct3) * flatness + height; @@ -836,8 +836,8 @@ void cChunk::GenerateTerrain() // int yy = TopY; int zz = z + m_PosZ*16; - float val1 = m_Noise.CubicNoise2D( xx*0.1f, zz*0.1f ); - float val2 = m_Noise.CubicNoise2D( xx*0.01f, zz*0.01f ); + float val1 = m_Noise.SSE_CubicNoise2D( xx*0.1f, zz*0.1f ); + float val2 = m_Noise.SSE_CubicNoise2D( xx*0.01f, zz*0.01f ); if( m_BlockType[index] == SandID ) { if( (val1 + val2 > 0.f) && (rand()%128) > 124 && m_BlockType[index] == E_BLOCK_SAND ) @@ -852,8 +852,8 @@ void cChunk::GenerateTerrain() } else if( m_BlockType[index] == GrassID ) { - float val3 = m_Noise.CubicNoise2D( xx*0.01f+10, zz*0.01f+10 ); - float val4 = m_Noise.CubicNoise2D( xx*0.05f+20, zz*0.05f+20 ); + float val3 = m_Noise.SSE_CubicNoise2D( xx*0.01f+10, zz*0.01f+10 ); + float val4 = m_Noise.SSE_CubicNoise2D( xx*0.05f+20, zz*0.05f+20 ); if( val1 + val2 > 0.2f && (rand()%128) > 124 ) cRoot::Get()->GetWorld()->GrowTree( xx, TopY, zz ); else if( val3 > 0.2f && (rand()%128) > 124 ) -- cgit v1.2.3