diff options
author | Teravus Ovares | 2007-11-14 02:41:15 +0000 |
---|---|---|
committer | Teravus Ovares | 2007-11-14 02:41:15 +0000 |
commit | 52fbc6710078232f7db3a86f2b2820f138c2f3b7 (patch) | |
tree | 881971a7fe86e261be09e1095acb40fff17b2fee /OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |
parent | * Possibly resolved the excess sim lag. (diff) | |
download | opensim-SC-52fbc6710078232f7db3a86f2b2820f138c2f3b7.zip opensim-SC-52fbc6710078232f7db3a86f2b2820f138c2f3b7.tar.gz opensim-SC-52fbc6710078232f7db3a86f2b2820f138c2f3b7.tar.bz2 opensim-SC-52fbc6710078232f7db3a86f2b2820f138c2f3b7.tar.xz |
* Should help avatar climb steps better
* Reduced ground friction when an avatar is moving
* Followed Dan's advice and moved the walk/run movement controller to target_velocity instead of on the total movement
* Reduced PID_D power by 1/5th (80)
* More avatar movement tweaks.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 76 |
1 files changed, 54 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 7eca7ed..472a10b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -89,6 +89,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
89 | private d.ContactGeom[] contacts = new d.ContactGeom[30]; | 89 | private d.ContactGeom[] contacts = new d.ContactGeom[30]; |
90 | private d.Contact contact; | 90 | private d.Contact contact; |
91 | private d.Contact TerrainContact; | 91 | private d.Contact TerrainContact; |
92 | private d.Contact AvatarMovementprimContact; | ||
93 | private d.Contact AvatarMovementTerrainContact; | ||
92 | 94 | ||
93 | private int m_physicsiterations = 10; | 95 | private int m_physicsiterations = 10; |
94 | private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag | 96 | private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag |
@@ -116,11 +118,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
116 | 118 | ||
117 | contact.surface.mu = 250.0f; | 119 | contact.surface.mu = 250.0f; |
118 | contact.surface.bounce = 0.2f; | 120 | contact.surface.bounce = 0.2f; |
121 | |||
119 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; | 122 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; |
120 | TerrainContact.surface.mu = 250.0f; | 123 | TerrainContact.surface.mu = 250.0f; |
121 | TerrainContact.surface.bounce = 0.1f; | 124 | TerrainContact.surface.bounce = 0.1f; |
122 | TerrainContact.surface.soft_erp = 0.1025f; | 125 | TerrainContact.surface.soft_erp = 0.1025f; |
123 | 126 | ||
127 | AvatarMovementprimContact.surface.mu = 150.0f; | ||
128 | AvatarMovementprimContact.surface.bounce = 0.2f; | ||
129 | |||
130 | AvatarMovementTerrainContact.surface.mode |= d.ContactFlags.SoftERP; | ||
131 | AvatarMovementTerrainContact.surface.mu = 150.0f; | ||
132 | AvatarMovementTerrainContact.surface.bounce = 0.1f; | ||
133 | AvatarMovementTerrainContact.surface.soft_erp = 0.1025f; | ||
134 | |||
124 | lock (OdeLock) | 135 | lock (OdeLock) |
125 | { | 136 | { |
126 | world = d.WorldCreate(); | 137 | world = d.WorldCreate(); |
@@ -195,23 +206,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
195 | IntPtr joint; | 206 | IntPtr joint; |
196 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. | 207 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. |
197 | // allows us to have different settings | 208 | // allows us to have different settings |
198 | if (name1 == "Terrain" || name2 == "Terrain") | ||
199 | { | ||
200 | |||
201 | TerrainContact.geom = contacts[i]; | ||
202 | joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); | ||
203 | |||
204 | } | ||
205 | else | ||
206 | { | ||
207 | contact.geom = contacts[i]; | ||
208 | joint = d.JointCreateContact(world, contactgroup, ref contact); | ||
209 | } | ||
210 | |||
211 | |||
212 | d.JointAttach(joint, b1, b2); | ||
213 | |||
214 | |||
215 | PhysicsActor p1; | 209 | PhysicsActor p1; |
216 | PhysicsActor p2; | 210 | PhysicsActor p2; |
217 | 211 | ||
@@ -226,6 +220,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
226 | 220 | ||
227 | // We only need to test p2 for 'jump crouch purposes' | 221 | // We only need to test p2 for 'jump crouch purposes' |
228 | p2.IsColliding = true; | 222 | p2.IsColliding = true; |
223 | |||
229 | switch(p1.PhysicsActorType) { | 224 | switch(p1.PhysicsActorType) { |
230 | case (int)ActorTypes.Agent: | 225 | case (int)ActorTypes.Agent: |
231 | p2.CollidingObj = true; | 226 | p2.CollidingObj = true; |
@@ -237,6 +232,43 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
237 | p2.CollidingGround = true; | 232 | p2.CollidingGround = true; |
238 | break; | 233 | break; |
239 | } | 234 | } |
235 | |||
236 | if (name1 == "Terrain" || name2 == "Terrain") | ||
237 | { | ||
238 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | ||
239 | { | ||
240 | AvatarMovementTerrainContact.geom = contacts[i]; | ||
241 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | TerrainContact.geom = contacts[i]; | ||
246 | joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); | ||
247 | } | ||
248 | |||
249 | |||
250 | } | ||
251 | else | ||
252 | { | ||
253 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | ||
254 | { | ||
255 | AvatarMovementprimContact.geom = contacts[i]; | ||
256 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | contact.geom = contacts[i]; | ||
261 | joint = d.JointCreateContact(world, contactgroup, ref contact); | ||
262 | |||
263 | } | ||
264 | |||
265 | } | ||
266 | |||
267 | |||
268 | d.JointAttach(joint, b1, b2); | ||
269 | |||
270 | |||
271 | |||
240 | if (count > 3) | 272 | if (count > 3) |
241 | { | 273 | { |
242 | p2.ThrottleUpdates = true; | 274 | p2.ThrottleUpdates = true; |
@@ -652,7 +684,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
652 | private PhysicsVector _target_velocity; | 684 | private PhysicsVector _target_velocity; |
653 | private PhysicsVector _acceleration; | 685 | private PhysicsVector _acceleration; |
654 | private PhysicsVector m_rotationalVelocity; | 686 | private PhysicsVector m_rotationalVelocity; |
655 | private static float PID_D = 4000.0f; | 687 | private static float PID_D = 3020.0f; |
656 | private static float PID_P = 7000.0f; | 688 | private static float PID_P = 7000.0f; |
657 | private static float POSTURE_SERVO = 10000.0f; | 689 | private static float POSTURE_SERVO = 10000.0f; |
658 | public static float CAPSULE_RADIUS = 0.5f; | 690 | public static float CAPSULE_RADIUS = 0.5f; |
@@ -955,11 +987,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
955 | 987 | ||
956 | if (!m_alwaysRun) | 988 | if (!m_alwaysRun) |
957 | { | 989 | { |
958 | movementdivisor = 10.5f; | 990 | movementdivisor = 1.3f; |
959 | } | 991 | } |
960 | else | 992 | else |
961 | { | 993 | { |
962 | movementdivisor = 0.2079f; | 994 | movementdivisor = 0.8f; |
963 | 995 | ||
964 | } | 996 | } |
965 | 997 | ||
@@ -987,8 +1019,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
987 | if (m_iscolliding || flying) | 1019 | if (m_iscolliding || flying) |
988 | { | 1020 | { |
989 | 1021 | ||
990 | vec.X = ((_target_velocity.X - vel.X)/movementdivisor) * PID_D; | 1022 | vec.X = ((_target_velocity.X/movementdivisor) - vel.X) * PID_D; |
991 | vec.Y = ((_target_velocity.Y - vel.Y)/movementdivisor) * PID_D; | 1023 | vec.Y = ((_target_velocity.Y/movementdivisor) - vel.Y) * PID_D; |
992 | } | 1024 | } |
993 | if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) | 1025 | if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) |
994 | { | 1026 | { |