aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
diff options
context:
space:
mode:
authorRobert Adams2013-01-07 16:05:02 -0800
committerRobert Adams2013-01-07 16:05:02 -0800
commit8452c0a8702ccf7ea045740dd829c69a6f509845 (patch)
treea2c094fbded7a502dc997d1eb4252659eddbb003 /OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
parentBulletSim: fix exception when re-creating the terrain when loading an OAR file (diff)
downloadopensim-SC_OLD-8452c0a8702ccf7ea045740dd829c69a6f509845.zip
opensim-SC_OLD-8452c0a8702ccf7ea045740dd829c69a6f509845.tar.gz
opensim-SC_OLD-8452c0a8702ccf7ea045740dd829c69a6f509845.tar.bz2
opensim-SC_OLD-8452c0a8702ccf7ea045740dd829c69a6f509845.tar.xz
BulletSim: add function to push avatar up when hitting stairs.
It looks like BulletSim and ODE rely on penetration correction to cause the avatar to move up and thus allowing walking up stairs. Object penetration was minimized for walking and flying (so one doesn't go through walls) and this stopped stairs from working. This commit introduces avatar movement code to check for collisions at the feet while walking and attempts to raise the avatar for the steps. Not yet perfect but movement is better.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 534f929..e8575f6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -79,6 +79,7 @@ public abstract class BSPhysObject : PhysicsActor
79 Material = MaterialAttributes.Material.Wood; 79 Material = MaterialAttributes.Material.Wood;
80 80
81 CollisionCollection = new CollisionEventUpdate(); 81 CollisionCollection = new CollisionEventUpdate();
82 CollisionsLastTick = CollisionCollection;
82 SubscribedEventsMs = 0; 83 SubscribedEventsMs = 0;
83 CollidingStep = 0; 84 CollidingStep = 0;
84 CollidingGroundStep = 0; 85 CollidingGroundStep = 0;
@@ -159,6 +160,7 @@ public abstract class BSPhysObject : PhysicsActor
159 public abstract OMV.Quaternion ForceOrientation { get; set; } 160 public abstract OMV.Quaternion ForceOrientation { get; set; }
160 161
161 // The system is telling us the velocity it wants to move at. 162 // The system is telling us the velocity it wants to move at.
163 // Velocity in world coordinates.
162 // protected OMV.Vector3 m_targetVelocity; // use the definition in PhysicsActor 164 // protected OMV.Vector3 m_targetVelocity; // use the definition in PhysicsActor
163 public override OMV.Vector3 TargetVelocity 165 public override OMV.Vector3 TargetVelocity
164 { 166 {
@@ -169,6 +171,15 @@ public abstract class BSPhysObject : PhysicsActor
169 Velocity = value; 171 Velocity = value;
170 } 172 }
171 } 173 }
174 public virtual float TargetSpeed
175 {
176 get
177 {
178 OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation));
179 return characterOrientedVelocity.X;
180 }
181 }
182 public abstract OMV.Vector3 RawVelocity { get; set; }
172 public abstract OMV.Vector3 ForceVelocity { get; set; } 183 public abstract OMV.Vector3 ForceVelocity { get; set; }
173 184
174 public abstract OMV.Vector3 ForceRotationalVelocity { get; set; } 185 public abstract OMV.Vector3 ForceRotationalVelocity { get; set; }
@@ -177,6 +188,15 @@ public abstract class BSPhysObject : PhysicsActor
177 188
178 public virtual bool ForceBodyShapeRebuild(bool inTaintTime) { return false; } 189 public virtual bool ForceBodyShapeRebuild(bool inTaintTime) { return false; }
179 190
191 public virtual float ForwardSpeed
192 {
193 get
194 {
195 OMV.Vector3 characterOrientedVelocity = RawVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation));
196 return characterOrientedVelocity.X;
197 }
198 }
199
180 #region Collisions 200 #region Collisions
181 201
182 // Requested number of milliseconds between collision events. Zero means disabled. 202 // Requested number of milliseconds between collision events. Zero means disabled.
@@ -223,9 +243,13 @@ public abstract class BSPhysObject : PhysicsActor
223 243
224 // The collisions that have been collected this tick 244 // The collisions that have been collected this tick
225 protected CollisionEventUpdate CollisionCollection; 245 protected CollisionEventUpdate CollisionCollection;
246 // Remember collisions from last tick for fancy collision based actions
247 // (like a BSCharacter walking up stairs).
248 protected CollisionEventUpdate CollisionsLastTick;
226 249
227 // The simulation step is telling this object about a collision. 250 // The simulation step is telling this object about a collision.
228 // Return 'true' if a collision was processed and should be sent up. 251 // Return 'true' if a collision was processed and should be sent up.
252 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
229 // Called at taint time from within the Step() function 253 // Called at taint time from within the Step() function
230 public virtual bool Collide(uint collidingWith, BSPhysObject collidee, 254 public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
231 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 255 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
@@ -286,6 +310,9 @@ public abstract class BSPhysObject : PhysicsActor
286 // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); 310 // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count);
287 base.SendCollisionUpdate(CollisionCollection); 311 base.SendCollisionUpdate(CollisionCollection);
288 312
313 // Remember the collisions from this tick for some collision specific processing.
314 CollisionsLastTick = CollisionCollection;
315
289 // The CollisionCollection instance is passed around in the simulator. 316 // The CollisionCollection instance is passed around in the simulator.
290 // Make sure we don't have a handle to that one and that a new one is used for next time. 317 // Make sure we don't have a handle to that one and that a new one is used for next time.
291 // This fixes an interesting 'gotcha'. If we call CollisionCollection.Clear() here, 318 // This fixes an interesting 'gotcha'. If we call CollisionCollection.Clear() here,