Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/BLI_dial_2d.c
| Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if (!dial->initialized) { | ||||
| copy_v2_v2(dial->initial_direction, current_direction); | copy_v2_v2(dial->initial_direction, current_direction); | ||||
| dial->initialized = true; | dial->initialized = true; | ||||
| } | } | ||||
| /* calculate mouse angle between initial and final mouse position */ | /* calculate mouse angle between initial and final mouse position */ | ||||
| cosval = dot_v2v2(current_direction, dial->initial_direction); | cosval = dot_v2v2(current_direction, dial->initial_direction); | ||||
| sinval = cross_v2v2(current_direction, dial->initial_direction); | sinval = cross_v2v2(current_direction, dial->initial_direction); | ||||
| /* clamp to avoid nans in acos */ | /* clamp to avoid nans in #acos */ | ||||
| angle = atan2f(sinval, cosval); | angle = atan2f(sinval, cosval); | ||||
| /* change of sign, we passed the 180 degree threshold. This means we need to add a turn. | /* change of sign, we passed the 180 degree threshold. This means we need to add a turn. | ||||
| * to distinguish between transition from 0 to -1 and -PI to +PI, | * to distinguish between transition from 0 to -1 and -PI to +PI, | ||||
| * use comparison with PI/2 */ | * use comparison with PI/2 */ | ||||
| if ((angle * dial->last_angle < 0.0f) && (fabsf(dial->last_angle) > (float)M_PI_2)) { | if ((angle * dial->last_angle < 0.0f) && (fabsf(dial->last_angle) > (float)M_PI_2)) { | ||||
| if (dial->last_angle < 0.0f) { | if (dial->last_angle < 0.0f) { | ||||
| dial->rotations--; | dial->rotations--; | ||||
| Show All 12 Lines | |||||