Changeset View
Changeset View
Standalone View
Standalone View
source/blender/alembic/intern/abc_customdata.cc
| Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | static void read_uvs(const CDStreamConfig &config, void *data, | ||||
| } | } | ||||
| } | } | ||||
| static size_t mcols_out_of_bounds_check( | static size_t mcols_out_of_bounds_check( | ||||
| const size_t color_index, | const size_t color_index, | ||||
| const size_t array_size, | const size_t array_size, | ||||
| const std::string & iobject_full_name, | const std::string & iobject_full_name, | ||||
| const PropertyHeader &prop_header, | const PropertyHeader &prop_header, | ||||
| bool &r_is_out_of_bounds, | |||||
| bool &r_bounds_warning_given) | bool &r_bounds_warning_given) | ||||
| { | { | ||||
| if (color_index < array_size) { | if (color_index < array_size) { | ||||
| return color_index; | return color_index; | ||||
| } | } | ||||
| if (!r_bounds_warning_given) { | if (!r_bounds_warning_given) { | ||||
| std::cerr << "Alembic: color index out of bounds " | std::cerr << "Alembic: color index out of bounds " | ||||
| "reading face colors for object " | "reading face colors for object " | ||||
| << iobject_full_name | << iobject_full_name | ||||
| << ", property " | << ", property " | ||||
| << prop_header.getName() << std::endl; | << prop_header.getName() << std::endl; | ||||
| r_bounds_warning_given = true; | r_bounds_warning_given = true; | ||||
| } | } | ||||
| r_is_out_of_bounds = true; | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static void read_custom_data_mcols(const std::string & iobject_full_name, | static void read_custom_data_mcols(const std::string & iobject_full_name, | ||||
| const ICompoundProperty &arbGeomParams, | const ICompoundProperty &arbGeomParams, | ||||
| const PropertyHeader &prop_header, | const PropertyHeader &prop_header, | ||||
| const CDStreamConfig &config, | const CDStreamConfig &config, | ||||
| const Alembic::Abc::ISampleSelector &iss) | const Alembic::Abc::ISampleSelector &iss) | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | for (int j = 0; j < poly->totloop; ++j, ++face_index) { | ||||
| --cface; | --cface; | ||||
| --mloop; | --mloop; | ||||
| color_index = is_facevarying ? face_index : mloop->v; | color_index = is_facevarying ? face_index : mloop->v; | ||||
| if (use_dual_indexing) { | if (use_dual_indexing) { | ||||
| color_index = (*indices)[color_index]; | color_index = (*indices)[color_index]; | ||||
| } | } | ||||
| if (use_c3f_ptr) { | if (use_c3f_ptr) { | ||||
| bool is_mcols_out_of_bounds = false; | |||||
| color_index = mcols_out_of_bounds_check( | color_index = mcols_out_of_bounds_check( | ||||
| color_index, | color_index, | ||||
| c3f_ptr->size(), | c3f_ptr->size(), | ||||
| iobject_full_name, prop_header, | iobject_full_name, prop_header, | ||||
| bounds_warning_given); | is_mcols_out_of_bounds, bounds_warning_given); | ||||
| if (is_mcols_out_of_bounds) { | |||||
| continue; | |||||
| } | |||||
| const Imath::C3f &color = (*c3f_ptr)[color_index]; | const Imath::C3f &color = (*c3f_ptr)[color_index]; | ||||
| cface->a = unit_float_to_uchar_clamp(color[0]); | cface->a = unit_float_to_uchar_clamp(color[0]); | ||||
| cface->r = unit_float_to_uchar_clamp(color[1]); | cface->r = unit_float_to_uchar_clamp(color[1]); | ||||
| cface->g = unit_float_to_uchar_clamp(color[2]); | cface->g = unit_float_to_uchar_clamp(color[2]); | ||||
| cface->b = 255; | cface->b = 255; | ||||
| } | } | ||||
sybren: I think that `if (is_mcols_out_of_bounds) { continue; }` would be more elegant here. | |||||
| else { | else { | ||||
| bool is_mcols_out_of_bounds = false; | |||||
| color_index = mcols_out_of_bounds_check( | color_index = mcols_out_of_bounds_check( | ||||
| color_index, | color_index, | ||||
| c4f_ptr->size(), | c4f_ptr->size(), | ||||
| iobject_full_name, prop_header, | iobject_full_name, prop_header, | ||||
| bounds_warning_given); | is_mcols_out_of_bounds, bounds_warning_given); | ||||
| if (is_mcols_out_of_bounds) { | |||||
| continue; | |||||
| } | |||||
| const Imath::C4f &color = (*c4f_ptr)[color_index]; | const Imath::C4f &color = (*c4f_ptr)[color_index]; | ||||
| cface->a = unit_float_to_uchar_clamp(color[0]); | cface->a = unit_float_to_uchar_clamp(color[0]); | ||||
| cface->r = unit_float_to_uchar_clamp(color[1]); | cface->r = unit_float_to_uchar_clamp(color[1]); | ||||
| cface->g = unit_float_to_uchar_clamp(color[2]); | cface->g = unit_float_to_uchar_clamp(color[2]); | ||||
| cface->b = unit_float_to_uchar_clamp(color[3]); | cface->b = unit_float_to_uchar_clamp(color[3]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||
I think that if (is_mcols_out_of_bounds) { continue; } would be more elegant here.