def loadColliders(colliders): print 'loadColliders start' paths = [(typ, glob.glob(glob_path), scale) for (typ, (glob_path, scale)) in colliders.items()] lookup_paths = {} for (typ, path_list, scale) in paths: if typ not in lookup_paths: lookup_paths[typ] = [] lookup_paths[typ].extend([(getNativePath(p), scale) for p in path_list]) manage.lookup_colliders = {} for (typ, path_list, scale) in paths: #lookup_paths[typ][:]=[ (getNativePath(p), scale) # for (p, scale) in lookup_paths[typ] ] num_paths = len(lookup_paths[typ]) coll_arr = collider.allocColliders(num_paths) #lookup_colliders[typ]=object3dLib.allocColliders(num_paths) idx = 0 print 'loadColliders. in paths: ' + str((typ, path_list, scale)) for (path, scale) in lookup_paths[typ]: print 'loadColliders. pathScale: ' + str((path, scale)) collider.loadCollider(coll_arr, idx, path, scale) idx += 1 collider.identifyBigCollider(coll_arr, num_paths) manage.lookup_colliders[typ] = (num_paths, coll_arr)
def loadMeshes(mesh_paths, views): # mesh_paths = { <(TYP, view): (all, not)>* } # all = [ (glob_path, (mesh_constructor, scale, <group|None>))* ] # not = [ glob_path* ] # <something>* = something, something, something, ..., something print 'loadMeshes. mesh_paths: ' + str(mesh_paths) lookup = {} global meshes meshes = {} global vbo_meshes vbo_meshes = {} global name_to_mesh name_to_mesh = {} paths = {} def genGlobbedList(glob_path, cls, scale, group, blacklisted): globs = glob.glob(getNativePath(glob_path)) return [(path, (cls, scale, group)) for path in globs if path not in blacklisted] for mesh_key in mesh_paths: all_possible_globs = mesh_paths[mesh_key][0] blacklist = list( itertools.chain(*[ glob.glob(getNativePath(black_glob)) for black_glob in mesh_paths[mesh_key][1] ])) paths[mesh_key] = dict( itertools.chain(*[ genGlobbedList(glob_path, cls, scale, group, blacklist) for (glob_path, (cls, scale, group)) in all_possible_globs ])).items() # paths does not contain any path found in not list above # paths = { <(TYP, view) : { <path : (mesh_constructor, scale, group)>* } >* } def c_ifyGroup(group): if group is None: return NO_VBO_GROUP else: return group print 'loadMeshes: paths: ' + str(paths) for key in mesh_paths: meshes[key] = [ cls(collider.load(path, scale, c_ifyGroup(group)), views, key, group) for (path, (cls, scale, group)) in paths[key] ] # meshes = { <(TYP, view): mesh_inst>* } for mesh_key in dict(meshes): [m.finishInit() for m in meshes[mesh_key]] vbo_meshes[mesh_key] = [ m for m in meshes[mesh_key] if m.group is not None and manage.vbo ] meshes[mesh_key] = [ m for m in meshes[mesh_key] if m.group is None or not manage.vbo ]
def loadMeshes(mesh_paths, views): # mesh_paths = { <(TYP, view): (all, not)>* } # all = [ (glob_path, (mesh_constructor, scale, <group|None>))* ] # not = [ glob_path* ] # <something>* = something, something, something, ..., something print 'loadMeshes. mesh_paths: '+str(mesh_paths) lookup = {} global meshes meshes = {} global vbo_meshes vbo_meshes = {} global name_to_mesh name_to_mesh = {} paths = {} def genGlobbedList(glob_path, cls, scale, group, blacklisted): globs=glob.glob(getNativePath(glob_path)) return [ (path, (cls, scale, group)) for path in globs if path not in blacklisted] for mesh_key in mesh_paths: all_possible_globs=mesh_paths[mesh_key][0] blacklist=list(itertools.chain(*[ glob.glob(getNativePath(black_glob)) for black_glob in mesh_paths[mesh_key][1]])) paths[mesh_key]=dict(itertools.chain(*[ genGlobbedList(glob_path, cls, scale, group, blacklist) for (glob_path, (cls, scale, group)) in all_possible_globs ])).items() # paths does not contain any path found in not list above # paths = { <(TYP, view) : { <path : (mesh_constructor, scale, group)>* } >* } def c_ifyGroup(group): if group is None: return NO_VBO_GROUP else: return group print 'loadMeshes: paths: '+str(paths) for key in mesh_paths: meshes[key]=[ cls(collider.load(path, scale, c_ifyGroup(group)), views, key, group) for (path, (cls, scale, group)) in paths[key]] # meshes = { <(TYP, view): mesh_inst>* } for mesh_key in dict(meshes): [ m.finishInit() for m in meshes[mesh_key] ] vbo_meshes[mesh_key]=[ m for m in meshes[mesh_key] if m.group is not None and manage.vbo] meshes[mesh_key]=[ m for m in meshes[mesh_key] if m.group is None or not manage.vbo]
def loadColliders( colliders ): print 'loadColliders start' paths=[ (typ, glob.glob(glob_path), scale) for (typ, (glob_path, scale)) in colliders.items() ] lookup_paths={} for (typ, path_list, scale) in paths: if typ not in lookup_paths: lookup_paths[typ]=[] lookup_paths[typ].extend([ (getNativePath(p), scale) for p in path_list ]) manage.lookup_colliders={} for (typ, path_list, scale) in paths: #lookup_paths[typ][:]=[ (getNativePath(p), scale) # for (p, scale) in lookup_paths[typ] ] num_paths=len(lookup_paths[typ]) coll_arr=collider.allocColliders(num_paths) #lookup_colliders[typ]=object3dLib.allocColliders(num_paths) idx=0 print 'loadColliders. in paths: '+str((typ, path_list, scale)) for (path, scale) in lookup_paths[typ]: print 'loadColliders. pathScale: '+str((path,scale)) collider.loadCollider(coll_arr, idx, path, scale) idx+=1 collider.identifyBigCollider(coll_arr, num_paths) manage.lookup_colliders[typ]=(num_paths, coll_arr)
def genGlobbedList(glob_path, cls, scale, group, blacklisted): globs=glob.glob(getNativePath(glob_path)) return [ (path, (cls, scale, group)) for path in globs if path not in blacklisted]
def genGlobbedList(glob_path, cls, scale, group, blacklisted): globs = glob.glob(getNativePath(glob_path)) return [(path, (cls, scale, group)) for path in globs if path not in blacklisted]