diff options
author | Robert Adams | 2012-11-21 16:31:23 -0800 |
---|---|---|
committer | Robert Adams | 2012-11-21 16:43:53 -0800 |
commit | cbc7e7bf85bfd9e916146b0ae4a605996c24720b (patch) | |
tree | 9873174e8174ce230b2b0e8d30c490d0b79db745 /OpenSim/Region | |
parent | BulletSim: Properly position mesh terrain on creation (fixes terrain not appe... (diff) | |
download | opensim-SC-cbc7e7bf85bfd9e916146b0ae4a605996c24720b.zip opensim-SC-cbc7e7bf85bfd9e916146b0ae4a605996c24720b.tar.gz opensim-SC-cbc7e7bf85bfd9e916146b0ae4a605996c24720b.tar.bz2 opensim-SC-cbc7e7bf85bfd9e916146b0ae4a605996c24720b.tar.xz |
BulletSim: Make avatar capsule so it is not circular.
Simple attempt to make avatars better shaped.
Replace parameter 'avatarCapsuleRadius' with 'avatarCapsuleWidth'
and 'avatarCapsuleDepth'.
More tweeking to avatar height calculation. A little better but
short avatar's feet are above the terrain and tall avatar's feet
are a little below the ground.
Diffstat (limited to 'OpenSim/Region')
6 files changed, 39 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 799211e..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 { |
@@ -614,14 +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 | // The 1.15f came from ODE. Not sure what this factors in. | 627 | // The 1.15f came from ODE. Not sure what this factors in. |
623 | newScale.Z = (size.Z * 1.15f) - (newScale.X + newScale.Y); | 628 | // newScale.Z = (size.Z * 1.15f) - (newScale.X + newScale.Y); |
624 | Scale = newScale; | 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; | ||
625 | } | 635 | } |
626 | 636 | ||
627 | // set _avatarVolume and _mass based on capsule size, _density and Scale | 637 | // set _avatarVolume and _mass based on capsule size, _density and Scale |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 2657e4b..5d16bbf 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -93,7 +93,7 @@ public sealed class BSPrim : BSPhysObject | |||
93 | _physicsActorType = (int)ActorTypes.Prim; | 93 | _physicsActorType = (int)ActorTypes.Prim; |
94 | _position = pos; | 94 | _position = pos; |
95 | _size = size; | 95 | _size = size; |
96 | Scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type | 96 | Scale = size; // the scale will be set by CreateGeom depending on object type |
97 | _orientation = rotation; | 97 | _orientation = rotation; |
98 | _buoyancy = 1f; | 98 | _buoyancy = 1f; |
99 | _velocity = OMV.Vector3.Zero; | 99 | _velocity = OMV.Vector3.Zero; |
@@ -154,6 +154,8 @@ public sealed class BSPrim : BSPhysObject | |||
154 | public override OMV.Vector3 Size { | 154 | public override OMV.Vector3 Size { |
155 | get { return _size; } | 155 | get { return _size; } |
156 | set { | 156 | set { |
157 | // We presume the scale and size are the same. If scale must be changed for | ||
158 | // the physical shape, that is done when the geometry is built. | ||
157 | _size = value; | 159 | _size = value; |
158 | ForceBodyShapeRebuild(false); | 160 | ForceBodyShapeRebuild(false); |
159 | } | 161 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 0e73d04..27a78d1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -1185,14 +1185,18 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
1185 | (s,cf,p,v) => { s.m_params[0].avatarRestitution = cf.GetFloat(p, v); }, | 1185 | (s,cf,p,v) => { s.m_params[0].avatarRestitution = cf.GetFloat(p, v); }, |
1186 | (s) => { return s.m_params[0].avatarRestitution; }, | 1186 | (s) => { return s.m_params[0].avatarRestitution; }, |
1187 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarRestitution, p, l, v); } ), | 1187 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarRestitution, p, l, v); } ), |
1188 | new ParameterDefn("AvatarCapsuleRadius", "Radius of space around an avatar", | 1188 | new ParameterDefn("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule", |
1189 | 0.37f, | 1189 | 0.6f, |
1190 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleRadius = cf.GetFloat(p, v); }, | 1190 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleWidth = cf.GetFloat(p, v); }, |
1191 | (s) => { return s.m_params[0].avatarCapsuleRadius; }, | 1191 | (s) => { return s.m_params[0].avatarCapsuleWidth; }, |
1192 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ), | 1192 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleWidth, p, l, v); } ), |
1193 | new ParameterDefn("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule", | ||
1194 | 0.45f, | ||
1195 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleDepth = cf.GetFloat(p, v); }, | ||
1196 | (s) => { return s.m_params[0].avatarCapsuleDepth; }, | ||
1197 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleDepth, p, l, v); } ), | ||
1193 | new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", | 1198 | new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", |
1194 | // 1.5f, | 1199 | 1.5f, |
1195 | 2.140599f, | ||
1196 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); }, | 1200 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); }, |
1197 | (s) => { return s.m_params[0].avatarCapsuleHeight; }, | 1201 | (s) => { return s.m_params[0].avatarCapsuleHeight; }, |
1198 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ), | 1202 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ), |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index a53ad6e..869735c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -525,9 +525,6 @@ public sealed class BSShapeCollection : IDisposable | |||
525 | // release any previous shape | 525 | // release any previous shape |
526 | DereferenceShape(prim.PhysShape, true, shapeCallback); | 526 | DereferenceShape(prim.PhysShape, true, shapeCallback); |
527 | 527 | ||
528 | // Bullet native objects are scaled by the Bullet engine so pass the size in | ||
529 | prim.Scale = prim.Size; | ||
530 | |||
531 | BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey); | 528 | BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey); |
532 | 529 | ||
533 | // Don't need to do a 'ReferenceShape()' here because native shapes are not shared. | 530 | // Don't need to do a 'ReferenceShape()' here because native shapes are not shared. |
@@ -547,12 +544,13 @@ public sealed class BSShapeCollection : IDisposable | |||
547 | nativeShapeData.Type = shapeType; | 544 | nativeShapeData.Type = shapeType; |
548 | nativeShapeData.ID = prim.LocalID; | 545 | nativeShapeData.ID = prim.LocalID; |
549 | nativeShapeData.Scale = prim.Scale; | 546 | nativeShapeData.Scale = prim.Scale; |
550 | nativeShapeData.Size = prim.Scale; | 547 | nativeShapeData.Size = prim.Scale; // unneeded, I think. |
551 | nativeShapeData.MeshKey = (ulong)shapeKey; | 548 | nativeShapeData.MeshKey = (ulong)shapeKey; |
552 | nativeShapeData.HullKey = (ulong)shapeKey; | 549 | nativeShapeData.HullKey = (ulong)shapeKey; |
553 | 550 | ||
554 | if (shapeType == PhysicsShapeType.SHAPE_CAPSULE) | 551 | if (shapeType == PhysicsShapeType.SHAPE_CAPSULE) |
555 | { | 552 | { |
553 | // The proper scale has been calculated in the prim. | ||
556 | newShape = new BulletShape( | 554 | newShape = new BulletShape( |
557 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) | 555 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) |
558 | , shapeType); | 556 | , shapeType); |
@@ -560,6 +558,9 @@ public sealed class BSShapeCollection : IDisposable | |||
560 | } | 558 | } |
561 | else | 559 | else |
562 | { | 560 | { |
561 | // Native shapes are scaled in Bullet so set the scaling to the size | ||
562 | prim.Scale = prim.Size; | ||
563 | nativeShapeData.Scale = prim.Scale; | ||
563 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType); | 564 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType); |
564 | } | 565 | } |
565 | if (newShape.ptr == IntPtr.Zero) | 566 | if (newShape.ptr == IntPtr.Zero) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 097cd3e..71fca33 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -308,7 +308,7 @@ public sealed class BSTerrainManager | |||
308 | { | 308 | { |
309 | PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}", | 309 | PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}", |
310 | LogHeader, PhysicsScene.RegionName, terrainRegionBase, | 310 | LogHeader, PhysicsScene.RegionName, terrainRegionBase, |
311 | PhysicsScene.Params.terrainImplementation); | 311 | (BSTerrainPhys.TerrainImplementation)PhysicsScene.Params.terrainImplementation); |
312 | BSTerrainPhys newTerrainPhys = null; | 312 | BSTerrainPhys newTerrainPhys = null; |
313 | switch ((int)PhysicsScene.Params.terrainImplementation) | 313 | switch ((int)PhysicsScene.Params.terrainImplementation) |
314 | { | 314 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index e218053..4647c2d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -291,7 +291,8 @@ public struct ConfigurationParameters | |||
291 | public float avatarStandingFriction; | 291 | public float avatarStandingFriction; |
292 | public float avatarDensity; | 292 | public float avatarDensity; |
293 | public float avatarRestitution; | 293 | public float avatarRestitution; |
294 | public float avatarCapsuleRadius; | 294 | public float avatarCapsuleWidth; |
295 | public float avatarCapsuleDepth; | ||
295 | public float avatarCapsuleHeight; | 296 | public float avatarCapsuleHeight; |
296 | public float avatarContactProcessingThreshold; | 297 | public float avatarContactProcessingThreshold; |
297 | 298 | ||