aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs189
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs10
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs6
3 files changed, 165 insertions, 40 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index cd40b29..9f602f7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -304,11 +304,10 @@ namespace OpenSim.Region.Framework.Scenes
304 protected int m_lastTerseSent; 304 protected int m_lastTerseSent;
305 305
306 protected byte m_physicsShapeType = (byte)PhysShapeType.prim; 306 protected byte m_physicsShapeType = (byte)PhysShapeType.prim;
307 // TODO: Implement these 307 protected float m_density = 1000.0f; // in kg/m^3
308 //protected float m_density = 1000.0f; // in kg/m^3 308 protected float m_gravitymod = 1.0f;
309 //protected float m_gravitymod = 1.0f; 309 protected float m_friction = 0.6f; // wood
310 //protected float m_friction = 0.6f; // wood 310 protected float m_bounce = 0.5f; // wood
311 //protected float m_bounce = 0.5f; // wood
312 311
313 /// <summary> 312 /// <summary>
314 /// Stores media texture data 313 /// Stores media texture data
@@ -1379,19 +1378,92 @@ namespace OpenSim.Region.Framework.Scenes
1379 } 1378 }
1380 else 1379 else
1381 { 1380 {
1382 // TODO: Update physics actor 1381 PhysActor.PhysicsShapeType = m_physicsShapeType;
1383 } 1382 }
1384 1383
1385 if (ParentGroup != null) 1384 if (ParentGroup != null)
1386 ParentGroup.HasGroupChanged = true; 1385 ParentGroup.HasGroupChanged = true;
1387 } 1386 }
1387
1388 if (m_physicsShapeType != value)
1389 {
1390 UpdatePhysRequired = true;
1391 }
1388 } 1392 }
1389 } 1393 }
1390 1394
1391 public float Density { get; set; } 1395 public float Density // in kg/m^3
1392 public float GravityModifier { get; set; } 1396 {
1393 public float Friction { get; set; } 1397 get { return m_density; }
1394 public float Restitution { get; set; } 1398 set
1399 {
1400 if (value >=1 && value <= 22587.0)
1401 {
1402 m_density = value;
1403 UpdatePhysRequired = true;
1404 }
1405
1406 ScheduleFullUpdateIfNone();
1407
1408 if (ParentGroup != null)
1409 ParentGroup.HasGroupChanged = true;
1410 }
1411 }
1412
1413 public float GravityModifier
1414 {
1415 get { return m_gravitymod; }
1416 set
1417 {
1418 if( value >= -1 && value <=28.0f)
1419 {
1420 m_gravitymod = value;
1421 UpdatePhysRequired = true;
1422 }
1423
1424 ScheduleFullUpdateIfNone();
1425
1426 if (ParentGroup != null)
1427 ParentGroup.HasGroupChanged = true;
1428
1429 }
1430 }
1431
1432 public float Friction
1433 {
1434 get { return m_friction; }
1435 set
1436 {
1437 if (value >= 0 && value <= 255.0f)
1438 {
1439 m_friction = value;
1440 UpdatePhysRequired = true;
1441 }
1442
1443 ScheduleFullUpdateIfNone();
1444
1445 if (ParentGroup != null)
1446 ParentGroup.HasGroupChanged = true;
1447 }
1448 }
1449
1450 public float Restitution
1451 {
1452 get { return m_bounce; }
1453 set
1454 {
1455 if (value >= 0 && value <= 1.0f)
1456 {
1457 m_bounce = value;
1458 UpdatePhysRequired = true;
1459 }
1460
1461 ScheduleFullUpdateIfNone();
1462
1463 if (ParentGroup != null)
1464 ParentGroup.HasGroupChanged = true;
1465 }
1466 }
1395 1467
1396 #endregion Public Properties with only Get 1468 #endregion Public Properties with only Get
1397 1469
@@ -1589,8 +1661,10 @@ namespace OpenSim.Region.Framework.Scenes
1589 /// </summary> 1661 /// </summary>
1590 /// <param name="rootObjectFlags"></param> 1662 /// <param name="rootObjectFlags"></param>
1591 /// <param name="VolumeDetectActive"></param> 1663 /// <param name="VolumeDetectActive"></param>
1592 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) 1664 public void ApplyPhysics(uint rootObjectFlags, bool _VolumeDetectActive)
1593 { 1665 {
1666 VolumeDetectActive = _VolumeDetectActive;
1667
1594 if (!ParentGroup.Scene.CollidablePrims) 1668 if (!ParentGroup.Scene.CollidablePrims)
1595 return; 1669 return;
1596 1670
@@ -1600,28 +1674,22 @@ namespace OpenSim.Region.Framework.Scenes
1600 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; 1674 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0;
1601 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; 1675 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0;
1602 1676
1677 if (_VolumeDetectActive)
1678 isPhantom = true;
1679
1603 if (IsJoint()) 1680 if (IsJoint())
1604 { 1681 {
1605 DoPhysicsPropertyUpdate(isPhysical, true); 1682 DoPhysicsPropertyUpdate(isPhysical, true);
1606 } 1683 }
1607 else 1684 else
1608 { 1685 {
1609 // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored 1686 if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment
1610 if (VolumeDetectActive) 1687 && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1611 isPhantom = false;
1612
1613 // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition
1614 // or flexible
1615 if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1616 { 1688 {
1617 // Added clarification.. since A rigid body is an object that you can kick around, etc. 1689 AddToPhysics(isPhysical, isPhantom, isPhysical);
1618 bool rigidBody = isPhysical && !isPhantom;
1619
1620 PhysicsActor pa = AddToPhysics(rigidBody);
1621
1622 if (pa != null)
1623 pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
1624 } 1690 }
1691 else
1692 PhysActor = null; // just to be sure
1625 } 1693 }
1626 } 1694 }
1627 1695
@@ -2503,6 +2571,19 @@ namespace OpenSim.Region.Framework.Scenes
2503 APIDTarget = Quaternion.Identity; 2571 APIDTarget = Quaternion.Identity;
2504 } 2572 }
2505 2573
2574
2575
2576 public void ScheduleFullUpdateIfNone()
2577 {
2578 if (ParentGroup == null)
2579 return;
2580
2581// ??? ParentGroup.HasGroupChanged = true;
2582
2583 if (UpdateFlag != UpdateRequired.FULL)
2584 ScheduleFullUpdate();
2585 }
2586
2506 /// <summary> 2587 /// <summary>
2507 /// Schedules this prim for a full update 2588 /// Schedules this prim for a full update
2508 /// </summary> 2589 /// </summary>
@@ -4059,7 +4140,9 @@ namespace OpenSim.Region.Framework.Scenes
4059 4140
4060 if (ParentGroup.Scene.CollidablePrims && pa == null) 4141 if (ParentGroup.Scene.CollidablePrims && pa == null)
4061 { 4142 {
4062 pa = AddToPhysics(UsePhysics); 4143 AddToPhysics(UsePhysics, SetPhantom, false);
4144 pa = PhysActor;
4145
4063 4146
4064 if (pa != null) 4147 if (pa != null)
4065 { 4148 {
@@ -4146,10 +4229,13 @@ namespace OpenSim.Region.Framework.Scenes
4146 /// <returns> 4229 /// <returns>
4147 /// The physics actor. null if there was a failure. 4230 /// The physics actor. null if there was a failure.
4148 /// </returns> 4231 /// </returns>
4149 private PhysicsActor AddToPhysics(bool rigidBody) 4232 private void AddToPhysics(bool isPhysical, bool isPhantom, bool applyDynamics)
4150 { 4233 {
4151 PhysicsActor pa; 4234 PhysicsActor pa;
4152 4235
4236 Vector3 velocity = Velocity;
4237 Vector3 rotationalVelocity = AngularVelocity;;
4238
4153 try 4239 try
4154 { 4240 {
4155 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4241 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
@@ -4157,8 +4243,10 @@ namespace OpenSim.Region.Framework.Scenes
4157 Shape, 4243 Shape,
4158 AbsolutePosition, 4244 AbsolutePosition,
4159 Scale, 4245 Scale,
4160 RotationOffset, 4246 GetWorldRotation(),
4161 rigidBody, 4247 isPhysical,
4248 isPhantom,
4249 PhysicsShapeType,
4162 m_localId); 4250 m_localId);
4163 } 4251 }
4164 catch (Exception e) 4252 catch (Exception e)
@@ -4167,20 +4255,47 @@ namespace OpenSim.Region.Framework.Scenes
4167 pa = null; 4255 pa = null;
4168 } 4256 }
4169 4257
4170 // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
4171 // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
4172 // being set.
4173 PhysActor = pa;
4174
4175 // Basic Physics can also return null as well as an exception catch.
4176 if (pa != null) 4258 if (pa != null)
4177 { 4259 {
4178 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4260 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4179 pa.SetMaterial(Material); 4261 pa.SetMaterial(Material);
4180 DoPhysicsPropertyUpdate(rigidBody, true); 4262
4263 if (VolumeDetectActive) // change if not the default only
4264 pa.SetVolumeDetect(1);
4265 // we are going to tell rest of code about physics so better have this here
4266 PhysActor = pa;
4267
4268 if (isPhysical)
4269 {
4270 ParentGroup.Scene.AddPhysicalPrim(1);
4271
4272 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
4273 pa.OnOutOfBounds += PhysicsOutOfBounds;
4274
4275 if (ParentID != 0 && ParentID != LocalId)
4276 {
4277 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
4278
4279 if (parentPa != null)
4280 {
4281 pa.link(parentPa);
4282 }
4283 }
4284 }
4285
4286 if (applyDynamics)
4287 // do independent of isphysical so parameters get setted (at least some)
4288 {
4289 Velocity = velocity;
4290 AngularVelocity = rotationalVelocity;
4291// pa.Velocity = velocity;
4292 pa.RotationalVelocity = rotationalVelocity;
4293 }
4294
4295 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4181 } 4296 }
4182 4297
4183 return pa; 4298 PhysActor = pa;
4184 } 4299 }
4185 4300
4186 /// <summary> 4301 /// <summary>
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index d119791..bd806eb 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -147,6 +147,8 @@ namespace OpenSim.Region.Physics.Manager
147 147
148 public abstract Vector3 Size { get; set; } 148 public abstract Vector3 Size { get; set; }
149 149
150 public virtual byte PhysicsShapeType { get; set; }
151
150 public abstract PrimitiveBaseShape Shape { set; } 152 public abstract PrimitiveBaseShape Shape { set; }
151 153
152 uint m_baseLocalID; 154 uint m_baseLocalID;
@@ -218,9 +220,11 @@ namespace OpenSim.Region.Physics.Manager
218 handler(e); 220 handler(e);
219 } 221 }
220 222
221 public virtual void SetMaterial (int material) 223 public virtual void SetMaterial (int material) { }
222 { 224 public virtual float Density { get; set; }
223 } 225 public virtual float GravModifier { get; set; }
226 public virtual float Friction { get; set; }
227 public virtual float Restitution { get; set; }
224 228
225 /// <summary> 229 /// <summary>
226 /// Position of this actor. 230 /// Position of this actor.
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index c4d7ef3..290b72e 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -166,6 +166,12 @@ namespace OpenSim.Region.Physics.Manager
166 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 166 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
167 Vector3 size, Quaternion rotation, bool isPhysical, uint localid); 167 Vector3 size, Quaternion rotation, bool isPhysical, uint localid);
168 168
169 public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
170 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid)
171 {
172 return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid);
173 }
174
169 public virtual float TimeDilation 175 public virtual float TimeDilation
170 { 176 {
171 get { return 1.0f; } 177 get { return 1.0f; }