remove unused fn

This commit is contained in:
Carter Anderson 2020-05-16 12:53:49 -07:00
parent b1f07e3749
commit 623c8a8d9a

View file

@ -320,76 +320,6 @@ pub mod shape {
}
}
fn setup_mesh_resource(
render_resources: &dyn RenderResourceContext,
renderable: &mut Renderable,
vertex_buffer_descriptor: &VertexBufferDescriptor,
entities_waiting_for_assets: &EntitiesWaitingForAssets,
entity: Entity,
handle: Handle<Mesh>,
meshes: &Assets<Mesh>,
mesh_changed: bool,
) {
log::trace!(
"setup mesh for {:?}",
renderable.render_resource_assignments.id
);
let index_format = IndexFormat::Uint16;
let (vertex_buffer, index_buffer) = if mesh_changed
|| render_resources
.get_asset_resource(handle, VERTEX_BUFFER_ASSET_INDEX)
.is_none()
{
if let Some(mesh_asset) = meshes.get(&handle) {
renderable
.render_resource_assignments
.pipeline_specialization
.primitive_topology = mesh_asset.primitive_topology;
let vertex_bytes = mesh_asset
.get_vertex_buffer_bytes(&vertex_buffer_descriptor)
.unwrap();
// TODO: use a staging buffer here
let vertex_buffer = render_resources.create_buffer_with_data(
BufferInfo {
buffer_usage: BufferUsage::VERTEX,
..Default::default()
},
&vertex_bytes,
);
let index_bytes = mesh_asset.get_index_buffer_bytes(index_format).unwrap();
let index_buffer = render_resources.create_buffer_with_data(
BufferInfo {
buffer_usage: BufferUsage::INDEX,
..Default::default()
},
&index_bytes,
);
render_resources.set_asset_resource(handle, vertex_buffer, VERTEX_BUFFER_ASSET_INDEX);
render_resources.set_asset_resource(handle, index_buffer, INDEX_BUFFER_ASSET_INDEX);
(vertex_buffer, Some(index_buffer))
} else {
// mesh doesn't exist. it probably hasn't loaded yet
entities_waiting_for_assets.add(entity);
return;
}
} else if let Some(vertex_buffer) =
render_resources.get_asset_resource(handle, VERTEX_BUFFER_ASSET_INDEX)
{
(
vertex_buffer,
render_resources.get_asset_resource(handle, INDEX_BUFFER_ASSET_INDEX),
)
} else {
panic!("This should never be reached. The current 'if let' limitations make this case required.")
};
renderable
.render_resource_assignments
.set_vertex_buffer("Vertex", vertex_buffer, index_buffer);
}
pub fn mesh_resource_provider_system(resources: &mut Resources) -> Box<dyn Schedulable> {
let mut vertex_buffer_descriptors = resources.get_mut::<VertexBufferDescriptors>().unwrap();
let mesh_events = resources.get::<Events<AssetEvent<Mesh>>>().unwrap();