def rebuild_on_render(self, shader): """Fill the VAO with new mesh data. This "safe" version uses foreach_get() operations to fetch data. Parameters: shader (BaseShader): Shader program that houses the VAO target """ init_log('Rebuild on Render: {}'.format(self)) vao = self.vao mesh = self.eval_obj.to_mesh() log('to_mesh() from {}'.format(id(self.eval_obj))) mesh.calc_loop_triangles() log('calc_loop_triangles()') vertices_len = len(mesh.vertices) loops_len = len(mesh.loops) looptris_len = len(mesh.loop_triangles) # Pipe mesh data into VBOs co = vao.get_vertex_buffer(VertexBuffer.POSITION) co.resize(3, vertices_len) mesh.vertices.foreach_get('co', co.data) log('Upload co') no = vao.get_vertex_buffer(VertexBuffer.NORMAL) no.resize(3, vertices_len) mesh.vertices.foreach_get('normal', no.data) log('Upload no') indices = vao.get_index_buffer() indices.resize(looptris_len * 3) mesh.loop_triangles.foreach_get('vertices', indices.data) log('Upload indices') op_log('Set buffers') # Upload buffers to the GPU vao.upload(shader.program) op_log('Total VAO write time') # Cleanup self.eval_obj.to_mesh_clear() # mesh_owner.to_mesh_clear() op_log('Total Cleanup time')
async def on_ready(): """http://discordpy.readthedocs.io/en/rewrite/api.html#discord.on_ready""" # Changes the bot's Playing Status. type=1(streaming) for a standard game you could remove type and url. await bot.change_presence( status=discord.Status[parsed_args.status], activity=discord.Activity( name=bot.command_prefix + "help" if parsed_args.presence is None else parsed_args.presence, type=discord.ActivityType[parsed_args.presence_type], url='https://twitch.tv/thisisaneasteregg')) debug.log('Successfully logged in!') if parsed_args.message is not None: message = parsed_args.message[1] channel = int(parsed_args.message[0]) await bot.get_channel(channel).send(message)
sys.exit() # Variables # localPath = os.path.dirname(os.path.realpath(__file__)) debugmsgs = "" print("Local path: " + localPath) # Add libs folder to path # if localPath not in sys.path: print("Styleventer path is not in sys.path, updating...") sys.path.append(localPath) print("Using debug.log from now on.") import libs.debug as debug debug.log("Testing,", "testing...") debug.log("Importing assets.py...") import libs.assets as assets class ModuleInfo: def __init__(self, filename, modname, cmds, state): self.filename = filename self.name = modname self.commands = cmds self.state = state # Token and bot loading # if parsed_args.debug: # Stylusventer
def setup(_bot, **kwargs): global modules _bot.add_command(modstatecmd) modules = _bot.moduleInfos debug.log(modules)
def rebuild_on_render_unsafe(self, shader): """Fill the VAO with new mesh data This unsafe version uses direct C struct access to fetch data. Parameters: shader (BaseShader): Shader program that houses the VAO target """ init_log('Rebuild on Render (unsafe): {}'.format(self)) vao = self.vao # depsgraph = bpy.context.evaluated_depsgraph_get() # log('depsgraph {}'.format(depsgraph)) # mesh_owner = self.eval_obj.evaluated_get(depsgraph) # log('mesh_owner {}'.format(mesh_owner)) # mesh = mesh_owner.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph) # Moved to the render thread - otherwise we get access violations when # trying to use multiple viewports. But really - there should only be # one mesh instance across all viewports. mesh = self.eval_obj.to_mesh() log('to_mesh() from {}'.format(id(self.eval_obj))) mesh.calc_loop_triangles() log('calc_loop_triangles()') # mesh = self.eval_mesh # TODO: Could setup on rebuild() update loop instead. data = MeshData(mesh) op_log('Load into MeshData') # Pipe mesh data into VBOs co = vao.get_vertex_buffer(VertexBuffer.POSITION) co.set_data(data.co) log('Upload co') no = vao.get_vertex_buffer(VertexBuffer.NORMAL) no.set_data(data.normals) log('Upload no') # Upload all UV layers as TexcoordN for index in range(data.total_texcoords): # TODO: Somehow use VertexBuffer constants for this instead of Texcoord{} texcoord = vao.get_vertex_buffer('Texcoord{}'.format(index)) texcoord.set_data(data.texcoord(index)) log('Upload texcoord{}'.format(index)) # TODO: What happens when we *remove* a texcoord? # That's not handled currently. indices = vao.get_index_buffer() indices.set_data(data.triangles) log('Upload indices') op_log('Set buffers') # Upload buffers to the GPU vao.upload(shader.program) op_log('Total VAO write time') # Cleanup self.eval_obj.to_mesh_clear() # mesh_owner.to_mesh_clear() op_log('Total Cleanup time')