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:
authorCampbell Barton <ideasman42@gmail.com>2018-05-13 18:10:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-13 18:10:20 +0300
commit64245e735c392bd2b0d368006379822f00818b6c (patch)
treeaa2d41d9a597eb8a394d587dbf38c9c7e1a9b8d5 /release/datafiles/blender_icons_geom.py
parenta23995f42a662533f24764f9051a70b224aa77d7 (diff)
Icons: fix z-sorting
Was depth sorting per mesh.
Diffstat (limited to 'release/datafiles/blender_icons_geom.py')
-rw-r--r--release/datafiles/blender_icons_geom.py56
1 files changed, 31 insertions, 25 deletions
diff --git a/release/datafiles/blender_icons_geom.py b/release/datafiles/blender_icons_geom.py
index f983ffd356c..e9155a91fc8 100644
--- a/release/datafiles/blender_icons_geom.py
+++ b/release/datafiles/blender_icons_geom.py
@@ -113,11 +113,7 @@ def mesh_data_lists_from_mesh(me, material_colors):
me_verts = me.vertices[:]
me_polys = me.polygons[:]
- # 100 layers of depth
- me_polys.sort(key=lambda p: int(p.center.z * 100))
-
- tris_coords = []
- tris_colors = []
+ tris_data = []
for p in me_polys:
# Backface culling (allows using spheres without tedious manual deleting).
@@ -153,22 +149,27 @@ def mesh_data_lists_from_mesh(me, material_colors):
v1 = me_verts[l1.vertex_index]
v2 = me_verts[l2.vertex_index]
- tris_coords.append((
- v0.co.xy[:],
- v1.co.xy[:],
- v2.co.xy[:],
+ tris_data.append((
+ # float depth
+ p.center.z,
+ # XY coords.
+ (
+ v0.co.xy[:],
+ v1.co.xy[:],
+ v2.co.xy[:],
+ ),
+ # RGBA color.
+ tuple((
+ [int(c * b * 255) for c, b in zip(cn.color, base_color)]
+ for cn in (c0, c1, c2)
+ )),
))
- # Color as RGBA for each tri
- tris_colors.append(
- [[int(c * b * 255) for c, b in zip(cn.color, base_color)] for cn in (c0, c1, c2)]
- )
i1 = i2
- return (tris_coords, tris_colors)
+ return tris_data
def mesh_data_lists_from_objects(ob_parent, ob_children):
- tris_coords = []
- tris_colors = []
+ tris_data = []
has_parent = False
if ob_children:
@@ -179,14 +180,15 @@ def mesh_data_lists_from_objects(ob_parent, ob_children):
with TriMesh(ob) as me:
if has_parent:
me.transform(parent_matrix_inverted * ob.matrix_world)
- tris_coords_iter, tris_colors_iter = mesh_data_lists_from_mesh(
- me,
- object_material_colors(ob),
+
+ tris_data.extend(
+ mesh_data_lists_from_mesh(
+ me,
+ object_material_colors(ob),
+ )
)
- tris_coords.extend(tris_coords_iter)
- tris_colors.extend(tris_colors_iter)
has_parent = True
- return tris_coords, tris_colors
+ return tris_data
def write_mesh_to_py(fh, ob, ob_children):
@@ -204,7 +206,11 @@ def write_mesh_to_py(fh, ob, ob_children):
float_as_byte(v[1], coords_range_align[1]),
)
- tris_coords, tris_colors = mesh_data_lists_from_objects(ob, ob_children)
+ tris_data = mesh_data_lists_from_objects(ob, ob_children)
+
+ # 100 levels of Z depth, round to avoid differences from precision error
+ # causing different computers to write triangles in more or less random order.
+ tris_data.sort(key=lambda data: int(data[0] * 100))
if 0:
# make as large as we can, keeping alignment
@@ -237,10 +243,10 @@ def write_mesh_to_py(fh, ob, ob_children):
# X, Y
fw(bytes((0, 0)))
- for tri_coords in tris_coords:
+ for (_, tri_coords, _) in tris_data:
for vert in tri_coords:
fw(bytes(vert_as_byte_pair(vert)))
- for tri_color in tris_colors:
+ for (_, _, tri_color) in tris_data:
for color in tri_color:
fw(bytes(color))