diff options
author | Jeff Ames | 2008-05-01 14:31:30 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 14:31:30 +0000 |
commit | d51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch) | |
tree | d3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/World | |
parent | * Looks like I had the bamboo build right in the first place - it was just th... (diff) | |
download | opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2 opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz |
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
47 files changed, 6986 insertions, 6986 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs index efc5234..9ac3cc3 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs | |||
@@ -1,1000 +1,1000 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using Axiom.Math; | 30 | using Axiom.Math; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
36 | using OpenSim.Region.Physics.Manager; | 36 | using OpenSim.Region.Physics.Manager; |
37 | 37 | ||
38 | namespace OpenSim.Region.Environment.Modules.World.Land | 38 | namespace OpenSim.Region.Environment.Modules.World.Land |
39 | { | 39 | { |
40 | public class LandChannel : ILandChannel | 40 | public class LandChannel : ILandChannel |
41 | { | 41 | { |
42 | #region Constants | 42 | #region Constants |
43 | 43 | ||
44 | //Land types set with flags in ParcelOverlay. | 44 | //Land types set with flags in ParcelOverlay. |
45 | //Only one of these can be used. | 45 | //Only one of these can be used. |
46 | public const float BAN_LINE_SAFETY_HIEGHT = 100; | 46 | public const float BAN_LINE_SAFETY_HIEGHT = 100; |
47 | public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 | 47 | public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 |
48 | public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 | 48 | public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 |
49 | 49 | ||
50 | //RequestResults (I think these are right, they seem to work): | 50 | //RequestResults (I think these are right, they seem to work): |
51 | public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land | 51 | public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land |
52 | public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land | 52 | public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land |
53 | 53 | ||
54 | //ParcelSelectObjects | 54 | //ParcelSelectObjects |
55 | public const int LAND_SELECT_OBJECTS_GROUP = 4; | 55 | public const int LAND_SELECT_OBJECTS_GROUP = 4; |
56 | public const int LAND_SELECT_OBJECTS_OTHER = 8; | 56 | public const int LAND_SELECT_OBJECTS_OTHER = 8; |
57 | public const int LAND_SELECT_OBJECTS_OWNER = 2; | 57 | public const int LAND_SELECT_OBJECTS_OWNER = 2; |
58 | public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 | 58 | public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 |
59 | public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 | 59 | public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 |
60 | public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 | 60 | public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 |
61 | public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 | 61 | public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 |
62 | public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 | 62 | public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 |
63 | public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 | 63 | public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 |
64 | 64 | ||
65 | //These are other constants. Yay! | 65 | //These are other constants. Yay! |
66 | public const int START_LAND_LOCAL_ID = 1; | 66 | public const int START_LAND_LOCAL_ID = 1; |
67 | 67 | ||
68 | #endregion | 68 | #endregion |
69 | 69 | ||
70 | private int[,] landIDList = new int[64,64]; | 70 | private int[,] landIDList = new int[64,64]; |
71 | private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); | 71 | private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); |
72 | 72 | ||
73 | private bool landPrimCountTainted = false; | 73 | private bool landPrimCountTainted = false; |
74 | private int lastLandLocalID = START_LAND_LOCAL_ID - 1; | 74 | private int lastLandLocalID = START_LAND_LOCAL_ID - 1; |
75 | 75 | ||
76 | private bool m_allowedForcefulBans = true; | 76 | private bool m_allowedForcefulBans = true; |
77 | private Scene m_scene; | 77 | private Scene m_scene; |
78 | 78 | ||
79 | public LandChannel(Scene scene) | 79 | public LandChannel(Scene scene) |
80 | { | 80 | { |
81 | m_scene = scene; | 81 | m_scene = scene; |
82 | landIDList.Initialize(); | 82 | landIDList.Initialize(); |
83 | } | 83 | } |
84 | 84 | ||
85 | #region Land Object From Storage Functions | 85 | #region Land Object From Storage Functions |
86 | 86 | ||
87 | public void IncomingLandObjectsFromStorage(List<LandData> data) | 87 | public void IncomingLandObjectsFromStorage(List<LandData> data) |
88 | { | 88 | { |
89 | for (int i = 0; i < data.Count; i++) | 89 | for (int i = 0; i < data.Count; i++) |
90 | { | 90 | { |
91 | //try | 91 | //try |
92 | //{ | 92 | //{ |
93 | IncomingLandObjectFromStorage(data[i]); | 93 | IncomingLandObjectFromStorage(data[i]); |
94 | //} | 94 | //} |
95 | //catch (Exception ex) | 95 | //catch (Exception ex) |
96 | //{ | 96 | //{ |
97 | //m_log.Error("[LandManager]: IncomingLandObjectsFromStorage: Exception: " + ex.ToString()); | 97 | //m_log.Error("[LandManager]: IncomingLandObjectsFromStorage: Exception: " + ex.ToString()); |
98 | //throw ex; | 98 | //throw ex; |
99 | //} | 99 | //} |
100 | } | 100 | } |
101 | //foreach (LandData parcel in data) | 101 | //foreach (LandData parcel in data) |
102 | //{ | 102 | //{ |
103 | // IncomingLandObjectFromStorage(parcel); | 103 | // IncomingLandObjectFromStorage(parcel); |
104 | //} | 104 | //} |
105 | } | 105 | } |
106 | 106 | ||
107 | public void IncomingLandObjectFromStorage(LandData data) | 107 | public void IncomingLandObjectFromStorage(LandData data) |
108 | { | 108 | { |
109 | ILandObject new_land = new LandObject(data.ownerID, data.isGroupOwned, m_scene); | 109 | ILandObject new_land = new LandObject(data.ownerID, data.isGroupOwned, m_scene); |
110 | new_land.landData = data.Copy(); | 110 | new_land.landData = data.Copy(); |
111 | new_land.setLandBitmapFromByteArray(); | 111 | new_land.setLandBitmapFromByteArray(); |
112 | addLandObject(new_land); | 112 | addLandObject(new_land); |
113 | } | 113 | } |
114 | 114 | ||
115 | public void NoLandDataFromStorage() | 115 | public void NoLandDataFromStorage() |
116 | { | 116 | { |
117 | resetSimLandObjects(); | 117 | resetSimLandObjects(); |
118 | } | 118 | } |
119 | 119 | ||
120 | #endregion | 120 | #endregion |
121 | 121 | ||
122 | #region Parcel Add/Remove/Get/Create | 122 | #region Parcel Add/Remove/Get/Create |
123 | 123 | ||
124 | public void updateLandObject(int local_id, LandData newData) | 124 | public void updateLandObject(int local_id, LandData newData) |
125 | { | 125 | { |
126 | if (landList.ContainsKey(local_id)) | 126 | if (landList.ContainsKey(local_id)) |
127 | { | 127 | { |
128 | landList[local_id].landData = newData.Copy(); | 128 | landList[local_id].landData = newData.Copy(); |
129 | m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); | 129 | m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | /// <summary> | 133 | /// <summary> |
134 | /// Get the land object at the specified point | 134 | /// Get the land object at the specified point |
135 | /// </summary> | 135 | /// </summary> |
136 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> | 136 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> |
137 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> | 137 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> |
138 | /// <returns>Land object at the point supplied</returns> | 138 | /// <returns>Land object at the point supplied</returns> |
139 | public ILandObject getLandObject(float x_float, float y_float) | 139 | public ILandObject getLandObject(float x_float, float y_float) |
140 | { | 140 | { |
141 | int x; | 141 | int x; |
142 | int y; | 142 | int y; |
143 | 143 | ||
144 | try | 144 | try |
145 | { | 145 | { |
146 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); | 146 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); |
147 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); | 147 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); |
148 | } | 148 | } |
149 | catch (OverflowException) | 149 | catch (OverflowException) |
150 | { | 150 | { |
151 | return null; | 151 | return null; |
152 | } | 152 | } |
153 | 153 | ||
154 | if (x >= 64 || y >= 64 || x < 0 || y < 0) | 154 | if (x >= 64 || y >= 64 || x < 0 || y < 0) |
155 | { | 155 | { |
156 | return null; | 156 | return null; |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | return landList[landIDList[x, y]]; | 160 | return landList[landIDList[x, y]]; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | public ILandObject getLandObject(int x, int y) | 164 | public ILandObject getLandObject(int x, int y) |
165 | { | 165 | { |
166 | if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) | 166 | if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) |
167 | { | 167 | { |
168 | // These exceptions here will cause a lot of complaints from the users specifically because | 168 | // These exceptions here will cause a lot of complaints from the users specifically because |
169 | // they happen every time at border crossings | 169 | // they happen every time at border crossings |
170 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | 170 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); |
171 | } | 171 | } |
172 | else | 172 | else |
173 | { | 173 | { |
174 | return landList[landIDList[x / 4, y / 4]]; | 174 | return landList[landIDList[x / 4, y / 4]]; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | /// <summary> | 178 | /// <summary> |
179 | /// Creates a basic Parcel object without an owner (a zeroed key) | 179 | /// Creates a basic Parcel object without an owner (a zeroed key) |
180 | /// </summary> | 180 | /// </summary> |
181 | /// <returns></returns> | 181 | /// <returns></returns> |
182 | public ILandObject createBaseLand() | 182 | public ILandObject createBaseLand() |
183 | { | 183 | { |
184 | return new LandObject(LLUUID.Zero, false, m_scene); | 184 | return new LandObject(LLUUID.Zero, false, m_scene); |
185 | } | 185 | } |
186 | 186 | ||
187 | /// <summary> | 187 | /// <summary> |
188 | /// Adds a land object to the stored list and adds them to the landIDList to what they own | 188 | /// Adds a land object to the stored list and adds them to the landIDList to what they own |
189 | /// </summary> | 189 | /// </summary> |
190 | /// <param name="new_land">The land object being added</param> | 190 | /// <param name="new_land">The land object being added</param> |
191 | public ILandObject addLandObject(ILandObject new_land) | 191 | public ILandObject addLandObject(ILandObject new_land) |
192 | { | 192 | { |
193 | lastLandLocalID++; | 193 | lastLandLocalID++; |
194 | new_land.landData.localID = lastLandLocalID; | 194 | new_land.landData.localID = lastLandLocalID; |
195 | landList.Add(lastLandLocalID, (LandObject) new_land.Copy()); | 195 | landList.Add(lastLandLocalID, (LandObject) new_land.Copy()); |
196 | 196 | ||
197 | 197 | ||
198 | bool[,] landBitmap = new_land.getLandBitmap(); | 198 | bool[,] landBitmap = new_land.getLandBitmap(); |
199 | int x, y; | 199 | int x, y; |
200 | for (x = 0; x < 64; x++) | 200 | for (x = 0; x < 64; x++) |
201 | { | 201 | { |
202 | for (y = 0; y < 64; y++) | 202 | for (y = 0; y < 64; y++) |
203 | { | 203 | { |
204 | if (landBitmap[x, y]) | 204 | if (landBitmap[x, y]) |
205 | { | 205 | { |
206 | landIDList[x, y] = lastLandLocalID; | 206 | landIDList[x, y] = lastLandLocalID; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | landList[lastLandLocalID].forceUpdateLandInfo(); | 210 | landList[lastLandLocalID].forceUpdateLandInfo(); |
211 | m_scene.EventManager.TriggerLandObjectAdded(new_land); | 211 | m_scene.EventManager.TriggerLandObjectAdded(new_land); |
212 | return new_land; | 212 | return new_land; |
213 | } | 213 | } |
214 | 214 | ||
215 | /// <summary> | 215 | /// <summary> |
216 | /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList | 216 | /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList |
217 | /// </summary> | 217 | /// </summary> |
218 | /// <param name="local_id">Land.localID of the peice of land to remove.</param> | 218 | /// <param name="local_id">Land.localID of the peice of land to remove.</param> |
219 | public void removeLandObject(int local_id) | 219 | public void removeLandObject(int local_id) |
220 | { | 220 | { |
221 | int x, y; | 221 | int x, y; |
222 | for (x = 0; x < 64; x++) | 222 | for (x = 0; x < 64; x++) |
223 | { | 223 | { |
224 | for (y = 0; y < 64; y++) | 224 | for (y = 0; y < 64; y++) |
225 | { | 225 | { |
226 | if (landIDList[x, y] == local_id) | 226 | if (landIDList[x, y] == local_id) |
227 | { | 227 | { |
228 | return; | 228 | return; |
229 | //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); | 229 | //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | m_scene.EventManager.TriggerLandObjectRemoved(landList[local_id].landData.globalID); | 234 | m_scene.EventManager.TriggerLandObjectRemoved(landList[local_id].landData.globalID); |
235 | landList.Remove(local_id); | 235 | landList.Remove(local_id); |
236 | } | 236 | } |
237 | 237 | ||
238 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 238 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |
239 | { | 239 | { |
240 | int x, y; | 240 | int x, y; |
241 | bool[,] landBitmapSlave = slave.getLandBitmap(); | 241 | bool[,] landBitmapSlave = slave.getLandBitmap(); |
242 | for (x = 0; x < 64; x++) | 242 | for (x = 0; x < 64; x++) |
243 | { | 243 | { |
244 | for (y = 0; y < 64; y++) | 244 | for (y = 0; y < 64; y++) |
245 | { | 245 | { |
246 | if (landBitmapSlave[x, y]) | 246 | if (landBitmapSlave[x, y]) |
247 | { | 247 | { |
248 | landIDList[x, y] = master.landData.localID; | 248 | landIDList[x, y] = master.landData.localID; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | removeLandObject(slave.landData.localID); | 253 | removeLandObject(slave.landData.localID); |
254 | updateLandObject(master.landData.localID, master.landData); | 254 | updateLandObject(master.landData.localID, master.landData); |
255 | } | 255 | } |
256 | 256 | ||
257 | public ILandObject getLandObject(int parcelLocalID) | 257 | public ILandObject getLandObject(int parcelLocalID) |
258 | { | 258 | { |
259 | lock (landList) | 259 | lock (landList) |
260 | { | 260 | { |
261 | if (landList.ContainsKey(parcelLocalID)) | 261 | if (landList.ContainsKey(parcelLocalID)) |
262 | { | 262 | { |
263 | return landList[parcelLocalID]; | 263 | return landList[parcelLocalID]; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | return null; | 266 | return null; |
267 | } | 267 | } |
268 | 268 | ||
269 | #endregion | 269 | #endregion |
270 | 270 | ||
271 | #region Parcel Modification | 271 | #region Parcel Modification |
272 | 272 | ||
273 | public void resetAllLandPrimCounts() | 273 | public void resetAllLandPrimCounts() |
274 | { | 274 | { |
275 | foreach (LandObject p in landList.Values) | 275 | foreach (LandObject p in landList.Values) |
276 | { | 276 | { |
277 | p.resetLandPrimCounts(); | 277 | p.resetLandPrimCounts(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | public void setPrimsTainted() | 281 | public void setPrimsTainted() |
282 | { | 282 | { |
283 | landPrimCountTainted = true; | 283 | landPrimCountTainted = true; |
284 | } | 284 | } |
285 | 285 | ||
286 | public bool isLandPrimCountTainted() | 286 | public bool isLandPrimCountTainted() |
287 | { | 287 | { |
288 | return landPrimCountTainted; | 288 | return landPrimCountTainted; |
289 | } | 289 | } |
290 | 290 | ||
291 | public void addPrimToLandPrimCounts(SceneObjectGroup obj) | 291 | public void addPrimToLandPrimCounts(SceneObjectGroup obj) |
292 | { | 292 | { |
293 | LLVector3 position = obj.AbsolutePosition; | 293 | LLVector3 position = obj.AbsolutePosition; |
294 | ILandObject landUnderPrim = getLandObject(position.X, position.Y); | 294 | ILandObject landUnderPrim = getLandObject(position.X, position.Y); |
295 | if (landUnderPrim != null) | 295 | if (landUnderPrim != null) |
296 | { | 296 | { |
297 | landUnderPrim.addPrimToCount(obj); | 297 | landUnderPrim.addPrimToCount(obj); |
298 | } | 298 | } |
299 | } | 299 | } |
300 | 300 | ||
301 | public void removePrimFromLandPrimCounts(SceneObjectGroup obj) | 301 | public void removePrimFromLandPrimCounts(SceneObjectGroup obj) |
302 | { | 302 | { |
303 | foreach (LandObject p in landList.Values) | 303 | foreach (LandObject p in landList.Values) |
304 | { | 304 | { |
305 | p.removePrimFromCount(obj); | 305 | p.removePrimFromCount(obj); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | public void finalizeLandPrimCountUpdate() | 309 | public void finalizeLandPrimCountUpdate() |
310 | { | 310 | { |
311 | //Get Simwide prim count for owner | 311 | //Get Simwide prim count for owner |
312 | Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>(); | 312 | Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>(); |
313 | foreach (LandObject p in landList.Values) | 313 | foreach (LandObject p in landList.Values) |
314 | { | 314 | { |
315 | if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) | 315 | if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) |
316 | { | 316 | { |
317 | List<LandObject> tempList = new List<LandObject>(); | 317 | List<LandObject> tempList = new List<LandObject>(); |
318 | tempList.Add(p); | 318 | tempList.Add(p); |
319 | landOwnersAndParcels.Add(p.landData.ownerID, tempList); | 319 | landOwnersAndParcels.Add(p.landData.ownerID, tempList); |
320 | } | 320 | } |
321 | else | 321 | else |
322 | { | 322 | { |
323 | landOwnersAndParcels[p.landData.ownerID].Add(p); | 323 | landOwnersAndParcels[p.landData.ownerID].Add(p); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | foreach (LLUUID owner in landOwnersAndParcels.Keys) | 327 | foreach (LLUUID owner in landOwnersAndParcels.Keys) |
328 | { | 328 | { |
329 | int simArea = 0; | 329 | int simArea = 0; |
330 | int simPrims = 0; | 330 | int simPrims = 0; |
331 | foreach (LandObject p in landOwnersAndParcels[owner]) | 331 | foreach (LandObject p in landOwnersAndParcels[owner]) |
332 | { | 332 | { |
333 | simArea += p.landData.area; | 333 | simArea += p.landData.area; |
334 | simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + | 334 | simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + |
335 | p.landData.selectedPrims; | 335 | p.landData.selectedPrims; |
336 | } | 336 | } |
337 | 337 | ||
338 | foreach (LandObject p in landOwnersAndParcels[owner]) | 338 | foreach (LandObject p in landOwnersAndParcels[owner]) |
339 | { | 339 | { |
340 | p.landData.simwideArea = simArea; | 340 | p.landData.simwideArea = simArea; |
341 | p.landData.simwidePrims = simPrims; | 341 | p.landData.simwidePrims = simPrims; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | public void updateLandPrimCounts() | 346 | public void updateLandPrimCounts() |
347 | { | 347 | { |
348 | foreach (EntityBase obj in m_scene.Entities.Values) | 348 | foreach (EntityBase obj in m_scene.Entities.Values) |
349 | { | 349 | { |
350 | if (obj is SceneObjectGroup) | 350 | if (obj is SceneObjectGroup) |
351 | { | 351 | { |
352 | m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); | 352 | m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); |
353 | } | 353 | } |
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | public void performParcelPrimCountUpdate() | 357 | public void performParcelPrimCountUpdate() |
358 | { | 358 | { |
359 | resetAllLandPrimCounts(); | 359 | resetAllLandPrimCounts(); |
360 | m_scene.EventManager.TriggerParcelPrimCountUpdate(); | 360 | m_scene.EventManager.TriggerParcelPrimCountUpdate(); |
361 | finalizeLandPrimCountUpdate(); | 361 | finalizeLandPrimCountUpdate(); |
362 | landPrimCountTainted = false; | 362 | landPrimCountTainted = false; |
363 | } | 363 | } |
364 | 364 | ||
365 | /// <summary> | 365 | /// <summary> |
366 | /// Subdivides a piece of land | 366 | /// Subdivides a piece of land |
367 | /// </summary> | 367 | /// </summary> |
368 | /// <param name="start_x">West Point</param> | 368 | /// <param name="start_x">West Point</param> |
369 | /// <param name="start_y">South Point</param> | 369 | /// <param name="start_y">South Point</param> |
370 | /// <param name="end_x">East Point</param> | 370 | /// <param name="end_x">East Point</param> |
371 | /// <param name="end_y">North Point</param> | 371 | /// <param name="end_y">North Point</param> |
372 | /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> | 372 | /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> |
373 | /// <returns>Returns true if successful</returns> | 373 | /// <returns>Returns true if successful</returns> |
374 | private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) | 374 | private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) |
375 | { | 375 | { |
376 | //First, lets loop through the points and make sure they are all in the same peice of land | 376 | //First, lets loop through the points and make sure they are all in the same peice of land |
377 | //Get the land object at start | 377 | //Get the land object at start |
378 | ILandObject startLandObject = null; | 378 | ILandObject startLandObject = null; |
379 | try | 379 | try |
380 | { | 380 | { |
381 | startLandObject = getLandObject(start_x, start_y); | 381 | startLandObject = getLandObject(start_x, start_y); |
382 | } | 382 | } |
383 | catch (Exception) | 383 | catch (Exception) |
384 | { | 384 | { |
385 | //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y); | 385 | //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y); |
386 | } | 386 | } |
387 | if (startLandObject == null) return false; //No such land object at the beginning | 387 | if (startLandObject == null) return false; //No such land object at the beginning |
388 | 388 | ||
389 | //Loop through the points | 389 | //Loop through the points |
390 | try | 390 | try |
391 | { | 391 | { |
392 | int totalX = end_x - start_x; | 392 | int totalX = end_x - start_x; |
393 | int totalY = end_y - start_y; | 393 | int totalY = end_y - start_y; |
394 | int x, y; | 394 | int x, y; |
395 | for (y = 0; y < totalY; y++) | 395 | for (y = 0; y < totalY; y++) |
396 | { | 396 | { |
397 | for (x = 0; x < totalX; x++) | 397 | for (x = 0; x < totalX; x++) |
398 | { | 398 | { |
399 | ILandObject tempLandObject = getLandObject(start_x + x, start_y + y); | 399 | ILandObject tempLandObject = getLandObject(start_x + x, start_y + y); |
400 | if (tempLandObject == null) return false; //No such land object at that point | 400 | if (tempLandObject == null) return false; //No such land object at that point |
401 | if (tempLandObject != startLandObject) return false; //Subdividing over 2 land objects; no-no | 401 | if (tempLandObject != startLandObject) return false; //Subdividing over 2 land objects; no-no |
402 | } | 402 | } |
403 | } | 403 | } |
404 | } | 404 | } |
405 | catch (Exception) | 405 | catch (Exception) |
406 | { | 406 | { |
407 | return false; //Exception. For now, lets skip subdivision | 407 | return false; //Exception. For now, lets skip subdivision |
408 | } | 408 | } |
409 | 409 | ||
410 | //If we are still here, then they are subdividing within one piece of land | 410 | //If we are still here, then they are subdividing within one piece of land |
411 | //Check owner | 411 | //Check owner |
412 | if (startLandObject.landData.ownerID != attempting_user_id) | 412 | if (startLandObject.landData.ownerID != attempting_user_id) |
413 | { | 413 | { |
414 | return false; //They cant do this! | 414 | return false; //They cant do this! |
415 | } | 415 | } |
416 | 416 | ||
417 | //Lets create a new land object with bitmap activated at that point (keeping the old land objects info) | 417 | //Lets create a new land object with bitmap activated at that point (keeping the old land objects info) |
418 | ILandObject newLand = startLandObject.Copy(); | 418 | ILandObject newLand = startLandObject.Copy(); |
419 | newLand.landData.landName = "Subdivision of " + newLand.landData.landName; | 419 | newLand.landData.landName = "Subdivision of " + newLand.landData.landName; |
420 | newLand.landData.globalID = LLUUID.Random(); | 420 | newLand.landData.globalID = LLUUID.Random(); |
421 | 421 | ||
422 | newLand.setLandBitmap(newLand.getSquareLandBitmap(start_x, start_y, end_x, end_y)); | 422 | newLand.setLandBitmap(newLand.getSquareLandBitmap(start_x, start_y, end_x, end_y)); |
423 | 423 | ||
424 | //Now, lets set the subdivision area of the original to false | 424 | //Now, lets set the subdivision area of the original to false |
425 | int startLandObjectIndex = startLandObject.landData.localID; | 425 | int startLandObjectIndex = startLandObject.landData.localID; |
426 | landList[startLandObjectIndex].setLandBitmap( | 426 | landList[startLandObjectIndex].setLandBitmap( |
427 | newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); | 427 | newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); |
428 | landList[startLandObjectIndex].forceUpdateLandInfo(); | 428 | landList[startLandObjectIndex].forceUpdateLandInfo(); |
429 | 429 | ||
430 | setPrimsTainted(); | 430 | setPrimsTainted(); |
431 | 431 | ||
432 | //Now add the new land object | 432 | //Now add the new land object |
433 | ILandObject result = addLandObject(newLand); | 433 | ILandObject result = addLandObject(newLand); |
434 | updateLandObject(startLandObject.landData.localID, startLandObject.landData); | 434 | updateLandObject(startLandObject.landData.localID, startLandObject.landData); |
435 | result.sendLandUpdateToAvatarsOverMe(); | 435 | result.sendLandUpdateToAvatarsOverMe(); |
436 | 436 | ||
437 | 437 | ||
438 | return true; | 438 | return true; |
439 | } | 439 | } |
440 | 440 | ||
441 | /// <summary> | 441 | /// <summary> |
442 | /// Join 2 land objects together | 442 | /// Join 2 land objects together |
443 | /// </summary> | 443 | /// </summary> |
444 | /// <param name="start_x">x value in first piece of land</param> | 444 | /// <param name="start_x">x value in first piece of land</param> |
445 | /// <param name="start_y">y value in first piece of land</param> | 445 | /// <param name="start_y">y value in first piece of land</param> |
446 | /// <param name="end_x">x value in second peice of land</param> | 446 | /// <param name="end_x">x value in second peice of land</param> |
447 | /// <param name="end_y">y value in second peice of land</param> | 447 | /// <param name="end_y">y value in second peice of land</param> |
448 | /// <param name="attempting_user_id">LLUUID of the avatar trying to join the land objects</param> | 448 | /// <param name="attempting_user_id">LLUUID of the avatar trying to join the land objects</param> |
449 | /// <returns>Returns true if successful</returns> | 449 | /// <returns>Returns true if successful</returns> |
450 | private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) | 450 | private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) |
451 | { | 451 | { |
452 | end_x -= 4; | 452 | end_x -= 4; |
453 | end_y -= 4; | 453 | end_y -= 4; |
454 | 454 | ||
455 | List<ILandObject> selectedLandObjects = new List<ILandObject>(); | 455 | List<ILandObject> selectedLandObjects = new List<ILandObject>(); |
456 | int stepXSelected = 0; | 456 | int stepXSelected = 0; |
457 | int stepYSelected = 0; | 457 | int stepYSelected = 0; |
458 | for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) | 458 | for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) |
459 | { | 459 | { |
460 | for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) | 460 | for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) |
461 | { | 461 | { |
462 | ILandObject p = null; | 462 | ILandObject p = null; |
463 | try | 463 | try |
464 | { | 464 | { |
465 | p = getLandObject(stepXSelected, stepYSelected); | 465 | p = getLandObject(stepXSelected, stepYSelected); |
466 | } | 466 | } |
467 | catch (Exception) | 467 | catch (Exception) |
468 | { | 468 | { |
469 | //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected); | 469 | //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected); |
470 | } | 470 | } |
471 | if (p != null) | 471 | if (p != null) |
472 | { | 472 | { |
473 | if (!selectedLandObjects.Contains(p)) | 473 | if (!selectedLandObjects.Contains(p)) |
474 | { | 474 | { |
475 | selectedLandObjects.Add(p); | 475 | selectedLandObjects.Add(p); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } | 478 | } |
479 | } | 479 | } |
480 | ILandObject masterLandObject = selectedLandObjects[0]; | 480 | ILandObject masterLandObject = selectedLandObjects[0]; |
481 | selectedLandObjects.RemoveAt(0); | 481 | selectedLandObjects.RemoveAt(0); |
482 | 482 | ||
483 | 483 | ||
484 | if (selectedLandObjects.Count < 1) | 484 | if (selectedLandObjects.Count < 1) |
485 | { | 485 | { |
486 | return false; //Only one piece of land selected | 486 | return false; //Only one piece of land selected |
487 | } | 487 | } |
488 | if (masterLandObject.landData.ownerID != attempting_user_id) | 488 | if (masterLandObject.landData.ownerID != attempting_user_id) |
489 | { | 489 | { |
490 | return false; //Not the same owner | 490 | return false; //Not the same owner |
491 | } | 491 | } |
492 | foreach (ILandObject p in selectedLandObjects) | 492 | foreach (ILandObject p in selectedLandObjects) |
493 | { | 493 | { |
494 | if (p.landData.ownerID != masterLandObject.landData.ownerID) | 494 | if (p.landData.ownerID != masterLandObject.landData.ownerID) |
495 | { | 495 | { |
496 | return false; //Over multiple users. TODO: make this just ignore this piece of land? | 496 | return false; //Over multiple users. TODO: make this just ignore this piece of land? |
497 | } | 497 | } |
498 | } | 498 | } |
499 | foreach (ILandObject slaveLandObject in selectedLandObjects) | 499 | foreach (ILandObject slaveLandObject in selectedLandObjects) |
500 | { | 500 | { |
501 | landList[masterLandObject.landData.localID].setLandBitmap( | 501 | landList[masterLandObject.landData.localID].setLandBitmap( |
502 | slaveLandObject.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap())); | 502 | slaveLandObject.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap())); |
503 | performFinalLandJoin(masterLandObject, slaveLandObject); | 503 | performFinalLandJoin(masterLandObject, slaveLandObject); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | setPrimsTainted(); | 507 | setPrimsTainted(); |
508 | 508 | ||
509 | masterLandObject.sendLandUpdateToAvatarsOverMe(); | 509 | masterLandObject.sendLandUpdateToAvatarsOverMe(); |
510 | 510 | ||
511 | return true; | 511 | return true; |
512 | } | 512 | } |
513 | 513 | ||
514 | #endregion | 514 | #endregion |
515 | 515 | ||
516 | #region Parcel Updating | 516 | #region Parcel Updating |
517 | 517 | ||
518 | /// <summary> | 518 | /// <summary> |
519 | /// Where we send the ParcelOverlay packet to the client | 519 | /// Where we send the ParcelOverlay packet to the client |
520 | /// </summary> | 520 | /// </summary> |
521 | /// <param name="remote_client">The object representing the client</param> | 521 | /// <param name="remote_client">The object representing the client</param> |
522 | public void sendParcelOverlay(IClientAPI remote_client) | 522 | public void sendParcelOverlay(IClientAPI remote_client) |
523 | { | 523 | { |
524 | const int LAND_BLOCKS_PER_PACKET = 1024; | 524 | const int LAND_BLOCKS_PER_PACKET = 1024; |
525 | int x, y = 0; | 525 | int x, y = 0; |
526 | byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; | 526 | byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; |
527 | int byteArrayCount = 0; | 527 | int byteArrayCount = 0; |
528 | int sequenceID = 0; | 528 | int sequenceID = 0; |
529 | ParcelOverlayPacket packet; | 529 | ParcelOverlayPacket packet; |
530 | 530 | ||
531 | for (y = 0; y < 64; y++) | 531 | for (y = 0; y < 64; y++) |
532 | { | 532 | { |
533 | for (x = 0; x < 64; x++) | 533 | for (x = 0; x < 64; x++) |
534 | { | 534 | { |
535 | byte tempByte = (byte) 0; //This represents the byte for the current 4x4 | 535 | byte tempByte = (byte) 0; //This represents the byte for the current 4x4 |
536 | ILandObject currentParcelBlock = null; | 536 | ILandObject currentParcelBlock = null; |
537 | 537 | ||
538 | try | 538 | try |
539 | { | 539 | { |
540 | currentParcelBlock = getLandObject(x * 4, y * 4); | 540 | currentParcelBlock = getLandObject(x * 4, y * 4); |
541 | } | 541 | } |
542 | catch (Exception) | 542 | catch (Exception) |
543 | { | 543 | { |
544 | //m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4)); | 544 | //m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4)); |
545 | } | 545 | } |
546 | 546 | ||
547 | 547 | ||
548 | if (currentParcelBlock != null) | 548 | if (currentParcelBlock != null) |
549 | { | 549 | { |
550 | if (currentParcelBlock.landData.ownerID == remote_client.AgentId) | 550 | if (currentParcelBlock.landData.ownerID == remote_client.AgentId) |
551 | { | 551 | { |
552 | //Owner Flag | 552 | //Owner Flag |
553 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER); | 553 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER); |
554 | } | 554 | } |
555 | else if (currentParcelBlock.landData.salePrice > 0 && | 555 | else if (currentParcelBlock.landData.salePrice > 0 && |
556 | (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || | 556 | (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || |
557 | currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) | 557 | currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) |
558 | { | 558 | { |
559 | //Sale Flag | 559 | //Sale Flag |
560 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE); | 560 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE); |
561 | } | 561 | } |
562 | else if (currentParcelBlock.landData.ownerID == LLUUID.Zero) | 562 | else if (currentParcelBlock.landData.ownerID == LLUUID.Zero) |
563 | { | 563 | { |
564 | //Public Flag | 564 | //Public Flag |
565 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_PUBLIC); | 565 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_PUBLIC); |
566 | } | 566 | } |
567 | else | 567 | else |
568 | { | 568 | { |
569 | //Other Flag | 569 | //Other Flag |
570 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_OTHER); | 570 | tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_OTHER); |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | //Now for border control | 574 | //Now for border control |
575 | try | 575 | try |
576 | { | 576 | { |
577 | ILandObject westParcel = null; | 577 | ILandObject westParcel = null; |
578 | ILandObject southParcel = null; | 578 | ILandObject southParcel = null; |
579 | if (x > 0) | 579 | if (x > 0) |
580 | { | 580 | { |
581 | westParcel = getLandObject((x - 1) * 4, y * 4); | 581 | westParcel = getLandObject((x - 1) * 4, y * 4); |
582 | } | 582 | } |
583 | if (y > 0) | 583 | if (y > 0) |
584 | { | 584 | { |
585 | southParcel = getLandObject(x * 4, (y - 1) * 4); | 585 | southParcel = getLandObject(x * 4, (y - 1) * 4); |
586 | } | 586 | } |
587 | 587 | ||
588 | if (x == 0) | 588 | if (x == 0) |
589 | { | 589 | { |
590 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); | 590 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); |
591 | } | 591 | } |
592 | else if (westParcel != null && westParcel != currentParcelBlock) | 592 | else if (westParcel != null && westParcel != currentParcelBlock) |
593 | { | 593 | { |
594 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); | 594 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); |
595 | } | 595 | } |
596 | 596 | ||
597 | if (y == 0) | 597 | if (y == 0) |
598 | { | 598 | { |
599 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); | 599 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); |
600 | } | 600 | } |
601 | else if (southParcel != null && southParcel != currentParcelBlock) | 601 | else if (southParcel != null && southParcel != currentParcelBlock) |
602 | { | 602 | { |
603 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); | 603 | tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); |
604 | } | 604 | } |
605 | 605 | ||
606 | byteArray[byteArrayCount] = tempByte; | 606 | byteArray[byteArrayCount] = tempByte; |
607 | byteArrayCount++; | 607 | byteArrayCount++; |
608 | if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) | 608 | if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) |
609 | { | 609 | { |
610 | byteArrayCount = 0; | 610 | byteArrayCount = 0; |
611 | packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); | 611 | packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); |
612 | packet.ParcelData.Data = byteArray; | 612 | packet.ParcelData.Data = byteArray; |
613 | packet.ParcelData.SequenceID = sequenceID; | 613 | packet.ParcelData.SequenceID = sequenceID; |
614 | remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); | 614 | remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); |
615 | sequenceID++; | 615 | sequenceID++; |
616 | byteArray = new byte[LAND_BLOCKS_PER_PACKET]; | 616 | byteArray = new byte[LAND_BLOCKS_PER_PACKET]; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | catch (Exception) | 619 | catch (Exception) |
620 | { | 620 | { |
621 | //m_log.Debug("[LAND]: Skipped Land checks because avatar is out of bounds: " + e.Message); | 621 | //m_log.Debug("[LAND]: Skipped Land checks because avatar is out of bounds: " + e.Message); |
622 | } | 622 | } |
623 | } | 623 | } |
624 | } | 624 | } |
625 | } | 625 | } |
626 | } | 626 | } |
627 | 627 | ||
628 | public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, | 628 | public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, |
629 | bool snap_selection, IClientAPI remote_client) | 629 | bool snap_selection, IClientAPI remote_client) |
630 | { | 630 | { |
631 | //Get the land objects within the bounds | 631 | //Get the land objects within the bounds |
632 | List<ILandObject> temp = new List<ILandObject>(); | 632 | List<ILandObject> temp = new List<ILandObject>(); |
633 | int x, y, i; | 633 | int x, y, i; |
634 | int inc_x = end_x - start_x; | 634 | int inc_x = end_x - start_x; |
635 | int inc_y = end_y - start_y; | 635 | int inc_y = end_y - start_y; |
636 | for (x = 0; x < inc_x; x++) | 636 | for (x = 0; x < inc_x; x++) |
637 | { | 637 | { |
638 | for (y = 0; y < inc_y; y++) | 638 | for (y = 0; y < inc_y; y++) |
639 | { | 639 | { |
640 | ILandObject currentParcel = null; | 640 | ILandObject currentParcel = null; |
641 | try | 641 | try |
642 | { | 642 | { |
643 | currentParcel = getLandObject(start_x + x, start_y + y); | 643 | currentParcel = getLandObject(start_x + x, start_y + y); |
644 | } | 644 | } |
645 | catch (Exception) | 645 | catch (Exception) |
646 | { | 646 | { |
647 | //m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y)); | 647 | //m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y)); |
648 | } | 648 | } |
649 | if (currentParcel != null) | 649 | if (currentParcel != null) |
650 | { | 650 | { |
651 | if (!temp.Contains(currentParcel)) | 651 | if (!temp.Contains(currentParcel)) |
652 | { | 652 | { |
653 | currentParcel.forceUpdateLandInfo(); | 653 | currentParcel.forceUpdateLandInfo(); |
654 | temp.Add(currentParcel); | 654 | temp.Add(currentParcel); |
655 | } | 655 | } |
656 | } | 656 | } |
657 | } | 657 | } |
658 | } | 658 | } |
659 | 659 | ||
660 | int requestResult = LAND_RESULT_SINGLE; | 660 | int requestResult = LAND_RESULT_SINGLE; |
661 | if (temp.Count > 1) | 661 | if (temp.Count > 1) |
662 | { | 662 | { |
663 | requestResult = LAND_RESULT_MULTIPLE; | 663 | requestResult = LAND_RESULT_MULTIPLE; |
664 | } | 664 | } |
665 | 665 | ||
666 | for (i = 0; i < temp.Count; i++) | 666 | for (i = 0; i < temp.Count; i++) |
667 | { | 667 | { |
668 | temp[i].sendLandProperties(sequence_id, snap_selection, requestResult, remote_client); | 668 | temp[i].sendLandProperties(sequence_id, snap_selection, requestResult, remote_client); |
669 | } | 669 | } |
670 | 670 | ||
671 | 671 | ||
672 | sendParcelOverlay(remote_client); | 672 | sendParcelOverlay(remote_client); |
673 | } | 673 | } |
674 | 674 | ||
675 | public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) | 675 | public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) |
676 | { | 676 | { |
677 | if (landList.ContainsKey(packet.ParcelData.LocalID)) | 677 | if (landList.ContainsKey(packet.ParcelData.LocalID)) |
678 | { | 678 | { |
679 | landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); | 679 | landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); |
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) | 683 | public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) |
684 | { | 684 | { |
685 | subdivide(west, south, east, north, remote_client.AgentId); | 685 | subdivide(west, south, east, north, remote_client.AgentId); |
686 | } | 686 | } |
687 | 687 | ||
688 | public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) | 688 | public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) |
689 | { | 689 | { |
690 | join(west, south, east, north, remote_client.AgentId); | 690 | join(west, south, east, north, remote_client.AgentId); |
691 | } | 691 | } |
692 | 692 | ||
693 | public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client) | 693 | public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client) |
694 | { | 694 | { |
695 | landList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); | 695 | landList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); |
696 | } | 696 | } |
697 | 697 | ||
698 | public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) | 698 | public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) |
699 | { | 699 | { |
700 | landList[local_id].sendLandObjectOwners(remote_client); | 700 | landList[local_id].sendLandObjectOwners(remote_client); |
701 | } | 701 | } |
702 | 702 | ||
703 | #endregion | 703 | #endregion |
704 | 704 | ||
705 | #region ILandChannel Members | 705 | #region ILandChannel Members |
706 | 706 | ||
707 | public bool allowedForcefulBans | 707 | public bool allowedForcefulBans |
708 | { | 708 | { |
709 | get { return m_allowedForcefulBans; } | 709 | get { return m_allowedForcefulBans; } |
710 | set { m_allowedForcefulBans = value; } | 710 | set { m_allowedForcefulBans = value; } |
711 | } | 711 | } |
712 | 712 | ||
713 | /// <summary> | 713 | /// <summary> |
714 | /// Resets the sim to the default land object (full sim piece of land owned by the default user) | 714 | /// Resets the sim to the default land object (full sim piece of land owned by the default user) |
715 | /// </summary> | 715 | /// </summary> |
716 | public void resetSimLandObjects() | 716 | public void resetSimLandObjects() |
717 | { | 717 | { |
718 | //Remove all the land objects in the sim and add a blank, full sim land object set to public | 718 | //Remove all the land objects in the sim and add a blank, full sim land object set to public |
719 | landList.Clear(); | 719 | landList.Clear(); |
720 | lastLandLocalID = START_LAND_LOCAL_ID - 1; | 720 | lastLandLocalID = START_LAND_LOCAL_ID - 1; |
721 | landIDList.Initialize(); | 721 | landIDList.Initialize(); |
722 | 722 | ||
723 | ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); | 723 | ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); |
724 | 724 | ||
725 | fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize)); | 725 | fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize)); |
726 | fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; | 726 | fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; |
727 | 727 | ||
728 | addLandObject(fullSimParcel); | 728 | addLandObject(fullSimParcel); |
729 | } | 729 | } |
730 | 730 | ||
731 | public List<ILandObject> parcelsNearPoint(LLVector3 position) | 731 | public List<ILandObject> parcelsNearPoint(LLVector3 position) |
732 | { | 732 | { |
733 | List<ILandObject> parcelsNear = new List<ILandObject>(); | 733 | List<ILandObject> parcelsNear = new List<ILandObject>(); |
734 | int x, y; | 734 | int x, y; |
735 | for (x = -4; x <= 4; x += 4) | 735 | for (x = -4; x <= 4; x += 4) |
736 | { | 736 | { |
737 | for (y = -4; y <= 4; y += 4) | 737 | for (y = -4; y <= 4; y += 4) |
738 | { | 738 | { |
739 | ILandObject check = getLandObject(position.X + x, position.Y + y); | 739 | ILandObject check = getLandObject(position.X + x, position.Y + y); |
740 | if (check != null) | 740 | if (check != null) |
741 | { | 741 | { |
742 | if (!parcelsNear.Contains(check)) | 742 | if (!parcelsNear.Contains(check)) |
743 | { | 743 | { |
744 | parcelsNear.Add(check); | 744 | parcelsNear.Add(check); |
745 | } | 745 | } |
746 | } | 746 | } |
747 | } | 747 | } |
748 | } | 748 | } |
749 | 749 | ||
750 | return parcelsNear; | 750 | return parcelsNear; |
751 | } | 751 | } |
752 | 752 | ||
753 | public void sendYouAreBannedNotice(ScenePresence avatar) | 753 | public void sendYouAreBannedNotice(ScenePresence avatar) |
754 | { | 754 | { |
755 | if (allowedForcefulBans) | 755 | if (allowedForcefulBans) |
756 | { | 756 | { |
757 | avatar.ControllingClient.SendAlertMessage( | 757 | avatar.ControllingClient.SendAlertMessage( |
758 | "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); | 758 | "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); |
759 | 759 | ||
760 | avatar.PhysicsActor.Position = | 760 | avatar.PhysicsActor.Position = |
761 | new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, | 761 | new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, |
762 | avatar.lastKnownAllowedPosition.z); | 762 | avatar.lastKnownAllowedPosition.z); |
763 | avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0); | 763 | avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0); |
764 | } | 764 | } |
765 | else | 765 | else |
766 | { | 766 | { |
767 | avatar.ControllingClient.SendAlertMessage( | 767 | avatar.ControllingClient.SendAlertMessage( |
768 | "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); | 768 | "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | 771 | ||
772 | public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID) | 772 | public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID) |
773 | { | 773 | { |
774 | if (m_scene.RegionInfo.RegionID == regionID) | 774 | if (m_scene.RegionInfo.RegionID == regionID) |
775 | { | 775 | { |
776 | if (landList[localLandID] != null) | 776 | if (landList[localLandID] != null) |
777 | { | 777 | { |
778 | ILandObject parcelAvatarIsEntering = landList[localLandID]; | 778 | ILandObject parcelAvatarIsEntering = landList[localLandID]; |
779 | if (avatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT) | 779 | if (avatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT) |
780 | { | 780 | { |
781 | if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID)) | 781 | if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID)) |
782 | { | 782 | { |
783 | sendYouAreBannedNotice(avatar); | 783 | sendYouAreBannedNotice(avatar); |
784 | } | 784 | } |
785 | else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) | 785 | else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) |
786 | { | 786 | { |
787 | avatar.ControllingClient.SendAlertMessage( | 787 | avatar.ControllingClient.SendAlertMessage( |
788 | "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); | 788 | "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); |
789 | } | 789 | } |
790 | else | 790 | else |
791 | { | 791 | { |
792 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | 792 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; |
793 | } | 793 | } |
794 | } | 794 | } |
795 | else | 795 | else |
796 | { | 796 | { |
797 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; | 797 | avatar.sentMessageAboutRestrictedParcelFlyingDown = true; |
798 | } | 798 | } |
799 | } | 799 | } |
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | public void sendOutNearestBanLine(IClientAPI avatar) | 803 | public void sendOutNearestBanLine(IClientAPI avatar) |
804 | { | 804 | { |
805 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 805 | List<ScenePresence> avatars = m_scene.GetAvatars(); |
806 | foreach (ScenePresence presence in avatars) | 806 | foreach (ScenePresence presence in avatars) |
807 | { | 807 | { |
808 | if (presence.UUID == avatar.AgentId) | 808 | if (presence.UUID == avatar.AgentId) |
809 | { | 809 | { |
810 | List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); | 810 | List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); |
811 | foreach (ILandObject checkBan in checkLandParcels) | 811 | foreach (ILandObject checkBan in checkLandParcels) |
812 | { | 812 | { |
813 | if (checkBan.isBannedFromLand(avatar.AgentId)) | 813 | if (checkBan.isBannedFromLand(avatar.AgentId)) |
814 | { | 814 | { |
815 | checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); | 815 | checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); |
816 | return; //Only send one | 816 | return; //Only send one |
817 | } | 817 | } |
818 | else if (checkBan.isRestrictedFromLand(avatar.AgentId)) | 818 | else if (checkBan.isRestrictedFromLand(avatar.AgentId)) |
819 | { | 819 | { |
820 | checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); | 820 | checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); |
821 | return; //Only send one | 821 | return; //Only send one |
822 | } | 822 | } |
823 | } | 823 | } |
824 | return; | 824 | return; |
825 | } | 825 | } |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | public void sendLandUpdate(ScenePresence avatar, bool force) | 829 | public void sendLandUpdate(ScenePresence avatar, bool force) |
830 | { | 830 | { |
831 | ILandObject over = null; | 831 | ILandObject over = null; |
832 | try | 832 | try |
833 | { | 833 | { |
834 | over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 834 | over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
835 | (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 835 | (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
836 | } | 836 | } |
837 | catch (Exception) | 837 | catch (Exception) |
838 | { | 838 | { |
839 | //m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y)); | 839 | //m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y)); |
840 | } | 840 | } |
841 | 841 | ||
842 | if (over != null) | 842 | if (over != null) |
843 | { | 843 | { |
844 | if (force) | 844 | if (force) |
845 | { | 845 | { |
846 | if (!avatar.IsChildAgent) | 846 | if (!avatar.IsChildAgent) |
847 | { | 847 | { |
848 | over.sendLandUpdateToClient(avatar.ControllingClient); | 848 | over.sendLandUpdateToClient(avatar.ControllingClient); |
849 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, | 849 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, |
850 | m_scene.RegionInfo.RegionID); | 850 | m_scene.RegionInfo.RegionID); |
851 | } | 851 | } |
852 | } | 852 | } |
853 | 853 | ||
854 | if (avatar.currentParcelUUID != over.landData.globalID) | 854 | if (avatar.currentParcelUUID != over.landData.globalID) |
855 | { | 855 | { |
856 | if (!avatar.IsChildAgent) | 856 | if (!avatar.IsChildAgent) |
857 | { | 857 | { |
858 | over.sendLandUpdateToClient(avatar.ControllingClient); | 858 | over.sendLandUpdateToClient(avatar.ControllingClient); |
859 | avatar.currentParcelUUID = over.landData.globalID; | 859 | avatar.currentParcelUUID = over.landData.globalID; |
860 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, | 860 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, |
861 | m_scene.RegionInfo.RegionID); | 861 | m_scene.RegionInfo.RegionID); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | } | 864 | } |
865 | } | 865 | } |
866 | 866 | ||
867 | public void sendLandUpdate(ScenePresence avatar) | 867 | public void sendLandUpdate(ScenePresence avatar) |
868 | { | 868 | { |
869 | sendLandUpdate(avatar, false); | 869 | sendLandUpdate(avatar, false); |
870 | } | 870 | } |
871 | 871 | ||
872 | public void handleSignificantClientMovement(IClientAPI remote_client) | 872 | public void handleSignificantClientMovement(IClientAPI remote_client) |
873 | { | 873 | { |
874 | ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); | 874 | ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); |
875 | 875 | ||
876 | if (clientAvatar != null) | 876 | if (clientAvatar != null) |
877 | { | 877 | { |
878 | sendLandUpdate(clientAvatar); | 878 | sendLandUpdate(clientAvatar); |
879 | sendOutNearestBanLine(remote_client); | 879 | sendOutNearestBanLine(remote_client); |
880 | ILandObject parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); | 880 | ILandObject parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); |
881 | if (parcel != null) | 881 | if (parcel != null) |
882 | { | 882 | { |
883 | if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && | 883 | if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && |
884 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) | 884 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) |
885 | { | 885 | { |
886 | handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); | 886 | handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); |
887 | //They are going below the safety line! | 887 | //They are going below the safety line! |
888 | if (!parcel.isBannedFromLand(clientAvatar.UUID)) | 888 | if (!parcel.isBannedFromLand(clientAvatar.UUID)) |
889 | { | 889 | { |
890 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; | 890 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; |
891 | } | 891 | } |
892 | } | 892 | } |
893 | else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && | 893 | else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && |
894 | parcel.isBannedFromLand(clientAvatar.UUID)) | 894 | parcel.isBannedFromLand(clientAvatar.UUID)) |
895 | { | 895 | { |
896 | sendYouAreBannedNotice(clientAvatar); | 896 | sendYouAreBannedNotice(clientAvatar); |
897 | } | 897 | } |
898 | } | 898 | } |
899 | } | 899 | } |
900 | } | 900 | } |
901 | 901 | ||
902 | public void handleAnyClientMovement(ScenePresence avatar) | 902 | public void handleAnyClientMovement(ScenePresence avatar) |
903 | //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. | 903 | //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. |
904 | { | 904 | { |
905 | ILandObject over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 905 | ILandObject over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); |
906 | if (over != null) | 906 | if (over != null) |
907 | { | 907 | { |
908 | if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) | 908 | if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) |
909 | { | 909 | { |
910 | avatar.lastKnownAllowedPosition = | 910 | avatar.lastKnownAllowedPosition = |
911 | new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); | 911 | new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); |
912 | } | 912 | } |
913 | } | 913 | } |
914 | } | 914 | } |
915 | 915 | ||
916 | 916 | ||
917 | public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, | 917 | public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, |
918 | int landLocalID, IClientAPI remote_client) | 918 | int landLocalID, IClientAPI remote_client) |
919 | { | 919 | { |
920 | if (landList.ContainsKey(landLocalID)) | 920 | if (landList.ContainsKey(landLocalID)) |
921 | { | 921 | { |
922 | landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client); | 922 | landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, | 926 | public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, |
927 | List<ParcelManager.ParcelAccessEntry> entries, | 927 | List<ParcelManager.ParcelAccessEntry> entries, |
928 | IClientAPI remote_client) | 928 | IClientAPI remote_client) |
929 | { | 929 | { |
930 | if (landList.ContainsKey(landLocalID)) | 930 | if (landList.ContainsKey(landLocalID)) |
931 | { | 931 | { |
932 | if (agentID == landList[landLocalID].landData.ownerID) | 932 | if (agentID == landList[landLocalID].landData.ownerID) |
933 | { | 933 | { |
934 | landList[landLocalID].updateAccessList(flags, entries, remote_client); | 934 | landList[landLocalID].updateAccessList(flags, entries, remote_client); |
935 | } | 935 | } |
936 | } | 936 | } |
937 | else | 937 | else |
938 | { | 938 | { |
939 | Console.WriteLine("INVALID LOCAL LAND ID"); | 939 | Console.WriteLine("INVALID LOCAL LAND ID"); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | 942 | ||
943 | #endregion | 943 | #endregion |
944 | 944 | ||
945 | // If the economy has been validated by the economy module, | 945 | // If the economy has been validated by the economy module, |
946 | // and land has been validated as well, this method transfers | 946 | // and land has been validated as well, this method transfers |
947 | // the land ownership | 947 | // the land ownership |
948 | 948 | ||
949 | public void handleLandBuyRequest(Object o, EventManager.LandBuyArgs e) | 949 | public void handleLandBuyRequest(Object o, EventManager.LandBuyArgs e) |
950 | { | 950 | { |
951 | if (e.economyValidated && e.landValidated) | 951 | if (e.economyValidated && e.landValidated) |
952 | { | 952 | { |
953 | lock (landList) | 953 | lock (landList) |
954 | { | 954 | { |
955 | if (landList.ContainsKey(e.parcelLocalID)) | 955 | if (landList.ContainsKey(e.parcelLocalID)) |
956 | { | 956 | { |
957 | landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea); | 957 | landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea); |
958 | return; | 958 | return; |
959 | } | 959 | } |
960 | } | 960 | } |
961 | } | 961 | } |
962 | } | 962 | } |
963 | 963 | ||
964 | // After receiving a land buy packet, first the data needs to | 964 | // After receiving a land buy packet, first the data needs to |
965 | // be validated. This method validates the right to buy the | 965 | // be validated. This method validates the right to buy the |
966 | // parcel | 966 | // parcel |
967 | 967 | ||
968 | public void handleLandValidationRequest(Object o, EventManager.LandBuyArgs e) | 968 | public void handleLandValidationRequest(Object o, EventManager.LandBuyArgs e) |
969 | { | 969 | { |
970 | if (e.landValidated == false) | 970 | if (e.landValidated == false) |
971 | { | 971 | { |
972 | ILandObject lob = null; | 972 | ILandObject lob = null; |
973 | lock (landList) | 973 | lock (landList) |
974 | { | 974 | { |
975 | if (landList.ContainsKey(e.parcelLocalID)) | 975 | if (landList.ContainsKey(e.parcelLocalID)) |
976 | { | 976 | { |
977 | lob = landList[e.parcelLocalID]; | 977 | lob = landList[e.parcelLocalID]; |
978 | } | 978 | } |
979 | } | 979 | } |
980 | if (lob != null) | 980 | if (lob != null) |
981 | { | 981 | { |
982 | LLUUID AuthorizedID = lob.landData.authBuyerID; | 982 | LLUUID AuthorizedID = lob.landData.authBuyerID; |
983 | int saleprice = lob.landData.salePrice; | 983 | int saleprice = lob.landData.salePrice; |
984 | LLUUID pOwnerID = lob.landData.ownerID; | 984 | LLUUID pOwnerID = lob.landData.ownerID; |
985 | 985 | ||
986 | bool landforsale = ((lob.landData.landFlags & | 986 | bool landforsale = ((lob.landData.landFlags & |
987 | (uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); | 987 | (uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); |
988 | if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) | 988 | if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) |
989 | { | 989 | { |
990 | lock (e) | 990 | lock (e) |
991 | { | 991 | { |
992 | e.parcelOwnerID = pOwnerID; | 992 | e.parcelOwnerID = pOwnerID; |
993 | e.landValidated = true; | 993 | e.landValidated = true; |
994 | } | 994 | } |
995 | } | 995 | } |
996 | } | 996 | } |
997 | } | 997 | } |
998 | } | 998 | } |
999 | } | 999 | } |
1000 | } \ No newline at end of file | 1000 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index 3f09bd5..877bed5 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs | |||
@@ -1,79 +1,79 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using Nini.Config; | 28 | using Nini.Config; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Land | 32 | namespace OpenSim.Region.Environment.Modules.World.Land |
33 | { | 33 | { |
34 | public class LandManagementModule : IRegionModule | 34 | public class LandManagementModule : IRegionModule |
35 | { | 35 | { |
36 | private LandChannel landChannel; | 36 | private LandChannel landChannel; |
37 | private Scene m_scene; | 37 | private Scene m_scene; |
38 | 38 | ||
39 | #region IRegionModule Members | 39 | #region IRegionModule Members |
40 | 40 | ||
41 | public void Initialise(Scene scene, IConfigSource source) | 41 | public void Initialise(Scene scene, IConfigSource source) |
42 | { | 42 | { |
43 | m_scene = scene; | 43 | m_scene = scene; |
44 | landChannel = new LandChannel(scene); | 44 | landChannel = new LandChannel(scene); |
45 | 45 | ||
46 | m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; | 46 | m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; |
47 | m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; | 47 | m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; |
48 | m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); | 48 | m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); |
49 | m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); | 49 | m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); |
50 | m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest; | 50 | m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest; |
51 | m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest; | 51 | m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest; |
52 | 52 | ||
53 | lock (m_scene) | 53 | lock (m_scene) |
54 | { | 54 | { |
55 | m_scene.LandChannel = (ILandChannel) landChannel; | 55 | m_scene.LandChannel = (ILandChannel) landChannel; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | public void PostInitialise() | 59 | public void PostInitialise() |
60 | { | 60 | { |
61 | } | 61 | } |
62 | 62 | ||
63 | public void Close() | 63 | public void Close() |
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | public string Name | 67 | public string Name |
68 | { | 68 | { |
69 | get { return "LandManagementModule"; } | 69 | get { return "LandManagementModule"; } |
70 | } | 70 | } |
71 | 71 | ||
72 | public bool IsSharedModule | 72 | public bool IsSharedModule |
73 | { | 73 | { |
74 | get { return false; } | 74 | get { return false; } |
75 | } | 75 | } |
76 | 76 | ||
77 | #endregion | 77 | #endregion |
78 | } | 78 | } |
79 | } \ No newline at end of file | 79 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index 368e113..e297b10 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs | |||
@@ -1,928 +1,928 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Environment.Interfaces; | 35 | using OpenSim.Region.Environment.Interfaces; |
36 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
37 | 37 | ||
38 | namespace OpenSim.Region.Environment.Modules.World.Land | 38 | namespace OpenSim.Region.Environment.Modules.World.Land |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// Keeps track of a specific piece of land's information | 41 | /// Keeps track of a specific piece of land's information |
42 | /// </summary> | 42 | /// </summary> |
43 | public class LandObject : ILandObject | 43 | public class LandObject : ILandObject |
44 | { | 44 | { |
45 | #region Member Variables | 45 | #region Member Variables |
46 | 46 | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | private bool[,] m_landBitmap = new bool[64,64]; | 48 | private bool[,] m_landBitmap = new bool[64,64]; |
49 | 49 | ||
50 | protected LandData m_landData = new LandData(); | 50 | protected LandData m_landData = new LandData(); |
51 | protected Scene m_scene; | 51 | protected Scene m_scene; |
52 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | 52 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); |
53 | 53 | ||
54 | public bool[,] landBitmap | 54 | public bool[,] landBitmap |
55 | { | 55 | { |
56 | get { return m_landBitmap; } | 56 | get { return m_landBitmap; } |
57 | set { m_landBitmap = value; } | 57 | set { m_landBitmap = value; } |
58 | } | 58 | } |
59 | 59 | ||
60 | #endregion | 60 | #endregion |
61 | 61 | ||
62 | #region ILandObject Members | 62 | #region ILandObject Members |
63 | 63 | ||
64 | public LandData landData | 64 | public LandData landData |
65 | { | 65 | { |
66 | get { return m_landData; } | 66 | get { return m_landData; } |
67 | 67 | ||
68 | set { m_landData = value; } | 68 | set { m_landData = value; } |
69 | } | 69 | } |
70 | 70 | ||
71 | public LLUUID regionUUID | 71 | public LLUUID regionUUID |
72 | { | 72 | { |
73 | get { return m_scene.RegionInfo.RegionID; } | 73 | get { return m_scene.RegionInfo.RegionID; } |
74 | } | 74 | } |
75 | 75 | ||
76 | #region Constructors | 76 | #region Constructors |
77 | 77 | ||
78 | public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) | 78 | public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) |
79 | { | 79 | { |
80 | m_scene = scene; | 80 | m_scene = scene; |
81 | landData.ownerID = owner_id; | 81 | landData.ownerID = owner_id; |
82 | landData.isGroupOwned = is_group_owned; | 82 | landData.isGroupOwned = is_group_owned; |
83 | } | 83 | } |
84 | 84 | ||
85 | #endregion | 85 | #endregion |
86 | 86 | ||
87 | #region Member Functions | 87 | #region Member Functions |
88 | 88 | ||
89 | #region General Functions | 89 | #region General Functions |
90 | 90 | ||
91 | /// <summary> | 91 | /// <summary> |
92 | /// Checks to see if this land object contains a point | 92 | /// Checks to see if this land object contains a point |
93 | /// </summary> | 93 | /// </summary> |
94 | /// <param name="x"></param> | 94 | /// <param name="x"></param> |
95 | /// <param name="y"></param> | 95 | /// <param name="y"></param> |
96 | /// <returns>Returns true if the piece of land contains the specified point</returns> | 96 | /// <returns>Returns true if the piece of land contains the specified point</returns> |
97 | public bool containsPoint(int x, int y) | 97 | public bool containsPoint(int x, int y) |
98 | { | 98 | { |
99 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) | 99 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) |
100 | { | 100 | { |
101 | return (landBitmap[x / 4, y / 4] == true); | 101 | return (landBitmap[x / 4, y / 4] == true); |
102 | } | 102 | } |
103 | else | 103 | else |
104 | { | 104 | { |
105 | return false; | 105 | return false; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | public ILandObject Copy() | 109 | public ILandObject Copy() |
110 | { | 110 | { |
111 | ILandObject newLand = new LandObject(landData.ownerID, landData.isGroupOwned, m_scene); | 111 | ILandObject newLand = new LandObject(landData.ownerID, landData.isGroupOwned, m_scene); |
112 | 112 | ||
113 | //Place all new variables here! | 113 | //Place all new variables here! |
114 | newLand.landBitmap = (bool[,]) (landBitmap.Clone()); | 114 | newLand.landBitmap = (bool[,]) (landBitmap.Clone()); |
115 | newLand.landData = landData.Copy(); | 115 | newLand.landData = landData.Copy(); |
116 | 116 | ||
117 | return newLand; | 117 | return newLand; |
118 | } | 118 | } |
119 | 119 | ||
120 | #endregion | 120 | #endregion |
121 | 121 | ||
122 | #region Packet Request Handling | 122 | #region Packet Request Handling |
123 | 123 | ||
124 | /// <summary> | 124 | /// <summary> |
125 | /// Sends land properties as requested | 125 | /// Sends land properties as requested |
126 | /// </summary> | 126 | /// </summary> |
127 | /// <param name="sequence_id">ID sent by client for them to keep track of</param> | 127 | /// <param name="sequence_id">ID sent by client for them to keep track of</param> |
128 | /// <param name="snap_selection">Bool sent by client for them to use</param> | 128 | /// <param name="snap_selection">Bool sent by client for them to use</param> |
129 | /// <param name="remote_client">Object representing the client</param> | 129 | /// <param name="remote_client">Object representing the client</param> |
130 | public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, | 130 | public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, |
131 | IClientAPI remote_client) | 131 | IClientAPI remote_client) |
132 | { | 132 | { |
133 | ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); | 133 | ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); |
134 | // TODO: don't create new blocks if recycling an old packet | 134 | // TODO: don't create new blocks if recycling an old packet |
135 | 135 | ||
136 | updatePacket.ParcelData.AABBMax = landData.AABBMax; | 136 | updatePacket.ParcelData.AABBMax = landData.AABBMax; |
137 | updatePacket.ParcelData.AABBMin = landData.AABBMin; | 137 | updatePacket.ParcelData.AABBMin = landData.AABBMin; |
138 | updatePacket.ParcelData.Area = landData.area; | 138 | updatePacket.ParcelData.Area = landData.area; |
139 | updatePacket.ParcelData.AuctionID = landData.auctionID; | 139 | updatePacket.ParcelData.AuctionID = landData.auctionID; |
140 | updatePacket.ParcelData.AuthBuyerID = landData.authBuyerID; //unemplemented | 140 | updatePacket.ParcelData.AuthBuyerID = landData.authBuyerID; //unemplemented |
141 | 141 | ||
142 | updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray; | 142 | updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray; |
143 | 143 | ||
144 | updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc); | 144 | updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc); |
145 | updatePacket.ParcelData.Category = (byte) landData.category; | 145 | updatePacket.ParcelData.Category = (byte) landData.category; |
146 | updatePacket.ParcelData.ClaimDate = landData.claimDate; | 146 | updatePacket.ParcelData.ClaimDate = landData.claimDate; |
147 | updatePacket.ParcelData.ClaimPrice = landData.claimPrice; | 147 | updatePacket.ParcelData.ClaimPrice = landData.claimPrice; |
148 | updatePacket.ParcelData.GroupID = landData.groupID; | 148 | updatePacket.ParcelData.GroupID = landData.groupID; |
149 | updatePacket.ParcelData.GroupPrims = landData.groupPrims; | 149 | updatePacket.ParcelData.GroupPrims = landData.groupPrims; |
150 | updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; | 150 | updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; |
151 | updatePacket.ParcelData.LandingType = (byte) landData.landingType; | 151 | updatePacket.ParcelData.LandingType = (byte) landData.landingType; |
152 | updatePacket.ParcelData.LocalID = landData.localID; | 152 | updatePacket.ParcelData.LocalID = landData.localID; |
153 | if (landData.area > 0) | 153 | if (landData.area > 0) |
154 | { | 154 | { |
155 | updatePacket.ParcelData.MaxPrims = | 155 | updatePacket.ParcelData.MaxPrims = |
156 | Convert.ToInt32( | 156 | Convert.ToInt32( |
157 | Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity * | 157 | Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity * |
158 | Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); | 158 | Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); |
159 | } | 159 | } |
160 | else | 160 | else |
161 | { | 161 | { |
162 | updatePacket.ParcelData.MaxPrims = 0; | 162 | updatePacket.ParcelData.MaxPrims = 0; |
163 | } | 163 | } |
164 | updatePacket.ParcelData.MediaAutoScale = landData.mediaAutoScale; | 164 | updatePacket.ParcelData.MediaAutoScale = landData.mediaAutoScale; |
165 | updatePacket.ParcelData.MediaID = landData.mediaID; | 165 | updatePacket.ParcelData.MediaID = landData.mediaID; |
166 | updatePacket.ParcelData.MediaURL = Helpers.StringToField(landData.mediaURL); | 166 | updatePacket.ParcelData.MediaURL = Helpers.StringToField(landData.mediaURL); |
167 | updatePacket.ParcelData.MusicURL = Helpers.StringToField(landData.musicURL); | 167 | updatePacket.ParcelData.MusicURL = Helpers.StringToField(landData.musicURL); |
168 | updatePacket.ParcelData.Name = Helpers.StringToField(landData.landName); | 168 | updatePacket.ParcelData.Name = Helpers.StringToField(landData.landName); |
169 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented | 169 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented |
170 | updatePacket.ParcelData.OtherCount = 0; //unemplemented | 170 | updatePacket.ParcelData.OtherCount = 0; //unemplemented |
171 | updatePacket.ParcelData.OtherPrims = landData.otherPrims; | 171 | updatePacket.ParcelData.OtherPrims = landData.otherPrims; |
172 | updatePacket.ParcelData.OwnerID = landData.ownerID; | 172 | updatePacket.ParcelData.OwnerID = landData.ownerID; |
173 | updatePacket.ParcelData.OwnerPrims = landData.ownerPrims; | 173 | updatePacket.ParcelData.OwnerPrims = landData.ownerPrims; |
174 | updatePacket.ParcelData.ParcelFlags = landData.landFlags; | 174 | updatePacket.ParcelData.ParcelFlags = landData.landFlags; |
175 | updatePacket.ParcelData.ParcelPrimBonus = m_scene.RegionInfo.EstateSettings.objectBonusFactor; | 175 | updatePacket.ParcelData.ParcelPrimBonus = m_scene.RegionInfo.EstateSettings.objectBonusFactor; |
176 | updatePacket.ParcelData.PassHours = landData.passHours; | 176 | updatePacket.ParcelData.PassHours = landData.passHours; |
177 | updatePacket.ParcelData.PassPrice = landData.passPrice; | 177 | updatePacket.ParcelData.PassPrice = landData.passPrice; |
178 | updatePacket.ParcelData.PublicCount = 0; //unemplemented | 178 | updatePacket.ParcelData.PublicCount = 0; //unemplemented |
179 | 179 | ||
180 | uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; | 180 | uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; |
181 | updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > | 181 | updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > |
182 | 0); | 182 | 0); |
183 | updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint) Simulator.RegionFlags.DenyIdentified) > | 183 | updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint) Simulator.RegionFlags.DenyIdentified) > |
184 | 0); | 184 | 0); |
185 | updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint) Simulator.RegionFlags.DenyTransacted) > | 185 | updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint) Simulator.RegionFlags.DenyTransacted) > |
186 | 0); | 186 | 0); |
187 | updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint) Simulator.RegionFlags.RestrictPushObject) > | 187 | updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint) Simulator.RegionFlags.RestrictPushObject) > |
188 | 0); | 188 | 0); |
189 | 189 | ||
190 | updatePacket.ParcelData.RentPrice = 0; | 190 | updatePacket.ParcelData.RentPrice = 0; |
191 | updatePacket.ParcelData.RequestResult = request_result; | 191 | updatePacket.ParcelData.RequestResult = request_result; |
192 | updatePacket.ParcelData.SalePrice = landData.salePrice; | 192 | updatePacket.ParcelData.SalePrice = landData.salePrice; |
193 | updatePacket.ParcelData.SelectedPrims = landData.selectedPrims; | 193 | updatePacket.ParcelData.SelectedPrims = landData.selectedPrims; |
194 | updatePacket.ParcelData.SelfCount = 0; //unemplemented | 194 | updatePacket.ParcelData.SelfCount = 0; //unemplemented |
195 | updatePacket.ParcelData.SequenceID = sequence_id; | 195 | updatePacket.ParcelData.SequenceID = sequence_id; |
196 | if (landData.simwideArea > 0) | 196 | if (landData.simwideArea > 0) |
197 | { | 197 | { |
198 | updatePacket.ParcelData.SimWideMaxPrims = | 198 | updatePacket.ParcelData.SimWideMaxPrims = |
199 | Convert.ToInt32( | 199 | Convert.ToInt32( |
200 | Math.Round((Convert.ToDecimal(landData.simwideArea) / Convert.ToDecimal(65536)) * m_scene.objectCapacity * | 200 | Math.Round((Convert.ToDecimal(landData.simwideArea) / Convert.ToDecimal(65536)) * m_scene.objectCapacity * |
201 | Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); | 201 | Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); |
202 | } | 202 | } |
203 | else | 203 | else |
204 | { | 204 | { |
205 | updatePacket.ParcelData.SimWideMaxPrims = 0; | 205 | updatePacket.ParcelData.SimWideMaxPrims = 0; |
206 | } | 206 | } |
207 | updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims; | 207 | updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims; |
208 | updatePacket.ParcelData.SnapSelection = snap_selection; | 208 | updatePacket.ParcelData.SnapSelection = snap_selection; |
209 | updatePacket.ParcelData.SnapshotID = landData.snapshotID; | 209 | updatePacket.ParcelData.SnapshotID = landData.snapshotID; |
210 | updatePacket.ParcelData.Status = (byte) landData.landStatus; | 210 | updatePacket.ParcelData.Status = (byte) landData.landStatus; |
211 | updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + | 211 | updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + |
212 | landData.selectedPrims; | 212 | landData.selectedPrims; |
213 | updatePacket.ParcelData.UserLocation = landData.userLocation; | 213 | updatePacket.ParcelData.UserLocation = landData.userLocation; |
214 | updatePacket.ParcelData.UserLookAt = landData.userLookAt; | 214 | updatePacket.ParcelData.UserLookAt = landData.userLookAt; |
215 | remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task); | 215 | remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task); |
216 | } | 216 | } |
217 | 217 | ||
218 | public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) | 218 | public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) |
219 | { | 219 | { |
220 | if (remote_client.AgentId == landData.ownerID) | 220 | if (remote_client.AgentId == landData.ownerID) |
221 | { | 221 | { |
222 | //Needs later group support | 222 | //Needs later group support |
223 | LandData newData = landData.Copy(); | 223 | LandData newData = landData.Copy(); |
224 | newData.authBuyerID = packet.ParcelData.AuthBuyerID; | 224 | newData.authBuyerID = packet.ParcelData.AuthBuyerID; |
225 | newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; | 225 | newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; |
226 | newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); | 226 | newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); |
227 | newData.groupID = packet.ParcelData.GroupID; | 227 | newData.groupID = packet.ParcelData.GroupID; |
228 | newData.landingType = packet.ParcelData.LandingType; | 228 | newData.landingType = packet.ParcelData.LandingType; |
229 | newData.mediaAutoScale = packet.ParcelData.MediaAutoScale; | 229 | newData.mediaAutoScale = packet.ParcelData.MediaAutoScale; |
230 | newData.mediaID = packet.ParcelData.MediaID; | 230 | newData.mediaID = packet.ParcelData.MediaID; |
231 | newData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); | 231 | newData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); |
232 | newData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); | 232 | newData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); |
233 | newData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name); | 233 | newData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name); |
234 | newData.landFlags = packet.ParcelData.ParcelFlags; | 234 | newData.landFlags = packet.ParcelData.ParcelFlags; |
235 | newData.passHours = packet.ParcelData.PassHours; | 235 | newData.passHours = packet.ParcelData.PassHours; |
236 | newData.passPrice = packet.ParcelData.PassPrice; | 236 | newData.passPrice = packet.ParcelData.PassPrice; |
237 | newData.salePrice = packet.ParcelData.SalePrice; | 237 | newData.salePrice = packet.ParcelData.SalePrice; |
238 | newData.snapshotID = packet.ParcelData.SnapshotID; | 238 | newData.snapshotID = packet.ParcelData.SnapshotID; |
239 | newData.userLocation = packet.ParcelData.UserLocation; | 239 | newData.userLocation = packet.ParcelData.UserLocation; |
240 | newData.userLookAt = packet.ParcelData.UserLookAt; | 240 | newData.userLookAt = packet.ParcelData.UserLookAt; |
241 | 241 | ||
242 | m_scene.LandChannel.updateLandObject(landData.localID, newData); | 242 | m_scene.LandChannel.updateLandObject(landData.localID, newData); |
243 | 243 | ||
244 | sendLandUpdateToAvatarsOverMe(); | 244 | sendLandUpdateToAvatarsOverMe(); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) | 248 | public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) |
249 | { | 249 | { |
250 | LandData newData = landData.Copy(); | 250 | LandData newData = landData.Copy(); |
251 | newData.ownerID = avatarID; | 251 | newData.ownerID = avatarID; |
252 | newData.groupID = groupID; | 252 | newData.groupID = groupID; |
253 | newData.isGroupOwned = groupOwned; | 253 | newData.isGroupOwned = groupOwned; |
254 | //newData.auctionID = AuctionID; | 254 | //newData.auctionID = AuctionID; |
255 | newData.claimDate = Util.UnixTimeSinceEpoch(); | 255 | newData.claimDate = Util.UnixTimeSinceEpoch(); |
256 | newData.claimPrice = claimprice; | 256 | newData.claimPrice = claimprice; |
257 | newData.salePrice = 0; | 257 | newData.salePrice = 0; |
258 | newData.authBuyerID = LLUUID.Zero; | 258 | newData.authBuyerID = LLUUID.Zero; |
259 | newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); | 259 | newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); |
260 | m_scene.LandChannel.updateLandObject(landData.localID, newData); | 260 | m_scene.LandChannel.updateLandObject(landData.localID, newData); |
261 | 261 | ||
262 | sendLandUpdateToAvatarsOverMe(); | 262 | sendLandUpdateToAvatarsOverMe(); |
263 | } | 263 | } |
264 | 264 | ||
265 | public bool isEitherBannedOrRestricted(LLUUID avatar) | 265 | public bool isEitherBannedOrRestricted(LLUUID avatar) |
266 | { | 266 | { |
267 | if (isBannedFromLand(avatar)) | 267 | if (isBannedFromLand(avatar)) |
268 | { | 268 | { |
269 | return true; | 269 | return true; |
270 | } | 270 | } |
271 | else if (isRestrictedFromLand(avatar)) | 271 | else if (isRestrictedFromLand(avatar)) |
272 | { | 272 | { |
273 | return true; | 273 | return true; |
274 | } | 274 | } |
275 | return false; | 275 | return false; |
276 | } | 276 | } |
277 | 277 | ||
278 | public bool isBannedFromLand(LLUUID avatar) | 278 | public bool isBannedFromLand(LLUUID avatar) |
279 | { | 279 | { |
280 | if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0) | 280 | if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0) |
281 | { | 281 | { |
282 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | 282 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
283 | entry.AgentID = avatar; | 283 | entry.AgentID = avatar; |
284 | entry.Flags = ParcelManager.AccessList.Ban; | 284 | entry.Flags = ParcelManager.AccessList.Ban; |
285 | entry.Time = new DateTime(); | 285 | entry.Time = new DateTime(); |
286 | if (landData.parcelAccessList.Contains(entry)) | 286 | if (landData.parcelAccessList.Contains(entry)) |
287 | { | 287 | { |
288 | //They are banned, so lets send them a notice about this parcel | 288 | //They are banned, so lets send them a notice about this parcel |
289 | return true; | 289 | return true; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | 294 | ||
295 | public bool isRestrictedFromLand(LLUUID avatar) | 295 | public bool isRestrictedFromLand(LLUUID avatar) |
296 | { | 296 | { |
297 | if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0) | 297 | if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0) |
298 | { | 298 | { |
299 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | 299 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
300 | entry.AgentID = avatar; | 300 | entry.AgentID = avatar; |
301 | entry.Flags = ParcelManager.AccessList.Access; | 301 | entry.Flags = ParcelManager.AccessList.Access; |
302 | entry.Time = new DateTime(); | 302 | entry.Time = new DateTime(); |
303 | if (!landData.parcelAccessList.Contains(entry)) | 303 | if (!landData.parcelAccessList.Contains(entry)) |
304 | { | 304 | { |
305 | //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel | 305 | //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel |
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | return false; | 309 | return false; |
310 | } | 310 | } |
311 | 311 | ||
312 | public void sendLandUpdateToClient(IClientAPI remote_client) | 312 | public void sendLandUpdateToClient(IClientAPI remote_client) |
313 | { | 313 | { |
314 | sendLandProperties(0, false, 0, remote_client); | 314 | sendLandProperties(0, false, 0, remote_client); |
315 | } | 315 | } |
316 | 316 | ||
317 | public void sendLandUpdateToAvatarsOverMe() | 317 | public void sendLandUpdateToAvatarsOverMe() |
318 | { | 318 | { |
319 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 319 | List<ScenePresence> avatars = m_scene.GetAvatars(); |
320 | ILandObject over = null; | 320 | ILandObject over = null; |
321 | for (int i = 0; i < avatars.Count; i++) | 321 | for (int i = 0; i < avatars.Count; i++) |
322 | { | 322 | { |
323 | try | 323 | try |
324 | { | 324 | { |
325 | over = | 325 | over = |
326 | m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))), | 326 | m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))), |
327 | (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y)))); | 327 | (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y)))); |
328 | } | 328 | } |
329 | catch (Exception) | 329 | catch (Exception) |
330 | { | 330 | { |
331 | m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + | 331 | m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + |
332 | Math.Round(avatars[i].AbsolutePosition.Y)); | 332 | Math.Round(avatars[i].AbsolutePosition.Y)); |
333 | } | 333 | } |
334 | 334 | ||
335 | if (over != null) | 335 | if (over != null) |
336 | { | 336 | { |
337 | if (over.landData.localID == landData.localID) | 337 | if (over.landData.localID == landData.localID) |
338 | { | 338 | { |
339 | sendLandUpdateToClient(avatars[i].ControllingClient); | 339 | sendLandUpdateToClient(avatars[i].ControllingClient); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | #endregion | 345 | #endregion |
346 | 346 | ||
347 | #region AccessList Functions | 347 | #region AccessList Functions |
348 | 348 | ||
349 | public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag) | 349 | public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag) |
350 | { | 350 | { |
351 | List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>(); | 351 | List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>(); |
352 | foreach (ParcelManager.ParcelAccessEntry entry in landData.parcelAccessList) | 352 | foreach (ParcelManager.ParcelAccessEntry entry in landData.parcelAccessList) |
353 | { | 353 | { |
354 | if (entry.Flags == flag) | 354 | if (entry.Flags == flag) |
355 | { | 355 | { |
356 | ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); | 356 | ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); |
357 | 357 | ||
358 | listBlock.Flags = (uint) 0; | 358 | listBlock.Flags = (uint) 0; |
359 | listBlock.ID = entry.AgentID; | 359 | listBlock.ID = entry.AgentID; |
360 | listBlock.Time = 0; | 360 | listBlock.Time = 0; |
361 | 361 | ||
362 | list.Add(listBlock); | 362 | list.Add(listBlock); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | if (list.Count == 0) | 366 | if (list.Count == 0) |
367 | { | 367 | { |
368 | ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); | 368 | ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); |
369 | 369 | ||
370 | listBlock.Flags = (uint) 0; | 370 | listBlock.Flags = (uint) 0; |
371 | listBlock.ID = LLUUID.Zero; | 371 | listBlock.ID = LLUUID.Zero; |
372 | listBlock.Time = 0; | 372 | listBlock.Time = 0; |
373 | 373 | ||
374 | list.Add(listBlock); | 374 | list.Add(listBlock); |
375 | } | 375 | } |
376 | return list.ToArray(); | 376 | return list.ToArray(); |
377 | } | 377 | } |
378 | 378 | ||
379 | public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, | 379 | public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, |
380 | IClientAPI remote_client) | 380 | IClientAPI remote_client) |
381 | { | 381 | { |
382 | ParcelAccessListReplyPacket replyPacket; | 382 | ParcelAccessListReplyPacket replyPacket; |
383 | 383 | ||
384 | if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both) | 384 | if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both) |
385 | { | 385 | { |
386 | replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); | 386 | replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); |
387 | replyPacket.Data.AgentID = agentID; | 387 | replyPacket.Data.AgentID = agentID; |
388 | replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; | 388 | replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; |
389 | replyPacket.Data.LocalID = landData.localID; | 389 | replyPacket.Data.LocalID = landData.localID; |
390 | replyPacket.Data.SequenceID = 0; | 390 | replyPacket.Data.SequenceID = 0; |
391 | 391 | ||
392 | replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); | 392 | replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); |
393 | remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); | 393 | remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); |
394 | } | 394 | } |
395 | 395 | ||
396 | if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) | 396 | if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) |
397 | { | 397 | { |
398 | replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); | 398 | replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); |
399 | replyPacket.Data.AgentID = agentID; | 399 | replyPacket.Data.AgentID = agentID; |
400 | replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; | 400 | replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; |
401 | replyPacket.Data.LocalID = landData.localID; | 401 | replyPacket.Data.LocalID = landData.localID; |
402 | replyPacket.Data.SequenceID = 0; | 402 | replyPacket.Data.SequenceID = 0; |
403 | 403 | ||
404 | replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); | 404 | replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); |
405 | remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); | 405 | remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) | 409 | public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) |
410 | { | 410 | { |
411 | LandData newData = landData.Copy(); | 411 | LandData newData = landData.Copy(); |
412 | 412 | ||
413 | if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero) | 413 | if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero) |
414 | { | 414 | { |
415 | entries.Clear(); | 415 | entries.Clear(); |
416 | } | 416 | } |
417 | 417 | ||
418 | List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); | 418 | List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); |
419 | foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) | 419 | foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) |
420 | { | 420 | { |
421 | if (entry.Flags == (ParcelManager.AccessList) flags) | 421 | if (entry.Flags == (ParcelManager.AccessList) flags) |
422 | { | 422 | { |
423 | toRemove.Add(entry); | 423 | toRemove.Add(entry); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | foreach (ParcelManager.ParcelAccessEntry entry in toRemove) | 427 | foreach (ParcelManager.ParcelAccessEntry entry in toRemove) |
428 | { | 428 | { |
429 | newData.parcelAccessList.Remove(entry); | 429 | newData.parcelAccessList.Remove(entry); |
430 | } | 430 | } |
431 | foreach (ParcelManager.ParcelAccessEntry entry in entries) | 431 | foreach (ParcelManager.ParcelAccessEntry entry in entries) |
432 | { | 432 | { |
433 | ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); | 433 | ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); |
434 | temp.AgentID = entry.AgentID; | 434 | temp.AgentID = entry.AgentID; |
435 | temp.Time = new DateTime(); //Pointless? Yes. | 435 | temp.Time = new DateTime(); //Pointless? Yes. |
436 | temp.Flags = (ParcelManager.AccessList) flags; | 436 | temp.Flags = (ParcelManager.AccessList) flags; |
437 | 437 | ||
438 | if (!newData.parcelAccessList.Contains(temp)) | 438 | if (!newData.parcelAccessList.Contains(temp)) |
439 | { | 439 | { |
440 | newData.parcelAccessList.Add(temp); | 440 | newData.parcelAccessList.Add(temp); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | m_scene.LandChannel.updateLandObject(landData.localID, newData); | 444 | m_scene.LandChannel.updateLandObject(landData.localID, newData); |
445 | } | 445 | } |
446 | 446 | ||
447 | #endregion | 447 | #endregion |
448 | 448 | ||
449 | #region Update Functions | 449 | #region Update Functions |
450 | 450 | ||
451 | public void updateLandBitmapByteArray() | 451 | public void updateLandBitmapByteArray() |
452 | { | 452 | { |
453 | landData.landBitmapByteArray = convertLandBitmapToBytes(); | 453 | landData.landBitmapByteArray = convertLandBitmapToBytes(); |
454 | } | 454 | } |
455 | 455 | ||
456 | /// <summary> | 456 | /// <summary> |
457 | /// Update all settings in land such as area, bitmap byte array, etc | 457 | /// Update all settings in land such as area, bitmap byte array, etc |
458 | /// </summary> | 458 | /// </summary> |
459 | public void forceUpdateLandInfo() | 459 | public void forceUpdateLandInfo() |
460 | { | 460 | { |
461 | updateAABBAndAreaValues(); | 461 | updateAABBAndAreaValues(); |
462 | updateLandBitmapByteArray(); | 462 | updateLandBitmapByteArray(); |
463 | } | 463 | } |
464 | 464 | ||
465 | public void setLandBitmapFromByteArray() | 465 | public void setLandBitmapFromByteArray() |
466 | { | 466 | { |
467 | landBitmap = convertBytesToLandBitmap(); | 467 | landBitmap = convertBytesToLandBitmap(); |
468 | } | 468 | } |
469 | 469 | ||
470 | /// <summary> | 470 | /// <summary> |
471 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object | 471 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object |
472 | /// </summary> | 472 | /// </summary> |
473 | private void updateAABBAndAreaValues() | 473 | private void updateAABBAndAreaValues() |
474 | { | 474 | { |
475 | int min_x = 64; | 475 | int min_x = 64; |
476 | int min_y = 64; | 476 | int min_y = 64; |
477 | int max_x = 0; | 477 | int max_x = 0; |
478 | int max_y = 0; | 478 | int max_y = 0; |
479 | int tempArea = 0; | 479 | int tempArea = 0; |
480 | int x, y; | 480 | int x, y; |
481 | for (x = 0; x < 64; x++) | 481 | for (x = 0; x < 64; x++) |
482 | { | 482 | { |
483 | for (y = 0; y < 64; y++) | 483 | for (y = 0; y < 64; y++) |
484 | { | 484 | { |
485 | if (landBitmap[x, y] == true) | 485 | if (landBitmap[x, y] == true) |
486 | { | 486 | { |
487 | if (min_x > x) min_x = x; | 487 | if (min_x > x) min_x = x; |
488 | if (min_y > y) min_y = y; | 488 | if (min_y > y) min_y = y; |
489 | if (max_x < x) max_x = x; | 489 | if (max_x < x) max_x = x; |
490 | if (max_y < y) max_y = y; | 490 | if (max_y < y) max_y = y; |
491 | tempArea += 16; //16sqm peice of land | 491 | tempArea += 16; //16sqm peice of land |
492 | } | 492 | } |
493 | } | 493 | } |
494 | } | 494 | } |
495 | int tx = min_x * 4; | 495 | int tx = min_x * 4; |
496 | if (tx > 255) | 496 | if (tx > 255) |
497 | tx = 255; | 497 | tx = 255; |
498 | int ty = min_y * 4; | 498 | int ty = min_y * 4; |
499 | if (ty > 255) | 499 | if (ty > 255) |
500 | ty = 255; | 500 | ty = 255; |
501 | landData.AABBMin = | 501 | landData.AABBMin = |
502 | new LLVector3((float) (min_x * 4), (float) (min_y * 4), | 502 | new LLVector3((float) (min_x * 4), (float) (min_y * 4), |
503 | (float) m_scene.Heightmap[tx, ty]); | 503 | (float) m_scene.Heightmap[tx, ty]); |
504 | 504 | ||
505 | tx = max_x * 4; | 505 | tx = max_x * 4; |
506 | if (tx > 255) | 506 | if (tx > 255) |
507 | tx = 255; | 507 | tx = 255; |
508 | ty = max_y * 4; | 508 | ty = max_y * 4; |
509 | if (ty > 255) | 509 | if (ty > 255) |
510 | ty = 255; | 510 | ty = 255; |
511 | landData.AABBMax = | 511 | landData.AABBMax = |
512 | new LLVector3((float) (max_x * 4), (float) (max_y * 4), | 512 | new LLVector3((float) (max_x * 4), (float) (max_y * 4), |
513 | (float) m_scene.Heightmap[tx, ty]); | 513 | (float) m_scene.Heightmap[tx, ty]); |
514 | landData.area = tempArea; | 514 | landData.area = tempArea; |
515 | } | 515 | } |
516 | 516 | ||
517 | #endregion | 517 | #endregion |
518 | 518 | ||
519 | #region Land Bitmap Functions | 519 | #region Land Bitmap Functions |
520 | 520 | ||
521 | /// <summary> | 521 | /// <summary> |
522 | /// Sets the land's bitmap manually | 522 | /// Sets the land's bitmap manually |
523 | /// </summary> | 523 | /// </summary> |
524 | /// <param name="bitmap">64x64 block representing where this land is on a map</param> | 524 | /// <param name="bitmap">64x64 block representing where this land is on a map</param> |
525 | public void setLandBitmap(bool[,] bitmap) | 525 | public void setLandBitmap(bool[,] bitmap) |
526 | { | 526 | { |
527 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) | 527 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) |
528 | { | 528 | { |
529 | //Throw an exception - The bitmap is not 64x64 | 529 | //Throw an exception - The bitmap is not 64x64 |
530 | //throw new Exception("Error: Invalid Parcel Bitmap"); | 530 | //throw new Exception("Error: Invalid Parcel Bitmap"); |
531 | } | 531 | } |
532 | else | 532 | else |
533 | { | 533 | { |
534 | //Valid: Lets set it | 534 | //Valid: Lets set it |
535 | landBitmap = bitmap; | 535 | landBitmap = bitmap; |
536 | forceUpdateLandInfo(); | 536 | forceUpdateLandInfo(); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | /// <summary> | 540 | /// <summary> |
541 | /// Gets the land's bitmap manually | 541 | /// Gets the land's bitmap manually |
542 | /// </summary> | 542 | /// </summary> |
543 | /// <returns></returns> | 543 | /// <returns></returns> |
544 | public bool[,] getLandBitmap() | 544 | public bool[,] getLandBitmap() |
545 | { | 545 | { |
546 | return landBitmap; | 546 | return landBitmap; |
547 | } | 547 | } |
548 | 548 | ||
549 | /// <summary> | 549 | /// <summary> |
550 | /// Full sim land object creation | 550 | /// Full sim land object creation |
551 | /// </summary> | 551 | /// </summary> |
552 | /// <returns></returns> | 552 | /// <returns></returns> |
553 | public bool[,] basicFullRegionLandBitmap() | 553 | public bool[,] basicFullRegionLandBitmap() |
554 | { | 554 | { |
555 | return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); | 555 | return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); |
556 | } | 556 | } |
557 | 557 | ||
558 | /// <summary> | 558 | /// <summary> |
559 | /// Used to modify the bitmap between the x and y points. Points use 64 scale | 559 | /// Used to modify the bitmap between the x and y points. Points use 64 scale |
560 | /// </summary> | 560 | /// </summary> |
561 | /// <param name="start_x"></param> | 561 | /// <param name="start_x"></param> |
562 | /// <param name="start_y"></param> | 562 | /// <param name="start_y"></param> |
563 | /// <param name="end_x"></param> | 563 | /// <param name="end_x"></param> |
564 | /// <param name="end_y"></param> | 564 | /// <param name="end_y"></param> |
565 | /// <returns></returns> | 565 | /// <returns></returns> |
566 | public bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) | 566 | public bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) |
567 | { | 567 | { |
568 | bool[,] tempBitmap = new bool[64,64]; | 568 | bool[,] tempBitmap = new bool[64,64]; |
569 | tempBitmap.Initialize(); | 569 | tempBitmap.Initialize(); |
570 | 570 | ||
571 | tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); | 571 | tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); |
572 | return tempBitmap; | 572 | return tempBitmap; |
573 | } | 573 | } |
574 | 574 | ||
575 | /// <summary> | 575 | /// <summary> |
576 | /// Change a land bitmap at within a square and set those points to a specific value | 576 | /// Change a land bitmap at within a square and set those points to a specific value |
577 | /// </summary> | 577 | /// </summary> |
578 | /// <param name="land_bitmap"></param> | 578 | /// <param name="land_bitmap"></param> |
579 | /// <param name="start_x"></param> | 579 | /// <param name="start_x"></param> |
580 | /// <param name="start_y"></param> | 580 | /// <param name="start_y"></param> |
581 | /// <param name="end_x"></param> | 581 | /// <param name="end_x"></param> |
582 | /// <param name="end_y"></param> | 582 | /// <param name="end_y"></param> |
583 | /// <param name="set_value"></param> | 583 | /// <param name="set_value"></param> |
584 | /// <returns></returns> | 584 | /// <returns></returns> |
585 | public bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, | 585 | public bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, |
586 | bool set_value) | 586 | bool set_value) |
587 | { | 587 | { |
588 | if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) | 588 | if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) |
589 | { | 589 | { |
590 | //Throw an exception - The bitmap is not 64x64 | 590 | //Throw an exception - The bitmap is not 64x64 |
591 | //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); | 591 | //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); |
592 | } | 592 | } |
593 | 593 | ||
594 | int x, y; | 594 | int x, y; |
595 | for (y = 0; y < 64; y++) | 595 | for (y = 0; y < 64; y++) |
596 | { | 596 | { |
597 | for (x = 0; x < 64; x++) | 597 | for (x = 0; x < 64; x++) |
598 | { | 598 | { |
599 | if (x >= start_x / 4 && x < end_x / 4 | 599 | if (x >= start_x / 4 && x < end_x / 4 |
600 | && y >= start_y / 4 && y < end_y / 4) | 600 | && y >= start_y / 4 && y < end_y / 4) |
601 | { | 601 | { |
602 | land_bitmap[x, y] = set_value; | 602 | land_bitmap[x, y] = set_value; |
603 | } | 603 | } |
604 | } | 604 | } |
605 | } | 605 | } |
606 | return land_bitmap; | 606 | return land_bitmap; |
607 | } | 607 | } |
608 | 608 | ||
609 | /// <summary> | 609 | /// <summary> |
610 | /// Join the true values of 2 bitmaps together | 610 | /// Join the true values of 2 bitmaps together |
611 | /// </summary> | 611 | /// </summary> |
612 | /// <param name="bitmap_base"></param> | 612 | /// <param name="bitmap_base"></param> |
613 | /// <param name="bitmap_add"></param> | 613 | /// <param name="bitmap_add"></param> |
614 | /// <returns></returns> | 614 | /// <returns></returns> |
615 | public bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) | 615 | public bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) |
616 | { | 616 | { |
617 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) | 617 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) |
618 | { | 618 | { |
619 | //Throw an exception - The bitmap is not 64x64 | 619 | //Throw an exception - The bitmap is not 64x64 |
620 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps"); | 620 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps"); |
621 | } | 621 | } |
622 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) | 622 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) |
623 | { | 623 | { |
624 | //Throw an exception - The bitmap is not 64x64 | 624 | //Throw an exception - The bitmap is not 64x64 |
625 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); | 625 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); |
626 | } | 626 | } |
627 | 627 | ||
628 | int x, y; | 628 | int x, y; |
629 | for (y = 0; y < 64; y++) | 629 | for (y = 0; y < 64; y++) |
630 | { | 630 | { |
631 | for (x = 0; x < 64; x++) | 631 | for (x = 0; x < 64; x++) |
632 | { | 632 | { |
633 | if (bitmap_add[x, y]) | 633 | if (bitmap_add[x, y]) |
634 | { | 634 | { |
635 | bitmap_base[x, y] = true; | 635 | bitmap_base[x, y] = true; |
636 | } | 636 | } |
637 | } | 637 | } |
638 | } | 638 | } |
639 | return bitmap_base; | 639 | return bitmap_base; |
640 | } | 640 | } |
641 | 641 | ||
642 | /// <summary> | 642 | /// <summary> |
643 | /// Converts the land bitmap to a packet friendly byte array | 643 | /// Converts the land bitmap to a packet friendly byte array |
644 | /// </summary> | 644 | /// </summary> |
645 | /// <returns></returns> | 645 | /// <returns></returns> |
646 | private byte[] convertLandBitmapToBytes() | 646 | private byte[] convertLandBitmapToBytes() |
647 | { | 647 | { |
648 | byte[] tempConvertArr = new byte[512]; | 648 | byte[] tempConvertArr = new byte[512]; |
649 | byte tempByte = 0; | 649 | byte tempByte = 0; |
650 | int x, y, i, byteNum = 0; | 650 | int x, y, i, byteNum = 0; |
651 | i = 0; | 651 | i = 0; |
652 | for (y = 0; y < 64; y++) | 652 | for (y = 0; y < 64; y++) |
653 | { | 653 | { |
654 | for (x = 0; x < 64; x++) | 654 | for (x = 0; x < 64; x++) |
655 | { | 655 | { |
656 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8)); | 656 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8)); |
657 | if (i % 8 == 0) | 657 | if (i % 8 == 0) |
658 | { | 658 | { |
659 | tempConvertArr[byteNum] = tempByte; | 659 | tempConvertArr[byteNum] = tempByte; |
660 | tempByte = (byte) 0; | 660 | tempByte = (byte) 0; |
661 | i = 0; | 661 | i = 0; |
662 | byteNum++; | 662 | byteNum++; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | } | 665 | } |
666 | return tempConvertArr; | 666 | return tempConvertArr; |
667 | } | 667 | } |
668 | 668 | ||
669 | private bool[,] convertBytesToLandBitmap() | 669 | private bool[,] convertBytesToLandBitmap() |
670 | { | 670 | { |
671 | bool[,] tempConvertMap = new bool[64,64]; | 671 | bool[,] tempConvertMap = new bool[64,64]; |
672 | tempConvertMap.Initialize(); | 672 | tempConvertMap.Initialize(); |
673 | byte tempByte = 0; | 673 | byte tempByte = 0; |
674 | int x = 0, y = 0, i = 0, bitNum = 0; | 674 | int x = 0, y = 0, i = 0, bitNum = 0; |
675 | for (i = 0; i < 512; i++) | 675 | for (i = 0; i < 512; i++) |
676 | { | 676 | { |
677 | tempByte = landData.landBitmapByteArray[i]; | 677 | tempByte = landData.landBitmapByteArray[i]; |
678 | for (bitNum = 0; bitNum < 8; bitNum++) | 678 | for (bitNum = 0; bitNum < 8; bitNum++) |
679 | { | 679 | { |
680 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); | 680 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); |
681 | tempConvertMap[x, y] = bit; | 681 | tempConvertMap[x, y] = bit; |
682 | x++; | 682 | x++; |
683 | if (x > 63) | 683 | if (x > 63) |
684 | { | 684 | { |
685 | x = 0; | 685 | x = 0; |
686 | y++; | 686 | y++; |
687 | } | 687 | } |
688 | } | 688 | } |
689 | } | 689 | } |
690 | return tempConvertMap; | 690 | return tempConvertMap; |
691 | } | 691 | } |
692 | 692 | ||
693 | #endregion | 693 | #endregion |
694 | 694 | ||
695 | #region Object Select and Object Owner Listing | 695 | #region Object Select and Object Owner Listing |
696 | 696 | ||
697 | public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) | 697 | public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) |
698 | { | 698 | { |
699 | List<uint> resultLocalIDs = new List<uint>(); | 699 | List<uint> resultLocalIDs = new List<uint>(); |
700 | foreach (SceneObjectGroup obj in primsOverMe) | 700 | foreach (SceneObjectGroup obj in primsOverMe) |
701 | { | 701 | { |
702 | if (obj.LocalId > 0) | 702 | if (obj.LocalId > 0) |
703 | { | 703 | { |
704 | if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID) | 704 | if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID) |
705 | { | 705 | { |
706 | resultLocalIDs.Add(obj.LocalId); | 706 | resultLocalIDs.Add(obj.LocalId); |
707 | } | 707 | } |
708 | // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support | 708 | // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support |
709 | // { | 709 | // { |
710 | // } | 710 | // } |
711 | else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && | 711 | else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && |
712 | obj.OwnerID != remote_client.AgentId) | 712 | obj.OwnerID != remote_client.AgentId) |
713 | { | 713 | { |
714 | resultLocalIDs.Add(obj.LocalId); | 714 | resultLocalIDs.Add(obj.LocalId); |
715 | } | 715 | } |
716 | } | 716 | } |
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | bool firstCall = true; | 720 | bool firstCall = true; |
721 | int MAX_OBJECTS_PER_PACKET = 251; | 721 | int MAX_OBJECTS_PER_PACKET = 251; |
722 | ForceObjectSelectPacket pack = (ForceObjectSelectPacket) PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect); | 722 | ForceObjectSelectPacket pack = (ForceObjectSelectPacket) PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect); |
723 | // TODO: don't create new blocks if recycling an old packet | 723 | // TODO: don't create new blocks if recycling an old packet |
724 | ForceObjectSelectPacket.DataBlock[] data; | 724 | ForceObjectSelectPacket.DataBlock[] data; |
725 | while (resultLocalIDs.Count > 0) | 725 | while (resultLocalIDs.Count > 0) |
726 | { | 726 | { |
727 | if (firstCall) | 727 | if (firstCall) |
728 | { | 728 | { |
729 | pack._Header.ResetList = true; | 729 | pack._Header.ResetList = true; |
730 | firstCall = false; | 730 | firstCall = false; |
731 | } | 731 | } |
732 | else | 732 | else |
733 | { | 733 | { |
734 | pack._Header.ResetList = false; | 734 | pack._Header.ResetList = false; |
735 | } | 735 | } |
736 | 736 | ||
737 | if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) | 737 | if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) |
738 | { | 738 | { |
739 | data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; | 739 | data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; |
740 | } | 740 | } |
741 | else | 741 | else |
742 | { | 742 | { |
743 | data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; | 743 | data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; |
744 | } | 744 | } |
745 | 745 | ||
746 | int i; | 746 | int i; |
747 | for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) | 747 | for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) |
748 | { | 748 | { |
749 | data[i] = new ForceObjectSelectPacket.DataBlock(); | 749 | data[i] = new ForceObjectSelectPacket.DataBlock(); |
750 | data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); | 750 | data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); |
751 | resultLocalIDs.RemoveAt(0); | 751 | resultLocalIDs.RemoveAt(0); |
752 | } | 752 | } |
753 | pack.Data = data; | 753 | pack.Data = data; |
754 | remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task); | 754 | remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task); |
755 | } | 755 | } |
756 | } | 756 | } |
757 | 757 | ||
758 | /// <summary> | 758 | /// <summary> |
759 | /// Notify the parcel owner each avatar that owns prims situated on their land. This notification includes | 759 | /// Notify the parcel owner each avatar that owns prims situated on their land. This notification includes |
760 | /// aggreagete details such as the number of prims. | 760 | /// aggreagete details such as the number of prims. |
761 | /// | 761 | /// |
762 | /// </summary> | 762 | /// </summary> |
763 | /// <param name="remote_client"> | 763 | /// <param name="remote_client"> |
764 | /// A <see cref="IClientAPI"/> | 764 | /// A <see cref="IClientAPI"/> |
765 | /// </param> | 765 | /// </param> |
766 | public void sendLandObjectOwners(IClientAPI remote_client) | 766 | public void sendLandObjectOwners(IClientAPI remote_client) |
767 | { | 767 | { |
768 | Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>(); | 768 | Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>(); |
769 | ParcelObjectOwnersReplyPacket pack | 769 | ParcelObjectOwnersReplyPacket pack |
770 | = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); | 770 | = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); |
771 | // TODO: don't create new blocks if recycling an old packet | 771 | // TODO: don't create new blocks if recycling an old packet |
772 | 772 | ||
773 | foreach (SceneObjectGroup obj in primsOverMe) | 773 | foreach (SceneObjectGroup obj in primsOverMe) |
774 | { | 774 | { |
775 | try | 775 | try |
776 | { | 776 | { |
777 | if (!primCount.ContainsKey(obj.OwnerID)) | 777 | if (!primCount.ContainsKey(obj.OwnerID)) |
778 | { | 778 | { |
779 | primCount.Add(obj.OwnerID, 0); | 779 | primCount.Add(obj.OwnerID, 0); |
780 | } | 780 | } |
781 | } | 781 | } |
782 | catch (NullReferenceException) | 782 | catch (NullReferenceException) |
783 | { | 783 | { |
784 | m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); | 784 | m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); |
785 | } | 785 | } |
786 | try | 786 | try |
787 | { | 787 | { |
788 | primCount[obj.OwnerID] += obj.PrimCount; | 788 | primCount[obj.OwnerID] += obj.PrimCount; |
789 | } | 789 | } |
790 | catch (KeyNotFoundException) | 790 | catch (KeyNotFoundException) |
791 | { | 791 | { |
792 | m_log.Error("[LAND]: Unable to match a prim with it's owner."); | 792 | m_log.Error("[LAND]: Unable to match a prim with it's owner."); |
793 | } | 793 | } |
794 | } | 794 | } |
795 | 795 | ||
796 | int notifyCount = primCount.Count; | 796 | int notifyCount = primCount.Count; |
797 | 797 | ||
798 | if (notifyCount > 0) | 798 | if (notifyCount > 0) |
799 | { | 799 | { |
800 | if (notifyCount > 32) | 800 | if (notifyCount > 32) |
801 | { | 801 | { |
802 | m_log.InfoFormat( | 802 | m_log.InfoFormat( |
803 | "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" | 803 | "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" |
804 | + " - a developer might want to investigate whether this is a hard limit", 32); | 804 | + " - a developer might want to investigate whether this is a hard limit", 32); |
805 | 805 | ||
806 | notifyCount = 32; | 806 | notifyCount = 32; |
807 | } | 807 | } |
808 | 808 | ||
809 | ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock | 809 | ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock |
810 | = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; | 810 | = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; |
811 | 811 | ||
812 | int num = 0; | 812 | int num = 0; |
813 | foreach (LLUUID owner in primCount.Keys) | 813 | foreach (LLUUID owner in primCount.Keys) |
814 | { | 814 | { |
815 | dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); | 815 | dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); |
816 | dataBlock[num].Count = primCount[owner]; | 816 | dataBlock[num].Count = primCount[owner]; |
817 | dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added | 817 | dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added |
818 | dataBlock[num].OnlineStatus = true; //TODO: fix me later | 818 | dataBlock[num].OnlineStatus = true; //TODO: fix me later |
819 | dataBlock[num].OwnerID = owner; | 819 | dataBlock[num].OwnerID = owner; |
820 | 820 | ||
821 | num++; | 821 | num++; |
822 | 822 | ||
823 | if (num >= notifyCount) | 823 | if (num >= notifyCount) |
824 | { | 824 | { |
825 | break; | 825 | break; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | pack.Data = dataBlock; | 829 | pack.Data = dataBlock; |
830 | } | 830 | } |
831 | 831 | ||
832 | remote_client.OutPacket(pack, ThrottleOutPacketType.Task); | 832 | remote_client.OutPacket(pack, ThrottleOutPacketType.Task); |
833 | } | 833 | } |
834 | 834 | ||
835 | public Dictionary<LLUUID, int> getLandObjectOwners() | 835 | public Dictionary<LLUUID, int> getLandObjectOwners() |
836 | { | 836 | { |
837 | Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>(); | 837 | Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>(); |
838 | foreach (SceneObjectGroup obj in primsOverMe) | 838 | foreach (SceneObjectGroup obj in primsOverMe) |
839 | { | 839 | { |
840 | if (!ownersAndCount.ContainsKey(obj.OwnerID)) | 840 | if (!ownersAndCount.ContainsKey(obj.OwnerID)) |
841 | { | 841 | { |
842 | ownersAndCount.Add(obj.OwnerID, 0); | 842 | ownersAndCount.Add(obj.OwnerID, 0); |
843 | } | 843 | } |
844 | ownersAndCount[obj.OwnerID] += obj.PrimCount; | 844 | ownersAndCount[obj.OwnerID] += obj.PrimCount; |
845 | } | 845 | } |
846 | return ownersAndCount; | 846 | return ownersAndCount; |
847 | } | 847 | } |
848 | 848 | ||
849 | #endregion | 849 | #endregion |
850 | 850 | ||
851 | #region Object Returning | 851 | #region Object Returning |
852 | 852 | ||
853 | public void returnObject(SceneObjectGroup obj) | 853 | public void returnObject(SceneObjectGroup obj) |
854 | { | 854 | { |
855 | } | 855 | } |
856 | 856 | ||
857 | public void returnLandObjects(int type, LLUUID owner) | 857 | public void returnLandObjects(int type, LLUUID owner) |
858 | { | 858 | { |
859 | } | 859 | } |
860 | 860 | ||
861 | #endregion | 861 | #endregion |
862 | 862 | ||
863 | #region Object Adding/Removing from Parcel | 863 | #region Object Adding/Removing from Parcel |
864 | 864 | ||
865 | public void resetLandPrimCounts() | 865 | public void resetLandPrimCounts() |
866 | { | 866 | { |
867 | landData.groupPrims = 0; | 867 | landData.groupPrims = 0; |
868 | landData.ownerPrims = 0; | 868 | landData.ownerPrims = 0; |
869 | landData.otherPrims = 0; | 869 | landData.otherPrims = 0; |
870 | landData.selectedPrims = 0; | 870 | landData.selectedPrims = 0; |
871 | primsOverMe.Clear(); | 871 | primsOverMe.Clear(); |
872 | } | 872 | } |
873 | 873 | ||
874 | public void addPrimToCount(SceneObjectGroup obj) | 874 | public void addPrimToCount(SceneObjectGroup obj) |
875 | { | 875 | { |
876 | LLUUID prim_owner = obj.OwnerID; | 876 | LLUUID prim_owner = obj.OwnerID; |
877 | int prim_count = obj.PrimCount; | 877 | int prim_count = obj.PrimCount; |
878 | 878 | ||
879 | if (obj.IsSelected) | 879 | if (obj.IsSelected) |
880 | { | 880 | { |
881 | landData.selectedPrims += prim_count; | 881 | landData.selectedPrims += prim_count; |
882 | } | 882 | } |
883 | else | 883 | else |
884 | { | 884 | { |
885 | if (prim_owner == landData.ownerID) | 885 | if (prim_owner == landData.ownerID) |
886 | { | 886 | { |
887 | landData.ownerPrims += prim_count; | 887 | landData.ownerPrims += prim_count; |
888 | } | 888 | } |
889 | else | 889 | else |
890 | { | 890 | { |
891 | landData.otherPrims += prim_count; | 891 | landData.otherPrims += prim_count; |
892 | } | 892 | } |
893 | } | 893 | } |
894 | 894 | ||
895 | primsOverMe.Add(obj); | 895 | primsOverMe.Add(obj); |
896 | } | 896 | } |
897 | 897 | ||
898 | public void removePrimFromCount(SceneObjectGroup obj) | 898 | public void removePrimFromCount(SceneObjectGroup obj) |
899 | { | 899 | { |
900 | if (primsOverMe.Contains(obj)) | 900 | if (primsOverMe.Contains(obj)) |
901 | { | 901 | { |
902 | LLUUID prim_owner = obj.OwnerID; | 902 | LLUUID prim_owner = obj.OwnerID; |
903 | int prim_count = obj.PrimCount; | 903 | int prim_count = obj.PrimCount; |
904 | 904 | ||
905 | if (prim_owner == landData.ownerID) | 905 | if (prim_owner == landData.ownerID) |
906 | { | 906 | { |
907 | landData.ownerPrims -= prim_count; | 907 | landData.ownerPrims -= prim_count; |
908 | } | 908 | } |
909 | else if (prim_owner == landData.groupID) | 909 | else if (prim_owner == landData.groupID) |
910 | { | 910 | { |
911 | landData.groupPrims -= prim_count; | 911 | landData.groupPrims -= prim_count; |
912 | } | 912 | } |
913 | else | 913 | else |
914 | { | 914 | { |
915 | landData.otherPrims -= prim_count; | 915 | landData.otherPrims -= prim_count; |
916 | } | 916 | } |
917 | 917 | ||
918 | primsOverMe.Remove(obj); | 918 | primsOverMe.Remove(obj); |
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | #endregion | 922 | #endregion |
923 | 923 | ||
924 | #endregion | 924 | #endregion |
925 | 925 | ||
926 | #endregion | 926 | #endregion |
927 | } | 927 | } |
928 | } \ No newline at end of file | 928 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs index fc3f75d..77a418f 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs | |||
@@ -1,36 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Scenes; | 28 | using OpenSim.Region.Environment.Scenes; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 30 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
31 | { | 31 | { |
32 | internal interface IFileSerialiser | 32 | internal interface IFileSerialiser |
33 | { | 33 | { |
34 | string WriteToFile(Scene scene, string dir); | 34 | string WriteToFile(Scene scene, string dir); |
35 | } | 35 | } |
36 | } \ No newline at end of file | 36 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs index 0ea2f30..e1721ff 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs | |||
@@ -1,37 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenSim.Region.Environment.Scenes; | 29 | using OpenSim.Region.Environment.Scenes; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 31 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
32 | { | 32 | { |
33 | public interface IRegionSerialiser | 33 | public interface IRegionSerialiser |
34 | { | 34 | { |
35 | List<string> SerialiseRegion(Scene scene, string saveDir); | 35 | List<string> SerialiseRegion(Scene scene, string saveDir); |
36 | } | 36 | } |
37 | } \ No newline at end of file | 37 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs index ef90fd4..40e1771 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs | |||
@@ -1,125 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.IO.Compression; | 30 | using System.IO.Compression; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | using OpenSim.Region.Environment.Scenes; | 33 | using OpenSim.Region.Environment.Scenes; |
34 | 34 | ||
35 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 35 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
36 | { | 36 | { |
37 | internal class SerialiseObjects : IFileSerialiser | 37 | internal class SerialiseObjects : IFileSerialiser |
38 | { | 38 | { |
39 | #region IFileSerialiser Members | 39 | #region IFileSerialiser Members |
40 | 40 | ||
41 | public string WriteToFile(Scene scene, string dir) | 41 | public string WriteToFile(Scene scene, string dir) |
42 | { | 42 | { |
43 | string targetFileName = dir + "objects.xml"; | 43 | string targetFileName = dir + "objects.xml"; |
44 | 44 | ||
45 | SaveSerialisedToFile(targetFileName, scene); | 45 | SaveSerialisedToFile(targetFileName, scene); |
46 | 46 | ||
47 | return "objects.xml"; | 47 | return "objects.xml"; |
48 | } | 48 | } |
49 | 49 | ||
50 | #endregion | 50 | #endregion |
51 | 51 | ||
52 | public void SaveSerialisedToFile(string fileName, Scene scene) | 52 | public void SaveSerialisedToFile(string fileName, Scene scene) |
53 | { | 53 | { |
54 | string xmlstream = GetObjectXml(scene); | 54 | string xmlstream = GetObjectXml(scene); |
55 | 55 | ||
56 | MemoryStream stream = ReformatXmlString(xmlstream); | 56 | MemoryStream stream = ReformatXmlString(xmlstream); |
57 | 57 | ||
58 | stream.Seek(0, SeekOrigin.Begin); | 58 | stream.Seek(0, SeekOrigin.Begin); |
59 | CreateXmlFile(stream, fileName); | 59 | CreateXmlFile(stream, fileName); |
60 | 60 | ||
61 | stream.Seek(0, SeekOrigin.Begin); | 61 | stream.Seek(0, SeekOrigin.Begin); |
62 | CreateCompressedXmlFile(stream, fileName); | 62 | CreateCompressedXmlFile(stream, fileName); |
63 | } | 63 | } |
64 | 64 | ||
65 | private static MemoryStream ReformatXmlString(string xmlstream) | 65 | private static MemoryStream ReformatXmlString(string xmlstream) |
66 | { | 66 | { |
67 | MemoryStream stream = new MemoryStream(); | 67 | MemoryStream stream = new MemoryStream(); |
68 | XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8); | 68 | XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8); |
69 | XmlDocument doc = new XmlDocument(); | 69 | XmlDocument doc = new XmlDocument(); |
70 | 70 | ||
71 | doc.LoadXml(xmlstream); | 71 | doc.LoadXml(xmlstream); |
72 | formatter.Formatting = Formatting.Indented; | 72 | formatter.Formatting = Formatting.Indented; |
73 | doc.WriteContentTo(formatter); | 73 | doc.WriteContentTo(formatter); |
74 | formatter.Flush(); | 74 | formatter.Flush(); |
75 | return stream; | 75 | return stream; |
76 | } | 76 | } |
77 | 77 | ||
78 | private static string GetObjectXml(Scene scene) | 78 | private static string GetObjectXml(Scene scene) |
79 | { | 79 | { |
80 | string xmlstream = "<scene>"; | 80 | string xmlstream = "<scene>"; |
81 | 81 | ||
82 | List<EntityBase> EntityList = scene.GetEntities(); | 82 | List<EntityBase> EntityList = scene.GetEntities(); |
83 | List<string> EntityXml = new List<string>(); | 83 | List<string> EntityXml = new List<string>(); |
84 | 84 | ||
85 | foreach (EntityBase ent in EntityList) | 85 | foreach (EntityBase ent in EntityList) |
86 | { | 86 | { |
87 | if (ent is SceneObjectGroup) | 87 | if (ent is SceneObjectGroup) |
88 | { | 88 | { |
89 | EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2()); | 89 | EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2()); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | EntityXml.Sort(); | 92 | EntityXml.Sort(); |
93 | 93 | ||
94 | foreach (string xml in EntityXml) | 94 | foreach (string xml in EntityXml) |
95 | xmlstream += xml; | 95 | xmlstream += xml; |
96 | 96 | ||
97 | xmlstream += "</scene>"; | 97 | xmlstream += "</scene>"; |
98 | return xmlstream; | 98 | return xmlstream; |
99 | } | 99 | } |
100 | 100 | ||
101 | private static void CreateXmlFile(MemoryStream xmlStream, string fileName) | 101 | private static void CreateXmlFile(MemoryStream xmlStream, string fileName) |
102 | { | 102 | { |
103 | FileStream objectsFile = new FileStream(fileName, FileMode.Create); | 103 | FileStream objectsFile = new FileStream(fileName, FileMode.Create); |
104 | 104 | ||
105 | xmlStream.WriteTo(objectsFile); | 105 | xmlStream.WriteTo(objectsFile); |
106 | objectsFile.Flush(); | 106 | objectsFile.Flush(); |
107 | objectsFile.Close(); | 107 | objectsFile.Close(); |
108 | } | 108 | } |
109 | 109 | ||
110 | private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) | 110 | private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) |
111 | { | 111 | { |
112 | #region GZip Compressed Version | 112 | #region GZip Compressed Version |
113 | 113 | ||
114 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); | 114 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); |
115 | MemoryStream gzipMSStream = new MemoryStream(); | 115 | MemoryStream gzipMSStream = new MemoryStream(); |
116 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); | 116 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); |
117 | xmlStream.WriteTo(gzipStream); | 117 | xmlStream.WriteTo(gzipStream); |
118 | gzipMSStream.WriteTo(objectsFileCompressed); | 118 | gzipMSStream.WriteTo(objectsFileCompressed); |
119 | objectsFileCompressed.Flush(); | 119 | objectsFileCompressed.Flush(); |
120 | objectsFileCompressed.Close(); | 120 | objectsFileCompressed.Close(); |
121 | 121 | ||
122 | #endregion | 122 | #endregion |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } \ No newline at end of file | 125 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs index 03824e8..dacdbc8 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs | |||
@@ -1,53 +1,53 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Modules.World.Terrain; | 28 | using OpenSim.Region.Environment.Modules.World.Terrain; |
29 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | 29 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; |
30 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 32 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
33 | { | 33 | { |
34 | internal class SerialiseTerrain : IFileSerialiser | 34 | internal class SerialiseTerrain : IFileSerialiser |
35 | { | 35 | { |
36 | #region IFileSerialiser Members | 36 | #region IFileSerialiser Members |
37 | 37 | ||
38 | public string WriteToFile(Scene scene, string dir) | 38 | public string WriteToFile(Scene scene, string dir) |
39 | { | 39 | { |
40 | ITerrainLoader fileSystemExporter = new RAW32(); | 40 | ITerrainLoader fileSystemExporter = new RAW32(); |
41 | string targetFileName = dir + "heightmap.r32"; | 41 | string targetFileName = dir + "heightmap.r32"; |
42 | 42 | ||
43 | lock (scene.Heightmap) | 43 | lock (scene.Heightmap) |
44 | { | 44 | { |
45 | fileSystemExporter.SaveFile(targetFileName, scene.Heightmap); | 45 | fileSystemExporter.SaveFile(targetFileName, scene.Heightmap); |
46 | } | 46 | } |
47 | 47 | ||
48 | return "heightmap.r32"; | 48 | return "heightmap.r32"; |
49 | } | 49 | } |
50 | 50 | ||
51 | #endregion | 51 | #endregion |
52 | } | 52 | } |
53 | } \ No newline at end of file | 53 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs index b626f16..75fc428 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs | |||
@@ -1,169 +1,169 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
33 | using OpenSim.Region.Environment.Modules.ExportSerialiser; | 33 | using OpenSim.Region.Environment.Modules.ExportSerialiser; |
34 | using OpenSim.Region.Environment.Modules.Framework; | 34 | using OpenSim.Region.Environment.Modules.Framework; |
35 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
36 | 36 | ||
37 | namespace OpenSim.Region.Environment.Modules.World.Serialiser | 37 | namespace OpenSim.Region.Environment.Modules.World.Serialiser |
38 | { | 38 | { |
39 | public class SerialiserModule : IRegionModule, IRegionSerialiser | 39 | public class SerialiserModule : IRegionModule, IRegionSerialiser |
40 | { | 40 | { |
41 | private Commander m_commander = new Commander("Export"); | 41 | private Commander m_commander = new Commander("Export"); |
42 | private List<Scene> m_regions = new List<Scene>(); | 42 | private List<Scene> m_regions = new List<Scene>(); |
43 | private string m_savedir = "exports" + "/"; | 43 | private string m_savedir = "exports" + "/"; |
44 | private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); | 44 | private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); |
45 | 45 | ||
46 | #region IRegionModule Members | 46 | #region IRegionModule Members |
47 | 47 | ||
48 | public void Initialise(Scene scene, IConfigSource source) | 48 | public void Initialise(Scene scene, IConfigSource source) |
49 | { | 49 | { |
50 | scene.RegisterModuleCommander("Export", m_commander); | 50 | scene.RegisterModuleCommander("Export", m_commander); |
51 | scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 51 | scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
52 | scene.RegisterModuleInterface<IRegionSerialiser>(this); | 52 | scene.RegisterModuleInterface<IRegionSerialiser>(this); |
53 | 53 | ||
54 | lock (m_regions) | 54 | lock (m_regions) |
55 | { | 55 | { |
56 | m_regions.Add(scene); | 56 | m_regions.Add(scene); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | public void PostInitialise() | 60 | public void PostInitialise() |
61 | { | 61 | { |
62 | lock (m_serialisers) | 62 | lock (m_serialisers) |
63 | { | 63 | { |
64 | m_serialisers.Add(new SerialiseTerrain()); | 64 | m_serialisers.Add(new SerialiseTerrain()); |
65 | m_serialisers.Add(new SerialiseObjects()); | 65 | m_serialisers.Add(new SerialiseObjects()); |
66 | } | 66 | } |
67 | 67 | ||
68 | LoadCommanderCommands(); | 68 | LoadCommanderCommands(); |
69 | } | 69 | } |
70 | 70 | ||
71 | public void Close() | 71 | public void Close() |
72 | { | 72 | { |
73 | m_regions.Clear(); | 73 | m_regions.Clear(); |
74 | } | 74 | } |
75 | 75 | ||
76 | public string Name | 76 | public string Name |
77 | { | 77 | { |
78 | get { return "ExportSerialisationModule"; } | 78 | get { return "ExportSerialisationModule"; } |
79 | } | 79 | } |
80 | 80 | ||
81 | public bool IsSharedModule | 81 | public bool IsSharedModule |
82 | { | 82 | { |
83 | get { return true; } | 83 | get { return true; } |
84 | } | 84 | } |
85 | 85 | ||
86 | #endregion | 86 | #endregion |
87 | 87 | ||
88 | #region IRegionSerialiser Members | 88 | #region IRegionSerialiser Members |
89 | 89 | ||
90 | public List<string> SerialiseRegion(Scene scene, string saveDir) | 90 | public List<string> SerialiseRegion(Scene scene, string saveDir) |
91 | { | 91 | { |
92 | List<string> results = new List<string>(); | 92 | List<string> results = new List<string>(); |
93 | 93 | ||
94 | if (!Directory.Exists(saveDir)) | 94 | if (!Directory.Exists(saveDir)) |
95 | { | 95 | { |
96 | Directory.CreateDirectory(saveDir); | 96 | Directory.CreateDirectory(saveDir); |
97 | } | 97 | } |
98 | 98 | ||
99 | lock (m_serialisers) | 99 | lock (m_serialisers) |
100 | { | 100 | { |
101 | foreach (IFileSerialiser serialiser in m_serialisers) | 101 | foreach (IFileSerialiser serialiser in m_serialisers) |
102 | { | 102 | { |
103 | results.Add(serialiser.WriteToFile(scene, saveDir)); | 103 | results.Add(serialiser.WriteToFile(scene, saveDir)); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); | 107 | TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); |
108 | regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); | 108 | regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); |
109 | regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); | 109 | regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); |
110 | regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); | 110 | regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); |
111 | regionInfoWriter.WriteLine("Serialise Version: 0.1"); | 111 | regionInfoWriter.WriteLine("Serialise Version: 0.1"); |
112 | regionInfoWriter.Close(); | 112 | regionInfoWriter.Close(); |
113 | 113 | ||
114 | TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); | 114 | TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); |
115 | foreach (string line in results) | 115 | foreach (string line in results) |
116 | { | 116 | { |
117 | manifestWriter.WriteLine(line); | 117 | manifestWriter.WriteLine(line); |
118 | } | 118 | } |
119 | manifestWriter.Close(); | 119 | manifestWriter.Close(); |
120 | 120 | ||
121 | return results; | 121 | return results; |
122 | } | 122 | } |
123 | 123 | ||
124 | #endregion | 124 | #endregion |
125 | 125 | ||
126 | private void EventManager_OnPluginConsole(string[] args) | 126 | private void EventManager_OnPluginConsole(string[] args) |
127 | { | 127 | { |
128 | if (args[0] == "export") | 128 | if (args[0] == "export") |
129 | { | 129 | { |
130 | string[] tmpArgs = new string[args.Length - 2]; | 130 | string[] tmpArgs = new string[args.Length - 2]; |
131 | int i = 0; | 131 | int i = 0; |
132 | for (i = 2; i < args.Length; i++) | 132 | for (i = 2; i < args.Length; i++) |
133 | tmpArgs[i - 2] = args[i]; | 133 | tmpArgs[i - 2] = args[i]; |
134 | 134 | ||
135 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | 135 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | private void InterfaceSaveRegion(Object[] args) | 139 | private void InterfaceSaveRegion(Object[] args) |
140 | { | 140 | { |
141 | foreach (Scene region in m_regions) | 141 | foreach (Scene region in m_regions) |
142 | { | 142 | { |
143 | if (region.RegionInfo.RegionName == (string) args[0]) | 143 | if (region.RegionInfo.RegionName == (string) args[0]) |
144 | { | 144 | { |
145 | List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); | 145 | List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | private void InterfaceSaveAllRegions(Object[] args) | 150 | private void InterfaceSaveAllRegions(Object[] args) |
151 | { | 151 | { |
152 | foreach (Scene region in m_regions) | 152 | foreach (Scene region in m_regions) |
153 | { | 153 | { |
154 | List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); | 154 | List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | private void LoadCommanderCommands() | 158 | private void LoadCommanderCommands() |
159 | { | 159 | { |
160 | Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); | 160 | Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); |
161 | serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); | 161 | serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); |
162 | 162 | ||
163 | Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); | 163 | Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); |
164 | 164 | ||
165 | m_commander.RegisterCommand("save", serialiseSceneCommand); | 165 | m_commander.RegisterCommand("save", serialiseSceneCommand); |
166 | m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); | 166 | m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } \ No newline at end of file | 169 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index a12118e..85c4cdd 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | |||
@@ -1,199 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Environment.Interfaces; | 33 | using OpenSim.Region.Environment.Interfaces; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
35 | 35 | ||
36 | namespace OpenSim.Region.Environment.Modules | 36 | namespace OpenSim.Region.Environment.Modules |
37 | { | 37 | { |
38 | public class SunModule : IRegionModule | 38 | public class SunModule : IRegionModule |
39 | { | 39 | { |
40 | //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 40 | //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | private const int m_default_frame = 100; | 42 | private const int m_default_frame = 100; |
43 | private const double m_real_day = 24.0; | 43 | private const double m_real_day = 24.0; |
44 | private double m_day_length; | 44 | private double m_day_length; |
45 | private int m_dilation; | 45 | private int m_dilation; |
46 | private int m_frame; | 46 | private int m_frame; |
47 | private int m_frame_mod; | 47 | private int m_frame_mod; |
48 | 48 | ||
49 | private Scene m_scene; | 49 | private Scene m_scene; |
50 | private long m_start; | 50 | private long m_start; |
51 | 51 | ||
52 | #region IRegionModule Members | 52 | #region IRegionModule Members |
53 | 53 | ||
54 | public void Initialise(Scene scene, IConfigSource config) | 54 | public void Initialise(Scene scene, IConfigSource config) |
55 | { | 55 | { |
56 | m_start = DateTime.Now.Ticks; | 56 | m_start = DateTime.Now.Ticks; |
57 | m_frame = 0; | 57 | m_frame = 0; |
58 | 58 | ||
59 | // Just in case they don't have the stanzas | 59 | // Just in case they don't have the stanzas |
60 | try | 60 | try |
61 | { | 61 | { |
62 | m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); | 62 | m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); |
63 | m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); | 63 | m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); |
64 | } | 64 | } |
65 | catch (Exception) | 65 | catch (Exception) |
66 | { | 66 | { |
67 | m_day_length = m_real_day; | 67 | m_day_length = m_real_day; |
68 | m_frame_mod = m_default_frame; | 68 | m_frame_mod = m_default_frame; |
69 | } | 69 | } |
70 | 70 | ||
71 | m_dilation = (int) (m_real_day / m_day_length); | 71 | m_dilation = (int) (m_real_day / m_day_length); |
72 | m_scene = scene; | 72 | m_scene = scene; |
73 | scene.EventManager.OnFrame += SunUpdate; | 73 | scene.EventManager.OnFrame += SunUpdate; |
74 | scene.EventManager.OnNewClient += SunToClient; | 74 | scene.EventManager.OnNewClient += SunToClient; |
75 | } | 75 | } |
76 | 76 | ||
77 | public void PostInitialise() | 77 | public void PostInitialise() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | public void Close() | 81 | public void Close() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | public string Name | 85 | public string Name |
86 | { | 86 | { |
87 | get { return "SunModule"; } | 87 | get { return "SunModule"; } |
88 | } | 88 | } |
89 | 89 | ||
90 | public bool IsSharedModule | 90 | public bool IsSharedModule |
91 | { | 91 | { |
92 | get { return false; } | 92 | get { return false; } |
93 | } | 93 | } |
94 | 94 | ||
95 | #endregion | 95 | #endregion |
96 | 96 | ||
97 | public void SunToClient(IClientAPI client) | 97 | public void SunToClient(IClientAPI client) |
98 | { | 98 | { |
99 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); | 99 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); |
100 | } | 100 | } |
101 | 101 | ||
102 | public void SunUpdate() | 102 | public void SunUpdate() |
103 | { | 103 | { |
104 | if (m_frame < m_frame_mod) | 104 | if (m_frame < m_frame_mod) |
105 | { | 105 | { |
106 | m_frame++; | 106 | m_frame++; |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | // m_log.InfoFormat("[SUN]: I've got an update {0} => {1}", m_scene.RegionsInfo.RegionName, HourOfTheDay()); | 109 | // m_log.InfoFormat("[SUN]: I've got an update {0} => {1}", m_scene.RegionsInfo.RegionName, HourOfTheDay()); |
110 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 110 | List<ScenePresence> avatars = m_scene.GetAvatars(); |
111 | foreach (ScenePresence avatar in avatars) | 111 | foreach (ScenePresence avatar in avatars) |
112 | { | 112 | { |
113 | avatar.ControllingClient.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); | 113 | avatar.ControllingClient.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); |
114 | } | 114 | } |
115 | // set estate settings for region access to sun position | 115 | // set estate settings for region access to sun position |
116 | m_scene.RegionInfo.EstateSettings.sunPosition = SunPos(HourOfTheDay()); | 116 | m_scene.RegionInfo.EstateSettings.sunPosition = SunPos(HourOfTheDay()); |
117 | 117 | ||
118 | m_frame = 0; | 118 | m_frame = 0; |
119 | } | 119 | } |
120 | 120 | ||
121 | // Hour of the Day figures out the hour of the day as a float. | 121 | // Hour of the Day figures out the hour of the day as a float. |
122 | // The intent here is that we seed hour of the day with real | 122 | // The intent here is that we seed hour of the day with real |
123 | // time when the simulator starts, then run time forward | 123 | // time when the simulator starts, then run time forward |
124 | // faster based on time dilation factor. This means that | 124 | // faster based on time dilation factor. This means that |
125 | // ticks don't get out of hand | 125 | // ticks don't get out of hand |
126 | private double HourOfTheDay() | 126 | private double HourOfTheDay() |
127 | { | 127 | { |
128 | long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; | 128 | long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; |
129 | DateTime dt = new DateTime(m_start + m_addticks); | 129 | DateTime dt = new DateTime(m_start + m_addticks); |
130 | return (double) dt.Hour + ((double) dt.Minute / 60.0); | 130 | return (double) dt.Hour + ((double) dt.Minute / 60.0); |
131 | } | 131 | } |
132 | 132 | ||
133 | private LLVector3 SunPos(double hour) | 133 | private LLVector3 SunPos(double hour) |
134 | { | 134 | { |
135 | // now we have our radian position | 135 | // now we have our radian position |
136 | double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); | 136 | double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); |
137 | double z = Math.Sin(rad); | 137 | double z = Math.Sin(rad); |
138 | double x = Math.Cos(rad); | 138 | double x = Math.Cos(rad); |
139 | return new LLVector3((float) x, 0f, (float) z); | 139 | return new LLVector3((float) x, 0f, (float) z); |
140 | } | 140 | } |
141 | 141 | ||
142 | // TODO: clear this out. This is here so that I remember to | 142 | // TODO: clear this out. This is here so that I remember to |
143 | // figure out if we need those other packet fields that I've | 143 | // figure out if we need those other packet fields that I've |
144 | // left out so far | 144 | // left out so far |
145 | // | 145 | // |
146 | // public void SendViewerTime(int phase) | 146 | // public void SendViewerTime(int phase) |
147 | // { | 147 | // { |
148 | // Console.WriteLine("SunPhase: {0}", phase); | 148 | // Console.WriteLine("SunPhase: {0}", phase); |
149 | // SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); | 149 | // SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); |
150 | // //viewertime.TimeInfo.SecPerDay = 86400; | 150 | // //viewertime.TimeInfo.SecPerDay = 86400; |
151 | // // viewertime.TimeInfo.SecPerYear = 31536000; | 151 | // // viewertime.TimeInfo.SecPerYear = 31536000; |
152 | // viewertime.TimeInfo.SecPerDay = 1000; | 152 | // viewertime.TimeInfo.SecPerDay = 1000; |
153 | // viewertime.TimeInfo.SecPerYear = 365000; | 153 | // viewertime.TimeInfo.SecPerYear = 365000; |
154 | // viewertime.TimeInfo.SunPhase = 1; | 154 | // viewertime.TimeInfo.SunPhase = 1; |
155 | // int sunPhase = (phase + 2)/2; | 155 | // int sunPhase = (phase + 2)/2; |
156 | // if ((sunPhase < 6) || (sunPhase > 36)) | 156 | // if ((sunPhase < 6) || (sunPhase > 36)) |
157 | // { | 157 | // { |
158 | // viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f); | 158 | // viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f); |
159 | // Console.WriteLine("sending night"); | 159 | // Console.WriteLine("sending night"); |
160 | // } | 160 | // } |
161 | // else | 161 | // else |
162 | // { | 162 | // { |
163 | // if (sunPhase < 12) | 163 | // if (sunPhase < 12) |
164 | // { | 164 | // { |
165 | // sunPhase = 12; | 165 | // sunPhase = 12; |
166 | // } | 166 | // } |
167 | // sunPhase = sunPhase - 12; | 167 | // sunPhase = sunPhase - 12; |
168 | // | 168 | // |
169 | // float yValue = 0.1f*(sunPhase); | 169 | // float yValue = 0.1f*(sunPhase); |
170 | // Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue); | 170 | // Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue); |
171 | // if (yValue > 1.2f) | 171 | // if (yValue > 1.2f) |
172 | // { | 172 | // { |
173 | // yValue = yValue - 1.2f; | 173 | // yValue = yValue - 1.2f; |
174 | // } | 174 | // } |
175 | // if (yValue > 1) | 175 | // if (yValue > 1) |
176 | // { | 176 | // { |
177 | // yValue = 1; | 177 | // yValue = 1; |
178 | // } | 178 | // } |
179 | // if (yValue < 0) | 179 | // if (yValue < 0) |
180 | // { | 180 | // { |
181 | // yValue = 0; | 181 | // yValue = 0; |
182 | // } | 182 | // } |
183 | // if (sunPhase < 14) | 183 | // if (sunPhase < 14) |
184 | // { | 184 | // { |
185 | // yValue = 1 - yValue; | 185 | // yValue = 1 - yValue; |
186 | // } | 186 | // } |
187 | // if (sunPhase < 12) | 187 | // if (sunPhase < 12) |
188 | // { | 188 | // { |
189 | // yValue *= -1; | 189 | // yValue *= -1; |
190 | // } | 190 | // } |
191 | // viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f); | 191 | // viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f); |
192 | // Console.WriteLine("sending sun update " + yValue); | 192 | // Console.WriteLine("sending sun update " + yValue); |
193 | // } | 193 | // } |
194 | // viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f); | 194 | // viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f); |
195 | // viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch(); | 195 | // viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch(); |
196 | // // OutPacket(viewertime); | 196 | // // OutPacket(viewertime); |
197 | // } | 197 | // } |
198 | } | 198 | } |
199 | } \ No newline at end of file | 199 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs index 731326e..a2e0c40 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs | |||
@@ -1,124 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; | 29 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; |
30 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 30 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects |
33 | { | 33 | { |
34 | internal class CookieCutter : ITerrainEffect | 34 | internal class CookieCutter : ITerrainEffect |
35 | { | 35 | { |
36 | #region ITerrainEffect Members | 36 | #region ITerrainEffect Members |
37 | 37 | ||
38 | public void RunEffect(ITerrainChannel map) | 38 | public void RunEffect(ITerrainChannel map) |
39 | { | 39 | { |
40 | SmoothArea smooth = new SmoothArea(); | 40 | SmoothArea smooth = new SmoothArea(); |
41 | ITerrainPaintableEffect eroder = new WeatherSphere(); | 41 | ITerrainPaintableEffect eroder = new WeatherSphere(); |
42 | 42 | ||
43 | bool[,] cliffMask = new bool[map.Width,map.Height]; | 43 | bool[,] cliffMask = new bool[map.Width,map.Height]; |
44 | bool[,] channelMask = new bool[map.Width,map.Height]; | 44 | bool[,] channelMask = new bool[map.Width,map.Height]; |
45 | bool[,] smoothMask = new bool[map.Width,map.Height]; | 45 | bool[,] smoothMask = new bool[map.Width,map.Height]; |
46 | 46 | ||
47 | Console.WriteLine("S1"); | 47 | Console.WriteLine("S1"); |
48 | 48 | ||
49 | // Step one, generate rough mask | 49 | // Step one, generate rough mask |
50 | int x, y; | 50 | int x, y; |
51 | for (x = 0; x < map.Width; x++) | 51 | for (x = 0; x < map.Width; x++) |
52 | { | 52 | { |
53 | for (y = 0; y < map.Height; y++) | 53 | for (y = 0; y < map.Height; y++) |
54 | { | 54 | { |
55 | Console.Write("."); | 55 | Console.Write("."); |
56 | smoothMask[x, y] = true; | 56 | smoothMask[x, y] = true; |
57 | 57 | ||
58 | // Start underwater | 58 | // Start underwater |
59 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5; | 59 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5; |
60 | // Add a little height. (terrain should now be above water, mostly.) | 60 | // Add a little height. (terrain should now be above water, mostly.) |
61 | map[x, y] += 20; | 61 | map[x, y] += 20; |
62 | 62 | ||
63 | int channelsX = 4; | 63 | int channelsX = 4; |
64 | int channelWidth = (map.Width / channelsX / 4); | 64 | int channelWidth = (map.Width / channelsX / 4); |
65 | int channelsY = 4; | 65 | int channelsY = 4; |
66 | int channelHeight = (map.Height / channelsY / 4); | 66 | int channelHeight = (map.Height / channelsY / 4); |
67 | 67 | ||
68 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x); | 68 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x); |
69 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y); | 69 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | Console.WriteLine("S2"); | 73 | Console.WriteLine("S2"); |
74 | //smooth.FloodEffect(map, smoothMask, 4.0); | 74 | //smooth.FloodEffect(map, smoothMask, 4.0); |
75 | 75 | ||
76 | Console.WriteLine("S3"); | 76 | Console.WriteLine("S3"); |
77 | for (x = 0; x < map.Width; x++) | 77 | for (x = 0; x < map.Width; x++) |
78 | { | 78 | { |
79 | for (y = 0; y < map.Height; y++) | 79 | for (y = 0; y < map.Height; y++) |
80 | { | 80 | { |
81 | if (cliffMask[x, y] == true) | 81 | if (cliffMask[x, y] == true) |
82 | eroder.PaintEffect(map, x, y, 4, 0.1); | 82 | eroder.PaintEffect(map, x, y, 4, 0.1); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | for (x = 0; x < map.Width; x += 2) | 86 | for (x = 0; x < map.Width; x += 2) |
87 | { | 87 | { |
88 | for (y = 0; y < map.Height; y += 2) | 88 | for (y = 0; y < map.Height; y += 2) |
89 | { | 89 | { |
90 | if (map[x, y] < 0.1) | 90 | if (map[x, y] < 0.1) |
91 | map[x, y] = 0.1; | 91 | map[x, y] = 0.1; |
92 | if (map[x, y] > 256) | 92 | if (map[x, y] > 256) |
93 | map[x, y] = 256; | 93 | map[x, y] = 256; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | //smooth.FloodEffect(map, smoothMask, 4.0); | 96 | //smooth.FloodEffect(map, smoothMask, 4.0); |
97 | } | 97 | } |
98 | 98 | ||
99 | #endregion | 99 | #endregion |
100 | 100 | ||
101 | private static void SetLowerChannel(ITerrainChannel map, bool[,] cliffMask, bool[,] channelMask, int x, int y, int numChannels, int channelWidth, | 101 | private static void SetLowerChannel(ITerrainChannel map, bool[,] cliffMask, bool[,] channelMask, int x, int y, int numChannels, int channelWidth, |
102 | int mapSize, int rp) | 102 | int mapSize, int rp) |
103 | { | 103 | { |
104 | for (int i = 0; i < numChannels; i++) | 104 | for (int i = 0; i < numChannels; i++) |
105 | { | 105 | { |
106 | double distanceToLine = Math.Abs(rp - ((mapSize / numChannels) * i)); | 106 | double distanceToLine = Math.Abs(rp - ((mapSize / numChannels) * i)); |
107 | 107 | ||
108 | if (distanceToLine < channelWidth) | 108 | if (distanceToLine < channelWidth) |
109 | { | 109 | { |
110 | if (channelMask[x, y]) | 110 | if (channelMask[x, y]) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Remove channels | 113 | // Remove channels |
114 | map[x, y] -= 10; | 114 | map[x, y] -= 10; |
115 | channelMask[x, y] = true; | 115 | channelMask[x, y] = true; |
116 | } | 116 | } |
117 | if (distanceToLine < 1) | 117 | if (distanceToLine < 1) |
118 | { | 118 | { |
119 | cliffMask[x, y] = true; | 119 | cliffMask[x, y] = true; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } \ No newline at end of file | 124 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs index 9c35d4e..5bc6799 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs | |||
@@ -1,55 +1,55 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using OpenSim.Framework; | 27 | using OpenSim.Framework; |
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects |
31 | { | 31 | { |
32 | internal class DefaultTerrainGenerator : ITerrainEffect | 32 | internal class DefaultTerrainGenerator : ITerrainEffect |
33 | { | 33 | { |
34 | #region ITerrainEffect Members | 34 | #region ITerrainEffect Members |
35 | 35 | ||
36 | public void RunEffect(ITerrainChannel map) | 36 | public void RunEffect(ITerrainChannel map) |
37 | { | 37 | { |
38 | int x, y; | 38 | int x, y; |
39 | for (x = 0; x < map.Width; x++) | 39 | for (x = 0; x < map.Width; x++) |
40 | { | 40 | { |
41 | for (y = 0; y < map.Height; y++) | 41 | for (y = 0; y < map.Height; y++) |
42 | { | 42 | { |
43 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; | 43 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; |
44 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; | 44 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; |
45 | if (map[x, y] < spherFac) | 45 | if (map[x, y] < spherFac) |
46 | { | 46 | { |
47 | map[x, y] = spherFac; | 47 | map[x, y] = spherFac; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | #endregion | 53 | #endregion |
54 | } | 54 | } |
55 | } \ No newline at end of file | 55 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs index 4705dad..eb981d9 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs | |||
@@ -1,62 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// A generic windows bitmap loader. | 34 | /// A generic windows bitmap loader. |
35 | /// Should be capable of handling 24-bit RGB images. | 35 | /// Should be capable of handling 24-bit RGB images. |
36 | /// | 36 | /// |
37 | /// Uses the System.Drawing filesystem loader. | 37 | /// Uses the System.Drawing filesystem loader. |
38 | /// </summary> | 38 | /// </summary> |
39 | internal class BMP : GenericSystemDrawing | 39 | internal class BMP : GenericSystemDrawing |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Exports a file to a image on the disk using a System.Drawing exporter. | 42 | /// Exports a file to a image on the disk using a System.Drawing exporter. |
43 | /// </summary> | 43 | /// </summary> |
44 | /// <param name="filename">The target filename</param> | 44 | /// <param name="filename">The target filename</param> |
45 | /// <param name="map">The terrain channel being saved</param> | 45 | /// <param name="map">The terrain channel being saved</param> |
46 | public override void SaveFile(string filename, ITerrainChannel map) | 46 | public override void SaveFile(string filename, ITerrainChannel map) |
47 | { | 47 | { |
48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
49 | 49 | ||
50 | colours.Save(filename, ImageFormat.Bmp); | 50 | colours.Save(filename, ImageFormat.Bmp); |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// The human readable version of the file format(s) this loader handles | 54 | /// The human readable version of the file format(s) this loader handles |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <returns></returns> | 56 | /// <returns></returns> |
57 | public override string ToString() | 57 | public override string ToString() |
58 | { | 58 | { |
59 | return "BMP"; | 59 | return "BMP"; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } \ No newline at end of file | 62 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs index 9c2fedc..9bfe851 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class GIF : GenericSystemDrawing | 33 | internal class GIF : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Gif); | 39 | colours.Save(filename, ImageFormat.Gif); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "GIF"; | 44 | return "GIF"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index b5e6bd9..9730b16 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -1,172 +1,172 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A virtual class designed to have methods overloaded, | 36 | /// A virtual class designed to have methods overloaded, |
37 | /// this class provides an interface for a generic image | 37 | /// this class provides an interface for a generic image |
38 | /// saving and loading mechanism, but does not specify the | 38 | /// saving and loading mechanism, but does not specify the |
39 | /// format. It should not be insubstantiated directly. | 39 | /// format. It should not be insubstantiated directly. |
40 | /// </summary> | 40 | /// </summary> |
41 | public class GenericSystemDrawing : ITerrainLoader | 41 | public class GenericSystemDrawing : ITerrainLoader |
42 | { | 42 | { |
43 | #region ITerrainLoader Members | 43 | #region ITerrainLoader Members |
44 | 44 | ||
45 | public string FileExtension | 45 | public string FileExtension |
46 | { | 46 | { |
47 | get { return ".gsd"; } | 47 | get { return ".gsd"; } |
48 | } | 48 | } |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Loads a file from a specified filename on the disk, | 51 | /// Loads a file from a specified filename on the disk, |
52 | /// parses the image using the System.Drawing parsers | 52 | /// parses the image using the System.Drawing parsers |
53 | /// then returns a terrain channel. Values are | 53 | /// then returns a terrain channel. Values are |
54 | /// returned based on HSL brightness between 0m and 128m | 54 | /// returned based on HSL brightness between 0m and 128m |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <param name="filename">The target image to load</param> | 56 | /// <param name="filename">The target image to load</param> |
57 | /// <returns>A terrain channel generated from the image.</returns> | 57 | /// <returns>A terrain channel generated from the image.</returns> |
58 | public virtual ITerrainChannel LoadFile(string filename) | 58 | public virtual ITerrainChannel LoadFile(string filename) |
59 | { | 59 | { |
60 | Bitmap file = new Bitmap(filename); | 60 | Bitmap file = new Bitmap(filename); |
61 | 61 | ||
62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); | 62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); |
63 | 63 | ||
64 | int x, y; | 64 | int x, y; |
65 | for (x = 0; x < file.Width; x++) | 65 | for (x = 0; x < file.Width; x++) |
66 | { | 66 | { |
67 | for (y = 0; y < file.Height; y++) | 67 | for (y = 0; y < file.Height; y++) |
68 | { | 68 | { |
69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; | 69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | return retval; | 73 | return retval; |
74 | } | 74 | } |
75 | 75 | ||
76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
77 | { | 77 | { |
78 | throw new NotImplementedException(); | 78 | throw new NotImplementedException(); |
79 | } | 79 | } |
80 | 80 | ||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Exports a file to a image on the disk using a System.Drawing exporter. | 82 | /// Exports a file to a image on the disk using a System.Drawing exporter. |
83 | /// </summary> | 83 | /// </summary> |
84 | /// <param name="filename">The target filename</param> | 84 | /// <param name="filename">The target filename</param> |
85 | /// <param name="map">The terrain channel being saved</param> | 85 | /// <param name="map">The terrain channel being saved</param> |
86 | public virtual void SaveFile(string filename, ITerrainChannel map) | 86 | public virtual void SaveFile(string filename, ITerrainChannel map) |
87 | { | 87 | { |
88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
89 | 89 | ||
90 | colours.Save(filename, ImageFormat.Png); | 90 | colours.Save(filename, ImageFormat.Png); |
91 | } | 91 | } |
92 | 92 | ||
93 | #endregion | 93 | #endregion |
94 | 94 | ||
95 | public override string ToString() | 95 | public override string ToString() |
96 | { | 96 | { |
97 | return "SYS.DRAWING"; | 97 | return "SYS.DRAWING"; |
98 | } | 98 | } |
99 | 99 | ||
100 | /// <summary> | 100 | /// <summary> |
101 | /// Protected method, generates a grayscale bitmap | 101 | /// Protected method, generates a grayscale bitmap |
102 | /// image from a specified terrain channel. | 102 | /// image from a specified terrain channel. |
103 | /// </summary> | 103 | /// </summary> |
104 | /// <param name="map">The terrain channel to export to bitmap</param> | 104 | /// <param name="map">The terrain channel to export to bitmap</param> |
105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> | 105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> |
106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) | 106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) |
107 | { | 107 | { |
108 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 108 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
109 | 109 | ||
110 | int pallete = 256; | 110 | int pallete = 256; |
111 | 111 | ||
112 | Color[] grays = new Color[pallete]; | 112 | Color[] grays = new Color[pallete]; |
113 | for (int i = 0; i < grays.Length; i++) | 113 | for (int i = 0; i < grays.Length; i++) |
114 | { | 114 | { |
115 | grays[i] = Color.FromArgb(i, i, i); | 115 | grays[i] = Color.FromArgb(i, i, i); |
116 | } | 116 | } |
117 | 117 | ||
118 | for (int y = 0; y < map.Height; y++) | 118 | for (int y = 0; y < map.Height; y++) |
119 | { | 119 | { |
120 | for (int x = 0; x < map.Width; x++) | 120 | for (int x = 0; x < map.Width; x++) |
121 | { | 121 | { |
122 | // 512 is the largest possible height before colours clamp | 122 | // 512 is the largest possible height before colours clamp |
123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); | 123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); |
124 | 124 | ||
125 | // Handle error conditions | 125 | // Handle error conditions |
126 | if (colorindex > pallete - 1 || colorindex < 0) | 126 | if (colorindex > pallete - 1 || colorindex < 0) |
127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | 127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); |
128 | else | 128 | else |
129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); | 129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | return bmp; | 132 | return bmp; |
133 | } | 133 | } |
134 | 134 | ||
135 | /// <summary> | 135 | /// <summary> |
136 | /// Protected method, generates a coloured bitmap | 136 | /// Protected method, generates a coloured bitmap |
137 | /// image from a specified terrain channel. | 137 | /// image from a specified terrain channel. |
138 | /// </summary> | 138 | /// </summary> |
139 | /// <param name="map">The terrain channel to export to bitmap</param> | 139 | /// <param name="map">The terrain channel to export to bitmap</param> |
140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | 140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> |
141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) | 141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) |
142 | { | 142 | { |
143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
144 | 144 | ||
145 | int pallete = gradientmapLd.Height; | 145 | int pallete = gradientmapLd.Height; |
146 | 146 | ||
147 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 147 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
148 | Color[] colours = new Color[pallete]; | 148 | Color[] colours = new Color[pallete]; |
149 | 149 | ||
150 | for (int i = 0; i < pallete; i++) | 150 | for (int i = 0; i < pallete; i++) |
151 | { | 151 | { |
152 | colours[i] = gradientmapLd.GetPixel(0, i); | 152 | colours[i] = gradientmapLd.GetPixel(0, i); |
153 | } | 153 | } |
154 | 154 | ||
155 | for (int y = 0; y < map.Height; y++) | 155 | for (int y = 0; y < map.Height; y++) |
156 | { | 156 | { |
157 | for (int x = 0; x < map.Width; x++) | 157 | for (int x = 0; x < map.Width; x++) |
158 | { | 158 | { |
159 | // 512 is the largest possible height before colours clamp | 159 | // 512 is the largest possible height before colours clamp |
160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
161 | 161 | ||
162 | // Handle error conditions | 162 | // Handle error conditions |
163 | if (colorindex > pallete - 1 || colorindex < 0) | 163 | if (colorindex > pallete - 1 || colorindex < 0) |
164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | 164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); |
165 | else | 165 | else |
166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | return bmp; | 169 | return bmp; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } \ No newline at end of file | 172 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs index 39ade10..d58926e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | public class JPEG : ITerrainLoader | 35 | public class JPEG : ITerrainLoader |
36 | { | 36 | { |
37 | #region ITerrainLoader Members | 37 | #region ITerrainLoader Members |
38 | 38 | ||
39 | public string FileExtension | 39 | public string FileExtension |
40 | { | 40 | { |
41 | get { return ".jpg"; } | 41 | get { return ".jpg"; } |
42 | } | 42 | } |
43 | 43 | ||
44 | public ITerrainChannel LoadFile(string filename) | 44 | public ITerrainChannel LoadFile(string filename) |
45 | { | 45 | { |
46 | throw new NotImplementedException(); | 46 | throw new NotImplementedException(); |
47 | } | 47 | } |
48 | 48 | ||
49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
50 | { | 50 | { |
51 | throw new NotImplementedException(); | 51 | throw new NotImplementedException(); |
52 | } | 52 | } |
53 | 53 | ||
54 | public void SaveFile(string filename, ITerrainChannel map) | 54 | public void SaveFile(string filename, ITerrainChannel map) |
55 | { | 55 | { |
56 | Bitmap colours = CreateBitmapFromMap(map); | 56 | Bitmap colours = CreateBitmapFromMap(map); |
57 | 57 | ||
58 | colours.Save(filename, ImageFormat.Jpeg); | 58 | colours.Save(filename, ImageFormat.Jpeg); |
59 | } | 59 | } |
60 | 60 | ||
61 | #endregion | 61 | #endregion |
62 | 62 | ||
63 | public override string ToString() | 63 | public override string ToString() |
64 | { | 64 | { |
65 | return "JPEG"; | 65 | return "JPEG"; |
66 | } | 66 | } |
67 | 67 | ||
68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) | 68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) |
69 | { | 69 | { |
70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
71 | 71 | ||
72 | int pallete = gradientmapLd.Height; | 72 | int pallete = gradientmapLd.Height; |
73 | 73 | ||
74 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 74 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
75 | Color[] colours = new Color[pallete]; | 75 | Color[] colours = new Color[pallete]; |
76 | 76 | ||
77 | for (int i = 0; i < pallete; i++) | 77 | for (int i = 0; i < pallete; i++) |
78 | { | 78 | { |
79 | colours[i] = gradientmapLd.GetPixel(0, i); | 79 | colours[i] = gradientmapLd.GetPixel(0, i); |
80 | } | 80 | } |
81 | 81 | ||
82 | for (int y = 0; y < map.Height; y++) | 82 | for (int y = 0; y < map.Height; y++) |
83 | { | 83 | { |
84 | for (int x = 0; x < map.Width; x++) | 84 | for (int x = 0; x < map.Width; x++) |
85 | { | 85 | { |
86 | // 512 is the largest possible height before colours clamp | 86 | // 512 is the largest possible height before colours clamp |
87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | return bmp; | 91 | return bmp; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } \ No newline at end of file | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs index 468ecc9..5d6723f 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -1,148 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 33 | { |
34 | public class LLRAW : ITerrainLoader | 34 | public class LLRAW : ITerrainLoader |
35 | { | 35 | { |
36 | #region ITerrainLoader Members | 36 | #region ITerrainLoader Members |
37 | 37 | ||
38 | public ITerrainChannel LoadFile(string filename) | 38 | public ITerrainChannel LoadFile(string filename) |
39 | { | 39 | { |
40 | TerrainChannel retval = new TerrainChannel(); | 40 | TerrainChannel retval = new TerrainChannel(); |
41 | 41 | ||
42 | FileInfo file = new FileInfo(filename); | 42 | FileInfo file = new FileInfo(filename); |
43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
44 | BinaryReader bs = new BinaryReader(s); | 44 | BinaryReader bs = new BinaryReader(s); |
45 | int x, y; | 45 | int x, y; |
46 | for (y = 0; y < retval.Height; y++) | 46 | for (y = 0; y < retval.Height; y++) |
47 | { | 47 | { |
48 | for (x = 0; x < retval.Width; x++) | 48 | for (x = 0; x < retval.Width; x++) |
49 | { | 49 | { |
50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); | 50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); |
51 | bs.ReadBytes(11); // Advance the stream to next bytes. | 51 | bs.ReadBytes(11); // Advance the stream to next bytes. |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | bs.Close(); | 55 | bs.Close(); |
56 | s.Close(); | 56 | s.Close(); |
57 | 57 | ||
58 | return retval; | 58 | return retval; |
59 | } | 59 | } |
60 | 60 | ||
61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
62 | { | 62 | { |
63 | throw new NotImplementedException(); | 63 | throw new NotImplementedException(); |
64 | } | 64 | } |
65 | 65 | ||
66 | public void SaveFile(string filename, ITerrainChannel map) | 66 | public void SaveFile(string filename, ITerrainChannel map) |
67 | { | 67 | { |
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
70 | BinaryWriter binStream = new BinaryWriter(s); | 70 | BinaryWriter binStream = new BinaryWriter(s); |
71 | 71 | ||
72 | // Generate a smegging big lookup table to speed the operation up (it needs it) | 72 | // Generate a smegging big lookup table to speed the operation up (it needs it) |
73 | double[] lookupHeightTable = new double[65536]; | 73 | double[] lookupHeightTable = new double[65536]; |
74 | int i, j, x, y; | 74 | int i, j, x, y; |
75 | for (i = 0; i < 256; i++) | 75 | for (i = 0; i < 256; i++) |
76 | { | 76 | { |
77 | for (j = 0; j < 256; j++) | 77 | for (j = 0; j < 256; j++) |
78 | { | 78 | { |
79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); | 79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | // Output the calculated raw | 83 | // Output the calculated raw |
84 | for (y = 0; y < map.Height; y++) | 84 | for (y = 0; y < map.Height; y++) |
85 | { | 85 | { |
86 | for (x = 0; x < map.Width; x++) | 86 | for (x = 0; x < map.Width; x++) |
87 | { | 87 | { |
88 | double t = map[x, y]; | 88 | double t = map[x, y]; |
89 | double min = double.MaxValue; | 89 | double min = double.MaxValue; |
90 | int index = 0; | 90 | int index = 0; |
91 | 91 | ||
92 | for (i = 0; i < 65536; i++) | 92 | for (i = 0; i < 65536; i++) |
93 | { | 93 | { |
94 | if (Math.Abs(t - lookupHeightTable[i]) < min) | 94 | if (Math.Abs(t - lookupHeightTable[i]) < min) |
95 | { | 95 | { |
96 | min = Math.Abs(t - lookupHeightTable[i]); | 96 | min = Math.Abs(t - lookupHeightTable[i]); |
97 | index = i; | 97 | index = i; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | byte red = (byte) (index & 0xFF); | 101 | byte red = (byte) (index & 0xFF); |
102 | byte green = (byte) ((index >> 8) & 0xFF); | 102 | byte green = (byte) ((index >> 8) & 0xFF); |
103 | byte blue = 20; | 103 | byte blue = 20; |
104 | byte alpha1 = 0; // Land Parcels | 104 | byte alpha1 = 0; // Land Parcels |
105 | byte alpha2 = 0; // For Sale Land | 105 | byte alpha2 = 0; // For Sale Land |
106 | byte alpha3 = 0; // Public Edit Object | 106 | byte alpha3 = 0; // Public Edit Object |
107 | byte alpha4 = 0; // Public Edit Land | 107 | byte alpha4 = 0; // Public Edit Land |
108 | byte alpha5 = 255; // Safe Land | 108 | byte alpha5 = 255; // Safe Land |
109 | byte alpha6 = 255; // Flying Allowed | 109 | byte alpha6 = 255; // Flying Allowed |
110 | byte alpha7 = 255; // Create Landmark | 110 | byte alpha7 = 255; // Create Landmark |
111 | byte alpha8 = 255; // Outside Scripts | 111 | byte alpha8 = 255; // Outside Scripts |
112 | byte alpha9 = red; | 112 | byte alpha9 = red; |
113 | byte alpha10 = green; | 113 | byte alpha10 = green; |
114 | 114 | ||
115 | binStream.Write(red); | 115 | binStream.Write(red); |
116 | binStream.Write(green); | 116 | binStream.Write(green); |
117 | binStream.Write(blue); | 117 | binStream.Write(blue); |
118 | binStream.Write(alpha1); | 118 | binStream.Write(alpha1); |
119 | binStream.Write(alpha2); | 119 | binStream.Write(alpha2); |
120 | binStream.Write(alpha3); | 120 | binStream.Write(alpha3); |
121 | binStream.Write(alpha4); | 121 | binStream.Write(alpha4); |
122 | binStream.Write(alpha5); | 122 | binStream.Write(alpha5); |
123 | binStream.Write(alpha6); | 123 | binStream.Write(alpha6); |
124 | binStream.Write(alpha7); | 124 | binStream.Write(alpha7); |
125 | binStream.Write(alpha8); | 125 | binStream.Write(alpha8); |
126 | binStream.Write(alpha9); | 126 | binStream.Write(alpha9); |
127 | binStream.Write(alpha10); | 127 | binStream.Write(alpha10); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | binStream.Close(); | 131 | binStream.Close(); |
132 | s.Close(); | 132 | s.Close(); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | public string FileExtension | 136 | public string FileExtension |
137 | { | 137 | { |
138 | get { return ".raw"; } | 138 | get { return ".raw"; } |
139 | } | 139 | } |
140 | 140 | ||
141 | #endregion | 141 | #endregion |
142 | 142 | ||
143 | public override string ToString() | 143 | public override string ToString() |
144 | { | 144 | { |
145 | return "LL/SL RAW"; | 145 | return "LL/SL RAW"; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } \ No newline at end of file | 148 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs index 2925c7d..b893f70 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class PNG : GenericSystemDrawing | 33 | internal class PNG : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Png); | 39 | colours.Save(filename, ImageFormat.Png); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "PNG"; | 44 | return "PNG"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs index 71f56c5..fd2136c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -1,153 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.IO; | 28 | using System.IO; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | public class RAW32 : ITerrainLoader | 33 | public class RAW32 : ITerrainLoader |
34 | { | 34 | { |
35 | #region ITerrainLoader Members | 35 | #region ITerrainLoader Members |
36 | 36 | ||
37 | public string FileExtension | 37 | public string FileExtension |
38 | { | 38 | { |
39 | get { return ".r32"; } | 39 | get { return ".r32"; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public ITerrainChannel LoadFile(string filename) | 42 | public ITerrainChannel LoadFile(string filename) |
43 | { | 43 | { |
44 | TerrainChannel retval = new TerrainChannel(); | 44 | TerrainChannel retval = new TerrainChannel(); |
45 | 45 | ||
46 | FileInfo file = new FileInfo(filename); | 46 | FileInfo file = new FileInfo(filename); |
47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
48 | BinaryReader bs = new BinaryReader(s); | 48 | BinaryReader bs = new BinaryReader(s); |
49 | int x, y; | 49 | int x, y; |
50 | for (y = 0; y < retval.Height; y++) | 50 | for (y = 0; y < retval.Height; y++) |
51 | { | 51 | { |
52 | for (x = 0; x < retval.Width; x++) | 52 | for (x = 0; x < retval.Width; x++) |
53 | { | 53 | { |
54 | retval[x, y] = bs.ReadSingle(); | 54 | retval[x, y] = bs.ReadSingle(); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | bs.Close(); | 58 | bs.Close(); |
59 | s.Close(); | 59 | s.Close(); |
60 | 60 | ||
61 | return retval; | 61 | return retval; |
62 | } | 62 | } |
63 | 63 | ||
64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | 64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) |
65 | { | 65 | { |
66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | 66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); |
67 | 67 | ||
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
70 | BinaryReader bs = new BinaryReader(s); | 70 | BinaryReader bs = new BinaryReader(s); |
71 | 71 | ||
72 | int currFileXOffset = 0; | 72 | int currFileXOffset = 0; |
73 | int currFileYOffset = 0; | 73 | int currFileYOffset = 0; |
74 | 74 | ||
75 | // if our region isn't on the first Y section of the areas to be landscaped, then | 75 | // if our region isn't on the first Y section of the areas to be landscaped, then |
76 | // advance to our section of the file | 76 | // advance to our section of the file |
77 | while (currFileYOffset < offsetY) | 77 | while (currFileYOffset < offsetY) |
78 | { | 78 | { |
79 | // read a whole strip of regions | 79 | // read a whole strip of regions |
80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | 80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); |
81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file | 81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file |
82 | currFileYOffset++; | 82 | currFileYOffset++; |
83 | } | 83 | } |
84 | 84 | ||
85 | // got to the Y start offset within the file of our region | 85 | // got to the Y start offset within the file of our region |
86 | // so read the file bits associated with our region | 86 | // so read the file bits associated with our region |
87 | int x, y; | 87 | int x, y; |
88 | // for each Y within our Y offset | 88 | // for each Y within our Y offset |
89 | for (y = 0; y < sectionHeight; y++) | 89 | for (y = 0; y < sectionHeight; y++) |
90 | { | 90 | { |
91 | currFileXOffset = 0; | 91 | currFileXOffset = 0; |
92 | 92 | ||
93 | // if our region isn't the first X section of the areas to be landscaped, then | 93 | // if our region isn't the first X section of the areas to be landscaped, then |
94 | // advance the stream to the X start pos of our section in the file | 94 | // advance the stream to the X start pos of our section in the file |
95 | // i.e. eat X upto where we start | 95 | // i.e. eat X upto where we start |
96 | while (currFileXOffset < offsetX) | 96 | while (currFileXOffset < offsetX) |
97 | { | 97 | { |
98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
99 | currFileXOffset++; | 99 | currFileXOffset++; |
100 | } | 100 | } |
101 | 101 | ||
102 | // got to our X offset, so write our regions X line | 102 | // got to our X offset, so write our regions X line |
103 | for (x = 0; x < sectionWidth; x++) | 103 | for (x = 0; x < sectionWidth; x++) |
104 | { | 104 | { |
105 | // Read a strip and continue | 105 | // Read a strip and continue |
106 | retval[x, y] = bs.ReadSingle(); | 106 | retval[x, y] = bs.ReadSingle(); |
107 | } | 107 | } |
108 | // record that we wrote it | 108 | // record that we wrote it |
109 | currFileXOffset++; | 109 | currFileXOffset++; |
110 | 110 | ||
111 | // if our region isn't the last X section of the areas to be landscaped, then | 111 | // if our region isn't the last X section of the areas to be landscaped, then |
112 | // advance the stream to the end of this Y column | 112 | // advance the stream to the end of this Y column |
113 | while (currFileXOffset < fileWidth) | 113 | while (currFileXOffset < fileWidth) |
114 | { | 114 | { |
115 | // eat the next regions x line | 115 | // eat the next regions x line |
116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
117 | currFileXOffset++; | 117 | currFileXOffset++; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | bs.Close(); | 121 | bs.Close(); |
122 | s.Close(); | 122 | s.Close(); |
123 | 123 | ||
124 | return retval; | 124 | return retval; |
125 | } | 125 | } |
126 | 126 | ||
127 | public void SaveFile(string filename, ITerrainChannel map) | 127 | public void SaveFile(string filename, ITerrainChannel map) |
128 | { | 128 | { |
129 | FileInfo file = new FileInfo(filename); | 129 | FileInfo file = new FileInfo(filename); |
130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); | 130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); |
131 | BinaryWriter bs = new BinaryWriter(s); | 131 | BinaryWriter bs = new BinaryWriter(s); |
132 | 132 | ||
133 | int x, y; | 133 | int x, y; |
134 | for (y = 0; y < map.Height; y++) | 134 | for (y = 0; y < map.Height; y++) |
135 | { | 135 | { |
136 | for (x = 0; x < map.Width; x++) | 136 | for (x = 0; x < map.Width; x++) |
137 | { | 137 | { |
138 | bs.Write((float) map[x, y]); | 138 | bs.Write((float) map[x, y]); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | bs.Close(); | 142 | bs.Close(); |
143 | s.Close(); | 143 | s.Close(); |
144 | } | 144 | } |
145 | 145 | ||
146 | #endregion | 146 | #endregion |
147 | 147 | ||
148 | public override string ToString() | 148 | public override string ToString() |
149 | { | 149 | { |
150 | return "RAW32"; | 150 | return "RAW32"; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } \ No newline at end of file | 153 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs index 3a137ae..c081aea 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class TIFF : GenericSystemDrawing | 33 | internal class TIFF : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Tiff); | 39 | colours.Save(filename, ImageFormat.Tiff); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "TIFF"; | 44 | return "TIFF"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs index f2672ad..7cb4b00 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -1,127 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// Terragen File Format Loader | 36 | /// Terragen File Format Loader |
37 | /// Built from specification at | 37 | /// Built from specification at |
38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html | 38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html |
39 | /// </summary> | 39 | /// </summary> |
40 | internal class Terragen : ITerrainLoader | 40 | internal class Terragen : ITerrainLoader |
41 | { | 41 | { |
42 | #region ITerrainLoader Members | 42 | #region ITerrainLoader Members |
43 | 43 | ||
44 | public ITerrainChannel LoadFile(string filename) | 44 | public ITerrainChannel LoadFile(string filename) |
45 | { | 45 | { |
46 | TerrainChannel retval = new TerrainChannel(); | 46 | TerrainChannel retval = new TerrainChannel(); |
47 | 47 | ||
48 | FileInfo file = new FileInfo(filename); | 48 | FileInfo file = new FileInfo(filename); |
49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
50 | BinaryReader bs = new BinaryReader(s); | 50 | BinaryReader bs = new BinaryReader(s); |
51 | 51 | ||
52 | bool eof = false; | 52 | bool eof = false; |
53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | 53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") |
54 | { | 54 | { |
55 | // Terragen file | 55 | // Terragen file |
56 | while (eof == false) | 56 | while (eof == false) |
57 | { | 57 | { |
58 | int w = 256; | 58 | int w = 256; |
59 | int h = 256; | 59 | int h = 256; |
60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); | 60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); |
61 | switch (tmp) | 61 | switch (tmp) |
62 | { | 62 | { |
63 | case "SIZE": | 63 | case "SIZE": |
64 | int sztmp = bs.ReadInt16() + 1; | 64 | int sztmp = bs.ReadInt16() + 1; |
65 | w = sztmp; | 65 | w = sztmp; |
66 | h = sztmp; | 66 | h = sztmp; |
67 | bs.ReadInt16(); | 67 | bs.ReadInt16(); |
68 | break; | 68 | break; |
69 | case "XPTS": | 69 | case "XPTS": |
70 | w = bs.ReadInt16(); | 70 | w = bs.ReadInt16(); |
71 | bs.ReadInt16(); | 71 | bs.ReadInt16(); |
72 | break; | 72 | break; |
73 | case "YPTS": | 73 | case "YPTS": |
74 | h = bs.ReadInt16(); | 74 | h = bs.ReadInt16(); |
75 | bs.ReadInt16(); | 75 | bs.ReadInt16(); |
76 | break; | 76 | break; |
77 | case "ALTW": | 77 | case "ALTW": |
78 | eof = true; | 78 | eof = true; |
79 | Int16 heightScale = bs.ReadInt16(); | 79 | Int16 heightScale = bs.ReadInt16(); |
80 | Int16 baseHeight = bs.ReadInt16(); | 80 | Int16 baseHeight = bs.ReadInt16(); |
81 | retval = new TerrainChannel(w, h); | 81 | retval = new TerrainChannel(w, h); |
82 | int x, y; | 82 | int x, y; |
83 | for (x = 0; x < w; x++) | 83 | for (x = 0; x < w; x++) |
84 | { | 84 | { |
85 | for (y = 0; y < h; y++) | 85 | for (y = 0; y < h; y++) |
86 | { | 86 | { |
87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; | 87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | bs.ReadInt32(); | 92 | bs.ReadInt32(); |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | bs.Close(); | 98 | bs.Close(); |
99 | s.Close(); | 99 | s.Close(); |
100 | 100 | ||
101 | return retval; | 101 | return retval; |
102 | } | 102 | } |
103 | 103 | ||
104 | public void SaveFile(string filename, ITerrainChannel map) | 104 | public void SaveFile(string filename, ITerrainChannel map) |
105 | { | 105 | { |
106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); | 106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); |
107 | throw new NotImplementedException(); | 107 | throw new NotImplementedException(); |
108 | } | 108 | } |
109 | 109 | ||
110 | public string FileExtension | 110 | public string FileExtension |
111 | { | 111 | { |
112 | get { return ".ter"; } | 112 | get { return ".ter"; } |
113 | } | 113 | } |
114 | 114 | ||
115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
116 | { | 116 | { |
117 | throw new NotImplementedException(); | 117 | throw new NotImplementedException(); |
118 | } | 118 | } |
119 | 119 | ||
120 | #endregion | 120 | #endregion |
121 | 121 | ||
122 | public override string ToString() | 122 | public override string ToString() |
123 | { | 123 | { |
124 | return "Terragen"; | 124 | return "Terragen"; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } \ No newline at end of file | 127 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs index 7bf81d3..496da63 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs | |||
@@ -1,71 +1,71 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class FlattenArea : ITerrainFloodEffect | 32 | public class FlattenArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | double sum = 0.0; | 38 | double sum = 0.0; |
39 | double steps = 0.0; | 39 | double steps = 0.0; |
40 | double avg; | 40 | double avg; |
41 | 41 | ||
42 | int x, y; | 42 | int x, y; |
43 | for (x = 0; x < map.Width; x++) | 43 | for (x = 0; x < map.Width; x++) |
44 | { | 44 | { |
45 | for (y = 0; y < map.Height; y++) | 45 | for (y = 0; y < map.Height; y++) |
46 | { | 46 | { |
47 | if (fillArea[x, y]) | 47 | if (fillArea[x, y]) |
48 | { | 48 | { |
49 | sum += map[x, y]; | 49 | sum += map[x, y]; |
50 | steps += 1.0; | 50 | steps += 1.0; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | avg = sum / steps; | 55 | avg = sum / steps; |
56 | 56 | ||
57 | double str = 0.1 * strength; // == 0.2 in the default client | 57 | double str = 0.1 * strength; // == 0.2 in the default client |
58 | 58 | ||
59 | for (x = 0; x < map.Width; x++) | 59 | for (x = 0; x < map.Width; x++) |
60 | { | 60 | { |
61 | for (y = 0; y < map.Height; y++) | 61 | for (y = 0; y < map.Height; y++) |
62 | { | 62 | { |
63 | if (fillArea[x, y]) | 63 | if (fillArea[x, y]) |
64 | map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); | 64 | map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | #endregion | 69 | #endregion |
70 | } | 70 | } |
71 | } \ No newline at end of file | 71 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs index a7a4431..3646d61 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs | |||
@@ -1,54 +1,54 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class LowerArea : ITerrainFloodEffect | 32 | public class LowerArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | int x; | 38 | int x; |
39 | for (x = 0; x < map.Width; x++) | 39 | for (x = 0; x < map.Width; x++) |
40 | { | 40 | { |
41 | int y; | 41 | int y; |
42 | for (y = 0; y < map.Height; y++) | 42 | for (y = 0; y < map.Height; y++) |
43 | { | 43 | { |
44 | if (fillArea[x, y]) | 44 | if (fillArea[x, y]) |
45 | { | 45 | { |
46 | map[x, y] -= strength; | 46 | map[x, y] -= strength; |
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | #endregion | 52 | #endregion |
53 | } | 53 | } |
54 | } \ No newline at end of file | 54 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs index 3da3826..6c8e76e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using OpenSim.Framework; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
32 | { | 32 | { |
33 | public class NoiseArea : ITerrainFloodEffect | 33 | public class NoiseArea : ITerrainFloodEffect |
34 | { | 34 | { |
35 | #region ITerrainFloodEffect Members | 35 | #region ITerrainFloodEffect Members |
36 | 36 | ||
37 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 37 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
38 | { | 38 | { |
39 | int x, y; | 39 | int x, y; |
40 | for (x = 0; x < map.Width; x++) | 40 | for (x = 0; x < map.Width; x++) |
41 | { | 41 | { |
42 | for (y = 0; y < map.Height; y++) | 42 | for (y = 0; y < map.Height; y++) |
43 | { | 43 | { |
44 | if (fillArea[x, y]) | 44 | if (fillArea[x, y]) |
45 | { | 45 | { |
46 | double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); | 46 | double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); |
47 | 47 | ||
48 | map[x, y] += noise * strength; | 48 | map[x, y] += noise * strength; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | #endregion | 54 | #endregion |
55 | } | 55 | } |
56 | } \ No newline at end of file | 56 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs index b57caed..5cb236c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs | |||
@@ -1,53 +1,53 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class RaiseArea : ITerrainFloodEffect | 32 | public class RaiseArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | int x, y; | 38 | int x, y; |
39 | for (x = 0; x < map.Width; x++) | 39 | for (x = 0; x < map.Width; x++) |
40 | { | 40 | { |
41 | for (y = 0; y < map.Height; y++) | 41 | for (y = 0; y < map.Height; y++) |
42 | { | 42 | { |
43 | if (fillArea[x, y]) | 43 | if (fillArea[x, y]) |
44 | { | 44 | { |
45 | map[x, y] += strength; | 45 | map[x, y] += strength; |
46 | } | 46 | } |
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | #endregion | 51 | #endregion |
52 | } | 52 | } |
53 | } \ No newline at end of file | 53 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs index 76a2cae..f1d9ce6 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs | |||
@@ -1,60 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class RevertArea : ITerrainFloodEffect | 32 | public class RevertArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | private readonly ITerrainChannel m_revertmap; | 34 | private readonly ITerrainChannel m_revertmap; |
35 | 35 | ||
36 | public RevertArea(ITerrainChannel revertmap) | 36 | public RevertArea(ITerrainChannel revertmap) |
37 | { | 37 | { |
38 | m_revertmap = revertmap; | 38 | m_revertmap = revertmap; |
39 | } | 39 | } |
40 | 40 | ||
41 | #region ITerrainFloodEffect Members | 41 | #region ITerrainFloodEffect Members |
42 | 42 | ||
43 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 43 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
44 | { | 44 | { |
45 | int x, y; | 45 | int x, y; |
46 | for (x = 0; x < map.Width; x++) | 46 | for (x = 0; x < map.Width; x++) |
47 | { | 47 | { |
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | if (fillArea[x, y]) | 50 | if (fillArea[x, y]) |
51 | { | 51 | { |
52 | map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); | 52 | map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | #endregion | 58 | #endregion |
59 | } | 59 | } |
60 | } \ No newline at end of file | 60 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs index bdd9f18..d17d9cb 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs | |||
@@ -1,114 +1,114 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class SmoothArea : ITerrainFloodEffect | 32 | public class SmoothArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | double area = strength; | 38 | double area = strength; |
39 | double step = strength / 4.0; | 39 | double step = strength / 4.0; |
40 | 40 | ||
41 | double[,] manipulate = new double[map.Width,map.Height]; | 41 | double[,] manipulate = new double[map.Width,map.Height]; |
42 | int x, y; | 42 | int x, y; |
43 | for (x = 0; x < map.Width; x++) | 43 | for (x = 0; x < map.Width; x++) |
44 | { | 44 | { |
45 | for (y = 0; y < map.Height; y++) | 45 | for (y = 0; y < map.Height; y++) |
46 | { | 46 | { |
47 | if (!fillArea[x, y]) | 47 | if (!fillArea[x, y]) |
48 | continue; | 48 | continue; |
49 | 49 | ||
50 | double average = 0.0; | 50 | double average = 0.0; |
51 | int avgsteps = 0; | 51 | int avgsteps = 0; |
52 | 52 | ||
53 | double n; | 53 | double n; |
54 | for (n = 0.0 - area; n < area; n += step) | 54 | for (n = 0.0 - area; n < area; n += step) |
55 | { | 55 | { |
56 | double l; | 56 | double l; |
57 | for (l = 0.0 - area; l < area; l += step) | 57 | for (l = 0.0 - area; l < area; l += step) |
58 | { | 58 | { |
59 | avgsteps++; | 59 | avgsteps++; |
60 | average += GetBilinearInterpolate(x + n, y + l, map); | 60 | average += GetBilinearInterpolate(x + n, y + l, map); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | manipulate[x, y] = average / avgsteps; | 64 | manipulate[x, y] = average / avgsteps; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | for (x = 0; x < map.Width; x++) | 67 | for (x = 0; x < map.Width; x++) |
68 | { | 68 | { |
69 | for (y = 0; y < map.Height; y++) | 69 | for (y = 0; y < map.Height; y++) |
70 | { | 70 | { |
71 | if (!fillArea[x, y]) | 71 | if (!fillArea[x, y]) |
72 | continue; | 72 | continue; |
73 | 73 | ||
74 | map[x, y] = manipulate[x, y]; | 74 | map[x, y] = manipulate[x, y]; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | #endregion | 79 | #endregion |
80 | 80 | ||
81 | private static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 81 | private static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
82 | { | 82 | { |
83 | int w = map.Width; | 83 | int w = map.Width; |
84 | int h = map.Height; | 84 | int h = map.Height; |
85 | 85 | ||
86 | if (x > w - 2.0) | 86 | if (x > w - 2.0) |
87 | x = w - 2.0; | 87 | x = w - 2.0; |
88 | if (y > h - 2.0) | 88 | if (y > h - 2.0) |
89 | y = h - 2.0; | 89 | y = h - 2.0; |
90 | if (x < 0.0) | 90 | if (x < 0.0) |
91 | x = 0.0; | 91 | x = 0.0; |
92 | if (y < 0.0) | 92 | if (y < 0.0) |
93 | y = 0.0; | 93 | y = 0.0; |
94 | 94 | ||
95 | int stepSize = 1; | 95 | int stepSize = 1; |
96 | double h00 = map[(int) x, (int) y]; | 96 | double h00 = map[(int) x, (int) y]; |
97 | double h10 = map[(int) x + stepSize, (int) y]; | 97 | double h10 = map[(int) x + stepSize, (int) y]; |
98 | double h01 = map[(int) x, (int) y + stepSize]; | 98 | double h01 = map[(int) x, (int) y + stepSize]; |
99 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; | 99 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; |
100 | double h1 = h00; | 100 | double h1 = h00; |
101 | double h2 = h10; | 101 | double h2 = h10; |
102 | double h3 = h01; | 102 | double h3 = h01; |
103 | double h4 = h11; | 103 | double h4 = h11; |
104 | double a00 = h1; | 104 | double a00 = h1; |
105 | double a10 = h2 - h1; | 105 | double a10 = h2 - h1; |
106 | double a01 = h3 - h1; | 106 | double a01 = h3 - h1; |
107 | double a11 = h1 - h2 - h3 + h4; | 107 | double a11 = h1 - h2 - h3 + h4; |
108 | double partialx = x - (int) x; | 108 | double partialx = x - (int) x; |
109 | double partialz = y - (int) y; | 109 | double partialz = y - (int) y; |
110 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 110 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
111 | return hi; | 111 | return hi; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } \ No newline at end of file | 114 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs index 821fc4b..bbbe2a3 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs | |||
@@ -1,36 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public interface ITerrainEffect | 32 | public interface ITerrainEffect |
33 | { | 33 | { |
34 | void RunEffect(ITerrainChannel map); | 34 | void RunEffect(ITerrainChannel map); |
35 | } | 35 | } |
36 | } \ No newline at end of file | 36 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs index 6b0d7f9..9fe93a2 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs | |||
@@ -1,37 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 32 | { |
33 | public interface ITerrainFloodEffect | 33 | public interface ITerrainFloodEffect |
34 | { | 34 | { |
35 | void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); | 35 | void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); |
36 | } | 36 | } |
37 | } \ No newline at end of file | 37 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs index 6211892..4c16c1c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs | |||
@@ -1,39 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public interface ITerrainLoader | 32 | public interface ITerrainLoader |
33 | { | 33 | { |
34 | string FileExtension { get; } | 34 | string FileExtension { get; } |
35 | ITerrainChannel LoadFile(string filename); | 35 | ITerrainChannel LoadFile(string filename); |
36 | ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight); | 36 | ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight); |
37 | void SaveFile(string filename, ITerrainChannel map); | 37 | void SaveFile(string filename, ITerrainChannel map); |
38 | } | 38 | } |
39 | } \ No newline at end of file | 39 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs index 756354a..224cc3a 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs | |||
@@ -1,8 +1,8 @@ | |||
1 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 1 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
2 | { | 2 | { |
3 | public interface ITerrainModule | 3 | public interface ITerrainModule |
4 | { | 4 | { |
5 | void LoadFromFile(string filename); | 5 | void LoadFromFile(string filename); |
6 | void SaveToFile(string filename); | 6 | void SaveToFile(string filename); |
7 | } | 7 | } |
8 | } \ No newline at end of file | 8 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs index d73f44d..cf2e58a 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs | |||
@@ -1,36 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public interface ITerrainPaintableEffect | 32 | public interface ITerrainPaintableEffect |
33 | { | 33 | { |
34 | void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); | 34 | void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); |
35 | } | 35 | } |
36 | } \ No newline at end of file | 36 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs index dbaec0f..fe26902 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs | |||
@@ -1,168 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenJPEGNet; | 31 | using OpenJPEGNet; |
32 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
33 | using OpenSim.Region.Environment.Scenes; | 33 | using OpenSim.Region.Environment.Scenes; |
34 | 34 | ||
35 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 35 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
36 | { | 36 | { |
37 | internal class MapImageModule : IMapImageGenerator, IRegionModule | 37 | internal class MapImageModule : IMapImageGenerator, IRegionModule |
38 | { | 38 | { |
39 | private Scene m_scene; | 39 | private Scene m_scene; |
40 | 40 | ||
41 | #region IMapImageGenerator Members | 41 | #region IMapImageGenerator Members |
42 | 42 | ||
43 | public byte[] WriteJpeg2000Image(string gradientmap) | 43 | public byte[] WriteJpeg2000Image(string gradientmap) |
44 | { | 44 | { |
45 | byte[] imageData = null; | 45 | byte[] imageData = null; |
46 | 46 | ||
47 | Bitmap bmp = TerrainToBitmap(gradientmap); | 47 | Bitmap bmp = TerrainToBitmap(gradientmap); |
48 | 48 | ||
49 | try | 49 | try |
50 | { | 50 | { |
51 | imageData = OpenJPEG.EncodeFromImage(bmp, true); | 51 | imageData = OpenJPEG.EncodeFromImage(bmp, true); |
52 | } | 52 | } |
53 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | 53 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke |
54 | { | 54 | { |
55 | Console.WriteLine("Failed generating terrain map: " + e); | 55 | Console.WriteLine("Failed generating terrain map: " + e); |
56 | } | 56 | } |
57 | 57 | ||
58 | return imageData; | 58 | return imageData; |
59 | } | 59 | } |
60 | 60 | ||
61 | #endregion | 61 | #endregion |
62 | 62 | ||
63 | #region IRegionModule Members | 63 | #region IRegionModule Members |
64 | 64 | ||
65 | public void Initialise(Scene scene, IConfigSource source) | 65 | public void Initialise(Scene scene, IConfigSource source) |
66 | { | 66 | { |
67 | m_scene = scene; | 67 | m_scene = scene; |
68 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); | 68 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
69 | } | 69 | } |
70 | 70 | ||
71 | public void PostInitialise() | 71 | public void PostInitialise() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | public void Close() | 75 | public void Close() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | public string Name | 79 | public string Name |
80 | { | 80 | { |
81 | get { return "MapImageModule"; } | 81 | get { return "MapImageModule"; } |
82 | } | 82 | } |
83 | 83 | ||
84 | public bool IsSharedModule | 84 | public bool IsSharedModule |
85 | { | 85 | { |
86 | get { return false; } | 86 | get { return false; } |
87 | } | 87 | } |
88 | 88 | ||
89 | #endregion | 89 | #endregion |
90 | 90 | ||
91 | private void ShadeBuildings(ref Bitmap map) | 91 | private void ShadeBuildings(ref Bitmap map) |
92 | { | 92 | { |
93 | lock (map) | 93 | lock (map) |
94 | { | 94 | { |
95 | lock (m_scene.Entities) | 95 | lock (m_scene.Entities) |
96 | { | 96 | { |
97 | foreach (EntityBase entity in m_scene.Entities.Values) | 97 | foreach (EntityBase entity in m_scene.Entities.Values) |
98 | { | 98 | { |
99 | if (entity is SceneObjectGroup) | 99 | if (entity is SceneObjectGroup) |
100 | { | 100 | { |
101 | SceneObjectGroup sog = (SceneObjectGroup) entity; | 101 | SceneObjectGroup sog = (SceneObjectGroup) entity; |
102 | 102 | ||
103 | foreach (SceneObjectPart primitive in sog.Children.Values) | 103 | foreach (SceneObjectPart primitive in sog.Children.Values) |
104 | { | 104 | { |
105 | int x, y, w, h; | 105 | int x, y, w, h; |
106 | x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2)); | 106 | x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2)); |
107 | y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2)); | 107 | y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2)); |
108 | w = (int) primitive.Scale.X; | 108 | w = (int) primitive.Scale.X; |
109 | h = (int) primitive.Scale.Y; | 109 | h = (int) primitive.Scale.Y; |
110 | 110 | ||
111 | int dx; | 111 | int dx; |
112 | for (dx = x; dx < x + w; dx++) | 112 | for (dx = x; dx < x + w; dx++) |
113 | { | 113 | { |
114 | int dy; | 114 | int dy; |
115 | for (dy = y; dy < y + h; dy++) | 115 | for (dy = y; dy < y + h; dy++) |
116 | { | 116 | { |
117 | if (x < 0 || y < 0) | 117 | if (x < 0 || y < 0) |
118 | continue; | 118 | continue; |
119 | if (x >= map.Width || y >= map.Height) | 119 | if (x >= map.Width || y >= map.Height) |
120 | continue; | 120 | continue; |
121 | 121 | ||
122 | map.SetPixel(dx, dy, Color.DarkGray); | 122 | map.SetPixel(dx, dy, Color.DarkGray); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | private Bitmap TerrainToBitmap(string gradientmap) | 132 | private Bitmap TerrainToBitmap(string gradientmap) |
133 | { | 133 | { |
134 | Bitmap gradientmapLd = new Bitmap(gradientmap); | 134 | Bitmap gradientmapLd = new Bitmap(gradientmap); |
135 | 135 | ||
136 | int pallete = gradientmapLd.Height; | 136 | int pallete = gradientmapLd.Height; |
137 | 137 | ||
138 | Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height); | 138 | Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height); |
139 | Color[] colours = new Color[pallete]; | 139 | Color[] colours = new Color[pallete]; |
140 | 140 | ||
141 | for (int i = 0; i < pallete; i++) | 141 | for (int i = 0; i < pallete; i++) |
142 | { | 142 | { |
143 | colours[i] = gradientmapLd.GetPixel(0, i); | 143 | colours[i] = gradientmapLd.GetPixel(0, i); |
144 | } | 144 | } |
145 | 145 | ||
146 | lock (m_scene.Heightmap) | 146 | lock (m_scene.Heightmap) |
147 | { | 147 | { |
148 | ITerrainChannel copy = m_scene.Heightmap; | 148 | ITerrainChannel copy = m_scene.Heightmap; |
149 | for (int y = 0; y < copy.Height; y++) | 149 | for (int y = 0; y < copy.Height; y++) |
150 | { | 150 | { |
151 | for (int x = 0; x < copy.Width; x++) | 151 | for (int x = 0; x < copy.Width; x++) |
152 | { | 152 | { |
153 | // 512 is the largest possible height before colours clamp | 153 | // 512 is the largest possible height before colours clamp |
154 | int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); | 154 | int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); |
155 | 155 | ||
156 | // Handle error conditions | 156 | // Handle error conditions |
157 | if (colorindex > pallete - 1 || colorindex < 0) | 157 | if (colorindex > pallete - 1 || colorindex < 0) |
158 | bmp.SetPixel(x, copy.Height - y - 1, Color.Red); | 158 | bmp.SetPixel(x, copy.Height - y - 1, Color.Red); |
159 | else | 159 | else |
160 | bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]); | 160 | bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | ShadeBuildings(ref bmp); | 163 | ShadeBuildings(ref bmp); |
164 | return bmp; | 164 | return bmp; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } \ No newline at end of file | 168 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs index 29448aa..e036988 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs | |||
@@ -1,312 +1,312 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Hydraulic Erosion Brush | 34 | /// Hydraulic Erosion Brush |
35 | /// </summary> | 35 | /// </summary> |
36 | public class ErodeSphere : ITerrainPaintableEffect | 36 | public class ErodeSphere : ITerrainPaintableEffect |
37 | { | 37 | { |
38 | private double rainHeight = 0.2; | 38 | private double rainHeight = 0.2; |
39 | private int rounds = 10; | 39 | private int rounds = 10; |
40 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 40 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
41 | private double waterSaturation = 0.30; // Can carry 1% of water in height | 41 | private double waterSaturation = 0.30; // Can carry 1% of water in height |
42 | 42 | ||
43 | #region Supporting Functions | 43 | #region Supporting Functions |
44 | 44 | ||
45 | private int[] Neighbours(NeighbourSystem type, int index) | 45 | private int[] Neighbours(NeighbourSystem type, int index) |
46 | { | 46 | { |
47 | int[] coord = new int[2]; | 47 | int[] coord = new int[2]; |
48 | 48 | ||
49 | index++; | 49 | index++; |
50 | 50 | ||
51 | switch (type) | 51 | switch (type) |
52 | { | 52 | { |
53 | case NeighbourSystem.Moore: | 53 | case NeighbourSystem.Moore: |
54 | switch (index) | 54 | switch (index) |
55 | { | 55 | { |
56 | case 1: | 56 | case 1: |
57 | coord[0] = -1; | 57 | coord[0] = -1; |
58 | coord[1] = -1; | 58 | coord[1] = -1; |
59 | break; | 59 | break; |
60 | 60 | ||
61 | case 2: | 61 | case 2: |
62 | coord[0] = -0; | 62 | coord[0] = -0; |
63 | coord[1] = -1; | 63 | coord[1] = -1; |
64 | break; | 64 | break; |
65 | 65 | ||
66 | case 3: | 66 | case 3: |
67 | coord[0] = +1; | 67 | coord[0] = +1; |
68 | coord[1] = -1; | 68 | coord[1] = -1; |
69 | break; | 69 | break; |
70 | 70 | ||
71 | case 4: | 71 | case 4: |
72 | coord[0] = -1; | 72 | coord[0] = -1; |
73 | coord[1] = -0; | 73 | coord[1] = -0; |
74 | break; | 74 | break; |
75 | 75 | ||
76 | case 5: | 76 | case 5: |
77 | coord[0] = -0; | 77 | coord[0] = -0; |
78 | coord[1] = -0; | 78 | coord[1] = -0; |
79 | break; | 79 | break; |
80 | 80 | ||
81 | case 6: | 81 | case 6: |
82 | coord[0] = +1; | 82 | coord[0] = +1; |
83 | coord[1] = -0; | 83 | coord[1] = -0; |
84 | break; | 84 | break; |
85 | 85 | ||
86 | case 7: | 86 | case 7: |
87 | coord[0] = -1; | 87 | coord[0] = -1; |
88 | coord[1] = +1; | 88 | coord[1] = +1; |
89 | break; | 89 | break; |
90 | 90 | ||
91 | case 8: | 91 | case 8: |
92 | coord[0] = -0; | 92 | coord[0] = -0; |
93 | coord[1] = +1; | 93 | coord[1] = +1; |
94 | break; | 94 | break; |
95 | 95 | ||
96 | case 9: | 96 | case 9: |
97 | coord[0] = +1; | 97 | coord[0] = +1; |
98 | coord[1] = +1; | 98 | coord[1] = +1; |
99 | break; | 99 | break; |
100 | 100 | ||
101 | default: | 101 | default: |
102 | break; | 102 | break; |
103 | } | 103 | } |
104 | break; | 104 | break; |
105 | 105 | ||
106 | case NeighbourSystem.VonNeumann: | 106 | case NeighbourSystem.VonNeumann: |
107 | switch (index) | 107 | switch (index) |
108 | { | 108 | { |
109 | case 1: | 109 | case 1: |
110 | coord[0] = 0; | 110 | coord[0] = 0; |
111 | coord[1] = -1; | 111 | coord[1] = -1; |
112 | break; | 112 | break; |
113 | 113 | ||
114 | case 2: | 114 | case 2: |
115 | coord[0] = -1; | 115 | coord[0] = -1; |
116 | coord[1] = 0; | 116 | coord[1] = 0; |
117 | break; | 117 | break; |
118 | 118 | ||
119 | case 3: | 119 | case 3: |
120 | coord[0] = +1; | 120 | coord[0] = +1; |
121 | coord[1] = 0; | 121 | coord[1] = 0; |
122 | break; | 122 | break; |
123 | 123 | ||
124 | case 4: | 124 | case 4: |
125 | coord[0] = 0; | 125 | coord[0] = 0; |
126 | coord[1] = +1; | 126 | coord[1] = +1; |
127 | break; | 127 | break; |
128 | 128 | ||
129 | case 5: | 129 | case 5: |
130 | coord[0] = -0; | 130 | coord[0] = -0; |
131 | coord[1] = -0; | 131 | coord[1] = -0; |
132 | break; | 132 | break; |
133 | 133 | ||
134 | default: | 134 | default: |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | 139 | ||
140 | return coord; | 140 | return coord; |
141 | } | 141 | } |
142 | 142 | ||
143 | private enum NeighbourSystem | 143 | private enum NeighbourSystem |
144 | { | 144 | { |
145 | Moore, | 145 | Moore, |
146 | VonNeumann | 146 | VonNeumann |
147 | } ; | 147 | } ; |
148 | 148 | ||
149 | #endregion | 149 | #endregion |
150 | 150 | ||
151 | #region ITerrainPaintableEffect Members | 151 | #region ITerrainPaintableEffect Members |
152 | 152 | ||
153 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 153 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
154 | { | 154 | { |
155 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 155 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
156 | 156 | ||
157 | int x, y; | 157 | int x, y; |
158 | // Using one 'rain' round for this, so skipping a useless loop | 158 | // Using one 'rain' round for this, so skipping a useless loop |
159 | // Will need to adapt back in for the Flood brush | 159 | // Will need to adapt back in for the Flood brush |
160 | 160 | ||
161 | ITerrainChannel water = new TerrainChannel(map.Width, map.Height); | 161 | ITerrainChannel water = new TerrainChannel(map.Width, map.Height); |
162 | ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height); | 162 | ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height); |
163 | 163 | ||
164 | // Fill with rain | 164 | // Fill with rain |
165 | for (x = 0; x < water.Width; x++) | 165 | for (x = 0; x < water.Width; x++) |
166 | for (y = 0; y < water.Height; y++) | 166 | for (y = 0; y < water.Height; y++) |
167 | water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); | 167 | water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); |
168 | 168 | ||
169 | for (int i = 0; i < rounds; i++) | 169 | for (int i = 0; i < rounds; i++) |
170 | { | 170 | { |
171 | // Erode underlying terrain | 171 | // Erode underlying terrain |
172 | for (x = 0; x < water.Width; x++) | 172 | for (x = 0; x < water.Width; x++) |
173 | { | 173 | { |
174 | for (y = 0; y < water.Height; y++) | 174 | for (y = 0; y < water.Height; y++) |
175 | { | 175 | { |
176 | double solConst = (1.0 / rounds); | 176 | double solConst = (1.0 / rounds); |
177 | double sedDelta = water[x, y] * solConst; | 177 | double sedDelta = water[x, y] * solConst; |
178 | map[x, y] -= sedDelta; | 178 | map[x, y] -= sedDelta; |
179 | sediment[x, y] += sedDelta; | 179 | sediment[x, y] += sedDelta; |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | // Move water | 183 | // Move water |
184 | for (x = 0; x < water.Width; x++) | 184 | for (x = 0; x < water.Width; x++) |
185 | { | 185 | { |
186 | for (y = 0; y < water.Height; y++) | 186 | for (y = 0; y < water.Height; y++) |
187 | { | 187 | { |
188 | if (water[x, y] <= 0) | 188 | if (water[x, y] <= 0) |
189 | continue; | 189 | continue; |
190 | 190 | ||
191 | // Step 1. Calculate average of neighbours | 191 | // Step 1. Calculate average of neighbours |
192 | 192 | ||
193 | int neighbours = 0; | 193 | int neighbours = 0; |
194 | double altitudeTotal = 0.0; | 194 | double altitudeTotal = 0.0; |
195 | double altitudeMe = map[x, y] + water[x, y]; | 195 | double altitudeMe = map[x, y] + water[x, y]; |
196 | 196 | ||
197 | int NEIGHBOUR_ME = 4; | 197 | int NEIGHBOUR_ME = 4; |
198 | 198 | ||
199 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 199 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
200 | 200 | ||
201 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 201 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
202 | { | 202 | { |
203 | if (j != NEIGHBOUR_ME) | 203 | if (j != NEIGHBOUR_ME) |
204 | { | 204 | { |
205 | int[] coords = Neighbours(type, j); | 205 | int[] coords = Neighbours(type, j); |
206 | 206 | ||
207 | coords[0] += x; | 207 | coords[0] += x; |
208 | coords[1] += y; | 208 | coords[1] += y; |
209 | 209 | ||
210 | if (coords[0] > map.Width - 1) | 210 | if (coords[0] > map.Width - 1) |
211 | continue; | 211 | continue; |
212 | if (coords[1] > map.Height - 1) | 212 | if (coords[1] > map.Height - 1) |
213 | continue; | 213 | continue; |
214 | if (coords[0] < 0) | 214 | if (coords[0] < 0) |
215 | continue; | 215 | continue; |
216 | if (coords[1] < 0) | 216 | if (coords[1] < 0) |
217 | continue; | 217 | continue; |
218 | 218 | ||
219 | // Calculate total height of this neighbour | 219 | // Calculate total height of this neighbour |
220 | double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]]; | 220 | double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]]; |
221 | 221 | ||
222 | // If it's greater than me... | 222 | // If it's greater than me... |
223 | if (altitudeNeighbour - altitudeMe < 0) | 223 | if (altitudeNeighbour - altitudeMe < 0) |
224 | { | 224 | { |
225 | // Add it to our calculations | 225 | // Add it to our calculations |
226 | neighbours++; | 226 | neighbours++; |
227 | altitudeTotal += altitudeNeighbour; | 227 | altitudeTotal += altitudeNeighbour; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | if (neighbours == 0) | 232 | if (neighbours == 0) |
233 | continue; | 233 | continue; |
234 | 234 | ||
235 | double altitudeAvg = altitudeTotal / neighbours; | 235 | double altitudeAvg = altitudeTotal / neighbours; |
236 | 236 | ||
237 | // Step 2. Allocate water to neighbours. | 237 | // Step 2. Allocate water to neighbours. |
238 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 238 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
239 | { | 239 | { |
240 | if (j != NEIGHBOUR_ME) | 240 | if (j != NEIGHBOUR_ME) |
241 | { | 241 | { |
242 | int[] coords = Neighbours(type, j); | 242 | int[] coords = Neighbours(type, j); |
243 | 243 | ||
244 | coords[0] += x; | 244 | coords[0] += x; |
245 | coords[1] += y; | 245 | coords[1] += y; |
246 | 246 | ||
247 | if (coords[0] > map.Width - 1) | 247 | if (coords[0] > map.Width - 1) |
248 | continue; | 248 | continue; |
249 | if (coords[1] > map.Height - 1) | 249 | if (coords[1] > map.Height - 1) |
250 | continue; | 250 | continue; |
251 | if (coords[0] < 0) | 251 | if (coords[0] < 0) |
252 | continue; | 252 | continue; |
253 | if (coords[1] < 0) | 253 | if (coords[1] < 0) |
254 | continue; | 254 | continue; |
255 | 255 | ||
256 | // Skip if we dont have water to begin with. | 256 | // Skip if we dont have water to begin with. |
257 | if (water[x, y] < 0) | 257 | if (water[x, y] < 0) |
258 | continue; | 258 | continue; |
259 | 259 | ||
260 | // Calculate our delta average | 260 | // Calculate our delta average |
261 | double altitudeDelta = altitudeMe - altitudeAvg; | 261 | double altitudeDelta = altitudeMe - altitudeAvg; |
262 | 262 | ||
263 | if (altitudeDelta < 0) | 263 | if (altitudeDelta < 0) |
264 | continue; | 264 | continue; |
265 | 265 | ||
266 | // Calculate how much water we can move | 266 | // Calculate how much water we can move |
267 | double waterMin = Math.Min(water[x, y], altitudeDelta); | 267 | double waterMin = Math.Min(water[x, y], altitudeDelta); |
268 | double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]]) | 268 | double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]]) |
269 | / altitudeTotal); | 269 | / altitudeTotal); |
270 | 270 | ||
271 | double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]); | 271 | double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]); |
272 | 272 | ||
273 | if (sedimentDelta > 0) | 273 | if (sedimentDelta > 0) |
274 | { | 274 | { |
275 | sediment[x, y] -= sedimentDelta; | 275 | sediment[x, y] -= sedimentDelta; |
276 | sediment[coords[0], coords[1]] += sedimentDelta; | 276 | sediment[coords[0], coords[1]] += sedimentDelta; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | // Evaporate | 283 | // Evaporate |
284 | 284 | ||
285 | for (x = 0; x < water.Width; x++) | 285 | for (x = 0; x < water.Width; x++) |
286 | { | 286 | { |
287 | for (y = 0; y < water.Height; y++) | 287 | for (y = 0; y < water.Height; y++) |
288 | { | 288 | { |
289 | water[x, y] *= 1.0 - (rainHeight / rounds); | 289 | water[x, y] *= 1.0 - (rainHeight / rounds); |
290 | 290 | ||
291 | double waterCapacity = waterSaturation * water[x, y]; | 291 | double waterCapacity = waterSaturation * water[x, y]; |
292 | 292 | ||
293 | double sedimentDeposit = sediment[x, y] - waterCapacity; | 293 | double sedimentDeposit = sediment[x, y] - waterCapacity; |
294 | if (sedimentDeposit > 0) | 294 | if (sedimentDeposit > 0) |
295 | { | 295 | { |
296 | sediment[x, y] -= sedimentDeposit; | 296 | sediment[x, y] -= sedimentDeposit; |
297 | map[x, y] += sedimentDeposit; | 297 | map[x, y] += sedimentDeposit; |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | // Deposit any remainder (should be minimal) | 303 | // Deposit any remainder (should be minimal) |
304 | for (x = 0; x < water.Width; x++) | 304 | for (x = 0; x < water.Width; x++) |
305 | for (y = 0; y < water.Height; y++) | 305 | for (y = 0; y < water.Height; y++) |
306 | if (sediment[x, y] > 0) | 306 | if (sediment[x, y] > 0) |
307 | map[x, y] += sediment[x, y]; | 307 | map[x, y] += sediment[x, y]; |
308 | } | 308 | } |
309 | 309 | ||
310 | #endregion | 310 | #endregion |
311 | } | 311 | } |
312 | } \ No newline at end of file | 312 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs index d4f3b9f..dee455f 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | public class FlattenSphere : ITerrainPaintableEffect | 32 | public class FlattenSphere : ITerrainPaintableEffect |
33 | { | 33 | { |
34 | 34 | ||
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | ||
41 | int x, y; | 41 | int x, y; |
42 | double[,] tweak = new double[map.Width,map.Height]; | 42 | double[,] tweak = new double[map.Width,map.Height]; |
43 | 43 | ||
44 | double area = strength; | 44 | double area = strength; |
45 | double step = strength / 4.0; | 45 | double step = strength / 4.0; |
46 | 46 | ||
47 | double sum = 0.0; | 47 | double sum = 0.0; |
48 | double step2 = 0.0; | 48 | double step2 = 0.0; |
49 | double avg = 0.0; | 49 | double avg = 0.0; |
50 | 50 | ||
51 | // compute delta map | 51 | // compute delta map |
52 | for (x = 0; x < map.Width; x++) | 52 | for (x = 0; x < map.Width; x++) |
53 | { | 53 | { |
54 | for (y = 0; y < map.Height; y++) | 54 | for (y = 0; y < map.Height; y++) |
55 | { | 55 | { |
56 | double z = SphericalFactor(x, y, rx, ry, strength); | 56 | double z = SphericalFactor(x, y, rx, ry, strength); |
57 | 57 | ||
58 | if (z > 0) // add in non-zero amount | 58 | if (z > 0) // add in non-zero amount |
59 | { | 59 | { |
60 | sum += map[x, y] * z; | 60 | sum += map[x, y] * z; |
61 | step2 += z; | 61 | step2 += z; |
62 | } | 62 | } |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | avg = sum / step2; | 66 | avg = sum / step2; |
67 | 67 | ||
68 | // blend in map | 68 | // blend in map |
69 | for (x = 0; x < map.Width; x++) | 69 | for (x = 0; x < map.Width; x++) |
70 | { | 70 | { |
71 | for (y = 0; y < map.Height; y++) | 71 | for (y = 0; y < map.Height; y++) |
72 | { | 72 | { |
73 | double z = SphericalFactor(x, y, rx, ry, strength) * duration; | 73 | double z = SphericalFactor(x, y, rx, ry, strength) * duration; |
74 | 74 | ||
75 | if (z > 0) // add in non-zero amount | 75 | if (z > 0) // add in non-zero amount |
76 | { | 76 | { |
77 | if (z > 1.0) | 77 | if (z > 1.0) |
78 | z = 1.0; | 78 | z = 1.0; |
79 | 79 | ||
80 | map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); | 80 | map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | #endregion | 86 | #endregion |
87 | 87 | ||
88 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 88 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
89 | { | 89 | { |
90 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 90 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
91 | return z; | 91 | return z; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } \ No newline at end of file | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs index 0b80407..092bd29 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs | |||
@@ -1,67 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class LowerSphere : ITerrainPaintableEffect | 33 | public class LowerSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | ||
41 | int x, y; | 41 | int x, y; |
42 | for (x = 0; x < map.Width; x++) | 42 | for (x = 0; x < map.Width; x++) |
43 | { | 43 | { |
44 | // Skip everything unlikely to be affected | 44 | // Skip everything unlikely to be affected |
45 | if (Math.Abs(x - rx) > strength * 1.1) | 45 | if (Math.Abs(x - rx) > strength * 1.1) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | // Skip everything unlikely to be affected | 50 | // Skip everything unlikely to be affected |
51 | if (Math.Abs(y - ry) > strength * 1.1) | 51 | if (Math.Abs(y - ry) > strength * 1.1) |
52 | continue; | 52 | continue; |
53 | 53 | ||
54 | // Calculate a sphere and add it to the heighmap | 54 | // Calculate a sphere and add it to the heighmap |
55 | double z = strength; | 55 | double z = strength; |
56 | z *= z; | 56 | z *= z; |
57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
58 | 58 | ||
59 | if (z > 0.0) | 59 | if (z > 0.0) |
60 | map[x, y] -= z * duration; | 60 | map[x, y] -= z * duration; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | #endregion | 65 | #endregion |
66 | } | 66 | } |
67 | } \ No newline at end of file | 67 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs index a188e9f..8ae583e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs | |||
@@ -1,70 +1,70 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
33 | { | 33 | { |
34 | public class NoiseSphere : ITerrainPaintableEffect | 34 | public class NoiseSphere : ITerrainPaintableEffect |
35 | { | 35 | { |
36 | #region ITerrainPaintableEffect Members | 36 | #region ITerrainPaintableEffect Members |
37 | 37 | ||
38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
39 | { | 39 | { |
40 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 40 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
41 | 41 | ||
42 | int x, y; | 42 | int x, y; |
43 | for (x = 0; x < map.Width; x++) | 43 | for (x = 0; x < map.Width; x++) |
44 | { | 44 | { |
45 | // Skip everything unlikely to be affected | 45 | // Skip everything unlikely to be affected |
46 | if (Math.Abs(x - rx) > strength * 1.1) | 46 | if (Math.Abs(x - rx) > strength * 1.1) |
47 | continue; | 47 | continue; |
48 | 48 | ||
49 | for (y = 0; y < map.Height; y++) | 49 | for (y = 0; y < map.Height; y++) |
50 | { | 50 | { |
51 | // Skip everything unlikely to be affected | 51 | // Skip everything unlikely to be affected |
52 | if (Math.Abs(y - ry) > strength * 1.1) | 52 | if (Math.Abs(y - ry) > strength * 1.1) |
53 | continue; | 53 | continue; |
54 | 54 | ||
55 | // Calculate a sphere and add it to the heighmap | 55 | // Calculate a sphere and add it to the heighmap |
56 | double z = strength; | 56 | double z = strength; |
57 | z *= z; | 57 | z *= z; |
58 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 58 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
59 | 59 | ||
60 | double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0); | 60 | double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0); |
61 | 61 | ||
62 | if (z > 0.0) | 62 | if (z > 0.0) |
63 | map[x, y] += noise * z * duration; | 63 | map[x, y] += noise * z * duration; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | #endregion | 68 | #endregion |
69 | } | 69 | } |
70 | } \ No newline at end of file | 70 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs index dc56cf1..ba01a01 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs | |||
@@ -1,225 +1,225 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Speed-Optimised Hybrid Erosion Brush | 34 | /// Speed-Optimised Hybrid Erosion Brush |
35 | /// | 35 | /// |
36 | /// As per Jacob Olsen's Paper | 36 | /// As per Jacob Olsen's Paper |
37 | /// http://www.oddlabs.com/download/terrain_generation.pdf | 37 | /// http://www.oddlabs.com/download/terrain_generation.pdf |
38 | /// </summary> | 38 | /// </summary> |
39 | public class OlsenSphere : ITerrainPaintableEffect | 39 | public class OlsenSphere : ITerrainPaintableEffect |
40 | { | 40 | { |
41 | private double nConst = 1024.0; | 41 | private double nConst = 1024.0; |
42 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 42 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
43 | 43 | ||
44 | #region Supporting Functions | 44 | #region Supporting Functions |
45 | 45 | ||
46 | private int[] Neighbours(NeighbourSystem type, int index) | 46 | private int[] Neighbours(NeighbourSystem type, int index) |
47 | { | 47 | { |
48 | int[] coord = new int[2]; | 48 | int[] coord = new int[2]; |
49 | 49 | ||
50 | index++; | 50 | index++; |
51 | 51 | ||
52 | switch (type) | 52 | switch (type) |
53 | { | 53 | { |
54 | case NeighbourSystem.Moore: | 54 | case NeighbourSystem.Moore: |
55 | switch (index) | 55 | switch (index) |
56 | { | 56 | { |
57 | case 1: | 57 | case 1: |
58 | coord[0] = -1; | 58 | coord[0] = -1; |
59 | coord[1] = -1; | 59 | coord[1] = -1; |
60 | break; | 60 | break; |
61 | 61 | ||
62 | case 2: | 62 | case 2: |
63 | coord[0] = -0; | 63 | coord[0] = -0; |
64 | coord[1] = -1; | 64 | coord[1] = -1; |
65 | break; | 65 | break; |
66 | 66 | ||
67 | case 3: | 67 | case 3: |
68 | coord[0] = +1; | 68 | coord[0] = +1; |
69 | coord[1] = -1; | 69 | coord[1] = -1; |
70 | break; | 70 | break; |
71 | 71 | ||
72 | case 4: | 72 | case 4: |
73 | coord[0] = -1; | 73 | coord[0] = -1; |
74 | coord[1] = -0; | 74 | coord[1] = -0; |
75 | break; | 75 | break; |
76 | 76 | ||
77 | case 5: | 77 | case 5: |
78 | coord[0] = -0; | 78 | coord[0] = -0; |
79 | coord[1] = -0; | 79 | coord[1] = -0; |
80 | break; | 80 | break; |
81 | 81 | ||
82 | case 6: | 82 | case 6: |
83 | coord[0] = +1; | 83 | coord[0] = +1; |
84 | coord[1] = -0; | 84 | coord[1] = -0; |
85 | break; | 85 | break; |
86 | 86 | ||
87 | case 7: | 87 | case 7: |
88 | coord[0] = -1; | 88 | coord[0] = -1; |
89 | coord[1] = +1; | 89 | coord[1] = +1; |
90 | break; | 90 | break; |
91 | 91 | ||
92 | case 8: | 92 | case 8: |
93 | coord[0] = -0; | 93 | coord[0] = -0; |
94 | coord[1] = +1; | 94 | coord[1] = +1; |
95 | break; | 95 | break; |
96 | 96 | ||
97 | case 9: | 97 | case 9: |
98 | coord[0] = +1; | 98 | coord[0] = +1; |
99 | coord[1] = +1; | 99 | coord[1] = +1; |
100 | break; | 100 | break; |
101 | 101 | ||
102 | default: | 102 | default: |
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | break; | 105 | break; |
106 | 106 | ||
107 | case NeighbourSystem.VonNeumann: | 107 | case NeighbourSystem.VonNeumann: |
108 | switch (index) | 108 | switch (index) |
109 | { | 109 | { |
110 | case 1: | 110 | case 1: |
111 | coord[0] = 0; | 111 | coord[0] = 0; |
112 | coord[1] = -1; | 112 | coord[1] = -1; |
113 | break; | 113 | break; |
114 | 114 | ||
115 | case 2: | 115 | case 2: |
116 | coord[0] = -1; | 116 | coord[0] = -1; |
117 | coord[1] = 0; | 117 | coord[1] = 0; |
118 | break; | 118 | break; |
119 | 119 | ||
120 | case 3: | 120 | case 3: |
121 | coord[0] = +1; | 121 | coord[0] = +1; |
122 | coord[1] = 0; | 122 | coord[1] = 0; |
123 | break; | 123 | break; |
124 | 124 | ||
125 | case 4: | 125 | case 4: |
126 | coord[0] = 0; | 126 | coord[0] = 0; |
127 | coord[1] = +1; | 127 | coord[1] = +1; |
128 | break; | 128 | break; |
129 | 129 | ||
130 | case 5: | 130 | case 5: |
131 | coord[0] = -0; | 131 | coord[0] = -0; |
132 | coord[1] = -0; | 132 | coord[1] = -0; |
133 | break; | 133 | break; |
134 | 134 | ||
135 | default: | 135 | default: |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | break; | 138 | break; |
139 | } | 139 | } |
140 | 140 | ||
141 | return coord; | 141 | return coord; |
142 | } | 142 | } |
143 | 143 | ||
144 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 144 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
145 | { | 145 | { |
146 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 146 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
147 | return z; | 147 | return z; |
148 | } | 148 | } |
149 | 149 | ||
150 | private enum NeighbourSystem | 150 | private enum NeighbourSystem |
151 | { | 151 | { |
152 | Moore, | 152 | Moore, |
153 | VonNeumann | 153 | VonNeumann |
154 | } ; | 154 | } ; |
155 | 155 | ||
156 | #endregion | 156 | #endregion |
157 | 157 | ||
158 | #region ITerrainPaintableEffect Members | 158 | #region ITerrainPaintableEffect Members |
159 | 159 | ||
160 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 160 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
161 | { | 161 | { |
162 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 162 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
163 | 163 | ||
164 | int x, y; | 164 | int x, y; |
165 | 165 | ||
166 | for (x = 0; x < map.Width; x++) | 166 | for (x = 0; x < map.Width; x++) |
167 | { | 167 | { |
168 | for (y = 0; y < map.Height; y++) | 168 | for (y = 0; y < map.Height; y++) |
169 | { | 169 | { |
170 | double z = SphericalFactor(x, y, rx, ry, strength); | 170 | double z = SphericalFactor(x, y, rx, ry, strength); |
171 | 171 | ||
172 | if (z > 0) // add in non-zero amount | 172 | if (z > 0) // add in non-zero amount |
173 | { | 173 | { |
174 | int NEIGHBOUR_ME = 4; | 174 | int NEIGHBOUR_ME = 4; |
175 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 175 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
176 | 176 | ||
177 | double max = Double.MinValue; | 177 | double max = Double.MinValue; |
178 | int loc = 0; | 178 | int loc = 0; |
179 | double cellmax = 0; | 179 | double cellmax = 0; |
180 | 180 | ||
181 | 181 | ||
182 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 182 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
183 | { | 183 | { |
184 | if (j != NEIGHBOUR_ME) | 184 | if (j != NEIGHBOUR_ME) |
185 | { | 185 | { |
186 | int[] coords = Neighbours(type, j); | 186 | int[] coords = Neighbours(type, j); |
187 | 187 | ||
188 | coords[0] += x; | 188 | coords[0] += x; |
189 | coords[1] += y; | 189 | coords[1] += y; |
190 | 190 | ||
191 | if (coords[0] > map.Width - 1) | 191 | if (coords[0] > map.Width - 1) |
192 | continue; | 192 | continue; |
193 | if (coords[1] > map.Height - 1) | 193 | if (coords[1] > map.Height - 1) |
194 | continue; | 194 | continue; |
195 | if (coords[0] < 0) | 195 | if (coords[0] < 0) |
196 | continue; | 196 | continue; |
197 | if (coords[1] < 0) | 197 | if (coords[1] < 0) |
198 | continue; | 198 | continue; |
199 | 199 | ||
200 | cellmax = map[x, y] - map[coords[0], coords[1]]; | 200 | cellmax = map[x, y] - map[coords[0], coords[1]]; |
201 | if (cellmax > max) | 201 | if (cellmax > max) |
202 | { | 202 | { |
203 | max = cellmax; | 203 | max = cellmax; |
204 | loc = j; | 204 | loc = j; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | double T = nConst / ((map.Width + map.Height) / 2); | 209 | double T = nConst / ((map.Width + map.Height) / 2); |
210 | // Apply results | 210 | // Apply results |
211 | if (0 < max && max <= T) | 211 | if (0 < max && max <= T) |
212 | { | 212 | { |
213 | int[] maxCoords = Neighbours(type, loc); | 213 | int[] maxCoords = Neighbours(type, loc); |
214 | double heightDelta = 0.5 * max * z * duration; | 214 | double heightDelta = 0.5 * max * z * duration; |
215 | map[x, y] -= heightDelta; | 215 | map[x, y] -= heightDelta; |
216 | map[x + maxCoords[0], y + maxCoords[1]] += heightDelta; | 216 | map[x + maxCoords[0], y + maxCoords[1]] += heightDelta; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | #endregion | 223 | #endregion |
224 | } | 224 | } |
225 | } \ No newline at end of file | 225 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs index cd5a22b..5d6f093 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs | |||
@@ -1,67 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class RaiseSphere : ITerrainPaintableEffect | 33 | public class RaiseSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | ||
41 | int x, y; | 41 | int x, y; |
42 | for (x = 0; x < map.Width; x++) | 42 | for (x = 0; x < map.Width; x++) |
43 | { | 43 | { |
44 | // Skip everything unlikely to be affected | 44 | // Skip everything unlikely to be affected |
45 | if (Math.Abs(x - rx) > strength * 1.1) | 45 | if (Math.Abs(x - rx) > strength * 1.1) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | // Skip everything unlikely to be affected | 50 | // Skip everything unlikely to be affected |
51 | if (Math.Abs(y - ry) > strength * 1.1) | 51 | if (Math.Abs(y - ry) > strength * 1.1) |
52 | continue; | 52 | continue; |
53 | 53 | ||
54 | // Calculate a sphere and add it to the heighmap | 54 | // Calculate a sphere and add it to the heighmap |
55 | double z = strength; | 55 | double z = strength; |
56 | z *= z; | 56 | z *= z; |
57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
58 | 58 | ||
59 | if (z > 0.0) | 59 | if (z > 0.0) |
60 | map[x, y] += z * duration; | 60 | map[x, y] += z * duration; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | #endregion | 65 | #endregion |
66 | } | 66 | } |
67 | } \ No newline at end of file | 67 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs index 5b92cb5..b47e041 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs | |||
@@ -1,82 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class RevertSphere : ITerrainPaintableEffect | 33 | public class RevertSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | private ITerrainChannel m_revertmap; | 35 | private ITerrainChannel m_revertmap; |
36 | 36 | ||
37 | public RevertSphere(ITerrainChannel revertmap) | 37 | public RevertSphere(ITerrainChannel revertmap) |
38 | { | 38 | { |
39 | m_revertmap = revertmap; | 39 | m_revertmap = revertmap; |
40 | } | 40 | } |
41 | 41 | ||
42 | #region ITerrainPaintableEffect Members | 42 | #region ITerrainPaintableEffect Members |
43 | 43 | ||
44 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 44 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
45 | { | 45 | { |
46 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 46 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
47 | 47 | ||
48 | if (duration > 1.0) | 48 | if (duration > 1.0) |
49 | duration = 1.0; | 49 | duration = 1.0; |
50 | if (duration < 0) | 50 | if (duration < 0) |
51 | return; | 51 | return; |
52 | 52 | ||
53 | int x, y; | 53 | int x, y; |
54 | for (x = 0; x < map.Width; x++) | 54 | for (x = 0; x < map.Width; x++) |
55 | { | 55 | { |
56 | // Skip everything unlikely to be affected | 56 | // Skip everything unlikely to be affected |
57 | if (Math.Abs(x - rx) > strength * 1.1) | 57 | if (Math.Abs(x - rx) > strength * 1.1) |
58 | continue; | 58 | continue; |
59 | 59 | ||
60 | for (y = 0; y < map.Height; y++) | 60 | for (y = 0; y < map.Height; y++) |
61 | { | 61 | { |
62 | // Skip everything unlikely to be affected | 62 | // Skip everything unlikely to be affected |
63 | if (Math.Abs(y - ry) > strength * 1.1) | 63 | if (Math.Abs(y - ry) > strength * 1.1) |
64 | continue; | 64 | continue; |
65 | 65 | ||
66 | // Calculate a sphere and add it to the heighmap | 66 | // Calculate a sphere and add it to the heighmap |
67 | double z = strength; | 67 | double z = strength; |
68 | z *= z; | 68 | z *= z; |
69 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 69 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
70 | 70 | ||
71 | if (z > 0.0) | 71 | if (z > 0.0) |
72 | { | 72 | { |
73 | z *= duration; | 73 | z *= duration; |
74 | map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); | 74 | map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | #endregion | 80 | #endregion |
81 | } | 81 | } |
82 | } \ No newline at end of file | 82 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs index 305a875..51d5f0e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs | |||
@@ -1,93 +1,93 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | public class SmoothSphere : ITerrainPaintableEffect | 32 | public class SmoothSphere : ITerrainPaintableEffect |
33 | { | 33 | { |
34 | #region ITerrainPaintableEffect Members | 34 | #region ITerrainPaintableEffect Members |
35 | 35 | ||
36 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 36 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
37 | { | 37 | { |
38 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 38 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
39 | 39 | ||
40 | int x, y; | 40 | int x, y; |
41 | double[,] tweak = new double[map.Width,map.Height]; | 41 | double[,] tweak = new double[map.Width,map.Height]; |
42 | 42 | ||
43 | double n, l; | 43 | double n, l; |
44 | double area = strength; | 44 | double area = strength; |
45 | double step = strength / 4.0; | 45 | double step = strength / 4.0; |
46 | 46 | ||
47 | // compute delta map | 47 | // compute delta map |
48 | for (x = 0; x < map.Width; x++) | 48 | for (x = 0; x < map.Width; x++) |
49 | { | 49 | { |
50 | for (y = 0; y < map.Height; y++) | 50 | for (y = 0; y < map.Height; y++) |
51 | { | 51 | { |
52 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 52 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
53 | 53 | ||
54 | if (z > 0) // add in non-zero amount | 54 | if (z > 0) // add in non-zero amount |
55 | { | 55 | { |
56 | double average = 0.0; | 56 | double average = 0.0; |
57 | int avgsteps = 0; | 57 | int avgsteps = 0; |
58 | 58 | ||
59 | for (n = 0.0 - area; n < area; n += step) | 59 | for (n = 0.0 - area; n < area; n += step) |
60 | { | 60 | { |
61 | for (l = 0.0 - area; l < area; l += step) | 61 | for (l = 0.0 - area; l < area; l += step) |
62 | { | 62 | { |
63 | avgsteps++; | 63 | avgsteps++; |
64 | average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); | 64 | average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | tweak[x, y] = average / avgsteps; | 67 | tweak[x, y] = average / avgsteps; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | // blend in map | 71 | // blend in map |
72 | for (x = 0; x < map.Width; x++) | 72 | for (x = 0; x < map.Width; x++) |
73 | { | 73 | { |
74 | for (y = 0; y < map.Height; y++) | 74 | for (y = 0; y < map.Height; y++) |
75 | { | 75 | { |
76 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 76 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
77 | 77 | ||
78 | if (z > 0) // add in non-zero amount | 78 | if (z > 0) // add in non-zero amount |
79 | { | 79 | { |
80 | double da = z; | 80 | double da = z; |
81 | double a = (map[x, y] - tweak[x, y]) * da; | 81 | double a = (map[x, y] - tweak[x, y]) * da; |
82 | double newz = map[x, y] - (a * duration); | 82 | double newz = map[x, y] - (a * duration); |
83 | 83 | ||
84 | if (newz > 0.0) | 84 | if (newz > 0.0) |
85 | map[x, y] = newz; | 85 | map[x, y] = newz; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | #endregion | 91 | #endregion |
92 | } | 92 | } |
93 | } \ No newline at end of file | 93 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs index 2d81054..b48beb8 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs | |||
@@ -1,207 +1,207 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Thermal Weathering Paint Brush | 33 | /// Thermal Weathering Paint Brush |
34 | /// </summary> | 34 | /// </summary> |
35 | public class WeatherSphere : ITerrainPaintableEffect | 35 | public class WeatherSphere : ITerrainPaintableEffect |
36 | { | 36 | { |
37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. | 37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. |
38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
39 | 39 | ||
40 | #region Supporting Functions | 40 | #region Supporting Functions |
41 | 41 | ||
42 | private int[] Neighbours(NeighbourSystem type, int index) | 42 | private int[] Neighbours(NeighbourSystem type, int index) |
43 | { | 43 | { |
44 | int[] coord = new int[2]; | 44 | int[] coord = new int[2]; |
45 | 45 | ||
46 | index++; | 46 | index++; |
47 | 47 | ||
48 | switch (type) | 48 | switch (type) |
49 | { | 49 | { |
50 | case NeighbourSystem.Moore: | 50 | case NeighbourSystem.Moore: |
51 | switch (index) | 51 | switch (index) |
52 | { | 52 | { |
53 | case 1: | 53 | case 1: |
54 | coord[0] = -1; | 54 | coord[0] = -1; |
55 | coord[1] = -1; | 55 | coord[1] = -1; |
56 | break; | 56 | break; |
57 | 57 | ||
58 | case 2: | 58 | case 2: |
59 | coord[0] = -0; | 59 | coord[0] = -0; |
60 | coord[1] = -1; | 60 | coord[1] = -1; |
61 | break; | 61 | break; |
62 | 62 | ||
63 | case 3: | 63 | case 3: |
64 | coord[0] = +1; | 64 | coord[0] = +1; |
65 | coord[1] = -1; | 65 | coord[1] = -1; |
66 | break; | 66 | break; |
67 | 67 | ||
68 | case 4: | 68 | case 4: |
69 | coord[0] = -1; | 69 | coord[0] = -1; |
70 | coord[1] = -0; | 70 | coord[1] = -0; |
71 | break; | 71 | break; |
72 | 72 | ||
73 | case 5: | 73 | case 5: |
74 | coord[0] = -0; | 74 | coord[0] = -0; |
75 | coord[1] = -0; | 75 | coord[1] = -0; |
76 | break; | 76 | break; |
77 | 77 | ||
78 | case 6: | 78 | case 6: |
79 | coord[0] = +1; | 79 | coord[0] = +1; |
80 | coord[1] = -0; | 80 | coord[1] = -0; |
81 | break; | 81 | break; |
82 | 82 | ||
83 | case 7: | 83 | case 7: |
84 | coord[0] = -1; | 84 | coord[0] = -1; |
85 | coord[1] = +1; | 85 | coord[1] = +1; |
86 | break; | 86 | break; |
87 | 87 | ||
88 | case 8: | 88 | case 8: |
89 | coord[0] = -0; | 89 | coord[0] = -0; |
90 | coord[1] = +1; | 90 | coord[1] = +1; |
91 | break; | 91 | break; |
92 | 92 | ||
93 | case 9: | 93 | case 9: |
94 | coord[0] = +1; | 94 | coord[0] = +1; |
95 | coord[1] = +1; | 95 | coord[1] = +1; |
96 | break; | 96 | break; |
97 | 97 | ||
98 | default: | 98 | default: |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | break; | 101 | break; |
102 | 102 | ||
103 | case NeighbourSystem.VonNeumann: | 103 | case NeighbourSystem.VonNeumann: |
104 | switch (index) | 104 | switch (index) |
105 | { | 105 | { |
106 | case 1: | 106 | case 1: |
107 | coord[0] = 0; | 107 | coord[0] = 0; |
108 | coord[1] = -1; | 108 | coord[1] = -1; |
109 | break; | 109 | break; |
110 | 110 | ||
111 | case 2: | 111 | case 2: |
112 | coord[0] = -1; | 112 | coord[0] = -1; |
113 | coord[1] = 0; | 113 | coord[1] = 0; |
114 | break; | 114 | break; |
115 | 115 | ||
116 | case 3: | 116 | case 3: |
117 | coord[0] = +1; | 117 | coord[0] = +1; |
118 | coord[1] = 0; | 118 | coord[1] = 0; |
119 | break; | 119 | break; |
120 | 120 | ||
121 | case 4: | 121 | case 4: |
122 | coord[0] = 0; | 122 | coord[0] = 0; |
123 | coord[1] = +1; | 123 | coord[1] = +1; |
124 | break; | 124 | break; |
125 | 125 | ||
126 | case 5: | 126 | case 5: |
127 | coord[0] = -0; | 127 | coord[0] = -0; |
128 | coord[1] = -0; | 128 | coord[1] = -0; |
129 | break; | 129 | break; |
130 | 130 | ||
131 | default: | 131 | default: |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | 136 | ||
137 | return coord; | 137 | return coord; |
138 | } | 138 | } |
139 | 139 | ||
140 | private enum NeighbourSystem | 140 | private enum NeighbourSystem |
141 | { | 141 | { |
142 | Moore, | 142 | Moore, |
143 | VonNeumann | 143 | VonNeumann |
144 | } ; | 144 | } ; |
145 | 145 | ||
146 | #endregion | 146 | #endregion |
147 | 147 | ||
148 | #region ITerrainPaintableEffect Members | 148 | #region ITerrainPaintableEffect Members |
149 | 149 | ||
150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
151 | { | 151 | { |
152 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 152 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
153 | 153 | ||
154 | int x, y; | 154 | int x, y; |
155 | 155 | ||
156 | for (x = 0; x < map.Width; x++) | 156 | for (x = 0; x < map.Width; x++) |
157 | { | 157 | { |
158 | for (y = 0; y < map.Height; y++) | 158 | for (y = 0; y < map.Height; y++) |
159 | { | 159 | { |
160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
161 | 161 | ||
162 | if (z > 0) // add in non-zero amount | 162 | if (z > 0) // add in non-zero amount |
163 | { | 163 | { |
164 | int NEIGHBOUR_ME = 4; | 164 | int NEIGHBOUR_ME = 4; |
165 | 165 | ||
166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
167 | 167 | ||
168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
169 | { | 169 | { |
170 | if (j != NEIGHBOUR_ME) | 170 | if (j != NEIGHBOUR_ME) |
171 | { | 171 | { |
172 | int[] coords = Neighbours(type, j); | 172 | int[] coords = Neighbours(type, j); |
173 | 173 | ||
174 | coords[0] += x; | 174 | coords[0] += x; |
175 | coords[1] += y; | 175 | coords[1] += y; |
176 | 176 | ||
177 | if (coords[0] > map.Width - 1) | 177 | if (coords[0] > map.Width - 1) |
178 | continue; | 178 | continue; |
179 | if (coords[1] > map.Height - 1) | 179 | if (coords[1] > map.Height - 1) |
180 | continue; | 180 | continue; |
181 | if (coords[0] < 0) | 181 | if (coords[0] < 0) |
182 | continue; | 182 | continue; |
183 | if (coords[1] < 0) | 183 | if (coords[1] < 0) |
184 | continue; | 184 | continue; |
185 | 185 | ||
186 | double heightF = map[x, y]; | 186 | double heightF = map[x, y]; |
187 | double target = map[coords[0], coords[1]]; | 187 | double target = map[coords[0], coords[1]]; |
188 | 188 | ||
189 | if (target > heightF + talus) | 189 | if (target > heightF + talus) |
190 | { | 190 | { |
191 | double calc = duration * ((target - heightF) - talus) * z; | 191 | double calc = duration * ((target - heightF) - talus) * z; |
192 | heightF += calc; | 192 | heightF += calc; |
193 | target -= calc; | 193 | target -= calc; |
194 | } | 194 | } |
195 | 195 | ||
196 | map[x, y] = heightF; | 196 | map[x, y] = heightF; |
197 | map[coords[0], coords[1]] = target; | 197 | map[coords[0], coords[1]] = target; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | #endregion | 205 | #endregion |
206 | } | 206 | } |
207 | } \ No newline at end of file | 207 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs index e2df885..4f7d20c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs | |||
@@ -1,157 +1,157 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using OpenSim.Framework; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// A new version of the old Channel class, simplified | 34 | /// A new version of the old Channel class, simplified |
35 | /// </summary> | 35 | /// </summary> |
36 | public class TerrainChannel : ITerrainChannel | 36 | public class TerrainChannel : ITerrainChannel |
37 | { | 37 | { |
38 | private readonly bool[,] taint; | 38 | private readonly bool[,] taint; |
39 | private double[,] map; | 39 | private double[,] map; |
40 | 40 | ||
41 | public TerrainChannel() | 41 | public TerrainChannel() |
42 | { | 42 | { |
43 | map = new double[Constants.RegionSize,Constants.RegionSize]; | 43 | map = new double[Constants.RegionSize,Constants.RegionSize]; |
44 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | 44 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; |
45 | 45 | ||
46 | int x; | 46 | int x; |
47 | for (x = 0; x < Constants.RegionSize; x++) | 47 | for (x = 0; x < Constants.RegionSize; x++) |
48 | { | 48 | { |
49 | int y; | 49 | int y; |
50 | for (y = 0; y < Constants.RegionSize; y++) | 50 | for (y = 0; y < Constants.RegionSize; y++) |
51 | { | 51 | { |
52 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; | 52 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; |
53 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; | 53 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; |
54 | if (map[x, y] < spherFac) | 54 | if (map[x, y] < spherFac) |
55 | { | 55 | { |
56 | map[x, y] = spherFac; | 56 | map[x, y] = spherFac; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | public TerrainChannel(double[,] import) | 62 | public TerrainChannel(double[,] import) |
63 | { | 63 | { |
64 | map = import; | 64 | map = import; |
65 | taint = new bool[import.GetLength(0),import.GetLength(1)]; | 65 | taint = new bool[import.GetLength(0),import.GetLength(1)]; |
66 | } | 66 | } |
67 | 67 | ||
68 | public TerrainChannel(bool createMap) | 68 | public TerrainChannel(bool createMap) |
69 | { | 69 | { |
70 | if (createMap) | 70 | if (createMap) |
71 | { | 71 | { |
72 | map = new double[Constants.RegionSize,Constants.RegionSize]; | 72 | map = new double[Constants.RegionSize,Constants.RegionSize]; |
73 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | 73 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | public TerrainChannel(int w, int h) | 77 | public TerrainChannel(int w, int h) |
78 | { | 78 | { |
79 | map = new double[w,h]; | 79 | map = new double[w,h]; |
80 | taint = new bool[w / 16,h / 16]; | 80 | taint = new bool[w / 16,h / 16]; |
81 | } | 81 | } |
82 | 82 | ||
83 | #region ITerrainChannel Members | 83 | #region ITerrainChannel Members |
84 | 84 | ||
85 | public int Width | 85 | public int Width |
86 | { | 86 | { |
87 | get { return map.GetLength(0); } | 87 | get { return map.GetLength(0); } |
88 | } | 88 | } |
89 | 89 | ||
90 | public int Height | 90 | public int Height |
91 | { | 91 | { |
92 | get { return map.GetLength(1); } | 92 | get { return map.GetLength(1); } |
93 | } | 93 | } |
94 | 94 | ||
95 | public ITerrainChannel MakeCopy() | 95 | public ITerrainChannel MakeCopy() |
96 | { | 96 | { |
97 | TerrainChannel copy = new TerrainChannel(false); | 97 | TerrainChannel copy = new TerrainChannel(false); |
98 | copy.map = (double[,]) map.Clone(); | 98 | copy.map = (double[,]) map.Clone(); |
99 | 99 | ||
100 | return copy; | 100 | return copy; |
101 | } | 101 | } |
102 | 102 | ||
103 | public float[] GetFloatsSerialised() | 103 | public float[] GetFloatsSerialised() |
104 | { | 104 | { |
105 | float[] heights = new float[Width * Height]; | 105 | float[] heights = new float[Width * Height]; |
106 | int i; | 106 | int i; |
107 | 107 | ||
108 | for (i = 0; i < Width * Height; i++) | 108 | for (i = 0; i < Width * Height; i++) |
109 | { | 109 | { |
110 | heights[i] = (float) map[i % Width, i / Width]; | 110 | heights[i] = (float) map[i % Width, i / Width]; |
111 | } | 111 | } |
112 | 112 | ||
113 | return heights; | 113 | return heights; |
114 | } | 114 | } |
115 | 115 | ||
116 | public double[,] GetDoubles() | 116 | public double[,] GetDoubles() |
117 | { | 117 | { |
118 | return map; | 118 | return map; |
119 | } | 119 | } |
120 | 120 | ||
121 | public double this[int x, int y] | 121 | public double this[int x, int y] |
122 | { | 122 | { |
123 | get { return map[x, y]; } | 123 | get { return map[x, y]; } |
124 | set | 124 | set |
125 | { | 125 | { |
126 | if (map[x, y] != value) | 126 | if (map[x, y] != value) |
127 | { | 127 | { |
128 | taint[x / 16, y / 16] = true; | 128 | taint[x / 16, y / 16] = true; |
129 | map[x, y] = value; | 129 | map[x, y] = value; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | public bool Tainted(int x, int y) | 134 | public bool Tainted(int x, int y) |
135 | { | 135 | { |
136 | if (taint[x / 16, y / 16]) | 136 | if (taint[x / 16, y / 16]) |
137 | { | 137 | { |
138 | taint[x / 16, y / 16] = false; | 138 | taint[x / 16, y / 16] = false; |
139 | return true; | 139 | return true; |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | { |
143 | return false; | 143 | return false; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | #endregion | 147 | #endregion |
148 | 148 | ||
149 | public TerrainChannel Copy() | 149 | public TerrainChannel Copy() |
150 | { | 150 | { |
151 | TerrainChannel copy = new TerrainChannel(false); | 151 | TerrainChannel copy = new TerrainChannel(false); |
152 | copy.map = (double[,]) map.Clone(); | 152 | copy.map = (double[,]) map.Clone(); |
153 | 153 | ||
154 | return copy; | 154 | return copy; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } \ No newline at end of file | 157 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs index 1095cb9..f5c0fe4 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs | |||
@@ -1,46 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public class TerrainException : Exception | 32 | public class TerrainException : Exception |
33 | { | 33 | { |
34 | public TerrainException() : base() | 34 | public TerrainException() : base() |
35 | { | 35 | { |
36 | } | 36 | } |
37 | 37 | ||
38 | public TerrainException(string msg) : base(msg) | 38 | public TerrainException(string msg) : base(msg) |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | public TerrainException(string msg, Exception e) : base(msg, e) | 42 | public TerrainException(string msg, Exception e) : base(msg, e) |
43 | { | 43 | { |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } \ No newline at end of file | 46 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index 09c3117..eff6159 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs | |||
@@ -1,736 +1,736 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using log4net; | 33 | using log4net; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Environment.Interfaces; | 36 | using OpenSim.Region.Environment.Interfaces; |
37 | using OpenSim.Region.Environment.Modules.Framework; | 37 | using OpenSim.Region.Environment.Modules.Framework; |
38 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | 38 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; |
39 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; | 39 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; |
40 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 40 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
41 | using OpenSim.Region.Environment.Scenes; | 41 | using OpenSim.Region.Environment.Scenes; |
42 | 42 | ||
43 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 43 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
44 | { | 44 | { |
45 | public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule | 45 | public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule |
46 | { | 46 | { |
47 | #region StandardTerrainEffects enum | 47 | #region StandardTerrainEffects enum |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// A standard set of terrain brushes and effects recognised by viewers | 50 | /// A standard set of terrain brushes and effects recognised by viewers |
51 | /// </summary> | 51 | /// </summary> |
52 | public enum StandardTerrainEffects : byte | 52 | public enum StandardTerrainEffects : byte |
53 | { | 53 | { |
54 | Flatten = 0, | 54 | Flatten = 0, |
55 | Raise = 1, | 55 | Raise = 1, |
56 | Lower = 2, | 56 | Lower = 2, |
57 | Smooth = 3, | 57 | Smooth = 3, |
58 | Noise = 4, | 58 | Noise = 4, |
59 | Revert = 5, | 59 | Revert = 5, |
60 | 60 | ||
61 | // Extended brushes | 61 | // Extended brushes |
62 | Erode = 255, | 62 | Erode = 255, |
63 | Weather = 254, | 63 | Weather = 254, |
64 | Olsen = 253 | 64 | Olsen = 253 |
65 | } | 65 | } |
66 | 66 | ||
67 | #endregion | 67 | #endregion |
68 | 68 | ||
69 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 69 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
70 | 70 | ||
71 | private readonly Commander m_commander = new Commander("Terrain"); | 71 | private readonly Commander m_commander = new Commander("Terrain"); |
72 | 72 | ||
73 | private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects = | 73 | private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects = |
74 | new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>(); | 74 | new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>(); |
75 | 75 | ||
76 | private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); | 76 | private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); |
77 | 77 | ||
78 | private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = | 78 | private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = |
79 | new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); | 79 | new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); |
80 | 80 | ||
81 | private ITerrainChannel m_channel; | 81 | private ITerrainChannel m_channel; |
82 | private Dictionary<Location, ITerrainChannel> m_channels; | 82 | private Dictionary<Location, ITerrainChannel> m_channels; |
83 | private Dictionary<string, ITerrainEffect> m_plugineffects; | 83 | private Dictionary<string, ITerrainEffect> m_plugineffects; |
84 | private ITerrainChannel m_revert; | 84 | private ITerrainChannel m_revert; |
85 | private Scene m_scene; | 85 | private Scene m_scene; |
86 | private bool m_tainted = false; | 86 | private bool m_tainted = false; |
87 | 87 | ||
88 | #region ICommandableModule Members | 88 | #region ICommandableModule Members |
89 | 89 | ||
90 | public ICommander CommandInterface | 90 | public ICommander CommandInterface |
91 | { | 91 | { |
92 | get { return m_commander; } | 92 | get { return m_commander; } |
93 | } | 93 | } |
94 | 94 | ||
95 | #endregion | 95 | #endregion |
96 | 96 | ||
97 | #region IRegionModule Members | 97 | #region IRegionModule Members |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// Creates and initialises a terrain module for a region | 100 | /// Creates and initialises a terrain module for a region |
101 | /// </summary> | 101 | /// </summary> |
102 | /// <param name="scene">Region initialising</param> | 102 | /// <param name="scene">Region initialising</param> |
103 | /// <param name="config">Config for the region</param> | 103 | /// <param name="config">Config for the region</param> |
104 | public void Initialise(Scene scene, IConfigSource config) | 104 | public void Initialise(Scene scene, IConfigSource config) |
105 | { | 105 | { |
106 | m_scene = scene; | 106 | m_scene = scene; |
107 | 107 | ||
108 | // Install terrain module in the simulator | 108 | // Install terrain module in the simulator |
109 | if (m_scene.Heightmap == null) | 109 | if (m_scene.Heightmap == null) |
110 | { | 110 | { |
111 | lock (m_scene) | 111 | lock (m_scene) |
112 | { | 112 | { |
113 | m_channel = new TerrainChannel(); | 113 | m_channel = new TerrainChannel(); |
114 | m_scene.Heightmap = m_channel; | 114 | m_scene.Heightmap = m_channel; |
115 | m_revert = new TerrainChannel(); | 115 | m_revert = new TerrainChannel(); |
116 | UpdateRevertMap(); | 116 | UpdateRevertMap(); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | else | 119 | else |
120 | { | 120 | { |
121 | m_channel = m_scene.Heightmap; | 121 | m_channel = m_scene.Heightmap; |
122 | m_revert = new TerrainChannel(); | 122 | m_revert = new TerrainChannel(); |
123 | UpdateRevertMap(); | 123 | UpdateRevertMap(); |
124 | } | 124 | } |
125 | 125 | ||
126 | m_scene.RegisterModuleInterface<ITerrainModule>(this); | 126 | m_scene.RegisterModuleInterface<ITerrainModule>(this); |
127 | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; | 127 | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; |
128 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 128 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
129 | m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; | 129 | m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; |
130 | } | 130 | } |
131 | 131 | ||
132 | /// <summary> | 132 | /// <summary> |
133 | /// Enables terrain module when called | 133 | /// Enables terrain module when called |
134 | /// </summary> | 134 | /// </summary> |
135 | public void PostInitialise() | 135 | public void PostInitialise() |
136 | { | 136 | { |
137 | InstallDefaultEffects(); | 137 | InstallDefaultEffects(); |
138 | InstallInterfaces(); | 138 | InstallInterfaces(); |
139 | LoadPlugins(); | 139 | LoadPlugins(); |
140 | } | 140 | } |
141 | 141 | ||
142 | public void Close() | 142 | public void Close() |
143 | { | 143 | { |
144 | } | 144 | } |
145 | 145 | ||
146 | public string Name | 146 | public string Name |
147 | { | 147 | { |
148 | get { return "TerrainModule"; } | 148 | get { return "TerrainModule"; } |
149 | } | 149 | } |
150 | 150 | ||
151 | public bool IsSharedModule | 151 | public bool IsSharedModule |
152 | { | 152 | { |
153 | get { return false; } | 153 | get { return false; } |
154 | } | 154 | } |
155 | 155 | ||
156 | #endregion | 156 | #endregion |
157 | 157 | ||
158 | #region ITerrainModule Members | 158 | #region ITerrainModule Members |
159 | 159 | ||
160 | /// <summary> | 160 | /// <summary> |
161 | /// Loads a terrain file from disk and installs it in the scene. | 161 | /// Loads a terrain file from disk and installs it in the scene. |
162 | /// </summary> | 162 | /// </summary> |
163 | /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> | 163 | /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> |
164 | public void LoadFromFile(string filename) | 164 | public void LoadFromFile(string filename) |
165 | { | 165 | { |
166 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 166 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
167 | { | 167 | { |
168 | if (filename.EndsWith(loader.Key)) | 168 | if (filename.EndsWith(loader.Key)) |
169 | { | 169 | { |
170 | lock (m_scene) | 170 | lock (m_scene) |
171 | { | 171 | { |
172 | try | 172 | try |
173 | { | 173 | { |
174 | ITerrainChannel channel = loader.Value.LoadFile(filename); | 174 | ITerrainChannel channel = loader.Value.LoadFile(filename); |
175 | m_scene.Heightmap = channel; | 175 | m_scene.Heightmap = channel; |
176 | m_channel = channel; | 176 | m_channel = channel; |
177 | UpdateRevertMap(); | 177 | UpdateRevertMap(); |
178 | } | 178 | } |
179 | catch (NotImplementedException) | 179 | catch (NotImplementedException) |
180 | { | 180 | { |
181 | m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value + | 181 | m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value + |
182 | " parser does not support file loading. (May be save only)"); | 182 | " parser does not support file loading. (May be save only)"); |
183 | throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); | 183 | throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); |
184 | } | 184 | } |
185 | catch (FileNotFoundException) | 185 | catch (FileNotFoundException) |
186 | { | 186 | { |
187 | m_log.Error( | 187 | m_log.Error( |
188 | "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)"); | 188 | "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)"); |
189 | throw new TerrainException( | 189 | throw new TerrainException( |
190 | String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename)); | 190 | String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename)); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | CheckForTerrainUpdates(); | 193 | CheckForTerrainUpdates(); |
194 | m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); | 194 | m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format."); | 198 | m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format."); |
199 | throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); | 199 | throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); |
200 | } | 200 | } |
201 | 201 | ||
202 | /// <summary> | 202 | /// <summary> |
203 | /// Saves the current heightmap to a specified file. | 203 | /// Saves the current heightmap to a specified file. |
204 | /// </summary> | 204 | /// </summary> |
205 | /// <param name="filename">The destination filename</param> | 205 | /// <param name="filename">The destination filename</param> |
206 | public void SaveToFile(string filename) | 206 | public void SaveToFile(string filename) |
207 | { | 207 | { |
208 | try | 208 | try |
209 | { | 209 | { |
210 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 210 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
211 | { | 211 | { |
212 | if (filename.EndsWith(loader.Key)) | 212 | if (filename.EndsWith(loader.Key)) |
213 | { | 213 | { |
214 | loader.Value.SaveFile(filename, m_channel); | 214 | loader.Value.SaveFile(filename, m_channel); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | catch (NotImplementedException) | 219 | catch (NotImplementedException) |
220 | { | 220 | { |
221 | m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented."); | 221 | m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented."); |
222 | throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented")); | 222 | throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented")); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | #region Plugin Loading Methods | 226 | #region Plugin Loading Methods |
227 | 227 | ||
228 | private void LoadPlugins() | 228 | private void LoadPlugins() |
229 | { | 229 | { |
230 | m_plugineffects = new Dictionary<string, ITerrainEffect>(); | 230 | m_plugineffects = new Dictionary<string, ITerrainEffect>(); |
231 | // Load the files in the Terrain/ dir | 231 | // Load the files in the Terrain/ dir |
232 | string[] files = Directory.GetFiles("Terrain"); | 232 | string[] files = Directory.GetFiles("Terrain"); |
233 | foreach (string file in files) | 233 | foreach (string file in files) |
234 | { | 234 | { |
235 | m_log.Info("Loading effects in " + file); | 235 | m_log.Info("Loading effects in " + file); |
236 | try | 236 | try |
237 | { | 237 | { |
238 | Assembly library = Assembly.LoadFrom(file); | 238 | Assembly library = Assembly.LoadFrom(file); |
239 | foreach (Type pluginType in library.GetTypes()) | 239 | foreach (Type pluginType in library.GetTypes()) |
240 | { | 240 | { |
241 | try | 241 | try |
242 | { | 242 | { |
243 | if (pluginType.IsAbstract || pluginType.IsNotPublic) | 243 | if (pluginType.IsAbstract || pluginType.IsNotPublic) |
244 | continue; | 244 | continue; |
245 | 245 | ||
246 | if (pluginType.GetInterface("ITerrainEffect", false) != null) | 246 | if (pluginType.GetInterface("ITerrainEffect", false) != null) |
247 | { | 247 | { |
248 | ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString())); | 248 | ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString())); |
249 | if (!m_plugineffects.ContainsKey(pluginType.Name)) | 249 | if (!m_plugineffects.ContainsKey(pluginType.Name)) |
250 | { | 250 | { |
251 | m_plugineffects.Add(pluginType.Name, terEffect); | 251 | m_plugineffects.Add(pluginType.Name, terEffect); |
252 | m_log.Info("E ... " + pluginType.Name); | 252 | m_log.Info("E ... " + pluginType.Name); |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | m_log.Warn("E ... " + pluginType.Name + " (Already added)"); | 256 | m_log.Warn("E ... " + pluginType.Name + " (Already added)"); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | else if (pluginType.GetInterface("ITerrainLoader", false) != null) | 259 | else if (pluginType.GetInterface("ITerrainLoader", false) != null) |
260 | { | 260 | { |
261 | ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString())); | 261 | ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString())); |
262 | m_loaders[terLoader.FileExtension] = terLoader; | 262 | m_loaders[terLoader.FileExtension] = terLoader; |
263 | m_log.Info("L ... " + pluginType.Name); | 263 | m_log.Info("L ... " + pluginType.Name); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | catch (AmbiguousMatchException) | 266 | catch (AmbiguousMatchException) |
267 | { | 267 | { |
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | catch (BadImageFormatException) | 271 | catch (BadImageFormatException) |
272 | { | 272 | { |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | #endregion | 277 | #endregion |
278 | 278 | ||
279 | #endregion | 279 | #endregion |
280 | 280 | ||
281 | /// <summary> | 281 | /// <summary> |
282 | /// Installs into terrain module the standard suite of brushes | 282 | /// Installs into terrain module the standard suite of brushes |
283 | /// </summary> | 283 | /// </summary> |
284 | private void InstallDefaultEffects() | 284 | private void InstallDefaultEffects() |
285 | { | 285 | { |
286 | // Draggable Paint Brush Effects | 286 | // Draggable Paint Brush Effects |
287 | m_painteffects[StandardTerrainEffects.Raise] = new RaiseSphere(); | 287 | m_painteffects[StandardTerrainEffects.Raise] = new RaiseSphere(); |
288 | m_painteffects[StandardTerrainEffects.Lower] = new LowerSphere(); | 288 | m_painteffects[StandardTerrainEffects.Lower] = new LowerSphere(); |
289 | m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere(); | 289 | m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere(); |
290 | m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); | 290 | m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); |
291 | m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); | 291 | m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); |
292 | m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert); | 292 | m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert); |
293 | m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere(); | 293 | m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere(); |
294 | m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere(); | 294 | m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere(); |
295 | m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere(); | 295 | m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere(); |
296 | 296 | ||
297 | // Area of effect selection effects | 297 | // Area of effect selection effects |
298 | m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea(); | 298 | m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea(); |
299 | m_floodeffects[StandardTerrainEffects.Lower] = new LowerArea(); | 299 | m_floodeffects[StandardTerrainEffects.Lower] = new LowerArea(); |
300 | m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea(); | 300 | m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea(); |
301 | m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea(); | 301 | m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea(); |
302 | m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea(); | 302 | m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea(); |
303 | m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert); | 303 | m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert); |
304 | 304 | ||
305 | // Filesystem load/save loaders | 305 | // Filesystem load/save loaders |
306 | m_loaders[".r32"] = new RAW32(); | 306 | m_loaders[".r32"] = new RAW32(); |
307 | m_loaders[".f32"] = m_loaders[".r32"]; | 307 | m_loaders[".f32"] = m_loaders[".r32"]; |
308 | m_loaders[".ter"] = new Terragen(); | 308 | m_loaders[".ter"] = new Terragen(); |
309 | m_loaders[".raw"] = new LLRAW(); | 309 | m_loaders[".raw"] = new LLRAW(); |
310 | m_loaders[".jpg"] = new JPEG(); | 310 | m_loaders[".jpg"] = new JPEG(); |
311 | m_loaders[".jpeg"] = m_loaders[".jpg"]; | 311 | m_loaders[".jpeg"] = m_loaders[".jpg"]; |
312 | m_loaders[".bmp"] = new BMP(); | 312 | m_loaders[".bmp"] = new BMP(); |
313 | m_loaders[".png"] = new PNG(); | 313 | m_loaders[".png"] = new PNG(); |
314 | m_loaders[".gif"] = new GIF(); | 314 | m_loaders[".gif"] = new GIF(); |
315 | m_loaders[".tif"] = new TIFF(); | 315 | m_loaders[".tif"] = new TIFF(); |
316 | m_loaders[".tiff"] = m_loaders[".tif"]; | 316 | m_loaders[".tiff"] = m_loaders[".tif"]; |
317 | } | 317 | } |
318 | 318 | ||
319 | /// <summary> | 319 | /// <summary> |
320 | /// Saves the current state of the region into the revert map buffer. | 320 | /// Saves the current state of the region into the revert map buffer. |
321 | /// </summary> | 321 | /// </summary> |
322 | public void UpdateRevertMap() | 322 | public void UpdateRevertMap() |
323 | { | 323 | { |
324 | int x; | 324 | int x; |
325 | for (x = 0; x < m_channel.Width; x++) | 325 | for (x = 0; x < m_channel.Width; x++) |
326 | { | 326 | { |
327 | int y; | 327 | int y; |
328 | for (y = 0; y < m_channel.Height; y++) | 328 | for (y = 0; y < m_channel.Height; y++) |
329 | { | 329 | { |
330 | m_revert[x, y] = m_channel[x, y]; | 330 | m_revert[x, y] = m_channel[x, y]; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | /// <summary> | 335 | /// <summary> |
336 | /// Loads a tile from a larger terrain file and installs it into the region. | 336 | /// Loads a tile from a larger terrain file and installs it into the region. |
337 | /// </summary> | 337 | /// </summary> |
338 | /// <param name="filename">The terrain file to load</param> | 338 | /// <param name="filename">The terrain file to load</param> |
339 | /// <param name="fileWidth">The width of the file in units</param> | 339 | /// <param name="fileWidth">The width of the file in units</param> |
340 | /// <param name="fileHeight">The height of the file in units</param> | 340 | /// <param name="fileHeight">The height of the file in units</param> |
341 | /// <param name="fileStartX">Where to begin our slice</param> | 341 | /// <param name="fileStartX">Where to begin our slice</param> |
342 | /// <param name="fileStartY">Where to begin our slice</param> | 342 | /// <param name="fileStartY">Where to begin our slice</param> |
343 | public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | 343 | public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) |
344 | { | 344 | { |
345 | int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX; | 345 | int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX; |
346 | int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY; | 346 | int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY; |
347 | 347 | ||
348 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | 348 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) |
349 | { | 349 | { |
350 | // this region is included in the tile request | 350 | // this region is included in the tile request |
351 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 351 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
352 | { | 352 | { |
353 | if (filename.EndsWith(loader.Key)) | 353 | if (filename.EndsWith(loader.Key)) |
354 | { | 354 | { |
355 | lock (m_scene) | 355 | lock (m_scene) |
356 | { | 356 | { |
357 | ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, | 357 | ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, |
358 | fileWidth, fileHeight, | 358 | fileWidth, fileHeight, |
359 | (int) Constants.RegionSize, | 359 | (int) Constants.RegionSize, |
360 | (int) Constants.RegionSize); | 360 | (int) Constants.RegionSize); |
361 | m_scene.Heightmap = channel; | 361 | m_scene.Heightmap = channel; |
362 | m_channel = channel; | 362 | m_channel = channel; |
363 | UpdateRevertMap(); | 363 | UpdateRevertMap(); |
364 | } | 364 | } |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | /// <summary> | 371 | /// <summary> |
372 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections | 372 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections |
373 | /// </summary> | 373 | /// </summary> |
374 | private void EventManager_OnTerrainTick() | 374 | private void EventManager_OnTerrainTick() |
375 | { | 375 | { |
376 | if (m_tainted) | 376 | if (m_tainted) |
377 | { | 377 | { |
378 | m_tainted = false; | 378 | m_tainted = false; |
379 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); | 379 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); |
380 | m_scene.SaveTerrain(); | 380 | m_scene.SaveTerrain(); |
381 | m_scene.CreateTerrainTexture(true); | 381 | m_scene.CreateTerrainTexture(true); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | /// <summary> | 385 | /// <summary> |
386 | /// Processes commandline input. Do not call directly. | 386 | /// Processes commandline input. Do not call directly. |
387 | /// </summary> | 387 | /// </summary> |
388 | /// <param name="args">Commandline arguments</param> | 388 | /// <param name="args">Commandline arguments</param> |
389 | private void EventManager_OnPluginConsole(string[] args) | 389 | private void EventManager_OnPluginConsole(string[] args) |
390 | { | 390 | { |
391 | if (args[0] == "terrain") | 391 | if (args[0] == "terrain") |
392 | { | 392 | { |
393 | string[] tmpArgs = new string[args.Length - 2]; | 393 | string[] tmpArgs = new string[args.Length - 2]; |
394 | int i; | 394 | int i; |
395 | for (i = 2; i < args.Length; i++) | 395 | for (i = 2; i < args.Length; i++) |
396 | tmpArgs[i - 2] = args[i]; | 396 | tmpArgs[i - 2] = args[i]; |
397 | 397 | ||
398 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | 398 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | /// <summary> | 402 | /// <summary> |
403 | /// Installs terrain brush hook to IClientAPI | 403 | /// Installs terrain brush hook to IClientAPI |
404 | /// </summary> | 404 | /// </summary> |
405 | /// <param name="client"></param> | 405 | /// <param name="client"></param> |
406 | private void EventManager_OnNewClient(IClientAPI client) | 406 | private void EventManager_OnNewClient(IClientAPI client) |
407 | { | 407 | { |
408 | client.OnModifyTerrain += client_OnModifyTerrain; | 408 | client.OnModifyTerrain += client_OnModifyTerrain; |
409 | } | 409 | } |
410 | 410 | ||
411 | /// <summary> | 411 | /// <summary> |
412 | /// Checks to see if the terrain has been modified since last check | 412 | /// Checks to see if the terrain has been modified since last check |
413 | /// </summary> | 413 | /// </summary> |
414 | private void CheckForTerrainUpdates() | 414 | private void CheckForTerrainUpdates() |
415 | { | 415 | { |
416 | bool shouldTaint = false; | 416 | bool shouldTaint = false; |
417 | float[] serialised = m_channel.GetFloatsSerialised(); | 417 | float[] serialised = m_channel.GetFloatsSerialised(); |
418 | int x; | 418 | int x; |
419 | for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize) | 419 | for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize) |
420 | { | 420 | { |
421 | int y; | 421 | int y; |
422 | for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize) | 422 | for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize) |
423 | { | 423 | { |
424 | if (m_channel.Tainted(x, y)) | 424 | if (m_channel.Tainted(x, y)) |
425 | { | 425 | { |
426 | SendToClients(serialised, x, y); | 426 | SendToClients(serialised, x, y); |
427 | shouldTaint = true; | 427 | shouldTaint = true; |
428 | } | 428 | } |
429 | } | 429 | } |
430 | } | 430 | } |
431 | if (shouldTaint) | 431 | if (shouldTaint) |
432 | { | 432 | { |
433 | m_tainted = true; | 433 | m_tainted = true; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | /// <summary> | 437 | /// <summary> |
438 | /// Sends a copy of the current terrain to the scenes clients | 438 | /// Sends a copy of the current terrain to the scenes clients |
439 | /// </summary> | 439 | /// </summary> |
440 | /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param> | 440 | /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param> |
441 | /// <param name="x">The patch corner to send</param> | 441 | /// <param name="x">The patch corner to send</param> |
442 | /// <param name="y">The patch corner to send</param> | 442 | /// <param name="y">The patch corner to send</param> |
443 | private void SendToClients(float[] serialised, int x, int y) | 443 | private void SendToClients(float[] serialised, int x, int y) |
444 | { | 444 | { |
445 | m_scene.ForEachClient( | 445 | m_scene.ForEachClient( |
446 | delegate(IClientAPI controller) { controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); }); | 446 | delegate(IClientAPI controller) { controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); }); |
447 | } | 447 | } |
448 | 448 | ||
449 | private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, | 449 | private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, |
450 | float south, float east, IClientAPI remoteClient) | 450 | float south, float east, IClientAPI remoteClient) |
451 | { | 451 | { |
452 | // Not a good permissions check, if in area mode, need to check the entire area. | 452 | // Not a good permissions check, if in area mode, need to check the entire area. |
453 | if (m_scene.PermissionsMngr.CanTerraform(remoteClient.AgentId, new LLVector3(north, west, 0))) | 453 | if (m_scene.PermissionsMngr.CanTerraform(remoteClient.AgentId, new LLVector3(north, west, 0))) |
454 | { | 454 | { |
455 | if (north == south && east == west) | 455 | if (north == south && east == west) |
456 | { | 456 | { |
457 | if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) | 457 | if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) |
458 | { | 458 | { |
459 | m_painteffects[(StandardTerrainEffects) action].PaintEffect( | 459 | m_painteffects[(StandardTerrainEffects) action].PaintEffect( |
460 | m_channel, west, south, size, seconds); | 460 | m_channel, west, south, size, seconds); |
461 | 461 | ||
462 | CheckForTerrainUpdates(); | 462 | CheckForTerrainUpdates(); |
463 | } | 463 | } |
464 | else | 464 | else |
465 | { | 465 | { |
466 | m_log.Debug("Unknown terrain brush type " + action); | 466 | m_log.Debug("Unknown terrain brush type " + action); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | else | 469 | else |
470 | { | 470 | { |
471 | if (m_floodeffects.ContainsKey((StandardTerrainEffects) action)) | 471 | if (m_floodeffects.ContainsKey((StandardTerrainEffects) action)) |
472 | { | 472 | { |
473 | bool[,] fillArea = new bool[m_channel.Width,m_channel.Height]; | 473 | bool[,] fillArea = new bool[m_channel.Width,m_channel.Height]; |
474 | fillArea.Initialize(); | 474 | fillArea.Initialize(); |
475 | 475 | ||
476 | int x; | 476 | int x; |
477 | for (x = 0; x < m_channel.Width; x++) | 477 | for (x = 0; x < m_channel.Width; x++) |
478 | { | 478 | { |
479 | int y; | 479 | int y; |
480 | for (y = 0; y < m_channel.Height; y++) | 480 | for (y = 0; y < m_channel.Height; y++) |
481 | { | 481 | { |
482 | if (x < east && x > west) | 482 | if (x < east && x > west) |
483 | { | 483 | { |
484 | if (y < north && y > south) | 484 | if (y < north && y > south) |
485 | { | 485 | { |
486 | fillArea[x, y] = true; | 486 | fillArea[x, y] = true; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | 491 | ||
492 | m_floodeffects[(StandardTerrainEffects) action].FloodEffect( | 492 | m_floodeffects[(StandardTerrainEffects) action].FloodEffect( |
493 | m_channel, fillArea, size); | 493 | m_channel, fillArea, size); |
494 | 494 | ||
495 | CheckForTerrainUpdates(); | 495 | CheckForTerrainUpdates(); |
496 | } | 496 | } |
497 | else | 497 | else |
498 | { | 498 | { |
499 | m_log.Debug("Unknown terrain flood type " + action); | 499 | m_log.Debug("Unknown terrain flood type " + action); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | #region Console Commands | 505 | #region Console Commands |
506 | 506 | ||
507 | private void InterfaceLoadFile(Object[] args) | 507 | private void InterfaceLoadFile(Object[] args) |
508 | { | 508 | { |
509 | LoadFromFile((string) args[0]); | 509 | LoadFromFile((string) args[0]); |
510 | CheckForTerrainUpdates(); | 510 | CheckForTerrainUpdates(); |
511 | } | 511 | } |
512 | 512 | ||
513 | private void InterfaceLoadTileFile(Object[] args) | 513 | private void InterfaceLoadTileFile(Object[] args) |
514 | { | 514 | { |
515 | LoadFromFile((string) args[0], | 515 | LoadFromFile((string) args[0], |
516 | (int) args[1], | 516 | (int) args[1], |
517 | (int) args[2], | 517 | (int) args[2], |
518 | (int) args[3], | 518 | (int) args[3], |
519 | (int) args[4]); | 519 | (int) args[4]); |
520 | CheckForTerrainUpdates(); | 520 | CheckForTerrainUpdates(); |
521 | } | 521 | } |
522 | 522 | ||
523 | private void InterfaceSaveFile(Object[] args) | 523 | private void InterfaceSaveFile(Object[] args) |
524 | { | 524 | { |
525 | SaveToFile((string) args[0]); | 525 | SaveToFile((string) args[0]); |
526 | } | 526 | } |
527 | 527 | ||
528 | private void InterfaceBakeTerrain(Object[] args) | 528 | private void InterfaceBakeTerrain(Object[] args) |
529 | { | 529 | { |
530 | UpdateRevertMap(); | 530 | UpdateRevertMap(); |
531 | } | 531 | } |
532 | 532 | ||
533 | private void InterfaceRevertTerrain(Object[] args) | 533 | private void InterfaceRevertTerrain(Object[] args) |
534 | { | 534 | { |
535 | int x, y; | 535 | int x, y; |
536 | for (x = 0; x < m_channel.Width; x++) | 536 | for (x = 0; x < m_channel.Width; x++) |
537 | for (y = 0; y < m_channel.Height; y++) | 537 | for (y = 0; y < m_channel.Height; y++) |
538 | m_channel[x, y] = m_revert[x, y]; | 538 | m_channel[x, y] = m_revert[x, y]; |
539 | 539 | ||
540 | CheckForTerrainUpdates(); | 540 | CheckForTerrainUpdates(); |
541 | } | 541 | } |
542 | 542 | ||
543 | private void InterfaceElevateTerrain(Object[] args) | 543 | private void InterfaceElevateTerrain(Object[] args) |
544 | { | 544 | { |
545 | int x, y; | 545 | int x, y; |
546 | for (x = 0; x < m_channel.Width; x++) | 546 | for (x = 0; x < m_channel.Width; x++) |
547 | for (y = 0; y < m_channel.Height; y++) | 547 | for (y = 0; y < m_channel.Height; y++) |
548 | m_channel[x, y] += (double) args[0]; | 548 | m_channel[x, y] += (double) args[0]; |
549 | CheckForTerrainUpdates(); | 549 | CheckForTerrainUpdates(); |
550 | } | 550 | } |
551 | 551 | ||
552 | private void InterfaceMultiplyTerrain(Object[] args) | 552 | private void InterfaceMultiplyTerrain(Object[] args) |
553 | { | 553 | { |
554 | int x, y; | 554 | int x, y; |
555 | for (x = 0; x < m_channel.Width; x++) | 555 | for (x = 0; x < m_channel.Width; x++) |
556 | for (y = 0; y < m_channel.Height; y++) | 556 | for (y = 0; y < m_channel.Height; y++) |
557 | m_channel[x, y] *= (double) args[0]; | 557 | m_channel[x, y] *= (double) args[0]; |
558 | CheckForTerrainUpdates(); | 558 | CheckForTerrainUpdates(); |
559 | } | 559 | } |
560 | 560 | ||
561 | private void InterfaceLowerTerrain(Object[] args) | 561 | private void InterfaceLowerTerrain(Object[] args) |
562 | { | 562 | { |
563 | int x, y; | 563 | int x, y; |
564 | for (x = 0; x < m_channel.Width; x++) | 564 | for (x = 0; x < m_channel.Width; x++) |
565 | for (y = 0; y < m_channel.Height; y++) | 565 | for (y = 0; y < m_channel.Height; y++) |
566 | m_channel[x, y] -= (double) args[0]; | 566 | m_channel[x, y] -= (double) args[0]; |
567 | CheckForTerrainUpdates(); | 567 | CheckForTerrainUpdates(); |
568 | } | 568 | } |
569 | 569 | ||
570 | private void InterfaceFillTerrain(Object[] args) | 570 | private void InterfaceFillTerrain(Object[] args) |
571 | { | 571 | { |
572 | int x, y; | 572 | int x, y; |
573 | 573 | ||
574 | for (x = 0; x < m_channel.Width; x++) | 574 | for (x = 0; x < m_channel.Width; x++) |
575 | for (y = 0; y < m_channel.Height; y++) | 575 | for (y = 0; y < m_channel.Height; y++) |
576 | m_channel[x, y] = (double) args[0]; | 576 | m_channel[x, y] = (double) args[0]; |
577 | CheckForTerrainUpdates(); | 577 | CheckForTerrainUpdates(); |
578 | } | 578 | } |
579 | 579 | ||
580 | private void InterfaceShowDebugStats(Object[] args) | 580 | private void InterfaceShowDebugStats(Object[] args) |
581 | { | 581 | { |
582 | double max = Double.MinValue; | 582 | double max = Double.MinValue; |
583 | double min = double.MaxValue; | 583 | double min = double.MaxValue; |
584 | double avg; | 584 | double avg; |
585 | double sum = 0; | 585 | double sum = 0; |
586 | 586 | ||
587 | int x; | 587 | int x; |
588 | for (x = 0; x < m_channel.Width; x++) | 588 | for (x = 0; x < m_channel.Width; x++) |
589 | { | 589 | { |
590 | int y; | 590 | int y; |
591 | for (y = 0; y < m_channel.Height; y++) | 591 | for (y = 0; y < m_channel.Height; y++) |
592 | { | 592 | { |
593 | sum += m_channel[x, y]; | 593 | sum += m_channel[x, y]; |
594 | if (max < m_channel[x, y]) | 594 | if (max < m_channel[x, y]) |
595 | max = m_channel[x, y]; | 595 | max = m_channel[x, y]; |
596 | if (min > m_channel[x, y]) | 596 | if (min > m_channel[x, y]) |
597 | min = m_channel[x, y]; | 597 | min = m_channel[x, y]; |
598 | } | 598 | } |
599 | } | 599 | } |
600 | 600 | ||
601 | avg = sum / (m_channel.Height * m_channel.Width); | 601 | avg = sum / (m_channel.Height * m_channel.Width); |
602 | 602 | ||
603 | m_log.Info("Channel " + m_channel.Width + "x" + m_channel.Height); | 603 | m_log.Info("Channel " + m_channel.Width + "x" + m_channel.Height); |
604 | m_log.Info("max/min/avg/sum: " + max + "/" + min + "/" + avg + "/" + sum); | 604 | m_log.Info("max/min/avg/sum: " + max + "/" + min + "/" + avg + "/" + sum); |
605 | } | 605 | } |
606 | 606 | ||
607 | private void InterfaceEnableExperimentalBrushes(Object[] args) | 607 | private void InterfaceEnableExperimentalBrushes(Object[] args) |
608 | { | 608 | { |
609 | if ((bool) args[0]) | 609 | if ((bool) args[0]) |
610 | { | 610 | { |
611 | m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere(); | 611 | m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere(); |
612 | m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere(); | 612 | m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere(); |
613 | m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere(); | 613 | m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere(); |
614 | } | 614 | } |
615 | else | 615 | else |
616 | { | 616 | { |
617 | InstallDefaultEffects(); | 617 | InstallDefaultEffects(); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | private void InterfaceRunPluginEffect(Object[] args) | 621 | private void InterfaceRunPluginEffect(Object[] args) |
622 | { | 622 | { |
623 | if ((string) args[0] == "list") | 623 | if ((string) args[0] == "list") |
624 | { | 624 | { |
625 | m_log.Info("List of loaded plugins"); | 625 | m_log.Info("List of loaded plugins"); |
626 | foreach (KeyValuePair<string, ITerrainEffect> kvp in m_plugineffects) | 626 | foreach (KeyValuePair<string, ITerrainEffect> kvp in m_plugineffects) |
627 | { | 627 | { |
628 | m_log.Info(kvp.Key); | 628 | m_log.Info(kvp.Key); |
629 | } | 629 | } |
630 | return; | 630 | return; |
631 | } | 631 | } |
632 | if ((string) args[0] == "reload") | 632 | if ((string) args[0] == "reload") |
633 | { | 633 | { |
634 | LoadPlugins(); | 634 | LoadPlugins(); |
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | if (m_plugineffects.ContainsKey((string) args[0])) | 637 | if (m_plugineffects.ContainsKey((string) args[0])) |
638 | { | 638 | { |
639 | m_plugineffects[(string) args[0]].RunEffect(m_channel); | 639 | m_plugineffects[(string) args[0]].RunEffect(m_channel); |
640 | CheckForTerrainUpdates(); | 640 | CheckForTerrainUpdates(); |
641 | } | 641 | } |
642 | else | 642 | else |
643 | { | 643 | { |
644 | m_log.Warn("No such plugin effect loaded."); | 644 | m_log.Warn("No such plugin effect loaded."); |
645 | } | 645 | } |
646 | } | 646 | } |
647 | 647 | ||
648 | private void InstallInterfaces() | 648 | private void InstallInterfaces() |
649 | { | 649 | { |
650 | // Load / Save | 650 | // Load / Save |
651 | string supportedFileExtensions = ""; | 651 | string supportedFileExtensions = ""; |
652 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 652 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
653 | supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; | 653 | supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; |
654 | 654 | ||
655 | Command loadFromFileCommand = | 655 | Command loadFromFileCommand = |
656 | new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file."); | 656 | new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file."); |
657 | loadFromFileCommand.AddArgument("filename", | 657 | loadFromFileCommand.AddArgument("filename", |
658 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + | 658 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + |
659 | supportedFileExtensions, "String"); | 659 | supportedFileExtensions, "String"); |
660 | 660 | ||
661 | Command saveToFileCommand = | 661 | Command saveToFileCommand = |
662 | new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file."); | 662 | new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file."); |
663 | saveToFileCommand.AddArgument("filename", | 663 | saveToFileCommand.AddArgument("filename", |
664 | "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + | 664 | "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + |
665 | supportedFileExtensions, "String"); | 665 | supportedFileExtensions, "String"); |
666 | 666 | ||
667 | Command loadFromTileCommand = | 667 | Command loadFromTileCommand = |
668 | new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); | 668 | new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); |
669 | loadFromTileCommand.AddArgument("filename", | 669 | loadFromTileCommand.AddArgument("filename", |
670 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + | 670 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + |
671 | supportedFileExtensions, "String"); | 671 | supportedFileExtensions, "String"); |
672 | loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); | 672 | loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); |
673 | loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); | 673 | loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); |
674 | loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", | 674 | loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", |
675 | "Integer"); | 675 | "Integer"); |
676 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | 676 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", |
677 | "Integer"); | 677 | "Integer"); |
678 | 678 | ||
679 | // Terrain adjustments | 679 | // Terrain adjustments |
680 | Command fillRegionCommand = | 680 | Command fillRegionCommand = |
681 | new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 681 | new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |
682 | fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", | 682 | fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", |
683 | "Double"); | 683 | "Double"); |
684 | 684 | ||
685 | Command elevateCommand = | 685 | Command elevateCommand = |
686 | new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); | 686 | new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); |
687 | elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); | 687 | elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); |
688 | 688 | ||
689 | Command lowerCommand = | 689 | Command lowerCommand = |
690 | new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); | 690 | new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); |
691 | lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); | 691 | lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); |
692 | 692 | ||
693 | Command multiplyCommand = | 693 | Command multiplyCommand = |
694 | new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); | 694 | new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); |
695 | multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); | 695 | multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); |
696 | 696 | ||
697 | Command bakeRegionCommand = | 697 | Command bakeRegionCommand = |
698 | new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); | 698 | new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); |
699 | Command revertRegionCommand = | 699 | Command revertRegionCommand = |
700 | new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); | 700 | new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); |
701 | 701 | ||
702 | // Debug | 702 | // Debug |
703 | Command showDebugStatsCommand = | 703 | Command showDebugStatsCommand = |
704 | new Command("stats", InterfaceShowDebugStats, | 704 | new Command("stats", InterfaceShowDebugStats, |
705 | "Shows some information about the regions heightmap for debugging purposes."); | 705 | "Shows some information about the regions heightmap for debugging purposes."); |
706 | 706 | ||
707 | Command experimentalBrushesCommand = | 707 | Command experimentalBrushesCommand = |
708 | new Command("newbrushes", InterfaceEnableExperimentalBrushes, | 708 | new Command("newbrushes", InterfaceEnableExperimentalBrushes, |
709 | "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); | 709 | "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); |
710 | experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); | 710 | experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); |
711 | 711 | ||
712 | //Plugins | 712 | //Plugins |
713 | Command pluginRunCommand = | 713 | Command pluginRunCommand = |
714 | new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect"); | 714 | new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect"); |
715 | pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); | 715 | pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); |
716 | 716 | ||
717 | m_commander.RegisterCommand("load", loadFromFileCommand); | 717 | m_commander.RegisterCommand("load", loadFromFileCommand); |
718 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); | 718 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); |
719 | m_commander.RegisterCommand("save", saveToFileCommand); | 719 | m_commander.RegisterCommand("save", saveToFileCommand); |
720 | m_commander.RegisterCommand("fill", fillRegionCommand); | 720 | m_commander.RegisterCommand("fill", fillRegionCommand); |
721 | m_commander.RegisterCommand("elevate", elevateCommand); | 721 | m_commander.RegisterCommand("elevate", elevateCommand); |
722 | m_commander.RegisterCommand("lower", lowerCommand); | 722 | m_commander.RegisterCommand("lower", lowerCommand); |
723 | m_commander.RegisterCommand("multiply", multiplyCommand); | 723 | m_commander.RegisterCommand("multiply", multiplyCommand); |
724 | m_commander.RegisterCommand("bake", bakeRegionCommand); | 724 | m_commander.RegisterCommand("bake", bakeRegionCommand); |
725 | m_commander.RegisterCommand("revert", revertRegionCommand); | 725 | m_commander.RegisterCommand("revert", revertRegionCommand); |
726 | m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand); | 726 | m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand); |
727 | m_commander.RegisterCommand("stats", showDebugStatsCommand); | 727 | m_commander.RegisterCommand("stats", showDebugStatsCommand); |
728 | m_commander.RegisterCommand("effect", pluginRunCommand); | 728 | m_commander.RegisterCommand("effect", pluginRunCommand); |
729 | 729 | ||
730 | // Add this to our scene so scripts can call these functions | 730 | // Add this to our scene so scripts can call these functions |
731 | m_scene.RegisterModuleCommander("Terrain", m_commander); | 731 | m_scene.RegisterModuleCommander("Terrain", m_commander); |
732 | } | 732 | } |
733 | 733 | ||
734 | #endregion | 734 | #endregion |
735 | } | 735 | } |
736 | } \ No newline at end of file | 736 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs index b593717..daef6bd 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs | |||
@@ -1,133 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 32 | { |
33 | public static class TerrainUtil | 33 | public static class TerrainUtil |
34 | { | 34 | { |
35 | public static double MetersToSphericalStrength(double size) | 35 | public static double MetersToSphericalStrength(double size) |
36 | { | 36 | { |
37 | return Math.Pow(2, size); | 37 | return Math.Pow(2, size); |
38 | } | 38 | } |
39 | 39 | ||
40 | public static double SphericalFactor(double x, double y, double rx, double ry, double size) | 40 | public static double SphericalFactor(double x, double y, double rx, double ry, double size) |
41 | { | 41 | { |
42 | return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 42 | return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
43 | } | 43 | } |
44 | 44 | ||
45 | public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 45 | public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
46 | { | 46 | { |
47 | int w = map.Width; | 47 | int w = map.Width; |
48 | int h = map.Height; | 48 | int h = map.Height; |
49 | 49 | ||
50 | if (x > w - 2.0) | 50 | if (x > w - 2.0) |
51 | x = w - 2.0; | 51 | x = w - 2.0; |
52 | if (y > h - 2.0) | 52 | if (y > h - 2.0) |
53 | y = h - 2.0; | 53 | y = h - 2.0; |
54 | if (x < 0.0) | 54 | if (x < 0.0) |
55 | x = 0.0; | 55 | x = 0.0; |
56 | if (y < 0.0) | 56 | if (y < 0.0) |
57 | y = 0.0; | 57 | y = 0.0; |
58 | 58 | ||
59 | int stepSize = 1; | 59 | int stepSize = 1; |
60 | double h00 = map[(int) x, (int) y]; | 60 | double h00 = map[(int) x, (int) y]; |
61 | double h10 = map[(int) x + stepSize, (int) y]; | 61 | double h10 = map[(int) x + stepSize, (int) y]; |
62 | double h01 = map[(int) x, (int) y + stepSize]; | 62 | double h01 = map[(int) x, (int) y + stepSize]; |
63 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; | 63 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; |
64 | double h1 = h00; | 64 | double h1 = h00; |
65 | double h2 = h10; | 65 | double h2 = h10; |
66 | double h3 = h01; | 66 | double h3 = h01; |
67 | double h4 = h11; | 67 | double h4 = h11; |
68 | double a00 = h1; | 68 | double a00 = h1; |
69 | double a10 = h2 - h1; | 69 | double a10 = h2 - h1; |
70 | double a01 = h3 - h1; | 70 | double a01 = h3 - h1; |
71 | double a11 = h1 - h2 - h3 + h4; | 71 | double a11 = h1 - h2 - h3 + h4; |
72 | double partialx = x - (int) x; | 72 | double partialx = x - (int) x; |
73 | double partialz = y - (int) y; | 73 | double partialz = y - (int) y; |
74 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 74 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
75 | return hi; | 75 | return hi; |
76 | } | 76 | } |
77 | 77 | ||
78 | private static double Noise(double x, double y) | 78 | private static double Noise(double x, double y) |
79 | { | 79 | { |
80 | int n = (int) x + (int) (y * 749); | 80 | int n = (int) x + (int) (y * 749); |
81 | n = (n << 13) ^ n; | 81 | n = (n << 13) ^ n; |
82 | return (1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); | 82 | return (1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); |
83 | } | 83 | } |
84 | 84 | ||
85 | private static double SmoothedNoise1(double x, double y) | 85 | private static double SmoothedNoise1(double x, double y) |
86 | { | 86 | { |
87 | double corners = (Noise(x - 1, y - 1) + Noise(x + 1, y - 1) + Noise(x - 1, y + 1) + Noise(x + 1, y + 1)) / 16; | 87 | double corners = (Noise(x - 1, y - 1) + Noise(x + 1, y - 1) + Noise(x - 1, y + 1) + Noise(x + 1, y + 1)) / 16; |
88 | double sides = (Noise(x - 1, y) + Noise(x + 1, y) + Noise(x, y - 1) + Noise(x, y + 1)) / 8; | 88 | double sides = (Noise(x - 1, y) + Noise(x + 1, y) + Noise(x, y - 1) + Noise(x, y + 1)) / 8; |
89 | double center = Noise(x, y) / 4; | 89 | double center = Noise(x, y) / 4; |
90 | return corners + sides + center; | 90 | return corners + sides + center; |
91 | } | 91 | } |
92 | 92 | ||
93 | private static double Interpolate(double x, double y, double z) | 93 | private static double Interpolate(double x, double y, double z) |
94 | { | 94 | { |
95 | return (x * (1.0 - z)) + (y * z); | 95 | return (x * (1.0 - z)) + (y * z); |
96 | } | 96 | } |
97 | 97 | ||
98 | private static double InterpolatedNoise(double x, double y) | 98 | private static double InterpolatedNoise(double x, double y) |
99 | { | 99 | { |
100 | int integer_X = (int) (x); | 100 | int integer_X = (int) (x); |
101 | double fractional_X = x - integer_X; | 101 | double fractional_X = x - integer_X; |
102 | 102 | ||
103 | int integer_Y = (int) y; | 103 | int integer_Y = (int) y; |
104 | double fractional_Y = y - integer_Y; | 104 | double fractional_Y = y - integer_Y; |
105 | 105 | ||
106 | double v1 = SmoothedNoise1(integer_X, integer_Y); | 106 | double v1 = SmoothedNoise1(integer_X, integer_Y); |
107 | double v2 = SmoothedNoise1(integer_X + 1, integer_Y); | 107 | double v2 = SmoothedNoise1(integer_X + 1, integer_Y); |
108 | double v3 = SmoothedNoise1(integer_X, integer_Y + 1); | 108 | double v3 = SmoothedNoise1(integer_X, integer_Y + 1); |
109 | double v4 = SmoothedNoise1(integer_X + 1, integer_Y + 1); | 109 | double v4 = SmoothedNoise1(integer_X + 1, integer_Y + 1); |
110 | 110 | ||
111 | double i1 = Interpolate(v1, v2, fractional_X); | 111 | double i1 = Interpolate(v1, v2, fractional_X); |
112 | double i2 = Interpolate(v3, v4, fractional_X); | 112 | double i2 = Interpolate(v3, v4, fractional_X); |
113 | 113 | ||
114 | return Interpolate(i1, i2, fractional_Y); | 114 | return Interpolate(i1, i2, fractional_Y); |
115 | } | 115 | } |
116 | 116 | ||
117 | public static double PerlinNoise2D(double x, double y, int octaves, double persistence) | 117 | public static double PerlinNoise2D(double x, double y, int octaves, double persistence) |
118 | { | 118 | { |
119 | double frequency = 0.0; | 119 | double frequency = 0.0; |
120 | double amplitude = 0.0; | 120 | double amplitude = 0.0; |
121 | double total = 0.0; | 121 | double total = 0.0; |
122 | 122 | ||
123 | for (int i = 0; i < octaves; i++) | 123 | for (int i = 0; i < octaves; i++) |
124 | { | 124 | { |
125 | frequency = Math.Pow(2, i); | 125 | frequency = Math.Pow(2, i); |
126 | amplitude = Math.Pow(persistence, i); | 126 | amplitude = Math.Pow(persistence, i); |
127 | 127 | ||
128 | total += InterpolatedNoise(x * frequency, y * frequency) * amplitude; | 128 | total += InterpolatedNoise(x * frequency, y * frequency) * amplitude; |
129 | } | 129 | } |
130 | return total; | 130 | return total; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | } \ No newline at end of file | 133 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs index ccb0561..842e2ee 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -1,59 +1,59 @@ | |||
1 | using System; | 1 | using System; |
2 | using NUnit.Framework; | 2 | using NUnit.Framework; |
3 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 3 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests | 5 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests |
6 | { | 6 | { |
7 | [TestFixture] | 7 | [TestFixture] |
8 | public class TerrainTest | 8 | public class TerrainTest |
9 | { | 9 | { |
10 | [Test] | 10 | [Test] |
11 | public void BrushTest() | 11 | public void BrushTest() |
12 | { | 12 | { |
13 | TerrainChannel x = new TerrainChannel(256, 256); | 13 | TerrainChannel x = new TerrainChannel(256, 256); |
14 | ITerrainPaintableEffect effect = new RaiseSphere(); | 14 | ITerrainPaintableEffect effect = new RaiseSphere(); |
15 | 15 | ||
16 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); | 16 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); |
17 | Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); | 17 | Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); |
18 | Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); | 18 | Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); |
19 | 19 | ||
20 | x = new TerrainChannel(256, 256); | 20 | x = new TerrainChannel(256, 256); |
21 | effect = new LowerSphere(); | 21 | effect = new LowerSphere(); |
22 | 22 | ||
23 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); | 23 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); |
24 | Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); | 24 | Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); |
25 | Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); | 25 | Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); |
26 | } | 26 | } |
27 | 27 | ||
28 | [Test] | 28 | [Test] |
29 | public void TerrainChannelTest() | 29 | public void TerrainChannelTest() |
30 | { | 30 | { |
31 | TerrainChannel x = new TerrainChannel(256, 256); | 31 | TerrainChannel x = new TerrainChannel(256, 256); |
32 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); | 32 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); |
33 | 33 | ||
34 | x[0, 0] = 1.0; | 34 | x[0, 0] = 1.0; |
35 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); | 35 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); |
36 | 36 | ||
37 | x[0, 0] = 0; | 37 | x[0, 0] = 0; |
38 | x[0, 0] += 5.0; | 38 | x[0, 0] += 5.0; |
39 | x[0, 0] -= 1.0; | 39 | x[0, 0] -= 1.0; |
40 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); | 40 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); |
41 | 41 | ||
42 | x[0, 0] = Math.PI; | 42 | x[0, 0] = Math.PI; |
43 | double[,] doublesExport = x.GetDoubles(); | 43 | double[,] doublesExport = x.GetDoubles(); |
44 | Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly."); | 44 | Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly."); |
45 | 45 | ||
46 | x[0, 0] = 1.0; | 46 | x[0, 0] = 1.0; |
47 | float[] floatsExport = x.GetFloatsSerialised(); | 47 | float[] floatsExport = x.GetFloatsSerialised(); |
48 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); | 48 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); |
49 | 49 | ||
50 | x[0, 0] = 1.0; | 50 | x[0, 0] = 1.0; |
51 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | 51 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); |
52 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | 52 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); |
53 | 53 | ||
54 | TerrainChannel y = x.Copy(); | 54 | TerrainChannel y = x.Copy(); |
55 | Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly."); | 55 | Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly."); |
56 | Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly."); | 56 | Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly."); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } \ No newline at end of file | 59 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs index f144444..32e45b7 100644 --- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs | |||
@@ -1,251 +1,251 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Timers; | 31 | using System.Timers; |
32 | using Axiom.Math; | 32 | using Axiom.Math; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Region.Environment.Interfaces; | 37 | using OpenSim.Region.Environment.Interfaces; |
38 | using OpenSim.Region.Environment.Scenes; | 38 | using OpenSim.Region.Environment.Scenes; |
39 | 39 | ||
40 | namespace OpenSim.Region.Environment.Modules | 40 | namespace OpenSim.Region.Environment.Modules |
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Version 2.0 - Very hacky compared to the original. Will fix original and release as 0.3 later. | 43 | /// Version 2.0 - Very hacky compared to the original. Will fix original and release as 0.3 later. |
44 | /// </summary> | 44 | /// </summary> |
45 | public class TreePopulatorModule : IRegionModule | 45 | public class TreePopulatorModule : IRegionModule |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | private Scene m_scene; | 48 | private Scene m_scene; |
49 | 49 | ||
50 | public double m_tree_density = 50.0; // Aim for this many per region | 50 | public double m_tree_density = 50.0; // Aim for this many per region |
51 | public double m_tree_updates = 1000.0; // MS between updates | 51 | public double m_tree_updates = 1000.0; // MS between updates |
52 | private List<LLUUID> m_trees; | 52 | private List<LLUUID> m_trees; |
53 | 53 | ||
54 | #region IRegionModule Members | 54 | #region IRegionModule Members |
55 | 55 | ||
56 | public void Initialise(Scene scene, IConfigSource config) | 56 | public void Initialise(Scene scene, IConfigSource config) |
57 | { | 57 | { |
58 | try | 58 | try |
59 | { | 59 | { |
60 | m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); | 60 | m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); |
61 | } | 61 | } |
62 | catch (Exception) | 62 | catch (Exception) |
63 | { | 63 | { |
64 | } | 64 | } |
65 | 65 | ||
66 | m_trees = new List<LLUUID>(); | 66 | m_trees = new List<LLUUID>(); |
67 | m_scene = scene; | 67 | m_scene = scene; |
68 | 68 | ||
69 | m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); | 69 | m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); |
70 | 70 | ||
71 | Timer CalculateTrees = new Timer(m_tree_updates); | 71 | Timer CalculateTrees = new Timer(m_tree_updates); |
72 | CalculateTrees.Elapsed += new ElapsedEventHandler(CalculateTrees_Elapsed); | 72 | CalculateTrees.Elapsed += new ElapsedEventHandler(CalculateTrees_Elapsed); |
73 | CalculateTrees.Start(); | 73 | CalculateTrees.Start(); |
74 | m_log.Debug("[TREES]: Initialised tree module"); | 74 | m_log.Debug("[TREES]: Initialised tree module"); |
75 | } | 75 | } |
76 | 76 | ||
77 | public void PostInitialise() | 77 | public void PostInitialise() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | public void Close() | 81 | public void Close() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | public string Name | 85 | public string Name |
86 | { | 86 | { |
87 | get { return "TreePopulatorModule"; } | 87 | get { return "TreePopulatorModule"; } |
88 | } | 88 | } |
89 | 89 | ||
90 | public bool IsSharedModule | 90 | public bool IsSharedModule |
91 | { | 91 | { |
92 | get { return false; } | 92 | get { return false; } |
93 | } | 93 | } |
94 | 94 | ||
95 | #endregion | 95 | #endregion |
96 | 96 | ||
97 | private void EventManager_OnPluginConsole(string[] args) | 97 | private void EventManager_OnPluginConsole(string[] args) |
98 | { | 98 | { |
99 | if (args[0] == "tree") | 99 | if (args[0] == "tree") |
100 | { | 100 | { |
101 | m_log.Debug("[TREES]: New tree planting"); | 101 | m_log.Debug("[TREES]: New tree planting"); |
102 | CreateTree(new LLVector3(128.0f, 128.0f, 0.0f)); | 102 | CreateTree(new LLVector3(128.0f, 128.0f, 0.0f)); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | private void growTrees() | 106 | private void growTrees() |
107 | { | 107 | { |
108 | foreach (LLUUID tree in m_trees) | 108 | foreach (LLUUID tree in m_trees) |
109 | { | 109 | { |
110 | if (m_scene.Entities.ContainsKey(tree)) | 110 | if (m_scene.Entities.ContainsKey(tree)) |
111 | { | 111 | { |
112 | SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; | 112 | SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; |
113 | 113 | ||
114 | // 100 seconds to grow 1m | 114 | // 100 seconds to grow 1m |
115 | s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); | 115 | s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); |
116 | s_tree.SendFullUpdateToAllClients(); | 116 | s_tree.SendFullUpdateToAllClients(); |
117 | //s_tree.ScheduleTerseUpdate(); | 117 | //s_tree.ScheduleTerseUpdate(); |
118 | } | 118 | } |
119 | else | 119 | else |
120 | { | 120 | { |
121 | m_trees.Remove(tree); | 121 | m_trees.Remove(tree); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | private void seedTrees() | 126 | private void seedTrees() |
127 | { | 127 | { |
128 | foreach (LLUUID tree in m_trees) | 128 | foreach (LLUUID tree in m_trees) |
129 | { | 129 | { |
130 | if (m_scene.Entities.ContainsKey(tree)) | 130 | if (m_scene.Entities.ContainsKey(tree)) |
131 | { | 131 | { |
132 | SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; | 132 | SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; |
133 | 133 | ||
134 | if (s_tree.Scale.X > 0.5) | 134 | if (s_tree.Scale.X > 0.5) |
135 | { | 135 | { |
136 | if (Util.RandomClass.NextDouble() > 0.75) | 136 | if (Util.RandomClass.NextDouble() > 0.75) |
137 | { | 137 | { |
138 | SpawnChild(s_tree); | 138 | SpawnChild(s_tree); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
144 | m_trees.Remove(tree); | 144 | m_trees.Remove(tree); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | private void killTrees() | 149 | private void killTrees() |
150 | { | 150 | { |
151 | foreach (LLUUID tree in m_trees) | 151 | foreach (LLUUID tree in m_trees) |
152 | { | 152 | { |
153 | double killLikelyhood = 0.0; | 153 | double killLikelyhood = 0.0; |
154 | 154 | ||
155 | if (m_scene.Entities.ContainsKey(tree)) | 155 | if (m_scene.Entities.ContainsKey(tree)) |
156 | { | 156 | { |
157 | SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; | 157 | SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; |
158 | double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + | 158 | double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + |
159 | Math.Pow(selectedTree.Scale.Y, 2) + | 159 | Math.Pow(selectedTree.Scale.Y, 2) + |
160 | Math.Pow(selectedTree.Scale.Z, 2)); | 160 | Math.Pow(selectedTree.Scale.Z, 2)); |
161 | 161 | ||
162 | foreach (LLUUID picktree in m_trees) | 162 | foreach (LLUUID picktree in m_trees) |
163 | { | 163 | { |
164 | if (picktree != tree) | 164 | if (picktree != tree) |
165 | { | 165 | { |
166 | SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart; | 166 | SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart; |
167 | 167 | ||
168 | double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + | 168 | double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + |
169 | Math.Pow(pickedTree.Scale.Y, 2) + | 169 | Math.Pow(pickedTree.Scale.Y, 2) + |
170 | Math.Pow(pickedTree.Scale.Z, 2)); | 170 | Math.Pow(pickedTree.Scale.Z, 2)); |
171 | 171 | ||
172 | double pickedTreeDistance = Math.Sqrt(Math.Pow(Math.Abs(pickedTree.AbsolutePosition.X - selectedTree.AbsolutePosition.X), 2) + | 172 | double pickedTreeDistance = Math.Sqrt(Math.Pow(Math.Abs(pickedTree.AbsolutePosition.X - selectedTree.AbsolutePosition.X), 2) + |
173 | Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Y - selectedTree.AbsolutePosition.Y), 2) + | 173 | Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Y - selectedTree.AbsolutePosition.Y), 2) + |
174 | Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Z - selectedTree.AbsolutePosition.Z), 2)); | 174 | Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Z - selectedTree.AbsolutePosition.Z), 2)); |
175 | 175 | ||
176 | killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1; | 176 | killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1; |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | if (Util.RandomClass.NextDouble() < killLikelyhood) | 180 | if (Util.RandomClass.NextDouble() < killLikelyhood) |
181 | { | 181 | { |
182 | m_scene.RemoveEntity(selectedTree.ParentGroup); | 182 | m_scene.RemoveEntity(selectedTree.ParentGroup); |
183 | m_trees.Remove(selectedTree.ParentGroup.UUID); | 183 | m_trees.Remove(selectedTree.ParentGroup.UUID); |
184 | 184 | ||
185 | m_scene.ForEachClient(delegate(IClientAPI controller) | 185 | m_scene.ForEachClient(delegate(IClientAPI controller) |
186 | { | 186 | { |
187 | controller.SendKillObject(m_scene.RegionInfo.RegionHandle, | 187 | controller.SendKillObject(m_scene.RegionInfo.RegionHandle, |
188 | selectedTree.LocalId); | 188 | selectedTree.LocalId); |
189 | }); | 189 | }); |
190 | 190 | ||
191 | break; | 191 | break; |
192 | } | 192 | } |
193 | else | 193 | else |
194 | { | 194 | { |
195 | selectedTree.SetText(killLikelyhood.ToString(), new Vector3(1.0f, 1.0f, 1.0f), 1.0); | 195 | selectedTree.SetText(killLikelyhood.ToString(), new Vector3(1.0f, 1.0f, 1.0f), 1.0); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | else | 198 | else |
199 | { | 199 | { |
200 | m_trees.Remove(tree); | 200 | m_trees.Remove(tree); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | private void SpawnChild(SceneObjectPart s_tree) | 205 | private void SpawnChild(SceneObjectPart s_tree) |
206 | { | 206 | { |
207 | LLVector3 position = new LLVector3(); | 207 | LLVector3 position = new LLVector3(); |
208 | 208 | ||
209 | position.X = s_tree.AbsolutePosition.X + (1 * (-1 * Util.RandomClass.Next(1))); | 209 | position.X = s_tree.AbsolutePosition.X + (1 * (-1 * Util.RandomClass.Next(1))); |
210 | if (position.X > 255) | 210 | if (position.X > 255) |
211 | position.X = 255; | 211 | position.X = 255; |
212 | if (position.X < 0) | 212 | if (position.X < 0) |
213 | position.X = 0; | 213 | position.X = 0; |
214 | position.Y = s_tree.AbsolutePosition.Y + (1 * (-1 * Util.RandomClass.Next(1))); | 214 | position.Y = s_tree.AbsolutePosition.Y + (1 * (-1 * Util.RandomClass.Next(1))); |
215 | if (position.Y > 255) | 215 | if (position.Y > 255) |
216 | position.Y = 255; | 216 | position.Y = 255; |
217 | if (position.Y < 0) | 217 | if (position.Y < 0) |
218 | position.Y = 0; | 218 | position.Y = 0; |
219 | 219 | ||
220 | double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); | 220 | double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); |
221 | double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); | 221 | double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); |
222 | 222 | ||
223 | position.X += (float) randX; | 223 | position.X += (float) randX; |
224 | position.Y += (float) randY; | 224 | position.Y += (float) randY; |
225 | 225 | ||
226 | CreateTree(position); | 226 | CreateTree(position); |
227 | } | 227 | } |
228 | 228 | ||
229 | private void CreateTree(LLVector3 position) | 229 | private void CreateTree(LLVector3 position) |
230 | { | 230 | { |
231 | position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y]; | 231 | position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y]; |
232 | 232 | ||
233 | SceneObjectGroup tree = | 233 | SceneObjectGroup tree = |
234 | m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), | 234 | m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), |
235 | LLQuaternion.Identity, | 235 | LLQuaternion.Identity, |
236 | position, | 236 | position, |
237 | Tree.Cypress1, | 237 | Tree.Cypress1, |
238 | false); | 238 | false); |
239 | 239 | ||
240 | m_trees.Add(tree.UUID); | 240 | m_trees.Add(tree.UUID); |
241 | tree.SendGroupFullUpdate(); | 241 | tree.SendGroupFullUpdate(); |
242 | } | 242 | } |
243 | 243 | ||
244 | private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) | 244 | private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) |
245 | { | 245 | { |
246 | growTrees(); | 246 | growTrees(); |
247 | seedTrees(); | 247 | seedTrees(); |
248 | killTrees(); | 248 | killTrees(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } \ No newline at end of file | 251 | } \ No newline at end of file |