aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2013-02-06 08:03:04 +0000
committerMelanie2013-02-06 08:03:04 +0000
commite5beb480eaf23fa7454728724de80b2a67ded1e8 (patch)
tree232bfd14074cc3730ab02bdefa339b99a587f1dc /OpenSim/Region/Framework
parentminor: Add explanation of MaptileStaticUUID setting in Regions.ini.example (diff)
downloadopensim-SC_OLD-e5beb480eaf23fa7454728724de80b2a67ded1e8.zip
opensim-SC_OLD-e5beb480eaf23fa7454728724de80b2a67ded1e8.tar.gz
opensim-SC_OLD-e5beb480eaf23fa7454728724de80b2a67ded1e8.tar.bz2
opensim-SC_OLD-e5beb480eaf23fa7454728724de80b2a67ded1e8.tar.xz
Partial port of Avination's support for the new physics parameters.
Implements the parameters as properties, the serialization and database storage (MySQL only). Implements llSetPrimitiveParams for prim physics shape and the other 4 extra params. Only the prim shape type "None" is currently functional. No support for the Viewer UI (yet), that will be ported in due course. Lots more to port, this is a large-ish changeset.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs96
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs43
2 files changed, 136 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