Compare commits

..

12 Commits

Author SHA1 Message Date
04147e2864 use data type and domain enum in random attribute node 2020-11-17 17:20:15 +01:00
9a157d6532 initial attribute creation 2020-11-17 16:58:52 +01:00
7234fd5b31 initial WriteAttribute 2020-11-17 16:39:36 +01:00
6b8a52e2b1 initial random attribute node 2020-11-17 15:25:56 +01:00
2eb00bd479 cleanup 2020-11-17 15:08:49 +01:00
d755281413 simplify typed access 2020-11-17 13:55:23 +01:00
0e9567c63c cleanup 2020-11-17 13:51:33 +01:00
1faab5c82d cleanup naming 2020-11-17 13:42:44 +01:00
d3e05090a8 cleanup 2020-11-17 13:27:58 +01:00
a889254974 use simpler accessor 2020-11-17 12:45:03 +01:00
3c020f9416 initial working version 2020-11-17 12:18:25 +01:00
8786624534 wip 2020-11-16 17:17:45 +01:00
1594 changed files with 27594 additions and 45996 deletions

View File

@@ -29,19 +29,23 @@ Checks: >
-bugprone-sizeof-expression, -bugprone-sizeof-expression,
-bugprone-integer-division, -bugprone-integer-division,
-bugprone-exception-escape,
-bugprone-redundant-branch-condition, -bugprone-redundant-branch-condition,
modernize-*, modernize-*,
-modernize-use-auto, -modernize-use-auto,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,
-modernize-deprecated-headers,
-modernize-avoid-c-arrays, -modernize-avoid-c-arrays,
-modernize-use-equals-default, -modernize-use-equals-default,
-modernize-use-nodiscard, -modernize-use-nodiscard,
-modernize-use-using,
-modernize-loop-convert, -modernize-loop-convert,
-modernize-pass-by-value, -modernize-pass-by-value,
-modernize-use-default-member-init, -modernize-use-default-member-init,
-modernize-raw-string-literal, -modernize-raw-string-literal,
-modernize-avoid-bind, -modernize-avoid-bind,
-modernize-use-override,
-modernize-use-transparent-functors, -modernize-use-transparent-functors,
WarningsAsErrors: '*' WarningsAsErrors: '*'

View File

@@ -91,79 +91,3 @@ c42a6b77b52560d257279de2cb624b4ef2c0d24c
# Cleanup: use doxy sections for imbuf # Cleanup: use doxy sections for imbuf
c207f7c22e1439e0b285fba5d2c072bdae23f981 c207f7c22e1439e0b285fba5d2c072bdae23f981
# Cleanup: Clang-Tidy, modernize-use-bool-literals
af35ada2f3fa8da4d46b3a71de724d353d716820
# Cleanup: Use nullptr everywhere in fluid code
311031ecd03dbfbf43e1df672a395f24b2e7d4d3
# Cleanup: Clang-Tidy, modernize-redundant-void-arg
a331d5c99299c4514ca33c843b1c79b872f2728d
# Cleanup: Clang-Tidy modernize-use-nullptr
16732def37c5a66f3ea28dbe247b09cc6bca6677
# Cleanup: Clang-tidy, modernize-concat-nested-namespaces
4525049aa0cf818f6483dce589ac9791eb562338
# Cleanup: Clang-tidy else-after-return
ae342ed4511cf2e144dcd27ce2c635d3d536f9ad
# Cleanup: Clang-Tidy, readability-redundant-member-init
190170d4cc92ff34abe1744a10474ac4f1074086
# Cleanup: use 'filepath' instead of 'name' for ImBuf utilities
99f56b4c16323f96c0cbf54e392fb509fcac5bda
# Cleanup: clang-format
c4d8f6a4a8ddc29ed27311ed7578b3c8c31399d2
b5d310b569e07a937798a2d38539cfd290149f1c
8c846cccd6bdfd3e90a695fabbf05f53e5466a57
40d4a4cb1a6b4c3c2a486e8f2868f547530e0811
4eac03d821fa17546f562485f7d073813a5e5943
# Cleanup: use preprocessor version check for PyTypeObject declaration
cd9acfed4f7674b84be965d469a367aef96f8af3
# Cycles: fix compilation of OSL shaders following API change
b980cd163a9d5d77eeffc2e353333e739fa9e719
# Cleanup: clang-tidy suppress warnings for PyTypeObject.tp_print
efd71aad4f22ec0073d80b8dd296015d3f395aa8
# Cleanup: fix wrong merge, remove extra unique_ptr.
6507449e54a167c63a72229e4d0119dd2af68ae5
# Cleanup: fix some clang tidy issues
525a042c5c7513c41240b118acca002f6c60cc12
# Fix T82520: error building freestyle with Python3.8
e118426e4695a97d67e65d69677f3c4e2db50a56
# Cleanup: Clang-tidy, readability-else-after-return
7be47dadea5066ae095c644e0b4f1f10d75f5ab3
# Cleanup: Add `r_` to return parameter
45dca05b1cd2a5ead59144c93d790fdfe7c35ee6
# Cleanup: Typo in `print_default_info` function name.
41a73909dec716642f044e60b40a28335c9fdb10
# Cleanup: Reduce indentation
1cc3a0e2cf73a5ff4f9e0a7f5338eda77266b300
# Build-system: Force C linkage for all DNA type headers
ad4b7741dba45a2be210942c18af6b6e4438f129
# Cleanup: Move function to proper section
c126e27cdc8b28365a9d5f9fafc4d521d1eb83df
# Cleanup: remove break after return statements
bbdfeb751e16d939482d2e4b95c4d470f53f18a5
# Cleanup: clang-tidy
af013ff76feef7e8b8ba642279c62a5dc275d59f
# Cleanup: Make panel type flag names more clear
9d28353b525ecfbcca1501be72e4276dfb2bbc2a

View File

@@ -178,7 +178,6 @@ mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON) option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
option(WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON) option(WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON)
option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON) option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON)
option(WITH_PUGIXML "Enable PugiXML support (Used for OpenImageIO, Grease Pencil SVG export)" ON)
option(WITH_BULLET "Enable Bullet (Physics Engine)" ON) option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" ) option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
mark_as_advanced(WITH_SYSTEM_BULLET) mark_as_advanced(WITH_SYSTEM_BULLET)
@@ -347,21 +346,16 @@ if(UNIX AND NOT APPLE)
endif() endif()
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON) option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
if((WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE) OR WITH_MOD_FLUID)
option(WITH_PYTHON_NUMPY "Include NumPy in Blender (used by Audaspace and Mantaflow)" ON)
endif()
if(WIN32 OR APPLE) if(WIN32 OR APPLE)
# Windows and macOS have this bundled with Python libraries. # Windows and macOS have this bundled with Python libraries.
elseif(WITH_PYTHON_INSTALL OR WITH_PYTHON_NUMPY) elseif(WITH_PYTHON_INSTALL OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module") set(PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module")
mark_as_advanced(PYTHON_NUMPY_PATH) mark_as_advanced(PYTHON_NUMPY_PATH)
set(PYTHON_NUMPY_INCLUDE_DIRS "" CACHE PATH "Path to the include directory of the NumPy module") set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS) mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
endif() endif()
if(WITH_PYTHON_INSTALL) if(WITH_PYTHON_INSTALL)
option(WITH_PYTHON_INSTALL_NUMPY "Copy system NumPy into the blender install folder" ON) option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON) option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
@@ -383,7 +377,6 @@ option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF) option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF) option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL) mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
set(CYCLES_TEST_DEVICES CPU CACHE STRING "Run regression tests on the specified device types (CPU CUDA OPTIX OPENCL)" )
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for") set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH) mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT) unset(PLATFORM_DEFAULT)
@@ -432,8 +425,8 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON) option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
mark_as_advanced(WITH_ASSERT_ABORT) mark_as_advanced(WITH_ASSERT_ABORT)
if((UNIX AND NOT APPLE) OR (CMAKE_GENERATOR MATCHES "^Visual Studio.+")) if(UNIX AND NOT APPLE)
option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang, or Windows using the Visual Studio IDE)" OFF) option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang)" OFF)
mark_as_advanced(WITH_CLANG_TIDY) mark_as_advanced(WITH_CLANG_TIDY)
endif() endif()
@@ -704,8 +697,6 @@ set_and_warn_dependency(WITH_BOOST WITH_OPENCOLORIO OFF)
set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF) set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF)
set_and_warn_dependency(WITH_BOOST WITH_USD OFF) set_and_warn_dependency(WITH_BOOST WITH_USD OFF)
set_and_warn_dependency(WITH_BOOST WITH_ALEMBIC OFF) set_and_warn_dependency(WITH_BOOST WITH_ALEMBIC OFF)
set_and_warn_dependency(WITH_PUGIXML WITH_CYCLES_OSL OFF)
set_and_warn_dependency(WITH_PUGIXML WITH_OPENIMAGEIO OFF)
if(WITH_BOOST AND NOT (WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR if(WITH_BOOST AND NOT (WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_USD OR WITH_ALEMBIC)) WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_USD OR WITH_ALEMBIC))
@@ -884,11 +875,9 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
if(APPLE AND COMPILER_ASAN_LIBRARY) if(APPLE AND COMPILER_ASAN_LIBRARY)
string(REPLACE " " ";" _list_COMPILER_ASAN_CFLAGS ${COMPILER_ASAN_CFLAGS}) string(REPLACE " " ";" _list_COMPILER_ASAN_CFLAGS ${COMPILER_ASAN_CFLAGS})
set(_is_CONFIG_DEBUG "$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>") add_compile_options("$<$<NOT:$<CONFIG:Release>>:${_list_COMPILER_ASAN_CFLAGS}>")
add_compile_options("$<${_is_CONFIG_DEBUG}:${_list_COMPILER_ASAN_CFLAGS}>") add_link_options("$<$<NOT:$<CONFIG:Release>>:-fno-omit-frame-pointer;-fsanitize=address>")
add_link_options("$<${_is_CONFIG_DEBUG}:-fno-omit-frame-pointer;-fsanitize=address>")
unset(_list_COMPILER_ASAN_CFLAGS) unset(_list_COMPILER_ASAN_CFLAGS)
unset(_is_CONFIG_DEBUG)
elseif(COMPILER_ASAN_LIBRARY) elseif(COMPILER_ASAN_LIBRARY)
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}") set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}")
set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}") set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
@@ -1626,16 +1615,19 @@ if(WITH_PYTHON)
if(WIN32 OR APPLE) if(WIN32 OR APPLE)
# Windows and macOS have this bundled with Python libraries. # Windows and macOS have this bundled with Python libraries.
elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR WITH_PYTHON_NUMPY) elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE))
if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND)) if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
find_python_package(numpy "core/include") find_python_package(numpy)
unset(PYTHON_NUMPY_INCLUDE_DIRS CACHE)
set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_PATH}/numpy/core/include CACHE PATH "Path to the include directory of the numpy module")
mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
endif() endif()
endif() endif()
if(WIN32 OR APPLE) if(WIN32 OR APPLE)
# pass, we have this in lib/python/site-packages # pass, we have this in lib/python/site-packages
elseif(WITH_PYTHON_INSTALL_REQUESTS) elseif(WITH_PYTHON_INSTALL_REQUESTS)
find_python_package(requests "") find_python_package(requests)
endif() endif()
endif() endif()

View File

@@ -94,7 +94,11 @@ include(cmake/usd.cmake)
include(cmake/potrace.cmake) include(cmake/potrace.cmake)
# Boost needs to be included after python.cmake due to the PYTHON_BINARY variable being needed. # Boost needs to be included after python.cmake due to the PYTHON_BINARY variable being needed.
include(cmake/boost.cmake) include(cmake/boost.cmake)
include(cmake/pugixml.cmake) if(UNIX)
# Rely on PugiXML compiled with OpenImageIO
else()
include(cmake/pugixml.cmake)
endif()
if((NOT APPLE) OR ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")) if((NOT APPLE) OR ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64"))
include(cmake/ispc.cmake) include(cmake/ispc.cmake)
include(cmake/openimagedenoise.cmake) include(cmake/openimagedenoise.cmake)

View File

@@ -42,13 +42,7 @@ if(UNIX)
endforeach() endforeach()
if(APPLE) if(APPLE)
# Homebrew has different default locations for ARM and Intel macOS. if(NOT EXISTS "/usr/local/opt/bison/bin/bison")
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(HOMEBREW_LOCATION "/opt/homebrew")
else()
set(HOMEBREW_LOCATION "/usr/local")
endif()
if(NOT EXISTS "${HOMEBREW_LOCATION}/opt/bison/bin/bison")
string(APPEND _software_missing " bison") string(APPEND _software_missing " bison")
endif() endif()
endif() endif()

View File

@@ -17,14 +17,13 @@
# ***** END GPL LICENSE BLOCK ***** # ***** END GPL LICENSE BLOCK *****
set(CLANG_EXTRA_ARGS set(CLANG_EXTRA_ARGS
-DLLVM_DIR="${LIBDIR}/llvm/lib/cmake/llvm/" -DCLANG_PATH_TO_LLVM_SOURCE=${BUILD_DIR}/ll/src/ll
-DCLANG_PATH_TO_LLVM_BUILD=${LIBDIR}/llvm
-DLLVM_USE_CRT_RELEASE=MD -DLLVM_USE_CRT_RELEASE=MD
-DLLVM_USE_CRT_DEBUG=MDd -DLLVM_USE_CRT_DEBUG=MDd
-DLLVM_CONFIG=${LIBDIR}/llvm/bin/llvm-config -DLLVM_CONFIG=${LIBDIR}/llvm/bin/llvm-config
) )
set(BUILD_CLANG_TOOLS OFF)
if(WIN32) if(WIN32)
set(CLANG_GENERATOR "Ninja") set(CLANG_GENERATOR "Ninja")
else() else()
@@ -32,32 +31,11 @@ else()
endif() endif()
if(APPLE) if(APPLE)
set(BUILD_CLANG_TOOLS ON)
set(CLANG_EXTRA_ARGS ${CLANG_EXTRA_ARGS} set(CLANG_EXTRA_ARGS ${CLANG_EXTRA_ARGS}
-DLIBXML2_LIBRARY=${LIBDIR}/xml2/lib/libxml2.a -DLIBXML2_LIBRARY=${LIBDIR}/xml2/lib/libxml2.a
) )
endif() endif()
if(BUILD_CLANG_TOOLS)
# ExternalProject_Add does not allow multiple tarballs to be
# downloaded. Work around this by having an empty build action
# for the extra tools, and referring the clang build to the location
# of the clang-tools-extra source.
ExternalProject_Add(external_clang_tools
URL ${CLANG_TOOLS_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${CLANG_TOOLS_HASH}
INSTALL_DIR ${LIBDIR}/clang_tools
PREFIX ${BUILD_DIR}/clang_tools
CONFIGURE_COMMAND echo "."
BUILD_COMMAND echo "."
INSTALL_COMMAND echo "."
)
list(APPEND CLANG_EXTRA_ARGS
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=${BUILD_DIR}/clang_tools/src/external_clang_tools/
)
endif()
ExternalProject_Add(external_clang ExternalProject_Add(external_clang
URL ${CLANG_URI} URL ${CLANG_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR} DOWNLOAD_DIR ${DOWNLOAD_DIR}
@@ -87,14 +65,6 @@ add_dependencies(
ll ll
) )
if(BUILD_CLANG_TOOLS)
# `external_clang_tools` is for downloading the source, not compiling it.
add_dependencies(
external_clang
external_clang_tools
)
endif()
# We currently do not build libxml2 on Windows. # We currently do not build libxml2 on Windows.
if(NOT WIN32) if(NOT WIN32)
add_dependencies( add_dependencies(

View File

@@ -98,10 +98,6 @@ harvest(jpg/include jpeg/include "*.h")
harvest(jpg/lib jpeg/lib "libjpeg.a") harvest(jpg/lib jpeg/lib "libjpeg.a")
harvest(lame/lib ffmpeg/lib "*.a") harvest(lame/lib ffmpeg/lib "*.a")
harvest(clang/bin llvm/bin "clang-format") harvest(clang/bin llvm/bin "clang-format")
if(BUILD_CLANG_TOOLS)
harvest(clang/bin llvm/bin "clang-tidy")
harvest(clang/share/clang llvm/share "run-clang-tidy.py")
endif()
harvest(clang/include llvm/include "*") harvest(clang/include llvm/include "*")
harvest(llvm/include llvm/include "*") harvest(llvm/include llvm/include "*")
harvest(llvm/bin llvm/bin "llvm-config") harvest(llvm/bin llvm/bin "llvm-config")
@@ -160,8 +156,6 @@ harvest(osl/lib osl/lib "*.a")
harvest(osl/shaders osl/shaders "*.h") harvest(osl/shaders osl/shaders "*.h")
harvest(png/include png/include "*.h") harvest(png/include png/include "*.h")
harvest(png/lib png/lib "*.a") harvest(png/lib png/lib "*.a")
harvest(pugixml/include pugixml/include "*.hpp")
harvest(pugixml/lib pugixml/lib "*.a")
harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}m") harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}m")
harvest(python/include python/include "*h") harvest(python/include python/include "*h")
harvest(python/lib python/lib "*") harvest(python/lib python/lib "*")

View File

@@ -25,13 +25,8 @@ if(WIN32)
elseif(APPLE) elseif(APPLE)
# Use bison installed via Homebrew. # Use bison installed via Homebrew.
# The one which comes which Xcode toolset is too old. # The one which comes which Xcode toolset is too old.
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(HOMEBREW_LOCATION "/opt/homebrew")
else()
set(HOMEBREW_LOCATION "/usr/local")
endif()
set(ISPC_EXTRA_ARGS_APPLE set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=${HOMEBREW_LOCATION}/opt/bison/bin/bison -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
) )
elseif(UNIX) elseif(UNIX)
set(ISPC_EXTRA_ARGS_UNIX set(ISPC_EXTRA_ARGS_UNIX

View File

@@ -112,9 +112,6 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DOPENEXR_IEX_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}Iex${OPENEXR_VERSION_POSTFIX}${LIBEXT} -DOPENEXR_IEX_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}Iex${OPENEXR_VERSION_POSTFIX}${LIBEXT}
-DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf${OPENEXR_VERSION_POSTFIX}${LIBEXT} -DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf${OPENEXR_VERSION_POSTFIX}${LIBEXT}
-DSTOP_ON_WARNING=OFF -DSTOP_ON_WARNING=OFF
-DUSE_EXTERNAL_PUGIXML=ON
-DPUGIXML_LIBRARY=${LIBDIR}/pugixml/lib/${LIBPREFIX}pugixml${LIBEXT}
-DPUGIXML_INCLUDE_DIR=${LIBDIR}/pugixml/include/
${WEBP_FLAGS} ${WEBP_FLAGS}
${OIIO_SIMD_FLAGS} ${OIIO_SIMD_FLAGS}
) )
@@ -137,7 +134,6 @@ add_dependencies(
external_jpeg external_jpeg
external_boost external_boost
external_tiff external_tiff
external_pugixml
external_openjpeg${OPENJPEG_POSTFIX} external_openjpeg${OPENJPEG_POSTFIX}
${WEBP_DEP} ${WEBP_DEP}
) )

View File

@@ -78,10 +78,14 @@ set(OSL_EXTRA_ARGS
-DINSTALL_DOCS=OFF -DINSTALL_DOCS=OFF
${OSL_SIMD_FLAGS} ${OSL_SIMD_FLAGS}
-DPARTIO_LIBRARIES= -DPARTIO_LIBRARIES=
-DPUGIXML_HOME=${LIBDIR}/pugixml
) )
if(APPLE) if(WIN32)
set(OSL_EXTRA_ARGS
${OSL_EXTRA_ARGS}
-DPUGIXML_HOME=${LIBDIR}/pugixml
)
elseif(APPLE)
# Make symbol hiding consistent with OIIO which defaults to OFF, # Make symbol hiding consistent with OIIO which defaults to OFF,
# avoids linker warnings on macOS # avoids linker warnings on macOS
set(OSL_EXTRA_ARGS set(OSL_EXTRA_ARGS
@@ -110,9 +114,17 @@ add_dependencies(
external_zlib external_zlib
external_flexbison external_flexbison
external_openimageio external_openimageio
external_pugixml
) )
if(UNIX)
# Rely on PugiXML compiled with OpenImageIO
else()
add_dependencies(
external_osl
external_pugixml
)
endif()
if(WIN32) if(WIN32)
if(BUILD_MODE STREQUAL Release) if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_osl after_install ExternalProject_Add_Step(external_osl after_install

View File

@@ -30,13 +30,13 @@ ExternalProject_Add(external_pugixml
if(WIN32) if(WIN32)
if(BUILD_MODE STREQUAL Release) if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_pugixml after_install ExternalProject_Add_Step(external_pugixml after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pugixml ${HARVEST_TARGET}/pugixml COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/pugixml/lib/pugixml.lib ${HARVEST_TARGET}/osl/lib/pugixml.lib
DEPENDEES install DEPENDEES install
) )
endif() endif()
if(BUILD_MODE STREQUAL Debug) if(BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_pugixml after_install ExternalProject_Add_Step(external_pugixml after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/pugixml/lib/pugixml.lib ${HARVEST_TARGET}/pugixml/lib/pugixml_d.lib COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/pugixml/lib/pugixml.lib ${HARVEST_TARGET}/osl/lib/pugixml_d.lib
DEPENDEES install DEPENDEES install
) )
endif() endif()

View File

@@ -120,9 +120,6 @@ set(LLVM_HASH 31eb9ce73dd2a0f8dcab8319fb03f8fc)
set(CLANG_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang-${LLVM_VERSION}.src.tar.xz) set(CLANG_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang-${LLVM_VERSION}.src.tar.xz)
set(CLANG_HASH 13468e4a44940efef1b75e8641752f90) set(CLANG_HASH 13468e4a44940efef1b75e8641752f90)
set(CLANG_TOOLS_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang-tools-extra-${LLVM_VERSION}.src.tar.xz)
set(CLANG_TOOLS_HASH c76293870b564c6a7968622b475b7646)
set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/openmp-${LLVM_VERSION}.src.tar.xz) set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/openmp-${LLVM_VERSION}.src.tar.xz)
set(OPENMP_HASH 6eade16057edbdecb3c4eef9daa2bfcf) set(OPENMP_HASH 6eade16057edbdecb3c4eef9daa2bfcf)

