Skip to content

Commit

Permalink
Chunkify and winter cleanup (#13)
Browse files Browse the repository at this point in the history
- Removed gaiku 2d references
- Added Chunkify and ChunkifyMut
- Added rustfmt
- Replaced mod with named files
- Removed unneeded deps
- Runned clippy
  • Loading branch information
norman784 authored Jan 11, 2021
1 parent 43ea3c5 commit b766561
Show file tree
Hide file tree
Showing 35 changed files with 1,947 additions and 1,985 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
toolchain: nightly
token: ${{ secrets.GITHUB_TOKEN }}
args: +--features=empty -Zpackage-features
args: --features=empty -Zpackage-features

check_fmt:
name: Rust-fmt
Expand Down
7 changes: 3 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

![Rust](https://github.com/norman784/gaiku/workflows/Rust/badge.svg)

[2d](gaiku-2d) and [3d](gaiku-3d) agnostic framework (game engine) terrain engine. The purpose of the Gaiku is to provide a
[3d](gaiku-3d) agnostic framework (game engine) terrain engine. The purpose of the Gaiku is to provide a

foundation to build your games easily without worrying about implementing your own terrain engine.

The main crate is developed game engine agnostic, so we can help to reach more developers.
Expand All @@ -25,9 +26,7 @@ General features:
- Chunk based for infinite generated terrains
- Mesh optimization
- LOD support
- For procedural terrain generation check the 2d and 3d `Bakers` documentations.

For specific features check [2d](gaiku-2d/Readme.md) and [3d](gaiku-3d/Readme.md)
- For procedural terrain generation check the 3d `Baker` documentation.

## Examples

Expand Down
8 changes: 0 additions & 8 deletions gaiku-2d/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions gaiku-2d/Readme.md

This file was deleted.

8 changes: 0 additions & 8 deletions gaiku-2d/example/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions gaiku-2d/example/src/main.rs

This file was deleted.

1 change: 0 additions & 1 deletion gaiku-2d/src/lib.rs

This file was deleted.

94 changes: 47 additions & 47 deletions gaiku-3d/benches/benchmarks/heightmap.rs
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
use criterion::{criterion_group, Criterion};
use gaiku_3d::{
bakers::HeightMapBaker,
common::{Baker, Chunk, FileFormat},
formats::GoxReader,
bakers::HeightMapBaker,
common::{Baker, Chunk, Chunkify, FileFormat},
formats::GoxReader,
};

fn get_chunks(name: &str) -> Vec<Chunk> {
let file = format!(
"{}/examples/assets/{}.gox",
env!("CARGO_MANIFEST_DIR"),
name
);
let file = format!(
"{}/examples/assets/{}.gox",
env!("CARGO_MANIFEST_DIR"),
name
);

GoxReader::read(&file)
GoxReader::read(&file)
}

fn heightmap_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("HeightMap");
let chunks = get_chunks("terrain");
let mut group = c.benchmark_group("HeightMap");
let chunks = get_chunks("terrain");

group.bench_function("Terrain", |b| {
b.iter(|| {
let mut meshes = vec![];
group.bench_function("Terrain", |b| {
b.iter(|| {
let mut meshes = vec![];

for chunk in chunks.iter() {
let mesh = HeightMapBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});
for chunk in chunks.iter() {
let mesh = HeightMapBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});

let chunks = get_chunks("planet");
let chunks = get_chunks("planet");

group.bench_function("Planet", |b| {
b.iter(|| {
let mut meshes = vec![];
group.bench_function("Planet", |b| {
b.iter(|| {
let mut meshes = vec![];

for chunk in chunks.iter() {
let mesh = HeightMapBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});
for chunk in chunks.iter() {
let mesh = HeightMapBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});

let chunks = get_chunks("small_tree");
let chunks = get_chunks("small_tree");

group.bench_function("Small tree", |b| {
b.iter(|| {
let mut meshes = vec![];
group.bench_function("Small tree", |b| {
b.iter(|| {
let mut meshes = vec![];

for chunk in chunks.iter() {
let mesh = HeightMapBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});
for chunk in chunks.iter() {
let mesh = HeightMapBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});

group.finish();
group.finish();
}

criterion_group!(benches, heightmap_benchmark);
94 changes: 47 additions & 47 deletions gaiku-3d/benches/benchmarks/marching_cubes.rs
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
use criterion::{criterion_group, Criterion};
use gaiku_3d::{
bakers::MarchingCubesBaker,
common::{Baker, Chunk, FileFormat},
formats::GoxReader,
bakers::MarchingCubesBaker,
common::{Baker, Chunk, Chunkify, FileFormat},
formats::GoxReader,
};

fn get_chunks(name: &str) -> Vec<Chunk> {
let file = format!(
"{}/examples/assets/{}.gox",
env!("CARGO_MANIFEST_DIR"),
name
);
let file = format!(
"{}/examples/assets/{}.gox",
env!("CARGO_MANIFEST_DIR"),
name
);

GoxReader::read(&file)
GoxReader::read(&file)
}

fn marching_cubes_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("Marching cubes");
let chunks = get_chunks("terrain");
let mut group = c.benchmark_group("Marching cubes");
let chunks = get_chunks("terrain");

group.bench_function("Terrain", |b| {
b.iter(|| {
let mut meshes = vec![];
group.bench_function("Terrain", |b| {
b.iter(|| {
let mut meshes = vec![];

for chunk in chunks.iter() {
let mesh = MarchingCubesBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});
for chunk in chunks.iter() {
let mesh = MarchingCubesBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});

let chunks = get_chunks("planet");
let chunks = get_chunks("planet");

group.bench_function("Planet", |b| {
b.iter(|| {
let mut meshes = vec![];
group.bench_function("Planet", |b| {
b.iter(|| {
let mut meshes = vec![];

for chunk in chunks.iter() {
let mesh = MarchingCubesBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});
for chunk in chunks.iter() {
let mesh = MarchingCubesBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});

let chunks = get_chunks("small_tree");
let chunks = get_chunks("small_tree");

group.bench_function("Small tree", |b| {
b.iter(|| {
let mut meshes = vec![];
group.bench_function("Small tree", |b| {
b.iter(|| {
let mut meshes = vec![];

for chunk in chunks.iter() {
let mesh = MarchingCubesBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});
for chunk in chunks.iter() {
let mesh = MarchingCubesBaker::bake(chunk);
if let Some(mesh) = mesh {
meshes.push((mesh, chunk.position()));
}
}
})
});

group.finish();
group.finish();
}

criterion_group!(benches, marching_cubes_benchmark);
Loading

0 comments on commit b766561

Please sign in to comment.