aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world/World.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer/world/World.cs')
-rw-r--r--OpenSim.RegionServer/world/World.cs100
1 files changed, 71 insertions, 29 deletions
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 0d126e6..3c131b2 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -14,6 +14,7 @@ namespace OpenSim.world
14{ 14{
15 public class World : ILocalStorageReceiver 15 public class World : ILocalStorageReceiver
16 { 16 {
17 public object LockPhysicsEngine = new object();
17 public Dictionary<libsecondlife.LLUUID, Entity> Entities; 18 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
18 public float[] LandMap; 19 public float[] LandMap;
19 public ScriptEngine Scripts; 20 public ScriptEngine Scripts;
@@ -25,19 +26,19 @@ namespace OpenSim.world
25 private Random Rand = new Random(); 26 private Random Rand = new Random();
26 private uint _primCount = 702000; 27 private uint _primCount = 702000;
27 private int storageCount; 28 private int storageCount;
28 private Dictionary<uint, SimClient> m_clientThreads; 29 private Dictionary<uint, SimClient> m_clientThreads;
29 private ulong m_regionHandle; 30 private ulong m_regionHandle;
30 private string m_regionName; 31 private string m_regionName;
31 private SimConfig m_cfg; 32 private SimConfig m_cfg;
32 33
33 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName, SimConfig cfg) 34 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName, SimConfig cfg)
34 { 35 {
35 m_clientThreads = clientThreads; 36 m_clientThreads = clientThreads;
36 m_regionHandle = regionHandle; 37 m_regionHandle = regionHandle;
37 m_regionName = regionName; 38 m_regionName = regionName;
38 m_cfg = cfg; 39 m_cfg = cfg;
39 40
40 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); 41 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
41 Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); 42 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
42 43
43 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); 44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
@@ -73,8 +74,11 @@ namespace OpenSim.world
73 { 74 {
74 Entities[UUID].addForces(); 75 Entities[UUID].addForces();
75 } 76 }
76 77
77 this.phyScene.Simulate(timeStep); 78 lock (this.LockPhysicsEngine)
79 {
80 this.phyScene.Simulate(timeStep);
81 }
78 82
79 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 83 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
80 { 84 {
@@ -118,18 +122,49 @@ namespace OpenSim.world
118 this.localStorage = store; 122 this.localStorage = store;
119 return(store == null); 123 return(store == null);
120 } 124 }
125
126 public void RegenerateTerrain()
127 {
128 HeightmapGenHills hills = new HeightmapGenHills();
129 this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
130 lock (this.LockPhysicsEngine)
131 {
132 this.phyScene.SetTerrain(this.LandMap);
133 }
134 m_cfg.SaveMap(this.LandMap);
135
136 foreach (SimClient client in m_clientThreads.Values)
137 {
138 this.SendLayerData(client);
139 }
140
141 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
142 {
143 Entities[UUID].LandRenegerated();
144 }
145 }
146
147 public void RegenerateTerrain(float[] newMap)
148 {
149
150 this.LandMap = newMap;
151 lock (this.LockPhysicsEngine)
152 {
153 this.phyScene.SetTerrain(this.LandMap);
154 }
155 m_cfg.SaveMap(this.LandMap);
156
157 foreach (SimClient client in m_clientThreads.Values)
158 {
159 this.SendLayerData(client);
160 }
161
162 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
163 {
164 Entities[UUID].LandRenegerated();
165 }
166 }
121 167
122 public void RegenerateTerrain()
123 {
124 HeightmapGenHills hills = new HeightmapGenHills();
125 this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
126 this.phyScene.SetTerrain(this.LandMap);
127 m_cfg.SaveMap(this.LandMap);
128
129 foreach(SimClient client in m_clientThreads.Values) {
130 this.SendLayerData(client);
131 }
132 }
133 public void LoadPrimsFromStorage() 168 public void LoadPrimsFromStorage()
134 { 169 {
135 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives"); 170 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives");
@@ -143,7 +178,7 @@ namespace OpenSim.world
143 _primCount = prim.LocalID + 1; 178 _primCount = prim.LocalID + 1;
144 } 179 }
145 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage"); 180 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage");
146 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); 181 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
147 nPrim.CreateFromStorage(prim); 182 nPrim.CreateFromStorage(prim);
148 this.Entities.Add(nPrim.uuid, nPrim); 183 this.Entities.Add(nPrim.uuid, nPrim);
149 } 184 }
@@ -182,27 +217,34 @@ namespace OpenSim.world
182 } 217 }
183 } 218 }
184 219
185 public void AddViewerAgent(SimClient AgentClient) { 220 public void AddViewerAgent(SimClient AgentClient)
221 {
186 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); 222 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
187 Avatar NewAvatar = new Avatar(AgentClient, this, m_regionName, m_clientThreads, m_regionHandle ); 223 Avatar NewAvatar = new Avatar(AgentClient, this, m_regionName, m_clientThreads, m_regionHandle);
188 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); 224 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
189 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); 225 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
190 NewAvatar.SendRegionHandshake(this); 226 NewAvatar.SendRegionHandshake(this);
191 PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z); 227 PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z);
192 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec); 228 lock (this.LockPhysicsEngine)
229 {
230 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
231 }
193 this.Entities.Add(AgentClient.AgentID, NewAvatar); 232 this.Entities.Add(AgentClient.AgentID, NewAvatar);
194 } 233 }
195 234
196 public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) 235 public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient)
197 { 236 {
198 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); 237 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
199 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this ); 238 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
200 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); 239 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
201 PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z); 240 PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z);
202 PhysicsVector pSize = new PhysicsVector( 0.255f, 0.255f, 0.255f); 241 PhysicsVector pSize = new PhysicsVector( 0.255f, 0.255f, 0.255f);
203 if(OpenSim.world.Avatar.PhysicsEngineFlying) 242 if(OpenSim.world.Avatar.PhysicsEngineFlying)
204 { 243 {
205 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize ); 244 lock (this.LockPhysicsEngine)
245 {
246 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
247 }
206 } 248 }
207 //prim.PhysicsEnabled = true; 249 //prim.PhysicsEnabled = true;
208 this.Entities.Add(prim.uuid, prim); 250 this.Entities.Add(prim.uuid, prim);
@@ -243,9 +285,9 @@ namespace OpenSim.world
243 } 285 }
244 foreach( libsecondlife.LLUUID uuid in DeRezEnts ) 286 foreach( libsecondlife.LLUUID uuid in DeRezEnts )
245 { 287 {
246 lock (this.Entities) 288 lock (Entities)
247 { 289 {
248 this.Entities.Remove(uuid); 290 Entities.Remove(uuid);
249 } 291 }
250 } 292 }
251 293