diff options
author | Robert Adams | 2012-10-23 17:30:43 -0700 |
---|---|---|
committer | Robert Adams | 2012-10-23 17:30:43 -0700 |
commit | b6fc5bad000e7e7af992e7f29eeb2de9f716fcc4 (patch) | |
tree | c3d20e87083d9781316b719ea684d4a5c6eeabba /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |
parent | BulletSim: minor change to insure avatar body recreation when shape changes. (diff) | |
download | opensim-SC-b6fc5bad000e7e7af992e7f29eeb2de9f716fcc4.zip opensim-SC-b6fc5bad000e7e7af992e7f29eeb2de9f716fcc4.tar.gz opensim-SC-b6fc5bad000e7e7af992e7f29eeb2de9f716fcc4.tar.bz2 opensim-SC-b6fc5bad000e7e7af992e7f29eeb2de9f716fcc4.tar.xz |
BulletSim: fix problem with avatars sinking into the ground.
Change terrain activation state to DISABLE_SIMULATION for better performance.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 07dd613..a041ba8 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -105,7 +105,7 @@ public class BSCharacter : BSPhysObject | |||
105 | shapeData.Position = _position; | 105 | shapeData.Position = _position; |
106 | shapeData.Rotation = _orientation; | 106 | shapeData.Rotation = _orientation; |
107 | shapeData.Velocity = _velocity; | 107 | shapeData.Velocity = _velocity; |
108 | shapeData.Size = Scale; | 108 | shapeData.Size = Scale; // capsule is a native shape but scale is not just <1,1,1> |
109 | shapeData.Scale = Scale; | 109 | shapeData.Scale = Scale; |
110 | shapeData.Mass = _mass; | 110 | shapeData.Mass = _mass; |
111 | shapeData.Buoyancy = _buoyancy; | 111 | shapeData.Buoyancy = _buoyancy; |
@@ -144,7 +144,9 @@ public class BSCharacter : BSPhysObject | |||
144 | ForcePosition = _position; | 144 | ForcePosition = _position; |
145 | // Set the velocity and compute the proper friction | 145 | // Set the velocity and compute the proper friction |
146 | ForceVelocity = _velocity; | 146 | ForceVelocity = _velocity; |
147 | |||
147 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution); | 148 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution); |
149 | BulletSimAPI.SetMargin2(BSShape.ptr, PhysicsScene.Params.collisionMargin); | ||
148 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); | 150 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); |
149 | BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); | 151 | BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); |
150 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 152 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
@@ -156,11 +158,15 @@ public class BSCharacter : BSPhysObject | |||
156 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); | 158 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); |
157 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | 159 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); |
158 | 160 | ||
161 | // Make so capsule does not fall over | ||
162 | BulletSimAPI.SetAngularFactorV2(BSBody.ptr, OMV.Vector3.Zero); | ||
163 | |||
159 | BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); | 164 | BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); |
160 | 165 | ||
161 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 166 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); |
162 | 167 | ||
163 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); | 168 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); |
169 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_DEACTIVATION); | ||
164 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); | 170 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); |
165 | 171 | ||
166 | // Do this after the object has been added to the world | 172 | // Do this after the object has been added to the world |
@@ -175,11 +181,13 @@ public class BSCharacter : BSPhysObject | |||
175 | } | 181 | } |
176 | // No one calls this method so I don't know what it could possibly mean | 182 | // No one calls this method so I don't know what it could possibly mean |
177 | public override bool Stopped { get { return false; } } | 183 | public override bool Stopped { get { return false; } } |
184 | |||
178 | public override OMV.Vector3 Size { | 185 | public override OMV.Vector3 Size { |
179 | get | 186 | get |
180 | { | 187 | { |
181 | // Avatar capsule size is kept in the scale parameter. | 188 | // Avatar capsule size is kept in the scale parameter. |
182 | return _size; | 189 | // return _size; |
190 | return new OMV.Vector3(Scale.X * 2f, Scale.Y * 2f, Scale.Z); | ||
183 | } | 191 | } |
184 | 192 | ||
185 | set { | 193 | set { |
@@ -199,7 +207,9 @@ public class BSCharacter : BSPhysObject | |||
199 | 207 | ||
200 | } | 208 | } |
201 | } | 209 | } |
210 | |||
202 | public override OMV.Vector3 Scale { get; set; } | 211 | public override OMV.Vector3 Scale { get; set; } |
212 | |||
203 | public override PrimitiveBaseShape Shape | 213 | public override PrimitiveBaseShape Shape |
204 | { | 214 | { |
205 | set { BaseShape = value; } | 215 | set { BaseShape = value; } |
@@ -264,7 +274,7 @@ public class BSCharacter : BSPhysObject | |||
264 | 274 | ||
265 | 275 | ||
266 | // Check that the current position is sane and, if not, modify the position to make it so. | 276 | // Check that the current position is sane and, if not, modify the position to make it so. |
267 | // Check for being below terrain and being out of bounds. | 277 | // Check for being below terrain or on water. |
268 | // Returns 'true' of the position was made sane by some action. | 278 | // Returns 'true' of the position was made sane by some action. |
269 | private bool PositionSanityCheck() | 279 | private bool PositionSanityCheck() |
270 | { | 280 | { |
@@ -335,7 +345,7 @@ public class BSCharacter : BSPhysObject | |||
335 | } | 345 | } |
336 | 346 | ||
337 | // Avatars don't do vehicles | 347 | // Avatars don't do vehicles |
338 | public override int VehicleType { get { return 0; } set { return; } } | 348 | public override int VehicleType { get { return (int)Vehicle.TYPE_NONE; } set { return; } } |
339 | public override void VehicleFloatParam(int param, float value) { } | 349 | public override void VehicleFloatParam(int param, float value) { } |
340 | public override void VehicleVectorParam(int param, OMV.Vector3 value) {} | 350 | public override void VehicleVectorParam(int param, OMV.Vector3 value) {} |
341 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { } | 351 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { } |
@@ -588,9 +598,8 @@ public class BSCharacter : BSPhysObject | |||
588 | newScale.X = PhysicsScene.Params.avatarCapsuleRadius; | 598 | newScale.X = PhysicsScene.Params.avatarCapsuleRadius; |
589 | newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; | 599 | newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; |
590 | 600 | ||
591 | // From the total height, remote the capsule half spheres that are at each end | 601 | // From the total height, remove the capsule half spheres that are at each end |
592 | newScale.Z = (size.Z * 2f) - Math.Min(newScale.X, newScale.Y); | 602 | newScale.Z = size.Z- (newScale.X + newScale.Y); |
593 | // newScale.Z = (size.Z * 2f); | ||
594 | Scale = newScale; | 603 | Scale = newScale; |
595 | } | 604 | } |
596 | 605 | ||
@@ -636,7 +645,7 @@ public class BSCharacter : BSPhysObject | |||
636 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, avVel); | 645 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, avVel); |
637 | } | 646 | } |
638 | 647 | ||
639 | // Tell the linkset about this | 648 | // Tell the linkset about value changes |
640 | Linkset.UpdateProperties(this); | 649 | Linkset.UpdateProperties(this); |
641 | 650 | ||
642 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. | 651 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. |