From 35d6052c7da5d282e8a4bbb1afde8c7bfa44ba03 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 24 Oct 2023 19:45:09 -0700 Subject: [PATCH] Remove float->int casts from read_integer/read_index The float->int cast in read_integer is unreachable as this function is only called from read_float, and it handles r_32f separately. The float->int cast in read_index is reachable since the caller may call accessor_read_index or unpack_indices on a floating-point buffer. However, there should be no valid circumstances to do this as cases when glTF buffers carry index data (geometry indices, sparse accessors) require unnormalized integers by the spec. --- cgltf.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cgltf.h b/cgltf.h index af24c65..039bdaa 100644 --- a/cgltf.h +++ b/cgltf.h @@ -2225,8 +2225,6 @@ static cgltf_ssize cgltf_component_read_integer(const void* in, cgltf_component_ return *((const uint16_t*) in); case cgltf_component_type_r_32u: return *((const uint32_t*) in); - case cgltf_component_type_r_32f: - return (cgltf_ssize)*((const float*) in); case cgltf_component_type_r_8: return *((const int8_t*) in); case cgltf_component_type_r_8u: @@ -2244,8 +2242,6 @@ static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_typ return *((const uint16_t*) in); case cgltf_component_type_r_32u: return *((const uint32_t*) in); - case cgltf_component_type_r_32f: - return (cgltf_size)((cgltf_ssize)*((const float*) in)); case cgltf_component_type_r_8u: return *((const uint8_t*) in); default: