Advertisement
Guest User

Untitled

a guest
May 3rd, 2023
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. // UPDATE LOOP
  2. {
  3.     //prepare new values
  4.     velocityX,Y = deflectionX,Y - deflectionX,Y_old
  5.     deflection = sqrt(...)
  6.    
  7.     //check deadzones
  8.     if (deflection>inner_deadzone)
  9.     {
  10.         magnitude = (deflection - inner_deadzone) / livezone
  11.         inClippingZone = true
  12.         //check outer_deadzone
  13.         if (deflection>outer_deadzone)
  14.         {
  15.             //clip outward radial velocity
  16.             ...
  17.             magnitude = 1        
  18.             //check entering
  19.             if(deflection_old<=deadzoneEdge)
  20.             {
  21.                 edgePushAmount = velocityRadial_old
  22.             }
  23.         }
  24.     }
  25.     else
  26.     {
  27.         magnitude = 0
  28.         edgePushAmount = 0
  29.         if (radial(velocityX,Y)) >= 0)
  30.         {
  31.             inClippingZone = false
  32.         }
  33.     }
  34.    
  35.     //compute output
  36.     magnitudeX,Y = ...
  37.     outputX,Y = factor_integral * magnitudeX,Y * delta_time
  38.     outputX,Y += factor_proportional * velocityX,Y
  39.    
  40.     //clip output while returning to center
  41.     outputRadial = radial(outputX,Y, deflectionX,Y)
  42.     if (inClippingZone && outputRadial < 0)
  43.     {
  44.         if (clippingModeIsRadial)
  45.         {
  46.             if (-outputRadial < clippingThreshhold / delta_time)
  47.             {
  48.                 //clip radial output
  49.                 ...
  50.             }
  51.             else if (-outputRadial < (clippingThreshhold + clippingRampUp) / delta_time)
  52.             {
  53.                 //ramp up radial output
  54.                 ...
  55.             }
  56.         }
  57.         else
  58.         {
  59.             output = sqrt(...)
  60.             if (output < clippingThreshhold / delta_time)
  61.             {
  62.                 //clip entire output
  63.                 outputX,Y = 0, 0
  64.             }
  65.             else if (output < (clippingThreshhold + clippingRampUp) / delta_time)
  66.             {
  67.                 //ramp up output
  68.                 ...
  69.             }
  70.         }
  71.     }
  72.    
  73.     mouseMove(outputX,Y)
  74.    
  75.     //prepare for next iteration
  76.     velocityRadial_old = radial(velocityX,Y)
  77.     deflectionX,Y_old = deflectionX,Y
  78.     deflection_old = deflection
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement