This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A variant of greedy meshing for 2D tile grids. | |
| // | |
| // As is, the algorithm treats the grid as binary: empty or non-epmty. No quads are emitted for non-empty tiles. | |
| // It can be extended to multiple types by keeping track of the current tile type | |
| // and 1) treating a change of type as an obstacle and 2) not skipping over the found 'obstacle'. | |
| // | |
| // The algorithm has the following guarantees: | |
| // - Each tile in the chunk is accessed exactly once. | |
| // - None of the returned quads have a width or height of 0. | |
| // - It can never return more quads than a naive mesher would. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // If this looks weird, it's because the Java used in Processing sketches is a bit different. | |
| // Wikipedia considers it its own language, even | |
| import java.util.List; | |
| import java.util.ArrayList; | |
| class Atom { | |
| PVector pos; | |
| PVector velocity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class CatmullRomSpline implements Iterator<PVector> { | |
| private final PVector[] points; | |
| private int pointIdx; | |
| private PVector P0, P1, P2, P3; | |
| private float t; | |
| private final float tInc; | |
| private boolean hasNext; |