mirror of
https://github.com/redstrate/Physis.git
synced 2025-05-18 16:07:46 +00:00
Make indice reading (for models) slightly faster
As suspected - this was a little slow, and can be corroborated with Hotspot. This is only a marginal increase in performance, it isn't huge but still worth doing.
This commit is contained in:
parent
39f1c9665f
commit
f58d4e6bb0
1 changed files with 5 additions and 7 deletions
|
@ -10,8 +10,8 @@ pub mod vertex_declarations;
|
||||||
use std::io::{Cursor, Seek, SeekFrom};
|
use std::io::{Cursor, Seek, SeekFrom};
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
|
||||||
use binrw::BinRead;
|
|
||||||
use binrw::BinReaderExt;
|
use binrw::BinReaderExt;
|
||||||
|
use binrw::{BinRead, VecArgs};
|
||||||
use binrw::{BinWrite, BinWriterExt, binrw};
|
use binrw::{BinWrite, BinWriterExt, binrw};
|
||||||
|
|
||||||
use crate::common_file_operations::{read_bool_from, write_bool_as};
|
use crate::common_file_operations::{read_bool_from, write_bool_as};
|
||||||
|
@ -694,12 +694,10 @@ impl MDL {
|
||||||
))
|
))
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
// TODO: optimize!
|
let index_count = model.meshes[j as usize].index_count as usize;
|
||||||
let mut indices: Vec<u16> =
|
let indices: Vec<u16> = cursor
|
||||||
Vec::with_capacity(model.meshes[j as usize].index_count as usize);
|
.read_le_args(VecArgs::builder().count(index_count).finalize())
|
||||||
for _ in 0..model.meshes[j as usize].index_count {
|
.ok()?;
|
||||||
indices.push(cursor.read_le::<u16>().ok()?);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut submeshes: Vec<SubMesh> =
|
let mut submeshes: Vec<SubMesh> =
|
||||||
Vec::with_capacity(model.meshes[j as usize].submesh_count as usize);
|
Vec::with_capacity(model.meshes[j as usize].submesh_count as usize);
|
||||||
|
|
Loading…
Add table
Reference in a new issue