View webgpu-raii.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using https://github.com/eliemichel/WebGPU-Cpp | |
#include <webgpu/webgpu.hpp> | |
namespace raii { | |
class Buffer { | |
public: | |
// Whenever a RAII instance is created, we create an underlying resource | |
Buffer(wgpu::Device device, const wgpu::BufferDescriptor& bufferDesc) | |
: m_raw(device.createBuffer(bufferDesc)) | |
{} |
View save_texture.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stb_image_write.h" | |
#include <webgpu/webgpu.hpp> | |
#include <filesystem> | |
#include <string> | |
bool saveTexture(const std::filesystem::path path, wgpu::Device device, wgpu::Texture texture, int mipLevel) { | |
using namespace wgpu; | |
View save_texture_view.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stb_image_write.h" | |
#include <webgpu/webgpu.hpp> | |
#include <filesystem>h | |
#include <string> | |
std::filesystem::path resolvePath(int frame) { | |
std::filesystem::path base = "render/frame" + std::to_string(frame) + ".png"; | |
create_directories(base.parent_path()); |
View local_import.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def local_import(module_name): | |
exec('\n'.join([l.body for l in bpy.data.texts[module_name].lines])) | |
for k, v in locals().items(): | |
globals()[k] = v | |
# Example | |
import bpy | |
import bmesh | |
import numpy as np | |
local_import('tiny_timer.py') |
View tiny_timer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits 2020-2022 to Élie Michel <elie.michel@exppad.com> | |
# Released in Public Domain | |
# | |
# The Software is provided "as is", without warranty of any kind, express or | |
# implied, including but not limited to the warranties of merchantability, | |
# fitness for a particular purpose and non-infringement. In no event shall the | |
# authors or copyright holders be liable for any claim, damages or other | |
# liability, whether in an action of contract, tort or otherwise, arising | |
# from, out of or in connection with the software or the use or other dealings | |
# in the Software. |
View blender_duplicate_node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def duplicate_node(n1, node_group=None, duplicate_links=False): | |
""" | |
Duplicate a node (without duplicating its links) | |
@param n1 The node to duplicate | |
@param node_group (optional) Group in which the node must be duplicated | |
@param duplicate_links Whether to keep input links or not | |
@return the new duplicate node | |
""" |
View node_geo_pizza.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [...] | |
/** | |
* Create a new Mesh representing a simple pizza (really just a disc with | |
* a few quads on top of it). | |
* olive_count is the number of olives topping the pizza | |
* radius is the radius of the pizza | |
* base_polys is filled with the range of polygons belonging to the base | |
* olive_polys is filled with the range of polygons representing the olives | |
*/ |
View git_resolve.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an automation of https://stackoverflow.com/questions/71783590/git-merge-strategy-option-theirs-for-individual-files | |
# Example: | |
# git_resolve.py --theirs path/to/some/file | |
import os | |
import argparse | |
from shutil import copyfile | |
import subprocess | |
parser = argparse.ArgumentParser(description='Resolve conflicted areas of a file during a git merge') |
View CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.7..3.20) | |
project(MyTest LANGUAGES CXX) | |
set(OpenVDB_INSTALL_DIR "" CACHE STRING "Directory specified as CMAKE_INSTALL_PREFIX when building OpenVDB") | |
list(APPEND CMAKE_MODULE_PATH "${OpenVDB_INSTALL_DIR}/lib/cmake/OpenVDB") | |
set(OPENVDB_USE_STATIC_LIBS ON) | |
find_package(OpenVDB COMPONENTS openvdb REQUIRED) |
View TinyTimer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple timer library. | |
* | |
* Basic usage: | |
* using TinyTimer::Timer; | |
* Timer timer; | |
* // .. do something | |
* cout << "Something took " << timer.ellapsed() << " seconds" << endl; | |
* | |
* One can also consolidate several timings to measure standard deviation: |
NewerOlder