Skip to content

Instantly share code, notes, and snippets.

/* ======================================================================================
* VISGRID-3D — High-Performance Spatial Indexing Engine
* ======================================================================================
*
* DESCRIPTION:
* Visgrid-3D is a specialized, embedded-grade spatial state engine designed for
* high-velocity 3D environments (Drone Swarms, Satellite Constellations, and
* Autonomous Robotics). It implements a "Linearized Implicit Octree" using
* Z-Order curves (Morton Codes) backed by a memory-mapped B-Tree (LMDB).
*
@vurtun
vurtun / foot_ik.c
Last active December 19, 2025 22:41
Foot IK
#include <stdint.h>
#include <stdalign.h> /* C11 alignas */
#include <immintrin.h> /* AVX2 intrinsics */
#include <float.h>
/* --------------------------------------------------------------------------
* SYSTEM CONFIGURATION
* -------------------------------------------------------------------------- */
#define BATCH_SIZE 8
#define MAX_ENTITIES 512
@vurtun
vurtun / tree_view_db.c
Last active December 19, 2025 22:21
Virtual Tree Database
/*
* VIRTUAL TREE FLATTENING ENGINE (LMDB-BACKED)
* ============================================
*
* A high-performance virtualization layer that transforms a hierarchical tree
* stored in LMDB into a linear, flat list of visible rows suitable for UI rendering.
*
* DESIGN PHILOSOPHY:
* This system is architected for "Infinite Scrolling" over massive datasets
* (10M+ nodes) where latency must remain under 1ms (1000 FPS). It prioritizes
@vurtun
vurtun / visgrid.c
Last active December 21, 2025 19:11
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 / mt.c
Last active December 18, 2025 18:01
Multi-Core By Default
// https://www.rfleury.com/p/multi-core-by-default
// https://github.com/EpicGamesExt/raddebugger/blob/c738768e41153b8e598ef51aa57530cf71c19880/src/base/base_entry_point.c#L179
// https://github.com/EpicGamesExt/raddebugger/blob/master/src/radbin/radbin.c#L37
#include <pthread.h>
#ifdef __linux__
#define _GNU_SOURCE // For pthread_setaffinity_np and sched.h extensions
#include <sched.h> // For sched_param, SCHED_FIFO, sched_yield
#include <sys/sysinfo.h> // For fallback cpu_cnt
#endif
#include <immintrin.h> // For AVX2 intrinsics
#include <stdio.h>
#include <float.h> // For FLT_MAX and FLT_MIN
#include <string.h> // For memset
#include <stdlib.h> // For exit
#include <math.h> // For fmaxf, fminf
#include <pthread.h> // For pthreads (example, assuming your pool uses similar mechanisms)
#include <assert.h>
#define EPSILON 1e-6f // Define a small epsilon to handle floating point inaccuracies
// https://danglingpointers.com/post/spinlock-implementation/
void Lock(AtomicI32& _spinLock)
{
for (;;)
{
if (_spinLock.load_Acquire() == 0)
{
i32 expected = 0;
i32 store = 1;
if (_spinLock.compareExchange_Acquire(expected, store))
@vurtun
vurtun / astar.c
Last active December 14, 2025 11:45
A* Pathfinder optimized for 64x64 grids on ARM64 mobile SoCs
/*
* A* Pathfinder optimized for 64x64 grids on ARM64 mobile SoCs.
*
* Features:
* - Deterministic memory (Strict Indexed Priority Queue, no heap bloat).
* - Cache-coherent SoA layout (Structure of Arrays) fitting ~50KB L1 Cache.
* - Register-level map caching (loading rows into uint64_t registers).
* - Fully NEON-accelerated initialization.
* - Branchless heuristics and collision checking.
* - Zero allocations (Context is reusable).
@vurtun
vurtun / cloth.c
Last active December 17, 2025 18:21
cloth simulation
/*
* -----------------------------------------------------------------------------
* High-Performance Hard-Realtime Cloth Simulation (AVX2 Optimized)
* -----------------------------------------------------------------------------
* DESCRIPTION:
* This module implements a production-hardened CPU cloth
* solver designed for AA/AAA open-world game. It utilizes
* NvCloth cooking data (topology) but replaces the runtime with a highly
* optimized, cache-aware, and predictable AVX2 implementation.
*
@vurtun
vurtun / chain.c
Last active December 19, 2025 22:50
chain simulation
/*
* ======================================================================================
* XPBD CHAIN SIMULATION LIBRARY
* ======================================================================================
* OVERVIEW:
* Physics simulation designed specifically for high-fidelity decorative chains
* in AAA games (jewelry, hair braids, lantern holders, armor attachments).
* It prioritizes visual stability, artistic control, and extreme CPU efficiency.
*
* ALGORITHM & ARCHITECTURE: