Skip to content

Commit

Permalink
Merge pull request #38 from urholaukkarinen/major-overhaul
Browse files Browse the repository at this point in the history
Subgizmo code is reorganized and simplified + fixes to graphical glitches
  • Loading branch information
urholaukkarinen authored Jan 29, 2024
2 parents 57215a0 + 51faba0 commit 26e1c4a
Show file tree
Hide file tree
Showing 21 changed files with 1,086 additions and 989 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on: [push, pull_request]

name: Rust

jobs:
fmt-crank-check-test:
name: format + check + test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.72.0

- name: cache
uses: Swatinem/rust-cache@v2

- name: fmt
run: cargo fmt --all -- --check

- name: install cargo-cranky
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-cranky

- name: check --all-features
run: cargo check --all-features --all-targets

- name: test doc-tests
run: cargo test --doc --all-features

- name: test
run: cargo test --all-features

- name: cranky
run: cargo cranky --all-targets --all-features -- -D warnings

- name: cranky --release
run: cargo cranky --all-targets --all-features --release -- -D warnings
153 changes: 153 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,156 @@ mint = "0.5"
[profile.release]
opt-level = "s"
lto = "thin"

[lints]
workspace = true

[workspace.lints.rust]
elided_lifetimes_in_paths = "allow"
future_incompatible = "deny"
nonstandard_style = "deny"
rust_2018_idioms = "warn"
rust_2021_prelude_collisions = "deny"
semicolon_in_expressions_from_macros = "deny"
trivial_numeric_casts = "deny"
unsafe_op_in_unsafe_fn = "deny"
unused_extern_crates = "deny"
unused_import_braces = "deny"
unused_lifetimes = "deny"
unsafe_code = "deny"

[workspace.lints.clippy]
all = "deny"
as_ptr_cast_mut = "deny"
await_holding_lock = "deny"
bool_to_int_with_if = "deny"
branches_sharing_code = "deny"
char_lit_as_u8 = "deny"
checked_conversions = "deny"
clear_with_drain = "deny"
cloned_instead_of_copied = "deny"
dbg_macro = "deny"
debug_assert_with_mut_call = "deny"
default_union_representation = "deny"
derive_partial_eq_without_eq = "deny"
disallowed_macros = "deny"
disallowed_methods = "deny"
disallowed_names = "deny"
disallowed_script_idents = "deny"
disallowed_types = "deny"
doc_link_with_quotes = "deny"
doc_markdown = "deny"
empty_enum = "deny"
empty_line_after_outer_attr = "deny"
enum_glob_use = "deny"
equatable_if_let = "deny"
exit = "deny"
expl_impl_clone_on_copy = "deny"
explicit_deref_methods = "deny"
explicit_into_iter_loop = "deny"
explicit_iter_loop = "deny"
fallible_impl_from = "deny"
filter_map_next = "deny"
flat_map_option = "deny"
float_cmp_const = "deny"
fn_params_excessive_bools = "deny"
fn_to_numeric_cast_any = "deny"
from_iter_instead_of_collect = "deny"
get_unwrap = "deny"
if_let_mutex = "deny"
implicit_clone = "deny"
imprecise_flops = "deny"
index_refutable_slice = "deny"
inefficient_to_string = "deny"
invalid_upcast_comparisons = "deny"
iter_not_returning_iterator = "deny"
iter_on_empty_collections = "deny"
iter_on_single_items = "deny"
large_digit_groups = "deny"
large_include_file = "deny"
large_stack_arrays = "deny"
large_stack_frames = "deny"
large_types_passed_by_value = "deny"
let_unit_value = "deny"
linkedlist = "deny"
lossy_float_literal = "deny"
macro_use_imports = "deny"
manual_assert = "deny"
manual_clamp = "deny"
manual_instant_elapsed = "deny"
manual_let_else = "deny"
manual_ok_or = "deny"
manual_string_new = "deny"
map_err_ignore = "deny"
map_flatten = "deny"
map_unwrap_or = "deny"
match_on_vec_items = "deny"
match_same_arms = "deny"
match_wild_err_arm = "deny"
match_wildcard_for_single_variants = "deny"
mem_forget = "deny"
mismatched_target_os = "deny"
mismatching_type_param_order = "deny"
missing_enforced_import_renames = "deny"
missing_safety_doc = "deny"
mut_mut = "deny"
mutex_integer = "deny"
needless_borrow = "deny"
needless_continue = "deny"
needless_for_each = "deny"
needless_pass_by_value = "deny"
negative_feature_names = "deny"
nonstandard_macro_braces = "deny"
option_option = "deny"
path_buf_push_overwrite = "deny"
print_stdout = "deny"
ptr_as_ptr = "deny"
ptr_cast_constness = "deny"
pub_without_shorthand = "deny"
rc_mutex = "deny"
redundant_type_annotations = "deny"
ref_option_ref = "deny"
rest_pat_in_fully_bound_structs = "deny"
same_functions_in_if_condition = "deny"
semicolon_if_nothing_returned = "deny"
significant_drop_tightening = "deny"
single_match_else = "deny"
str_to_string = "deny"
string_add_assign = "deny"
string_add = "deny"
string_lit_as_bytes = "deny"
string_to_string = "deny"
suspicious_command_arg_space = "deny"
suspicious_xor_used_as_pow = "deny"
todo = "deny"
trailing_empty_array = "deny"
trait_duplication_in_bounds = "deny"
transmute_ptr_to_ptr = "deny"
tuple_array_conversions = "deny"
unchecked_duration_subtraction = "deny"
unimplemented = "deny"
uninlined_format_args = "deny"
unnecessary_box_returns = "deny"
unnecessary_safety_comment = "deny"
unnecessary_safety_doc = "deny"
unnecessary_self_imports = "deny"
unnecessary_struct_initialization = "deny"
unnecessary_wraps = "deny"
unnested_or_patterns = "deny"
unused_peekable = "deny"
unused_rounding = "deny"
unused_self = "deny"
use_self = "deny"
useless_transmute = "deny"
verbose_file_reads = "deny"
wildcard_dependencies = "deny"
zero_sized_map_values = "deny"
let_underscore_untyped = "allow"
missing_assert_message = "allow"
missing_errors_doc = "allow"
too_many_lines = "allow"
undocumented_unsafe_blocks = "allow"
unwrap_used = "allow"
wildcard_imports = "allow"
large-types-passed-by-value = "allow"
needless-pass-by-value = "allow"
3 changes: 3 additions & 0 deletions demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ rev="bc3dd1559e24ca0178ed1d2dfef07cb784437505"
[dependencies.bevy_infinite_grid]
git = "https://github.com/pcwalton/bevy_infinite_grid.git"
rev = "c752a23063b2b05163e307889eb276d6574115ab"

