Updated ozz-animation to version 0.14.3 (commit 92c392b667844)
parent
1ef53d6486
commit
c7d2d195a3
|
@ -1,3 +1,19 @@
|
||||||
|
Release version 0.14.3
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* Build pipeline
|
||||||
|
- Adds vs2022 compiler support for fbxsdk (#170)
|
||||||
|
|
||||||
|
Release version 0.14.2
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* Library
|
||||||
|
- Transitions away from sprintf to the more secure snprintf.
|
||||||
|
- #147 Works around gcc 11 error stringop-overflow which emits false positives for ozz math serialization.
|
||||||
|
|
||||||
|
* Build pipeline
|
||||||
|
- Updates CI compiler versions.
|
||||||
|
|
||||||
Release version 0.14.1
|
Release version 0.14.1
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required (VERSION 3.3)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
# Defines the project's name
|
# Defines the project's name
|
||||||
project(ozz)
|
project(ozz)
|
||||||
|
@ -9,7 +9,7 @@ get_directory_property(is_sub_project PARENT_DIRECTORY)
|
||||||
# Current version
|
# Current version
|
||||||
set(OZZ_VERSION_MAJOR 0)
|
set(OZZ_VERSION_MAJOR 0)
|
||||||
set(OZZ_VERSION_MINOR 14)
|
set(OZZ_VERSION_MINOR 14)
|
||||||
set(OZZ_VERSION_PATCH 1)
|
set(OZZ_VERSION_PATCH 3)
|
||||||
set(OZZ_VERSION ${OZZ_VERSION_MAJOR}.${OZZ_VERSION_MINOR}.${OZZ_VERSION_PATCH})
|
set(OZZ_VERSION ${OZZ_VERSION_MAJOR}.${OZZ_VERSION_MINOR}.${OZZ_VERSION_PATCH})
|
||||||
|
|
||||||
# Add project build options
|
# Add project build options
|
||||||
|
@ -30,6 +30,7 @@ if(WIN32 AND BUILD_SHARED_LIBS AND NOT ozz_build_msvc_rt_dll)
|
||||||
message("Forcing ozz_build_msvc_rt_dll to ON as ozz is being built as dll (BUILD_SHARED_LIBS is ON).")
|
message("Forcing ozz_build_msvc_rt_dll to ON as ozz is being built as dll (BUILD_SHARED_LIBS is ON).")
|
||||||
set(ozz_build_msvc_rt_dll ON)
|
set(ozz_build_msvc_rt_dll ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(is_sub_project)
|
if(is_sub_project)
|
||||||
set(ozz_build_msvc_rt_dll ${ozz_build_msvc_rt_dll} PARENT_SCOPE)
|
set(ozz_build_msvc_rt_dll ${ozz_build_msvc_rt_dll} PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -51,7 +52,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/build-utils/cm
|
||||||
|
|
||||||
# Detects Fbx SDK, required to build Fbx pipeline.
|
# Detects Fbx SDK, required to build Fbx pipeline.
|
||||||
if(ozz_build_tools AND ozz_build_fbx)
|
if(ozz_build_tools AND ozz_build_fbx)
|
||||||
|
|
||||||
# Select a msvc runtime compatible with ozz_build_msvc_rt_dll
|
# Select a msvc runtime compatible with ozz_build_msvc_rt_dll
|
||||||
set(FBX_SHARED ${BUILD_SHARED_LIBS})
|
set(FBX_SHARED ${BUILD_SHARED_LIBS})
|
||||||
set(FBX_MSVC_RT_DLL ${ozz_build_msvc_rt_dll})
|
set(FBX_MSVC_RT_DLL ${ozz_build_msvc_rt_dll})
|
||||||
|
@ -69,6 +69,7 @@ else()
|
||||||
# Disables fbx if tools are disabled
|
# Disables fbx if tools are disabled
|
||||||
set(ozz_build_fbx OFF)
|
set(ozz_build_fbx OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(is_sub_project)
|
if(is_sub_project)
|
||||||
set(ozz_build_fbx ${ozz_build_fbx} PARENT_SCOPE)
|
set(ozz_build_fbx ${ozz_build_fbx} PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -78,6 +79,7 @@ if(ozz_build_tools AND ozz_build_gltf)
|
||||||
else()
|
else()
|
||||||
set(ozz_build_gltf OFF)
|
set(ozz_build_gltf OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(is_sub_project)
|
if(is_sub_project)
|
||||||
set(ozz_build_gltf ${ozz_build_gltf} PARENT_SCOPE)
|
set(ozz_build_gltf ${ozz_build_gltf} PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -131,4 +133,4 @@ install(FILES
|
||||||
${PROJECT_SOURCE_DIR}/CHANGES.md
|
${PROJECT_SOURCE_DIR}/CHANGES.md
|
||||||
${PROJECT_SOURCE_DIR}/LICENSE.md
|
${PROJECT_SOURCE_DIR}/LICENSE.md
|
||||||
${PROJECT_SOURCE_DIR}/README.md
|
${PROJECT_SOURCE_DIR}/README.md
|
||||||
DESTINATION ./)
|
DESTINATION "share/doc/ozz-animation/")
|
||||||
|
|
|
@ -18,7 +18,7 @@ Documentation and samples are available from [ozz-animation website](http://guil
|
||||||
Supported platforms
|
Supported platforms
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Ozz is tested on Linux, Mac OS and Windows, for x86, x86-64 and ARM architectures. The run-time code (ozz_base, ozz_animation, ozz_geometry) depends only on c++11, the standard CRT and has no OS specific code, portability to any other platform shouldn't be an issue.
|
Ozz is tested on Linux, Mac OS and Windows, for x86, x86-64 and ARM architectures. The run-time code (ozz_base, ozz_animation, ozz_geometry) depends only on c++11, on the C and the C++ standard libraries, and has no OS specific code. Portability to any other platform shouldn't be an issue.
|
||||||
|
|
||||||
Samples, tools and tests depend on external libraries (glfw, tinygltf, Fbx SDK, jsoncpp, gtest, ...), which could limit portability.
|
Samples, tools and tests depend on external libraries (glfw, tinygltf, Fbx SDK, jsoncpp, gtest, ...), which could limit portability.
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
# Set compilers settings for all platforms/compilers.
|
# Set compilers settings for all platforms/compilers.
|
||||||
#---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
|
|
||||||
#-----------------
|
# -----------------
|
||||||
# Includes modules
|
# Includes modules
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
|
|
||||||
#------------------------------
|
# ------------------------------
|
||||||
# Enables IDE folders y default
|
# Enables IDE folders y default
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
#------------------------
|
# ------------------------
|
||||||
# Available build options
|
# Available build options
|
||||||
|
|
||||||
#------------------------
|
# ------------------------
|
||||||
# Lists all the cxx flags
|
# Lists all the cxx flags
|
||||||
set(cxx_all_flags
|
set(cxx_all_flags
|
||||||
CMAKE_CXX_FLAGS
|
CMAKE_CXX_FLAGS
|
||||||
|
@ -26,13 +26,14 @@ set(cxx_all_flags
|
||||||
CMAKE_CXX_FLAGS_RELEASE
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
CMAKE_C_FLAGS_RELEASE)
|
CMAKE_C_FLAGS_RELEASE)
|
||||||
|
|
||||||
#--------------------------------------
|
# --------------------------------------
|
||||||
# Cross compiler compilation flags
|
# Cross compiler compilation flags
|
||||||
|
|
||||||
# Requires C++11
|
# Requires C++11
|
||||||
if(NOT CMAKE_CXX_STANDARD)
|
if(NOT CMAKE_CXX_STANDARD)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
@ -41,15 +42,15 @@ if(ozz_build_simd_ref)
|
||||||
add_compile_definitions(OZZ_BUILD_SIMD_REF)
|
add_compile_definitions(OZZ_BUILD_SIMD_REF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Disables crt secure warnings
|
# --------------------------------------
|
||||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
|
||||||
|
|
||||||
#--------------------------------------
|
|
||||||
# Modify default MSVC compilation flags
|
# Modify default MSVC compilation flags
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
#---------------------------
|
# ---------------------------
|
||||||
# For the common build flags
|
# For the common build flags
|
||||||
|
|
||||||
|
# Disables crt secure warnings
|
||||||
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||||
|
|
||||||
# Adds support for multiple processes builds
|
# Adds support for multiple processes builds
|
||||||
add_compile_options(/MP)
|
add_compile_options(/MP)
|
||||||
|
|
||||||
|
@ -60,62 +61,61 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
add_compile_options(/WX)
|
add_compile_options(/WX)
|
||||||
|
|
||||||
# Select whether to use the DLL version or the static library version of the Visual C++ runtime library.
|
# Select whether to use the DLL version or the static library version of the Visual C++ runtime library.
|
||||||
foreach(flag ${cxx_all_flags})
|
if(ozz_build_msvc_rt_dll)
|
||||||
if (ozz_build_msvc_rt_dll)
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||||
string(REGEX REPLACE "/MT" "/MD" ${flag} "${${flag}}")
|
else()
|
||||||
else()
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
endif()
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
#--------------------------------------
|
# --------------------------------------
|
||||||
# else consider the compiler as GCC compatible (inc clang)
|
# else consider the compiler as GCC compatible (inc clang)
|
||||||
else()
|
else()
|
||||||
|
|
||||||
# Set the warning level to Wall
|
# Set the warning level to Wall
|
||||||
add_compile_options(-Wall)
|
add_compile_options(-Wall)
|
||||||
|
|
||||||
# Enable extra level of warning
|
# Enable extra level of warning
|
||||||
#add_compile_options(-Wextra)
|
# add_compile_options(-Wextra)
|
||||||
|
|
||||||
# Set warning as error
|
# Set warning as error
|
||||||
add_compile_options(-Werror)
|
add_compile_options(-Werror)
|
||||||
|
|
||||||
# ignored-attributes reports issue when using _m128 as template argument
|
# ignored-attributes reports issue when using _m128 as template argument
|
||||||
check_cxx_compiler_flag("-Wignored-attributes" W_IGNORED_ATTRIBUTES)
|
check_cxx_compiler_flag("-Wignored-attributes" W_IGNORED_ATTRIBUTES)
|
||||||
|
|
||||||
if(W_IGNORED_ATTRIBUTES)
|
if(W_IGNORED_ATTRIBUTES)
|
||||||
add_compile_options(-Wno-ignored-attributes)
|
add_compile_options(-Wno-ignored-attributes)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Disables c98 retrocompatibility warnings
|
# Disables c98 retrocompatibility warnings
|
||||||
check_cxx_compiler_flag("-Wc++98-compat-pedantic" W_98_COMPAT_PEDANTIC)
|
check_cxx_compiler_flag("-Wc++98-compat-pedantic" W_98_COMPAT_PEDANTIC)
|
||||||
|
|
||||||
if(W_98_COMPAT_PEDANTIC)
|
if(W_98_COMPAT_PEDANTIC)
|
||||||
add_compile_options(-Wno-c++98-compat-pedantic)
|
add_compile_options(-Wno-c++98-compat-pedantic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Check some options availibity for the targetted compiler
|
# Check some options availibity for the targetted compiler
|
||||||
|
check_cxx_compiler_flag("-Wunused-result" W_UNUSED_RESULT)
|
||||||
check_cxx_compiler_flag("-Wnull-dereference" W_NULL_DEREFERENCE)
|
check_cxx_compiler_flag("-Wnull-dereference" W_NULL_DEREFERENCE)
|
||||||
check_cxx_compiler_flag("-Wpragma-pack" W_PRAGMA_PACK)
|
check_cxx_compiler_flag("-Wpragma-pack" W_PRAGMA_PACK)
|
||||||
|
|
||||||
#----------------------
|
# ----------------------
|
||||||
# Sets emscripten output
|
# Sets emscripten output
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
add_link_options(-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0)
|
add_link_options(-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0)
|
||||||
|
|
||||||
#if(NOT ozz_build_simd_ref)
|
# if(NOT ozz_build_simd_ref)
|
||||||
# set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-msse2")
|
# set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-msse2")
|
||||||
#endif()
|
# endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#---------------------
|
# ---------------------
|
||||||
# Prints all the flags
|
# Prints all the flags
|
||||||
message(STATUS "---------------------------------------------------------")
|
message(STATUS "---------------------------------------------------------")
|
||||||
message(STATUS "Default build type is: ${CMAKE_BUILD_TYPE}")
|
message(STATUS "Default build type is: ${CMAKE_BUILD_TYPE}")
|
||||||
message(STATUS "The following compilation flags will be used:")
|
message(STATUS "The following compilation flags will be used:")
|
||||||
|
|
||||||
foreach(flag ${cxx_all_flags})
|
foreach(flag ${cxx_all_flags})
|
||||||
message(${flag} " ${${flag}}")
|
message(${flag} " ${${flag}}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -124,6 +124,7 @@ message(STATUS "---------------------------------------------------------")
|
||||||
|
|
||||||
get_directory_property(DirectoryCompileOptions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_OPTIONS)
|
get_directory_property(DirectoryCompileOptions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_OPTIONS)
|
||||||
message(STATUS "Directory Compile Options:")
|
message(STATUS "Directory Compile Options:")
|
||||||
|
|
||||||
foreach(opt ${DirectoryCompileOptions})
|
foreach(opt ${DirectoryCompileOptions})
|
||||||
message(STATUS ${opt})
|
message(STATUS ${opt})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -132,13 +133,14 @@ message(STATUS "---------------------------------------------------------")
|
||||||
|
|
||||||
get_directory_property(DirectoryCompileDefinitions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
|
get_directory_property(DirectoryCompileDefinitions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
|
||||||
message(STATUS "Directory Compile Definitions:")
|
message(STATUS "Directory Compile Definitions:")
|
||||||
|
|
||||||
foreach(def ${DirectoryCompileDefinitions})
|
foreach(def ${DirectoryCompileDefinitions})
|
||||||
message(STATUS ${def})
|
message(STATUS ${def})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
message(STATUS "---------------------------------------------------------")
|
message(STATUS "---------------------------------------------------------")
|
||||||
|
|
||||||
#----------------------------------------------
|
# ----------------------------------------------
|
||||||
# Modifies output directory for all executables
|
# Modifies output directory for all executables
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ".")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ".")
|
||||||
|
@ -146,7 +148,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ".")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ".")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ".")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ".")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ".")
|
||||||
|
|
||||||
#-------------------------------
|
# -------------------------------
|
||||||
# Set a postfix for output files
|
# Set a postfix for output files
|
||||||
if(ozz_build_postfix)
|
if(ozz_build_postfix)
|
||||||
set(CMAKE_DEBUG_POSTFIX "_d")
|
set(CMAKE_DEBUG_POSTFIX "_d")
|
||||||
|
|
|
@ -67,7 +67,9 @@ function(FindFbxLibrariesGeneric _FBX_ROOT_DIR _OUT_FBX_LIBRARIES _OUT_FBX_LIBRA
|
||||||
# Figures out matching compiler/os directory.
|
# Figures out matching compiler/os directory.
|
||||||
|
|
||||||
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
|
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
|
||||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.20)
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.30)
|
||||||
|
set(FBX_CP_PATH "vs2022")
|
||||||
|
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.20)
|
||||||
set(FBX_CP_PATH "vs2019")
|
set(FBX_CP_PATH "vs2019")
|
||||||
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
|
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
|
||||||
set(FBX_CP_PATH "vs2017")
|
set(FBX_CP_PATH "vs2017")
|
||||||
|
|
|
@ -57,8 +57,6 @@ if(UNIX AND APPLE)
|
||||||
lib/cocoa/cocoa_joystick.m
|
lib/cocoa/cocoa_joystick.m
|
||||||
lib/cocoa/cocoa_time.m
|
lib/cocoa/cocoa_time.m
|
||||||
lib/cocoa/cocoa_window.m)
|
lib/cocoa/cocoa_window.m)
|
||||||
# Treats .m files as C files.
|
|
||||||
set_source_files_properties(${specific_objc_file_list} PROPERTIES LANGUAGE C)
|
|
||||||
|
|
||||||
# Disables warnings in glfw.
|
# Disables warnings in glfw.
|
||||||
set_source_files_properties(${specific_objc_file_list} PROPERTIES COMPILE_FLAGS
|
set_source_files_properties(${specific_objc_file_list} PROPERTIES COMPILE_FLAGS
|
||||||
|
|
|
@ -3887,7 +3887,7 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec
|
||||||
int len = -1;
|
int len = -1;
|
||||||
|
|
||||||
char formatString[6];
|
char formatString[6];
|
||||||
sprintf(formatString, "%%.%dg", precision);
|
snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
|
||||||
|
|
||||||
// Print into the buffer. We need not request the alternative representation
|
// Print into the buffer. We need not request the alternative representation
|
||||||
// that always has a decimal point because JSON doesn't distingish the
|
// that always has a decimal point because JSON doesn't distingish the
|
||||||
|
|
|
@ -66,12 +66,11 @@ template <typename _Ty, size_t _size = sizeof(_Ty)>
|
||||||
struct EndianSwapper;
|
struct EndianSwapper;
|
||||||
|
|
||||||
// Internal macro used to swap two bytes.
|
// Internal macro used to swap two bytes.
|
||||||
#define OZZ_BYTE_SWAP(_a, _b) \
|
OZZ_INLINE void _in_place_byte_swap(byte& _a, byte& _b) {
|
||||||
do { \
|
_a = _a ^ _b;
|
||||||
const ozz::byte temp = (_a); \
|
_b = _a ^ _b;
|
||||||
(_a) = (_b); \
|
_a = _a ^ _b;
|
||||||
(_b) = temp; \
|
}
|
||||||
} while (0)
|
|
||||||
|
|
||||||
// EndianSwapper specialization for 1 byte types.
|
// EndianSwapper specialization for 1 byte types.
|
||||||
template <typename _Ty>
|
template <typename _Ty>
|
||||||
|
@ -86,12 +85,12 @@ struct EndianSwapper<_Ty, 2> {
|
||||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||||
byte* alias = reinterpret_cast<byte*>(_ty);
|
byte* alias = reinterpret_cast<byte*>(_ty);
|
||||||
for (size_t i = 0; i < _count * 2; i += 2) {
|
for (size_t i = 0; i < _count * 2; i += 2) {
|
||||||
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 1]);
|
_in_place_byte_swap(alias[i + 0], alias[i + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
||||||
byte* alias = reinterpret_cast<byte*>(&_ty);
|
byte* alias = reinterpret_cast<byte*>(&_ty);
|
||||||
OZZ_BYTE_SWAP(alias[0], alias[1]);
|
_in_place_byte_swap(alias[0], alias[1]);
|
||||||
return _ty;
|
return _ty;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -102,14 +101,14 @@ struct EndianSwapper<_Ty, 4> {
|
||||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||||
byte* alias = reinterpret_cast<byte*>(_ty);
|
byte* alias = reinterpret_cast<byte*>(_ty);
|
||||||
for (size_t i = 0; i < _count * 4; i += 4) {
|
for (size_t i = 0; i < _count * 4; i += 4) {
|
||||||
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 3]);
|
_in_place_byte_swap(alias[i + 0], alias[i + 3]);
|
||||||
OZZ_BYTE_SWAP(alias[i + 1], alias[i + 2]);
|
_in_place_byte_swap(alias[i + 1], alias[i + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
||||||
byte* alias = reinterpret_cast<byte*>(&_ty);
|
byte* alias = reinterpret_cast<byte*>(&_ty);
|
||||||
OZZ_BYTE_SWAP(alias[0], alias[3]);
|
_in_place_byte_swap(alias[0], alias[3]);
|
||||||
OZZ_BYTE_SWAP(alias[1], alias[2]);
|
_in_place_byte_swap(alias[1], alias[2]);
|
||||||
return _ty;
|
return _ty;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -120,25 +119,22 @@ struct EndianSwapper<_Ty, 8> {
|
||||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||||
byte* alias = reinterpret_cast<byte*>(_ty);
|
byte* alias = reinterpret_cast<byte*>(_ty);
|
||||||
for (size_t i = 0; i < _count * 8; i += 8) {
|
for (size_t i = 0; i < _count * 8; i += 8) {
|
||||||
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 7]);
|
_in_place_byte_swap(alias[i + 0], alias[i + 7]);
|
||||||
OZZ_BYTE_SWAP(alias[i + 1], alias[i + 6]);
|
_in_place_byte_swap(alias[i + 1], alias[i + 6]);
|
||||||
OZZ_BYTE_SWAP(alias[i + 2], alias[i + 5]);
|
_in_place_byte_swap(alias[i + 2], alias[i + 5]);
|
||||||
OZZ_BYTE_SWAP(alias[i + 3], alias[i + 4]);
|
_in_place_byte_swap(alias[i + 3], alias[i + 4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
||||||
byte* alias = reinterpret_cast<byte*>(&_ty);
|
byte* alias = reinterpret_cast<byte*>(&_ty);
|
||||||
OZZ_BYTE_SWAP(alias[0], alias[7]);
|
_in_place_byte_swap(alias[0], alias[7]);
|
||||||
OZZ_BYTE_SWAP(alias[1], alias[6]);
|
_in_place_byte_swap(alias[1], alias[6]);
|
||||||
OZZ_BYTE_SWAP(alias[2], alias[5]);
|
_in_place_byte_swap(alias[2], alias[5]);
|
||||||
OZZ_BYTE_SWAP(alias[3], alias[4]);
|
_in_place_byte_swap(alias[3], alias[4]);
|
||||||
return _ty;
|
return _ty;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// OZZ_BYTE_SWAP is not useful anymore.
|
|
||||||
#undef OZZ_BYTE_SWAP
|
|
||||||
|
|
||||||
// Helper function that swaps _count elements of the array _ty in place.
|
// Helper function that swaps _count elements of the array _ty in place.
|
||||||
template <typename _Ty>
|
template <typename _Ty>
|
||||||
OZZ_INLINE void EndianSwap(_Ty* _ty, size_t _count) {
|
OZZ_INLINE void EndianSwap(_Ty* _ty, size_t _count) {
|
||||||
|
|
|
@ -250,7 +250,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "Blending parameters", &open);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "Blending parameters", &open);
|
||||||
if (open) {
|
if (open) {
|
||||||
_im_gui->DoLabel("Main layer:");
|
_im_gui->DoLabel("Main layer:");
|
||||||
std::sprintf(label, "Layer weight: %.2f", base_weight_);
|
std::snprintf(label, sizeof(label), "Layer weight: %.2f", base_weight_);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f, &base_weight_, 1.f);
|
_im_gui->DoSlider(label, 0.f, 1.f, &base_weight_, 1.f);
|
||||||
|
|
||||||
_im_gui->DoLabel("Additive layer:");
|
_im_gui->DoLabel("Additive layer:");
|
||||||
|
@ -259,8 +259,8 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application {
|
||||||
std::memcpy(weights.data(), additive_weigths_,
|
std::memcpy(weights.data(), additive_weigths_,
|
||||||
sizeof(additive_weigths_));
|
sizeof(additive_weigths_));
|
||||||
|
|
||||||
std::sprintf(label, "Weights\nCurl: %.2f\nSplay: %.2f",
|
std::snprintf(label, sizeof(label), "Weights\nCurl: %.2f\nSplay: %.2f",
|
||||||
additive_weigths_[kCurl], additive_weigths_[kSplay]);
|
additive_weigths_[kCurl], additive_weigths_[kSplay]);
|
||||||
if (_im_gui->DoSlider2D(label, {{0.f, 0.f}}, {{1.f, 1.f}}, &weights)) {
|
if (_im_gui->DoSlider2D(label, {{0.f, 0.f}}, {{1.f, 1.f}}, &weights)) {
|
||||||
auto_animate_weights_ = false; // User interacted.
|
auto_animate_weights_ = false; // User interacted.
|
||||||
std::memcpy(additive_weigths_, weights.data(),
|
std::memcpy(additive_weigths_, weights.data(),
|
||||||
|
|
|
@ -161,16 +161,16 @@ class AttachSampleApplication : public ozz::sample::Application {
|
||||||
if (open && skeleton_.num_joints() != 0) {
|
if (open && skeleton_.num_joints() != 0) {
|
||||||
_im_gui->DoLabel("Select joint:");
|
_im_gui->DoLabel("Select joint:");
|
||||||
char label[64];
|
char label[64];
|
||||||
std::sprintf(label, "%s (%d)", skeleton_.joint_names()[attachment_],
|
std::snprintf(label, sizeof(label), "%s (%d)",
|
||||||
attachment_);
|
skeleton_.joint_names()[attachment_], attachment_);
|
||||||
_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &attachment_);
|
_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &attachment_);
|
||||||
|
|
||||||
_im_gui->DoLabel("Attachment offset:");
|
_im_gui->DoLabel("Attachment offset:");
|
||||||
sprintf(label, "x: %02f", offset_.x);
|
std::snprintf(label, sizeof(label), "x: %02f", offset_.x);
|
||||||
_im_gui->DoSlider(label, -1.f, 1.f, &offset_.x);
|
_im_gui->DoSlider(label, -1.f, 1.f, &offset_.x);
|
||||||
sprintf(label, "y: %02f", offset_.y);
|
std::snprintf(label, sizeof(label), "y: %02f", offset_.y);
|
||||||
_im_gui->DoSlider(label, -1.f, 1.f, &offset_.y);
|
_im_gui->DoSlider(label, -1.f, 1.f, &offset_.y);
|
||||||
sprintf(label, "z: %02f", offset_.z);
|
std::snprintf(label, sizeof(label), "z: %02f", offset_.z);
|
||||||
_im_gui->DoSlider(label, -1.f, 1.f, &offset_.z);
|
_im_gui->DoSlider(label, -1.f, 1.f, &offset_.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ OZZ_OPTIONS_DECLARE_STRING(animation2,
|
||||||
|
|
||||||
// Third animation archive can be specified as an option.
|
// Third animation archive can be specified as an option.
|
||||||
OZZ_OPTIONS_DECLARE_STRING(animation3,
|
OZZ_OPTIONS_DECLARE_STRING(animation3,
|
||||||
"Path to the second animation (ozz archive format).",
|
"Path to the third animation (ozz archive format).",
|
||||||
"media/animation3.ozz", false)
|
"media/animation3.ozz", false)
|
||||||
|
|
||||||
class BlendSampleApplication : public ozz::sample::Application {
|
class BlendSampleApplication : public ozz::sample::Application {
|
||||||
|
@ -242,16 +242,16 @@ class BlendSampleApplication : public ozz::sample::Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
char label[64];
|
char label[64];
|
||||||
std::sprintf(label, "Blend ratio: %.2f", blend_ratio_);
|
std::snprintf(label, sizeof(label), "Blend ratio: %.2f", blend_ratio_);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f, &blend_ratio_, 1.f, !manual_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &blend_ratio_, 1.f, !manual_);
|
||||||
|
|
||||||
for (int i = 0; i < kNumLayers; ++i) {
|
for (int i = 0; i < kNumLayers; ++i) {
|
||||||
Sampler& sampler = samplers_[i];
|
Sampler& sampler = samplers_[i];
|
||||||
std::sprintf(label, "Weight %d: %.2f", i, sampler.weight);
|
std::snprintf(label, sizeof(label), "Weight %d: %.2f", i, sampler.weight);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f, &sampler.weight, 1.f, manual_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &sampler.weight, 1.f, manual_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sprintf(label, "Threshold: %.2f", threshold_);
|
std::snprintf(label, sizeof(label), "Threshold: %.2f", threshold_);
|
||||||
_im_gui->DoSlider(label, .01f, 1.f, &threshold_);
|
_im_gui->DoSlider(label, .01f, 1.f, &threshold_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,7 +608,7 @@ class FootIKSampleApplication : public ozz::sample::Application {
|
||||||
virtual void OnDestroy() {}
|
virtual void OnDestroy() {}
|
||||||
|
|
||||||
virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
|
virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
|
||||||
char txt[32];
|
char label[32];
|
||||||
|
|
||||||
// Main options
|
// Main options
|
||||||
{
|
{
|
||||||
|
@ -636,12 +636,12 @@ class FootIKSampleApplication : public ozz::sample::Application {
|
||||||
static bool opened = true;
|
static bool opened = true;
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "IK settings", &opened);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "IK settings", &opened);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
sprintf(txt, "Foot height %.2g", foot_heigh_);
|
snprintf(label, sizeof(label), "Foot height %.2g", foot_heigh_);
|
||||||
_im_gui->DoSlider(txt, 0.f, .3f, &foot_heigh_);
|
_im_gui->DoSlider(label, 0.f, .3f, &foot_heigh_);
|
||||||
sprintf(txt, "Weight %.2g", weight_);
|
snprintf(label, sizeof(label), "Weight %.2g", weight_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &weight_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &weight_);
|
||||||
sprintf(txt, "Soften %.2g", soften_);
|
snprintf(label, sizeof(label), "Soften %.2g", soften_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &soften_, 1.f, two_bone_ik_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &soften_, 1.f, two_bone_ik_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,19 +652,19 @@ class FootIKSampleApplication : public ozz::sample::Application {
|
||||||
bool moved = false;
|
bool moved = false;
|
||||||
// Translation
|
// Translation
|
||||||
_im_gui->DoLabel("Translation");
|
_im_gui->DoLabel("Translation");
|
||||||
sprintf(txt, "x %.2g", root_translation_.x);
|
snprintf(label, sizeof(label), "x %.2g", root_translation_.x);
|
||||||
moved |= _im_gui->DoSlider(txt, -10.f, 10.f, &root_translation_.x);
|
moved |= _im_gui->DoSlider(label, -10.f, 10.f, &root_translation_.x);
|
||||||
sprintf(txt, "y %.2g", root_translation_.y);
|
snprintf(label, sizeof(label), "y %.2g", root_translation_.y);
|
||||||
moved |= _im_gui->DoSlider(txt, 0.f, 5.f, &root_translation_.y, 1.f,
|
moved |= _im_gui->DoSlider(label, 0.f, 5.f, &root_translation_.y, 1.f,
|
||||||
!auto_character_height_);
|
!auto_character_height_);
|
||||||
sprintf(txt, "z %.2g", root_translation_.z);
|
snprintf(label, sizeof(label), "z %.2g", root_translation_.z);
|
||||||
moved |= _im_gui->DoSlider(txt, -10.f, 10.f, &root_translation_.z);
|
moved |= _im_gui->DoSlider(label, -10.f, 10.f, &root_translation_.z);
|
||||||
|
|
||||||
// Rotation (in euler form)
|
// Rotation (in euler form)
|
||||||
_im_gui->DoLabel("Rotation");
|
_im_gui->DoLabel("Rotation");
|
||||||
sprintf(txt, "yaw %.3g", root_yaw_ * ozz::math::kRadianToDegree);
|
snprintf(label, sizeof(label), "yaw %.3g", root_yaw_ * ozz::math::kRadianToDegree);
|
||||||
moved |=
|
moved |=
|
||||||
_im_gui->DoSlider(txt, -ozz::math::kPi, ozz::math::kPi, &root_yaw_);
|
_im_gui->DoSlider(label, -ozz::math::kPi, ozz::math::kPi, &root_yaw_);
|
||||||
|
|
||||||
// Character position shouldn't be changed after the update. In this
|
// Character position shouldn't be changed after the update. In this
|
||||||
// case, because UI is updated after "game" update, we need to recompute
|
// case, because UI is updated after "game" update, we need to recompute
|
||||||
|
|
|
@ -528,31 +528,32 @@ bool Application::Gui() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::FrameworkGui() {
|
bool Application::FrameworkGui() {
|
||||||
|
char label[64];
|
||||||
// Downcast to public imgui.
|
// Downcast to public imgui.
|
||||||
ImGui* im_gui = im_gui_.get();
|
ImGui* im_gui = im_gui_.get();
|
||||||
{ // Render statistics
|
{ // Render statistics
|
||||||
static bool open = true;
|
static bool open = true;
|
||||||
ImGui::OpenClose stat_oc(im_gui, "Statistics", &open);
|
ImGui::OpenClose stat_oc(im_gui, "Statistics", &open);
|
||||||
if (open) {
|
if (open) {
|
||||||
char szLabel[64];
|
|
||||||
{ // FPS
|
{ // FPS
|
||||||
Record::Statistics statistics = fps_->GetStatistics();
|
Record::Statistics statistics = fps_->GetStatistics();
|
||||||
std::sprintf(szLabel, "FPS: %.0f",
|
std::snprintf(label, sizeof(label), "FPS: %.0f",
|
||||||
statistics.mean == 0.f ? 0.f : 1000.f / statistics.mean);
|
statistics.mean == 0.f ? 0.f : 1000.f / statistics.mean);
|
||||||
static bool fps_open = false;
|
static bool fps_open = false;
|
||||||
ImGui::OpenClose stats(im_gui, szLabel, &fps_open);
|
ImGui::OpenClose stats(im_gui, label, &fps_open);
|
||||||
if (fps_open) {
|
if (fps_open) {
|
||||||
std::sprintf(szLabel, "Frame: %.2f ms", statistics.mean);
|
std::snprintf(label, sizeof(label), "Frame: %.2f ms",
|
||||||
im_gui->DoGraph(szLabel, 0.f, statistics.max, statistics.latest,
|
statistics.mean);
|
||||||
|
im_gui->DoGraph(label, 0.f, statistics.max, statistics.latest,
|
||||||
fps_->cursor(), fps_->record_begin(),
|
fps_->cursor(), fps_->record_begin(),
|
||||||
fps_->record_end());
|
fps_->record_end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // Update time
|
{ // Update time
|
||||||
Record::Statistics statistics = update_time_->GetStatistics();
|
Record::Statistics statistics = update_time_->GetStatistics();
|
||||||
std::sprintf(szLabel, "Update: %.2f ms", statistics.mean);
|
std::snprintf(label, sizeof(label), "Update: %.2f ms", statistics.mean);
|
||||||
static bool update_open = true; // This is the most relevant for ozz.
|
static bool update_open = true; // This is the most relevant for ozz.
|
||||||
ImGui::OpenClose stats(im_gui, szLabel, &update_open);
|
ImGui::OpenClose stats(im_gui, label, &update_open);
|
||||||
if (update_open) {
|
if (update_open) {
|
||||||
im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest,
|
im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest,
|
||||||
update_time_->cursor(), update_time_->record_begin(),
|
update_time_->cursor(), update_time_->record_begin(),
|
||||||
|
@ -561,9 +562,9 @@ bool Application::FrameworkGui() {
|
||||||
}
|
}
|
||||||
{ // Render time
|
{ // Render time
|
||||||
Record::Statistics statistics = render_time_->GetStatistics();
|
Record::Statistics statistics = render_time_->GetStatistics();
|
||||||
std::sprintf(szLabel, "Render: %.2f ms", statistics.mean);
|
std::snprintf(label, sizeof(label), "Render: %.2f ms", statistics.mean);
|
||||||
static bool render_open = false;
|
static bool render_open = false;
|
||||||
ImGui::OpenClose stats(im_gui, szLabel, &render_open);
|
ImGui::OpenClose stats(im_gui, label, &render_open);
|
||||||
if (render_open) {
|
if (render_open) {
|
||||||
im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest,
|
im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest,
|
||||||
render_time_->cursor(), render_time_->record_begin(),
|
render_time_->cursor(), render_time_->record_begin(),
|
||||||
|
@ -580,18 +581,15 @@ bool Application::FrameworkGui() {
|
||||||
im_gui->DoButton("Freeze", true, &freeze_);
|
im_gui->DoButton("Freeze", true, &freeze_);
|
||||||
im_gui->DoCheckBox("Fix update rate", &fix_update_rate, true);
|
im_gui->DoCheckBox("Fix update rate", &fix_update_rate, true);
|
||||||
if (!fix_update_rate) {
|
if (!fix_update_rate) {
|
||||||
char sz_factor[64];
|
std::snprintf(label, sizeof(label), "Time factor: %.2f", time_factor_);
|
||||||
std::sprintf(sz_factor, "Time factor: %.2f", time_factor_);
|
im_gui->DoSlider(label, -5.f, 5.f, &time_factor_);
|
||||||
im_gui->DoSlider(sz_factor, -5.f, 5.f, &time_factor_);
|
|
||||||
if (im_gui->DoButton("Reset time factor", time_factor_ != 1.f)) {
|
if (im_gui->DoButton("Reset time factor", time_factor_ != 1.f)) {
|
||||||
time_factor_ = 1.f;
|
time_factor_ = 1.f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char sz_fixed_update_rate[64];
|
std::snprintf(label, sizeof(label), "Update rate: %.0f fps",
|
||||||
std::sprintf(sz_fixed_update_rate, "Update rate: %.0f fps",
|
fixed_update_rate);
|
||||||
fixed_update_rate);
|
im_gui->DoSlider(label, 1.f, 200.f, &fixed_update_rate, .5f, true);
|
||||||
im_gui->DoSlider(sz_fixed_update_rate, 1.f, 200.f, &fixed_update_rate,
|
|
||||||
.5f, true);
|
|
||||||
if (im_gui->DoButton("Reset update rate", fixed_update_rate != 60.f)) {
|
if (im_gui->DoButton("Reset update rate", fixed_update_rate != 60.f)) {
|
||||||
fixed_update_rate = 60.f;
|
fixed_update_rate = 60.f;
|
||||||
}
|
}
|
||||||
|
@ -615,10 +613,9 @@ bool Application::FrameworkGui() {
|
||||||
}
|
}
|
||||||
// Vertical sync & swap interval
|
// Vertical sync & swap interval
|
||||||
bool changed = im_gui->DoCheckBox("Vertical sync", &vertical_sync_);
|
bool changed = im_gui->DoCheckBox("Vertical sync", &vertical_sync_);
|
||||||
char szLabel[64];
|
std::snprintf(label, sizeof(label), "Swap interval: %d", swap_interval_);
|
||||||
std::sprintf(szLabel, "Swap interval: %d", swap_interval_);
|
|
||||||
changed |=
|
changed |=
|
||||||
im_gui->DoSlider(szLabel, 1, 4, &swap_interval_, 1.f, vertical_sync_);
|
im_gui->DoSlider(label, 1, 4, &swap_interval_, 1.f, vertical_sync_);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
glfwSwapInterval(vertical_sync_ ? swap_interval_ : 0);
|
glfwSwapInterval(vertical_sync_ ? swap_interval_ : 0);
|
||||||
}
|
}
|
||||||
|
@ -640,10 +637,9 @@ bool Application::FrameworkGui() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char szResolution[64];
|
std::snprintf(label, sizeof(label), "Resolution: %dx%d", resolution_.width,
|
||||||
std::sprintf(szResolution, "Resolution: %dx%d", resolution_.width,
|
resolution_.height);
|
||||||
resolution_.height);
|
if (im_gui->DoSlider(label, 0, kNumPresets - 1, &preset_lookup)) {
|
||||||
if (im_gui->DoSlider(szResolution, 0, kNumPresets - 1, &preset_lookup)) {
|
|
||||||
// Resolution changed.
|
// Resolution changed.
|
||||||
resolution_ = resolution_presets[preset_lookup];
|
resolution_ = resolution_presets[preset_lookup];
|
||||||
glfwSetWindowSize(resolution_.width, resolution_.height);
|
glfwSetWindowSize(resolution_.width, resolution_.height);
|
||||||
|
|
|
@ -149,7 +149,7 @@ class Application {
|
||||||
enum LoopStatus {
|
enum LoopStatus {
|
||||||
kContinue, // Can continue with next loop.
|
kContinue, // Can continue with next loop.
|
||||||
kBreak, // Should stop looping (ex: exit).
|
kBreak, // Should stop looping (ex: exit).
|
||||||
kBreakFailure, // // Should stop looping beacause something went wrong.
|
kBreakFailure, // Should stop looping because something went wrong.
|
||||||
};
|
};
|
||||||
LoopStatus OneLoop(int _loops);
|
LoopStatus OneLoop(int _loops);
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ bool FormatFloat(float _value, char* _string, const char* _string_end) {
|
||||||
if (!_string || _string_end - _string < 8 + precision + 1) {
|
if (!_string || _string_end - _string < 8 + precision + 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::sprintf(_string, "%.2g\n", _value);
|
std::snprintf(_string, _string_end - _string, "%.2g\n", _value);
|
||||||
|
|
||||||
// Removes unnecessary '0' digits in the exponent.
|
// Removes unnecessary '0' digits in the exponent.
|
||||||
char* exponent = strchr(_string, 'e');
|
char* exponent = strchr(_string, 'e');
|
||||||
|
|
|
@ -160,12 +160,12 @@ bool Shooter::Process() {
|
||||||
GL(BindBuffer(GL_PIXEL_PACK_BUFFER, shot.pbo));
|
GL(BindBuffer(GL_PIXEL_PACK_BUFFER, shot.pbo));
|
||||||
const void* pixels = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
const void* pixels = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||||
if (pixels) {
|
if (pixels) {
|
||||||
char name[16];
|
char filename[16];
|
||||||
sprintf(name, "%06d.tga", shot_number_++);
|
std::snprintf(filename, sizeof(filename), "%06d.tga", shot_number_++);
|
||||||
|
|
||||||
ozz::sample::image::WriteTGA(name, shot.width, shot.height, image_format_,
|
ozz::sample::image::WriteTGA(
|
||||||
reinterpret_cast<const uint8_t*>(pixels),
|
filename, shot.width, shot.height, image_format_,
|
||||||
false);
|
reinterpret_cast<const uint8_t*>(pixels), false);
|
||||||
GL(UnmapBuffer(GL_PIXEL_PACK_BUFFER));
|
GL(UnmapBuffer(GL_PIXEL_PACK_BUFFER));
|
||||||
}
|
}
|
||||||
GL(BindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
GL(BindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
||||||
|
|
|
@ -110,21 +110,22 @@ bool PlaybackController::OnGui(const animation::Animation& _animation,
|
||||||
|
|
||||||
_im_gui->DoCheckBox("Loop", &loop_, _enabled);
|
_im_gui->DoCheckBox("Loop", &loop_, _enabled);
|
||||||
|
|
||||||
char szLabel[64];
|
char label[64];
|
||||||
|
|
||||||
// Uses a local copy of time_ so that set_time is used to actually apply
|
// Uses a local copy of time_ so that set_time is used to actually apply
|
||||||
// changes. Otherwise previous time would be incorrect.
|
// changes. Otherwise previous time would be incorrect.
|
||||||
float ratio = time_ratio();
|
float ratio = time_ratio();
|
||||||
std::sprintf(szLabel, "Animation time: %.2f", ratio * _animation.duration());
|
std::snprintf(label, sizeof(label), "Animation time: %.2f",
|
||||||
if (_im_gui->DoSlider(szLabel, 0.f, 1.f, &ratio, 1.f,
|
ratio * _animation.duration());
|
||||||
|
if (_im_gui->DoSlider(label, 0.f, 1.f, &ratio, 1.f,
|
||||||
_enabled && _allow_set_time)) {
|
_enabled && _allow_set_time)) {
|
||||||
set_time_ratio(ratio);
|
set_time_ratio(ratio);
|
||||||
// Pause the time if slider as moved.
|
// Pause the time if slider as moved.
|
||||||
play_ = false;
|
play_ = false;
|
||||||
time_changed = true;
|
time_changed = true;
|
||||||
}
|
}
|
||||||
std::sprintf(szLabel, "Playback speed: %.2f", playback_speed_);
|
std::snprintf(label, sizeof(label), "Playback speed: %.2f", playback_speed_);
|
||||||
_im_gui->DoSlider(szLabel, -5.f, 5.f, &playback_speed_, 1.f, _enabled);
|
_im_gui->DoSlider(label, -5.f, 5.f, &playback_speed_, 1.f, _enabled);
|
||||||
|
|
||||||
// Allow to reset speed if it is not the default value.
|
// Allow to reset speed if it is not the default value.
|
||||||
if (_im_gui->DoButton("Reset playback speed",
|
if (_im_gui->DoButton("Reset playback speed",
|
||||||
|
@ -139,7 +140,7 @@ bool OnRawSkeletonJointGui(
|
||||||
ozz::sample::ImGui* _im_gui,
|
ozz::sample::ImGui* _im_gui,
|
||||||
ozz::animation::offline::RawSkeleton::Joint::Children* _children,
|
ozz::animation::offline::RawSkeleton::Joint::Children* _children,
|
||||||
ozz::vector<bool>::iterator* _oc_state) {
|
ozz::vector<bool>::iterator* _oc_state) {
|
||||||
char txt[255];
|
char label[255];
|
||||||
|
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
for (size_t i = 0; i < _children->size(); ++i) {
|
for (size_t i = 0; i < _children->size(); ++i) {
|
||||||
|
@ -152,23 +153,23 @@ bool OnRawSkeletonJointGui(
|
||||||
// Translation
|
// Translation
|
||||||
ozz::math::Float3& translation = joint.transform.translation;
|
ozz::math::Float3& translation = joint.transform.translation;
|
||||||
_im_gui->DoLabel("Translation");
|
_im_gui->DoLabel("Translation");
|
||||||
sprintf(txt, "x %.2g", translation.x);
|
snprintf(label, sizeof(label), "x %.2g", translation.x);
|
||||||
modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.x);
|
modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.x);
|
||||||
sprintf(txt, "y %.2g", translation.y);
|
snprintf(label, sizeof(label), "y %.2g", translation.y);
|
||||||
modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.y);
|
modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.y);
|
||||||
sprintf(txt, "z %.2g", translation.z);
|
snprintf(label, sizeof(label), "z %.2g", translation.z);
|
||||||
modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.z);
|
modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.z);
|
||||||
|
|
||||||
// Rotation (in euler form)
|
// Rotation (in euler form)
|
||||||
ozz::math::Quaternion& rotation = joint.transform.rotation;
|
ozz::math::Quaternion& rotation = joint.transform.rotation;
|
||||||
_im_gui->DoLabel("Rotation");
|
_im_gui->DoLabel("Rotation");
|
||||||
ozz::math::Float3 euler = ToEuler(rotation) * ozz::math::kRadianToDegree;
|
ozz::math::Float3 euler = ToEuler(rotation) * ozz::math::kRadianToDegree;
|
||||||
sprintf(txt, "x %.3g", euler.x);
|
snprintf(label, sizeof(label), "x %.3g", euler.x);
|
||||||
bool euler_modified = _im_gui->DoSlider(txt, -180.f, 180.f, &euler.x);
|
bool euler_modified = _im_gui->DoSlider(label, -180.f, 180.f, &euler.x);
|
||||||
sprintf(txt, "y %.3g", euler.y);
|
snprintf(label, sizeof(label), "y %.3g", euler.y);
|
||||||
euler_modified |= _im_gui->DoSlider(txt, -180.f, 180.f, &euler.y);
|
euler_modified |= _im_gui->DoSlider(label, -180.f, 180.f, &euler.y);
|
||||||
sprintf(txt, "z %.3g", euler.z);
|
snprintf(label, sizeof(label), "z %.3g", euler.z);
|
||||||
euler_modified |= _im_gui->DoSlider(txt, -180.f, 180.f, &euler.z);
|
euler_modified |= _im_gui->DoSlider(label, -180.f, 180.f, &euler.z);
|
||||||
if (euler_modified) {
|
if (euler_modified) {
|
||||||
modified = true;
|
modified = true;
|
||||||
ozz::math::Float3 euler_rad = euler * ozz::math::kDegreeToRadian;
|
ozz::math::Float3 euler_rad = euler * ozz::math::kDegreeToRadian;
|
||||||
|
@ -179,8 +180,8 @@ bool OnRawSkeletonJointGui(
|
||||||
// Scale (must be uniform and not 0)
|
// Scale (must be uniform and not 0)
|
||||||
_im_gui->DoLabel("Scale");
|
_im_gui->DoLabel("Scale");
|
||||||
ozz::math::Float3& scale = joint.transform.scale;
|
ozz::math::Float3& scale = joint.transform.scale;
|
||||||
sprintf(txt, "%.2g", scale.x);
|
snprintf(label, sizeof(label), "%.2g", scale.x);
|
||||||
if (_im_gui->DoSlider(txt, -1.f, 1.f, &scale.x)) {
|
if (_im_gui->DoSlider(label, -1.f, 1.f, &scale.x)) {
|
||||||
modified = true;
|
modified = true;
|
||||||
scale.y = scale.z = scale.x = scale.x != 0.f ? scale.x : .01f;
|
scale.y = scale.z = scale.x = scale.x != 0.f ? scale.x : .01f;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +329,7 @@ bool LoadAnimation(const char* _filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadRawAnimation(const char* _filename,
|
bool LoadRawAnimation(const char* _filename,
|
||||||
ozz::animation::offline::RawAnimation* _animation) {
|
ozz::animation::offline::RawAnimation* _animation) {
|
||||||
assert(_filename && _animation);
|
assert(_filename && _animation);
|
||||||
ozz::log::Out() << "Loading raw animation archive: " << _filename << "."
|
ozz::log::Out() << "Loading raw animation archive: " << _filename << "."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
|
@ -387,15 +387,15 @@ class LookAtSampleApplication : public ozz::sample::Application {
|
||||||
virtual void OnDestroy() {}
|
virtual void OnDestroy() {}
|
||||||
|
|
||||||
virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
|
virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
|
||||||
char txt[64];
|
char label[64];
|
||||||
|
|
||||||
_im_gui->DoCheckBox("Enable ik", &enable_ik_);
|
_im_gui->DoCheckBox("Enable ik", &enable_ik_);
|
||||||
sprintf(txt, "IK chain length: %d", chain_length_);
|
snprintf(label, sizeof(label), "IK chain length: %d", chain_length_);
|
||||||
_im_gui->DoSlider(txt, 0, kMaxChainLength, &chain_length_);
|
_im_gui->DoSlider(label, 0, kMaxChainLength, &chain_length_);
|
||||||
sprintf(txt, "Joint weight %.2g", joint_weight_);
|
snprintf(label, sizeof(label), "Joint weight %.2g", joint_weight_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &joint_weight_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &joint_weight_);
|
||||||
sprintf(txt, "Chain weight %.2g", chain_weight_);
|
snprintf(label, sizeof(label), "Chain weight %.2g", chain_weight_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &chain_weight_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &chain_weight_);
|
||||||
|
|
||||||
// Exposes animation runtime playback controls.
|
// Exposes animation runtime playback controls.
|
||||||
{
|
{
|
||||||
|
@ -413,15 +413,15 @@ class LookAtSampleApplication : public ozz::sample::Application {
|
||||||
const float kTargetRange = 3.f;
|
const float kTargetRange = 3.f;
|
||||||
|
|
||||||
_im_gui->DoLabel("Animated extent");
|
_im_gui->DoLabel("Animated extent");
|
||||||
sprintf(txt, "%.2g", target_extent_);
|
snprintf(label, sizeof(label), "%.2g", target_extent_);
|
||||||
_im_gui->DoSlider(txt, 0.f, kTargetRange, &target_extent_);
|
_im_gui->DoSlider(label, 0.f, kTargetRange, &target_extent_);
|
||||||
|
|
||||||
sprintf(txt, "x %.2g", target_offset_.x);
|
snprintf(label, sizeof(label), "x %.2g", target_offset_.x);
|
||||||
_im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.x);
|
_im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.x);
|
||||||
sprintf(txt, "y %.2g", target_offset_.y);
|
snprintf(label, sizeof(label), "y %.2g", target_offset_.y);
|
||||||
_im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.y);
|
_im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.y);
|
||||||
sprintf(txt, "z %.2g", target_offset_.z);
|
snprintf(label, sizeof(label), "z %.2g", target_offset_.z);
|
||||||
_im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.z);
|
_im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,12 +430,12 @@ class LookAtSampleApplication : public ozz::sample::Application {
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "Eyes offset", &opened);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "Eyes offset", &opened);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
const float kOffsetRange = .5f;
|
const float kOffsetRange = .5f;
|
||||||
sprintf(txt, "x %.2g", eyes_offset_.x);
|
snprintf(label, sizeof(label), "x %.2g", eyes_offset_.x);
|
||||||
_im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.x);
|
_im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.x);
|
||||||
sprintf(txt, "y %.2g", eyes_offset_.y);
|
snprintf(label, sizeof(label), "y %.2g", eyes_offset_.y);
|
||||||
_im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.y);
|
_im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.y);
|
||||||
sprintf(txt, "z %.2g", eyes_offset_.z);
|
snprintf(label, sizeof(label), "z %.2g", eyes_offset_.z);
|
||||||
_im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.z);
|
_im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
// Rebuilds all if the number of joints has changed.
|
// Rebuilds all if the number of joints has changed.
|
||||||
int joints = skeleton_->num_joints();
|
int joints = skeleton_->num_joints();
|
||||||
char label[64];
|
char label[64];
|
||||||
std::sprintf(label, "Joints count: %d", joints);
|
std::snprintf(label, sizeof(label), "Joints count: %d", joints);
|
||||||
|
|
||||||
// Uses an exponential scale in the slider to maintain enough precision in
|
// Uses an exponential scale in the slider to maintain enough precision in
|
||||||
// the lowest values.
|
// the lowest values.
|
||||||
|
@ -219,17 +219,17 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
root->transform.rotation = Quaternion::identity();
|
root->transform.rotation = Quaternion::identity();
|
||||||
root->transform.scale = Float3::one();
|
root->transform.scale = Float3::one();
|
||||||
|
|
||||||
char buf[16];
|
char number[16];
|
||||||
for (int i = 0; i < slice_count_; ++i) {
|
for (int i = 0; i < slice_count_; ++i) {
|
||||||
// Format joint number.
|
// Format joint number.
|
||||||
std::sprintf(buf, "%d", i);
|
std::snprintf(number, sizeof(number), "%d", i);
|
||||||
|
|
||||||
root->children.resize(3);
|
root->children.resize(3);
|
||||||
|
|
||||||
// Left leg.
|
// Left leg.
|
||||||
RawSkeleton::Joint& lu = root->children[0];
|
RawSkeleton::Joint& lu = root->children[0];
|
||||||
lu.name = "lu";
|
lu.name = "lu";
|
||||||
lu.name += buf;
|
lu.name += number;
|
||||||
lu.transform.translation = kTransUp;
|
lu.transform.translation = kTransUp;
|
||||||
lu.transform.rotation = kRotLeftUp;
|
lu.transform.rotation = kRotLeftUp;
|
||||||
lu.transform.scale = Float3::one();
|
lu.transform.scale = Float3::one();
|
||||||
|
@ -237,7 +237,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
lu.children.resize(1);
|
lu.children.resize(1);
|
||||||
RawSkeleton::Joint& ld = lu.children[0];
|
RawSkeleton::Joint& ld = lu.children[0];
|
||||||
ld.name = "ld";
|
ld.name = "ld";
|
||||||
ld.name += buf;
|
ld.name += number;
|
||||||
ld.transform.translation = kTransDown;
|
ld.transform.translation = kTransDown;
|
||||||
ld.transform.rotation = kRotLeftDown;
|
ld.transform.rotation = kRotLeftDown;
|
||||||
ld.transform.scale = Float3::one();
|
ld.transform.scale = Float3::one();
|
||||||
|
@ -245,7 +245,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
ld.children.resize(1);
|
ld.children.resize(1);
|
||||||
RawSkeleton::Joint& lf = ld.children[0];
|
RawSkeleton::Joint& lf = ld.children[0];
|
||||||
lf.name = "lf";
|
lf.name = "lf";
|
||||||
lf.name += buf;
|
lf.name += number;
|
||||||
lf.transform.translation = Float3::x_axis();
|
lf.transform.translation = Float3::x_axis();
|
||||||
lf.transform.rotation = Quaternion::identity();
|
lf.transform.rotation = Quaternion::identity();
|
||||||
lf.transform.scale = Float3::one();
|
lf.transform.scale = Float3::one();
|
||||||
|
@ -253,7 +253,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
// Right leg.
|
// Right leg.
|
||||||
RawSkeleton::Joint& ru = root->children[1];
|
RawSkeleton::Joint& ru = root->children[1];
|
||||||
ru.name = "ru";
|
ru.name = "ru";
|
||||||
ru.name += buf;
|
ru.name += number;
|
||||||
ru.transform.translation = kTransUp;
|
ru.transform.translation = kTransUp;
|
||||||
ru.transform.rotation = kRotRightUp;
|
ru.transform.rotation = kRotRightUp;
|
||||||
ru.transform.scale = Float3::one();
|
ru.transform.scale = Float3::one();
|
||||||
|
@ -261,7 +261,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
ru.children.resize(1);
|
ru.children.resize(1);
|
||||||
RawSkeleton::Joint& rd = ru.children[0];
|
RawSkeleton::Joint& rd = ru.children[0];
|
||||||
rd.name = "rd";
|
rd.name = "rd";
|
||||||
rd.name += buf;
|
rd.name += number;
|
||||||
rd.transform.translation = kTransDown;
|
rd.transform.translation = kTransDown;
|
||||||
rd.transform.rotation = kRotRightDown;
|
rd.transform.rotation = kRotRightDown;
|
||||||
rd.transform.scale = Float3::one();
|
rd.transform.scale = Float3::one();
|
||||||
|
@ -269,7 +269,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
rd.children.resize(1);
|
rd.children.resize(1);
|
||||||
RawSkeleton::Joint& rf = rd.children[0];
|
RawSkeleton::Joint& rf = rd.children[0];
|
||||||
rf.name = "rf";
|
rf.name = "rf";
|
||||||
rf.name += buf;
|
rf.name += number;
|
||||||
rf.transform.translation = Float3::x_axis();
|
rf.transform.translation = Float3::x_axis();
|
||||||
rf.transform.rotation = Quaternion::identity();
|
rf.transform.rotation = Quaternion::identity();
|
||||||
rf.transform.scale = Float3::one();
|
rf.transform.scale = Float3::one();
|
||||||
|
@ -277,7 +277,7 @@ class MillipedeSampleApplication : public ozz::sample::Application {
|
||||||
// Spine.
|
// Spine.
|
||||||
RawSkeleton::Joint& sp = root->children[2];
|
RawSkeleton::Joint& sp = root->children[2];
|
||||||
sp.name = "sp";
|
sp.name = "sp";
|
||||||
sp.name += buf;
|
sp.name += number;
|
||||||
sp.transform.translation = Float3(0.f, 0.f, kSpinLength);
|
sp.transform.translation = Float3(0.f, 0.f, kSpinLength);
|
||||||
sp.transform.rotation = Quaternion::identity();
|
sp.transform.rotation = Quaternion::identity();
|
||||||
sp.transform.scale = Float3::one();
|
sp.transform.scale = Float3::one();
|
||||||
|
|
|
@ -287,10 +287,10 @@ class MultithreadSampleApplication : public ozz::sample::Application {
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "Sample control", &oc_open);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "Sample control", &oc_open);
|
||||||
if (oc_open) {
|
if (oc_open) {
|
||||||
char label[64];
|
char label[64];
|
||||||
std::sprintf(label, "Number of entities: %d", num_characters_);
|
std::snprintf(label, sizeof(label), "Number of entities: %d", num_characters_);
|
||||||
_im_gui->DoSlider(label, 1, kMaxCharacters, &num_characters_, .7f);
|
_im_gui->DoSlider(label, 1, kMaxCharacters, &num_characters_, .7f);
|
||||||
const int num_joints = num_characters_ * skeleton_.num_joints();
|
const int num_joints = num_characters_ * skeleton_.num_joints();
|
||||||
std::sprintf(label, "Number of joints: %d", num_joints);
|
std::snprintf(label, sizeof(label), "Number of joints: %d", num_joints);
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,11 +303,11 @@ class MultithreadSampleApplication : public ozz::sample::Application {
|
||||||
has_threading_support_);
|
has_threading_support_);
|
||||||
if (enable_theading_) {
|
if (enable_theading_) {
|
||||||
char label[64];
|
char label[64];
|
||||||
std::sprintf(label, "Grain size: %d", grain_size_);
|
std::snprintf(label, sizeof(label), "Grain size: %d", grain_size_);
|
||||||
_im_gui->DoSlider(label, kMinGrainSize, kMaxCharacters, &grain_size_,
|
_im_gui->DoSlider(label, kMinGrainSize, kMaxCharacters, &grain_size_,
|
||||||
.2f);
|
.2f);
|
||||||
const int num_threads = monitor_.ThreadCount();
|
const int num_threads = monitor_.ThreadCount();
|
||||||
std::sprintf(label, "Thread/task count: %d/%d", num_threads,
|
std::snprintf(label, sizeof(label), "Thread/task count: %d/%d", num_threads,
|
||||||
monitor_.TaskCount());
|
monitor_.TaskCount());
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,29 +312,32 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||||
|
|
||||||
rebuild |= _im_gui->DoCheckBox("Enable optimizations", &optimize_);
|
rebuild |= _im_gui->DoCheckBox("Enable optimizations", &optimize_);
|
||||||
|
|
||||||
std::sprintf(label, "Tolerance: %0.2f mm", setting_.tolerance * 1000);
|
std::snprintf(label, sizeof(label), "Tolerance: %0.2f mm",
|
||||||
|
setting_.tolerance * 1000);
|
||||||
rebuild |= _im_gui->DoSlider(label, 0.f, .1f, &setting_.tolerance, .5f,
|
rebuild |= _im_gui->DoSlider(label, 0.f, .1f, &setting_.tolerance, .5f,
|
||||||
optimize_);
|
optimize_);
|
||||||
|
|
||||||
std::sprintf(label, "Distance: %0.2f mm", setting_.distance * 1000);
|
std::snprintf(label, sizeof(label), "Distance: %0.2f mm",
|
||||||
|
setting_.distance * 1000);
|
||||||
rebuild |= _im_gui->DoSlider(label, 0.f, 1.f, &setting_.distance, .5f,
|
rebuild |= _im_gui->DoSlider(label, 0.f, 1.f, &setting_.distance, .5f,
|
||||||
optimize_);
|
optimize_);
|
||||||
|
|
||||||
rebuild |= _im_gui->DoCheckBox("Enable joint setting",
|
rebuild |= _im_gui->DoCheckBox("Enable joint setting",
|
||||||
&joint_setting_enable_, optimize_);
|
&joint_setting_enable_, optimize_);
|
||||||
|
|
||||||
std::sprintf(label, "%s (%d)", skeleton_.joint_names()[joint_], joint_);
|
std::snprintf(label, sizeof(label), "%s (%d)",
|
||||||
|
skeleton_.joint_names()[joint_], joint_);
|
||||||
rebuild |=
|
rebuild |=
|
||||||
_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &joint_,
|
_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &joint_,
|
||||||
1.f, joint_setting_enable_ && optimize_);
|
1.f, joint_setting_enable_ && optimize_);
|
||||||
|
|
||||||
std::sprintf(label, "Tolerance: %0.2f mm",
|
std::snprintf(label, sizeof(label), "Tolerance: %0.2f mm",
|
||||||
joint_setting_.tolerance * 1000);
|
joint_setting_.tolerance * 1000);
|
||||||
rebuild |= _im_gui->DoSlider(label, 0.f, .1f, &joint_setting_.tolerance,
|
rebuild |= _im_gui->DoSlider(label, 0.f, .1f, &joint_setting_.tolerance,
|
||||||
.5f, joint_setting_enable_ && optimize_);
|
.5f, joint_setting_enable_ && optimize_);
|
||||||
|
|
||||||
std::sprintf(label, "Distance: %0.2f mm",
|
std::snprintf(label, sizeof(label), "Distance: %0.2f mm",
|
||||||
joint_setting_.distance * 1000);
|
joint_setting_.distance * 1000);
|
||||||
rebuild |= _im_gui->DoSlider(label, 0.f, 1.f, &joint_setting_.distance,
|
rebuild |= _im_gui->DoSlider(label, 0.f, 1.f, &joint_setting_.distance,
|
||||||
.5f, joint_setting_enable_ && optimize_);
|
.5f, joint_setting_enable_ && optimize_);
|
||||||
|
|
||||||
|
@ -356,18 +359,18 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||||
static bool open = true;
|
static bool open = true;
|
||||||
ozz::sample::ImGui::OpenClose ocb(_im_gui, "Memory size", &open);
|
ozz::sample::ImGui::OpenClose ocb(_im_gui, "Memory size", &open);
|
||||||
if (open) {
|
if (open) {
|
||||||
std::sprintf(label, "Original: %dKB",
|
std::snprintf(label, sizeof(label), "Original: %dKB",
|
||||||
static_cast<int>(raw_animation_.size() >> 10));
|
static_cast<int>(raw_animation_.size() >> 10));
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
|
|
||||||
std::sprintf(label, "Optimized: %dKB (%.1f:1)",
|
std::snprintf(label, sizeof(label), "Optimized: %dKB (%.1f:1)",
|
||||||
static_cast<int>(raw_optimized_animation_.size() >> 10),
|
static_cast<int>(raw_optimized_animation_.size() >> 10),
|
||||||
static_cast<float>(raw_animation_.size()) /
|
static_cast<float>(raw_animation_.size()) /
|
||||||
raw_optimized_animation_.size());
|
raw_optimized_animation_.size());
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
|
|
||||||
std::sprintf(
|
std::snprintf(
|
||||||
label, "Compressed: %dKB (%.1f:1)",
|
label, sizeof(label), "Compressed: %dKB (%.1f:1)",
|
||||||
static_cast<int>(animation_rt_->size() >> 10),
|
static_cast<int>(animation_rt_->size() >> 10),
|
||||||
static_cast<float>(raw_animation_.size()) / animation_rt_->size());
|
static_cast<float>(raw_animation_.size()) / animation_rt_->size());
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
|
@ -388,37 +391,36 @@ class OptimizeSampleApplication : public ozz::sample::Application {
|
||||||
|
|
||||||
// Show absolute error.
|
// Show absolute error.
|
||||||
{
|
{
|
||||||
char szLabel[64];
|
|
||||||
static bool error_open = true;
|
static bool error_open = true;
|
||||||
ozz::sample::ImGui::OpenClose oc_stats(_im_gui, "Absolute error",
|
ozz::sample::ImGui::OpenClose oc_stats(_im_gui, "Absolute error",
|
||||||
&error_open);
|
&error_open);
|
||||||
if (error_open) {
|
if (error_open) {
|
||||||
{
|
{
|
||||||
std::sprintf(szLabel, "Median error: %.2fmm",
|
std::snprintf(label, sizeof(label), "Median error: %.2fmm",
|
||||||
*error_record_med_.cursor());
|
*error_record_med_.cursor());
|
||||||
const ozz::sample::Record::Statistics error_stats =
|
const ozz::sample::Record::Statistics error_stats =
|
||||||
error_record_med_.GetStatistics();
|
error_record_med_.GetStatistics();
|
||||||
_im_gui->DoGraph(szLabel, 0.f, error_stats.max, error_stats.latest,
|
_im_gui->DoGraph(label, 0.f, error_stats.max, error_stats.latest,
|
||||||
error_record_med_.cursor(),
|
error_record_med_.cursor(),
|
||||||
error_record_med_.record_begin(),
|
error_record_med_.record_begin(),
|
||||||
error_record_med_.record_end());
|
error_record_med_.record_end());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::sprintf(szLabel, "Maximum error: %.2fmm",
|
std::snprintf(label, sizeof(label), "Maximum error: %.2fmm",
|
||||||
*error_record_max_.cursor());
|
*error_record_max_.cursor());
|
||||||
const ozz::sample::Record::Statistics error_stats =
|
const ozz::sample::Record::Statistics error_stats =
|
||||||
error_record_max_.GetStatistics();
|
error_record_max_.GetStatistics();
|
||||||
_im_gui->DoGraph(szLabel, 0.f, error_stats.max, error_stats.latest,
|
_im_gui->DoGraph(label, 0.f, error_stats.max, error_stats.latest,
|
||||||
error_record_max_.cursor(),
|
error_record_max_.cursor(),
|
||||||
error_record_max_.record_begin(),
|
error_record_max_.record_begin(),
|
||||||
error_record_max_.record_end());
|
error_record_max_.record_end());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::sprintf(szLabel, "Joint %d error: %.2fmm", joint_,
|
std::snprintf(label, sizeof(label), "Joint %d error: %.2fmm", joint_,
|
||||||
*joint_error_record_.cursor());
|
*joint_error_record_.cursor());
|
||||||
const ozz::sample::Record::Statistics error_stats =
|
const ozz::sample::Record::Statistics error_stats =
|
||||||
joint_error_record_.GetStatistics();
|
joint_error_record_.GetStatistics();
|
||||||
_im_gui->DoGraph(szLabel, 0.f, error_stats.max, error_stats.latest,
|
_im_gui->DoGraph(label, 0.f, error_stats.max, error_stats.latest,
|
||||||
joint_error_record_.cursor(),
|
joint_error_record_.cursor(),
|
||||||
joint_error_record_.record_begin(),
|
joint_error_record_.record_begin(),
|
||||||
joint_error_record_.record_end());
|
joint_error_record_.record_end());
|
||||||
|
|
|
@ -251,7 +251,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
|
||||||
_im_gui->DoCheckBox("Use automatic blending settings", &automatic);
|
_im_gui->DoCheckBox("Use automatic blending settings", &automatic);
|
||||||
|
|
||||||
static float coeff = 1.f; // All power to the partial animation.
|
static float coeff = 1.f; // All power to the partial animation.
|
||||||
std::sprintf(label, "Upper body weight: %.2f", coeff);
|
std::snprintf(label, sizeof(label), "Upper body weight: %.2f", coeff);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f, &coeff, 1.f, automatic);
|
_im_gui->DoSlider(label, 0.f, 1.f, &coeff, 1.f, automatic);
|
||||||
|
|
||||||
Sampler& lower_body_sampler = samplers_[kLowerBody];
|
Sampler& lower_body_sampler = samplers_[kLowerBody];
|
||||||
|
@ -267,27 +267,27 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
|
||||||
|
|
||||||
_im_gui->DoLabel("Manual settings:");
|
_im_gui->DoLabel("Manual settings:");
|
||||||
_im_gui->DoLabel("Lower body layer:");
|
_im_gui->DoLabel("Lower body layer:");
|
||||||
std::sprintf(label, "Layer weight: %.2f",
|
std::snprintf(label, sizeof(label), "Layer weight: %.2f",
|
||||||
lower_body_sampler.weight_setting);
|
lower_body_sampler.weight_setting);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f, &lower_body_sampler.weight_setting,
|
_im_gui->DoSlider(label, 0.f, 1.f, &lower_body_sampler.weight_setting,
|
||||||
1.f, !automatic);
|
1.f, !automatic);
|
||||||
std::sprintf(label, "Joints weight: %.2f",
|
std::snprintf(label, sizeof(label), "Joints weight: %.2f",
|
||||||
lower_body_sampler.joint_weight_setting);
|
lower_body_sampler.joint_weight_setting);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f,
|
_im_gui->DoSlider(label, 0.f, 1.f,
|
||||||
&lower_body_sampler.joint_weight_setting, 1.f,
|
&lower_body_sampler.joint_weight_setting, 1.f,
|
||||||
!automatic);
|
!automatic);
|
||||||
_im_gui->DoLabel("Upper body layer:");
|
_im_gui->DoLabel("Upper body layer:");
|
||||||
std::sprintf(label, "Layer weight: %.2f",
|
std::snprintf(label, sizeof(label), "Layer weight: %.2f",
|
||||||
upper_body_sampler.weight_setting);
|
upper_body_sampler.weight_setting);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f, &upper_body_sampler.weight_setting,
|
_im_gui->DoSlider(label, 0.f, 1.f, &upper_body_sampler.weight_setting,
|
||||||
1.f, !automatic);
|
1.f, !automatic);
|
||||||
std::sprintf(label, "Joints weight: %.2f",
|
std::snprintf(label, sizeof(label), "Joints weight: %.2f",
|
||||||
upper_body_sampler.joint_weight_setting);
|
upper_body_sampler.joint_weight_setting);
|
||||||
_im_gui->DoSlider(label, 0.f, 1.f,
|
_im_gui->DoSlider(label, 0.f, 1.f,
|
||||||
&upper_body_sampler.joint_weight_setting, 1.f,
|
&upper_body_sampler.joint_weight_setting, 1.f,
|
||||||
!automatic);
|
!automatic);
|
||||||
_im_gui->DoLabel("Global settings:");
|
_im_gui->DoLabel("Global settings:");
|
||||||
std::sprintf(label, "Threshold: %.2f", threshold_);
|
std::snprintf(label, sizeof(label), "Threshold: %.2f", threshold_);
|
||||||
_im_gui->DoSlider(label, .01f, 1.f, &threshold_);
|
_im_gui->DoSlider(label, .01f, 1.f, &threshold_);
|
||||||
|
|
||||||
SetupPerJointWeights();
|
SetupPerJointWeights();
|
||||||
|
@ -301,7 +301,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application {
|
||||||
_im_gui->DoLabel("Root of the upper body hierarchy:",
|
_im_gui->DoLabel("Root of the upper body hierarchy:",
|
||||||
ozz::sample::ImGui::kLeft, false);
|
ozz::sample::ImGui::kLeft, false);
|
||||||
char label[64];
|
char label[64];
|
||||||
std::sprintf(label, "%s (%d)",
|
std::snprintf(label, sizeof(label), "%s (%d)",
|
||||||
skeleton_.joint_names()[upper_body_root_],
|
skeleton_.joint_names()[upper_body_root_],
|
||||||
upper_body_root_);
|
upper_body_root_);
|
||||||
if (_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1,
|
if (_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1,
|
||||||
|
|
|
@ -186,28 +186,28 @@ class SkinningSampleApplication : public ozz::sample::Application {
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "Model statisitics", &open);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "Model statisitics", &open);
|
||||||
if (open) {
|
if (open) {
|
||||||
char label[255];
|
char label[255];
|
||||||
sprintf(label, "%d animated joints", skeleton_.num_joints());
|
std::snprintf(label, sizeof(label), "%d animated joints", skeleton_.num_joints());
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
|
|
||||||
int influences = 0;
|
int influences = 0;
|
||||||
for (const auto& mesh : meshes_) {
|
for (const auto& mesh : meshes_) {
|
||||||
influences = ozz::math::Max(influences, mesh.max_influences_count());
|
influences = ozz::math::Max(influences, mesh.max_influences_count());
|
||||||
}
|
}
|
||||||
sprintf(label, "%d influences (max)", influences);
|
std::snprintf(label, sizeof(label), "%d influences (max)", influences);
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
|
|
||||||
int vertices = 0;
|
int vertices = 0;
|
||||||
for (const auto& mesh : meshes_) {
|
for (const auto& mesh : meshes_) {
|
||||||
vertices += mesh.vertex_count();
|
vertices += mesh.vertex_count();
|
||||||
}
|
}
|
||||||
sprintf(label, "%.1fK vertices", vertices / 1000.f);
|
std::snprintf(label, sizeof(label), "%.1fK vertices", vertices / 1000.f);
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
|
|
||||||
int indices = 0;
|
int indices = 0;
|
||||||
for (const auto& mesh : meshes_) {
|
for (const auto& mesh : meshes_) {
|
||||||
indices += mesh.triangle_index_count();
|
indices += mesh.triangle_index_count();
|
||||||
}
|
}
|
||||||
sprintf(label, "%.1fK triangles", indices / 3000.f);
|
std::snprintf(label, sizeof(label), "%.1fK triangles", indices / 3000.f);
|
||||||
_im_gui->DoLabel(label);
|
_im_gui->DoLabel(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,7 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application {
|
||||||
virtual void OnDestroy() {}
|
virtual void OnDestroy() {}
|
||||||
|
|
||||||
virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
|
virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
|
||||||
char txt[32];
|
char label[32];
|
||||||
|
|
||||||
// IK parameters
|
// IK parameters
|
||||||
_im_gui->DoCheckBox("Fix initial transform", &fix_initial_transform_);
|
_im_gui->DoCheckBox("Fix initial transform", &fix_initial_transform_);
|
||||||
|
@ -273,25 +273,25 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application {
|
||||||
static bool opened = true;
|
static bool opened = true;
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "IK parameters", &opened);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "IK parameters", &opened);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
sprintf(txt, "Soften: %.2g", soften_);
|
snprintf(label, sizeof(label), "Soften: %.2g", soften_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &soften_, 2.f);
|
_im_gui->DoSlider(label, 0.f, 1.f, &soften_, 2.f);
|
||||||
sprintf(txt, "Twist angle: %.0f",
|
snprintf(label, sizeof(label), "Twist angle: %.0f",
|
||||||
twist_angle_ * ozz::math::kRadianToDegree);
|
twist_angle_ * ozz::math::kRadianToDegree);
|
||||||
_im_gui->DoSlider(txt, -ozz::math::kPi, ozz::math::kPi, &twist_angle_);
|
_im_gui->DoSlider(label, -ozz::math::kPi, ozz::math::kPi, &twist_angle_);
|
||||||
sprintf(txt, "Weight: %.2g", weight_);
|
snprintf(label, sizeof(label), "Weight: %.2g", weight_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &weight_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &weight_);
|
||||||
{
|
{
|
||||||
// Pole vector
|
// Pole vector
|
||||||
static bool pole_opened = true;
|
static bool pole_opened = true;
|
||||||
ozz::sample::ImGui::OpenClose oc_pole(_im_gui, "Pole vector",
|
ozz::sample::ImGui::OpenClose oc_pole(_im_gui, "Pole vector",
|
||||||
&pole_opened);
|
&pole_opened);
|
||||||
if (pole_opened) {
|
if (pole_opened) {
|
||||||
sprintf(txt, "x %.2g", pole_vector.x);
|
snprintf(label, sizeof(label), "x %.2g", pole_vector.x);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.x);
|
_im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.x);
|
||||||
sprintf(txt, "y %.2g", pole_vector.y);
|
snprintf(label, sizeof(label), "y %.2g", pole_vector.y);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.y);
|
_im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.y);
|
||||||
sprintf(txt, "z %.2g", pole_vector.z);
|
snprintf(label, sizeof(label), "z %.2g", pole_vector.z);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.z);
|
_im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,17 +301,17 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application {
|
||||||
ozz::sample::ImGui::OpenClose oc(_im_gui, "Target position", &opened);
|
ozz::sample::ImGui::OpenClose oc(_im_gui, "Target position", &opened);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
_im_gui->DoLabel("Target animation extent");
|
_im_gui->DoLabel("Target animation extent");
|
||||||
sprintf(txt, "%.2g", target_extent_);
|
snprintf(label, sizeof(label), "%.2g", target_extent_);
|
||||||
_im_gui->DoSlider(txt, 0.f, 1.f, &target_extent_);
|
_im_gui->DoSlider(label, 0.f, 1.f, &target_extent_);
|
||||||
|
|
||||||
_im_gui->DoLabel("Target Offset");
|
_im_gui->DoLabel("Target Offset");
|
||||||
const float kOffsetRange = 1.f;
|
const float kOffsetRange = 1.f;
|
||||||
sprintf(txt, "x %.2g", target_offset_.x);
|
snprintf(label, sizeof(label), "x %.2g", target_offset_.x);
|
||||||
_im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.x);
|
_im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.x);
|
||||||
sprintf(txt, "y %.2g", target_offset_.y);
|
snprintf(label, sizeof(label), "y %.2g", target_offset_.y);
|
||||||
_im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.y);
|
_im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.y);
|
||||||
sprintf(txt, "z %.2g", target_offset_.z);
|
snprintf(label, sizeof(label), "z %.2g", target_offset_.z);
|
||||||
_im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.z);
|
_im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // Root
|
{ // Root
|
||||||
|
@ -320,28 +320,28 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application {
|
||||||
if (opened) {
|
if (opened) {
|
||||||
// Translation
|
// Translation
|
||||||
_im_gui->DoLabel("Translation");
|
_im_gui->DoLabel("Translation");
|
||||||
sprintf(txt, "x %.2g", root_translation_.x);
|
snprintf(label, sizeof(label), "x %.2g", root_translation_.x);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.x);
|
_im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.x);
|
||||||
sprintf(txt, "y %.2g", root_translation_.y);
|
snprintf(label, sizeof(label), "y %.2g", root_translation_.y);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.y);
|
_im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.y);
|
||||||
sprintf(txt, "z %.2g", root_translation_.z);
|
snprintf(label, sizeof(label), "z %.2g", root_translation_.z);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.z);
|
_im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.z);
|
||||||
|
|
||||||
// Rotation (in euler form)
|
// Rotation (in euler form)
|
||||||
_im_gui->DoLabel("Rotation");
|
_im_gui->DoLabel("Rotation");
|
||||||
ozz::math::Float3 euler = root_euler_ * ozz::math::kRadianToDegree;
|
ozz::math::Float3 euler = root_euler_ * ozz::math::kRadianToDegree;
|
||||||
sprintf(txt, "yaw %.3g", euler.x);
|
snprintf(label, sizeof(label), "yaw %.3g", euler.x);
|
||||||
_im_gui->DoSlider(txt, -180.f, 180.f, &euler.x);
|
_im_gui->DoSlider(label, -180.f, 180.f, &euler.x);
|
||||||
sprintf(txt, "pitch %.3g", euler.y);
|
snprintf(label, sizeof(label), "pitch %.3g", euler.y);
|
||||||
_im_gui->DoSlider(txt, -180.f, 180.f, &euler.y);
|
_im_gui->DoSlider(label, -180.f, 180.f, &euler.y);
|
||||||
sprintf(txt, "roll %.3g", euler.z);
|
snprintf(label, sizeof(label), "roll %.3g", euler.z);
|
||||||
_im_gui->DoSlider(txt, -180.f, 180.f, &euler.z);
|
_im_gui->DoSlider(label, -180.f, 180.f, &euler.z);
|
||||||
root_euler_ = euler * ozz::math::kDegreeToRadian;
|
root_euler_ = euler * ozz::math::kDegreeToRadian;
|
||||||
|
|
||||||
// Scale (must be uniform and not 0)
|
// Scale (must be uniform and not 0)
|
||||||
_im_gui->DoLabel("Scale");
|
_im_gui->DoLabel("Scale");
|
||||||
sprintf(txt, "%.2g", root_scale_);
|
snprintf(label, sizeof(label), "%.2g", root_scale_);
|
||||||
_im_gui->DoSlider(txt, -1.f, 1.f, &root_scale_);
|
_im_gui->DoSlider(label, -1.f, 1.f, &root_scale_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // Display options
|
{ // Display options
|
||||||
|
|
|
@ -62,6 +62,7 @@ target_compile_definitions(ozz_base
|
||||||
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:OZZ_BUILD_BASE_LIB>)
|
PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:OZZ_BUILD_BASE_LIB>)
|
||||||
|
|
||||||
target_compile_options(ozz_base PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/wd4251>)
|
target_compile_options(ozz_base PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/wd4251>)
|
||||||
|
|
||||||
target_include_directories(ozz_base PUBLIC
|
target_include_directories(ozz_base PUBLIC
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
|
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
|
||||||
|
|
|
@ -25,15 +25,13 @@
|
||||||
// //
|
// //
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "ozz/animation/runtime/ik_aim_job.h"
|
#include "ozz/animation/runtime/ik_aim_job.h"
|
||||||
|
#include "ozz/base/maths/gtest_math_helper.h"
|
||||||
#include "ozz/base/maths/quaternion.h"
|
#include "ozz/base/maths/quaternion.h"
|
||||||
#include "ozz/base/maths/simd_math.h"
|
#include "ozz/base/maths/simd_math.h"
|
||||||
#include "ozz/base/maths/simd_quaternion.h"
|
#include "ozz/base/maths/simd_quaternion.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
#include "ozz/base/maths/gtest_math_helper.h"
|
|
||||||
|
|
||||||
TEST(JobValidity, IKAimJob) {
|
TEST(JobValidity, IKAimJob) {
|
||||||
const ozz::math::Float4x4 joint = ozz::math::Float4x4::identity();
|
const ozz::math::Float4x4 joint = ozz::math::Float4x4::identity();
|
||||||
ozz::math::SimdQuaternion quat;
|
ozz::math::SimdQuaternion quat;
|
||||||
|
@ -428,43 +426,24 @@ TEST(Twist, IKAimJob) {
|
||||||
EXPECT_SIMDQUATERNION_EQ_TOL(quat, 0.f, 0.f, 0.f, 1.f, 2e-3f);
|
EXPECT_SIMDQUATERNION_EQ_TOL(quat, 0.f, 0.f, 0.f, 1.f, 2e-3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Pole y, twist pi
|
{ // Pole y, twist pi / 2
|
||||||
job.pole_vector = ozz::math::simd_float4::y_axis();
|
job.pole_vector = ozz::math::simd_float4::y_axis();
|
||||||
job.twist_angle = ozz::math::kPi;
|
job.twist_angle = ozz::math::kPi_2;
|
||||||
EXPECT_TRUE(job.Run());
|
EXPECT_TRUE(job.Run());
|
||||||
const ozz::math::Quaternion x_Pi = ozz::math::Quaternion::FromAxisAngle(
|
const ozz::math::Quaternion x_Pi = ozz::math::Quaternion::FromAxisAngle(
|
||||||
ozz::math::Float3::x_axis(), -ozz::math::kPi);
|
ozz::math::Float3::x_axis(), ozz::math::kPi_2);
|
||||||
EXPECT_SIMDQUATERNION_EQ_TOL(quat, x_Pi.x, x_Pi.y, x_Pi.z, x_Pi.w, 2e-3f);
|
EXPECT_SIMDQUATERNION_EQ_TOL(quat, x_Pi.x, x_Pi.y, x_Pi.z, x_Pi.w, 2e-3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Pole y, twist -pi
|
{ // Pole y, twist -pi / 2
|
||||||
job.pole_vector = ozz::math::simd_float4::y_axis();
|
job.pole_vector = ozz::math::simd_float4::y_axis();
|
||||||
job.twist_angle = -ozz::math::kPi;
|
job.twist_angle = -ozz::math::kPi_2;
|
||||||
EXPECT_TRUE(job.Run());
|
EXPECT_TRUE(job.Run());
|
||||||
const ozz::math::Quaternion x_mPi = ozz::math::Quaternion::FromAxisAngle(
|
const ozz::math::Quaternion x_mPi = ozz::math::Quaternion::FromAxisAngle(
|
||||||
ozz::math::Float3::x_axis(), -ozz::math::kPi);
|
ozz::math::Float3::x_axis(), -ozz::math::kPi_2);
|
||||||
EXPECT_SIMDQUATERNION_EQ_TOL(quat, x_mPi.x, x_mPi.y, x_mPi.z, x_mPi.w,
|
EXPECT_SIMDQUATERNION_EQ_TOL(quat, x_mPi.x, x_mPi.y, x_mPi.z, x_mPi.w,
|
||||||
2e-3f);
|
2e-3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Pole y, twist pi/2
|
|
||||||
job.pole_vector = ozz::math::simd_float4::y_axis();
|
|
||||||
job.twist_angle = ozz::math::kPi_2;
|
|
||||||
EXPECT_TRUE(job.Run());
|
|
||||||
const ozz::math::Quaternion x_Pi_2 = ozz::math::Quaternion::FromAxisAngle(
|
|
||||||
ozz::math::Float3::x_axis(), ozz::math::kPi_2);
|
|
||||||
EXPECT_SIMDQUATERNION_EQ_TOL(quat, x_Pi_2.x, x_Pi_2.y, x_Pi_2.z, x_Pi_2.w,
|
|
||||||
2e-3f);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // Pole z, twist pi/2
|
|
||||||
job.pole_vector = ozz::math::simd_float4::z_axis();
|
|
||||||
job.twist_angle = ozz::math::kPi_2;
|
|
||||||
EXPECT_TRUE(job.Run());
|
|
||||||
const ozz::math::Quaternion x_Pi = ozz::math::Quaternion::FromAxisAngle(
|
|
||||||
ozz::math::Float3::x_axis(), ozz::math::kPi);
|
|
||||||
EXPECT_SIMDQUATERNION_EQ_TOL(quat, x_Pi.x, x_Pi.y, x_Pi.z, x_Pi.w, 2e-3f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(AlignedTargetUp, IKAimJob) {
|
TEST(AlignedTargetUp, IKAimJob) {
|
||||||
|
|
|
@ -3,6 +3,8 @@ target_include_directories(test_intrusive_list
|
||||||
PUBLIC "${PROJECT_SOURCE_DIR}/include")
|
PUBLIC "${PROJECT_SOURCE_DIR}/include")
|
||||||
target_link_libraries(test_intrusive_list
|
target_link_libraries(test_intrusive_list
|
||||||
gtest)
|
gtest)
|
||||||
|
target_compile_options(test_intrusive_list
|
||||||
|
PRIVATE $<$<BOOL:${W_UNUSED_RESULT}>:-Wno-unused-result>)
|
||||||
target_copy_shared_libraries(test_intrusive_list)
|
target_copy_shared_libraries(test_intrusive_list)
|
||||||
add_test(NAME test_intrusive_list COMMAND test_intrusive_list)
|
add_test(NAME test_intrusive_list COMMAND test_intrusive_list)
|
||||||
set_target_properties(test_intrusive_list PROPERTIES FOLDER "ozz/tests/base")
|
set_target_properties(test_intrusive_list PROPERTIES FOLDER "ozz/tests/base")
|
||||||
|
@ -11,6 +13,8 @@ add_executable(test_std_containers std_containers_tests.cc)
|
||||||
target_link_libraries(test_std_containers
|
target_link_libraries(test_std_containers
|
||||||
ozz_base
|
ozz_base
|
||||||
gtest)
|
gtest)
|
||||||
|
target_compile_options(test_std_containers
|
||||||
|
PRIVATE $<$<BOOL:${W_UNUSED_RESULT}>:-Wno-unused-result>)
|
||||||
target_copy_shared_libraries(test_std_containers)
|
target_copy_shared_libraries(test_std_containers)
|
||||||
add_test(NAME test_std_containers COMMAND test_std_containers)
|
add_test(NAME test_std_containers COMMAND test_std_containers)
|
||||||
set_target_properties(test_std_containers PROPERTIES FOLDER "ozz/tests/base")
|
set_target_properties(test_std_containers PROPERTIES FOLDER "ozz/tests/base")
|
||||||
|
|
|
@ -160,8 +160,10 @@ struct Viewport {
|
||||||
.compare = SG_COMPAREFUNC_LESS_EQUAL,
|
.compare = SG_COMPAREFUNC_LESS_EQUAL,
|
||||||
.write_enabled = true
|
.write_enabled = true
|
||||||
},
|
},
|
||||||
.cull_mode = SG_CULLMODE_BACK
|
.cull_mode = SG_CULLMODE_BACK,
|
||||||
|
.sample_count = cMSAASampleCount
|
||||||
};
|
};
|
||||||
|
// this->pip = sg_make_pipeline(gl_pipeline_desc);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -472,7 +474,7 @@ int main() {
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE);
|
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_SAMPLES, 16);
|
glfwWindowHint(GLFW_SAMPLES, cMSAASampleCount);
|
||||||
GLFWwindow* w =
|
GLFWwindow* w =
|
||||||
glfwCreateWindow(Width, Height, "ATP Editor", nullptr, nullptr);
|
glfwCreateWindow(Width, Height, "ATP Editor", nullptr, nullptr);
|
||||||
glfwMakeContextCurrent(w);
|
glfwMakeContextCurrent(w);
|
||||||
|
@ -527,7 +529,7 @@ int main() {
|
||||||
|
|
||||||
// setup sokol_gfx and sokol_time
|
// setup sokol_gfx and sokol_time
|
||||||
stm_setup();
|
stm_setup();
|
||||||
sg_desc desc = {.logger = {.func = slog_func}};
|
sg_desc desc = {.logger = {.func = slog_func}, .context {.sample_count = cMSAASampleCount}};
|
||||||
sg_setup(&desc);
|
sg_setup(&desc);
|
||||||
assert(sg_isvalid());
|
assert(sg_isvalid());
|
||||||
|
|
||||||
|
@ -658,6 +660,7 @@ int main() {
|
||||||
pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA;
|
pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA;
|
||||||
pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
|
pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
pip_desc.colors[0].write_mask = SG_COLORMASK_RGB;
|
pip_desc.colors[0].write_mask = SG_COLORMASK_RGB;
|
||||||
|
pip_desc.sample_count = cMSAASampleCount;
|
||||||
pip_desc.label = "imgui-rendering";
|
pip_desc.label = "imgui-rendering";
|
||||||
pip = sg_make_pipeline(&pip_desc);
|
pip = sg_make_pipeline(&pip_desc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue