mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 00:47:32 +00:00
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
This commit is contained in:
parent
a3f91a28fc
commit
f757fe80b2
1 changed files with 12 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
//! Tool to run all examples or generate a showcase page for the Bevy website.
|
//! Tool to run all examples or generate a showcase page for the Bevy website.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::DefaultHasher, HashMap, HashSet},
|
collections::{hash_map::DefaultHasher, HashMap},
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
@ -731,13 +731,17 @@ fn parse_examples() -> Vec<Example> {
|
||||||
Regex::new(r"(shaders\/\w+\.wgsl)|(shaders\/\w+\.frag)|(shaders\/\w+\.vert)")
|
Regex::new(r"(shaders\/\w+\.wgsl)|(shaders\/\w+\.frag)|(shaders\/\w+\.vert)")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Find all instances of references to shader files, collect into set to avoid duplicates, then convert to vec of strings.
|
// Find all instances of references to shader files, and keep them in an ordered and deduped vec.
|
||||||
let shader_paths = Vec::from_iter(
|
let mut shader_paths = vec![];
|
||||||
shader_regex
|
for path in shader_regex
|
||||||
.find_iter(&source_code)
|
.find_iter(&source_code)
|
||||||
.map(|matches| matches.as_str().to_owned())
|
.map(|matches| matches.as_str().to_owned())
|
||||||
.collect::<HashSet<String>>(),
|
{
|
||||||
);
|
if !shader_paths.contains(&path) {
|
||||||
|
shader_paths.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if metadatas
|
if metadatas
|
||||||
.get(&technical_name)
|
.get(&technical_name)
|
||||||
.and_then(|metadata| metadata.get("hidden"))
|
.and_then(|metadata| metadata.get("hidden"))
|
||||||
|
|
Loading…
Reference in a new issue