From 3a4b2d56dcd273311c1fec8cd922628a32ebf08e Mon Sep 17 00:00:00 2001 From: Hugo Woodiwiss Date: Tue, 1 Jun 2021 14:30:36 +0100 Subject: [PATCH] Update tutorial 13 to tobj 3.0.x --- Cargo.lock | 2 +- code/intermediate/tutorial13-threading/Cargo.toml | 2 +- code/intermediate/tutorial13-threading/src/model.rs | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f620979..30246c04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2239,7 +2239,7 @@ dependencies = [ "image", "log", "rayon", - "tobj 2.0.2", + "tobj 3.0.1", "wgpu", "winit", ] diff --git a/code/intermediate/tutorial13-threading/Cargo.toml b/code/intermediate/tutorial13-threading/Cargo.toml index f60e0115..5fd0fafb 100644 --- a/code/intermediate/tutorial13-threading/Cargo.toml +++ b/code/intermediate/tutorial13-threading/Cargo.toml @@ -13,7 +13,7 @@ futures = "0.3" image = "0.23" log = "0.4" rayon = "1.4" # NEW! -tobj = "2.0" +tobj = "3.0" wgpu = "0.8" winit = "0.24" diff --git a/code/intermediate/tutorial13-threading/src/model.rs b/code/intermediate/tutorial13-threading/src/model.rs index bbdfb1bc..2297678e 100644 --- a/code/intermediate/tutorial13-threading/src/model.rs +++ b/code/intermediate/tutorial13-threading/src/model.rs @@ -1,3 +1,4 @@ +use tobj::LoadOptions; use anyhow::*; use rayon::prelude::*; use std::ops::Range; @@ -125,7 +126,14 @@ impl Model { layout: &wgpu::BindGroupLayout, path: P, ) -> Result { - let (obj_models, obj_materials) = tobj::load_obj(path.as_ref(), true)?; + let (obj_models, obj_materials) = tobj::load_obj(path.as_ref(), &LoadOptions { + triangulate: true, + single_index: true, + ..Default::default() + }, + )?; + + let obj_materials = obj_materials?; // We're assuming that the texture files are stored with the obj file let containing_folder = path.as_ref().parent().context("Directory has no parent")?;