aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-12-12 16:29:03 -0800
committerRobert Adams2012-12-12 16:51:43 -0800
commite1814aa827c2d0af21d087bd34e3c7f4f7cf25bd (patch)
tree283bcee9a3320a93e9c252937f754c5962f9a19d /OpenSim/Region
parentBulletSim: non-functional commenting and reorganization of material attribute... (diff)
downloadopensim-SC-e1814aa827c2d0af21d087bd34e3c7f4f7cf25bd.zip
opensim-SC-e1814aa827c2d0af21d087bd34e3c7f4f7cf25bd.tar.gz
opensim-SC-e1814aa827c2d0af21d087bd34e3c7f4f7cf25bd.tar.bz2
opensim-SC-e1814aa827c2d0af21d087bd34e3c7f4f7cf25bd.tar.xz
BulletSim: fix problem of avatar's floating off the ground after unsitting. Reworked size/scale logic so physical scale is kept in Bullet and physObject scale is the preferred size -- usually same as size but avatars are computed differently.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs18
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs23
4 files changed, 27 insertions, 24 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 83c78f6..c8aad8d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -105,12 +105,12 @@ public sealed class BSCharacter : BSPhysObject
105 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", 105 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}",
106 LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); 106 LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
107 107
108 // do actual create at taint time 108 // do actual creation in taint time
109 PhysicsScene.TaintedObject("BSCharacter.create", delegate() 109 PhysicsScene.TaintedObject("BSCharacter.create", delegate()
110 { 110 {
111 DetailLog("{0},BSCharacter.create,taint", LocalID); 111 DetailLog("{0},BSCharacter.create,taint", LocalID);
112 // New body and shape into PhysBody and PhysShape 112 // New body and shape into PhysBody and PhysShape
113 PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, null, null); 113 PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this);
114 114
115 SetPhysicalProperties(); 115 SetPhysicalProperties();
116 }); 116 });
@@ -189,6 +189,11 @@ public sealed class BSCharacter : BSPhysObject
189 set { 189 set {
190 // When an avatar's size is set, only the height is changed. 190 // When an avatar's size is set, only the height is changed.
191 _size = value; 191 _size = value;
192 // Old versions of ScenePresence passed only the height. If width and/or depth are zero,
193 // replace with the default values.
194 if (_size.X == 0f) _size.X = PhysicsScene.Params.avatarCapsuleDepth;
195 if (_size.Y == 0f) _size.Y = PhysicsScene.Params.avatarCapsuleWidth;
196
192 ComputeAvatarScale(_size); 197 ComputeAvatarScale(_size);
193 ComputeAvatarVolumeAndMass(); 198 ComputeAvatarVolumeAndMass();
194 DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", 199 DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
@@ -196,18 +201,18 @@ public sealed class BSCharacter : BSPhysObject
196 201
197 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() 202 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
198 { 203 {
199 if (PhysShape.HasPhysicalShape) 204 if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape)
200 { 205 {
201 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); 206 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
202 UpdatePhysicalMassProperties(RawMass); 207 UpdatePhysicalMassProperties(RawMass);
208 // Make sure this change appears as a property update event
209 BulletSimAPI.PushUpdate2(PhysBody.ptr);
203 } 210 }
204 }); 211 });
205 212
206 } 213 }
207 } 214 }
208 215
209 public override OMV.Vector3 Scale { get; set; }
210
211 public override PrimitiveBaseShape Shape 216 public override PrimitiveBaseShape Shape
212 { 217 {
213 set { BaseShape = value; } 218 set { BaseShape = value; }
@@ -638,9 +643,6 @@ public sealed class BSCharacter : BSPhysObject
638 643
639 private void ComputeAvatarScale(OMV.Vector3 size) 644 private void ComputeAvatarScale(OMV.Vector3 size)
640 { 645 {
641 // The 'size' given by the simulator is the mid-point of the avatar
642 // and X and Y are unspecified.
643
644 OMV.Vector3 newScale = size; 646 OMV.Vector3 newScale = size;
645 // newScale.X = PhysicsScene.Params.avatarCapsuleWidth; 647 // newScale.X = PhysicsScene.Params.avatarCapsuleWidth;
646 // newScale.Y = PhysicsScene.Params.avatarCapsuleDepth; 648 // newScale.Y = PhysicsScene.Params.avatarCapsuleDepth;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index f3b6993..6539b43 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -109,7 +109,7 @@ public abstract class BSPhysObject : PhysicsActor
109 public EntityProperties CurrentEntityProperties { get; set; } 109 public EntityProperties CurrentEntityProperties { get; set; }
110 public EntityProperties LastEntityProperties { get; set; } 110 public EntityProperties LastEntityProperties { get; set; }
111 111
112 public abstract OMV.Vector3 Scale { get; set; } 112 public virtual OMV.Vector3 Scale { get; set; }
113 public abstract bool IsSolid { get; } 113 public abstract bool IsSolid { get; }
114 public abstract bool IsStatic { get; } 114 public abstract bool IsStatic { get; }
115 115
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 35d22c0..19c29cc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -45,7 +45,6 @@ public sealed class BSPrim : BSPhysObject
45 private static readonly string LogHeader = "[BULLETS PRIM]"; 45 private static readonly string LogHeader = "[BULLETS PRIM]";
46 46
47 // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. 47 // _size is what the user passed. Scale is what we pass to the physics engine with the mesh.
48 // Often Scale is unity because the meshmerizer will apply _size when creating the mesh.
49 private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user 48 private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user
50 49
51 private bool _grabbed; 50 private bool _grabbed;
@@ -93,7 +92,7 @@ public sealed class BSPrim : BSPhysObject
93 _physicsActorType = (int)ActorTypes.Prim; 92 _physicsActorType = (int)ActorTypes.Prim;
94 _position = pos; 93 _position = pos;
95 _size = size; 94 _size = size;
96 Scale = size; // the scale will be set by CreateGeom depending on object type 95 Scale = size; // prims are the size the user wants them to be (different for BSCharactes).
97 _orientation = rotation; 96 _orientation = rotation;
98 _buoyancy = 1f; 97 _buoyancy = 1f;
99 _velocity = OMV.Vector3.Zero; 98 _velocity = OMV.Vector3.Zero;
@@ -159,12 +158,10 @@ public sealed class BSPrim : BSPhysObject
159 // We presume the scale and size are the same. If scale must be changed for 158 // We presume the scale and size are the same. If scale must be changed for
160 // the physical shape, that is done when the geometry is built. 159 // the physical shape, that is done when the geometry is built.
161 _size = value; 160 _size = value;
161 Scale = _size;
162 ForceBodyShapeRebuild(false); 162 ForceBodyShapeRebuild(false);
163 } 163 }
164 } 164 }
165 // Scale is what we set in the physics engine. It is different than 'size' in that
166 // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>.
167 public override OMV.Vector3 Scale { get; set; }
168 165
169 public override PrimitiveBaseShape Shape { 166 public override PrimitiveBaseShape Shape {
170 set { 167 set {
@@ -1369,7 +1366,6 @@ public sealed class BSPrim : BSPhysObject
1369 // Create the correct physical representation for this type of object. 1366 // Create the correct physical representation for this type of object.
1370 // Updates PhysBody and PhysShape with the new information. 1367 // Updates PhysBody and PhysShape with the new information.
1371 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. 1368 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
1372 // Returns 'true' if either the body or the shape was changed.
1373 PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody) 1369 PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody)
1374 { 1370 {
1375 // Called if the current prim body is about to be destroyed. 1371 // Called if the current prim body is about to be destroyed.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 4ab9a99..ea996ae 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -126,6 +126,11 @@ public sealed class BSShapeCollection : IDisposable
126 return ret; 126 return ret;
127 } 127 }
128 128
129 public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim)
130 {
131 return GetBodyAndShape(forceRebuild, sim, prim, null, null);
132 }
133
129 // Track another user of a body. 134 // Track another user of a body.
130 // We presume the caller has allocated the body. 135 // We presume the caller has allocated the body.
131 // Bodies only have one user so the body is just put into the world if not already there. 136 // Bodies only have one user so the body is just put into the world if not already there.
@@ -460,6 +465,11 @@ public sealed class BSShapeCollection : IDisposable
460 && pbs.PathScaleX == 100 && pbs.PathScaleY == 100 465 && pbs.PathScaleX == 100 && pbs.PathScaleY == 100
461 && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) ) 466 && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) )
462 { 467 {
468 // Get the scale of any existing shape so we can see if the new shape is same native type and same size.
469 OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero;
470 if (prim.PhysShape.HasPhysicalShape)
471 scaleOfExistingShape = BulletSimAPI.GetLocalScaling2(prim.PhysShape.ptr);
472
463 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}", 473 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}",
464 prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type); 474 prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type);
465 475
@@ -469,7 +479,7 @@ public sealed class BSShapeCollection : IDisposable
469 { 479 {
470 haveShape = true; 480 haveShape = true;
471 if (forceRebuild 481 if (forceRebuild
472 || prim.Scale != prim.Size 482 || prim.Scale != scaleOfExistingShape
473 || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_SPHERE 483 || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_SPHERE
474 ) 484 )
475 { 485 {
@@ -483,7 +493,7 @@ public sealed class BSShapeCollection : IDisposable
483 { 493 {
484 haveShape = true; 494 haveShape = true;
485 if (forceRebuild 495 if (forceRebuild
486 || prim.Scale != prim.Size 496 || prim.Scale != scaleOfExistingShape
487 || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_BOX 497 || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_BOX
488 ) 498 )
489 { 499 {
@@ -542,7 +552,6 @@ public sealed class BSShapeCollection : IDisposable
542 prim.LocalID, newShape, prim.Scale); 552 prim.LocalID, newShape, prim.Scale);
543 553
544 // native shapes are scaled by Bullet 554 // native shapes are scaled by Bullet
545 prim.Scale = prim.Size;
546 prim.PhysShape = newShape; 555 prim.PhysShape = newShape;
547 return true; 556 return true;
548 } 557 }
@@ -555,8 +564,8 @@ public sealed class BSShapeCollection : IDisposable
555 ShapeData nativeShapeData = new ShapeData(); 564 ShapeData nativeShapeData = new ShapeData();
556 nativeShapeData.Type = shapeType; 565 nativeShapeData.Type = shapeType;
557 nativeShapeData.ID = prim.LocalID; 566 nativeShapeData.ID = prim.LocalID;
558 nativeShapeData.Scale = prim.Size; 567 nativeShapeData.Scale = prim.Scale;
559 nativeShapeData.Size = prim.Size; // unneeded, I think. 568 nativeShapeData.Size = prim.Scale; // unneeded, I think.
560 nativeShapeData.MeshKey = (ulong)shapeKey; 569 nativeShapeData.MeshKey = (ulong)shapeKey;
561 nativeShapeData.HullKey = (ulong)shapeKey; 570 nativeShapeData.HullKey = (ulong)shapeKey;
562 571
@@ -611,8 +620,6 @@ public sealed class BSShapeCollection : IDisposable
611 620
612 ReferenceShape(newShape); 621 ReferenceShape(newShape);
613 622
614 // meshes are already scaled by the meshmerizer
615 prim.Scale = new OMV.Vector3(1f, 1f, 1f);
616 prim.PhysShape = newShape; 623 prim.PhysShape = newShape;
617 624
618 return true; // 'true' means a new shape has been added to this prim 625 return true; // 'true' means a new shape has been added to this prim
@@ -683,8 +690,6 @@ public sealed class BSShapeCollection : IDisposable
683 690
684 ReferenceShape(newShape); 691 ReferenceShape(newShape);
685 692
686 // hulls are already scaled by the meshmerizer
687 prim.Scale = new OMV.Vector3(1f, 1f, 1f);
688 prim.PhysShape = newShape; 693 prim.PhysShape = newShape;
689 return true; // 'true' means a new shape has been added to this prim 694 return true; // 'true' means a new shape has been added to this prim
690 } 695 }