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:
Diffstat (limited to 'extern/draco/draco/src/draco/core')
-rw-r--r--extern/draco/draco/src/draco/core/bounding_box.cc13
-rw-r--r--extern/draco/draco/src/draco/core/bounding_box.h42
-rw-r--r--extern/draco/draco/src/draco/core/cycle_timer.cc14
-rw-r--r--extern/draco/draco/src/draco/core/cycle_timer.h7
-rw-r--r--extern/draco/draco/src/draco/core/data_buffer.cc2
-rw-r--r--extern/draco/draco/src/draco/core/decoder_buffer.h12
-rw-r--r--extern/draco/draco/src/draco/core/draco_index_type_vector.h3
-rw-r--r--extern/draco/draco/src/draco/core/draco_version.h2
-rw-r--r--extern/draco/draco/src/draco/core/macros.h27
-rw-r--r--extern/draco/draco/src/draco/core/options.h2
-rw-r--r--extern/draco/draco/src/draco/core/status.h4
-rw-r--r--extern/draco/draco/src/draco/core/varint_decoding.h1
-rw-r--r--extern/draco/draco/src/draco/core/vector_d.h14
13 files changed, 95 insertions, 48 deletions
diff --git a/extern/draco/draco/src/draco/core/bounding_box.cc b/extern/draco/draco/src/draco/core/bounding_box.cc
index d95b1e90759..be0d209d857 100644
--- a/extern/draco/draco/src/draco/core/bounding_box.cc
+++ b/extern/draco/draco/src/draco/core/bounding_box.cc
@@ -16,8 +16,15 @@
namespace draco {
-BoundingBox::BoundingBox(const Vector3f &min_point_in,
- const Vector3f &max_point_in)
- : min_point_(min_point_in), max_point_(max_point_in) {}
+BoundingBox::BoundingBox()
+ : BoundingBox(Vector3f(std::numeric_limits<float>::max(),
+ std::numeric_limits<float>::max(),
+ std::numeric_limits<float>::max()),
+ Vector3f(std::numeric_limits<float>::lowest(),
+ std::numeric_limits<float>::lowest(),
+ std::numeric_limits<float>::lowest())) {}
+
+BoundingBox::BoundingBox(const Vector3f &min_point, const Vector3f &max_point)
+ : min_point_(min_point), max_point_(max_point) {}
} // namespace draco
diff --git a/extern/draco/draco/src/draco/core/bounding_box.h b/extern/draco/draco/src/draco/core/bounding_box.h
index 1c20fad8bf2..31ba2d68340 100644
--- a/extern/draco/draco/src/draco/core/bounding_box.h
+++ b/extern/draco/draco/src/draco/core/bounding_box.h
@@ -19,22 +19,27 @@
namespace draco {
-// Class for detecting the bounding box of a point_cloud or mesh.
-// Use the minimum point and the maximum point to define the bounding box.
-// TODO(xiaoxumeng): Change the class of BoundingBox to a template, similar to
-// draco/src/draco/core/vector_d.h
+// Class for computing the bounding box of points in 3D space.
class BoundingBox {
public:
- // Initialization
- BoundingBox(const Vector3f &min_point_in, const Vector3f &max_point_in);
+ // Creates bounding box object with minimum and maximum points initialized to
+ // the largest positive and the smallest negative values, respectively. The
+ // resulting abstract bounding box effectively has no points and can be
+ // updated by providing any point to Update() method.
+ BoundingBox();
- inline const Vector3f &min_point() const { return min_point_; }
- inline const Vector3f &max_point() const { return max_point_; }
+ // Creates bounding box object with minimum and maximum points initialized to
+ // |min_point| and |max_point|, respectively.
+ BoundingBox(const Vector3f &min_point, const Vector3f &max_point);
- // Conditionally updates the bounding box.
- // TODO(xiaoxumeng): Change the function to a template function and change the
- // argument to an iterator.
- inline void update_bounding_box(const Vector3f &new_point) {
+ // Returns the minimum point of the bounding box.
+ inline const Vector3f &GetMinPoint() const { return min_point_; }
+
+ // Returns the maximum point of the bounding box.
+ inline const Vector3f &GetMaxPoint() const { return max_point_; }
+
+ // Conditionally updates the bounding box with a given |new_point|.
+ void Update(const Vector3f &new_point) {
for (int i = 0; i < 3; i++) {
if (new_point[i] < min_point_[i]) {
min_point_[i] = new_point[i];
@@ -45,6 +50,19 @@ class BoundingBox {
}
}
+ // Updates bounding box with minimum and maximum points of the |other|
+ // bounding box.
+ void Update(const BoundingBox &other) {
+ Update(other.GetMinPoint());
+ Update(other.GetMaxPoint());
+ }
+
+ // Returns the size of the bounding box along each axis.
+ Vector3f Size() const { return max_point_ - min_point_; }
+
+ // Returns the center of the bounding box.
+ Vector3f Center() const { return (min_point_ + max_point_) / 2; }
+
private:
Vector3f min_point_;
Vector3f max_point_;
diff --git a/extern/draco/draco/src/draco/core/cycle_timer.cc b/extern/draco/draco/src/draco/core/cycle_timer.cc
index 94b4b28b2f9..58df4df77de 100644
--- a/extern/draco/draco/src/draco/core/cycle_timer.cc
+++ b/extern/draco/draco/src/draco/core/cycle_timer.cc
@@ -17,31 +17,31 @@
namespace draco {
void DracoTimer::Start() {
#ifdef _WIN32
- QueryPerformanceCounter(&tv_start);
+ QueryPerformanceCounter(&tv_start_);
#else
- gettimeofday(&tv_start, nullptr);
+ gettimeofday(&tv_start_, nullptr);
#endif
}
void DracoTimer::Stop() {
#ifdef _WIN32
- QueryPerformanceCounter(&tv_end);
+ QueryPerformanceCounter(&tv_end_);
#else
- gettimeofday(&tv_end, nullptr);
+ gettimeofday(&tv_end_, nullptr);
#endif
}
int64_t DracoTimer::GetInMs() {
#ifdef _WIN32
LARGE_INTEGER elapsed = {0};
- elapsed.QuadPart = tv_end.QuadPart - tv_start.QuadPart;
+ elapsed.QuadPart = tv_end_.QuadPart - tv_start_.QuadPart;
LARGE_INTEGER frequency = {0};
QueryPerformanceFrequency(&frequency);
return elapsed.QuadPart * 1000 / frequency.QuadPart;
#else
- const int64_t seconds = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
- const int64_t milliseconds = (tv_end.tv_usec - tv_start.tv_usec) / 1000;
+ const int64_t seconds = (tv_end_.tv_sec - tv_start_.tv_sec) * 1000;
+ const int64_t milliseconds = (tv_end_.tv_usec - tv_start_.tv_usec) / 1000;
return seconds + milliseconds;
#endif
}
diff --git a/extern/draco/draco/src/draco/core/cycle_timer.h b/extern/draco/draco/src/draco/core/cycle_timer.h
index 172f1c2e9b5..f480cc9d389 100644
--- a/extern/draco/draco/src/draco/core/cycle_timer.h
+++ b/extern/draco/draco/src/draco/core/cycle_timer.h
@@ -20,9 +20,10 @@
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
-typedef LARGE_INTEGER timeval;
+typedef LARGE_INTEGER DracoTimeVal;
#else
#include <sys/time.h>
+typedef timeval DracoTimeVal;
#endif
#include <cinttypes>
@@ -39,8 +40,8 @@ class DracoTimer {
int64_t GetInMs();
private:
- timeval tv_start;
- timeval tv_end;
+ DracoTimeVal tv_start_;
+ DracoTimeVal tv_end_;
};
typedef DracoTimer CycleTimer;
diff --git a/extern/draco/draco/src/draco/core/data_buffer.cc b/extern/draco/draco/src/draco/core/data_buffer.cc
index f0b43d67dbd..96a3787987c 100644
--- a/extern/draco/draco/src/draco/core/data_buffer.cc
+++ b/extern/draco/draco/src/draco/core/data_buffer.cc
@@ -52,7 +52,7 @@ void DataBuffer::Resize(int64_t size) {
}
void DataBuffer::WriteDataToStream(std::ostream &stream) {
- if (data_.size() == 0) {
+ if (data_.empty()) {
return;
}
stream.write(reinterpret_cast<char *>(data_.data()), data_.size());
diff --git a/extern/draco/draco/src/draco/core/decoder_buffer.h b/extern/draco/draco/src/draco/core/decoder_buffer.h
index 0559abbe415..be98e52d60e 100644
--- a/extern/draco/draco/src/draco/core/decoder_buffer.h
+++ b/extern/draco/draco/src/draco/core/decoder_buffer.h
@@ -54,12 +54,11 @@ class DecoderBuffer {
// Decodes up to 32 bits into out_val. Can be called only in between
// StartBitDecoding and EndBitDecoding. Otherwise returns false.
- bool DecodeLeastSignificantBits32(int nbits, uint32_t *out_value) {
+ bool DecodeLeastSignificantBits32(uint32_t nbits, uint32_t *out_value) {
if (!bit_decoder_active()) {
return false;
}
- bit_decoder_.GetBits(nbits, out_value);
- return true;
+ return bit_decoder_.GetBits(nbits, out_value);
}
// Decodes an arbitrary data type.
@@ -158,9 +157,10 @@ class DecoderBuffer {
inline void ConsumeBits(int k) { bit_offset_ += k; }
// Returns |nbits| bits in |x|.
- inline bool GetBits(int32_t nbits, uint32_t *x) {
- DRACO_DCHECK_GE(nbits, 0);
- DRACO_DCHECK_LE(nbits, 32);
+ inline bool GetBits(uint32_t nbits, uint32_t *x) {
+ if (nbits > 32) {
+ return false;
+ }
uint32_t value = 0;
for (int32_t bit = 0; bit < nbits; ++bit) {
value |= GetBit() << bit;
diff --git a/extern/draco/draco/src/draco/core/draco_index_type_vector.h b/extern/draco/draco/src/draco/core/draco_index_type_vector.h
index d47ab3b04eb..0fefc43b23d 100644
--- a/extern/draco/draco/src/draco/core/draco_index_type_vector.h
+++ b/extern/draco/draco/src/draco/core/draco_index_type_vector.h
@@ -28,7 +28,6 @@ namespace draco {
// draco_index_type.h .
// TODO(ostava): Make the interface more complete. It's currently missing
// features such as iterators.
-// TODO(vytyaz): Add more unit tests for this class.
template <class IndexTypeT, class ValueTypeT>
class IndexTypeVector {
public:
@@ -56,7 +55,7 @@ class IndexTypeVector {
void push_back(ValueTypeT &&val) { vector_.push_back(std::move(val)); }
template <typename... Args>
- void emplace_back(Args &&... args) {
+ void emplace_back(Args &&...args) {
vector_.emplace_back(std::forward<Args>(args)...);
}
diff --git a/extern/draco/draco/src/draco/core/draco_version.h b/extern/draco/draco/src/draco/core/draco_version.h
index ffd7948c64d..5f2676ad7e9 100644
--- a/extern/draco/draco/src/draco/core/draco_version.h
+++ b/extern/draco/draco/src/draco/core/draco_version.h
@@ -18,7 +18,7 @@
namespace draco {
// Draco version is comprised of <major>.<minor>.<revision>.
-static const char kDracoVersion[] = "1.3.6";
+static const char kDracoVersion[] = "1.5.2";
const char *Version() { return kDracoVersion; }
diff --git a/extern/draco/draco/src/draco/core/macros.h b/extern/draco/draco/src/draco/core/macros.h
index 89b706e53a5..64647d129d5 100644
--- a/extern/draco/draco/src/draco/core/macros.h
+++ b/extern/draco/draco/src/draco/core/macros.h
@@ -21,11 +21,13 @@
#ifdef ANDROID_LOGGING
#include <android/log.h>
#define LOG_TAG "draco"
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+#define DRACO_LOGI(...) \
+ __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define DRACO_LOGE(...) \
+ __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#else
-#define LOGI printf
-#define LOGE printf
+#define DRACO_LOGI printf
+#define DRACO_LOGE printf
#endif
#include <iostream>
@@ -88,6 +90,10 @@ namespace draco {
#define DRACO_MACROS_IMPL_CONCAT_INNER_(x, y) x##y
#define DRACO_MACROS_IMPL_CONCAT_(x, y) DRACO_MACROS_IMPL_CONCAT_INNER_(x, y)
+#define DRACO_MACROS_IMPL_CONCAT_INNER_3_(x, y, z) x##y##z
+#define DRACO_MACROS_IMPL_CONCAT_3_(x, y, z) \
+ DRACO_MACROS_IMPL_CONCAT_INNER_3_(x, y, z)
+
// Expand the n-th argument of the macro. Used to select an argument based on
// the number of entries in a variadic macro argument. Example usage:
//
@@ -98,13 +104,20 @@ namespace draco {
// #define VARIADIC_MACRO(...)
// DRACO_SELECT_NTH_FROM_3(__VA_ARGS__, FUNC_3, FUNC_2, FUNC_1) __VA_ARGS__
//
-#define DRACO_SELECT_NTH_FROM_2(_1, _2, NAME) NAME
-#define DRACO_SELECT_NTH_FROM_3(_1, _2, _3, NAME) NAME
-#define DRACO_SELECT_NTH_FROM_4(_1, _2, _3, _4, NAME) NAME
+#define DRACO_SELECT_NTH_FROM_2(_1, _2, NAME, ...) NAME
+#define DRACO_SELECT_NTH_FROM_3(_1, _2, _3, NAME, ...) NAME
+#define DRACO_SELECT_NTH_FROM_4(_1, _2, _3, _4, NAME, ...) NAME
// Macro that converts the Draco bit-stream into one uint16_t number.
// Useful mostly when checking version numbers.
#define DRACO_BITSTREAM_VERSION(MAJOR, MINOR) \
((static_cast<uint16_t>(MAJOR) << 8) | MINOR)
+// Macro that converts the uint16_t Draco bit-stream number into the major
+// and minor components respectively.
+#define DRACO_BISTREAM_VERSION_MAJOR(VERSION) \
+ (static_cast<uint8_t>(VERSION >> 8))
+#define DRACO_BISTREAM_VERSION_MINOR(VERSION) \
+ (static_cast<uint8_t>(VERSION & 0xFF))
+
#endif // DRACO_CORE_MACROS_H_
diff --git a/extern/draco/draco/src/draco/core/options.h b/extern/draco/draco/src/draco/core/options.h
index 1bc4dc0fb7b..9dc22ce16c2 100644
--- a/extern/draco/draco/src/draco/core/options.h
+++ b/extern/draco/draco/src/draco/core/options.h
@@ -71,8 +71,6 @@ class Options {
private:
// All entries are internally stored as strings and converted to the desired
// return type based on the used Get* method.
- // TODO(ostava): Consider adding type safety mechanism that would prevent
- // unsafe operations such as a conversion from vector to int.
std::map<std::string, std::string> options_;
};
diff --git a/extern/draco/draco/src/draco/core/status.h b/extern/draco/draco/src/draco/core/status.h
index 449ad8566de..ee7f43ee59c 100644
--- a/extern/draco/draco/src/draco/core/status.h
+++ b/extern/draco/draco/src/draco/core/status.h
@@ -15,6 +15,7 @@
#ifndef DRACO_CORE_STATUS_H_
#define DRACO_CORE_STATUS_H_
+#include <ostream>
#include <string>
namespace draco {
@@ -61,6 +62,9 @@ inline std::ostream &operator<<(std::ostream &os, const Status &status) {
}
inline Status OkStatus() { return Status(Status::OK); }
+inline Status ErrorStatus(const std::string &msg) {
+ return Status(Status::DRACO_ERROR, msg);
+}
// Evaluates an expression that returns draco::Status. If the status is not OK,
// the macro returns the status object.
diff --git a/extern/draco/draco/src/draco/core/varint_decoding.h b/extern/draco/draco/src/draco/core/varint_decoding.h
index 4e86df732e0..cff47e930b4 100644
--- a/extern/draco/draco/src/draco/core/varint_decoding.h
+++ b/extern/draco/draco/src/draco/core/varint_decoding.h
@@ -58,6 +58,7 @@ bool DecodeVarintUnsigned(int depth, IntTypeT *out_val, DecoderBuffer *buffer) {
// Decodes a specified integer as varint. Note that the IntTypeT must be the
// same as the one used in the corresponding EncodeVarint() call.
+// out_val is undefined if this returns false.
template <typename IntTypeT>
bool DecodeVarint(IntTypeT *out_val, DecoderBuffer *buffer) {
if (std::is_unsigned<IntTypeT>::value) {
diff --git a/extern/draco/draco/src/draco/core/vector_d.h b/extern/draco/draco/src/draco/core/vector_d.h
index bed97304feb..a0ec2dedf2e 100644
--- a/extern/draco/draco/src/draco/core/vector_d.h
+++ b/extern/draco/draco/src/draco/core/vector_d.h
@@ -20,6 +20,7 @@
#include <algorithm>
#include <array>
#include <cmath>
+#include <limits>
#include "draco/core/macros.h"
@@ -33,7 +34,7 @@ class VectorD {
typedef ScalarT Scalar;
typedef VectorD<Scalar, dimension_t> Self;
- // TODO(hemmer): Deprecate.
+ // TODO(b/199760123): Deprecate.
typedef ScalarT CoefficientType;
VectorD() {
@@ -44,7 +45,7 @@ class VectorD {
// The following constructor does not compile in opt mode, which for now led
// to the constructors further down, which is not ideal.
- // TODO(hemmer): fix constructor below and remove others.
+ // TODO(b/199760123): Fix constructor below and remove others.
// template <typename... Args>
// explicit VectorD(Args... args) : v_({args...}) {}
@@ -110,7 +111,7 @@ class VectorD {
Scalar &operator[](int i) { return v_[i]; }
const Scalar &operator[](int i) const { return v_[i]; }
- // TODO(hemmer): remove.
+ // TODO(b/199760123): Remove.
// Similar to interface of Eigen library.
Scalar &operator()(int i) { return v_[i]; }
const Scalar &operator()(int i) const { return v_[i]; }
@@ -236,7 +237,12 @@ class VectorD {
Scalar AbsSum() const {
Scalar result(0);
for (int i = 0; i < dimension; ++i) {
- result += std::abs(v_[i]);
+ Scalar next_value = std::abs(v_[i]);
+ if (result > std::numeric_limits<Scalar>::max() - next_value) {
+ // Return the max if adding would have caused an overflow.
+ return std::numeric_limits<Scalar>::max();
+ }
+ result += next_value;
}
return result;
}