aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs117
1 files changed, 90 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c6d8c73..2026c53 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.IO;
31using System.Reflection; 32using System.Reflection;
32using System.Runtime.Serialization; 33using System.Runtime.Serialization;
33using System.Security.Permissions; 34using System.Security.Permissions;
@@ -800,7 +801,8 @@ namespace OpenSim.Region.Framework.Scenes
800 actor.Orientation = GetWorldRotation(); 801 actor.Orientation = GetWorldRotation();
801 802
802 // Tell the physics engines that this prim changed. 803 // Tell the physics engines that this prim changed.
803 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 804 if (m_parentGroup.Scene != null)
805 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
804 } 806 }
805 } 807 }
806 } 808 }
@@ -1067,7 +1069,6 @@ namespace OpenSim.Region.Framework.Scenes
1067 } 1069 }
1068 } 1070 }
1069 1071
1070
1071 public bool CreateSelected 1072 public bool CreateSelected
1072 { 1073 {
1073 get { return m_createSelected; } 1074 get { return m_createSelected; }
@@ -1085,11 +1086,13 @@ namespace OpenSim.Region.Framework.Scenes
1085 1086
1086 public Vector3 AbsolutePosition 1087 public Vector3 AbsolutePosition
1087 { 1088 {
1088 get { 1089 get
1090 {
1089 if (IsAttachment) 1091 if (IsAttachment)
1090 return GroupPosition; 1092 return GroupPosition;
1091 1093
1092 return m_offsetPosition + m_groupPosition; } 1094 return m_offsetPosition + m_groupPosition;
1095 }
1093 } 1096 }
1094 1097
1095 public SceneObjectGroup ParentGroup 1098 public SceneObjectGroup ParentGroup
@@ -1238,7 +1241,9 @@ namespace OpenSim.Region.Framework.Scenes
1238 /// <summary> 1241 /// <summary>
1239 /// Property flags. See OpenMetaverse.PrimFlags 1242 /// Property flags. See OpenMetaverse.PrimFlags
1240 /// </summary> 1243 /// </summary>
1244 /// <remarks>
1241 /// Example properties are PrimFlags.Phantom and PrimFlags.DieAtEdge 1245 /// Example properties are PrimFlags.Phantom and PrimFlags.DieAtEdge
1246 /// </remarks>
1242 public PrimFlags Flags 1247 public PrimFlags Flags
1243 { 1248 {
1244 get { return _flags; } 1249 get { return _flags; }
@@ -1561,6 +1566,8 @@ namespace OpenSim.Region.Framework.Scenes
1561 /// <param name="m_physicalPrim"></param> 1566 /// <param name="m_physicalPrim"></param>
1562 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool m_physicalPrim) 1567 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool m_physicalPrim)
1563 { 1568 {
1569// m_log.DebugFormat("[SCENE OBJECT PART]: Applying physics to {0} {1} {2}", Name, LocalId, UUID);
1570
1564 bool isPhysical = (((rootObjectFlags & (uint) PrimFlags.Physics) != 0) && m_physicalPrim); 1571 bool isPhysical = (((rootObjectFlags & (uint) PrimFlags.Physics) != 0) && m_physicalPrim);
1565 bool isPhantom = ((rootObjectFlags & (uint) PrimFlags.Phantom) != 0); 1572 bool isPhantom = ((rootObjectFlags & (uint) PrimFlags.Phantom) != 0);
1566 1573
@@ -1581,6 +1588,8 @@ namespace OpenSim.Region.Framework.Scenes
1581 // or flexible 1588 // or flexible
1582 if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) 1589 if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible))
1583 { 1590 {
1591// m_log.DebugFormat("[SCENE OBJECT PART]: Creating PhysActor for {0} {1} {2}", Name, LocalId, UUID);
1592
1584 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 1593 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
1585 LocalId, 1594 LocalId,
1586 string.Format("{0}/{1}", Name, UUID), 1595 string.Format("{0}/{1}", Name, UUID),
@@ -1802,7 +1811,6 @@ namespace OpenSim.Region.Framework.Scenes
1802 { 1811 {
1803 ParentGroup.Scene.jointErrorMessage(joint, "warning: tracked body name not found! joint location will not be updated properly. joint: " + Name); 1812 ParentGroup.Scene.jointErrorMessage(joint, "warning: tracked body name not found! joint location will not be updated properly. joint: " + Name);
1804 } 1813 }
1805
1806 } 1814 }
1807 else 1815 else
1808 { 1816 {
@@ -1864,7 +1872,6 @@ namespace OpenSim.Region.Framework.Scenes
1864 1872
1865 PhysActor.IsPhysical = UsePhysics; 1873 PhysActor.IsPhysical = UsePhysics;
1866 1874
1867
1868 // If we're not what we're supposed to be in the physics scene, recreate ourselves. 1875 // If we're not what we're supposed to be in the physics scene, recreate ourselves.
1869 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 1876 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
1870 /// that's not wholesome. Had to make Scene public 1877 /// that's not wholesome. Had to make Scene public
@@ -1888,6 +1895,7 @@ namespace OpenSim.Region.Framework.Scenes
1888 } 1895 }
1889 } 1896 }
1890 } 1897 }
1898
1891 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 1899 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
1892 } 1900 }
1893 } 1901 }
@@ -2823,6 +2831,12 @@ namespace OpenSim.Region.Framework.Scenes
2823 StoreUndoState(); 2831 StoreUndoState();
2824 m_shape.Scale = scale; 2832 m_shape.Scale = scale;
2825 2833
2834 // If we're a mesh/sculpt, then we need to tell the physics engine about our new size. To do this, we
2835 // need to reinsert the sculpt data into the shape, since the physics engine deletes it when done to
2836 // save memory
2837 if (PhysActor != null)
2838 CheckSculptAndLoad();
2839
2826 ParentGroup.HasGroupChanged = true; 2840 ParentGroup.HasGroupChanged = true;
2827 ScheduleFullUpdate(); 2841 ScheduleFullUpdate();
2828 } 2842 }
@@ -2951,7 +2965,6 @@ namespace OpenSim.Region.Framework.Scenes
2951 } 2965 }
2952 } 2966 }
2953 2967
2954
2955 public void SculptTextureCallback(UUID textureID, AssetBase texture) 2968 public void SculptTextureCallback(UUID textureID, AssetBase texture)
2956 { 2969 {
2957 if (m_shape.SculptEntry) 2970 if (m_shape.SculptEntry)
@@ -2960,14 +2973,17 @@ namespace OpenSim.Region.Framework.Scenes
2960 //if (texture != null) 2973 //if (texture != null)
2961 { 2974 {
2962 if (texture != null) 2975 if (texture != null)
2976 {
2977// m_log.DebugFormat(
2978// "[SCENE OBJECT PART]: Setting sculpt data for {0} on SculptTextureCallback()", Name);
2979
2963 m_shape.SculptData = texture.Data; 2980 m_shape.SculptData = texture.Data;
2981 }
2964 2982
2965 if (PhysActor != null) 2983 if (PhysActor != null)
2966 { 2984 {
2967 // Tricks physics engine into thinking we've changed the part shape. 2985 // Update the physics actor with the new loaded sculpt data and set the taint signal.
2968 PrimitiveBaseShape m_newshape = m_shape.Copy(); 2986 PhysActor.Shape = m_shape;
2969 PhysActor.Shape = m_newshape;
2970 m_shape = m_newshape;
2971 2987
2972 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 2988 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
2973 } 2989 }
@@ -3263,11 +3279,14 @@ namespace OpenSim.Region.Framework.Scenes
3263 { 3279 {
3264 m_parentGroup.SetAxisRotation(axis, rotate); 3280 m_parentGroup.SetAxisRotation(axis, rotate);
3265 } 3281 }
3282
3266 //Cannot use ScriptBaseClass constants as no referance to it currently. 3283 //Cannot use ScriptBaseClass constants as no referance to it currently.
3267 if (axis == 2)//STATUS_ROTATE_X 3284 if (axis == 2)//STATUS_ROTATE_X
3268 STATUS_ROTATE_X = rotate; 3285 STATUS_ROTATE_X = rotate;
3286
3269 if (axis == 4)//STATUS_ROTATE_Y 3287 if (axis == 4)//STATUS_ROTATE_Y
3270 STATUS_ROTATE_Y = rotate; 3288 STATUS_ROTATE_Y = rotate;
3289
3271 if (axis == 8)//STATUS_ROTATE_Z 3290 if (axis == 8)//STATUS_ROTATE_Z
3272 STATUS_ROTATE_Z = rotate; 3291 STATUS_ROTATE_Z = rotate;
3273 } 3292 }
@@ -4318,14 +4337,21 @@ namespace OpenSim.Region.Framework.Scenes
4318 } 4337 }
4319 } 4338 }
4320 4339
4321 public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVD) 4340 /// <summary>
4341 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
4342 /// </summary>
4343 /// <param name="UsePhysics"></param>
4344 /// <param name="SetTemporary"></param>
4345 /// <param name="SetPhantom"></param>
4346 /// <param name="SetVD"></param>
4347 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD)
4322 { 4348 {
4323 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4349 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
4324 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); 4350 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
4325 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4351 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4326 bool wasVD = VolumeDetectActive; 4352 bool wasVD = VolumeDetectActive;
4327 4353
4328 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD==wasVD)) 4354 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4329 { 4355 {
4330 return; 4356 return;
4331 } 4357 }
@@ -4335,32 +4361,31 @@ namespace OpenSim.Region.Framework.Scenes
4335 // that... 4361 // that...
4336 // ... if VD is changed, all others are not. 4362 // ... if VD is changed, all others are not.
4337 // ... if one of the others is changed, VD is not. 4363 // ... if one of the others is changed, VD is not.
4338 if (IsVD) // VD is active, special logic applies 4364 if (SetVD) // VD is active, special logic applies
4339 { 4365 {
4340 // State machine logic for VolumeDetect 4366 // State machine logic for VolumeDetect
4341 // More logic below 4367 // More logic below
4342 bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom; 4368 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
4343 4369
4344 if (phanReset) // Phantom changes from on to off switch VD off too 4370 if (phanReset) // Phantom changes from on to off switch VD off too
4345 { 4371 {
4346 IsVD = false; // Switch it of for the course of this routine 4372 SetVD = false; // Switch it of for the course of this routine
4347 VolumeDetectActive = false; // and also permanently 4373 VolumeDetectActive = false; // and also permanently
4348 if (PhysActor != null) 4374 if (PhysActor != null)
4349 PhysActor.SetVolumeDetect(0); // Let physics know about it too 4375 PhysActor.SetVolumeDetect(0); // Let physics know about it too
4350 } 4376 }
4351 else 4377 else
4352 { 4378 {
4353 IsPhantom = false;
4354 // If volumedetect is active we don't want phantom to be applied. 4379 // If volumedetect is active we don't want phantom to be applied.
4355 // If this is a new call to VD out of the state "phantom" 4380 // If this is a new call to VD out of the state "phantom"
4356 // this will also cause the prim to be visible to physics 4381 // this will also cause the prim to be visible to physics
4382 SetPhantom = false;
4357 } 4383 }
4358
4359 } 4384 }
4360 4385
4361 if (UsePhysics && IsJoint()) 4386 if (UsePhysics && IsJoint())
4362 { 4387 {
4363 IsPhantom = true; 4388 SetPhantom = true;
4364 } 4389 }
4365 4390
4366 if (UsePhysics) 4391 if (UsePhysics)
@@ -4390,8 +4415,7 @@ namespace OpenSim.Region.Framework.Scenes
4390 } 4415 }
4391 } 4416 }
4392 4417
4393 4418 if (SetPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4394 if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4395 { 4419 {
4396 AddFlag(PrimFlags.Phantom); 4420 AddFlag(PrimFlags.Phantom);
4397 if (PhysActor != null) 4421 if (PhysActor != null)
@@ -4406,6 +4430,7 @@ namespace OpenSim.Region.Framework.Scenes
4406 RemFlag(PrimFlags.Phantom); 4430 RemFlag(PrimFlags.Phantom);
4407 4431
4408 PhysicsActor pa = PhysActor; 4432 PhysicsActor pa = PhysActor;
4433
4409 if (pa == null) 4434 if (pa == null)
4410 { 4435 {
4411 // It's not phantom anymore. So make sure the physics engine get's knowledge of it 4436 // It's not phantom anymore. So make sure the physics engine get's knowledge of it
@@ -4422,6 +4447,7 @@ namespace OpenSim.Region.Framework.Scenes
4422 if (pa != null) 4447 if (pa != null)
4423 { 4448 {
4424 DoPhysicsPropertyUpdate(UsePhysics, true); 4449 DoPhysicsPropertyUpdate(UsePhysics, true);
4450
4425 if (m_parentGroup != null) 4451 if (m_parentGroup != null)
4426 { 4452 {
4427 if (!m_parentGroup.IsDeleted) 4453 if (!m_parentGroup.IsDeleted)
@@ -4432,6 +4458,7 @@ namespace OpenSim.Region.Framework.Scenes
4432 } 4458 }
4433 } 4459 }
4434 } 4460 }
4461
4435 if ( 4462 if (
4436 ((AggregateScriptEvents & scriptEvents.collision) != 0) || 4463 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4437 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || 4464 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
@@ -4442,8 +4469,8 @@ namespace OpenSim.Region.Framework.Scenes
4442 (CollisionSound != UUID.Zero) 4469 (CollisionSound != UUID.Zero)
4443 ) 4470 )
4444 { 4471 {
4445 PhysActor.OnCollisionUpdate += PhysicsCollision; 4472 PhysActor.OnCollisionUpdate += PhysicsCollision;
4446 PhysActor.SubscribeEvents(1000); 4473 PhysActor.SubscribeEvents(1000);
4447 } 4474 }
4448 } 4475 }
4449 } 4476 }
@@ -4465,7 +4492,7 @@ namespace OpenSim.Region.Framework.Scenes
4465 } 4492 }
4466 } 4493 }
4467 4494
4468 if (IsVD) 4495 if (SetVD)
4469 { 4496 {
4470 // If the above logic worked (this is urgent candidate to unit tests!) 4497 // If the above logic worked (this is urgent candidate to unit tests!)
4471 // we now have a physicsactor. 4498 // we now have a physicsactor.
@@ -4480,18 +4507,19 @@ namespace OpenSim.Region.Framework.Scenes
4480 } 4507 }
4481 } 4508 }
4482 else 4509 else
4483 { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like 4510 {
4511 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4484 // (mumbles, well, at least if you have infinte CPU powers :-)) 4512 // (mumbles, well, at least if you have infinte CPU powers :-))
4485 PhysicsActor pa = this.PhysActor; 4513 PhysicsActor pa = this.PhysActor;
4486 if (pa != null) 4514 if (pa != null)
4487 { 4515 {
4488 PhysActor.SetVolumeDetect(0); 4516 PhysActor.SetVolumeDetect(0);
4489 } 4517 }
4518
4490 this.VolumeDetectActive = false; 4519 this.VolumeDetectActive = false;
4491 } 4520 }
4492 4521
4493 4522 if (SetTemporary)
4494 if (IsTemporary)
4495 { 4523 {
4496 AddFlag(PrimFlags.TemporaryOnRez); 4524 AddFlag(PrimFlags.TemporaryOnRez);
4497 } 4525 }
@@ -4542,6 +4570,7 @@ namespace OpenSim.Region.Framework.Scenes
4542 m_shape.PathTaperY = shapeBlock.PathTaperY; 4570 m_shape.PathTaperY = shapeBlock.PathTaperY;
4543 m_shape.PathTwist = shapeBlock.PathTwist; 4571 m_shape.PathTwist = shapeBlock.PathTwist;
4544 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; 4572 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin;
4573
4545 if (PhysActor != null) 4574 if (PhysActor != null)
4546 { 4575 {
4547 PhysActor.Shape = m_shape; 4576 PhysActor.Shape = m_shape;
@@ -4563,11 +4592,44 @@ namespace OpenSim.Region.Framework.Scenes
4563 } 4592 }
4564 4593
4565 /// <summary> 4594 /// <summary>
4595 /// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics
4596 /// engine can use it.
4597 /// </summary>
4598 /// <remarks>
4599 /// When the physics engine has finished with it, the sculpt data is discarded to save memory.
4600 /// </remarks>
4601 public void CheckSculptAndLoad()
4602 {
4603// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
4604
4605 if (ParentGroup.IsDeleted)
4606 return;
4607
4608 if ((ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0)
4609 return;
4610
4611 if (Shape.SculptEntry && Shape.SculptTexture != UUID.Zero)
4612 {
4613 // check if a previously decoded sculpt map has been cached
4614 if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + Shape.SculptTexture.ToString())))
4615 {
4616 SculptTextureCallback(Shape.SculptTexture, null);
4617 }
4618 else
4619 {
4620 ParentGroup.Scene.AssetService.Get(Shape.SculptTexture.ToString(), this, AssetReceived);
4621 }
4622 }
4623 }
4624
4625 /// <summary>
4566 /// Update the textures on the part. 4626 /// Update the textures on the part.
4567 /// </summary> 4627 /// </summary>
4628 /// <remarks>
4568 /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() 4629 /// Added to handle bug in libsecondlife's TextureEntry.ToBytes()
4569 /// not handling RGBA properly. Cycles through, and "fixes" the color 4630 /// not handling RGBA properly. Cycles through, and "fixes" the color
4570 /// info 4631 /// info
4632 /// </remarks>
4571 /// <param name="tex"></param> 4633 /// <param name="tex"></param>
4572 public void UpdateTexture(Primitive.TextureEntry tex) 4634 public void UpdateTexture(Primitive.TextureEntry tex)
4573 { 4635 {
@@ -4798,6 +4860,7 @@ namespace OpenSim.Region.Framework.Scenes
4798 4860
4799 Inventory.ApplyNextOwnerPermissions(); 4861 Inventory.ApplyNextOwnerPermissions();
4800 } 4862 }
4863
4801 public void UpdateLookAt() 4864 public void UpdateLookAt()
4802 { 4865 {
4803 try 4866 try