Skip to content

Commit 27aa9d2

Browse files
committed
example showcase: keep the order of the shaders imported (#14035)
# Objective - After #13908, shaders imported are collected - this is done with a hashset, so order is random between executions ## Solution - Don't use a hashset, and keep the order they were found in the example
1 parent f8e165b commit 27aa9d2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tools/example-showcase/src/main.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Tool to run all examples or generate a showcase page for the Bevy website.
22
33
use std::{
4-
collections::{hash_map::DefaultHasher, HashMap, HashSet},
4+
collections::{hash_map::DefaultHasher, HashMap},
55
fmt::Display,
66
fs::{self, File},
77
hash::{Hash, Hasher},
@@ -731,13 +731,17 @@ fn parse_examples() -> Vec<Example> {
731731
Regex::new(r"(shaders\/\w+\.wgsl)|(shaders\/\w+\.frag)|(shaders\/\w+\.vert)")
732732
.unwrap();
733733

734-
// Find all instances of references to shader files, collect into set to avoid duplicates, then convert to vec of strings.
735-
let shader_paths = Vec::from_iter(
736-
shader_regex
737-
.find_iter(&source_code)
738-
.map(|matches| matches.as_str().to_owned())
739-
.collect::<HashSet<String>>(),
740-
);
734+
// Find all instances of references to shader files, and keep them in an ordered and deduped vec.
735+
let mut shader_paths = vec![];
736+
for path in shader_regex
737+
.find_iter(&source_code)
738+
.map(|matches| matches.as_str().to_owned())
739+
{
740+
if !shader_paths.contains(&path) {
741+
shader_paths.push(path);
742+
}
743+
}
744+
741745
if metadatas
742746
.get(&technical_name)
743747
.and_then(|metadata| metadata.get("hidden"))

0 commit comments

Comments
 (0)