#ifndef __types_h__ #define __types_h__ /* An unordered vector down on mallocs and frees */ typedef struct Heap Heap; struct Heap { void** data; /* Array of pointers to data */ int count; /* Current number of items */ int capacity; /* Maximum number of items before growth */ int step; /* Number of pointers to allocate at a time */ void* (*create)(void); /* Function to allocate new items */ void (*destroy)(void*); /* Function to deallocate items */ }; /* x,y pair */ typedef struct Point Point; struct Point { int x, y; }; /* Simple line segment */ typedef struct Line Line; struct Line { int x1, y1, x2, y2; }; /* Fixed list of points */ typedef struct Polygon Polygon; struct Polygon { Point* vtx; /* List of x,y pairs */ /* (can be cast to int* for polygon funcs) */ int vtx_count; /* Total number of vertices */ }; /* Line with triangle endpoints on it, for visibility calculations */ typedef struct VLine VLine; struct VLine { int x1, y1, x2, y2; /* Endpoints of line */ int xa, ya, xb, yb; /* Vertices of triangle */ int vtx_count; /* Number of vertices found so far */ VLine* prev; /* Line before me (circularly-linked) */ VLine* next; /* Line after me */ int skip; /* Flag for looking past corners */ }; /* Visibility wedge */ typedef struct VWedge VWedge; struct VWedge { int x, y; /* Focus */ float a; /* Direction wedge is facing */ int r; /* Radius */ float fov; /* Angular width * 0.5 */ Heap vis; /* Associated VLines */ }; #endif