Skip to content

Commit

Permalink
Updated snapshot to 1.3.2
Browse files Browse the repository at this point in the history
  - Bug fixes
  • Loading branch information
ondys committed Jun 5, 2018
1 parent 6d70ba7 commit 79774fe
Show file tree
Hide file tree
Showing 79 changed files with 772 additions and 185 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ set(draco_js_enc_sources
"${draco_src_root}/javascript/emscripten/draco_encoder_glue_wrapper.cc"
"${draco_src_root}/javascript/emscripten/encoder_webidl_wrapper.cc")


set(draco_test_sources
"${draco_src_root}/attributes/point_attribute_test.cc"
"${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_test.cc"
Expand Down Expand Up @@ -648,6 +649,7 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE)
message(FATAL_ERROR "Glue generation failed.")
endif ()


# Add a custom rule depending on the IDL to regenerate
# ${draco_build_dir}/glue_decoder.cpp as needed.
add_custom_command(OUTPUT ${draco_build_dir}/glue_decoder.cpp
Expand All @@ -670,6 +672,7 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE)
WORKING_DIRECTORY ${draco_build_dir}
VERBATIM)


set(draco_decoder_src
${draco_attributes_sources}
${draco_compression_attributes_dec_sources}
Expand All @@ -687,7 +690,6 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE)
${draco_point_cloud_sources}
${draco_points_dec_sources}
${draco_version_sources})

set(draco_encoder_src
${draco_attributes_sources}
${draco_compression_attributes_enc_sources}
Expand Down Expand Up @@ -792,7 +794,7 @@ else ()
add_library(draco_unity_plugin OBJECT
${draco_unity_plug_sources})
add_library(draco_maya_plugin OBJECT
${draco_maya_plug_sources})
${draco_maya_plug_sources})

# Library targets that consume the object collections.
add_library(dracodec
Expand Down Expand Up @@ -904,13 +906,13 @@ else ()
$<TARGET_OBJECTS:draco_points_dec>
$<TARGET_OBJECTS:draco_metadata_enc>
$<TARGET_OBJECTS:draco_points_enc>)

# For Mac, we need to build a .bundle for plugin.
if (APPLE)
set_target_properties(draco_maya_wrapper PROPERTIES BUNDLE true)
endif ()
endif ()

set(draco_header_only_targets
draco_compression_attributes_pred_schemes_dec
draco_dec_config
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

News
=======
### Version 1.3.2 release
* Bug fixes

### Version 1.3.1 release
* Fix issue with multiple attributes when skipping an attribute transform

Expand Down
1 change: 1 addition & 0 deletions cmake/draco_test_config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
// GENERATED FILE, DO NOT EDIT. SEE ABOVE.

#define DRACO_TEST_DATA_DIR "${DRACO_TEST_DATA_DIR}"
#define DRACO_TEST_TEMP_DIR "${DRACO_TEST_TEMP_DIR}"

#endif // DRACO_TESTING_DRACO_TEST_CONFIG_H_
10 changes: 5 additions & 5 deletions javascript/draco_decoder.js

Large diffs are not rendered by default.

Binary file modified javascript/draco_decoder.wasm
Binary file not shown.
8 changes: 4 additions & 4 deletions javascript/draco_decoder_gltf.js

Large diffs are not rendered by default.

Binary file modified javascript/draco_decoder_gltf.wasm
Binary file not shown.
16 changes: 8 additions & 8 deletions javascript/draco_encoder.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions javascript/npm/draco3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

News
=======
### Version 1.3.2 release
* Bug fixes

### Version 1.3.1 release
* Fix issue with multiple attributes when skipping an attribute transform

Expand Down
10 changes: 5 additions & 5 deletions javascript/npm/draco3d/draco_decoder_nodejs.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions javascript/npm/draco3d/draco_encoder_nodejs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/npm/draco3d/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "draco3d",
"version": "1.3.1",
"version": "1.3.2",
"description": "Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.",
"main": "draco3d.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions javascript/npm/draco3dgltf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ TODO: Add glTF branch url.

News
=======
### Version 1.3.2 release
* Bug Fixes

### Version 1.3.1 release
* Fix issue with multiple attributes when skipping an attribute transform

Expand Down
8 changes: 4 additions & 4 deletions javascript/npm/draco3dgltf/draco_decoder_gltf_nodejs.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions javascript/npm/draco3dgltf/draco_encoder_gltf_nodejs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/npm/draco3dgltf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "draco3dgltf",
"version": "1.3.1",
"version": "1.3.2",
"description": "This package contains a specific version of Draco 3D geometric compression library that is used for glTF Draco mesh compression extension.",
"main": "draco3dgltf.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/draco/attributes/geometry_indices.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static constexpr CornerIndex kInvalidCornerIndex(
static constexpr FaceIndex kInvalidFaceIndex(
std::numeric_limits<uint32_t>::max());

// TODO(ostava): Add strongly typed indices for attribute id and unique
// attribute id.

} // namespace draco

