Skip to content

Commit

Permalink
Hardware accelerated tilemap (+ a lot of other changes) (#43)
Browse files Browse the repository at this point in the history
* Merge

* Outline basic tilemap code?

* feat(tilemap): 🚧 Hasty commit so I can work on my other computer

* feat(tilemap): I hate OpenGL

* feat: 🏗️ Move to wgpu

* feat(tilemap): 🚧 Tilemap work

* feat(tilemap): 🚧 Generate tileset vertices

* feat(tilemap): 🚧 Sorta works

* feat(tilemap): 🎨 Split tilemap up into multiple modules

* feat(tilemap): 🚧 Try getting autotiles working

* feat(tilemap): 🚧 Move to quad system

* feat(tilemap): 🚧 Get tiles rendering under new system

* feat(tilemap): 🚧 Scaling tilemap

* feat(tilemap): 🏗️ Use projection matrix

* feat(tilemap): 🚧 Wonky autotiles and map pan

* feat(tilemap): 🎨 Split tilemap up into components

* fix(tilemap): 🐛 Fix multiple maps

* feat(tilemap): 🚧 Add tilemap panning

* feat(tilemap): 🐛 Fix autotiles

* feat(tilemap): 🚧 Sorta functional animated autotiles

* feat(tilemap): ✨ Partially implement events

* feat(tilemap): ⚡ Move to a shared viewport uniform

* feat(tilemap): ✨ Get blend modes working

* feat(tilemap): ✨

Hue shifting events

* feat(tilemap): 🎨 Group events together

* feat(tilemap): ✨ Event opacity

* feat(tilemap): 🚧 Fail to make plane properly

* feat(tilemap): ✨ Get plane working

* feat(tilemap): ✨ Toggle layers

* feat(tilemap): ⚡ Render to texture

* feat(tilemap): ✨ Get tilemap scaling working properly

* feat(tilemap): 🔥 Use egui instead of a basic renderer

* feat(tilemap): 🐛 Fix events with tiles

* fix(tilemap): 🐛 Fix z layering and tilemap cursor being wrong

* fix(tilemap): 🐛 Fix saving tilemap as image

* feat(tilemap): ✨ Display a messagebox when crashing with a wgpu error

* feat(filesystem): 🚧 Convert data cache and filesystem into an enum

* refactor(config): 🎨 Improve seperation of concerns by storing config seperate to the data cache

* refactor(data cache): 🎨 Clean up data cache code

* refactor(filesystem): 🚧 Try a new filesystem structure

* feat(filesystem): 🚧 Completely rework filesystem

* fix(audio): 🐛 Fix audio playback issues

* feat(filesystem): 🚧 RGSSAD support

* feat(filesystem): ✨ RGSSAD archive reading

* chore: 🔥 whoops

* fix(tilemap): 🐛 Fix tile 0 drawing bug

* fix(filesystem): 🐛 Fix overlay bug

* perf(tilemap): 🚧 Rework tilemap to use instancing

* perf(tilemap): ⚡ Use instancing for tiles

* feat(tilemap): ✨ Basic tilepicker support

* refactor: 🎨 Shift code around

* refactor(RPG Maker Structs): 🎨 Begin to refactor RMXP types to make it mroe ergonomic to use

* refactor: 🎨 Change Ids to usize, refactor them to subtract and add 1 at load/save time

* refactor: 🎨 appease the compiler

* chore: ⬆️ Update alox-48 and remove it as a git submodule

* refactor: 🎨 More RMXP refactors

* refactor: 🎨 Improve rmxp struct exports

* feat(filesystem): ✨ Load from RTPs

* feat(filesystem): ✨ Load rtps on Linux

* fix(filesystem): 🐛 Fix duplication issues and general code smell

* fix(filesystem): 🐛 Apparently rgssad and rgss2a are the same

* feat(audio): ✨ Midi support (uses a public domain soundfont recommended in the mkxp readme)

* fix(audio): 🐛 FIx audio crash when unloading a project

* refactor(tilemap): 🎨 Move tilepicker to seperate struct

* refactor(tilemap): 🎨 Move blendmode to be a shared enum

* fix(audio): 🐛 Windows filepaths cause me agony

* refactor: 🎨 Use a slab instead of hashmap for tilemap resources

* feat(tilemap): ✨ Add event tooltip and refactor code

Very jank. Need to fix

* fix: 🚨 Fix dependencies

* feat(filesystem): ✨ Add rgss3a support

* feat(tilemap): ✨ Re-add tilemap layer toggling, with extra performance!!

* chore: Update pinned nightly to 08/28/2023

* ci: Bump nightly in workflows

* ci: 👷 Limit cargo jobs

* ci: 👷 Limit jobs even more

* ci: 👷 grahhh github

* feat(tilemap): ✨ Add tile snapping

* fix: 🐛 Fix event tooltip scaling

* feat: ✨ Global config window

* Slightly reduce quad size for map tiles (#35)

* Fix rendering of event graphics and the tilepicker (#36)

* Implement `calc_quad` in atlas.rs properly

This is just a stopgap to get the events with tileset graphics rendering
properly.

It's probably better to get rendering of these events to go through the
tilemap shader somehow...

* Move the "+ 1" from atlas.rs to event.rs in case it is an isolated issue

* Implement `Tiles::draw` for the tilepicker and other non-layered surfaces

* Run rustfmt on src/graphics/primitives/tiles/mod.rs

* Tilepicker no longer needs to clone or copy the atlas

* Atlas wraparound is now handled when rendering tiles

* fix(tilemap): 🐛 Fix tileset rendering with no autotiles

* Atlas wrapping handler fixes (#37)

* Replace leftover hardcoded values in `calc_quad`

* Fix rendering of tiles to the right of the autotiles

* chore: ⬇️ Change dependency optimization level

This helps with compile times on debug builds massively

* ci: 👷 Use mold and lld as linkers, bump nightly

There is apparently a regression in the pervious version of nightly, bumping it should fix it?

* ci: 💚 Install clang and mold in checks

* Tile drawing implementation and bug fixes (#38)

* Fix off-by-one when the layer number is displayed

* Basic tile drawing for non-autotiles

* Fix tilepicker default width being too small

* Fix `Table3` indexing implementation

Co-authored-by: Speak2Erase <[email protected]>

* Fix tilepicker showing incorrect autotile graphics

RPG Maker XP displays autotile index 47 for autotiles in the tilepicker,
not 0.

* Tile drawing now works with autotiles as well

* Fix bottom-right corner of map not rendering

* Blank tiles should always have ID 0

---------

Co-authored-by: Speak2Erase <[email protected]>

* perf(tilemap): ⚡ Use push constants instead of uniforms

* feat(tilemap): ✨ Add layer darkening

* Fix out-of-bounds vector access in `recompute_autotile` (#39)

* Implement basic event manipulation operations in the map editor (#40)

* `MapView.events` is now a `Slab` instead of a `HashMap`

* Add mechanism for selecting events in the map

If you hover over an event graphic in the map, it'll now show a magenta
outline to show that it is selected (for things like moving it around,
editing the event or deleting it).

If there are multiple overlapping graphics, the one with the highest ID
will be selected because event graphics are rendered in order of ID.

Alternatively you can also hover over the actual tile on which the event
is located, which allows you to select an event that is completely
covered by another event's graphic without having to move the covering
graphic aside. A green border is rendered around the selected event's
tile to make this user-friendly.

* This arm is unreachable assuming `map.events` is sorted

* Remove redundant type annotation

* Selected event is now highlighted in the hover tooltip

* Apply texture bleeding fix to events as well

* Don't interact with events if event layer isn't selected

* Event editor now opens when double-clicking events

* I was wrong; this line is not safe

* Fix name editing in the event editor

* Events can now also be selected by the yellow square cursor

* Implement event deletion when pressing delete on the map

* Event editor windows now have (mostly) unique IDs

* Use a vector to store the events instead of a slab

A slab does not support inserting elements at arbitrary positions, which
we'll need to do if we want to change the ID of an event.

Also, we already know where all of the unused IDs are since we have to
iterate through all the events every time we draw the map, so a regular
vector will not lose any performance compared to a slab.

* Double-click on map tiles without events to create one

* Enter key can now also be used for event creation/editing

* Fix incorrect serialization length for `OptionVec`

* Drag-and-drop events to move them on the map

* Remove unused variables from map_view.rs

* Event drag-and-drop now preserves the event offset from the cursor

* Apply clippy recommendations

* Apply another clippy recommendation

* Fix misleading comment in src/tabs/map.rs

* Don't move events when the mouse is not hovering over them

* Simplify deserialization implementation for OptionVec

* Remove `pub` from `event_drag_offset`

* Fix crash when adding event on a map with no events

* Prevent event from sticking to cursor after double-clicking

* Selected event border is now yellow instead of magenta

* Show magenta border around events that are being edited

* feat(tilemap): ✨ Handle keyboard for moving the cursor

* Implement the circle, rectangle and fill brushes (#41)

* Fix corner case in `OptionVec` `FromIterator` implementation

* Implement the flood fill brush

* Implement the rectangle brush

* Implement the circle/ellipse brush

* Buffer all map tile changes to reduce brush lag

* Fix arrow keys allowing map cursor to move out of bounds

* Implement drawing rectangular regions of tiles from the tilepicker (#42)

* Allow multiple tiles to be selected in the tilepicker

* Refactor the tile calculation function in tilepicker.rs

* Implement rectangle drawing for all four brushes

* Fix redundant position calculation in src/tabs/map.rs

* Fix tilepicker selection being able to extend out of bounds

* Fix pattern rectangle being shown when event layer is selected

* Fix pattern rectangle extending out of map bounds

* Pen brush needs to do bounds checking

* Floor tileset height to nearest multiple of 32

Rounding down to the nearest multiple of 32 is the correct behavior when
the tileset height in pixels is not divisible by 32.

* Fix tilepicker not showing last row of tiles

* chore: 📝 Update readme to include finished features

* refactor: 🎨 Move primitives into mod.rs

* chore: 🎨 Rustfmt

---------

Co-authored-by: white-axe <[email protected]>
  • Loading branch information
melody-rs and white-axe authored Sep 24, 2023
1 parent 09cc2f7 commit 8df72ba
Show file tree
Hide file tree
Showing 122 changed files with 10,685 additions and 4,214 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-pc-windows-msvc]
linker = "rust-lld"

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=mold"]
14 changes: 7 additions & 7 deletions .github/workflows/build-steam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
- name: Install libraries
run: |
sudo apt update
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev -y
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang lld -y
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build luminol (Release)
run: cargo build --features steamworks --release
run: cargo build --features steamworks --release --jobs 1
- name: Setup artifact
run: |
mkdir -p ${{ github.workspace }}/artifact
Expand All @@ -44,11 +44,11 @@ jobs:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build luminol (Release)
run: cargo build --features steamworks --release
run: cargo build --features steamworks --release --jobs 1
- name: Setup artifact
run: |
mkdir -p ${{ github.workspace }}/artifact
Expand All @@ -69,11 +69,11 @@ jobs:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build luminol (Release)
run: cargo build --features steamworks --release
run: cargo build --features steamworks --release --jobs 1
- name: Setup artifact
run: |
mkdir -p ${{ github.workspace }}/artifact
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
- name: Install libraries
run: |
sudo apt update
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev -y
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build luminol (Release)
run: cargo build --release
run: cargo build --release --jobs 1
- name: Setup artifact
run: |
mkdir -p ${{ github.workspace }}/artifact
Expand All @@ -42,11 +42,11 @@ jobs:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build luminol (Release)
run: cargo build --release
run: cargo build --release --jobs 1
- name: Setup artifact
run: |
mkdir -p ${{ github.workspace }}/artifact
Expand All @@ -66,11 +66,11 @@ jobs:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build luminol (Release)
run: cargo build --release
run: cargo build --release --jobs 1
- name: Setup artifact
run: |
mkdir -p ${{ github.workspace }}/artifact
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
- name: Install libraries
run: |
sudo apt update
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- run: cargo check --all-features
- run: cargo check --all-features --jobs 1

test:
name: Test Suite
Expand All @@ -30,13 +30,13 @@ jobs:
submodules: true
- run: |
sudo apt update
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libgtk-3-dev libasound2-dev -y
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- run: cargo test --lib
- run: cargo test --lib --jobs 1

fmt:
name: Rustfmt
Expand All @@ -48,10 +48,10 @@ jobs:
- name: Install libraries
run: |
sudo apt update
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev -y
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
components: rustfmt
- name: Rust Cache
uses: Swatinem/rust-cache@v2
Expand All @@ -67,11 +67,11 @@ jobs:
- name: Install libraries
run: |
sudo apt update
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev -y
sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-21
toolchain: nightly-2023-09-12
components: clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- run: cargo clippy -- # -D warnings
- run: cargo clippy --jobs 1 -- # -D warnings
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ git-conventional-commits.yaml
# Steamworks common folder
steamworks/*
# Allow the redistributable, though
!steamworks/redistributable_bin
!steamworks/redistributable_bin
#! renderdoc
captures/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "alox-48"]
path = alox-48
url = https://github.com/Speak2Erase/alox-48
8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
"playtest",
"wasm",
"filesystem",
"image cache"
"image cache",
"tilemap",
"config",
"audio"
],
"rust-analyzer.showUnlinkedFileNotification": false,
"rust-analyzer.cargo.extraEnv": {
"CARGO_PROFILE_RUST_ANALYZER_INHERITS": "dev"
},
"rust-analyzer.cargo.extraArgs": [
"rust-analyzer.cargo.extraArgs": [],
"rust-analyzer.check.extraArgs": [
"--profile",
"rust-analyzer"
],
Expand Down
Loading

0 comments on commit 8df72ba

Please sign in to comment.