diff options
author | Charles Krinke | 2007-10-31 04:18:34 +0000 |
---|---|---|
committer | Charles Krinke | 2007-10-31 04:18:34 +0000 |
commit | 33d6222e8dc40331e98c3549a040d3d206eed338 (patch) | |
tree | d5481827758cdfc7a9f44faf016706ed75bd9ca4 /OpenSim/Region | |
parent | set svn:eol-style (diff) | |
download | opensim-SC_OLD-33d6222e8dc40331e98c3549a040d3d206eed338.zip opensim-SC_OLD-33d6222e8dc40331e98c3549a040d3d206eed338.tar.gz opensim-SC_OLD-33d6222e8dc40331e98c3549a040d3d206eed338.tar.bz2 opensim-SC_OLD-33d6222e8dc40331e98c3549a040d3d206eed338.tar.xz |
Thank you Teravus, very much, for a 'jump', 'crouch' and 'inertia' patch for all three physics plugins.
Diffstat (limited to '')
6 files changed, 177 insertions, 43 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 3b73893..b9c723b 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -613,12 +613,27 @@ namespace OpenSim.Region.Environment.Scenes | |||
613 | } | 613 | } |
614 | else | 614 | else |
615 | { | 615 | { |
616 | SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); | 616 | if (((m_movementflag & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) |
617 | { | ||
618 | SendAnimPack(Animations.AnimsLLUUID["CROUCHWALK"], 1); | ||
619 | } | ||
620 | else | ||
621 | { | ||
622 | SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); | ||
623 | } | ||
624 | |||
617 | } | 625 | } |
618 | } | 626 | } |
619 | else | 627 | else |
620 | { | 628 | { |
621 | SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); | 629 | if (((m_movementflag & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) |
630 | { | ||
631 | SendAnimPack(Animations.AnimsLLUUID["CROUCH"], 1); | ||
632 | } | ||
633 | else | ||
634 | { | ||
635 | SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); | ||
636 | } | ||
622 | } | 637 | } |
623 | } | 638 | } |
624 | } | 639 | } |
@@ -638,7 +653,21 @@ namespace OpenSim.Region.Environment.Scenes | |||
638 | 653 | ||
639 | direc = direc*((0.03f)*128f); | 654 | direc = direc*((0.03f)*128f); |
640 | if (m_physicsActor.Flying) | 655 | if (m_physicsActor.Flying) |
641 | direc *= 4; | 656 | { direc *= 4; } |
657 | else | ||
658 | { | ||
659 | if (!m_physicsActor.Flying && m_physicsActor.IsColliding) | ||
660 | { | ||
661 | //direc.z *= 40; | ||
662 | if (direc.z > 2.0f) | ||
663 | { | ||
664 | direc.z *= 3; | ||
665 | //System.Console.WriteLine("Jump"); | ||
666 | SendAnimPack(Animations.AnimsLLUUID["PRE_JUMP"], 1); | ||
667 | } | ||
668 | |||
669 | } | ||
670 | } | ||
642 | 671 | ||
643 | newVelocity.X = direc.x; | 672 | newVelocity.X = direc.x; |
644 | newVelocity.Y = direc.y; | 673 | newVelocity.Y = direc.y; |
@@ -867,7 +896,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
867 | 896 | ||
868 | protected void CheckForSignificantMovement() | 897 | protected void CheckForSignificantMovement() |
869 | { | 898 | { |
870 | if (AbsolutePosition.GetDistanceTo(posLastSignificantMove) > 2.0) | 899 | if (AbsolutePosition.GetDistanceTo(posLastSignificantMove) > 0.02) |
871 | { | 900 | { |
872 | posLastSignificantMove = AbsolutePosition; | 901 | posLastSignificantMove = AbsolutePosition; |
873 | if (OnSignificantClientMovement != null) | 902 | if (OnSignificantClientMovement != null) |
@@ -982,6 +1011,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
982 | NewForce force = m_forcesList[i]; | 1011 | NewForce force = m_forcesList[i]; |
983 | 1012 | ||
984 | m_updateflag = true; | 1013 | m_updateflag = true; |
1014 | |||
1015 | |||
985 | Velocity = new LLVector3(force.X, force.Y, force.Z); | 1016 | Velocity = new LLVector3(force.X, force.Y, force.Z); |
986 | m_newForce = true; | 1017 | m_newForce = true; |
987 | } | 1018 | } |
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index b412818..c516044 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | |||
@@ -177,6 +177,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
177 | private PhysicsVector _velocity; | 177 | private PhysicsVector _velocity; |
178 | private PhysicsVector _acceleration; | 178 | private PhysicsVector _acceleration; |
179 | private bool flying; | 179 | private bool flying; |
180 | private bool iscolliding; | ||
180 | 181 | ||
181 | public BasicActor() | 182 | public BasicActor() |
182 | { | 183 | { |
@@ -191,6 +192,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
191 | set { flying = value; } | 192 | set { flying = value; } |
192 | } | 193 | } |
193 | 194 | ||
195 | public override bool IsColliding | ||
196 | { | ||
197 | get { return iscolliding; } | ||
198 | set { iscolliding = value; } | ||
199 | } | ||
200 | |||
194 | public override PhysicsVector Position | 201 | public override PhysicsVector Position |
195 | { | 202 | { |
196 | get { return _position; } | 203 | get { return _position; } |
@@ -239,4 +246,4 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
239 | { | 246 | { |
240 | } | 247 | } |
241 | } | 248 | } |
242 | } \ No newline at end of file | 249 | } |
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 1658e2d..8b05295 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -643,6 +643,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
643 | private PhysicsVector _acceleration; | 643 | private PhysicsVector _acceleration; |
644 | private AxiomQuaternion _orientation; | 644 | private AxiomQuaternion _orientation; |
645 | private bool flying; | 645 | private bool flying; |
646 | private bool iscolliding = false; | ||
646 | private RigidBody rigidBody; | 647 | private RigidBody rigidBody; |
647 | 648 | ||
648 | public Vector3 RigidBodyPosition | 649 | public Vector3 RigidBodyPosition |
@@ -773,6 +774,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
773 | get { return flying; } | 774 | get { return flying; } |
774 | set { flying = value; } | 775 | set { flying = value; } |
775 | } | 776 | } |
777 | public override bool IsColliding | ||
778 | { | ||
779 | get { return iscolliding; } | ||
780 | set { iscolliding = value; } | ||
781 | } | ||
776 | 782 | ||
777 | public void SetAcceleration(PhysicsVector accel) | 783 | public void SetAcceleration(PhysicsVector accel) |
778 | { | 784 | { |
@@ -913,6 +919,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
913 | private BulletXScene _parent_scene; | 919 | private BulletXScene _parent_scene; |
914 | //_physical value will be linked with the prim object value | 920 | //_physical value will be linked with the prim object value |
915 | private Boolean _physical = false; | 921 | private Boolean _physical = false; |
922 | private Boolean iscolliding = false; | ||
916 | 923 | ||
917 | public Vector3 RigidBodyPosition | 924 | public Vector3 RigidBodyPosition |
918 | { | 925 | { |
@@ -1060,6 +1067,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
1060 | set { } | 1067 | set { } |
1061 | } | 1068 | } |
1062 | 1069 | ||
1070 | public override bool IsColliding | ||
1071 | { | ||
1072 | get { return iscolliding; } | ||
1073 | set { iscolliding = value; } | ||
1074 | } | ||
1063 | public Boolean Physical | 1075 | public Boolean Physical |
1064 | { | 1076 | { |
1065 | get { return _physical; } | 1077 | get { return _physical; } |
@@ -1304,4 +1316,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
1304 | return height; | 1316 | return height; |
1305 | } | 1317 | } |
1306 | } | 1318 | } |
1307 | } \ No newline at end of file | 1319 | } |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index b59c13a..74608ef 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -59,6 +59,8 @@ namespace OpenSim.Region.Physics.Manager | |||
59 | public abstract Quaternion Orientation { get; set; } | 59 | public abstract Quaternion Orientation { get; set; } |
60 | 60 | ||
61 | public abstract bool Flying { get; set; } | 61 | public abstract bool Flying { get; set; } |
62 | |||
63 | public abstract bool IsColliding { get; set; } | ||
62 | 64 | ||
63 | public abstract bool Kinematic { get; set; } | 65 | public abstract bool Kinematic { get; set; } |
64 | 66 | ||
@@ -103,6 +105,11 @@ namespace OpenSim.Region.Physics.Manager | |||
103 | get { return false; } | 105 | get { return false; } |
104 | set { return; } | 106 | set { return; } |
105 | } | 107 | } |
108 | public override bool IsColliding | ||
109 | { | ||
110 | get { return false; } | ||
111 | set { return; } | ||
112 | } | ||
106 | 113 | ||
107 | public override bool Kinematic | 114 | public override bool Kinematic |
108 | { | 115 | { |
@@ -120,4 +127,4 @@ namespace OpenSim.Region.Physics.Manager | |||
120 | return; | 127 | return; |
121 | } | 128 | } |
122 | } | 129 | } |
123 | } \ No newline at end of file | 130 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 27c3a6a..4afe784 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -83,8 +83,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
83 | private List<OdeCharacter> _characters = new List<OdeCharacter>(); | 83 | private List<OdeCharacter> _characters = new List<OdeCharacter>(); |
84 | private List<OdePrim> _prims = new List<OdePrim>(); | 84 | private List<OdePrim> _prims = new List<OdePrim>(); |
85 | public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); | 85 | public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); |
86 | public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); | ||
86 | private d.ContactGeom[] contacts = new d.ContactGeom[30]; | 87 | private d.ContactGeom[] contacts = new d.ContactGeom[30]; |
87 | private d.Contact contact; | 88 | private d.Contact contact; |
89 | private PhysicsActor PANull = new NullPhysicsActor(); | ||
88 | private float step_time = 0.0f; | 90 | private float step_time = 0.0f; |
89 | public IntPtr world; | 91 | public IntPtr world; |
90 | public IntPtr space; | 92 | public IntPtr space; |
@@ -117,36 +119,33 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
117 | } | 119 | } |
118 | 120 | ||
119 | _heightmap = new double[258*258]; | 121 | _heightmap = new double[258*258]; |
122 | |||
120 | } | 123 | } |
121 | 124 | ||
122 | // This function blatantly ripped off from BoxStack.cs | 125 | // This function blatantly ripped off from BoxStack.cs |
123 | private void near(IntPtr space, IntPtr g1, IntPtr g2) | 126 | private void near(IntPtr space, IntPtr g1, IntPtr g2) |
124 | { | 127 | { |
125 | // no lock here! It's invoked from within Simulate(), which is thread-locked | 128 | // no lock here! It's invoked from within Simulate(), which is thread-locked |
129 | IntPtr b1 = d.GeomGetBody(g1); | ||
130 | IntPtr b2 = d.GeomGetBody(g2); | ||
131 | |||
132 | |||
126 | if (g1 == g2) | 133 | if (g1 == g2) |
127 | return; // Can't collide with yourself | 134 | return; // Can't collide with yourself |
135 | |||
128 | 136 | ||
129 | IntPtr b1 = d.GeomGetBody(g1); | ||
130 | IntPtr b2 = d.GeomGetBody(g2); | ||
131 | 137 | ||
132 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | 138 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) |
133 | return; | 139 | return; |
134 | 140 | ||
141 | |||
135 | d.GeomClassID id = d.GeomGetClass(g1); | 142 | d.GeomClassID id = d.GeomGetClass(g1); |
136 | if (id == d.GeomClassID.TriMeshClass) | 143 | if (id == d.GeomClassID.TriMeshClass) |
137 | { | 144 | { |
138 | String name1 = null; | 145 | |
139 | String name2 = null; | ||
140 | if (!geom_name_map.TryGetValue(g1, out name1)) | ||
141 | { | ||
142 | name1 = "null"; | ||
143 | } | ||
144 | if (!geom_name_map.TryGetValue(g2, out name2)) | ||
145 | { | ||
146 | name2 = "null"; | ||
147 | } | ||
148 | 146 | ||
149 | // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); | 147 | // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); |
148 | //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); | ||
150 | } | 149 | } |
151 | 150 | ||
152 | int count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); | 151 | int count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); |
@@ -155,6 +154,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
155 | contact.geom = contacts[i]; | 154 | contact.geom = contacts[i]; |
156 | IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); | 155 | IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); |
157 | d.JointAttach(joint, b1, b2); | 156 | d.JointAttach(joint, b1, b2); |
157 | PhysicsActor p1; | ||
158 | PhysicsActor p2; | ||
159 | |||
160 | |||
161 | if (!actor_name_map.TryGetValue(g1, out p1)) | ||
162 | { | ||
163 | p1 = PANull; | ||
164 | } | ||
165 | if (!actor_name_map.TryGetValue(g2, out p2)) | ||
166 | { | ||
167 | p2 = PANull; | ||
168 | } | ||
169 | |||
170 | p1.IsColliding = true; | ||
171 | p2.IsColliding = true; | ||
172 | //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); | ||
158 | } | 173 | } |
159 | } | 174 | } |
160 | 175 | ||
@@ -162,10 +177,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
162 | { | 177 | { |
163 | foreach (OdeCharacter chr in _characters) | 178 | foreach (OdeCharacter chr in _characters) |
164 | { | 179 | { |
180 | chr.IsColliding = false; | ||
181 | } | ||
182 | foreach (OdeCharacter chr in _characters) | ||
183 | { | ||
184 | |||
185 | |||
186 | |||
165 | d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); | 187 | d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); |
166 | foreach (OdeCharacter ch2 in _characters) | 188 | foreach (OdeCharacter ch2 in _characters) |
167 | /// should be a separate space -- lots of avatars will be N**2 slow | 189 | /// should be a separate space -- lots of avatars will be N**2 slow |
168 | { | 190 | { |
191 | |||
192 | |||
169 | d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback); | 193 | d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback); |
170 | } | 194 | } |
171 | } | 195 | } |
@@ -333,8 +357,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
333 | { | 357 | { |
334 | foreach (OdeCharacter actor in _characters) | 358 | foreach (OdeCharacter actor in _characters) |
335 | { | 359 | { |
336 | actor.Move(timeStep); | 360 | actor.Move(timeStep); |
337 | } | 361 | } |
362 | |||
338 | collision_optimized(); | 363 | collision_optimized(); |
339 | d.WorldQuickStep(world, ODE_STEPSIZE); | 364 | d.WorldQuickStep(world, ODE_STEPSIZE); |
340 | d.JointGroupEmpty(contactgroup); | 365 | d.JointGroupEmpty(contactgroup); |
@@ -457,6 +482,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
457 | public static float CAPSULE_RADIUS = 0.5f; | 482 | public static float CAPSULE_RADIUS = 0.5f; |
458 | public static float CAPSULE_LENGTH = 0.9f; | 483 | public static float CAPSULE_LENGTH = 0.9f; |
459 | private bool flying = false; | 484 | private bool flying = false; |
485 | private bool iscolliding = false; | ||
486 | private bool jumping = false; | ||
460 | //private float gravityAccel; | 487 | //private float gravityAccel; |
461 | public IntPtr Body; | 488 | public IntPtr Body; |
462 | private OdeScene _parent_scene; | 489 | private OdeScene _parent_scene; |
@@ -480,6 +507,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
480 | d.GeomSetBody(Shell, Body); | 507 | d.GeomSetBody(Shell, Body); |
481 | } | 508 | } |
482 | parent_scene.geom_name_map[Shell] = avName; | 509 | parent_scene.geom_name_map[Shell] = avName; |
510 | parent_scene.actor_name_map[Shell] = (PhysicsActor)this; | ||
483 | } | 511 | } |
484 | 512 | ||
485 | public override bool Flying | 513 | public override bool Flying |
@@ -487,7 +515,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
487 | get { return flying; } | 515 | get { return flying; } |
488 | set { flying = value; } | 516 | set { flying = value; } |
489 | } | 517 | } |
490 | 518 | public override bool IsColliding | |
519 | { | ||
520 | get { return iscolliding; } | ||
521 | set | ||
522 | {iscolliding = value;} | ||
523 | } | ||
491 | public override PhysicsVector Position | 524 | public override PhysicsVector Position |
492 | { | 525 | { |
493 | get { return _position; } | 526 | get { return _position; } |
@@ -538,12 +571,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
538 | 571 | ||
539 | public override void AddForce(PhysicsVector force) | 572 | public override void AddForce(PhysicsVector force) |
540 | { | 573 | { |
574 | |||
575 | _target_velocity.X += force.X; | ||
576 | _target_velocity.Y += force.Y; | ||
577 | _target_velocity.Z += force.Z; | ||
578 | |||
579 | |||
541 | } | 580 | } |
581 | public void doForce(PhysicsVector force) | ||
582 | { | ||
583 | d.BodyAddForce(Body, force.X, force.Y, force.Z); | ||
584 | |||
585 | // ok -- let's stand up straight! | ||
586 | d.Vector3 feet; | ||
587 | d.Vector3 head; | ||
588 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet); | ||
589 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head); | ||
590 | float posture = head.Z - feet.Z; | ||
542 | 591 | ||
592 | // restoring force proportional to lack of posture: | ||
593 | float servo = (2.5f - posture) * POSTURE_SERVO; | ||
594 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); | ||
595 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); | ||
596 | |||
597 | } | ||
543 | public override void SetMomentum(PhysicsVector momentum) | 598 | public override void SetMomentum(PhysicsVector momentum) |
544 | { | 599 | { |
545 | } | ||
546 | 600 | ||
601 | } | ||
602 | |||
547 | public void Move(float timeStep) | 603 | public void Move(float timeStep) |
548 | { | 604 | { |
549 | // no lock; for now it's only called from within Simulate() | 605 | // no lock; for now it's only called from within Simulate() |
@@ -551,7 +607,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
551 | d.Vector3 vel = d.BodyGetLinearVel(Body); | 607 | d.Vector3 vel = d.BodyGetLinearVel(Body); |
552 | 608 | ||
553 | // if velocity is zero, use position control; otherwise, velocity control | 609 | // if velocity is zero, use position control; otherwise, velocity control |
554 | if (_target_velocity.X == 0.0f & _target_velocity.Y == 0.0f & _target_velocity.Z == 0.0f) | 610 | if (_target_velocity.X == 0.0f & _target_velocity.Y == 0.0f & _target_velocity.Z == 0.0f & iscolliding) |
555 | { | 611 | { |
556 | // keep track of where we stopped. No more slippin' & slidin' | 612 | // keep track of where we stopped. No more slippin' & slidin' |
557 | if (!_zeroFlag) | 613 | if (!_zeroFlag) |
@@ -569,9 +625,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
569 | } | 625 | } |
570 | else | 626 | else |
571 | { | 627 | { |
628 | |||
572 | _zeroFlag = false; | 629 | _zeroFlag = false; |
573 | vec.X = (_target_velocity.X - vel.X)*PID_D; | 630 | if (iscolliding || flying) |
574 | vec.Y = (_target_velocity.Y - vel.Y)*PID_D; | 631 | { |
632 | vec.X = (_target_velocity.X - vel.X) * PID_D; | ||
633 | vec.Y = (_target_velocity.Y - vel.Y) * PID_D; | ||
634 | } | ||
635 | if (iscolliding && !flying && _target_velocity.Z > 0.0f) | ||
636 | { | ||
637 | d.Vector3 pos = d.BodyGetPosition(Body); | ||
638 | vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; | ||
639 | } | ||
640 | |||
575 | if (flying) | 641 | if (flying) |
576 | { | 642 | { |
577 | vec.Z = (_target_velocity.Z - vel.Z)*PID_D; | 643 | vec.Z = (_target_velocity.Z - vel.Z)*PID_D; |
@@ -581,19 +647,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
581 | { | 647 | { |
582 | vec.Z += 10.0f; | 648 | vec.Z += 10.0f; |
583 | } | 649 | } |
584 | d.BodyAddForce(Body, vec.X, vec.Y, vec.Z); | 650 | doForce(vec); |
585 | |||
586 | // ok -- let's stand up straight! | ||
587 | d.Vector3 feet; | ||
588 | d.Vector3 head; | ||
589 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet); | ||
590 | d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head); | ||
591 | float posture = head.Z - feet.Z; | ||
592 | |||
593 | // restoring force proportional to lack of posture: | ||
594 | float servo = (2.5f - posture)*POSTURE_SERVO; | ||
595 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); | ||
596 | d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); | ||
597 | } | 651 | } |
598 | 652 | ||
599 | public void UpdatePositionAndVelocity() | 653 | public void UpdatePositionAndVelocity() |
@@ -649,6 +703,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
649 | private OdeScene _parent_scene; | 703 | private OdeScene _parent_scene; |
650 | public IntPtr prim_geom; | 704 | public IntPtr prim_geom; |
651 | public IntPtr _triMeshData; | 705 | public IntPtr _triMeshData; |
706 | private bool iscolliding = false; | ||
652 | 707 | ||
653 | public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, | 708 | public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, |
654 | Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) | 709 | Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) |
@@ -661,6 +716,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
661 | _mesh = mesh; | 716 | _mesh = mesh; |
662 | _pbs = pbs; | 717 | _pbs = pbs; |
663 | _parent_scene = parent_scene; | 718 | _parent_scene = parent_scene; |
719 | |||
664 | 720 | ||
665 | lock (OdeScene.OdeLock) | 721 | lock (OdeScene.OdeLock) |
666 | { | 722 | { |
@@ -681,6 +737,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
681 | myrot.Z = rotation.z; | 737 | myrot.Z = rotation.z; |
682 | d.GeomSetQuaternion(prim_geom, ref myrot); | 738 | d.GeomSetQuaternion(prim_geom, ref myrot); |
683 | parent_scene.geom_name_map[prim_geom] = primName; | 739 | parent_scene.geom_name_map[prim_geom] = primName; |
740 | parent_scene.actor_name_map[prim_geom] = (PhysicsActor) this; | ||
684 | // don't do .add() here; old geoms get recycled with the same hash | 741 | // don't do .add() here; old geoms get recycled with the same hash |
685 | } | 742 | } |
686 | } | 743 | } |
@@ -708,6 +765,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
708 | set { } | 765 | set { } |
709 | } | 766 | } |
710 | 767 | ||
768 | public override bool IsColliding | ||
769 | { | ||
770 | get { return iscolliding; } | ||
771 | set { iscolliding = value; } | ||
772 | } | ||
773 | |||
774 | |||
711 | public override PhysicsVector Position | 775 | public override PhysicsVector Position |
712 | { | 776 | { |
713 | get { return _position; } | 777 | get { return _position; } |
@@ -793,4 +857,4 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
793 | { | 857 | { |
794 | } | 858 | } |
795 | } | 859 | } |
796 | } \ No newline at end of file | 860 | } |
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 4896359..cad66d7 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | |||
@@ -182,6 +182,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
182 | private PhysicsVector _acceleration; | 182 | private PhysicsVector _acceleration; |
183 | private NxCharacter _character; | 183 | private NxCharacter _character; |
184 | private bool flying; | 184 | private bool flying; |
185 | private bool iscolliding = false; | ||
185 | private float gravityAccel; | 186 | private float gravityAccel; |
186 | 187 | ||
187 | public PhysXCharacter(NxCharacter character) | 188 | public PhysXCharacter(NxCharacter character) |
@@ -197,6 +198,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
197 | get { return flying; } | 198 | get { return flying; } |
198 | set { flying = value; } | 199 | set { flying = value; } |
199 | } | 200 | } |
201 | public override bool IsColliding | ||
202 | { | ||
203 | get { return iscolliding; } | ||
204 | set { iscolliding = value; } | ||
205 | } | ||
200 | 206 | ||
201 | public override PhysicsVector Position | 207 | public override PhysicsVector Position |
202 | { | 208 | { |
@@ -305,7 +311,14 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
305 | } | 311 | } |
306 | set { } | 312 | set { } |
307 | } | 313 | } |
308 | 314 | public override bool IsColliding | |
315 | { | ||
316 | get | ||
317 | { | ||
318 | return false; //no flying prims for you | ||
319 | } | ||
320 | set { } | ||
321 | } | ||
309 | public override PhysicsVector Position | 322 | public override PhysicsVector Position |
310 | { | 323 | { |
311 | get | 324 | get |
@@ -379,4 +392,4 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
379 | { | 392 | { |
380 | } | 393 | } |
381 | } | 394 | } |
382 | } \ No newline at end of file | 395 | } |