aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorKitto Flora2010-09-02 21:51:19 +0000
committerKitto Flora2010-09-02 21:51:19 +0000
commit16814dd8f18b51f5dd8841ae341847e117bb83b3 (patch)
tree46f1322936eb959292a320636c4a6f27be379d9e /OpenSim/Region
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
downloadopensim-SC-16814dd8f18b51f5dd8841ae341847e117bb83b3.zip
opensim-SC-16814dd8f18b51f5dd8841ae341847e117bb83b3.tar.gz
opensim-SC-16814dd8f18b51f5dd8841ae341847e117bb83b3.tar.bz2
opensim-SC-16814dd8f18b51f5dd8841ae341847e117bb83b3.tar.xz
Fixes to JUMP system.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs151
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs66
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs7
3 files changed, 168 insertions, 56 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index b847d87..99d9564 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -58,7 +58,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
58 private int m_animTickFall; 58 private int m_animTickFall;
59// private int m_animTickJump; 59// private int m_animTickJump;
60 public int m_animTickJump; // ScenePresence has to see this to control +Z force 60 public int m_animTickJump; // ScenePresence has to see this to control +Z force
61 61 public bool m_jumping = false; // Add for jumping
62 public float m_jumpVelocity = 0f; // Add for jumping
63 private int m_landing = 0; // Add for jumping
64
62 /// <value> 65 /// <value>
63 /// The scene presence that this animator applies to 66 /// The scene presence that this animator applies to
64 /// </value> 67 /// </value>
@@ -141,9 +144,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
141 /// </summary> 144 /// </summary>
142 public string GetMovementAnimation() 145 public string GetMovementAnimation()
143 { 146 {
147//Console.WriteLine("GMA-------"); //##
144 const float FALL_DELAY = 0.33f; 148 const float FALL_DELAY = 0.33f;
145 const float PREJUMP_DELAY = 0.25f; 149//rm for jumping const float PREJUMP_DELAY = 0.25f;
146 150 const float PREJUMP_DELAY = 200f; // mS add for jumping
151 const float JUMP_PERIOD = 800f; // mS add for jumping
147 #region Inputs 152 #region Inputs
148 153
149 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; 154 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
@@ -177,8 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
177 182
178 // Is the avatar trying to move? 183 // Is the avatar trying to move?
179// bool moving = (move != Vector3.Zero); 184// bool moving = (move != Vector3.Zero);
180 bool jumping = m_animTickJump != 0; 185// rm for jumping bool jumping = m_animTickJump != 0;
181
182 #endregion Inputs 186 #endregion Inputs
183 187
184 #region Flying 188 #region Flying
@@ -187,6 +191,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation
187 { 191 {
188 m_animTickFall = 0; 192 m_animTickFall = 0;
189 m_animTickJump = 0; 193 m_animTickJump = 0;
194 m_jumping = false; //add for jumping flag
195 m_jumpVelocity = 0f; //add for jumping flag
196 actor.Selected = false; //add for jumping flag
190 197
191 if (move.X != 0f || move.Y != 0f) 198 if (move.X != 0f || move.Y != 0f)
192 { 199 {
@@ -213,8 +220,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
213 220
214 #region Falling/Floating/Landing 221 #region Falling/Floating/Landing
215 222
216 if (actor == null || !actor.IsColliding) 223// rm for jumping if (actor == null || !actor.IsColliding)
224 if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping
217 { 225 {
226//Console.WriteLine("FFL"); //##
218 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 227 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
219 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; 228 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
220 229
@@ -223,7 +232,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
223 // Just started falling 232 // Just started falling
224 m_animTickFall = Environment.TickCount; 233 m_animTickFall = Environment.TickCount;
225 } 234 }
226 else if (!jumping && fallElapsed > FALL_DELAY) 235// else if (!jumping && fallElapsed > FALL_DELAY)
236 else if (!m_jumping && fallElapsed > FALL_DELAY) // add for jumping
227 { 237 {
228 // Falling long enough to trigger the animation 238 // Falling long enough to trigger the animation
229 return "FALLDOWN"; 239 return "FALLDOWN";
@@ -234,6 +244,67 @@ namespace OpenSim.Region.Framework.Scenes.Animation
234 244
235 #endregion Falling/Floating/Landing 245 #endregion Falling/Floating/Landing
236 246
247
248 #region Jumping // section added for jumping...
249
250 Vector3 vj = Vector3.Zero;
251 int jumptime;
252 jumptime = Environment.TickCount - m_animTickJump;
253
254
255 if ((move.Z > 0f) && (!m_jumping))
256 {
257//Console.WriteLine("PJ {0}", jumptime); //##
258 // Start jumping, prejump
259 m_animTickFall = 0;
260 m_jumping = true;
261 actor.Selected = true; // borrowed for jmping flag
262 m_animTickJump = Environment.TickCount;
263 vj.Z = 0.35f;
264m_jumpVelocity = 0.35f;
265 vj += actor.Velocity;
266// #@ actor.Velocity = vj;
267 return "PREJUMP";
268 }
269
270 if(m_jumping)
271 {
272 if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding)
273 {
274//Console.WriteLine("LA {0}", jumptime); //##
275 // end jumping
276 m_jumping = false;
277 actor.Selected = false; // borrowed for jumping flag
278m_jumpVelocity = 0f;
279 m_animTickFall = Environment.TickCount;
280 return "LAND";
281 }
282 else if (jumptime > JUMP_PERIOD)
283 {
284//Console.WriteLine("JD {0}", jumptime); //##
285 // jump down
286 vj = actor.Velocity;
287 vj.Z = 0f;
288m_jumpVelocity = 0f;
289// #@ actor.Velocity = vj;
290 return "JUMP";
291 }
292 else if (jumptime > PREJUMP_DELAY)
293 {
294//Console.WriteLine("JU {0}", jumptime); //##
295 // jump up
296 m_jumping = true;
297 vj.Z = 10f;
298m_jumpVelocity = 10f;
299 vj.X = actor.Velocity.X;
300 vj.Y = actor.Velocity.Y;
301// #@ actor.Velocity = vj;
302 return "JUMP";
303 }
304 }
305
306 #endregion Jumping // end added section
307
237 #region Ground Movement 308 #region Ground Movement
238 309
239 if (m_movementAnimation == "FALLDOWN") 310 if (m_movementAnimation == "FALLDOWN")
@@ -245,11 +316,26 @@ namespace OpenSim.Region.Framework.Scenes.Animation
245 } 316 }
246 else if (m_movementAnimation == "LAND") 317 else if (m_movementAnimation == "LAND")
247 { 318 {
248 float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 319// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
249 if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) 320 int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping
321// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY))
322/* Try change ##
323 if ((m_animTickFall != 0) && (landElapsed <= 500)) // add for jumping
324 return "LAND";
325 */
326 // NB if this is set too long a weird anim reset from some place prevents STAND from being sent to client
327 if ((m_animTickFall != 0) && (landElapsed <= 300)) // add for jumping
328 {
329//Console.WriteLine("LAND"); //##
250 return "LAND"; 330 return "LAND";
331 }
332 else
333 {
334//Console.WriteLine("STAND"); //##
335 return "STAND";
336 }
251 } 337 }
252 338/* This section removed, replaced by jumping section
253 m_animTickFall = 0; 339 m_animTickFall = 0;
254 340
255 if (move.Z > 0f) 341 if (move.Z > 0f)
@@ -279,27 +365,28 @@ namespace OpenSim.Region.Framework.Scenes.Animation
279 { 365 {
280 // Not jumping 366 // Not jumping
281 m_animTickJump = 0; 367 m_animTickJump = 0;
282 368 */
283 if (move.X != 0f || move.Y != 0f) 369 // next section moved outside paren. and realigned for jumping
284 { 370 if (move.X != 0f || move.Y != 0f)
285 // Walking / crouchwalking / running 371 {
286 if (move.Z < 0f) 372 // Walking / crouchwalking / running
287 return "CROUCHWALK"; 373 if (move.Z < 0f)
288 else if (m_scenePresence.SetAlwaysRun) 374 return "CROUCHWALK";
289 return "RUN"; 375 else if (m_scenePresence.SetAlwaysRun)
290 else 376 return "RUN";
291 return "WALK";
292 }
293 else 377 else
294 { 378 return "WALK";
295 // Not walking
296 if (move.Z < 0f)
297 return "CROUCH";
298 else
299 return "STAND";
300 }
301 } 379 }
302 380// rm for jumping else
381 else if (!m_jumping) // add for jumping
382 {
383 // Not walking
384 if (move.Z < 0f)
385 return "CROUCH";
386 else
387 return "STAND";
388 }
389 // end section realign for jumping
303 #endregion Ground Movement 390 #endregion Ground Movement
304 391
305 return m_movementAnimation; 392 return m_movementAnimation;
@@ -311,15 +398,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
311 public void UpdateMovementAnimations() 398 public void UpdateMovementAnimations()
312 { 399 {
313 m_movementAnimation = GetMovementAnimation(); 400 m_movementAnimation = GetMovementAnimation();
314 if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) 401/* if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump)
315 { 402 {
316 // This was the previous behavior before PREJUMP 403 // This was the previous behavior before PREJUMP
317 TrySetMovementAnimation("JUMP"); 404 TrySetMovementAnimation("JUMP");
318 } 405 }
319 else 406 else
320 { 407 { removed for jumping */
321 TrySetMovementAnimation(m_movementAnimation); 408 TrySetMovementAnimation(m_movementAnimation);
322 } 409// rm for jumping }
323 } 410 }
324 411
325 public UUID[] GetAnimationArray() 412 public UUID[] GetAnimationArray()
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cd80eb0..f682ee5 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1471,6 +1471,9 @@ namespace OpenSim.Region.Framework.Scenes
1471 if (actor.Flying != oldflying) 1471 if (actor.Flying != oldflying)
1472 update_movementflag = true; 1472 update_movementflag = true;
1473 1473
1474 if (m_animator.m_jumping) // add for jumping
1475 update_movementflag = true;
1476
1474 if (q != m_bodyRot) 1477 if (q != m_bodyRot)
1475 { 1478 {
1476 m_bodyRot = q; 1479 m_bodyRot = q;
@@ -2580,6 +2583,7 @@ namespace OpenSim.Region.Framework.Scenes
2580 // m_log.Info("[AGENT]: Stop FLying"); 2583 // m_log.Info("[AGENT]: Stop FLying");
2581 //} 2584 //}
2582 } 2585 }
2586 /* This jumping section removed to SPA
2583 else if (!actor.Flying && actor.IsColliding) 2587 else if (!actor.Flying && actor.IsColliding)
2584 { 2588 {
2585 if (direc.Z > 2.0f) 2589 if (direc.Z > 2.0f)
@@ -2592,12 +2596,12 @@ namespace OpenSim.Region.Framework.Scenes
2592 { 2596 {
2593 direc.Z *= 0.1f; // prejump 2597 direc.Z *= 0.1f; // prejump
2594 } 2598 }
2595 /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs 2599 / * Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs
2596 Animator.TrySetMovementAnimation("PREJUMP"); 2600 Animator.TrySetMovementAnimation("PREJUMP");
2597 Animator.TrySetMovementAnimation("JUMP"); 2601 Animator.TrySetMovementAnimation("JUMP");
2598 */ 2602 * /
2599 } 2603 }
2600 } 2604 } */
2601 } 2605 }
2602 2606
2603 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2607 // TODO: Add the force instead of only setting it to support multiple forces per frame?
@@ -3543,28 +3547,46 @@ namespace OpenSim.Region.Framework.Scenes
3543 /// </summary> 3547 /// </summary>
3544 public override void UpdateMovement() 3548 public override void UpdateMovement()
3545 { 3549 {
3546 if (m_forceToApply.HasValue) 3550 if (Animator!=null) // add for jumping
3547 { 3551 { // add for jumping
3552 // if (!m_animator.m_jumping) // add for jumping
3553 // { // add for jumping
3548 3554
3549 Vector3 force = m_forceToApply.Value; 3555 if (m_forceToApply.HasValue) // this section realigned
3550 m_updateflag = true; 3556 {
3551 Velocity = force;
3552 3557
3553 m_forceToApply = null; 3558 Vector3 force = m_forceToApply.Value;
3554 } 3559 m_updateflag = true;
3555 else 3560if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping
3556 { 3561 Velocity = force;
3557 if (m_isNudging) 3562//Console.WriteLine("UM1 {0}", Velocity);
3558 { 3563 m_forceToApply = null;
3559 Vector3 force = Vector3.Zero; 3564 }
3565 else
3566 {
3567 if (m_isNudging)
3568 {
3569 Vector3 force = Vector3.Zero;
3570
3571 m_updateflag = true;
3572if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping
3573 Velocity = force;
3574//Console.WriteLine("UM2 {0}", Velocity);
3575 m_isNudging = false;
3576 m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND"
3577 }
3578 else // add for jumping
3579 { // add for jumping
3580 Vector3 force = Vector3.Zero; // add for jumping
3581if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping
3582//Console.WriteLine("UM3 {0}", Velocity);
3583 Velocity = force; // add for jumping
3584 }
3560 3585
3561 m_updateflag = true; 3586 }
3562 Velocity = force; 3587 // } // end realign
3563 m_isNudging = false; 3588 } // add for jumping
3564 m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" 3589 } // add for jumping
3565 }
3566 }
3567 }
3568 3590
3569 /// <summary> 3591 /// <summary>
3570 /// Adds a physical representation of the avatar to the Physics plugin 3592 /// Adds a physical representation of the avatar to the Physics plugin
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
index 61c16b8..0c79aa6 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
@@ -90,6 +90,7 @@ namespace OpenSim.Region.Physics.OdePlugin
90 public float walkDivisor = 1.3f; 90 public float walkDivisor = 1.3f;
91 public float runDivisor = 0.8f; 91 public float runDivisor = 0.8f;
92 private bool flying = false; 92 private bool flying = false;
93 private bool jumping = false; // add for jumping
93 private bool m_iscolliding = false; 94 private bool m_iscolliding = false;
94 private bool m_iscollidingGround = false; 95 private bool m_iscollidingGround = false;
95 private bool m_wascolliding = false; 96 private bool m_wascolliding = false;
@@ -229,7 +230,8 @@ namespace OpenSim.Region.Physics.OdePlugin
229 230
230 public override bool Selected 231 public override bool Selected
231 { 232 {
232 set { return; } 233// set { return; }
234 set { jumping = value; } // add for jumping flag
233 } 235 }
234 236
235 public override float Buoyancy 237 public override float Buoyancy
@@ -1018,7 +1020,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1018 { // close, jump to lateral destination 1020 { // close, jump to lateral destination
1019 d.BodySetPosition(Body, _zeroPosition.X, _zeroPosition.Y, pos.Z); 1021 d.BodySetPosition(Body, _zeroPosition.X, _zeroPosition.Y, pos.Z);
1020 } 1022 }
1021 if (flying) 1023// if (flying)
1024 if (flying || jumping) // add for jumping
1022 { 1025 {
1023 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P; 1026 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1024 } 1027 }