From e991095180f774e3582329447c291a11499989ba Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 24 Feb 2025 21:31:46 +0200 Subject: overhaul meshes + Previous name was grid --- include/gran/grid/node.h | 29 ----------------------------- include/gran/grid/node3d.h | 38 -------------------------------------- include/gran/mesh/node.h | 31 +++++++++++++++++++++++++++++++ include/gran/mesh/node3d.h | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 67 deletions(-) delete mode 100644 include/gran/grid/node.h delete mode 100644 include/gran/grid/node3d.h create mode 100644 include/gran/mesh/node.h create mode 100644 include/gran/mesh/node3d.h (limited to 'include') diff --git a/include/gran/grid/node.h b/include/gran/grid/node.h deleted file mode 100644 index db617f8..0000000 --- a/include/gran/grid/node.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef GRAN_GRID_NODE_H -#define GRAN_GRID_NODE_H - -#include -#include - -struct component *create_grid_node(uint16_t x, uint16_t y); - -stat grid_node_connect(struct component *node, - struct component *left, struct component *right, - struct component *up, struct component *down, - struct component *lower); - -static inline uint64_t grid_addr(uint16_t x, uint16_t y, uint32_t off) -{ - return off - | ((uint64_t)x << 32) - | ((uint64_t)y << 48) - ; -} - -static inline void addr_grid(uint64_t addr, uint32_t *off, uint16_t *x, uint16_t *y) -{ - if (off) *off = addr & 0xffffffff; - if (x) *x = (addr >> 32) & 0xffff; - if (y) *y = (addr >> 48) & 0xffff; -} - -#endif /* GRAN_GRID_NODE_H */ diff --git a/include/gran/grid/node3d.h b/include/gran/grid/node3d.h deleted file mode 100644 index e424d9b..0000000 --- a/include/gran/grid/node3d.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef GRAN_GRID_NODE3D_H -#define GRAN_GRID_NODE3D_H - -/** @todo rename to mesh to follow conventions a bit better */ - -#include -#include - -struct component *create_grid_node3d(uint8_t x, uint8_t y, uint8_t z); - -stat grid_node3d_connect(struct component *node, - struct component *n, - struct component *s, - struct component *w, - struct component *e, - struct component *u, - struct component *d, - struct component *l); - -static inline uint64_t grid3d_addr(uint8_t x, uint8_t y, uint8_t z, uint32_t off) -{ - return off - | ((uint64_t)x << 32) - | ((uint64_t)y << 40) - | ((uint64_t)z << 48) - ; -} - -static inline void addr_grid3d(uint64_t addr, uint8_t *x, uint8_t *y, uint8_t *z, uint32_t *off) -{ - if (off) *off = addr & 0xffffffff; - if (x) *x = (addr >> 32) & 0xff; - if (y) *y = (addr >> 40) & 0xff; - if (z) *z = (addr >> 48) & 0xff; - assert(((addr >> 56) & 0xff) == 0); -} - -#endif /* GRAN_GRID_NODE3D_H */ diff --git a/include/gran/mesh/node.h b/include/gran/mesh/node.h new file mode 100644 index 0000000..53ee08b --- /dev/null +++ b/include/gran/mesh/node.h @@ -0,0 +1,31 @@ +#ifndef GRAN_GRID_NODE_H +#define GRAN_GRID_NODE_H + +#include +#include + +struct component *create_mesh_node(uint16_t x, uint16_t y); + +stat mesh_node_connect(struct component *node, + struct component *n, + struct component *s, + struct component *e, + struct component *w, + struct component *l); + +static inline uint64_t mesh_addr(uint16_t x, uint16_t y, uint32_t off) +{ + return off + | ((uint64_t)x << 32) + | ((uint64_t)y << 48) + ; +} + +static inline void addr_mesh(uint64_t addr, uint16_t *x, uint16_t *y, uint32_t *off) +{ + if (off) *off = addr & 0xffffffff; + if (x) *x = (addr >> 32) & 0xffff; + if (y) *y = (addr >> 48) & 0xffff; +} + +#endif /* GRAN_GRID_NODE_H */ diff --git a/include/gran/mesh/node3d.h b/include/gran/mesh/node3d.h new file mode 100644 index 0000000..4f1c2c7 --- /dev/null +++ b/include/gran/mesh/node3d.h @@ -0,0 +1,36 @@ +#ifndef GRAN_MESH_NODE3D_H +#define GRAN_MESH_NODE3D_H + +#include +#include + +struct component *create_mesh_node3d(uint8_t x, uint8_t y, uint8_t z); + +stat mesh_node3d_connect(struct component *node, + struct component *n, + struct component *s, + struct component *e, + struct component *w, + struct component *u, + struct component *d, + struct component *l); + +static inline uint64_t mesh3d_addr(uint8_t x, uint8_t y, uint8_t z, uint32_t off) +{ + return off + | ((uint64_t)x << 32) + | ((uint64_t)y << 40) + | ((uint64_t)z << 48) + ; +} + +static inline void addr_mesh3d(uint64_t addr, uint8_t *x, uint8_t *y, uint8_t *z, uint32_t *off) +{ + if (off) *off = addr & 0xffffffff; + if (x) *x = (addr >> 32) & 0xff; + if (y) *y = (addr >> 40) & 0xff; + if (z) *z = (addr >> 48) & 0xff; + assert(((addr >> 56) & 0xff) == 0); +} + +#endif /* GRAN_GRID_NODE3D_H */ -- cgit v1.3