diff options
author | Robert Adams | 2012-10-29 11:30:47 -0700 |
---|---|---|
committer | Robert Adams | 2012-11-03 21:13:35 -0700 |
commit | e20bad12cc0584c6368e46e0f326e6b616133e8f (patch) | |
tree | 9eb7db09bdb82036ebfe3623f27dc97868de4c02 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |
parent | BulletSim: rename constraint classes so they show up together alphabetically. (diff) | |
download | opensim-SC_OLD-e20bad12cc0584c6368e46e0f326e6b616133e8f.zip opensim-SC_OLD-e20bad12cc0584c6368e46e0f326e6b616133e8f.tar.gz opensim-SC_OLD-e20bad12cc0584c6368e46e0f326e6b616133e8f.tar.bz2 opensim-SC_OLD-e20bad12cc0584c6368e46e0f326e6b616133e8f.tar.xz |
BulletSim: centralize mass/inertia computation with UpdatePhysicalMassProperties() function. Didn't add setMassRaw because assignment with side effect is dirty.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 8bb4b21..b9013ab 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -155,8 +155,7 @@ public sealed class BSCharacter : BSPhysObject | |||
155 | BulletSimAPI.SetCcdSweptSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | 155 | BulletSimAPI.SetCcdSweptSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); |
156 | } | 156 | } |
157 | 157 | ||
158 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); | 158 | UpdatePhysicalMassProperties(MassRaw); |
159 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | ||
160 | 159 | ||
161 | // Make so capsule does not fall over | 160 | // Make so capsule does not fall over |
162 | BulletSimAPI.SetAngularFactorV2(BSBody.ptr, OMV.Vector3.Zero); | 161 | BulletSimAPI.SetAngularFactorV2(BSBody.ptr, OMV.Vector3.Zero); |
@@ -201,8 +200,7 @@ public sealed class BSCharacter : BSPhysObject | |||
201 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() | 200 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() |
202 | { | 201 | { |
203 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); | 202 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); |
204 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); | 203 | UpdatePhysicalMassProperties(MassRaw); |
205 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | ||
206 | }); | 204 | }); |
207 | 205 | ||
208 | } | 206 | } |
@@ -329,7 +327,14 @@ public sealed class BSCharacter : BSPhysObject | |||
329 | public override float Mass { get { return _mass; } } | 327 | public override float Mass { get { return _mass; } } |
330 | 328 | ||
331 | // used when we only want this prim's mass and not the linkset thing | 329 | // used when we only want this prim's mass and not the linkset thing |
332 | public override float MassRaw { get {return _mass; } } | 330 | public override float MassRaw { |
331 | get {return _mass; } | ||
332 | } | ||
333 | public override void UpdatePhysicalMassProperties(float physMass) | ||
334 | { | ||
335 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, physMass); | ||
336 | BulletSimAPI.SetMassProps2(BSBody.ptr, physMass, localInertia); | ||
337 | } | ||
333 | 338 | ||
334 | public override OMV.Vector3 Force { | 339 | public override OMV.Vector3 Force { |
335 | get { return _force; } | 340 | get { return _force; } |