Skip to content
Myr

add todo list, try to compile as C++ (untested), tweak data structure

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent 31bc5d1 · Browse files · 1 file+23 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−2 removed

  • other:+23 added−2 removed

1 file+23 added−2 removed

modified:stb_connected_components.h+23 added-2 removed
1// stb_connected_components - v0.90 - public domain connected components on grids1// stb_connected_components - v0.91 - public domain connected components on grids2// http://github.com/nothings/stb3//4// Finds connected components on 2D grids for testing reachability between5// two points, with fast updates when changing reachability (e.g. on one machine
16 unmodified lines
22// This software is dual-licensed to the public domain and under the following23// license: you are granted a perpetual, irrevocable license to copy, modify,24// publish, and distribute this file as you see fit.25//26//27// TODO:28// - test C++ compile29// - better API documentation30// - internals documentation (including algorithm)31// - try re-integrating naive algorithm & compare performance32// - batching (keep data structure w/ dirty clusters)33// - function for setting a grid of squares at once (just use batching)34// - shrink data by storing only, say, 2X max exits35// (instead of max exits per clump), and repack cluster36// if it runs out (possibly by just rebuilding from scratch,37// could even use dirty-cluster data structure)38// should reduce 1Kx1K from ~66MB to ~8MB3940#ifndef INCLUDE_STB_CONNECTED_COMPONENTS_H41#define INCLUDE_STB_CONNECTED_COMPONENTS_H42
1 unmodified line
44#include <assert.h>4546typedef struct st_stbcc_grid stbcc_grid;4748#ifdef __cplusplus49extern "C" {50#endif5152//////////////////////////////////////////////////////////////////////////////////////////53//54// initialization55//
29 unmodified lines
85// get a unique id for the connected component this is in; it's not necessarily86// small, you'll need a hash table or something to remap it (or just use87extern unsigned int stbcc_get_unique_id(stbcc_grid *g, int x, int y);8889#ifdef __cplusplus90}91#endif9293#endif // INCLUDE_STB_CONNECTED_COMPONENTS_H9495#ifdef STB_CONNECTED_COMPONENTS_IMPLEMENTATION96
71 unmodified lines
168169typedef struct170{171 stbcc__global_clumpid global_label;151 unsigned char num_adjacent;172 unsigned short num_adjacent;173 stbcc__relative_clumpid adjacent_clumps[STBCC__MAX_EXITS_PER_CLUMP];174} stbcc__clump;175176typedef struct
498 unmodified lines