mirror of
https://github.com/Chaoscaot/schemsearch.git
synced 2025-12-15 20:17:05 +01:00
Add CPU matching option and improve default behavior handling
This commit is contained in:
@@ -7,10 +7,9 @@ license = "AGPL-3.0-or-later"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.160", features = ["derive"] }
|
||||
schemsearch-files = { path = "../schemsearch-files" }
|
||||
schemsearch-common = { path = "../schemsearch-common" }
|
||||
schemsearch-ocl-matcher = { path = "../schemsearch-ocl-matcher" }
|
||||
named-binary-tag = "0.6"
|
||||
libmath = "0.2.1"
|
||||
lazy_static = "1.4.0"
|
||||
lazy_static = "1.4.0"
|
||||
@@ -84,15 +84,7 @@ mod tests {
|
||||
let schematic = SpongeSchematic::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||
let endstone = SpongeSchematic::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
||||
|
||||
let _ = search(schematic, &endstone, SearchBehavior {
|
||||
ignore_block_data: true,
|
||||
ignore_block_entities: true,
|
||||
ignore_entities: true,
|
||||
ignore_air: false,
|
||||
air_as_any: false,
|
||||
threshold: 0.9,
|
||||
invalid_nbt: false
|
||||
});
|
||||
let _ = search(schematic, &endstone, SearchBehavior::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -100,15 +92,7 @@ mod tests {
|
||||
let schematic = SpongeSchematic::load(&PathBuf::from("../tests/Random.schem")).unwrap();
|
||||
let pattern = SpongeSchematic::load(&PathBuf::from("../tests/Pattern.schem")).unwrap();
|
||||
|
||||
let matches = search(schematic, &pattern, SearchBehavior {
|
||||
ignore_block_data: true,
|
||||
ignore_block_entities: true,
|
||||
ignore_entities: true,
|
||||
ignore_air: false,
|
||||
air_as_any: false,
|
||||
threshold: 0.9,
|
||||
invalid_nbt: false
|
||||
});
|
||||
let matches = search(schematic, &pattern, SearchBehavior::default());
|
||||
|
||||
assert_eq!(matches.len(), 1);
|
||||
assert_eq!(matches[0].x, 1);
|
||||
@@ -122,15 +106,7 @@ mod tests {
|
||||
let schematic = SpongeSchematic::load(&PathBuf::from("../tests/warships/GreyFly-by-Bosslar.schem")).unwrap();
|
||||
let pattern = SpongeSchematic::load(&PathBuf::from("../tests/gray_castle_complex.schem")).unwrap();
|
||||
|
||||
let matches = search(schematic, &pattern, SearchBehavior {
|
||||
ignore_block_data: false,
|
||||
ignore_block_entities: false,
|
||||
ignore_entities: false,
|
||||
ignore_air: false,
|
||||
air_as_any: false,
|
||||
threshold: 0.9,
|
||||
invalid_nbt: false
|
||||
});
|
||||
let matches = search(schematic, &pattern, SearchBehavior::default());
|
||||
|
||||
assert_eq!(matches.len(), 1);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ pub fn search(
|
||||
let schem_width = schem.width as usize;
|
||||
let schem_height = schem.height as usize;
|
||||
let schem_length = schem.length as usize;
|
||||
|
||||
if ocl_available() {
|
||||
|
||||
if !search_behavior.use_cpu && ocl_available() {
|
||||
return ocl_search(schem_data.as_slice(), [schem_width, schem_height, schem_length], pattern_schem.block_data.as_slice(), [pattern_width, pattern_height, pattern_length], *air_id, search_behavior).unwrap()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user