| 7 |
using ModularRex.RexNetwork; |
using ModularRex.RexNetwork; |
| 8 |
using Nini.Config; |
using Nini.Config; |
| 9 |
using OpenMetaverse; |
using OpenMetaverse; |
| 10 |
using OpenSim.Region.Environment.Interfaces; |
using OpenSim.Region.Framework.Interfaces; |
| 11 |
using OpenSim.Region.Environment.Scenes; |
using OpenSim.Region.Framework.Scenes; |
|
using OpenSim.Data.NHibernate; |
|
| 12 |
using OpenSim.Framework; |
using OpenSim.Framework; |
| 13 |
|
using ModularRex.NHibernate; |
| 14 |
|
using OpenSim.Framework.Communications.Cache; |
| 15 |
|
|
| 16 |
namespace ModularRex.RexParts |
namespace ModularRex.RexParts |
| 17 |
{ |
{ |
| 18 |
public class ModrexObjects : IRegionModule |
public class ModrexObjects : IRegionModule, IRexObjectPropertiesEventManager, IModrexObjectsProvider |
| 19 |
{ |
{ |
| 20 |
private static readonly ILog m_log = |
private static readonly ILog m_log = |
| 21 |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
| 22 |
|
|
| 23 |
//private Dictionary<UUID,RexObjectProperties> m_objs = new Dictionary<UUID, RexObjectProperties>(); |
private RexObjectPropertiesManager RexObjectPropertiesCache = new RexObjectPropertiesManager(); |
| 24 |
private List<Scene> m_scenes = new List<Scene>(); |
private List<Scene> m_scenes = new List<Scene>(); |
| 25 |
|
|
| 26 |
private NHibernateRexObjectData m_db; |
private NHibernateRexObjectData m_db; |
| 27 |
private string m_db_connectionstring; |
private string m_db_connectionstring; |
| 28 |
|
|
| 29 |
|
public delegate void OnChangePythonClassDelegate(UUID id); |
| 30 |
public event OnChangePythonClassDelegate OnPythonClassChange; |
public event OnChangePythonClassDelegate OnPythonClassChange; |
| 31 |
|
|
| 32 |
public void Initialise(Scene scene, IConfigSource source) |
public void Initialise(Scene scene, IConfigSource source) |
| 33 |
{ |
{ |
| 34 |
m_scenes.Add(scene); |
m_scenes.Add(scene); |
| 35 |
|
|
| 36 |
|
scene.RegisterModuleInterface<ModrexObjects>(this); |
| 37 |
|
scene.RegisterModuleInterface<IModrexObjectsProvider>(this); |
| 38 |
scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
| 39 |
|
scene.SceneContents.OnObjectDuplicate += SceneGraph_OnObjectDuplicate; |
| 40 |
|
scene.SceneContents.OnObjectRemove += SceneGraph_OnObjectRemove; |
| 41 |
|
|
| 42 |
|
scene.AddCommand(this, "modreximport", "load 0.4 rex database <connstring>", "conn string example: SQLiteDialect;SQLite20Driver;Data Source=beneath_the_waves.db;Version=3", HandleLoadRexLegacyData); |
| 43 |
|
|
| 44 |
if (m_db == null) |
if (m_db == null) |
| 45 |
{ |
{ |
| 67 |
|
|
| 68 |
void EventManager_OnClientConnect(OpenSim.Framework.Client.IClientCore client) |
void EventManager_OnClientConnect(OpenSim.Framework.Client.IClientCore client) |
| 69 |
{ |
{ |
| 70 |
RexClientView rcv; |
RexClientViewBase rcv; |
| 71 |
if (client.TryGet(out rcv)) |
if (client.TryGet(out rcv)) |
| 72 |
{ |
{ |
| 73 |
rcv.OnRexObjectProperties += rcv_OnRexObjectProperties; |
rcv.OnRexObjectProperties += rcv_OnRexObjectProperties; |
| 74 |
|
rcv.OnPrimFreeData += rcv_OnPrimFreeData; |
| 75 |
//rcv.OnChatFromClient += rcv_OnChatFromClient; |
//rcv.OnChatFromClient += rcv_OnChatFromClient; |
| 76 |
|
|
| 77 |
// Send them the current Scene. |
// Send them the current Scene. |
| 79 |
} |
} |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
|
private void rcv_OnPrimFreeData(IClientAPI sender, List<string> parameters) |
| 83 |
|
{ |
| 84 |
|
m_log.Info("[REXOBJS] Received Prim free data"); |
| 85 |
|
if (parameters.Count >= 2) |
| 86 |
|
{ |
| 87 |
|
UUID primID = new UUID(parameters[0]); |
| 88 |
|
string data = String.Empty; |
| 89 |
|
if(parameters.Count == 2) |
| 90 |
|
{ |
| 91 |
|
data = parameters[1]; |
| 92 |
|
}else |
| 93 |
|
{ |
| 94 |
|
for (int i = 1; i < parameters.Count; i++) |
| 95 |
|
{ |
| 96 |
|
data += parameters[i]; |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
RexObjectProperties props = GetObject(primID); |
| 101 |
|
props.RexData = data; |
| 102 |
|
|
| 103 |
|
SendPrimFreeDataToAllUsers(primID, data); |
| 104 |
|
} |
| 105 |
|
else |
| 106 |
|
{ |
| 107 |
|
m_log.Warn("[REXOBJS] unexpected number of parameters"); |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
void SendPrimFreeDataToAllUsers(UUID id, string data) |
| 112 |
|
{ |
| 113 |
|
foreach (Scene scene in m_scenes) |
| 114 |
|
{ |
| 115 |
|
scene.ForEachScenePresence( |
| 116 |
|
delegate(ScenePresence avatar) |
| 117 |
|
{ |
| 118 |
|
RexClientViewBase rex; |
| 119 |
|
if (avatar.ClientView.TryGet(out rex)) |
| 120 |
|
{ |
| 121 |
|
rex.SendRexPrimFreeData(id, data); |
| 122 |
|
} |
| 123 |
|
}); |
| 124 |
|
} |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase clone) |
| 128 |
|
{ |
| 129 |
|
RexObjectProperties origprops = GetObject(original.UUID); |
| 130 |
|
RexObjectProperties cloneprops = GetObject(clone.UUID); |
| 131 |
|
|
| 132 |
|
cloneprops.SetRexPrimDataFromObject(origprops); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
void SceneGraph_OnObjectRemove(EntityBase obj) |
| 136 |
|
{ |
| 137 |
|
DeleteObject(obj.UUID); |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
//void rcv_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage e) |
//void rcv_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage e) |
| 142 |
//{ |
//{ |
| 143 |
// if (e.Message.StartsWith("/rexobj ")) |
// if (e.Message.StartsWith("/rexobj ")) |
| 160 |
scene.ForEachScenePresence( |
scene.ForEachScenePresence( |
| 161 |
delegate(ScenePresence avatar) |
delegate(ScenePresence avatar) |
| 162 |
{ |
{ |
| 163 |
RexClientView rex; |
RexClientViewBase rex; |
| 164 |
if (avatar.ClientView.TryGet(out rex)) |
if (avatar.ClientView.TryGet(out rex)) |
| 165 |
{ |
{ |
| 166 |
rex.SendRexObjectProperties(id,props); |
rex.SendRexObjectProperties(id,props); |
| 169 |
} |
} |
| 170 |
} |
} |
| 171 |
|
|
| 172 |
void SendAllPropertiesToUser(RexClientView user) |
private void SendPreloadAssetsToUser(RexClientViewBase user) |
| 173 |
{ |
{ |
| 174 |
if (m_db.Inizialized) |
try |
| 175 |
{ |
{ |
| 176 |
|
Scene ourScene = null; |
| 177 |
foreach (Scene s in m_scenes) |
foreach (Scene s in m_scenes) |
| 178 |
{ |
{ |
| 179 |
foreach (EntityBase e in s.Entities) |
if (user.Scene.RegionInfo.RegionHandle == s.RegionInfo.RegionHandle) |
| 180 |
|
ourScene = s; |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
if (ourScene != null) |
| 184 |
{ |
{ |
| 185 |
RexObjectProperties p = m_db.LoadObject(e.UUID); |
if (ourScene.Modules.ContainsKey("RexAssetPreload")) |
|
if (p != null) |
|
| 186 |
{ |
{ |
| 187 |
user.SendRexObjectProperties(e.UUID, p); |
RexAssetPreload module = (RexAssetPreload)ourScene.Modules["RexAssetPreload"]; |
| 188 |
//p.OnPythonClassChange += PythonClassNameChanged; |
if (module.PreloadAssetDictionary.Count > 0) |
|
if (p.RexClassName.Length > 0) |
|
| 189 |
{ |
{ |
| 190 |
s.GetSceneObjectPart(e.UUID).SetScriptEvents(e.UUID, (int)scriptEvents.touch_start); |
user.SendRexPreloadAssets(module.PreloadAssetDictionary); |
| 191 |
} |
} |
| 192 |
} |
} |
| 193 |
} |
} |
| 194 |
} |
} |
| 195 |
|
catch (Exception e) |
| 196 |
|
{ |
| 197 |
|
m_log.Error("[MODREXOBJECTS]: Sending preload assets failed.", e); |
| 198 |
} |
} |
| 199 |
} |
} |
| 200 |
|
|
| 201 |
private void PythonClassNameChanged(UUID id) |
void SendAllPropertiesToUser(RexClientViewBase user) |
| 202 |
{ |
{ |
| 203 |
if (OnPythonClassChange != null) |
SendPreloadAssetsToUser(user); |
| 204 |
|
|
| 205 |
|
foreach (RexObjectProperties p in GetObjects()) |
| 206 |
{ |
{ |
| 207 |
OnPythonClassChange(id); |
user.SendRexObjectProperties(p.ParentObjectID, p); |
| 208 |
|
if (p.RexData.Length > 0) //send rex data also if exists |
| 209 |
|
{ |
| 210 |
|
user.SendRexPrimFreeData(p.ParentObjectID, p.RexData); |
| 211 |
|
} |
| 212 |
} |
} |
| 213 |
} |
} |
| 214 |
|
|
| 215 |
void rcv_OnRexObjectProperties(RexClientView sender, UUID id, RexObjectProperties props) |
void rcv_OnRexObjectProperties(IClientAPI sender, UUID id, RexObjectProperties props) |
| 216 |
{ |
{ |
| 217 |
m_log.Info("[REXOBJS] Received RexObjData for " + id); |
m_log.Info("[REXOBJS] Received RexObjData for " + id); |
| 218 |
if (props.ParentObjectID == UUID.Zero) |
if (props.ParentObjectID == UUID.Zero) |
| 219 |
props.ParentObjectID = id; |
props.ParentObjectID = id; |
| 220 |
|
|
| 221 |
props.PrintRexPrimdata(); // fixme, debugdata |
// debugdata props.PrintRexPrimdata(); |
| 222 |
|
|
| 223 |
// Before saving to db, check if values have changed from the previous values. |
RexObjectProperties currentprops = GetObject(id); |
| 224 |
RexObjectProperties oldprops = Load(id); |
currentprops.SetRexPrimDataFromObject(props); |
|
|
|
|
m_db.StoreObject(props); |
|
|
|
|
|
// Compare values |
|
|
if (oldprops.RexClassName != props.RexClassName) |
|
|
PythonClassNameChanged(props.ParentObjectID); |
|
|
if (oldprops.RexScaleToPrim != props.RexScaleToPrim) |
|
|
ScaleToPrimChanged(id); |
|
|
if (oldprops.RexCollisionMeshUUID != props.RexCollisionMeshUUID) |
|
|
CollisionMeshChanged(id); |
|
|
|
|
|
SendPropertiesToAllUsers(id, props); |
|
| 225 |
} |
} |
| 226 |
|
|
| 227 |
public void PostInitialise() |
public void PostInitialise() |
| 233 |
m_db.Initialise(m_db_connectionstring); |
m_db.Initialise(m_db_connectionstring); |
| 234 |
} |
} |
| 235 |
} |
} |
| 236 |
|
LoadRexObjectPropertiesToCache(); |
| 237 |
} |
} |
| 238 |
|
|
| 239 |
public void Close() |
public void Close() |
| 251 |
get { return true; } |
get { return true; } |
| 252 |
} |
} |
| 253 |
|
|
|
public RexObjectProperties Load(UUID id) |
|
|
{ |
|
|
RexObjectProperties robject = m_db.LoadObject(id); |
|
|
if (robject == null) |
|
|
{ |
|
|
robject = new RexObjectProperties(); |
|
|
robject.ParentObjectID = id; |
|
|
} |
|
|
return robject; |
|
|
} |
|
| 254 |
|
|
| 255 |
public void Save(RexObjectProperties obj) |
|
| 256 |
|
#region Trigger/handle rexobjectproperties events |
| 257 |
|
public void TriggerOnChangePythonClass(UUID id) |
| 258 |
{ |
{ |
| 259 |
m_db.StoreObject(obj); |
if (OnPythonClassChange != null) |
| 260 |
|
OnPythonClassChange(id); |
| 261 |
} |
} |
| 262 |
|
|
| 263 |
private void CollisionMeshChanged(UUID id) |
public void TriggerOnChangeCollisionMesh(UUID id) |
| 264 |
{ |
{ |
| 265 |
// tucofixme, add |
// tucofixme, add |
| 266 |
//if (!GlobalSettings.Instance.m_3d_collision_models) |
//if (!GlobalSettings.Instance.m_3d_collision_models) |
| 267 |
// return; |
// return; |
| 268 |
|
|
| 269 |
RexObjectProperties p = m_db.LoadObject(id); |
RexObjectProperties p = GetObject(id); |
|
if (p == null) |
|
|
{ |
|
|
m_log.Error("[REXOBJS] CollisionMeshChanged, no RexObjectProperties for id:" + id.ToString()); |
|
|
return; |
|
|
} |
|
|
|
|
| 270 |
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(id); |
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(id); |
| 271 |
if (sop == null) |
if (sop == null) |
| 272 |
{ |
{ |
| 273 |
m_log.Error("[REXOBJS] CollisionMeshChanged, no SceneObjectPart for id:" + id.ToString()); |
m_log.Error("[REXOBJS] TriggerOnChangeCollisionMesh, no SceneObjectPart for id:" + id.ToString()); |
| 274 |
return; |
return; |
| 275 |
} |
} |
| 276 |
|
|
| 277 |
if (sop.ParentGroup != null) |
if (sop.ParentGroup != null && sop.PhysActor is IRexPhysicsActor) |
|
{ |
|
|
if (sop.PhysActor != null) |
|
| 278 |
{ |
{ |
| 279 |
if (p.RexCollisionMeshUUID != UUID.Zero) |
if (p.RexCollisionMeshUUID != UUID.Zero) |
| 280 |
RexUpdateCollisionMesh(id); |
RexUpdateCollisionMesh(id); |
| 281 |
else |
else |
| 282 |
sop.PhysActor.SetCollisionMesh(null, "", false); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(null, "", false); |
|
} |
|
| 283 |
} |
} |
| 284 |
} |
} |
| 285 |
|
|
| 286 |
private void ScaleToPrimChanged(UUID id) |
public void TriggerOnChangeScaleToPrim(UUID id) |
| 287 |
{ |
{ |
| 288 |
// tucofixme, add |
// tucofixme, add |
| 289 |
//if (!GlobalSettings.Instance.m_3d_collision_models) |
//if (!GlobalSettings.Instance.m_3d_collision_models) |
| 290 |
// return; |
// return; |
| 291 |
|
|
| 292 |
RexObjectProperties p = m_db.LoadObject(id); |
RexObjectProperties p = GetObject(id); |
|
if(p == null) |
|
|
{ |
|
|
m_log.Error("[REXOBJS] ScaleToPrimChanged, no RexObjectProperties for id:" + id.ToString()); |
|
|
return; |
|
|
} |
|
|
|
|
| 293 |
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(id); |
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(id); |
| 294 |
if (sop == null) |
if (sop == null) |
| 295 |
{ |
{ |
| 296 |
m_log.Error("[REXOBJS] ScaleToPrimChanged, no SceneObjectPart for id:" + id.ToString()); |
m_log.Error("[REXOBJS] TriggerOnChangeScaleToPrim, no SceneObjectPart for id:" + id.ToString()); |
| 297 |
return; |
return; |
| 298 |
} |
} |
| 299 |
|
|
| 300 |
if (sop.ParentGroup != null) |
if (sop.ParentGroup != null && sop.PhysActor is IRexPhysicsActor) |
|
{ |
|
|
if (sop.PhysActor != null) |
|
| 301 |
{ |
{ |
| 302 |
sop.PhysActor.SetBoundsScaling(p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetBoundsScaling(p.RexScaleToPrim); |
| 303 |
sop.ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(sop.PhysActor); |
sop.ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(sop.PhysActor); |
| 304 |
} |
} |
| 305 |
} |
} |
| 306 |
|
|
| 307 |
|
public void TriggerOnChangeRexObjectProperties(UUID id) |
| 308 |
|
{ |
| 309 |
|
RexObjectProperties props = GetObject(id); |
| 310 |
|
|
| 311 |
|
//instead of saving right away, set timer to save after a sec. |
| 312 |
|
//m_db.StoreObject(props); |
| 313 |
|
SendPropertiesToAllUsers(id,props); |
| 314 |
|
props.ScheduleSave(); |
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
public void TriggerOnChangeRexObjectMetaData(UUID id) |
| 318 |
|
{ |
| 319 |
|
RexObjectProperties props = GetObject(id); |
| 320 |
|
|
| 321 |
|
m_db.StoreObject(props); |
| 322 |
|
// tucofixme, send metadata to all users |
| 323 |
} |
} |
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
public void RexUpdateCollisionMesh(UUID id) |
public void RexUpdateCollisionMesh(UUID id) |
| 328 |
{ |
{ |
| 329 |
// tucofixme |
// tucofixme, add |
| 330 |
//if (!GlobalSettings.Instance.m_3d_collision_models) |
//if (!GlobalSettings.Instance.m_3d_collision_models) |
| 331 |
// return; |
// return; |
| 332 |
|
|
| 333 |
RexObjectProperties p = m_db.LoadObject(id); |
RexObjectProperties p = GetObject(id); |
|
if (p == null) |
|
|
{ |
|
|
m_log.Error("[REXOBJS] RexUpdateCollisionMesh, no RexObjectProperties for id:" + id.ToString()); |
|
|
return; |
|
|
} |
|
|
|
|
| 334 |
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(id); |
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(id); |
| 335 |
if (sop == null) |
if (sop == null) |
| 336 |
{ |
{ |
| 338 |
return; |
return; |
| 339 |
} |
} |
| 340 |
|
|
| 341 |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor != null) |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor is IRexPhysicsActor) |
| 342 |
{ |
{ |
| 343 |
AssetBase tempmodel = sop.ParentGroup.Scene.AssetCache.GetAsset(p.RexCollisionMeshUUID,false); |
AssetBase tempmodel = sop.ParentGroup.Scene.AssetService.Get(p.RexCollisionMeshUUID.ToString()); |
| 344 |
if (tempmodel != null) |
if (tempmodel != null) |
| 345 |
sop.PhysActor.SetCollisionMesh(tempmodel.Data, tempmodel.Metadata.Name, p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(tempmodel.Data, tempmodel.Name, p.RexScaleToPrim); |
| 346 |
|
} |
| 347 |
|
} |
| 348 |
|
|
| 349 |
|
public byte GetAssetType(UUID assetid) |
| 350 |
|
{ |
| 351 |
|
AssetBase tempmodel = m_scenes[0].AssetService.Get(assetid.ToString()); |
| 352 |
|
if (tempmodel == null) |
| 353 |
|
m_scenes[0].AssetService.Get(assetid.ToString()); |
| 354 |
|
|
| 355 |
|
if (tempmodel != null) |
| 356 |
|
return(byte)(tempmodel.Type); |
| 357 |
|
else |
| 358 |
|
return 0; |
| 359 |
|
} |
| 360 |
|
|
| 361 |
|
|
| 362 |
|
public void TriggerOnSaveObject(UUID id) |
| 363 |
|
{ |
| 364 |
|
RexObjectProperties props = GetObject(id); |
| 365 |
|
m_db.StoreObject(props); |
| 366 |
|
} |
| 367 |
|
#endregion |
| 368 |
|
|
| 369 |
|
|
| 370 |
|
#region RexObjectProperties Cache |
| 371 |
|
|
| 372 |
|
private void LoadRexObjectPropertiesToCache() |
| 373 |
|
{ |
| 374 |
|
if (!m_db.Inizialized) |
| 375 |
|
{ |
| 376 |
|
m_log.ErrorFormat("LoadRexObjectPropertiesToCache failed, db not initialized"); |
| 377 |
|
return; |
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
foreach (Scene s in m_scenes) |
| 381 |
|
{ |
| 382 |
|
foreach (EntityBase e in s.Entities) |
| 383 |
|
{ |
| 384 |
|
RexObjectProperties p = LoadObject(e.UUID); |
| 385 |
|
p.ParentObjectID = e.UUID; |
| 386 |
|
p.SetRexEventManager(this); |
| 387 |
|
RexObjectPropertiesCache.Add(e.UUID,p); |
| 388 |
|
|
| 389 |
|
// Since loaded objects have their properties already set, any initialization that needs to be done should be here. |
| 390 |
|
if(p.RexCollisionMeshUUID != UUID.Zero) |
| 391 |
|
TriggerOnChangeCollisionMesh(e.UUID); |
| 392 |
|
|
| 393 |
|
if (p.RexClassName.Length > 0) |
| 394 |
|
{ |
| 395 |
|
SceneObjectPart sop = m_scenes[0].GetSceneObjectPart(p.ParentObjectID); |
| 396 |
|
if (sop != null) |
| 397 |
|
sop.SetScriptEvents(p.ParentObjectID, (int)scriptEvents.touch_start); |
| 398 |
|
} |
| 399 |
|
} |
| 400 |
} |
} |
| 401 |
} |
} |
| 402 |
|
|
| 403 |
|
private RexObjectProperties LoadObject(UUID id) |
| 404 |
|
{ |
| 405 |
|
RexObjectProperties robject = m_db.LoadObject(id); |
| 406 |
|
if (robject == null) |
| 407 |
|
{ |
| 408 |
|
robject = new RexObjectProperties(); |
| 409 |
|
robject.ParentObjectID = id; |
| 410 |
|
} |
| 411 |
|
return robject; |
| 412 |
|
} |
| 413 |
|
|
| 414 |
|
public RexObjectProperties GetObject(UUID id) |
| 415 |
|
{ |
| 416 |
|
RexObjectProperties props = RexObjectPropertiesCache[id]; |
| 417 |
|
if (props == null) |
| 418 |
|
{ |
| 419 |
|
//Objects that are not in the scene can't be found from cache. |
| 420 |
|
//So before we create new properties, we try to find them from db |
| 421 |
|
props = m_db.LoadObject(id); |
| 422 |
|
if (props == null) |
| 423 |
|
{ |
| 424 |
|
props = new RexObjectProperties(id, this); |
| 425 |
|
} |
| 426 |
|
RexObjectPropertiesCache.Add(id, props); |
| 427 |
|
} |
| 428 |
|
return props; |
| 429 |
|
} |
| 430 |
|
|
| 431 |
|
public List<RexObjectProperties> GetObjects() |
| 432 |
|
{ |
| 433 |
|
return RexObjectPropertiesCache.GetAllRexObjectProperties(); |
| 434 |
|
} |
| 435 |
|
|
| 436 |
|
public bool DeleteObject(UUID id) |
| 437 |
|
{ |
| 438 |
|
if (RexObjectPropertiesCache.ContainsKey(id)) |
| 439 |
|
{ |
| 440 |
|
RexObjectPropertiesCache.Remove(id); |
| 441 |
|
m_db.RemoveObject(id); |
| 442 |
|
return true; |
| 443 |
|
} |
| 444 |
|
return false; |
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
#endregion |
| 448 |
|
|
| 449 |
|
|
| 450 |
|
public void HandleLoadRexLegacyData(string module, string[] args) |
| 451 |
|
{ |
| 452 |
|
NHibernateRexLegacyData legacydata = new NHibernateRexLegacyData(); |
| 453 |
|
|
| 454 |
|
legacydata.Initialise(args[1]); |
| 455 |
|
if(!legacydata.Inizialized) |
| 456 |
|
{ |
| 457 |
|
m_log.Info("[MODREXOBJECTS]: Legacy database failed to initialize."); |
| 458 |
|
return; |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
List<RexLegacyPrimData> rexprimdata = legacydata.LoadAllRexPrimData(); |
| 462 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimdata objects loaded:" + rexprimdata.Count.ToString()); |
| 463 |
|
|
| 464 |
|
List<RexLegacyPrimMaterialData> rexprimmaterialdata = legacydata.LoadAllRexPrimMaterialData(); |
| 465 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimmaterialdata objects loaded:" + rexprimmaterialdata.Count.ToString()); |
| 466 |
|
|
| 467 |
|
foreach (RexLegacyPrimData prim in rexprimdata) |
| 468 |
|
{ |
| 469 |
|
RexObjectProperties p = GetObject(prim.UUID); |
| 470 |
|
p.SetRexPrimDataFromLegacyData(prim); |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
foreach (RexLegacyPrimMaterialData primmat in rexprimmaterialdata) |
| 474 |
|
{ |
| 475 |
|
RexObjectProperties p = GetObject(primmat.UUID); |
| 476 |
|
p.RexMaterials.AddMaterial((uint)primmat.MaterialIndex,primmat.MaterialUUID); |
| 477 |
|
} |
| 478 |
|
} |
| 479 |
|
|
| 480 |
} |
} |
| 481 |
} |
} |