https://github.com/infinitifall/face-remove
Given cubes in 3D space, finds cube faces which are hidden from view and removes them. An improvement over the Krunker Editor face optimizer.
https://github.com/infinitifall/face-remove
3d-geometry c cube krunker krunkerio rendering
Last synced: 5 months ago
JSON representation
Given cubes in 3D space, finds cube faces which are hidden from view and removes them. An improvement over the Krunker Editor face optimizer.
- Host: GitHub
- URL: https://github.com/infinitifall/face-remove
- Owner: Infinitifall
- License: mit
- Created: 2022-10-15T08:19:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-01T07:30:34.000Z (over 1 year ago)
- Last Synced: 2025-01-11T02:32:39.455Z (6 months ago)
- Topics: 3d-geometry, c, cube, krunker, krunkerio, rendering
- Language: C
- Homepage:
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Face Remove
Given the sizes, positions and orientations of cubes in 3D space, finds cube faces which are hidden from view and removes them. Disabling rendering for hidden faces nets a significant performance boost with no change in appearance.
A significant improvement over the Krunker Editor face optimizer, which can only handle one-on-one face overlaps.
## Setup
`python3` and `gcc` must be installed
```bash
# clone repo
git clone https://github.com/Infinitifall/face-remove
cd face-remove# build
make
```## Run
Paste your map export in `input.json`
```bash
# run
python3 run.py
```## How it works
To determine if a face is hidden we check if all points on an $n \times n$ grid are touching or covered by another cube. We can get an arbitrarily accurate (albeit computationally heavy) solution as $n \rightarrow \infty$. For most scenarios though, $n \approx 20$, checking 400 points per face, works just fine, which is what we do here.
In the image below, the yellow cube and the blue cube will have one face each disabled, as they are hidden inside the purple and the green cubes respectively.

In the image below, the orange cube will have one face disabled, as it is hidden by the other three cubes put together.
