Skip to content

Instantly share code, notes, and snippets.

@rorydriscoll
rorydriscoll / FeatherUI.cpp
Created January 8, 2012 21:56
Mikko Mononen's UI 'feathering' technique
void CalculateEdgeNormal(float& nx, float& ny, float x0, float y0, float x1, float y1)
{
const float x01 = x1 - x0;
const float y01 = y1 - y0;
const float length = Sqrt(x01 * x01 + y01 * y01);
const float dx = x01 / length;
const float dy = y01 / length;
@rorydriscoll
rorydriscoll / SubsetSum
Created December 3, 2011 00:32
Subset sum problem
var max_sum = -Inf, best_begin = 0, best_end = 0, cur_begin = 0, cur_sum = 0
for (i = 0; i < values.length; ++i)
# Add the current value into our working sum
cur_sum += values[i]
# Update the max sum if we beat it
if cur_sum > max_sum:
max_sum = cur_sum
@rorydriscoll
rorydriscoll / unityambientproblem
Created April 21, 2015 04:02
Unity ambient problem
Version:
Unity 5.0.1f1 Personal
Repro:
- Sync to scene at https://github.com/rorydriscoll/ld32
- Mark all objects under 'Geometry' game object as static
- Enable 'Baked GI' in the lighting panel, but not precomputed realtime GI
- Bake
@rorydriscoll
rorydriscoll / gist:10013303
Created April 7, 2014 00:54
Inspector window setup
As a post-build step, run type database compiler to grab the pdb and convert it to a custom type database format (just a list of types, fields and enumerators).
struct Type
{
// Name of the type
char name[TypeDatabaseBlueprint::Type::kMaxName];
// Unique id for this type
Hash id;