aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs185
1 files changed, 92 insertions, 93 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 961bcde..b88ec3c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -122,7 +122,6 @@ public class BSCharacter : BSPhysObject
122 BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, 122 BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr,
123 (uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask); 123 (uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask);
124 }); 124 });
125
126 return; 125 return;
127 } 126 }
128 127
@@ -141,8 +140,8 @@ public class BSCharacter : BSPhysObject
141 base.RequestPhysicsterseUpdate(); 140 base.RequestPhysicsterseUpdate();
142 } 141 }
143 // No one calls this method so I don't know what it could possibly mean 142 // No one calls this method so I don't know what it could possibly mean
144 public override bool Stopped { 143 public override bool Stopped {
145 get { return false; } 144 get { return false; }
146 } 145 }
147 public override OMV.Vector3 Size { 146 public override OMV.Vector3 Size {
148 get 147 get
@@ -151,7 +150,7 @@ public class BSCharacter : BSPhysObject
151 return new OMV.Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z); 150 return new OMV.Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z);
152 } 151 }
153 152
154 set { 153 set {
155 // When an avatar's size is set, only the height is changed 154 // When an avatar's size is set, only the height is changed
156 // and that really only depends on the radius. 155 // and that really only depends on the radius.
157 _size = value; 156 _size = value;
@@ -166,19 +165,19 @@ public class BSCharacter : BSPhysObject
166 BulletSimAPI.SetObjectScaleMass(PhysicsScene.WorldID, LocalID, _scale, _mass, true); 165 BulletSimAPI.SetObjectScaleMass(PhysicsScene.WorldID, LocalID, _scale, _mass, true);
167 }); 166 });
168 167
169 } 168 }
170 } 169 }
171 public override PrimitiveBaseShape Shape { 170 public override PrimitiveBaseShape Shape {
172 set { _pbs = value; 171 set { _pbs = value;
173 } 172 }
174 } 173 }
175 public override bool Grabbed { 174 public override bool Grabbed {
176 set { _grabbed = value; 175 set { _grabbed = value;
177 } 176 }
178 } 177 }
179 public override bool Selected { 178 public override bool Selected {
180 set { _selected = value; 179 set { _selected = value;
181 } 180 }
182 } 181 }
183 public override void CrossingFailure() { return; } 182 public override void CrossingFailure() { return; }
184 public override void link(PhysicsActor obj) { return; } 183 public override void link(PhysicsActor obj) { return; }
@@ -203,11 +202,11 @@ public class BSCharacter : BSPhysObject
203 202
204 public override void LockAngularMotion(OMV.Vector3 axis) { return; } 203 public override void LockAngularMotion(OMV.Vector3 axis) { return; }
205 204
206 public override OMV.Vector3 Position { 205 public override OMV.Vector3 Position {
207 get { 206 get {
208 // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID); 207 // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID);
209 return _position; 208 return _position;
210 } 209 }
211 set { 210 set {
212 _position = value; 211 _position = value;
213 PositionSanityCheck(); 212 PositionSanityCheck();
@@ -217,7 +216,7 @@ public class BSCharacter : BSPhysObject
217 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 216 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
218 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); 217 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation);
219 }); 218 });
220 } 219 }
221 } 220 }
222 221
223 // Check that the current position is sane and, if not, modify the position to make it so. 222 // Check that the current position is sane and, if not, modify the position to make it so.
@@ -226,7 +225,7 @@ public class BSCharacter : BSPhysObject
226 private bool PositionSanityCheck() 225 private bool PositionSanityCheck()
227 { 226 {
228 bool ret = false; 227 bool ret = false;
229 228
230 // If below the ground, move the avatar up 229 // If below the ground, move the avatar up
231 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); 230 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
232 if (Position.Z < terrainHeight) 231 if (Position.Z < terrainHeight)
@@ -260,17 +259,17 @@ public class BSCharacter : BSPhysObject
260 return ret; 259 return ret;
261 } 260 }
262 261
263 public override float Mass { 262 public override float Mass {
264 get { 263 get {
265 return _mass; 264 return _mass;
266 } 265 }
267 } 266 }
268 267
269 // used when we only want this prim's mass and not the linkset thing 268 // used when we only want this prim's mass and not the linkset thing
270 public override float MassRaw { get {return _mass; } } 269 public override float MassRaw { get {return _mass; } }
271 270
272 public override OMV.Vector3 Force { 271 public override OMV.Vector3 Force {
273 get { return _force; } 272 get { return _force; }
274 set { 273 set {
275 _force = value; 274 _force = value;
276 // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); 275 // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
@@ -279,12 +278,12 @@ public class BSCharacter : BSPhysObject
279 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); 278 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
280 BulletSimAPI.SetObjectForce(PhysicsScene.WorldID, LocalID, _force); 279 BulletSimAPI.SetObjectForce(PhysicsScene.WorldID, LocalID, _force);
281 }); 280 });
282 } 281 }
283 } 282 }
284 283
285 public override int VehicleType { 284 public override int VehicleType {
286 get { return 0; } 285 get { return 0; }
287 set { return; } 286 set { return; }
288 } 287 }
289 public override void VehicleFloatParam(int param, float value) { } 288 public override void VehicleFloatParam(int param, float value) { }
290 public override void VehicleVectorParam(int param, OMV.Vector3 value) {} 289 public override void VehicleVectorParam(int param, OMV.Vector3 value) {}
@@ -296,8 +295,8 @@ public class BSCharacter : BSPhysObject
296 295
297 public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } } 296 public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } }
298 public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } 297 public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } }
299 public override OMV.Vector3 Velocity { 298 public override OMV.Vector3 Velocity {
300 get { return _velocity; } 299 get { return _velocity; }
301 set { 300 set {
302 _velocity = value; 301 _velocity = value;
303 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); 302 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
@@ -306,24 +305,24 @@ public class BSCharacter : BSPhysObject
306 DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity); 305 DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity);
307 BulletSimAPI.SetObjectVelocity(PhysicsScene.WorldID, LocalID, _velocity); 306 BulletSimAPI.SetObjectVelocity(PhysicsScene.WorldID, LocalID, _velocity);
308 }); 307 });
309 } 308 }
310 } 309 }
311 public override OMV.Vector3 Torque { 310 public override OMV.Vector3 Torque {
312 get { return _torque; } 311 get { return _torque; }
313 set { _torque = value; 312 set { _torque = value;
314 } 313 }
315 } 314 }
316 public override float CollisionScore { 315 public override float CollisionScore {
317 get { return _collisionScore; } 316 get { return _collisionScore; }
318 set { _collisionScore = value; 317 set { _collisionScore = value;
319 } 318 }
320 } 319 }
321 public override OMV.Vector3 Acceleration { 320 public override OMV.Vector3 Acceleration {
322 get { return _acceleration; } 321 get { return _acceleration; }
323 set { _acceleration = value; } 322 set { _acceleration = value; }
324 } 323 }
325 public override OMV.Quaternion Orientation { 324 public override OMV.Quaternion Orientation {
326 get { return _orientation; } 325 get { return _orientation; }
327 set { 326 set {
328 _orientation = value; 327 _orientation = value;
329 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); 328 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
@@ -332,98 +331,98 @@ public class BSCharacter : BSPhysObject
332 // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID); 331 // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID);
333 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); 332 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation);
334 }); 333 });
335 } 334 }
336 } 335 }
337 public override int PhysicsActorType { 336 public override int PhysicsActorType {
338 get { return _physicsActorType; } 337 get { return _physicsActorType; }
339 set { _physicsActorType = value; 338 set { _physicsActorType = value;
340 } 339 }
341 } 340 }
342 public override bool IsPhysical { 341 public override bool IsPhysical {
343 get { return _isPhysical; } 342 get { return _isPhysical; }
344 set { _isPhysical = value; 343 set { _isPhysical = value;
345 } 344 }
346 } 345 }
347 public override bool Flying { 346 public override bool Flying {
348 get { return _flying; } 347 get { return _flying; }
349 set { 348 set {
350 _flying = value; 349 _flying = value;
351 // simulate flying by changing the effect of gravity 350 // simulate flying by changing the effect of gravity
352 this.Buoyancy = ComputeBuoyancyFromFlying(_flying); 351 this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
353 } 352 }
354 } 353 }
355 // Flying is implimented by changing the avatar's buoyancy. 354 // Flying is implimented by changing the avatar's buoyancy.
356 // Would this be done better with a vehicle type? 355 // Would this be done better with a vehicle type?
357 private float ComputeBuoyancyFromFlying(bool ifFlying) { 356 private float ComputeBuoyancyFromFlying(bool ifFlying) {
358 return ifFlying ? 1f : 0f; 357 return ifFlying ? 1f : 0f;
359 } 358 }
360 public override bool 359 public override bool
361 SetAlwaysRun { 360 SetAlwaysRun {
362 get { return _setAlwaysRun; } 361 get { return _setAlwaysRun; }
363 set { _setAlwaysRun = value; } 362 set { _setAlwaysRun = value; }
364 } 363 }
365 public override bool ThrottleUpdates { 364 public override bool ThrottleUpdates {
366 get { return _throttleUpdates; } 365 get { return _throttleUpdates; }
367 set { _throttleUpdates = value; } 366 set { _throttleUpdates = value; }
368 } 367 }
369 public override bool IsColliding { 368 public override bool IsColliding {
370 get { return (CollidingStep == PhysicsScene.SimulationStep); } 369 get { return (CollidingStep == PhysicsScene.SimulationStep); }
371 set { _isColliding = value; } 370 set { _isColliding = value; }
372 } 371 }
373 public override bool CollidingGround { 372 public override bool CollidingGround {
374 get { return (CollidingGroundStep == PhysicsScene.SimulationStep); } 373 get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
375 set { CollidingGround = value; } 374 set { CollidingGround = value; }
376 } 375 }
377 public override bool CollidingObj { 376 public override bool CollidingObj {
378 get { return _collidingObj; } 377 get { return _collidingObj; }
379 set { _collidingObj = value; } 378 set { _collidingObj = value; }
380 } 379 }
381 public override bool FloatOnWater { 380 public override bool FloatOnWater {
382 set { _floatOnWater = value; } 381 set { _floatOnWater = value; }
383 } 382 }
384 public override OMV.Vector3 RotationalVelocity { 383 public override OMV.Vector3 RotationalVelocity {
385 get { return _rotationalVelocity; } 384 get { return _rotationalVelocity; }
386 set { _rotationalVelocity = value; } 385 set { _rotationalVelocity = value; }
387 } 386 }
388 public override bool Kinematic { 387 public override bool Kinematic {
389 get { return _kinematic; } 388 get { return _kinematic; }
390 set { _kinematic = value; } 389 set { _kinematic = value; }
391 } 390 }
392 // neg=fall quickly, 0=1g, 1=0g, pos=float up 391 // neg=fall quickly, 0=1g, 1=0g, pos=float up
393 public override float Buoyancy { 392 public override float Buoyancy {
394 get { return _buoyancy; } 393 get { return _buoyancy; }
395 set { _buoyancy = value; 394 set { _buoyancy = value;
396 PhysicsScene.TaintedObject("BSCharacter.setBuoyancy", delegate() 395 PhysicsScene.TaintedObject("BSCharacter.setBuoyancy", delegate()
397 { 396 {
398 DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 397 DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
399 BulletSimAPI.SetObjectBuoyancy(PhysicsScene.WorldID, LocalID, _buoyancy); 398 BulletSimAPI.SetObjectBuoyancy(PhysicsScene.WorldID, LocalID, _buoyancy);
400 }); 399 });
401 } 400 }
402 } 401 }
403 402
404 // Used for MoveTo 403 // Used for MoveTo
405 public override OMV.Vector3 PIDTarget { 404 public override OMV.Vector3 PIDTarget {
406 set { _PIDTarget = value; } 405 set { _PIDTarget = value; }
407 } 406 }
408 public override bool PIDActive { 407 public override bool PIDActive {
409 set { _usePID = value; } 408 set { _usePID = value; }
410 } 409 }
411 public override float PIDTau { 410 public override float PIDTau {
412 set { _PIDTau = value; } 411 set { _PIDTau = value; }
413 } 412 }
414 413
415 // Used for llSetHoverHeight and maybe vehicle height 414 // Used for llSetHoverHeight and maybe vehicle height
416 // Hover Height will override MoveTo target's Z 415 // Hover Height will override MoveTo target's Z
417 public override bool PIDHoverActive { 416 public override bool PIDHoverActive {
418 set { _useHoverPID = value; } 417 set { _useHoverPID = value; }
419 } 418 }
420 public override float PIDHoverHeight { 419 public override float PIDHoverHeight {
421 set { _PIDHoverHeight = value; } 420 set { _PIDHoverHeight = value; }
422 } 421 }
423 public override PIDHoverType PIDHoverType { 422 public override PIDHoverType PIDHoverType {
424 set { _PIDHoverType = value; } 423 set { _PIDHoverType = value; }
425 } 424 }
426 public override float PIDHoverTau { 425 public override float PIDHoverTau {
427 set { _PIDHoverTao = value; } 426 set { _PIDHoverTao = value; }
428 } 427 }
429 428
@@ -433,7 +432,7 @@ public class BSCharacter : BSPhysObject
433 public override float APIDStrength { set { return; } } 432 public override float APIDStrength { set { return; } }
434 public override float APIDDamping { set { return; } } 433 public override float APIDDamping { set { return; } }
435 434
436 public override void AddForce(OMV.Vector3 force, bool pushforce) { 435 public override void AddForce(OMV.Vector3 force, bool pushforce) {
437 if (force.IsFinite()) 436 if (force.IsFinite())
438 { 437 {
439 _force.X += force.X; 438 _force.X += force.X;
@@ -453,9 +452,9 @@ public class BSCharacter : BSPhysObject
453 //m_lastUpdateSent = false; 452 //m_lastUpdateSent = false;
454 } 453 }
455 454
456 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { 455 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
457 } 456 }
458 public override void SetMomentum(OMV.Vector3 momentum) { 457 public override void SetMomentum(OMV.Vector3 momentum) {
459 } 458 }
460 459
461 private void ComputeAvatarScale(OMV.Vector3 size) 460 private void ComputeAvatarScale(OMV.Vector3 size)