Use at most 16 textures for ground and structures and load a part of the ground

This commit is contained in:
Benjamin Loison
2022-11-03 02:07:59 +01:00
parent a015f318c7
commit 9451959f78
2 changed files with 36 additions and 23 deletions
+12 -12
View File
@@ -25,7 +25,7 @@ struct PerInstance {
}
implement_vertex!(PerInstance, w_position, w_rotation);
const STRUCTURES_TEXTURES_NUMBER: usize = 78;
const STRUCTURES_TEXTURES_NUMBER: usize = 16; //78;
const STRUCTURES_TEXTURES: [&str; STRUCTURES_TEXTURES_NUMBER] = [
"redNoise.jpg",
"cargoLightBlue.jpg",
@@ -43,7 +43,7 @@ const STRUCTURES_TEXTURES: [&str; STRUCTURES_TEXTURES_NUMBER] = [
"30kmh.jpg",
"white.jpg",
"blackYellow.jpg",
"stopText.jpg",
/*"stopText.jpg",
"cargoOrange.jpg",
"redWhite.jpg",
"grid.png",
@@ -104,7 +104,7 @@ const STRUCTURES_TEXTURES: [&str; STRUCTURES_TEXTURES_NUMBER] = [
"yellowNoise.jpg",
"gridFull.jpg",
"rust.jpg",
"cargo.jpg",
"cargo.jpg",*/
];
// This approach works as there isn't file names having several file extensions.
@@ -126,7 +126,7 @@ static STRUCTURES_TEXTURES_REVERSED: phf::Map<&'static str, u32> = phf_map! {
"30kmh" => 13,
"white" => 14,
"blackYellow" => 15,
"stopText" => 16,
/*"stopText" => 16,
"cargoOrange" => 17,
"redWhite" => 18,
"grid" => 19,
@@ -187,10 +187,10 @@ static STRUCTURES_TEXTURES_REVERSED: phf::Map<&'static str, u32> = phf_map! {
"yellowNoise" => 74,
"gridFull" => 75,
"rust" => 76,
"cargo" => 77,
"cargo" => 77,*/
};
const BIOMES_NUMBER: usize = 19;
const BIOMES_NUMBER: usize = 16; //19;
const BIOMES: [&str; BIOMES_NUMBER] = [
"dirt",
"grassDry",
@@ -208,9 +208,9 @@ const BIOMES: [&str; BIOMES_NUMBER] = [
"mud",
"stonyThistle",
"marsh",
"dead",
/*"dead",
"desert",
"weed",
"weed",*/
];
fn main() {
@@ -549,9 +549,9 @@ fn main() {
tex13: &ground_textures[13],
tex14: &ground_textures[14],
tex15: &ground_textures[15],
tex16: &ground_textures[16],
/*tex16: &ground_textures[16],
tex17: &ground_textures[17],
tex18: &ground_textures[18],
tex18: &ground_textures[18],*/
};
// That way we *load* far too many textures per structure but until haven't treated http://gitea.lemnoslife.com:3006/Benjamin_Loison/LemnosLife_Rust/issues/6#issuecomment-240, can't do better.
@@ -575,7 +575,7 @@ fn main() {
tex13: &structures_textures[13],
tex14: &structures_textures[14],
tex15: &structures_textures[15],
tex16: &structures_textures[16],
/*tex16: &structures_textures[16],
tex17: &structures_textures[17],
tex18: &structures_textures[18],
tex19: &structures_textures[19],
@@ -636,7 +636,7 @@ fn main() {
tex74: &structures_textures[74],
tex75: &structures_textures[75],
tex76: &structures_textures[76],
tex77: &structures_textures[77],
tex77: &structures_textures[77],*/
};
// draw parameters
+17 -4
View File
@@ -104,6 +104,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
.unwrap()
.replace(ground_folder, "")
.replace(".height", "");
//for file_name in ["3 13"] {
println!("{}", file_name);
let file_name_parts: Vec<&str> = file_name.split(' ').collect();
@@ -187,9 +188,9 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
chunk,
});
// i == 250 thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BufferCreationError(OutOfMemory)', src/support/mod.rs:203:10
/*if i == 1 {
if i == 200 {
break;
}*/
}
}
println!("charlie");
@@ -226,7 +227,13 @@ pub fn load_wavefront(display: &Display, data: &[u8]) -> VertexBufferAny {
let texture_index = if let obj::ObjMaterial::Ref(texture) =
group.material.as_ref().unwrap()
{
STRUCTURES_TEXTURES_REVERSED[texture]
if let Some(texture_index) =
STRUCTURES_TEXTURES_REVERSED.get(texture)
{
*texture_index
} else {
0
}
} else {
panic!()
};
@@ -246,7 +253,13 @@ pub fn load_wavefront(display: &Display, data: &[u8]) -> VertexBufferAny {
let texture_index = if let obj::ObjMaterial::Ref(texture) =
group.material.as_ref().unwrap()
{
STRUCTURES_TEXTURES_REVERSED[texture]
if let Some(texture_index) =
STRUCTURES_TEXTURES_REVERSED.get(texture)
{
*texture_index
} else {
0
}
} else {
panic!()
};