Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# the License.

cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
if(DRACO_TRANSCODER_SUPPORTED)
set(CMAKE_CXX_STANDARD 17)
endif()
project(draco C CXX)

if(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -479,10 +482,14 @@ list(
"${draco_src_root}/metadata/geometry_metadata.h"
"${draco_src_root}/metadata/metadata.cc"
"${draco_src_root}/metadata/metadata.h"
"${draco_src_root}/metadata/property_attribute.cc"
"${draco_src_root}/metadata/property_attribute.h"
"${draco_src_root}/metadata/property_table.cc"
"${draco_src_root}/metadata/property_table.h"
"${draco_src_root}/metadata/structural_metadata.cc"
"${draco_src_root}/metadata/structural_metadata.h")
"${draco_src_root}/metadata/structural_metadata.h"
"${draco_src_root}/metadata/structural_metadata_schema.cc"
"${draco_src_root}/metadata/structural_metadata_schema.h")

list(APPEND draco_metadata_enc_sources
"${draco_src_root}/metadata/metadata_encoder.cc"
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ delays can result in transient errors that can be difficult to diagnose when
new Draco releases are launched. To avoid the issue pin your sites to a
versioned release.

### Version 1.5.7 release:
* Using the versioned www.gstatic.com WASM and Javascript decoders continues
to be recommended. To use v1.5.7, use this URL:
* https://www.gstatic.com/draco/versioned/decoders/1.5.7/*
* Added support for normalized attributes to Emscripten encoder API.
* Bug fixes.
* Security fixes.

### Version 1.5.6 release:
* Using the versioned www.gstatic.com WASM and Javascript decoders continues
to be recommended. To use v1.5.6, use this URL:
Expand Down
2 changes: 1 addition & 1 deletion cmake/draco_build_definitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro(draco_set_build_definitions)
# passed to libtool.
#
# We set DRACO_SOVERSION = [c-a].a.r
set(LT_CURRENT 8)
set(LT_CURRENT 9)
set(LT_REVISION 0)
set(LT_AGE 0)
math(EXPR DRACO_SOVERSION_MAJOR "${LT_CURRENT} - ${LT_AGE}")
Expand Down
2 changes: 2 additions & 0 deletions cmake/draco_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ if(DRACO_TRANSCODER_SUPPORTED)
"${draco_src_root}/io/texture_io_test.cc"
"${draco_src_root}/material/material_library_test.cc"
"${draco_src_root}/material/material_test.cc"
"${draco_src_root}/metadata/property_attribute_test.cc"
"${draco_src_root}/metadata/property_table_test.cc"
"${draco_src_root}/metadata/structural_metadata_test.cc"
"${draco_src_root}/metadata/structural_metadata_schema_test.cc"
"${draco_src_root}/scene/instance_array_test.cc"
"${draco_src_root}/scene/light_test.cc"
"${draco_src_root}/scene/mesh_group_test.cc"
Expand Down
4 changes: 2 additions & 2 deletions javascript/draco_decoder.js

Large diffs are not rendered by default.

Binary file modified javascript/draco_decoder.wasm
Binary file not shown.
4 changes: 2 additions & 2 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.

Binary file modified javascript/draco_encoder.wasm
Binary file not shown.
99 changes: 50 additions & 49 deletions javascript/draco_encoder_wrapper.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Create DracoLoader by setting the decoder type:

```js
// (Optional) Change decoder source directory (defaults to
// 'https://www.gstatic.com/draco/versioned/decoders/1.5.6/'). It is recommended
// 'https://www.gstatic.com/draco/versioned/decoders/1.5.7/'). It is recommended
// to always pull your Draco JavaScript and WASM decoders from this URL. Users
// will benefit from having the Draco decoder in cache as more sites start using
// the static URL.
Expand Down
2 changes: 1 addition & 1 deletion javascript/example/webgl_loader_draco_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1>Open a draco compressed file (.drc):</h1>
// It is recommended to always pull your Draco JavaScript and WASM decoders
// from this URL. Users will benefit from having the Draco decoder in cache
// as more sites start using the static URL.
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.6/');
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.7/');

var camera, cameraTarget, scene, renderer;

Expand Down
2 changes: 1 addition & 1 deletion javascript/npm/draco3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
News
=======

Check out the [README](https://github.com/google/draco/blob/1.5.6/README.md)
Check out the [README](https://github.com/google/draco/blob/1.5.7/README.md)
file for news about this release.

Description
Expand Down
Binary file modified javascript/npm/draco3d/draco_decoder.wasm
Binary file not shown.
Binary file modified javascript/npm/draco3d/draco_encoder.wasm
Binary file not shown.
99 changes: 50 additions & 49 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.5.6",
"version": "1.5.7",
"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
2 changes: 1 addition & 1 deletion javascript/npm/draco3dgltf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Draco github glTF branch URL: https://github.com/google/draco/tree/gltf_2.0_drac
News
=======

Check out the [README](https://github.com/google/draco/blob/1.5.6/README.md)
Check out the [README](https://github.com/google/draco/blob/1.5.7/README.md)
file for news about this release.

NPM Package
Expand Down
Binary file modified javascript/npm/draco3dgltf/draco_decoder_gltf.wasm
Binary file not shown.
Binary file modified javascript/npm/draco3dgltf/draco_encoder.wasm
Binary file not shown.
99 changes: 50 additions & 49 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.5.6",
"version": "1.5.7",
"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
4 changes: 2 additions & 2 deletions javascript/with_asserts/draco_decoder.js

Large diffs are not rendered by default.

Binary file modified javascript/with_asserts/draco_decoder.wasm
Binary file not shown.
18 changes: 9 additions & 9 deletions javascript/with_asserts/draco_encoder.js

Large diffs are not rendered by default.

Binary file modified javascript/with_asserts/draco_encoder.wasm
Binary file not shown.
150 changes: 76 additions & 74 deletions javascript/with_asserts/draco_encoder_wrapper.js

Large diffs are not rendered by default.

Binary file modified maya/draco_maya_wrapper_macos.tar.bz
Binary file not shown.
Binary file modified maya/draco_maya_wrapper_windows.tar.bz
Binary file not shown.
8 changes: 8 additions & 0 deletions src/draco/attributes/attribute_quantization_transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
//
#include "draco/attributes/attribute_quantization_transform.h"

#include <cmath>
#include <cstring>
#include <memory>
#include <vector>

#include "draco/attributes/attribute_transform_type.h"
#include "draco/core/quantization_utils.h"

Expand Down Expand Up @@ -144,6 +149,9 @@ bool AttributeQuantizationTransform::ComputeParameters(
++i) {
attribute.GetValue(i, att_val.get());
for (int c = 0; c < num_components; ++c) {
if (std::isnan(att_val[c])) {
return false;
}
if (min_values_[c] > att_val[c]) {
min_values_[c] = att_val[c];
}
Expand Down
8 changes: 8 additions & 0 deletions src/draco/attributes/geometry_attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ bool GeometryAttribute::CopyFrom(const GeometryAttribute &src_att) {
}
buffer_->Update(src_att.buffer_->data(), src_att.buffer_->data_size());
}
#ifdef DRACO_TRANSCODER_SUPPORTED
name_ = src_att.name_;
#endif
return true;
}

Expand Down Expand Up @@ -87,6 +90,11 @@ bool GeometryAttribute::operator==(const GeometryAttribute &va) const {
if (byte_offset_ != va.byte_offset_) {
return false;
}
#ifdef DRACO_TRANSCODER_SUPPORTED
if (name_ != va.name_) {
return false;
}
#endif
return true;
}

Expand Down
18 changes: 18 additions & 0 deletions src/draco/attributes/geometry_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ class GeometryAttribute {
return "TEX_COORD";
case GENERIC:
return "GENERIC";
#ifdef DRACO_TRANSCODER_SUPPORTED
case TANGENT:
return "TANGENT";
case MATERIAL:
return "MATERIAL";
case JOINTS:
return "JOINTS";
case WEIGHTS:
return "WEIGHTS";
#endif
default:
return "UNKNOWN";
}
Expand Down Expand Up @@ -276,6 +286,10 @@ class GeometryAttribute {
DataBufferDescriptor buffer_descriptor() const { return buffer_descriptor_; }
uint32_t unique_id() const { return unique_id_; }
void set_unique_id(uint32_t id) { unique_id_ = id; }
#ifdef DRACO_TRANSCODER_SUPPORTED
std::string name() const { return name_; }
void set_name(std::string name) { name_ = name; }
#endif

protected:
// Sets a new internal storage for the attribute.
Expand Down Expand Up @@ -445,6 +459,10 @@ class GeometryAttribute {
// multiple attribute of the same type in a point cloud.
uint32_t unique_id_;

#ifdef DRACO_TRANSCODER_SUPPORTED
std::string name_;
#endif

friend struct GeometryAttributeHasher;
};

Expand Down
28 changes: 15 additions & 13 deletions src/draco/attributes/point_attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//
#include "draco/attributes/point_attribute.h"

#include <tuple>
#include <unordered_map>

using std::unordered_map;

// Shortcut for typed conditionals.
Expand Down Expand Up @@ -166,10 +166,12 @@ AttributeValueIndex::ValueType PointAttribute::DeduplicateFormattedValues(
AttributeValueIndex unique_vals(0);
typedef std::array<T, num_components_t> AttributeValue;
typedef std::array<HashType, num_components_t> AttributeHashableValue;
typedef unordered_map<AttributeHashableValue, AttributeValueIndex,
HashArray<AttributeHashableValue>>
ValueToIndexMap;

// Hash map storing index of the first attribute with a given value.
unordered_map<AttributeHashableValue, AttributeValueIndex,
HashArray<AttributeHashableValue>>
value_to_index_map;
ValueToIndexMap value_to_index_map;
AttributeValue att_value;
AttributeHashableValue hashable_value;
IndexTypeVector<AttributeValueIndex, AttributeValueIndex> value_map(
Expand All @@ -180,19 +182,19 @@ AttributeValueIndex::ValueType PointAttribute::DeduplicateFormattedValues(
// Convert the value to hashable type. Bit-copy real attributes to integers.
memcpy(&(hashable_value[0]), &(att_value[0]), sizeof(att_value));

// Check if the given attribute value has been used before already.
auto it = value_to_index_map.find(hashable_value);
if (it != value_to_index_map.end()) {
typename ValueToIndexMap::iterator it;
bool inserted;
std::tie(it, inserted) = value_to_index_map.insert(
std::pair<AttributeHashableValue, AttributeValueIndex>(hashable_value,
unique_vals));

// Try to update the hash map with a new entry pointing to the latest unique
// vertex index.
if (!inserted) {
// Duplicated value found. Update index mapping.
value_map[i] = it->second;
} else {
// New unique value.
// Update the hash map with a new entry pointing to the latest unique
// vertex index.
value_to_index_map.insert(
std::pair<AttributeHashableValue, AttributeValueIndex>(hashable_value,
unique_vals));
// Add the unique value to the mesh builder.
SetAttributeValue(unique_vals, &att_value);
// Update index mapping.
value_map[i] = unique_vals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<

// Bit-field used for computing permutations of excluded edges
// (parallelograms).
bool exluded_parallelograms[kMaxNumParallelograms];
bool excluded_parallelograms[kMaxNumParallelograms];

// Data about the number of used parallelogram and total number of available
// parallelogram for each context. Used to compute overhead needed for storing
Expand Down Expand Up @@ -291,12 +291,12 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
num_used_parallelograms <= num_parallelograms;
++num_used_parallelograms) {
// Mark all parallelograms as excluded.
std::fill(exluded_parallelograms,
exluded_parallelograms + num_parallelograms, true);
std::fill(excluded_parallelograms,
excluded_parallelograms + num_parallelograms, true);
// TODO(draco-eng) maybe this should be another std::fill.
// Mark the first |num_used_parallelograms| as not excluded.
for (int j = 0; j < num_used_parallelograms; ++j) {
exluded_parallelograms[j] = false;
excluded_parallelograms[j] = false;
}
// Permute over the excluded edges and compute error for each
// configuration (permutation of excluded parallelograms).
Expand All @@ -307,7 +307,7 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
}
uint8_t configuration = 0;
for (int j = 0; j < num_parallelograms; ++j) {
if (exluded_parallelograms[j]) {
if (excluded_parallelograms[j]) {
continue;
}
for (int c = 0; c < num_components; ++c) {
Expand All @@ -322,15 +322,13 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
}
error = ComputeError(multi_pred_vals.data(), in_data + dst_offset,
&current_residuals[0], num_components);
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;
}
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 @@ -340,8 +338,9 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
best_prediction.residuals.assign(current_residuals.begin(),
current_residuals.end());
}
} while (std::next_permutation(
exluded_parallelograms, exluded_parallelograms + num_parallelograms));
} while (
std::next_permutation(excluded_parallelograms,
excluded_parallelograms + num_parallelograms));
}
if (num_parallelograms > 0) {
total_used_parallelograms[num_parallelograms - 1] +=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ bool MeshPredictionSchemeGeometricNormalDecoder<
if (!buffer->Decode(&prediction_mode)) {
return false;
}
if (prediction_mode > TRIANGLE_AREA) {
// Invalid prediction mode.
return false;
}

if (!predictor_.SetNormalPredictionMode(
NormalPredictionMode(prediction_mode))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,16 @@ bool MeshPredictionSchemeTexCoordsPortablePredictor<
}
const int64_t pn_uv_absmax_element =
std::max(std::abs(pn_uv[0]), std::abs(pn_uv[1]));
if (cn_dot_pn >
if (std::abs(cn_dot_pn) >
std::numeric_limits<int64_t>::max() / pn_uv_absmax_element) {
// Return false if squared length calculation would overflow.
return false;
}
const Vec2 x_uv = n_uv * pn_norm2_squared + (cn_dot_pn * pn_uv);
const int64_t pn_absmax_element =
std::max(std::max(std::abs(pn[0]), std::abs(pn[1])), std::abs(pn[2]));
if (cn_dot_pn > std::numeric_limits<int64_t>::max() / pn_absmax_element) {
if (std::abs(cn_dot_pn) >
std::numeric_limits<int64_t>::max() / pn_absmax_element) {
// Return false if squared length calculation would overflow.
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ bool SequentialIntegerAttributeDecoder::DecodeValues(
if (!in_buffer->Decode(&prediction_scheme_method)) {
return false;
}
// Check that decoded prediction scheme method type is valid.
if (prediction_scheme_method < PREDICTION_NONE ||
prediction_scheme_method >= NUM_PREDICTION_SCHEMES) {
return false;
}
if (prediction_scheme_method != PREDICTION_NONE) {
int8_t prediction_transform_type;
if (!in_buffer->Decode(&prediction_transform_type)) {
Expand Down
Loading