Skip to content

Instantly share code, notes, and snippets.

@vurtun
vurtun / visgrid.c
Last active September 30, 2026 00:27
High-Performance Spatial Indexing Engine
/* ======================================================================================
* VISGRID — High-Performance Spatial Indexing Engine
* ======================================================================================
*
* DESCRIPTION:
* Visgrid is a specialized, embedded-grade spatial database designed for highly
* interactive node graphs, infinite canvas UI, and real-time 2D simulations.
* It implements a "Linearized Implicit Quadtree" using Z-Order curves (Morton Codes)
* backed by a memory-mapped B-Tree (LMDB).
*
@vurtun
vurtun / _GJK.md
Last active June 8, 2026 20:25
3D Gilbert–Johnson–Keerthi (GJK) distance algorithm

Gilbert–Johnson–Keerthi (GJK) 3D distance algorithm

The Gilbert–Johnson–Keerthi (GJK) distance algorithm is a method of determining the minimum distance between two convex sets. The algorithm's stability, speed which operates in near-constant time, and small storage footprint make it popular for realtime collision detection.

Unlike many other distance algorithms, it has no requirments on geometry data to be stored in any specific format, but instead relies solely on a support function to iteratively generate closer simplices to the correct answer using the Minkowski sum (CSO) of two convex shapes.

@vurtun
vurtun / _readme_quarks.md
Last active June 7, 2026 21:25
Quarks: Graphical user interface

gui

@vurtun
vurtun / Library writing.txt
Created September 12, 2016 11:20
Library writing
LIBRARY WRITING REFERENCE LIST
===============================
1.) Designing and Evaluating Reusable Components (Casey Muratori: http://mollyrocket.com/casey/stream_0028.html)
----------------------------------------------------------------------------------------------------------------
_THE_ reference on API design up to this day on the internet. Nobody should write a library without having seen this.
I come back to this talk every N number of weeks it is that good.
2.) stb_howto (Sean Barrett: https://github.com/nothings/stb/blob/master/docs/stb_howto.txt)
--------------------------------------------------------------------------------------------
Sean Barretts single header libraries (https://github.com/nothings/stb) was the first time for me that I came across
@vurtun
vurtun / api.md
Last active June 2, 2026 22:28
API Design: Modular Data-oriented processes

API Design: Modular Data-oriented processes (June-2017)

This is the second entry in my series about API design. While I wrote about granularity and request based APIs in my last post I want to write about API design and code architecture for modular data-oriented process this time. This is basically the write up of my findings while writing and finishing the core of my current GUI research quarks.

Actually sparking my interest for writing up my findings however was rasmusbarr@github (rasmusbarr@twitter) releasing his small data-oriented and SIMD-optimized 3D rigid body physics library. I noticed a lot of overlap in design between his physics and my GUI library and wanted to write up some general thoughts about what seems

API Design: Coroutines APIs (Janurary-2017)

I am currently dealing with a lot of libraries at work. Both third party as well as libraries written or being currently in process of being written by me. I absolutely love writing and working with libraries. Especially if they present or bring me to either a new or different approach to solve a problem. Or at least provide a different view.

Over time I noticed however that quite regulary we had to decide that we cannot use a third party library. Often it is the usual reason.

@vurtun
vurtun / defl.c
Last active March 26, 2026 01:27
Full deflate/inflate implementation in ~300 LoC
/* ===============================================================
* SDEFL
* ===============================================================
* public domain - no warranty implied; use at your own risk
* References:
https://bitbucket.org/rmitton/tigr/src/be3832bee7fb2f274fe5823e38f8ec7fa94e0ce9/src/tigr_inflate.c?at=default&fileviewer=file-view-default
https://github.com/github/putty/blob/49fb598b0e78d09d6a2a42679ee0649df482090e/sshzlib.c
https://www.ietf.org/rfc/rfc1951.txt
*/
#include <stdlib.h>
@vurtun
vurtun / chain.c
Last active March 5, 2026 13:17
3D XPBD CHAIN SIMULATION
#include <immintrin.h>
#include <math.h>
#include <assert.h>
#include <string.h>
/* --- Compiler Feature Macros --- */
#if defined(_MSC_VER)
#define ALWAYS_INLINE __forceinline
#define RESTRICT __restrict
#define ALIGN_VAR(x) __declspec(align(x))
@vurtun
vurtun / fibers.c
Last active February 10, 2026 19:01
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <string.h>
#define streq(a, b) (!strcmp((a), (b)))
#ifndef __USE_GNU
#define __USE_GNU
@vurtun
vurtun / layout.c
Last active February 1, 2026 13:18
// --- Library --------------------------------------------------------------------------
#include <string.h>
#include <assert.h>
struct ui_box {int x,y,w,h;};
typedef unsigned long long ui_id;
struct ui_node {
int parent;
int lst, end, nxt;
int siz[2];