more python 2.3 compat, should be the last of it.
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
# Tooltip: 'Export to DirectX text file format format for XNA Animation Component Library.'
|
# Tooltip: 'Export to DirectX text file format format for XNA Animation Component Library.'
|
||||||
"""
|
"""
|
||||||
__author__ = "vertex color exporting feature is added by mnemoto (original:minahito (original:Arben (Ben) Omari))"
|
__author__ = "vertex color exporting feature is added by mnemoto (original:minahito (original:Arben (Ben) Omari))"
|
||||||
__url__ = ("blender", "elysiun", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/")
|
__url__ = ("blender.org", "blenderartists.org", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/")
|
||||||
__version__ = "3.1"
|
__version__ = "3.1"
|
||||||
|
|
||||||
__bpydoc__ = """\
|
__bpydoc__ = """\
|
||||||
|
|||||||
@@ -47,6 +47,12 @@ def AngleBetweenVecs(a1,a2):
|
|||||||
except:
|
except:
|
||||||
return 180.0
|
return 180.0
|
||||||
|
|
||||||
|
# python 2.3 has no reversed() iterator. this will only work on lists and tuples
|
||||||
|
try:
|
||||||
|
reversed
|
||||||
|
except:
|
||||||
|
def reversed(l): return l[::-1]
|
||||||
|
|
||||||
class prettyface(object):
|
class prettyface(object):
|
||||||
__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
|
__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
@@ -451,7 +457,10 @@ PREF_MARGIN_DIV= 512):
|
|||||||
# Even boxes in groups of 4
|
# Even boxes in groups of 4
|
||||||
for d, boxes in even_dict.items():
|
for d, boxes in even_dict.items():
|
||||||
if d < max_int_dimension:
|
if d < max_int_dimension:
|
||||||
boxes.sort(key = lambda a: len(a.children))
|
# py 2.3 compat
|
||||||
|
try: boxes.sort(key = lambda a: len(a.children))
|
||||||
|
except: boxes.sort(lambda a, b: cmp(len(a.children), len(b.children)))
|
||||||
|
|
||||||
while len(boxes) >= 4:
|
while len(boxes) >= 4:
|
||||||
# print "bar", len(boxes)
|
# print "bar", len(boxes)
|
||||||
ok = True
|
ok = True
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ def AngleBetweenVecsSafe(a1, a2):
|
|||||||
except:
|
except:
|
||||||
return 180.0
|
return 180.0
|
||||||
|
|
||||||
|
# Python 2.3 has no reversed.
|
||||||
|
try:
|
||||||
|
reversed
|
||||||
|
except:
|
||||||
|
def reversed(l): return l[::-1]
|
||||||
|
|
||||||
# Copied from blender, we could wrap this! - BKE_curve.c
|
# Copied from blender, we could wrap this! - BKE_curve.c
|
||||||
# But probably not toooo bad in python
|
# But probably not toooo bad in python
|
||||||
def forward_diff_bezier(q0, q1, q2, q3, pointlist, steps, axis):
|
def forward_diff_bezier(q0, q1, q2, q3, pointlist, steps, axis):
|
||||||
@@ -268,7 +274,7 @@ class tree:
|
|||||||
# Sort from big to small, so big branches get priority
|
# Sort from big to small, so big branches get priority
|
||||||
# Py 2.3 dosnt have keywords in sort
|
# Py 2.3 dosnt have keywords in sort
|
||||||
try: self.branches_all.sort( key = lambda brch: -brch.bpoints[0].radius )
|
try: self.branches_all.sort( key = lambda brch: -brch.bpoints[0].radius )
|
||||||
except: self.branches_all.sort( lambda brch_a, brch_b: cmp(brch_b.bpoints[0].radius, brch_a.bpoints[0].radius) )
|
except: self.branches_all.sort( lambda brch_a, brch_b: cmp(brch_b.bpoints[0].radius, brch_a.bpoints[0].radius) ) # py2.3
|
||||||
|
|
||||||
|
|
||||||
def closestBranchPt(self, co):
|
def closestBranchPt(self, co):
|
||||||
@@ -1146,7 +1152,8 @@ class tree:
|
|||||||
|
|
||||||
# Try sorting by other properties! this is ok for now
|
# Try sorting by other properties! this is ok for now
|
||||||
for segments_level_current in segments_level:
|
for segments_level_current in segments_level:
|
||||||
segments_level_current.sort( key = lambda seg: -(seg.headCo-seg.tailCo).length )
|
try: segments_level_current.sort( key = lambda seg: -(seg.headCo-seg.tailCo).length )
|
||||||
|
except: segments_level_current.sort( lambda a,b: cmp((b.headCo-b.tailCo).length, (a.headCo-a.tailCo).length) ) # py2.3
|
||||||
|
|
||||||
for level in xrange(twig_fill_levels):
|
for level in xrange(twig_fill_levels):
|
||||||
if len(segments_level) > level:
|
if len(segments_level) > level:
|
||||||
@@ -1372,18 +1379,23 @@ class tree:
|
|||||||
|
|
||||||
# Get the branches based on our selection method!
|
# Get the branches based on our selection method!
|
||||||
if twig_select_mode==0:
|
if twig_select_mode==0:
|
||||||
branches_sorted.sort( key = lambda brch: brch.getLength())
|
try: branches_sorted.sort( key = lambda brch: brch.getLength())
|
||||||
|
except: branches_sorted.sort( lambda a,b: cmp(a.getLength(),a.getLength()) ) # py2.3
|
||||||
elif twig_select_mode==1:
|
elif twig_select_mode==1:
|
||||||
branches_sorted.sort( key = lambda brch:-brch.getLength())
|
try: branches_sorted.sort( key = lambda brch:-brch.getLength())
|
||||||
|
except: branches_sorted.sort( lambda a,b: cmp(b.getLength(), a.getLength()) ) # py2.3
|
||||||
elif twig_select_mode==2:
|
elif twig_select_mode==2:
|
||||||
branches_sorted.sort( key = lambda brch:brch.getStraightness())
|
try: branches_sorted.sort( key = lambda brch:brch.getStraightness())
|
||||||
|
except: branches_sorted.sort( lambda a,b: cmp(a.getStraightness(), b.getStraightness())) # py2.3
|
||||||
elif twig_select_mode==3:
|
elif twig_select_mode==3:
|
||||||
branches_sorted.sort( key = lambda brch:-brch.getStraightness())
|
try: branches_sorted.sort( key = lambda brch:-brch.getStraightness())
|
||||||
|
except: branches_sorted.sort( lambda a,b: cmp(b.getStraightness(), a.getStraightness())) # py2.3
|
||||||
|
|
||||||
factor_int = int(len(self.branches_all) * twig_select_factor)
|
factor_int = int(len(self.branches_all) * twig_select_factor)
|
||||||
branches_sorted[factor_int:] = [] # remove the last part of the list
|
branches_sorted[factor_int:] = [] # remove the last part of the list
|
||||||
|
|
||||||
branches_sorted.sort( key = lambda brch: len(brch.bpoints))
|
try: branches_sorted.sort( key = lambda brch: len(brch.bpoints))
|
||||||
|
except: branches_sorted.sort( lambda a,b: cmp(len(a.bpoints), len(b.bpoints)) ) # py2.3
|
||||||
|
|
||||||
branches_new = []
|
branches_new = []
|
||||||
#for i in xrange(ratio_int):
|
#for i in xrange(ratio_int):
|
||||||
|
|||||||
Reference in New Issue
Block a user