diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 3c48dcc..e2aa41e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -82,7 +82,13 @@ public sealed class BSCharacter : BSPhysObject | |||
82 | { | 82 | { |
83 | _physicsActorType = (int)ActorTypes.Agent; | 83 | _physicsActorType = (int)ActorTypes.Agent; |
84 | _position = pos; | 84 | _position = pos; |
85 | |||
86 | // Old versions of ScenePresence passed only the height. If width and/or depth are zero, | ||
87 | // replace with the default values. | ||
85 | _size = size; | 88 | _size = size; |
89 | if (_size.X == 0f) _size.X = PhysicsScene.Params.avatarCapsuleDepth; | ||
90 | if (_size.Y == 0f) _size.Y = PhysicsScene.Params.avatarCapsuleWidth; | ||
91 | |||
86 | _flying = isFlying; | 92 | _flying = isFlying; |
87 | _orientation = OMV.Quaternion.Identity; | 93 | _orientation = OMV.Quaternion.Identity; |
88 | _velocity = OMV.Vector3.Zero; | 94 | _velocity = OMV.Vector3.Zero; |
@@ -175,8 +181,7 @@ public sealed class BSCharacter : BSPhysObject | |||
175 | get | 181 | get |
176 | { | 182 | { |
177 | // Avatar capsule size is kept in the scale parameter. | 183 | // Avatar capsule size is kept in the scale parameter. |
178 | // return _size; | 184 | return _size; |
179 | return new OMV.Vector3(Scale.X * 2f, Scale.Y * 2f, Scale.Z); | ||
180 | } | 185 | } |
181 | 186 | ||
182 | set { | 187 | set { |
@@ -184,8 +189,8 @@ public sealed class BSCharacter : BSPhysObject | |||
184 | _size = value; | 189 | _size = value; |
185 | ComputeAvatarScale(_size); | 190 | ComputeAvatarScale(_size); |
186 | ComputeAvatarVolumeAndMass(); | 191 | ComputeAvatarVolumeAndMass(); |
187 | DetailLog("{0},BSCharacter.setSize,call,scale={1},density={2},volume={3},mass={4}", | 192 | DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", |
188 | LocalID, Scale, _avatarDensity, _avatarVolume, RawMass); | 193 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); |
189 | 194 | ||
190 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() | 195 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() |
191 | { | 196 | { |
@@ -203,9 +208,9 @@ public sealed class BSCharacter : BSPhysObject | |||
203 | set { BaseShape = value; } | 208 | set { BaseShape = value; } |
204 | } | 209 | } |
205 | // I want the physics engine to make an avatar capsule | 210 | // I want the physics engine to make an avatar capsule |
206 | public override ShapeData.PhysicsShapeType PreferredPhysicalShape | 211 | public override PhysicsShapeType PreferredPhysicalShape |
207 | { | 212 | { |
208 | get {return ShapeData.PhysicsShapeType.SHAPE_AVATAR; } | 213 | get {return PhysicsShapeType.SHAPE_CAPSULE; } |
209 | } | 214 | } |
210 | 215 | ||
211 | public override bool Grabbed { | 216 | public override bool Grabbed { |
@@ -614,13 +619,19 @@ public sealed class BSCharacter : BSPhysObject | |||
614 | // The 'size' given by the simulator is the mid-point of the avatar | 619 | // The 'size' given by the simulator is the mid-point of the avatar |
615 | // and X and Y are unspecified. | 620 | // and X and Y are unspecified. |
616 | 621 | ||
617 | OMV.Vector3 newScale = OMV.Vector3.Zero; | 622 | OMV.Vector3 newScale = size; |
618 | newScale.X = PhysicsScene.Params.avatarCapsuleRadius; | 623 | // newScale.X = PhysicsScene.Params.avatarCapsuleWidth; |
619 | newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; | 624 | // newScale.Y = PhysicsScene.Params.avatarCapsuleDepth; |
620 | 625 | ||
621 | // From the total height, remove the capsule half spheres that are at each end | 626 | // From the total height, remove the capsule half spheres that are at each end |
622 | newScale.Z = size.Z - (newScale.X + newScale.Y); | 627 | // The 1.15f came from ODE. Not sure what this factors in. |
623 | Scale = newScale; | 628 | // newScale.Z = (size.Z * 1.15f) - (newScale.X + newScale.Y); |
629 | |||
630 | // The total scale height is the central cylindar plus the caps on the two ends. | ||
631 | newScale.Z = size.Z + (Math.Min(size.X, size.Y) * 2f); | ||
632 | |||
633 | // Convert diameters to radii and height to half height -- the way Bullet expects it. | ||
634 | Scale = newScale / 2f; | ||
624 | } | 635 | } |
625 | 636 | ||
626 | // set _avatarVolume and _mass based on capsule size, _density and Scale | 637 | // set _avatarVolume and _mass based on capsule size, _density and Scale |