View File

@@ -34,24 +34,3 @@ diff -Naur orig/src/include/OpenImageIO/platform.h external_openimageio/src/incl
# include <windows.h> # include <windows.h>
#endif #endif
diff -Naur orig/src/libutil/ustring.cpp external_openimageio/src/libutil/ustring.cpp
--- orig/src/libutil/ustring.cpp 2020-05-11 05:43:52.000000000 +0200
+++ external_openimageio/src/libutil/ustring.cpp 2020-11-26 12:06:08.000000000 +0100
@@ -337,6 +337,8 @@
// the std::string to make it point to our chars! In such a case, the
// destructor will be careful not to allow a deallocation.
+ // Disable internal std::string for Apple silicon based Macs
+#if !(defined(__APPLE__) && defined(__arm64__))
#if defined(__GNUC__) && !defined(_LIBCPP_VERSION) \
&& defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI
// NEW gcc ABI
@@ -382,7 +384,7 @@
return;
}
#endif
-
+#endif
// Remaining cases - just assign the internal string. This may result
// in double allocation for the chars. If you care about that, do
// something special for your platform, much like we did for gcc and

View File

@@ -64,12 +64,7 @@ class WindowsCodeSigner(BaseCodeSigner):
def run_codesign_tool(self, filepath: Path) -> None: def run_codesign_tool(self, filepath: Path) -> None:
command = self.get_sign_command_prefix() + [filepath] command = self.get_sign_command_prefix() + [filepath]
codesign_output = self.check_output_or_mock(command, util.Platform.WINDOWS)
try:
codesign_output = self.check_output_or_mock(command, util.Platform.WINDOWS)
except subprocess.CalledProcessError as e:
raise SigntoolException(f'Error running signtool {e}')
logger_server.info(f'signtool output:\n{codesign_output}') logger_server.info(f'signtool output:\n{codesign_output}')
got_number_of_success = False got_number_of_success = False

View File

@@ -49,7 +49,7 @@ FIND_LIBRARY(PUGIXML_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set PUGIXML_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set PUGIXML_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PugiXML DEFAULT_MSG FIND_PACKAGE_HANDLE_STANDARD_ARGS(PUGIXML DEFAULT_MSG
PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR) PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
IF(PUGIXML_FOUND) IF(PUGIXML_FOUND)

View File

@@ -1,10 +1,7 @@
# Distributed under the OSI-approved BSD 3-Clause License, # Distributed under the OSI-approved BSD 3-Clause License,
# see accompanying file BSD-3-Clause-license.txt for details. # see accompanying file BSD-3-Clause-license.txt for details.
# Changes made to this script have been marked with "BLENDER". # Blender: disable ASAN leak detection when trying to discover tests.
# BLENDER: disable ASAN leak detection when trying to discover tests.
set(ENV{ASAN_OPTIONS} "detect_leaks=0") set(ENV{ASAN_OPTIONS} "detect_leaks=0")
cmake_minimum_required(VERSION ${CMAKE_VERSION}) cmake_minimum_required(VERSION ${CMAKE_VERSION})

View File

@@ -1139,7 +1139,6 @@ endfunction()
function(find_python_package function(find_python_package
package package
relative_include_dir
) )
string(TOUPPER ${package} _upper_package) string(TOUPPER ${package} _upper_package)
@@ -1171,10 +1170,7 @@ function(find_python_package
dist-packages dist-packages
vendor-packages vendor-packages
NO_DEFAULT_PATH NO_DEFAULT_PATH
DOC
"Path to python site-packages or dist-packages containing '${package}' module"
) )
mark_as_advanced(PYTHON_${_upper_package}_PATH)
if(NOT EXISTS "${PYTHON_${_upper_package}_PATH}") if(NOT EXISTS "${PYTHON_${_upper_package}_PATH}")
message(WARNING message(WARNING
@@ -1192,50 +1188,6 @@ function(find_python_package
set(WITH_PYTHON_INSTALL_${_upper_package} OFF PARENT_SCOPE) set(WITH_PYTHON_INSTALL_${_upper_package} OFF PARENT_SCOPE)
else() else()
message(STATUS "${package} found at '${PYTHON_${_upper_package}_PATH}'") message(STATUS "${package} found at '${PYTHON_${_upper_package}_PATH}'")
if(NOT "${relative_include_dir}" STREQUAL "")
set(_relative_include_dir "${package}/${relative_include_dir}")
unset(PYTHON_${_upper_package}_INCLUDE_DIRS CACHE)
find_path(PYTHON_${_upper_package}_INCLUDE_DIRS
NAMES
"${_relative_include_dir}"
HINTS
"${PYTHON_LIBPATH}/"
"${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
"${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
PATH_SUFFIXES
"site-packages/"
"dist-packages/"
"vendor-packages/"
NO_DEFAULT_PATH
DOC
"Path to python site-packages or dist-packages containing '${package}' module header files"
)
mark_as_advanced(PYTHON_${_upper_package}_INCLUDE_DIRS)
if(NOT EXISTS "${PYTHON_${_upper_package}_INCLUDE_DIRS}")
message(WARNING
"Python package '${package}' include dir path could not be found in:\n"
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${_relative_include_dir}', "
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/${_relative_include_dir}', "
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${_relative_include_dir}', "
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${_relative_include_dir}', "
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/vendor-packages/${_relative_include_dir}', "
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/vendor-packages/${_relative_include_dir}', "
"\n"
"The 'WITH_PYTHON_${_upper_package}' option will be disabled.\n"
"The build will be usable, only add-ons that depend on this package won't be functional."
)
set(WITH_PYTHON_${_upper_package} OFF PARENT_SCOPE)
else()
set(_temp "${PYTHON_${_upper_package}_INCLUDE_DIRS}/${package}/${relative_include_dir}")
unset(PYTHON_${_upper_package}_INCLUDE_DIRS CACHE)
set(PYTHON_${_upper_package}_INCLUDE_DIRS "${_temp}"
CACHE PATH "Path to the include directory of the ${package} module")
message(STATUS "${package} include files found at '${PYTHON_${_upper_package}_INCLUDE_DIRS}'")
endif()
endif()
endif() endif()
endif() endif()
endfunction() endfunction()

View File

@@ -73,6 +73,9 @@ endif()
if(NOT DEFINED LIBDIR) if(NOT DEFINED LIBDIR)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin) set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
# Prefer lib directory paths
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS})
else() else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
endif() endif()
@@ -80,10 +83,6 @@ if(NOT EXISTS "${LIBDIR}/")
message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'") message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'")
endif() endif()
# Prefer lib directory paths
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS})
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Find precompiled libraries, and avoid system or user-installed ones. # Find precompiled libraries, and avoid system or user-installed ones.
@@ -270,14 +269,6 @@ if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG)
string(APPEND PLATFORM_LINKFLAGS " -liconv") # boost_locale and ffmpeg needs it ! string(APPEND PLATFORM_LINKFLAGS " -liconv") # boost_locale and ffmpeg needs it !
endif() endif()
if(WITH_PUGIXML)
find_package(PugiXML)
if(NOT PUGIXML_FOUND)
message(WARNING "PugiXML not found, disabling WITH_PUGIXML")
set(WITH_PUGIXML OFF)
endif()
endif()
if(WITH_OPENIMAGEIO) if(WITH_OPENIMAGEIO)
find_package(OpenImageIO) find_package(OpenImageIO)
list(APPEND OPENIMAGEIO_LIBRARIES list(APPEND OPENIMAGEIO_LIBRARIES
@@ -346,7 +337,7 @@ if(WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED) find_package(Embree 3.8.0 REQUIRED)
# Increase stack size for Embree, only works for executables. # Increase stack size for Embree, only works for executables.
if(NOT WITH_PYTHON_MODULE) if(NOT WITH_PYTHON_MODULE)
string(APPEND PLATFORM_LINKFLAGS " -Wl,-stack_size,0x100000") string(APPEND PLATFORM_LINKFLAGS " -Xlinker -stack_size -Xlinker 0x100000")
endif() endif()
# Embree static library linking can mix up SSE and AVX symbols, causing # Embree static library linking can mix up SSE and AVX symbols, causing
@@ -458,8 +449,8 @@ endif()
# Avoid conflicts with Luxrender, and other plug-ins that may use the same # Avoid conflicts with Luxrender, and other plug-ins that may use the same
# libraries as Blender with a different version or build options. # libraries as Blender with a different version or build options.
string(APPEND PLATFORM_LINKFLAGS set(PLATFORM_LINKFLAGS
" -Wl,-unexported_symbols_list,'${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map'" "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker '${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map'"
) )
string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++") string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++")

View File

@@ -350,12 +350,15 @@ if(WITH_BOOST)
endif() endif()
endif() endif()
if(WITH_PUGIXML)
find_package_wrapper(PugiXML)
endif()
if(WITH_OPENIMAGEIO) if(WITH_OPENIMAGEIO)
find_package_wrapper(OpenImageIO) find_package_wrapper(OpenImageIO)
if(NOT OPENIMAGEIO_PUGIXML_FOUND AND WITH_CYCLES_STANDALONE)
find_package_wrapper(PugiXML)
else()
set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}")
set(PUGIXML_LIBRARIES "")
endif()
set(OPENIMAGEIO_LIBRARIES set(OPENIMAGEIO_LIBRARIES
${OPENIMAGEIO_LIBRARIES} ${OPENIMAGEIO_LIBRARIES}
${PNG_LIBRARIES} ${PNG_LIBRARIES}

View File

@@ -239,24 +239,9 @@ if(NOT EXISTS "${LIBDIR}/")
message(FATAL_ERROR "\n\nWindows requires pre-compiled libs at: '${LIBDIR}'. Please run `make update` in the blender source folder to obtain them.") message(FATAL_ERROR "\n\nWindows requires pre-compiled libs at: '${LIBDIR}'. Please run `make update` in the blender source folder to obtain them.")
endif() endif()
if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND # Only supported in the VS IDE
MSVC_VERSION GREATER_EQUAL 1924 AND # Supported for 16.4+
WITH_CLANG_TIDY # And Clang Tidy needs to be on
)
set(CMAKE_VS_GLOBALS
"RunCodeAnalysis=false"
"EnableMicrosoftCodeAnalysis=false"
"EnableClangTidyCodeAnalysis=true"
)
set(VS_CLANG_TIDY On)
endif()
# Mark libdir as system headers with a lower warn level, to resolve some warnings # Mark libdir as system headers with a lower warn level, to resolve some warnings
# that we have very little control over # that we have very little control over
if(MSVC_VERSION GREATER_EQUAL 1914 AND # Available with 15.7+ if(MSVC_VERSION GREATER_EQUAL 1914 AND NOT MSVC_CLANG AND NOT WITH_WINDOWS_SCCACHE)
NOT MSVC_CLANG AND # But not for clang
NOT WITH_WINDOWS_SCCACHE AND # And not when sccache is enabled
NOT VS_CLANG_TIDY) # Clang-tidy does not like these options
add_compile_options(/experimental:external /external:templates- /external:I "${LIBDIR}" /external:W0) add_compile_options(/experimental:external /external:templates- /external:I "${LIBDIR}" /external:W0)
endif() endif()
@@ -268,11 +253,6 @@ foreach(child ${children})
endif() endif()
endforeach() endforeach()
if(WITH_PUGIXML)
set(PUGIXML_LIBRARIES optimized ${LIBDIR}/pugixml/lib/pugixml.lib debug ${LIBDIR}/pugixml/lib/pugixml_d.lib)
set(PUGIXML_INCLUDE_DIR ${LIBDIR}/pugixml/include)
endif()
set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include) set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib) set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib)
set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include) set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include)
@@ -671,10 +651,11 @@ if(WITH_CYCLES_OSL)
optimized ${OSL_LIB_COMP} optimized ${OSL_LIB_COMP}
optimized ${OSL_LIB_EXEC} optimized ${OSL_LIB_EXEC}
optimized ${OSL_LIB_QUERY} optimized ${OSL_LIB_QUERY}
optimized ${CYCLES_OSL}/lib/pugixml.lib
debug ${OSL_LIB_EXEC_DEBUG} debug ${OSL_LIB_EXEC_DEBUG}
debug ${OSL_LIB_COMP_DEBUG} debug ${OSL_LIB_COMP_DEBUG}
debug ${OSL_LIB_QUERY_DEBUG} debug ${OSL_LIB_QUERY_DEBUG}
${PUGIXML_LIBRARIES} debug ${CYCLES_OSL}/lib/pugixml_d.lib
) )
find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
@@ -739,7 +720,7 @@ if(WINDOWS_PYTHON_DEBUG)
string(REPLACE "/" "\\" _group_path "${_source_path}") string(REPLACE "/" "\\" _group_path "${_source_path}")
source_group("${_group_path}" FILES "${_source}") source_group("${_group_path}" FILES "${_source}")
endforeach() endforeach()
# If the user scripts env var is set, include scripts from there otherwise # If the user scripts env var is set, include scripts from there otherwise
# include user scripts in the profile folder. # include user scripts in the profile folder.
if(DEFINED ENV{BLENDER_USER_SCRIPTS}) if(DEFINED ENV{BLENDER_USER_SCRIPTS})
@@ -750,7 +731,7 @@ if(WINDOWS_PYTHON_DEBUG)
# Include the user scripts from the profile folder in the blender_python_user_scripts project. # Include the user scripts from the profile folder in the blender_python_user_scripts project.
set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender foundation/blender/${BLENDER_VERSION}/scripts") set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender foundation/blender/${BLENDER_VERSION}/scripts")
endif() endif()
file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT) file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT)
FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" ) FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" )
ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles}) ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles})

View File

@@ -92,5 +92,5 @@ echo if "%%VSCMD_VER%%" == "" ^( >> %BUILD_DIR%\rebuild.cmd
echo call "%VCVARS%" %BUILD_ARCH% >> %BUILD_DIR%\rebuild.cmd echo call "%VCVARS%" %BUILD_ARCH% >> %BUILD_DIR%\rebuild.cmd
echo ^) >> %BUILD_DIR%\rebuild.cmd echo ^) >> %BUILD_DIR%\rebuild.cmd
echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
echo ninja install %%* >> %BUILD_DIR%\rebuild.cmd echo ninja install >> %BUILD_DIR%\rebuild.cmd
echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd

View File

@@ -453,7 +453,7 @@ TYPEDEF_HIDES_STRUCT = NO
# the optimal cache size from a speed point of view. # the optimal cache size from a speed point of view.
# Minimum value: 0, maximum value: 9, default value: 0. # Minimum value: 0, maximum value: 9, default value: 0.
LOOKUP_CACHE_SIZE = 3 LOOKUP_CACHE_SIZE = 0
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Build related configuration options # Build related configuration options
@@ -1321,7 +1321,7 @@ DOCSET_PUBLISHER_NAME = Publisher
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_HTMLHELP = NO GENERATE_HTMLHELP = YES
# The CHM_FILE tag can be used to specify the file name of the resulting .chm # The CHM_FILE tag can be used to specify the file name of the resulting .chm
# file. You can add a path in front of the file if the result should not be # file. You can add a path in front of the file if the result should not be

View File

@@ -121,10 +121,6 @@
* \ingroup editors * \ingroup editors
*/ */
/** \defgroup edasset asset
* \ingroup editors
*/
/** \defgroup edcurve curve /** \defgroup edcurve curve
* \ingroup editors * \ingroup editors
*/ */

View File

@@ -1,30 +0,0 @@
"""
.. note::
Properties defined at run-time store the values of the properties as custom-properties.
This method checks if the underlying data exists, causing the property to be considered *set*.
A common pattern for operators is to calculate a value for the properties
that have not had their values explicitly set by the caller
(where the caller could be a key-binding, menu-items or Python script for example).
In the case of executing operators multiple times, values are re-used from the previous execution.
For example: subdividing a mesh with a smooth value of 1.0 will keep using
that value on subsequent calls to subdivision, unless the operator is called with
that property set to a different value.
This behavior can be disabled using the ``SKIP_SAVE`` option when the property is declared (see: :mod:`bpy.props`).
The ``ghost`` argument allows detecting how a value from a previous execution is handled.
- When true: The property is considered unset even if the value from a previous call is used.
- When false: The existence of any values causes ``is_property_set`` to return true.
While this argument should typically be omitted, there are times when
it's important to know if a value is anything besides the default.
For example, the previous value may have been scaled by the scene's unit scale.
In this case scaling the value multiple times would cause problems, so the ``ghost`` argument should be false.
"""

View File

@@ -551,7 +551,7 @@ def example_extract_docstring(filepath):
file.close() file.close()
return "", 0 return "", 0
for line in file: for line in file.readlines():
line_no += 1 line_no += 1
if line.startswith('"""'): if line.startswith('"""'):
break break
@@ -559,13 +559,6 @@ def example_extract_docstring(filepath):
text.append(line.rstrip()) text.append(line.rstrip())
line_no += 1 line_no += 1
# Skip over blank lines so the Python code doesn't have blank lines at the top.
for line in file:
if line.strip():
break
line_no += 1
file.close() file.close()
return "\n".join(text), line_no return "\n".join(text), line_no
@@ -2195,20 +2188,9 @@ def setup_blender():
# Remove handlers since the functions get included # Remove handlers since the functions get included
# in the doc-string and don't have meaningful names. # in the doc-string and don't have meaningful names.
lists_to_restore = [] for ls in bpy.app.handlers:
for var in bpy.app.handlers: if isinstance(ls, list):
if isinstance(var, list): ls.clear()
lists_to_restore.append((var[:], var))
var.clear()
return {
"lists_to_restore": lists_to_restore,
}
def teardown_blender(setup_data):
for var_src, var_dst in setup_data["lists_to_restore"]:
var_dst[:] = var_src
def main(): def main():
@@ -2217,7 +2199,7 @@ def main():
setup_monkey_patch() setup_monkey_patch()
# Perform changes to Blender it's self. # Perform changes to Blender it's self.
setup_data = setup_blender() setup_blender()
# eventually, create the dirs # eventually, create the dirs
for dir_path in [ARGS.output_dir, SPHINX_IN]: for dir_path in [ARGS.output_dir, SPHINX_IN]:
@@ -2323,8 +2305,6 @@ def main():
shutil.copy(os.path.join(SPHINX_OUT_PDF, "contents.pdf"), shutil.copy(os.path.join(SPHINX_OUT_PDF, "contents.pdf"),
os.path.join(REFERENCE_PATH, BLENDER_PDF_FILENAME)) os.path.join(REFERENCE_PATH, BLENDER_PDF_FILENAME))
teardown_blender(setup_data)
sys.exit() sys.exit()

4
extern/README vendored
View File

@@ -1,4 +0,0 @@
When updating a library remember to:
* Update the README.blender with the corresponding version.
* Update the THIRD-PARTY-LICENSE.txt document

View File

@@ -1,5 +0,0 @@
Project: Audaspace
URL: https://audaspace.github.io/
License: Apache 2.0
Upstream version: 1.3 (Last Release)
Local modifications: None

View File

@@ -24,6 +24,6 @@ set(JACK_FOUND ${WITH_JACK})
set(LIBSNDFILE_FOUND ${WITH_CODEC_SNDFILE}) set(LIBSNDFILE_FOUND ${WITH_CODEC_SNDFILE})
set(OPENAL_FOUND ${WITH_OPENAL}) set(OPENAL_FOUND ${WITH_OPENAL})
set(PYTHONLIBS_FOUND TRUE) set(PYTHONLIBS_FOUND TRUE)
set(NUMPY_FOUND ${WITH_PYTHON_NUMPY}) set(NUMPY_FOUND TRUE)
set(NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_INCLUDE_DIRS}) set(NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_INCLUDE_DIRS})
set(SDL_FOUND ${WITH_SDL}) set(SDL_FOUND ${WITH_SDL})

View File

@@ -1,5 +0,0 @@
Project: Bullet Continuous Collision Detection and Physics Library
URL: http://bulletphysics.org
License: zlib
Upstream version: 3.07
Local modifications: Fixed inertia

View File

@@ -1,5 +1,4 @@
Project: Ceres Solver Project: Ceres Solver
URL: http://ceres-solver.org/ URL: http://ceres-solver.org/
License: BSD 3-Clause
Upstream version 2.0.0 Upstream version 2.0.0
Local modifications: None Local modifications: None

