aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs')
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs375
1 files changed, 0 insertions, 375 deletions
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs
deleted file mode 100644
index 0248f36..0000000
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Drawing;
31
32using OpenMetaverse;
33
34using Nini.Config;
35
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Serialization;
40using OpenSim.Region.Physics.Manager;
41
42using log4net;
43
44namespace OpenSim.Region.OptionalModules.ContentManagement
45{
46 public class ContentManagementEntity : MetaEntity
47 {
48 #region Static Fields
49
50// static float TimeToDiff = 0;
51// static float TimeToCreateEntities = 0;
52
53 #endregion Static Fields
54
55 #region Fields
56
57 protected Dictionary<UUID, AuraMetaEntity> m_AuraEntities = new Dictionary<UUID, AuraMetaEntity>();
58 protected Dictionary<UUID, BeamMetaEntity> m_BeamEntities = new Dictionary<UUID, BeamMetaEntity>();
59
60 // The LinkNum of parts in m_Entity and m_UnchangedEntity are the same though UUID and LocalId are different.
61 // This can come in handy.
62 protected SceneObjectGroup m_UnchangedEntity = null;
63
64 /// <value>
65 /// Should be set to true when there is a difference between m_UnchangedEntity and the corresponding scene object group in the scene entity list.
66 /// </value>
67 bool DiffersFromSceneGroup = false;
68
69 #endregion Fields
70
71 #region Constructors
72
73 public ContentManagementEntity(SceneObjectGroup Unchanged, bool physics)
74 : base(Unchanged, false)
75 {
76 m_UnchangedEntity = Unchanged.Copy(false);
77 }
78
79 public ContentManagementEntity(string objectXML, Scene scene, bool physics)
80 : base(objectXML, scene, false)
81 {
82 m_UnchangedEntity = SceneObjectSerializer.FromXml2Format(objectXML);
83 }
84
85 #endregion Constructors
86
87 #region Public Properties
88
89 public SceneObjectGroup UnchangedEntity
90 {
91 get { return m_UnchangedEntity; }
92 }
93
94 #endregion Public Properties
95
96 #region Private Methods
97
98 /// <summary>
99 /// Check if an entitybase list (like that returned by scene.GetEntities()) contains a group with the rootpart uuid that matches the current uuid.
100 /// </summary>
101 private bool ContainsKey(List<EntityBase> list, UUID uuid)
102 {
103 foreach (EntityBase part in list)
104 if (part.UUID == uuid)
105 return true;
106 return false;
107 }
108
109 private SceneObjectGroup GetGroupByUUID(System.Collections.Generic.List<EntityBase> list, UUID uuid)
110 {
111 foreach (EntityBase ent in list)
112 {
113 if (ent is SceneObjectGroup)
114 if (ent.UUID == uuid)
115 return (SceneObjectGroup)ent;
116 }
117 return null;
118 }
119
120 #endregion Private Methods
121
122 #region Public Methods
123
124 /// <summary>
125 /// Search for a corresponding group UUID in the scene. If not found, then the revisioned group this CMEntity represents has been deleted. Mark the metaentity appropriately.
126 /// If a matching UUID is found in a scene object group, compare the two for differences. If differences exist, Mark the metaentity appropriately.
127 /// </summary>
128 public void FindDifferences()
129 {
130 List<EntityBase> sceneEntityList = new List<EntityBase>(m_Entity.Scene.GetEntities());
131 DiffersFromSceneGroup = false;
132 // if group is not contained in scene's list
133 if (!ContainsKey(sceneEntityList, m_UnchangedEntity.UUID))
134 {
135 foreach (SceneObjectPart part in m_UnchangedEntity.Parts)
136 {
137 // if scene list no longer contains this part, display translucent part and mark with red aura
138 if (!ContainsKey(sceneEntityList, part.UUID))
139 {
140 // if already displaying a red aura over part, make sure its red
141 if (m_AuraEntities.ContainsKey(part.UUID))
142 {
143 m_AuraEntities[part.UUID].SetAura(new Vector3(254, 0, 0), part.Scale);
144 }
145 else
146 {
147 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
148 part.GetWorldPosition(),
149 MetaEntity.TRANSLUCENT,
150 new Vector3(254, 0, 0),
151 part.Scale
152 );
153 m_AuraEntities.Add(part.UUID, auraGroup);
154 }
155 SceneObjectPart metaPart = m_Entity.GetLinkNumPart(part.LinkNum);
156 SetPartTransparency(metaPart, MetaEntity.TRANSLUCENT);
157 }
158 // otherwise, scene will not contain the part. note: a group can not remove a part without changing group id
159 }
160
161 // a deleted part has no where to point a beam particle system,
162 // if a metapart had a particle system (maybe it represented a moved part) remove it
163 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
164 {
165 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
166 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
167 }
168
169 DiffersFromSceneGroup = true;
170 }
171 // if scene list does contain group, compare each part in group for differences and display beams and auras appropriately
172 else
173 {
174 MarkWithDifferences((SceneObjectGroup)GetGroupByUUID(sceneEntityList, m_UnchangedEntity.UUID));
175 }
176 }
177
178 /// <summary>
179 /// Check if the revisioned scene object group that this CMEntity is based off of contains a child with the given UUID.
180 /// </summary>
181 public bool HasChildPrim(UUID uuid)
182 {
183 return m_UnchangedEntity.ContainsPart(uuid);
184 }
185
186 /// <summary>
187 /// Check if the revisioned scene object group that this CMEntity is based off of contains a child with the given LocalId.
188 /// </summary>
189 public bool HasChildPrim(uint localID)
190 {
191 foreach (SceneObjectPart part in m_UnchangedEntity.Parts)
192 if (part.LocalId == localID)
193 return true;
194
195 return false;
196 }
197
198 public override void Hide(IClientAPI client)
199 {
200 base.Hide(client);
201 foreach (MetaEntity group in m_AuraEntities.Values)
202 group.Hide(client);
203 foreach (MetaEntity group in m_BeamEntities.Values)
204 group.Hide(client);
205 }
206
207 public override void HideFromAll()
208 {
209 base.HideFromAll();
210 foreach (MetaEntity group in m_AuraEntities.Values)
211 group.HideFromAll();
212 foreach (MetaEntity group in m_BeamEntities.Values)
213 group.HideFromAll();
214 }
215
216 /// <summary>
217 /// Returns true if there was a change between meta entity and the entity group, false otherwise.
218 /// If true is returned, it is assumed the metaentity's appearance has changed to reflect the difference (though clients haven't been updated).
219 /// </summary>
220 public bool MarkWithDifferences(SceneObjectGroup sceneEntityGroup)
221 {
222 SceneObjectPart sceneEntityPart;
223 SceneObjectPart metaEntityPart;
224 Diff differences;
225 bool changed = false;
226
227 // Use "UnchangedEntity" to do comparisons because its text, transparency, and other attributes will be just as the user
228 // had originally saved.
229 // m_Entity will NOT necessarily be the same entity as the user had saved.
230 foreach (SceneObjectPart UnchangedPart in m_UnchangedEntity.Parts)
231 {
232 //This is the part that we use to show changes.
233 metaEntityPart = m_Entity.GetLinkNumPart(UnchangedPart.LinkNum);
234 if (sceneEntityGroup.ContainsPart(UnchangedPart.UUID))
235 {
236 sceneEntityPart = sceneEntityGroup.GetChildPart(UnchangedPart.UUID);
237 differences = Difference.FindDifferences(UnchangedPart, sceneEntityPart);
238 if (differences != Diff.NONE)
239 metaEntityPart.Text = "CHANGE: " + differences.ToString();
240 if (differences != 0)
241 {
242 // Root Part that has been modified
243 if ((differences & Diff.POSITION) > 0)
244 {
245 // If the position of any part has changed, make sure the RootPart of the
246 // meta entity is pointing with a beam particle system
247 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
248 {
249 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
250 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
251 }
252 BeamMetaEntity beamGroup = new BeamMetaEntity(m_Entity.Scene,
253 m_UnchangedEntity.RootPart.GetWorldPosition(),
254 MetaEntity.TRANSLUCENT,
255 sceneEntityPart,
256 new Vector3(0, 0, 254)
257 );
258 m_BeamEntities.Add(m_UnchangedEntity.RootPart.UUID, beamGroup);
259 }
260
261 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
262 {
263 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
264 m_AuraEntities.Remove(UnchangedPart.UUID);
265 }
266 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
267 UnchangedPart.GetWorldPosition(),
268 MetaEntity.TRANSLUCENT,
269 new Vector3(0, 0, 254),
270 UnchangedPart.Scale
271 );
272 m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
273 SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
274
275 DiffersFromSceneGroup = true;
276 }
277 else // no differences between scene part and meta part
278 {
279 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
280 {
281 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
282 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
283 }
284 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
285 {
286 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
287 m_AuraEntities.Remove(UnchangedPart.UUID);
288 }
289 SetPartTransparency(metaEntityPart, MetaEntity.NONE);
290 }
291 }
292 else //The entity currently in the scene is missing parts from the metaentity saved, so mark parts red as deleted.
293 {
294 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
295 {
296 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
297 m_AuraEntities.Remove(UnchangedPart.UUID);
298 }
299 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
300 UnchangedPart.GetWorldPosition(),
301 MetaEntity.TRANSLUCENT,
302 new Vector3(254, 0, 0),
303 UnchangedPart.Scale
304 );
305 m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
306 SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
307
308 DiffersFromSceneGroup = true;
309 }
310 }
311
312 return changed;
313 }
314
315 public void SendFullAuraUpdate(IClientAPI client)
316 {
317 if (DiffersFromSceneGroup)
318 {
319 foreach (AuraMetaEntity group in m_AuraEntities.Values)
320 group.SendFullUpdate(client);
321 }
322 }
323
324 public void SendFullAuraUpdateToAll()
325 {
326 if (DiffersFromSceneGroup)
327 {
328 foreach (AuraMetaEntity group in m_AuraEntities.Values)
329 group.SendFullUpdateToAll();
330 }
331 }
332
333 public void SendFullBeamUpdate(IClientAPI client)
334 {
335 if (DiffersFromSceneGroup)
336 {
337 foreach (BeamMetaEntity group in m_BeamEntities.Values)
338 group.SendFullUpdate(client);
339 }
340 }
341
342 public void SendFullBeamUpdateToAll()
343 {
344 if (DiffersFromSceneGroup)
345 {
346 foreach (BeamMetaEntity group in m_BeamEntities.Values)
347 group.SendFullUpdateToAll();
348 }
349 }
350
351 public void SendFullDiffUpdate(IClientAPI client)
352 {
353 FindDifferences();
354 if (DiffersFromSceneGroup)
355 {
356 SendFullUpdate(client);
357 SendFullAuraUpdate(client);
358 SendFullBeamUpdate(client);
359 }
360 }
361
362 public void SendFullDiffUpdateToAll()
363 {
364 FindDifferences();
365 if (DiffersFromSceneGroup)
366 {
367 SendFullUpdateToAll();
368 SendFullAuraUpdateToAll();
369 SendFullBeamUpdateToAll();
370 }
371 }
372
373 #endregion Public Methods
374 }
375}