Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2011-07-30 01:07:51 +0400
committerMike Erwin <significant.bit@gmail.com>2011-07-30 01:07:51 +0400
commitaec91c0cf530d637a15c95cf1e4d0e27a7660a4c (patch)
treea24dd9cdd3f7991a316b90af2aaca70b9dec3d76 /source/blender/windowmanager
parent24def76ac899e106b4a04364504ba0cbc100d7f7 (diff)
ndof sensitivity operator follows power curve and respects min/max
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 1b48e36d2b7..d813fd913ab 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3435,16 +3435,36 @@ static void WM_OT_memory_statistics(wmOperatorType *ot)
static int wm_ndof_sensitivity_exec(bContext *UNUSED(C), wmOperator *op)
{
- float change = 0.1f;
- int dir = 1;
- if(RNA_boolean_get(op->ptr, "decrease"))
- dir = -1;
+ const float min = 0.25f, max = 4.f; // TODO: get these from RNA property
+ float change;
+ float sensitivity = U.ndof_sensitivity;
+
if(RNA_boolean_get(op->ptr, "fast"))
- change = 1.0f;
+ change = 0.5f; // 50% change
+ else
+ change = 0.1f; // 10%
+ if(RNA_boolean_get(op->ptr, "decrease"))
+ {
+ sensitivity -= sensitivity * change;
+ if (sensitivity < min)
+ sensitivity = min;
+ }
+ else
+ {
+ sensitivity += sensitivity * change;
+ if (sensitivity > max)
+ sensitivity = max;
+ }
+
+ if (sensitivity != U.ndof_sensitivity)
+ {
+ U.ndof_sensitivity = sensitivity;
+ printf("new sensitivity: %f\n", U.ndof_sensitivity);
+ }
+ else
+ printf("same sensitivity: %f\n", U.ndof_sensitivity);
- U.ndof_sensitivity += (dir * change);
- printf("new sensitivity: %f\n", U.ndof_sensitivity);
return OPERATOR_FINISHED;
}
@@ -3457,8 +3477,9 @@ static void WM_OT_ndof_sensitivity_change(wmOperatorType *ot)
ot->exec= wm_ndof_sensitivity_exec;
RNA_def_boolean(ot->srna, "decrease", 1, "Decrease NDOF sensitivity", "If true then action decreases NDOF sensitivity instead of increasing");
- RNA_def_boolean(ot->srna, "fast", 0, "Fast NDOF sensitivity change", "If true then action change with factor 1.0, otherwise 0.1");
+ RNA_def_boolean(ot->srna, "fast", 0, "Fast NDOF sensitivity change", "If true then sensitivity changes 50%, otherwise 10%");
}
+
/* ******************************************************* */
/* called on initialize WM_exit() */
void wm_operatortype_free(void)