Commit c66abc0b authored by Adam P. Goucher's avatar Adam P. Goucher

More directionality detection

parent 6f563f28
#pragma once
#include <stdint.h>
#include <cstring>
#include "lifeperm.h"
#include "lifelogic/iterators_all.h"
namespace apg {
uint64_t determine_direction(uint64_t * inleaf) {
uint64_t centres[10];
iterate_var_leaf(-4, inleaf, centres);
uint64_t dmap = 0;
for (uint64_t i = 0; i < 8; i++) {
dmap |= (((centres[0] == centres[i+2]) ? 1 : 0) << i);
}
uint64_t lmask = 0;
if (centres[1]) {
if (dmap & 170) {
lmask |= 1;
}
if (dmap & 17) {
if (centres[1] & 0xff7f3f1f0f070301ull) { lmask |= 1; }
if (centres[1] & 0x80c0e0f0f8fcfeffull) { lmask |= 2; }
}
if (dmap & 68) {
if (centres[1] & 0x0103070f1f3f7fffull) { lmask |= 1; }
if (centres[1] & 0xfffefcf8f0e0c080ull) { lmask |= 2; }
}
}
// Use a uint64 as an ordered pair of uint32s:
return (dmap | (lmask << 32));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment