Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UPDATE LOOP
- {
- //prepare new values
- velocityX,Y = deflectionX,Y - deflectionX,Y_old
- deflection = sqrt(...)
- //check deadzones
- if (deflection>inner_deadzone)
- {
- magnitude = (deflection - inner_deadzone) / livezone
- inClippingZone = true
- //check outer_deadzone
- if (deflection>outer_deadzone)
- {
- //clip outward radial velocity
- ...
- magnitude = 1
- //check entering
- if(deflection_old<=deadzoneEdge)
- {
- edgePushAmount = velocityRadial_old
- }
- }
- }
- else
- {
- magnitude = 0
- edgePushAmount = 0
- if (radial(velocityX,Y)) >= 0)
- {
- inClippingZone = false
- }
- }
- //compute output
- magnitudeX,Y = ...
- outputX,Y = factor_integral * magnitudeX,Y * delta_time
- outputX,Y += factor_proportional * velocityX,Y
- //clip output while returning to center
- outputRadial = radial(outputX,Y, deflectionX,Y)
- if (inClippingZone && outputRadial < 0)
- {
- if (clippingModeIsRadial)
- {
- if (-outputRadial < clippingThreshhold / delta_time)
- {
- //clip radial output
- ...
- }
- else if (-outputRadial < (clippingThreshhold + clippingRampUp) / delta_time)
- {
- //ramp up radial output
- ...
- }
- }
- else
- {
- output = sqrt(...)
- if (output < clippingThreshhold / delta_time)
- {
- //clip entire output
- outputX,Y = 0, 0
- }
- else if (output < (clippingThreshhold + clippingRampUp) / delta_time)
- {
- //ramp up output
- ...
- }
- }
- }
- mouseMove(outputX,Y)
- //prepare for next iteration
- velocityRadial_old = radial(velocityX,Y)
- deflectionX,Y_old = deflectionX,Y
- deflection_old = deflection
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement