aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
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/Scenes/SceneObjectPart.cs
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/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs96
1 files changed, 93 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);