Code Monkey home page Code Monkey logo

face-remove's Introduction

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

# clone repo
git clone https://github.com/Infinitifall/face-remove
cd face-remove

# build
make

Run

Paste your map export in input.json

# 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.

Cubes in various positions and orientations, some with their faces hidden

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

Multiple cubes together cover up the orange cubes face

face-remove's People

Contributors

infinitifall avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.