View File

@@ -1,5 +1,5 @@
Project: Curve-Fit-nD Project: Curve-Fit-nD
URL: https://github.com/ideasman42/curve-fit-nd URL: https://github.com/ideasman42/curve-fit-nd
License: BSD 3-Clause License: BSD 3-Clause
Upstream version: ddcd5bd (Last Release) Upstream version: Unknown (Last Release)
Local modifications: None Local modifications: None

View File

@@ -19,24 +19,20 @@
# ***** END GPL LICENSE BLOCK ***** # ***** END GPL LICENSE BLOCK *****
# Build Draco library. # Build Draco library.
add_subdirectory(draco) add_subdirectory(dracoenc)
# Build Draco-Blender bridging module. # Build blender-draco-exporter module.
set(SRC set(SRC
src/common.cpp src/draco-compressor.cpp
src/common.h src/draco-compressor.h
src/decoder.cpp
src/decoder.h
src/encoder.cpp
src/encoder.h
) )
set(INC set(INC
draco/src dracoenc/src
) )
set(LIB set(LIB
draco dracoenc
) )
add_library(extern_draco SHARED "${SRC}") add_library(extern_draco SHARED "${SRC}")

View File

@@ -1,5 +0,0 @@
Project: Draco
URL: https://google.github.io/draco/
License: Apache 2.0
Upstream version: 1.3.6
Local modifications: None

View File

@@ -1,10 +0,0 @@
#ifndef DRACO_FEATURES_H_
#define DRACO_FEATURES_H_
#define DRACO_MESH_COMPRESSION_SUPPORTED
#define DRACO_NORMAL_ENCODING_SUPPORTED
#define DRACO_STANDARD_EDGEBREAKER_SUPPORTED
#define DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED
#define DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED
#endif // DRACO_FEATURES_H_

View File