#endif // DRACO_ATTRIBUTES_GEOMETRY_INDICES_H_
2 changes: 1 addition & 1 deletion src/draco/compression/attributes/attributes_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool AttributesDecoder::DecodeAttributesDecoderData(DecoderBuffer *in_buffer) {
uint16_t custom_id;
if (!in_buffer->Decode(&custom_id))
return false;
// TODO(zhafang): Add "custom_id" to attribute metadata.
// TODO(draco-eng): Add "custom_id" to attribute metadata.
unique_id = static_cast<uint32_t>(custom_id);
ga.set_unique_id(unique_id);
} else
Expand Down
11 changes: 7 additions & 4 deletions src/draco/compression/attributes/kd_tree_attributes_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class PointAttributeVectorOutputIterator {
uint32_t required_decode_bytes = 0;
for (auto index = 0; index < attributes_.size(); index++) {
const AttributeTuple &att = attributes_[index];
required_decode_bytes = (std::max)(required_decode_bytes,
std::get<1>(att) * std::get<3>(att));
required_decode_bytes =
(std::max)(required_decode_bytes,
std::get<1>(att) * std::get<3>(att) * std::get<4>(att));
}
memory_.resize(required_decode_bytes);
data_ = memory_.data();
Expand Down Expand Up @@ -102,8 +103,10 @@ class PointAttributeVectorOutputIterator {
// redirect to copied data
data_source = reinterpret_cast<uint32_t *>(data_);
}
attribute->SetAttributeValue(attribute->mapped_index(point_id_),
data_source);
const AttributeValueIndex avi = attribute->mapped_index(point_id_);
if (avi >= attribute->size())
return *this;
attribute->SetAttributeValue(avi, data_source);
}
return *this;
}
Expand Down
10 changes: 6 additions & 4 deletions src/draco/compression/attributes/mesh_traversal_sequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,23 @@ class MeshTraversalSequencer : public PointsSequencer {
traverser_.OnTraversalStart();
if (corner_order_) {
for (uint32_t i = 0; i < corner_order_->size(); ++i) {
ProcessCorner(corner_order_->at(i));
if (!ProcessCorner(corner_order_->at(i)))
return false;
}
} else {
const int32_t num_faces = traverser_.corner_table()->num_faces();
for (int i = 0; i < num_faces; ++i) {
ProcessCorner(CornerIndex(3 * i));
if (!ProcessCorner(CornerIndex(3 * i)))
return false;
}
}
traverser_.OnTraversalEnd();
return true;
}

