Skip to content

Instantly share code, notes, and snippets.

Leonard Ritter paniq

  • Duangle GbR
Block or report user

Report or block paniq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:453ea55a0c56b3d3247cc81d79ab1e3f
using import struct
typedef FILE
let
FILE* = (mutable pointer FILE)
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
View gist:bea06b8d194a494e4d5b5bce0a953949
using import ..tukan.libc
using import ..tukan.ode
using import ..tukan.sdl
let NUM_CONTACTS = 3
let world = (dWorldCreate)
assert (world != null)
View cube-simplex-bary.sc
#-------------------------------------------------------------------------------
implicit cube-to-simplex subdivision
fn cube-simplex (pred)
""""ivec3 ivec3 ivec3 ivec3 <- ivec3
for three coordinate predicates
r: y <= z, g: z < x, b: x < y
return the two defining vertices of the simplex that the coordinate is in
and the four planes required for computing barycentric coordinates
the resulting simplex has the corners (0 0 0) v1 v2 (1 1 1)
View bluenoise.sc
#!/usr/bin/env scopes
using import glm
using import glsl
using import itertools
using import ..tukan.gl
using import ..tukan.bitmap
using import ..tukan.random
using import .testfragment
View number_parser.cpp
struct NumberParser {
enum {
NPF_Sign = (1 << 0),
NPF_Negative = (1 << 1),
NPF_Base = (1 << 2),
NPF_Dot = (1 << 3),
NPF_Exponent = (1 << 4),
NPF_ExponentSign = (1 << 5),
NPF_ExponentNegative = (1 << 6),
NPF_Inf = (1 << 7),
View gist:b7bb72b5bd1a910ffcf5e4bb16bb29af
inline gen-include-options! (name)
print "gen-include-options!" name
let modules... =
'app
'gfx
'time
'audio
'args
View utf8_decoder.sc
using import enum
enum UTF8
# an invalid state was encountered
Invalid : i8
# a codepoint has been read successfully
Codepoint : u32
# declare i8 @llvm.ctlz.i8 (i8 <src>, i1 <is_zero_undef>)
let llvm.ctlz.i8 =
View twisting_pool_queue.sc
# implementation of
https://gist.github.com/paniq/856241af5d8a69a76a5b7e941b2533f0
using import Array
let IdIndexT = u32
let GenT = u32
# must be at least 1
View twistpool.md

Twisting Pool Queue

by Leonard Ritter leonard.ritter@duangle.com, 2019-05-12

An implementation written in Scopes can be found here

We have the task of distributing IDs to objects in a pool that we can use to look up their contents. We want to ensure that:

  • Insert, access, and remove are operations with O(1) complexity.
  • The object array is compact, i.e. without any gaps, so we can parallelize work on it with full occupancy.
@paniq
paniq / twistpool.sc
Last active May 11, 2019
Twisting Pool Allocator (Scopes)
View twistpool.sc
""""Twisting Pool Allocator
=======================
written by Leonard Ritter (leonard.ritter@duangle.com)
ported and expanded from the C version (https://gist.github.com/paniq/d867c6b5ea9c68a352a1)
This file is in the public domain
I don't know if I was the first one to stumble upon this technique, so
I can't guarantee there's no patent on it, but let's hope there's not,
You can’t perform that action at this time.