* Fix a rare maptile shading error, terrain difference mod 1 = 0 + abs = oops.

0.6.0-stable
Teravus Ovares 2008-08-16 19:03:29 +00:00
parent 6fa26f5b41
commit f191f38a3e
1 changed files with 13 additions and 36 deletions

View File

@ -1085,8 +1085,10 @@ namespace OpenSim.Region.Environment.Scenes
//float tmpval = (float)hm[x, y]; //float tmpval = (float)hm[x, y];
float heightvalue = (float)hm[x, y]; float heightvalue = (float)hm[x, y];
if (heightvalue > (float)m_regInfo.RegionSettings.WaterHeight) if (heightvalue > (float)m_regInfo.RegionSettings.WaterHeight)
{ {
// scale height value // scale height value
heightvalue = low + mid * (heightvalue - low) / mid; heightvalue = low + mid * (heightvalue - low) / mid;
@ -1108,13 +1110,14 @@ namespace OpenSim.Region.Environment.Scenes
//X //X
// . // .
// //
// Shade the terrain for shadows
if ((x - 1 > 0) && (y - 1 > 0)) if ((x - 1 > 0) && (y - 1 > 0))
{ {
hfvalue = (float)hm[x, y]; hfvalue = (float)hm[x, y];
hfvaluecompare = (float)hm[x - 1, y - 1]; hfvaluecompare = (float)hm[x - 1, y - 1];
hfdiff = hfvaluecompare - hfvalue; hfdiff = hfvaluecompare - hfvalue;
if (Single.IsInfinity(hfvalue) || Single.IsNaN(hfvalue)) if (Single.IsInfinity(hfvalue) || Single.IsNaN(hfvalue))
hfvalue = 0; hfvalue = 0;
@ -1127,7 +1130,14 @@ namespace OpenSim.Region.Environment.Scenes
} }
else if (hfdiff < -0.3f) else if (hfdiff < -0.3f)
{ {
hfdiffi = Math.Abs((int)((hfdiff * 4) + (hfdiff * 0.5))) + Math.Abs((int)(((hfdiff % 1) * 0.5f) * 10f)); // We have to desaturate and blacken the land at the same time
// we use floats, colors use bytes, so shrink are space down to
// 0-255
hfdiffi = Math.Abs((int)((hfdiff * 4) + (hfdiff * 0.5))) + 1;
if (hfdiff % 1 != 0)
{
hfdiffi = hfdiffi + Math.Abs((int)(((hfdiff % 1) * 0.5f) * 10f) + 1);
}
//hfdiffi2 = (int)(hfdiff * 0.5f) + 1; //hfdiffi2 = (int)(hfdiff * 0.5f) + 1;
if ((256 - y) - 1 > 0) if ((256 - y) - 1 > 0)
{ {
@ -1146,40 +1156,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/*
//
// .
// X
if ((x + 1 < 255) && (y + 1 < 255))
{
hfvalue = (float)hm[x, y];
hfvaluecompare = (float)hm[x + 1, y + 1];
hfdiff = hfvaluecompare - hfvalue;
if (hfdiff > 0.3f)
{
}
else if (hfdiff < -0.3f)
{
hfdiffi = Math.Abs((int)hfdiff) + 1;
if ((256 - y) + 1 < 256)
{
Color Shade = mapbmp.GetPixel(x + 1, (256 - y) + 1);
int r = Shade.R;
int g = Shade.G;
int b = Shade.B;
Shade = Color.FromArgb((r - hfdiffi > 0) ? r - hfdiffi : 0, (g - hfdiffi > 0) ? g - hfdiffi : 0, (b - hfdiffi > 0) ? g - hfdiffi : 0);
mapbmp.SetPixel(x + 1, (256 - y) + 1, Shade);
}
}
}
*/
//if ((x
} }