Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="blender::StringRef">
<DisplayString>{data_}</DisplayString>
<Expand>
<Item Name="[size]">size_</Item>
<Item Name="[data]">data_</Item>
</Expand>
</Type>
</AutoVisualizer>
uint a = BLI_rng_get_uint(rng);
uint b = 0x3F800000 | (0x007FFFFF & a);
float c = *(float *)&b;
return c - 1.0f;
import bpy
from dataclasses import dataclass
from itertools import islice
@dataclass
class Rectangle:
x: float
y: float
width: float
height: float
@JacquesLucke
JacquesLucke / llvm_add.cc
Created November 30, 2018 14:54
Compile simple add function using the LLVM C++ API.
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include <vector>
#include <memory>
void test_llvm() {
llvm::LLVMContext *context = new llvm::LLVMContext();
@JacquesLucke
JacquesLucke / auto_load.py
Last active January 28, 2024 13:45
Utility to (un)register all classes in a Blender addon.
import os
import bpy
import sys
import typing
import inspect
import pkgutil
import importlib
from pathlib import Path
__all__ = (
static PyObject *get_external_function(const char *module_name, const char *function_name)
{
PyObject *module = PyImport_ImportModule(module_name);
PyObject *globals = PyModule_GetDict(module);
PyObject *function = PyDict_GetItemString(globals, function_name);
Py_DecRef(module);
return function;
}
static PyObject *call_external_method(
from math import ceil
from random import randint
def mergesort(A):
B = [None] * len(A)
chunk_size = 1
while chunk_size < len(A):
for i in range(ceil(len(A) / chunk_size / 2)):
merge(A, B,
start1 = 2 * i * chunk_size,
@JacquesLucke
JacquesLucke / setup.py
Created November 1, 2017 17:04
Simple setup.py that also checks if cython exists or not. Also allows for extra .c files.
sources = [
("test1.pyx", []),
("test2.pyx", ["extra.c"])
]
import os
import sys
def main():
if cython_exists():
@JacquesLucke
JacquesLucke / midi_input_node.py
Last active October 23, 2017 17:54
Idea for the structure of a simple Midi Input node.
import bpy
from bpy.props import *
from ... base_types import AnimationNode
from ... data_structures import DoubleList
class MidiNoteData(bpy.types.PropertyGroup):
noteName = StringProperty() # e.g. C4, B5, ...
# This value can be keyframed.
# It is possible but not easy to 'find' the fcurve of this property.
# Therefor only the value in the current frame can be accessed efficiently.