@@ -2,165 +2,103 @@ remove_strict_flags()
set(SRC set(SRC
src/draco/animation/keyframe_animation.cc src/draco/animation/keyframe_animation.cc
src/draco/animation/keyframe_animation.h
src/draco/animation/keyframe_animation_decoder.cc
src/draco/animation/keyframe_animation_decoder.h
src/draco/animation/keyframe_animation_encoder.cc src/draco/animation/keyframe_animation_encoder.cc
src/draco/animation/keyframe_animation_encoder.h src/draco/animation/keyframe_animation_encoder.h
src/draco/animation/keyframe_animation.h
src/draco/attributes/attribute_octahedron_transform.cc src/draco/attributes/attribute_octahedron_transform.cc
src/draco/attributes/attribute_octahedron_transform.h src/draco/attributes/attribute_octahedron_transform.h
src/draco/attributes/attribute_quantization_transform.cc src/draco/attributes/attribute_quantization_transform.cc
src/draco/attributes/attribute_quantization_transform.h src/draco/attributes/attribute_quantization_transform.h
src/draco/attributes/attribute_transform.cc src/draco/attributes/attribute_transform.cc
src/draco/attributes/attribute_transform.h
src/draco/attributes/attribute_transform_data.h src/draco/attributes/attribute_transform_data.h
src/draco/attributes/attribute_transform.h
src/draco/attributes/attribute_transform_type.h src/draco/attributes/attribute_transform_type.h
src/draco/attributes/geometry_attribute.cc src/draco/attributes/geometry_attribute.cc
src/draco/attributes/geometry_attribute.h src/draco/attributes/geometry_attribute.h
src/draco/attributes/geometry_indices.h src/draco/attributes/geometry_indices.h
src/draco/attributes/point_attribute.cc src/draco/attributes/point_attribute.cc
src/draco/attributes/point_attribute.h src/draco/attributes/point_attribute.h
src/draco/compression/attributes/attributes_decoder.cc
src/draco/compression/attributes/attributes_decoder.h
src/draco/compression/attributes/attributes_decoder_interface.h
src/draco/compression/attributes/attributes_encoder.cc src/draco/compression/attributes/attributes_encoder.cc
src/draco/compression/attributes/attributes_encoder.h src/draco/compression/attributes/attributes_encoder.h
src/draco/compression/attributes/kd_tree_attributes_decoder.cc
src/draco/compression/attributes/kd_tree_attributes_decoder.h
src/draco/compression/attributes/kd_tree_attributes_encoder.cc src/draco/compression/attributes/kd_tree_attributes_encoder.cc
src/draco/compression/attributes/kd_tree_attributes_encoder.h src/draco/compression/attributes/kd_tree_attributes_encoder.h
src/draco/compression/attributes/kd_tree_attributes_shared.h
src/draco/compression/attributes/linear_sequencer.h src/draco/compression/attributes/linear_sequencer.h
src/draco/compression/attributes/mesh_attribute_indices_encoding_data.h
src/draco/compression/attributes/normal_compression_utils.h
src/draco/compression/attributes/point_d_vector.h
src/draco/compression/attributes/points_sequencer.h src/draco/compression/attributes/points_sequencer.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h
src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.cc src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.cc
src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h
src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h
src/draco/compression/attributes/sequential_attribute_decoder.cc
src/draco/compression/attributes/sequential_attribute_decoder.h
src/draco/compression/attributes/sequential_attribute_decoders_controller.cc
src/draco/compression/attributes/sequential_attribute_decoders_controller.h
src/draco/compression/attributes/sequential_attribute_encoder.cc src/draco/compression/attributes/sequential_attribute_encoder.cc
src/draco/compression/attributes/sequential_attribute_encoder.h src/draco/compression/attributes/sequential_attribute_encoder.h
src/draco/compression/attributes/sequential_attribute_encoders_controller.cc src/draco/compression/attributes/sequential_attribute_encoders_controller.cc
src/draco/compression/attributes/sequential_attribute_encoders_controller.h src/draco/compression/attributes/sequential_attribute_encoders_controller.h
src/draco/compression/attributes/sequential_integer_attribute_decoder.cc
src/draco/compression/attributes/sequential_integer_attribute_decoder.h
src/draco/compression/attributes/sequential_integer_attribute_encoder.cc src/draco/compression/attributes/sequential_integer_attribute_encoder.cc
src/draco/compression/attributes/sequential_integer_attribute_encoder.h src/draco/compression/attributes/sequential_integer_attribute_encoder.h
src/draco/compression/attributes/sequential_normal_attribute_decoder.cc
src/draco/compression/attributes/sequential_normal_attribute_decoder.h
src/draco/compression/attributes/sequential_normal_attribute_encoder.cc src/draco/compression/attributes/sequential_normal_attribute_encoder.cc
src/draco/compression/attributes/sequential_normal_attribute_encoder.h src/draco/compression/attributes/sequential_normal_attribute_encoder.h
src/draco/compression/attributes/sequential_quantization_attribute_decoder.cc
src/draco/compression/attributes/sequential_quantization_attribute_decoder.h
src/draco/compression/attributes/sequential_quantization_attribute_encoder.cc src/draco/compression/attributes/sequential_quantization_attribute_encoder.cc
src/draco/compression/attributes/sequential_quantization_attribute_encoder.h src/draco/compression/attributes/sequential_quantization_attribute_encoder.h
src/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h src/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h
src/draco/compression/bit_coders/adaptive_rans_bit_decoder.cc
src/draco/compression/bit_coders/adaptive_rans_bit_decoder.h
src/draco/compression/bit_coders/adaptive_rans_bit_encoder.cc src/draco/compression/bit_coders/adaptive_rans_bit_encoder.cc
src/draco/compression/bit_coders/adaptive_rans_bit_encoder.h src/draco/compression/bit_coders/adaptive_rans_bit_encoder.h
src/draco/compression/bit_coders/direct_bit_decoder.cc
src/draco/compression/bit_coders/direct_bit_decoder.h
src/draco/compression/bit_coders/direct_bit_encoder.cc src/draco/compression/bit_coders/direct_bit_encoder.cc
src/draco/compression/bit_coders/direct_bit_encoder.h src/draco/compression/bit_coders/direct_bit_encoder.h
src/draco/compression/bit_coders/folded_integer_bit_decoder.h
src/draco/compression/bit_coders/folded_integer_bit_encoder.h src/draco/compression/bit_coders/folded_integer_bit_encoder.h
src/draco/compression/bit_coders/rans_bit_decoder.cc
src/draco/compression/bit_coders/rans_bit_decoder.h
src/draco/compression/bit_coders/rans_bit_encoder.cc src/draco/compression/bit_coders/rans_bit_encoder.cc
src/draco/compression/bit_coders/rans_bit_encoder.h src/draco/compression/bit_coders/rans_bit_encoder.h
src/draco/compression/bit_coders/symbol_bit_decoder.cc
src/draco/compression/bit_coders/symbol_bit_decoder.h
src/draco/compression/bit_coders/symbol_bit_encoder.cc src/draco/compression/bit_coders/symbol_bit_encoder.cc
src/draco/compression/bit_coders/symbol_bit_encoder.h src/draco/compression/bit_coders/symbol_bit_encoder.h
src/draco/compression/config/compression_shared.h src/draco/compression/config/compression_shared.h
src/draco/compression/config/decoder_options.h
src/draco/compression/config/draco_options.h src/draco/compression/config/draco_options.h
src/draco/compression/config/encoder_options.h src/draco/compression/config/encoder_options.h
src/draco/compression/config/encoding_features.h src/draco/compression/config/encoding_features.h
src/draco/compression/decode.cc src/draco/compression/encode_base.h
src/draco/compression/decode.h
src/draco/compression/encode.cc src/draco/compression/encode.cc
src/draco/compression/encode.h src/draco/compression/encode.h
src/draco/compression/encode_base.h
src/draco/compression/entropy/ans.h src/draco/compression/entropy/ans.h
src/draco/compression/entropy/rans_symbol_coding.h src/draco/compression/entropy/rans_symbol_coding.h
src/draco/compression/entropy/rans_symbol_decoder.h
src/draco/compression/entropy/rans_symbol_encoder.h src/draco/compression/entropy/rans_symbol_encoder.h
src/draco/compression/entropy/shannon_entropy.cc src/draco/compression/entropy/shannon_entropy.cc
src/draco/compression/entropy/shannon_entropy.h src/draco/compression/entropy/shannon_entropy.h
src/draco/compression/entropy/symbol_decoding.cc
src/draco/compression/entropy/symbol_decoding.h
src/draco/compression/entropy/symbol_encoding.cc src/draco/compression/entropy/symbol_encoding.cc
src/draco/compression/entropy/symbol_encoding.h src/draco/compression/entropy/symbol_encoding.h
src/draco/compression/expert_encode.cc src/draco/compression/expert_encode.cc
src/draco/compression/expert_encode.h src/draco/compression/expert_encode.h
src/draco/compression/mesh/mesh_decoder.cc
src/draco/compression/mesh/mesh_decoder.h
src/draco/compression/mesh/mesh_edgebreaker_decoder.cc
src/draco/compression/mesh/mesh_edgebreaker_decoder.h
src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.cc
src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h
src/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h
src/draco/compression/mesh/mesh_edgebreaker_encoder.cc src/draco/compression/mesh/mesh_edgebreaker_encoder.cc
src/draco/compression/mesh/mesh_edgebreaker_encoder.h src/draco/compression/mesh/mesh_edgebreaker_encoder.h
src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.cc
src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h src/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h
src/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h src/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h
src/draco/compression/mesh/mesh_edgebreaker_shared.h src/draco/compression/mesh/mesh_edgebreaker_shared.h
src/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h
src/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h src/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h
src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h
src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h src/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h
src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h
src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h
src/draco/compression/mesh/mesh_encoder.cc src/draco/compression/mesh/mesh_encoder.cc
src/draco/compression/mesh/mesh_encoder.h src/draco/compression/mesh/mesh_encoder.h
src/draco/compression/mesh/mesh_sequential_decoder.cc src/draco/compression/mesh/mesh_encoder_helpers.h
src/draco/compression/mesh/mesh_sequential_decoder.h
src/draco/compression/mesh/mesh_sequential_encoder.cc src/draco/compression/mesh/mesh_sequential_encoder.cc
src/draco/compression/mesh/mesh_sequential_encoder.h src/draco/compression/mesh/mesh_sequential_encoder.h
src/draco/compression/mesh/traverser/depth_first_traverser.h src/draco/compression/mesh/traverser/depth_first_traverser.h
@@ -168,32 +106,18 @@ set(SRC
src/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h src/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h
src/draco/compression/mesh/traverser/mesh_traversal_sequencer.h src/draco/compression/mesh/traverser/mesh_traversal_sequencer.h
src/draco/compression/mesh/traverser/traverser_base.h src/draco/compression/mesh/traverser/traverser_base.h
src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.cc
src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h
src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.cc src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.cc
src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h
src/draco/compression/point_cloud/algorithms/float_points_tree_decoder.cc
src/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h
src/draco/compression/point_cloud/algorithms/float_points_tree_encoder.cc src/draco/compression/point_cloud/algorithms/float_points_tree_encoder.cc
src/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h src/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h
src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.cc
src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h
src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_encoder.cc
src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_encoder.h
src/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h src/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h
src/draco/compression/point_cloud/algorithms/point_cloud_types.h src/draco/compression/point_cloud/algorithms/point_cloud_types.h
src/draco/compression/point_cloud/algorithms/quantize_points_3.h src/draco/compression/point_cloud/algorithms/quantize_points_3.h
src/draco/compression/point_cloud/algorithms/queuing_policy.h src/draco/compression/point_cloud/algorithms/queuing_policy.h
src/draco/compression/point_cloud/point_cloud_decoder.cc
src/draco/compression/point_cloud/point_cloud_decoder.h
src/draco/compression/point_cloud/point_cloud_encoder.cc src/draco/compression/point_cloud/point_cloud_encoder.cc
src/draco/compression/point_cloud/point_cloud_encoder.h src/draco/compression/point_cloud/point_cloud_encoder.h
src/draco/compression/point_cloud/point_cloud_kd_tree_decoder.cc
src/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h
src/draco/compression/point_cloud/point_cloud_kd_tree_encoder.cc src/draco/compression/point_cloud/point_cloud_kd_tree_encoder.cc
src/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h src/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h
src/draco/compression/point_cloud/point_cloud_sequential_decoder.cc
src/draco/compression/point_cloud/point_cloud_sequential_decoder.h
src/draco/compression/point_cloud/point_cloud_sequential_encoder.cc src/draco/compression/point_cloud/point_cloud_sequential_encoder.cc
src/draco/compression/point_cloud/point_cloud_sequential_encoder.h src/draco/compression/point_cloud/point_cloud_sequential_encoder.h
src/draco/core/bit_utils.cc src/draco/core/bit_utils.cc
@@ -204,15 +128,12 @@ set(SRC
src/draco/core/cycle_timer.h src/draco/core/cycle_timer.h
src/draco/core/data_buffer.cc src/draco/core/data_buffer.cc
src/draco/core/data_buffer.h src/draco/core/data_buffer.h
src/draco/core/decoder_buffer.cc
src/draco/core/decoder_buffer.h
src/draco/core/divide.cc src/draco/core/divide.cc
src/draco/core/divide.h src/draco/core/divide.h
src/draco/core/draco_index_type.h src/draco/core/draco_index_type.h
src/draco/core/draco_index_type_vector.h src/draco/core/draco_index_type_vector.h
src/draco/core/draco_types.cc src/draco/core/draco_types.cc
src/draco/core/draco_types.h src/draco/core/draco_types.h
src/draco/core/draco_version.h
src/draco/core/encoder_buffer.cc src/draco/core/encoder_buffer.cc
src/draco/core/encoder_buffer.h src/draco/core/encoder_buffer.h
src/draco/core/hash_utils.cc src/draco/core/hash_utils.cc
@@ -224,21 +145,20 @@ set(SRC
src/draco/core/quantization_utils.cc src/draco/core/quantization_utils.cc
src/draco/core/quantization_utils.h src/draco/core/quantization_utils.h
src/draco/core/status.h src/draco/core/status.h
src/draco/core/status_or.h src/draco/core/statusor.h
src/draco/core/varint_decoding.h
src/draco/core/varint_encoding.h src/draco/core/varint_encoding.h
src/draco/core/vector_d.h src/draco/core/vector_d.h
src/draco/mesh/corner_table.cc src/draco/mesh/corner_table.cc
src/draco/mesh/corner_table.h src/draco/mesh/corner_table.h
src/draco/mesh/corner_table_iterators.h src/draco/mesh/corner_table_iterators.h
src/draco/mesh/mesh.cc
src/draco/mesh/mesh.h
src/draco/mesh/mesh_are_equivalent.cc src/draco/mesh/mesh_are_equivalent.cc
src/draco/mesh/mesh_are_equivalent.h src/draco/mesh/mesh_are_equivalent.h
src/draco/mesh/mesh_attribute_corner_table.cc src/draco/mesh/mesh_attribute_corner_table.cc
src/draco/mesh/mesh_attribute_corner_table.h src/draco/mesh/mesh_attribute_corner_table.h
src/draco/mesh/mesh.cc
src/draco/mesh/mesh_cleanup.cc src/draco/mesh/mesh_cleanup.cc
src/draco/mesh/mesh_cleanup.h src/draco/mesh/mesh_cleanup.h
src/draco/mesh/mesh.h
src/draco/mesh/mesh_misc_functions.cc src/draco/mesh/mesh_misc_functions.cc
src/draco/mesh/mesh_misc_functions.h src/draco/mesh/mesh_misc_functions.h
src/draco/mesh/mesh_stripifier.cc src/draco/mesh/mesh_stripifier.cc
@@ -249,15 +169,13 @@ set(SRC
src/draco/metadata/geometry_metadata.cc src/draco/metadata/geometry_metadata.cc
src/draco/metadata/geometry_metadata.h src/draco/metadata/geometry_metadata.h
src/draco/metadata/metadata.cc src/draco/metadata/metadata.cc
src/draco/metadata/metadata.h
src/draco/metadata/metadata_decoder.cc
src/draco/metadata/metadata_decoder.h
src/draco/metadata/metadata_encoder.cc src/draco/metadata/metadata_encoder.cc
src/draco/metadata/metadata_encoder.h src/draco/metadata/metadata_encoder.h
src/draco/point_cloud/point_cloud.cc src/draco/metadata/metadata.h
src/draco/point_cloud/point_cloud.h
src/draco/point_cloud/point_cloud_builder.cc src/draco/point_cloud/point_cloud_builder.cc
src/draco/point_cloud/point_cloud_builder.h src/draco/point_cloud/point_cloud_builder.h
src/draco/point_cloud/point_cloud.cc
src/draco/point_cloud/point_cloud.h
) )
set(LIB set(LIB
@@ -267,4 +185,4 @@ set(INC
src src
) )
blender_add_lib(draco "${SRC}" "${INC}" "" "${LIB}") blender_add_lib(dracoenc "${SRC}" "${INC}" "" "${LIB}")

View File

@@ -0,0 +1,3 @@
@PACKAGE_INIT@
set_and_check(draco_INCLUDE_DIR "@PACKAGE_draco_include_install_dir@")
set_and_check(draco_LIBRARY_DIR "@PACKAGE_draco_lib_install_dir@")

View File

@@ -0,0 +1,58 @@
# Finddraco
#
# Locates draco and sets the following variables:
#
# draco_FOUND
# draco_INCLUDE_DIRS
# draco_LIBARY_DIRS
# draco_LIBRARIES
# draco_VERSION_STRING
#
# draco_FOUND is set to YES only when all other variables are successfully
# configured.
unset(draco_FOUND)
unset(draco_INCLUDE_DIRS)
unset(draco_LIBRARY_DIRS)
unset(draco_LIBRARIES)
unset(draco_VERSION_STRING)
mark_as_advanced(draco_FOUND)
mark_as_advanced(draco_INCLUDE_DIRS)
mark_as_advanced(draco_LIBRARY_DIRS)
mark_as_advanced(draco_LIBRARIES)
mark_as_advanced(draco_VERSION_STRING)
set(draco_version_file_no_prefix "draco/src/draco/core/draco_version.h")
# Set draco_INCLUDE_DIRS
find_path(draco_INCLUDE_DIRS NAMES "${draco_version_file_no_prefix}")
# Extract the version string from draco_version.h.
if (draco_INCLUDE_DIRS)
set(draco_version_file
"${draco_INCLUDE_DIRS}/draco/src/draco/core/draco_version.h")
file(STRINGS "${draco_version_file}" draco_version
REGEX "kdracoVersion")
list(GET draco_version 0 draco_version)
string(REPLACE "static const char kdracoVersion[] = " "" draco_version
"${draco_version}")
string(REPLACE ";" "" draco_version "${draco_version}")
string(REPLACE "\"" "" draco_version "${draco_version}")
set(draco_VERSION_STRING ${draco_version})
endif ()
# Find the library.
if (BUILD_SHARED_LIBS)
find_library(draco_LIBRARIES NAMES draco.dll libdraco.dylib libdraco.so)
else ()
find_library(draco_LIBRARIES NAMES draco.lib libdraco.a)
endif ()
# Store path to library.
get_filename_component(draco_LIBRARY_DIRS ${draco_LIBRARIES} DIRECTORY)
if (draco_INCLUDE_DIRS AND draco_LIBRARY_DIRS AND draco_LIBRARIES AND
draco_VERSION_STRING)
set(draco_FOUND YES)
endif ()

View File

@@ -0,0 +1,216 @@
if (NOT DRACO_CMAKE_COMPILER_FLAGS_CMAKE_)
set(DRACO_CMAKE_COMPILER_FLAGS_CMAKE_ 1)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include("${draco_root}/cmake/compiler_tests.cmake")
# Strings used to cache failed C/CXX flags.
set(DRACO_FAILED_C_FLAGS)
set(DRACO_FAILED_CXX_FLAGS)
# Checks C compiler for support of $c_flag. Adds $c_flag to $CMAKE_C_FLAGS when
# the compile test passes. Caches $c_flag in $DRACO_FAILED_C_FLAGS when the test
# fails.
macro (add_c_flag_if_supported c_flag)
unset(C_FLAG_FOUND CACHE)
string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND)
unset(C_FLAG_FAILED CACHE)
string(FIND "${DRACO_FAILED_C_FLAGS}" "${c_flag}" C_FLAG_FAILED)
if (${C_FLAG_FOUND} EQUAL -1 AND ${C_FLAG_FAILED} EQUAL -1)
unset(C_FLAG_SUPPORTED CACHE)
message("Checking C compiler flag support for: " ${c_flag})
check_c_compiler_flag("${c_flag}" C_FLAG_SUPPORTED)
if (${C_FLAG_SUPPORTED})
string(APPEND CMAKE_C_FLAGS " ${c_flag}" CACHE STRING "")
else ()
string(APPEND DRACO_FAILED_C_FLAGS " ${c_flag}" CACHE STRING
"" FORCE)
endif ()
endif ()
endmacro ()
# Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to
# $CMAKE_CXX_FLAGS when the compile test passes. Caches $c_flag in
# $DRACO_FAILED_CXX_FLAGS when the test fails.
macro (add_cxx_flag_if_supported cxx_flag)
unset(CXX_FLAG_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
unset(CXX_FLAG_FAILED CACHE)
string(FIND "${DRACO_FAILED_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FAILED)
if (${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1)
unset(CXX_FLAG_SUPPORTED CACHE)
message("Checking CXX compiler flag support for: " ${cxx_flag})
check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
if (${CXX_FLAG_SUPPORTED})
string(APPEND CMAKE_CXX_FLAGS " ${cxx_flag}" CACHE STRING "")
else()
string(APPEND DRACO_FAILED_CXX_FLAGS " ${cxx_flag}" CACHE
STRING "" FORCE)
endif ()
endif ()
endmacro ()
# Convenience method for adding a flag to both the C and C++ compiler command
# lines.
macro (add_compiler_flag_if_supported flag)
add_c_flag_if_supported(${flag})
add_cxx_flag_if_supported(${flag})
endmacro ()
# Checks C compiler for support of $c_flag and terminates generation when
# support is not present.
macro (require_c_flag c_flag update_c_flags)
unset(C_FLAG_FOUND CACHE)
string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND)
if (${C_FLAG_FOUND} EQUAL -1)
unset(HAVE_C_FLAG CACHE)
message("Checking C compiler flag support for: " ${c_flag})
check_c_compiler_flag("${c_flag}" HAVE_C_FLAG)
if (NOT ${HAVE_C_FLAG})
message(FATAL_ERROR
"${PROJECT_NAME} requires support for C flag: ${c_flag}.")
endif ()
if (${update_c_flags})
set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
endif ()
endif ()
endmacro ()
# Checks CXX compiler for support of $cxx_flag and terminates generation when
# support is not present.
macro (require_cxx_flag cxx_flag update_cxx_flags)
unset(CXX_FLAG_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
if (${CXX_FLAG_FOUND} EQUAL -1)
unset(HAVE_CXX_FLAG CACHE)
message("Checking CXX compiler flag support for: " ${cxx_flag})
check_cxx_compiler_flag("${cxx_flag}" HAVE_CXX_FLAG)
if (NOT ${HAVE_CXX_FLAG})
message(FATAL_ERROR
"${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
endif ()
if (${update_cxx_flags})
set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING ""
FORCE)
endif ()
endif ()
endmacro ()
# Checks for support of $flag by both the C and CXX compilers. Terminates
# generation when support is not present in both compilers.
macro (require_compiler_flag flag update_cmake_flags)
require_c_flag(${flag} ${update_cmake_flags})
require_cxx_flag(${flag} ${update_cmake_flags})
endmacro ()
# Checks only non-MSVC targets for support of $c_flag and terminates generation
# when support is not present.
macro (require_c_flag_nomsvc c_flag update_c_flags)
if (NOT MSVC)
require_c_flag(${c_flag} ${update_c_flags})
endif ()
endmacro ()
# Checks only non-MSVC targets for support of $cxx_flag and terminates
# generation when support is not present.
macro (require_cxx_flag_nomsvc cxx_flag update_cxx_flags)
if (NOT MSVC)
require_cxx_flag(${cxx_flag} ${update_cxx_flags})
endif ()
endmacro ()
# Checks only non-MSVC targets for support of $flag by both the C and CXX
# compilers. Terminates generation when support is not present in both
# compilers.
macro (require_compiler_flag_nomsvc flag update_cmake_flags)
require_c_flag_nomsvc(${flag} ${update_cmake_flags})
require_cxx_flag_nomsvc(${flag} ${update_cmake_flags})
endmacro ()
# Adds $flag to assembler command line.
macro (append_as_flag flag)
unset(AS_FLAG_FOUND CACHE)
string(FIND "${DRACO_AS_FLAGS}" "${flag}" AS_FLAG_FOUND)
if (${AS_FLAG_FOUND} EQUAL -1)
string(APPEND DRACO_AS_FLAGS " ${flag}")
endif ()
endmacro ()
# Adds $flag to the C compiler command line.
macro (append_c_flag flag)
unset(C_FLAG_FOUND CACHE)
string(FIND "${CMAKE_C_FLAGS}" "${flag}" C_FLAG_FOUND)
if (${C_FLAG_FOUND} EQUAL -1)
string(APPEND CMAKE_C_FLAGS " ${flag}")
endif ()
endmacro ()
# Adds $flag to the CXX compiler command line.
macro (append_cxx_flag flag)
unset(CXX_FLAG_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" CXX_FLAG_FOUND)
if (${CXX_FLAG_FOUND} EQUAL -1)
string(APPEND CMAKE_CXX_FLAGS " ${flag}")
endif ()
endmacro ()
# Adds $flag to the C and CXX compiler command lines.
macro (append_compiler_flag flag)
append_c_flag(${flag})
append_cxx_flag(${flag})
endmacro ()
# Adds $flag to the executable linker command line.
macro (append_exe_linker_flag flag)
unset(LINKER_FLAG_FOUND CACHE)
string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "${flag}" LINKER_FLAG_FOUND)
if (${LINKER_FLAG_FOUND} EQUAL -1)
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${flag}")
endif ()
endmacro ()
# Adds $flag to the link flags for $target.
function (append_link_flag_to_target target flags)
unset(target_link_flags)
get_target_property(target_link_flags ${target} LINK_FLAGS)
if (target_link_flags)
unset(link_flag_found)
string(FIND "${target_link_flags}" "${flags}" link_flag_found)
if (NOT ${link_flag_found} EQUAL -1)
return()
endif ()
string(APPEND target_link_flags " ${flags}")
else ()
set(target_link_flags "${flags}")
endif ()
set_target_properties(${target} PROPERTIES LINK_FLAGS ${target_link_flags})
endfunction ()
# Adds $flag to executable linker flags, and makes sure C/CXX builds still work.
macro (require_linker_flag flag)
append_exe_linker_flag(${flag})
unset(c_passed)
draco_check_c_compiles("LINKER_FLAG_C_TEST(${flag})" "" c_passed)
unset(cxx_passed)
draco_check_cxx_compiles("LINKER_FLAG_CXX_TEST(${flag})" "" cxx_passed)
if (NOT c_passed OR NOT cxx_passed)
message(FATAL_ERROR "Linker flag test for ${flag} failed.")
endif ()
endmacro ()
endif () # DRACO_CMAKE_COMPILER_FLAGS_CMAKE_

View File

@@ -0,0 +1,124 @@
if (NOT DRACO_CMAKE_COMPILER_TESTS_CMAKE_)
set(DRACO_CMAKE_COMPILER_TESTS_CMAKE_ 1)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
# The basic main() macro used in all compile tests.
set(DRACO_C_MAIN "\nint main(void) { return 0; }")
set(DRACO_CXX_MAIN "\nint main() { return 0; }")
# Strings containing the names of passed and failed tests.
set(DRACO_C_PASSED_TESTS)
set(DRACO_C_FAILED_TESTS)
set(DRACO_CXX_PASSED_TESTS)
set(DRACO_CXX_FAILED_TESTS)
macro(draco_push_var var new_value)
set(SAVED_${var} ${var})
set(${var} ${new_value})
endmacro ()
macro(draco_pop_var var)
set(var ${SAVED_${var}})
unset(SAVED_${var})
endmacro ()
# Confirms $test_source compiles and stores $test_name in one of
# $DRACO_C_PASSED_TESTS or $DRACO_C_FAILED_TESTS depending on out come. When the
# test passes $result_var is set to 1. When it fails $result_var is unset.
# The test is not run if the test name is found in either of the passed or
# failed test variables.
macro(draco_check_c_compiles test_name test_source result_var)
unset(C_TEST_PASSED CACHE)
unset(C_TEST_FAILED CACHE)
string(FIND "${DRACO_C_PASSED_TESTS}" "${test_name}" C_TEST_PASSED)
string(FIND "${DRACO_C_FAILED_TESTS}" "${test_name}" C_TEST_FAILED)
if (${C_TEST_PASSED} EQUAL -1 AND ${C_TEST_FAILED} EQUAL -1)
unset(C_TEST_COMPILED CACHE)
message("Running C compiler test: ${test_name}")
check_c_source_compiles("${test_source} ${DRACO_C_MAIN}" C_TEST_COMPILED)
set(${result_var} ${C_TEST_COMPILED})
if (${C_TEST_COMPILED})
string(APPEND DRACO_C_PASSED_TESTS " ${test_name}")
else ()
string(APPEND DRACO_C_FAILED_TESTS " ${test_name}")
message("C Compiler test ${test_name} failed.")
endif ()
elseif (NOT ${C_TEST_PASSED} EQUAL -1)
set(${result_var} 1)
else () # ${C_TEST_FAILED} NOT EQUAL -1
unset(${result_var})
endif ()
endmacro ()
# Confirms $test_source compiles and stores $test_name in one of
# $DRACO_CXX_PASSED_TESTS or $DRACO_CXX_FAILED_TESTS depending on out come. When
# the test passes $result_var is set to 1. When it fails $result_var is unset.
# The test is not run if the test name is found in either of the passed or
# failed test variables.
macro(draco_check_cxx_compiles test_name test_source result_var)
unset(CXX_TEST_PASSED CACHE)
unset(CXX_TEST_FAILED CACHE)
string(FIND "${DRACO_CXX_PASSED_TESTS}" "${test_name}" CXX_TEST_PASSED)
string(FIND "${DRACO_CXX_FAILED_TESTS}" "${test_name}" CXX_TEST_FAILED)
if (${CXX_TEST_PASSED} EQUAL -1 AND ${CXX_TEST_FAILED} EQUAL -1)
unset(CXX_TEST_COMPILED CACHE)
message("Running CXX compiler test: ${test_name}")
check_cxx_source_compiles("${test_source} ${DRACO_CXX_MAIN}"
CXX_TEST_COMPILED)
set(${result_var} ${CXX_TEST_COMPILED})
if (${CXX_TEST_COMPILED})
string(APPEND DRACO_CXX_PASSED_TESTS " ${test_name}")
else ()
string(APPEND DRACO_CXX_FAILED_TESTS " ${test_name}")
message("CXX Compiler test ${test_name} failed.")
endif ()
elseif (NOT ${CXX_TEST_PASSED} EQUAL -1)
set(${result_var} 1)
else () # ${CXX_TEST_FAILED} NOT EQUAL -1
unset(${result_var})
endif ()
endmacro ()
# Convenience macro that confirms $test_source compiles as C and C++.
# $result_var is set to 1 when both tests are successful, and 0 when one or both
# tests fail.
# Note: This macro is intended to be used to write to result variables that
# are expanded via configure_file(). $result_var is set to 1 or 0 to allow
# direct usage of the value in generated source files.
macro(draco_check_source_compiles test_name test_source result_var)
unset(C_PASSED)
unset(CXX_PASSED)
draco_check_c_compiles(${test_name} ${test_source} C_PASSED)
draco_check_cxx_compiles(${test_name} ${test_source} CXX_PASSED)
if (${C_PASSED} AND ${CXX_PASSED})
set(${result_var} 1)
else ()
set(${result_var} 0)
endif ()
endmacro ()
# When inline support is detected for the current compiler the supported
# inlining keyword is written to $result in caller scope.
macro (draco_get_inline result)
draco_check_source_compiles("inline_check_1"
"static inline void macro(void) {}"
HAVE_INLINE_1)
if (HAVE_INLINE_1 EQUAL 1)
set(${result} "inline")
return()
endif ()
# Check __inline.
draco_check_source_compiles("inline_check_2"
"static __inline void macro(void) {}"
HAVE_INLINE_2)
if (HAVE_INLINE_2 EQUAL 1)
set(${result} "__inline")
endif ()
endmacro ()
endif () # DRACO_CMAKE_COMPILER_TESTS_CMAKE_

View File

@@ -0,0 +1,57 @@
if (NOT DRACO_CMAKE_DRACO_FEATURES_CMAKE_)
set(DRACO_CMAKE_DRACO_FEATURES_CMAKE_ 1)
set(draco_features_file_name "${draco_build_dir}/draco/draco_features.h")
set(draco_features_list)
# Macro that handles tracking of Draco preprocessor symbols for the purpose of
# producing draco_features.h.
#
# draco_enable_feature(FEATURE <feature_name> [TARGETS <target_name>])
# FEATURE is required. It should be a Draco preprocessor symbol.
# TARGETS is optional. It can be one or more draco targets.
#
# When the TARGETS argument is not present the preproc symbol is added to
# draco_features.h. When it is draco_features.h is unchanged, and
# target_compile_options() is called for each target specified.
macro (draco_enable_feature)
set(def_flags)
set(def_single_arg_opts FEATURE)
set(def_multi_arg_opts TARGETS)
cmake_parse_arguments(DEF "${def_flags}" "${def_single_arg_opts}"
"${def_multi_arg_opts}" ${ARGN})
if ("${DEF_FEATURE}" STREQUAL "")
message(FATAL_ERROR "Empty FEATURE passed to draco_enable_feature().")
endif ()
# Do nothing/return early if $DEF_FEATURE is already in the list.
list(FIND draco_features_list ${DEF_FEATURE} df_index)
if (NOT df_index EQUAL -1)
return ()
endif ()
list(LENGTH DEF_TARGETS df_targets_list_length)
if (${df_targets_list_length} EQUAL 0)
list(APPEND draco_features_list ${DEF_FEATURE})
else ()
foreach (target ${DEF_TARGETS})
target_compile_definitions(${target} PRIVATE ${DEF_FEATURE})
endforeach ()
endif ()
endmacro ()
# Function for generating draco_features.h.
function (draco_generate_features_h)
file(WRITE "${draco_features_file_name}"
"// GENERATED FILE -- DO NOT EDIT\n\n"
"#ifndef DRACO_FEATURES_H_\n"
"#define DRACO_FEATURES_H_\n\n")
foreach (feature ${draco_features_list})
file(APPEND "${draco_features_file_name}" "#define ${feature}\n")
endforeach ()
file(APPEND "${draco_features_file_name}" "\n#endif // DRACO_FEATURES_H_")
endfunction ()
endif () # DRACO_CMAKE_DRACO_FEATURES_CMAKE_

View File

@@ -0,0 +1,13 @@
#ifndef DRACO_TESTING_DRACO_TEST_CONFIG_H_
#define DRACO_TESTING_DRACO_TEST_CONFIG_H_
// If this file is named draco_test_config.h.cmake:
// This file is used as input at cmake generation time.
// If this file is named draco_test_config.h:
// 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_

View File

@@ -0,0 +1,21 @@
// If this file is named draco_version.cc.cmake:
// This file is used as input at cmake generation time.
// If this file is named draco_version.cc:
// GENERATED FILE, DO NOT EDIT. SEE ABOVE.
#include "draco_version.h"
static const char kDracoGitHash[] = "${draco_git_hash}";
static const char kDracoGitDesc[] = "${draco_git_desc}";
const char *draco_git_hash() {
return kDracoGitHash;
}
const char *draco_git_version() {
return kDracoGitDesc;
}
const char* draco_version() {
return draco::Version();
}

View File

@@ -0,0 +1,21 @@
// If this file is named draco_version.h.cmake:
// This file is used as input at cmake generation time.
// If this file is named draco_version.h:
// GENERATED FILE, DO NOT EDIT. SEE ABOVE.
#ifndef DRACO_DRACO_VERSION_H_
#define DRACO_DRACO_VERSION_H_
#include "draco/core/draco_version.h"
// Returns git hash of Draco git repository.
const char *draco_git_hash();
// Returns the output of the git describe command when run from the Draco git
// repository.
const char *draco_git_version();
// Returns the version string from core/draco_version.h.
const char* draco_version();
#endif // DRACO_DRACO_VERSION_H_

View File

@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.2)
if (MSVC)
# Use statically linked versions of the MS standard libraries.
if (NOT "${MSVC_RUNTIME}" STREQUAL "dll")
foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif ()
endforeach ()
endif ()
endif ()

View File

@@ -0,0 +1,19 @@
if (NOT DRACO_CMAKE_SANITIZERS_CMAKE_)
set(DRACO_CMAKE_SANITIZERS_CMAKE_ 1)
if (MSVC OR NOT SANITIZE)
return ()
endif ()
include("${draco_root}/cmake/compiler_flags.cmake")
string(TOLOWER ${SANITIZE} SANITIZE)
# Require the sanitizer requested.
require_linker_flag("-fsanitize=${SANITIZE}")
require_compiler_flag("-fsanitize=${SANITIZE}" YES)
# Make callstacks accurate.
require_compiler_flag("-fno-omit-frame-pointer -fno-optimize-sibling-calls" YES)
endif() # DRACO_CMAKE_SANITIZERS_CMAKE_

View File

@@ -0,0 +1,13 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_)
set(DRACO_CMAKE_ARM_IOS_COMMON_CMAKE_ 1)
set(CMAKE_SYSTEM_NAME "Darwin")
set(CMAKE_OSX_SYSROOT iphoneos)
set(CMAKE_C_COMPILER clang)
set(CMAKE_C_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
# TODO(tomfinegan): Handle bit code embedding.
endif () # DRACO_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_

View File

@@ -0,0 +1,12 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_ 1)
include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake")
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
require_variable(CMAKE_ANDROID_NDK)
set_variable_if_unset(CMAKE_SYSTEM_VERSION 21)
set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static)
endif () # DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_

View File

@@ -0,0 +1,14 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_ 1)
if (XCODE)
# TODO(tomfinegan): Handle arm builds in Xcode.
message(FATAL_ERROR "This toolchain does not support Xcode.")
endif ()
set(CMAKE_SYSTEM_PROCESSOR "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64")
include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
endif () # DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_

View File

@@ -0,0 +1,18 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_NAME "Linux")
if ("${CROSS}" STREQUAL "")
# Default the cross compiler prefix to something known to work.
set(CROSS aarch64-linux-gnu-)
endif ()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(AS_EXECUTABLE ${CROSS}as)
set(CMAKE_C_COMPILER_ARG1 "-march=armv8-a")
set(CMAKE_CXX_COMPILER_ARG1 "-march=armv8-a")
set(CMAKE_SYSTEM_PROCESSOR "arm64")
endif () # DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_

View File

@@ -0,0 +1,12 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_ 1)
include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake")
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
require_variable(CMAKE_ANDROID_NDK)
set_variable_if_unset(CMAKE_SYSTEM_VERSION 18)
set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static)
endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_

View File

@@ -0,0 +1,14 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_ 1)
if (XCODE)
# TODO(tomfinegan): Handle arm builds in Xcode.
message(FATAL_ERROR "This toolchain does not support Xcode.")
endif ()
set(CMAKE_SYSTEM_PROCESSOR "armv7")
set(CMAKE_OSX_ARCHITECTURES "armv7")
include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_

View File

@@ -0,0 +1,24 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_NAME "Linux")
if ("${CROSS}" STREQUAL "")
# Default the cross compiler prefix to something known to work.
set(CROSS arm-linux-gnueabihf-)
endif ()
if (NOT ${CROSS} MATCHES hf-$)
set(DRACO_EXTRA_TOOLCHAIN_FLAGS "-mfloat-abi=softfp")
endif ()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(AS_EXECUTABLE ${CROSS}as)
set(CMAKE_C_COMPILER_ARG1
"-march=armv7-a -mfpu=neon ${DRACO_EXTRA_TOOLCHAIN_FLAGS}")
set(CMAKE_CXX_COMPILER_ARG1
"-march=armv7-a -mfpu=neon ${DRACO_EXTRA_TOOLCHAIN_FLAGS}")
set(CMAKE_SYSTEM_PROCESSOR "armv7")
endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_

View File

