aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs96
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs43
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs11
4 files changed, 163 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 19e6d37..55b5462 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -302,6 +302,13 @@ namespace OpenSim.Region.Framework.Scenes
302 protected Vector3 m_lastAcceleration; 302 protected Vector3 m_lastAcceleration;
303 protected Vector3 m_lastAngularVelocity; 303 protected Vector3 m_lastAngularVelocity;
304 protected int m_lastTerseSent; 304 protected int m_lastTerseSent;
305
306 protected byte m_physicsShapeType = (byte)PhysShapeType.prim;
307 // TODO: Implement these
308 //protected float m_density = 1000.0f; // in kg/m^3
309 //protected float m_gravitymod = 1.0f;
310 //protected float m_friction = 0.6f; // wood
311 //protected float m_bounce = 0.5f; // wood
305 312
306 /// <summary> 313 /// <summary>
307 /// Stores media texture data 314 /// Stores media texture data
@@ -1322,6 +1329,69 @@ namespace OpenSim.Region.Framework.Scenes
1322 set { m_collisionSoundVolume = value; } 1329 set { m_collisionSoundVolume = value; }
1323 } 1330 }
1324 1331
1332 public byte DefaultPhysicsShapeType()
1333 {
1334 byte type;
1335
1336 if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh))
1337 type = (byte)PhysShapeType.convex;
1338 else
1339 type = (byte)PhysShapeType.prim;
1340
1341 return type;
1342 }
1343
1344 public byte PhysicsShapeType
1345 {
1346 get { return m_physicsShapeType; }
1347 set
1348 {
1349 byte oldv = m_physicsShapeType;
1350
1351 if (value >= 0 && value <= (byte)PhysShapeType.convex)
1352 {
1353 if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this)
1354 m_physicsShapeType = DefaultPhysicsShapeType();
1355 else
1356 m_physicsShapeType = value;
1357 }
1358 else
1359 m_physicsShapeType = DefaultPhysicsShapeType();
1360
1361 if (m_physicsShapeType != oldv && ParentGroup != null)
1362 {
1363 if (m_physicsShapeType == (byte)PhysShapeType.none)
1364 {
1365 if (PhysActor != null)
1366 {
1367 Velocity = new Vector3(0, 0, 0);
1368 Acceleration = new Vector3(0, 0, 0);
1369 if (ParentGroup.RootPart == this)
1370 AngularVelocity = new Vector3(0, 0, 0);
1371 ParentGroup.Scene.RemovePhysicalPrim(1);
1372 RemoveFromPhysics();
1373 }
1374 }
1375 else if (PhysActor == null)
1376 {
1377 ApplyPhysics((uint)Flags, VolumeDetectActive);
1378 }
1379 else
1380 {
1381 // TODO: Update physics actor
1382 }
1383
1384 if (ParentGroup != null)
1385 ParentGroup.HasGroupChanged = true;
1386 }
1387 }
1388 }
1389
1390 public float Density { get; set; }
1391 public float GravityModifier { get; set; }
1392 public float Friction { get; set; }
1393 public float Bounciness { get; set; }
1394
1325 #endregion Public Properties with only Get 1395 #endregion Public Properties with only Get
1326 1396
1327 private uint ApplyMask(uint val, bool set, uint mask) 1397 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1523,9 +1593,8 @@ namespace OpenSim.Region.Framework.Scenes
1523 if (!ParentGroup.Scene.CollidablePrims) 1593 if (!ParentGroup.Scene.CollidablePrims)
1524 return; 1594 return;
1525 1595
1526// m_log.DebugFormat( 1596 if (PhysicsShapeType == (byte)PhysShapeType.none)
1527// "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}", 1597 return;
1528// Name, LocalId, UUID, m_physicalPrim);
1529 1598
1530 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; 1599 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0;
1531 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; 1600 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0;
@@ -3878,6 +3947,26 @@ namespace OpenSim.Region.Framework.Scenes
3878 } 3947 }
3879 } 3948 }
3880 3949
3950 public void UpdateExtraPhysics(ExtraPhysicsData physdata)
3951 {
3952 if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
3953 return;
3954
3955 if (PhysicsShapeType != (byte)physdata.PhysShapeType)
3956 {
3957 PhysicsShapeType = (byte)physdata.PhysShapeType;
3958
3959 }
3960
3961 if(Density != physdata.Density)
3962 Density = physdata.Density;
3963 if(GravityModifier != physdata.GravitationModifier)
3964 GravityModifier = physdata.GravitationModifier;
3965 if(Friction != physdata.Friction)
3966 Friction = physdata.Friction;
3967 if(Bounciness != physdata.Bounce)
3968 Bounciness = physdata.Bounce;
3969 }
3881 /// <summary> 3970 /// <summary>
3882 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. 3971 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
3883 /// </summary> 3972 /// </summary>
@@ -3949,6 +4038,7 @@ namespace OpenSim.Region.Framework.Scenes
3949 4038
3950 if (SetPhantom 4039 if (SetPhantom
3951 || ParentGroup.IsAttachment 4040 || ParentGroup.IsAttachment
4041 || PhysicsShapeType == (byte)PhysShapeType.none
3952 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints 4042 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
3953 { 4043 {
3954 AddFlag(PrimFlags.Phantom); 4044 AddFlag(PrimFlags.Phantom);
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 4a2a47e..78229fe 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -367,6 +367,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
367 m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); 367 m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2);
368 m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); 368 m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3);
369 m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); 369 m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
370
371 m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType);
372 m_SOPXmlProcessors.Add("Density", ProcessDensity);
373 m_SOPXmlProcessors.Add("Friction", ProcessFriction);
374 m_SOPXmlProcessors.Add("Bounce", ProcessBounce);
375 m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier);
376
370 #endregion 377 #endregion
371 378
372 #region TaskInventoryXmlProcessors initialization 379 #region TaskInventoryXmlProcessors initialization
@@ -594,6 +601,31 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
594 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); 601 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
595 } 602 }
596 603
604 private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlTextReader reader)
605 {
606 obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty);
607 }
608
609 private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader)
610 {
611 obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty);
612 }
613
614 private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader)
615 {
616 obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty);
617 }
618
619 private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader)
620 {
621 obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty);
622 }
623
624 private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader)
625 {
626 obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
627 }
628
597 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) 629 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
598 { 630 {
599 List<string> errorNodeNames; 631 List<string> errorNodeNames;
@@ -1257,6 +1289,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1257 writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); 1289 writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString());
1258 writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); 1290 writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString());
1259 1291
1292 if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType())
1293 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
1294 if (sop.Density != 1000.0f)
1295 writer.WriteElementString("Density", sop.Density.ToString().ToLower());
1296 if (sop.Friction != 0.6f)
1297 writer.WriteElementString("Friction", sop.Friction.ToString().ToLower());
1298 if (sop.Bounciness != 0.5f)
1299 writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower());
1300 if (sop.GravityModifier != 1.0f)
1301 writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower());
1302
1260 writer.WriteEndElement(); 1303 writer.WriteEndElement();
1261 } 1304 }
1262 1305
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4fa3c60..64052ae 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7594,6 +7594,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7594 part.ScriptSetPhysicsStatus(physics); 7594 part.ScriptSetPhysicsStatus(physics);
7595 break; 7595 break;
7596 7596
7597 case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
7598 if (remain < 1)
7599 return null;
7600
7601 int shape_type = rules.GetLSLIntegerItem(idx++);
7602
7603 ExtraPhysicsData physdata = new ExtraPhysicsData();
7604 physdata.Density = part.Density;
7605 physdata.Bounce = part.Bounciness;
7606 physdata.GravitationModifier = part.GravityModifier;
7607 physdata.PhysShapeType = (PhysShapeType)shape_type;
7608
7609 part.UpdateExtraPhysics(physdata);
7610
7611 break;
7612
7597 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: 7613 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
7598 if (remain < 1) 7614 if (remain < 1)
7599 return null; 7615 return null;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 9bf1a64..bd66ba3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -661,6 +661,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
661 public const int PRIM_MEDIA_PERM_GROUP = 2; 661 public const int PRIM_MEDIA_PERM_GROUP = 2;
662 public const int PRIM_MEDIA_PERM_ANYONE = 4; 662 public const int PRIM_MEDIA_PERM_ANYONE = 4;
663 663
664 public const int PRIM_PHYSICS_SHAPE_TYPE = 30;
665 public const int PRIM_PHYSICS_SHAPE_PRIM = 0;
666 public const int PRIM_PHYSICS_SHAPE_CONVEX = 2;
667 public const int PRIM_PHYSICS_SHAPE_NONE = 1;
668
669 public const int PRIM_PHYSICS_MATERIAL = 31;
670 public const int DENSITY = 1;
671 public const int FRICTION = 2;
672 public const int RESTITUTION = 4;
673 public const int GRAVITY_MULTIPLIER = 8;
674
664 // extra constants for llSetPrimMediaParams 675 // extra constants for llSetPrimMediaParams
665 public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); 676 public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0);
666 public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000); 677 public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000);