# HG changeset patch # User Thibaut Girka # Date 1315159440 -7200 # Node ID ca571697ec83b8afa9dfbdda26e027cd6fe3a80a # Parent d167280a82fc6a359567d1f42cbd4a0f1fecc5c7 Various minor optimisations and refactoring diff --git a/eclviewer.py b/eclviewer.py --- a/eclviewer.py +++ b/eclviewer.py @@ -154,9 +154,7 @@ def main(path, stage_num): glTranslatef(-x, -y, -z) glEnable(GL_DEPTH_TEST) - objects_by_texture = {} - background.get_objects_by_texture(objects_by_texture) - for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in objects_by_texture.items(): + for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items(): glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) glVertexPointer(3, GL_FLOAT, 0, vertices) @@ -179,7 +177,7 @@ def main(path, stage_num): glDisable(GL_FOG) objects_by_texture = {} enemy_manager.get_objects_by_texture(objects_by_texture) - for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in objects_by_texture.items(): + for (texture_key, blendfunc), (vertices, uvs, colors) in objects_by_texture.items(): nb_vertices = len(vertices) glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) diff --git a/pytouhou/formats/std.py b/pytouhou/formats/std.py --- a/pytouhou/formats/std.py +++ b/pytouhou/formats/std.py @@ -19,9 +19,11 @@ from pytouhou.utils.helpers import read_ logger = get_logger(__name__) -class Object(object): +class Model(object): def __init__(self): - self.header = (b'\x00') * 28 #TODO + self.unknown = 0 + self.bounding_box = (0., 0., 0., + 0., 0., 0.) self.quads = [] @@ -31,7 +33,7 @@ class Stage(object): self.num = num self.name = '' self.bgms = (('', ''), ('', ''), ('', '')) - self.objects = [] + self.models = [] self.object_instances = [] self.script = [] @@ -40,7 +42,7 @@ class Stage(object): def read(cls, file, num): stage = Stage(num) - nb_objects, nb_faces = unpack('