[lints]
workspace = true
1 change: 0 additions & 1 deletion demo/build_web.sh

This file was deleted.

4 changes: 2 additions & 2 deletions demo/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct PanOrbitCamera {

impl Default for PanOrbitCamera {
fn default() -> Self {
PanOrbitCamera {
Self {
focus: Vec3::ZERO,
radius: 5.0,
upside_down: false,
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn update_camera(
orbit_button_changed = true;
}

for (mut pan_orbit, mut transform, projection) in query.iter_mut() {
for (mut pan_orbit, mut transform, projection) in &mut query {
if orbit_button_changed {
// only check for upside down when orbiting started or ended this frame
// if the camera is "upside" down, panning horizontally would be inverted, so invert the input to make it correct
Expand Down
2 changes: 1 addition & 1 deletion docs/egui-gizmo-demo.js

Large diffs are not rendered by default.

Binary file modified docs/egui-gizmo-demo_bg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<title>egui-gizmo demo</title><style>body,canvas,html{margin:0;padding:0;width:100%;height:100%;overflow:hidden;position:absolute;background:black;z-index:0}</style><link as=fetch crossorigin href=./egui-gizmo-demo_bg.wasm integrity=sha384-0IsFCjRufCuGXGz07Y9s5KPkzzJ4lc9eStTf1slrcfK6T6qJV2o-APa6DgyIymyy rel=preload type=application/wasm><link crossorigin href=./egui-gizmo-demo.js integrity=sha384-AMlWz6FdyRln6WA_6U03u7Y2DAcOIc0eyT-OJ0UAQSSK7olp-CRXAUEivD4rH425 rel=modulepreload></head><body oncontextmenu="return false;"><script type=module>import a,*as b from"./egui-gizmo-demo.js";a(`./egui-gizmo-demo_bg.wasm`);window.wasmBindings=b</script></body></html>
<title>egui-gizmo demo</title><style>body,canvas,html{margin:0;padding:0;width:100%;height:100%;overflow:hidden;position:absolute;background:black;z-index:0}</style><link as=fetch crossorigin href=./egui-gizmo-demo_bg.wasm integrity=sha384-CoZgxOfGNgMidVxJZBj4y6IuxI1sBygjdJhVTE1STBBbuI7MwBz-Db2lvBAIZn27 rel=preload type=application/wasm><link crossorigin href=./egui-gizmo-demo.js integrity=sha384-pWDv33DuDrrkUHe2XL4zSWeCkMKnGRdKnj4ZFZtrJ9rHUbhYIC37AQfABk_zoZ-C rel=modulepreload></head><body oncontextmenu="return false;"><script type=module>import a,*as b from"./egui-gizmo-demo.js";a(`./egui-gizmo-demo_bg.wasm`);window.wasmBindings=b</script></body></html>
4 changes: 4 additions & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "1.74.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
12 changes: 12 additions & 0 deletions scripts/build_demo_web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

WASM_PATH="docs/egui-gizmo-demo_bg.wasm"

pushd "$script_path/../demo"
trunk build --config Trunk.toml --release
popd

wasm-opt "$WASM_PATH" -O2 --fast-math -o "$WASM_PATH"
Loading

0 comments on commit 26e1c4a

Please sign in to comment.