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:
authorJoerg Mueller <nexyon@gmail.com>2011-07-30 01:28:18 +0400
committerJoerg Mueller <nexyon@gmail.com>2011-07-30 01:28:18 +0400
commit29f214f7f31bf7490b0c2795ad716ce5a9dc1818 (patch)
treefa9cb969c253e58c71c0dd61e89731f185849030 /release/scripts/modules
parentce1c78e18bf41115a8a149dd85115292c1919bea (diff)
parent6a27da310c61b3372d565060506221a5afb9fe43 (diff)
Merging up to trunk r38834.
Diffstat (limited to 'release/scripts/modules')
-rw-r--r--release/scripts/modules/addon_utils.py1
-rw-r--r--release/scripts/modules/bpy/__init__.py1
-rw-r--r--release/scripts/modules/bpy/path.py2
-rw-r--r--release/scripts/modules/bpy_extras/io_utils.py19
-rw-r--r--release/scripts/modules/bpy_extras/mesh_utils.py32
-rw-r--r--release/scripts/modules/bpy_extras/view3d_utils.py10
-rw-r--r--release/scripts/modules/bpy_types.py14
7 files changed, 46 insertions, 33 deletions
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
index cf74282d064..5aed0581ea9 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -33,6 +33,7 @@ import bpy as _bpy
error_duplicates = False
+
def paths():
# RELEASE SCRIPTS: official scripts distributed in Blender releases
paths = _bpy.utils.script_paths("addons")
diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py
index 9c48dc89f83..0add2b3e6cd 100644
--- a/release/scripts/modules/bpy/__init__.py
+++ b/release/scripts/modules/bpy/__init__.py
@@ -43,6 +43,7 @@ from . import utils, path, ops
# fake operator module
ops = ops.ops_fake_module
+
def _main():
import sys as _sys
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index f6254efac2e..eb1a5ffc455 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -239,4 +239,4 @@ def basename(path):
Use for Windows compatibility.
"""
- return _os.path.basename(path[2:] if path.startswith("//") else path)
+ return _os.path.basename(path[2:] if path[:2] in {"//", b"//"} else path)
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py
index 9545e20b025..0a3f1392653 100644
--- a/release/scripts/modules/bpy_extras/io_utils.py
+++ b/release/scripts/modules/bpy_extras/io_utils.py
@@ -159,14 +159,19 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'):
raise Exception("invalid axis arguments passed, "
"can't use up/forward on the same axis.")
- value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3) for i, a in enumerate((from_forward, from_up, to_forward, to_up))))
+ value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3)
+ for i, a in enumerate((from_forward,
+ from_up,
+ to_forward,
+ to_up,
+ ))))
for i, axis_lut in enumerate(_axis_convert_lut):
if value in axis_lut:
return Matrix(_axis_convert_matrix[i])
assert(0)
-
+
def axis_conversion_ensure(operator, forward_attr, up_attr):
"""
Function to ensure an operator has valid axis conversion settings, intended
@@ -174,9 +179,9 @@ def axis_conversion_ensure(operator, forward_attr, up_attr):
:arg operator: the operator to access axis attributes from.
:type operator: :class:`Operator`
- :arg forward_attr:
+ :arg forward_attr: attribute storing the forward axis
:type forward_attr: string
- :arg up_attr: the directory the *filepath* will be referenced from (normally the export path).
+ :arg up_attr: attribute storing the up axis
:type up_attr: string
:return: True if the value was modified.
:rtype: boolean
@@ -184,9 +189,9 @@ def axis_conversion_ensure(operator, forward_attr, up_attr):
def validate(axis_forward, axis_up):
if axis_forward[-1] == axis_up[-1]:
axis_up = axis_up[0:-1] + 'XYZ'[('XYZ'.index(axis_up[-1]) + 1) % 3]
-
+
return axis_forward, axis_up
-
+
change = False
axis = getattr(operator, forward_attr), getattr(operator, up_attr)
@@ -203,7 +208,7 @@ def axis_conversion_ensure(operator, forward_attr, up_attr):
# return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()
def create_derived_objects(scene, ob):
- if ob.parent and ob.parent.dupli_type != 'NONE':
+ if ob.parent and ob.parent.dupli_type in {'VERTS', 'FACES'}:
return False, None
if ob.dupli_type != 'NONE':
diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py
index c42d3d0236a..ecd620ff2c9 100644
--- a/release/scripts/modules/bpy_extras/mesh_utils.py
+++ b/release/scripts/modules/bpy_extras/mesh_utils.py
@@ -170,8 +170,8 @@ def edge_loops_from_faces(mesh, faces=None, seams=()):
# from knowing the last 2, look for th next.
ed_adj = edges[context_loop[-1]]
if len(ed_adj) != 2:
-
- if other_dir and flipped == False: # the original edge had 2 other edges
+ # the original edge had 2 other edges
+ if other_dir and flipped == False:
flipped = True # only flip the list once
context_loop.reverse()
ed_adj[:] = []
@@ -259,13 +259,15 @@ def edge_loops_from_edges(mesh, edges=None):
def ngon_tesselate(from_data, indices, fix_loops=True):
'''
- Takes a polyline of indices (fgon)
- and returns a list of face indicie lists.
- Designed to be used for importers that need indices for an fgon to create from existing verts.
+ Takes a polyline of indices (fgon) and returns a list of face
+ indicie lists. Designed to be used for importers that need indices for an
+ fgon to create from existing verts.
from_data: either a mesh, or a list/tuple of vectors.
- indices: a list of indices to use this list is the ordered closed polyline to fill, and can be a subset of the data given.
- fix_loops: If this is enabled polylines that use loops to make multiple polylines are delt with correctly.
+ indices: a list of indices to use this list is the ordered closed polyline
+ to fill, and can be a subset of the data given.
+ fix_loops: If this is enabled polylines that use loops to make multiple
+ polylines are delt with correctly.
'''
from mathutils.geometry import tesselate_polygon
@@ -276,7 +278,8 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
return []
def mlen(co):
- return abs(co[0]) + abs(co[1]) + abs(co[2]) # manhatten length of a vector, faster then length
+ # manhatten length of a vector, faster then length
+ return abs(co[0]) + abs(co[1]) + abs(co[2])
def vert_treplet(v, i):
return v, vector_to_tuple(v, 6), i, mlen(v)
@@ -296,7 +299,8 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
else:
verts = [from_data.vertices[i].co for ii, i in enumerate(indices)]
- for i in range(len(verts) - 1, 0, -1): # same as reversed(xrange(1, len(verts))):
+ # same as reversed(range(1, len(verts))):
+ for i in range(len(verts) - 1, 0, -1):
if verts[i][1] == verts[i - 1][0]:
verts.pop(i - 1)
@@ -304,14 +308,16 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
else:
'''
- Seperate this loop into multiple loops be finding edges that are used twice
- This is used by lightwave LWO files a lot
+ Seperate this loop into multiple loops be finding edges that are
+ used twice. This is used by lightwave LWO files a lot
'''
if type(from_data) in (tuple, list):
- verts = [vert_treplet(Vector(from_data[i]), ii) for ii, i in enumerate(indices)]
+ verts = [vert_treplet(Vector(from_data[i]), ii)
+ for ii, i in enumerate(indices)]
else:
- verts = [vert_treplet(from_data.vertices[i].co, ii) for ii, i in enumerate(indices)]
+ verts = [vert_treplet(from_data.vertices[i].co, ii)
+ for ii, i in enumerate(indices)]
edges = [(i, i - 1) for i in range(len(verts))]
if edges:
diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py
index c0c0f9186bd..5796abce72c 100644
--- a/release/scripts/modules/bpy_extras/view3d_utils.py
+++ b/release/scripts/modules/bpy_extras/view3d_utils.py
@@ -50,11 +50,11 @@ def region_2d_to_vector_3d(region, rv3d, coord):
-0.5
))
- w = (out[0] * persinv[0][3]) + \
- (out[1] * persinv[1][3]) + \
- (out[2] * persinv[2][3]) + persinv[3][3]
+ w = ((out[0] * persinv[0][3]) +
+ (out[1] * persinv[1][3]) +
+ (out[2] * persinv[2][3]) + persinv[3][3])
- return ((out * persinv) / w) - rv3d.view_matrix.inverted()[3].xyz
+ return ((persinv * out) / w) - rv3d.view_matrix.inverted()[3].xyz
else:
return rv3d.view_matrix.inverted()[2].xyz.normalized()
@@ -116,7 +116,7 @@ def location_3d_to_region_2d(region, rv3d, coord):
"""
from mathutils import Vector
- prj = Vector((coord[0], coord[1], coord[2], 1.0)) * rv3d.perspective_matrix
+ prj = rv3d.perspective_matrix * Vector((coord[0], coord[1], coord[2], 1.0))
if prj.w > 0.0:
width_half = region.width / 2.0
height_half = region.height / 2.0
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 7cd10fc05bc..056899d7bda 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -144,21 +144,21 @@ class _GenericBone:
""" Vector pointing down the x-axis of the bone.
"""
from mathutils import Vector
- return Vector((1.0, 0.0, 0.0)) * self.matrix.to_3x3()
+ return self.matrix.to_3x3() * Vector((1.0, 0.0, 0.0))
@property
def y_axis(self):
""" Vector pointing down the x-axis of the bone.
"""
from mathutils import Vector
- return Vector((0.0, 1.0, 0.0)) * self.matrix.to_3x3()
+ return self.matrix.to_3x3() * Vector((0.0, 1.0, 0.0))
@property
def z_axis(self):
""" Vector pointing down the x-axis of the bone.
"""
from mathutils import Vector
- return Vector((0.0, 0.0, 1.0)) * self.matrix.to_3x3()
+ return self.matrix.to_3x3() * Vector((0.0, 0.0, 1.0))
@property
def basename(self):
@@ -294,9 +294,9 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup):
:type roll: bool
"""
from mathutils import Vector
- z_vec = Vector((0.0, 0.0, 1.0)) * self.matrix.to_3x3()
- self.tail = self.tail * matrix
- self.head = self.head * matrix
+ z_vec = self.matrix.to_3x3() * Vector((0.0, 0.0, 1.0))
+ self.tail = matrix * self.tail
+ self.head = matrix * self.head
if scale:
scalar = matrix.median_scale
@@ -304,7 +304,7 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup):
self.tail_radius *= scalar
if roll:
- self.align_roll(z_vec * matrix)
+ self.align_roll(matrix * z_vec)
def ord_ind(i1, i2):