Skip to content

Instantly share code, notes, and snippets.

View devsleeper's full-sized avatar

djames devsleeper

  • British Columbia, Canada
View GitHub Profile
@LukasFratzl
LukasFratzl / MarchingCubesJob.cs
Last active April 6, 2026 03:03
Marching Cubes in Unity with Burst and C# Jobs
/*
LICENCE -> MIT License
AUTHOR -> Lukas Fratzl
GIT -> https://github.com/LukasFratzl
DESCRIPTION -> My implementation of "Marching Cubes" in Unity with Burst and Multithreaded with c# Jobs
the algorithm is smart enough to generate every "Grid Size" with every wanted "Resolution"
as extra with a "Smooth" or "Flat" normal generation
USAGE -> Assign all field and allocate the Native Containers, Schedule the Job and Complete it
-> SEE EXAMPLE JOB DOWN BELOW!
GENERATE SPEED -> RESOLUTION 32 -> 26.9 ms | 27 024 Vertices | 1 CHUNK
@Vercidium
Vercidium / greedyvoxelmeshing
Last active February 21, 2026 20:34
Greedy Voxel Meshing ported to C#
// Code ported from https://0fps.net/2012/06/30/meshing-in-a-minecraft-game/
// Note this implementation does not support different block types or block normals
// The original author describes how to do this here: https://0fps.net/2012/07/07/meshing-minecraft-part-2/
const int CHUNK_SIZE = 32;
// These variables store the location of the chunk in the world, e.g. (0,0,0), (32,0,0), (64,0,0)
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active June 14, 2026 22:44
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th