Skip to content

Commit 1aea0ab

Browse files
committed
80 chars
1 parent e93d8b5 commit 1aea0ab

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
docs/_site
2+
build

src/draco/io/ply_decoder.cc

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ Status PlyDecoder::DecodeInternal() {
9999
return OkStatus();
100100
}
101101

102-
Status PlyDecoder::DecodeFaceData(const PlyElement *face_element, const int num_vertices) {
102+
Status PlyDecoder::DecodeFaceData(const PlyElement *face_element,
103+
const int num_vertices) {
103104
// We accept point clouds now.
104105
if (face_element == nullptr) {
105106
return Status(Status::INVALID_PARAMETER, "face_element is null");
@@ -142,7 +143,8 @@ Status PlyDecoder::DecodeFaceData(const PlyElement *face_element, const int num_
142143
}
143144
out_mesh_->SetNumFaces(face_index.value());
144145

145-
DecodeFaceTexCoordData(face_element, vertex_indices, num_vertices);
146+
DRACO_RETURN_IF_ERROR(
147+
DecodeFaceTexCoordData(face_element, vertex_indices, num_vertices));
146148

147149
return OkStatus();
148150
}
@@ -172,32 +174,35 @@ Status PlyDecoder::DecodeFaceTexCoordData(
172174

173175
// Allocate attribute for texture coordinates.
174176
GeometryAttribute uv_attr;
175-
uv_attr.Init(GeometryAttribute::TEX_COORD, nullptr, 2, DT_FLOAT32, false, sizeof(float) * 2, 0);
176-
const int uv_att_id = out_point_cloud_->AddAttribute(uv_attr, true, num_vertices);
177+
uv_attr.Init(GeometryAttribute::TEX_COORD, nullptr, 2, DT_FLOAT32, false,
178+
sizeof(float) * 2, 0);
179+
const int uv_att_id =
180+
out_point_cloud_->AddAttribute(uv_attr, true, num_vertices);
177181

178-
const int64_t num_polygons = face_element->num_entries();
182+
const int num_polygons = face_element->num_entries();
179183
PlyPropertyReader<float> uv_reader(texture_coordinates);
180184
PlyPropertyReader<PointIndex::ValueType> vertex_index_reader(vertex_indices);
181185

182-
for (int64_t face_index = 0; face_index < num_polygons; ++face_index) {
183-
const int64_t vertex_list_offset = vertex_indices->GetListEntryOffset(face_index);
184-
const int64_t vertex_list_size = vertex_indices->GetListEntryNumValues(face_index);
186+
for (int i = 0; i < num_polygons; ++i) {
187+
const int vertex_list_offset = vertex_indices->GetListEntryOffset(i);
188+
const int vertex_list_size = vertex_indices->GetListEntryNumValues(i);
185189

186-
const int64_t uv_list_offset = texture_coordinates->GetListEntryOffset(face_index);
187-
const int64_t uv_list_size = texture_coordinates->GetListEntryNumValues(face_index);
190+
const int uv_list_offset = texture_coordinates->GetListEntryOffset(i);
191+
const int uv_list_size = texture_coordinates->GetListEntryNumValues(i);
188192

189-
if (uv_list_size < 2 * vertex_list_size) {
190-
continue; // Skip invalid uv list. Must have two texture coords per vertex.
191-
}
193+
if (uv_list_size < 2 * vertex_list_size) {
194+
continue; // Skip invalid uv list. Need two texture coords per vertex.
195+
}
192196

193-
for (int64_t i = 0; i < vertex_list_size; ++i) {
194-
uint32_t vertex_index = vertex_index_reader.ReadValue(static_cast<int>(vertex_list_offset + i));
195-
float uv_value[2];
196-
uv_value[0] = uv_reader.ReadValue(static_cast<int>(uv_list_offset + i * 2));
197-
uv_value[1] = uv_reader.ReadValue(static_cast<int>(uv_list_offset + i * 2 + 1));
198-
out_point_cloud_->attribute(uv_att_id)->SetAttributeValue(
199-
AttributeValueIndex(vertex_index), uv_value);
200-
}
197+
for (int j = 0; j < vertex_list_size; ++j) {
198+
uint32_t vertex_index =
199+
vertex_index_reader.ReadValue(vertex_list_offset + j);
200+
float uv_value[2];
201+
uv_value[0] = uv_reader.ReadValue(uv_list_offset + j * 2);
202+
uv_value[1] = uv_reader.ReadValue(uv_list_offset + j * 2 + 1);
203+
out_point_cloud_->attribute(uv_att_id)->SetAttributeValue(
204+
AttributeValueIndex(vertex_index), uv_value);
205+
}
201206
}
202207

203208
return OkStatus();

0 commit comments

Comments
 (0)