pep8 compliance for Randomize objects loc/rot/scale.

- scale min -1 to 1 rather then -100 to 100
- default precision for float props to 2.
This commit is contained in:
Campbell Barton 2010-01-19 09:36:40 +00:00
parent 98312235b0
commit 8ae76d7249
2 changed files with 26 additions and 20 deletions

@ -16,8 +16,11 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
def randomize_selected(seed, loc, rot, scale, scale_even, scale_min):
import random
@ -53,17 +56,20 @@ def randomize_selected(seed, loc, rot, scale, scale_even, scale_min):
sca_x, sca_y, sca_z = rand_vec(scale)
aX = sca_x + org_sca_x
bX = org_sca_x * scale_min / 100.0
bX = org_sca_x * scale_min
aY = sca_y + org_sca_y
bY = org_sca_y * scale_min / 100.0
bY = org_sca_y * scale_min
aZ = sca_z + org_sca_z
bZ = org_sca_z * scale_min / 100.0
bZ = org_sca_z * scale_min
if aX < bX: aX = bX
if aY < bY: aY = bY
if aZ < bZ: aZ = bZ
if aX < bX:
aX = bX
if aY < bY:
aY = bY
if aZ < bZ:
aZ = bZ
obj.scale = aX, aY, aZ
else:
@ -105,7 +111,7 @@ class RandomizeLocRotSize(bpy.types.Operator):
scale_min = FloatProperty(name="Minimun Scale Factor",
description="Lowest scale percentage possible",
default=15.0, min=-100.0, max=100.0)
default=15.0, min=-1.0, max=1.0, precision=3)
scale = FloatVectorProperty(name="Scale",
description="Maximum scale randomization over each axis",
@ -130,7 +136,7 @@ class RandomizeLocRotSize(bpy.types.Operator):
# Register the operator
bpy.types.register(RandomizeLocRotSize)
# Add to the menu
def menu_func(self, context):
if context.mode == 'OBJECT':
self.layout.operator(RandomizeLocRotSize.bl_idname,

@ -130,7 +130,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "hidden", NULL};
char *id=NULL, *name="", *description="";
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def=0.0f;
int precision= 1, hidden=0;
int precision= 2, hidden=0;
PropertyRNA *prop;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffii:FloatProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &hidden))
@ -164,7 +164,7 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "hidden", "size", NULL};
char *id=NULL, *name="", *description="";
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def[PYRNA_STACK_ARRAY]={0.0f};
int precision= 1, hidden=0, size=3;
int precision= 2, hidden=0, size=3;
PropertyRNA *prop;
PyObject *pydef= NULL;