Skip to content
Snippets Groups Projects
Commit edb358be authored by Campbell Barton's avatar Campbell Barton
Browse files

minor adjustments

- dont import *
- dont use builtin names for vars
- strip trailing white space
parent 37db3924
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ import bpy
def readMesh(filename, objName):
file = open(filename, "rb")
filehandle = open(filename, "rb")
def line_to_face(line):
# Each triplet is an xyz float
......@@ -59,12 +59,12 @@ def readMesh(filename, objName):
return None
faces = []
for line in file.readlines():
for line in filehandle.readlines():
face = line_to_face(line)
if face:
faces.append(face)
file.close()
filehandle.close()
# Generate verts and faces lists, without duplicates
verts = []
......
......@@ -112,16 +112,12 @@ def add_object_data(context, obdata, operator=None):
return base
def flatten_vector_list(list):
def flatten_vector_list(ls):
'''flatten a list of vetcors to use in foreach_set and the like'''
if not list:
if not ls:
return None
result = []
for vec in list:
result.extend([i for i in vec])
return result
return [i for v in ls for i in v]
def list_to_vector_list(list, dimension=3):
......
......@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
from bpy.props import *
from bpy.props import StringProperty
import rigify
from rigify.utils import get_rig_type
from rigify import generate
......@@ -257,7 +257,11 @@ class Sample(bpy.types.Operator):
bl_label = "Add a sample metarig for a rig type"
bl_options = {'UNDO'}
metarig_type = StringProperty(name="Type", description="Name of the rig type to generate a sample of", maxlen=128, default="")
metarig_type = StringProperty(
name="Type",
description="Name of the rig type to generate a sample of",
maxlen=128,
)
def execute(self, context):
if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "":
......
......@@ -27,10 +27,10 @@ bl_info = {
'warning': '',
'description': 'Display keys pressed in the 3d-view, '\
'useful for screencasts.',
'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/'\
'Py/Scripts/3D_interaction/Screencast_Key_Status_Tool',
'tracker_url': 'http://projects.blender.org/tracker/index.php?'\
'func=detail&aid=21612',
'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/'
'Py/Scripts/3D_interaction/Screencast_Key_Status_Tool',
'tracker_url': 'http://projects.blender.org/tracker/index.php?'
'func=detail&aid=21612',
'category': '3D View'}
......@@ -49,7 +49,7 @@ def getDisplayLocation(context):
pos_x = int( (context.region.width - mouse_size * MOUSE_RATIO) * \
scene.screencast_keys_pos_x / 100)
pos_y = int( (context.region.height - mouse_size) *
pos_y = int( (context.region.height - mouse_size) *
scene.screencast_keys_pos_y / 100)
return(pos_x, pos_y)
......@@ -96,7 +96,7 @@ def draw_callback_px(self, context):
label_time = time.time() - self.time[i]
if label_time < 2: # only display key-presses of last 2 seconds
keypos_y = pos_y + shift + font_size*(i+0.1)
keypos_y = pos_y + shift + font_size*(i+0.1)
blf.position(0, keypos_x, keypos_y , 0)
alpha = min(1.0, max(0.0, 2 * (2 - label_time)))
......@@ -150,7 +150,7 @@ def draw_callback_px(self, context):
bgl.glEnable(bgl.GL_BLEND)
bgl.glBegin(mode)
bgl.glColor4f(r, g, b, box_alpha)
for v1, v2 in positions:
for v1, v2 in positions:
bgl.glVertex2f(v1, v2)
bgl.glEnd()
......@@ -231,150 +231,150 @@ def draw_mouse(context, shape, style, alpha):
def get_shape_data(shape):
data = []
if shape == "mouse":
data = [[[0.264, 0.002, 0.0],
[0.096, 0.002, 0.0],
[0.059, 0.226, 0.0],
[0.04, 0.313, 0.0]],
[[0.04, 0.313, 0.0],
[-0.015, 0.565, 0.0],
[-0.005, 0.664, 0.0],
[0.032, 0.87, 0.0]],
[[0.032, 0.87, 0.0],
[0.05, 0.973, 0.0],
[0.16, 1.002, 0.0],
[0.264, 1.002, 0.0]],
[[0.264, 1.002, 0.0],
[0.369, 1.002, 0.0],
[0.478, 0.973, 0.0],
[0.497, 0.87, 0.0]],
[[0.497, 0.87, 0.0],
[0.533, 0.664, 0.0],
[0.544, 0.565, 0.0],
[0.489, 0.313, 0.0]],
[[0.489, 0.313, 0.0],
[0.47, 0.226, 0.0],
[0.432, 0.002, 0.0],
data = [[[0.264, 0.002, 0.0],
[0.096, 0.002, 0.0],
[0.059, 0.226, 0.0],
[0.04, 0.313, 0.0]],
[[0.04, 0.313, 0.0],
[-0.015, 0.565, 0.0],
[-0.005, 0.664, 0.0],
[0.032, 0.87, 0.0]],
[[0.032, 0.87, 0.0],
[0.05, 0.973, 0.0],
[0.16, 1.002, 0.0],
[0.264, 1.002, 0.0]],
[[0.264, 1.002, 0.0],
[0.369, 1.002, 0.0],
[0.478, 0.973, 0.0],
[0.497, 0.87, 0.0]],
[[0.497, 0.87, 0.0],
[0.533, 0.664, 0.0],
[0.544, 0.565, 0.0],
[0.489, 0.313, 0.0]],
[[0.489, 0.313, 0.0],
[0.47, 0.226, 0.0],
[0.432, 0.002, 0.0],
[0.264, 0.002, 0.0]]]
elif shape == "left_button":
data = [[[0.154, 0.763, 0.0],
[0.126, 0.755, 0.0],
[0.12, 0.754, 0.0],
[0.066, 0.751, 0.0]],
[[0.066, 0.751, 0.0],
[0.043, 0.75, 0.0],
[0.039, 0.757, 0.0],
[0.039, 0.767, 0.0]],
[[0.039, 0.767, 0.0],
[0.047, 0.908, 0.0],
[0.078, 0.943, 0.0],
[0.155, 0.97, 0.0]],
[[0.155, 0.97, 0.0],
[0.174, 0.977, 0.0],
[0.187, 0.975, 0.0],
[0.191, 0.972, 0.0]],
[[0.191, 0.972, 0.0],
[0.203, 0.958, 0.0],
[0.205, 0.949, 0.0],
[0.199, 0.852, 0.0]],
[[0.199, 0.852, 0.0],
[0.195, 0.77, 0.0],
[0.18, 0.771, 0.0],
data = [[[0.154, 0.763, 0.0],
[0.126, 0.755, 0.0],
[0.12, 0.754, 0.0],
[0.066, 0.751, 0.0]],
[[0.066, 0.751, 0.0],
[0.043, 0.75, 0.0],
[0.039, 0.757, 0.0],
[0.039, 0.767, 0.0]],
[[0.039, 0.767, 0.0],
[0.047, 0.908, 0.0],
[0.078, 0.943, 0.0],
[0.155, 0.97, 0.0]],
[[0.155, 0.97, 0.0],
[0.174, 0.977, 0.0],
[0.187, 0.975, 0.0],
[0.191, 0.972, 0.0]],
[[0.191, 0.972, 0.0],
[0.203, 0.958, 0.0],
[0.205, 0.949, 0.0],
[0.199, 0.852, 0.0]],
[[0.199, 0.852, 0.0],
[0.195, 0.77, 0.0],
[0.18, 0.771, 0.0],
[0.154, 0.763, 0.0]]]
elif shape == "middle_button":
data = [[[0.301, 0.8, 0.0],
[0.298, 0.768, 0.0],
[0.231, 0.768, 0.0],
[0.228, 0.8, 0.0]],
[[0.228, 0.8, 0.0],
[0.226, 0.817, 0.0],
[0.225, 0.833, 0.0],
[0.224, 0.85, 0.0]],
[[0.224, 0.85, 0.0],
[0.222, 0.873, 0.0],
[0.222, 0.877, 0.0],
[0.224, 0.9, 0.0]],
[[0.224, 0.9, 0.0],
[0.225, 0.917, 0.0],
[0.226, 0.933, 0.0],
[0.228, 0.95, 0.0]],
[[0.228, 0.95, 0.0],
[0.231, 0.982, 0.0],
[0.298, 0.982, 0.0],
[0.301, 0.95, 0.0]],
[[0.301, 0.95, 0.0],
[0.302, 0.933, 0.0],
[0.303, 0.917, 0.0],
[0.305, 0.9, 0.0]],
[[0.305, 0.9, 0.0],
[0.307, 0.877, 0.0],
[0.307, 0.873, 0.0],
[0.305, 0.85, 0.0]],
[[0.305, 0.85, 0.0],
[0.303, 0.833, 0.0],
[0.302, 0.817, 0.0],
data = [[[0.301, 0.8, 0.0],
[0.298, 0.768, 0.0],
[0.231, 0.768, 0.0],
[0.228, 0.8, 0.0]],
[[0.228, 0.8, 0.0],
[0.226, 0.817, 0.0],
[0.225, 0.833, 0.0],
[0.224, 0.85, 0.0]],
[[0.224, 0.85, 0.0],
[0.222, 0.873, 0.0],
[0.222, 0.877, 0.0],
[0.224, 0.9, 0.0]],
[[0.224, 0.9, 0.0],
[0.225, 0.917, 0.0],
[0.226, 0.933, 0.0],
[0.228, 0.95, 0.0]],
[[0.228, 0.95, 0.0],
[0.231, 0.982, 0.0],
[0.298, 0.982, 0.0],
[0.301, 0.95, 0.0]],
[[0.301, 0.95, 0.0],
[0.302, 0.933, 0.0],
[0.303, 0.917, 0.0],
[0.305, 0.9, 0.0]],
[[0.305, 0.9, 0.0],
[0.307, 0.877, 0.0],
[0.307, 0.873, 0.0],
[0.305, 0.85, 0.0]],
[[0.305, 0.85, 0.0],
[0.303, 0.833, 0.0],
[0.302, 0.817, 0.0],
[0.301, 0.8, 0.0]]]
elif shape == "middle_down_button":
data = [[[0.301, 0.8, 0.0],
[0.298, 0.768, 0.0],
[0.231, 0.768, 0.0],
[0.228, 0.8, 0.0]],
[[0.228, 0.8, 0.0],
[0.226, 0.817, 0.0],
[0.225, 0.833, 0.0],
[0.224, 0.85, 0.0]],
[[0.224, 0.85, 0.0],
[0.264, 0.873, 0.0],
[0.284, 0.873, 0.0],
[0.305, 0.85, 0.0]],
[[0.305, 0.85, 0.0],
[0.303, 0.833, 0.0],
[0.302, 0.817, 0.0],
data = [[[0.301, 0.8, 0.0],
[0.298, 0.768, 0.0],
[0.231, 0.768, 0.0],
[0.228, 0.8, 0.0]],
[[0.228, 0.8, 0.0],
[0.226, 0.817, 0.0],
[0.225, 0.833, 0.0],
[0.224, 0.85, 0.0]],
[[0.224, 0.85, 0.0],
[0.264, 0.873, 0.0],
[0.284, 0.873, 0.0],
[0.305, 0.85, 0.0]],
[[0.305, 0.85, 0.0],
[0.303, 0.833, 0.0],
[0.302, 0.817, 0.0],
[0.301, 0.8, 0.0]]]
elif shape == "middle_up_button":
data = [[[0.270, 0.873, 0.0],
[0.264, 0.873, 0.0],
[0.222, 0.877, 0.0],
[0.224, 0.9, 0.0]],
[[0.224, 0.9, 0.0],
[0.225, 0.917, 0.0],
[0.226, 0.933, 0.0],
[0.228, 0.95, 0.0]],
[[0.228, 0.95, 0.0],
[0.231, 0.982, 0.0],
[0.298, 0.982, 0.0],
[0.301, 0.95, 0.0]],
[[0.301, 0.95, 0.0],
[0.302, 0.933, 0.0],
[0.303, 0.917, 0.0],
[0.305, 0.9, 0.0]],
[[0.305, 0.9, 0.0],
[0.307, 0.877, 0.0],
[0.284, 0.873, 0.0],
data = [[[0.270, 0.873, 0.0],
[0.264, 0.873, 0.0],
[0.222, 0.877, 0.0],
[0.224, 0.9, 0.0]],
[[0.224, 0.9, 0.0],
[0.225, 0.917, 0.0],
[0.226, 0.933, 0.0],
[0.228, 0.95, 0.0]],
[[0.228, 0.95, 0.0],
[0.231, 0.982, 0.0],
[0.298, 0.982, 0.0],
[0.301, 0.95, 0.0]],
[[0.301, 0.95, 0.0],
[0.302, 0.933, 0.0],
[0.303, 0.917, 0.0],
[0.305, 0.9, 0.0]],
[[0.305, 0.9, 0.0],
[0.307, 0.877, 0.0],
[0.284, 0.873, 0.0],
[0.270, 0.873, 0.0]]]
elif shape == "right_button":
data = [[[0.375, 0.763, 0.0],
[0.402, 0.755, 0.0],
[0.408, 0.754, 0.0],
[0.462, 0.751, 0.0]],
[[0.462, 0.751, 0.0],
[0.486, 0.75, 0.0],
[0.49, 0.757, 0.0],
[0.489, 0.767, 0.0]],
[[0.489, 0.767, 0.0],
[0.481, 0.908, 0.0],
[0.451, 0.943, 0.0],
[0.374, 0.97, 0.0]],
[[0.374, 0.97, 0.0],
[0.354, 0.977, 0.0],
[0.341, 0.975, 0.0],
[0.338, 0.972, 0.0]],
[[0.338, 0.972, 0.0],
[0.325, 0.958, 0.0],
[0.324, 0.949, 0.0],
[0.329, 0.852, 0.0]],
[[0.329, 0.852, 0.0],
[0.334, 0.77, 0.0],
[0.348, 0.771, 0.0],
data = [[[0.375, 0.763, 0.0],
[0.402, 0.755, 0.0],
[0.408, 0.754, 0.0],
[0.462, 0.751, 0.0]],
[[0.462, 0.751, 0.0],
[0.486, 0.75, 0.0],
[0.49, 0.757, 0.0],
[0.489, 0.767, 0.0]],
[[0.489, 0.767, 0.0],
[0.481, 0.908, 0.0],
[0.451, 0.943, 0.0],
[0.374, 0.97, 0.0]],
[[0.374, 0.97, 0.0],
[0.354, 0.977, 0.0],
[0.341, 0.975, 0.0],
[0.338, 0.972, 0.0]],
[[0.338, 0.972, 0.0],
[0.325, 0.958, 0.0],
[0.324, 0.949, 0.0],
[0.329, 0.852, 0.0]],
[[0.329, 0.852, 0.0],
[0.334, 0.77, 0.0],
[0.348, 0.771, 0.0],
[0.375, 0.763, 0.0]]]
return(data)
......@@ -410,11 +410,11 @@ class ScreencastKeysStatus(bpy.types.Operator):
def modal(self, context, event):
if context.area:
context.area.tag_redraw()
if event.type == 'TIMER':
# no input, so no need to change the display
return {'PASS_THROUGH'}
scene = context.scene
# keys that shouldn't show up in the 3d-view
mouse_keys = ['MOUSEMOVE','MIDDLEMOUSE','LEFTMOUSE',
......@@ -462,7 +462,7 @@ class ScreencastKeysStatus(bpy.types.Operator):
scene.screencast_keys_mouse == 'icon':
#print("Recorded as mouse press")
self.mouse.insert(0, event.type)
self.mouse_time.insert(0, time.time())
self.mouse_time.insert(0, time.time())
if event.type in mouse_keys:
self.last_activity = 'MOUSE'
......@@ -546,7 +546,7 @@ def init_properties():
max=1,
subtype='COLOR')
scene.screencast_keys_mouse = bpy.props.EnumProperty(
items=(("none", "None", "Don't display mouse events"),
items=(("none", "None", "Don't display mouse events"),
("icon", "Icon", "Display graphical represenation of "\
"the mouse"),
("text", "Text", "Display mouse events as text lines")),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment