aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJeff Ames2008-02-15 00:43:20 +0000
committerJeff Ames2008-02-15 00:43:20 +0000
commitb13836db57f53191b20a60247a59b25888381bea (patch)
treed3074fd29be0adf822d761b2f2514de0d536c138 /OpenSim
parentattempt to make our logging at least fail gracefully, we'll see if this helps (diff)
downloadopensim-SC_OLD-b13836db57f53191b20a60247a59b25888381bea.zip
opensim-SC_OLD-b13836db57f53191b20a60247a59b25888381bea.tar.gz
opensim-SC_OLD-b13836db57f53191b20a60247a59b25888381bea.tar.bz2
opensim-SC_OLD-b13836db57f53191b20a60247a59b25888381bea.tar.xz
Update svn properties.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Constants.cs22
-rw-r--r--OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs20
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs264
-rw-r--r--OpenSim/Region/Environment/Modules/TreePopulatorModule.cs490
4 files changed, 398 insertions, 398 deletions
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index b308221..80fdb64 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -1,11 +1,11 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Framework 5namespace OpenSim.Framework
6{ 6{
7 public class Constants 7 public class Constants
8 { 8 {
9 public const uint RegionSize = 256; 9 public const uint RegionSize = 256;
10 } 10 }
11} 11}
diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
index eb5b0a6..50b2a5e 100644
--- a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
+++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
@@ -1,10 +1,10 @@
1using System; 1using System;
2namespace OpenSim.Region.Environment.Interfaces 2namespace OpenSim.Region.Environment.Interfaces
3{ 3{
4 public interface ITerrainChannel 4 public interface ITerrainChannel
5 { 5 {
6 int Height { get; } 6 int Height { get; }
7 double this[int x, int y] { get; set; } 7 double this[int x, int y] { get; set; }
8 int Width { get; } 8 int Width { get; }
9 } 9 }
10} 10}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 990a1e0..4e937bb 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -1,132 +1,132 @@
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 28
29using Nini.Config; 29using Nini.Config;
30using System; 30using System;
31using System.Collections; 31using System.Collections;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Modules; 35using OpenSim.Region.Environment.Modules;
36using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
38using libsecondlife; 38using libsecondlife;
39 39
40namespace OpenSim.Region.Environment.Modules.Terrain 40namespace OpenSim.Region.Environment.Modules.Terrain
41{ 41{
42 /// <summary> 42 /// <summary>
43 /// A new version of the old Channel class, simplified 43 /// A new version of the old Channel class, simplified
44 /// </summary> 44 /// </summary>
45 public class TerrainChannel : ITerrainChannel 45 public class TerrainChannel : ITerrainChannel
46 { 46 {
47 private double[,] map; 47 private double[,] map;
48 48
49 public int Width 49 public int Width
50 { 50 {
51 get { return map.GetLength(0); } 51 get { return map.GetLength(0); }
52 } 52 }
53 53
54 public int Height 54 public int Height
55 { 55 {
56 get { return map.GetLength(1); } 56 get { return map.GetLength(1); }
57 } 57 }
58 58
59 public TerrainChannel Copy() 59 public TerrainChannel Copy()
60 { 60 {
61 TerrainChannel copy = new TerrainChannel(false); 61 TerrainChannel copy = new TerrainChannel(false);
62 copy.map = (double[,])this.map.Clone(); 62 copy.map = (double[,])this.map.Clone();
63 63
64 return copy; 64 return copy;
65 } 65 }
66 66
67 public double this[int x, int y] 67 public double this[int x, int y]
68 { 68 {
69 get 69 get
70 { 70 {
71 return map[x, y]; 71 return map[x, y];
72 } 72 }
73 set 73 set
74 { 74 {
75 map[x, y] = value; 75 map[x, y] = value;
76 } 76 }
77 } 77 }
78 78
79 public TerrainChannel() 79 public TerrainChannel()
80 { 80 {
81 map = new double[Constants.RegionSize, Constants.RegionSize]; 81 map = new double[Constants.RegionSize, Constants.RegionSize];
82 } 82 }
83 83
84 public TerrainChannel(bool createMap) 84 public TerrainChannel(bool createMap)
85 { 85 {
86 if (createMap) 86 if (createMap)
87 map = new double[Constants.RegionSize, Constants.RegionSize]; 87 map = new double[Constants.RegionSize, Constants.RegionSize];
88 } 88 }
89 89
90 public TerrainChannel(int w, int h) 90 public TerrainChannel(int w, int h)
91 { 91 {
92 map = new double[w, h]; 92 map = new double[w, h];
93 } 93 }
94 } 94 }
95 95
96 public class TerrainModule : IRegionModule 96 public class TerrainModule : IRegionModule
97 { 97 {
98 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 98 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
99 99
100 Scene m_scene; 100 Scene m_scene;
101 101
102 private IConfigSource m_gConfig; 102 private IConfigSource m_gConfig;
103 103
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 m_gConfig = config; 107 m_gConfig = config;
108 } 108 }
109 109
110 public void Close() 110 public void Close()
111 { 111 {
112 112
113 } 113 }
114 114
115 public string Name 115 public string Name
116 { 116 {
117 get { return "TerrainModule"; } 117 get { return "TerrainModule"; }
118 } 118 }
119 119
120 public bool IsSharedModule 120 public bool IsSharedModule
121 { 121 {
122 get { return false; } 122 get { return false; }
123 } 123 }
124 124
125 public void PostInitialise() 125 public void PostInitialise()
126 { 126 {
127 127
128 } 128 }
129 129
130 } 130 }
131 131
132} 132}
diff --git a/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
index 9c556c1..725ce0d 100644
--- a/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
+++ b/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
@@ -1,246 +1,246 @@
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 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife; 31using libsecondlife;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37 37
38namespace OpenSim.Region.Environment.Modules 38namespace OpenSim.Region.Environment.Modules
39{ 39{
40 /// <summary> 40 /// <summary>
41 /// Version 2.0 - Very hacky compared to the original. Will fix original and release as 0.3 later. 41 /// Version 2.0 - Very hacky compared to the original. Will fix original and release as 0.3 later.
42 /// </summary> 42 /// </summary>
43 public class TreePopulatorModule : IRegionModule 43 public class TreePopulatorModule : IRegionModule
44 { 44 {
45 private Scene m_scene; 45 private Scene m_scene;
46 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private List<LLUUID> m_trees; 48 private List<LLUUID> m_trees;
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 52
53 public void Initialise(Scene scene, IConfigSource config) 53 public void Initialise(Scene scene, IConfigSource config)
54 { 54 {
55 try 55 try
56 { 56 {
57 m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); 57 m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density);
58 } 58 }
59 catch (Exception) 59 catch (Exception)
60 { } 60 { }
61 61
62 m_trees = new List<LLUUID>(); 62 m_trees = new List<LLUUID>();
63 m_scene = scene; 63 m_scene = scene;
64 64
65 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); 65 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
66 66
67 System.Timers.Timer CalculateTrees = new System.Timers.Timer(m_tree_updates); 67 System.Timers.Timer CalculateTrees = new System.Timers.Timer(m_tree_updates);
68 CalculateTrees.Elapsed += new System.Timers.ElapsedEventHandler(CalculateTrees_Elapsed); 68 CalculateTrees.Elapsed += new System.Timers.ElapsedEventHandler(CalculateTrees_Elapsed);
69 CalculateTrees.Start(); 69 CalculateTrees.Start();
70 m_log.Debug("[TREES]: Initialised tree module"); 70 m_log.Debug("[TREES]: Initialised tree module");
71 } 71 }
72 72
73 void EventManager_OnPluginConsole(string[] args) 73 void EventManager_OnPluginConsole(string[] args)
74 { 74 {
75 if (args[0] == "tree") 75 if (args[0] == "tree")
76 { 76 {
77 m_log.Debug("[TREES]: New tree planting"); 77 m_log.Debug("[TREES]: New tree planting");
78 CreateTree(new LLVector3(128.0f, 128.0f, 0.0f)); 78 CreateTree(new LLVector3(128.0f, 128.0f, 0.0f));
79 } 79 }
80 } 80 }
81 81
82 void growTrees() 82 void growTrees()
83 { 83 {
84 foreach (LLUUID tree in m_trees) 84 foreach (LLUUID tree in m_trees)
85 { 85 {
86 if (m_scene.Entities.ContainsKey(tree)) 86 if (m_scene.Entities.ContainsKey(tree))
87 { 87 {
88 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 88 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
89 89
90 // 100 seconds to grow 1m 90 // 100 seconds to grow 1m
91 s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); 91 s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f);
92 s_tree.SendFullUpdateToAllClients(); 92 s_tree.SendFullUpdateToAllClients();
93 //s_tree.ScheduleTerseUpdate(); 93 //s_tree.ScheduleTerseUpdate();
94 } 94 }
95 else 95 else
96 { 96 {
97 m_trees.Remove(tree); 97 m_trees.Remove(tree);
98 } 98 }
99 } 99 }
100 } 100 }
101 101
102 void seedTrees() 102 void seedTrees()
103 { 103 {
104 foreach (LLUUID tree in m_trees) 104 foreach (LLUUID tree in m_trees)
105 { 105 {
106 if (m_scene.Entities.ContainsKey(tree)) 106 if (m_scene.Entities.ContainsKey(tree))
107 { 107 {
108 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 108 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
109 109
110 if (s_tree.Scale.X > 0.5) 110 if (s_tree.Scale.X > 0.5)
111 { 111 {
112 if (Util.RandomClass.NextDouble() > 0.75) 112 if (Util.RandomClass.NextDouble() > 0.75)
113 { 113 {
114 SpawnChild(s_tree); 114 SpawnChild(s_tree);
115 } 115 }
116 } 116 }
117 117
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 void killTrees() 126 void killTrees()
127 { 127 {
128 foreach (LLUUID tree in m_trees) 128 foreach (LLUUID tree in m_trees)
129 { 129 {
130 double killLikelyhood = 0.0; 130 double killLikelyhood = 0.0;
131 131
132 if (m_scene.Entities.ContainsKey(tree)) 132 if (m_scene.Entities.ContainsKey(tree))
133 { 133 {
134 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 134 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
135 double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + 135 double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
136 Math.Pow(selectedTree.Scale.Y, 2) + 136 Math.Pow(selectedTree.Scale.Y, 2) +
137 Math.Pow(selectedTree.Scale.Z, 2)); 137 Math.Pow(selectedTree.Scale.Z, 2));
138 138
139 foreach (LLUUID picktree in m_trees) 139 foreach (LLUUID picktree in m_trees)
140 { 140 {
141 if (picktree != tree) 141 if (picktree != tree)
142 { 142 {
143 SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart; 143 SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart;
144 144
145 double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + 145 double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
146 Math.Pow(pickedTree.Scale.Y, 2) + 146 Math.Pow(pickedTree.Scale.Y, 2) +
147 Math.Pow(pickedTree.Scale.Z, 2)); 147 Math.Pow(pickedTree.Scale.Z, 2));
148 148
149 double pickedTreeDistance = Math.Sqrt(Math.Pow(Math.Abs(pickedTree.AbsolutePosition.X - selectedTree.AbsolutePosition.X), 2) + 149 double pickedTreeDistance = Math.Sqrt(Math.Pow(Math.Abs(pickedTree.AbsolutePosition.X - selectedTree.AbsolutePosition.X), 2) +
150 Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Y - selectedTree.AbsolutePosition.Y), 2) + 150 Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Y - selectedTree.AbsolutePosition.Y), 2) +
151 Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Z - selectedTree.AbsolutePosition.Z), 2)); 151 Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Z - selectedTree.AbsolutePosition.Z), 2));
152 152
153 killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1; 153 killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1;
154 } 154 }
155 } 155 }
156 156
157 if (Util.RandomClass.NextDouble() < killLikelyhood) 157 if (Util.RandomClass.NextDouble() < killLikelyhood)
158 { 158 {
159 m_scene.RemoveEntity(selectedTree.ParentGroup); 159 m_scene.RemoveEntity(selectedTree.ParentGroup);
160 m_trees.Remove(selectedTree.ParentGroup.UUID); 160 m_trees.Remove(selectedTree.ParentGroup.UUID);
161 161
162 m_scene.ForEachClient(delegate(IClientAPI controller) 162 m_scene.ForEachClient(delegate(IClientAPI controller)
163 { 163 {
164 controller.SendKillObject(m_scene.RegionInfo.RegionHandle, 164 controller.SendKillObject(m_scene.RegionInfo.RegionHandle,
165 selectedTree.LocalID); 165 selectedTree.LocalID);
166 }); 166 });
167 167
168 break; 168 break;
169 } 169 }
170 else 170 else
171 { 171 {
172 selectedTree.SetText(killLikelyhood.ToString(), new Axiom.Math.Vector3(1.0f, 1.0f, 1.0f), 1.0); 172 selectedTree.SetText(killLikelyhood.ToString(), new Axiom.Math.Vector3(1.0f, 1.0f, 1.0f), 1.0);
173 } 173 }
174 } 174 }
175 else 175 else
176 { 176 {
177 m_trees.Remove(tree); 177 m_trees.Remove(tree);
178 } 178 }
179 } 179 }
180 } 180 }
181 181
182 private void SpawnChild(SceneObjectPart s_tree) 182 private void SpawnChild(SceneObjectPart s_tree)
183 { 183 {
184 LLVector3 position = new LLVector3(); 184 LLVector3 position = new LLVector3();
185 185
186 position.X = s_tree.AbsolutePosition.X + (1 * (-1 * Util.RandomClass.Next(1))); 186 position.X = s_tree.AbsolutePosition.X + (1 * (-1 * Util.RandomClass.Next(1)));
187 if (position.X > 255) 187 if (position.X > 255)
188 position.X = 255; 188 position.X = 255;
189 if (position.X < 0) 189 if (position.X < 0)
190 position.X = 0; 190 position.X = 0;
191 position.Y = s_tree.AbsolutePosition.Y + (1 * (-1 * Util.RandomClass.Next(1))); 191 position.Y = s_tree.AbsolutePosition.Y + (1 * (-1 * Util.RandomClass.Next(1)));
192 if (position.Y > 255) 192 if (position.Y > 255)
193 position.Y = 255; 193 position.Y = 255;
194 if (position.Y < 0) 194 if (position.Y < 0)
195 position.Y = 0; 195 position.Y = 0;
196 196
197 double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); 197 double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
198 double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); 198 double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
199 199
200 position.X += (float)randX; 200 position.X += (float)randX;
201 position.Y += (float)randY; 201 position.Y += (float)randY;
202 202
203 CreateTree(position); 203 CreateTree(position);
204 } 204 }
205 205
206 private void CreateTree(LLVector3 position) 206 private void CreateTree(LLVector3 position)
207 { 207 {
208 position.Z = (float)m_scene.Terrain.heightmap.Get((int)position.X, (int)position.Y); 208 position.Z = (float)m_scene.Terrain.heightmap.Get((int)position.X, (int)position.Y);
209 209
210 SceneObjectGroup tree = 210 SceneObjectGroup tree =
211 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), 211 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f),
212 LLQuaternion.Identity, 212 LLQuaternion.Identity,
213 position, 213 position,
214 Tree.Cypress1, 214 Tree.Cypress1,
215 false); 215 false);
216 216
217 m_trees.Add(tree.UUID); 217 m_trees.Add(tree.UUID);
218 tree.SendGroupFullUpdate(); 218 tree.SendGroupFullUpdate();
219 } 219 }
220 220
221 void CalculateTrees_Elapsed(object sender, System.Timers.ElapsedEventArgs e) 221 void CalculateTrees_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
222 { 222 {
223 growTrees(); 223 growTrees();
224 seedTrees(); 224 seedTrees();
225 killTrees(); 225 killTrees();
226 } 226 }
227 227
228 public void PostInitialise() 228 public void PostInitialise()
229 { 229 {
230 } 230 }
231 231
232 public void Close() 232 public void Close()
233 { 233 {
234 } 234 }
235 235
236 public string Name 236 public string Name
237 { 237 {
238 get { return "TreePopulatorModule"; } 238 get { return "TreePopulatorModule"; }
239 } 239 }
240 240
241 public bool IsSharedModule 241 public bool IsSharedModule
242 { 242 {
243 get { return false; } 243 get { return false; }
244 } 244 }
245 } 245 }
246} \ No newline at end of file 246} \ No newline at end of file