@@ -0,0 +1,14 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_ 1)
if (XCODE)
# TODO(tomfinegan): Handle arm builds in Xcode.
message(FATAL_ERROR "This toolchain does not support Xcode.")
endif ()
set(CMAKE_SYSTEM_PROCESSOR "armv7s")
set(CMAKE_OSX_ARCHITECTURES "armv7s")
include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_

View File

@@ -0,0 +1,12 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_ 1)
include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake")
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI x86)
require_variable(CMAKE_ANDROID_NDK)
set_variable_if_unset(CMAKE_SYSTEM_VERSION 18)
set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static)
endif () # DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_

View File

@@ -0,0 +1,12 @@
if (NOT DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_)
set(DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_ 1)
include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake")
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI x86_64)
require_variable(CMAKE_ANDROID_NDK)
set_variable_if_unset(CMAKE_SYSTEM_VERSION 21)
set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static)
endif () # DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_

73
extern/draco/dracoenc/cmake/util.cmake vendored Normal file
View File

@@ -0,0 +1,73 @@
if (NOT DRACO_CMAKE_UTIL_CMAKE_)
set(DRACO_CMAKE_UTIL_CMAKE_ 1)
# Creates dummy source file in $draco_build_dir named $basename.$extension and
# returns the full path to the dummy source file via the $out_file_path
# parameter.
function (create_dummy_source_file basename extension out_file_path)
set(dummy_source_file "${draco_build_dir}/${basename}.${extension}")
file(WRITE "${dummy_source_file}"
"// Generated file. DO NOT EDIT!\n"
"// ${target_name} needs a ${extension} file to force link language, \n"
"// or to silence a harmless CMake warning: Ignore me.\n"
"void ${target_name}_dummy_function(void) {}\n")
set(${out_file_path} ${dummy_source_file} PARENT_SCOPE)
endfunction ()
# Convenience function for adding a dummy source file to $target_name using
# $extension as the file extension. Wraps create_dummy_source_file().
function (add_dummy_source_file_to_target target_name extension)
create_dummy_source_file("${target_name}" "${extension}" "dummy_source_file")
target_sources(${target_name} PRIVATE ${dummy_source_file})
endfunction ()
# Extracts the version number from $version_file and returns it to the user via
# $version_string_out_var. This is achieved by finding the first instance of
# the kDracoVersion variable and then removing everything but the string literal
# assigned to the variable. Quotes and semicolon are stripped from the returned
# string.
function (extract_version_string version_file version_string_out_var)
file(STRINGS "${version_file}" draco_version REGEX "kDracoVersion")
list(GET draco_version 0 draco_version)
string(REPLACE "static const char kDracoVersion[] = " "" draco_version
"${draco_version}")
string(REPLACE ";" "" draco_version "${draco_version}")
string(REPLACE "\"" "" draco_version "${draco_version}")
set("${version_string_out_var}" "${draco_version}" PARENT_SCOPE)
endfunction ()
# Sets CMake compiler launcher to $launcher_name when $launcher_name is found in
# $PATH. Warns user about ignoring build flag $launcher_flag when $launcher_name
# is not found in $PATH.
function (set_compiler_launcher launcher_flag launcher_name)
find_program(launcher_path "${launcher_name}")
if (launcher_path)
set(CMAKE_C_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE)
set(CMAKE_CXX_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE)
message("--- Using ${launcher_name} as compiler launcher.")
else ()
message(WARNING
"--- Cannot find ${launcher_name}, ${launcher_flag} ignored.")
endif ()
endfunction ()
# Terminates CMake execution when $var_name is unset in the environment. Sets
# CMake variable to the value of the environment variable when the variable is
# present in the environment.
macro(require_variable var_name)
if ("$ENV{${var_name}}" STREQUAL "")
message(FATAL_ERROR "${var_name} must be set in environment.")
endif ()
set_variable_if_unset(${var_name} "")
endmacro ()
# Sets $var_name to $default_value if not already set in the environment.
macro (set_variable_if_unset var_name default_value)
if (NOT "$ENV{${var_name}}" STREQUAL "")
set(${var_name} $ENV{${var_name}})
else ()
set(${var_name} ${default_value})
endif ()
endmacro ()
endif() # DRACO_CMAKE_UTIL_CMAKE_

View File

@@ -29,9 +29,8 @@ bool KeyframeAnimation::SetTimestamps(
} else { } else {
// Check if the number of frames is consistent with // Check if the number of frames is consistent with
// the existing keyframes. // the existing keyframes.
if (num_frames != num_points()) { if (num_frames != num_points())
return false; return false;
}
} }
} else { } else {
// This is the first attribute. // This is the first attribute.
@@ -41,8 +40,10 @@ bool KeyframeAnimation::SetTimestamps(
// Add attribute for time stamp data. // Add attribute for time stamp data.
std::unique_ptr<PointAttribute> timestamp_att = std::unique_ptr<PointAttribute> timestamp_att =
std::unique_ptr<PointAttribute>(new PointAttribute()); std::unique_ptr<PointAttribute>(new PointAttribute());
timestamp_att->Init(GeometryAttribute::GENERIC, 1, DT_FLOAT32, false, timestamp_att->Init(GeometryAttribute::GENERIC, nullptr, 1, DT_FLOAT32, false,
num_frames); sizeof(float), 0);
timestamp_att->SetIdentityMapping();
timestamp_att->Reset(num_frames);
for (PointIndex i(0); i < num_frames; ++i) { for (PointIndex i(0); i < num_frames; ++i) {
timestamp_att->SetAttributeValue(timestamp_att->mapped_index(i), timestamp_att->SetAttributeValue(timestamp_att->mapped_index(i),
&timestamp[i.value()]); &timestamp[i.value()]);

View File

@@ -71,29 +71,30 @@ int32_t KeyframeAnimation::AddKeyframes(DataType data_type,
uint32_t num_components, uint32_t num_components,
const std::vector<T> &data) { const std::vector<T> &data) {
// TODO(draco-eng): Verify T is consistent with |data_type|. // TODO(draco-eng): Verify T is consistent with |data_type|.
if (num_components == 0) { if (num_components == 0)
return -1; return -1;
}
// If timestamps is not added yet, then reserve attribute 0 for timestamps. // If timestamps is not added yet, then reserve attribute 0 for timestamps.
if (!num_attributes()) { if (!num_attributes()) {
// Add a temporary attribute with 0 points to fill attribute id 0. // Add a temporary attribute with 0 points to fill attribute id 0.
std::unique_ptr<PointAttribute> temp_att = std::unique_ptr<PointAttribute> temp_att =
std::unique_ptr<PointAttribute>(new PointAttribute()); std::unique_ptr<PointAttribute>(new PointAttribute());
temp_att->Init(GeometryAttribute::GENERIC, num_components, data_type, false, temp_att->Init(GeometryAttribute::GENERIC, nullptr, num_components,
0); data_type, false, DataTypeLength(data_type), 0);
temp_att->Reset(0);
this->AddAttribute(std::move(temp_att)); this->AddAttribute(std::move(temp_att));
set_num_frames(data.size() / num_components); set_num_frames(data.size() / num_components);
} }
if (data.size() != num_components * num_frames()) { if (data.size() != num_components * num_frames())
return -1; return -1;
}
std::unique_ptr<PointAttribute> keyframe_att = std::unique_ptr<PointAttribute> keyframe_att =
std::unique_ptr<PointAttribute>(new PointAttribute()); std::unique_ptr<PointAttribute>(new PointAttribute());
keyframe_att->Init(GeometryAttribute::GENERIC, num_components, data_type, keyframe_att->Init(GeometryAttribute::GENERIC, nullptr, num_components,
false, num_frames()); data_type, false, DataTypeLength(data_type), 0);
keyframe_att->SetIdentityMapping();
keyframe_att->Reset(num_frames());
const size_t stride = num_components; const size_t stride = num_components;
for (PointIndex i(0); i < num_frames(); ++i) { for (PointIndex i(0); i < num_frames(); ++i) {
keyframe_att->SetAttributeValue(keyframe_att->mapped_index(i), keyframe_att->SetAttributeValue(keyframe_att->mapped_index(i),

View File

@@ -21,9 +21,8 @@ Status KeyframeAnimationDecoder::Decode(const DecoderOptions &options,
KeyframeAnimation *animation) { KeyframeAnimation *animation) {
const auto status = PointCloudSequentialDecoder::Decode( const auto status = PointCloudSequentialDecoder::Decode(
options, in_buffer, static_cast<PointCloud *>(animation)); options, in_buffer, static_cast<PointCloud *>(animation));
if (!status.ok()) { if (!status.ok())
return status; return status;
}
return OkStatus(); return OkStatus();
} }

View File

@@ -0,0 +1,168 @@
// Copyright 2017 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "draco/animation/keyframe_animation.h"
#include "draco/animation/keyframe_animation_decoder.h"
#include "draco/animation/keyframe_animation_encoder.h"
#include "draco/core/draco_test_base.h"
#include "draco/core/draco_test_utils.h"
namespace draco {
class KeyframeAnimationEncodingTest : public ::testing::Test {
protected:
KeyframeAnimationEncodingTest() {}
bool CreateAndAddTimestamps(int32_t num_frames) {
timestamps_.resize(num_frames);
for (int i = 0; i < timestamps_.size(); ++i)
timestamps_[i] = static_cast<draco::KeyframeAnimation::TimestampType>(i);
return keyframe_animation_.SetTimestamps(timestamps_);
}
int32_t CreateAndAddAnimationData(int32_t num_frames,
uint32_t num_components) {
// Create and add animation data with.
animation_data_.resize(num_frames * num_components);
for (int i = 0; i < animation_data_.size(); ++i)
animation_data_[i] = static_cast<float>(i);
return keyframe_animation_.AddKeyframes(draco::DT_FLOAT32, num_components,
animation_data_);
}
template <int num_components_t>
void CompareAnimationData(const KeyframeAnimation &animation0,
const KeyframeAnimation &animation1,
bool quantized) {
ASSERT_EQ(animation0.num_frames(), animation1.num_frames());
ASSERT_EQ(animation0.num_animations(), animation1.num_animations());
if (quantized) {
// TODO(hemmer) : Add test for stable quantization.
// Quantization will result in slightly different values.
// Skip comparing values.
return;
}
// Compare time stamp.
const auto timestamp_att0 = animation0.timestamps();
const auto timestamp_att1 = animation0.timestamps();
for (int i = 0; i < animation0.num_frames(); ++i) {
std::array<float, 1> att_value0;
std::array<float, 1> att_value1;
ASSERT_TRUE((timestamp_att0->GetValue<float, 1>(
draco::AttributeValueIndex(i), &att_value0)));
ASSERT_TRUE((timestamp_att1->GetValue<float, 1>(
draco::AttributeValueIndex(i), &att_value1)));
ASSERT_FLOAT_EQ(att_value0[0], att_value1[0]);
}
for (int animation_id = 1; animation_id < animation0.num_animations();
++animation_id) {
// Compare keyframe data.
const auto keyframe_att0 = animation0.keyframes(animation_id);
const auto keyframe_att1 = animation1.keyframes(animation_id);
ASSERT_EQ(keyframe_att0->num_components(),
keyframe_att1->num_components());
for (int i = 0; i < animation0.num_frames(); ++i) {
std::array<float, num_components_t> att_value0;
std::array<float, num_components_t> att_value1;
ASSERT_TRUE((keyframe_att0->GetValue<float, num_components_t>(
draco::AttributeValueIndex(i), &att_value0)));
ASSERT_TRUE((keyframe_att1->GetValue<float, num_components_t>(
draco::AttributeValueIndex(i), &att_value1)));
for (int j = 0; j < att_value0.size(); ++j) {
ASSERT_FLOAT_EQ(att_value0[j], att_value1[j]);
}
}
}
}
template <int num_components_t>
void TestKeyframeAnimationEncoding() {
TestKeyframeAnimationEncoding<num_components_t>(false);
}
template <int num_components_t>
void TestKeyframeAnimationEncoding(bool quantized) {
// Encode animation class.
draco::EncoderBuffer buffer;
draco::KeyframeAnimationEncoder encoder;
EncoderOptions options = EncoderOptions::CreateDefaultOptions();
if (quantized) {
// Set quantization for timestamps.
options.SetAttributeInt(0, "quantization_bits", 20);
// Set quantization for keyframes.
for (int i = 1; i <= keyframe_animation_.num_animations(); ++i) {
options.SetAttributeInt(i, "quantization_bits", 20);
}
}
ASSERT_TRUE(
encoder.EncodeKeyframeAnimation(keyframe_animation_, options, &buffer)
.ok());
draco::DecoderBuffer dec_decoder;
draco::KeyframeAnimationDecoder decoder;
DecoderBuffer dec_buffer;
dec_buffer.Init(buffer.data(), buffer.size());
// Decode animation class.
std::unique_ptr<KeyframeAnimation> decoded_animation(
new KeyframeAnimation());
DecoderOptions dec_options;
ASSERT_TRUE(
decoder.Decode(dec_options, &dec_buffer, decoded_animation.get()).ok());
// Verify if animation before and after compression is identical.
CompareAnimationData<num_components_t>(keyframe_animation_,
*decoded_animation, quantized);
}
draco::KeyframeAnimation keyframe_animation_;
std::vector<draco::KeyframeAnimation::TimestampType> timestamps_;
std::vector<float> animation_data_;
};
TEST_F(KeyframeAnimationEncodingTest, OneComponent) {
const int num_frames = 1;
ASSERT_TRUE(CreateAndAddTimestamps(num_frames));
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 1), 1);
TestKeyframeAnimationEncoding<1>();
}
TEST_F(KeyframeAnimationEncodingTest, ManyComponents) {
const int num_frames = 100;
ASSERT_TRUE(CreateAndAddTimestamps(num_frames));
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 100), 1);
TestKeyframeAnimationEncoding<100>();
}
TEST_F(KeyframeAnimationEncodingTest, ManyComponentsWithQuantization) {
const int num_frames = 100;
ASSERT_TRUE(CreateAndAddTimestamps(num_frames));
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 4), 1);
// Test compression with quantization.
TestKeyframeAnimationEncoding<4>(true);
}
TEST_F(KeyframeAnimationEncodingTest, MultipleAnimations) {
const int num_frames = 5;
ASSERT_TRUE(CreateAndAddTimestamps(num_frames));
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 3), 1);
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 3), 2);
TestKeyframeAnimationEncoding<3>();
}
} // namespace draco

View File

@@ -0,0 +1,102 @@
// Copyright 2017 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "draco/animation/keyframe_animation.h"
#include "draco/core/draco_test_base.h"
namespace {
class KeyframeAnimationTest : public ::testing::Test {
protected:
KeyframeAnimationTest() {}
bool CreateAndAddTimestamps(int32_t num_frames) {
timestamps_.resize(num_frames);
for (int i = 0; i < timestamps_.size(); ++i)
timestamps_[i] = static_cast<draco::KeyframeAnimation::TimestampType>(i);
return keyframe_animation_.SetTimestamps(timestamps_);
}
int32_t CreateAndAddAnimationData(int32_t num_frames,
uint32_t num_components) {
// Create and add animation data with.
animation_data_.resize(num_frames * num_components);
for (int i = 0; i < animation_data_.size(); ++i)
animation_data_[i] = static_cast<float>(i);
return keyframe_animation_.AddKeyframes(draco::DT_FLOAT32, num_components,
animation_data_);
}
template <int num_components_t>
void CompareAnimationData() {
// Compare time stamp.
const auto timestamp_att = keyframe_animation_.timestamps();
for (int i = 0; i < timestamps_.size(); ++i) {
std::array<float, 1> att_value;
ASSERT_TRUE((timestamp_att->GetValue<float, 1>(
draco::AttributeValueIndex(i), &att_value)));
ASSERT_FLOAT_EQ(att_value[0], i);
}
// Compare keyframe data.
const auto keyframe_att = keyframe_animation_.keyframes(1);
for (int i = 0; i < animation_data_.size() / num_components_t; ++i) {
std::array<float, num_components_t> att_value;
ASSERT_TRUE((keyframe_att->GetValue<float, num_components_t>(
draco::AttributeValueIndex(i), &att_value)));
for (int j = 0; j < num_components_t; ++j) {
ASSERT_FLOAT_EQ(att_value[j], i * num_components_t + j);
}
}
}
template <int num_components_t>
void TestKeyframeAnimation(int32_t num_frames) {
ASSERT_TRUE(CreateAndAddTimestamps(num_frames));
ASSERT_EQ(CreateAndAddAnimationData(num_frames, num_components_t), 1);
CompareAnimationData<num_components_t>();
}
draco::KeyframeAnimation keyframe_animation_;
std::vector<draco::KeyframeAnimation::TimestampType> timestamps_;
std::vector<float> animation_data_;
};
// Test animation with 1 component and 10 frames.
TEST_F(KeyframeAnimationTest, OneComponent) { TestKeyframeAnimation<1>(10); }
// Test animation with 4 component and 10 frames.
TEST_F(KeyframeAnimationTest, FourComponent) { TestKeyframeAnimation<4>(10); }
// Test adding animation data before timestamp.
TEST_F(KeyframeAnimationTest, AddingAnimationFirst) {
ASSERT_EQ(CreateAndAddAnimationData(5, 1), 1);
ASSERT_TRUE(CreateAndAddTimestamps(5));
}
// Test adding timestamp more than once.
TEST_F(KeyframeAnimationTest, ErrorAddingTimestampsTwice) {
ASSERT_TRUE(CreateAndAddTimestamps(5));
ASSERT_FALSE(CreateAndAddTimestamps(5));
}
// Test animation with multiple animation data.
TEST_F(KeyframeAnimationTest, MultipleAnimationData) {
const int num_frames = 5;
ASSERT_TRUE(CreateAndAddTimestamps(num_frames));
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 1), 1);
ASSERT_EQ(CreateAndAddAnimationData(num_frames, 2), 2);
}
} // namespace

View File

