comparison pytouhou/ui/background.pyx @ 397:c5ba11ede097

Don’t duplicate values in sprite rendering data.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 06 Feb 2013 21:41:05 +0100
parents 98c64ffcbdff
children
comparison
equal deleted inserted replaced
396:34a91f918e7c 397:c5ba11ede097
34 colors = [] 34 colors = []
35 35
36 for ox, oy, oz, model_id, model in background.object_instances: 36 for ox, oy, oz, model_id, model in background.object_instances:
37 for ox2, oy2, oz2, width_override, height_override, sprite in model: 37 for ox2, oy2, oz2, width_override, height_override, sprite in model:
38 #TODO: view frustum culling 38 #TODO: view frustum culling
39 key, (vertices2, uvs2, colors2) = get_sprite_rendering_data(sprite) 39 key, (vertices2, (left, right, bottom, top), colors2) = get_sprite_rendering_data(sprite)
40 vertices.extend([(x + ox + ox2, y + oy + oy2, z + oz + oz2) 40 vertices.extend([(x + ox + ox2, y + oy + oy2, z + oz + oz2)
41 for x, y, z in vertices2]) 41 for x, y, z in vertices2])
42 uvs.extend(uvs2) 42 uvs.extend((left, bottom, right, bottom, right, top, left, top))
43 colors.extend(colors2) 43 colors.extend(colors2 * 4)
44 44
45 nb_vertices = len(vertices) 45 nb_vertices = len(vertices)
46 vertices_s = pack(str(3 * nb_vertices) + 'f', *chain(*vertices)) 46 vertices_s = pack(str(3 * nb_vertices) + 'f', *chain(*vertices))
47 uvs_s = pack(str(2 * nb_vertices) + 'f', *uvs) 47 uvs_s = pack(str(2 * nb_vertices) + 'f', *uvs)
48 colors_s = pack(str(4 * nb_vertices) + 'B', *colors) 48 colors_s = pack(str(4 * nb_vertices) + 'B', *colors)