diff options
author | Robert Adams | 2016-11-13 11:19:54 -0800 |
---|---|---|
committer | Robert Adams | 2016-11-13 11:19:54 -0800 |
commit | e13ff5a39233fd871e69f9ace23b4559cdfdcb7f (patch) | |
tree | a5e56577bb153a7dd481ee13571fabeb3e716b35 /OpenSim | |
parent | mantis 8055: fix default value of npc options (diff) | |
download | opensim-SC_OLD-e13ff5a39233fd871e69f9ace23b4559cdfdcb7f.zip opensim-SC_OLD-e13ff5a39233fd871e69f9ace23b4559cdfdcb7f.tar.gz opensim-SC_OLD-e13ff5a39233fd871e69f9ace23b4559cdfdcb7f.tar.bz2 opensim-SC_OLD-e13ff5a39233fd871e69f9ace23b4559cdfdcb7f.tar.xz |
BulletSim: update avatar velocity setting to the new TargetVelocity pattern.
Now PhysicsActor.Velocity.set and PhysicsActor.SetMomentum do the same thing
of setting the instantanious avatar velocity. PhysicsActor.TargetVelocity
sets a velocity target and the movement motor is used to accelerate the'
avatar to that velocity.
Diffstat (limited to 'OpenSim')
4 files changed, 47 insertions, 51 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs index 79ee00f..40c6b98 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs | |||
@@ -108,10 +108,6 @@ public class BSActorAvatarMove : BSActor | |||
108 | { | 108 | { |
109 | if (m_velocityMotor != null) | 109 | if (m_velocityMotor != null) |
110 | { | 110 | { |
111 | // if (targ == OMV.Vector3.Zero) | ||
112 | // Util.PrintCallStack(); | ||
113 | // | ||
114 | // Console.WriteLine("SetVelocityAndTarget, {0} {1}", vel, targ); | ||
115 | m_velocityMotor.Reset(); | 111 | m_velocityMotor.Reset(); |
116 | m_velocityMotor.SetTarget(targ); | 112 | m_velocityMotor.SetTarget(targ); |
117 | m_velocityMotor.SetCurrent(vel); | 113 | m_velocityMotor.SetCurrent(vel); |
@@ -128,7 +124,7 @@ public class BSActorAvatarMove : BSActor | |||
128 | m_waitingForLowVelocityForStationary = true; | 124 | m_waitingForLowVelocityForStationary = true; |
129 | } | 125 | } |
130 | 126 | ||
131 | // If a movement motor has not been created, create one and start the hovering. | 127 | // If a movement motor has not been created, create one and start the movement |
132 | private void ActivateAvatarMove() | 128 | private void ActivateAvatarMove() |
133 | { | 129 | { |
134 | if (m_velocityMotor == null) | 130 | if (m_velocityMotor == null) |
@@ -161,7 +157,7 @@ public class BSActorAvatarMove : BSActor | |||
161 | } | 157 | } |
162 | } | 158 | } |
163 | 159 | ||
164 | // Called just before the simulation step. Update the vertical position for hoverness. | 160 | // Called just before the simulation step. |
165 | private void Mover(float timeStep) | 161 | private void Mover(float timeStep) |
166 | { | 162 | { |
167 | // Don't do movement while the object is selected. | 163 | // Don't do movement while the object is selected. |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs index 757f06c..6322695 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs | |||
@@ -449,6 +449,7 @@ public sealed class BSCharacter : BSPhysObject | |||
449 | public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } } | 449 | public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } } |
450 | public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } | 450 | public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } |
451 | 451 | ||
452 | // PhysicsActor.TargetVelocity | ||
452 | // Sets the target in the motor. This starts the changing of the avatar's velocity. | 453 | // Sets the target in the motor. This starts the changing of the avatar's velocity. |
453 | public override OMV.Vector3 TargetVelocity | 454 | public override OMV.Vector3 TargetVelocity |
454 | { | 455 | { |
@@ -459,7 +460,7 @@ public sealed class BSCharacter : BSPhysObject | |||
459 | set | 460 | set |
460 | { | 461 | { |
461 | DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value); | 462 | DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value); |
462 | m_targetVelocity = value; | 463 | base.m_targetVelocity = value; |
463 | OMV.Vector3 targetVel = value; | 464 | OMV.Vector3 targetVel = value; |
464 | if (_setAlwaysRun && !_flying) | 465 | if (_setAlwaysRun && !_flying) |
465 | targetVel *= new OMV.Vector3(BSParam.AvatarAlwaysRunFactor, BSParam.AvatarAlwaysRunFactor, 1f); | 466 | targetVel *= new OMV.Vector3(BSParam.AvatarAlwaysRunFactor, BSParam.AvatarAlwaysRunFactor, 1f); |
@@ -472,46 +473,38 @@ public sealed class BSCharacter : BSPhysObject | |||
472 | public override OMV.Vector3 Velocity { | 473 | public override OMV.Vector3 Velocity { |
473 | get { return RawVelocity; } | 474 | get { return RawVelocity; } |
474 | set { | 475 | set { |
475 | RawVelocity = value; | 476 | if (m_moveActor != null) |
476 | OMV.Vector3 vel = RawVelocity; | ||
477 | |||
478 | DetailLog("{0}: set Velocity = {1}", LocalID, value); | ||
479 | |||
480 | PhysScene.TaintedObject(LocalID, "BSCharacter.setVelocity", delegate() | ||
481 | { | 477 | { |
482 | if (m_moveActor != null) | 478 | // m_moveActor.SetVelocityAndTarget(OMV.Vector3.Zero, OMV.Vector3.Zero, false /* inTaintTime */); |
483 | m_moveActor.SetVelocityAndTarget(vel, vel, true /* inTaintTime */); | 479 | m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false /* inTaintTime */); |
480 | } | ||
481 | base.Velocity = value; | ||
482 | } | ||
483 | } | ||
484 | 484 | ||
485 | DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, vel); | 485 | // SetMomentum just sets the velocity without a target. We need to stop the movement actor if a character. |
486 | ForceVelocity = vel; | 486 | public override void SetMomentum(OMV.Vector3 momentum) |
487 | }); | 487 | { |
488 | if (m_moveActor != null) | ||
489 | { | ||
490 | // m_moveActor.SetVelocityAndTarget(OMV.Vector3.Zero, OMV.Vector3.Zero, false /* inTaintTime */); | ||
491 | m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false /* inTaintTime */); | ||
488 | } | 492 | } |
493 | base.SetMomentum(momentum); | ||
489 | } | 494 | } |
490 | 495 | ||
491 | public override OMV.Vector3 ForceVelocity { | 496 | public override OMV.Vector3 ForceVelocity { |
492 | get { return RawVelocity; } | 497 | get { return RawVelocity; } |
493 | set { | 498 | set { |
494 | PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity"); | 499 | PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity"); |
495 | // Util.PrintCallStack(); | 500 | DetailLog("{0}: BSCharacter.ForceVelocity.set = {1}", LocalID, value); |
496 | DetailLog("{0}: set ForceVelocity = {1}", LocalID, value); | ||
497 | 501 | ||
498 | RawVelocity = value; | 502 | RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); |
499 | PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); | 503 | PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); |
500 | PhysScene.PE.Activate(PhysBody, true); | 504 | PhysScene.PE.Activate(PhysBody, true); |
501 | } | 505 | } |
502 | } | 506 | } |
503 | 507 | ||
504 | // SetMomentum just sets the velocity without a target. We need to stop the movement actor if a character. | ||
505 | public override void SetMomentum(OMV.Vector3 momentum) | ||
506 | { | ||
507 | if (m_moveActor != null) | ||
508 | { | ||
509 | m_moveActor.SetVelocityAndTarget(OMV.Vector3.Zero, OMV.Vector3.Zero, false /* inTaintTime */); | ||
510 | } | ||
511 | base.SetMomentum(momentum); | ||
512 | } | ||
513 | |||
514 | |||
515 | public override OMV.Vector3 Torque { | 508 | public override OMV.Vector3 Torque { |
516 | get { return RawTorque; } | 509 | get { return RawTorque; } |
517 | set { RawTorque = value; | 510 | set { RawTorque = value; |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs index 3682455..a846869 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs | |||
@@ -230,15 +230,22 @@ public abstract class BSPhysObject : PhysicsActor | |||
230 | // Update the physical location and motion of the object. Called with data from Bullet. | 230 | // Update the physical location and motion of the object. Called with data from Bullet. |
231 | public abstract void UpdateProperties(EntityProperties entprop); | 231 | public abstract void UpdateProperties(EntityProperties entprop); |
232 | 232 | ||
233 | // The position value as known by BulletSim. Does not effect the physics engine. | ||
233 | public virtual OMV.Vector3 RawPosition { get; set; } | 234 | public virtual OMV.Vector3 RawPosition { get; set; } |
235 | // Set position in BulletSim and the physics engined to a value immediately. Must be called at taint time. | ||
234 | public abstract OMV.Vector3 ForcePosition { get; set; } | 236 | public abstract OMV.Vector3 ForcePosition { get; set; } |
235 | 237 | ||
238 | // The orientation value as known by BulletSim. Does not effect the physics engine. | ||
236 | public virtual OMV.Quaternion RawOrientation { get; set; } | 239 | public virtual OMV.Quaternion RawOrientation { get; set; } |
240 | // Set orientation in BulletSim and the physics engine to a value immediately. Must be called at taint time. | ||
237 | public abstract OMV.Quaternion ForceOrientation { get; set; } | 241 | public abstract OMV.Quaternion ForceOrientation { get; set; } |
238 | 242 | ||
243 | // The velocity value as known by BulletSim. Does not effect the physics engine. | ||
239 | public virtual OMV.Vector3 RawVelocity { get; set; } | 244 | public virtual OMV.Vector3 RawVelocity { get; set; } |
245 | // Set velocity in BulletSim and the physics engined to a value immediately. Must be called at taint time. | ||
240 | public abstract OMV.Vector3 ForceVelocity { get; set; } | 246 | public abstract OMV.Vector3 ForceVelocity { get; set; } |
241 | 247 | ||
248 | // The rotational velocity value as known by BulletSim. Does not effect the physics engine. | ||
242 | public OMV.Vector3 RawRotationalVelocity { get; set; } | 249 | public OMV.Vector3 RawRotationalVelocity { get; set; } |
243 | 250 | ||
244 | // RawForce is a constant force applied to object (see Force { set; } ) | 251 | // RawForce is a constant force applied to object (see Force { set; } ) |
@@ -252,17 +259,28 @@ public abstract class BSPhysObject : PhysicsActor | |||
252 | public abstract void AddAngularForce(bool inTaintTime, OMV.Vector3 force); | 259 | public abstract void AddAngularForce(bool inTaintTime, OMV.Vector3 force); |
253 | public abstract void AddForce(bool inTaintTime, OMV.Vector3 force); | 260 | public abstract void AddForce(bool inTaintTime, OMV.Vector3 force); |
254 | 261 | ||
262 | // PhysicsActor.Velocity | ||
263 | public override OMV.Vector3 Velocity | ||
264 | { | ||
265 | get { return RawVelocity; } | ||
266 | set | ||
267 | { | ||
268 | // This sets the velocity now. BSCharacter will override to clear target velocity | ||
269 | // before calling this. | ||
270 | RawVelocity = value; | ||
271 | PhysScene.TaintedObject(LocalID, TypeName + ".SetVelocity", delegate () { | ||
272 | // DetailLog("{0},BSPhysObject.Velocity.set,vel={1}", LocalID, RawVelocity); | ||
273 | ForceVelocity = RawVelocity; | ||
274 | }); | ||
275 | } | ||
276 | } | ||
277 | |||
255 | // PhysicsActor.SetMomentum | 278 | // PhysicsActor.SetMomentum |
256 | // All the physics engined use this as a way of forcing the velocity to something. | 279 | // All the physics engines use this as a way of forcing the velocity to something. |
280 | // BSCharacter overrides this so it can set the target velocity to zero before calling this. | ||
257 | public override void SetMomentum(OMV.Vector3 momentum) | 281 | public override void SetMomentum(OMV.Vector3 momentum) |
258 | { | 282 | { |
259 | // This doesn't just set Velocity=momentum because velocity is ramped up to (see MoveActor) | 283 | this.Velocity = momentum; |
260 | RawVelocity = momentum; | ||
261 | PhysScene.TaintedObject(LocalID, TypeName + ".SetMomentum", delegate() | ||
262 | { | ||
263 | // DetailLog("{0},BSPrim.SetMomentum,taint,vel={1}", LocalID, RawVelocity); | ||
264 | ForceVelocity = RawVelocity; | ||
265 | }); | ||
266 | } | 284 | } |
267 | 285 | ||
268 | public override OMV.Vector3 RotationalVelocity { | 286 | public override OMV.Vector3 RotationalVelocity { |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs index 78a617d..db2b9db 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs | |||
@@ -787,17 +787,6 @@ public class BSPrim : BSPhysObject | |||
787 | } | 787 | } |
788 | } | 788 | } |
789 | } | 789 | } |
790 | public override OMV.Vector3 Velocity { | ||
791 | get { return RawVelocity; } | ||
792 | set { | ||
793 | RawVelocity = value; | ||
794 | PhysScene.TaintedObject(LocalID, "BSPrim.setVelocity", delegate() | ||
795 | { | ||
796 | // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); | ||
797 | ForceVelocity = RawVelocity; | ||
798 | }); | ||
799 | } | ||
800 | } | ||
801 | public override OMV.Vector3 ForceVelocity { | 790 | public override OMV.Vector3 ForceVelocity { |
802 | get { return RawVelocity; } | 791 | get { return RawVelocity; } |
803 | set { | 792 | set { |