aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObject.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObject.cs618
1 files changed, 309 insertions, 309 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs
index e615599..43d41e6 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObject.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs
@@ -1,309 +1,309 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.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*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types; 33using OpenSim.Framework.Types;
34using OpenSim.Physics.Manager; 34using OpenSim.Physics.Manager;
35 35
36namespace OpenSim.Region.Environment.Scenes 36namespace OpenSim.Region.Environment.Scenes
37{ 37{
38 public class SceneObject : EntityBase 38 public class SceneObject : EntityBase
39 { 39 {
40 private Encoding enc = Encoding.ASCII; 40 private Encoding enc = Encoding.ASCII;
41 private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group 41 private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group
42 public Primitive rootPrimitive; 42 public Primitive rootPrimitive;
43 private new Scene m_world; 43 private new Scene m_world;
44 protected ulong m_regionHandle; 44 protected ulong m_regionHandle;
45 45
46 private bool physicsEnabled = false; 46 private bool physicsEnabled = false;
47 private PhysicsScene m_PhysScene; 47 private PhysicsScene m_PhysScene;
48 private PhysicsActor m_PhysActor; 48 private PhysicsActor m_PhysActor;
49 49
50 private EventManager m_eventManager; 50 private EventManager m_eventManager;
51 51
52 public bool isSelected = false; 52 public bool isSelected = false;
53 53
54 public LLUUID rootUUID 54 public LLUUID rootUUID
55 { 55 {
56 get 56 get
57 { 57 {
58 this.uuid = this.rootPrimitive.uuid; 58 this.uuid = this.rootPrimitive.uuid;
59 return this.uuid; 59 return this.uuid;
60 } 60 }
61 } 61 }
62 62
63 public uint rootLocalID 63 public uint rootLocalID
64 { 64 {
65 get 65 get
66 { 66 {
67 this.m_localId = this.rootPrimitive.LocalId; 67 this.m_localId = this.rootPrimitive.LocalId;
68 return this.LocalId; 68 return this.LocalId;
69 } 69 }
70 } 70 }
71 71
72 public int primCount 72 public int primCount
73 { 73 {
74 get 74 get
75 { 75 {
76 return this.ChildPrimitives.Count; 76 return this.ChildPrimitives.Count;
77 } 77 }
78 } 78 }
79 79
80 public Dictionary<LLUUID, Primitive> Children 80 public Dictionary<LLUUID, Primitive> Children
81 { 81 {
82 get 82 get
83 { 83 {
84 return this.ChildPrimitives; 84 return this.ChildPrimitives;
85 } 85 }
86 } 86 }
87 87
88 /// <summary> 88 /// <summary>
89 /// 89 ///
90 /// </summary> 90 /// </summary>
91 public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) 91 public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
92 { 92 {
93 m_regionHandle = world.RegionInfo.RegionHandle; 93 m_regionHandle = world.RegionInfo.RegionHandle;
94 m_world = world; 94 m_world = world;
95 m_eventManager = eventManager; 95 m_eventManager = eventManager;
96 96
97 this.Pos = pos; 97 this.Pos = pos;
98 this.CreateRootFromShape(ownerID, localID, shape, pos); 98 this.CreateRootFromShape(ownerID, localID, shape, pos);
99 99
100 registerEvents(); 100 registerEvents();
101 101
102 } 102 }
103 103
104 /// <summary> 104 /// <summary>
105 /// 105 ///
106 /// </summary> 106 /// </summary>
107 /// <remarks>Need a null constructor for duplication</remarks> 107 /// <remarks>Need a null constructor for duplication</remarks>
108 public SceneObject() 108 public SceneObject()
109 { 109 {
110 110
111 } 111 }
112 112
113 public void registerEvents() 113 public void registerEvents()
114 { 114 {
115 m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); 115 m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup);
116 m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); 116 m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate);
117 } 117 }
118 118
119 public void unregisterEvents() 119 public void unregisterEvents()
120 { 120 {
121 m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); 121 m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup);
122 m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); 122 m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate);
123 } 123 }
124 124
125 /// <summary> 125 /// <summary>
126 /// Processes backup 126 /// Processes backup
127 /// </summary> 127 /// </summary>
128 /// <param name="datastore"></param> 128 /// <param name="datastore"></param>
129 public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) 129 public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
130 { 130 {
131 datastore.StoreObject(this); 131 datastore.StoreObject(this);
132 } 132 }
133 133
134 /// <summary> 134 /// <summary>
135 /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! 135 /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims!
136 /// </summary> 136 /// </summary>
137 private void ProcessParcelPrimCountUpdate() 137 private void ProcessParcelPrimCountUpdate()
138 { 138 {
139 139
140 m_eventManager.TriggerParcelPrimCountAdd(this); 140 m_eventManager.TriggerParcelPrimCountAdd(this);
141 } 141 }
142 142
143 /// <summary> 143 /// <summary>
144 /// 144 ///
145 /// </summary> 145 /// </summary>
146 /// <param name="addPacket"></param> 146 /// <param name="addPacket"></param>
147 /// <param name="agentID"></param> 147 /// <param name="agentID"></param>
148 /// <param name="localID"></param> 148 /// <param name="localID"></param>
149 public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) 149 public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos)
150 { 150 {
151 151
152 this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos); 152 this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos);
153 153
154 this.children.Add(rootPrimitive); 154 this.children.Add(rootPrimitive);
155 this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); 155 this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive);
156 } 156 }
157 157
158 /// <summary> 158 /// <summary>
159 /// 159 ///
160 /// </summary> 160 /// </summary>
161 /// <param name="data"></param> 161 /// <param name="data"></param>
162 public void CreateFromBytes(byte[] data) 162 public void CreateFromBytes(byte[] data)
163 { 163 {
164 164
165 } 165 }
166 166
167 /// <summary> 167 /// <summary>
168 /// Makes a copy of this SceneObject (and child primitives) 168 /// Makes a copy of this SceneObject (and child primitives)
169 /// </summary> 169 /// </summary>
170 /// <returns>A complete copy of the object</returns> 170 /// <returns>A complete copy of the object</returns>
171 public new SceneObject Copy() 171 public new SceneObject Copy()
172 { 172 {
173 SceneObject dupe = new SceneObject(); 173 SceneObject dupe = new SceneObject();
174 174
175 dupe.m_world = this.m_world; 175 dupe.m_world = this.m_world;
176 dupe.m_eventManager = this.m_eventManager; 176 dupe.m_eventManager = this.m_eventManager;
177 dupe.m_regionHandle = this.m_regionHandle; 177 dupe.m_regionHandle = this.m_regionHandle;
178 Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); 178 Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe);
179 dupe.rootPrimitive = newRoot; 179 dupe.rootPrimitive = newRoot;
180 dupe.children.Add(dupe.rootPrimitive); 180 dupe.children.Add(dupe.rootPrimitive);
181 dupe.rootPrimitive.Pos = this.Pos; 181 dupe.rootPrimitive.Pos = this.Pos;
182 dupe.Rotation = this.Rotation; 182 dupe.Rotation = this.Rotation;
183 dupe.LocalId = m_world.PrimIDAllocate(); 183 dupe.LocalId = m_world.PrimIDAllocate();
184 184
185 dupe.registerEvents(); 185 dupe.registerEvents();
186 return dupe; 186 return dupe;
187 } 187 }
188 188
189 /// <summary> 189 /// <summary>
190 /// 190 ///
191 /// </summary> 191 /// </summary>
192 public void DeleteAllChildren() 192 public void DeleteAllChildren()
193 { 193 {
194 this.children.Clear(); 194 this.children.Clear();
195 this.ChildPrimitives.Clear(); 195 this.ChildPrimitives.Clear();
196 this.rootPrimitive = null; 196 this.rootPrimitive = null;
197 unregisterEvents(); 197 unregisterEvents();
198 } 198 }
199 199
200 /// <summary> 200 /// <summary>
201 /// 201 ///
202 /// </summary> 202 /// </summary>
203 /// <param name="primObject"></param> 203 /// <param name="primObject"></param>
204 public void AddNewChildPrims(SceneObject primObject) 204 public void AddNewChildPrims(SceneObject primObject)
205 { 205 {
206 this.rootPrimitive.AddNewChildren(primObject); 206 this.rootPrimitive.AddNewChildren(primObject);
207 } 207 }
208 208
209 public void AddChildToList(Primitive prim) 209 public void AddChildToList(Primitive prim)
210 { 210 {
211 if (!this.ChildPrimitives.ContainsKey(prim.uuid)) 211 if (!this.ChildPrimitives.ContainsKey(prim.uuid))
212 { 212 {
213 this.ChildPrimitives.Add(prim.uuid, prim); 213 this.ChildPrimitives.Add(prim.uuid, prim);
214 } 214 }
215 } 215 }
216 /// <summary> 216 /// <summary>
217 /// 217 ///
218 /// </summary> 218 /// </summary>
219 /// <param name="primID"></param> 219 /// <param name="primID"></param>
220 /// <returns></returns> 220 /// <returns></returns>
221 public Primitive HasChildPrim(LLUUID primID) 221 public Primitive HasChildPrim(LLUUID primID)
222 { 222 {
223 if (this.ChildPrimitives.ContainsKey(primID)) 223 if (this.ChildPrimitives.ContainsKey(primID))
224 { 224 {
225 return this.ChildPrimitives[primID]; 225 return this.ChildPrimitives[primID];
226 } 226 }
227 227
228 return null; 228 return null;
229 } 229 }
230 230
231 /// <summary> 231 /// <summary>
232 /// 232 ///
233 /// </summary> 233 /// </summary>
234 /// <param name="localID"></param> 234 /// <param name="localID"></param>
235 /// <returns></returns> 235 /// <returns></returns>
236 public Primitive HasChildPrim(uint localID) 236 public Primitive HasChildPrim(uint localID)
237 { 237 {
238 Primitive returnPrim = null; 238 Primitive returnPrim = null;
239 foreach (Primitive prim in this.ChildPrimitives.Values) 239 foreach (Primitive prim in this.ChildPrimitives.Values)
240 { 240 {
241 if (prim.LocalId == localID) 241 if (prim.LocalId == localID)
242 { 242 {
243 returnPrim = prim; 243 returnPrim = prim;
244 break; 244 break;
245 } 245 }
246 } 246 }
247 return returnPrim; 247 return returnPrim;
248 } 248 }
249 249
250 public void SendAllChildPrimsToClient(IClientAPI client) 250 public void SendAllChildPrimsToClient(IClientAPI client)
251 { 251 {
252 this.rootPrimitive.SendFullUpdateForAllChildren(client); 252 this.rootPrimitive.SendFullUpdateForAllChildren(client);
253 } 253 }
254 254
255 /// <summary> 255 /// <summary>
256 /// 256 ///
257 /// </summary> 257 /// </summary>
258 public override void BackUp() 258 public override void BackUp()
259 { 259 {
260 260
261 } 261 }
262 262
263 /// <summary> 263 /// <summary>
264 /// 264 ///
265 /// </summary> 265 /// </summary>
266 /// <param name="offset"></param> 266 /// <param name="offset"></param>
267 /// <param name="pos"></param> 267 /// <param name="pos"></param>
268 /// <param name="remoteClient"></param> 268 /// <param name="remoteClient"></param>
269 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) 269 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
270 { 270 {
271 this.rootPrimitive.Pos = pos; 271 this.rootPrimitive.Pos = pos;
272 this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); 272 this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient);
273 } 273 }
274 274
275 /// <summary> 275 /// <summary>
276 /// 276 ///
277 /// </summary> 277 /// </summary>
278 /// <param name="client"></param> 278 /// <param name="client"></param>
279 public void GetProperites(IClientAPI client) 279 public void GetProperites(IClientAPI client)
280 { 280 {
281 ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); 281 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
282 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; 282 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
283 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); 283 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
284 proper.ObjectData[0].ItemID = LLUUID.Zero; 284 proper.ObjectData[0].ItemID = LLUUID.Zero;
285 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; 285 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate;
286 proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; 286 proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID;
287 proper.ObjectData[0].FolderID = LLUUID.Zero; 287 proper.ObjectData[0].FolderID = LLUUID.Zero;
288 proper.ObjectData[0].FromTaskID = LLUUID.Zero; 288 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
289 proper.ObjectData[0].GroupID = LLUUID.Zero; 289 proper.ObjectData[0].GroupID = LLUUID.Zero;
290 proper.ObjectData[0].InventorySerial = 0; 290 proper.ObjectData[0].InventorySerial = 0;
291 proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID; 291 proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID;
292 proper.ObjectData[0].ObjectID = this.rootUUID; 292 proper.ObjectData[0].ObjectID = this.rootUUID;
293 proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; 293 proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID;
294 proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); 294 proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0");
295 proper.ObjectData[0].TextureID = new byte[0]; 295 proper.ObjectData[0].TextureID = new byte[0];
296 proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0"); 296 proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0");
297 proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0"); 297 proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0");
298 proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0"); 298 proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0");
299 proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; 299 proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask;
300 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; 300 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask;
301 proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; 301 proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask;
302 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; 302 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask;
303 proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; 303 proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask;
304 304
305 client.OutPacket(proper); 305 client.OutPacket(proper);
306 } 306 }
307 307
308 } 308 }
309} 309}