Skip to content

Commit

Permalink
test: add xpbd collider for chunk back. remesh only for neighbor comp…
Browse files Browse the repository at this point in the history
…leted chunks

perf:

only render:
0dist = 140fps
20dist = 18fps, sky = 25fps 35fps
20dist in high air no visible chunk = 100fps

render+xpbd collider:
 0dist=140fps
20dist=17fps, sky = 24fps
20dist in high air no visible chunk = 60fps
  • Loading branch information
Dreamtowards committed Jan 19, 2024
1 parent 6a301c5 commit eb3b721
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/build_windows_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ jobs:
./windows-x86_64.zip
./target/x86_64-pc-windows-msvc/release/${APP_NAME}.exe
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
This is the release of ${APP_NAME}.
draft: false
prerelease: true
# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.ref }}
# release_name: Release ${{ github.ref }}
# body: |
# This is the release of ${APP_NAME}.
# draft: false
# prerelease: true


3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ __Minecraft + GTAV + VRChat__  /  A Sandbox Survival Game, with Rust,

### Showcase

![](https://github.com/Dreamtowards/Ethertum/releases/download/ethertum-0.1.4-2023.01d/screenshot-20240119191310.png)


<img style="height: 80px;" src="https://github.com/Dreamtowards/Ethertum/releases/download/ethertum-0.1.4-2023.01d/screenshot-20240120001806.png"> <img style="height: 80px;" src="https://github.com/Dreamtowards/Ethertum/releases/download/ethertum-0.1.4-2023.01d/screenshot-20240119013301.png"> <img style="height: 80px;" src="https://github.com/Dreamtowards/Ethertia/raw/main/run/screenshots/qs230310-1.png"> <img style="height: 80px;" src="https://github.com/Dreamtowards/Ethertia/raw/main/run/screenshots/qs221130.png"> <img style="height: 80px;" src="https://github.com/Dreamtowards/Ethertia/raw/main/run/screenshots/_figures/23u07.png">
17 changes: 14 additions & 3 deletions src/voxel/chunk_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ impl ChunkSystem {
let mut chunk = chunkptr.write().unwrap();
chunkpos = chunk.chunkpos;

let mut load = Vec::new();

for neib_idx in 0..Chunk::NEIGHBOR_DIR.len() {
let neib_dir = Chunk::NEIGHBOR_DIR[neib_idx];
let neib_chunkpos = chunkpos + neib_dir * Chunk::SIZE;
Expand All @@ -126,10 +128,16 @@ impl ChunkSystem {
chunk.neighbor_chunks[neib_idx] = if let Some(neib_chunkptr) =
self.get_chunk(neib_chunkpos)
{
{
let mut neib_chunk = neib_chunkptr.write().unwrap();

// update neighbor's `neighbor_chunk`
neib_chunk.neighbor_chunks[Chunk::neighbor_idx_opposite(neib_idx)] = Some(Arc::downgrade(&chunkptr));

// update neighbor's `neighbor_chunk`
neib_chunkptr.write().unwrap().neighbor_chunks
[Chunk::neighbor_idx_opposite(neib_idx)] = Some(Arc::downgrade(&chunkptr));
if neib_chunk.is_neighbors_complete() {
load.push(neib_chunk.chunkpos);
}
}

Some(Arc::downgrade(neib_chunkptr))
} else {
Expand All @@ -140,6 +148,9 @@ impl ChunkSystem {
if chunk.is_neighbors_complete() {
self.mark_chunk_remesh(chunkpos);
}
for cp in load {
self.mark_chunk_remesh(cp);
}
}

self.chunks.insert(chunkpos, chunkptr);
Expand Down
15 changes: 11 additions & 4 deletions src/voxel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fn chunks_detect_load_and_unload(
..default()
},
// Aabb::from_min_max(Vec3::ZERO, Vec3::ONE * (Chunk::SIZE as f32)),
// RigidBody::Static,
RigidBody::Static,
))
.set_parent(chunksys_entity)
.id();
Expand Down Expand Up @@ -282,15 +282,22 @@ fn chunks_remesh(

chunk_sys.chunks_meshing.retain(|chunkpos, task| {
if let Some(r) = future::block_on(future::poll_once(task)) {
let not_empty = r.0.indices().is_some_and(|idx| !idx.is_empty());

// Update Mesh Asset
*meshes.get_mut(r.3).unwrap() = r.0;

// Update Phys Collider TriMesh
if let Some(collider) = r.1 {
if let Some(mut cmds) = commands.get_entity(r.2) {
cmds.remove::<Collider>()
// .insert(collider)
.insert(Visibility::Visible);
cmds.remove::<Collider>();
if not_empty {
cmds.insert(collider)
.insert(Visibility::Visible);
} else {
cmds.insert(Visibility::Hidden);
}
assert!(not_empty);
}
}

Expand Down

0 comments on commit eb3b721

Please sign in to comment.