private:
void ProcessCorner(CornerIndex corner_id) {
traverser_.TraverseFromCorner(corner_id);
bool ProcessCorner(CornerIndex corner_id) {
return traverser_.TraverseFromCorner(corner_id);
}

TraverserT traverser_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder<
// Check which parallelograms are actually used.
for (int i = 0; i < num_parallelograms; ++i) {
const int context = num_parallelograms - 1;
const bool is_crease =
is_crease_edge_[context][is_crease_edge_pos[context]++];
const int pos = is_crease_edge_pos[context]++;
if (is_crease_edge_[context].size() <= pos)
return false;
const bool is_crease = is_crease_edge_[context][pos];
if (!is_crease) {
++num_used_parallelograms;
for (int j = 0; j < num_components; ++j) {
Expand Down Expand Up @@ -207,7 +209,8 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder<
if (num_flags > 0) {
is_crease_edge_[i].resize(num_flags);
RAnsBitDecoder decoder;
decoder.StartDecoding(buffer);
if (!decoder.StartDecoding(buffer))
return false;
for (int j = 0; j < num_flags; ++j) {
is_crease_edge_[i][j] = decoder.DecodeNextBit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,19 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
// Variable for holding the best configuration that has been found so far.
PredictionConfiguration best_prediction;

total_parallelograms[num_parallelograms - 1] += num_parallelograms;
// Compute delta coding error (configuration when no parallelogram is
// selected).
const int src_offset = (p - 1) * num_components;
error = ComputeError(in_data + src_offset, in_data + dst_offset,
&current_residuals[0], num_components);

int64_t new_overhead_bits =
ComputeOverheadBits(total_used_parallelograms[num_parallelograms - 1],
total_parallelograms[num_parallelograms - 1]);
error.num_bits += new_overhead_bits;
if (num_parallelograms > 0) {
total_parallelograms[num_parallelograms - 1] += num_parallelograms;
const int64_t new_overhead_bits =
ComputeOverheadBits(total_used_parallelograms[num_parallelograms - 1],
total_parallelograms[num_parallelograms - 1]);
error.num_bits += new_overhead_bits;
}

best_prediction.error = error;
best_prediction.configuration = 0;
Expand Down Expand Up @@ -312,13 +314,15 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
}
error = ComputeError(multi_pred_vals.data(), in_data + dst_offset,
&current_residuals[0], num_components);
new_overhead_bits = ComputeOverheadBits(
total_used_parallelograms[num_parallelograms - 1] +
num_used_parallelograms,
total_parallelograms[num_parallelograms - 1]);

// Add overhead bits to the total error.
error.num_bits += new_overhead_bits;
if (num_parallelograms > 0) {
const int64_t new_overhead_bits = ComputeOverheadBits(
total_used_parallelograms[num_parallelograms - 1] +
num_used_parallelograms,
total_parallelograms[num_parallelograms - 1]);

// Add overhead bits to the total error.
error.num_bits += new_overhead_bits;
}
if (error < best_prediction.error) {
best_prediction.error = error;
best_prediction.configuration = configuration;
Expand All @@ -331,8 +335,10 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
} while (std::next_permutation(
exluded_parallelograms, exluded_parallelograms + num_parallelograms));
}
total_used_parallelograms[num_parallelograms - 1] +=
best_prediction.num_used_parallelograms;
if (num_parallelograms > 0) {
total_used_parallelograms[num_parallelograms - 1] +=
best_prediction.num_used_parallelograms;
}

// Update the entropy stream by adding selected residuals as symbols to the
// stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ bool MeshPredictionSchemeTexCoordsDecoder<DataTypeT, TransformT, MeshDataT>::
if (!DecodeVarint(&num_orientations, buffer))
return false;
}
if (num_orientations == 0)
return false;
orientations_.resize(num_orientations);
bool last_orientation = true;
RAnsBitDecoder decoder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ bool MeshPredictionSchemeTexCoordsPortableDecoder<
const int corner_map_size = this->mesh_data().data_to_corner_map()->size();
for (int p = 0; p < corner_map_size; ++p) {
const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p);
predictor_.template ComputePredictedValue<false>(corner_id, out_data, p);
if (!predictor_.template ComputePredictedValue<false>(corner_id, out_data,
p))
return false;

const int dst_offset = p * num_components;
this->transform().ComputeOriginalValue(predictor_.predicted_value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MeshPredictionSchemeTexCoordsPortablePredictor {
// Computes predicted UV coordinates on a given corner. The coordinates are
// stored in |predicted_value_| member.
template <bool is_encoder_t>
void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data,
bool ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data,
int data_id);

const DataTypeT *predicted_value() const { return predicted_value_; }
Expand All @@ -82,7 +82,7 @@ class MeshPredictionSchemeTexCoordsPortablePredictor {

template <typename DataTypeT, class MeshDataT>
template <bool is_encoder_t>
void MeshPredictionSchemeTexCoordsPortablePredictor<
bool MeshPredictionSchemeTexCoordsPortablePredictor<
DataTypeT, MeshDataT>::ComputePredictedValue(CornerIndex corner_id,
const DataTypeT *data,
int data_id) {
Expand Down Expand Up @@ -111,7 +111,7 @@ void MeshPredictionSchemeTexCoordsPortablePredictor<
// We cannot do a reliable prediction on degenerated UV triangles.
predicted_value_[0] = p_uv[0];
predicted_value_[1] = p_uv[1];
return;
return true;
}

// Get positions at all corners.
Expand Down Expand Up @@ -203,6 +203,8 @@ void MeshPredictionSchemeTexCoordsPortablePredictor<
}
} else {
// When decoding the data, we already know which orientation to use.
if (orientations_.empty())
return false;
const bool orientation = orientations_.back();
orientations_.pop_back();
if (orientation)
Expand All @@ -212,7 +214,7 @@ void MeshPredictionSchemeTexCoordsPortablePredictor<
}
predicted_value_[0] = static_cast<int>(predicted_uv[0]);
predicted_value_[1] = static_cast<int>(predicted_uv[1]);
return;
return true;
}
}
// Else we don't have available textures on both corners or the position data
Expand All @@ -236,12 +238,13 @@ void MeshPredictionSchemeTexCoordsPortablePredictor<
for (int i = 0; i < kNumComponents; ++i) {
predicted_value_[i] = 0;
}
return;
return true;
}
}
for (int i = 0; i < kNumComponents; ++i) {
predicted_value_[i] = data[data_offset + i];
}
return true;
}

} // namespace draco
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class PredictionSchemeNormalOctahedronCanonicalizedDecodingTransform
return false;
if (!buffer->Decode(&center_value))
return false;
this->set_max_quantized_value(max_quantized_value);
(void)center_value;
if (!this->set_max_quantized_value(max_quantized_value))
return false;
// Account for reading wrong values, e.g., due to fuzzing.
if (this->quantization_bits() < 2)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ class PredictionSchemeNormalOctahedronDecodingTransform
if (!buffer->Decode(&center_value))
return false;
}
this->set_max_quantized_value(max_quantized_value);
(void)center_value;
return true;
return this->set_max_quantized_value(max_quantized_value);
}

inline void ComputeOriginalValue(const DataType *pred_vals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class PredictionSchemeNormalOctahedronTransformBase {
}

protected:
inline void set_max_quantized_value(DataTypeT max_quantized_value) {
DRACO_DCHECK_EQ(max_quantized_value % 2, 1);
inline bool set_max_quantized_value(DataTypeT max_quantized_value) {
if (max_quantized_value % 2 == 0)
return false;
int q = bits::MostSignificantBit(max_quantized_value) + 1;
octahedron_tool_box_.SetQuantizationBits(q);
return octahedron_tool_box_.SetQuantizationBits(q);
}

bool IsInDiamond(DataTypeT s, DataTypeT t) const {
Expand Down
Loading

0 comments on commit 79774fe

Please sign in to comment.