diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-02-24 21:31:46 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-02-24 21:31:46 +0200 |
| commit | e991095180f774e3582329447c291a11499989ba (patch) | |
| tree | 0708d2308a229b932a84d8ae803b31d296f9fc0f /include | |
| parent | 238116c1cf08b93335abd493df110a669786553e (diff) | |
| download | gran-e991095180f774e3582329447c291a11499989ba.tar.gz gran-e991095180f774e3582329447c291a11499989ba.zip | |
overhaul meshes
+ Previous name was grid
Diffstat (limited to 'include')
| -rw-r--r-- | include/gran/grid/node.h | 29 | ||||
| -rw-r--r-- | include/gran/mesh/node.h | 31 | ||||
| -rw-r--r-- | include/gran/mesh/node3d.h (renamed from include/gran/grid/node3d.h) | 16 |
3 files changed, 38 insertions, 38 deletions
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 <gran/component.h> -#include <stdint.h> - -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/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 <gran/component.h> +#include <stdint.h> + +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/grid/node3d.h b/include/gran/mesh/node3d.h index e424d9b..4f1c2c7 100644 --- a/include/gran/grid/node3d.h +++ b/include/gran/mesh/node3d.h @@ -1,23 +1,21 @@ -#ifndef GRAN_GRID_NODE3D_H -#define GRAN_GRID_NODE3D_H - -/** @todo rename to mesh to follow conventions a bit better */ +#ifndef GRAN_MESH_NODE3D_H +#define GRAN_MESH_NODE3D_H #include <gran/component.h> #include <stdint.h> -struct component *create_grid_node3d(uint8_t x, uint8_t y, uint8_t z); +struct component *create_mesh_node3d(uint8_t x, uint8_t y, uint8_t z); -stat grid_node3d_connect(struct component *node, +stat mesh_node3d_connect(struct component *node, struct component *n, struct component *s, - struct component *w, struct component *e, + struct component *w, 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) +static inline uint64_t mesh3d_addr(uint8_t x, uint8_t y, uint8_t z, uint32_t off) { return off | ((uint64_t)x << 32) @@ -26,7 +24,7 @@ static inline uint64_t grid3d_addr(uint8_t x, uint8_t y, uint8_t z, uint32_t off ; } -static inline void addr_grid3d(uint64_t addr, uint8_t *x, uint8_t *y, uint8_t *z, uint32_t *off) +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; |
