File: INTERNALS.md

package info (click to toggle)
goxel 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 13,232 kB
  • sloc: ansic: 87,714; cpp: 87,537; python: 128; makefile: 74; xml: 55
file content (29 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

Small explanation of the internals of goxel code
================================================

The voxels data are stored as blocks of 16^3 voxels (`block_t`).  The blocks
implement a copy on write mechanism with references counting, so that it is
very fast to copy blocks, the actual data (`block_data_t`) is copied only when
we make change to a block.

Several blocks together form a mesh (`mesh_t`), the meshes also use a copy on
write mechanism to make copy basically free.

An `image_t` contains several `layer_t`, which is basically a mesh plus a few
attributes.  The image also keeps snapshots of the layers at every changes for
undo history (since we use copy on write on individual blocks, this does not
require much memory).

The basic function to operate on a mesh is `mesh_op`, we give it a `painter_t`
pointer that defines the operation: shape, color, mode, etc.

All the rendering functions are differed.  The `render_xxx` calls just build a
list of operations, that is executed when we call `render_render`.

The assets are stored directly in the C code (`src/assets.inl`), a python
script (`tools/create_assets`) takes care of generating this file.
We can then use `assets_get` to retrieve them.

The gui is using Ocornut imgui library, with a few custom widgets defined in
`src/imgui_user.inl`.