From 073df9fa0ef7544eaf85a6ef410690008126e530 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 28 Sep 2019 23:43:25 -0400 Subject: Added bitmask stuff. --- clld.c | 123 +++++++++++++++++++++++++++++++++++++++++------------------ test-bitmask | 56 +++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 37 deletions(-) create mode 100644 test-bitmask diff --git a/clld.c b/clld.c index 70e111d..2ff7975 100644 --- a/clld.c +++ b/clld.c @@ -7,10 +7,14 @@ * Created: September 27, 2019 @ 09:25PM */ +#include #include #include #include #include +#define TERASGN(a, b, c, d) (a) ? (b = d) : (c = d) + +enum {THM, AABB, PPX }; /* Collision type */ int colltype = -1; @@ -29,8 +33,6 @@ static int usage() { "Options:\n" " -c Force the collision type to be\n" " the specified type (0-2).\n" - " -p Force the position type to be\n" - " the specified type (0-2).\n" " -v[level] Sets the verbosity level (0-3).\n" ); return 0; @@ -45,62 +47,109 @@ int main(int argc, char **argv) { double fy; double fz; }; - struct pos cursor; - struct pos floor; - struct pos tmp; + + struct colis { + unsigned int w; + unsigned int h; + struct pos pos; + uint8_t **bitmask; + unsigned int clds : 1; + unsigned int gnded : 1; + }; + + + + struct colis cursor; + struct colis floor; + struct colis tmp; char *buf = NULL; size_t size; - getline(&buf, &size, stdin); - if (postype == -1) - postype = atoi(strtok(buf, "\n")); + /*getline(&buf, &size, stdin);*/ + /*if (postype == -1) + postype = atoi(strtok(buf, "\n"));*/ - buf = NULL; + /*buf = NULL;*/ getline(&buf, &size, stdin); if (colltype == -1) colltype = atoi(strtok(buf, "\n")); - printf("%i\n%i\n", postype, colltype); - for (int i = 0; i <= 1; i++) { + printf("%i\n", colltype); + for (int coll = 0; coll <= 1; coll++) { + buf = NULL; + getline(&buf, &size, stdin); + /* , */ + tmp.w = atoi(strtok(buf, ",")); + tmp.h = atoi(strtok(NULL, "\n")); + /* Initialize y axis of bitmask. */ + tmp.bitmask = malloc(sizeof(int *)*tmp.h); + /* Initialize x axis of bitmask. */ + for(int i = 0; i= tmp.w) ? tmp.w : newidth; + for (int i = 0; i