Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chunking #49

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0052c2b
Seperated atlas and values. Switched to f32 values in preperation for…
QuantumEntangledAndy Jul 3, 2021
b091bc8
Updated marching cubes to include colour
QuantumEntangledAndy Jul 3, 2021
cdb4a4c
Modify voxel baker to use a grid and isovalues
QuantumEntangledAndy Jul 3, 2021
320fc04
Add a modified marching cube that supports atlases
QuantumEntangledAndy Jul 3, 2021
897aefd
Modified benches to use long bench sampling method of criterion
QuantumEntangledAndy Jul 3, 2021
aa79a4f
Allocate mod marching cubes tables on the heap
QuantumEntangledAndy Jul 4, 2021
cbf3840
Add alternative mesh builders
QuantumEntangledAndy Jul 4, 2021
5ccdbb4
Updated the terrain example
QuantumEntangledAndy Jul 4, 2021
d0a86d0
Add a bench for the mesh builders
QuantumEntangledAndy Jul 4, 2021
3662a4a
Merge branch 'master' of https://github.com/norman784/gaiku into Bake…
QuantumEntangledAndy Jul 5, 2021
19f65af
Bug fix to voxel tables
QuantumEntangledAndy Jul 5, 2021
1581a0f
Added some more tests for meshbuilders
QuantumEntangledAndy Jul 5, 2021
0de7e95
Clippy styling
QuantumEntangledAndy Jul 5, 2021
4bd7862
Add isovalue to is_air calc
QuantumEntangledAndy Jul 5, 2021
c57cb90
Clippy styling
QuantumEntangledAndy Jul 5, 2021
1cef1df
Use condition on clippy-check action
QuantumEntangledAndy Jul 5, 2021
fffd226
Apply clippy to test, benches and examples
QuantumEntangledAndy Jul 5, 2021
637bbc2
Update crates/gaiku_format_gox/src/lib.rs
QuantumEntangledAndy Jul 5, 2021
db1cf1d
Author update
QuantumEntangledAndy Jul 5, 2021
36387e2
Bug fix in boundary overlap code
QuantumEntangledAndy Jul 6, 2021
afd76d8
Added a meshbuilder based on a hashmap scaled grid
QuantumEntangledAndy Jul 6, 2021
2329481
Fixed a few tests needed due to prior bug fix
QuantumEntangledAndy Jul 7, 2021
444c2d3
More clippy issues
QuantumEntangledAndy Jul 7, 2021
b1c87d0
Added a flat chunker
QuantumEntangledAndy Jul 7, 2021
6fdc43d
Bug fix to corner index in voxel
QuantumEntangledAndy Jul 8, 2021
d78b61b
Use flatchunker to chunk the gox files
QuantumEntangledAndy Jul 8, 2021
b01c931
Add some documentation
QuantumEntangledAndy Jul 9, 2021
06cda31
Added some interpolators
QuantumEntangledAndy Jul 9, 2021
2dbfb10
Bug fixes to the interpolators
QuantumEntangledAndy Jul 9, 2021
d5bee93
Added a trilinear interpolator
QuantumEntangledAndy Jul 9, 2021
d92563a
Changed the memory pattern in chunked to prepare for the lod tree imp…
QuantumEntangledAndy Jul 10, 2021
6e9ede3
Add a LOD tree chunker
QuantumEntangledAndy Jul 10, 2021
5c93a97
Use clamping on UV calc to reduce rounding errors
QuantumEntangledAndy Jul 19, 2021
cc946f1
Added a lod chunking example
QuantumEntangledAndy Jul 20, 2021
ff729c4
Merge branch 'master' of https://github.com/norman784/gaiku into Chun…
QuantumEntangledAndy Jul 20, 2021
bdf5956
Fix doctests
QuantumEntangledAndy Jul 21, 2021
59c82a5
Applied clippy suggestions
QuantumEntangledAndy Jul 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/gaiku_baker_marching_cubes/src/baker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,18 @@ impl MarchingCubesBaker {
let uvs = texture.get_uv(atlas);

let atlas_origin = uvs.0;
let atlas_dimensions = [uvs.2[0] - uvs.0[0], uvs.2[1] - uvs.0[1]];
let atlas_min = uvs.0;
let atlas_max = uvs.2;
let atlas_dimensions = [atlas_max[0] - atlas_min[0], atlas_max[1] - atlas_min[1]];
// Put face uvs into atlas uv space
let final_uvs: [[f32; 2]; 3] = face_uvs
.iter()
.map(|uv| {
[
atlas_origin[0] + uv[0] * atlas_dimensions[0],
atlas_origin[1] + uv[1] * atlas_dimensions[1],
(atlas_origin[0] + uv[0] * atlas_dimensions[0])
.clamp(atlas_min[0], atlas_max[0]),
(atlas_origin[1] + uv[1] * atlas_dimensions[1])
.clamp(atlas_min[1], atlas_max[1]),
]
})
.collect::<Vec<[f32; 2]>>()
Expand Down
10 changes: 7 additions & 3 deletions crates/gaiku_baker_modified_marching_cubes/src/baker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,18 @@ impl ModMarchingCubesBaker {
let uvs = texture.get_uv(atlas);

let atlas_origin = uvs.0;
let atlas_dimensions = [uvs.2[0] - uvs.0[0], uvs.2[1] - uvs.0[1]];
let atlas_min = uvs.0;
let atlas_max = uvs.2;
let atlas_dimensions = [atlas_max[0] - atlas_min[0], atlas_max[1] - atlas_min[1]];
// Put face uvs into atlas uv space
let final_uvs: [[f32; 2]; 3] = face_uvs
.iter()
.map(|uv| {
[
atlas_origin[0] + uv[0] * atlas_dimensions[0],
atlas_origin[1] + uv[1] * atlas_dimensions[1],
(atlas_origin[0] + uv[0] * atlas_dimensions[0])
.clamp(atlas_min[0], atlas_max[0]),
(atlas_origin[1] + uv[1] * atlas_dimensions[1])
.clamp(atlas_min[1], atlas_max[1]),
]
})
.collect::<Vec<[f32; 2]>>()
Expand Down
10 changes: 7 additions & 3 deletions crates/gaiku_baker_voxel/src/baker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,18 @@ impl VoxelBaker {
let uvs = texture.get_uv(atlas);

let atlas_origin = uvs.0;
let atlas_dimensions = [uvs.2[0] - uvs.0[0], uvs.2[1] - uvs.0[1]];
let atlas_min = uvs.0;
let atlas_max = uvs.2;
let atlas_dimensions = [atlas_max[0] - atlas_min[0], atlas_max[1] - atlas_min[1]];
// Put face uvs into atlas uv space
let final_uvs: [[f32; 2]; 3] = face_uvs
.iter()
.map(|uv| {
[
atlas_origin[0] + uv[0] * atlas_dimensions[0],
atlas_origin[1] + uv[1] * atlas_dimensions[1],
(atlas_origin[0] + uv[0] * atlas_dimensions[0])
.clamp(atlas_min[0], atlas_max[0]),
(atlas_origin[1] + uv[1] * atlas_dimensions[1])
.clamp(atlas_min[1], atlas_max[1]),
]
})
.collect::<Vec<[f32; 2]>>()
Expand Down
19 changes: 8 additions & 11 deletions crates/gaiku_baker_voxel/src/table_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn vec_dot(a: &[f32; 3], b: &[f32; 3]) -> f32 {
a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
}

fn get_verts(a_coord: [i8; 3], b_coord: [i8; 3]) -> Option<([i8; 4], [[f32; 2]; 4], u8)> {
fn get_verts(a_coord: [i8; 3], b_coord: [i8; 3]) -> Option<([i8; 4], [[f32; 2]; 4])> {
// All a_coord or b_coors are corner points so their values all always [0/2, 0/2, 0/2] never 1
let mid_coord = [
(b_coord[0] + a_coord[0]) / 2,
Expand Down Expand Up @@ -179,14 +179,11 @@ fn get_verts(a_coord: [i8; 3], b_coord: [i8; 3]) -> Option<([i8; 4], [[f32; 2];
let cross = vec_cross(c_delta, d_delta);
let mid_cross = vec_add(mid_coord, cross);
let result;
let corner;
if vec_eq(mid_cross, a_coord) {
// Cross of c,d + mid == a
result = [mid_coord, d, c, [1, 1, 1]];
corner = 0;
} else {
result = [mid_coord, c, d, [1, 1, 1]];
corner = 1;
}

let normal = [-cross[0] as f32, -cross[1] as f32, -cross[2] as f32];
Expand Down Expand Up @@ -247,7 +244,6 @@ fn get_verts(a_coord: [i8; 3], b_coord: [i8; 3]) -> Option<([i8; 4], [[f32; 2];
*VERT_MAP.get(&result[3]).unwrap(),
],
uvs.try_into().unwrap(),
corner,
))
}

Expand All @@ -272,21 +268,22 @@ fn main() {
for j in (i + 1)..8 {
let m = values[i];
let n = values[j];
if let Some((verts, uvs, corner_idx)) =
if let Some((verts, uvs)) =
get_verts(CORNER_MAP[&(i as i8)], CORNER_MAP[&(j as i8)])
{
let corner = match corner_idx {
0 => i,
1 => j,
_ => unreachable!(),
let corner: i8 = if m {
i.try_into().unwrap()
} else {
j.try_into().unwrap()
};

add_to_tables(
m,
n,
cube_index,
verts,
uvs,
corner.try_into().unwrap(),
corner,
&mut edge_table,
&mut triangle_table,
&mut uv_table,
Expand Down
Loading