diff options
author | Teravus Ovares | 2008-08-16 19:03:29 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-08-16 19:03:29 +0000 |
commit | f191f38a3e4d45efd0ec1d7714b4331171cc8c6b (patch) | |
tree | 8c29f2cf6f4c3305eb9deef56a1673cf8c4d81a2 /OpenSim | |
parent | Update svn properties, minor formatting cleanup. (diff) | |
download | opensim-SC-f191f38a3e4d45efd0ec1d7714b4331171cc8c6b.zip opensim-SC-f191f38a3e4d45efd0ec1d7714b4331171cc8c6b.tar.gz opensim-SC-f191f38a3e4d45efd0ec1d7714b4331171cc8c6b.tar.bz2 opensim-SC-f191f38a3e4d45efd0ec1d7714b4331171cc8c6b.tar.xz |
* Fix a rare maptile shading error, terrain difference mod 1 = 0 + abs = oops.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index ae7e3aa..2e89e4b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1085,8 +1085,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
1085 | //float tmpval = (float)hm[x, y]; | 1085 | //float tmpval = (float)hm[x, y]; |
1086 | float heightvalue = (float)hm[x, y]; | 1086 | float heightvalue = (float)hm[x, y]; |
1087 | 1087 | ||
1088 | |||
1088 | if (heightvalue > (float)m_regInfo.RegionSettings.WaterHeight) | 1089 | if (heightvalue > (float)m_regInfo.RegionSettings.WaterHeight) |
1089 | { | 1090 | { |
1091 | |||
1090 | // scale height value | 1092 | // scale height value |
1091 | heightvalue = low + mid * (heightvalue - low) / mid; | 1093 | heightvalue = low + mid * (heightvalue - low) / mid; |
1092 | 1094 | ||
@@ -1108,13 +1110,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
1108 | //X | 1110 | //X |
1109 | // . | 1111 | // . |
1110 | // | 1112 | // |
1111 | 1113 | // Shade the terrain for shadows | |
1112 | if ((x - 1 > 0) && (y - 1 > 0)) | 1114 | if ((x - 1 > 0) && (y - 1 > 0)) |
1113 | { | 1115 | { |
1114 | hfvalue = (float)hm[x, y]; | 1116 | hfvalue = (float)hm[x, y]; |
1115 | hfvaluecompare = (float)hm[x - 1, y - 1]; | 1117 | hfvaluecompare = (float)hm[x - 1, y - 1]; |
1116 | hfdiff = hfvaluecompare - hfvalue; | 1118 | hfdiff = hfvaluecompare - hfvalue; |
1117 | 1119 | ||
1120 | |||
1118 | if (Single.IsInfinity(hfvalue) || Single.IsNaN(hfvalue)) | 1121 | if (Single.IsInfinity(hfvalue) || Single.IsNaN(hfvalue)) |
1119 | hfvalue = 0; | 1122 | hfvalue = 0; |
1120 | 1123 | ||
@@ -1127,7 +1130,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
1127 | } | 1130 | } |
1128 | else if (hfdiff < -0.3f) | 1131 | else if (hfdiff < -0.3f) |
1129 | { | 1132 | { |
1130 | hfdiffi = Math.Abs((int)((hfdiff * 4) + (hfdiff * 0.5))) + Math.Abs((int)(((hfdiff % 1) * 0.5f) * 10f)); | 1133 | // We have to desaturate and blacken the land at the same time |
1134 | // we use floats, colors use bytes, so shrink are space down to | ||
1135 | // 0-255 | ||
1136 | hfdiffi = Math.Abs((int)((hfdiff * 4) + (hfdiff * 0.5))) + 1; | ||
1137 | if (hfdiff % 1 != 0) | ||
1138 | { | ||
1139 | hfdiffi = hfdiffi + Math.Abs((int)(((hfdiff % 1) * 0.5f) * 10f) + 1); | ||
1140 | } | ||
1131 | //hfdiffi2 = (int)(hfdiff * 0.5f) + 1; | 1141 | //hfdiffi2 = (int)(hfdiff * 0.5f) + 1; |
1132 | if ((256 - y) - 1 > 0) | 1142 | if ((256 - y) - 1 > 0) |
1133 | { | 1143 | { |
@@ -1146,40 +1156,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1146 | 1156 | ||
1147 | } | 1157 | } |
1148 | 1158 | ||
1149 | /* | 1159 | |
1150 | // | ||
1151 | // . | ||
1152 | // X | ||
1153 | if ((x + 1 < 255) && (y + 1 < 255)) | ||
1154 | { | ||
1155 | hfvalue = (float)hm[x, y]; | ||
1156 | hfvaluecompare = (float)hm[x + 1, y + 1]; | ||
1157 | hfdiff = hfvaluecompare - hfvalue; | ||
1158 | |||
1159 | if (hfdiff > 0.3f) | ||
1160 | { | ||
1161 | |||
1162 | } | ||
1163 | else if (hfdiff < -0.3f) | ||
1164 | { | ||
1165 | hfdiffi = Math.Abs((int)hfdiff) + 1; | ||
1166 | if ((256 - y) + 1 < 256) | ||
1167 | { | ||
1168 | Color Shade = mapbmp.GetPixel(x + 1, (256 - y) + 1); | ||
1169 | |||
1170 | int r = Shade.R; | ||
1171 | int g = Shade.G; | ||
1172 | int b = Shade.B; | ||
1173 | Shade = Color.FromArgb((r - hfdiffi > 0) ? r - hfdiffi : 0, (g - hfdiffi > 0) ? g - hfdiffi : 0, (b - hfdiffi > 0) ? g - hfdiffi : 0); | ||
1174 | mapbmp.SetPixel(x + 1, (256 - y) + 1, Shade); | ||
1175 | } | ||
1176 | |||
1177 | } | ||
1178 | |||
1179 | |||
1180 | } | ||
1181 | */ | ||
1182 | //if ((x | ||
1183 | 1160 | ||
1184 | 1161 | ||
1185 | } | 1162 | } |