aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-11-29 00:12:11 +0000
committerJustin Clark-Casey (justincc)2014-11-29 00:12:11 +0000
commit265fe349e00b3ece59ec02e56f83bb7623e9d962 (patch)
tree42afe816271f54a017fe5f731d905e923ef5d67b /OpenSim/Region/Physics
parentAvoid repeated lag-generating continuous attempts to retrieve HG service Urls... (diff)
downloadopensim-SC-265fe349e00b3ece59ec02e56f83bb7623e9d962.zip
opensim-SC-265fe349e00b3ece59ec02e56f83bb7623e9d962.tar.gz
opensim-SC-265fe349e00b3ece59ec02e56f83bb7623e9d962.tar.bz2
opensim-SC-265fe349e00b3ece59ec02e56f83bb7623e9d962.tar.xz
Somewhat improve avatar region crossings by properly preserving velocity when avatar enters the new region.
This commit addresses the following issues were causing velocity to be set to 0 on the new region, disrupting flight in particular * Full avatar updates contained no velocity information, which does appear to have some effect in testing. * BulletSim was always setting the velocity to 0 for the new BSCharacter. Now, physics engines take a velocity parameter when setting up characters so we can avoid this. This patch applies to both Bullet and ODE.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs3
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs5
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs41
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs6
-rw-r--r--OpenSim/Region/Physics/Manager/NullPhysicsScene.cs3
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs15
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs6
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs11
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSScene.cs3
10 files changed, 65 insertions, 30 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index f53adcb..06a205e 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -80,10 +80,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
80 return prim; 80 return prim;
81 } 81 }
82 82
83 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 83 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
84 { 84 {
85 BasicActor act = new BasicActor(size); 85 BasicActor act = new BasicActor(size);
86 act.Position = position; 86 act.Position = position;
87 act.Velocity = velocity;
87 act.Flying = isFlying; 88 act.Flying = isFlying;
88 _actors.Add(act); 89 _actors.Add(act);
89 return act; 90 return act;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
index 14518e9..8e998ba 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.Physics.Manager;
34 35
35using OMV = OpenMetaverse; 36using OMV = OpenMetaverse;
@@ -109,6 +110,10 @@ public class BSActorAvatarMove : BSActor
109 { 110 {
110 if (m_velocityMotor != null) 111 if (m_velocityMotor != null)
111 { 112 {
113// if (targ == OMV.Vector3.Zero)
114// Util.PrintCallStack();
115//
116// Console.WriteLine("SetVelocityAndTarget, {0} {1}", vel, targ);
112 m_velocityMotor.Reset(); 117 m_velocityMotor.Reset();
113 m_velocityMotor.SetTarget(targ); 118 m_velocityMotor.SetTarget(targ);
114 m_velocityMotor.SetCurrent(vel); 119 m_velocityMotor.SetCurrent(vel);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 4c54f9f..f29784a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -64,15 +64,25 @@ public sealed class BSCharacter : BSPhysObject
64 private bool _usePID; 64 private bool _usePID;
65 private float _PIDTau; 65 private float _PIDTau;
66 66
67 public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying) 67// public override OMV.Vector3 RawVelocity
68// { get { return base.RawVelocity; }
69// set {
70// if (value != base.RawVelocity)
71// Util.PrintCallStack();
72// Console.WriteLine("Set rawvel to {0}", value);
73// base.RawVelocity = value; }
74// }
75
76 public BSCharacter(
77 uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying)
68 : base(parent_scene, localID, avName, "BSCharacter") 78 : base(parent_scene, localID, avName, "BSCharacter")
69 { 79 {
70 _physicsActorType = (int)ActorTypes.Agent; 80 _physicsActorType = (int)ActorTypes.Agent;
71 RawPosition = pos; 81 RawPosition = pos;
72 82
73 _flying = isFlying; 83 _flying = isFlying;
74 RawOrientation = OMV.Quaternion.Identity; 84 RawOrientation = OMV.Quaternion.Identity;
75 RawVelocity = OMV.Vector3.Zero; 85 RawVelocity = vel;
76 _buoyancy = ComputeBuoyancyFromFlying(isFlying); 86 _buoyancy = ComputeBuoyancyFromFlying(isFlying);
77 Friction = BSParam.AvatarStandingFriction; 87 Friction = BSParam.AvatarStandingFriction;
78 Density = BSParam.AvatarDensity; 88 Density = BSParam.AvatarDensity;
@@ -89,13 +99,15 @@ public sealed class BSCharacter : BSPhysObject
89 // set _avatarVolume and _mass based on capsule size, _density and Scale 99 // set _avatarVolume and _mass based on capsule size, _density and Scale
90 ComputeAvatarVolumeAndMass(); 100 ComputeAvatarVolumeAndMass();
91 101
92 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6}", 102 DetailLog(
93 LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos); 103 "{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}",
104 LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos, vel);
94 105
95 // do actual creation in taint time 106 // do actual creation in taint time
96 PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate() 107 PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate()
97 { 108 {
98 DetailLog("{0},BSCharacter.create,taint", LocalID); 109 DetailLog("{0},BSCharacter.create,taint", LocalID);
110
99 // New body and shape into PhysBody and PhysShape 111 // New body and shape into PhysBody and PhysShape
100 PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this); 112 PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this);
101 113
@@ -142,6 +154,7 @@ public sealed class BSCharacter : BSPhysObject
142 m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false); 154 m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false);
143 155
144 ForceVelocity = RawVelocity; 156 ForceVelocity = RawVelocity;
157 TargetVelocity = RawVelocity;
145 158
146 // This will enable or disable the flying buoyancy of the avatar. 159 // This will enable or disable the flying buoyancy of the avatar.
147 // Needs to be reset especially when an avatar is recreated after crossing a region boundry. 160 // Needs to be reset especially when an avatar is recreated after crossing a region boundry.
@@ -256,7 +269,6 @@ public sealed class BSCharacter : BSPhysObject
256 // Called at taint time! 269 // Called at taint time!
257 public override void ZeroMotion(bool inTaintTime) 270 public override void ZeroMotion(bool inTaintTime)
258 { 271 {
259 RawVelocity = OMV.Vector3.Zero;
260 _acceleration = OMV.Vector3.Zero; 272 _acceleration = OMV.Vector3.Zero;
261 _rotationalVelocity = OMV.Vector3.Zero; 273 _rotationalVelocity = OMV.Vector3.Zero;
262 274
@@ -267,6 +279,7 @@ public sealed class BSCharacter : BSPhysObject
267 PhysScene.PE.ClearAllForces(PhysBody); 279 PhysScene.PE.ClearAllForces(PhysBody);
268 }); 280 });
269 } 281 }
282
270 public override void ZeroAngularMotion(bool inTaintTime) 283 public override void ZeroAngularMotion(bool inTaintTime)
271 { 284 {
272 _rotationalVelocity = OMV.Vector3.Zero; 285 _rotationalVelocity = OMV.Vector3.Zero;
@@ -441,32 +454,40 @@ public sealed class BSCharacter : BSPhysObject
441 get { return RawVelocity; } 454 get { return RawVelocity; }
442 set { 455 set {
443 RawVelocity = value; 456 RawVelocity = value;
444 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, RawVelocity); 457 OMV.Vector3 vel = RawVelocity;
458
459 DetailLog("{0}: set Velocity = {1}", LogHeader, value);
460
445 PhysScene.TaintedObject(LocalID, "BSCharacter.setVelocity", delegate() 461 PhysScene.TaintedObject(LocalID, "BSCharacter.setVelocity", delegate()
446 { 462 {
447 if (m_moveActor != null) 463 if (m_moveActor != null)
448 m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, true /* inTaintTime */); 464 m_moveActor.SetVelocityAndTarget(vel, vel, true /* inTaintTime */);
449 465
450 DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, RawVelocity); 466 m_log.DebugFormat("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, vel);
451 ForceVelocity = RawVelocity; 467 ForceVelocity = vel;
452 }); 468 });
453 } 469 }
454 } 470 }
471
455 public override OMV.Vector3 ForceVelocity { 472 public override OMV.Vector3 ForceVelocity {
456 get { return RawVelocity; } 473 get { return RawVelocity; }
457 set { 474 set {
458 PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity"); 475 PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity");
476// Util.PrintCallStack();
477 DetailLog("{0}: set ForceVelocity = {1}", LogHeader, value);
459 478
460 RawVelocity = value; 479 RawVelocity = value;
461 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); 480 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity);
462 PhysScene.PE.Activate(PhysBody, true); 481 PhysScene.PE.Activate(PhysBody, true);
463 } 482 }
464 } 483 }
484
465 public override OMV.Vector3 Torque { 485 public override OMV.Vector3 Torque {
466 get { return RawTorque; } 486 get { return RawTorque; }
467 set { RawTorque = value; 487 set { RawTorque = value;
468 } 488 }
469 } 489 }
490
470 public override float CollisionScore { 491 public override float CollisionScore {
471 get { return _collisionScore; } 492 get { return _collisionScore; }
472 set { _collisionScore = value; 493 set { _collisionScore = value;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index f059322..e4d8df8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -228,7 +228,7 @@ public abstract class BSPhysObject : PhysicsActor
228 public virtual OMV.Quaternion RawOrientation { get; set; } 228 public virtual OMV.Quaternion RawOrientation { get; set; }
229 public abstract OMV.Quaternion ForceOrientation { get; set; } 229 public abstract OMV.Quaternion ForceOrientation { get; set; }
230 230
231 public OMV.Vector3 RawVelocity { get; set; } 231 public virtual OMV.Vector3 RawVelocity { get; set; }
232 public abstract OMV.Vector3 ForceVelocity { get; set; } 232 public abstract OMV.Vector3 ForceVelocity { get; set; }
233 233
234 public OMV.Vector3 RawForce { get; set; } 234 public OMV.Vector3 RawForce { get; set; }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 0f79a10..414bc92 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -461,19 +461,19 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
461 461
462 #region Prim and Avatar addition and removal 462 #region Prim and Avatar addition and removal
463 463
464 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 464 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
465 { 465 {
466 m_log.ErrorFormat("{0}: CALL TO AddAvatar in BSScene. NOT IMPLEMENTED", LogHeader); 466 m_log.ErrorFormat("{0}: CALL TO AddAvatar in BSScene. NOT IMPLEMENTED", LogHeader);
467 return null; 467 return null;
468 } 468 }
469 469
470 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying) 470 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
471 { 471 {
472 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName); 472 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
473 473
474 if (!m_initialized) return null; 474 if (!m_initialized) return null;
475 475
476 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying); 476 BSCharacter actor = new BSCharacter(localID, avName, this, position, velocity, size, isFlying);
477 lock (PhysObjects) 477 lock (PhysObjects)
478 PhysObjects.Add(localID, actor); 478 PhysObjects.Add(localID, actor);
479 479
diff --git a/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs b/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs
index 1ccf46d..b52f1f6 100644
--- a/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs
@@ -45,7 +45,8 @@ namespace OpenSim.Region.Physics.Manager
45 // Does nothing right now 45 // Does nothing right now
46 } 46 }
47 47
48 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 48 public override PhysicsActor AddAvatar(
49 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
49 { 50 {
50 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position); 51 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position);
51 return PhysicsActor.Null; 52 return PhysicsActor.Null;
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 71ad795..9cdedbf 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -142,10 +142,12 @@ namespace OpenSim.Region.Physics.Manager
142 /// </summary> 142 /// </summary>
143 /// <param name="avName"></param> 143 /// <param name="avName"></param>
144 /// <param name="position"></param> 144 /// <param name="position"></param>
145 /// <param name="velocity"></param>
145 /// <param name="size"></param> 146 /// <param name="size"></param>
146 /// <param name="isFlying"></param> 147 /// <param name="isFlying"></param>
147 /// <returns></returns> 148 /// <returns></returns>
148 public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); 149 public abstract PhysicsActor AddAvatar(
150 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying);
149 151
150 /// <summary> 152 /// <summary>
151 /// Add an avatar 153 /// Add an avatar
@@ -153,13 +155,18 @@ namespace OpenSim.Region.Physics.Manager
153 /// <param name="localID"></param> 155 /// <param name="localID"></param>
154 /// <param name="avName"></param> 156 /// <param name="avName"></param>
155 /// <param name="position"></param> 157 /// <param name="position"></param>
158 /// <param name="velocity"></param>
156 /// <param name="size"></param> 159 /// <param name="size"></param>
157 /// <param name="isFlying"></param> 160 /// <param name="isFlying"></param>
158 /// <returns></returns> 161 /// <returns></returns>
159 public virtual PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying) 162 public virtual PhysicsActor AddAvatar(
163 uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
160 { 164 {
161 PhysicsActor ret = AddAvatar(avName, position, size, isFlying); 165 PhysicsActor ret = AddAvatar(avName, position, velocity, size, isFlying);
162 if (ret != null) ret.LocalID = localID; 166
167 if (ret != null)
168 ret.LocalID = localID;
169
163 return ret; 170 return ret;
164 } 171 }
165 172
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 67503df..05eaf2a 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -167,6 +167,7 @@ namespace OpenSim.Region.Physics.OdePlugin
167 /// <param name="avName"></param> 167 /// <param name="avName"></param>
168 /// <param name="parent_scene"></param> 168 /// <param name="parent_scene"></param>
169 /// <param name="pos"></param> 169 /// <param name="pos"></param>
170 /// <param name="vel"></param>
170 /// <param name="size"></param> 171 /// <param name="size"></param>
171 /// <param name="pid_d"></param> 172 /// <param name="pid_d"></param>
172 /// <param name="pid_p"></param> 173 /// <param name="pid_p"></param>
@@ -178,7 +179,7 @@ namespace OpenSim.Region.Physics.OdePlugin
178 /// <param name="walk_divisor"></param> 179 /// <param name="walk_divisor"></param>
179 /// <param name="rundivisor"></param> 180 /// <param name="rundivisor"></param>
180 public OdeCharacter( 181 public OdeCharacter(
181 String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, 182 String avName, OdeScene parent_scene, Vector3 pos, Vector3 vel, Vector3 size, float pid_d, float pid_p,
182 float capsule_radius, float tensor, float density, 183 float capsule_radius, float tensor, float density,
183 float walk_divisor, float rundivisor) 184 float walk_divisor, float rundivisor)
184 { 185 {
@@ -210,6 +211,9 @@ namespace OpenSim.Region.Physics.OdePlugin
210 m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName); 211 m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName);
211 } 212 }
212 213
214 _velocity = vel;
215 m_taintTargetVelocity = vel;
216
213 _parent_scene = parent_scene; 217 _parent_scene = parent_scene;
214 218
215 PID_D = pid_d; 219 PID_D = pid_d;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 6d7f079..5953557 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1969,16 +1969,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1969 1969
1970 #region Add/Remove Entities 1970 #region Add/Remove Entities
1971 1971
1972 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 1972 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
1973 { 1973 {
1974 Vector3 pos;
1975 pos.X = position.X;
1976 pos.Y = position.Y;
1977 pos.Z = position.Z;
1978
1979 OdeCharacter newAv 1974 OdeCharacter newAv
1980 = new OdeCharacter( 1975 = new OdeCharacter(
1981 avName, this, pos, size, avPIDD, avPIDP, 1976 avName, this, position, velocity, size, avPIDD, avPIDP,
1982 avCapRadius, avStandupTensor, avDensity, 1977 avCapRadius, avStandupTensor, avDensity,
1983 avMovementDivisorWalk, avMovementDivisorRun); 1978 avMovementDivisorWalk, avMovementDivisorRun);
1984 1979
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
index d30d482..080c6ab 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
@@ -58,7 +58,8 @@ namespace OpenSim.Region.Physics.POSPlugin
58 { 58 {
59 } 59 }
60 60
61 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 61 public override PhysicsActor AddAvatar(
62 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
62 { 63 {
63 POSCharacter act = new POSCharacter(); 64 POSCharacter act = new POSCharacter();
64 act.Position = position; 65 act.Position = position;