diff options
author | Robert Adams | 2012-10-15 12:11:00 -0700 |
---|---|---|
committer | Robert Adams | 2012-10-19 10:52:14 -0700 |
commit | fc33afddd360843d05f030750b7075315a526ae1 (patch) | |
tree | 69b48a3eaf800c9a3a24abaa0a12d8eb864bddc9 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |
parent | BulletSim: Fix small problems with last patch: BSScene.World properly initial... (diff) | |
download | opensim-SC_OLD-fc33afddd360843d05f030750b7075315a526ae1.zip opensim-SC_OLD-fc33afddd360843d05f030750b7075315a526ae1.tar.gz opensim-SC_OLD-fc33afddd360843d05f030750b7075315a526ae1.tar.bz2 opensim-SC_OLD-fc33afddd360843d05f030750b7075315a526ae1.tar.xz |
BulletSim: remove code in ShapeCollection that hinted at shape sharing.
Add new function to ParameterDefn for calling BulletSimAPI to set values.
Tweaking to BSCharacter parameter setting to try and have avatars stand.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 7bc6b69..8e1171a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -114,17 +114,9 @@ public class BSCharacter : BSPhysObject | |||
114 | PhysicsScene.TaintedObject("BSCharacter.create", delegate() | 114 | PhysicsScene.TaintedObject("BSCharacter.create", delegate() |
115 | { | 115 | { |
116 | DetailLog("{0},BSCharacter.create,taint", LocalID); | 116 | DetailLog("{0},BSCharacter.create,taint", LocalID); |
117 | PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, shapeData, null, null, null); | 117 | PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, shapeData, null, null, null); |
118 | 118 | ||
119 | SetPhysicalProperties(); | 119 | SetPhysicalProperties(); |
120 | |||
121 | // Set the buoyancy for flying. This will be refactored when all the settings happen in C#. | ||
122 | // If not set at creation, the avatar will stop flying when created after crossing a region boundry. | ||
123 | ForceBuoyancy = _buoyancy; | ||
124 | |||
125 | // This works here because CreateObject has already put the character into the physical world. | ||
126 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, | ||
127 | (uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask); | ||
128 | }); | 120 | }); |
129 | return; | 121 | return; |
130 | } | 122 | } |
@@ -146,27 +138,32 @@ public class BSCharacter : BSPhysObject | |||
146 | 138 | ||
147 | ZeroMotion(); | 139 | ZeroMotion(); |
148 | 140 | ||
149 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); | 141 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); |
150 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | 142 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); |
151 | 143 | ||
144 | ForcePosition = _position; | ||
152 | // Set the velocity and compute the proper friction | 145 | // Set the velocity and compute the proper friction |
153 | ForceVelocity = _velocity; | 146 | ForceVelocity = _velocity; |
154 | |||
155 | BulletSimAPI.SetFriction2(BSBody.ptr, _currentFriction); | ||
156 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution); | 147 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution); |
157 | |||
158 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); | 148 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); |
159 | BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); | 149 | BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); |
160 | |||
161 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 150 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
162 | { | 151 | { |
163 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); | 152 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); |
164 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | 153 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); |
165 | } | 154 | } |
166 | 155 | ||
167 | BulletSimAPI.SetActivationState2(BSBody.ptr, (int)ActivationState.DISABLE_DEACTIVATION); | 156 | BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); |
168 | 157 | ||
169 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 158 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); |
159 | |||
160 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_DEACTIVATION); | ||
161 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); | ||
162 | |||
163 | // Do this after the object has been added to the world | ||
164 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, | ||
165 | (uint)CollisionFilterGroups.AvatarFilter, | ||
166 | (uint)CollisionFilterGroups.AvatarMask); | ||
170 | } | 167 | } |
171 | 168 | ||
172 | public override void RequestPhysicsterseUpdate() | 169 | public override void RequestPhysicsterseUpdate() |
@@ -174,9 +171,7 @@ public class BSCharacter : BSPhysObject | |||
174 | base.RequestPhysicsterseUpdate(); | 171 | base.RequestPhysicsterseUpdate(); |
175 | } | 172 | } |
176 | // No one calls this method so I don't know what it could possibly mean | 173 | // No one calls this method so I don't know what it could possibly mean |
177 | public override bool Stopped { | 174 | public override bool Stopped { get { return false; } } |
178 | get { return false; } | ||
179 | } | ||
180 | public override OMV.Vector3 Size { | 175 | public override OMV.Vector3 Size { |
181 | get | 176 | get |
182 | { | 177 | { |
@@ -185,18 +180,14 @@ public class BSCharacter : BSPhysObject | |||
185 | } | 180 | } |
186 | 181 | ||
187 | set { | 182 | set { |
188 | // When an avatar's size is set, only the height is changed | 183 | // When an avatar's size is set, only the height is changed. |
189 | // and that really only depends on the radius. | ||
190 | _size = value; | 184 | _size = value; |
191 | ComputeAvatarScale(_size); | 185 | ComputeAvatarScale(_size); |
192 | |||
193 | // TODO: something has to be done with the avatar's vertical position | ||
194 | |||
195 | ComputeAvatarVolumeAndMass(); | 186 | ComputeAvatarVolumeAndMass(); |
196 | 187 | ||
197 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() | 188 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() |
198 | { | 189 | { |
199 | BulletSimAPI.SetLocalScaling2(BSBody.ptr, Scale); | 190 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); |
200 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSBody.ptr, MassRaw); | 191 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSBody.ptr, MassRaw); |
201 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | 192 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); |
202 | }); | 193 | }); |
@@ -300,7 +291,7 @@ public class BSCharacter : BSPhysObject | |||
300 | // A version of the sanity check that also makes sure a new position value is | 291 | // A version of the sanity check that also makes sure a new position value is |
301 | // pushed back to the physics engine. This routine would be used by anyone | 292 | // pushed back to the physics engine. This routine would be used by anyone |
302 | // who is not already pushing the value. | 293 | // who is not already pushing the value. |
303 | private bool PositionSanityCheck2(bool inTaintTime) | 294 | private bool PositionSanityCheck(bool inTaintTime) |
304 | { | 295 | { |
305 | bool ret = false; | 296 | bool ret = false; |
306 | if (PositionSanityCheck()) | 297 | if (PositionSanityCheck()) |
@@ -378,14 +369,16 @@ public class BSCharacter : BSPhysObject | |||
378 | } | 369 | } |
379 | else | 370 | else |
380 | { | 371 | { |
381 | if (_currentFriction == 999f) | 372 | if (_currentFriction != PhysicsScene.Params.avatarFriction) |
382 | { | 373 | { |
383 | _currentFriction = PhysicsScene.Params.avatarFriction; | 374 | _currentFriction = PhysicsScene.Params.avatarFriction; |
384 | BulletSimAPI.SetFriction2(BSBody.ptr, _currentFriction); | 375 | BulletSimAPI.SetFriction2(BSBody.ptr, _currentFriction); |
385 | } | 376 | } |
386 | } | 377 | } |
387 | _velocity = value; | 378 | _velocity = value; |
379 | // Remember the set velocity so we can suppress the reduction by friction, ... | ||
388 | _appliedVelocity = value; | 380 | _appliedVelocity = value; |
381 | |||
389 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); | 382 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); |
390 | BulletSimAPI.Activate2(BSBody.ptr, true); | 383 | BulletSimAPI.Activate2(BSBody.ptr, true); |
391 | } | 384 | } |
@@ -590,7 +583,8 @@ public class BSCharacter : BSPhysObject | |||
590 | 583 | ||
591 | // The 1.15 came from ODE but it seems to cause the avatar to float off the ground | 584 | // The 1.15 came from ODE but it seems to cause the avatar to float off the ground |
592 | // Scale.Z = (_size.Z * 1.15f) - (Scale.X + Scale.Y); | 585 | // Scale.Z = (_size.Z * 1.15f) - (Scale.X + Scale.Y); |
593 | newScale.Z = (_size.Z) - (Scale.X + Scale.Y); | 586 | // From the total height, remove the capsule half spheres that are at each end |
587 | newScale.Z = (size.Z) - (Math.Min(newScale.X, newScale.Y) * 2f); | ||
594 | Scale = newScale; | 588 | Scale = newScale; |
595 | } | 589 | } |
596 | 590 | ||
@@ -621,7 +615,7 @@ public class BSCharacter : BSPhysObject | |||
621 | _acceleration = entprop.Acceleration; | 615 | _acceleration = entprop.Acceleration; |
622 | _rotationalVelocity = entprop.RotationalVelocity; | 616 | _rotationalVelocity = entprop.RotationalVelocity; |
623 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. | 617 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. |
624 | PositionSanityCheck2(true); | 618 | PositionSanityCheck(true); |
625 | 619 | ||
626 | // remember the current and last set values | 620 | // remember the current and last set values |
627 | LastEntityProperties = CurrentEntityProperties; | 621 | LastEntityProperties = CurrentEntityProperties; |