aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDan Lake2011-07-20 15:01:32 -0700
committerDan Lake2011-07-20 15:01:32 -0700
commit2c11f7fc38ba14e041ed0e648088d574dadaaffe (patch)
treed593e3d1130e78ec74a11650d413f451a9a844da /OpenSim/Region
parentMerge branch 'master' into bulletsim (diff)
parentRemoved unused AddPrimShape methods in PhysicsScene caused by merge conflicts (diff)
downloadopensim-SC_OLD-2c11f7fc38ba14e041ed0e648088d574dadaaffe.zip
opensim-SC_OLD-2c11f7fc38ba14e041ed0e648088d574dadaaffe.tar.gz
opensim-SC_OLD-2c11f7fc38ba14e041ed0e648088d574dadaaffe.tar.bz2
opensim-SC_OLD-2c11f7fc38ba14e041ed0e648088d574dadaaffe.tar.xz
Merge branch 'master' into bulletsim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs19
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs8
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs10
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs75
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs479
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs301
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs104
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs219
-rw-r--r--OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs119
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs4
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs8
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs7
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs8
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs47
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs5
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs23
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs92
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs77
-rw-r--r--OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs7
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSScene.cs8
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs226
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs16
36 files changed, 1335 insertions, 620 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index d3bb0bc..8db4e67 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -331,14 +331,22 @@ namespace OpenSim.Region.ClientStack.Linden
331 } 331 }
332 } 332 }
333 333
334 /// <summary>
335 /// Handle a request from the client for a Uri to upload a baked texture.
336 /// </summary>
337 /// <param name="request"></param>
338 /// <param name="path"></param>
339 /// <param name="param"></param>
340 /// <param name="httpRequest"></param>
341 /// <param name="httpResponse"></param>
342 /// <returns>The upload response if the request is successful, null otherwise.</returns>
334 public string UploadBakedTexture(string request, string path, 343 public string UploadBakedTexture(string request, string path,
335 string param, OSHttpRequest httpRequest, 344 string param, OSHttpRequest httpRequest,
336 OSHttpResponse httpResponse) 345 OSHttpResponse httpResponse)
337 { 346 {
338 try 347 try
339 { 348 {
340 // m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + 349// m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
341 // m_regionName);
342 350
343 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; 351 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
344 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 352 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
@@ -374,6 +382,11 @@ namespace OpenSim.Region.ClientStack.Linden
374 return null; 382 return null;
375 } 383 }
376 384
385 /// <summary>
386 /// Called when a baked texture has been successfully uploaded by a client.
387 /// </summary>
388 /// <param name="assetID"></param>
389 /// <param name="data"></param>
377 public void BakedTextureUploaded(UUID assetID, byte[] data) 390 public void BakedTextureUploaded(UUID assetID, byte[] data)
378 { 391 {
379 // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); 392 // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
@@ -687,7 +700,7 @@ namespace OpenSim.Region.ClientStack.Linden
687 item.CurrentPermissions = (uint)PermissionMask.All; 700 item.CurrentPermissions = (uint)PermissionMask.All;
688 item.BasePermissions = (uint)PermissionMask.All; 701 item.BasePermissions = (uint)PermissionMask.All;
689 item.EveryOnePermissions = 0; 702 item.EveryOnePermissions = 0;
690 item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); 703 item.NextPermissions = (uint)PermissionMask.All;
691 item.CreationDate = Util.UnixTimeSinceEpoch(); 704 item.CreationDate = Util.UnixTimeSinceEpoch();
692 705
693 if (AddNewInventoryItem != null) 706 if (AddNewInventoryItem != null)
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs
index c9d7ae1..29a9199 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs
@@ -124,7 +124,7 @@ namespace OpenSim.Region.ClientStack.Linden
124 124
125 private Hashtable MeshUploadFlag(Hashtable mDhttpMethod) 125 private Hashtable MeshUploadFlag(Hashtable mDhttpMethod)
126 { 126 {
127 m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: MeshUploadFlag request"); 127// m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request");
128 128
129 OSDMap data = new OSDMap(); 129 OSDMap data = new OSDMap();
130 ScenePresence sp = m_scene.GetScenePresence(m_agentID); 130 ScenePresence sp = m_scene.GetScenePresence(m_agentID);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
index b7e79cc..b2f04f9 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
@@ -160,8 +160,6 @@ namespace OpenSim.Region.ClientStack.Linden
160 } 160 }
161 } 161 }
162 // } 162 // }
163
164
165 163
166 string assetName = llsdRequest.name; 164 string assetName = llsdRequest.name;
167 string assetDes = llsdRequest.description; 165 string assetDes = llsdRequest.description;
@@ -208,12 +206,10 @@ namespace OpenSim.Region.ClientStack.Linden
208 return uploadResponse; 206 return uploadResponse;
209 } 207 }
210 208
211
212 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, 209 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
213 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, 210 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
214 string assetType,UUID AgentID) 211 string assetType,UUID AgentID)
215 { 212 {
216
217 sbyte assType = 0; 213 sbyte assType = 0;
218 sbyte inType = 0; 214 sbyte inType = 0;
219 215
@@ -266,10 +262,10 @@ namespace OpenSim.Region.ClientStack.Linden
266 item.CurrentPermissions = (uint)PermissionMask.All; 262 item.CurrentPermissions = (uint)PermissionMask.All;
267 item.BasePermissions = (uint)PermissionMask.All; 263 item.BasePermissions = (uint)PermissionMask.All;
268 item.EveryOnePermissions = 0; 264 item.EveryOnePermissions = 0;
269 item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); 265 item.NextPermissions = (uint)PermissionMask.All;
270 item.CreationDate = Util.UnixTimeSinceEpoch(); 266 item.CreationDate = Util.UnixTimeSinceEpoch();
271 m_scene.AddInventoryItem(item); 267 m_scene.AddInventoryItem(item);
272 268
273 } 269 }
274 } 270 }
275} 271} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
index 15ed3b3..8189518 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
@@ -129,7 +129,7 @@ namespace OpenSim.Region.ClientStack.Linden
129 129
130 130
131 /// <summary> 131 /// <summary>
132 /// Parses ad request 132 /// Parses add request
133 /// </summary> 133 /// </summary>
134 /// <param name="request"></param> 134 /// <param name="request"></param>
135 /// <param name="AgentId"></param> 135 /// <param name="AgentId"></param>
@@ -312,11 +312,11 @@ namespace OpenSim.Region.ClientStack.Linden
312 primFace.RepeatV = face.ScaleT; 312 primFace.RepeatV = face.ScaleT;
313 primFace.TexMapType = (MappingType) (face.MediaFlags & 6); 313 primFace.TexMapType = (MappingType) (face.MediaFlags & 6);
314 } 314 }
315
315 pbs.TextureEntry = tmp.GetBytes(); 316 pbs.TextureEntry = tmp.GetBytes();
316 prim.Shape = pbs; 317 prim.Shape = pbs;
317 prim.Scale = obj.Scale; 318 prim.Scale = obj.Scale;
318 319
319
320 SceneObjectGroup grp = new SceneObjectGroup(); 320 SceneObjectGroup grp = new SceneObjectGroup();
321 321
322 grp.SetRootPart(prim); 322 grp.SetRootPart(prim);
@@ -339,8 +339,8 @@ namespace OpenSim.Region.ClientStack.Linden
339 m_scene.AddSceneObject(grp); 339 m_scene.AddSceneObject(grp);
340 grp.AbsolutePosition = obj.Position; 340 grp.AbsolutePosition = obj.Position;
341 } 341 }
342
342 allparts[i] = grp; 343 allparts[i] = grp;
343
344 } 344 }
345 345
346 for (int j = 1; j < allparts.Length; j++) 346 for (int j = 1; j < allparts.Length; j++)
@@ -351,7 +351,9 @@ namespace OpenSim.Region.ClientStack.Linden
351 } 351 }
352 352
353 rootGroup.ScheduleGroupForFullUpdate(); 353 rootGroup.ScheduleGroupForFullUpdate();
354 pos = m_scene.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale(), false); 354 pos
355 = m_scene.GetNewRezLocation(
356 Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale, false);
355 357
356 responsedata["int_response_code"] = 200; //501; //410; //404; 358 responsedata["int_response_code"] = 200; //501; //410; //404;
357 responsedata["content_type"] = "text/plain"; 359 responsedata["content_type"] = "text/plain";
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index c176c2b..a34ad62 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -574,22 +574,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP
574 return result; 574 return result;
575 } 575 }
576 576
577 /// <summary>
578 /// Add a handler for the given packet type.
579 /// </summary>
580 /// <remarks>The packet is handled on its own thread. If packets must be handled in the order in which thye
581 /// are received then please us ethe synchronous version of this method.</remarks>
582 /// <param name="packetType"></param>
583 /// <param name="handler"></param>
584 /// <returns>true if the handler was added. This is currently always the case.</returns>
577 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) 585 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
578 { 586 {
579 return AddLocalPacketHandler(packetType, handler, true); 587 return AddLocalPacketHandler(packetType, handler, true);
580 } 588 }
581 589
582 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool async) 590 /// <summary>
591 /// Add a handler for the given packet type.
592 /// </summary>
593 /// <param name="packetType"></param>
594 /// <param name="handler"></param>
595 /// <param name="doAsync">
596 /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
597 /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
598 /// synchronously.
599 /// </param>
600 /// <returns>true if the handler was added. This is currently always the case.</returns>
601 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
583 { 602 {
584 bool result = false; 603 bool result = false;
585 lock (m_packetHandlers) 604 lock (m_packetHandlers)
586 { 605 {
587 if (!m_packetHandlers.ContainsKey(packetType)) 606 if (!m_packetHandlers.ContainsKey(packetType))
588 { 607 {
589 m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = async }); 608 m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
590 result = true; 609 result = true;
591 } 610 }
592 } 611 }
612
593 return result; 613 return result;
594 } 614 }
595 615
@@ -11200,8 +11220,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11200 protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet) 11220 protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
11201 { 11221 {
11202 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; 11222 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
11203 if (multipleupdate.AgentData.SessionID != SessionId) return false; 11223
11204 // m_log.Debug("new multi update packet " + multipleupdate.ToString()); 11224 if (multipleupdate.AgentData.SessionID != SessionId)
11225 return false;
11226
11227// m_log.DebugFormat(
11228// "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
11229
11205 Scene tScene = (Scene)m_scene; 11230 Scene tScene = (Scene)m_scene;
11206 11231
11207 for (int i = 0; i < multipleupdate.ObjectData.Length; i++) 11232 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
@@ -11222,7 +11247,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11222 } 11247 }
11223 else 11248 else
11224 { 11249 {
11225 // UUID partId = part.UUID; 11250// m_log.DebugFormat(
11251// "[CLIENT]: Processing block {0} type {1} for {2} {3}",
11252// i, block.Type, part.Name, part.LocalId);
11253
11254// // Do this once since fetch parts creates a new array.
11255// SceneObjectPart[] parts = part.ParentGroup.Parts;
11256// for (int j = 0; j < parts.Length; j++)
11257// {
11258// part.StoreUndoState();
11259// parts[j].IgnoreUndoUpdate = true;
11260// }
11261
11226 UpdatePrimGroupRotation handlerUpdatePrimGroupRotation; 11262 UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
11227 11263
11228 switch (block.Type) 11264 switch (block.Type)
@@ -11237,6 +11273,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11237 handlerUpdatePrimSinglePosition(localId, pos1, this); 11273 handlerUpdatePrimSinglePosition(localId, pos1, this);
11238 } 11274 }
11239 break; 11275 break;
11276
11240 case 2: 11277 case 2:
11241 Quaternion rot1 = new Quaternion(block.Data, 0, true); 11278 Quaternion rot1 = new Quaternion(block.Data, 0, true);
11242 11279
@@ -11247,6 +11284,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11247 handlerUpdatePrimSingleRotation(localId, rot1, this); 11284 handlerUpdatePrimSingleRotation(localId, rot1, this);
11248 } 11285 }
11249 break; 11286 break;
11287
11250 case 3: 11288 case 3:
11251 Vector3 rotPos = new Vector3(block.Data, 0); 11289 Vector3 rotPos = new Vector3(block.Data, 0);
11252 Quaternion rot2 = new Quaternion(block.Data, 12, true); 11290 Quaternion rot2 = new Quaternion(block.Data, 12, true);
@@ -11259,6 +11297,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11259 handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this); 11297 handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
11260 } 11298 }
11261 break; 11299 break;
11300
11262 case 4: 11301 case 4:
11263 case 20: 11302 case 20:
11264 Vector3 scale4 = new Vector3(block.Data, 0); 11303 Vector3 scale4 = new Vector3(block.Data, 0);
@@ -11270,8 +11309,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11270 handlerUpdatePrimScale(localId, scale4, this); 11309 handlerUpdatePrimScale(localId, scale4, this);
11271 } 11310 }
11272 break; 11311 break;
11273 case 5:
11274 11312
11313 case 5:
11275 Vector3 scale1 = new Vector3(block.Data, 12); 11314 Vector3 scale1 = new Vector3(block.Data, 12);
11276 Vector3 pos11 = new Vector3(block.Data, 0); 11315 Vector3 pos11 = new Vector3(block.Data, 0);
11277 11316
@@ -11288,6 +11327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11288 } 11327 }
11289 } 11328 }
11290 break; 11329 break;
11330
11291 case 9: 11331 case 9:
11292 Vector3 pos2 = new Vector3(block.Data, 0); 11332 Vector3 pos2 = new Vector3(block.Data, 0);
11293 11333
@@ -11295,10 +11335,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11295 11335
11296 if (handlerUpdateVector != null) 11336 if (handlerUpdateVector != null)
11297 { 11337 {
11298
11299 handlerUpdateVector(localId, pos2, this); 11338 handlerUpdateVector(localId, pos2, this);
11300 } 11339 }
11301 break; 11340 break;
11341
11302 case 10: 11342 case 10:
11303 Quaternion rot3 = new Quaternion(block.Data, 0, true); 11343 Quaternion rot3 = new Quaternion(block.Data, 0, true);
11304 11344
@@ -11309,6 +11349,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11309 handlerUpdatePrimRotation(localId, rot3, this); 11349 handlerUpdatePrimRotation(localId, rot3, this);
11310 } 11350 }
11311 break; 11351 break;
11352
11312 case 11: 11353 case 11:
11313 Vector3 pos3 = new Vector3(block.Data, 0); 11354 Vector3 pos3 = new Vector3(block.Data, 0);
11314 Quaternion rot4 = new Quaternion(block.Data, 12, true); 11355 Quaternion rot4 = new Quaternion(block.Data, 12, true);
@@ -11332,6 +11373,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11332 handlerUpdatePrimGroupScale(localId, scale7, this); 11373 handlerUpdatePrimGroupScale(localId, scale7, this);
11333 } 11374 }
11334 break; 11375 break;
11376
11335 case 13: 11377 case 13:
11336 Vector3 scale2 = new Vector3(block.Data, 12); 11378 Vector3 scale2 = new Vector3(block.Data, 12);
11337 Vector3 pos4 = new Vector3(block.Data, 0); 11379 Vector3 pos4 = new Vector3(block.Data, 0);
@@ -11351,6 +11393,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11351 } 11393 }
11352 } 11394 }
11353 break; 11395 break;
11396
11354 case 29: 11397 case 29:
11355 Vector3 scale5 = new Vector3(block.Data, 12); 11398 Vector3 scale5 = new Vector3(block.Data, 12);
11356 Vector3 pos5 = new Vector3(block.Data, 0); 11399 Vector3 pos5 = new Vector3(block.Data, 0);
@@ -11359,6 +11402,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11359 if (handlerUpdatePrimGroupScale != null) 11402 if (handlerUpdatePrimGroupScale != null)
11360 { 11403 {
11361 // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 11404 // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
11405 part.StoreUndoState(true);
11406 part.IgnoreUndoUpdate = true;
11362 handlerUpdatePrimGroupScale(localId, scale5, this); 11407 handlerUpdatePrimGroupScale(localId, scale5, this);
11363 handlerUpdateVector = OnUpdatePrimGroupPosition; 11408 handlerUpdateVector = OnUpdatePrimGroupPosition;
11364 11409
@@ -11366,8 +11411,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11366 { 11411 {
11367 handlerUpdateVector(localId, pos5, this); 11412 handlerUpdateVector(localId, pos5, this);
11368 } 11413 }
11414
11415 part.IgnoreUndoUpdate = false;
11369 } 11416 }
11417
11370 break; 11418 break;
11419
11371 case 21: 11420 case 21:
11372 Vector3 scale6 = new Vector3(block.Data, 12); 11421 Vector3 scale6 = new Vector3(block.Data, 12);
11373 Vector3 pos6 = new Vector3(block.Data, 0); 11422 Vector3 pos6 = new Vector3(block.Data, 0);
@@ -11375,6 +11424,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11375 handlerUpdatePrimScale = OnUpdatePrimScale; 11424 handlerUpdatePrimScale = OnUpdatePrimScale;
11376 if (handlerUpdatePrimScale != null) 11425 if (handlerUpdatePrimScale != null)
11377 { 11426 {
11427 part.StoreUndoState(false);
11428 part.IgnoreUndoUpdate = true;
11429
11378 // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 11430 // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
11379 handlerUpdatePrimScale(localId, scale6, this); 11431 handlerUpdatePrimScale(localId, scale6, this);
11380 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; 11432 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
@@ -11382,15 +11434,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11382 { 11434 {
11383 handlerUpdatePrimSinglePosition(localId, pos6, this); 11435 handlerUpdatePrimSinglePosition(localId, pos6, this);
11384 } 11436 }
11437
11438 part.IgnoreUndoUpdate = false;
11385 } 11439 }
11386 break; 11440 break;
11441
11387 default: 11442 default:
11388 m_log.Debug("[CLIENT] MultipleObjUpdate recieved an unknown packet type: " + (block.Type)); 11443 m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
11389 break; 11444 break;
11390 } 11445 }
11446
11447// for (int j = 0; j < parts.Length; j++)
11448// parts[j].IgnoreUndoUpdate = false;
11391 } 11449 }
11392 } 11450 }
11393 } 11451 }
11452
11394 return true; 11453 return true;
11395 } 11454 }
11396 11455
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 520d794..1e09610 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -566,7 +566,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
566 /// <param name="silent"></param> 566 /// <param name="silent"></param>
567 protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) 567 protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
568 { 568 {
569
570 m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, 569 m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name,
571 attachmentpoint, attachOffset, so.RootPart.AttachedPos); 570 attachmentpoint, attachOffset, so.RootPart.AttachedPos);
572 571
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 1955e5b..75dbeb8 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -180,8 +180,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
180 } 180 }
181 181
182 /// <summary> 182 /// <summary>
183 /// Set appearance data (textureentry and slider settings) received from the client 183 /// Set appearance data (texture asset IDs and slider settings) received from the client
184 /// </summary> 184 /// </summary>
185 /// <param name="client"></param>
185 /// <param name="texture"></param> 186 /// <param name="texture"></param>
186 /// <param name="visualParam"></param> 187 /// <param name="visualParam"></param>
187 public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) 188 public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 321b38b..8d055d4 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -173,9 +173,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
173 { 173 {
174 if (m_RestURL != "") 174 if (m_RestURL != "")
175 { 175 {
176 m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId); 176 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
177 177
178 List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( 178 List<GridInstantMessage> msglist
179 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
179 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 180 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
180 181
181 if (msglist == null) 182 if (msglist == null)
@@ -203,7 +204,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
203 if ((im.offline != 0) 204 if ((im.offline != 0)
204 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) 205 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
205 { 206 {
206 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( 207 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
207 "POST", m_RestURL+"/SaveMessage/", im); 208 "POST", m_RestURL+"/SaveMessage/", im);
208 209
209 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 210 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
index c82cfd2..d687e6a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
@@ -196,7 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
196 if (!(client.Scene is Scene)) 196 if (!(client.Scene is Scene))
197 return; 197 return;
198 198
199 Scene scene = (Scene)(client.Scene); 199// Scene scene = (Scene)(client.Scene);
200 200
201 GridInstantMessage im = null; 201 GridInstantMessage im = null;
202 if (m_PendingLures.TryGetValue(lureID, out im)) 202 if (m_PendingLures.TryGetValue(lureID, out im))
diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs
index 079e1b6..dee0ad4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs
@@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile
134 if (!(s is Scene)) 134 if (!(s is Scene))
135 return; 135 return;
136 136
137 Scene scene = (Scene)s; 137// Scene scene = (Scene)s;
138 138
139 string profileUrl = String.Empty; 139 string profileUrl = String.Empty;
140 string aboutText = String.Empty; 140 string aboutText = String.Empty;
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 66fbcb9..b714f2b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -810,18 +810,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
810 // 810 //
811 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) 811 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
812 remoteClient.SendBulkUpdateInventory(item); 812 remoteClient.SendBulkUpdateInventory(item);
813
813 return null; 814 return null;
814 } 815 }
815 816
816 for (int i = 0 ; i < objlist.Count ; i++ ) 817 for (int i = 0 ; i < objlist.Count; i++)
817 { 818 {
818 group = objlist[i]; 819 group = objlist[i];
819 820
820 Vector3 storedPosition = group.AbsolutePosition; 821// Vector3 storedPosition = group.AbsolutePosition;
821 if (group.UUID == UUID.Zero) 822 if (group.UUID == UUID.Zero)
822 { 823 {
823 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); 824 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3");
824 } 825 }
826
825 group.RootPart.FromFolderID = item.Folder; 827 group.RootPart.FromFolderID = item.Folder;
826 828
827 // If it's rezzed in world, select it. Much easier to 829 // If it's rezzed in world, select it. Much easier to
@@ -833,6 +835,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
833 foreach (SceneObjectPart child in group.Parts) 835 foreach (SceneObjectPart child in group.Parts)
834 child.CreateSelected = true; 836 child.CreateSelected = true;
835 } 837 }
838
836 group.ResetIDs(); 839 group.ResetIDs();
837 840
838 if (attachment) 841 if (attachment)
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
index f15f8f6..b5cbcbb 100644
--- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
@@ -68,7 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
68 { 68 {
69 m_scene = scene; 69 m_scene = scene;
70 70
71
72 m_scene.AddCommand(this, "monitor report", 71 m_scene.AddCommand(this, "monitor report",
73 "monitor report", 72 "monitor report",
74 "Returns a variety of statistics about the current region and/or simulator", 73 "Returns a variety of statistics about the current region and/or simulator",
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 9c7b2fa..c832520 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
84 private ITerrainChannel m_revert; 84 private ITerrainChannel m_revert;
85 private Scene m_scene; 85 private Scene m_scene;
86 private volatile bool m_tainted; 86 private volatile bool m_tainted;
87 private readonly UndoStack<LandUndoState> m_undo = new UndoStack<LandUndoState>(5); 87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
88 88
89 #region ICommandableModule Members 89 #region ICommandableModule Members
90 90
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8195a0d..6e66632 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1751,8 +1751,9 @@ namespace OpenSim.Region.Framework.Scenes
1751 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1751 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1752 rootPart.Flags &= ~PrimFlags.Scripted; 1752 rootPart.Flags &= ~PrimFlags.Scripted;
1753 rootPart.TrimPermissions(); 1753 rootPart.TrimPermissions();
1754 group.CheckSculptAndLoad(); 1754
1755 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 1755 // Don't do this here - it will get done later on when sculpt data is loaded.
1756// group.CheckSculptAndLoad();
1756 } 1757 }
1757 1758
1758 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 1759 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
@@ -2715,12 +2716,14 @@ namespace OpenSim.Region.Framework.Scenes
2715 2716
2716 public virtual void SubscribeToClientPrimEvents(IClientAPI client) 2717 public virtual void SubscribeToClientPrimEvents(IClientAPI client)
2717 { 2718 {
2718 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; 2719 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2719 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2720 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2720 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; 2721
2721 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimRotation; 2722 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2723 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2722 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 2724 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
2723 client.OnUpdatePrimSingleRotationPosition += m_sceneGraph.UpdatePrimSingleRotationPosition; 2725 client.OnUpdatePrimSingleRotationPosition += m_sceneGraph.UpdatePrimSingleRotationPosition;
2726
2724 client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale; 2727 client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale;
2725 client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale; 2728 client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale;
2726 client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam; 2729 client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam;
@@ -2842,12 +2845,14 @@ namespace OpenSim.Region.Framework.Scenes
2842 2845
2843 public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) 2846 public virtual void UnSubscribeToClientPrimEvents(IClientAPI client)
2844 { 2847 {
2845 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimPosition; 2848 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
2846 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 2849 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
2847 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimRotation; 2850
2848 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimRotation; 2851 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2852 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2849 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 2853 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
2850 client.OnUpdatePrimSingleRotationPosition -= m_sceneGraph.UpdatePrimSingleRotationPosition; 2854 client.OnUpdatePrimSingleRotationPosition -= m_sceneGraph.UpdatePrimSingleRotationPosition;
2855
2851 client.OnUpdatePrimScale -= m_sceneGraph.UpdatePrimScale; 2856 client.OnUpdatePrimScale -= m_sceneGraph.UpdatePrimScale;
2852 client.OnUpdatePrimGroupScale -= m_sceneGraph.UpdatePrimGroupScale; 2857 client.OnUpdatePrimGroupScale -= m_sceneGraph.UpdatePrimGroupScale;
2853 client.OnUpdateExtraParams -= m_sceneGraph.UpdateExtraParam; 2858 client.OnUpdateExtraParams -= m_sceneGraph.UpdateExtraParam;
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 7ec7ea3..65dc2c9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -564,11 +564,13 @@ namespace OpenSim.Region.Framework.Scenes
564 part.Undo(); 564 part.Undo();
565 } 565 }
566 } 566 }
567
567 protected internal void HandleRedo(IClientAPI remoteClient, UUID primId) 568 protected internal void HandleRedo(IClientAPI remoteClient, UUID primId)
568 { 569 {
569 if (primId != UUID.Zero) 570 if (primId != UUID.Zero)
570 { 571 {
571 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId); 572 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId);
573
572 if (part != null) 574 if (part != null)
573 part.Redo(); 575 part.Redo();
574 } 576 }
@@ -1210,19 +1212,20 @@ namespace OpenSim.Region.Framework.Scenes
1210 #region Client Event handlers 1212 #region Client Event handlers
1211 1213
1212 /// <summary> 1214 /// <summary>
1213 /// 1215 /// Update the scale of an individual prim.
1214 /// </summary> 1216 /// </summary>
1215 /// <param name="localID"></param> 1217 /// <param name="localID"></param>
1216 /// <param name="scale"></param> 1218 /// <param name="scale"></param>
1217 /// <param name="remoteClient"></param> 1219 /// <param name="remoteClient"></param>
1218 protected internal void UpdatePrimScale(uint localID, Vector3 scale, IClientAPI remoteClient) 1220 protected internal void UpdatePrimScale(uint localID, Vector3 scale, IClientAPI remoteClient)
1219 { 1221 {
1220 SceneObjectGroup group = GetGroupByPrim(localID); 1222 SceneObjectPart part = GetSceneObjectPart(localID);
1221 if (group != null) 1223
1224 if (part != null)
1222 { 1225 {
1223 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1226 if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId))
1224 { 1227 {
1225 group.Resize(scale, localID); 1228 part.Resize(scale);
1226 } 1229 }
1227 } 1230 }
1228 } 1231 }
@@ -1234,7 +1237,7 @@ namespace OpenSim.Region.Framework.Scenes
1234 { 1237 {
1235 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1238 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId))
1236 { 1239 {
1237 group.GroupResize(scale, localID); 1240 group.GroupResize(scale);
1238 } 1241 }
1239 } 1242 }
1240 } 1243 }
@@ -1288,19 +1291,18 @@ namespace OpenSim.Region.Framework.Scenes
1288 { 1291 {
1289 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1292 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))
1290 { 1293 {
1291 group.UpdateSingleRotation(rot,pos, localID); 1294 group.UpdateSingleRotation(rot, pos, localID);
1292 } 1295 }
1293 } 1296 }
1294 } 1297 }
1295 1298
1296
1297 /// <summary> 1299 /// <summary>
1298 /// 1300 /// Update the rotation of a whole group.
1299 /// </summary> 1301 /// </summary>
1300 /// <param name="localID"></param> 1302 /// <param name="localID"></param>
1301 /// <param name="rot"></param> 1303 /// <param name="rot"></param>
1302 /// <param name="remoteClient"></param> 1304 /// <param name="remoteClient"></param>
1303 protected internal void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient) 1305 protected internal void UpdatePrimGroupRotation(uint localID, Quaternion rot, IClientAPI remoteClient)
1304 { 1306 {
1305 SceneObjectGroup group = GetGroupByPrim(localID); 1307 SceneObjectGroup group = GetGroupByPrim(localID);
1306 if (group != null) 1308 if (group != null)
@@ -1319,7 +1321,7 @@ namespace OpenSim.Region.Framework.Scenes
1319 /// <param name="pos"></param> 1321 /// <param name="pos"></param>
1320 /// <param name="rot"></param> 1322 /// <param name="rot"></param>
1321 /// <param name="remoteClient"></param> 1323 /// <param name="remoteClient"></param>
1322 protected internal void UpdatePrimRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient) 1324 protected internal void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient)
1323 { 1325 {
1324 SceneObjectGroup group = GetGroupByPrim(localID); 1326 SceneObjectGroup group = GetGroupByPrim(localID);
1325 if (group != null) 1327 if (group != null)
@@ -1350,12 +1352,12 @@ namespace OpenSim.Region.Framework.Scenes
1350 } 1352 }
1351 1353
1352 /// <summary> 1354 /// <summary>
1353 /// Update the position of the given part 1355 /// Update the position of the given group.
1354 /// </summary> 1356 /// </summary>
1355 /// <param name="localID"></param> 1357 /// <param name="localID"></param>
1356 /// <param name="pos"></param> 1358 /// <param name="pos"></param>
1357 /// <param name="remoteClient"></param> 1359 /// <param name="remoteClient"></param>
1358 public void UpdatePrimPosition(uint localID, Vector3 pos, IClientAPI remoteClient) 1360 public void UpdatePrimGroupPosition(uint localID, Vector3 pos, IClientAPI remoteClient)
1359 { 1361 {
1360 SceneObjectGroup group = GetGroupByPrim(localID); 1362 SceneObjectGroup group = GetGroupByPrim(localID);
1361 1363
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fa23fcd..b6fb5a4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -236,6 +236,38 @@ namespace OpenSim.Region.Framework.Scenes
236 get { return m_rootPart.RotationOffset; } 236 get { return m_rootPart.RotationOffset; }
237 } 237 }
238 238
239 public Vector3 GroupScale
240 {
241 get
242 {
243 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
244 Vector3 maxScale = Vector3.Zero;
245 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
246
247 SceneObjectPart[] parts = m_parts.GetArray();
248 for (int i = 0; i < parts.Length; i++)
249 {
250 SceneObjectPart part = parts[i];
251 Vector3 partscale = part.Scale;
252 Vector3 partoffset = part.OffsetPosition;
253
254 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
255 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
256 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
257
258 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
259 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
260 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
261 }
262
263 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
264 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
265 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
266
267 return finalScale;
268 }
269 }
270
239 public UUID GroupID 271 public UUID GroupID
240 { 272 {
241 get { return m_rootPart.GroupID; } 273 get { return m_rootPart.GroupID; }
@@ -584,7 +616,7 @@ namespace OpenSim.Region.Framework.Scenes
584 part.ParentID = m_rootPart.LocalId; 616 part.ParentID = m_rootPart.LocalId;
585 //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID); 617 //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
586 } 618 }
587 619
588 ApplyPhysics(m_scene.m_physicalPrim); 620 ApplyPhysics(m_scene.m_physicalPrim);
589 621
590 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled 622 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
@@ -592,34 +624,6 @@ namespace OpenSim.Region.Framework.Scenes
592 //ScheduleGroupForFullUpdate(); 624 //ScheduleGroupForFullUpdate();
593 } 625 }
594 626
595 public Vector3 GroupScale()
596 {
597 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
598 Vector3 maxScale = Vector3.Zero;
599 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
600
601 SceneObjectPart[] parts = m_parts.GetArray();
602 for (int i = 0; i < parts.Length; i++)
603 {
604 SceneObjectPart part = parts[i];
605 Vector3 partscale = part.Scale;
606 Vector3 partoffset = part.OffsetPosition;
607
608 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
609 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
610 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
611
612 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
613 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
614 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
615 }
616
617 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
618 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
619 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
620 return finalScale;
621
622 }
623 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) 627 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
624 { 628 {
625 // We got a request from the inner_scene to raytrace along the Ray hRay 629 // We got a request from the inner_scene to raytrace along the Ray hRay
@@ -1141,6 +1145,10 @@ namespace OpenSim.Region.Framework.Scenes
1141 1145
1142 public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) 1146 public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient)
1143 { 1147 {
1148// m_log.DebugFormat(
1149// "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}",
1150// remoteClient.Name, part.Name, part.LocalId, offsetPos);
1151
1144 part.StoreUndoState(); 1152 part.StoreUndoState();
1145 part.OnGrab(offsetPos, remoteClient); 1153 part.OnGrab(offsetPos, remoteClient);
1146 } 1154 }
@@ -1463,17 +1471,17 @@ namespace OpenSim.Region.Framework.Scenes
1463 // Need to duplicate the physics actor as well 1471 // Need to duplicate the physics actor as well
1464 if (part.PhysActor != null && userExposed) 1472 if (part.PhysActor != null && userExposed)
1465 { 1473 {
1466 PrimitiveBaseShape pbs = part.Shape; 1474 PrimitiveBaseShape pbs = newPart.Shape;
1467 1475
1468 newPart.PhysActor 1476 newPart.PhysActor
1469 = m_scene.PhysicsScene.AddPrimShape( 1477 = m_scene.PhysicsScene.AddPrimShape(
1470 part.LocalId, 1478 string.Format("{0}/{1}", newPart.Name, newPart.UUID),
1471 string.Format("{0}/{1}", part.Name, part.UUID),
1472 pbs, 1479 pbs,
1473 part.AbsolutePosition, 1480 newPart.AbsolutePosition,
1474 part.Scale, 1481 newPart.Scale,
1475 part.RotationOffset, 1482 newPart.RotationOffset,
1476 part.PhysActor.IsPhysical); 1483 part.PhysActor.IsPhysical,
1484 newPart.LocalId);
1477 1485
1478 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); 1486 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
1479 } 1487 }
@@ -2608,195 +2616,150 @@ namespace OpenSim.Region.Framework.Scenes
2608 #region Resize 2616 #region Resize
2609 2617
2610 /// <summary> 2618 /// <summary>
2611 /// Resize the given part 2619 /// Resize the entire group of prims.
2612 /// </summary> 2620 /// </summary>
2613 /// <param name="scale"></param> 2621 /// <param name="scale"></param>
2614 /// <param name="localID"></param> 2622 public void GroupResize(Vector3 scale)
2615 public void Resize(Vector3 scale, uint localID)
2616 { 2623 {
2617 if (scale.X > m_scene.m_maxNonphys) 2624// m_log.DebugFormat(
2618 scale.X = m_scene.m_maxNonphys; 2625// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
2619 if (scale.Y > m_scene.m_maxNonphys)
2620 scale.Y = m_scene.m_maxNonphys;
2621 if (scale.Z > m_scene.m_maxNonphys)
2622 scale.Z = m_scene.m_maxNonphys;
2623 2626
2624 SceneObjectPart part = GetChildPart(localID); 2627 RootPart.StoreUndoState(true);
2625 if (part != null)
2626 {
2627 part.Resize(scale);
2628 if (part.PhysActor != null)
2629 {
2630 if (part.PhysActor.IsPhysical)
2631 {
2632 if (scale.X > m_scene.m_maxPhys)
2633 scale.X = m_scene.m_maxPhys;
2634 if (scale.Y > m_scene.m_maxPhys)
2635 scale.Y = m_scene.m_maxPhys;
2636 if (scale.Z > m_scene.m_maxPhys)
2637 scale.Z = m_scene.m_maxPhys;
2638 }
2639 part.PhysActor.Size = scale;
2640 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2641 }
2642 //if (part.UUID != m_rootPart.UUID)
2643 2628
2644 HasGroupChanged = true; 2629 scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
2645 part.TriggerScriptChangedEvent(Changed.SCALE); 2630 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
2646 ScheduleGroupForFullUpdate(); 2631 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
2647 2632
2648 //if (part.UUID == m_rootPart.UUID) 2633 if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
2649 //{ 2634 {
2650 //if (m_rootPart.PhysActor != null) 2635 scale.X = Math.Min(scale.X, Scene.m_maxPhys);
2651 //{ 2636 scale.Y = Math.Min(scale.Y, Scene.m_maxPhys);
2652 //m_rootPart.PhysActor.Size = 2637 scale.Z = Math.Min(scale.Z, Scene.m_maxPhys);
2653 //new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
2654 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
2655 //}
2656 //}
2657 } 2638 }
2658 }
2659 2639
2660 public void GroupResize(Vector3 scale, uint localID) 2640 float x = (scale.X / RootPart.Scale.X);
2661 { 2641 float y = (scale.Y / RootPart.Scale.Y);
2662 SceneObjectPart part = GetChildPart(localID); 2642 float z = (scale.Z / RootPart.Scale.Z);
2663 if (part != null)
2664 {
2665 part.IgnoreUndoUpdate = true;
2666 if (scale.X > m_scene.m_maxNonphys)
2667 scale.X = m_scene.m_maxNonphys;
2668 if (scale.Y > m_scene.m_maxNonphys)
2669 scale.Y = m_scene.m_maxNonphys;
2670 if (scale.Z > m_scene.m_maxNonphys)
2671 scale.Z = m_scene.m_maxNonphys;
2672 if (part.PhysActor != null && part.PhysActor.IsPhysical)
2673 {
2674 if (scale.X > m_scene.m_maxPhys)
2675 scale.X = m_scene.m_maxPhys;
2676 if (scale.Y > m_scene.m_maxPhys)
2677 scale.Y = m_scene.m_maxPhys;
2678 if (scale.Z > m_scene.m_maxPhys)
2679 scale.Z = m_scene.m_maxPhys;
2680 }
2681 float x = (scale.X / part.Scale.X);
2682 float y = (scale.Y / part.Scale.Y);
2683 float z = (scale.Z / part.Scale.Z);
2684 2643
2685 SceneObjectPart[] parts; 2644 SceneObjectPart[] parts;
2686 if (x > 1.0f || y > 1.0f || z > 1.0f) 2645 if (x > 1.0f || y > 1.0f || z > 1.0f)
2646 {
2647 parts = m_parts.GetArray();
2648 for (int i = 0; i < parts.Length; i++)
2687 { 2649 {
2688 parts = m_parts.GetArray(); 2650 SceneObjectPart obPart = parts[i];
2689 for (int i = 0; i < parts.Length; i++) 2651 if (obPart.UUID != m_rootPart.UUID)
2690 { 2652 {
2691 SceneObjectPart obPart = parts[i]; 2653// obPart.IgnoreUndoUpdate = true;
2692 if (obPart.UUID != m_rootPart.UUID) 2654 Vector3 oldSize = new Vector3(obPart.Scale);
2655
2656 float f = 1.0f;
2657 float a = 1.0f;
2658
2659 if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
2693 { 2660 {
2694 obPart.IgnoreUndoUpdate = true; 2661 if (oldSize.X * x > m_scene.m_maxPhys)
2695 Vector3 oldSize = new Vector3(obPart.Scale); 2662 {
2663 f = m_scene.m_maxPhys / oldSize.X;
2664 a = f / x;
2665 x *= a;
2666 y *= a;
2667 z *= a;
2668 }
2696 2669
2697 float f = 1.0f; 2670 if (oldSize.Y * y > m_scene.m_maxPhys)
2698 float a = 1.0f; 2671 {
2672 f = m_scene.m_maxPhys / oldSize.Y;
2673 a = f / y;
2674 x *= a;
2675 y *= a;
2676 z *= a;
2677 }
2699 2678
2700 if (part.PhysActor != null && part.PhysActor.IsPhysical) 2679 if (oldSize.Z * z > m_scene.m_maxPhys)
2701 { 2680 {
2702 if (oldSize.X * x > m_scene.m_maxPhys) 2681 f = m_scene.m_maxPhys / oldSize.Z;
2703 { 2682 a = f / z;
2704 f = m_scene.m_maxPhys / oldSize.X; 2683 x *= a;
2705 a = f / x; 2684 y *= a;
2706 x *= a; 2685 z *= a;
2707 y *= a; 2686 }
2708 z *= a; 2687 }
2709 } 2688 else
2710 if (oldSize.Y * y > m_scene.m_maxPhys) 2689 {
2711 { 2690 if (oldSize.X * x > m_scene.m_maxNonphys)
2712 f = m_scene.m_maxPhys / oldSize.Y; 2691 {
2713 a = f / y; 2692 f = m_scene.m_maxNonphys / oldSize.X;
2714 x *= a; 2693 a = f / x;
2715 y *= a; 2694 x *= a;
2716 z *= a; 2695 y *= a;
2717 } 2696 z *= a;
2718 if (oldSize.Z * z > m_scene.m_maxPhys)
2719 {
2720 f = m_scene.m_maxPhys / oldSize.Z;
2721 a = f / z;
2722 x *= a;
2723 y *= a;
2724 z *= a;
2725 }
2726 } 2697 }
2727 else 2698
2699 if (oldSize.Y * y > m_scene.m_maxNonphys)
2728 { 2700 {
2729 if (oldSize.X * x > m_scene.m_maxNonphys) 2701 f = m_scene.m_maxNonphys / oldSize.Y;
2730 { 2702 a = f / y;
2731 f = m_scene.m_maxNonphys / oldSize.X; 2703 x *= a;
2732 a = f / x; 2704 y *= a;
2733 x *= a; 2705 z *= a;
2734 y *= a; 2706 }
2735 z *= a; 2707
2736 } 2708 if (oldSize.Z * z > m_scene.m_maxNonphys)
2737 if (oldSize.Y * y > m_scene.m_maxNonphys) 2709 {
2738 { 2710 f = m_scene.m_maxNonphys / oldSize.Z;
2739 f = m_scene.m_maxNonphys / oldSize.Y; 2711 a = f / z;
2740 a = f / y; 2712 x *= a;
2741 x *= a; 2713 y *= a;
2742 y *= a; 2714 z *= a;
2743 z *= a;
2744 }
2745 if (oldSize.Z * z > m_scene.m_maxNonphys)
2746 {
2747 f = m_scene.m_maxNonphys / oldSize.Z;
2748 a = f / z;
2749 x *= a;
2750 y *= a;
2751 z *= a;
2752 }
2753 } 2715 }
2754 obPart.IgnoreUndoUpdate = false;
2755 obPart.StoreUndoState();
2756 } 2716 }
2717
2718// obPart.IgnoreUndoUpdate = false;
2757 } 2719 }
2758 } 2720 }
2721 }
2759 2722
2760 Vector3 prevScale = part.Scale; 2723 Vector3 prevScale = RootPart.Scale;
2761 prevScale.X *= x; 2724 prevScale.X *= x;
2762 prevScale.Y *= y; 2725 prevScale.Y *= y;
2763 prevScale.Z *= z; 2726 prevScale.Z *= z;
2764 part.Resize(prevScale);
2765 2727
2766 parts = m_parts.GetArray(); 2728// RootPart.IgnoreUndoUpdate = true;
2767 for (int i = 0; i < parts.Length; i++) 2729 RootPart.Resize(prevScale);
2730// RootPart.IgnoreUndoUpdate = false;
2731
2732 parts = m_parts.GetArray();
2733 for (int i = 0; i < parts.Length; i++)
2734 {
2735 SceneObjectPart obPart = parts[i];
2736
2737 if (obPart.UUID != m_rootPart.UUID)
2768 { 2738 {
2769 SceneObjectPart obPart = parts[i];
2770 obPart.IgnoreUndoUpdate = true; 2739 obPart.IgnoreUndoUpdate = true;
2771 if (obPart.UUID != m_rootPart.UUID)
2772 {
2773 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
2774 currentpos.X *= x;
2775 currentpos.Y *= y;
2776 currentpos.Z *= z;
2777 Vector3 newSize = new Vector3(obPart.Scale);
2778 newSize.X *= x;
2779 newSize.Y *= y;
2780 newSize.Z *= z;
2781 obPart.Resize(newSize);
2782 obPart.UpdateOffSet(currentpos);
2783 }
2784 obPart.IgnoreUndoUpdate = false;
2785 obPart.StoreUndoState();
2786 }
2787 2740
2788 if (part.PhysActor != null) 2741 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
2789 { 2742 currentpos.X *= x;
2790 part.PhysActor.Size = prevScale; 2743 currentpos.Y *= y;
2791 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2744 currentpos.Z *= z;
2745
2746 Vector3 newSize = new Vector3(obPart.Scale);
2747 newSize.X *= x;
2748 newSize.Y *= y;
2749 newSize.Z *= z;
2750
2751 obPart.Resize(newSize);
2752 obPart.UpdateOffSet(currentpos);
2753
2754 obPart.IgnoreUndoUpdate = false;
2792 } 2755 }
2793 2756
2794 part.IgnoreUndoUpdate = false; 2757// obPart.IgnoreUndoUpdate = false;
2795 part.StoreUndoState(); 2758// obPart.StoreUndoState();
2796 HasGroupChanged = true;
2797 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE);
2798 ScheduleGroupForTerseUpdate();
2799 } 2759 }
2760
2761// m_log.DebugFormat(
2762// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale);
2800 } 2763 }
2801 2764
2802 #endregion 2765 #endregion
@@ -2809,9 +2772,13 @@ namespace OpenSim.Region.Framework.Scenes
2809 /// <param name="pos"></param> 2772 /// <param name="pos"></param>
2810 public void UpdateGroupPosition(Vector3 pos) 2773 public void UpdateGroupPosition(Vector3 pos)
2811 { 2774 {
2812 SceneObjectPart[] parts = m_parts.GetArray(); 2775// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
2813 for (int i = 0; i < parts.Length; i++) 2776
2814 parts[i].StoreUndoState(); 2777 RootPart.StoreUndoState(true);
2778
2779// SceneObjectPart[] parts = m_parts.GetArray();
2780// for (int i = 0; i < parts.Length; i++)
2781// parts[i].StoreUndoState();
2815 2782
2816 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 2783 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
2817 { 2784 {
@@ -2848,12 +2815,18 @@ namespace OpenSim.Region.Framework.Scenes
2848 { 2815 {
2849 SceneObjectPart part = GetChildPart(localID); 2816 SceneObjectPart part = GetChildPart(localID);
2850 2817
2851 SceneObjectPart[] parts = m_parts.GetArray(); 2818// SceneObjectPart[] parts = m_parts.GetArray();
2852 for (int i = 0; i < parts.Length; i++) 2819// for (int i = 0; i < parts.Length; i++)
2853 parts[i].StoreUndoState(); 2820// parts[i].StoreUndoState();
2854 2821
2855 if (part != null) 2822 if (part != null)
2856 { 2823 {
2824// m_log.DebugFormat(
2825// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
2826
2827 part.StoreUndoState(false);
2828 part.IgnoreUndoUpdate = true;
2829
2857 if (part.UUID == m_rootPart.UUID) 2830 if (part.UUID == m_rootPart.UUID)
2858 { 2831 {
2859 UpdateRootPosition(pos); 2832 UpdateRootPosition(pos);
@@ -2864,18 +2837,22 @@ namespace OpenSim.Region.Framework.Scenes
2864 } 2837 }
2865 2838
2866 HasGroupChanged = true; 2839 HasGroupChanged = true;
2840 part.IgnoreUndoUpdate = false;
2867 } 2841 }
2868 } 2842 }
2869 2843
2870 /// <summary> 2844 /// <summary>
2871 /// 2845 /// Update just the root prim position in a linkset
2872 /// </summary> 2846 /// </summary>
2873 /// <param name="pos"></param> 2847 /// <param name="pos"></param>
2874 private void UpdateRootPosition(Vector3 pos) 2848 public void UpdateRootPosition(Vector3 pos)
2875 { 2849 {
2876 SceneObjectPart[] parts = m_parts.GetArray(); 2850// m_log.DebugFormat(
2877 for (int i = 0; i < parts.Length; i++) 2851// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
2878 parts[i].StoreUndoState(); 2852
2853// SceneObjectPart[] parts = m_parts.GetArray();
2854// for (int i = 0; i < parts.Length; i++)
2855// parts[i].StoreUndoState();
2879 2856
2880 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 2857 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
2881 Vector3 oldPos = 2858 Vector3 oldPos =
@@ -2888,7 +2865,7 @@ namespace OpenSim.Region.Framework.Scenes
2888 axDiff *= Quaternion.Inverse(partRotation); 2865 axDiff *= Quaternion.Inverse(partRotation);
2889 diff = axDiff; 2866 diff = axDiff;
2890 2867
2891 parts = m_parts.GetArray(); 2868 SceneObjectPart[] parts = m_parts.GetArray();
2892 for (int i = 0; i < parts.Length; i++) 2869 for (int i = 0; i < parts.Length; i++)
2893 { 2870 {
2894 SceneObjectPart obPart = parts[i]; 2871 SceneObjectPart obPart = parts[i];
@@ -2917,9 +2894,14 @@ namespace OpenSim.Region.Framework.Scenes
2917 /// <param name="rot"></param> 2894 /// <param name="rot"></param>
2918 public void UpdateGroupRotationR(Quaternion rot) 2895 public void UpdateGroupRotationR(Quaternion rot)
2919 { 2896 {
2920 SceneObjectPart[] parts = m_parts.GetArray(); 2897// m_log.DebugFormat(
2921 for (int i = 0; i < parts.Length; i++) 2898// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
2922 parts[i].StoreUndoState(); 2899
2900// SceneObjectPart[] parts = m_parts.GetArray();
2901// for (int i = 0; i < parts.Length; i++)
2902// parts[i].StoreUndoState();
2903
2904 m_rootPart.StoreUndoState(true);
2923 2905
2924 m_rootPart.UpdateRotation(rot); 2906 m_rootPart.UpdateRotation(rot);
2925 2907
@@ -2941,9 +2923,15 @@ namespace OpenSim.Region.Framework.Scenes
2941 /// <param name="rot"></param> 2923 /// <param name="rot"></param>
2942 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) 2924 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
2943 { 2925 {
2944 SceneObjectPart[] parts = m_parts.GetArray(); 2926// m_log.DebugFormat(
2945 for (int i = 0; i < parts.Length; i++) 2927// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
2946 parts[i].StoreUndoState(); 2928
2929// SceneObjectPart[] parts = m_parts.GetArray();
2930// for (int i = 0; i < parts.Length; i++)
2931// parts[i].StoreUndoState();
2932
2933 RootPart.StoreUndoState(true);
2934 RootPart.IgnoreUndoUpdate = true;
2947 2935
2948 m_rootPart.UpdateRotation(rot); 2936 m_rootPart.UpdateRotation(rot);
2949 2937
@@ -2958,6 +2946,8 @@ namespace OpenSim.Region.Framework.Scenes
2958 2946
2959 HasGroupChanged = true; 2947 HasGroupChanged = true;
2960 ScheduleGroupForTerseUpdate(); 2948 ScheduleGroupForTerseUpdate();
2949
2950 RootPart.IgnoreUndoUpdate = false;
2961 } 2951 }
2962 2952
2963 /// <summary> 2953 /// <summary>
@@ -2975,6 +2965,9 @@ namespace OpenSim.Region.Framework.Scenes
2975 2965
2976 if (part != null) 2966 if (part != null)
2977 { 2967 {
2968// m_log.DebugFormat(
2969// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot);
2970
2978 if (part.UUID == m_rootPart.UUID) 2971 if (part.UUID == m_rootPart.UUID)
2979 { 2972 {
2980 UpdateRootRotation(rot); 2973 UpdateRootRotation(rot);
@@ -2996,6 +2989,13 @@ namespace OpenSim.Region.Framework.Scenes
2996 SceneObjectPart part = GetChildPart(localID); 2989 SceneObjectPart part = GetChildPart(localID);
2997 if (part != null) 2990 if (part != null)
2998 { 2991 {
2992// m_log.DebugFormat(
2993// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}",
2994// part.Name, part.LocalId, rot);
2995
2996 part.StoreUndoState();
2997 part.IgnoreUndoUpdate = true;
2998
2999 if (part.UUID == m_rootPart.UUID) 2999 if (part.UUID == m_rootPart.UUID)
3000 { 3000 {
3001 UpdateRootRotation(rot); 3001 UpdateRootRotation(rot);
@@ -3003,12 +3003,11 @@ namespace OpenSim.Region.Framework.Scenes
3003 } 3003 }
3004 else 3004 else
3005 { 3005 {
3006 part.IgnoreUndoUpdate = true;
3007 part.UpdateRotation(rot); 3006 part.UpdateRotation(rot);
3008 part.OffsetPosition = pos; 3007 part.OffsetPosition = pos;
3009 part.IgnoreUndoUpdate = false;
3010 part.StoreUndoState();
3011 } 3008 }
3009
3010 part.IgnoreUndoUpdate = false;
3012 } 3011 }
3013 } 3012 }
3014 3013
@@ -3016,8 +3015,12 @@ namespace OpenSim.Region.Framework.Scenes
3016 /// 3015 ///
3017 /// </summary> 3016 /// </summary>
3018 /// <param name="rot"></param> 3017 /// <param name="rot"></param>
3019 private void UpdateRootRotation(Quaternion rot) 3018 public void UpdateRootRotation(Quaternion rot)
3020 { 3019 {
3020// m_log.DebugFormat(
3021// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
3022// Name, LocalId, rot);
3023
3021 Quaternion axRot = rot; 3024 Quaternion axRot = rot;
3022 Quaternion oldParentRot = m_rootPart.RotationOffset; 3025 Quaternion oldParentRot = m_rootPart.RotationOffset;
3023 3026
@@ -3045,20 +3048,25 @@ namespace OpenSim.Region.Framework.Scenes
3045 newRot *= Quaternion.Inverse(axRot); 3048 newRot *= Quaternion.Inverse(axRot);
3046 prim.RotationOffset = newRot; 3049 prim.RotationOffset = newRot;
3047 prim.ScheduleTerseUpdate(); 3050 prim.ScheduleTerseUpdate();
3051 prim.IgnoreUndoUpdate = false;
3048 } 3052 }
3049 } 3053 }
3050 3054
3051 for (int i = 0; i < parts.Length; i++) 3055// for (int i = 0; i < parts.Length; i++)
3052 { 3056// {
3053 SceneObjectPart childpart = parts[i]; 3057// SceneObjectPart childpart = parts[i];
3054 if (childpart != m_rootPart) 3058// if (childpart != m_rootPart)
3055 { 3059// {
3056 childpart.IgnoreUndoUpdate = false; 3060//// childpart.IgnoreUndoUpdate = false;
3057 childpart.StoreUndoState(); 3061//// childpart.StoreUndoState();
3058 } 3062// }
3059 } 3063// }
3060 3064
3061 m_rootPart.ScheduleTerseUpdate(); 3065 m_rootPart.ScheduleTerseUpdate();
3066
3067// m_log.DebugFormat(
3068// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}",
3069// Name, LocalId, rot);
3062 } 3070 }
3063 3071
3064 #endregion 3072 #endregion
@@ -3313,23 +3321,6 @@ namespace OpenSim.Region.Framework.Scenes
3313 } 3321 }
3314 3322
3315 /// <summary> 3323 /// <summary>
3316 /// Handle an asset received asynchronously from the asset service.
3317 /// </summary>
3318 /// <param name="id"></param>
3319 /// <param name="sender"></param>
3320 /// <param name="asset"></param>
3321 protected void AssetReceived(string id, Object sender, AssetBase asset)
3322 {
3323 SceneObjectPart sop = (SceneObjectPart)sender;
3324
3325 if (sop != null)
3326 {
3327 if (asset != null)
3328 sop.SculptTextureCallback(asset.FullID, asset);
3329 }
3330 }
3331
3332 /// <summary>
3333 /// Set the user group to which this scene object belongs. 3324 /// Set the user group to which this scene object belongs.
3334 /// </summary> 3325 /// </summary>
3335 /// <param name="GroupID"></param> 3326 /// <param name="GroupID"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2026c53..4629757 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -287,8 +287,8 @@ namespace OpenSim.Region.Framework.Scenes
287 private string m_sitAnimation = "SIT"; 287 private string m_sitAnimation = "SIT";
288 private string m_text = String.Empty; 288 private string m_text = String.Empty;
289 private string m_touchName = String.Empty; 289 private string m_touchName = String.Empty;
290 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); 290 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
291 private readonly UndoStack<UndoState> m_redo = new UndoStack<UndoState>(5); 291 private readonly Stack<UndoState> m_redo = new Stack<UndoState>(5);
292 private UUID _creatorID; 292 private UUID _creatorID;
293 293
294 private bool m_passTouches; 294 private bool m_passTouches;
@@ -414,7 +414,6 @@ namespace OpenSim.Region.Framework.Scenes
414 CreateSelected = true; 414 CreateSelected = true;
415 415
416 TrimPermissions(); 416 TrimPermissions();
417 //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
418 417
419 m_inventory = new SceneObjectPartInventory(this); 418 m_inventory = new SceneObjectPartInventory(this);
420 } 419 }
@@ -789,7 +788,7 @@ namespace OpenSim.Region.Framework.Scenes
789 get { return m_offsetPosition; } 788 get { return m_offsetPosition; }
790 set 789 set
791 { 790 {
792 StoreUndoState(); 791// StoreUndoState();
793 m_offsetPosition = value; 792 m_offsetPosition = value;
794 793
795 if (ParentGroup != null && !ParentGroup.IsDeleted) 794 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -1015,15 +1014,19 @@ namespace OpenSim.Region.Framework.Scenes
1015 get { return m_shape; } 1014 get { return m_shape; }
1016 set { m_shape = value; } 1015 set { m_shape = value; }
1017 } 1016 }
1018 1017
1018 /// <summary>
1019 /// Change the scale of this part.
1020 /// </summary>
1019 public Vector3 Scale 1021 public Vector3 Scale
1020 { 1022 {
1021 get { return m_shape.Scale; } 1023 get { return m_shape.Scale; }
1022 set 1024 set
1023 { 1025 {
1024 StoreUndoState();
1025 if (m_shape != null) 1026 if (m_shape != null)
1026 { 1027 {
1028 StoreUndoState();
1029
1027 m_shape.Scale = value; 1030 m_shape.Scale = value;
1028 1031
1029 PhysicsActor actor = PhysActor; 1032 PhysicsActor actor = PhysActor;
@@ -1034,11 +1037,16 @@ namespace OpenSim.Region.Framework.Scenes
1034 if (m_parentGroup.Scene.PhysicsScene != null) 1037 if (m_parentGroup.Scene.PhysicsScene != null)
1035 { 1038 {
1036 actor.Size = m_shape.Scale; 1039 actor.Size = m_shape.Scale;
1037 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 1040
1041 if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
1042 CheckSculptAndLoad();
1043 else
1044 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
1038 } 1045 }
1039 } 1046 }
1040 } 1047 }
1041 } 1048 }
1049
1042 TriggerScriptChangedEvent(Changed.SCALE); 1050 TriggerScriptChangedEvent(Changed.SCALE);
1043 } 1051 }
1044 } 1052 }
@@ -1588,17 +1596,23 @@ namespace OpenSim.Region.Framework.Scenes
1588 // or flexible 1596 // or flexible
1589 if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) 1597 if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible))
1590 { 1598 {
1591// m_log.DebugFormat("[SCENE OBJECT PART]: Creating PhysActor for {0} {1} {2}", Name, LocalId, UUID); 1599 try
1592 1600 {
1593 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 1601 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
1594 LocalId, 1602 string.Format("{0}/{1}", Name, UUID),
1595 string.Format("{0}/{1}", Name, UUID), 1603 Shape,
1596 Shape, 1604 AbsolutePosition,
1597 AbsolutePosition, 1605 Scale,
1598 Scale, 1606 RotationOffset,
1599 RotationOffset, 1607 RigidBody,
1600 RigidBody); 1608 m_localId);
1601 1609 PhysActor.SetMaterial(Material);
1610 }
1611 catch
1612 {
1613 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid);
1614 PhysActor = null;
1615 }
1602 // Basic Physics returns null.. joy joy joy. 1616 // Basic Physics returns null.. joy joy joy.
1603 if (PhysActor != null) 1617 if (PhysActor != null)
1604 { 1618 {
@@ -1615,19 +1629,6 @@ namespace OpenSim.Region.Framework.Scenes
1615 } 1629 }
1616 } 1630 }
1617 1631
1618 public void ClearUndoState()
1619 {
1620 lock (m_undo)
1621 {
1622 m_undo.Clear();
1623 }
1624 lock (m_redo)
1625 {
1626 m_redo.Clear();
1627 }
1628 StoreUndoState();
1629 }
1630
1631 public byte ConvertScriptUintToByte(uint indata) 1632 public byte ConvertScriptUintToByte(uint indata)
1632 { 1633 {
1633 byte outdata = (byte)TextureAnimFlags.NONE; 1634 byte outdata = (byte)TextureAnimFlags.NONE;
@@ -1705,7 +1706,8 @@ namespace OpenSim.Region.Framework.Scenes
1705 { 1706 {
1706 if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero) 1707 if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero)
1707 { 1708 {
1708 m_parentGroup.Scene.AssetService.Get(dupe.m_shape.SculptTexture.ToString(), dupe, AssetReceived); 1709 ParentGroup.Scene.AssetService.Get(
1710 dupe.m_shape.SculptTexture.ToString(), dupe, dupe.AssetReceived);
1709 } 1711 }
1710 1712
1711 bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); 1713 bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0);
@@ -1719,14 +1721,20 @@ namespace OpenSim.Region.Framework.Scenes
1719 return dupe; 1721 return dupe;
1720 } 1722 }
1721 1723
1724 /// <summary>
1725 /// Called back by asynchronous asset fetch.
1726 /// </summary>
1727 /// <param name="id">ID of asset received</param>
1728 /// <param name="sender">Register</param>
1729 /// <param name="asset"></param>
1722 protected void AssetReceived(string id, Object sender, AssetBase asset) 1730 protected void AssetReceived(string id, Object sender, AssetBase asset)
1723 { 1731 {
1724 if (asset != null) 1732 if (asset != null)
1725 { 1733 SculptTextureCallback(asset);
1726 SceneObjectPart sop = (SceneObjectPart)sender; 1734 else
1727 if (sop != null) 1735 m_log.WarnFormat(
1728 sop.SculptTextureCallback(asset.FullID, asset); 1736 "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data",
1729 } 1737 Name, LocalId, id);
1730 } 1738 }
1731 1739
1732 public static SceneObjectPart Create() 1740 public static SceneObjectPart Create()
@@ -1896,7 +1904,12 @@ namespace OpenSim.Region.Framework.Scenes
1896 } 1904 }
1897 } 1905 }
1898 1906
1899 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 1907 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the
1908 // mesh data.
1909 if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
1910 CheckSculptAndLoad();
1911 else
1912 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
1900 } 1913 }
1901 } 1914 }
1902 } 1915 }
@@ -2823,19 +2836,29 @@ namespace OpenSim.Region.Framework.Scenes
2823 } 2836 }
2824 2837
2825 /// <summary> 2838 /// <summary>
2826 /// Resize this part. 2839 /// Set the scale of this part.
2827 /// </summary> 2840 /// </summary>
2841 /// <remarks>
2842 /// Unlike the scale property, this checks the new size against scene limits and schedules a full property
2843 /// update to viewers.
2844 /// </remarks>
2828 /// <param name="scale"></param> 2845 /// <param name="scale"></param>
2829 public void Resize(Vector3 scale) 2846 public void Resize(Vector3 scale)
2830 { 2847 {
2831 StoreUndoState(); 2848 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxNonphys);
2832 m_shape.Scale = scale; 2849 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
2850 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
2833 2851
2834 // If we're a mesh/sculpt, then we need to tell the physics engine about our new size. To do this, we 2852 if (PhysActor != null && PhysActor.IsPhysical)
2835 // need to reinsert the sculpt data into the shape, since the physics engine deletes it when done to 2853 {
2836 // save memory 2854 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
2837 if (PhysActor != null) 2855 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
2838 CheckSculptAndLoad(); 2856 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys);
2857 }
2858
2859// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
2860
2861 Scale = scale;
2839 2862
2840 ParentGroup.HasGroupChanged = true; 2863 ParentGroup.HasGroupChanged = true;
2841 ScheduleFullUpdate(); 2864 ScheduleFullUpdate();
@@ -2965,7 +2988,11 @@ namespace OpenSim.Region.Framework.Scenes
2965 } 2988 }
2966 } 2989 }
2967 2990
2968 public void SculptTextureCallback(UUID textureID, AssetBase texture) 2991 /// <summary>
2992 /// Set sculpt and mesh data, and tell the physics engine to process the change.
2993 /// </summary>
2994 /// <param name="texture">The mesh itself.</param>
2995 public void SculptTextureCallback(AssetBase texture)
2969 { 2996 {
2970 if (m_shape.SculptEntry) 2997 if (m_shape.SculptEntry)
2971 { 2998 {
@@ -2991,16 +3018,6 @@ namespace OpenSim.Region.Framework.Scenes
2991 } 3018 }
2992 } 3019 }
2993 3020
2994// /// <summary>
2995// ///
2996// /// </summary>
2997// /// <param name="remoteClient"></param>
2998// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2999// {
3000// m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
3001// }
3002
3003
3004 /// <summary> 3021 /// <summary>
3005 /// Send a full update to the client for the given part 3022 /// Send a full update to the client for the given part
3006 /// </summary> 3023 /// </summary>
@@ -3648,6 +3665,11 @@ namespace OpenSim.Region.Framework.Scenes
3648 3665
3649 public void StoreUndoState() 3666 public void StoreUndoState()
3650 { 3667 {
3668 StoreUndoState(false);
3669 }
3670
3671 public void StoreUndoState(bool forGroup)
3672 {
3651 if (!Undoing) 3673 if (!Undoing)
3652 { 3674 {
3653 if (!IgnoreUndoUpdate) 3675 if (!IgnoreUndoUpdate)
@@ -3661,24 +3683,138 @@ namespace OpenSim.Region.Framework.Scenes
3661 UndoState last = m_undo.Peek(); 3683 UndoState last = m_undo.Peek();
3662 if (last != null) 3684 if (last != null)
3663 { 3685 {
3686 // TODO: May need to fix for group comparison
3664 if (last.Compare(this)) 3687 if (last.Compare(this))
3688 {
3689// m_log.DebugFormat(
3690// "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3691// Name, LocalId, m_undo.Count);
3692
3665 return; 3693 return;
3694 }
3666 } 3695 }
3667 } 3696 }
3668 3697
3698// m_log.DebugFormat(
3699// "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3700// Name, LocalId, forGroup, m_undo.Count);
3701
3669 if (m_parentGroup.GetSceneMaxUndo() > 0) 3702 if (m_parentGroup.GetSceneMaxUndo() > 0)
3670 { 3703 {
3671 UndoState nUndo = new UndoState(this); 3704 UndoState nUndo = new UndoState(this, forGroup);
3672 3705
3673 m_undo.Push(nUndo); 3706 m_undo.Push(nUndo);
3707
3708 if (m_redo.Count > 0)
3709 m_redo.Clear();
3710
3711// m_log.DebugFormat(
3712// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3713// Name, LocalId, forGroup, m_undo.Count);
3674 } 3714 }
3715 }
3716 }
3717 }
3718// else
3719// {
3720// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3721// }
3722 }
3723// else
3724// {
3725// m_log.DebugFormat(
3726// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3727// }
3728 }
3729
3730 /// <summary>
3731 /// Return number of undos on the stack. Here temporarily pending a refactor.
3732 /// </summary>
3733 public int UndoCount
3734 {
3735 get
3736 {
3737 lock (m_undo)
3738 return m_undo.Count;
3739 }
3740 }
3675 3741
3742 public void Undo()
3743 {
3744 lock (m_undo)
3745 {
3746// m_log.DebugFormat(
3747// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
3748// Name, LocalId, m_undo.Count);
3749
3750 if (m_undo.Count > 0)
3751 {
3752 UndoState goback = m_undo.Pop();
3753
3754 if (goback != null)
3755 {
3756 UndoState nUndo = null;
3757
3758 if (m_parentGroup.GetSceneMaxUndo() > 0)
3759 {
3760 nUndo = new UndoState(this, goback.ForGroup);
3761 }
3762
3763 goback.PlaybackState(this);
3764
3765 if (nUndo != null)
3766 m_redo.Push(nUndo);
3767 }
3768 }
3769
3770// m_log.DebugFormat(
3771// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}",
3772// Name, LocalId, m_undo.Count);
3773 }
3774 }
3775
3776 public void Redo()
3777 {
3778 lock (m_undo)
3779 {
3780// m_log.DebugFormat(
3781// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
3782// Name, LocalId, m_redo.Count);
3783
3784 if (m_redo.Count > 0)
3785 {
3786 UndoState gofwd = m_redo.Pop();
3787
3788 if (gofwd != null)
3789 {
3790 if (m_parentGroup.GetSceneMaxUndo() > 0)
3791 {
3792 UndoState nUndo = new UndoState(this, gofwd.ForGroup);
3793
3794 m_undo.Push(nUndo);
3676 } 3795 }
3796
3797 gofwd.PlayfwdState(this);
3677 } 3798 }
3799
3800// m_log.DebugFormat(
3801// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
3802// Name, LocalId, m_redo.Count);
3678 } 3803 }
3679 } 3804 }
3680 } 3805 }
3681 3806
3807 public void ClearUndoState()
3808 {
3809// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId);
3810
3811 lock (m_undo)
3812 {
3813 m_undo.Clear();
3814 m_redo.Clear();
3815 }
3816 }
3817
3682 public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot) 3818 public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
3683 { 3819 {
3684 // In this case we're using a sphere with a radius of the largest dimension of the prim 3820 // In this case we're using a sphere with a radius of the largest dimension of the prim
@@ -4139,44 +4275,6 @@ namespace OpenSim.Region.Framework.Scenes
4139 _nextOwnerMask &= (uint)PermissionMask.All; 4275 _nextOwnerMask &= (uint)PermissionMask.All;
4140 } 4276 }
4141 4277
4142 public void Undo()
4143 {
4144 lock (m_undo)
4145 {
4146 if (m_undo.Count > 0)
4147 {
4148 UndoState nUndo = null;
4149 if (m_parentGroup.GetSceneMaxUndo() > 0)
4150 {
4151 nUndo = new UndoState(this);
4152 }
4153 UndoState goback = m_undo.Pop();
4154 if (goback != null)
4155 {
4156 goback.PlaybackState(this);
4157 if (nUndo != null)
4158 m_redo.Push(nUndo);
4159 }
4160 }
4161 }
4162 }
4163
4164 public void Redo()
4165 {
4166 lock (m_redo)
4167 {
4168 if (m_parentGroup.GetSceneMaxUndo() > 0)
4169 {
4170 UndoState nUndo = new UndoState(this);
4171
4172 m_undo.Push(nUndo);
4173 }
4174 UndoState gofwd = m_redo.Pop();
4175 if (gofwd != null)
4176 gofwd.PlayfwdState(this);
4177 }
4178 }
4179
4180 public void UpdateExtraParam(ushort type, bool inUse, byte[] data) 4278 public void UpdateExtraParam(ushort type, bool inUse, byte[] data)
4181 { 4279 {
4182 m_shape.ReadInUpdateExtraParam(type, inUse, data); 4280 m_shape.ReadInUpdateExtraParam(type, inUse, data);
@@ -4435,13 +4533,14 @@ namespace OpenSim.Region.Framework.Scenes
4435 { 4533 {
4436 // It's not phantom anymore. So make sure the physics engine get's knowledge of it 4534 // It's not phantom anymore. So make sure the physics engine get's knowledge of it
4437 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 4535 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
4438 LocalId,
4439 string.Format("{0}/{1}", Name, UUID), 4536 string.Format("{0}/{1}", Name, UUID),
4440 Shape, 4537 Shape,
4441 AbsolutePosition, 4538 AbsolutePosition,
4442 Scale, 4539 Scale,
4443 RotationOffset, 4540 RotationOffset,
4444 UsePhysics); 4541 UsePhysics,
4542 m_localId);
4543 PhysActor.SetMaterial(Material);
4445 4544
4446 pa = PhysActor; 4545 pa = PhysActor;
4447 if (pa != null) 4546 if (pa != null)
@@ -4600,7 +4699,7 @@ namespace OpenSim.Region.Framework.Scenes
4600 /// </remarks> 4699 /// </remarks>
4601 public void CheckSculptAndLoad() 4700 public void CheckSculptAndLoad()
4602 { 4701 {
4603// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); 4702// m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
4604 4703
4605 if (ParentGroup.IsDeleted) 4704 if (ParentGroup.IsDeleted)
4606 return; 4705 return;
@@ -4611,9 +4710,11 @@ namespace OpenSim.Region.Framework.Scenes
4611 if (Shape.SculptEntry && Shape.SculptTexture != UUID.Zero) 4710 if (Shape.SculptEntry && Shape.SculptTexture != UUID.Zero)
4612 { 4711 {
4613 // check if a previously decoded sculpt map has been cached 4712 // check if a previously decoded sculpt map has been cached
4713 // We don't read the file here - the meshmerizer will do that later.
4714 // TODO: Could we simplify the meshmerizer code by reading and setting the data here?
4614 if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + Shape.SculptTexture.ToString()))) 4715 if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + Shape.SculptTexture.ToString())))
4615 { 4716 {
4616 SculptTextureCallback(Shape.SculptTexture, null); 4717 SculptTextureCallback(null);
4617 } 4718 }
4618 else 4719 else
4619 { 4720 {
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index c18c93a..8fb9fad 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -102,7 +102,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
102 sceneObject.AddPart(part); 102 sceneObject.AddPart(part);
103 part.LinkNum = linkNum; 103 part.LinkNum = linkNum;
104 part.TrimPermissions(); 104 part.TrimPermissions();
105 part.StoreUndoState();
106 reader.Close(); 105 reader.Close();
107 sr.Close(); 106 sr.Close();
108 } 107 }
@@ -236,15 +235,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
236 if (originalLinkNum != 0) 235 if (originalLinkNum != 0)
237 part.LinkNum = originalLinkNum; 236 part.LinkNum = originalLinkNum;
238 237
239 part.StoreUndoState();
240 reader.Close(); 238 reader.Close();
241 sr.Close(); 239 sr.Close();
242 } 240 }
243 241
244 // Script state may, or may not, exist. Not having any, is NOT 242 // Script state may, or may not, exist. Not having any, is NOT
245 // ever a problem. 243 // ever a problem.
246
247 sceneObject.LoadScriptState(doc); 244 sceneObject.LoadScriptState(doc);
245
248 return sceneObject; 246 return sceneObject;
249 } 247 }
250 catch (Exception e) 248 catch (Exception e)
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
new file mode 100644
index 0000000..c4047ee
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -0,0 +1,104 @@
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.Reflection;
30using NUnit.Framework;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Tests.Common;
36using OpenSim.Tests.Common.Mock;
37
38namespace OpenSim.Region.Framework.Scenes.Tests
39{
40 /// <summary>
41 /// Basic scene object resize tests
42 /// </summary>
43 [TestFixture]
44 public class SceneObjectResizeTests
45 {
46 /// <summary>
47 /// Test resizing an object
48 /// </summary>
49 [Test]
50 public void TestResizeSceneObject()
51 {
52 TestHelper.InMethod();
53// log4net.Config.XmlConfigurator.Configure();
54
55 Scene scene = SceneSetupHelpers.SetupScene();
56 SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup;
57
58 g1.GroupResize(new Vector3(2, 3, 4));
59
60 SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
61
62 Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2));
63 Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3));
64 Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4));
65
66 Assert.That(g1Post.RootPart.UndoCount, Is.EqualTo(1));
67 }
68
69 /// <summary>
70 /// Test resizing an individual part in a scene object.
71 /// </summary>
72 [Test]
73 public void TestResizeSceneObjectPart()
74 {
75 TestHelper.InMethod();
76 //log4net.Config.XmlConfigurator.Configure();
77
78 Scene scene = SceneSetupHelpers.SetupScene();
79
80 SceneObjectGroup g1 = SceneSetupHelpers.CreateSceneObject(2, UUID.Zero);
81 g1.RootPart.Scale = new Vector3(2, 3, 4);
82 g1.Parts[1].Scale = new Vector3(5, 6, 7);
83
84 scene.AddSceneObject(g1);
85
86 SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
87
88 g1Post.Parts[1].Resize(new Vector3(8, 9, 10));
89
90 SceneObjectGroup g1PostPost = scene.GetSceneObjectGroup(g1.UUID);
91
92 SceneObjectPart g1RootPart = g1PostPost.RootPart;
93 SceneObjectPart g1ChildPart = g1PostPost.Parts[1];
94
95 Assert.That(g1RootPart.Scale.X, Is.EqualTo(2));
96 Assert.That(g1RootPart.Scale.Y, Is.EqualTo(3));
97 Assert.That(g1RootPart.Scale.Z, Is.EqualTo(4));
98
99 Assert.That(g1ChildPart.Scale.X, Is.EqualTo(8));
100 Assert.That(g1ChildPart.Scale.Y, Is.EqualTo(9));
101 Assert.That(g1ChildPart.Scale.Z, Is.EqualTo(10));
102 }
103 }
104} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 55e407e..393f42d 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -25,6 +25,9 @@
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;
29using System.Reflection;
30using log4net;
28using OpenMetaverse; 31using OpenMetaverse;
29using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
30 33
@@ -32,110 +35,199 @@ namespace OpenSim.Region.Framework.Scenes
32{ 35{
33 public class UndoState 36 public class UndoState
34 { 37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
35 public Vector3 Position = Vector3.Zero; 40 public Vector3 Position = Vector3.Zero;
36 public Vector3 Scale = Vector3.Zero; 41 public Vector3 Scale = Vector3.Zero;
37 public Quaternion Rotation = Quaternion.Identity; 42 public Quaternion Rotation = Quaternion.Identity;
38 43
39 public UndoState(SceneObjectPart part) 44 /// <summary>
45 /// Is this undo state for an entire group?
46 /// </summary>
47 public bool ForGroup;
48
49 /// <summary>
50 /// Constructor.
51 /// </summary>
52 /// <param name="part"></param>
53 /// <param name="forGroup">True if the undo is for an entire group</param>
54 public UndoState(SceneObjectPart part, bool forGroup)
40 { 55 {
41 if (part != null) 56 if (part.ParentID == 0)
42 { 57 {
43 if (part.ParentID == 0) 58 ForGroup = forGroup;
44 { 59
60// if (ForGroup)
45 Position = part.ParentGroup.AbsolutePosition; 61 Position = part.ParentGroup.AbsolutePosition;
46 Rotation = part.RotationOffset; 62// else
47 Scale = part.Shape.Scale; 63// Position = part.OffsetPosition;
48 } 64
49 else 65// m_log.DebugFormat(
50 { 66// "[UNDO STATE]: Storing undo position {0} for root part", Position);
51 Position = part.OffsetPosition; 67
52 Rotation = part.RotationOffset; 68 Rotation = part.RotationOffset;
53 Scale = part.Shape.Scale; 69
54 } 70// m_log.DebugFormat(
71// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation);
72
73 Scale = part.Shape.Scale;
74
75// m_log.DebugFormat(
76// "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
77 }
78 else
79 {
80 Position = part.OffsetPosition;
81// m_log.DebugFormat(
82// "[UNDO STATE]: Storing undo position {0} for child part", Position);
83
84 Rotation = part.RotationOffset;
85// m_log.DebugFormat(
86// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
87
88 Scale = part.Shape.Scale;
89// m_log.DebugFormat(
90// "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
55 } 91 }
56 } 92 }
57 93
94 /// <summary>
95 /// Compare the relevant state in the given part to this state.
96 /// </summary>
97 /// <param name="part"></param>
98 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
58 public bool Compare(SceneObjectPart part) 99 public bool Compare(SceneObjectPart part)
59 { 100 {
60 if (part != null) 101 if (part != null)
61 { 102 {
62 if (part.ParentID == 0) 103 if (part.ParentID == 0)
63 { 104 return
64 if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation) 105 Position == part.ParentGroup.AbsolutePosition
65 return true; 106 && Rotation == part.RotationOffset
66 else 107 && Scale == part.Shape.Scale;
67 return false;
68 }
69 else 108 else
70 { 109 return
71 if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale) 110 Position == part.OffsetPosition
72 return true; 111 && Rotation == part.RotationOffset
73 else 112 && Scale == part.Shape.Scale;
74 return false;
75
76 }
77 } 113 }
114
78 return false; 115 return false;
79 } 116 }
80 117
81 public void PlaybackState(SceneObjectPart part) 118 public void PlaybackState(SceneObjectPart part)
82 { 119 {
83 if (part != null) 120 part.Undoing = true;
121
122 if (part.ParentID == 0)
84 { 123 {
85 part.Undoing = true; 124// m_log.DebugFormat(
125// "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
126// Position, part.Name, part.LocalId);
86 127
87 if (part.ParentID == 0) 128 if (Position != Vector3.Zero)
88 { 129 {
89 if (Position != Vector3.Zero) 130 if (ForGroup)
90 part.ParentGroup.AbsolutePosition = Position; 131 part.ParentGroup.AbsolutePosition = Position;
91 part.RotationOffset = Rotation; 132 else
92 if (Scale != Vector3.Zero) 133 part.ParentGroup.UpdateRootPosition(Position);
93 part.Resize(Scale);
94 part.ParentGroup.ScheduleGroupForTerseUpdate();
95 } 134 }
135
136// m_log.DebugFormat(
137// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
138// part.RotationOffset, Rotation, part.Name, part.LocalId);
139
140 if (ForGroup)
141 part.UpdateRotation(Rotation);
96 else 142 else
143 part.ParentGroup.UpdateRootRotation(Rotation);
144
145 if (Scale != Vector3.Zero)
97 { 146 {
98 if (Position != Vector3.Zero) 147// m_log.DebugFormat(
99 part.OffsetPosition = Position; 148// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}",
100 part.UpdateRotation(Rotation); 149// part.Shape.Scale, Scale, part.Name, part.LocalId);
101 if (Scale != Vector3.Zero) 150
102 part.Resize(Scale); part.ScheduleTerseUpdate(); 151 if (ForGroup)
152 part.ParentGroup.GroupResize(Scale);
153 else
154 part.Resize(Scale);
103 } 155 }
104 part.Undoing = false;
105 156
157 part.ParentGroup.ScheduleGroupForTerseUpdate();
106 } 158 }
159 else
160 {
161 if (Position != Vector3.Zero)
162 {
163// m_log.DebugFormat(
164// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}",
165// part.OffsetPosition, Position, part.Name, part.LocalId);
166
167 part.OffsetPosition = Position;
168 }
169
170// m_log.DebugFormat(
171// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}",
172// part.RotationOffset, Rotation, part.Name, part.LocalId);
173
174 part.UpdateRotation(Rotation);
175
176 if (Scale != Vector3.Zero)
177 {
178// m_log.DebugFormat(
179// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}",
180// part.Shape.Scale, Scale, part.Name, part.LocalId);
181
182 part.Resize(Scale);
183 }
184
185 part.ScheduleTerseUpdate();
186 }
187
188 part.Undoing = false;
107 } 189 }
190
108 public void PlayfwdState(SceneObjectPart part) 191 public void PlayfwdState(SceneObjectPart part)
109 { 192 {
110 if (part != null) 193 part.Undoing = true;
194
195 if (part.ParentID == 0)
111 { 196 {
112 part.Undoing = true; 197 if (Position != Vector3.Zero)
198 part.ParentGroup.AbsolutePosition = Position;
113 199
114 if (part.ParentID == 0) 200 if (Rotation != Quaternion.Identity)
115 { 201 part.UpdateRotation(Rotation);
116 if (Position != Vector3.Zero) 202
117 part.ParentGroup.AbsolutePosition = Position; 203 if (Scale != Vector3.Zero)
118 if (Rotation != Quaternion.Identity)
119 part.UpdateRotation(Rotation);
120 if (Scale != Vector3.Zero)
121 part.Resize(Scale);
122 part.ParentGroup.ScheduleGroupForTerseUpdate();
123 }
124 else
125 { 204 {
126 if (Position != Vector3.Zero) 205 if (ForGroup)
127 part.OffsetPosition = Position; 206 part.ParentGroup.GroupResize(Scale);
128 if (Rotation != Quaternion.Identity) 207 else
129 part.UpdateRotation(Rotation);
130 if (Scale != Vector3.Zero)
131 part.Resize(Scale); 208 part.Resize(Scale);
132 part.ScheduleTerseUpdate();
133 } 209 }
134 part.Undoing = false;
135 210
211 part.ParentGroup.ScheduleGroupForTerseUpdate();
136 } 212 }
213 else
214 {
215 if (Position != Vector3.Zero)
216 part.OffsetPosition = Position;
217
218 if (Rotation != Quaternion.Identity)
219 part.UpdateRotation(Rotation);
220
221 if (Scale != Vector3.Zero)
222 part.Resize(Scale);
223
224 part.ScheduleTerseUpdate();
225 }
226
227 part.Undoing = false;
137 } 228 }
138 } 229 }
230
139 public class LandUndoState 231 public class LandUndoState
140 { 232 {
141 public ITerrainModule m_terrainModule; 233 public ITerrainModule m_terrainModule;
@@ -149,10 +241,7 @@ namespace OpenSim.Region.Framework.Scenes
149 241
150 public bool Compare(ITerrainChannel terrainChannel) 242 public bool Compare(ITerrainChannel terrainChannel)
151 { 243 {
152 if (m_terrainChannel != terrainChannel) 244 return m_terrainChannel == terrainChannel;
153 return false;
154 else
155 return false;
156 } 245 }
157 246
158 public void PlaybackState() 247 public void PlaybackState()
@@ -160,4 +249,4 @@ namespace OpenSim.Region.Framework.Scenes
160 m_terrainModule.UndoTerrain(m_terrainChannel); 249 m_terrainModule.UndoTerrain(m_terrainChannel);
161 } 250 }
162 } 251 }
163} 252} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
new file mode 100644
index 0000000..d49face
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
@@ -0,0 +1,119 @@
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.Reflection;
30using System.Text;
31using log4net;
32using Mono.Addins;
33using Nini.Config;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39
40namespace OpenSim.Region.OptionalModules.Framework.Monitoring
41{
42 /// <summary>
43 /// An experimental module to return data on services used by the simulator.
44 /// </summary>
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MonitorServicesModule")]
46 public class MonitorServicesModule : ISharedRegionModule
47 {
48 protected Scene m_scene;
49
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 public string Name { get { return "Services Health Monitoring Module"; } }
53
54 public Type ReplaceableInterface { get { return null; } }
55
56 public void Initialise(IConfigSource source)
57 {
58 }
59
60 public void PostInitialise()
61 {
62 }
63
64 public void Close()
65 {
66 }
67
68 public void AddRegion(Scene scene)
69 {
70 if (m_scene == null)
71 {
72 m_scene = scene;
73
74// m_scene.AddCommand(this, "monitor services",
75// "monitor services",
76// "Returns the status of services used by the simulator. Experimental.",
77// HandleMonitorServices);
78 }
79 }
80
81 public void RemoveRegion(Scene scene)
82 {
83 }
84
85 public void RegionLoaded(Scene scene)
86 {
87 }
88
89 protected void HandleMonitorServices(string module, string[] args)
90 {
91 MainConsole.Instance.Output(GenerateServicesReport());
92 }
93
94 protected string GenerateServicesReport()
95 {
96 StringBuilder sb = new StringBuilder();
97 sb.Append("This is an experimental module. Please don't rely on these results\n");
98 sb.Append("Asset service: ");
99
100 try
101 {
102 CheckAssetService();
103 sb.Append("OK");
104 }
105 catch (Exception e)
106 {
107 sb.AppendFormat("FAIL ({0})", e.Message);
108 }
109
110 return sb.ToString();
111 }
112
113 protected void CheckAssetService()
114 {
115 // Try to fetch an asset that will not exist (and hence avoid hitting cache)
116 m_scene.AssetService.Get(UUID.Random().ToString());
117 }
118 }
119} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
index d18ac0a..2187449 100644
--- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
106 info.channel = channel; 106 info.channel = channel;
107 info.uri = uri; 107 info.uri = uri;
108 108
109 bool success = SynchronousRestObjectPoster.BeginPostObject<XmlRpcInfo, bool>( 109 bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>(
110 "POST", m_ServerURI+"/RegisterChannel/", info); 110 "POST", m_ServerURI+"/RegisterChannel/", info);
111 111
112 if (!success) 112 if (!success)
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
125 125
126 if (m_Channels.ContainsKey(itemID)) 126 if (m_Channels.ContainsKey(itemID))
127 { 127 {
128 bool success = SynchronousRestObjectPoster.BeginPostObject<UUID, bool>( 128 bool success = SynchronousRestObjectRequester.MakeRequest<UUID, bool>(
129 "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]); 129 "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]);
130 130
131 if (!success) 131 if (!success)
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index b6e1cb4..6c9d9ab 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -84,13 +84,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
84*/ 84*/
85 85
86 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 86 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
87 Vector3 size, Quaternion rotation) 87 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
88 {
89 return AddPrimShape(primName, pbs, position, size, rotation, false);
90 }
91
92 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
93 Vector3 size, Quaternion rotation, bool isPhysical)
94 { 88 {
95 return null; 89 return null;
96 } 90 }
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
index 6df213d..0d1bd82 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
@@ -213,12 +213,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
213 return newPrim; 213 return newPrim;
214 } 214 }
215 215
216 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation) 216 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
217 {
218 return AddPrimShape(primName, pbs, position, size, rotation, false);
219 }
220
221 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical)
222 { 217 {
223 PhysicsActor result; 218 PhysicsActor result;
224 IMesh mesh = null; 219 IMesh mesh = null;
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index e2a6a2e..df62dbc 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -626,13 +626,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
626 } 626 }
627 627
628 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position, 628 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position,
629 OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation) 629 OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, bool isPhysical, uint localid)
630 {
631 return AddPrimShape(primName, pbs, position, size, rotation, false);
632 }
633
634 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position,
635 OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, bool isPhysical)
636 { 630 {
637 PhysicsActor result; 631 PhysicsActor result;
638 632
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 13ea084..3870411 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -37,6 +37,18 @@ namespace OpenSim.Region.Physics.Manager
37 public delegate void physicsCrash(); 37 public delegate void physicsCrash();
38 38
39 public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); 39 public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal);
40 public delegate void RayCallback(List<ContactResult> list);
41
42 /// <summary>
43 /// Contact result from a raycast.
44 /// </summary>
45 public struct ContactResult
46 {
47 public Vector3 Pos;
48 public float Depth;
49 public uint ConsumerID;
50 public Vector3 Normal;
51 }
40 52
41 public abstract class PhysicsScene 53 public abstract class PhysicsScene
42 { 54 {
@@ -61,7 +73,6 @@ namespace OpenSim.Region.Physics.Manager
61 } 73 }
62 } 74 }
63 75
64
65 public abstract void Initialise(IMesher meshmerizer, IConfigSource config); 76 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
66 77
67 public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); 78 public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying);
@@ -78,20 +89,7 @@ namespace OpenSim.Region.Physics.Manager
78 public abstract void RemovePrim(PhysicsActor prim); 89 public abstract void RemovePrim(PhysicsActor prim);
79 90
80 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 91 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
81 Vector3 size, Quaternion rotation); //To be removed 92 Vector3 size, Quaternion rotation, bool isPhysical, uint localid);
82 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
83 Vector3 size, Quaternion rotation, bool isPhysical);
84
85 public virtual PhysicsActor AddPrimShape(uint localID, string primName, PrimitiveBaseShape pbs, Vector3 position,
86 Vector3 size, Quaternion rotation, bool isPhysical)
87 {
88 PhysicsActor ret = AddPrimShape(primName, pbs, position, size, rotation, isPhysical);
89
90 if (ret != null)
91 ret.LocalID = localID;
92
93 return ret;
94 }
95 93
96 public virtual float TimeDilation 94 public virtual float TimeDilation
97 { 95 {
@@ -225,6 +223,17 @@ namespace OpenSim.Region.Physics.Manager
225 retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); 223 retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero);
226 } 224 }
227 225
226 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod)
227 {
228 if (retMethod != null)
229 retMethod(new List<ContactResult>());
230 }
231
232 public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count)
233 {
234 return new List<ContactResult>();
235 }
236
228 private class NullPhysicsScene : PhysicsScene 237 private class NullPhysicsScene : PhysicsScene
229 { 238 {
230 private static int m_workIndicator; 239 private static int m_workIndicator;
@@ -262,13 +271,7 @@ namespace OpenSim.Region.Physics.Manager
262*/ 271*/
263 272
264 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 273 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
265 Vector3 size, Quaternion rotation) //To be removed 274 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
266 {
267 return AddPrimShape(primName, pbs, position, size, rotation, false);
268 }
269
270 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
271 Vector3 size, Quaternion rotation, bool isPhysical)
272 { 275 {
273 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); 276 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size);
274 return PhysicsActor.Null; 277 return PhysicsActor.Null;
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 5ca5f20..5413aa8 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -303,6 +303,10 @@ namespace OpenSim.Region.Physics.Meshing
303 303
304 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod) 304 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
305 { 305 {
306// m_log.DebugFormat(
307// "[MESH]: Creating physics proxy for {0}, shape {1}",
308// primName, (OpenMetaverse.SculptType)primShape.SculptType);
309
306 PrimMesh primMesh; 310 PrimMesh primMesh;
307 PrimMesher.SculptMesh sculptMesh; 311 PrimMesher.SculptMesh sculptMesh;
308 312
@@ -668,7 +672,6 @@ namespace OpenSim.Region.Physics.Meshing
668 672
669 // If this mesh has been created already, return it instead of creating another copy 673 // If this mesh has been created already, return it instead of creating another copy
670 // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory 674 // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory
671
672 key = GetMeshKey(primShape, size, lod); 675 key = GetMeshKey(primShape, size, lod);
673 if (m_uniqueMeshes.TryGetValue(key, out mesh)) 676 if (m_uniqueMeshes.TryGetValue(key, out mesh))
674 return mesh; 677 return mesh;
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 123c8ff..b3045bd 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -638,7 +638,7 @@ namespace OpenSim.Region.Physics.OdePlugin
638 float profileEnd; 638 float profileEnd;
639 639
640 if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible) 640 if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible)
641 { 641 {
642 taperX1 = _pbs.PathScaleX * 0.01f; 642 taperX1 = _pbs.PathScaleX * 0.01f;
643 if (taperX1 > 1.0f) 643 if (taperX1 > 1.0f)
644 taperX1 = 2.0f - taperX1; 644 taperX1 = 2.0f - taperX1;
@@ -648,9 +648,9 @@ namespace OpenSim.Region.Physics.OdePlugin
648 if (taperY1 > 1.0f) 648 if (taperY1 > 1.0f)
649 taperY1 = 2.0f - taperY1; 649 taperY1 = 2.0f - taperY1;
650 taperY = 1.0f - taperY1; 650 taperY = 1.0f - taperY1;
651 } 651 }
652 else 652 else
653 { 653 {
654 taperX = _pbs.PathTaperX * 0.01f; 654 taperX = _pbs.PathTaperX * 0.01f;
655 if (taperX < 0.0f) 655 if (taperX < 0.0f)
656 taperX = -taperX; 656 taperX = -taperX;
@@ -660,9 +660,7 @@ namespace OpenSim.Region.Physics.OdePlugin
660 if (taperY < 0.0f) 660 if (taperY < 0.0f)
661 taperY = -taperY; 661 taperY = -taperY;
662 taperY1 = 1.0f - taperY; 662 taperY1 = 1.0f - taperY;
663 663 }
664 }
665
666 664
667 volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); 665 volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY);
668 666
@@ -846,7 +844,6 @@ namespace OpenSim.Region.Physics.OdePlugin
846 return; 844 return;
847 } 845 }
848 846
849
850 // if (IsPhysical && Body == (IntPtr) 0) 847 // if (IsPhysical && Body == (IntPtr) 0)
851 // { 848 // {
852 // Recreate the body 849 // Recreate the body
@@ -859,7 +856,9 @@ namespace OpenSim.Region.Physics.OdePlugin
859 856
860 public void ProcessTaints(float timestep) 857 public void ProcessTaints(float timestep)
861 { 858 {
862//Console.WriteLine("ProcessTaints for " + Name); 859#if SPAM
860Console.WriteLine("ZProcessTaints for " + Name);
861#endif
863 if (m_taintadd) 862 if (m_taintadd)
864 { 863 {
865 changeadd(timestep); 864 changeadd(timestep);
@@ -1323,7 +1322,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1323 1322
1324 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) 1323 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
1325 { 1324 {
1326//Console.WriteLine("CreateGeom:"); 1325#if SPAM
1326Console.WriteLine("CreateGeom:");
1327#endif
1327 if (_mesh != null) 1328 if (_mesh != null)
1328 { 1329 {
1329 setMesh(_parent_scene, _mesh); 1330 setMesh(_parent_scene, _mesh);
@@ -1944,7 +1945,6 @@ Console.WriteLine(" JointCreateFixed");
1944 if (_parent_scene.needsMeshing(_pbs)) 1945 if (_parent_scene.needsMeshing(_pbs))
1945 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1946 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1946 1947
1947 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1948#if SPAM 1948#if SPAM
1949Console.WriteLine("changesize 1"); 1949Console.WriteLine("changesize 1");
1950#endif 1950#endif
@@ -2056,8 +2056,8 @@ Console.WriteLine("changesize 2");
2056 if (IsPhysical) 2056 if (IsPhysical)
2057 meshlod = _parent_scene.MeshSculptphysicalLOD; 2057 meshlod = _parent_scene.MeshSculptphysicalLOD;
2058 2058
2059 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
2060 // createmesh returns null when it doesn't mesh. 2059 // createmesh returns null when it doesn't mesh.
2060 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
2061#if SPAM 2061#if SPAM
2062Console.WriteLine("changeshape needed meshing"); 2062Console.WriteLine("changeshape needed meshing");
2063#endif 2063#endif
@@ -2284,6 +2284,7 @@ Console.WriteLine("changeshape not need meshing");
2284 if (value.IsFinite()) 2284 if (value.IsFinite())
2285 { 2285 {
2286 _size = value; 2286 _size = value;
2287// m_log.DebugFormat("[PHYSICS]: Set size on {0} to {1}", Name, value);
2287 } 2288 }
2288 else 2289 else
2289 { 2290 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
index ba77dae..6c2bdde 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
@@ -45,11 +45,16 @@ namespace OpenSim.Region.Physics.OdePlugin
45 public class ODERayCastRequestManager 45 public class ODERayCastRequestManager
46 { 46 {
47 /// <summary> 47 /// <summary>
48 /// Pending Raycast Requests 48 /// Pending raycast requests
49 /// </summary> 49 /// </summary>
50 protected List<ODERayCastRequest> m_PendingRequests = new List<ODERayCastRequest>(); 50 protected List<ODERayCastRequest> m_PendingRequests = new List<ODERayCastRequest>();
51 51
52 /// <summary> 52 /// <summary>
53 /// Pending ray requests
54 /// </summary>
55 protected List<ODERayRequest> m_PendingRayRequests = new List<ODERayRequest>();
56
57 /// <summary>
53 /// Scene that created this object. 58 /// Scene that created this object.
54 /// </summary> 59 /// </summary>
55 private OdeScene m_scene; 60 private OdeScene m_scene;
@@ -96,6 +101,29 @@ namespace OpenSim.Region.Physics.OdePlugin
96 } 101 }
97 102
98 /// <summary> 103 /// <summary>
104 /// Queues a raycast
105 /// </summary>
106 /// <param name="position">Origin of Ray</param>
107 /// <param name="direction">Ray normal</param>
108 /// <param name="length">Ray length</param>
109 /// <param name="count"></param>
110 /// <param name="retMethod">Return method to send the results</param>
111 public void QueueRequest(Vector3 position, Vector3 direction, float length, int count, RayCallback retMethod)
112 {
113 lock (m_PendingRequests)
114 {
115 ODERayRequest req = new ODERayRequest();
116 req.callbackMethod = retMethod;
117 req.length = length;
118 req.Normal = direction;
119 req.Origin = position;
120 req.Count = count;
121
122 m_PendingRayRequests.Add(req);
123 }
124 }
125
126 /// <summary>
99 /// Process all queued raycast requests 127 /// Process all queued raycast requests
100 /// </summary> 128 /// </summary>
101 /// <returns>Time in MS the raycasts took to process.</returns> 129 /// <returns>Time in MS the raycasts took to process.</returns>
@@ -112,15 +140,23 @@ namespace OpenSim.Region.Physics.OdePlugin
112 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast 140 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
113 RayCast(reqs[i]); // if there isn't anyone to send results 141 RayCast(reqs[i]); // if there isn't anyone to send results
114 } 142 }
115 /* 143
116 foreach (ODERayCastRequest req in m_PendingRequests) 144 m_PendingRequests.Clear();
145 }
146 }
147
148 lock (m_PendingRayRequests)
149 {
150 if (m_PendingRayRequests.Count > 0)
151 {
152 ODERayRequest[] reqs = m_PendingRayRequests.ToArray();
153 for (int i = 0; i < reqs.Length; i++)
117 { 154 {
118 if (req.callbackMethod != null) // quick optimization here, don't raycast 155 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
119 RayCast(req); // if there isn't anyone to send results to 156 RayCast(reqs[i]); // if there isn't anyone to send results
120
121 } 157 }
122 */ 158
123 m_PendingRequests.Clear(); 159 m_PendingRayRequests.Clear();
124 } 160 }
125 } 161 }
126 162
@@ -146,7 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin
146 // Remove Ray 182 // Remove Ray
147 d.GeomDestroy(ray); 183 d.GeomDestroy(ray);
148 184
149
150 // Define default results 185 // Define default results
151 bool hitYN = false; 186 bool hitYN = false;
152 uint hitConsumerID = 0; 187 uint hitConsumerID = 0;
@@ -177,6 +212,31 @@ namespace OpenSim.Region.Physics.OdePlugin
177 req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance, snormal); 212 req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance, snormal);
178 } 213 }
179 214
215 /// <summary>
216 /// Method that actually initiates the raycast
217 /// </summary>
218 /// <param name="req"></param>
219 private void RayCast(ODERayRequest req)
220 {
221 // Create the ray
222 IntPtr ray = d.CreateRay(m_scene.space, req.length);
223 d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z);
224
225 // Collide test
226 d.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback);
227
228 // Remove Ray
229 d.GeomDestroy(ray);
230
231 // Find closest contact and object.
232 lock (m_contactResults)
233 {
234 // Return results
235 if (req.callbackMethod != null)
236 req.callbackMethod(m_contactResults);
237 }
238 }
239
180 // This is the standard Near. Uses space AABBs to speed up detection. 240 // This is the standard Near. Uses space AABBs to speed up detection.
181 private void near(IntPtr space, IntPtr g1, IntPtr g2) 241 private void near(IntPtr space, IntPtr g1, IntPtr g2)
182 { 242 {
@@ -342,10 +402,7 @@ namespace OpenSim.Region.Physics.OdePlugin
342 m_contactResults.Add(collisionresult); 402 m_contactResults.Add(collisionresult);
343 } 403 }
344 } 404 }
345
346
347 } 405 }
348
349 } 406 }
350 407
351 /// <summary> 408 /// <summary>
@@ -365,11 +422,12 @@ namespace OpenSim.Region.Physics.OdePlugin
365 public RaycastCallback callbackMethod; 422 public RaycastCallback callbackMethod;
366 } 423 }
367 424
368 public struct ContactResult 425 public struct ODERayRequest
369 { 426 {
370 public Vector3 Pos; 427 public Vector3 Origin;
371 public float Depth;
372 public uint ConsumerID;
373 public Vector3 Normal; 428 public Vector3 Normal;
429 public int Count;
430 public float length;
431 public RayCallback callbackMethod;
374 } 432 }
375} 433} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 99392cc..a307469 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1677,7 +1677,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1677 } 1677 }
1678 1678
1679 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1679 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1680 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 1680 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, uint localID)
1681 { 1681 {
1682 Vector3 pos = position; 1682 Vector3 pos = position;
1683 Vector3 siz = size; 1683 Vector3 siz = size;
@@ -1691,7 +1691,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1691 lock (_prims) 1691 lock (_prims)
1692 _prims.Add(newPrim); 1692 _prims.Add(newPrim);
1693 } 1693 }
1694 1694 newPrim.LocalID = localID;
1695 return newPrim; 1695 return newPrim;
1696 } 1696 }
1697 1697
@@ -1708,13 +1708,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1708 } 1708 }
1709 1709
1710 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1710 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1711 Vector3 size, Quaternion rotation) //To be removed 1711 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
1712 {
1713 return AddPrimShape(primName, pbs, position, size, rotation, false);
1714 }
1715
1716 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1717 Vector3 size, Quaternion rotation, bool isPhysical)
1718 { 1712 {
1719#if SPAM 1713#if SPAM
1720 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName); 1714 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName);
@@ -1723,22 +1717,23 @@ namespace OpenSim.Region.Physics.OdePlugin
1723 PhysicsActor result; 1717 PhysicsActor result;
1724 IMesh mesh = null; 1718 IMesh mesh = null;
1725 1719
1726 if (needsMeshing(pbs)) 1720 // Don't create the mesh here - wait until the mesh data is loaded from the asset store.
1727 { 1721// if (needsMeshing(pbs))
1728 try 1722// {
1729 { 1723// try
1730 mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); 1724// {
1731 } 1725// mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical);
1732 catch(Exception e) 1726// }
1733 { 1727// catch(Exception e)
1734 m_log.ErrorFormat("[PHYSICS]: Exception while meshing prim {0}.", primName); 1728// {
1735 m_log.Debug(e.ToString()); 1729// m_log.ErrorFormat("[PHYSICS]: Exception while meshing prim {0}.", primName);
1736 mesh = null; 1730// m_log.Debug(e.ToString());
1737 return null; 1731// mesh = null;
1738 } 1732// return null;
1739 } 1733// }
1740 1734// }
1741 result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); 1735
1736 result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, localid);
1742 1737
1743 return result; 1738 return result;
1744 } 1739 }
@@ -2590,7 +2585,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2590 { 2585 {
2591 if (!(_taintedPrimH.Contains(taintedprim))) 2586 if (!(_taintedPrimH.Contains(taintedprim)))
2592 { 2587 {
2593//Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.m_primName); 2588#if SPAM
2589Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2590#endif
2594 _taintedPrimH.Add(taintedprim); // HashSet for searching 2591 _taintedPrimH.Add(taintedprim); // HashSet for searching
2595 _taintedPrimL.Add(taintedprim); // List for ordered readout 2592 _taintedPrimL.Add(taintedprim); // List for ordered readout
2596 } 2593 }
@@ -3733,6 +3730,34 @@ namespace OpenSim.Region.Physics.OdePlugin
3733 } 3730 }
3734 } 3731 }
3735 3732
3733 public override void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod)
3734 {
3735 if (retMethod != null)
3736 {
3737 m_rayCastManager.QueueRequest(position, direction, length, Count, retMethod);
3738 }
3739 }
3740
3741 public override List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count)
3742 {
3743 ContactResult[] ourResults = null;
3744 RayCallback retMethod = delegate(List<ContactResult> results)
3745 {
3746 ourResults = new ContactResult[results.Count];
3747 results.CopyTo(ourResults, 0);
3748 };
3749 int waitTime = 0;
3750 m_rayCastManager.QueueRequest(position, direction, length, Count, retMethod);
3751 while (ourResults == null && waitTime < 1000)
3752 {
3753 Thread.Sleep(1);
3754 waitTime++;
3755 }
3756 if (ourResults == null)
3757 return new List<ContactResult> ();
3758 return new List<ContactResult>(ourResults);
3759 }
3760
3736#if USE_DRAWSTUFF 3761#if USE_DRAWSTUFF
3737 // Keyboard callback 3762 // Keyboard callback
3738 public void command(int cmd) 3763 public void command(int cmd)
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
index a7f8baa..2ea810f 100644
--- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
@@ -31,17 +31,18 @@ using NUnit.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
34using OpenSim.Region.Physics.OdePlugin;
34using log4net; 35using log4net;
35using System.Reflection; 36using System.Reflection;
36 37
37namespace OpenSim.Region.Physics.OdePlugin 38namespace OpenSim.Region.Physics.OdePlugin.Tests
38{ 39{
39 [TestFixture] 40 [TestFixture]
40 public class ODETestClass 41 public class ODETestClass
41 { 42 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 44
44 private OdePlugin cbt; 45 private OpenSim.Region.Physics.OdePlugin.OdePlugin cbt;
45 private PhysicsScene ps; 46 private PhysicsScene ps;
46 private IMeshingPlugin imp; 47 private IMeshingPlugin imp;
47 48
@@ -83,7 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin
83 Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); 84 Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
84 Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); 85 Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
85 Quaternion rot = Quaternion.Identity; 86 Quaternion rot = Quaternion.Identity;
86 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); 87 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0);
87 OdePrim oprim = (OdePrim)prim; 88 OdePrim oprim = (OdePrim)prim;
88 OdeScene pscene = (OdeScene) ps; 89 OdeScene pscene = (OdeScene) ps;
89 90
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
index c3f5040..2f24a50 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
@@ -91,13 +91,7 @@ namespace OpenSim.Region.Physics.POSPlugin
91*/ 91*/
92 92
93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
94 Vector3 size, Quaternion rotation) 94 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
95 {
96 return AddPrimShape(primName, pbs, position, size, rotation, false);
97 }
98
99 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
100 Vector3 size, Quaternion rotation, bool isPhysical)
101 { 95 {
102 POSPrim prim = new POSPrim(); 96 POSPrim prim = new POSPrim();
103 prim.Position = position; 97 prim.Position = position;
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
index 4de4b01..beb3404 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
@@ -108,13 +108,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
108 } 108 }
109 109
110 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 110 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
111 Vector3 size, Quaternion rotation) //To be removed 111 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
112 {
113 return AddPrimShape(primName, pbs, position, size, rotation, false);
114 }
115
116 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
117 Vector3 size, Quaternion rotation, bool isPhysical)
118 { 112 {
119 return AddPrim(position, size, rotation); 113 return AddPrim(position, size, rotation);
120 } 114 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fd6d64c..26969a5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2214,7 +2214,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2214 public LSL_Vector llGetVel() 2214 public LSL_Vector llGetVel()
2215 { 2215 {
2216 m_host.AddScriptLPS(1); 2216 m_host.AddScriptLPS(1);
2217 return new LSL_Vector(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z); 2217
2218 Vector3 vel;
2219
2220 if (m_host.IsAttachment)
2221 {
2222 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.AttachedAvatar);
2223 vel = avatar.Velocity;
2224 }
2225 else
2226 {
2227 vel = m_host.Velocity;
2228 }
2229
2230 return new LSL_Vector(vel.X, vel.Y, vel.Z);
2218 } 2231 }
2219 2232
2220 public LSL_Vector llGetAccel() 2233 public LSL_Vector llGetAccel()
@@ -2510,10 +2523,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2510 /// negative (indicating end-relative) and may be inverted, 2523 /// negative (indicating end-relative) and may be inverted,
2511 /// i.e. end < start. 2524 /// i.e. end < start.
2512 /// </summary> 2525 /// </summary>
2513
2514 public LSL_String llDeleteSubString(string src, int start, int end) 2526 public LSL_String llDeleteSubString(string src, int start, int end)
2515 { 2527 {
2516
2517 m_host.AddScriptLPS(1); 2528 m_host.AddScriptLPS(1);
2518 2529
2519 // Normalize indices (if negative). 2530 // Normalize indices (if negative).
@@ -2593,10 +2604,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2593 /// which case it is end-relative. The index may exceed either 2604 /// which case it is end-relative. The index may exceed either
2594 /// string bound, with the result being a concatenation. 2605 /// string bound, with the result being a concatenation.
2595 /// </summary> 2606 /// </summary>
2596
2597 public LSL_String llInsertString(string dest, int index, string src) 2607 public LSL_String llInsertString(string dest, int index, string src)
2598 { 2608 {
2599
2600 m_host.AddScriptLPS(1); 2609 m_host.AddScriptLPS(1);
2601 2610
2602 // Normalize indices (if negative). 2611 // Normalize indices (if negative).
@@ -9983,6 +9992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9983 public LSL_List llGetObjectDetails(string id, LSL_List args) 9992 public LSL_List llGetObjectDetails(string id, LSL_List args)
9984 { 9993 {
9985 m_host.AddScriptLPS(1); 9994 m_host.AddScriptLPS(1);
9995
9986 LSL_List ret = new LSL_List(); 9996 LSL_List ret = new LSL_List();
9987 UUID key = new UUID(); 9997 UUID key = new UUID();
9988 if (UUID.TryParse(id, out key)) 9998 if (UUID.TryParse(id, out key))
@@ -9993,72 +10003,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9993 { 10003 {
9994 foreach (object o in args.Data) 10004 foreach (object o in args.Data)
9995 { 10005 {
9996 switch (o.ToString()) 10006 switch (int.Parse(o.ToString()))
9997 { 10007 {
9998 case "1": 10008 case ScriptBaseClass.OBJECT_NAME:
9999 ret.Add(new LSL_String(av.Firstname + " " + av.Lastname)); 10009 ret.Add(new LSL_String(av.Firstname + " " + av.Lastname));
10000 break; 10010 break;
10001 case "2": 10011 case ScriptBaseClass.OBJECT_DESC:
10002 ret.Add(new LSL_String("")); 10012 ret.Add(new LSL_String(""));
10003 break; 10013 break;
10004 case "3": 10014 case ScriptBaseClass.OBJECT_POS:
10005 ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); 10015 ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z));
10006 break; 10016 break;
10007 case "4": 10017 case ScriptBaseClass.OBJECT_ROT:
10008 ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); 10018 ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W));
10009 break; 10019 break;
10010 case "5": 10020 case ScriptBaseClass.OBJECT_VELOCITY:
10011 ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); 10021 ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z));
10012 break; 10022 break;
10013 case "6": 10023 case ScriptBaseClass.OBJECT_OWNER:
10014 ret.Add(new LSL_String(id)); 10024 ret.Add(new LSL_String(id));
10015 break; 10025 break;
10016 case "7": 10026 case ScriptBaseClass.OBJECT_GROUP:
10017 ret.Add(new LSL_String(UUID.Zero.ToString())); 10027 ret.Add(new LSL_String(UUID.Zero.ToString()));
10018 break; 10028 break;
10019 case "8": 10029 case ScriptBaseClass.OBJECT_CREATOR:
10020 ret.Add(new LSL_String(UUID.Zero.ToString())); 10030 ret.Add(new LSL_String(UUID.Zero.ToString()));
10021 break; 10031 break;
10022 } 10032 }
10023 } 10033 }
10034
10024 return ret; 10035 return ret;
10025 } 10036 }
10037
10026 SceneObjectPart obj = World.GetSceneObjectPart(key); 10038 SceneObjectPart obj = World.GetSceneObjectPart(key);
10027 if (obj != null) 10039 if (obj != null)
10028 { 10040 {
10029 foreach (object o in args.Data) 10041 foreach (object o in args.Data)
10030 { 10042 {
10031 switch (o.ToString()) 10043 switch (int.Parse(o.ToString()))
10032 { 10044 {
10033 case "1": 10045 case ScriptBaseClass.OBJECT_NAME:
10034 ret.Add(new LSL_String(obj.Name)); 10046 ret.Add(new LSL_String(obj.Name));
10035 break; 10047 break;
10036 case "2": 10048 case ScriptBaseClass.OBJECT_DESC:
10037 ret.Add(new LSL_String(obj.Description)); 10049 ret.Add(new LSL_String(obj.Description));
10038 break; 10050 break;
10039 case "3": 10051 case ScriptBaseClass.OBJECT_POS:
10040 ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); 10052 ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z));
10041 break; 10053 break;
10042 case "4": 10054 case ScriptBaseClass.OBJECT_ROT:
10043 ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); 10055 ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W));
10044 break; 10056 break;
10045 case "5": 10057 case ScriptBaseClass.OBJECT_VELOCITY:
10046 ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); 10058 ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z));
10047 break; 10059 break;
10048 case "6": 10060 case ScriptBaseClass.OBJECT_OWNER:
10049 ret.Add(new LSL_String(obj.OwnerID.ToString())); 10061 ret.Add(new LSL_String(obj.OwnerID.ToString()));
10050 break; 10062 break;
10051 case "7": 10063 case ScriptBaseClass.OBJECT_GROUP:
10052 ret.Add(new LSL_String(obj.GroupID.ToString())); 10064 ret.Add(new LSL_String(obj.GroupID.ToString()));
10053 break; 10065 break;
10054 case "8": 10066 case ScriptBaseClass.OBJECT_CREATOR:
10055 ret.Add(new LSL_String(obj.CreatorID.ToString())); 10067 ret.Add(new LSL_String(obj.CreatorID.ToString()));
10056 break; 10068 break;
10057 } 10069 }
10058 } 10070 }
10071
10059 return ret; 10072 return ret;
10060 } 10073 }
10061 } 10074 }
10075
10062 return new LSL_List(); 10076 return new LSL_List();
10063 } 10077 }
10064 10078
@@ -10309,51 +10323,191 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10309 return rq.ToString(); 10323 return rq.ToString();
10310 } 10324 }
10311 10325
10326 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10327 {
10328 m_host.AddScriptLPS(1);
10329
10330 Vector3 dir = new Vector3((float)(end-start).x, (float)(end-start).y, (float)(end-start).z);
10331 Vector3 startvector = new Vector3((float)start.x, (float)start.y, (float)start.z);
10332 Vector3 endvector = new Vector3((float)end.x, (float)end.y, (float)end.z);
10333
10334 int count = 0;
10335// int detectPhantom = 0;
10336 int dataFlags = 0;
10337 int rejectTypes = 0;
10338
10339 for (int i = 0; i < options.Length; i += 2)
10340 {
10341 if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS)
10342 {
10343 count = options.GetLSLIntegerItem(i + 1);
10344 }
10345// else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM)
10346// {
10347// detectPhantom = options.GetLSLIntegerItem(i + 1);
10348// }
10349 else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS)
10350 {
10351 dataFlags = options.GetLSLIntegerItem(i + 1);
10352 }
10353 else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES)
10354 {
10355 rejectTypes = options.GetLSLIntegerItem(i + 1);
10356 }
10357 }
10358
10359 LSL_List list = new LSL_List();
10360 List<ContactResult> results = World.PhysicsScene.RaycastWorld(startvector, dir, dir.Length(), count);
10361
10362 double distance = Util.GetDistanceTo(startvector, endvector);
10363
10364 if (distance == 0)
10365 distance = 0.001;
10366
10367 Vector3 posToCheck = startvector;
10368 ITerrainChannel channel = World.RequestModuleInterface<ITerrainChannel>();
10369
10370 bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND);
10371 bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS);
10372 bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL);
10373 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
10374
10375 for (float i = 0; i <= distance; i += 0.1f)
10376 {
10377 posToCheck = startvector + (dir * (i / (float)distance));
10378
10379 if (checkTerrain && channel[(int)(posToCheck.X + startvector.X), (int)(posToCheck.Y + startvector.Y)] < posToCheck.Z)
10380 {
10381 ContactResult result = new ContactResult();
10382 result.ConsumerID = 0;
10383 result.Depth = 0;
10384 result.Normal = Vector3.Zero;
10385 result.Pos = posToCheck;
10386 results.Add(result);
10387 checkTerrain = false;
10388 }
10389
10390 if (checkAgents)
10391 {
10392 World.ForEachScenePresence(delegate(ScenePresence sp)
10393 {
10394 if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X))
10395 {
10396 ContactResult result = new ContactResult ();
10397 result.ConsumerID = sp.LocalId;
10398 result.Depth = 0;
10399 result.Normal = Vector3.Zero;
10400 result.Pos = posToCheck;
10401 results.Add(result);
10402 }
10403 });
10404 }
10405 }
10406
10407 int refcount = 0;
10408 foreach (ContactResult result in results)
10409 {
10410 if ((rejectTypes & ScriptBaseClass.RC_REJECT_LAND)
10411 == ScriptBaseClass.RC_REJECT_LAND && result.ConsumerID == 0)
10412 continue;
10413
10414 ISceneEntity entity = World.GetSceneObjectPart(result.ConsumerID);
10415
10416 if (entity == null && (rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) != ScriptBaseClass.RC_REJECT_AGENTS)
10417 entity = World.GetScenePresence(result.ConsumerID); //Only check if we should be looking for agents
10418
10419 if (entity == null)
10420 {
10421 list.Add(UUID.Zero);
10422
10423 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
10424 list.Add(0);
10425
10426 list.Add(result.Pos);
10427
10428 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
10429 list.Add(result.Normal);
10430
10431 continue; //Can't find it, so add UUID.Zero
10432 }
10433
10434 /*if (detectPhantom == 0 && intersection.obj is ISceneChildEntity &&
10435 ((ISceneChildEntity)intersection.obj).PhysActor == null)
10436 continue;*/ //Can't do this ATM, physics engine knows only of non phantom objects
10437
10438 if (entity is SceneObjectPart)
10439 {
10440 if (((SceneObjectPart)entity).PhysActor != null && ((SceneObjectPart)entity).PhysActor.IsPhysical)
10441 {
10442 if (!checkPhysical)
10443 continue;
10444 }
10445 else
10446 {
10447 if (!checkNonPhysical)
10448 continue;
10449 }
10450 }
10451
10452 refcount++;
10453 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY && entity is SceneObjectPart)
10454 list.Add(((SceneObjectPart)entity).ParentGroup.UUID);
10455 else
10456 list.Add(entity.UUID);
10457
10458 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
10459 {
10460 if (entity is SceneObjectPart)
10461 list.Add(((SceneObjectPart)entity).LinkNum);
10462 else
10463 list.Add(0);
10464 }
10465
10466 list.Add(result.Pos);
10467
10468 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
10469 list.Add(result.Normal);
10470 }
10471
10472 list.Add(refcount); //The status code, either the # of contacts, RCERR_SIM_PERF_LOW, or RCERR_CAST_TIME_EXCEEDED
10473
10474 return list;
10475 }
10476
10312 #region Not Implemented 10477 #region Not Implemented
10313 // 10478 //
10314 // Listing the unimplemented lsl functions here, please move 10479 // Listing the unimplemented lsl functions here, please move
10315 // them from this region as they are completed 10480 // them from this region as they are completed
10316 // 10481 //
10317 public void llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10318 {
10319 m_host.AddScriptLPS(1);
10320 NotImplemented("llCastRay");
10321
10322 }
10323 10482
10324 public void llGetEnv(LSL_String name) 10483 public void llGetEnv(LSL_String name)
10325 { 10484 {
10326 m_host.AddScriptLPS(1); 10485 m_host.AddScriptLPS(1);
10327 NotImplemented("llGetEnv"); 10486 NotImplemented("llGetEnv");
10328
10329 } 10487 }
10330 10488
10331 public void llGetSPMaxMemory() 10489 public void llGetSPMaxMemory()
10332 { 10490 {
10333 m_host.AddScriptLPS(1); 10491 m_host.AddScriptLPS(1);
10334 NotImplemented("llGetSPMaxMemory"); 10492 NotImplemented("llGetSPMaxMemory");
10335
10336 } 10493 }
10337 10494
10338 public void llGetUsedMemory() 10495 public void llGetUsedMemory()
10339 { 10496 {
10340 m_host.AddScriptLPS(1); 10497 m_host.AddScriptLPS(1);
10341 NotImplemented("llGetUsedMemory"); 10498 NotImplemented("llGetUsedMemory");
10342
10343 } 10499 }
10344 10500
10345 public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) 10501 public void llRegionSayTo(LSL_Key target, LSL_Integer channel, LSL_String msg)
10346 { 10502 {
10347 m_host.AddScriptLPS(1); 10503 m_host.AddScriptLPS(1);
10348 NotImplemented("llRegionSayTo"); 10504 NotImplemented("llRegionSayTo");
10349
10350 } 10505 }
10351 10506
10352 public void llScriptProfiler( LSL_Integer flags ) 10507 public void llScriptProfiler(LSL_Integer flags)
10353 { 10508 {
10354 m_host.AddScriptLPS(1); 10509 m_host.AddScriptLPS(1);
10355 NotImplemented("llScriptProfiler"); 10510 NotImplemented("llScriptProfiler");
10356
10357 } 10511 }
10358 10512
10359 public void llSetSoundQueueing(int queue) 10513 public void llSetSoundQueueing(int queue)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 654ea81..27f9c84 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
60 LSL_String llBase64ToString(string str); 60 LSL_String llBase64ToString(string str);
61 void llBreakAllLinks(); 61 void llBreakAllLinks();
62 void llBreakLink(int linknum); 62 void llBreakLink(int linknum);
63 LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options);
63 LSL_Integer llCeil(double f); 64 LSL_Integer llCeil(double f);
64 void llClearCameraParams(); 65 void llClearCameraParams();
65 LSL_Integer llClearPrimMedia(LSL_Integer face); 66 LSL_Integer llClearPrimMedia(LSL_Integer face);
@@ -404,7 +405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
404 LSL_String llXorBase64StringsCorrect(string str1, string str2); 405 LSL_String llXorBase64StringsCorrect(string str1, string str2);
405 void print(string str); 406 void print(string str);
406 407
407 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 408 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
408 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 409 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
409 } 410 }
410} 411}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 9377cda..3f90788 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -593,5 +593,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
593 593
594 public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; 594 public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
595 public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; 595 public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
596
597 public static readonly LSLInteger RC_REJECT_TYPES = 2;
598 public static readonly LSLInteger RC_DATA_FLAGS = 4;
599 public static readonly LSLInteger RC_MAX_HITS = 8;
600 public static readonly LSLInteger RC_DETECT_PHANTOM = 16;
601
602 public static readonly LSLInteger RC_REJECT_AGENTS = 2;
603 public static readonly LSLInteger RC_REJECT_PHYSICAL = 4;
604 public static readonly LSLInteger RC_REJECT_NONPHYSICAL = 8;
605 public static readonly LSLInteger RC_REJECT_LAND = 16;
606
607 public static readonly LSLInteger RC_GET_NORMAL = 2;
608 public static readonly LSLInteger RC_GET_ROOT_KEY = 4;
609 public static readonly LSLInteger RC_GET_LINK_NUM = 8;
610
611 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 1;
596 } 612 }
597} 613}