Update
This commit is contained in:
parent
43b1a3c4fe
commit
f9a39fc84a
106
config/data.py
106
config/data.py
@ -5,6 +5,30 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import maya.cmds as cmds
|
import maya.cmds as cmds
|
||||||
|
|
||||||
|
def Qt():
|
||||||
|
try:
|
||||||
|
from PySide2 import QtCore, QtGui, QtWidgets
|
||||||
|
print("成功加载PySide2")
|
||||||
|
return QtCore, QtGui, QtWidgets
|
||||||
|
except ImportError as e:
|
||||||
|
print(f"PySide2加载失败: {str(e)}")
|
||||||
|
try:
|
||||||
|
from PySide import QtCore, QtGui
|
||||||
|
QtWidgets = QtGui
|
||||||
|
print("成功加载PySide")
|
||||||
|
return QtCore, QtGui, QtWidgets
|
||||||
|
except ImportError as e:
|
||||||
|
cmds.warning(f"PySide加载失败: {str(e)}")
|
||||||
|
try:
|
||||||
|
from PySide6 import QtCore, QtGui, QtWidgets
|
||||||
|
print("成功加载PySide6")
|
||||||
|
return QtCore, QtGui, QtWidgets
|
||||||
|
except ImportError as e:
|
||||||
|
cmds.warning(f"PySide加载失败: {str(e)}")
|
||||||
|
return None, None, None
|
||||||
|
|
||||||
|
QtCore, QtGui, QtWidgets = Qt()
|
||||||
|
|
||||||
#===================================== 2. Global Variables =====================================
|
#===================================== 2. Global Variables =====================================
|
||||||
try:
|
try:
|
||||||
ROOT_PATH = os.path.dirname(INSTALL_PATH).replace("\\", "/")
|
ROOT_PATH = os.path.dirname(INSTALL_PATH).replace("\\", "/")
|
||||||
@ -27,25 +51,33 @@ STYLES_PATH = os.path.join(ROOT_PATH, "resources", "styles").replace("\\", "/")
|
|||||||
DNA_PATH = os.path.join(ROOT_PATH, "resources", "dna").replace("\\", "/")
|
DNA_PATH = os.path.join(ROOT_PATH, "resources", "dna").replace("\\", "/")
|
||||||
DNA_IMG_PATH = os.path.join(ROOT_PATH, "resources", "img").replace("\\", "/")
|
DNA_IMG_PATH = os.path.join(ROOT_PATH, "resources", "img").replace("\\", "/")
|
||||||
|
|
||||||
MAYA_VERSION = cmds.about(version=True)
|
# 统一系统信息获取
|
||||||
SYSTEM_OS = cmds.about(os=True)
|
SYSTEM_OS = "Windows" if cmds.about(os=True).lower().startswith("win") else "Linux"
|
||||||
if MAYA_VERSION in ["2022", "2023", "2024", "2025"]:
|
MAYA_VERSION = str(int(cmds.about(version=True).split(".")[0])) # 直接获取最新版本
|
||||||
PLUGIN_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, MAYA_VERSION).replace("\\", "/")
|
|
||||||
else:
|
|
||||||
print(f"MetaFusion is not supported on Maya {MAYA_VERSION}")
|
|
||||||
|
|
||||||
PYTHON_VERSION = sys.version_info.major
|
|
||||||
if PYTHON_VERSION == 3:
|
|
||||||
PYDNA_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "pydna", f"python{sys.version_info.major}{sys.version_info.minor}").replace("\\", "/")
|
|
||||||
elif PYTHON_VERSION == 3.11:
|
|
||||||
PYDNA_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "python311").replace("\\", "/")
|
|
||||||
elif PYTHON_VERSION == 3.9:
|
|
||||||
PYDNA_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "python397").replace("\\", "/")
|
|
||||||
elif PYTHON_VERSION == 3.10:
|
|
||||||
PYDNA_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "python3108").replace("\\", "/")
|
|
||||||
else:
|
|
||||||
print(f"MetaFusion is not supported on Python {PYTHON_VERSION}")
|
|
||||||
|
|
||||||
|
#===================================== 获取Python版本路径 =====================================
|
||||||
|
# 必须先定义PYTHON_VERSION
|
||||||
|
PYTHON_VERSION = sys.version
|
||||||
|
# 去掉小数点,比如3.10.8 → 3108
|
||||||
|
PYTHON_VERSION = PYTHON_VERSION.replace(".", "")
|
||||||
|
# 获取主版本号和次版本号
|
||||||
|
major_version = int(PYTHON_VERSION[0])
|
||||||
|
minor_version = int(PYTHON_VERSION[1:3]) if len(PYTHON_VERSION) > 1 else None
|
||||||
|
|
||||||
|
# 创建版本元组
|
||||||
|
version_tuple = (major_version,) if minor_version is None else (major_version, minor_version)
|
||||||
|
|
||||||
|
# 调整版本映射表
|
||||||
|
PYTHON_VERSION_MAP = {
|
||||||
|
(3,): "python3", # 所有Python3主版本
|
||||||
|
(3, 9): "python397", # 3.9.x → python397
|
||||||
|
(3, 10): "python3108", # 3.10.x → python3108
|
||||||
|
(3, 11): "python311" # 3.11.x → python311
|
||||||
|
}
|
||||||
|
|
||||||
|
# 按照映射表获取PYTHON_VERSION_DIR
|
||||||
|
PYTHON_VERSION_DIR = PYTHON_VERSION_MAP.get(version_tuple, "python3") # 如果找不到对应版本,默认使用 python3
|
||||||
|
|
||||||
#===================================== 3. Files =====================================
|
#===================================== 3. Files =====================================
|
||||||
# FILES
|
# FILES
|
||||||
@ -55,35 +87,17 @@ TOOL_ICON = os.path.join(ICONS_PATH, f"{TOOL_NAME}Logo.png").replace("\\", "/")
|
|||||||
TOOL_COMMAND_ICON = os.path.join(ICONS_PATH, "CommandButton.png").replace("\\", "/")
|
TOOL_COMMAND_ICON = os.path.join(ICONS_PATH, "CommandButton.png").replace("\\", "/")
|
||||||
TOOL_MOD_FILENAME = f"{TOOL_NAME}.mod"
|
TOOL_MOD_FILENAME = f"{TOOL_NAME}.mod"
|
||||||
|
|
||||||
#===================================== 4. Qt =====================================
|
# 生成最终路径
|
||||||
# Qt
|
PLUGIN_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, MAYA_VERSION).replace("\\", "/")
|
||||||
def Qt():
|
PYDNA_PATH = os.path.join(ROOT_PATH, "plugins", SYSTEM_OS, "pydna", PYTHON_VERSION_DIR).replace("\\", "/")
|
||||||
try:
|
|
||||||
from PySide import QtCore, QtGui, QtWidgets
|
#===================================== 4. 新增工具路径 =====================================
|
||||||
return QtCore, QtGui, QtWidgets
|
# 新增工具路径
|
||||||
except ImportError:
|
BUILDER_PATH = os.path.join(SCRIPTS_PATH, "builder").replace("\\", "/")
|
||||||
try:
|
DNALIB_PATH = os.path.join(SCRIPTS_PATH, "dnalib").replace("\\", "/")
|
||||||
from PySide2 import QtCore, QtGui, QtWidgets
|
|
||||||
return QtCore, QtGui, QtWidgets
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from PySide3 import QtCore, QtGui, QtWidgets
|
|
||||||
return QtCore, QtGui, QtWidgets
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from PySide4 import QtCore, QtGui, QtWidgets
|
|
||||||
return QtCore, QtGui, QtWidgets
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from PySide5 import QtCore, QtGui, QtWidgets
|
|
||||||
return QtCore, QtGui, QtWidgets
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from PySide6 import QtCore, QtGui, QtWidgets
|
|
||||||
return QtCore, QtGui, QtWidgets
|
|
||||||
except ImportError:
|
|
||||||
print("未找到 Qt 模块")
|
|
||||||
return None, None, None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
27
dnacalib/CMakeLists.txt
Normal file
27
dnacalib/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
project(dnacalib)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMakeModulesExtra")
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_subdirectory(DNACalib)
|
||||||
|
add_subdirectory(SPyUS)
|
||||||
|
add_subdirectory(PyDNA)
|
||||||
|
add_subdirectory(PyDNACalib)
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Package build artifacts
|
||||||
|
set(CPACK_GENERATOR "ZIP")
|
||||||
|
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
||||||
|
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF)
|
||||||
|
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
|
||||||
|
string(CONCAT CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}"
|
||||||
|
"-${CMAKE_PROJECT_VERSION}"
|
||||||
|
"-${CMAKE_SYSTEM_NAME}"
|
||||||
|
"-${CMAKE_SYSTEM_PROCESSOR}"
|
||||||
|
"-${CMAKE_CXX_COMPILER_ID}${CMAKE_CXX_COMPILER_VERSION}"
|
||||||
|
"-${CMAKE_BUILD_TYPE}"
|
||||||
|
"-${PYTHON3_EXACT_VERSION}"
|
||||||
|
"-SHARED")
|
||||||
|
include(CPack)
|
5
dnacalib/CMakeModulesExtra/CMakeModulesExtra.cmake
Normal file
5
dnacalib/CMakeModulesExtra/CMakeModulesExtra.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(CMakeModulesExtra_DIRS "${CMAKE_CURRENT_LIST_DIR}/install"
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/symbols"
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/utilities"
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/version")
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMakeModulesExtra_DIRS})
|
12
dnacalib/CMakeModulesExtra/install/Config.cmake.in
Normal file
12
dnacalib/CMakeModulesExtra/install/Config.cmake.in
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@)
|
||||||
|
|
||||||
|
if(NOT TARGET @REPRESENTATIVE_TARGET_NAME@)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR@")
|
||||||
|
set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_LIB_DIR@")
|
||||||
|
|
||||||
|
check_required_components(@PROJECT_NAME@)
|
104
dnacalib/CMakeModulesExtra/install/InstallLibrary.cmake
Normal file
104
dnacalib/CMakeModulesExtra/install/InstallLibrary.cmake
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# Standard CMake library installation procedure
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# include(InstallLibrary)
|
||||||
|
# install_library(my_target)
|
||||||
|
#
|
||||||
|
# Module dependencies:
|
||||||
|
# CMakePackageConfigHelpers
|
||||||
|
# GNUInstallDirs
|
||||||
|
#
|
||||||
|
# Preconditions:
|
||||||
|
# Assumes that standard, global CMake variables are accessible, such as PROJECT_NAME
|
||||||
|
|
||||||
|
set(INSTALL_LIBRARY_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
|
||||||
|
macro(install_library target_name)
|
||||||
|
# component_name is an optional argument, and will default to the given target_name
|
||||||
|
set(COMPONENT_NAME ${target_name})
|
||||||
|
set(extra_args ${ARGN})
|
||||||
|
list(LENGTH extra_args num_extra_args)
|
||||||
|
if(${num_extra_args} GREATER 0)
|
||||||
|
list(GET extra_args 0 COMPONENT_NAME)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
set(REPRESENTATIVE_TARGET_NAME ${target_name})
|
||||||
|
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
|
# Set install destinations and associate installed target files with an export
|
||||||
|
install(TARGETS ${REPRESENTATIVE_TARGET_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
COMPONENT ${COMPONENT_NAME}
|
||||||
|
RUNTIME
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME}
|
||||||
|
LIBRARY
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME}
|
||||||
|
NAMELINK_COMPONENT ${COMPONENT_NAME}
|
||||||
|
ARCHIVE
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME}
|
||||||
|
PUBLIC_HEADER
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
|
||||||
|
# Write build-tree targets
|
||||||
|
export(TARGETS ${REPRESENTATIVE_TARGET_NAME}
|
||||||
|
FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::)
|
||||||
|
# Allow find_package to locate package without installing it (find it's build-tree)
|
||||||
|
export(PACKAGE ${PROJECT_NAME})
|
||||||
|
|
||||||
|
# Write install-tree targets
|
||||||
|
install(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION ${INSTALL_CONFIGDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME})
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
# Generate build-tree configuration
|
||||||
|
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
set(LIB_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
configure_package_config_file("${INSTALL_LIBRARY_SOURCE_DIR}/Config.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
|
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
PATH_VARS INCLUDE_DIR LIB_DIR
|
||||||
|
INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
# Generate install-tree configuration
|
||||||
|
set(INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
set(LIB_DIR ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
configure_package_config_file("${INSTALL_LIBRARY_SOURCE_DIR}/Config.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.install.cmake"
|
||||||
|
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
|
||||||
|
PATH_VARS INCLUDE_DIR LIB_DIR)
|
||||||
|
|
||||||
|
# Generate package version file
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
|
# Install the install-tree configuration
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.install.cmake"
|
||||||
|
DESTINATION ${INSTALL_CONFIGDIR}
|
||||||
|
RENAME "${PROJECT_NAME}Config.cmake"
|
||||||
|
COMPONENT ${COMPONENT_NAME})
|
||||||
|
|
||||||
|
# Install package version file
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
DESTINATION ${INSTALL_CONFIGDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME})
|
||||||
|
|
||||||
|
# Install include files
|
||||||
|
install(DIRECTORY include/
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
COMPONENT ${COMPONENT_NAME})
|
||||||
|
endmacro()
|
27
dnacalib/CMakeModulesExtra/symbols/Defs.h.in
Normal file
27
dnacalib/CMakeModulesExtra/symbols/Defs.h.in
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((dllexport))
|
||||||
|
#define DLL_IMPORT __attribute__((dllimport))
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define DLL_IMPORT DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(@DEF_BUILD_SHARED_NAME@)
|
||||||
|
// Build shared library
|
||||||
|
#define @DEF_EXPORT_ATTR_NAME@ DLL_EXPORT
|
||||||
|
#elif defined(@DEF_USE_SHARED_NAME@)
|
||||||
|
// Use shared library
|
||||||
|
#define @DEF_EXPORT_ATTR_NAME@ DLL_IMPORT
|
||||||
|
#else
|
||||||
|
// Build or use static library
|
||||||
|
#define @DEF_EXPORT_ATTR_NAME@
|
||||||
|
#endif
|
25
dnacalib/CMakeModulesExtra/symbols/Symbols.cmake
Normal file
25
dnacalib/CMakeModulesExtra/symbols/Symbols.cmake
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Generate header file that contains preprocessor definitions for exporting symbols from shared libraries.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# include(Symbols)
|
||||||
|
# generate_export_definitions(
|
||||||
|
# OUTPUT_FILE /abs/path/to/include/mylib/Defs.h
|
||||||
|
# EXPORT_ATTR_NAME MLAPI
|
||||||
|
# BUILD_SHARED_NAME ML_BUILD_SHARED
|
||||||
|
# USE_SHARED_NAME ML_SHARED)
|
||||||
|
#
|
||||||
|
# Module dependencies:
|
||||||
|
# CMakeParseArguments
|
||||||
|
|
||||||
|
set(SYMBOLS_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
function(generate_export_definitions)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args OUTPUT_FILE EXPORT_ATTR_NAME BUILD_SHARED_NAME USE_SHARED_NAME)
|
||||||
|
set(multi_value_args)
|
||||||
|
cmake_parse_arguments(DEF "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
||||||
|
configure_file("${SYMBOLS_SOURCE_DIR}/Defs.h.in"
|
||||||
|
"${DEF_OUTPUT_FILE}"
|
||||||
|
@ONLY
|
||||||
|
NEWLINE_STYLE LF)
|
||||||
|
endfunction()
|
@ -0,0 +1,43 @@
|
|||||||
|
# From the list of passed in compiler flags, add only those to the target
|
||||||
|
# which are supported by the selected compiler
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# include(SupportedCompileOptions)
|
||||||
|
# set(CXX_FLAGS -Wall -Wextra -Wpedantic -Wduplicated-branches -Wunused)
|
||||||
|
# target_supported_compile_options(target_name PUBLIC "${CXX_FLAGS}")
|
||||||
|
#
|
||||||
|
# Module dependencies:
|
||||||
|
# CheckCXXCompilerFlag
|
||||||
|
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
|
function(target_add_cxx_flag_if_supported target_name visibility flag_name)
|
||||||
|
# Check if flag was already checked whether it's supported or not
|
||||||
|
if(${flag_name} IN_LIST SUPPORTED_FLAGS_CACHE)
|
||||||
|
set(has_flag_${flag_name} TRUE)
|
||||||
|
elseif(${flag_name} IN_LIST UNSUPPORTED_FLAGS_CACHE)
|
||||||
|
set(has_flag_${flag_name} FALSE)
|
||||||
|
endif()
|
||||||
|
# If not found in cache, perform the check now and cache the result
|
||||||
|
if(NOT DEFINED has_flag_${flag_name})
|
||||||
|
check_cxx_compiler_flag("${flag_name}" has_flag_${flag_name})
|
||||||
|
# It's safe to rely on cache variables as the only parameter that may affect the validity
|
||||||
|
# of their content is the chosen compiler itself, and changing a compiler forces CMake to
|
||||||
|
# automatically purge the cache anyway.
|
||||||
|
if(has_flag_${flag_name})
|
||||||
|
set(SUPPORTED_FLAGS_CACHE "${SUPPORTED_FLAGS_CACHE};${flag_name}" CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
set(UNSUPPORTED_FLAGS_CACHE "${UNSUPPORTED_FLAGS_CACHE};${flag_name}" CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
# Enable flag is supported
|
||||||
|
if(has_flag_${flag_name})
|
||||||
|
target_compile_options(${target_name} ${visibility} ${flag_name})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(target_supported_compile_options target_name visibility flags)
|
||||||
|
foreach(flag_name IN LISTS flags)
|
||||||
|
target_add_cxx_flag_if_supported(${target_name} ${visibility} ${flag_name})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
64
dnacalib/CMakeModulesExtra/version/Version.rc.in
Normal file
64
dnacalib/CMakeModulesExtra/version/Version.rc.in
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
#define VER_APPLICATION_TYPE 0
|
||||||
|
#define VER_SHARED_LIBRARY_TYPE 1
|
||||||
|
#define VER_STATIC_LIBRARY_TYPE 2
|
||||||
|
|
||||||
|
#define VER_TARGET_TYPE @VI_TARGET_TYPE@
|
||||||
|
#if VER_TARGET_TYPE == VER_APPLICATION_TYPE
|
||||||
|
#define VER_FILETYPE VFT_APP
|
||||||
|
#define VER_FILEEXT ".exe\0"
|
||||||
|
#elif VER_TARGET_TYPE == VER_SHARED_LIBRARY_TYPE
|
||||||
|
#define VER_FILETYPE VFT_DLL
|
||||||
|
#define VER_FILEEXT ".dll\0"
|
||||||
|
#elif VER_TARGET_TYPE == VER_STATIC_LIBRARY_TYPE
|
||||||
|
#define VER_FILETYPE VFT_STATIC_LIB
|
||||||
|
#define VER_FILEEXT ".lib\0"
|
||||||
|
#else
|
||||||
|
#define VER_FILETYPE VFT_UNKNOWN
|
||||||
|
#define VER_FILEEXT "\0"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define VER_NAME_STR "@VI_NAME@\0"
|
||||||
|
#define VER_FILENAME_STR "@VI_FILENAME@" VER_FILEEXT
|
||||||
|
#define VER_VERSION @VI_MAJOR_VERSION@, @VI_MINOR_VERSION@, @VI_PATCH_VERSION@, 0
|
||||||
|
#define VER_VERSION_STR "@VI_MAJOR_VERSION@.@VI_MINOR_VERSION@.@VI_PATCH_VERSION@\0"
|
||||||
|
#define VER_DESCRIPTION_STR "@VI_NAME@ v@VI_MAJOR_VERSION@.@VI_MINOR_VERSION@.@VI_PATCH_VERSION@\0"
|
||||||
|
#define VER_COMPANY_NAME_STR "@VI_COMPANY_NAME@\0"
|
||||||
|
#define VER_COPYRIGHT_STR "@VI_COPYRIGHT@\0"
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define VER_DEBUG 0
|
||||||
|
#else
|
||||||
|
#define VER_DEBUG VS_FF_DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION VER_VERSION
|
||||||
|
PRODUCTVERSION VER_VERSION
|
||||||
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
|
FILEFLAGS VER_DEBUG
|
||||||
|
FILEOS VOS__WINDOWS32
|
||||||
|
FILETYPE VFT_DLL
|
||||||
|
FILESUBTYPE VFT2_UNKNOWN
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904E4"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", VER_COMPANY_NAME_STR
|
||||||
|
VALUE "FileDescription", VER_DESCRIPTION_STR
|
||||||
|
VALUE "FileVersion", VER_VERSION_STR
|
||||||
|
VALUE "InternalName", VER_FILENAME_STR
|
||||||
|
VALUE "LegalCopyright", VER_COPYRIGHT_STR
|
||||||
|
VALUE "OriginalFilename", VER_FILENAME_STR
|
||||||
|
VALUE "ProductName", VER_NAME_STR
|
||||||
|
VALUE "ProductVersion", VER_VERSION_STR
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1252
|
||||||
|
END
|
||||||
|
END
|
26
dnacalib/CMakeModulesExtra/version/VersionHeader.cmake
Normal file
26
dnacalib/CMakeModulesExtra/version/VersionHeader.cmake
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generate a Version.h file populated with the supplied values
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# include(VersionHeader)
|
||||||
|
# generate_version_header(
|
||||||
|
# OUTPUT_FILE "/path/to/lib/include/name/version/Version.h"
|
||||||
|
# PREFIX "MYLIB"
|
||||||
|
# MAJOR 1
|
||||||
|
# MINOR 0
|
||||||
|
# PATCH 3)
|
||||||
|
#
|
||||||
|
# Module dependencies:
|
||||||
|
# CMakeParseArguments
|
||||||
|
|
||||||
|
set(VERSION_HEADER_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
function(generate_version_header)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args OUTPUT_FILE PREFIX MAJOR MINOR PATCH)
|
||||||
|
set(multi_value_args)
|
||||||
|
cmake_parse_arguments(VERSION "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
||||||
|
configure_file("${VERSION_HEADER_SOURCE_DIR}/VersionHeader.h.in"
|
||||||
|
${VERSION_OUTPUT_FILE}
|
||||||
|
@ONLY
|
||||||
|
NEWLINE_STYLE LF)
|
||||||
|
endfunction()
|
8
dnacalib/CMakeModulesExtra/version/VersionHeader.h.in
Normal file
8
dnacalib/CMakeModulesExtra/version/VersionHeader.h.in
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define @VERSION_PREFIX@_MAJOR_VERSION @VERSION_MAJOR@
|
||||||
|
#define @VERSION_PREFIX@_MINOR_VERSION @VERSION_MINOR@
|
||||||
|
#define @VERSION_PREFIX@_PATCH_VERSION @VERSION_PATCH@
|
||||||
|
#define @VERSION_PREFIX@_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
|
51
dnacalib/CMakeModulesExtra/version/VersionInfo.cmake
Normal file
51
dnacalib/CMakeModulesExtra/version/VersionInfo.cmake
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# Generate a Version.rc file populated with the supplied values and add the
|
||||||
|
# generated file to the target's list of sources
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# include(VersionInfo)
|
||||||
|
# add_version_info(
|
||||||
|
# target_name
|
||||||
|
# NAME "Product name"
|
||||||
|
# FILENAME "SomeFile.dll"
|
||||||
|
# MAJOR_VERSION 1
|
||||||
|
# MINOR_VERSION 0
|
||||||
|
# PATCH_VERSION 3
|
||||||
|
# COMPANY_NAME "Some Company"
|
||||||
|
# COPYRIGHT "Copyright notice")
|
||||||
|
#
|
||||||
|
# Module dependencies:
|
||||||
|
# CMakeParseArguments
|
||||||
|
|
||||||
|
set(VERSION_INFO_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
function(add_version_info target_name)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args NAME
|
||||||
|
FILENAME
|
||||||
|
MAJOR_VERSION
|
||||||
|
MINOR_VERSION
|
||||||
|
PATCH_VERSION
|
||||||
|
COMPANY_NAME
|
||||||
|
COPYRIGHT)
|
||||||
|
set(multi_value_args)
|
||||||
|
cmake_parse_arguments(VI "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
||||||
|
|
||||||
|
get_target_property(TARGET_TYPE ${target_name} TYPE)
|
||||||
|
if(TARGET_TYPE STREQUAL EXECUTABLE)
|
||||||
|
set(VI_TARGET_TYPE 0)
|
||||||
|
elseif(TARGET_TYPE STREQUAL SHARED_LIBRARY)
|
||||||
|
set(VI_TARGET_TYPE 1)
|
||||||
|
elseif(TARGET_TYPE STREQUAL STATIC_LIBRARY)
|
||||||
|
set(VI_TARGET_TYPE 2)
|
||||||
|
else()
|
||||||
|
set(VI_TARGET_TYPE 3)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_target_property(TARGET_BINARY_DIR ${target_name} BINARY_DIR)
|
||||||
|
set(version_output_name "${TARGET_BINARY_DIR}/Version.rc")
|
||||||
|
configure_file("${VERSION_INFO_SOURCE_DIR}/Version.rc.in"
|
||||||
|
${version_output_name}
|
||||||
|
@ONLY)
|
||||||
|
target_sources(${target_name} PRIVATE ${version_output_name})
|
||||||
|
|
||||||
|
endfunction()
|
278
dnacalib/DNACalib/CMakeLists.txt
Normal file
278
dnacalib/DNACalib/CMakeLists.txt
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Project setup
|
||||||
|
set(DNAC dnacalib)
|
||||||
|
set(DNAC_VERSION 6.8.0)
|
||||||
|
# Prevent in-source-tree builds
|
||||||
|
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||||
|
# Create compilation database
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
project(DNACalib VERSION ${DNAC_VERSION} LANGUAGES CXX)
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
set(CMAKE_MODULES_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_MODULES_ROOT_DIR})
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
function(module_exists module_name)
|
||||||
|
include(${module_name} OPTIONAL RESULT_VARIABLE found)
|
||||||
|
set("${module_name}_FOUND" ${found} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Make custom cmake modules available
|
||||||
|
module_exists(CMakeModulesExtra)
|
||||||
|
if(NOT CMakeModulesExtra_FOUND)
|
||||||
|
include(CMakeModulesExtraLoader)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMakeModulesExtra)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMakeModulesExtra_DIRS})
|
||||||
|
|
||||||
|
option(READ_ONLY_SOURCE_TREE "Prevent autogeneration of files in source tree" OFF)
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Generate version information header
|
||||||
|
if (NOT READ_ONLY_SOURCE_TREE)
|
||||||
|
include(VersionHeader)
|
||||||
|
generate_version_header(
|
||||||
|
OUTPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/dnacalib/version/Version.h"
|
||||||
|
PREFIX "DNAC"
|
||||||
|
MAJOR ${PROJECT_VERSION_MAJOR}
|
||||||
|
MINOR ${PROJECT_VERSION_MINOR}
|
||||||
|
PATCH ${PROJECT_VERSION_PATCH})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Generate export definitions header
|
||||||
|
if (NOT READ_ONLY_SOURCE_TREE)
|
||||||
|
include(Symbols)
|
||||||
|
generate_export_definitions(
|
||||||
|
OUTPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/dnacalib/Defs.h"
|
||||||
|
EXPORT_ATTR_NAME DNACAPI
|
||||||
|
BUILD_SHARED_NAME DNAC_BUILD_SHARED
|
||||||
|
USE_SHARED_NAME DNAC_SHARED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Source code
|
||||||
|
set(HEADERS
|
||||||
|
include/dnacalib/DNACalib.h
|
||||||
|
include/dnacalib/Command.h
|
||||||
|
include/dnacalib/Defs.h
|
||||||
|
|
||||||
|
include/dnacalib/commands/CalculateMeshLowerLODsCommand.h
|
||||||
|
include/dnacalib/commands/ClearBlendShapesCommand.h
|
||||||
|
include/dnacalib/commands/CommandSequence.h
|
||||||
|
include/dnacalib/commands/ConditionalCommand.h
|
||||||
|
include/dnacalib/commands/PruneBlendShapeTargetsCommand.h
|
||||||
|
include/dnacalib/commands/RemoveAnimatedMapCommand.h
|
||||||
|
include/dnacalib/commands/RemoveBlendShapeCommand.h
|
||||||
|
include/dnacalib/commands/RemoveJointAnimationCommand.h
|
||||||
|
include/dnacalib/commands/RemoveJointCommand.h
|
||||||
|
include/dnacalib/commands/RemoveMeshCommand.h
|
||||||
|
include/dnacalib/commands/RenameAnimatedMapCommand.h
|
||||||
|
include/dnacalib/commands/RenameBlendShapeCommand.h
|
||||||
|
include/dnacalib/commands/RenameJointCommand.h
|
||||||
|
include/dnacalib/commands/RenameMeshCommand.h
|
||||||
|
include/dnacalib/commands/RotateCommand.h
|
||||||
|
include/dnacalib/commands/ScaleCommand.h
|
||||||
|
include/dnacalib/commands/SetBlendShapeTargetDeltasCommand.h
|
||||||
|
include/dnacalib/commands/SetLODsCommand.h
|
||||||
|
include/dnacalib/commands/SetNeutralJointRotationsCommand.h
|
||||||
|
include/dnacalib/commands/SetNeutralJointTranslationsCommand.h
|
||||||
|
include/dnacalib/commands/SetSkinWeightsCommand.h
|
||||||
|
include/dnacalib/commands/SetVertexPositionsCommand.h
|
||||||
|
include/dnacalib/commands/TranslateCommand.h
|
||||||
|
include/dnacalib/commands/VectorOperations.h
|
||||||
|
|
||||||
|
include/dnacalib/dna/DNACalibDNAReader.h
|
||||||
|
|
||||||
|
include/dnacalib/types/Aliases.h
|
||||||
|
|
||||||
|
include/dnacalib/version/Version.h
|
||||||
|
include/dnacalib/version/VersionInfo.h)
|
||||||
|
set(SOURCES
|
||||||
|
src/dnacalib/Command.cpp
|
||||||
|
src/dnacalib/CommandImplBase.h
|
||||||
|
src/dnacalib/TypeDefs.h
|
||||||
|
|
||||||
|
src/dnacalib/commands/CalculateMeshLowerLODsCommand.cpp
|
||||||
|
src/dnacalib/commands/CalculateMeshLowerLODsCommandImpl.cpp
|
||||||
|
src/dnacalib/commands/CalculateMeshLowerLODsCommandImpl.h
|
||||||
|
src/dnacalib/commands/ClearBlendShapesCommand.cpp
|
||||||
|
src/dnacalib/commands/CommandSequence.cpp
|
||||||
|
src/dnacalib/commands/PruneBlendShapeTargetsCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveAnimatedMapCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveBlendShapeCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveJointAnimationCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveJointCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveMeshCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameAnimatedMapCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameBlendShapeCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameJointCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameMeshCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameResourceCommand.h
|
||||||
|
src/dnacalib/commands/RotateCommand.cpp
|
||||||
|
src/dnacalib/commands/ScaleCommand.cpp
|
||||||
|
src/dnacalib/commands/SetBlendShapeTargetDeltasCommand.cpp
|
||||||
|
src/dnacalib/commands/SetLODsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetNeutralJointRotationsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetNeutralJointTranslationsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetSkinWeightsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetVertexPositionsCommand.cpp
|
||||||
|
src/dnacalib/commands/TranslateCommand.cpp
|
||||||
|
src/dnacalib/commands/SupportFactories.h
|
||||||
|
|
||||||
|
src/dnacalib/dna/DNACalibDNAReaderImpl.cpp
|
||||||
|
src/dnacalib/dna/DNACalibDNAReaderImpl.h
|
||||||
|
src/dnacalib/dna/BaseImpl.h
|
||||||
|
src/dnacalib/dna/DenormalizedData.h
|
||||||
|
src/dnacalib/dna/DNA.h
|
||||||
|
src/dnacalib/dna/LODConstraint.cpp
|
||||||
|
src/dnacalib/dna/LODConstraint.h
|
||||||
|
src/dnacalib/dna/LODMapping.cpp
|
||||||
|
src/dnacalib/dna/LODMapping.h
|
||||||
|
src/dnacalib/dna/ReaderImpl.h
|
||||||
|
src/dnacalib/dna/SurjectiveMapping.h
|
||||||
|
src/dnacalib/dna/WriterImpl.h
|
||||||
|
src/dnacalib/dna/filters/AnimatedMapFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/AnimatedMapFilter.h
|
||||||
|
src/dnacalib/dna/filters/BlendShapeFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/BlendShapeFilter.h
|
||||||
|
src/dnacalib/dna/filters/JointFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/JointFilter.h
|
||||||
|
src/dnacalib/dna/filters/MeshFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/MeshFilter.h
|
||||||
|
src/dnacalib/dna/filters/Remap.h
|
||||||
|
|
||||||
|
src/dnacalib/types/BoundingBox.h
|
||||||
|
src/dnacalib/types/Triangle.cpp
|
||||||
|
src/dnacalib/types/Triangle.h
|
||||||
|
src/dnacalib/types/UVBarycentricMapping.cpp
|
||||||
|
src/dnacalib/types/UVBarycentricMapping.h
|
||||||
|
|
||||||
|
src/dnacalib/utils/Algorithm.h
|
||||||
|
src/dnacalib/utils/Extd.h
|
||||||
|
src/dnacalib/utils/ScopedEnumEx.h
|
||||||
|
|
||||||
|
src/dnacalib/version/VersionInfo.cpp)
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Add target and build options
|
||||||
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||||
|
|
||||||
|
set(DNAC_DEFAULT_LIBRARY_TYPE STATIC)
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
set(DNAC_DEFAULT_LIBRARY_TYPE SHARED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(DNAC_LIBRARY_TYPE ${DNAC_DEFAULT_LIBRARY_TYPE} CACHE STRING "Build DNACalib as a library of type")
|
||||||
|
set_property(CACHE DNAC_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED MODULE)
|
||||||
|
|
||||||
|
# Python wrapper builds a shared object (e.g. .pyd, .so), so DNACalib library has to be built with -fPIC flag.
|
||||||
|
option(DNAC_BUILD_PIC "Build with position independent code" ON)
|
||||||
|
|
||||||
|
add_library(${DNAC} ${DNAC_LIBRARY_TYPE})
|
||||||
|
add_library(DNACalib::dnacalib ALIAS ${DNAC})
|
||||||
|
|
||||||
|
set_target_properties(${DNAC} PROPERTIES
|
||||||
|
CXX_STANDARD 11
|
||||||
|
CXX_STANDARD_REQUIRED NO
|
||||||
|
CXX_EXTENSIONS NO
|
||||||
|
CXX_VISIBILITY_PRESET hidden
|
||||||
|
POSITION_INDEPENDENT_CODE ${DNAC_BUILD_PIC}
|
||||||
|
SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||||
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||||
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||||
|
|
||||||
|
if (DNAC_LIBRARY_TYPE STREQUAL SHARED)
|
||||||
|
target_compile_definitions(${DNAC} PUBLIC DNAC_SHARED PRIVATE DNAC_BUILD_SHARED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
set(DNAC_PUBLIC_INCLUDE_DIRS
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
|
|
||||||
|
target_include_directories(${DNAC}
|
||||||
|
PUBLIC
|
||||||
|
${DNAC_PUBLIC_INCLUDE_DIRS}
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
|
option(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
|
||||||
|
if(MSVC)
|
||||||
|
set(CXX_FLAGS /W4 /w14061 /w14062 /w14121 /w14242 /w14245
|
||||||
|
/w14254 /w14263 /w14265 /w14266 /w14287 /w14289 /w14296
|
||||||
|
/w14302 /w14311 /w14365 /w14388 /w14545 /w14546 /w14547
|
||||||
|
/w14549 /w14555 /w14619 /w14640 /w14826 /w14905 /w14906
|
||||||
|
/w14928 /w14987 /w14946)
|
||||||
|
if(TREAT_WARNINGS_AS_ERRORS)
|
||||||
|
list(APPEND CXX_FLAGS /WX)
|
||||||
|
endif()
|
||||||
|
set(CXX_EXTRA_FLAGS /permissive-)
|
||||||
|
else()
|
||||||
|
set(CXX_FLAGS -Wall -Wextra -Wpedantic)
|
||||||
|
if(TREAT_WARNINGS_AS_ERRORS)
|
||||||
|
list(APPEND CXX_FLAGS -Werror)
|
||||||
|
endif()
|
||||||
|
set(CXX_EXTRA_FLAGS -Wcast-align -Wconversion -Wduplicated-branches
|
||||||
|
-Wduplicated-cond -Wexit-time-destructors
|
||||||
|
-Wglobal-constructors -Wlogical-op -Wmissing-noreturn
|
||||||
|
-Wnon-virtual-dtor -Wnull-dereference -Wold-style-cast
|
||||||
|
-Woverloaded-virtual -Wshadow -Wsign-conversion -Wunreachable-code
|
||||||
|
-Wunused -Wuseless-cast -Wweak-vtables -Wno-unknown-pragmas)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_options(${DNAC} PRIVATE "${CXX_FLAGS}")
|
||||||
|
include(SupportedCompileOptions)
|
||||||
|
target_supported_compile_options(${DNAC} PRIVATE "${CXX_EXTRA_FLAGS}")
|
||||||
|
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Dependencies
|
||||||
|
include(DNACDependencies)
|
||||||
|
|
||||||
|
set(ADAPTABLE_HEADERS)
|
||||||
|
foreach(hdr IN LISTS HEADERS)
|
||||||
|
list(APPEND ADAPTABLE_HEADERS $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${hdr}> $<INSTALL_INTERFACE:${hdr}>)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES})
|
||||||
|
target_sources(${DNAC} PRIVATE ${SOURCES} ${OBJECT_SOURCES} PUBLIC ${ADAPTABLE_HEADERS})
|
||||||
|
target_link_libraries(${DNAC} PUBLIC ${DNAC_PUBLIC_DEPENDENCIES} PRIVATE ${DNAC_PRIVATE_DEPENDENCIES})
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# VersionInfo
|
||||||
|
if(WIN32 AND (DNAC_LIBRARY_TYPE STREQUAL SHARED OR DNAC_LIBRARY_TYPE STREQUAL MODULE))
|
||||||
|
include(VersionInfo)
|
||||||
|
add_version_info(${DNAC}
|
||||||
|
NAME ${PROJECT_NAME}
|
||||||
|
FILENAME "${DNAC}.dll"
|
||||||
|
MAJOR_VERSION ${PROJECT_VERSION_MAJOR}
|
||||||
|
MINOR_VERSION ${PROJECT_VERSION_MINOR}
|
||||||
|
PATCH_VERSION ${PROJECT_VERSION_PATCH}
|
||||||
|
COMPANY_NAME "Epic Games"
|
||||||
|
COPYRIGHT "Copyright Epic Games, Inc. All Rights Reserved.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Export and install target
|
||||||
|
include(InstallLibrary)
|
||||||
|
install_library(${DNAC})
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Examples
|
||||||
|
option(DNAC_BUILD_EXAMPLES "Build examples" ON)
|
||||||
|
if(DNAC_BUILD_EXAMPLES)
|
||||||
|
set(COPY_LIB_TO_EXAMPLES OFF)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
set(COPY_LIB_TO_EXAMPLES ON)
|
||||||
|
endif()
|
||||||
|
add_subdirectory(examples)
|
||||||
|
endif()
|
17
dnacalib/DNACalib/README.md
Normal file
17
dnacalib/DNACalib/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# DNACalib
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Use [CMake](https://cmake.org/) to generate the build-scripts required for building _DNACalib_, e.g. by executing the following commands from the project root directory:
|
||||||
|
|
||||||
|
```
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
```
|
||||||
|
|
||||||
|
And subsequently, to start the build process:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake --build .
|
||||||
|
```
|
239
dnacalib/DNACalib/cmake/DNACDependencies.cmake
Normal file
239
dnacalib/DNACalib/cmake/DNACDependencies.cmake
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
set(INCLUDES
|
||||||
|
include/dna/BinaryStreamReader.h
|
||||||
|
include/dna/BinaryStreamWriter.h
|
||||||
|
include/dna/DataLayer.h
|
||||||
|
include/dna/Defs.h
|
||||||
|
include/dna/JSONStreamReader.h
|
||||||
|
include/dna/JSONStreamWriter.h
|
||||||
|
include/dna/Reader.h
|
||||||
|
include/dna/StreamReader.h
|
||||||
|
include/dna/StreamWriter.h
|
||||||
|
include/dna/Writer.h
|
||||||
|
include/dna/layers/BehaviorReader.h
|
||||||
|
include/dna/layers/BehaviorWriter.h
|
||||||
|
include/dna/layers/DefinitionReader.h
|
||||||
|
include/dna/layers/DefinitionWriter.h
|
||||||
|
include/dna/layers/Descriptor.h
|
||||||
|
include/dna/layers/DescriptorReader.h
|
||||||
|
include/dna/layers/DescriptorWriter.h
|
||||||
|
include/dna/layers/Geometry.h
|
||||||
|
include/dna/layers/GeometryReader.h
|
||||||
|
include/dna/layers/GeometryWriter.h
|
||||||
|
include/dna/types/Aliases.h
|
||||||
|
include/dna/types/ArrayView.h
|
||||||
|
include/dna/types/StringView.h
|
||||||
|
include/dna/types/Vector3.h
|
||||||
|
include/dna/version/Version.h
|
||||||
|
include/dnacalib/Command.h
|
||||||
|
include/dnacalib/DNACalib.h
|
||||||
|
include/dnacalib/Defs.h
|
||||||
|
include/dnacalib/commands/CalculateMeshLowerLODsCommand.h
|
||||||
|
include/dnacalib/commands/ClearBlendShapesCommand.h
|
||||||
|
include/dnacalib/commands/CommandSequence.h
|
||||||
|
include/dnacalib/commands/ConditionalCommand.h
|
||||||
|
include/dnacalib/commands/PruneBlendShapeTargetsCommand.h
|
||||||
|
include/dnacalib/commands/RemoveAnimatedMapCommand.h
|
||||||
|
include/dnacalib/commands/RemoveBlendShapeCommand.h
|
||||||
|
include/dnacalib/commands/RemoveJointAnimationCommand.h
|
||||||
|
include/dnacalib/commands/RemoveJointCommand.h
|
||||||
|
include/dnacalib/commands/RemoveMeshCommand.h
|
||||||
|
include/dnacalib/commands/RenameAnimatedMapCommand.h
|
||||||
|
include/dnacalib/commands/RenameBlendShapeCommand.h
|
||||||
|
include/dnacalib/commands/RenameJointCommand.h
|
||||||
|
include/dnacalib/commands/RenameMeshCommand.h
|
||||||
|
include/dnacalib/commands/RotateCommand.h
|
||||||
|
include/dnacalib/commands/ScaleCommand.h
|
||||||
|
include/dnacalib/commands/SetBlendShapeTargetDeltasCommand.h
|
||||||
|
include/dnacalib/commands/SetLODsCommand.h
|
||||||
|
include/dnacalib/commands/SetNeutralJointRotationsCommand.h
|
||||||
|
include/dnacalib/commands/SetNeutralJointTranslationsCommand.h
|
||||||
|
include/dnacalib/commands/SetSkinWeightsCommand.h
|
||||||
|
include/dnacalib/commands/SetVertexPositionsCommand.h
|
||||||
|
include/dnacalib/commands/TranslateCommand.h
|
||||||
|
include/dnacalib/commands/VectorOperations.h
|
||||||
|
include/dnacalib/dna/DNACalibDNAReader.h
|
||||||
|
include/dnacalib/types/Aliases.h
|
||||||
|
include/dnacalib/version/Version.h
|
||||||
|
include/dnacalib/version/VersionInfo.h
|
||||||
|
include/pma/Defs.h
|
||||||
|
include/pma/MemoryResource.h
|
||||||
|
include/pma/PolyAllocator.h
|
||||||
|
include/pma/ScopedPtr.h
|
||||||
|
include/pma/TypeDefs.h
|
||||||
|
include/pma/resources/AlignedMemoryResource.h
|
||||||
|
include/pma/resources/ArenaMemoryResource.h
|
||||||
|
include/pma/resources/DefaultMemoryResource.h
|
||||||
|
include/pma/utils/ManagedInstance.h
|
||||||
|
include/pma/version/Version.h
|
||||||
|
include/status/Defs.h
|
||||||
|
include/status/Provider.h
|
||||||
|
include/status/Status.h
|
||||||
|
include/status/StatusCode.h
|
||||||
|
include/status/version/Version.h
|
||||||
|
include/trio/Concepts.h
|
||||||
|
include/trio/Defs.h
|
||||||
|
include/trio/Stream.h
|
||||||
|
include/trio/streams/FileStream.h
|
||||||
|
include/trio/streams/MemoryMappedFileStream.h
|
||||||
|
include/trio/streams/MemoryStream.h
|
||||||
|
include/trio/types/Aliases.h
|
||||||
|
include/trio/types/Parameters.h
|
||||||
|
include/trio/utils/StreamScope.h
|
||||||
|
include/trio/version/Version.h)
|
||||||
|
set(SOURCES
|
||||||
|
src/dna/BaseImpl.h
|
||||||
|
src/dna/DNA.h
|
||||||
|
src/dna/DataLayerBitmask.h
|
||||||
|
src/dna/DenormalizedData.h
|
||||||
|
src/dna/LODConstraint.cpp
|
||||||
|
src/dna/LODConstraint.h
|
||||||
|
src/dna/LODMapping.cpp
|
||||||
|
src/dna/LODMapping.h
|
||||||
|
src/dna/Reader.cpp
|
||||||
|
src/dna/ReaderImpl.h
|
||||||
|
src/dna/SurjectiveMapping.h
|
||||||
|
src/dna/TypeDefs.h
|
||||||
|
src/dna/Writer.cpp
|
||||||
|
src/dna/WriterImpl.h
|
||||||
|
src/dna/filters/AnimatedMapFilter.cpp
|
||||||
|
src/dna/filters/AnimatedMapFilter.h
|
||||||
|
src/dna/filters/BlendShapeFilter.cpp
|
||||||
|
src/dna/filters/BlendShapeFilter.h
|
||||||
|
src/dna/filters/JointFilter.cpp
|
||||||
|
src/dna/filters/JointFilter.h
|
||||||
|
src/dna/filters/MeshFilter.cpp
|
||||||
|
src/dna/filters/MeshFilter.h
|
||||||
|
src/dna/filters/Remap.h
|
||||||
|
src/dna/stream/BinaryStreamReaderImpl.cpp
|
||||||
|
src/dna/stream/BinaryStreamReaderImpl.h
|
||||||
|
src/dna/stream/BinaryStreamWriterImpl.cpp
|
||||||
|
src/dna/stream/BinaryStreamWriterImpl.h
|
||||||
|
src/dna/stream/FilteredInputArchive.cpp
|
||||||
|
src/dna/stream/FilteredInputArchive.h
|
||||||
|
src/dna/stream/JSONStreamReaderImpl.cpp
|
||||||
|
src/dna/stream/JSONStreamReaderImpl.h
|
||||||
|
src/dna/stream/JSONStreamWriterImpl.cpp
|
||||||
|
src/dna/stream/JSONStreamWriterImpl.h
|
||||||
|
src/dna/stream/StreamReader.cpp
|
||||||
|
src/dna/stream/StreamWriter.cpp
|
||||||
|
src/dna/types/Limits.h
|
||||||
|
src/dna/utils/Extd.h
|
||||||
|
src/dna/utils/ScopedEnumEx.h
|
||||||
|
src/dnacalib/Command.cpp
|
||||||
|
src/dnacalib/CommandImplBase.h
|
||||||
|
src/dnacalib/TypeDefs.h
|
||||||
|
src/dnacalib/commands/CalculateMeshLowerLODsCommand.cpp
|
||||||
|
src/dnacalib/commands/CalculateMeshLowerLODsCommandImpl.cpp
|
||||||
|
src/dnacalib/commands/CalculateMeshLowerLODsCommandImpl.h
|
||||||
|
src/dnacalib/commands/ClearBlendShapesCommand.cpp
|
||||||
|
src/dnacalib/commands/CommandSequence.cpp
|
||||||
|
src/dnacalib/commands/PruneBlendShapeTargetsCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveAnimatedMapCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveBlendShapeCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveJointAnimationCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveJointCommand.cpp
|
||||||
|
src/dnacalib/commands/RemoveMeshCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameAnimatedMapCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameBlendShapeCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameJointCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameMeshCommand.cpp
|
||||||
|
src/dnacalib/commands/RenameResourceCommand.h
|
||||||
|
src/dnacalib/commands/RotateCommand.cpp
|
||||||
|
src/dnacalib/commands/ScaleCommand.cpp
|
||||||
|
src/dnacalib/commands/SetBlendShapeTargetDeltasCommand.cpp
|
||||||
|
src/dnacalib/commands/SetLODsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetNeutralJointRotationsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetNeutralJointTranslationsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetSkinWeightsCommand.cpp
|
||||||
|
src/dnacalib/commands/SetVertexPositionsCommand.cpp
|
||||||
|
src/dnacalib/commands/SupportFactories.h
|
||||||
|
src/dnacalib/commands/TranslateCommand.cpp
|
||||||
|
src/dnacalib/dna/BaseImpl.h
|
||||||
|
src/dnacalib/dna/DNA.h
|
||||||
|
src/dnacalib/dna/DNACalibDNAReaderImpl.cpp
|
||||||
|
src/dnacalib/dna/DNACalibDNAReaderImpl.h
|
||||||
|
src/dnacalib/dna/DenormalizedData.h
|
||||||
|
src/dnacalib/dna/LODConstraint.cpp
|
||||||
|
src/dnacalib/dna/LODConstraint.h
|
||||||
|
src/dnacalib/dna/LODMapping.cpp
|
||||||
|
src/dnacalib/dna/LODMapping.h
|
||||||
|
src/dnacalib/dna/ReaderImpl.h
|
||||||
|
src/dnacalib/dna/SurjectiveMapping.h
|
||||||
|
src/dnacalib/dna/WriterImpl.h
|
||||||
|
src/dnacalib/dna/filters/AnimatedMapFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/AnimatedMapFilter.h
|
||||||
|
src/dnacalib/dna/filters/BlendShapeFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/BlendShapeFilter.h
|
||||||
|
src/dnacalib/dna/filters/JointFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/JointFilter.h
|
||||||
|
src/dnacalib/dna/filters/MeshFilter.cpp
|
||||||
|
src/dnacalib/dna/filters/MeshFilter.h
|
||||||
|
src/dnacalib/dna/filters/Remap.h
|
||||||
|
src/dnacalib/types/BoundingBox.h
|
||||||
|
src/dnacalib/types/Triangle.cpp
|
||||||
|
src/dnacalib/types/Triangle.h
|
||||||
|
src/dnacalib/types/UVBarycentricMapping.cpp
|
||||||
|
src/dnacalib/types/UVBarycentricMapping.h
|
||||||
|
src/dnacalib/utils/Algorithm.h
|
||||||
|
src/dnacalib/utils/Extd.h
|
||||||
|
src/dnacalib/utils/FormatString.h
|
||||||
|
src/dnacalib/utils/ScopedEnumEx.h
|
||||||
|
src/dnacalib/version/VersionInfo.cpp
|
||||||
|
src/pma/MemoryResource.cpp
|
||||||
|
src/pma/resources/AlignedMemoryResource.cpp
|
||||||
|
src/pma/resources/ArenaMemoryResource.cpp
|
||||||
|
src/pma/resources/DefaultMemoryResource.cpp
|
||||||
|
src/status/PredefinedCodes.h
|
||||||
|
src/status/Provider.cpp
|
||||||
|
src/status/Registry.cpp
|
||||||
|
src/status/Registry.h
|
||||||
|
src/status/Status.cpp
|
||||||
|
src/status/Storage.cpp
|
||||||
|
src/status/Storage.h
|
||||||
|
src/tdm/Computations.h
|
||||||
|
src/tdm/Mat.h
|
||||||
|
src/tdm/TDM.h
|
||||||
|
src/tdm/Transforms.h
|
||||||
|
src/tdm/Types.h
|
||||||
|
src/tdm/Vec.h
|
||||||
|
src/tdm/version/Version.h
|
||||||
|
src/terse/Archive.h
|
||||||
|
src/terse/archives/Common.h
|
||||||
|
src/terse/archives/Traits.h
|
||||||
|
src/terse/archives/binary/InputArchive.h
|
||||||
|
src/terse/archives/binary/OutputArchive.h
|
||||||
|
src/terse/archives/json/InputArchive.h
|
||||||
|
src/terse/archives/json/OutputArchive.h
|
||||||
|
src/terse/types/Anchor.h
|
||||||
|
src/terse/types/ArchiveOffset.h
|
||||||
|
src/terse/types/ArchiveSize.h
|
||||||
|
src/terse/types/Blob.h
|
||||||
|
src/terse/types/CharInputStreamBuf.h
|
||||||
|
src/terse/types/CharOutputStreamBuf.h
|
||||||
|
src/terse/types/DynArray.h
|
||||||
|
src/terse/types/Transparent.h
|
||||||
|
src/terse/utils/Base64.h
|
||||||
|
src/terse/utils/ByteSwap.h
|
||||||
|
src/terse/utils/Endianness.h
|
||||||
|
src/terse/utils/VirtualSerializerProxy.h
|
||||||
|
src/terse/version/Version.h
|
||||||
|
src/trio/Concepts.cpp
|
||||||
|
src/trio/Stream.cpp
|
||||||
|
src/trio/streams/FileStreamImpl.cpp
|
||||||
|
src/trio/streams/FileStreamImpl.h
|
||||||
|
src/trio/streams/MemoryMappedFileStream.cpp
|
||||||
|
src/trio/streams/MemoryMappedFileStreamFallback.cpp
|
||||||
|
src/trio/streams/MemoryMappedFileStreamFallback.h
|
||||||
|
src/trio/streams/MemoryMappedFileStreamUnix.cpp
|
||||||
|
src/trio/streams/MemoryMappedFileStreamUnix.h
|
||||||
|
src/trio/streams/MemoryMappedFileStreamWindows.cpp
|
||||||
|
src/trio/streams/MemoryMappedFileStreamWindows.h
|
||||||
|
src/trio/streams/MemoryStreamImpl.cpp
|
||||||
|
src/trio/streams/MemoryStreamImpl.h
|
||||||
|
src/trio/streams/StreamStatus.cpp
|
||||||
|
src/trio/streams/StreamStatus.h
|
||||||
|
src/trio/utils/NativeString.h
|
||||||
|
src/trio/utils/PlatformWindows.h
|
||||||
|
src/trio/utils/ScopedEnumEx.h)
|
||||||
|
set(TESTS
|
||||||
|
)
|
26
dnacalib/DNACalib/examples/CMakeLists.txt
Normal file
26
dnacalib/DNACalib/examples/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
set(SOURCES
|
||||||
|
CommandSequence.cpp
|
||||||
|
SingleCommand.cpp)
|
||||||
|
|
||||||
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})
|
||||||
|
|
||||||
|
foreach(example IN LISTS SOURCES)
|
||||||
|
get_filename_component(filename ${example} NAME_WE)
|
||||||
|
string(TOLOWER ${filename} example_target_name)
|
||||||
|
add_executable(${example_target_name} ${example})
|
||||||
|
target_link_libraries(${example_target_name} PRIVATE ${DNAC})
|
||||||
|
set_target_properties(${example_target_name} PROPERTIES
|
||||||
|
CXX_STANDARD 11
|
||||||
|
CXX_STANDARD_REQUIRED NO
|
||||||
|
CXX_EXTENSIONS NO
|
||||||
|
FOLDER examples)
|
||||||
|
list(APPEND EXAMPLE_TARGETS ${example_target_name})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(DNAC_EXAMPLES ${EXAMPLE_TARGETS} PARENT_SCOPE)
|
||||||
|
|
||||||
|
if(COPY_LIB_TO_EXAMPLES)
|
||||||
|
list(GET EXAMPLE_TARGETS 0 EXAMPLE_TARGET)
|
||||||
|
add_custom_command(TARGET ${EXAMPLE_TARGET} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${DNAC}> $<TARGET_FILE_DIR:${EXAMPLE_TARGET}>)
|
||||||
|
endif()
|
65
dnacalib/DNACalib/examples/CommandSequence.cpp
Normal file
65
dnacalib/DNACalib/examples/CommandSequence.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "dnacalib/DNACalib.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
static const char* usage = "Usage: commandsequence.exe <path-to-dna-file-to-edit>\n";
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if (argc < 2) {
|
||||||
|
std::cout << "Provide input dna file!" << std::endl;
|
||||||
|
std::cout << usage << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* inputDNA = argv[1];
|
||||||
|
auto inStream = dnac::makeScoped<dnac::FileStream>(inputDNA,
|
||||||
|
dnac::FileStream::AccessMode::Read,
|
||||||
|
dnac::FileStream::OpenMode::Binary);
|
||||||
|
auto reader = dnac::makeScoped<dnac::BinaryStreamReader>(inStream.get());
|
||||||
|
reader->read();
|
||||||
|
|
||||||
|
if (!dnac::Status::isOk()) {
|
||||||
|
std::cout << "Could not read input DNA file!\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dnaReader = dnac::makeScoped<dnac::DNACalibDNAReader>(reader.get());
|
||||||
|
|
||||||
|
// Create command sequence instance
|
||||||
|
dnac::CommandSequence cmdSeq;
|
||||||
|
|
||||||
|
// Prepare a bunch of commands
|
||||||
|
std::vector<dnac::Vector3> positions;
|
||||||
|
std::vector<float> masks;
|
||||||
|
dnac::SetVertexPositionsCommand setMeshAPos{2, dnac::ConstArrayView<dnac::Vector3>{positions},
|
||||||
|
dnac::ConstArrayView<float>{masks},
|
||||||
|
dnac::VectorOperation::Interpolate};
|
||||||
|
dnac::RenameJointCommand renameJointA("clavicle_l", "cubicle_l");
|
||||||
|
dnac::RenameJointCommand renameJointB(10, "upperarm_corrosiveRoot_l");
|
||||||
|
|
||||||
|
// Add commands to the command sequence
|
||||||
|
cmdSeq.add(&setMeshAPos, &renameJointA);
|
||||||
|
cmdSeq.add(&renameJointB);
|
||||||
|
|
||||||
|
// Execute command sequence
|
||||||
|
cmdSeq.run(dnaReader.get());
|
||||||
|
|
||||||
|
// Reconfigure individual commands that are already in the command sequence
|
||||||
|
renameJointB.setName("FACIAL_L_12IPV_NeckBackB2", "FACIAL_L_12IPTV_NickelBackB52");
|
||||||
|
|
||||||
|
// Modify command sequence (turn an unconditional command into a conditional command)
|
||||||
|
cmdSeq.remove(&renameJointA);
|
||||||
|
auto guardedRenameJointA =
|
||||||
|
dnac::makeConditional(&renameJointA, [](dnac::RenameJointCommand* command, dnac::DNACalibDNAReader* output) {
|
||||||
|
return (output->getJointCount() > 6);
|
||||||
|
});
|
||||||
|
cmdSeq.add(&guardedRenameJointA);
|
||||||
|
|
||||||
|
// Execute modified command sequence
|
||||||
|
cmdSeq.run(dnaReader.get());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
36
dnacalib/DNACalib/examples/SingleCommand.cpp
Normal file
36
dnacalib/DNACalib/examples/SingleCommand.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "dnacalib/DNACalib.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
static const char* usage = "Usage: singlecommand.exe <path-to-dna-file-to-edit>\n";
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if (argc < 2) {
|
||||||
|
std::cout << "Provide input dna file!" << std::endl;
|
||||||
|
std::cout << usage << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* inputDNA = argv[1];
|
||||||
|
auto inStream = dnac::makeScoped<dnac::FileStream>(inputDNA,
|
||||||
|
dnac::FileStream::AccessMode::Read,
|
||||||
|
dnac::FileStream::OpenMode::Binary);
|
||||||
|
auto reader = dnac::makeScoped<dnac::BinaryStreamReader>(inStream.get());
|
||||||
|
reader->read();
|
||||||
|
|
||||||
|
if (!dnac::Status::isOk()) {
|
||||||
|
std::cout << "Could not read input DNA file!\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dnaReader = dnac::makeScoped<dnac::DNACalibDNAReader>(reader.get());
|
||||||
|
|
||||||
|
// Execute a one-off single command
|
||||||
|
dnac::RenameBlendShapeCommand renameBlendShapeA("brow_lateral_L", "wow");
|
||||||
|
renameBlendShapeA.run(dnaReader.get());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
133
dnacalib/DNACalib/include/dna/BinaryStreamReader.h
Normal file
133
dnacalib/DNACalib/include/dna/BinaryStreamReader.h
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/DataLayer.h"
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/StreamReader.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class DNAAPI BinaryStreamReader : public StreamReader {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of BinaryStreamReader
|
||||||
|
@param stream
|
||||||
|
Source stream from which data is going to be read.
|
||||||
|
@param layer
|
||||||
|
Specify the layer up to which the data needs to be loaded.
|
||||||
|
@note
|
||||||
|
The Definition data layer depends on and thus implicitly loads the Descriptor layer.
|
||||||
|
The Behavior data layer depends on and thus implicitly loads the Definition layer.
|
||||||
|
The Geometry data layer depends on and thus also implicitly loads the Definition layer.
|
||||||
|
@param maxLOD
|
||||||
|
The maximum level of details to be loaded.
|
||||||
|
@note
|
||||||
|
A value of zero indicates to load all LODs.
|
||||||
|
@warning
|
||||||
|
The maxLOD value must be less than the value returned by getLODCount.
|
||||||
|
@see getLODCount
|
||||||
|
@param memRes
|
||||||
|
Memory resource to be used for allocations.
|
||||||
|
@note
|
||||||
|
If a memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static BinaryStreamReader* create(BoundedIOStream* stream,
|
||||||
|
DataLayer layer = DataLayer::All,
|
||||||
|
std::uint16_t maxLOD = 0u,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of BinaryStreamReader
|
||||||
|
@param stream
|
||||||
|
Source stream from which data is going to be read.
|
||||||
|
@param layer
|
||||||
|
Specify the layer up to which the data needs to be loaded.
|
||||||
|
@note
|
||||||
|
The Definition data layer depends on and thus implicitly loads the Descriptor layer.
|
||||||
|
The Behavior data layer depends on and thus implicitly loads the Definition layer.
|
||||||
|
The Geometry data layer depends on and thus also implicitly loads the Definition layer.
|
||||||
|
@param maxLOD
|
||||||
|
The maximum level of details to be loaded.
|
||||||
|
@param minLOD
|
||||||
|
The minimum level of details to be loaded.
|
||||||
|
@note
|
||||||
|
A range of [0, LOD count - 1] for maxLOD / minLOD respectively indicates to load all LODs.
|
||||||
|
@warning
|
||||||
|
Both maxLOD and minLOD values must be less than the value returned by getLODCount.
|
||||||
|
@see getLODCount
|
||||||
|
@param memRes
|
||||||
|
Memory resource to be used for allocations.
|
||||||
|
@note
|
||||||
|
If a memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static BinaryStreamReader* create(BoundedIOStream* stream,
|
||||||
|
DataLayer layer,
|
||||||
|
std::uint16_t maxLOD,
|
||||||
|
std::uint16_t minLOD,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of BinaryStreamReader
|
||||||
|
@param stream
|
||||||
|
Source stream from which data is going to be read.
|
||||||
|
@param layer
|
||||||
|
Specify the layer up to which the data needs to be loaded.
|
||||||
|
@note
|
||||||
|
The Definition data layer depends on and thus implicitly loads the Descriptor layer.
|
||||||
|
The Behavior data layer depends on and thus implicitly loads the Definition layer.
|
||||||
|
The Geometry data layer depends on and thus also implicitly loads the Definition layer.
|
||||||
|
@param lods
|
||||||
|
An array specifying which exact lods to load.
|
||||||
|
@warning
|
||||||
|
All values in the array must be less than the value returned by getLODCount.
|
||||||
|
@see getLODCount
|
||||||
|
@param lodCount
|
||||||
|
The number of elements in the lods array.
|
||||||
|
@warning
|
||||||
|
There cannot be more elements in the array than the value returned by getLODCount.
|
||||||
|
@see getLODCount
|
||||||
|
@param memRes
|
||||||
|
Memory resource to be used for allocations.
|
||||||
|
@note
|
||||||
|
If a memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static BinaryStreamReader* create(BoundedIOStream* stream,
|
||||||
|
DataLayer layer,
|
||||||
|
std::uint16_t* lods,
|
||||||
|
std::uint16_t lodCount,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a BinaryStreamReader instance.
|
||||||
|
@param instance
|
||||||
|
Instance of BinaryStreamReader to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(BinaryStreamReader* instance);
|
||||||
|
|
||||||
|
~BinaryStreamReader() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<dna::BinaryStreamReader> {
|
||||||
|
using type = pma::FactoryCreate<dna::BinaryStreamReader>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<dna::BinaryStreamReader> {
|
||||||
|
using type = pma::FactoryDestroy<dna::BinaryStreamReader>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
51
dnacalib/DNACalib/include/dna/BinaryStreamWriter.h
Normal file
51
dnacalib/DNACalib/include/dna/BinaryStreamWriter.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/StreamWriter.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class DNAAPI BinaryStreamWriter : public StreamWriter {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of BinaryStreamWriter
|
||||||
|
@param stream
|
||||||
|
Stream into which the data is going to be written.
|
||||||
|
@param memRes
|
||||||
|
Memory resource to be used for allocations.
|
||||||
|
@note
|
||||||
|
If a memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static BinaryStreamWriter* create(BoundedIOStream* stream, MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a BinaryStreamWriter instance.
|
||||||
|
@param instance
|
||||||
|
Instance of BinaryStreamWriter to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(BinaryStreamWriter* instance);
|
||||||
|
|
||||||
|
~BinaryStreamWriter() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<dna::BinaryStreamWriter> {
|
||||||
|
using type = pma::FactoryCreate<dna::BinaryStreamWriter>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<dna::BinaryStreamWriter> {
|
||||||
|
using type = pma::FactoryDestroy<dna::BinaryStreamWriter>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
17
dnacalib/DNACalib/include/dna/DataLayer.h
Normal file
17
dnacalib/DNACalib/include/dna/DataLayer.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
enum class DataLayer {
|
||||||
|
Descriptor,
|
||||||
|
Definition, // Includes Descriptor
|
||||||
|
Behavior, // Includes Descriptor and Definition
|
||||||
|
Geometry, // Includes Descriptor and Definition
|
||||||
|
GeometryWithoutBlendShapes, // Includes Descriptor and Definition
|
||||||
|
AllWithoutBlendShapes, // Includes everything except blend shapes from Geometry
|
||||||
|
All
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
27
dnacalib/DNACalib/include/dna/Defs.h
Normal file
27
dnacalib/DNACalib/include/dna/Defs.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((dllexport))
|
||||||
|
#define DLL_IMPORT __attribute__((dllimport))
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define DLL_IMPORT DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DNAC_BUILD_SHARED)
|
||||||
|
// Build shared library
|
||||||
|
#define DNAAPI DLL_EXPORT
|
||||||
|
#elif defined(DNAC_SHARED)
|
||||||
|
// Use shared library
|
||||||
|
#define DNAAPI DLL_IMPORT
|
||||||
|
#else
|
||||||
|
// Build or use static library
|
||||||
|
#define DNAAPI
|
||||||
|
#endif
|
51
dnacalib/DNACalib/include/dna/JSONStreamReader.h
Normal file
51
dnacalib/DNACalib/include/dna/JSONStreamReader.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/StreamReader.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class DNAAPI JSONStreamReader : public StreamReader {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of JSONStreamReader
|
||||||
|
@param stream
|
||||||
|
Source stream from which data is going to be read.
|
||||||
|
@param memRes
|
||||||
|
Memory resource to be used for allocations.
|
||||||
|
@note
|
||||||
|
If a memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static JSONStreamReader* create(BoundedIOStream* stream, MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a JSONStreamReader instance.
|
||||||
|
@param instance
|
||||||
|
Instance of JSONStreamReader to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(JSONStreamReader* instance);
|
||||||
|
|
||||||
|
~JSONStreamReader() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<dna::JSONStreamReader> {
|
||||||
|
using type = pma::FactoryCreate<dna::JSONStreamReader>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<dna::JSONStreamReader> {
|
||||||
|
using type = pma::FactoryDestroy<dna::JSONStreamReader>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
54
dnacalib/DNACalib/include/dna/JSONStreamWriter.h
Normal file
54
dnacalib/DNACalib/include/dna/JSONStreamWriter.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/StreamWriter.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class DNAAPI JSONStreamWriter : public StreamWriter {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of JSONStreamWriter
|
||||||
|
@param stream
|
||||||
|
Stream into which the data is going to be written.
|
||||||
|
@param indentWidth
|
||||||
|
Number of spaces to use for indentation.
|
||||||
|
@param memRes
|
||||||
|
Memory resource to be used for allocations.
|
||||||
|
@note
|
||||||
|
If a memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static JSONStreamWriter* create(BoundedIOStream* stream, std::uint32_t indentWidth = 4u,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a JSONStreamWriter instance.
|
||||||
|
@param instance
|
||||||
|
Instance of JSONStreamWriter to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(JSONStreamWriter* instance);
|
||||||
|
|
||||||
|
~JSONStreamWriter() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<dna::JSONStreamWriter> {
|
||||||
|
using type = pma::FactoryCreate<dna::JSONStreamWriter>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<dna::JSONStreamWriter> {
|
||||||
|
using type = pma::FactoryDestroy<dna::JSONStreamWriter>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
32
dnacalib/DNACalib/include/dna/Reader.h
Normal file
32
dnacalib/DNACalib/include/dna/Reader.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/DataLayer.h"
|
||||||
|
#include "dna/layers/BehaviorReader.h"
|
||||||
|
#include "dna/layers/GeometryReader.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The abstract Reader which its implementations are expected to inherit.
|
||||||
|
@note
|
||||||
|
This class combines the various different reader interfaces into a single interface.
|
||||||
|
The artificial separation into multiple interfaces mirrors the DNA file structure that
|
||||||
|
is separated into matching layers under the same names. As these layers can be
|
||||||
|
selectively loaded, it might be convenient to slice-off interfaces which layers were
|
||||||
|
not loaded.
|
||||||
|
*/
|
||||||
|
class DNAAPI Reader : public BehaviorReader, public GeometryReader {
|
||||||
|
public:
|
||||||
|
~Reader() override;
|
||||||
|
/**
|
||||||
|
@brief Unload all data of the specified layer and all layers dependent on it.
|
||||||
|
@param layer
|
||||||
|
Layer which data should be unloaded.
|
||||||
|
*/
|
||||||
|
virtual void unload(DataLayer layer) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
26
dnacalib/DNACalib/include/dna/StreamReader.h
Normal file
26
dnacalib/DNACalib/include/dna/StreamReader.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/DataLayer.h"
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/Reader.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class DNAAPI StreamReader : public Reader {
|
||||||
|
public:
|
||||||
|
static const sc::StatusCode SignatureMismatchError;
|
||||||
|
static const sc::StatusCode VersionMismatchError;
|
||||||
|
static const sc::StatusCode InvalidDataError;
|
||||||
|
|
||||||
|
public:
|
||||||
|
~StreamReader() override;
|
||||||
|
/**
|
||||||
|
@brief read data from stream into internal structures.
|
||||||
|
*/
|
||||||
|
virtual void read() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
20
dnacalib/DNACalib/include/dna/StreamWriter.h
Normal file
20
dnacalib/DNACalib/include/dna/StreamWriter.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/Writer.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class DNAAPI StreamWriter : public Writer {
|
||||||
|
public:
|
||||||
|
~StreamWriter() override;
|
||||||
|
/**
|
||||||
|
@brief Write data to stream from internal structures.
|
||||||
|
*/
|
||||||
|
virtual void write() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
44
dnacalib/DNACalib/include/dna/Writer.h
Normal file
44
dnacalib/DNACalib/include/dna/Writer.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/DataLayer.h"
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/BehaviorWriter.h"
|
||||||
|
#include "dna/layers/GeometryWriter.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class Reader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The abstract Writer which its implementations are expected to inherit.
|
||||||
|
@note
|
||||||
|
This class combines the various different writer interfaces into a single interface.
|
||||||
|
The artificial separation into multiple interfaces in this case just mirrors the
|
||||||
|
structure of the Reader hierarchy, as it's not possible to selectively write only
|
||||||
|
specific layers.
|
||||||
|
*/
|
||||||
|
class DNAAPI Writer : public BehaviorWriter, public GeometryWriter {
|
||||||
|
public:
|
||||||
|
~Writer() override;
|
||||||
|
/**
|
||||||
|
@brief Initialize the Writer from the given Reader.
|
||||||
|
@note
|
||||||
|
This function copies all the data from the given Reader into the Writer instance,
|
||||||
|
by calling each getter function of the Reader, and passing the return values to
|
||||||
|
the matching setter functions in the Writer.
|
||||||
|
It is implemented in the abstract class itself to provide the functionality for
|
||||||
|
all DNA Writers.
|
||||||
|
@param source
|
||||||
|
The source DNA Reader from which the data needs to be copied.
|
||||||
|
@param layer
|
||||||
|
Limit which layers should be taken over from the given source reader.
|
||||||
|
@param memRes
|
||||||
|
Optional memory resource to use for temporary allocations during copying.
|
||||||
|
*/
|
||||||
|
void setFrom(const Reader* source, DataLayer layer = DataLayer::All, MemoryResource* memRes = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
216
dnacalib/DNACalib/include/dna/layers/BehaviorReader.h
Normal file
216
dnacalib/DNACalib/include/dna/layers/BehaviorReader.h
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/DefinitionReader.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Read-only accessors for DNA attributes that define the rig's evaluation.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Reader itself and not this class.
|
||||||
|
@see Reader
|
||||||
|
*/
|
||||||
|
class DNAAPI BehaviorReader : public virtual DefinitionReader {
|
||||||
|
protected:
|
||||||
|
virtual ~BehaviorReader();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Input indices used for mapping gui to raw controls.
|
||||||
|
@return View over the array of input indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getGUIToRawInputIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Output indices used for mapping gui to raw controls.
|
||||||
|
@return View over the array of output indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getGUIToRawOutputIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(lower-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not during gui to raw control mapping.
|
||||||
|
@return View over the array of filter values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getGUIToRawFromValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(upper-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not during gui to raw control mapping.
|
||||||
|
@return View over the array of filter values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getGUIToRawToValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(slope/gradient) used for calculating the
|
||||||
|
output value during gui to raw control mapping.
|
||||||
|
@return View over the array of computational values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getGUIToRawSlopeValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(vertical intercept) used for calculating the
|
||||||
|
output value during gui to raw control mapping.
|
||||||
|
@return View over the array of computational values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getGUIToRawCutValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief The number of distinct PSD expressions.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getPSDCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief PSD(input) indices.
|
||||||
|
@return View over the array of PSD indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getPSDRowIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Control(input) indices.
|
||||||
|
@return View over the array of control indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getPSDColumnIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Weights associated with each PSD row and column pair.
|
||||||
|
@return View over the array of weights.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getPSDValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of rows in the entire, uncompressed joint matrix.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getJointRowCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of columns in the entire, uncompressed joint matrix.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getJointColumnCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Joint attribute indices (output indices) for the requested LOD.
|
||||||
|
@return View over the array of joint indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getJointVariableAttributeIndices(std::uint16_t lod) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of joint groups present in the entire joint matrix.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getJointGroupCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of rows per each level of detail for the requested joint group.
|
||||||
|
@note
|
||||||
|
Each element's position represents the level itself, while the value denotes
|
||||||
|
the number of rows within the joint group belonging to that level. e.g.:
|
||||||
|
[12, 9, 3]
|
||||||
|
| | + LOD-2 contains first 3 rows
|
||||||
|
| + LOD-1 contains first 9 rows
|
||||||
|
+ LOD-0 contains first 12 rows
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@warning
|
||||||
|
jointGroupIndex must be less than the value returned by getJointGroupCount.
|
||||||
|
@return View over the array of LOD bounds.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getJointGroupLODs(std::uint16_t jointGroupIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Column indices that the requested joint group contains.
|
||||||
|
@note
|
||||||
|
The column indices point into the entire, uncompressed joint matrix.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@warning
|
||||||
|
jointGroupIndex must be less than the value returned by getJointGroupCount.
|
||||||
|
@return View over the array of column indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getJointGroupInputIndices(std::uint16_t jointGroupIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Row indices that the requested joint group contains.
|
||||||
|
@note
|
||||||
|
The row indices point into the entire, uncompressed joint matrix.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@warning
|
||||||
|
jointGroupIndex must be less than the value returned by getJointGroupCount.
|
||||||
|
@return View over the array of row indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getJointGroupOutputIndices(std::uint16_t jointGroupIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Values that the requested joint group contains.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@warning
|
||||||
|
jointGroupIndex must be less than the value returned by getJointGroupCount.
|
||||||
|
@return View over the array of values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getJointGroupValues(std::uint16_t jointGroupIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Joint indices that the requested joint group contains.
|
||||||
|
@note
|
||||||
|
These joint indices can be used to get the joint names through DefinitionReader::getJointName.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@warning
|
||||||
|
jointGroupIndex must be less than the value returned by getJointGroupCount.
|
||||||
|
@return View over the array of joint indices.
|
||||||
|
@see DefinitionReader
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getJointGroupJointIndices(std::uint16_t jointGroupIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Input index count per each level of detail for blend shape channels.
|
||||||
|
@note
|
||||||
|
Each element's position represents the level itself (e.g. [0,1,2,3,4,5] Value 0 is LOD with highest of details,
|
||||||
|
value 5 is LOD with lowest details), while the value denotes the number of input indices belonging to that level.
|
||||||
|
@warning
|
||||||
|
These LOD values are not interchangeable with the LOD indices from DefinitionReader::getBlendShapeChannelIndicesForLOD.
|
||||||
|
@return View over the array of LOD bounds.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getBlendShapeChannelLODs() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Input indices used to index into the input vector.
|
||||||
|
@return View over the array of input indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getBlendShapeChannelInputIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Output indices specify the positions of blend shape channel output values.
|
||||||
|
@return View over the array of output indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getBlendShapeChannelOutputIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Row count per each level of detail for animated maps.
|
||||||
|
@note
|
||||||
|
Each element's position represents the level itself (e.g. [0,1,2,3,4,5] Value 0 is LOD with highest of details,
|
||||||
|
value 5 is LOD with lowest details), while the value denotes the number of rows (within the conditional table),
|
||||||
|
belonging to that level.
|
||||||
|
@return View over the array of LOD bounds.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getAnimatedMapLODs() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Input indices used to index into the array of input values.
|
||||||
|
@return View over the array of input indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getAnimatedMapInputIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Output indices that specify the computed output value's position.
|
||||||
|
@return View over the array of output indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getAnimatedMapOutputIndices() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(lower-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not.
|
||||||
|
@return View over the array of filter values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getAnimatedMapFromValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(upper-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not.
|
||||||
|
@return View over the array of filter values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getAnimatedMapToValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(slope/gradient) used for calculating the output value.
|
||||||
|
@return View over the array of computational values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getAnimatedMapSlopeValues() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(vertical intercept) used for calculating the output value.
|
||||||
|
@return View over the array of computational values.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getAnimatedMapCutValues() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
300
dnacalib/DNACalib/include/dna/layers/BehaviorWriter.h
Normal file
300
dnacalib/DNACalib/include/dna/layers/BehaviorWriter.h
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/DefinitionWriter.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Write-only accessors for DNA attributes that define the rig's evaluation.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Writer itself and not this class.
|
||||||
|
@see Writer
|
||||||
|
*/
|
||||||
|
class DNAAPI BehaviorWriter : public virtual DefinitionWriter {
|
||||||
|
protected:
|
||||||
|
virtual ~BehaviorWriter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Input indices used for mapping gui to raw controls.
|
||||||
|
@param inputIndices
|
||||||
|
The source address from which the input indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of input indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setGUIToRawInputIndices(const std::uint16_t* inputIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Output indices used for mapping gui to raw controls.
|
||||||
|
@param outputIndices
|
||||||
|
The source address from which the output indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of output indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setGUIToRawOutputIndices(const std::uint16_t* outputIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(lower-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not during gui to raw control mapping.
|
||||||
|
@param fromValues
|
||||||
|
The source address from which the filter values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of filter values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setGUIToRawFromValues(const float* fromValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(upper-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not during gui to raw control mapping.
|
||||||
|
@param toValues
|
||||||
|
The source address from which the filter values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of filter values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setGUIToRawToValues(const float* toValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(slope/gradient) used for calculating the
|
||||||
|
output value during gui to raw control mapping.
|
||||||
|
@param slopeValues
|
||||||
|
The source address from which the computational values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of computational values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setGUIToRawSlopeValues(const float* slopeValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(vertical intercept) used for calculating the
|
||||||
|
output value during gui to raw control mapping.
|
||||||
|
@param cutValues
|
||||||
|
The source address from which the computational values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of computational values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setGUIToRawCutValues(const float* cutValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief The number of distinct PSD expressions.
|
||||||
|
*/
|
||||||
|
virtual void setPSDCount(std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief PSD(input) indices which will become the rows of the PSD matrix.
|
||||||
|
@param rowIndices
|
||||||
|
The source address from which the PSD indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of PSD indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setPSDRowIndices(const std::uint16_t* rowIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Control(input) indices which will become the columns of the PSD matrix.
|
||||||
|
@param columnIndices
|
||||||
|
The source address from which the control indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of control indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setPSDColumnIndices(const std::uint16_t* columnIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Weights associated with each PSD row and column pair.
|
||||||
|
@param weights
|
||||||
|
The source address from which the weight values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of weight values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setPSDValues(const float* weights, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of rows in the entire, uncompressed joint matrix.
|
||||||
|
*/
|
||||||
|
virtual void setJointRowCount(std::uint16_t rowCount) = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of columns in the entire, uncompressed joint matrix.
|
||||||
|
*/
|
||||||
|
virtual void setJointColumnCount(std::uint16_t columnCount) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all joint groups.
|
||||||
|
*/
|
||||||
|
virtual void clearJointGroups() = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete the specified joint group.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@warning
|
||||||
|
jointGroupIndex must be less than the value returned by getJointGroupCount.
|
||||||
|
*/
|
||||||
|
virtual void deleteJointGroup(std::uint16_t jointGroupIndex) = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of rows per each level of detail for the specified joint group.
|
||||||
|
@note
|
||||||
|
Each element's position represents the level itself, while the value denotes
|
||||||
|
the number of rows within the joint group belonging to that level. e.g.:
|
||||||
|
[12, 9, 3]
|
||||||
|
| | + LOD-2 contains first 3 rows
|
||||||
|
| + LOD-1 contains first 9 rows
|
||||||
|
+ LOD-0 contains first 12 rows
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@note
|
||||||
|
The joint group storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of joint groups that is inferred from the specified index.
|
||||||
|
@param lods
|
||||||
|
The source address from which the lod bounds are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of lod bounds to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointGroupLODs(std::uint16_t jointGroupIndex, const std::uint16_t* lods, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Column indices that the specified joint group contains.
|
||||||
|
@note
|
||||||
|
The column indices point into the entire, uncompressed joint matrix.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@note
|
||||||
|
The joint group storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of joint groups that is inferred from the specified index.
|
||||||
|
@param inputIndices
|
||||||
|
The source address from which the column indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of column indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointGroupInputIndices(std::uint16_t jointGroupIndex,
|
||||||
|
const std::uint16_t* inputIndices,
|
||||||
|
std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Row indices that the specified joint group contains.
|
||||||
|
@note
|
||||||
|
The row indices point into the entire, uncompressed joint matrix.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@note
|
||||||
|
The joint group storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of joint groups that is inferred from the specified index.
|
||||||
|
@param outputIndices
|
||||||
|
The source address from which the row indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of row indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointGroupOutputIndices(std::uint16_t jointGroupIndex,
|
||||||
|
const std::uint16_t* outputIndices,
|
||||||
|
std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Values that the specified joint group contains.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@note
|
||||||
|
The joint group storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of joint groups that is inferred from the specified index.
|
||||||
|
@param values
|
||||||
|
The source address from which the values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointGroupValues(std::uint16_t jointGroupIndex, const float* values, std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Joint indices that the specified joint group contains.
|
||||||
|
@param jointGroupIndex
|
||||||
|
A joint group's position in the zero-indexed array of joint groups.
|
||||||
|
@note
|
||||||
|
The joint group storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of joint groups that is inferred from the specified index.
|
||||||
|
@param jointIndices
|
||||||
|
The source address from which the joint indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of joint indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointGroupJointIndices(std::uint16_t jointGroupIndex,
|
||||||
|
const std::uint16_t* jointIndices,
|
||||||
|
std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Input index count per each level of detail for blend shapes.
|
||||||
|
@note
|
||||||
|
Each element's position represents the level itself (e.g. [0,1,2,3,4,5] Value 0 is LOD with highest of details,
|
||||||
|
value 5 is LOD with lowest details), while the value denotes the number of input indices belonging to that level.
|
||||||
|
@param lods
|
||||||
|
The source address from which the lod bounds are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of lod bounds to copy.
|
||||||
|
@warning
|
||||||
|
The LOD values set here are not interchangeable with the LOD indices set in DefinitionWriter::setBlendShapeNameIndices
|
||||||
|
and DefinitionWriter::setLODBlendShapeMapping
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeChannelLODs(const std::uint16_t* lods, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Input indices used to index into the input vector.
|
||||||
|
@param inputIndices
|
||||||
|
The source address from which the input indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of input indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeChannelInputIndices(const std::uint16_t* inputIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Output indices specify the positions of blend shape output values.
|
||||||
|
@param outputIndices
|
||||||
|
The source address from which the output indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of output indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeChannelOutputIndices(const std::uint16_t* outputIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Row count per each level of detail for animated maps.
|
||||||
|
@note
|
||||||
|
Each element's position represents the level itself (e.g. [0,1,2,3,4,5] Value 0 is LOD with highest of details,
|
||||||
|
value 5 is LOD with lowest details), while the value denotes the number of rows (within the conditional table),
|
||||||
|
belonging to that level.
|
||||||
|
@param lods
|
||||||
|
The source address from which the lod bounds are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of lod bounds to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapLODs(const std::uint16_t* lods, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Input indices used to index into the array of input values.
|
||||||
|
@param inputIndices
|
||||||
|
The source address from which the input indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of input indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapInputIndices(const std::uint16_t* inputIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Output indices that specify the computed output value's position.
|
||||||
|
@param outputIndices
|
||||||
|
The source address from which the output indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of output indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapOutputIndices(const std::uint16_t* outputIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(lower-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not.
|
||||||
|
@param fromValues
|
||||||
|
The source address from which the filter values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of filter values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapFromValues(const float* fromValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Filter values(upper-bounds) used to decide whether a particular
|
||||||
|
entry should be evaluated or not.
|
||||||
|
@param toValues
|
||||||
|
The source address from which the filter values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of filter values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapToValues(const float* toValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(slope/gradient) used for calculating the output value.
|
||||||
|
@param slopeValues
|
||||||
|
The source address from which the computational values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of computational values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapSlopeValues(const float* slopeValues, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Computational values(vertical intercept) used for calculating the output value.
|
||||||
|
@param cutValues
|
||||||
|
The source address from which the computational values are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of computational values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapCutValues(const float* cutValues, std::uint16_t count) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
284
dnacalib/DNACalib/include/dna/layers/DefinitionReader.h
Normal file
284
dnacalib/DNACalib/include/dna/layers/DefinitionReader.h
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/DescriptorReader.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
#include "dna/types/Vector3.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Mapping that associates a blend shape channel to it's mesh.
|
||||||
|
*/
|
||||||
|
struct MeshBlendShapeChannelMapping {
|
||||||
|
std::uint16_t meshIndex;
|
||||||
|
std::uint16_t blendShapeChannelIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Read-only accessors for DNA attributes that represent the rig's static data.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Reader itself and not this class.
|
||||||
|
@see Reader
|
||||||
|
*/
|
||||||
|
class DNAAPI DefinitionReader : public DescriptorReader {
|
||||||
|
protected:
|
||||||
|
virtual ~DefinitionReader();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual std::uint16_t getGUIControlCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the requested GUI control.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of GUI control names.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getGUIControlCount.
|
||||||
|
@return View over the GUI control name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getGUIControlName(std::uint16_t index) const = 0;
|
||||||
|
|
||||||
|
virtual std::uint16_t getRawControlCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the requested raw control.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of raw control names.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getRawControlCount.
|
||||||
|
@return View over the control name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getRawControlName(std::uint16_t index) const = 0;
|
||||||
|
|
||||||
|
virtual std::uint16_t getJointCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the requested joint.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of joint names.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getJointCount.
|
||||||
|
@return View over the joint name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getJointName(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of joint index lists.
|
||||||
|
@note
|
||||||
|
This value is useful only in the context of DefinitionWriter.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getJointIndexListCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of joint indices for the specified LOD.
|
||||||
|
@param lod
|
||||||
|
The level of detail which joints are being requested.
|
||||||
|
@warning
|
||||||
|
The lod index must be less than the value returned by getLODCount.
|
||||||
|
@return View over the joint indices.
|
||||||
|
@see getLODCount
|
||||||
|
@see getJointName
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getJointIndicesForLOD(std::uint16_t lod) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Index of the requested joint's parent.
|
||||||
|
@note
|
||||||
|
The joint hierarchy may be traversed and reconstructed using this function. Example:
|
||||||
|
Joint names: [A, B, C, D, E, F, G, H, I]
|
||||||
|
Hierarchy: [0, 0, 0, 1, 1, 4, 2, 6, 2]
|
||||||
|
Describes the following hierarchy:
|
||||||
|
A
|
||||||
|
+ B
|
||||||
|
| + D
|
||||||
|
| + E
|
||||||
|
| + F
|
||||||
|
+ C
|
||||||
|
+ G
|
||||||
|
| + H
|
||||||
|
+ I
|
||||||
|
|
||||||
|
Requesting the parent index of joint 5 (joint name: F) would return 4 (joint name: E).
|
||||||
|
Requesting the parent index of the root joint: 0 (joint name: A) would return the same index 0.
|
||||||
|
An out of bounds request (an index greater than the number of joints returns UINT16_MAX).
|
||||||
|
@param index
|
||||||
|
The joint index which parent is being requested.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getJointParentIndex(std::uint16_t index) const = 0;
|
||||||
|
|
||||||
|
virtual std::uint16_t getBlendShapeChannelCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the requested blend shape channel.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of blend shape channel names.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by BlendShapeChannelExtentReader::getBlendShapeChannelCount.
|
||||||
|
@return View over the blend shape channel name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getBlendShapeChannelName(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of blend shape channel index lists.
|
||||||
|
@note
|
||||||
|
This value is useful only in the context of DefinitionWriter.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getBlendShapeChannelIndexListCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of blend shape channel indices for the specified LOD.
|
||||||
|
@param lod
|
||||||
|
The level of detail which blend shape channels are being requested.
|
||||||
|
@warning
|
||||||
|
The lod index must be less than the value returned by getLODCount.
|
||||||
|
@return View over the blend shape channel indices.
|
||||||
|
@warning
|
||||||
|
These LOD indices are not interchangeable with the LOD values from BehaviorReader::getBlendShapeChannelLODs.
|
||||||
|
@see getLODCount
|
||||||
|
@see getBlendShapeChannelName
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getBlendShapeChannelIndicesForLOD(std::uint16_t lod) const = 0;
|
||||||
|
|
||||||
|
virtual std::uint16_t getAnimatedMapCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the requested animated map.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of animated map names.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getAnimatedMapCount.
|
||||||
|
@return View over the animated map name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getAnimatedMapName(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of animated map index lists.
|
||||||
|
@note
|
||||||
|
This value is useful only in the context of DefinitionWriter.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getAnimatedMapIndexListCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of animated map indices for the specified LOD.
|
||||||
|
@param lod
|
||||||
|
The level of detail which animated maps are being requested.
|
||||||
|
@warning
|
||||||
|
The lod index must be less than the value returned by getLODCount.
|
||||||
|
@return View over the animated map indices.
|
||||||
|
@see getLODCount
|
||||||
|
@see getAnimatedMapName
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getAnimatedMapIndicesForLOD(std::uint16_t lod) const = 0;
|
||||||
|
|
||||||
|
virtual std::uint16_t getMeshCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the requested mesh.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of mesh names.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getMeshCount.
|
||||||
|
@return View over the mesh name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getMeshName(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of mesh index lists.
|
||||||
|
@note
|
||||||
|
This value is useful only in the context of DefinitionWriter.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getMeshIndexListCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of mesh indices for the specified LOD.
|
||||||
|
@param lod
|
||||||
|
The level of detail which meshes are being requested.
|
||||||
|
@warning
|
||||||
|
The lod index must be less than the value returned by getLODCount.
|
||||||
|
@return View over the mesh indices.
|
||||||
|
@see getLODCount
|
||||||
|
@see getMeshName
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getMeshIndicesForLOD(std::uint16_t lod) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of mesh-blend shape channel mapping items.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getMeshBlendShapeChannelMappingCount() const = 0;
|
||||||
|
/**
|
||||||
|
@param index
|
||||||
|
A mapping's position in the zero-indexed array of mesh-blend shape channel mappings.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getMeshBlendShapeChannelMappingCount.
|
||||||
|
@return A structure holding the mesh index and the associated blend shape channel index.
|
||||||
|
*/
|
||||||
|
virtual MeshBlendShapeChannelMapping getMeshBlendShapeChannelMapping(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of mesh-blend shape channel mapping indices for the specified LOD.
|
||||||
|
@note
|
||||||
|
The indices from this list can be used with the getMeshBlendShapeChannelMapping API
|
||||||
|
to retrieve individual mapping items.
|
||||||
|
@param lod
|
||||||
|
The level of detail which meshes are being requested.
|
||||||
|
@warning
|
||||||
|
The lod index must be less than the value returned by getLODCount.
|
||||||
|
@return View over the mesh blend shape channel mapping indices.
|
||||||
|
@see getLODCount
|
||||||
|
@see getMeshBlendShapeChannelMapping
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getMeshBlendShapeChannelMappingIndicesForLOD(std::uint16_t lod) const = 0;
|
||||||
|
/**
|
||||||
|
@param index
|
||||||
|
A joint's position in the zero-indexed array of joint translations.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getJointCount.
|
||||||
|
@return The joint's translation (x, y, z).
|
||||||
|
*/
|
||||||
|
virtual Vector3 getNeutralJointTranslation(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all translation X values.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getNeutralJointTranslation.
|
||||||
|
@return View over all X values.
|
||||||
|
@see getNeutralJointTranslation
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getNeutralJointTranslationXs() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all translation Y values.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getNeutralJointTranslation.
|
||||||
|
@return View over all Y values.
|
||||||
|
@see getNeutralJointTranslation
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getNeutralJointTranslationYs() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all translation Z values.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getNeutralJointTranslation.
|
||||||
|
@return View over all Z values.
|
||||||
|
@see getNeutralJointTranslation
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getNeutralJointTranslationZs() const = 0;
|
||||||
|
/**
|
||||||
|
@param index
|
||||||
|
A joint's position in the zero-indexed array of joint rotations.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getJointCount.
|
||||||
|
@return The joint's rotation (x, y, z).
|
||||||
|
*/
|
||||||
|
virtual Vector3 getNeutralJointRotation(std::uint16_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all rotation X values.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getNeutralJointRotation.
|
||||||
|
@return View over all X values.
|
||||||
|
@see getNeutralJointRotation
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getNeutralJointRotationXs() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all rotation Y values.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getNeutralJointRotation.
|
||||||
|
@return View over all Y values.
|
||||||
|
@see getNeutralJointRotation
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getNeutralJointRotationYs() const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all rotation Z values.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getNeutralJointRotation.
|
||||||
|
@return View over all Z values.
|
||||||
|
@see getNeutralJointRotation
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getNeutralJointRotationZs() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
328
dnacalib/DNACalib/include/dna/layers/DefinitionWriter.h
Normal file
328
dnacalib/DNACalib/include/dna/layers/DefinitionWriter.h
Normal file
@ -0,0 +1,328 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/DescriptorWriter.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
#include "dna/types/Vector3.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Write-only accessors for DNA attributes that represent the rig's static data.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Writer itself and not this class.
|
||||||
|
@see Writer
|
||||||
|
*/
|
||||||
|
class DNAAPI DefinitionWriter : public DescriptorWriter {
|
||||||
|
protected:
|
||||||
|
virtual ~DefinitionWriter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Delete all stored GUI control names.
|
||||||
|
*/
|
||||||
|
virtual void clearGUIControlNames() = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the specified GUI control.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of GUI control names.
|
||||||
|
@note
|
||||||
|
The control name storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of names that is inferred from the specified index.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setGUIControlName(std::uint16_t index, const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored raw control names.
|
||||||
|
*/
|
||||||
|
virtual void clearRawControlNames() = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the specified raw control.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of raw control names.
|
||||||
|
@note
|
||||||
|
The control name storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of names that is inferred from the specified index.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setRawControlName(std::uint16_t index, const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored joint names.
|
||||||
|
*/
|
||||||
|
virtual void clearJointNames() = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the specified joint.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of joint names.
|
||||||
|
@note
|
||||||
|
The joint name storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of names that is inferred from the specified index.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setJointName(std::uint16_t index, const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored joint indices.
|
||||||
|
*/
|
||||||
|
virtual void clearJointIndices() = 0;
|
||||||
|
/**
|
||||||
|
@brief Store a list of joint indices onto a specified index.
|
||||||
|
@param index
|
||||||
|
A position in a zero-indexed array where joint indices are stored.
|
||||||
|
@note
|
||||||
|
The index denotes the position of an entire joint index list,
|
||||||
|
not the position of it's individual elements, i.e. the row index in a 2D
|
||||||
|
matrix of joint indices.
|
||||||
|
@note
|
||||||
|
The joint index storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of joint indices that is inferred from the specified index.
|
||||||
|
@param jointIndices
|
||||||
|
The source address from which the joint indices are to be copied.
|
||||||
|
@note
|
||||||
|
These indices can be used to access joint names through DefinitionReader::getJointName.
|
||||||
|
@param count
|
||||||
|
The number of joint indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointIndices(std::uint16_t index, const std::uint16_t* jointIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored LOD to joint list index mapping entries.
|
||||||
|
*/
|
||||||
|
virtual void clearLODJointMappings() = 0;
|
||||||
|
/**
|
||||||
|
@brief Set which joints belong to which level of detail.
|
||||||
|
@param lod
|
||||||
|
The actual level of detail to which the joints are being associated.
|
||||||
|
@param index
|
||||||
|
The index onto which joints indices were assigned using setJointIndices.
|
||||||
|
@see setJointIndices
|
||||||
|
*/
|
||||||
|
virtual void setLODJointMapping(std::uint16_t lod, std::uint16_t index) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored blend shape channel names.
|
||||||
|
*/
|
||||||
|
virtual void clearBlendShapeChannelNames() = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the specified blend shape channel.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of blend shape channel names.
|
||||||
|
@note
|
||||||
|
The blend shape channel name storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of names that is inferred from the specified index.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeChannelName(std::uint16_t index, const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored blend shape channel indices.
|
||||||
|
*/
|
||||||
|
virtual void clearBlendShapeChannelIndices() = 0;
|
||||||
|
/**
|
||||||
|
@brief Store a list of blend shape channel name indices onto a specified index.
|
||||||
|
@param index
|
||||||
|
A position in a zero-indexed array where blend shape channel name indices are stored.
|
||||||
|
@note
|
||||||
|
The index denotes the position of an entire blend shape channel index list,
|
||||||
|
not the position of it's individual elements, i.e. the row index in a 2D
|
||||||
|
matrix of blend shape channel indices.
|
||||||
|
@note
|
||||||
|
The blend shape channel index storage will be implicitly resized (if needed) to provide storage
|
||||||
|
for the number of blend shape channel name indices that is inferred from the specified index.
|
||||||
|
@param blendShapeChannelIndices
|
||||||
|
The source address from which the blend shape channel name indices are to be copied.
|
||||||
|
@note
|
||||||
|
These indices can be used to access blend shape channel names through DefinitionReader::getBlendShapeChannelName.
|
||||||
|
@param count
|
||||||
|
The number of blend shape channel name indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeChannelIndices(std::uint16_t index,
|
||||||
|
const std::uint16_t* blendShapeChannelIndices,
|
||||||
|
std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored LOD to blend shape channel list index mapping entries.
|
||||||
|
*/
|
||||||
|
virtual void clearLODBlendShapeChannelMappings() = 0;
|
||||||
|
/**
|
||||||
|
@brief Set which blend shape channels belong to which level of detail.
|
||||||
|
@param lod
|
||||||
|
The actual level of detail to which the blend shape channels are being associated.
|
||||||
|
@param index
|
||||||
|
The index onto which blend shape channel name indices were assigned using setBlendShapeChannelIndices.
|
||||||
|
@warning
|
||||||
|
The LOD indices set here are not interchangeable with the LOD values set in BehaviorWriter::setBlendShapeChannelLODs.
|
||||||
|
@see setBlendShapeChannelIndices
|
||||||
|
*/
|
||||||
|
virtual void setLODBlendShapeChannelMapping(std::uint16_t lod, std::uint16_t index) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored animated map names.
|
||||||
|
*/
|
||||||
|
virtual void clearAnimatedMapNames() = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the specified animated map.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of animated map names.
|
||||||
|
@note
|
||||||
|
The animated map name storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of names that is inferred from the specified index.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapName(std::uint16_t index, const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored animated map indices.
|
||||||
|
*/
|
||||||
|
virtual void clearAnimatedMapIndices() = 0;
|
||||||
|
/**
|
||||||
|
@brief Store a list of animated map name indices onto a specified index.
|
||||||
|
@param index
|
||||||
|
A position in a zero-indexed array where animated map name indices are stored.
|
||||||
|
@note
|
||||||
|
The index denotes the position of an entire animated map index list,
|
||||||
|
not the position of it's individual elements, i.e. the row index in a 2D
|
||||||
|
matrix of animated map indices.
|
||||||
|
@note
|
||||||
|
The animated map index storage will be implicitly resized (if needed) to provide storage
|
||||||
|
for the number of animated map name indices that is inferred from the specified index.
|
||||||
|
@param animatedMapIndices
|
||||||
|
The source address from which the animated map name indices are to be copied.
|
||||||
|
@note
|
||||||
|
These indices can be used to access animated map names through DefinitionReader::getAnimatedMapName.
|
||||||
|
@param count
|
||||||
|
The number of animated map name indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setAnimatedMapIndices(std::uint16_t index, const std::uint16_t* animatedMapIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored LOD to animated map list index mapping entries.
|
||||||
|
*/
|
||||||
|
virtual void clearLODAnimatedMapMappings() = 0;
|
||||||
|
/**
|
||||||
|
@brief Set which animated maps belong to which level of detail.
|
||||||
|
@param lod
|
||||||
|
The actual level of detail to which the animated maps are being associated.
|
||||||
|
@param index
|
||||||
|
The index onto which animated map indices were assigned using setAnimatedMapIndices.
|
||||||
|
@see setAnimatedMapIndices
|
||||||
|
*/
|
||||||
|
virtual void setLODAnimatedMapMapping(std::uint16_t lod, std::uint16_t index) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored mesh names.
|
||||||
|
*/
|
||||||
|
virtual void clearMeshNames() = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the specified mesh.
|
||||||
|
@param index
|
||||||
|
A name's position in the zero-indexed array of mesh names.
|
||||||
|
@note
|
||||||
|
The mesh name storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of names that is inferred from the specified index.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setMeshName(std::uint16_t index, const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored mesh indices.
|
||||||
|
*/
|
||||||
|
virtual void clearMeshIndices() = 0;
|
||||||
|
/**
|
||||||
|
@brief Store a list of mesh name indices onto a specified index.
|
||||||
|
@param index
|
||||||
|
A position in a zero-indexed array where mesh name indices are stored.
|
||||||
|
@note
|
||||||
|
The index denotes the position of an entire mesh index list,
|
||||||
|
not the position of it's individual elements, i.e. the row index in a 2D
|
||||||
|
matrix of mesh indices.
|
||||||
|
@note
|
||||||
|
The mesh index storage will be implicitly resized (if needed) to provide storage
|
||||||
|
for the number of mesh name indices that is inferred from the specified index.
|
||||||
|
@param meshIndices
|
||||||
|
The source address from which the mesh name indices are to be copied.
|
||||||
|
@note
|
||||||
|
These indices can be used to access mesh names through DefinitionReader::getMeshName.
|
||||||
|
@param count
|
||||||
|
The number of mesh name indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setMeshIndices(std::uint16_t index, const std::uint16_t* meshIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored LOD to mesh list index mapping entries.
|
||||||
|
*/
|
||||||
|
virtual void clearLODMeshMappings() = 0;
|
||||||
|
/**
|
||||||
|
@brief Set which meshes belong to which level of detail.
|
||||||
|
@param lod
|
||||||
|
The actual level of detail to which the meshes are being associated.
|
||||||
|
@param index
|
||||||
|
The index onto which mesh indices were assigned using setMeshIndices.
|
||||||
|
@see setMeshIndices
|
||||||
|
*/
|
||||||
|
virtual void setLODMeshMapping(std::uint16_t lod, std::uint16_t index) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all stored mesh to blend shape channel mapping entries.
|
||||||
|
*/
|
||||||
|
virtual void clearMeshBlendShapeChannelMappings() = 0;
|
||||||
|
/**
|
||||||
|
@brief Associate a blend shape channel with it's mesh.
|
||||||
|
@param index
|
||||||
|
A mapping's position in the zero-indexed array of mesh-blend shape channel mappings.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of mesh names.
|
||||||
|
@param blendShapeChannelIndex
|
||||||
|
A blend shape channel's position in the zero-indexed array of blend shape channel names.
|
||||||
|
*/
|
||||||
|
virtual void setMeshBlendShapeChannelMapping(std::uint32_t index, std::uint16_t meshIndex, std::uint16_t blendShapeChannelIndex) = 0;
|
||||||
|
/**
|
||||||
|
@brief A simple array describing the parent-child relationships between joints.
|
||||||
|
@note
|
||||||
|
Example:
|
||||||
|
Joint names: [A, B, C, D, E, F, G, H]
|
||||||
|
Hierarchy: [0, 0, 0, 1, 1, 4, 2, 2]
|
||||||
|
Describes the following hierarchy:
|
||||||
|
A
|
||||||
|
+ B
|
||||||
|
| + D
|
||||||
|
| + E
|
||||||
|
| + F
|
||||||
|
+ C
|
||||||
|
+ G
|
||||||
|
+ H
|
||||||
|
@param jointIndices
|
||||||
|
The source address from which the joint indices are to be copied.
|
||||||
|
@note
|
||||||
|
These indices can be used to access joint names through DefinitionReader::getJointName.
|
||||||
|
@param count
|
||||||
|
The number of joint indices to copy.
|
||||||
|
*/
|
||||||
|
virtual void setJointHierarchy(const std::uint16_t* jointIndices, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@param translations
|
||||||
|
The source address from which the translations are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of translation values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setNeutralJointTranslations(const Vector3* translations, std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@param rotations
|
||||||
|
The source address from which the rotations are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of rotation values to copy.
|
||||||
|
*/
|
||||||
|
virtual void setNeutralJointRotations(const Vector3* rotations, std::uint16_t count) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
47
dnacalib/DNACalib/include/dna/layers/Descriptor.h
Normal file
47
dnacalib/DNACalib/include/dna/layers/Descriptor.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
enum class Archetype {
|
||||||
|
asian,
|
||||||
|
black,
|
||||||
|
caucasian,
|
||||||
|
hispanic,
|
||||||
|
alien,
|
||||||
|
other
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Gender {
|
||||||
|
male,
|
||||||
|
female,
|
||||||
|
other
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class TranslationUnit {
|
||||||
|
cm,
|
||||||
|
m
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class RotationUnit {
|
||||||
|
degrees,
|
||||||
|
radians
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Direction {
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
up,
|
||||||
|
down,
|
||||||
|
front,
|
||||||
|
back
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CoordinateSystem {
|
||||||
|
Direction xAxis;
|
||||||
|
Direction yAxis;
|
||||||
|
Direction zAxis;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
80
dnacalib/DNACalib/include/dna/layers/DescriptorReader.h
Normal file
80
dnacalib/DNACalib/include/dna/layers/DescriptorReader.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/Descriptor.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Read-only accessors for various metadata about the character and the rig.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Reader itself and not this class.
|
||||||
|
@see Reader
|
||||||
|
*/
|
||||||
|
class DNAAPI DescriptorReader {
|
||||||
|
protected:
|
||||||
|
virtual ~DescriptorReader();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual StringView getName() const = 0;
|
||||||
|
virtual Archetype getArchetype() const = 0;
|
||||||
|
virtual Gender getGender() const = 0;
|
||||||
|
virtual std::uint16_t getAge() const = 0;
|
||||||
|
virtual std::uint32_t getMetaDataCount() const = 0;
|
||||||
|
/**
|
||||||
|
@param index
|
||||||
|
A position in the zero-indexed array of key-value pairs.
|
||||||
|
@warning
|
||||||
|
The index must be less than the value returned by getMetaDataCount.
|
||||||
|
@return View over the key name string.
|
||||||
|
*/
|
||||||
|
virtual StringView getMetaDataKey(std::uint32_t index) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Stored metadata value associated with the given key.
|
||||||
|
@note
|
||||||
|
If no value is associated with the given key, the returned view
|
||||||
|
will contain nullptr and will have a size of 0.
|
||||||
|
@param key
|
||||||
|
A unique-known key that has a value associated to it.
|
||||||
|
@warning
|
||||||
|
The key must be null-terminated.
|
||||||
|
@return View over the metadata value string.
|
||||||
|
*/
|
||||||
|
virtual StringView getMetaDataValue(const char* key) const = 0;
|
||||||
|
virtual TranslationUnit getTranslationUnit() const = 0;
|
||||||
|
virtual RotationUnit getRotationUnit() const = 0;
|
||||||
|
virtual CoordinateSystem getCoordinateSystem() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Available levels of detail (e.g. 6 which means the following levels are available:
|
||||||
|
[0,1,2,3,4,5], where 0 is the LOD with the highest details, and 5 is the LOD with
|
||||||
|
lowest details).
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getLODCount() const = 0;
|
||||||
|
/**
|
||||||
|
@brief The maximum level of detail stored in the DNA data for this character.
|
||||||
|
@note
|
||||||
|
The value is relative to LOD-0 from the database.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getDBMaxLOD() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the input control interface used to drive this character rig.
|
||||||
|
@note
|
||||||
|
This parameter denotes the character's input control complexity.
|
||||||
|
*/
|
||||||
|
virtual StringView getDBComplexity() const = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the database from which the character originates.
|
||||||
|
@note
|
||||||
|
All characters from the same database must have the same Definition, but may
|
||||||
|
have different complexity or LOD.
|
||||||
|
*/
|
||||||
|
virtual StringView getDBName() const = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
83
dnacalib/DNACalib/include/dna/layers/DescriptorWriter.h
Normal file
83
dnacalib/DNACalib/include/dna/layers/DescriptorWriter.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/Descriptor.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Write-only accessors to various metadata about the character and the rig.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Writer itself and not this class.
|
||||||
|
@see Writer
|
||||||
|
*/
|
||||||
|
class DNAAPI DescriptorWriter {
|
||||||
|
protected:
|
||||||
|
virtual ~DescriptorWriter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an allocation.
|
||||||
|
*/
|
||||||
|
virtual void setName(const char* name) = 0;
|
||||||
|
virtual void setArchetype(Archetype archetype) = 0;
|
||||||
|
virtual void setGender(Gender gender) = 0;
|
||||||
|
virtual void setAge(std::uint16_t age) = 0;
|
||||||
|
/**
|
||||||
|
@brief Empties the metadata storage, delete all key-value pairs.
|
||||||
|
*/
|
||||||
|
virtual void clearMetaData() = 0;
|
||||||
|
/**
|
||||||
|
@brief Associate the metadata value with the given key.
|
||||||
|
@param key
|
||||||
|
A unique, null-terminated key, to which the given value will be assigned.
|
||||||
|
@param value
|
||||||
|
A null-terminated, metadata value, which is to be assigned to the given key.
|
||||||
|
@note
|
||||||
|
Consecutive calls using the same key will overwrite any existing data.
|
||||||
|
@note
|
||||||
|
Passing nullptr as the value argument will cause the associated key to be deleted.
|
||||||
|
*/
|
||||||
|
virtual void setMetaData(const char* key, const char* value) = 0;
|
||||||
|
virtual void setTranslationUnit(TranslationUnit unit) = 0;
|
||||||
|
virtual void setRotationUnit(RotationUnit unit) = 0;
|
||||||
|
virtual void setCoordinateSystem(CoordinateSystem system) = 0;
|
||||||
|
/**
|
||||||
|
@brief Available levels of detail (e.g. 6 which means the following levels are available:
|
||||||
|
[0,1,2,3,4,5], where 0 is the LOD with the highest details, and 5 is the LOD with
|
||||||
|
lowest details).
|
||||||
|
@param lodCount
|
||||||
|
The number of levels available.
|
||||||
|
*/
|
||||||
|
virtual void setLODCount(std::uint16_t lodCount) = 0;
|
||||||
|
/**
|
||||||
|
@brief The maximum level of detail stored in the DNA data for this character.
|
||||||
|
*/
|
||||||
|
virtual void setDBMaxLOD(std::uint16_t lod) = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the input control interface used to drive this character rig.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setDBComplexity(const char* name) = 0;
|
||||||
|
/**
|
||||||
|
@brief Name of the database from which the character originates.
|
||||||
|
@param name
|
||||||
|
A null-terminated string.
|
||||||
|
@note
|
||||||
|
The passed in name is copied, which will involve an additional allocation.
|
||||||
|
*/
|
||||||
|
virtual void setDBName(const char* name) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
26
dnacalib/DNACalib/include/dna/layers/Geometry.h
Normal file
26
dnacalib/DNACalib/include/dna/layers/Geometry.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/types/Vector3.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
struct TextureCoordinate {
|
||||||
|
float u;
|
||||||
|
float v;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Position = Vector3;
|
||||||
|
using Normal = Vector3;
|
||||||
|
using Delta = Vector3;
|
||||||
|
|
||||||
|
struct VertexLayout {
|
||||||
|
std::uint32_t position;
|
||||||
|
std::uint32_t textureCoordinate;
|
||||||
|
std::uint32_t normal;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
442
dnacalib/DNACalib/include/dna/layers/GeometryReader.h
Normal file
442
dnacalib/DNACalib/include/dna/layers/GeometryReader.h
Normal file
@ -0,0 +1,442 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/DefinitionReader.h"
|
||||||
|
#include "dna/layers/Geometry.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Read-only accessors to the geometry data associated with a rig.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Reader itself and not this class.
|
||||||
|
*/
|
||||||
|
class DNAAPI GeometryReader : public virtual DefinitionReader {
|
||||||
|
protected:
|
||||||
|
virtual ~GeometryReader();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Number of vertex positions in the entire mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getVertexPositionCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param vertexIndex
|
||||||
|
The index of the vertex position in the zero-indexed array of vertex positions.
|
||||||
|
@warning
|
||||||
|
vertexIndex must be less than the value returned by getVertexPositionCount.
|
||||||
|
@note
|
||||||
|
The vertices are sorted by the vertex ID.
|
||||||
|
@return The vertex position.
|
||||||
|
*/
|
||||||
|
virtual Position getVertexPosition(std::uint16_t meshIndex, std::uint32_t vertexIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all vertex position X values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexPosition.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all X values.
|
||||||
|
@see getVertexPosition
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexPositionXs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all vertex position Y values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexPosition.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all Y values.
|
||||||
|
@see getVertexPosition
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexPositionYs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all vertex position Z values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexPosition.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all Z values.
|
||||||
|
@see getVertexPosition
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexPositionZs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of texture coordinates in the entire mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getVertexTextureCoordinateCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param textureCoordinateIndex
|
||||||
|
The index of the texture coordinate in the zero-indexed array of texture coordinates.
|
||||||
|
@warning
|
||||||
|
textureCoordinateIndex must be less than the value returned by getVertexTextureCoordinateCount.
|
||||||
|
@return The texture coordinate.
|
||||||
|
*/
|
||||||
|
virtual TextureCoordinate getVertexTextureCoordinate(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t textureCoordinateIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all texture coordinate U values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexTextureCoordinate.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all U values.
|
||||||
|
@see getVertexTextureCoordinate
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexTextureCoordinateUs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all texture coordinate V values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexTextureCoordinate.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all V values.
|
||||||
|
@see getVertexTextureCoordinate
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexTextureCoordinateVs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of vertex normals in the entire mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getVertexNormalCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param normalIndex
|
||||||
|
The index of the vertex normal in the zero-indexed array of vertex normals.
|
||||||
|
@warning
|
||||||
|
normalIndex must be less than the value returned by getVertexNormalCount.
|
||||||
|
@return The vertex normal.
|
||||||
|
*/
|
||||||
|
virtual Normal getVertexNormal(std::uint16_t meshIndex, std::uint32_t normalIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all normal X values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexNormal.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all X values.
|
||||||
|
@see getVertexNormal
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexNormalXs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all normal Y value for the referenced meshs.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexNormal.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all Y values.
|
||||||
|
@see getVertexNormal
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexNormalYs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all normal Z values for the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexNormal.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all Z values.
|
||||||
|
@see getVertexNormal
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getVertexNormalZs(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of vertex layouts in the entire mesh.
|
||||||
|
@note
|
||||||
|
A vertex layout is a collection of vertex attributes.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getVertexLayoutCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Vertex layouts contain only attribute indices which can be used to query
|
||||||
|
the actual attributes, such as positions, texture coordinates and normals,
|
||||||
|
which are associated with the vertex.
|
||||||
|
@note
|
||||||
|
The indices from a layout are usable with the above defined APIs.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param layoutIndex
|
||||||
|
The index of the layout in the zero-indexed array of vertex layouts.
|
||||||
|
@warning
|
||||||
|
layoutIndex must be less than the value returned by getVertexLayoutCount.
|
||||||
|
@see getVertexPosition
|
||||||
|
@see getVertexTextureCoordinate
|
||||||
|
@see getVertexNormal
|
||||||
|
*/
|
||||||
|
virtual VertexLayout getVertexLayout(std::uint16_t meshIndex, std::uint32_t layoutIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Position indices for each vertex of the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexLayout.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all vertex position indices values.
|
||||||
|
@see getVertexLayout
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint32_t> getVertexLayoutPositionIndices(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Texture coordinate indices for each vertex of the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexLayout.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all vertex texture coordinate indices.
|
||||||
|
@see getVertexLayout
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint32_t> getVertexLayoutTextureCoordinateIndices(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Normal indices for each vertex of the referenced mesh.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getVertexLayout.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@return View over all vertex normal indices.
|
||||||
|
@see getVertexLayout
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint32_t> getVertexLayoutNormalIndices(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of faces that belong to the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getFaceCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of vertex layout indices the belong to a face on the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param faceIndex
|
||||||
|
A face's position in the zero-indexed array of faces that belong to
|
||||||
|
the above referenced mesh.
|
||||||
|
@warning
|
||||||
|
faceIndex must be less than the value returned by getFaceCount.
|
||||||
|
@return View over the list of vertex layout indices.
|
||||||
|
@see getVertexLayout
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint32_t> getFaceVertexLayoutIndices(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t faceIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief The maximum number of joints that may influence any single vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getMaximumInfluencePerVertex(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of skin weights associated with the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getSkinWeightsCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of skin weights influencing the requested vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param vertexIndex
|
||||||
|
A position in the zero-indexed array of vertices.
|
||||||
|
@warning
|
||||||
|
vertexIndex must be less than the value returned by getVertexPositionCount.
|
||||||
|
@return View over the list of skin weights.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getSkinWeightsValues(std::uint16_t meshIndex, std::uint32_t vertexIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of joint indices associated with each skin weight for the specified vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param vertexIndex
|
||||||
|
A position in the zero-indexed array of vertices.
|
||||||
|
@warning
|
||||||
|
vertexIndex must be less than the value returned by getVertexPositionCount.
|
||||||
|
@note
|
||||||
|
The joint indices are stored in the same order as the weights they
|
||||||
|
are associated with.
|
||||||
|
@return View over the list of joint indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint16_t> getSkinWeightsJointIndices(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t vertexIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of blend shapes that belong to the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getBlendShapeTargetCount(std::uint16_t meshIndex) const = 0;
|
||||||
|
/** @brief The matching blend shape channel index of the requested blend shape target.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
@see DefinitionReader::getBlendShapeChannelName
|
||||||
|
*/
|
||||||
|
virtual std::uint16_t getBlendShapeChannelIndex(std::uint16_t meshIndex, std::uint16_t blendShapeTargetIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Number of deltas that belong to the specified blend shape.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
*/
|
||||||
|
virtual std::uint32_t getBlendShapeTargetDeltaCount(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of deltas for each affected vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
@param deltaIndex
|
||||||
|
A position in the zero-indexed array of blend shapes deltas.
|
||||||
|
@warning
|
||||||
|
deltaIndex must be less than the value returned by getBlendShapeTargetDeltaCount.
|
||||||
|
*/
|
||||||
|
virtual Delta getBlendShapeTargetDelta(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
std::uint32_t deltaIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all delta X values for the referenced blend shape target.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getBlendShapeTargetDelta.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
@return View over all X values.
|
||||||
|
@see getBlendShapeTargetDelta
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getBlendShapeTargetDeltaXs(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all delta Y values for the referenced blend shape target.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getBlendShapeTargetDelta.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
@return View over all Y values.
|
||||||
|
@see getBlendShapeTargetDelta
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getBlendShapeTargetDeltaYs(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief List of all delta Z values for the referenced blend shape target.
|
||||||
|
@note
|
||||||
|
This is an advanced API for performance critical access, for more convenient usage see getBlendShapeTargetDelta.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
@return View over all Z values.
|
||||||
|
@see getBlendShapeTargetDelta
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<float> getBlendShapeTargetDeltaZs(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex) const = 0;
|
||||||
|
/**
|
||||||
|
@brief Vertex position indices affected by the referenced blend shape target.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@warning
|
||||||
|
blendShapeTargetIndex must be less than the value returned by getBlendShapeTargetCount.
|
||||||
|
@note
|
||||||
|
The vertex position indices are stored in the same order as the deltas they
|
||||||
|
are associated with.
|
||||||
|
These indices can be used to query the associated vertices themselves through getVertexPosition.
|
||||||
|
@see getVertexPosition
|
||||||
|
@return View over the list of vertex position indices.
|
||||||
|
*/
|
||||||
|
virtual ConstArrayView<std::uint32_t> getBlendShapeTargetVertexIndices(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex) const = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
248
dnacalib/DNACalib/include/dna/layers/GeometryWriter.h
Normal file
248
dnacalib/DNACalib/include/dna/layers/GeometryWriter.h
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/Defs.h"
|
||||||
|
#include "dna/layers/DefinitionWriter.h"
|
||||||
|
#include "dna/layers/Geometry.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Write-only accessors for the geometry data associated with a rig.
|
||||||
|
@warning
|
||||||
|
Implementors should inherit from Writer itself and not this class.
|
||||||
|
@see Writer
|
||||||
|
*/
|
||||||
|
class DNAAPI GeometryWriter : public virtual DefinitionWriter {
|
||||||
|
protected:
|
||||||
|
virtual ~GeometryWriter();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Delete all meshes.
|
||||||
|
*/
|
||||||
|
virtual void clearMeshes() = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual void deleteMesh(std::uint16_t meshIndex) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of vertex positions.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param positions
|
||||||
|
The source address from which the vertex positions are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of vertex positions to copy.
|
||||||
|
@note
|
||||||
|
The mesh storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of meshes that is inferred from the specified index.
|
||||||
|
*/
|
||||||
|
virtual void setVertexPositions(std::uint16_t meshIndex, const Position* positions, std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of vertex texture coordinates.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param textureCoordinates
|
||||||
|
The source address from which the texture coordinates are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of texture coordinates to copy.
|
||||||
|
@note
|
||||||
|
The mesh storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of meshes that is inferred from the specified index.
|
||||||
|
*/
|
||||||
|
virtual void setVertexTextureCoordinates(std::uint16_t meshIndex,
|
||||||
|
const TextureCoordinate* textureCoordinates,
|
||||||
|
std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of vertex normals.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param normals
|
||||||
|
The source address from which the normals are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of normals to copy.
|
||||||
|
@note
|
||||||
|
The mesh storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of meshes that is inferred from the specified index.
|
||||||
|
*/
|
||||||
|
virtual void setVertexNormals(std::uint16_t meshIndex, const Normal* normals, std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of vertex layouts the belong to the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param layouts
|
||||||
|
The source address from which the layouts are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of layouts to copy.
|
||||||
|
@note
|
||||||
|
The mesh storage will be implicitly resized (if needed) to provide
|
||||||
|
storage for the number of meshes that is inferred from the specified index.
|
||||||
|
*/
|
||||||
|
virtual void setVertexLayouts(std::uint16_t meshIndex, const VertexLayout* layouts, std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all lists of vertex layout indices for the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual void clearFaceVertexLayoutIndices(std::uint16_t meshIndex) = 0;
|
||||||
|
/**
|
||||||
|
@brief Vertex layout indices that belong to the specified face.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param faceIndex
|
||||||
|
A face's position in the zero-indexed array of faces that belong to
|
||||||
|
the above referenced mesh.
|
||||||
|
@param layoutIndices
|
||||||
|
The source address from which the layout indices are to be copied.
|
||||||
|
@note
|
||||||
|
The layout indices point into the array that is set through setVertexLayouts
|
||||||
|
@param count
|
||||||
|
The number of vertices to copy.
|
||||||
|
@note
|
||||||
|
Both the mesh storage itself and it's face storage will be implicitly
|
||||||
|
resized (if needed) to provide storage for the number of meshes and/or
|
||||||
|
faces that are inferred from the specified indexes.
|
||||||
|
*/
|
||||||
|
virtual void setFaceVertexLayoutIndices(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t faceIndex,
|
||||||
|
const std::uint32_t* layoutIndices,
|
||||||
|
std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param maxInfluenceCount
|
||||||
|
The maximum number of joints that may influence any single vertex.
|
||||||
|
*/
|
||||||
|
virtual void setMaximumInfluencePerVertex(std::uint16_t meshIndex, std::uint16_t maxInfluenceCount) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all skin weights for the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual void clearSkinWeights(std::uint16_t meshIndex) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of skin weights influencing the referenced vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param vertexIndex
|
||||||
|
A position in the zero-indexed array of vertex positions.
|
||||||
|
@param weights
|
||||||
|
The source address from which the weights are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of weights to copy.
|
||||||
|
@note
|
||||||
|
Both the mesh storage itself and it's skin weight storage will be implicitly
|
||||||
|
resized (if needed) to provide storage for the number of meshes and/or
|
||||||
|
skin-weight lists that are inferred from the specified indexes.
|
||||||
|
@warning
|
||||||
|
The sum of weights must add up to 1.
|
||||||
|
*/
|
||||||
|
virtual void setSkinWeightsValues(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t vertexIndex,
|
||||||
|
const float* weights,
|
||||||
|
std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of joint indices associated with each skin weight for the specified vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param vertexIndex
|
||||||
|
A position in the zero-indexed array of vertex positions.
|
||||||
|
@param jointIndices
|
||||||
|
The source address from which the joint indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of joint indices to copy.
|
||||||
|
@note
|
||||||
|
Both the mesh storage itself and it's joint index list storage will be implicitly
|
||||||
|
resized (if needed) to provide storage for the number of meshes and/or
|
||||||
|
joint index lists that are inferred from the specified indexes.
|
||||||
|
@warning
|
||||||
|
The joint indices must be stored in the same order as the weights they
|
||||||
|
are associated with.
|
||||||
|
*/
|
||||||
|
virtual void setSkinWeightsJointIndices(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t vertexIndex,
|
||||||
|
const std::uint16_t* jointIndices,
|
||||||
|
std::uint16_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Delete all blend shape targets for the specified mesh.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@warning
|
||||||
|
meshIndex must be less than the value returned by getMeshCount.
|
||||||
|
*/
|
||||||
|
virtual void clearBlendShapeTargets(std::uint16_t meshIndex) = 0;
|
||||||
|
/** @brief The matching blend shape channel index of the specified blend shape target.
|
||||||
|
@note
|
||||||
|
Associate the mesh-local blend shape target index with the absolute blend shape channel
|
||||||
|
index as found in the Definition layer.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@param blendShapeChannelIndex
|
||||||
|
The index of the specified blend shape channel in the Definition layer.
|
||||||
|
@note
|
||||||
|
Both the mesh storage itself and it's blend shape target storage will be implicitly
|
||||||
|
resized (if needed) to provide storage for the number of meshes and/or
|
||||||
|
blend shape targets that are inferred from the specified indexes.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeChannelIndex(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
std::uint16_t blendShapeChannelIndex) = 0;
|
||||||
|
/**
|
||||||
|
@brief List of deltas for each affected vertex.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@param deltas
|
||||||
|
The source address from which the blend shape target deltas are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of blend shape target deltas to copy.
|
||||||
|
@note
|
||||||
|
Both the mesh storage itself and it's blend shape target storage will be implicitly
|
||||||
|
resized (if needed) to provide storage for the number of meshes and/or
|
||||||
|
blend shape targets that are inferred from the specified indexes.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeTargetDeltas(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
const Delta* deltas,
|
||||||
|
std::uint32_t count) = 0;
|
||||||
|
/**
|
||||||
|
@brief Vertex position indices affected by the specified blend shape target.
|
||||||
|
@param meshIndex
|
||||||
|
A mesh's position in the zero-indexed array of meshes.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
A position in the zero-indexed array of blend shape targets within the specified mesh.
|
||||||
|
@param vertexIndices
|
||||||
|
The source address from which the vertex position indices are to be copied.
|
||||||
|
@param count
|
||||||
|
The number of vertex position indices to copy.
|
||||||
|
@note
|
||||||
|
Both the mesh storage itself and it's blend shape target storage will be implicitly
|
||||||
|
resized (if needed) to provide storage for the number of meshes and/or
|
||||||
|
blend shape targets that are inferred from the specified indexes.
|
||||||
|
@warning
|
||||||
|
The vertex position indices must be stored in the same order as the deltas
|
||||||
|
they are associated with.
|
||||||
|
*/
|
||||||
|
virtual void setBlendShapeTargetVertexIndices(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
const std::uint32_t* vertexIndices,
|
||||||
|
std::uint32_t count) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
33
dnacalib/DNACalib/include/dna/types/Aliases.h
Normal file
33
dnacalib/DNACalib/include/dna/types/Aliases.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/types/ArrayView.h"
|
||||||
|
#include "dna/types/StringView.h"
|
||||||
|
|
||||||
|
#include <pma/MemoryResource.h>
|
||||||
|
#include <pma/ScopedPtr.h>
|
||||||
|
#include <status/Status.h>
|
||||||
|
#include <status/StatusCode.h>
|
||||||
|
#include <trio/Stream.h>
|
||||||
|
#include <trio/streams/FileStream.h>
|
||||||
|
#include <trio/streams/MemoryMappedFileStream.h>
|
||||||
|
#include <trio/streams/MemoryStream.h>
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using ArrayView = trust::ArrayView<T>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using ConstArrayView = trust::ConstArrayView<T>;
|
||||||
|
|
||||||
|
using trio::BoundedIOStream;
|
||||||
|
using trio::FileStream;
|
||||||
|
using trio::MemoryMappedFileStream;
|
||||||
|
using trio::MemoryStream;
|
||||||
|
using sc::Status;
|
||||||
|
|
||||||
|
using namespace pma;
|
||||||
|
|
||||||
|
} // namespace dna
|
241
dnacalib/DNACalib/include/dna/types/ArrayView.h
Normal file
241
dnacalib/DNACalib/include/dna/types/ArrayView.h
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// *INDENT-OFF*
|
||||||
|
#ifndef TRUST_ARRAYVIEW_H
|
||||||
|
#define TRUST_ARRAYVIEW_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4365 4987)
|
||||||
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace trust {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct ArrayViewTraits {
|
||||||
|
using value_type = T;
|
||||||
|
using reference = T&;
|
||||||
|
using const_reference = const T&;
|
||||||
|
using pointer = T*;
|
||||||
|
using const_pointer = const T*;
|
||||||
|
using size_type = std::size_t;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct ArrayViewTraits<const T> {
|
||||||
|
using value_type = const T;
|
||||||
|
using reference = const T&;
|
||||||
|
using const_reference = const T&;
|
||||||
|
using pointer = const T*;
|
||||||
|
using const_pointer = const T*;
|
||||||
|
using size_type = std::size_t;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
struct IsCompatible {
|
||||||
|
static constexpr bool value = std::is_same<typename std::remove_cv<T>::type, typename std::remove_cv<U>::type>::value &&
|
||||||
|
(std::is_const<typename std::remove_reference<T>::type>::value ||
|
||||||
|
!std::is_const<typename std::remove_reference<U>::type>::value);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief A view over a continuous sequence of objects.
|
||||||
|
@tparam T element type
|
||||||
|
Provides a view over a continuous sequence of objects owned by some other object.
|
||||||
|
Contains a count of elements and a pointer to a location where they are stored.
|
||||||
|
ArrayView does not own the memory it points to - it does not perform any allocation
|
||||||
|
and deallocation. It can be constructed given a pointer and element count, or a container
|
||||||
|
type argument. The class provides helper methods for creating subviews over the objects,
|
||||||
|
and methods for by-value comparison with containers. ConstArrayView represents an immutable view.
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
class ArrayView {
|
||||||
|
public:
|
||||||
|
using value_type = typename ArrayViewTraits<T>::value_type;
|
||||||
|
using reference = typename ArrayViewTraits<T>::reference;
|
||||||
|
using const_reference = typename ArrayViewTraits<T>::const_reference;
|
||||||
|
using const_pointer = typename ArrayViewTraits<T>::const_pointer;
|
||||||
|
using pointer = typename ArrayViewTraits<T>::pointer;
|
||||||
|
using size_type = typename ArrayViewTraits<T>::size_type;
|
||||||
|
using difference_type = typename ArrayViewTraits<T>::difference_type;
|
||||||
|
|
||||||
|
ArrayView() = default;
|
||||||
|
~ArrayView() noexcept = default;
|
||||||
|
|
||||||
|
ArrayView(const ArrayView&) = default;
|
||||||
|
ArrayView& operator=(const ArrayView&) = default;
|
||||||
|
|
||||||
|
ArrayView(ArrayView&&) = default;
|
||||||
|
ArrayView& operator=(ArrayView&&) = default;
|
||||||
|
|
||||||
|
ArrayView(pointer src, size_type size) :
|
||||||
|
ptr{src},
|
||||||
|
sz{size} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, typename std::enable_if<IsCompatible<T, U>::value, int>::type = 0>
|
||||||
|
ArrayView(ArrayView<U>& src) : ArrayView{src.data(), src.size()} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, typename std::enable_if<IsCompatible<T, U>::value, int>::type = 0>
|
||||||
|
ArrayView(const ArrayView<U>& src) : ArrayView{src.data(), src.size()} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, typename std::enable_if<IsCompatible<T, U>::value, int>::type = 0>
|
||||||
|
ArrayView(ArrayView<U>&& src) : ArrayView{src.data(), src.size()} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U,
|
||||||
|
typename std::enable_if<!std::is_rvalue_reference<U &&>::value &&
|
||||||
|
IsCompatible<T, typename std::remove_reference<U>::type::value_type>::value,
|
||||||
|
int>::type = 0>
|
||||||
|
ArrayView(U&& src) : ArrayView{src.data(), static_cast<size_type>(src.size())} {
|
||||||
|
}
|
||||||
|
|
||||||
|
size_type size() const {
|
||||||
|
return sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer data() {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_pointer data() const {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer begin() {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer end() {
|
||||||
|
return ptr + sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_pointer cbegin() const {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_pointer cend() const {
|
||||||
|
return ptr + sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_pointer begin() const {
|
||||||
|
return cbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
const_pointer end() const {
|
||||||
|
return cend();
|
||||||
|
}
|
||||||
|
|
||||||
|
reference operator[](std::size_t index) {
|
||||||
|
assert(index < sz);
|
||||||
|
return ptr[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
const_reference operator[](std::size_t index) const {
|
||||||
|
assert(index < sz);
|
||||||
|
return ptr[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
reference at(std::size_t index) {
|
||||||
|
return this->operator[](index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const_reference at(std::size_t index) const {
|
||||||
|
return this->operator[](index);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayView subview(std::size_t offset, std::size_t count) const {
|
||||||
|
assert(offset <= sz);
|
||||||
|
assert((offset + count) <= sz);
|
||||||
|
return {ptr + offset, count};
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayView first(std::size_t count) const {
|
||||||
|
assert(count <= sz);
|
||||||
|
return {ptr, count};
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayView last(std::size_t count) const {
|
||||||
|
assert(count <= sz);
|
||||||
|
return {ptr + (sz - count), count};
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
pointer ptr{nullptr};
|
||||||
|
size_type sz{};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator==(const ArrayView<T>& lhs, const ArrayView<U>& rhs) {
|
||||||
|
if (lhs.size() != rhs.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (lhs.data() == rhs.data()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||||
|
// Under Visual Studio 2015, the overload of std::equal accepting 4 parameters must be used,
|
||||||
|
// because the 3-parameter version causes insuppressible warnings
|
||||||
|
return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||||
|
#else
|
||||||
|
return std::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator!=(const ArrayView<T>& lhs, const ArrayView<U>& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename TContainer>
|
||||||
|
typename std::enable_if<!std::is_base_of<ArrayView<T>, TContainer>::value, bool>::type operator==(const ArrayView<T>& lhs,
|
||||||
|
const TContainer& rhs) {
|
||||||
|
if (lhs.size() != rhs.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||||
|
// Under Visual Studio 2015, the overload of std::equal accepting 4 parameters must be used,
|
||||||
|
// because the 3-parameter version causes insuppressible warnings
|
||||||
|
return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||||
|
#else
|
||||||
|
return std::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename TContainer>
|
||||||
|
typename std::enable_if<!std::is_base_of<ArrayView<T>, TContainer>::value, bool>::type operator!=(const ArrayView<T>& lhs,
|
||||||
|
const TContainer& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename TContainer>
|
||||||
|
typename std::enable_if<!std::is_base_of<ArrayView<T>, TContainer>::value, bool>::type operator==(const TContainer& lhs,
|
||||||
|
const ArrayView<T>& rhs) {
|
||||||
|
return (rhs == lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename TContainer>
|
||||||
|
typename std::enable_if<!std::is_base_of<ArrayView<T>, TContainer>::value, bool>::type operator!=(const TContainer& lhs,
|
||||||
|
const ArrayView<T>& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using ConstArrayView = ArrayView<const T>;
|
||||||
|
|
||||||
|
} // namespace trust
|
||||||
|
|
||||||
|
#endif // TRUST_ARRAYVIEW_H
|
||||||
|
// *INDENT-ON*
|
35
dnacalib/DNACalib/include/dna/types/StringView.h
Normal file
35
dnacalib/DNACalib/include/dna/types/StringView.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/types/ArrayView.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class StringView : public trust::ConstArrayView<char> {
|
||||||
|
public:
|
||||||
|
using Base = trust::ConstArrayView<char>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Base::ArrayView;
|
||||||
|
|
||||||
|
const char* c_str() const {
|
||||||
|
return dataOrEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
operator const char*() const {
|
||||||
|
return dataOrEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* operator*() const {
|
||||||
|
return dataOrEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* dataOrEmpty() const {
|
||||||
|
return (data() == nullptr ? "" : data());
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
110
dnacalib/DNACalib/include/dna/types/Vector3.h
Normal file
110
dnacalib/DNACalib/include/dna/types/Vector3.h
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
struct Vector3 {
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
|
||||||
|
Vector3& operator+=(const Vector3& rhs) {
|
||||||
|
x += rhs.x;
|
||||||
|
y += rhs.y;
|
||||||
|
z += rhs.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator-=(const Vector3& rhs) {
|
||||||
|
x -= rhs.x;
|
||||||
|
y -= rhs.y;
|
||||||
|
z -= rhs.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator*=(const Vector3& rhs) {
|
||||||
|
x *= rhs.x;
|
||||||
|
y *= rhs.y;
|
||||||
|
z *= rhs.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator/=(const Vector3& rhs) {
|
||||||
|
x /= rhs.x;
|
||||||
|
y /= rhs.y;
|
||||||
|
z /= rhs.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator+=(float rhs) {
|
||||||
|
x += rhs;
|
||||||
|
y += rhs;
|
||||||
|
z += rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator-=(float rhs) {
|
||||||
|
x -= rhs;
|
||||||
|
y -= rhs;
|
||||||
|
z -= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator*=(float rhs) {
|
||||||
|
x *= rhs;
|
||||||
|
y *= rhs;
|
||||||
|
z *= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3& operator/=(float rhs) {
|
||||||
|
x /= rhs;
|
||||||
|
y /= rhs;
|
||||||
|
z /= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
inline Vector3 operator+(Vector3 lhs, const Vector3& rhs) {
|
||||||
|
return (lhs += rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator-(Vector3 lhs, const Vector3& rhs) {
|
||||||
|
return (lhs -= rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator*(Vector3 lhs, const Vector3& rhs) {
|
||||||
|
return (lhs *= rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator/(Vector3 lhs, const Vector3& rhs) {
|
||||||
|
return (lhs /= rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator+(Vector3 lhs, float rhs) {
|
||||||
|
return (lhs += rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator-(Vector3 lhs, float rhs) {
|
||||||
|
return (lhs -= rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator*(Vector3 lhs, float rhs) {
|
||||||
|
return (lhs *= rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3 operator/(Vector3 lhs, float rhs) {
|
||||||
|
return (lhs /= rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const Vector3& lhs, const Vector3& rhs) {
|
||||||
|
return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const Vector3& lhs, const Vector3& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dna
|
8
dnacalib/DNACalib/include/dna/version/Version.h
Normal file
8
dnacalib/DNACalib/include/dna/version/Version.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define DNA_MAJOR_VERSION 7
|
||||||
|
#define DNA_MINOR_VERSION 1
|
||||||
|
#define DNA_PATCH_VERSION 0
|
||||||
|
#define DNA_VERSION_STRING "7.1.0"
|
22
dnacalib/DNACalib/include/dnacalib/Command.h
Normal file
22
dnacalib/DNACalib/include/dnacalib/Command.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Command is an abstract class whose implementations are expected to modify the DNA provided in the run() method in some way.
|
||||||
|
*/
|
||||||
|
class DNACAPI Command {
|
||||||
|
public:
|
||||||
|
virtual ~Command();
|
||||||
|
virtual void run(DNACalibDNAReader* output) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
29
dnacalib/DNACalib/include/dnacalib/DNACalib.h
Normal file
29
dnacalib/DNACalib/include/dnacalib/DNACalib.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/commands/CalculateMeshLowerLODsCommand.h"
|
||||||
|
#include "dnacalib/commands/ClearBlendShapesCommand.h"
|
||||||
|
#include "dnacalib/commands/CommandSequence.h"
|
||||||
|
#include "dnacalib/commands/ConditionalCommand.h"
|
||||||
|
#include "dnacalib/commands/PruneBlendShapeTargetsCommand.h"
|
||||||
|
#include "dnacalib/commands/RemoveAnimatedMapCommand.h"
|
||||||
|
#include "dnacalib/commands/RemoveBlendShapeCommand.h"
|
||||||
|
#include "dnacalib/commands/RemoveJointAnimationCommand.h"
|
||||||
|
#include "dnacalib/commands/RemoveJointCommand.h"
|
||||||
|
#include "dnacalib/commands/RemoveMeshCommand.h"
|
||||||
|
#include "dnacalib/commands/RenameAnimatedMapCommand.h"
|
||||||
|
#include "dnacalib/commands/RenameBlendShapeCommand.h"
|
||||||
|
#include "dnacalib/commands/RenameJointCommand.h"
|
||||||
|
#include "dnacalib/commands/RenameMeshCommand.h"
|
||||||
|
#include "dnacalib/commands/RotateCommand.h"
|
||||||
|
#include "dnacalib/commands/ScaleCommand.h"
|
||||||
|
#include "dnacalib/commands/SetBlendShapeTargetDeltasCommand.h"
|
||||||
|
#include "dnacalib/commands/SetLODsCommand.h"
|
||||||
|
#include "dnacalib/commands/SetNeutralJointTranslationsCommand.h"
|
||||||
|
#include "dnacalib/commands/SetNeutralJointRotationsCommand.h"
|
||||||
|
#include "dnacalib/commands/SetSkinWeightsCommand.h"
|
||||||
|
#include "dnacalib/commands/SetVertexPositionsCommand.h"
|
||||||
|
#include "dnacalib/commands/TranslateCommand.h"
|
||||||
|
#include "dnacalib/dna/DNACalibDNAReader.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
27
dnacalib/DNACalib/include/dnacalib/Defs.h
Normal file
27
dnacalib/DNACalib/include/dnacalib/Defs.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((dllexport))
|
||||||
|
#define DLL_IMPORT __attribute__((dllimport))
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define DLL_IMPORT DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DNAC_BUILD_SHARED)
|
||||||
|
// Build shared library
|
||||||
|
#define DNACAPI DLL_EXPORT
|
||||||
|
#elif defined(DNAC_SHARED)
|
||||||
|
// Use shared library
|
||||||
|
#define DNACAPI DLL_IMPORT
|
||||||
|
#else
|
||||||
|
// Build or use static library
|
||||||
|
#define DNACAPI
|
||||||
|
#endif
|
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CalculateMeshLowerLODsCommand is used to recalculate vertex positions for lower LOD meshes of the specified mesh.
|
||||||
|
@note
|
||||||
|
The calculation is done based on vertex positions of the specified mesh and vertex texture coordinates of its lower LOD meshes.
|
||||||
|
*/
|
||||||
|
class CalculateMeshLowerLODsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit CalculateMeshLowerLODsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI explicit CalculateMeshLowerLODsCommand(std::uint16_t meshIndex, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~CalculateMeshLowerLODsCommand();
|
||||||
|
|
||||||
|
CalculateMeshLowerLODsCommand(const CalculateMeshLowerLODsCommand&) = delete;
|
||||||
|
CalculateMeshLowerLODsCommand& operator=(const CalculateMeshLowerLODsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI CalculateMeshLowerLODsCommand(CalculateMeshLowerLODsCommand&&);
|
||||||
|
DNACAPI CalculateMeshLowerLODsCommand& operator=(CalculateMeshLowerLODsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the mesh to calculate lower LOD meshes from.
|
||||||
|
@param meshIndex
|
||||||
|
The index of the mesh.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMeshIndex(std::uint16_t meshIndex);
|
||||||
|
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ClearBlendShapesCommand is used to clear all blend shapes data from a DNA.
|
||||||
|
@note This command clears blend shape target deltas and blend shape animation data. By doing so, it transforms the DNA to be "joints only".
|
||||||
|
*/
|
||||||
|
class ClearBlendShapesCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit ClearBlendShapesCommand(MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~ClearBlendShapesCommand();
|
||||||
|
|
||||||
|
ClearBlendShapesCommand(const ClearBlendShapesCommand&) = delete;
|
||||||
|
ClearBlendShapesCommand& operator=(const ClearBlendShapesCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI ClearBlendShapesCommand(ClearBlendShapesCommand&&);
|
||||||
|
DNACAPI ClearBlendShapesCommand& operator=(ClearBlendShapesCommand&&);
|
||||||
|
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CommandSequence is used to run a sequence of commands on the same DNA.
|
||||||
|
@note
|
||||||
|
Commands will be run in the order in which they were added to the sequence.
|
||||||
|
@note
|
||||||
|
CommandSequence holds pointers to commands, but does not own them.
|
||||||
|
*/
|
||||||
|
class CommandSequence : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit CommandSequence(MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~CommandSequence();
|
||||||
|
|
||||||
|
CommandSequence(const CommandSequence&) = delete;
|
||||||
|
CommandSequence& operator=(const CommandSequence&) = delete;
|
||||||
|
|
||||||
|
DNACAPI CommandSequence(CommandSequence&&);
|
||||||
|
DNACAPI CommandSequence& operator=(CommandSequence&&);
|
||||||
|
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for adding a command to a sequence of commands to run.
|
||||||
|
@param command
|
||||||
|
The command to add.
|
||||||
|
*/
|
||||||
|
DNACAPI void add(Command* command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for adding multiple commands to a sequence of commands to run.
|
||||||
|
@param commands
|
||||||
|
The commands to add.
|
||||||
|
*/
|
||||||
|
DNACAPI void add(ArrayView<Command> commands);
|
||||||
|
|
||||||
|
template<class ... Commands>
|
||||||
|
void add(Commands... commands) {
|
||||||
|
static_assert(sizeof...(commands) > 0, "At least one command must be passed.");
|
||||||
|
Command* commandList[] = {commands ...};
|
||||||
|
for (auto cmd : commandList) {
|
||||||
|
add(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for removing a command from the sequence of commands to run.
|
||||||
|
@param command
|
||||||
|
The command to remove.
|
||||||
|
*/
|
||||||
|
DNACAPI void remove(Command* command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for removing an array of commands from the sequence of commands to run.
|
||||||
|
@param commands
|
||||||
|
The commands to remove.
|
||||||
|
*/
|
||||||
|
DNACAPI void remove(ArrayView<Command> commands);
|
||||||
|
|
||||||
|
template<class ... Commands>
|
||||||
|
void remove(Commands... commands) {
|
||||||
|
static_assert(sizeof...(commands) > 0, "At least one command must be passed.");
|
||||||
|
Command* commandList[] = {commands ...};
|
||||||
|
for (auto cmd : commandList) {
|
||||||
|
remove(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for checking if the provided command is part of the command sequence.
|
||||||
|
@param command
|
||||||
|
The command to check.
|
||||||
|
*/
|
||||||
|
DNACAPI bool contains(Command* command) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Number of commands in command sequence.
|
||||||
|
*/
|
||||||
|
DNACAPI std::size_t size() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,74 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ConditionalCommand is used to run a command if the specified condition is met.
|
||||||
|
*/
|
||||||
|
template<class TCommand, class TCondition>
|
||||||
|
class ConditionalCommand : public Command {
|
||||||
|
private:
|
||||||
|
using CommandType = TCommand;
|
||||||
|
using ConditionType = TCondition;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ConditionalCommand() :
|
||||||
|
command{nullptr},
|
||||||
|
condition{} {
|
||||||
|
}
|
||||||
|
|
||||||
|
ConditionalCommand(CommandType* command_, ConditionType condition_) :
|
||||||
|
command{command_},
|
||||||
|
condition{condition_} {
|
||||||
|
}
|
||||||
|
|
||||||
|
~ConditionalCommand() = default;
|
||||||
|
|
||||||
|
ConditionalCommand(const ConditionalCommand&) = delete;
|
||||||
|
ConditionalCommand& operator=(const ConditionalCommand&) = delete;
|
||||||
|
|
||||||
|
ConditionalCommand(ConditionalCommand&&) = default;
|
||||||
|
ConditionalCommand& operator=(ConditionalCommand&&) = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the command to run.
|
||||||
|
@param command_
|
||||||
|
The command to run.
|
||||||
|
*/
|
||||||
|
void setCommand(Command* command_) {
|
||||||
|
command = command_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the condition under which the command should run.
|
||||||
|
@param condition_
|
||||||
|
The condition that should be met.
|
||||||
|
*/
|
||||||
|
void setCondition(ConditionType condition_) {
|
||||||
|
condition = condition_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void run(DNACalibDNAReader* output) override {
|
||||||
|
if (command && condition(command, output)) {
|
||||||
|
command->run(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CommandType* command;
|
||||||
|
ConditionType condition;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class TCommand, class TCondition>
|
||||||
|
ConditionalCommand<TCommand, TCondition> makeConditional(TCommand* command, TCondition condition) {
|
||||||
|
return ConditionalCommand<TCommand, TCondition>{command, condition};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief PruneBlendShapeTargetsCommand is used to prune blend shape target deltas whose absolute magnitude is less than or equal to the specified threshold.
|
||||||
|
*/
|
||||||
|
class PruneBlendShapeTargetsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit PruneBlendShapeTargetsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI explicit PruneBlendShapeTargetsCommand(float threshold, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~PruneBlendShapeTargetsCommand();
|
||||||
|
|
||||||
|
PruneBlendShapeTargetsCommand(const PruneBlendShapeTargetsCommand&) = delete;
|
||||||
|
PruneBlendShapeTargetsCommand& operator=(const PruneBlendShapeTargetsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI PruneBlendShapeTargetsCommand(PruneBlendShapeTargetsCommand&&);
|
||||||
|
DNACAPI PruneBlendShapeTargetsCommand& operator=(PruneBlendShapeTargetsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the threshold for pruning blend shape target deltas.
|
||||||
|
@param threshold
|
||||||
|
The threshold to use.
|
||||||
|
*/
|
||||||
|
DNACAPI void setThreshold(float threshold);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveAnimatedMapCommand is used to remove animated maps.
|
||||||
|
*/
|
||||||
|
class RemoveAnimatedMapCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RemoveAnimatedMapCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveAnimatedMapCommand(std::uint16_t animatedMapIndex, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveAnimatedMapCommand(ConstArrayView<std::uint16_t> animatedMapIndices, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RemoveAnimatedMapCommand();
|
||||||
|
|
||||||
|
RemoveAnimatedMapCommand(const RemoveAnimatedMapCommand&) = delete;
|
||||||
|
RemoveAnimatedMapCommand& operator=(const RemoveAnimatedMapCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RemoveAnimatedMapCommand(RemoveAnimatedMapCommand&&);
|
||||||
|
DNACAPI RemoveAnimatedMapCommand& operator=(RemoveAnimatedMapCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the animated map to remove.
|
||||||
|
@param animatedMapIndex
|
||||||
|
The index of the animated map.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set animated map(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setAnimatedMapIndex(std::uint16_t animatedMapIndex);
|
||||||
|
/**
|
||||||
|
@brief Method for setting the indices of animated maps to remove.
|
||||||
|
@param animatedMapIndices
|
||||||
|
The animated map indices.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set animated map(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setAnimatedMapIndices(ConstArrayView<std::uint16_t> animatedMapIndices);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveBlendShapeCommand is used to remove blend shapes.
|
||||||
|
*/
|
||||||
|
class RemoveBlendShapeCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RemoveBlendShapeCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveBlendShapeCommand(std::uint16_t blendShapeIndex, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveBlendShapeCommand(ConstArrayView<std::uint16_t> blendShapeIndices, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RemoveBlendShapeCommand();
|
||||||
|
|
||||||
|
RemoveBlendShapeCommand(const RemoveBlendShapeCommand&) = delete;
|
||||||
|
RemoveBlendShapeCommand& operator=(const RemoveBlendShapeCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RemoveBlendShapeCommand(RemoveBlendShapeCommand&&);
|
||||||
|
DNACAPI RemoveBlendShapeCommand& operator=(RemoveBlendShapeCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the blend shape to remove.
|
||||||
|
@param blendShapeIndex
|
||||||
|
The index of the blend shape.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set blend shape(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setBlendShapeIndex(std::uint16_t blendShapeIndex);
|
||||||
|
/**
|
||||||
|
@brief Method for setting the indices of blend shapes to remove.
|
||||||
|
@param blendShapeIndices
|
||||||
|
The blend shape indices.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set blend shape(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setBlendShapeIndices(ConstArrayView<std::uint16_t> blendShapeIndices);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveJointAnimationCommand is used to remove joint animation data.
|
||||||
|
*/
|
||||||
|
class RemoveJointAnimationCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RemoveJointAnimationCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveJointAnimationCommand(std::uint16_t jointIndex, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveJointAnimationCommand(ConstArrayView<std::uint16_t> jointIndices, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RemoveJointAnimationCommand();
|
||||||
|
|
||||||
|
RemoveJointAnimationCommand(const RemoveJointAnimationCommand&) = delete;
|
||||||
|
RemoveJointAnimationCommand& operator=(const RemoveJointAnimationCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RemoveJointAnimationCommand(RemoveJointAnimationCommand&&);
|
||||||
|
DNACAPI RemoveJointAnimationCommand& operator=(RemoveJointAnimationCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of a joint whose animation data to remove.
|
||||||
|
@param jointIndex
|
||||||
|
The index of the joint.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set joint animation(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setJointIndex(std::uint16_t jointIndex);
|
||||||
|
/**
|
||||||
|
@brief Method for setting the indices of joints whose animation data to remove.
|
||||||
|
@param jointIndices
|
||||||
|
The joint indices.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set joint animation(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setJointIndices(ConstArrayView<std::uint16_t> jointIndices);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveJointCommand is used to remove joints.
|
||||||
|
*/
|
||||||
|
class RemoveJointCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RemoveJointCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveJointCommand(std::uint16_t jointIndex, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveJointCommand(ConstArrayView<std::uint16_t> jointIndices, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RemoveJointCommand();
|
||||||
|
|
||||||
|
RemoveJointCommand(const RemoveJointCommand&) = delete;
|
||||||
|
RemoveJointCommand& operator=(const RemoveJointCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RemoveJointCommand(RemoveJointCommand&&);
|
||||||
|
DNACAPI RemoveJointCommand& operator=(RemoveJointCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the joint to remove.
|
||||||
|
@param jointIndex
|
||||||
|
The index of the joint.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set joint(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setJointIndex(std::uint16_t jointIndex);
|
||||||
|
/**
|
||||||
|
@brief Method for setting the indices of joints to remove.
|
||||||
|
@param jointIndices
|
||||||
|
The joint indices.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set joint(s) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setJointIndices(ConstArrayView<std::uint16_t> jointIndices);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveMeshCommand is used to remove meshes.
|
||||||
|
*/
|
||||||
|
class RemoveMeshCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RemoveMeshCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveMeshCommand(std::uint16_t meshIndex, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RemoveMeshCommand(ConstArrayView<std::uint16_t> meshIndices, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RemoveMeshCommand();
|
||||||
|
|
||||||
|
RemoveMeshCommand(const RemoveMeshCommand&) = delete;
|
||||||
|
RemoveMeshCommand& operator=(const RemoveMeshCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RemoveMeshCommand(RemoveMeshCommand&&);
|
||||||
|
DNACAPI RemoveMeshCommand& operator=(RemoveMeshCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the mesh to remove.
|
||||||
|
@param meshIndex
|
||||||
|
The index of the mesh.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMeshIndex(std::uint16_t meshIndex);
|
||||||
|
/**
|
||||||
|
@brief Method for setting the indices of meshes to remove.
|
||||||
|
@param meshIndices
|
||||||
|
The mesh indices.
|
||||||
|
@note Call to either setter overwrites previous setter calls. When running the command, the last set mesh(es) will be removed.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMeshIndices(ConstArrayView<std::uint16_t> meshIndices);
|
||||||
|
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RenameAnimatedMapCommand is used to rename an animated map.
|
||||||
|
*/
|
||||||
|
class RenameAnimatedMapCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RenameAnimatedMapCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameAnimatedMapCommand(std::uint16_t animatedMapIndex, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameAnimatedMapCommand(const char* oldName, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RenameAnimatedMapCommand();
|
||||||
|
|
||||||
|
RenameAnimatedMapCommand(const RenameAnimatedMapCommand&) = delete;
|
||||||
|
RenameAnimatedMapCommand& operator=(const RenameAnimatedMapCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RenameAnimatedMapCommand(RenameAnimatedMapCommand&&);
|
||||||
|
DNACAPI RenameAnimatedMapCommand& operator=(RenameAnimatedMapCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for animated map with given index.
|
||||||
|
@param animatedMapIndex
|
||||||
|
The index of the animated map whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the animated map.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(std::uint16_t animatedMapIndex, const char* newName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for animated map with given name.
|
||||||
|
@note
|
||||||
|
The renaming will not happen if there is no animated map with given current name.
|
||||||
|
@param oldName
|
||||||
|
The current name of the animated map whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the animated map.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(const char* oldName, const char* newName);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RenameBlendShapeCommand is used to rename a blend shape channel.
|
||||||
|
*/
|
||||||
|
class RenameBlendShapeCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RenameBlendShapeCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameBlendShapeCommand(std::uint16_t blendShapeIndex, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameBlendShapeCommand(const char* oldName, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RenameBlendShapeCommand();
|
||||||
|
|
||||||
|
RenameBlendShapeCommand(const RenameBlendShapeCommand&) = delete;
|
||||||
|
RenameBlendShapeCommand& operator=(const RenameBlendShapeCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RenameBlendShapeCommand(RenameBlendShapeCommand&&);
|
||||||
|
DNACAPI RenameBlendShapeCommand& operator=(RenameBlendShapeCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for blend shape channel with given index.
|
||||||
|
@param blendShapeIndex
|
||||||
|
The index of the blend shape channel whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the blend shape channel.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(std::uint16_t blendShapeIndex, const char* newName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for blend shape channel with given name.
|
||||||
|
@note
|
||||||
|
The renaming will not happen if there is no blend shape channel with given current name.
|
||||||
|
@param oldName
|
||||||
|
The current name of the blend shape channel whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the blend shape channel.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(const char* oldName, const char* newName);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RenameJointCommand is used to rename a joint.
|
||||||
|
*/
|
||||||
|
class RenameJointCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RenameJointCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameJointCommand(std::uint16_t jointIndex, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameJointCommand(const char* oldName, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RenameJointCommand();
|
||||||
|
|
||||||
|
RenameJointCommand(const RenameJointCommand&) = delete;
|
||||||
|
RenameJointCommand& operator=(const RenameJointCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RenameJointCommand(RenameJointCommand&&);
|
||||||
|
DNACAPI RenameJointCommand& operator=(RenameJointCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for joint with given index.
|
||||||
|
@param jointIndex
|
||||||
|
The index of the joint whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the joint.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(std::uint16_t jointIndex, const char* newName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for joint with given name.
|
||||||
|
@note
|
||||||
|
The renaming will not happen if there is no joint with given current name.
|
||||||
|
@param oldName
|
||||||
|
The current name of the joint whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the joint.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(const char* oldName, const char* newName);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RenameMeshCommand is used to rename a mesh.
|
||||||
|
*/
|
||||||
|
class RenameMeshCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RenameMeshCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameMeshCommand(std::uint16_t meshIndex, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RenameMeshCommand(const char* oldName, const char* newName, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RenameMeshCommand();
|
||||||
|
|
||||||
|
RenameMeshCommand(const RenameMeshCommand&) = delete;
|
||||||
|
RenameMeshCommand& operator=(const RenameMeshCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RenameMeshCommand(RenameMeshCommand&&);
|
||||||
|
DNACAPI RenameMeshCommand& operator=(RenameMeshCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for mesh with given index.
|
||||||
|
@param meshIndex
|
||||||
|
The index of the mesh whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the mesh.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(std::uint16_t meshIndex, const char* newName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting a new name for mesh with given name.
|
||||||
|
@note
|
||||||
|
The renaming will not happen if there is no mesh with given current name.
|
||||||
|
@param oldName
|
||||||
|
The current name of the mesh whose name to change.
|
||||||
|
@param newName
|
||||||
|
The new name for the mesh.
|
||||||
|
*/
|
||||||
|
DNACAPI void setName(const char* oldName, const char* newName);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
54
dnacalib/DNACalib/include/dnacalib/commands/RotateCommand.h
Normal file
54
dnacalib/DNACalib/include/dnacalib/commands/RotateCommand.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RotateCommand is used to rotate neutral joints and vertex positions around given origin.
|
||||||
|
@note
|
||||||
|
Joint rotations are represented in parent space, so it is enough to rotate only root joints, as that rotation will be propagated to the rest of the joints.
|
||||||
|
@note
|
||||||
|
If the origin is not set, the assumed origin is (0, 0, 0).
|
||||||
|
*/
|
||||||
|
class RotateCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit RotateCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI RotateCommand(Vector3 degrees, Vector3 origin, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~RotateCommand();
|
||||||
|
|
||||||
|
RotateCommand(const RotateCommand&) = delete;
|
||||||
|
RotateCommand& operator=(const RotateCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI RotateCommand(RotateCommand&&);
|
||||||
|
DNACAPI RotateCommand& operator=(RotateCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the rotation angles.
|
||||||
|
@param degrees
|
||||||
|
Rotation angles in degrees.
|
||||||
|
*/
|
||||||
|
DNACAPI void setRotation(Vector3 degrees);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the rotation origin.
|
||||||
|
@param origin
|
||||||
|
Origin coordinates.
|
||||||
|
*/
|
||||||
|
DNACAPI void setOrigin(Vector3 origin);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
53
dnacalib/DNACalib/include/dnacalib/commands/ScaleCommand.h
Normal file
53
dnacalib/DNACalib/include/dnacalib/commands/ScaleCommand.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ScaleCommand is used to scale neutral joints, vertex positions and joint and blendshape deltas by a factor.
|
||||||
|
@note
|
||||||
|
Only translation attributes of neutral joints and joint deltas are scaled.
|
||||||
|
*/
|
||||||
|
class ScaleCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit ScaleCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI ScaleCommand(float scale, Vector3 origin, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~ScaleCommand();
|
||||||
|
|
||||||
|
ScaleCommand(const ScaleCommand&) = delete;
|
||||||
|
ScaleCommand& operator=(const ScaleCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI ScaleCommand(ScaleCommand&&);
|
||||||
|
DNACAPI ScaleCommand& operator=(ScaleCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the scale factor to multiply with.
|
||||||
|
@param scale
|
||||||
|
Scale factor.
|
||||||
|
*/
|
||||||
|
DNACAPI void setScale(float scale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the origin.
|
||||||
|
@note The origin is used to properly scale position values (vertex positions and neutral joint translations).
|
||||||
|
@param origin
|
||||||
|
Origin coordinates.
|
||||||
|
*/
|
||||||
|
DNACAPI void setOrigin(Vector3 origin);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,137 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/commands/VectorOperations.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief SetBlendShapeTargetDeltasCommand is used to change blend shape target deltas.
|
||||||
|
*/
|
||||||
|
class SetBlendShapeTargetDeltasCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI static const sc::StatusCode VertexIndicesOutOfBoundsError;
|
||||||
|
DNACAPI static const sc::StatusCode NoVertexIndicesSetError;
|
||||||
|
DNACAPI static const sc::StatusCode DeltasVertexIndicesCountMismatch;
|
||||||
|
DNACAPI static const sc::StatusCode DeltasMasksCountMismatch;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DNACAPI explicit SetBlendShapeTargetDeltasCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetBlendShapeTargetDeltasCommand(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
ConstArrayView<Vector3> deltas,
|
||||||
|
ConstArrayView<std::uint32_t> vertexIndices,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetBlendShapeTargetDeltasCommand(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
ConstArrayView<float> xs,
|
||||||
|
ConstArrayView<float> ys,
|
||||||
|
ConstArrayView<float> zs,
|
||||||
|
ConstArrayView<std::uint32_t> vertexIndices,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetBlendShapeTargetDeltasCommand(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
ConstArrayView<Vector3> deltas,
|
||||||
|
ConstArrayView<std::uint32_t> vertexIndices,
|
||||||
|
ConstArrayView<float> masks,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetBlendShapeTargetDeltasCommand(std::uint16_t meshIndex,
|
||||||
|
std::uint16_t blendShapeTargetIndex,
|
||||||
|
ConstArrayView<float> xs,
|
||||||
|
ConstArrayView<float> ys,
|
||||||
|
ConstArrayView<float> zs,
|
||||||
|
ConstArrayView<std::uint32_t> vertexIndices,
|
||||||
|
ConstArrayView<float> masks,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~SetBlendShapeTargetDeltasCommand();
|
||||||
|
|
||||||
|
SetBlendShapeTargetDeltasCommand(const SetBlendShapeTargetDeltasCommand&) = delete;
|
||||||
|
SetBlendShapeTargetDeltasCommand& operator=(const SetBlendShapeTargetDeltasCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI SetBlendShapeTargetDeltasCommand(SetBlendShapeTargetDeltasCommand&&);
|
||||||
|
DNACAPI SetBlendShapeTargetDeltasCommand& operator=(SetBlendShapeTargetDeltasCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the mesh whose blend shape target to change.
|
||||||
|
@param meshIndex
|
||||||
|
The mesh index.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMeshIndex(std::uint16_t meshIndex);
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the blend shape target to change.
|
||||||
|
@param blendShapeTargetIndex
|
||||||
|
The blend shape target index.
|
||||||
|
*/
|
||||||
|
DNACAPI void setBlendShapeTargetIndex(std::uint16_t blendShapeTargetIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the values used to calculate new deltas for blend shape target.
|
||||||
|
@param deltas
|
||||||
|
The values used in calculation.
|
||||||
|
*/
|
||||||
|
DNACAPI void setDeltas(ConstArrayView<Vector3> deltas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the values used to calculate new deltas for blend shape target.
|
||||||
|
@param xs
|
||||||
|
The X values for each delta.
|
||||||
|
@param ys
|
||||||
|
The Y values for each delta.
|
||||||
|
@param zs
|
||||||
|
The Z values for each delta.
|
||||||
|
*/
|
||||||
|
DNACAPI void setDeltas(ConstArrayView<float> xs, ConstArrayView<float> ys, ConstArrayView<float> zs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the vertex indices that correspond to new deltas.
|
||||||
|
@param vertexIndices
|
||||||
|
The vertexIndices.
|
||||||
|
*/
|
||||||
|
DNACAPI void setVertexIndices(ConstArrayView<std::uint32_t> vertexIndices);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting masks used to calculate new deltas for blend shape target.
|
||||||
|
@note
|
||||||
|
If no masks are set, default weight value of 1 is used for each delta.
|
||||||
|
@param masks
|
||||||
|
The weights for each delta.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMasks(ConstArrayView<float> masks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the type of operation used to calculate new deltas for blend shape target.
|
||||||
|
@note
|
||||||
|
Available operations are: Interpolate, Add, Subtract and Multiply. Each delta is calculated based on the provided operation type in the following way:
|
||||||
|
|
||||||
|
Interpolate: \f$newValue = previousValue * (1 - weight) + setValue * weight\f$\n
|
||||||
|
Add: \f$newValue = previousValue + (setValue * weight)\f$\n
|
||||||
|
Subtract: \f$newValue = previousValue - (setValue * weight)\f$\n
|
||||||
|
Multiply: \f$newValue = previousValue * (setValue * weight)\f$\n
|
||||||
|
|
||||||
|
setValue is the value from new deltas that were set, and weight is the value from masks array.
|
||||||
|
@param operation
|
||||||
|
The operation to use.
|
||||||
|
*/
|
||||||
|
DNACAPI void setOperation(VectorOperation operation);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
45
dnacalib/DNACalib/include/dnacalib/commands/SetLODsCommand.h
Normal file
45
dnacalib/DNACalib/include/dnacalib/commands/SetLODsCommand.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief SetLODsCommand is used to specify LODs to use. Joints, blend shapes, animated maps and meshes that are not in specified LODs are removed from the DNA.
|
||||||
|
*/
|
||||||
|
class SetLODsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit SetLODsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetLODsCommand(ConstArrayView<std::uint16_t> lods, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~SetLODsCommand();
|
||||||
|
|
||||||
|
SetLODsCommand(const SetLODsCommand&) = delete;
|
||||||
|
SetLODsCommand& operator=(const SetLODsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI SetLODsCommand(SetLODsCommand&&);
|
||||||
|
DNACAPI SetLODsCommand& operator=(SetLODsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the LODs to keep.
|
||||||
|
@param lods
|
||||||
|
New LODs to be used.
|
||||||
|
*/
|
||||||
|
DNACAPI void setLODs(ConstArrayView<std::uint16_t> lods);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief SetNeutralJointRotationsCommand is used to set new rotation values to neutral joints.
|
||||||
|
*/
|
||||||
|
class SetNeutralJointRotationsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit SetNeutralJointRotationsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetNeutralJointRotationsCommand(ConstArrayView<Vector3> rotations, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetNeutralJointRotationsCommand(ConstArrayView<float> xs,
|
||||||
|
ConstArrayView<float> ys,
|
||||||
|
ConstArrayView<float> zs,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~SetNeutralJointRotationsCommand();
|
||||||
|
|
||||||
|
SetNeutralJointRotationsCommand(const SetNeutralJointRotationsCommand&) = delete;
|
||||||
|
SetNeutralJointRotationsCommand& operator=(const SetNeutralJointRotationsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI SetNeutralJointRotationsCommand(SetNeutralJointRotationsCommand&&);
|
||||||
|
DNACAPI SetNeutralJointRotationsCommand& operator=(SetNeutralJointRotationsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the neutral joint rotations.
|
||||||
|
@param rotations
|
||||||
|
Rotation values for each joint.
|
||||||
|
*/
|
||||||
|
DNACAPI void setRotations(ConstArrayView<Vector3> rotations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the neutral joint rotations.
|
||||||
|
@param xs
|
||||||
|
The X rotation value for each joint.
|
||||||
|
@param ys
|
||||||
|
The Y rotation value for each joint.
|
||||||
|
@param zs
|
||||||
|
The Z rotation value for each joint.
|
||||||
|
*/
|
||||||
|
DNACAPI void setRotations(ConstArrayView<float> xs, ConstArrayView<float> ys, ConstArrayView<float> zs);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief SetNeutralJointTranslationsCommand is used to set new translation values to neutral joints.
|
||||||
|
*/
|
||||||
|
class SetNeutralJointTranslationsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit SetNeutralJointTranslationsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetNeutralJointTranslationsCommand(ConstArrayView<Vector3> translations, MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetNeutralJointTranslationsCommand(ConstArrayView<float> xs,
|
||||||
|
ConstArrayView<float> ys,
|
||||||
|
ConstArrayView<float> zs,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~SetNeutralJointTranslationsCommand();
|
||||||
|
|
||||||
|
SetNeutralJointTranslationsCommand(const SetNeutralJointTranslationsCommand&) = delete;
|
||||||
|
SetNeutralJointTranslationsCommand& operator=(const SetNeutralJointTranslationsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI SetNeutralJointTranslationsCommand(SetNeutralJointTranslationsCommand&&);
|
||||||
|
DNACAPI SetNeutralJointTranslationsCommand& operator=(SetNeutralJointTranslationsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the neutral joint translations.
|
||||||
|
@param translations
|
||||||
|
Translation values for each joint.
|
||||||
|
*/
|
||||||
|
DNACAPI void setTranslations(ConstArrayView<Vector3> translations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the neutral joint translations.
|
||||||
|
@param xs
|
||||||
|
The X translation value for each joint.
|
||||||
|
@param ys
|
||||||
|
The Y translation value for each joint.
|
||||||
|
@param zs
|
||||||
|
The Z translation value for each joint.
|
||||||
|
*/
|
||||||
|
DNACAPI void setTranslations(ConstArrayView<float> xs, ConstArrayView<float> ys, ConstArrayView<float> zs);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,70 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief SetSkinWeightsCommand is used to set new skin weights for a vertex in a mesh.
|
||||||
|
*/
|
||||||
|
class SetSkinWeightsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit SetSkinWeightsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetSkinWeightsCommand(std::uint16_t meshIndex,
|
||||||
|
std::uint32_t vertexIndex,
|
||||||
|
ConstArrayView<float> weights,
|
||||||
|
ConstArrayView<std::uint16_t> jointIndices,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~SetSkinWeightsCommand();
|
||||||
|
|
||||||
|
SetSkinWeightsCommand(const SetSkinWeightsCommand&) = delete;
|
||||||
|
SetSkinWeightsCommand& operator=(const SetSkinWeightsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI SetSkinWeightsCommand(SetSkinWeightsCommand&&);
|
||||||
|
DNACAPI SetSkinWeightsCommand& operator=(SetSkinWeightsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the targeted mesh.
|
||||||
|
@param meshIndex
|
||||||
|
The mesh index.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMeshIndex(std::uint16_t meshIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the vertex to change.
|
||||||
|
@param vertexIndex
|
||||||
|
The vertex index.
|
||||||
|
*/
|
||||||
|
DNACAPI void setVertexIndex(std::uint32_t vertexIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the weights with which joints influence the vertex in question.
|
||||||
|
@param weights
|
||||||
|
Weights for each joint that has an influence on the vertex.
|
||||||
|
*/
|
||||||
|
DNACAPI void setWeights(ConstArrayView<float> weights);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the joint indices of joints that influence the vertex in question.
|
||||||
|
@param jointIndices
|
||||||
|
Joint indices of joints that have an influence on the vertex.
|
||||||
|
*/
|
||||||
|
DNACAPI void setJointIndices(ConstArrayView<std::uint16_t> jointIndices);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,114 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/commands/VectorOperations.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief SetVertexPositionsCommand is used to change vertex positions values.
|
||||||
|
*/
|
||||||
|
class SetVertexPositionsCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI static const sc::StatusCode PositionsMasksCountMismatch;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DNACAPI explicit SetVertexPositionsCommand(MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI SetVertexPositionsCommand(std::uint16_t meshIndex,
|
||||||
|
ConstArrayView<Vector3> positions,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetVertexPositionsCommand(std::uint16_t meshIndex,
|
||||||
|
ConstArrayView<float> xs,
|
||||||
|
ConstArrayView<float> ys,
|
||||||
|
ConstArrayView<float> zs,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetVertexPositionsCommand(std::uint16_t meshIndex,
|
||||||
|
ConstArrayView<Vector3> positions,
|
||||||
|
ConstArrayView<float> masks,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI SetVertexPositionsCommand(std::uint16_t meshIndex,
|
||||||
|
ConstArrayView<float> xs,
|
||||||
|
ConstArrayView<float> ys,
|
||||||
|
ConstArrayView<float> zs,
|
||||||
|
ConstArrayView<float> masks,
|
||||||
|
VectorOperation operation,
|
||||||
|
MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~SetVertexPositionsCommand();
|
||||||
|
|
||||||
|
SetVertexPositionsCommand(const SetVertexPositionsCommand&) = delete;
|
||||||
|
SetVertexPositionsCommand& operator=(const SetVertexPositionsCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI SetVertexPositionsCommand(SetVertexPositionsCommand&&);
|
||||||
|
DNACAPI SetVertexPositionsCommand& operator=(SetVertexPositionsCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the index of the mesh to change.
|
||||||
|
@param meshIndex
|
||||||
|
The mesh index.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMeshIndex(std::uint16_t meshIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the vertex positions used to calculate new values.
|
||||||
|
@param positions
|
||||||
|
The vertex positions.
|
||||||
|
*/
|
||||||
|
DNACAPI void setPositions(ConstArrayView<Vector3> positions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the vertex positions used to calculate new values.
|
||||||
|
@param xs
|
||||||
|
The X coordinates for each vertex.
|
||||||
|
@param ys
|
||||||
|
The Y coordinates for each vertex.
|
||||||
|
@param zs
|
||||||
|
The Z coordinates for each vertex.
|
||||||
|
*/
|
||||||
|
DNACAPI void setPositions(ConstArrayView<float> xs, ConstArrayView<float> ys, ConstArrayView<float> zs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting vertex masks used to calculate new vertex position values.
|
||||||
|
@note
|
||||||
|
If no masks are set, default weight value of 1 is used for each vertex.
|
||||||
|
@param masks
|
||||||
|
The weights for each vertex.
|
||||||
|
*/
|
||||||
|
DNACAPI void setMasks(ConstArrayView<float> masks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the type of operation used to calculate new vertex position values.
|
||||||
|
@note
|
||||||
|
Available operations are: Interpolate, Add, Subtract and Multiply. Each position is calculated based on the provided operation type in the following way:
|
||||||
|
|
||||||
|
Interpolate: \f$newValue = previousValue * (1 - weight) + setValue * weight\f$\n
|
||||||
|
Add: \f$newValue = previousValue + (setValue * weight)\f$\n
|
||||||
|
Subtract: \f$newValue = previousValue - (setValue * weight)\f$\n
|
||||||
|
Multiply: \f$newValue = previousValue * (setValue * weight)\f$\n
|
||||||
|
|
||||||
|
setValue is the value from new positions that were set, and weight is the value from masks array.
|
||||||
|
@param operation
|
||||||
|
The operation to use.
|
||||||
|
*/
|
||||||
|
DNACAPI void setOperation(VectorOperation operation);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Command.h"
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACalibDNAReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief TranslateCommand is used to translate neutral joints and vertex positions.
|
||||||
|
@note
|
||||||
|
Joint translations are represented in parent space, so it is enough to translate only root joints, as that translation will be propagated to the rest of the joints.
|
||||||
|
*/
|
||||||
|
class TranslateCommand : public Command {
|
||||||
|
public:
|
||||||
|
DNACAPI explicit TranslateCommand(MemoryResource* memRes = nullptr);
|
||||||
|
DNACAPI TranslateCommand(Vector3 translation, MemoryResource* memRes = nullptr);
|
||||||
|
|
||||||
|
DNACAPI ~TranslateCommand();
|
||||||
|
|
||||||
|
TranslateCommand(const TranslateCommand&) = delete;
|
||||||
|
TranslateCommand& operator=(const TranslateCommand&) = delete;
|
||||||
|
|
||||||
|
DNACAPI TranslateCommand(TranslateCommand&&);
|
||||||
|
DNACAPI TranslateCommand& operator=(TranslateCommand&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Method for setting the translation vector.
|
||||||
|
@param translation
|
||||||
|
The translation vector.
|
||||||
|
*/
|
||||||
|
DNACAPI void setTranslation(Vector3 translation);
|
||||||
|
DNACAPI void run(DNACalibDNAReader* output) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl> pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
enum class VectorOperation {
|
||||||
|
Interpolate,
|
||||||
|
Add,
|
||||||
|
Subtract,
|
||||||
|
Multiply
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
36
dnacalib/DNACalib/include/dnacalib/dna/DNACalibDNAReader.h
Normal file
36
dnacalib/DNACalib/include/dnacalib/dna/DNACalibDNAReader.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
#include <dna/Reader.h>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
class DNACAPI DNACalibDNAReader : public dna::Reader {
|
||||||
|
public:
|
||||||
|
static DNACalibDNAReader* create(MemoryResource* memRes = nullptr);
|
||||||
|
static DNACalibDNAReader* create(const dna::Reader* reader, MemoryResource* memRes = nullptr);
|
||||||
|
static void destroy(DNACalibDNAReader* instance);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~DNACalibDNAReader();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<dnac::DNACalibDNAReader> {
|
||||||
|
using type = FactoryCreate<dnac::DNACalibDNAReader>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<dnac::DNACalibDNAReader> {
|
||||||
|
using type = FactoryDestroy<dnac::DNACalibDNAReader>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
51
dnacalib/DNACalib/include/dnacalib/types/Aliases.h
Normal file
51
dnacalib/DNACalib/include/dnacalib/types/Aliases.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <dna/DataLayer.h>
|
||||||
|
#include <dna/BinaryStreamReader.h>
|
||||||
|
#include <dna/BinaryStreamWriter.h>
|
||||||
|
#include <dna/JSONStreamReader.h>
|
||||||
|
#include <dna/JSONStreamWriter.h>
|
||||||
|
#include <dna/StreamReader.h>
|
||||||
|
#include <dna/StreamWriter.h>
|
||||||
|
#include <dna/types/Aliases.h>
|
||||||
|
#include <dna/types/Vector3.h>
|
||||||
|
#include <pma/MemoryResource.h>
|
||||||
|
#include <pma/ScopedPtr.h>
|
||||||
|
#include <pma/resources/AlignedMemoryResource.h>
|
||||||
|
#include <pma/resources/ArenaMemoryResource.h>
|
||||||
|
#include <pma/resources/DefaultMemoryResource.h>
|
||||||
|
#include <status/Status.h>
|
||||||
|
#include <status/StatusCode.h>
|
||||||
|
#include <trio/Stream.h>
|
||||||
|
#include <trio/streams/FileStream.h>
|
||||||
|
#include <trio/streams/MemoryMappedFileStream.h>
|
||||||
|
#include <trio/streams/MemoryStream.h>
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
using sc::Status;
|
||||||
|
using trio::BoundedIOStream;
|
||||||
|
using trio::FileStream;
|
||||||
|
using trio::MemoryMappedFileStream;
|
||||||
|
using trio::MemoryStream;
|
||||||
|
using dna::DataLayer;
|
||||||
|
using dna::BinaryStreamReader;
|
||||||
|
using dna::BinaryStreamWriter;
|
||||||
|
using dna::JSONStreamReader;
|
||||||
|
using dna::JSONStreamWriter;
|
||||||
|
using dna::StreamReader;
|
||||||
|
using dna::StreamWriter;
|
||||||
|
using dna::StringView;
|
||||||
|
using dna::Vector3;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using ArrayView = dna::ArrayView<T>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using ConstArrayView = dna::ConstArrayView<T>;
|
||||||
|
|
||||||
|
using namespace pma;
|
||||||
|
|
||||||
|
} // namespace dnac
|
8
dnacalib/DNACalib/include/dnacalib/version/Version.h
Normal file
8
dnacalib/DNACalib/include/dnacalib/version/Version.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define DNAC_MAJOR_VERSION 6
|
||||||
|
#define DNAC_MINOR_VERSION 8
|
||||||
|
#define DNAC_PATCH_VERSION 0
|
||||||
|
#define DNAC_VERSION_STRING "6.8.0"
|
17
dnacalib/DNACalib/include/dnacalib/version/VersionInfo.h
Normal file
17
dnacalib/DNACalib/include/dnacalib/version/VersionInfo.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dnacalib/Defs.h"
|
||||||
|
#include "dnacalib/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dnac {
|
||||||
|
|
||||||
|
struct DNACAPI VersionInfo {
|
||||||
|
static int getMajorVersion();
|
||||||
|
static int getMinorVersion();
|
||||||
|
static int getPatchVersion();
|
||||||
|
static StringView getVersionString();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dnac
|
27
dnacalib/DNACalib/include/pma/Defs.h
Normal file
27
dnacalib/DNACalib/include/pma/Defs.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((dllexport))
|
||||||
|
#define DLL_IMPORT __attribute__((dllimport))
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define DLL_IMPORT DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DNAC_BUILD_SHARED)
|
||||||
|
// Build shared library
|
||||||
|
#define PMAAPI DLL_EXPORT
|
||||||
|
#elif defined(DNAC_SHARED)
|
||||||
|
// Use shared library
|
||||||
|
#define PMAAPI DLL_IMPORT
|
||||||
|
#else
|
||||||
|
// Build or use static library
|
||||||
|
#define PMAAPI
|
||||||
|
#endif
|
24
dnacalib/DNACalib/include/pma/MemoryResource.h
Normal file
24
dnacalib/DNACalib/include/pma/MemoryResource.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/Defs.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief MemoryResource is an abstract class that allows the implementation of polymorphic allocators.
|
||||||
|
@note
|
||||||
|
It's purpose is to allow passing arbitrary allocators through API boundaries, without requiring changes in the
|
||||||
|
signatures and types involved.
|
||||||
|
*/
|
||||||
|
class PMAAPI MemoryResource {
|
||||||
|
public:
|
||||||
|
virtual ~MemoryResource();
|
||||||
|
virtual void* allocate(std::size_t size, std::size_t alignment) = 0;
|
||||||
|
virtual void deallocate(void* ptr, std::size_t size, std::size_t alignment) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
171
dnacalib/DNACalib/include/pma/PolyAllocator.h
Normal file
171
dnacalib/DNACalib/include/pma/PolyAllocator.h
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/MemoryResource.h"
|
||||||
|
#include "pma/resources/DefaultMemoryResource.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4365 4987)
|
||||||
|
#endif
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
|
#include <scoped_allocator>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#pragma warning(disable : 4068)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
namespace impl {
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
struct max_align_of {
|
||||||
|
using type = typename std::conditional<(alignof(T) > alignof(U)), T, U>::type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, std::size_t Alignment, class TDefaultMemoryResource>
|
||||||
|
class PolyAllocator {
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
using traits_type = std::allocator_traits<PolyAllocator>;
|
||||||
|
|
||||||
|
template<typename U, std::size_t UAlignment, class UDefaultMemoryResource>
|
||||||
|
friend class PolyAllocator;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PolyAllocator() {
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||||
|
#endif
|
||||||
|
static TDefaultMemoryResource dmr;
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
pMemRes = &dmr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PolyAllocator(MemoryResource* memRes) : PolyAllocator{} {
|
||||||
|
if (memRes != nullptr) {
|
||||||
|
pMemRes = memRes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PolyAllocator(std::nullptr_t /*unused*/) : PolyAllocator{} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class U, std::size_t UAlignment, class UDefaultMemoryResource>
|
||||||
|
PolyAllocator(const PolyAllocator<U, UAlignment, UDefaultMemoryResource>& rhs) : pMemRes{rhs.pMemRes} {
|
||||||
|
}
|
||||||
|
|
||||||
|
void* allocateBytes(std::size_t size, std::size_t alignment = Alignment) {
|
||||||
|
return pMemRes->allocate(size, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocateBytes(void* ptr, std::size_t size, std::size_t alignment = Alignment) {
|
||||||
|
pMemRes->deallocate(ptr, size, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U = value_type>
|
||||||
|
typename std::enable_if<!std::is_void<U>::value, U*>::type allocateObject(std::size_t count,
|
||||||
|
std::size_t alignment = Alignment) {
|
||||||
|
return static_cast<U*>(allocateBytes(count * sizeof(U), alignment));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U = value_type>
|
||||||
|
typename std::enable_if<!std::is_void<U>::value>::type deallocateObject(U* ptr,
|
||||||
|
std::size_t count,
|
||||||
|
std::size_t alignment = Alignment) {
|
||||||
|
deallocateBytes(static_cast<void*>(ptr), count * sizeof(U), alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U = value_type, typename ... Args>
|
||||||
|
U* newObject(Args&& ... args) {
|
||||||
|
auto ptr = traits_type::allocate(*this, 1ul);
|
||||||
|
assert(ptr != nullptr);
|
||||||
|
traits_type::construct(*this, ptr, std::forward<Args>(args)...);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U = value_type>
|
||||||
|
void deleteObject(U* ptr) {
|
||||||
|
traits_type::destroy(*this, ptr);
|
||||||
|
traits_type::deallocate(*this, ptr, 1ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocation function as requested by standard-library containers
|
||||||
|
value_type* allocate(std::size_t count) {
|
||||||
|
return allocateObject(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deallocation function as requested by standard-library containers
|
||||||
|
void deallocate(value_type* ptr, std::size_t count) {
|
||||||
|
deallocateObject(ptr, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::size_t getAlignment() {
|
||||||
|
return Alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryResource* getMemoryResource() const {
|
||||||
|
return pMemRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryResource* pMemRes;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
template<typename T,
|
||||||
|
std::size_t Alignment = alignof(typename impl::max_align_of<T, std::max_align_t>::type),
|
||||||
|
class TDefaultMemoryResource = DefaultMemoryResource>
|
||||||
|
class PolyAllocator : public std::scoped_allocator_adaptor<impl::PolyAllocator<T, Alignment, TDefaultMemoryResource> > {
|
||||||
|
private:
|
||||||
|
using Impl = impl::PolyAllocator<T, Alignment, TDefaultMemoryResource>;
|
||||||
|
using Base = std::scoped_allocator_adaptor<Impl>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
template<typename U>
|
||||||
|
struct rebind {
|
||||||
|
using other = PolyAllocator<U, Alignment, TDefaultMemoryResource>;
|
||||||
|
};
|
||||||
|
|
||||||
|
PolyAllocator() = default;
|
||||||
|
|
||||||
|
PolyAllocator(MemoryResource* memRes) : Base{Impl{memRes}} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class U, std::size_t UAlignment, class UDefaultMemoryResource>
|
||||||
|
PolyAllocator(const PolyAllocator<U, UAlignment, UDefaultMemoryResource>& rhs) : Base{rhs} {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class U, std::size_t UAlignment, class UDefaultMemoryResource>
|
||||||
|
PolyAllocator(const impl::PolyAllocator<U, UAlignment, UDefaultMemoryResource>& rhs) : Base{rhs} {
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, std::size_t TAlignment, class TDefaultMemoryResource,
|
||||||
|
typename U, std::size_t UAlignment, class UDefaultMemoryResource>
|
||||||
|
bool operator==(const PolyAllocator<T, TAlignment, TDefaultMemoryResource>& lhs, const PolyAllocator<U, UAlignment,
|
||||||
|
UDefaultMemoryResource>& rhs)
|
||||||
|
{
|
||||||
|
return (TAlignment == UAlignment && lhs.getMemoryResource() == rhs.getMemoryResource());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, std::size_t TAlignment, class TDefaultMemoryResource,
|
||||||
|
typename U, std::size_t UAlignment, class UDefaultMemoryResource>
|
||||||
|
bool operator!=(const PolyAllocator<T, TAlignment, TDefaultMemoryResource>& lhs, const PolyAllocator<U, UAlignment,
|
||||||
|
UDefaultMemoryResource>& rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace pma
|
274
dnacalib/DNACalib/include/pma/ScopedPtr.h
Normal file
274
dnacalib/DNACalib/include/pma/ScopedPtr.h
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4365 4987)
|
||||||
|
#endif
|
||||||
|
#include <utility>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<class T, class B = T>
|
||||||
|
struct New {
|
||||||
|
template<typename ... Args>
|
||||||
|
B* operator()(Args&& ... args) {
|
||||||
|
return new T{std::forward<Args>(args)...};
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, class B = T>
|
||||||
|
struct Delete {
|
||||||
|
void operator()(B* ptr) {
|
||||||
|
// Calling delete on an incomplete type is undefined behavior.
|
||||||
|
// This check will result in a compile error for incomplete types, rather than allow UB.
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
|
#endif
|
||||||
|
using complete_type_checker = char[sizeof(T) ? 1 : -1];
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
static_cast<void>(sizeof(complete_type_checker));
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct New<T[]> {
|
||||||
|
T* operator()(std::size_t size) {
|
||||||
|
return new T[size]{};
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct Delete<T[]> {
|
||||||
|
void operator()(T* ptr) {
|
||||||
|
// Calling delete on an incomplete type is undefined behavior.
|
||||||
|
// This check will result in a compile error for incomplete types, rather than allow UB.
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
|
#endif
|
||||||
|
using complete_type_checker = char[sizeof(T) ? 1 : -1];
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
static_cast<void>(sizeof(complete_type_checker));
|
||||||
|
delete[] ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, class B = T>
|
||||||
|
struct FactoryCreate {
|
||||||
|
template<typename ... Args>
|
||||||
|
B* operator()(Args&& ... args) {
|
||||||
|
return T::create(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, class B = T>
|
||||||
|
struct FactoryDestroy {
|
||||||
|
void operator()(B* ptr) {
|
||||||
|
T::destroy(static_cast<T*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct DefaultInstanceCreator {
|
||||||
|
using type = New<T>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct DefaultInstanceDestroyer {
|
||||||
|
using type = Delete<T>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Takes ownership over the given pointer and handles it's lifetime.
|
||||||
|
@note
|
||||||
|
As ScopedPtr inherits the specified destroyer type, stateless lifetime
|
||||||
|
managers are zero-cost, but it's also possible to use stateful lifetime
|
||||||
|
managers (such as lambdas with captures and what-not).
|
||||||
|
For stateful lifetime managers, a dedicated constructor exists that
|
||||||
|
receives the destroyer instance and initializes the inherited destroyer
|
||||||
|
type with it.
|
||||||
|
@see makeScoped
|
||||||
|
@see New
|
||||||
|
@see Delete
|
||||||
|
@see FactoryCreate
|
||||||
|
@see FactoryDestroy
|
||||||
|
@see DefaultInstanceCreator
|
||||||
|
@see DefaultInstanceDestroyer
|
||||||
|
*/
|
||||||
|
template<class T, class TDestroyer = typename DefaultInstanceDestroyer<T>::type>
|
||||||
|
class ScopedPtr : private TDestroyer {
|
||||||
|
private:
|
||||||
|
template<typename U>
|
||||||
|
struct inspect {
|
||||||
|
using element_type = U;
|
||||||
|
using pointer_type = element_type*;
|
||||||
|
using is_array = std::false_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename U>
|
||||||
|
struct inspect<U[]> {
|
||||||
|
using element_type = U;
|
||||||
|
using pointer_type = element_type*;
|
||||||
|
using is_array = std::true_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
using pointer = typename inspect<T>::pointer_type;
|
||||||
|
using element_type = typename inspect<T>::element_type;
|
||||||
|
using destroyer_type = TDestroyer;
|
||||||
|
|
||||||
|
template<typename U, class UDestroyer>
|
||||||
|
friend class ScopedPtr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ScopedPtr() : ptr{nullptr} {
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit ScopedPtr(pointer ptr_) : ptr{ptr_} {
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedPtr(pointer ptr_, destroyer_type&& destroyer) : destroyer_type{std::move(destroyer)}, ptr{ptr_} {
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedPtr() {
|
||||||
|
if (ptr) {
|
||||||
|
destroyer_type::operator()(ptr);
|
||||||
|
ptr = pointer{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedPtr(std::nullptr_t) : ptr{nullptr} {
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedPtr& operator=(std::nullptr_t) {
|
||||||
|
reset();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedPtr(const ScopedPtr&) = delete;
|
||||||
|
ScopedPtr& operator=(const ScopedPtr&) = delete;
|
||||||
|
|
||||||
|
ScopedPtr(ScopedPtr&& rhs) noexcept : ptr{nullptr} {
|
||||||
|
rhs.swap(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedPtr& operator=(ScopedPtr&& rhs) noexcept {
|
||||||
|
rhs.swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, class UDestroyer>
|
||||||
|
ScopedPtr(ScopedPtr<U, UDestroyer>&& rhs) noexcept : ptr{nullptr} {
|
||||||
|
ScopedPtr<T, destroyer_type> tmp{rhs.release(), static_cast<UDestroyer &&>(rhs)};
|
||||||
|
tmp.swap(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, class UDestroyer>
|
||||||
|
ScopedPtr& operator=(ScopedPtr<U, UDestroyer>&& rhs) noexcept {
|
||||||
|
ScopedPtr<T, destroyer_type> tmp{rhs.release(), static_cast<UDestroyer &&>(rhs)};
|
||||||
|
tmp.swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U = T, typename IA = typename inspect<U>::is_array>
|
||||||
|
typename std::enable_if<IA::value, element_type&>::type operator[](std::size_t index) const noexcept {
|
||||||
|
return ptr[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U = T, typename IA = typename inspect<U>::is_array>
|
||||||
|
typename std::enable_if<!IA::value, element_type&>::type operator*() const noexcept {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer operator->() const noexcept {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator bool() const noexcept {
|
||||||
|
return ptr != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer get() const noexcept {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer release() noexcept {
|
||||||
|
pointer result = nullptr;
|
||||||
|
std::swap(result, ptr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(pointer rhs = pointer()) noexcept {
|
||||||
|
pointer old = release();
|
||||||
|
ptr = rhs;
|
||||||
|
if (old) {
|
||||||
|
destroyer_type::operator()(old);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(ScopedPtr& rhs) noexcept {
|
||||||
|
std::swap(static_cast<destroyer_type&>(*this), static_cast<destroyer_type&>(rhs));
|
||||||
|
std::swap(ptr, rhs.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
pointer ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Syntactic sugar for creating instances wrapped in a ScopedPtr.
|
||||||
|
@note
|
||||||
|
The default behavior is to rely on the New / Delete pair of lifetime
|
||||||
|
managers, because it's sensible to do so.
|
||||||
|
However, because a significant portion of our abstractions follow
|
||||||
|
the convention of exposing a create / destroy pair of factory functions
|
||||||
|
(where create always returns a raw pointer), there also exists a dedicated
|
||||||
|
FactoryCreate / FactoryDestroy pair of lifetime managers.
|
||||||
|
To change the default behavior in order to utilize a specific lifetime
|
||||||
|
manager pair, specialize the DefaultInstanceCreator and DefaultInstanceDestroyer
|
||||||
|
traits for the types that need different handling.
|
||||||
|
Alternately, it's also possible to pass a custom creator / destroyer on each
|
||||||
|
invocation.
|
||||||
|
*/
|
||||||
|
template<class T, class TCreator, class TDestroyer, typename ... Args,
|
||||||
|
typename Base = typename std::remove_pointer < decltype(TCreator{} (std::declval<Args>()...)) > ::type>
|
||||||
|
ScopedPtr<Base, TDestroyer> makeScoped(Args&& ... args) {
|
||||||
|
static_assert(std::is_same<Base, T>::value ||
|
||||||
|
std::is_base_of<Base, T>::value ||
|
||||||
|
std::is_convertible<T, typename std::add_pointer<Base>::type>::value,
|
||||||
|
"Incompatible types.");
|
||||||
|
return ScopedPtr<Base, TDestroyer>{TCreator{} (std::forward<Args>(args)...)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, template<class ...> class TCreatorTemplate, template<class ...> class TDestroyerTemplate, typename ... Args>
|
||||||
|
ScopedPtr<T, TDestroyerTemplate<T> > makeScoped(Args&& ... args) {
|
||||||
|
using TCreator = TCreatorTemplate<T>;
|
||||||
|
using TDestroyer = TDestroyerTemplate<T>;
|
||||||
|
return makeScoped<T, TCreator, TDestroyer>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, typename ... Args>
|
||||||
|
ScopedPtr<T, typename DefaultInstanceDestroyer<T>::type> makeScoped(Args&& ... args) {
|
||||||
|
using TCreator = typename DefaultInstanceCreator<T>::type;
|
||||||
|
using TDestroyer = typename DefaultInstanceDestroyer<T>::type;
|
||||||
|
return makeScoped<T, TCreator, TDestroyer>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace pma
|
49
dnacalib/DNACalib/include/pma/TypeDefs.h
Normal file
49
dnacalib/DNACalib/include/pma/TypeDefs.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/PolyAllocator.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4365)
|
||||||
|
#endif
|
||||||
|
#include <cstddef>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<typename T, typename Allocator = PolyAllocator<T> >
|
||||||
|
using String = std::basic_string<T, std::char_traits<T>, Allocator>;
|
||||||
|
|
||||||
|
template<typename T, typename Allocator = PolyAllocator<T> >
|
||||||
|
using Vector = std::vector<T, Allocator>;
|
||||||
|
|
||||||
|
template<typename T, typename Allocator = PolyAllocator<Vector<T> > >
|
||||||
|
using Matrix = Vector<Vector<T>, Allocator>;
|
||||||
|
|
||||||
|
template<typename T, typename Allocator = PolyAllocator<T> >
|
||||||
|
using List = std::list<T, Allocator>;
|
||||||
|
|
||||||
|
template<typename T, typename Allocator = PolyAllocator<T> >
|
||||||
|
using Set = std::set<T, std::less<T>, Allocator>;
|
||||||
|
|
||||||
|
template<typename T, typename Allocator = PolyAllocator<T> >
|
||||||
|
using UnorderedSet = std::unordered_set<T, std::hash<T>, std::equal_to<T>, Allocator>;
|
||||||
|
|
||||||
|
template<typename K, typename V, typename Allocator = PolyAllocator<std::pair<const K, V> > >
|
||||||
|
using Map = std::map<K, V, std::less<K>, Allocator>;
|
||||||
|
|
||||||
|
template<typename K, typename V, typename Allocator = PolyAllocator<std::pair<const K, V> > >
|
||||||
|
using UnorderedMap = std::unordered_map<K, V, std::hash<K>, std::equal_to<K>, Allocator>;
|
||||||
|
|
||||||
|
} // namespace pma
|
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/Defs.h"
|
||||||
|
#include "pma/MemoryResource.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief A MemoryResource that honors alignment requirements.
|
||||||
|
@see MemoryResource
|
||||||
|
*/
|
||||||
|
class PMAAPI AlignedMemoryResource : public MemoryResource {
|
||||||
|
public:
|
||||||
|
void* allocate(std::size_t size, std::size_t alignment) override;
|
||||||
|
void deallocate(void* ptr, std::size_t size, std::size_t alignment) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
@ -0,0 +1,93 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/Defs.h"
|
||||||
|
#include "pma/MemoryResource.h"
|
||||||
|
#include "pma/ScopedPtr.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Serves allocations from a preallocated memory region.
|
||||||
|
@see MemoryResource
|
||||||
|
*/
|
||||||
|
class ArenaMemoryResource : public MemoryResource {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Constructor
|
||||||
|
@param initialSize
|
||||||
|
The size of the first allocated region from which allocation requests are served.
|
||||||
|
@param regionSize
|
||||||
|
When a memory region backing allocation requests has not enough free space to serve an
|
||||||
|
allocation, an additional region is allocated for both the current and all subsequent allocations.
|
||||||
|
This parameter denotes the size of these additionally allocated regions.
|
||||||
|
@param growthFactor
|
||||||
|
It describes by which factor should each subsequently allocated region be scaled,
|
||||||
|
relative to the previous region. A list of possible region allocation would look like:
|
||||||
|
|
||||||
|
regions = {initialSize, regionSize, regions[1] * growthFactor, regions[2] * growthFactor, ... , regions[n - 1] * growthFactor}
|
||||||
|
|
||||||
|
@param upstream
|
||||||
|
The backing memory region will be allocated using the given upstream MemoryResource.
|
||||||
|
*/
|
||||||
|
PMAAPI ArenaMemoryResource(std::size_t initialSize, std::size_t regionSize, float growthFactor, MemoryResource* upstream);
|
||||||
|
/**
|
||||||
|
@brief Constructor
|
||||||
|
@param regionSize
|
||||||
|
When a memory region backing allocation requests has not enough free space to serve an
|
||||||
|
allocation, an additional region is allocated for both the current and all subsequent allocations.
|
||||||
|
This parameter denotes the size of the initial and all subsequently allocated regions.
|
||||||
|
@param growthFactor
|
||||||
|
It describes by which factor should each subsequently allocated region be scaled,
|
||||||
|
relative to the previous region. A list of possible region allocation would look like:
|
||||||
|
|
||||||
|
regions = {initialSize, regionSize, regions[1] * growthFactor, regions[2] * growthFactor, ... , regions[n - 1] * growthFactor}
|
||||||
|
|
||||||
|
@param upstream
|
||||||
|
The backing memory region will be allocated using the given upstream MemoryResource.
|
||||||
|
*/
|
||||||
|
PMAAPI ArenaMemoryResource(std::size_t regionSize, float growthFactor, MemoryResource* upstream);
|
||||||
|
/**
|
||||||
|
@brief Constructor
|
||||||
|
@param regionSize
|
||||||
|
When a memory region backing allocation requests has not enough free space to serve an
|
||||||
|
allocation, an additional region is allocated for both the current and all subsequent allocations.
|
||||||
|
This parameter denotes the size of the initial and all subsequently allocated regions.
|
||||||
|
@note
|
||||||
|
The growth factor in this case will be 1.0, i.e. no growth.
|
||||||
|
@param upstream
|
||||||
|
The backing memory region will be allocated using the given upstream MemoryResource.
|
||||||
|
*/
|
||||||
|
PMAAPI ArenaMemoryResource(std::size_t regionSize, MemoryResource* upstream);
|
||||||
|
|
||||||
|
PMAAPI ~ArenaMemoryResource();
|
||||||
|
|
||||||
|
ArenaMemoryResource(const ArenaMemoryResource&) = delete;
|
||||||
|
ArenaMemoryResource& operator=(const ArenaMemoryResource&) = delete;
|
||||||
|
|
||||||
|
PMAAPI ArenaMemoryResource(ArenaMemoryResource&&);
|
||||||
|
PMAAPI ArenaMemoryResource& operator=(ArenaMemoryResource&&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief All allocations will be served from the currently active memory region.
|
||||||
|
*/
|
||||||
|
PMAAPI void* allocate(std::size_t size, std::size_t alignment) override;
|
||||||
|
/**
|
||||||
|
@brief This is a no-op, and the regions are only freed when the arena itself is destroyed.
|
||||||
|
*/
|
||||||
|
PMAAPI void deallocate(void* ptr, std::size_t size, std::size_t alignment) override;
|
||||||
|
/**
|
||||||
|
@brief The upstream memory resource was passed through the constructor and is backing all arena allocations.
|
||||||
|
*/
|
||||||
|
PMAAPI MemoryResource* getUpstreamMemoryResource() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Impl;
|
||||||
|
ScopedPtr<Impl, FactoryDestroy<Impl> > pImpl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/Defs.h"
|
||||||
|
#include "pma/MemoryResource.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief A MemoryResource that delegates to malloc / free.
|
||||||
|
@see MemoryResource
|
||||||
|
*/
|
||||||
|
class PMAAPI DefaultMemoryResource : public MemoryResource {
|
||||||
|
public:
|
||||||
|
void* allocate(std::size_t size, std::size_t alignment) override;
|
||||||
|
void deallocate(void* ptr, std::size_t size, std::size_t alignment) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
60
dnacalib/DNACalib/include/pma/utils/ManagedInstance.h
Normal file
60
dnacalib/DNACalib/include/pma/utils/ManagedInstance.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pma/PolyAllocator.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4365 4987)
|
||||||
|
#endif
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
class MemoryResource;
|
||||||
|
|
||||||
|
namespace impl {
|
||||||
|
|
||||||
|
template<class TPointer, class TTarget, class TBase = TTarget>
|
||||||
|
class ManagedInstance {
|
||||||
|
public:
|
||||||
|
using PointerType = TPointer;
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit ManagedInstance(MemoryResource* memRes) : pMemRes{memRes} {
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ManagedInstance with(MemoryResource* memRes) {
|
||||||
|
return ManagedInstance{memRes};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ... Args>
|
||||||
|
PointerType create(Args&& ... args) {
|
||||||
|
pma::PolyAllocator<TTarget> alloc{pMemRes};
|
||||||
|
auto deleter = [alloc](TBase* ptr) mutable {
|
||||||
|
alloc.deleteObject(static_cast<TTarget*>(ptr));
|
||||||
|
};
|
||||||
|
return {alloc.newObject(std::forward<Args>(args)...), deleter};
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryResource* pMemRes;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
template<class TTarget, class TBase = TTarget>
|
||||||
|
using UniqueInstance = impl::ManagedInstance<std::unique_ptr<TBase, std::function<void (TBase*)> >, TTarget, TBase>;
|
||||||
|
|
||||||
|
template<class TTarget, class TBase = TTarget>
|
||||||
|
using SharedInstance = impl::ManagedInstance<std::shared_ptr<TBase>, TTarget, TBase>;
|
||||||
|
|
||||||
|
} // namespace pma
|
8
dnacalib/DNACalib/include/pma/version/Version.h
Normal file
8
dnacalib/DNACalib/include/pma/version/Version.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define PMA_MAJOR_VERSION 1
|
||||||
|
#define PMA_MINOR_VERSION 3
|
||||||
|
#define PMA_PATCH_VERSION 3
|
||||||
|
#define PMA_VERSION_STRING "1.3.3"
|
27
dnacalib/DNACalib/include/status/Defs.h
Normal file
27
dnacalib/DNACalib/include/status/Defs.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((dllexport))
|
||||||
|
#define DLL_IMPORT __attribute__((dllimport))
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define DLL_IMPORT DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DNAC_BUILD_SHARED)
|
||||||
|
// Build shared library
|
||||||
|
#define SCAPI DLL_EXPORT
|
||||||
|
#elif defined(DNAC_SHARED)
|
||||||
|
// Use shared library
|
||||||
|
#define SCAPI DLL_IMPORT
|
||||||
|
#else
|
||||||
|
// Build or use static library
|
||||||
|
#define SCAPI
|
||||||
|
#endif
|
51
dnacalib/DNACalib/include/status/Provider.h
Normal file
51
dnacalib/DNACalib/include/status/Provider.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "status/Defs.h"
|
||||||
|
#include "status/StatusCode.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4365 4987)
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace sc {
|
||||||
|
|
||||||
|
class SCAPI StatusProvider {
|
||||||
|
public:
|
||||||
|
explicit StatusProvider(std::initializer_list<StatusCode> statuses);
|
||||||
|
|
||||||
|
static void reset();
|
||||||
|
static StatusCode get();
|
||||||
|
static bool isOk();
|
||||||
|
static void set(StatusCode status);
|
||||||
|
|
||||||
|
template<typename ... Args>
|
||||||
|
static void set(StatusCode status, Args&& ... args) {
|
||||||
|
std::array<char, 512> buffer{};
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat-security"
|
||||||
|
#endif
|
||||||
|
// The returned number of bytes to be written does not include the null terminator
|
||||||
|
const auto neededSize = snprintf(nullptr, 0ul, status.message, args ...) + 1;
|
||||||
|
const auto size = std::min(buffer.size(), static_cast<std::size_t>(neededSize));
|
||||||
|
snprintf(buffer.data(), size, status.message, args ...);
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
status.message = buffer.data();
|
||||||
|
set(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sc
|
16
dnacalib/DNACalib/include/status/Status.h
Normal file
16
dnacalib/DNACalib/include/status/Status.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "status/Defs.h"
|
||||||
|
#include "status/StatusCode.h"
|
||||||
|
|
||||||
|
namespace sc {
|
||||||
|
|
||||||
|
class SCAPI Status {
|
||||||
|
public:
|
||||||
|
static bool isOk();
|
||||||
|
static StatusCode get();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sc
|
24
dnacalib/DNACalib/include/status/StatusCode.h
Normal file
24
dnacalib/DNACalib/include/status/StatusCode.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "status/Defs.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace sc {
|
||||||
|
|
||||||
|
struct SCAPI StatusCode {
|
||||||
|
int code;
|
||||||
|
const char* message;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const StatusCode& lhs, const StatusCode& rhs) {
|
||||||
|
return (lhs.code == rhs.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const StatusCode& lhs, const StatusCode& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sc
|
8
dnacalib/DNACalib/include/status/version/Version.h
Normal file
8
dnacalib/DNACalib/include/status/version/Version.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define SC_MAJOR_VERSION 1
|
||||||
|
#define SC_MINOR_VERSION 1
|
||||||
|
#define SC_PATCH_VERSION 4
|
||||||
|
#define SC_VERSION_STRING "1.1.4"
|
158
dnacalib/DNACalib/include/trio/Concepts.h
Normal file
158
dnacalib/DNACalib/include/trio/Concepts.h
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "trio/Defs.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
class Writable;
|
||||||
|
|
||||||
|
class TRIOAPI Readable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Read bytes from stream into the given buffer.
|
||||||
|
@param destination
|
||||||
|
Destination buffer into which the data is going to be read from the stream.
|
||||||
|
@param size
|
||||||
|
Number of bytes to read from stream.
|
||||||
|
@return
|
||||||
|
Number of bytes read.
|
||||||
|
*/
|
||||||
|
virtual std::size_t read(char* destination, std::size_t size) = 0;
|
||||||
|
/**
|
||||||
|
@brief Read bytes from this stream into the given stream.
|
||||||
|
@param destination
|
||||||
|
Destination stream into which the data is going to be read from this stream.
|
||||||
|
@param size
|
||||||
|
Number of bytes to read from stream.
|
||||||
|
@return
|
||||||
|
Number of bytes read.
|
||||||
|
*/
|
||||||
|
virtual std::size_t read(Writable* destination, std::size_t size) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Readable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Writable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Writes bytes from the given buffer to the stream.
|
||||||
|
@param source
|
||||||
|
Source buffer from which the data is going to be written to the stream.
|
||||||
|
@param size
|
||||||
|
Number of bytes to write to the stream.
|
||||||
|
@return
|
||||||
|
Number of bytes written.
|
||||||
|
*/
|
||||||
|
virtual std::size_t write(const char* source, std::size_t size) = 0;
|
||||||
|
/**
|
||||||
|
@brief Writes bytes from the given stream to this stream.
|
||||||
|
@param source
|
||||||
|
Source stream from which the data is going to be written into this stream.
|
||||||
|
@param size
|
||||||
|
Number of bytes to write to the stream.
|
||||||
|
@return
|
||||||
|
Number of bytes written.
|
||||||
|
*/
|
||||||
|
virtual std::size_t write(Readable* source, std::size_t size) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Writable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Seekable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Get the current position in the stream.
|
||||||
|
@return
|
||||||
|
Position in the stream relative to it's start, with 0 denoting the start position.
|
||||||
|
*/
|
||||||
|
virtual std::uint64_t tell() = 0;
|
||||||
|
/**
|
||||||
|
@brief Set the current position in the stream.
|
||||||
|
@param position
|
||||||
|
Position in the stream relative to it's start, with 0 denoting the start position.
|
||||||
|
*/
|
||||||
|
virtual void seek(std::uint64_t position) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Seekable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Openable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Open access to the stream.
|
||||||
|
*/
|
||||||
|
virtual void open() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Openable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Closeable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Close access to the stream.
|
||||||
|
*/
|
||||||
|
virtual void close() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Closeable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Controllable : public Openable, public Closeable {
|
||||||
|
protected:
|
||||||
|
virtual ~Controllable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Bounded {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Obtain size of stream in bytes.
|
||||||
|
@return
|
||||||
|
Size in bytes.
|
||||||
|
*/
|
||||||
|
virtual std::uint64_t size() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Bounded();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Buffered {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Flush the changes to filesystem.
|
||||||
|
*/
|
||||||
|
virtual void flush() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Buffered();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TRIOAPI Resizable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Resize file to the requested size.
|
||||||
|
*/
|
||||||
|
virtual void resize(std::uint64_t size) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Resizable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
27
dnacalib/DNACalib/include/trio/Defs.h
Normal file
27
dnacalib/DNACalib/include/trio/Defs.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((dllexport))
|
||||||
|
#define DLL_IMPORT __attribute__((dllimport))
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define DLL_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define DLL_IMPORT DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DNAC_BUILD_SHARED)
|
||||||
|
// Build shared library
|
||||||
|
#define TRIOAPI DLL_EXPORT
|
||||||
|
#elif defined(DNAC_SHARED)
|
||||||
|
// Use shared library
|
||||||
|
#define TRIOAPI DLL_IMPORT
|
||||||
|
#else
|
||||||
|
// Build or use static library
|
||||||
|
#define TRIOAPI
|
||||||
|
#endif
|
29
dnacalib/DNACalib/include/trio/Stream.h
Normal file
29
dnacalib/DNACalib/include/trio/Stream.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "trio/Concepts.h"
|
||||||
|
#include "trio/Defs.h"
|
||||||
|
#include "trio/types/Aliases.h"
|
||||||
|
#include "trio/types/Parameters.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
class TRIOAPI BoundedIOStream : public Controllable, public Readable, public Writable, public Seekable, public Bounded {
|
||||||
|
public:
|
||||||
|
using AccessMode = trio::AccessMode;
|
||||||
|
using OpenMode = trio::OpenMode;
|
||||||
|
|
||||||
|
static const sc::StatusCode OpenError;
|
||||||
|
static const sc::StatusCode ReadError;
|
||||||
|
static const sc::StatusCode WriteError;
|
||||||
|
static const sc::StatusCode AlreadyOpenError;
|
||||||
|
static const sc::StatusCode SeekError;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~BoundedIOStream();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
65
dnacalib/DNACalib/include/trio/streams/FileStream.h
Normal file
65
dnacalib/DNACalib/include/trio/streams/FileStream.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "trio/Defs.h"
|
||||||
|
#include "trio/Stream.h"
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Standard file stream.
|
||||||
|
*/
|
||||||
|
class TRIOAPI FileStream : public BoundedIOStream {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of a FileStream instance.
|
||||||
|
@param path
|
||||||
|
UTF-8 encoded path to file to be opened.
|
||||||
|
@param accessMode
|
||||||
|
Control whether the file is opened for reading or writing.
|
||||||
|
@param openMode
|
||||||
|
Control whether the file is opened in binary or textual mode.
|
||||||
|
@param memRes
|
||||||
|
The memory resource to be used for the allocation of the FileStream instance.
|
||||||
|
@note
|
||||||
|
If a custom memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static FileStream* create(const char* path, AccessMode accessMode, OpenMode openMode, MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a FileStream instance.
|
||||||
|
@param instance
|
||||||
|
Instance of FileStream to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(FileStream* instance);
|
||||||
|
|
||||||
|
FileStream() = default;
|
||||||
|
~FileStream() override;
|
||||||
|
|
||||||
|
FileStream(const FileStream&) = delete;
|
||||||
|
FileStream& operator=(const FileStream&) = delete;
|
||||||
|
|
||||||
|
FileStream(FileStream&&) = default;
|
||||||
|
FileStream& operator=(FileStream&&) = default;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<trio::FileStream> {
|
||||||
|
using type = FactoryCreate<trio::FileStream>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<trio::FileStream> {
|
||||||
|
using type = FactoryDestroy<trio::FileStream>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "trio/Defs.h"
|
||||||
|
#include "trio/Stream.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Memory mapped file stream.
|
||||||
|
*/
|
||||||
|
class TRIOAPI MemoryMappedFileStream : public BoundedIOStream, public Buffered, public Resizable {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of a MemoryMappedFileStream instance.
|
||||||
|
@param path
|
||||||
|
UTF-8 encoded path to file to be opened.
|
||||||
|
@param accessMode
|
||||||
|
Control whether the file is opened for reading or writing.
|
||||||
|
@param memRes
|
||||||
|
The memory resource to be used for the allocation of the MemoryMappedFileStream instance.
|
||||||
|
@note
|
||||||
|
If a custom memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static MemoryMappedFileStream* create(const char* path, AccessMode accessMode, MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a MemoryMappedFileStream instance.
|
||||||
|
@param instance
|
||||||
|
Instance of MemoryMappedFileStream to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(MemoryMappedFileStream* instance);
|
||||||
|
|
||||||
|
MemoryMappedFileStream() = default;
|
||||||
|
~MemoryMappedFileStream() override;
|
||||||
|
|
||||||
|
MemoryMappedFileStream(const MemoryMappedFileStream&) = delete;
|
||||||
|
MemoryMappedFileStream& operator=(const MemoryMappedFileStream&) = delete;
|
||||||
|
|
||||||
|
MemoryMappedFileStream(MemoryMappedFileStream&&) = default;
|
||||||
|
MemoryMappedFileStream& operator=(MemoryMappedFileStream&&) = default;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<trio::MemoryMappedFileStream> {
|
||||||
|
using type = FactoryCreate<trio::MemoryMappedFileStream>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<trio::MemoryMappedFileStream> {
|
||||||
|
using type = FactoryDestroy<trio::MemoryMappedFileStream>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
73
dnacalib/DNACalib/include/trio/streams/MemoryStream.h
Normal file
73
dnacalib/DNACalib/include/trio/streams/MemoryStream.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "trio/Defs.h"
|
||||||
|
#include "trio/Stream.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief In-memory stream.
|
||||||
|
*/
|
||||||
|
class TRIOAPI MemoryStream : public BoundedIOStream {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of a MemoryStream instance.
|
||||||
|
@param memRes
|
||||||
|
The memory resource to be used for the allocation of the MemoryStream instance.
|
||||||
|
@note
|
||||||
|
If a custom memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static MemoryStream* create(MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Factory method for creation of a MemoryStream instance.
|
||||||
|
@param initialSize
|
||||||
|
Initial size of the memory stream.
|
||||||
|
@param memRes
|
||||||
|
The memory resource to be used for the allocation of the MemoryStream instance.
|
||||||
|
@note
|
||||||
|
If a custom memory resource is not given, a default allocation mechanism will be used.
|
||||||
|
@warning
|
||||||
|
User is responsible for releasing the returned pointer by calling destroy.
|
||||||
|
@see destroy
|
||||||
|
*/
|
||||||
|
static MemoryStream* create(std::size_t initialSize, MemoryResource* memRes = nullptr);
|
||||||
|
/**
|
||||||
|
@brief Method for freeing a MemoryStream instance.
|
||||||
|
@param instance
|
||||||
|
Instance of MemoryStream to be freed.
|
||||||
|
@see create
|
||||||
|
*/
|
||||||
|
static void destroy(MemoryStream* instance);
|
||||||
|
|
||||||
|
MemoryStream() = default;
|
||||||
|
~MemoryStream() override;
|
||||||
|
|
||||||
|
MemoryStream(const MemoryStream&) = delete;
|
||||||
|
MemoryStream& operator=(const MemoryStream&) = delete;
|
||||||
|
|
||||||
|
MemoryStream(MemoryStream&&) = default;
|
||||||
|
MemoryStream& operator=(MemoryStream&&) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
||||||
|
|
||||||
|
namespace pma {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceCreator<trio::MemoryStream> {
|
||||||
|
using type = FactoryCreate<trio::MemoryStream>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct DefaultInstanceDestroyer<trio::MemoryStream> {
|
||||||
|
using type = FactoryDestroy<trio::MemoryStream>;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pma
|
16
dnacalib/DNACalib/include/trio/types/Aliases.h
Normal file
16
dnacalib/DNACalib/include/trio/types/Aliases.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pma/MemoryResource.h>
|
||||||
|
#include <pma/ScopedPtr.h>
|
||||||
|
#include <status/Status.h>
|
||||||
|
#include <status/StatusCode.h>
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
using sc::Status;
|
||||||
|
|
||||||
|
using namespace pma;
|
||||||
|
|
||||||
|
} // namespace trio
|
18
dnacalib/DNACalib/include/trio/types/Parameters.h
Normal file
18
dnacalib/DNACalib/include/trio/types/Parameters.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
enum class AccessMode {
|
||||||
|
Read = 1,
|
||||||
|
Write = 2,
|
||||||
|
ReadWrite = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class OpenMode {
|
||||||
|
Binary = 4,
|
||||||
|
Text = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
39
dnacalib/DNACalib/include/trio/utils/StreamScope.h
Normal file
39
dnacalib/DNACalib/include/trio/utils/StreamScope.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "trio/Stream.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace trio {
|
||||||
|
|
||||||
|
class StreamScope {
|
||||||
|
public:
|
||||||
|
explicit StreamScope(Controllable* stream_) : stream{stream_} {
|
||||||
|
stream->open();
|
||||||
|
}
|
||||||
|
|
||||||
|
~StreamScope() {
|
||||||
|
if (stream != nullptr) {
|
||||||
|
stream->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamScope(const StreamScope&) = delete;
|
||||||
|
StreamScope& operator=(const StreamScope&) = delete;
|
||||||
|
|
||||||
|
StreamScope(StreamScope&& rhs) noexcept : stream{nullptr} {
|
||||||
|
std::swap(stream, rhs.stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamScope& operator=(StreamScope&& rhs) noexcept {
|
||||||
|
std::swap(stream, rhs.stream);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Controllable* stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace trio
|
8
dnacalib/DNACalib/include/trio/version/Version.h
Normal file
8
dnacalib/DNACalib/include/trio/version/Version.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define TRIO_MAJOR_VERSION 4
|
||||||
|
#define TRIO_MINOR_VERSION 0
|
||||||
|
#define TRIO_PATCH_VERSION 4
|
||||||
|
#define TRIO_VERSION_STRING "4.0.4"
|
36
dnacalib/DNACalib/src/dna/BaseImpl.h
Normal file
36
dnacalib/DNACalib/src/dna/BaseImpl.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dna/DNA.h"
|
||||||
|
#include "dna/types/Aliases.h"
|
||||||
|
|
||||||
|
namespace dna {
|
||||||
|
|
||||||
|
class BaseImpl {
|
||||||
|
protected:
|
||||||
|
explicit BaseImpl(MemoryResource* memRes_) :
|
||||||
|
memRes{memRes_},
|
||||||
|
dna{memRes} {
|
||||||
|
}
|
||||||
|
|
||||||
|
~BaseImpl() = default;
|
||||||
|
|
||||||
|
BaseImpl(const BaseImpl&) = delete;
|
||||||
|
BaseImpl& operator=(const BaseImpl&) = delete;
|
||||||
|
|
||||||
|
BaseImpl(BaseImpl&& rhs) = delete;
|
||||||
|
BaseImpl& operator=(BaseImpl&&) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MemoryResource* getMemoryResource() {
|
||||||
|
return memRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MemoryResource* memRes;
|
||||||
|
DNA dna;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dna
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user