Revert "a few more changes on terrain"

This reverts commit 9a02b55bf2.
This commit is contained in:
lickx
2025-04-24 08:13:29 +02:00
parent cb1bde70db
commit ce1f31864f
7 changed files with 53 additions and 78 deletions

View File

@@ -31,6 +31,8 @@ using System.IO;
using System.IO.Compression;
using System.Reflection;
using OpenMetaverse;
using log4net;
namespace OpenSim.Framework
@@ -359,35 +361,30 @@ namespace OpenSim.Framework
public unsafe void GetPatchMinMax(int px, int py, out float zmin, out float zmax)
{
float min, max;
zmax = float.MinValue;
zmin = float.MaxValue;
int mpy = Constants.TerrainPatchSize * py;
fixed (float* map = m_heightmap)
{
float* p = map + px * m_mapPatchsStride + Constants.TerrainPatchSize * py;
float* endp = p + m_mapPatchsStride;
min = max = *p;
float* y = p;
int j = Constants.TerrainPatchSize - 1;
do
float* p = map + px * m_mapPatchsStride;
float* pend = p + m_mapPatchsStride;
while (p < pend)
{
do
float* yt = p + mpy;
float* ytend = yt + 16;
while(yt < ytend)
{
float val = *y++;
if (val > max)
max = val;
else if (val < min)
min = val;
float val = *yt;
if (val > zmax)
zmax = val;
if (val < zmin)
zmin = val;
yt++;
}
while(--j > 0);
p += m_mapStride;
y = p;
j = Constants.TerrainPatchSize;
}
while (p < endp);
}
zmin = min;
zmax = max;
}
public unsafe void GetPatchBlock(float* block, int px, int py, float sub, float premult)

View File

@@ -26,8 +26,6 @@
*/
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
{
@@ -38,27 +36,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
int startX, int endX, int startY, int endY)
{
if(height < 0)
height = 0;
else if(height > Constants.MaxTerrainHeightmap)
height = Constants.MaxTerrainHeightmap;
strength *= 0.04f;
if(strength >= .999f)
{
for (int x = startX; x <= endX; x++)
{
for (int y = startY; y <= endY; y++)
{
if (fillArea[x, y])
map[x, y] = height;
}
}
return;
}
if(strength < 1e-3)
return;
if(strength > 1.0f)
strength = 1.0f;
for (int x = startX; x <= endX; x++)
{

View File

@@ -36,9 +36,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
int startX, int endX, int startY, int endY)
{
for (int x = startX; x <= endX; ++x)
int x,y;
for (x = startX; x <= endX; ++x)
{
for (int y = startY; y <= endY; ++y)
for (y = startY; y <= endY; ++y)
{
if (fillArea[x, y])
{

View File

@@ -39,18 +39,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
int startX, int endX, int startY, int endY)
{
strength *= 0.08f;
if(strength < 1e-4f)
return;
for (int x = startX; x <= endX; x++)
int x, y;
for (x = startX; x <= endX; x++)
{
for (int y = startY; y <= endY; y++)
for (y = startY; y <= endY; y++)
{
if (fillArea[x, y])
{
float noise = (float)TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
map[x, y] += noise * strength;
if(map[x, y] < 0)
map[x, y] = 0;
}
}
}

View File

@@ -36,9 +36,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
int startX, int endX, int startY, int endY)
{
for (int x = startX; x <= endX; x++)
int x,y;
for (x = startX; x <= endX; x++)
{
for (int y = startY; y <= endY; y++)
for (y = startY; y <= endY; y++)
{
if (fillArea[x, y])
{

View File

@@ -45,37 +45,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
/// </summary>
/// <param name="map">the current heightmap</param>
/// <param name="fillArea">array indicating which sections of the map are to be reverted</param>
/// <param name="strength"></param>
/// <param name="strength">unused</param>
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
int startX, int endX, int startY, int endY)
{
int x, y;
strength *= 2f;
if (strength >= .999f)
{
for (int x = startX; x <= endX; x++)
{
for (int y = startY; y <= endY; y++)
{
if (fillArea[x, y])
{
map[x, y] = m_revertmap[x, y];
}
}
}
return;
}
if (strength > 1.0f)
strength = 1.0f;
if(strength < 1e-4f)
return;
float OneMinusstrength = 1.0f - strength;
for (int x = startX; x <= endX; x++)
for (x = startX; x <= endX; x++)
{
for (int y = startY; y <= endY; y++)
for (y = startY; y <= endY; y++)
{
if (fillArea[x, y])
{
map[x, y] = map[x, y] * OneMinusstrength + m_revertmap[x, y] * strength;
map[x, y] = map[x, y] * (1.0f - strength) + m_revertmap[x, y] * strength;
}
}
}

View File

@@ -45,12 +45,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
sy = 4;
strength *= 0.002f;
if(strength < 1e-4f)
return;
if(strength > 1.0f)
strength = 1.0f;
float OneMinusstrength = 1.0f - strength;
float[,] tweak = new float[endX - startX + 1, endY - startY + 1];
for (int x = startX, i = 0; x <= endX; x++, i++)
{
for (int y = startY, j = 0; y <= endY; y++, j++)
@@ -75,7 +74,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
}
}
}
map[x, y] = OneMinusstrength * map[x, y] + strength * average / avgsteps;
tweak[i, j] = average / avgsteps;
}
}
for (int x = startX, i = 0; x <= endX; x++, i++)
{
for (int y = startY, j = 0; y <= endY; y++, j++)
{
float ty = tweak[i, j];
if (ty == 0.0)
continue;
map[x, y] = (1.0f - strength) * map[x, y] + strength * ty;
}
}
}