Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/alembic/intern/abc_customdata.cc
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/alembic/intern/abc_customdata.cc')
-rw-r--r--source/blender/alembic/intern/abc_customdata.cc680
1 files changed, 342 insertions, 338 deletions
diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 1587f333e3d..20ca659d32f 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -41,101 +41,101 @@ extern "C" {
* such data in a way that lets other DCC know what they are for. See comments
* in the write code for the conventions. */
-using Alembic::AbcGeom::kVertexScope;
using Alembic::AbcGeom::kFacevaryingScope;
+using Alembic::AbcGeom::kVertexScope;
using Alembic::Abc::C4fArraySample;
using Alembic::Abc::UInt32ArraySample;
using Alembic::Abc::V2fArraySample;
-using Alembic::AbcGeom::OV2fGeomParam;
using Alembic::AbcGeom::OC4fGeomParam;
+using Alembic::AbcGeom::OV2fGeomParam;
static void get_uvs(const CDStreamConfig &config,
std::vector<Imath::V2f> &uvs,
std::vector<uint32_t> &uvidx,
void *cd_data)
{
- MLoopUV *mloopuv_array = static_cast<MLoopUV *>(cd_data);
-
- if (!mloopuv_array) {
- return;
- }
-
- const int num_poly = config.totpoly;
- MPoly *polygons = config.mpoly;
- MLoop *mloop = config.mloop;
-
- if (!config.pack_uvs) {
- int cnt = 0;
- uvidx.resize(config.totloop);
- uvs.resize(config.totloop);
-
- /* Iterate in reverse order to match exported polygons. */
- for (int i = 0; i < num_poly; ++i) {
- MPoly &current_poly = polygons[i];
- MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
-
- for (int j = 0; j < current_poly.totloop; ++j, ++cnt) {
- --loopuv;
-
- uvidx[cnt] = cnt;
- uvs[cnt][0] = loopuv->uv[0];
- uvs[cnt][1] = loopuv->uv[1];
- }
- }
- }
- else {
- /* Mapping for indexed UVs, deduplicating UV coordinates at vertices. */
- std::vector<std::vector<uint32_t>> idx_map(config.totvert);
- int idx_count = 0;
-
- for (int i = 0; i < num_poly; ++i) {
- MPoly &current_poly = polygons[i];
- MLoop *looppoly = mloop + current_poly.loopstart + current_poly.totloop;
- MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
-
- for (int j = 0; j < current_poly.totloop; ++j) {
- --looppoly;
- --loopuv;
-
- Imath::V2f uv(loopuv->uv[0], loopuv->uv[1]);
- bool found_same = false;
-
- /* Find UV already in uvs array. */
- for (uint32_t uv_idx : idx_map[looppoly->v]) {
- if (uvs[uv_idx] == uv) {
- found_same = true;
- uvidx.push_back(uv_idx);
- break;
- }
- }
-
- /* UV doesn't exists for this vertex, add it. */
- if (!found_same) {
- uint32_t uv_idx = idx_count++;
- idx_map[looppoly->v].push_back(uv_idx);
- uvidx.push_back(uv_idx);
- uvs.push_back(uv);
- }
- }
- }
- }
+ MLoopUV *mloopuv_array = static_cast<MLoopUV *>(cd_data);
+
+ if (!mloopuv_array) {
+ return;
+ }
+
+ const int num_poly = config.totpoly;
+ MPoly *polygons = config.mpoly;
+ MLoop *mloop = config.mloop;
+
+ if (!config.pack_uvs) {
+ int cnt = 0;
+ uvidx.resize(config.totloop);
+ uvs.resize(config.totloop);
+
+ /* Iterate in reverse order to match exported polygons. */
+ for (int i = 0; i < num_poly; ++i) {
+ MPoly &current_poly = polygons[i];
+ MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
+
+ for (int j = 0; j < current_poly.totloop; ++j, ++cnt) {
+ --loopuv;
+
+ uvidx[cnt] = cnt;
+ uvs[cnt][0] = loopuv->uv[0];
+ uvs[cnt][1] = loopuv->uv[1];
+ }
+ }
+ }
+ else {
+ /* Mapping for indexed UVs, deduplicating UV coordinates at vertices. */
+ std::vector<std::vector<uint32_t>> idx_map(config.totvert);
+ int idx_count = 0;
+
+ for (int i = 0; i < num_poly; ++i) {
+ MPoly &current_poly = polygons[i];
+ MLoop *looppoly = mloop + current_poly.loopstart + current_poly.totloop;
+ MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
+
+ for (int j = 0; j < current_poly.totloop; ++j) {
+ --looppoly;
+ --loopuv;
+
+ Imath::V2f uv(loopuv->uv[0], loopuv->uv[1]);
+ bool found_same = false;
+
+ /* Find UV already in uvs array. */
+ for (uint32_t uv_idx : idx_map[looppoly->v]) {
+ if (uvs[uv_idx] == uv) {
+ found_same = true;
+ uvidx.push_back(uv_idx);
+ break;
+ }
+ }
+
+ /* UV doesn't exists for this vertex, add it. */
+ if (!found_same) {
+ uint32_t uv_idx = idx_count++;
+ idx_map[looppoly->v].push_back(uv_idx);
+ uvidx.push_back(uv_idx);
+ uvs.push_back(uv);
+ }
+ }
+ }
+ }
}
const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data)
{
- const int active_uvlayer = CustomData_get_active_layer(data, CD_MLOOPUV);
+ const int active_uvlayer = CustomData_get_active_layer(data, CD_MLOOPUV);
- if (active_uvlayer < 0) {
- return "";
- }
+ if (active_uvlayer < 0) {
+ return "";
+ }
- void *cd_data = CustomData_get_layer_n(data, CD_MLOOPUV, active_uvlayer);
+ void *cd_data = CustomData_get_layer_n(data, CD_MLOOPUV, active_uvlayer);
- get_uvs(config, sample.uvs, sample.indices, cd_data);
+ get_uvs(config, sample.uvs, sample.indices, cd_data);
- return CustomData_get_layer_name(data, CD_MLOOPUV, active_uvlayer);
+ return CustomData_get_layer_name(data, CD_MLOOPUV, active_uvlayer);
}
/* Convention to write UVs:
@@ -143,102 +143,109 @@ const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, Custom
* - set scope as face varying
* - (optional due to its behavior) tag as UV using Alembic::AbcGeom::SetIsUV
*/
-static void write_uv(const OCompoundProperty &prop, const CDStreamConfig &config, void *data, const char *name)
+static void write_uv(const OCompoundProperty &prop,
+ const CDStreamConfig &config,
+ void *data,
+ const char *name)
{
- std::vector<uint32_t> indices;
- std::vector<Imath::V2f> uvs;
+ std::vector<uint32_t> indices;
+ std::vector<Imath::V2f> uvs;
- get_uvs(config, uvs, indices, data);
+ get_uvs(config, uvs, indices, data);
- if (indices.empty() || uvs.empty()) {
- return;
- }
+ if (indices.empty() || uvs.empty()) {
+ return;
+ }
- OV2fGeomParam param(prop, name, true, kFacevaryingScope, 1);
+ OV2fGeomParam param(prop, name, true, kFacevaryingScope, 1);
- OV2fGeomParam::Sample sample(
- V2fArraySample(&uvs.front(), uvs.size()),
- UInt32ArraySample(&indices.front(), indices.size()),
- kFacevaryingScope);
+ OV2fGeomParam::Sample sample(V2fArraySample(&uvs.front(), uvs.size()),
+ UInt32ArraySample(&indices.front(), indices.size()),
+ kFacevaryingScope);
- param.set(sample);
+ param.set(sample);
}
/* Convention to write Vertex Colors:
* - C3fGeomParam/C4fGeomParam on the arbGeomParam
* - set scope as vertex varying
*/
-static void write_mcol(const OCompoundProperty &prop, const CDStreamConfig &config, void *data, const char *name)
+static void write_mcol(const OCompoundProperty &prop,
+ const CDStreamConfig &config,
+ void *data,
+ const char *name)
{
- const float cscale = 1.0f / 255.0f;
- MPoly *polys = config.mpoly;
- MLoop *mloops = config.mloop;
- MCol *cfaces = static_cast<MCol *>(data);
+ const float cscale = 1.0f / 255.0f;
+ MPoly *polys = config.mpoly;
+ MLoop *mloops = config.mloop;
+ MCol *cfaces = static_cast<MCol *>(data);
- std::vector<Imath::C4f> buffer;
- std::vector<uint32_t> indices;
+ std::vector<Imath::C4f> buffer;
+ std::vector<uint32_t> indices;
- buffer.reserve(config.totvert);
- indices.reserve(config.totvert);
+ buffer.reserve(config.totvert);
+ indices.reserve(config.totvert);
- Imath::C4f col;
+ Imath::C4f col;
- for (int i = 0; i < config.totpoly; ++i) {
- MPoly *p = &polys[i];
- MCol *cface = &cfaces[p->loopstart + p->totloop];
- MLoop *mloop = &mloops[p->loopstart + p->totloop];
+ for (int i = 0; i < config.totpoly; ++i) {
+ MPoly *p = &polys[i];
+ MCol *cface = &cfaces[p->loopstart + p->totloop];
+ MLoop *mloop = &mloops[p->loopstart + p->totloop];
- for (int j = 0; j < p->totloop; ++j) {
- cface--;
- mloop--;
+ for (int j = 0; j < p->totloop; ++j) {
+ cface--;
+ mloop--;
- col[0] = cface->a * cscale;
- col[1] = cface->r * cscale;
- col[2] = cface->g * cscale;
- col[3] = cface->b * cscale;
+ col[0] = cface->a * cscale;
+ col[1] = cface->r * cscale;
+ col[2] = cface->g * cscale;
+ col[3] = cface->b * cscale;
- buffer.push_back(col);
- indices.push_back(buffer.size() - 1);
- }
- }
+ buffer.push_back(col);
+ indices.push_back(buffer.size() - 1);
+ }
+ }
- OC4fGeomParam param(prop, name, true, kFacevaryingScope, 1);
+ OC4fGeomParam param(prop, name, true, kFacevaryingScope, 1);
- OC4fGeomParam::Sample sample(
- C4fArraySample(&buffer.front(), buffer.size()),
- UInt32ArraySample(&indices.front(), indices.size()),
- kVertexScope);
+ OC4fGeomParam::Sample sample(C4fArraySample(&buffer.front(), buffer.size()),
+ UInt32ArraySample(&indices.front(), indices.size()),
+ kVertexScope);
- param.set(sample);
+ param.set(sample);
}
-void write_custom_data(const OCompoundProperty &prop, const CDStreamConfig &config, CustomData *data, int data_type)
+void write_custom_data(const OCompoundProperty &prop,
+ const CDStreamConfig &config,
+ CustomData *data,
+ int data_type)
{
- CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
-
- if (!CustomData_has_layer(data, cd_data_type)) {
- return;
- }
-
- const int active_layer = CustomData_get_active_layer(data, cd_data_type);
- const int tot_layers = CustomData_number_of_layers(data, cd_data_type);
-
- for (int i = 0; i < tot_layers; ++i) {
- void *cd_data = CustomData_get_layer_n(data, cd_data_type, i);
- const char *name = CustomData_get_layer_name(data, cd_data_type, i);
-
- if (cd_data_type == CD_MLOOPUV) {
- /* Already exported. */
- if (i == active_layer) {
- continue;
- }
-
- write_uv(prop, config, cd_data, name);
- }
- else if (cd_data_type == CD_MLOOPCOL) {
- write_mcol(prop, config, cd_data, name);
- }
- }
+ CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
+
+ if (!CustomData_has_layer(data, cd_data_type)) {
+ return;
+ }
+
+ const int active_layer = CustomData_get_active_layer(data, cd_data_type);
+ const int tot_layers = CustomData_number_of_layers(data, cd_data_type);
+
+ for (int i = 0; i < tot_layers; ++i) {
+ void *cd_data = CustomData_get_layer_n(data, cd_data_type, i);
+ const char *name = CustomData_get_layer_name(data, cd_data_type, i);
+
+ if (cd_data_type == CD_MLOOPUV) {
+ /* Already exported. */
+ if (i == active_layer) {
+ continue;
+ }
+
+ write_uv(prop, config, cd_data, name);
+ }
+ else if (cd_data_type == CD_MLOOPCOL) {
+ write_mcol(prop, config, cd_data, name);
+ }
+ }
}
/* ************************************************************************** */
@@ -251,167 +258,165 @@ using Alembic::AbcGeom::IC3fGeomParam;
using Alembic::AbcGeom::IC4fGeomParam;
using Alembic::AbcGeom::IV2fGeomParam;
-
-static void read_uvs(const CDStreamConfig &config, void *data,
+static void read_uvs(const CDStreamConfig &config,
+ void *data,
const Alembic::AbcGeom::V2fArraySamplePtr &uvs,
const Alembic::AbcGeom::UInt32ArraySamplePtr &indices)
{
- MPoly *mpolys = config.mpoly;
- MLoopUV *mloopuvs = static_cast<MLoopUV *>(data);
-
- unsigned int uv_index, loop_index, rev_loop_index;
-
- for (int i = 0; i < config.totpoly; ++i) {
- MPoly &poly = mpolys[i];
- unsigned int rev_loop_offset = poly.loopstart + poly.totloop - 1;
-
- for (int f = 0; f < poly.totloop; ++f) {
- loop_index = poly.loopstart + f;
- rev_loop_index = rev_loop_offset - f;
- uv_index = (*indices)[loop_index];
- const Imath::V2f &uv = (*uvs)[uv_index];
-
- MLoopUV &loopuv = mloopuvs[rev_loop_index];
- loopuv.uv[0] = uv[0];
- loopuv.uv[1] = uv[1];
- }
- }
+ MPoly *mpolys = config.mpoly;
+ MLoopUV *mloopuvs = static_cast<MLoopUV *>(data);
+
+ unsigned int uv_index, loop_index, rev_loop_index;
+
+ for (int i = 0; i < config.totpoly; ++i) {
+ MPoly &poly = mpolys[i];
+ unsigned int rev_loop_offset = poly.loopstart + poly.totloop - 1;
+
+ for (int f = 0; f < poly.totloop; ++f) {
+ loop_index = poly.loopstart + f;
+ rev_loop_index = rev_loop_offset - f;
+ uv_index = (*indices)[loop_index];
+ const Imath::V2f &uv = (*uvs)[uv_index];
+
+ MLoopUV &loopuv = mloopuvs[rev_loop_index];
+ loopuv.uv[0] = uv[0];
+ loopuv.uv[1] = uv[1];
+ }
+ }
}
-static size_t mcols_out_of_bounds_check(
- const size_t color_index,
- const size_t array_size,
- const std::string & iobject_full_name,
- const PropertyHeader &prop_header,
- bool &r_is_out_of_bounds,
- bool &r_bounds_warning_given)
+static size_t mcols_out_of_bounds_check(const size_t color_index,
+ const size_t array_size,
+ const std::string &iobject_full_name,
+ const PropertyHeader &prop_header,
+ bool &r_is_out_of_bounds,
+ bool &r_bounds_warning_given)
{
- if (color_index < array_size) {
- return color_index;
- }
-
- if (!r_bounds_warning_given) {
- std::cerr << "Alembic: color index out of bounds "
- "reading face colors for object "
- << iobject_full_name
- << ", property "
- << prop_header.getName() << std::endl;
- r_bounds_warning_given = true;
- }
- r_is_out_of_bounds = true;
- return 0;
+ if (color_index < array_size) {
+ return color_index;
+ }
+
+ if (!r_bounds_warning_given) {
+ std::cerr << "Alembic: color index out of bounds "
+ "reading face colors for object "
+ << iobject_full_name << ", property " << prop_header.getName() << std::endl;
+ r_bounds_warning_given = true;
+ }
+ r_is_out_of_bounds = true;
+ 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 PropertyHeader &prop_header,
const CDStreamConfig &config,
const Alembic::Abc::ISampleSelector &iss)
{
- C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr();
- C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr();
- Alembic::Abc::UInt32ArraySamplePtr indices;
- bool use_c3f_ptr;
- bool is_facevarying;
-
- /* Find the correct interpretation of the data */
- if (IC3fGeomParam::matches(prop_header)) {
- IC3fGeomParam color_param(arbGeomParams, prop_header.getName());
- IC3fGeomParam::Sample sample;
- BLI_assert(!strcmp("rgb", color_param.getInterpretation()));
-
- color_param.getIndexed(sample, iss);
- is_facevarying = sample.getScope() == kFacevaryingScope &&
- config.totloop == sample.getIndices()->size();
-
- c3f_ptr = sample.getVals();
- indices = sample.getIndices();
- use_c3f_ptr = true;
- }
- else if (IC4fGeomParam::matches(prop_header)) {
- IC4fGeomParam color_param(arbGeomParams, prop_header.getName());
- IC4fGeomParam::Sample sample;
- BLI_assert(!strcmp("rgba", color_param.getInterpretation()));
-
- color_param.getIndexed(sample, iss);
- is_facevarying = sample.getScope() == kFacevaryingScope &&
- config.totloop == sample.getIndices()->size();
-
- c4f_ptr = sample.getVals();
- indices = sample.getIndices();
- use_c3f_ptr = false;
- }
- else {
- /* this won't happen due to the checks in read_custom_data() */
- return;
- }
- BLI_assert(c3f_ptr || c4f_ptr);
-
- /* Read the vertex colors */
- void *cd_data = config.add_customdata_cb(config.user_data,
- prop_header.getName().c_str(),
- CD_MLOOPCOL);
- MCol *cfaces = static_cast<MCol *>(cd_data);
- MPoly *mpolys = config.mpoly;
- MLoop *mloops = config.mloop;
-
- size_t face_index = 0;
- size_t color_index;
- bool bounds_warning_given = false;
-
- /* The colors can go through two layers of indexing. Often the 'indices'
- * array doesn't do anything (i.e. indices[n] = n), but when it does, it's
- * important. Blender 2.79 writes indices incorrectly (see T53745), which
- * is why we have to check for indices->size() > 0 */
- bool use_dual_indexing = is_facevarying && indices->size() > 0;
-
- for (int i = 0; i < config.totpoly; ++i) {
- MPoly *poly = &mpolys[i];
- MCol *cface = &cfaces[poly->loopstart + poly->totloop];
- MLoop *mloop = &mloops[poly->loopstart + poly->totloop];
-
- for (int j = 0; j < poly->totloop; ++j, ++face_index) {
- --cface;
- --mloop;
-
- color_index = is_facevarying ? face_index : mloop->v;
- if (use_dual_indexing) {
- color_index = (*indices)[color_index];
- }
- if (use_c3f_ptr) {
- bool is_mcols_out_of_bounds = false;
- color_index = mcols_out_of_bounds_check(
- color_index,
- c3f_ptr->size(),
- iobject_full_name, prop_header,
- is_mcols_out_of_bounds, bounds_warning_given);
- if (is_mcols_out_of_bounds) {
- continue;
- }
- const Imath::C3f &color = (*c3f_ptr)[color_index];
- cface->a = unit_float_to_uchar_clamp(color[0]);
- cface->r = unit_float_to_uchar_clamp(color[1]);
- cface->g = unit_float_to_uchar_clamp(color[2]);
- cface->b = 255;
- }
- else {
- bool is_mcols_out_of_bounds = false;
- color_index = mcols_out_of_bounds_check(
- color_index,
- c4f_ptr->size(),
- iobject_full_name, prop_header,
- is_mcols_out_of_bounds, bounds_warning_given);
- if (is_mcols_out_of_bounds) {
- continue;
- }
- const Imath::C4f &color = (*c4f_ptr)[color_index];
- cface->a = unit_float_to_uchar_clamp(color[0]);
- cface->r = unit_float_to_uchar_clamp(color[1]);
- cface->g = unit_float_to_uchar_clamp(color[2]);
- cface->b = unit_float_to_uchar_clamp(color[3]);
- }
- }
- }
+ C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr();
+ C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr();
+ Alembic::Abc::UInt32ArraySamplePtr indices;
+ bool use_c3f_ptr;
+ bool is_facevarying;
+
+ /* Find the correct interpretation of the data */
+ if (IC3fGeomParam::matches(prop_header)) {
+ IC3fGeomParam color_param(arbGeomParams, prop_header.getName());
+ IC3fGeomParam::Sample sample;
+ BLI_assert(!strcmp("rgb", color_param.getInterpretation()));
+
+ color_param.getIndexed(sample, iss);
+ is_facevarying = sample.getScope() == kFacevaryingScope &&
+ config.totloop == sample.getIndices()->size();
+
+ c3f_ptr = sample.getVals();
+ indices = sample.getIndices();
+ use_c3f_ptr = true;
+ }
+ else if (IC4fGeomParam::matches(prop_header)) {
+ IC4fGeomParam color_param(arbGeomParams, prop_header.getName());
+ IC4fGeomParam::Sample sample;
+ BLI_assert(!strcmp("rgba", color_param.getInterpretation()));
+
+ color_param.getIndexed(sample, iss);
+ is_facevarying = sample.getScope() == kFacevaryingScope &&
+ config.totloop == sample.getIndices()->size();
+
+ c4f_ptr = sample.getVals();
+ indices = sample.getIndices();
+ use_c3f_ptr = false;
+ }
+ else {
+ /* this won't happen due to the checks in read_custom_data() */
+ return;
+ }
+ BLI_assert(c3f_ptr || c4f_ptr);
+
+ /* Read the vertex colors */
+ void *cd_data = config.add_customdata_cb(
+ config.user_data, prop_header.getName().c_str(), CD_MLOOPCOL);
+ MCol *cfaces = static_cast<MCol *>(cd_data);
+ MPoly *mpolys = config.mpoly;
+ MLoop *mloops = config.mloop;
+
+ size_t face_index = 0;
+ size_t color_index;
+ bool bounds_warning_given = false;
+
+ /* The colors can go through two layers of indexing. Often the 'indices'
+ * array doesn't do anything (i.e. indices[n] = n), but when it does, it's
+ * important. Blender 2.79 writes indices incorrectly (see T53745), which
+ * is why we have to check for indices->size() > 0 */
+ bool use_dual_indexing = is_facevarying && indices->size() > 0;
+
+ for (int i = 0; i < config.totpoly; ++i) {
+ MPoly *poly = &mpolys[i];
+ MCol *cface = &cfaces[poly->loopstart + poly->totloop];
+ MLoop *mloop = &mloops[poly->loopstart + poly->totloop];
+
+ for (int j = 0; j < poly->totloop; ++j, ++face_index) {
+ --cface;
+ --mloop;
+
+ color_index = is_facevarying ? face_index : mloop->v;
+ if (use_dual_indexing) {
+ color_index = (*indices)[color_index];
+ }
+ if (use_c3f_ptr) {
+ bool is_mcols_out_of_bounds = false;
+ color_index = mcols_out_of_bounds_check(color_index,
+ c3f_ptr->size(),
+ iobject_full_name,
+ prop_header,
+ is_mcols_out_of_bounds,
+ bounds_warning_given);
+ if (is_mcols_out_of_bounds) {
+ continue;
+ }
+ const Imath::C3f &color = (*c3f_ptr)[color_index];
+ cface->a = unit_float_to_uchar_clamp(color[0]);
+ cface->r = unit_float_to_uchar_clamp(color[1]);
+ cface->g = unit_float_to_uchar_clamp(color[2]);
+ cface->b = 255;
+ }
+ else {
+ bool is_mcols_out_of_bounds = false;
+ color_index = mcols_out_of_bounds_check(color_index,
+ c4f_ptr->size(),
+ iobject_full_name,
+ prop_header,
+ is_mcols_out_of_bounds,
+ bounds_warning_given);
+ if (is_mcols_out_of_bounds) {
+ continue;
+ }
+ const Imath::C4f &color = (*c4f_ptr)[color_index];
+ cface->a = unit_float_to_uchar_clamp(color[0]);
+ cface->r = unit_float_to_uchar_clamp(color[1]);
+ cface->g = unit_float_to_uchar_clamp(color[2]);
+ cface->b = unit_float_to_uchar_clamp(color[3]);
+ }
+ }
+ }
}
static void read_custom_data_uvs(const ICompoundProperty &prop,
@@ -419,61 +424,60 @@ static void read_custom_data_uvs(const ICompoundProperty &prop,
const CDStreamConfig &config,
const Alembic::Abc::ISampleSelector &iss)
{
- IV2fGeomParam uv_param(prop, prop_header.getName());
+ IV2fGeomParam uv_param(prop, prop_header.getName());
- if (!uv_param.isIndexed()) {
- return;
- }
+ if (!uv_param.isIndexed()) {
+ return;
+ }
- IV2fGeomParam::Sample sample;
- uv_param.getIndexed(sample, iss);
+ IV2fGeomParam::Sample sample;
+ uv_param.getIndexed(sample, iss);
- if (uv_param.getScope() != kFacevaryingScope) {
- return;
- }
+ if (uv_param.getScope() != kFacevaryingScope) {
+ return;
+ }
- void *cd_data = config.add_customdata_cb(config.user_data,
- prop_header.getName().c_str(),
- CD_MLOOPUV);
+ void *cd_data = config.add_customdata_cb(
+ config.user_data, prop_header.getName().c_str(), CD_MLOOPUV);
- read_uvs(config, cd_data, sample.getVals(), sample.getIndices());
+ read_uvs(config, cd_data, sample.getVals(), sample.getIndices());
}
-void read_custom_data(const std::string & iobject_full_name,
+void read_custom_data(const std::string &iobject_full_name,
const ICompoundProperty &prop,
const CDStreamConfig &config,
const Alembic::Abc::ISampleSelector &iss)
{
- if (!prop.valid()) {
- return;
- }
-
- int num_uvs = 0;
- int num_colors = 0;
-
- const size_t num_props = prop.getNumProperties();
-
- for (size_t i = 0; i < num_props; ++i) {
- const Alembic::Abc::PropertyHeader &prop_header = prop.getPropertyHeader(i);
-
- /* Read UVs according to convention. */
- if (IV2fGeomParam::matches(prop_header) && Alembic::AbcGeom::isUV(prop_header)) {
- if (++num_uvs > MAX_MTFACE) {
- continue;
- }
-
- read_custom_data_uvs(prop, prop_header, config, iss);
- continue;
- }
-
- /* Read vertex colors according to convention. */
- if (IC3fGeomParam::matches(prop_header) || IC4fGeomParam::matches(prop_header)) {
- if (++num_colors > MAX_MCOL) {
- continue;
- }
-
- read_custom_data_mcols(iobject_full_name, prop, prop_header, config, iss);
- continue;
- }
- }
+ if (!prop.valid()) {
+ return;
+ }
+
+ int num_uvs = 0;
+ int num_colors = 0;
+
+ const size_t num_props = prop.getNumProperties();
+
+ for (size_t i = 0; i < num_props; ++i) {
+ const Alembic::Abc::PropertyHeader &prop_header = prop.getPropertyHeader(i);
+
+ /* Read UVs according to convention. */
+ if (IV2fGeomParam::matches(prop_header) && Alembic::AbcGeom::isUV(prop_header)) {
+ if (++num_uvs > MAX_MTFACE) {
+ continue;
+ }
+
+ read_custom_data_uvs(prop, prop_header, config, iss);
+ continue;
+ }
+
+ /* Read vertex colors according to convention. */
+ if (IC3fGeomParam::matches(prop_header) || IC4fGeomParam::matches(prop_header)) {
+ if (++num_colors > MAX_MCOL) {
+ continue;
+ }
+
+ read_custom_data_mcols(iobject_full_name, prop, prop_header, config, iss);
+ continue;
+ }
+ }
}