lullaby/systems/gltf_asset/gltf_asset.cc
// Gets an accessor for a specific vertex attribute |name| if it is in
// |attr_map|, which references model. Returns nullptr if the name isn't present
// in the map OR if the accessor is present, but has the wrong type, component
// type, or value count. If |expected_count| is 0, it will be ignored.
Gets an accessor for a specific vertex attribute |name| if it is in
|attr_map|, which references model. Returns nullptr if the name isn't present
in the map OR if the accessor is present, but has the wrong type, component
type, or value count. If |expected_count| is 0, it will be ignored.
Gets an accessor for a specific vertex attribute |name| if it is in |attr_map| which references model . Returns nullptr if the name isn ' t present in the map OR if the accessor is present but has the wrong type component type or value count . If |expected_count| is 0 it will be ignored .
const tinygltf::Accessor* GetAndVerifyAttributeAccessor(
    const std::map<std::string, int>& attr_map, const tinygltf::Model& model,
    string_view name, const std::unordered_set<int>& valid_types,
    const std::unordered_set<int>& valid_component_types,
    size_t expected_count) {
  const auto iter = attr_map.find(name.c_str());
  if (iter == attr_map.cend()) {
    return nullptr;
  }
  const tinygltf::Accessor& accessor = model.accessors[iter->second];
  if (valid_types.find(accessor.type) == valid_types.cend()) {
    LOG(DFATAL) << name << " accessor has an invalid type: " << accessor.type;
    return nullptr;
  }
  if (valid_component_types.find(accessor.componentType) ==
      valid_types.cend()) {
    LOG(DFATAL) << name << " accessor has an invalid component type: "
                << accessor.componentType;
    return nullptr;
  }
  if (expected_count != 0 && accessor.count != expected_count) {
    LOG(DFATAL) << name << " accessor does not have the correct count: "
                << "expected " << expected_count << ", got " << accessor.count;
    return nullptr;
  }
  return &accessor;
}
const tinygltf :: Accessor * GetAndVerifyAttributeAccessor ( const std :: map < std :: string , int > & attr_map , const tinygltf :: Model & model , string_view name , const std :: unordered_set < int > & valid_types , const std :: unordered_set < int > & valid_component_types , size_t expected_count ) { const auto iter = attr_map . find ( name . c_str ( ) ) ; if ( iter == attr_map . cend ( ) ) { return nullptr ; } const tinygltf :: Accessor & accessor = model . accessors [ iter -> second ] ; if ( valid_types . find ( accessor . type ) == valid_types . cend ( ) ) { LOG ( DFATAL ) << name << " " << accessor . type ; return nullptr ; } if ( valid_component_types . find ( accessor . componentType ) == valid_types . cend ( ) ) { LOG ( DFATAL ) << name << " " << accessor . componentType ; return nullptr ; } if ( expected_count != 0 && accessor . count != expected_count ) { LOG ( DFATAL ) << name << " " << " " << expected_count << " " << accessor . count ; return nullptr ; } return & accessor ; }
Gets an accessor for a specific vertex attribute |name| if it is in
|attr_map|, which references model.
Gets an accessor for a specific vertex attribute |name| if it is in |attr_map| which references model .