@@ -25,9 +25,8 @@ bool AttributeOctahedronTransform::InitFromAttribute(
const AttributeTransformData *const transform_data = const AttributeTransformData *const transform_data =
attribute.GetAttributeTransformData(); attribute.GetAttributeTransformData();
if (!transform_data || if (!transform_data ||
transform_data->transform_type() != ATTRIBUTE_OCTAHEDRON_TRANSFORM) { transform_data->transform_type() != ATTRIBUTE_OCTAHEDRON_TRANSFORM)
return false; // Wrong transform type. return false; // Wrong transform type.
}
quantization_bits_ = transform_data->GetParameterValue<int32_t>(0); quantization_bits_ = transform_data->GetParameterValue<int32_t>(0);
return true; return true;
} }
@@ -69,9 +68,8 @@ AttributeOctahedronTransform::GeneratePortableAttribute(
float att_val[3]; float att_val[3];
int32_t dst_index = 0; int32_t dst_index = 0;
OctahedronToolBox converter; OctahedronToolBox converter;
if (!converter.SetQuantizationBits(quantization_bits_)) { if (!converter.SetQuantizationBits(quantization_bits_))
return nullptr; return nullptr;
}
for (uint32_t i = 0; i < point_ids.size(); ++i) { for (uint32_t i = 0; i < point_ids.size(); ++i) {
const AttributeValueIndex att_val_id = attribute.mapped_index(point_ids[i]); const AttributeValueIndex att_val_id = attribute.mapped_index(point_ids[i]);
attribute.GetValue(att_val_id, att_val); attribute.GetValue(att_val_id, att_val);

View File

@@ -25,9 +25,8 @@ bool AttributeQuantizationTransform::InitFromAttribute(
const AttributeTransformData *const transform_data = const AttributeTransformData *const transform_data =
attribute.GetAttributeTransformData(); attribute.GetAttributeTransformData();
if (!transform_data || if (!transform_data ||
transform_data->transform_type() != ATTRIBUTE_QUANTIZATION_TRANSFORM) { transform_data->transform_type() != ATTRIBUTE_QUANTIZATION_TRANSFORM)
return false; // Wrong transform type. return false; // Wrong transform type.
}
int32_t byte_offset = 0; int32_t byte_offset = 0;
quantization_bits_ = transform_data->GetParameterValue<int32_t>(byte_offset); quantization_bits_ = transform_data->GetParameterValue<int32_t>(byte_offset);
byte_offset += 4; byte_offset += 4;
@@ -81,30 +80,22 @@ bool AttributeQuantizationTransform::ComputeParameters(
++i) { ++i) {
attribute.GetValue(i, att_val.get()); attribute.GetValue(i, att_val.get());
for (int c = 0; c < num_components; ++c) { for (int c = 0; c < num_components; ++c) {
if (min_values_[c] > att_val[c]) { if (min_values_[c] > att_val[c])
min_values_[c] = att_val[c]; min_values_[c] = att_val[c];
} if (max_values[c] < att_val[c])
if (max_values[c] < att_val[c]) {
max_values[c] = att_val[c]; max_values[c] = att_val[c];
}
} }
} }
for (int c = 0; c < num_components; ++c) { for (int c = 0; c < num_components; ++c) {
if (std::isnan(min_values_[c]) || std::isinf(min_values_[c]) ||
std::isnan(max_values[c]) || std::isinf(max_values[c])) {
return false;
}
const float dif = max_values[c] - min_values_[c]; const float dif = max_values[c] - min_values_[c];
if (dif > range_) { if (dif > range_)
range_ = dif; range_ = dif;
}
} }
// In case all values are the same, initialize the range to unit length. This // In case all values are the same, initialize the range to unit length. This
// will ensure that all values are quantized properly to the same value. // will ensure that all values are quantized properly to the same value.
if (range_ == 0.f) { if (range_ == 0.f)
range_ = 1.f; range_ = 1.f;
}
return true; return true;
} }

View File

@@ -14,6 +14,8 @@
// //
#include "draco/attributes/geometry_attribute.h" #include "draco/attributes/geometry_attribute.h"
using std::array;
namespace draco { namespace draco {
GeometryAttribute::GeometryAttribute() GeometryAttribute::GeometryAttribute()
@@ -43,9 +45,8 @@ void GeometryAttribute::Init(GeometryAttribute::Type attribute_type,
} }
bool GeometryAttribute::CopyFrom(const GeometryAttribute &src_att) { bool GeometryAttribute::CopyFrom(const GeometryAttribute &src_att) {
if (buffer_ == nullptr || src_att.buffer_ == nullptr) { if (buffer_ == nullptr || src_att.buffer_ == nullptr)
return false; return false;
}
buffer_->Update(src_att.buffer_->data(), src_att.buffer_->data_size()); buffer_->Update(src_att.buffer_->data(), src_att.buffer_->data_size());
num_components_ = src_att.num_components_; num_components_ = src_att.num_components_;
data_type_ = src_att.data_type_; data_type_ = src_att.data_type_;
@@ -54,35 +55,27 @@ bool GeometryAttribute::CopyFrom(const GeometryAttribute &src_att) {
byte_offset_ = src_att.byte_offset_; byte_offset_ = src_att.byte_offset_;
attribute_type_ = src_att.attribute_type_; attribute_type_ = src_att.attribute_type_;
buffer_descriptor_ = src_att.buffer_descriptor_; buffer_descriptor_ = src_att.buffer_descriptor_;
unique_id_ = src_att.unique_id_;
return true; return true;
} }
bool GeometryAttribute::operator==(const GeometryAttribute &va) const { bool GeometryAttribute::operator==(const GeometryAttribute &va) const {
if (attribute_type_ != va.attribute_type_) { if (attribute_type_ != va.attribute_type_)
return false; return false;
}
// It's OK to compare just the buffer descriptors here. We don't need to // It's OK to compare just the buffer descriptors here. We don't need to
// compare the buffers themselves. // compare the buffers themselves.
if (buffer_descriptor_.buffer_id != va.buffer_descriptor_.buffer_id) { if (buffer_descriptor_.buffer_id != va.buffer_descriptor_.buffer_id)
return false; return false;
}
if (buffer_descriptor_.buffer_update_count != if (buffer_descriptor_.buffer_update_count !=
va.buffer_descriptor_.buffer_update_count) { va.buffer_descriptor_.buffer_update_count)
return false; return false;
} if (num_components_ != va.num_components_)
if (num_components_ != va.num_components_) {
return false; return false;
} if (data_type_ != va.data_type_)
if (data_type_ != va.data_type_) {
return false; return false;
} if (byte_stride_ != va.byte_stride_)
if (byte_stride_ != va.byte_stride_) {
return false; return false;
} if (byte_offset_ != va.byte_offset_)
if (byte_offset_ != va.byte_offset_) {
return false; return false;
}
return true; return true;
} }

View File

@@ -91,9 +91,8 @@ class GeometryAttribute {
// Byte address of the attribute index. // Byte address of the attribute index.
const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value(); const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value();
// Check we are not reading past end of data. // Check we are not reading past end of data.
if (byte_pos + sizeof(*out) > buffer_->data_size()) { if (byte_pos + sizeof(*out) > buffer_->data_size())
return false; return false;
}
buffer_->Read(byte_pos, &((*out)[0]), sizeof(*out)); buffer_->Read(byte_pos, &((*out)[0]), sizeof(*out));
return true; return true;
} }
@@ -119,13 +118,6 @@ class GeometryAttribute {
buffer_->Read(byte_pos, out_data, byte_stride_); buffer_->Read(byte_pos, out_data, byte_stride_);
} }
// Sets a value of an attribute entry. The input value must be allocated to
// cover all components of a single attribute entry.
void SetAttributeValue(AttributeValueIndex entry_index, const void *value) {
const int64_t byte_pos = entry_index.value() * byte_stride();
buffer_->Write(byte_pos, value, byte_stride());
}
// DEPRECATED: Use // DEPRECATED: Use
// ConvertValue(AttributeValueIndex att_id, // ConvertValue(AttributeValueIndex att_id,
// int out_num_components, // int out_num_components,
@@ -147,9 +139,8 @@ class GeometryAttribute {
template <typename OutT> template <typename OutT>
bool ConvertValue(AttributeValueIndex att_id, int8_t out_num_components, bool ConvertValue(AttributeValueIndex att_id, int8_t out_num_components,
OutT *out_val) const { OutT *out_val) const {
if (out_val == nullptr) { if (out_val == nullptr)
return false; return false;
}
switch (data_type_) { switch (data_type_) {
case DT_INT8: case DT_INT8:
return ConvertTypedValue<int8_t, OutT>(att_id, out_num_components, return ConvertTypedValue<int8_t, OutT>(att_id, out_num_components,
@@ -200,26 +191,6 @@ class GeometryAttribute {
return ConvertValue<OutT>(att_index, num_components_, out_value); return ConvertValue<OutT>(att_index, num_components_, out_value);
} }
// Utility function. Returns |attribute_type| as std::string.
static std::string TypeToString(Type attribute_type) {
switch (attribute_type) {
case INVALID:
return "INVALID";
case POSITION:
return "POSITION";
case NORMAL:
return "NORMAL";
case COLOR:
return "COLOR";
case TEX_COORD:
return "TEX_COORD";
case GENERIC:
return "GENERIC";
default:
return "UNKNOWN";
}
}
bool operator==(const GeometryAttribute &va) const; bool operator==(const GeometryAttribute &va) const;
// Returns the type of the attribute indicating the nature of the attribute. // Returns the type of the attribute indicating the nature of the attribute.
@@ -314,8 +285,8 @@ struct GeometryAttributeHasher {
size_t hash = HashCombine(va.buffer_descriptor_.buffer_id, size_t hash = HashCombine(va.buffer_descriptor_.buffer_id,
va.buffer_descriptor_.buffer_update_count); va.buffer_descriptor_.buffer_update_count);
hash = HashCombine(va.num_components_, hash); hash = HashCombine(va.num_components_, hash);
hash = HashCombine(static_cast<int8_t>(va.data_type_), hash); hash = HashCombine((int8_t)va.data_type_, hash);
hash = HashCombine(static_cast<int8_t>(va.attribute_type_), hash); hash = HashCombine((int8_t)va.attribute_type_, hash);
hash = HashCombine(va.byte_stride_, hash); hash = HashCombine(va.byte_stride_, hash);
return HashCombine(va.byte_offset_, hash); return HashCombine(va.byte_offset_, hash);
} }

View File

@@ -32,32 +32,20 @@ PointAttribute::PointAttribute(const GeometryAttribute &att)
num_unique_entries_(0), num_unique_entries_(0),
identity_mapping_(false) {} identity_mapping_(false) {}
void PointAttribute::Init(Type attribute_type, int8_t num_components,
DataType data_type, bool normalized,
size_t num_attribute_values) {
attribute_buffer_ = std::unique_ptr<DataBuffer>(new DataBuffer());
GeometryAttribute::Init(attribute_type, attribute_buffer_.get(),
num_components, data_type, normalized,
DataTypeLength(data_type) * num_components, 0);
Reset(num_attribute_values);
SetIdentityMapping();
}
void PointAttribute::CopyFrom(const PointAttribute &src_att) { void PointAttribute::CopyFrom(const PointAttribute &src_att) {
if (buffer() == nullptr) { if (buffer() == nullptr) {
// If the destination attribute doesn't have a valid buffer, create it. // If the destination attribute doesn't have a valid buffer, create it.
attribute_buffer_ = std::unique_ptr<DataBuffer>(new DataBuffer()); attribute_buffer_ = std::unique_ptr<DataBuffer>(new DataBuffer());
ResetBuffer(attribute_buffer_.get(), 0, 0); ResetBuffer(attribute_buffer_.get(), 0, 0);
} }
if (!GeometryAttribute::CopyFrom(src_att)) { if (!GeometryAttribute::CopyFrom(src_att))
return; return;
}
identity_mapping_ = src_att.identity_mapping_; identity_mapping_ = src_att.identity_mapping_;
num_unique_entries_ = src_att.num_unique_entries_; num_unique_entries_ = src_att.num_unique_entries_;
indices_map_ = src_att.indices_map_; indices_map_ = src_att.indices_map_;
if (src_att.attribute_transform_data_) { if (src_att.attribute_transform_data_) {
attribute_transform_data_ = std::unique_ptr<AttributeTransformData>( attribute_transform_data_ = std::unique_ptr<AttributeTransformData>(
new AttributeTransformData(*src_att.attribute_transform_data_)); new AttributeTransformData(*src_att.attribute_transform_data_.get()));
} else { } else {
attribute_transform_data_ = nullptr; attribute_transform_data_ = nullptr;
} }
@@ -68,20 +56,14 @@ bool PointAttribute::Reset(size_t num_attribute_values) {
attribute_buffer_ = std::unique_ptr<DataBuffer>(new DataBuffer()); attribute_buffer_ = std::unique_ptr<DataBuffer>(new DataBuffer());
} }
const int64_t entry_size = DataTypeLength(data_type()) * num_components(); const int64_t entry_size = DataTypeLength(data_type()) * num_components();
if (!attribute_buffer_->Update(nullptr, num_attribute_values * entry_size)) { if (!attribute_buffer_->Update(nullptr, num_attribute_values * entry_size))
return false; return false;
}
// Assign the new buffer to the parent attribute. // Assign the new buffer to the parent attribute.
ResetBuffer(attribute_buffer_.get(), entry_size, 0); ResetBuffer(attribute_buffer_.get(), entry_size, 0);
num_unique_entries_ = static_cast<uint32_t>(num_attribute_values); num_unique_entries_ = static_cast<uint32_t>(num_attribute_values);
return true; return true;
} }
void PointAttribute::Resize(size_t new_num_unique_entries) {
num_unique_entries_ = static_cast<uint32_t>(new_num_unique_entries);
attribute_buffer_->Resize(new_num_unique_entries * byte_stride());
}
#ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED #ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED
AttributeValueIndex::ValueType PointAttribute::DeduplicateValues( AttributeValueIndex::ValueType PointAttribute::DeduplicateValues(
const GeometryAttribute &in_att) { const GeometryAttribute &in_att) {
@@ -118,9 +100,8 @@ AttributeValueIndex::ValueType PointAttribute::DeduplicateValues(
default: default:
return -1; // Unsupported data type. return -1; // Unsupported data type.
} }
if (unique_vals == 0) { if (unique_vals == 0)
return -1; // Unexpected error. return -1; // Unexpected error.
}
return unique_vals; return unique_vals;
} }
@@ -200,9 +181,8 @@ AttributeValueIndex::ValueType PointAttribute::DeduplicateFormattedValues(
++unique_vals; ++unique_vals;
} }
} }
if (unique_vals == num_unique_entries_) { if (unique_vals == num_unique_entries_)
return unique_vals.value(); // Nothing has changed. return unique_vals.value(); // Nothing has changed.
}
if (is_mapping_identity()) { if (is_mapping_identity()) {
// Change identity mapping to the explicit one. // Change identity mapping to the explicit one.
// The number of points is equal to the number of old unique values. // The number of points is equal to the number of old unique values.

View File

@@ -17,12 +17,13 @@
#include <memory> #include <memory>
#include "draco/draco_features.h"
#include "draco/attributes/attribute_transform_data.h" #include "draco/attributes/attribute_transform_data.h"
#include "draco/attributes/geometry_attribute.h" #include "draco/attributes/geometry_attribute.h"
#include "draco/core/draco_index_type_vector.h" #include "draco/core/draco_index_type_vector.h"
#include "draco/core/hash_utils.h" #include "draco/core/hash_utils.h"
#include "draco/core/macros.h" #include "draco/core/macros.h"
#include "draco/draco_features.h"
namespace draco { namespace draco {
@@ -40,12 +41,6 @@ class PointAttribute : public GeometryAttribute {
PointAttribute(PointAttribute &&attribute) = default; PointAttribute(PointAttribute &&attribute) = default;
PointAttribute &operator=(PointAttribute &&attribute) = default; PointAttribute &operator=(PointAttribute &&attribute) = default;
// Initializes a point attribute. By default the attribute will be set to
// identity mapping between point indices and attribute values. To set custom
// mapping use SetExplicitMapping() function.
void Init(Type attribute_type, int8_t num_components, DataType data_type,
bool normalized, size_t num_attribute_values);
// Copies attribute data from the provided |src_att| attribute. // Copies attribute data from the provided |src_att| attribute.
void CopyFrom(const PointAttribute &src_att); void CopyFrom(const PointAttribute &src_att);
@@ -54,17 +49,15 @@ class PointAttribute : public GeometryAttribute {
size_t size() const { return num_unique_entries_; } size_t size() const { return num_unique_entries_; }
AttributeValueIndex mapped_index(PointIndex point_index) const { AttributeValueIndex mapped_index(PointIndex point_index) const {
if (identity_mapping_) { if (identity_mapping_)
return AttributeValueIndex(point_index.value()); return AttributeValueIndex(point_index.value());
}
return indices_map_[point_index]; return indices_map_[point_index];
} }
DataBuffer *buffer() const { return attribute_buffer_.get(); } DataBuffer *buffer() const { return attribute_buffer_.get(); }
bool is_mapping_identity() const { return identity_mapping_; } bool is_mapping_identity() const { return identity_mapping_; }
size_t indices_map_size() const { size_t indices_map_size() const {
if (is_mapping_identity()) { if (is_mapping_identity())
return 0; return 0;
}
return indices_map_.size(); return indices_map_.size();
} }
@@ -72,14 +65,10 @@ class PointAttribute : public GeometryAttribute {
return GetAddress(mapped_index(point_index)); return GetAddress(mapped_index(point_index));
} }
// Sets the new number of unique attribute entries for the attribute. The // Sets the new number of unique attribute entries for the attribute.
// function resizes the attribute storage to hold |num_attribute_values| void Resize(size_t new_num_unique_entries) {
// entries. num_unique_entries_ = static_cast<uint32_t>(new_num_unique_entries);
// All previous entries with AttributeValueIndex < |num_attribute_values| }
// are preserved. Caller needs to ensure that the PointAttribute is still
// valid after the resizing operation (that is, each point is mapped to a
// valid attribute value).
void Resize(size_t new_num_unique_entries);
// Functions for setting the type of mapping between point indices and // Functions for setting the type of mapping between point indices and
// attribute entry ids. // attribute entry ids.
@@ -103,6 +92,13 @@ class PointAttribute : public GeometryAttribute {
indices_map_[point_index] = entry_index; indices_map_[point_index] = entry_index;
} }
// Sets a value of an attribute entry. The input value must be allocated to
// cover all components of a single attribute entry.
void SetAttributeValue(AttributeValueIndex entry_index, const void *value) {
const int64_t byte_pos = entry_index.value() * byte_stride();
buffer()->Write(byte_pos, value, byte_stride());
}
// Same as GeometryAttribute::GetValue(), but using point id as the input. // Same as GeometryAttribute::GetValue(), but using point id as the input.
// Mapping to attribute value index is performed automatically. // Mapping to attribute value index is performed automatically.
void GetMappedValue(PointIndex point_index, void *out_data) const { void GetMappedValue(PointIndex point_index, void *out_data) const {
@@ -169,7 +165,7 @@ struct PointAttributeHasher {
hash = HashCombine(attribute.identity_mapping_, hash); hash = HashCombine(attribute.identity_mapping_, hash);
hash = HashCombine(attribute.num_unique_entries_, hash); hash = HashCombine(attribute.num_unique_entries_, hash);
hash = HashCombine(attribute.indices_map_.size(), hash); hash = HashCombine(attribute.indices_map_.size(), hash);
if (!attribute.indices_map_.empty()) { if (attribute.indices_map_.size() > 0) {
const uint64_t indices_hash = FingerprintString( const uint64_t indices_hash = FingerprintString(
reinterpret_cast<const char *>(attribute.indices_map_.data()), reinterpret_cast<const char *>(attribute.indices_map_.data()),
attribute.indices_map_.size()); attribute.indices_map_.size());

View File

@@ -0,0 +1,129 @@
// Copyright 2017 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "draco/attributes/point_attribute.h"
#include "draco/core/draco_test_base.h"
namespace {
class PointAttributeTest : public ::testing::Test {
protected:
PointAttributeTest() {}
};
TEST_F(PointAttributeTest, TestCopy) {
// This test verifies that PointAttribute can copy data from another point
// attribute.
draco::GeometryAttribute pos_att;
pos_att.Init(draco::GeometryAttribute::POSITION, nullptr, 1, draco::DT_INT32,
false, 4, 0);
draco::PointAttribute pa(pos_att);
pa.SetIdentityMapping();
pa.Reset(10);
for (int32_t i = 0; i < 10; ++i) {
pa.SetAttributeValue(draco::AttributeValueIndex(i), &i);
}
draco::PointAttribute other_pa;
other_pa.CopyFrom(pa);
draco::PointAttributeHasher hasher;
ASSERT_EQ(hasher(pa), hasher(other_pa));
// The hash function does not actually compute the hash from attribute values,
// so ensure the data got copied correctly as well.
for (int32_t i = 0; i < 10; ++i) {
int32_t data;
other_pa.GetValue(draco::AttributeValueIndex(i), &data);
ASSERT_EQ(data, i);
}
}
TEST_F(PointAttributeTest, TestGetValueFloat) {
draco::GeometryAttribute pos_att;
pos_att.Init(draco::GeometryAttribute::POSITION, nullptr, 3,
draco::DT_FLOAT32, false, 4, 0);
draco::PointAttribute pa(pos_att);
pa.SetIdentityMapping();
pa.Reset(5);
float points[3];
for (int32_t i = 0; i < 5; ++i) {
points[0] = i * 3.0;
points[1] = (i * 3.0) + 1.0;
points[2] = (i * 3.0) + 2.0;
pa.SetAttributeValue(draco::AttributeValueIndex(i), &points);
}
for (int32_t i = 0; i < 5; ++i) {
pa.GetValue(draco::AttributeValueIndex(i), &points);
ASSERT_FLOAT_EQ(points[0], i * 3.0);
ASSERT_FLOAT_EQ(points[1], (i * 3.0) + 1.0);
ASSERT_FLOAT_EQ(points[2], (i * 3.0) + 2.0);
}
}
TEST_F(PointAttributeTest, TestGetArray) {
draco::GeometryAttribute pos_att;
pos_att.Init(draco::GeometryAttribute::POSITION, nullptr, 3,
draco::DT_FLOAT32, false, 4, 0);
draco::PointAttribute pa(pos_att);
pa.SetIdentityMapping();
pa.Reset(5);
float points[3];
for (int32_t i = 0; i < 5; ++i) {
points[0] = i * 3.0;
points[1] = (i * 3.0) + 1.0;
points[2] = (i * 3.0) + 2.0;
pa.SetAttributeValue(draco::AttributeValueIndex(i), &points);
}
for (int32_t i = 0; i < 5; ++i) {
std::array<float, 3> att_value;
att_value = pa.GetValue<float, 3>(draco::AttributeValueIndex(i));
ASSERT_FLOAT_EQ(att_value[0], i * 3.0);
ASSERT_FLOAT_EQ(att_value[1], (i * 3.0) + 1.0);
ASSERT_FLOAT_EQ(att_value[2], (i * 3.0) + 2.0);
}
for (int32_t i = 0; i < 5; ++i) {
std::array<float, 3> att_value;
EXPECT_TRUE(
(pa.GetValue<float, 3>(draco::AttributeValueIndex(i), &att_value)));
ASSERT_FLOAT_EQ(att_value[0], i * 3.0);
ASSERT_FLOAT_EQ(att_value[1], (i * 3.0) + 1.0);
ASSERT_FLOAT_EQ(att_value[2], (i * 3.0) + 2.0);
}
}
TEST_F(PointAttributeTest, TestArrayReadError) {
draco::GeometryAttribute pos_att;
pos_att.Init(draco::GeometryAttribute::POSITION, nullptr, 3,
draco::DT_FLOAT32, false, 4, 0);
draco::PointAttribute pa(pos_att);
pa.SetIdentityMapping();
pa.Reset(5);
float points[3];
for (int32_t i = 0; i < 5; ++i) {
points[0] = i * 3.0;
points[1] = (i * 3.0) + 1.0;
points[2] = (i * 3.0) + 2.0;
pa.SetAttributeValue(draco::AttributeValueIndex(i), &points);
}
std::array<float, 3> att_value;
EXPECT_FALSE(
(pa.GetValue<float, 3>(draco::AttributeValueIndex(5), &att_value)));
}
} // namespace

View File

@@ -33,42 +33,31 @@ bool AttributesDecoder::DecodeAttributesDecoderData(DecoderBuffer *in_buffer) {
#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
if (point_cloud_decoder_->bitstream_version() < if (point_cloud_decoder_->bitstream_version() <
DRACO_BITSTREAM_VERSION(2, 0)) { DRACO_BITSTREAM_VERSION(2, 0)) {
if (!in_buffer->Decode(&num_attributes)) { if (!in_buffer->Decode(&num_attributes))
return false; return false;
}
} else } else
#endif #endif
{ {
if (!DecodeVarint(&num_attributes, in_buffer)) { if (!DecodeVarint(&num_attributes, in_buffer))
return false; return false;
}
} }
if (num_attributes == 0) { if (num_attributes == 0)
return false; return false;
}
point_attribute_ids_.resize(num_attributes); point_attribute_ids_.resize(num_attributes);
PointCloud *pc = point_cloud_; PointCloud *pc = point_cloud_;
for (uint32_t i = 0; i < num_attributes; ++i) { for (uint32_t i = 0; i < num_attributes; ++i) {
// Decode attribute descriptor data. // Decode attribute descriptor data.
uint8_t att_type, data_type, num_components, normalized; uint8_t att_type, data_type, num_components, normalized;
if (!in_buffer->Decode(&att_type)) { if (!in_buffer->Decode(&att_type))
return false; return false;
} if (!in_buffer->Decode(&data_type))
if (!in_buffer->Decode(&data_type)) {
return false; return false;
} if (!in_buffer->Decode(&num_components))
if (!in_buffer->Decode(&num_components)) {
return false; return false;
} if (!in_buffer->Decode(&normalized))
if (!in_buffer->Decode(&normalized)) {
return false; return false;
} if (data_type <= DT_INVALID || data_type >= DT_TYPES_COUNT)
if (att_type >= GeometryAttribute::NAMED_ATTRIBUTES_COUNT) {
return false; return false;
}
if (data_type == DT_INVALID || data_type >= DT_TYPES_COUNT) {
return false;
}
const DataType draco_dt = static_cast<DataType>(data_type); const DataType draco_dt = static_cast<DataType>(data_type);
// Add the attribute to the point cloud // Add the attribute to the point cloud
@@ -81,9 +70,8 @@ bool AttributesDecoder::DecodeAttributesDecoderData(DecoderBuffer *in_buffer) {
if (point_cloud_decoder_->bitstream_version() < if (point_cloud_decoder_->bitstream_version() <
DRACO_BITSTREAM_VERSION(1, 3)) { DRACO_BITSTREAM_VERSION(1, 3)) {
uint16_t custom_id; uint16_t custom_id;
if (!in_buffer->Decode(&custom_id)) { if (!in_buffer->Decode(&custom_id))
return false; return false;
}
// TODO(draco-eng): Add "custom_id" to attribute metadata. // TODO(draco-eng): Add "custom_id" to attribute metadata.
unique_id = static_cast<uint32_t>(custom_id); unique_id = static_cast<uint32_t>(custom_id);
ga.set_unique_id(unique_id); ga.set_unique_id(unique_id);
@@ -99,10 +87,8 @@ bool AttributesDecoder::DecodeAttributesDecoderData(DecoderBuffer *in_buffer) {
point_attribute_ids_[i] = att_id; point_attribute_ids_[i] = att_id;
// Update the inverse map. // Update the inverse map.
if (att_id >= if (att_id >= static_cast<int32_t>(point_attribute_to_local_id_map_.size()))
static_cast<int32_t>(point_attribute_to_local_id_map_.size())) {
point_attribute_to_local_id_map_.resize(att_id + 1, -1); point_attribute_to_local_id_map_.resize(att_id + 1, -1);
}
point_attribute_to_local_id_map_[att_id] = i; point_attribute_to_local_id_map_[att_id] = i;
} }
return true; return true;

View File

@@ -17,10 +17,11 @@
#include <vector> #include <vector>
#include "draco/draco_features.h"
#include "draco/compression/attributes/attributes_decoder_interface.h" #include "draco/compression/attributes/attributes_decoder_interface.h"
#include "draco/compression/point_cloud/point_cloud_decoder.h" #include "draco/compression/point_cloud/point_cloud_decoder.h"
#include "draco/core/decoder_buffer.h" #include "draco/core/decoder_buffer.h"
#include "draco/draco_features.h"
#include "draco/point_cloud/point_cloud.h" #include "draco/point_cloud/point_cloud.h"
namespace draco { namespace draco {
@@ -53,15 +54,12 @@ class AttributesDecoder : public AttributesDecoderInterface {
// Decodes attribute data from the source buffer. // Decodes attribute data from the source buffer.
bool DecodeAttributes(DecoderBuffer *in_buffer) override { bool DecodeAttributes(DecoderBuffer *in_buffer) override {
if (!DecodePortableAttributes(in_buffer)) { if (!DecodePortableAttributes(in_buffer))
return false; return false;
} if (!DecodeDataNeededByPortableTransforms(in_buffer))
if (!DecodeDataNeededByPortableTransforms(in_buffer)) {
return false; return false;
} if (!TransformAttributesToOriginalFormat())
if (!TransformAttributesToOriginalFormat()) {
return false; return false;
}
return true; return true;
} }
@@ -69,9 +67,8 @@ class AttributesDecoder : public AttributesDecoderInterface {
int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const {
const int id_map_size = const int id_map_size =
static_cast<int>(point_attribute_to_local_id_map_.size()); static_cast<int>(point_attribute_to_local_id_map_.size());
if (point_attribute_id >= id_map_size) { if (point_attribute_id >= id_map_size)
return -1; return -1;
}
return point_attribute_to_local_id_map_[point_attribute_id]; return point_attribute_to_local_id_map_[point_attribute_id];
} }
virtual bool DecodePortableAttributes(DecoderBuffer *in_buffer) = 0; virtual bool DecodePortableAttributes(DecoderBuffer *in_buffer) = 0;

View File

@@ -48,18 +48,15 @@ class AttributesEncoder {
// Encode attribute data to the target buffer. // Encode attribute data to the target buffer.
virtual bool EncodeAttributes(EncoderBuffer *out_buffer) { virtual bool EncodeAttributes(EncoderBuffer *out_buffer) {
if (!TransformAttributesToPortableFormat()) { if (!TransformAttributesToPortableFormat())
return false; return false;
} if (!EncodePortableAttributes(out_buffer))
if (!EncodePortableAttributes(out_buffer)) {
return false; return false;
}
// Encode data needed by portable transforms after the attribute is encoded. // Encode data needed by portable transforms after the attribute is encoded.
// This corresponds to the order in which the data is going to be decoded by // This corresponds to the order in which the data is going to be decoded by
// the decoder. // the decoder.
if (!EncodeDataNeededByPortableTransforms(out_buffer)) { if (!EncodeDataNeededByPortableTransforms(out_buffer))
return false; return false;
}
return true; return true;
} }
@@ -90,9 +87,8 @@ class AttributesEncoder {
void AddAttributeId(int32_t id) { void AddAttributeId(int32_t id) {
point_attribute_ids_.push_back(id); point_attribute_ids_.push_back(id);
if (id >= static_cast<int32_t>(point_attribute_to_local_id_map_.size())) { if (id >= static_cast<int32_t>(point_attribute_to_local_id_map_.size()))
point_attribute_to_local_id_map_.resize(id + 1, -1); point_attribute_to_local_id_map_.resize(id + 1, -1);
}
point_attribute_to_local_id_map_[id] = point_attribute_to_local_id_map_[id] =
static_cast<int32_t>(point_attribute_ids_.size()) - 1; static_cast<int32_t>(point_attribute_ids_.size()) - 1;
} }
@@ -131,9 +127,8 @@ class AttributesEncoder {
int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const {
const int id_map_size = const int id_map_size =
static_cast<int>(point_attribute_to_local_id_map_.size()); static_cast<int>(point_attribute_to_local_id_map_.size());
if (point_attribute_id >= id_map_size) { if (point_attribute_id >= id_map_size)
return -1; return -1;
}
return point_attribute_to_local_id_map_[point_attribute_id]; return point_attribute_to_local_id_map_[point_attribute_id];
} }

View File

@@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
// //
#include "draco/compression/attributes/kd_tree_attributes_decoder.h" #include "draco/compression/attributes/kd_tree_attributes_decoder.h"
#include "draco/compression/attributes/kd_tree_attributes_shared.h" #include "draco/compression/attributes/kd_tree_attributes_shared.h"
#include "draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h" #include "draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h"
#include "draco/compression/point_cloud/algorithms/float_points_tree_decoder.h" #include "draco/compression/point_cloud/algorithms/float_points_tree_decoder.h"
@@ -93,7 +92,7 @@ class PointAttributeVectorOutputIterator {
const uint32_t &data_size = std::get<3>(att); const uint32_t &data_size = std::get<3>(att);
const uint32_t &num_components = std::get<4>(att); const uint32_t &num_components = std::get<4>(att);
const uint32_t *data_source = val.data() + offset; const uint32_t *data_source = val.data() + offset;
if (data_size < 4) { // handle uint16_t, uint8_t if (data_size != 4) { // handle uint16_t, uint8_t
// selectively copy data bytes // selectively copy data bytes
uint8_t *data_counter = data_; uint8_t *data_counter = data_;
for (uint32_t index = 0; index < num_components; for (uint32_t index = 0; index < num_components;
@@ -104,9 +103,8 @@ class PointAttributeVectorOutputIterator {
data_source = reinterpret_cast<uint32_t *>(data_); data_source = reinterpret_cast<uint32_t *>(data_);
} }
const AttributeValueIndex avi = attribute->mapped_index(point_id_); const AttributeValueIndex avi = attribute->mapped_index(point_id_);
if (avi >= static_cast<uint32_t>(attribute->size())) { if (avi >= static_cast<uint32_t>(attribute->size()))
return *this; return *this;
}
attribute->SetAttributeValue(avi, data_source); attribute->SetAttributeValue(avi, data_source);
} }
return *this; return *this;
@@ -136,9 +134,8 @@ bool KdTreeAttributesDecoder::DecodePortableAttributes(
return true; return true;
} }
uint8_t compression_level = 0; uint8_t compression_level = 0;
if (!in_buffer->Decode(&compression_level)) { if (!in_buffer->Decode(&compression_level))
return false; return false;
}
const int32_t num_points = GetDecoder()->point_cloud()->num_points(); const int32_t num_points = GetDecoder()->point_cloud()->num_points();
// Decode data using the kd tree decoding into integer (portable) attributes. // Decode data using the kd tree decoding into integer (portable) attributes.
@@ -200,51 +197,44 @@ bool KdTreeAttributesDecoder::DecodePortableAttributes(
switch (compression_level) { switch (compression_level) {
case 0: { case 0: {
DynamicIntegerPointsKdTreeDecoder<0> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<0> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 1: { case 1: {
DynamicIntegerPointsKdTreeDecoder<1> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<1> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 2: { case 2: {
DynamicIntegerPointsKdTreeDecoder<2> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<2> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 3: { case 3: {
DynamicIntegerPointsKdTreeDecoder<3> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<3> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 4: { case 4: {
DynamicIntegerPointsKdTreeDecoder<4> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<4> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 5: { case 5: {
DynamicIntegerPointsKdTreeDecoder<5> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<5> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 6: { case 6: {
DynamicIntegerPointsKdTreeDecoder<6> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<6> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
default: default:
@@ -266,26 +256,22 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms(
if (att->data_type() == DT_FLOAT32) { if (att->data_type() == DT_FLOAT32) {
const int num_components = att->num_components(); const int num_components = att->num_components();
min_value.resize(num_components); min_value.resize(num_components);
if (!in_buffer->Decode(&min_value[0], sizeof(float) * num_components)) { if (!in_buffer->Decode(&min_value[0], sizeof(float) * num_components))
return false; return false;
}
float max_value_dif; float max_value_dif;
if (!in_buffer->Decode(&max_value_dif)) { if (!in_buffer->Decode(&max_value_dif))
return false; return false;
}
uint8_t quantization_bits; uint8_t quantization_bits;
if (!in_buffer->Decode(&quantization_bits) || quantization_bits > 31) { if (!in_buffer->Decode(&quantization_bits) || quantization_bits > 31)
return false; return false;
}
AttributeQuantizationTransform transform; AttributeQuantizationTransform transform;
transform.SetParameters(quantization_bits, min_value.data(), transform.SetParameters(quantization_bits, min_value.data(),
num_components, max_value_dif); num_components, max_value_dif);
const int num_transforms = const int num_transforms =
static_cast<int>(attribute_quantization_transforms_.size()); static_cast<int>(attribute_quantization_transforms_.size());
if (!transform.TransferToAttribute( if (!transform.TransferToAttribute(
quantized_portable_attributes_[num_transforms].get())) { quantized_portable_attributes_[num_transforms].get()))
return false; return false;
}
attribute_quantization_transforms_.push_back(transform); attribute_quantization_transforms_.push_back(transform);
} }
} }
@@ -313,10 +299,6 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms(
const DataType data_type = att->data_type(); const DataType data_type = att->data_type();
const uint32_t data_size = (std::max)(0, DataTypeLength(data_type)); const uint32_t data_size = (std::max)(0, DataTypeLength(data_type));
const uint32_t num_components = att->num_components(); const uint32_t num_components = att->num_components();
if (data_size > 4) {
return false;
}
atts[attribute_index] = std::make_tuple( atts[attribute_index] = std::make_tuple(
att, total_dimensionality, data_type, data_size, num_components); att, total_dimensionality, data_type, data_size, num_components);
// everything is treated as 32bit in the encoder. // everything is treated as 32bit in the encoder.
@@ -328,30 +310,24 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms(
att->SetIdentityMapping(); att->SetIdentityMapping();
// Decode method // Decode method
uint8_t method; uint8_t method;
if (!in_buffer->Decode(&method)) { if (!in_buffer->Decode(&method))
return false; return false;
}
if (method == KdTreeAttributesEncodingMethod::kKdTreeQuantizationEncoding) { if (method == KdTreeAttributesEncodingMethod::kKdTreeQuantizationEncoding) {
uint8_t compression_level = 0; uint8_t compression_level = 0;
if (!in_buffer->Decode(&compression_level)) { if (!in_buffer->Decode(&compression_level))
return false; return false;
}
uint32_t num_points = 0; uint32_t num_points = 0;
if (!in_buffer->Decode(&num_points)) { if (!in_buffer->Decode(&num_points))
return false; return false;
}
att->Reset(num_points); att->Reset(num_points);
FloatPointsTreeDecoder decoder; FloatPointsTreeDecoder decoder;
decoder.set_num_points_from_header(num_points);
PointAttributeVectorOutputIterator<float> out_it(atts); PointAttributeVectorOutputIterator<float> out_it(atts);
if (!decoder.DecodePointCloud(in_buffer, out_it)) { if (!decoder.DecodePointCloud(in_buffer, out_it))
return false; return false;
}
} else if (method == KdTreeAttributesEncodingMethod::kKdTreeIntegerEncoding) { } else if (method == KdTreeAttributesEncodingMethod::kKdTreeIntegerEncoding) {
uint8_t compression_level = 0; uint8_t compression_level = 0;
if (!in_buffer->Decode(&compression_level)) { if (!in_buffer->Decode(&compression_level))
return false; return false;
}
if (6 < compression_level) { if (6 < compression_level) {
LOGE("KdTreeAttributesDecoder: compression level %i not supported.\n", LOGE("KdTreeAttributesDecoder: compression level %i not supported.\n",
compression_level); compression_level);
@@ -359,9 +335,8 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms(
} }
uint32_t num_points; uint32_t num_points;
if (!in_buffer->Decode(&num_points)) { if (!in_buffer->Decode(&num_points))
return false; return false;
}
for (auto attribute_index = 0; for (auto attribute_index = 0;
static_cast<uint32_t>(attribute_index) < attribute_count; static_cast<uint32_t>(attribute_index) < attribute_count;
@@ -378,51 +353,44 @@ bool KdTreeAttributesDecoder::DecodeDataNeededByPortableTransforms(
switch (compression_level) { switch (compression_level) {
case 0: { case 0: {
DynamicIntegerPointsKdTreeDecoder<0> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<0> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 1: { case 1: {
DynamicIntegerPointsKdTreeDecoder<1> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<1> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 2: { case 2: {
DynamicIntegerPointsKdTreeDecoder<2> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<2> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 3: { case 3: {
DynamicIntegerPointsKdTreeDecoder<3> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<3> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 4: { case 4: {
DynamicIntegerPointsKdTreeDecoder<4> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<4> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 5: { case 5: {
DynamicIntegerPointsKdTreeDecoder<5> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<5> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
case 6: { case 6: {
DynamicIntegerPointsKdTreeDecoder<6> decoder(total_dimensionality); DynamicIntegerPointsKdTreeDecoder<6> decoder(total_dimensionality);
if (!decoder.DecodePoints(in_buffer, out_it)) { if (!decoder.DecodePoints(in_buffer, out_it))
return false; return false;
}
break; break;
} }
default: default:
@@ -477,19 +445,16 @@ bool KdTreeAttributesDecoder::TransformAttributesToOriginalFormat() {
// Values are stored as unsigned in the attribute, make them signed again. // Values are stored as unsigned in the attribute, make them signed again.
if (att->data_type() == DT_INT32) { if (att->data_type() == DT_INT32) {
if (!TransformAttributeBackToSignedType<int32_t>( if (!TransformAttributeBackToSignedType<int32_t>(
att, num_processed_signed_components)) { att, num_processed_signed_components))
return false; return false;
}
} else if (att->data_type() == DT_INT16) { } else if (att->data_type() == DT_INT16) {
if (!TransformAttributeBackToSignedType<int16_t>( if (!TransformAttributeBackToSignedType<int16_t>(
att, num_processed_signed_components)) { att, num_processed_signed_components))
return false; return false;
}
} else if (att->data_type() == DT_INT8) { } else if (att->data_type() == DT_INT8) {
if (!TransformAttributeBackToSignedType<int8_t>( if (!TransformAttributeBackToSignedType<int8_t>(
att, num_processed_signed_components)) { att, num_processed_signed_components))
return false; return false;
}
} }
num_processed_signed_components += att->num_components(); num_processed_signed_components += att->num_components();
} else if (att->data_type() == DT_FLOAT32) { } else if (att->data_type() == DT_FLOAT32) {
@@ -526,9 +491,8 @@ bool KdTreeAttributesDecoder::TransformAttributesToOriginalFormat() {
int quant_val_id = 0; int quant_val_id = 0;
int out_byte_pos = 0; int out_byte_pos = 0;
Dequantizer dequantizer; Dequantizer dequantizer;
if (!dequantizer.Init(transform.range(), max_quantized_value)) { if (!dequantizer.Init(transform.range(), max_quantized_value))
return false; return false;
}
const uint32_t *const portable_attribute_data = const uint32_t *const portable_attribute_data =
reinterpret_cast<const uint32_t *>( reinterpret_cast<const uint32_t *>(
src_att->GetAddress(AttributeValueIndex(0))); src_att->GetAddress(AttributeValueIndex(0)));

View File

@@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
// //
#include "draco/compression/attributes/kd_tree_attributes_encoder.h" #include "draco/compression/attributes/kd_tree_attributes_encoder.h"
#include "draco/compression/attributes/kd_tree_attributes_shared.h" #include "draco/compression/attributes/kd_tree_attributes_shared.h"
#include "draco/compression/attributes/point_d_vector.h" #include "draco/compression/attributes/point_d_vector.h"
#include "draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h" #include "draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h"
@@ -51,9 +50,8 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() {
AttributeQuantizationTransform attribute_quantization_transform; AttributeQuantizationTransform attribute_quantization_transform;
const int quantization_bits = encoder()->options()->GetAttributeInt( const int quantization_bits = encoder()->options()->GetAttributeInt(
att_id, "quantization_bits", -1); att_id, "quantization_bits", -1);
if (quantization_bits < 1) { if (quantization_bits < 1)
return false; return false;
}
if (encoder()->options()->IsAttributeOptionSet(att_id, if (encoder()->options()->IsAttributeOptionSet(att_id,
"quantization_origin") && "quantization_origin") &&
encoder()->options()->IsAttributeOptionSet(att_id, encoder()->options()->IsAttributeOptionSet(att_id,
@@ -93,9 +91,8 @@ bool KdTreeAttributesEncoder::TransformAttributesToPortableFormat() {
++avi) { ++avi) {
att->ConvertValue<int32_t>(avi, &act_value[0]); att->ConvertValue<int32_t>(avi, &act_value[0]);
for (int c = 0; c < att->num_components(); ++c) { for (int c = 0; c < att->num_components(); ++c) {
if (min_value[c] > act_value[c]) { if (min_value[c] > act_value[c])
min_value[c] = act_value[c]; min_value[c] = act_value[c];
}
} }
} }
for (int c = 0; c < att->num_components(); ++c) { for (int c = 0; c < att->num_components(); ++c) {
@@ -170,9 +167,8 @@ bool KdTreeAttributesEncoder::EncodePortableAttributes(
return false; return false;
} }
if (source_att == nullptr) { if (source_att == nullptr)
return false; return false;
}
// Copy source_att to the vector. // Copy source_att to the vector.
if (source_att->data_type() == DT_UINT32) { if (source_att->data_type() == DT_UINT32) {
@@ -237,57 +233,50 @@ bool KdTreeAttributesEncoder::EncodePortableAttributes(
case 6: { case 6: {
DynamicIntegerPointsKdTreeEncoder<6> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<6> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
case 5: { case 5: {
DynamicIntegerPointsKdTreeEncoder<5> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<5> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
case 4: { case 4: {
DynamicIntegerPointsKdTreeEncoder<4> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<4> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
case 3: { case 3: {
DynamicIntegerPointsKdTreeEncoder<3> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<3> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
case 2: { case 2: {
DynamicIntegerPointsKdTreeEncoder<2> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<2> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
case 1: { case 1: {
DynamicIntegerPointsKdTreeEncoder<1> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<1> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
case 0: { case 0: {
DynamicIntegerPointsKdTreeEncoder<0> points_encoder(num_components_); DynamicIntegerPointsKdTreeEncoder<0> points_encoder(num_components_);
if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(), if (!points_encoder.EncodePoints(point_vector.begin(), point_vector.end(),
num_bits, out_buffer)) { num_bits, out_buffer))
return false; return false;
}
break; break;
} }
// Compression level and/or encoding speed seem wrong. // Compression level and/or encoding speed seem wrong.

View File

@@ -32,9 +32,8 @@ class LinearSequencer : public PointsSequencer {
protected: protected:
bool GenerateSequenceInternal() override { bool GenerateSequenceInternal() override {
if (num_points_ < 0) { if (num_points_ < 0)
return false; return false;
}
out_point_ids()->resize(num_points_); out_point_ids()->resize(num_points_);
for (int i = 0; i < num_points_; ++i) { for (int i = 0; i < num_points_; ++i) {
out_point_ids()->at(i) = PointIndex(i); out_point_ids()->at(i) = PointIndex(i);

View File

@@ -39,7 +39,6 @@
#define DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_ #define DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_
#include <inttypes.h> #include <inttypes.h>
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
@@ -56,9 +55,8 @@ class OctahedronToolBox {
center_value_(-1) {} center_value_(-1) {}
bool SetQuantizationBits(int32_t q) { bool SetQuantizationBits(int32_t q) {
if (q < 2 || q > 30) { if (q < 2 || q > 30)
return false; return false;
}
quantization_bits_ = q; quantization_bits_ = q;
max_quantized_value_ = (1 << quantization_bits_) - 1; max_quantized_value_ = (1 << quantization_bits_) - 1;
max_value_ = max_quantized_value_ - 1; max_value_ = max_quantized_value_ - 1;
@@ -159,9 +157,8 @@ class OctahedronToolBox {
int_vec[2] = 0; int_vec[2] = 0;
} }
// Take care of the sign. // Take care of the sign.
if (scaled_vector[2] < 0) { if (scaled_vector[2] < 0)
int_vec[2] *= -1; int_vec[2] *= -1;
}
IntegerVectorToQuantizedOctahedralCoords(int_vec, out_s, out_t); IntegerVectorToQuantizedOctahedralCoords(int_vec, out_s, out_t);
} }
@@ -192,8 +189,6 @@ class OctahedronToolBox {
} }
} }
// TODO(b/149328891): Change function to not use templates as |T| is only
// float.
template <typename T> template <typename T>
void OctaherdalCoordsToUnitVector(T in_s, T in_t, T *out_vector) const { void OctaherdalCoordsToUnitVector(T in_s, T in_t, T *out_vector) const {
DRACO_DCHECK_GE(in_s, 0); DRACO_DCHECK_GE(in_s, 0);
@@ -309,21 +304,18 @@ class OctahedronToolBox {
// For correction values. // For correction values.
int32_t ModMax(int32_t x) const { int32_t ModMax(int32_t x) const {
if (x > this->center_value()) { if (x > this->center_value())
return x - this->max_quantized_value(); return x - this->max_quantized_value();
} if (x < -this->center_value())
if (x < -this->center_value()) {
return x + this->max_quantized_value(); return x + this->max_quantized_value();
}
return x; return x;
} }
// For correction values. // For correction values.
int32_t MakePositive(int32_t x) const { int32_t MakePositive(int32_t x) const {
DRACO_DCHECK_LE(x, this->center_value() * 2); DRACO_DCHECK_LE(x, this->center_value() * 2);
if (x < 0) { if (x < 0)
return x + this->max_quantized_value(); return x + this->max_quantized_value();
}
return x; return x;
} }

View File

@@ -19,7 +19,6 @@
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "draco/core/macros.h" #include "draco/core/macros.h"
namespace draco { namespace draco {
@@ -43,9 +42,8 @@ class PseudoPointD {
// Specifically copies referenced memory // Specifically copies referenced memory
void swap(PseudoPointD &other) noexcept { void swap(PseudoPointD &other) noexcept {
for (internal_t dim = 0; dim < dimension_; dim += 1) { for (internal_t dim = 0; dim < dimension_; dim += 1)
std::swap(mem_[dim], other.mem_[dim]); std::swap(mem_[dim], other.mem_[dim]);
}
} }
PseudoPointD(const PseudoPointD &other) PseudoPointD(const PseudoPointD &other)
@@ -61,11 +59,9 @@ class PseudoPointD {
} }
bool operator==(const PseudoPointD &other) const { bool operator==(const PseudoPointD &other) const {
for (auto dim = 0; dim < dimension_; dim += 1) { for (auto dim = 0; dim < dimension_; dim += 1)
if (mem_[dim] != other.mem_[dim]) { if (mem_[dim] != other.mem_[dim])
return false; return false;
}
}
return true; return true;
} }
bool operator!=(const PseudoPointD &other) const { bool operator!=(const PseudoPointD &other) const {

View File

@@ -0,0 +1,359 @@
// Copyright 2018 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "draco/compression/attributes/point_d_vector.h"
#include "draco/compression/point_cloud/algorithms/point_cloud_types.h"
#include "draco/core/draco_test_base.h"
namespace draco {
class PointDVectorTest : public ::testing::Test {
protected:
template <typename PT>
void TestIntegrity() {}
template <typename PT>
void TestSize() {
for (uint32_t n_items = 0; n_items <= 10; ++n_items) {
for (uint32_t dimensionality = 1; dimensionality <= 10;
++dimensionality) {
draco::PointDVector<PT> var(n_items, dimensionality);
ASSERT_EQ(n_items, var.size());
ASSERT_EQ(n_items * dimensionality, var.GetBufferSize());
}
}
}
template <typename PT>
void TestContentsContiguous() {
for (uint32_t n_items = 1; n_items <= 1000; n_items *= 10) {
for (uint32_t dimensionality = 1; dimensionality < 10;
dimensionality += 2) {
for (uint32_t att_dimensionality = 1;
att_dimensionality <= dimensionality; att_dimensionality += 2) {
for (uint32_t offset_dimensionality = 0;
offset_dimensionality < dimensionality - att_dimensionality;
++offset_dimensionality) {
PointDVector<PT> var(n_items, dimensionality);
std::vector<PT> att(n_items * att_dimensionality);
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
att[val * att_dimensionality + att_dim] = val;
}
}
const PT *const attribute_data = att.data();
var.CopyAttribute(att_dimensionality, offset_dimensionality,
attribute_data);
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
ASSERT_EQ(var[val][offset_dimensionality + att_dim], val);
}
}
}
}
}
}
}
template <typename PT>
void TestContentsDiscrete() {
for (uint32_t n_items = 1; n_items <= 1000; n_items *= 10) {
for (uint32_t dimensionality = 1; dimensionality < 10;
dimensionality += 2) {
for (uint32_t att_dimensionality = 1;
att_dimensionality <= dimensionality; att_dimensionality += 2) {
for (uint32_t offset_dimensionality = 0;
offset_dimensionality < dimensionality - att_dimensionality;
++offset_dimensionality) {
PointDVector<PT> var(n_items, dimensionality);
std::vector<PT> att(n_items * att_dimensionality);
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
att[val * att_dimensionality + att_dim] = val;
}
}
const PT *const attribute_data = att.data();
for (PT item = 0; item < n_items; item += 1) {
var.CopyAttribute(att_dimensionality, offset_dimensionality, item,
attribute_data + item * att_dimensionality);
}
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
ASSERT_EQ(var[val][offset_dimensionality + att_dim], val);
}
}
}
}
}
}
}
template <typename PT>
void TestContentsCopy() {
for (uint32_t n_items = 1; n_items <= 1000; n_items *= 10) {
for (uint32_t dimensionality = 1; dimensionality < 10;
dimensionality += 2) {
for (uint32_t att_dimensionality = 1;
att_dimensionality <= dimensionality; att_dimensionality += 2) {
for (uint32_t offset_dimensionality = 0;
offset_dimensionality < dimensionality - att_dimensionality;
++offset_dimensionality) {
PointDVector<PT> var(n_items, dimensionality);
PointDVector<PT> dest(n_items, dimensionality);
std::vector<PT> att(n_items * att_dimensionality);
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
att[val * att_dimensionality + att_dim] = val;
}
}
const PT *const attribute_data = att.data();
var.CopyAttribute(att_dimensionality, offset_dimensionality,
attribute_data);
for (PT item = 0; item < n_items; item += 1) {
dest.CopyItem(var, item, item);
}
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
ASSERT_EQ(var[val][offset_dimensionality + att_dim], val);
ASSERT_EQ(dest[val][offset_dimensionality + att_dim], val);
}
}
}
}
}
}
}
template <typename PT>
void TestIterator() {
for (uint32_t n_items = 1; n_items <= 1000; n_items *= 10) {
for (uint32_t dimensionality = 1; dimensionality < 10;
dimensionality += 2) {
for (uint32_t att_dimensionality = 1;
att_dimensionality <= dimensionality; att_dimensionality += 2) {
for (uint32_t offset_dimensionality = 0;
offset_dimensionality < dimensionality - att_dimensionality;
++offset_dimensionality) {
PointDVector<PT> var(n_items, dimensionality);
PointDVector<PT> dest(n_items, dimensionality);
std::vector<PT> att(n_items * att_dimensionality);
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
att[val * att_dimensionality + att_dim] = val;
}
}
const PT *const attribute_data = att.data();
var.CopyAttribute(att_dimensionality, offset_dimensionality,
attribute_data);
for (PT item = 0; item < n_items; item += 1) {
dest.CopyItem(var, item, item);
}
auto V0 = var.begin();
auto VE = var.end();
auto D0 = dest.begin();
auto DE = dest.end();
while (V0 != VE && D0 != DE) {
ASSERT_EQ(*D0, *V0); // compare PseudoPointD
// verify elemental values
for (auto index = 0; index < dimensionality; index += 1) {
ASSERT_EQ((*D0)[index], (*V0)[index]);
}
++V0;
++D0;
}
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
ASSERT_EQ(var[val][offset_dimensionality + att_dim], val);
ASSERT_EQ(dest[val][offset_dimensionality + att_dim], val);
}
}
}
}
}
}
}
template <typename PT>
void TestPoint3Iterator() {
for (uint32_t n_items = 1; n_items <= 1000; n_items *= 10) {
const uint32_t dimensionality = 3;
// for (uint32_t dimensionality = 1; dimensionality < 10;
// dimensionality += 2) {
const uint32_t att_dimensionality = 3;
// for (uint32_t att_dimensionality = 1;
// att_dimensionality <= dimensionality; att_dimensionality += 2) {
for (uint32_t offset_dimensionality = 0;
offset_dimensionality < dimensionality - att_dimensionality;
++offset_dimensionality) {
PointDVector<PT> var(n_items, dimensionality);
PointDVector<PT> dest(n_items, dimensionality);
std::vector<PT> att(n_items * att_dimensionality);
std::vector<draco::Point3ui> att3(n_items);
for (PT val = 0; val < n_items; val += 1) {
att3[val][0] = val;
att3[val][1] = val;
att3[val][2] = val;
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
att[val * att_dimensionality + att_dim] = val;
}
}
const PT *const attribute_data = att.data();
var.CopyAttribute(att_dimensionality, offset_dimensionality,
attribute_data);
for (PT item = 0; item < n_items; item += 1) {
dest.CopyItem(var, item, item);
}
auto aV0 = att3.begin();
auto aVE = att3.end();
auto V0 = var.begin();
auto VE = var.end();
auto D0 = dest.begin();
auto DE = dest.end();
while (aV0 != aVE && V0 != VE && D0 != DE) {
ASSERT_EQ(*D0, *V0); // compare PseudoPointD
// verify elemental values
for (auto index = 0; index < dimensionality; index += 1) {
ASSERT_EQ((*D0)[index], (*V0)[index]);
ASSERT_EQ((*D0)[index], (*aV0)[index]);
ASSERT_EQ((*aV0)[index], (*V0)[index]);
}
++aV0;
++V0;
++D0;
}
for (PT val = 0; val < n_items; val += 1) {
for (PT att_dim = 0; att_dim < att_dimensionality; att_dim += 1) {
ASSERT_EQ(var[val][offset_dimensionality + att_dim], val);
ASSERT_EQ(dest[val][offset_dimensionality + att_dim], val);
}
}
}
}
}
void TestPseudoPointDSwap() {
draco::Point3ui val = {0, 1, 2};
draco::Point3ui dest = {10, 11, 12};
draco::PseudoPointD<uint32_t> val_src1(&val[0], 3);
draco::PseudoPointD<uint32_t> dest_src1(&dest[0], 3);
ASSERT_EQ(val_src1[0], 0);
ASSERT_EQ(val_src1[1], 1);
ASSERT_EQ(val_src1[2], 2);
ASSERT_EQ(dest_src1[0], 10);
ASSERT_EQ(dest_src1[1], 11);
ASSERT_EQ(dest_src1[2], 12);
ASSERT_NE(val_src1, dest_src1);
swap(val_src1, dest_src1);
ASSERT_EQ(dest_src1[0], 0);
ASSERT_EQ(dest_src1[1], 1);
ASSERT_EQ(dest_src1[2], 2);
ASSERT_EQ(val_src1[0], 10);
ASSERT_EQ(val_src1[1], 11);
ASSERT_EQ(val_src1[2], 12);
ASSERT_NE(val_src1, dest_src1);
}
void TestPseudoPointDEquality() {
draco::Point3ui val = {0, 1, 2};
draco::Point3ui dest = {0, 1, 2};
draco::PseudoPointD<uint32_t> val_src1(&val[0], 3);
draco::PseudoPointD<uint32_t> val_src2(&val[0], 3);
draco::PseudoPointD<uint32_t> dest_src1(&dest[0], 3);
draco::PseudoPointD<uint32_t> dest_src2(&dest[0], 3);
ASSERT_EQ(val_src1, val_src1);
ASSERT_EQ(val_src1, val_src2);
ASSERT_EQ(dest_src1, val_src1);
ASSERT_EQ(dest_src1, val_src2);
ASSERT_EQ(val_src2, val_src1);
ASSERT_EQ(val_src2, val_src2);
ASSERT_EQ(dest_src2, val_src1);
ASSERT_EQ(dest_src2, val_src2);
for (auto i = 0; i < 3; i++) {
ASSERT_EQ(val_src1[i], val_src1[i]);
ASSERT_EQ(val_src1[i], val_src2[i]);
ASSERT_EQ(dest_src1[i], val_src1[i]);
ASSERT_EQ(dest_src1[i], val_src2[i]);
ASSERT_EQ(val_src2[i], val_src1[i]);
ASSERT_EQ(val_src2[i], val_src2[i]);
ASSERT_EQ(dest_src2[i], val_src1[i]);
ASSERT_EQ(dest_src2[i], val_src2[i]);
}
}
void TestPseudoPointDInequality() {
draco::Point3ui val = {0, 1, 2};
draco::Point3ui dest = {1, 2, 3};
draco::PseudoPointD<uint32_t> val_src1(&val[0], 3);
draco::PseudoPointD<uint32_t> val_src2(&val[0], 3);
draco::PseudoPointD<uint32_t> dest_src1(&dest[0], 3);
draco::PseudoPointD<uint32_t> dest_src2(&dest[0], 3);
ASSERT_EQ(val_src1, val_src1);
ASSERT_EQ(val_src1, val_src2);
ASSERT_NE(dest_src1, val_src1);
ASSERT_NE(dest_src1, val_src2);
ASSERT_EQ(val_src2, val_src1);
ASSERT_EQ(val_src2, val_src2);
ASSERT_NE(dest_src2, val_src1);
ASSERT_NE(dest_src2, val_src2);
for (auto i = 0; i < 3; i++) {
ASSERT_EQ(val_src1[i], val_src1[i]);
ASSERT_EQ(val_src1[i], val_src2[i]);
ASSERT_NE(dest_src1[i], val_src1[i]);
ASSERT_NE(dest_src1[i], val_src2[i]);
ASSERT_EQ(val_src2[i], val_src1[i]);
ASSERT_EQ(val_src2[i], val_src2[i]);
ASSERT_NE(dest_src2[i], val_src1[i]);
ASSERT_NE(dest_src2[i], val_src2[i]);
}
}
};
TEST_F(PointDVectorTest, VectorTest) {
TestSize<uint32_t>();
TestContentsDiscrete<uint32_t>();
TestContentsContiguous<uint32_t>();
TestContentsCopy<uint32_t>();
TestIterator<uint32_t>();
TestPoint3Iterator<uint32_t>();
}
TEST_F(PointDVectorTest, PseudoPointDTest) {
TestPseudoPointDSwap();
TestPseudoPointDEquality();
TestPseudoPointDInequality();
}
} // namespace draco

View File

@@ -18,12 +18,13 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include "draco/draco_features.h"
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h"
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h"
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h"
#include "draco/compression/bit_coders/rans_bit_decoder.h" #include "draco/compression/bit_coders/rans_bit_decoder.h"
#include "draco/core/varint_decoding.h" #include "draco/core/varint_decoding.h"
#include "draco/draco_features.h"
namespace draco { namespace draco {
@@ -122,9 +123,8 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder<
++num_parallelograms; ++num_parallelograms;
// Stop processing when we reach the maximum number of allowed // Stop processing when we reach the maximum number of allowed
// parallelograms. // parallelograms.
if (num_parallelograms == kMaxNumParallelograms) { if (num_parallelograms == kMaxNumParallelograms)
break; break;
}
} }
// Proceed to the next corner attached to the vertex. First swing left // Proceed to the next corner attached to the vertex. First swing left
@@ -154,9 +154,8 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder<
for (int i = 0; i < num_parallelograms; ++i) { for (int i = 0; i < num_parallelograms; ++i) {
const int context = num_parallelograms - 1; const int context = num_parallelograms - 1;
const int pos = is_crease_edge_pos[context]++; const int pos = is_crease_edge_pos[context]++;
if (is_crease_edge_[context].size() <= pos) { if (is_crease_edge_[context].size() <= pos)
return false; return false;
}
const bool is_crease = is_crease_edge_[context][pos]; const bool is_crease = is_crease_edge_[context][pos];
if (!is_crease) { if (!is_crease) {
++num_used_parallelograms; ++num_used_parallelograms;
@@ -207,15 +206,12 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder<
// Encode selected edges using separate rans bit coder for each context. // Encode selected edges using separate rans bit coder for each context.
for (int i = 0; i < kMaxNumParallelograms; ++i) { for (int i = 0; i < kMaxNumParallelograms; ++i) {
uint32_t num_flags; uint32_t num_flags;
if (!DecodeVarint<uint32_t>(&num_flags, buffer)) { DecodeVarint<uint32_t>(&num_flags, buffer);
return false;
}
if (num_flags > 0) { if (num_flags > 0) {
is_crease_edge_[i].resize(num_flags); is_crease_edge_[i].resize(num_flags);
RAnsBitDecoder decoder; RAnsBitDecoder decoder;
if (!decoder.StartDecoding(buffer)) { if (!decoder.StartDecoding(buffer))
return false; return false;
}
for (uint32_t j = 0; j < num_flags; ++j) { for (uint32_t j = 0; j < num_flags; ++j) {
is_crease_edge_[i][j] = decoder.DecodeNextBit(); is_crease_edge_[i][j] = decoder.DecodeNextBit();
} }

View File

@@ -108,12 +108,10 @@ class MeshPredictionSchemeConstrainedMultiParallelogramEncoder
int residual_error; int residual_error;
bool operator<(const Error &e) const { bool operator<(const Error &e) const {
if (num_bits < e.num_bits) { if (num_bits < e.num_bits)
return true; return true;
} if (num_bits > e.num_bits)
if (num_bits > e.num_bits) {
return false; return false;
}
return residual_error < e.residual_error; return residual_error < e.residual_error;
} }
}; };
@@ -233,9 +231,8 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
++num_parallelograms; ++num_parallelograms;
// Stop processing when we reach the maximum number of allowed // Stop processing when we reach the maximum number of allowed
// parallelograms. // parallelograms.
if (num_parallelograms == kMaxNumParallelograms) { if (num_parallelograms == kMaxNumParallelograms)
break; break;
}
} }
// Proceed to the next corner attached to the vertex. First swing left // Proceed to the next corner attached to the vertex. First swing left
@@ -307,9 +304,8 @@ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
} }
uint8_t configuration = 0; uint8_t configuration = 0;
for (int j = 0; j < num_parallelograms; ++j) { for (int j = 0; j < num_parallelograms; ++j) {
if (exluded_parallelograms[j]) { if (exluded_parallelograms[j])
continue; continue;
}
for (int c = 0; c < num_components; ++c) { for (int c = 0; c < num_components; ++c) {
multi_pred_vals[c] += pred_vals[j][c]; multi_pred_vals[c] += pred_vals[j][c];
} }

Some files were not shown because too many files have changed in this diff Show More