diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index b49b8d9..a19d6d7 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -133,10 +133,7 @@ public sealed class BSPrim : PhysicsActor | |||
133 | _parentPrim = null; // not a child or a parent | 133 | _parentPrim = null; // not a child or a parent |
134 | _vehicle = new BSDynamics(this); // add vehicleness | 134 | _vehicle = new BSDynamics(this); // add vehicleness |
135 | _childrenPrims = new List<BSPrim>(); | 135 | _childrenPrims = new List<BSPrim>(); |
136 | if (_isPhysical) | 136 | _mass = CalculateMass(); |
137 | _mass = CalculateMass(); | ||
138 | else | ||
139 | _mass = 0f; | ||
140 | // do the actual object creation at taint time | 137 | // do the actual object creation at taint time |
141 | _scene.TaintedObject(delegate() | 138 | _scene.TaintedObject(delegate() |
142 | { | 139 | { |
@@ -181,8 +178,8 @@ public sealed class BSPrim : PhysicsActor | |||
181 | _size = value; | 178 | _size = value; |
182 | _scene.TaintedObject(delegate() | 179 | _scene.TaintedObject(delegate() |
183 | { | 180 | { |
184 | if (_isPhysical) _mass = CalculateMass(); // changing size changes the mass | 181 | _mass = CalculateMass(); // changing size changes the mass |
185 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, _mass, _isPhysical); | 182 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, Mass, IsPhysical); |
186 | RecreateGeomAndObject(); | 183 | RecreateGeomAndObject(); |
187 | }); | 184 | }); |
188 | } | 185 | } |
@@ -192,7 +189,7 @@ public sealed class BSPrim : PhysicsActor | |||
192 | _pbs = value; | 189 | _pbs = value; |
193 | _scene.TaintedObject(delegate() | 190 | _scene.TaintedObject(delegate() |
194 | { | 191 | { |
195 | if (_isPhysical) _mass = CalculateMass(); // changing the shape changes the mass | 192 | _mass = CalculateMass(); // changing the shape changes the mass |
196 | RecreateGeomAndObject(); | 193 | RecreateGeomAndObject(); |
197 | }); | 194 | }); |
198 | } | 195 | } |
@@ -278,6 +275,8 @@ public sealed class BSPrim : PhysicsActor | |||
278 | child._parentPrim = this; // the child has gained a parent | 275 | child._parentPrim = this; // the child has gained a parent |
279 | // RecreateGeomAndObject(); // rebuild my shape with the new child added | 276 | // RecreateGeomAndObject(); // rebuild my shape with the new child added |
280 | LinkAChildToMe(pchild); // build the physical binding between me and the child | 277 | LinkAChildToMe(pchild); // build the physical binding between me and the child |
278 | |||
279 | _mass = CalculateMass(); | ||
281 | } | 280 | } |
282 | }); | 281 | }); |
283 | return; | 282 | return; |
@@ -306,6 +305,8 @@ public sealed class BSPrim : PhysicsActor | |||
306 | // RecreateGeomAndObject(); // rebuild my shape with the child removed | 305 | // RecreateGeomAndObject(); // rebuild my shape with the child removed |
307 | UnlinkAChildFromMe(pchild); | 306 | UnlinkAChildFromMe(pchild); |
308 | } | 307 | } |
308 | |||
309 | _mass = CalculateMass(); | ||
309 | } | 310 | } |
310 | else | 311 | else |
311 | { | 312 | { |
@@ -364,9 +365,17 @@ public sealed class BSPrim : PhysicsActor | |||
364 | }); | 365 | }); |
365 | } | 366 | } |
366 | } | 367 | } |
368 | |||
369 | // Return the effective mass of the object. Non-physical objects do not have mass. | ||
367 | public override float Mass { | 370 | public override float Mass { |
368 | get { return _mass; } | 371 | get { |
372 | if (IsPhysical) | ||
373 | return _mass; | ||
374 | else | ||
375 | return 0f; | ||
376 | } | ||
369 | } | 377 | } |
378 | |||
370 | public override OMV.Vector3 Force { | 379 | public override OMV.Vector3 Force { |
371 | get { return _force; } | 380 | get { return _force; } |
372 | set { | 381 | set { |
@@ -446,7 +455,8 @@ public sealed class BSPrim : PhysicsActor | |||
446 | // Called from Scene when doing simulation step so we're in taint processing time. | 455 | // Called from Scene when doing simulation step so we're in taint processing time. |
447 | public void StepVehicle(float timeStep) | 456 | public void StepVehicle(float timeStep) |
448 | { | 457 | { |
449 | _vehicle.Step(timeStep); | 458 | if (IsPhysical) |
459 | _vehicle.Step(timeStep); | ||
450 | } | 460 | } |
451 | 461 | ||
452 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 462 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
@@ -543,20 +553,13 @@ public sealed class BSPrim : PhysicsActor | |||
543 | { | 553 | { |
544 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); | 554 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); |
545 | // non-physical things work best with a mass of zero | 555 | // non-physical things work best with a mass of zero |
546 | if (IsStatic) | 556 | if (!IsStatic) |
547 | { | ||
548 | _mass = 0f; | ||
549 | } | ||
550 | else | ||
551 | { | 557 | { |
552 | _mass = CalculateMass(); | 558 | _mass = CalculateMass(); |
553 | // If it's dynamic, make sure the hull has been created for it | ||
554 | // This shouldn't do much work if the object had previously been built | ||
555 | RecreateGeomAndObject(); | 559 | RecreateGeomAndObject(); |
556 | |||
557 | } | 560 | } |
558 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, _mass); | 561 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, Mass); |
559 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); | 562 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), Mass); |
560 | } | 563 | } |
561 | 564 | ||
562 | // prims don't fly | 565 | // prims don't fly |
@@ -1273,7 +1276,7 @@ public sealed class BSPrim : PhysicsActor | |||
1273 | shape.Rotation = _orientation; | 1276 | shape.Rotation = _orientation; |
1274 | shape.Velocity = _velocity; | 1277 | shape.Velocity = _velocity; |
1275 | shape.Scale = _scale; | 1278 | shape.Scale = _scale; |
1276 | shape.Mass = _isPhysical ? _mass : 0f; | 1279 | shape.Mass = Mass; |
1277 | shape.Buoyancy = _buoyancy; | 1280 | shape.Buoyancy = _buoyancy; |
1278 | shape.HullKey = _hullKey; | 1281 | shape.HullKey = _hullKey; |
1279 | shape.MeshKey = _meshKey; | 1282 | shape.MeshKey = _meshKey; |