diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs | 229 |
1 files changed, 126 insertions, 103 deletions
diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs index a47f83a..3355fa3 100644 --- a/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs +++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs | |||
@@ -1,47 +1,128 @@ | |||
1 | #region Header | ||
2 | |||
1 | // CMModel.cs | 3 | // CMModel.cs |
2 | // User: bongiojp | 4 | // User: bongiojp |
3 | // | 5 | // |
4 | // | 6 | // |
5 | 7 | ||
8 | #endregion Header | ||
9 | |||
6 | using System; | 10 | using System; |
7 | using System.Collections.Generic; | ||
8 | using System.Collections; | 11 | using System.Collections; |
12 | using System.Collections.Generic; | ||
13 | using System.Diagnostics; | ||
14 | |||
9 | using libsecondlife; | 15 | using libsecondlife; |
16 | |||
10 | using OpenSim; | 17 | using OpenSim; |
11 | using OpenSim.Framework; | 18 | using OpenSim.Framework; |
12 | using OpenSim.Region.Environment.Interfaces; | 19 | using OpenSim.Region.Environment.Interfaces; |
13 | using OpenSim.Region.Environment.Scenes; | 20 | using OpenSim.Region.Environment.Scenes; |
14 | using log4net; | ||
15 | using OpenSim.Region.Physics.Manager; | 21 | using OpenSim.Region.Physics.Manager; |
22 | |||
23 | using log4net; | ||
24 | |||
16 | using Axiom.Math; | 25 | using Axiom.Math; |
17 | using System.Diagnostics; | ||
18 | 26 | ||
19 | namespace OpenSim.Region.Environment.Modules.ContentManagement | 27 | namespace OpenSim.Region.Environment.Modules.ContentManagement |
20 | { | 28 | { |
21 | |||
22 | public class CMModel | 29 | public class CMModel |
23 | { | 30 | { |
31 | #region Static Fields | ||
32 | |||
24 | static float TimeToUpdate = 0; | 33 | static float TimeToUpdate = 0; |
25 | static float TimeToConvertXml = 0; | 34 | static float TimeToConvertXml = 0; |
26 | |||
27 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 35 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
28 | 36 | ||
29 | IContentDatabase m_database = null; | 37 | #endregion Static Fields |
30 | 38 | ||
39 | #region Fields | ||
40 | |||
31 | /// <value> | 41 | /// <value> |
32 | /// The class that contains all auras and metaentities used in the CMS. | 42 | /// The class that contains all auras and metaentities used in the CMS. |
33 | /// </value> | 43 | /// </value> |
34 | CMEntityCollection m_MetaEntityCollection = new CMEntityCollection(); | 44 | CMEntityCollection m_MetaEntityCollection = new CMEntityCollection(); |
35 | 45 | IContentDatabase m_database = null; | |
46 | |||
47 | #endregion Fields | ||
48 | |||
49 | #region Constructors | ||
50 | |||
51 | public CMModel() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | #endregion Constructors | ||
56 | |||
57 | #region Public Properties | ||
58 | |||
36 | public CMEntityCollection MetaEntityCollection | 59 | public CMEntityCollection MetaEntityCollection |
37 | { | 60 | { |
38 | get { return m_MetaEntityCollection; } | 61 | get { return m_MetaEntityCollection; } |
39 | } | 62 | } |
40 | 63 | ||
41 | public CMModel() | 64 | #endregion Public Properties |
65 | |||
66 | #region Public Methods | ||
67 | |||
68 | /// <summary> | ||
69 | /// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity | ||
70 | /// it is a new part that must have a green aura (for diff mode). | ||
71 | /// Returns list of ContentManagementEntities | ||
72 | /// </summary> | ||
73 | public ArrayList CheckForNewEntitiesMissingAuras(Scene scene) | ||
74 | { | ||
75 | ArrayList missingList = null; | ||
76 | ArrayList newList = new ArrayList(); | ||
77 | |||
78 | m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName); | ||
79 | |||
80 | //Check if the current scene has groups not included in the current list of MetaEntities | ||
81 | //If so, then the current scene's parts that are new should be marked green. | ||
82 | missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities()); | ||
83 | |||
84 | foreach(Object missingPart in missingList) | ||
85 | { | ||
86 | if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID)) | ||
87 | continue; | ||
88 | newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart)); | ||
89 | } | ||
90 | m_log.Info("Number of missing objects found: " + newList.Count); | ||
91 | return newList; | ||
92 | } | ||
93 | |||
94 | /// <summary> | ||
95 | /// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message. | ||
96 | /// </summary> | ||
97 | public void CommitRegion(Scene scene, String logMessage) | ||
42 | { | 98 | { |
99 | m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length); | ||
100 | m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage); | ||
101 | m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName ); | ||
43 | } | 102 | } |
44 | 103 | ||
104 | public void DeleteAllMetaObjects() | ||
105 | { | ||
106 | m_MetaEntityCollection.ClearAll(); | ||
107 | } | ||
108 | |||
109 | public ContentManagementEntity FindMetaEntityAffectedByUndo(LLUUID uuid) | ||
110 | { | ||
111 | ContentManagementEntity ent = GetMetaGroupByPrim(uuid); | ||
112 | return ent; | ||
113 | } | ||
114 | |||
115 | //-------------------------------- HELPERS --------------------------------------------------------------------// | ||
116 | public ContentManagementEntity GetMetaGroupByPrim(LLUUID uuid) | ||
117 | { | ||
118 | foreach (Object ent in m_MetaEntityCollection.Entities.Values) | ||
119 | { | ||
120 | if (((ContentManagementEntity)ent).HasChildPrim(uuid)) | ||
121 | return (ContentManagementEntity)ent; | ||
122 | } | ||
123 | return null; | ||
124 | } | ||
125 | |||
45 | public void Initialise(string database) | 126 | public void Initialise(string database) |
46 | { | 127 | { |
47 | if (database == "FileSystemDatabase") | 128 | if (database == "FileSystemDatabase") |
@@ -49,12 +130,12 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
49 | else if (database == "GitDatabase") | 130 | else if (database == "GitDatabase") |
50 | m_database = new GitDatabase(); | 131 | m_database = new GitDatabase(); |
51 | } | 132 | } |
52 | 133 | ||
53 | public void InitialiseDatabase(Scene scene, string dir) | 134 | public void InitialiseDatabase(Scene scene, string dir) |
54 | { | 135 | { |
55 | m_database.Initialise(scene, dir); | 136 | m_database.Initialise(scene, dir); |
56 | } | 137 | } |
57 | 138 | ||
58 | /// <summary> | 139 | /// <summary> |
59 | /// Should be called just once to finish initializing the database. | 140 | /// Should be called just once to finish initializing the database. |
60 | /// </summary> | 141 | /// </summary> |
@@ -62,13 +143,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
62 | { | 143 | { |
63 | m_database.PostInitialise(); | 144 | m_database.PostInitialise(); |
64 | } | 145 | } |
65 | 146 | ||
66 | public ContentManagementEntity FindMetaEntityAffectedByUndo(LLUUID uuid) | ||
67 | { | ||
68 | ContentManagementEntity ent = GetMetaGroupByPrim(uuid); | ||
69 | return ent; | ||
70 | } | ||
71 | |||
72 | /// <summary> | 147 | /// <summary> |
73 | /// Removes the green aura when an a new scene object group is deleted. | 148 | /// Removes the green aura when an a new scene object group is deleted. |
74 | /// </summary> | 149 | /// </summary> |
@@ -79,17 +154,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
79 | if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID)) | 154 | if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID)) |
80 | m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID); | 155 | m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID); |
81 | } | 156 | } |
82 | 157 | ||
83 | /// <summary> | ||
84 | /// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message. | ||
85 | /// </summary> | ||
86 | public void CommitRegion(Scene scene, String logMessage) | ||
87 | { | ||
88 | m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length); | ||
89 | m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage); | ||
90 | m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName ); | ||
91 | } | ||
92 | |||
93 | /// <summary> | 158 | /// <summary> |
94 | /// Retrieves the latest revision of a region in xml form, | 159 | /// Retrieves the latest revision of a region in xml form, |
95 | /// converts it to scene object groups and scene presences, | 160 | /// converts it to scene object groups and scene presences, |
@@ -105,20 +170,20 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
105 | Dictionary<LLUUID, EntityBase> ReplacementList = new Dictionary<LLUUID,EntityBase>(); | 170 | Dictionary<LLUUID, EntityBase> ReplacementList = new Dictionary<LLUUID,EntityBase>(); |
106 | int revision = m_database.GetMostRecentRevision(scene.RegionInfo.RegionID); | 171 | int revision = m_database.GetMostRecentRevision(scene.RegionInfo.RegionID); |
107 | EntityBase[] searchArray; | 172 | EntityBase[] searchArray; |
108 | 173 | ||
109 | xmllist = m_database.GetRegionObjectXMLList(scene.RegionInfo.RegionID, revision); | 174 | xmllist = m_database.GetRegionObjectXMLList(scene.RegionInfo.RegionID, revision); |
110 | if (xmllist == null) | 175 | if (xmllist == null) |
111 | { | 176 | { |
112 | m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") does not have given revision number (" + revision + ")."); | 177 | m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") does not have given revision number (" + revision + ")."); |
113 | return; | 178 | return; |
114 | } | 179 | } |
115 | 180 | ||
116 | m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") revision number (" + revision + ")."); | 181 | m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") revision number (" + revision + ")."); |
117 | m_log.Info("[CMMODEL]: Scene Objects = " + xmllist.Count); | 182 | m_log.Info("[CMMODEL]: Scene Objects = " + xmllist.Count); |
118 | m_log.Info("[CMMODEL]: Converting scene entities list to specified revision."); | 183 | m_log.Info("[CMMODEL]: Converting scene entities list to specified revision."); |
119 | 184 | ||
120 | m_log.ErrorFormat("[CMMODEL]: 1"); | 185 | m_log.ErrorFormat("[CMMODEL]: 1"); |
121 | 186 | ||
122 | foreach (string xml in xmllist) | 187 | foreach (string xml in xmllist) |
123 | { | 188 | { |
124 | try{ | 189 | try{ |
@@ -143,7 +208,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
143 | { | 208 | { |
144 | if (entity == null) | 209 | if (entity == null) |
145 | continue; | 210 | continue; |
146 | 211 | ||
147 | if (entity is ScenePresence) | 212 | if (entity is ScenePresence) |
148 | { | 213 | { |
149 | ReplacementList.Add(entity.UUID, entity); | 214 | ReplacementList.Add(entity.UUID, entity); |
@@ -162,7 +227,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
162 | } | 227 | } |
163 | break; | 228 | break; |
164 | } | 229 | } |
165 | 230 | ||
166 | foreach(LLUUID uuid in deleteListUUIDs.Keys) | 231 | foreach(LLUUID uuid in deleteListUUIDs.Keys) |
167 | { | 232 | { |
168 | try | 233 | try |
@@ -179,7 +244,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
179 | m_log.ErrorFormat("[CMMODEL]: Error while removing objects from scene: " + e); | 244 | m_log.ErrorFormat("[CMMODEL]: Error while removing objects from scene: " + e); |
180 | } | 245 | } |
181 | } | 246 | } |
182 | 247 | ||
183 | lock (scene) | 248 | lock (scene) |
184 | { | 249 | { |
185 | scene.Entities = ReplacementList; | 250 | scene.Entities = ReplacementList; |
@@ -191,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
191 | { | 256 | { |
192 | if (!(ent is SceneObjectGroup)) | 257 | if (!(ent is SceneObjectGroup)) |
193 | continue; | 258 | continue; |
194 | 259 | ||
195 | if ((((SceneObjectGroup)ent).RootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) | 260 | if ((((SceneObjectGroup)ent).RootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) |
196 | ((SceneObjectGroup)ent).ApplyPhysics(true); | 261 | ((SceneObjectGroup)ent).ApplyPhysics(true); |
197 | ((SceneObjectGroup)ent).AttachToBackup(); | 262 | ((SceneObjectGroup)ent).AttachToBackup(); |
@@ -206,32 +271,6 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
206 | m_log.Info("[CMMODEL]: Scheduling a backup of new scene object groups to backup."); | 271 | m_log.Info("[CMMODEL]: Scheduling a backup of new scene object groups to backup."); |
207 | scene.Backup(); | 272 | scene.Backup(); |
208 | } | 273 | } |
209 | |||
210 | /// <summary> | ||
211 | /// Detects if a scene object group from the scene list has moved or changed scale. The green aura | ||
212 | /// that surrounds the object is then moved or scaled with the group. | ||
213 | /// </summary> | ||
214 | public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group) | ||
215 | { | ||
216 | System.Collections.ArrayList auraList = new System.Collections.ArrayList(); | ||
217 | if (group == null) | ||
218 | return null; | ||
219 | foreach(SceneObjectPart part in group.Children.Values) | ||
220 | { | ||
221 | if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID)) | ||
222 | { | ||
223 | ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new LLVector3(0,254,0), part.Scale); | ||
224 | ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition(); | ||
225 | auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]); | ||
226 | } | ||
227 | } | ||
228 | return auraList; | ||
229 | } | ||
230 | |||
231 | public void DeleteAllMetaObjects() | ||
232 | { | ||
233 | m_MetaEntityCollection.ClearAll(); | ||
234 | } | ||
235 | 274 | ||
236 | /// <summary> | 275 | /// <summary> |
237 | /// Downloads the latest revision of the given scene and converts the xml file to CMEntities. After this method, the view can find the differences | 276 | /// Downloads the latest revision of the given scene and converts the xml file to CMEntities. After this method, the view can find the differences |
@@ -257,53 +296,37 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
257 | TimeToConvertXml += y.ElapsedMilliseconds; | 296 | TimeToConvertXml += y.ElapsedMilliseconds; |
258 | m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities for " + scene.RegionInfo.RegionName + ": " + y.ElapsedMilliseconds); | 297 | m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities for " + scene.RegionInfo.RegionName + ": " + y.ElapsedMilliseconds); |
259 | m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities so far: " + TimeToConvertXml); | 298 | m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities so far: " + TimeToConvertXml); |
260 | 299 | ||
261 | m_log.Info("[FSDB]: checking for new scene object parts missing green auras and create the auras"); | 300 | m_log.Info("[FSDB]: checking for new scene object parts missing green auras and create the auras"); |
262 | CheckForNewEntitiesMissingAuras(scene); | 301 | CheckForNewEntitiesMissingAuras(scene); |
263 | 302 | ||
264 | x.Stop(); | 303 | x.Stop(); |
265 | TimeToUpdate += x.ElapsedMilliseconds; | 304 | TimeToUpdate += x.ElapsedMilliseconds; |
266 | m_log.Info("[FileSystemDatabase] Time spent Updating entity list for " + scene.RegionInfo.RegionName + ": " + x.ElapsedMilliseconds); | 305 | m_log.Info("[FileSystemDatabase] Time spent Updating entity list for " + scene.RegionInfo.RegionName + ": " + x.ElapsedMilliseconds); |
267 | m_log.Info("[FileSystemDatabase] Time spent Updating so far: " + TimeToUpdate); | 306 | m_log.Info("[FileSystemDatabase] Time spent Updating so far: " + TimeToUpdate); |
268 | |||
269 | } | 307 | } |
270 | 308 | ||
271 | /// <summary> | 309 | /// <summary> |
272 | /// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity | 310 | /// Detects if a scene object group from the scene list has moved or changed scale. The green aura |
273 | /// it is a new part that must have a green aura (for diff mode). | 311 | /// that surrounds the object is then moved or scaled with the group. |
274 | /// Returns list of ContentManagementEntities | ||
275 | /// </summary> | 312 | /// </summary> |
276 | public ArrayList CheckForNewEntitiesMissingAuras(Scene scene) | 313 | public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group) |
277 | { | ||
278 | ArrayList missingList = null; | ||
279 | ArrayList newList = new ArrayList(); | ||
280 | |||
281 | m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName); | ||
282 | |||
283 | //Check if the current scene has groups not included in the current list of MetaEntities | ||
284 | //If so, then the current scene's parts that are new should be marked green. | ||
285 | missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities()); | ||
286 | |||
287 | foreach(Object missingPart in missingList) | ||
288 | { | ||
289 | if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID)) | ||
290 | continue; | ||
291 | newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart)); | ||
292 | } | ||
293 | m_log.Info("Number of missing objects found: " + newList.Count); | ||
294 | return newList; | ||
295 | } | ||
296 | |||
297 | //-------------------------------- HELPERS --------------------------------------------------------------------// | ||
298 | |||
299 | public ContentManagementEntity GetMetaGroupByPrim(LLUUID uuid) | ||
300 | { | 314 | { |
301 | foreach (Object ent in m_MetaEntityCollection.Entities.Values) | 315 | System.Collections.ArrayList auraList = new System.Collections.ArrayList(); |
316 | if (group == null) | ||
317 | return null; | ||
318 | foreach(SceneObjectPart part in group.Children.Values) | ||
302 | { | 319 | { |
303 | if (((ContentManagementEntity)ent).HasChildPrim(uuid)) | 320 | if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID)) |
304 | return (ContentManagementEntity)ent; | 321 | { |
322 | ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new LLVector3(0,254,0), part.Scale); | ||
323 | ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition(); | ||
324 | auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]); | ||
325 | } | ||
305 | } | 326 | } |
306 | return null; | 327 | return auraList; |
307 | } | 328 | } |
308 | } | 329 | |
330 | #endregion Public Methods | ||
331 | } | ||
309 | } \ No newline at end of file | 332 | } \ No newline at end of file |