Skip to content

Instantly share code, notes, and snippets.

@zvodd
zvodd / havok_wasm_physics_sim.ts
Last active November 3, 2024 04:25
Do physics sim asynchronously / not locked to renderer. Absolutely borked way to use havok_wasm.
import HavokPhysics, {
HavokPhysicsWithBindings,
Result, HP_ShapeId
} from "@babylonjs/havok";
// Global variable to store the initialized Havok physics engine
globalThis['HK'] = (await HavokPhysics()) as HavokPhysicsWithBindings;
const HK : HavokPhysicsWithBindings = globalThis.HK;
// Define helper functions for common physics types (Vector3, Quaternion, etc.)
@zvodd
zvodd / GridVertexSnap.py
Created October 12, 2024 03:39
Blender Operator + Panel: Snaps selected vertices to virtual 3d grid.
import bpy
import bmesh
from mathutils import Vector
from bpy.props import BoolProperty, FloatVectorProperty
from bpy.types import Operator, Panel, PropertyGroup
#######################
# Props
#######################
@zvodd
zvodd / loadenv.bat
Last active October 3, 2024 15:23
load a dotenv file in windows cmd line - doesn't support values containing `=`
@echo off
if "%~1"=="" (
set "ENV_FILE=%CD%\.env"
) else (
set "ENV_FILE=%~1"
)
if not exist "%ENV_FILE%" (
echo Error: %ENV_FILE% file not found
exit /b 1
@zvodd
zvodd / 3d-graphics-spaces-and-matrices.md
Last active September 9, 2024 09:50
3D Spaces and Matrices in Godot 4 Shaders

Vertex and Fragment Function Spaces

  1. Vertex Function:

    • Input: Model Space (Local Space)
    • Output: Clip Space
  2. Fragment Function:

    • Input: View Space (Camera Space)

Coordinate Spaces

@zvodd
zvodd / geom_node_instance_positions.py
Last active September 8, 2024 19:35
Blender 4 instance enumeration - Including unrealized Geometry Node generated instances.
import bpy
# https://docs.blender.org/api/current/bpy.types.Depsgraph.html
# https://docs.blender.org/api/current/bpy.types.DepsgraphObjectInstance.html
def report_instances(obj):
"""
Reports the instances under an object in the Blender scene.
Including unrealized Geometry Node generated instances.
@zvodd
zvodd / gallery_overlay_modal.py
Last active September 4, 2024 16:21
Blender 4 Image Gallery Overlay
@zvodd
zvodd / vFacePaint.py
Last active July 26, 2024 20:20
Blender Vertex Face Brush [tested in 3.6]
#
# Add a tool to vertex paint mode that paints by FACE
#
import bpy
import bmesh
from mathutils import Vector
from bpy.types import WorkSpaceTool
from bl_ui.space_toolsystem_common import ToolDef
from bpy_extras import view3d_utils
@zvodd
zvodd / synth_sound_demo.py
Last active March 3, 2024 02:15
pygame, pyaudio, additive "synth" demo with bandpass filter.
import pygame
import pygame_gui
import math
import pyaudio
import struct
SCREEN_X = 800
SCREEN_Y = 600
SCOPE_DIMS = (SCREEN_X//4, SCREEN_Y // 4)
@zvodd
zvodd / wave_combiner.py
Created February 24, 2023 10:18
pygame + pyaudio "synth": wave generation inspection and filtering
import pygame
import pygame_gui
import math
import pyaudio
import struct
SCREEN_X = 800
SCREEN_Y = 600
SCOPE_DIMS = (SCREEN_X//4, SCREEN_Y // 4)
@zvodd
zvodd / spiralout.py
Created February 23, 2023 07:34
pygame spiral markov chain pixels
import pygame
import numpy as np
SCREEN_X = 256
SCREEN_Y = 256
GRID_SIZE = SCREEN_X //6
CELL_W = SCREEN_X // GRID_SIZE
CELL_H = SCREEN_Y // GRID_SIZE