From 7048a1db6c365753cca078261956f5d64fa6c74b Mon Sep 17 00:00:00 2001 From: BenjaminGu Date: Tue, 1 Feb 2022 05:14:58 +0900 Subject: [PATCH 01/20] Removes non-ASCII characters in source codes. (#141) --- extern/gtest/fused-src/gtest/gtest.h | 2 +- samples/framework/utils.cc | 2 +- src/animation/offline/decimate.h | 2 +- src/animation/runtime/ik_two_bone_job.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extern/gtest/fused-src/gtest/gtest.h b/extern/gtest/fused-src/gtest/gtest.h index 3e3e986dc..e5da69e1c 100644 --- a/extern/gtest/fused-src/gtest/gtest.h +++ b/extern/gtest/fused-src/gtest/gtest.h @@ -7917,7 +7917,7 @@ namespace edit_distance { // Returns the optimal edits to go from 'left' to 'right'. // All edits cost the same, with replace having lower priority than // add/remove. -// Simple implementation of the Wagner–Fischer algorithm. +// Simple implementation of the Wagner-Fischer algorithm. // See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm enum EditType { kMatch, kAdd, kRemove, kReplace }; GTEST_API_ std::vector CalculateOptimalEdits( diff --git a/samples/framework/utils.cc b/samples/framework/utils.cc index af2c78725..9ab353e32 100644 --- a/samples/framework/utils.cc +++ b/samples/framework/utils.cc @@ -411,7 +411,7 @@ bool LoadMeshes(const char* _filename, } namespace { -// Moller–Trumbore intersection algorithm +// Moller-Trumbore intersection algorithm // https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm bool RayIntersectsTriangle(const ozz::math::Float3& _ray_origin, const ozz::math::Float3& _ray_direction, diff --git a/src/animation/offline/decimate.h b/src/animation/offline/decimate.h index 399438210..9f450bfe8 100644 --- a/src/animation/offline/decimate.h +++ b/src/animation/offline/decimate.h @@ -41,7 +41,7 @@ namespace ozz { namespace animation { namespace offline { -// Decimation algorithm based on Ramer–Douglas–Peucker. +// Decimation algorithm based on Ramer-Douglas-Peucker. // https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm // _Track must have std::vector interface. // Adapter must have the following interface: diff --git a/src/animation/runtime/ik_two_bone_job.cc b/src/animation/runtime/ik_two_bone_job.cc index f429c72e6..f7d999f7c 100644 --- a/src/animation/runtime/ik_two_bone_job.cc +++ b/src/animation/runtime/ik_two_bone_job.cc @@ -184,7 +184,7 @@ bool SoftenTarget(const IKTwoBoneJob& _job, const IKConstantSetup& _setup, // The maximum distance we can reach is the soften bone chain length: da // (stored in !x). The minimum distance we can reach is the absolute value of - // the difference of the 2 bone lengths, |d1−d2| (stored in z). x is 0 and z + // the difference of the 2 bone lengths, |d1-d2| (stored in z). x is 0 and z // is 1, yw are untested. return (comp_mask & 0x5) == 0x4; } From 5ed0aab6724b02a099832228f5e42ede066302c8 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Thu, 19 May 2022 13:32:45 +0200 Subject: [PATCH 02/20] Allows reusing sample framework outside of sample directory. --- samples/framework/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/framework/CMakeLists.txt b/samples/framework/CMakeLists.txt index 4b8e2c0e0..cf0f361d4 100644 --- a/samples/framework/CMakeLists.txt +++ b/samples/framework/CMakeLists.txt @@ -36,6 +36,10 @@ target_link_libraries(sample_framework ozz_geometry ozz_animation_offline ozz_options) + +target_include_directories(sample_framework PUBLIC + $ + $/samples>) if(TARGET BUILD_DATA_SAMPLE) add_dependencies(sample_framework BUILD_DATA_SAMPLE) From 137a4ad023f363a34aef8a7aba1469010ff128d3 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Thu, 16 Jun 2022 12:06:03 +0200 Subject: [PATCH 03/20] Exposes swap interval (#154) --- samples/framework/application.cc | 16 +++++++++++----- samples/framework/application.h | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/samples/framework/application.cc b/samples/framework/application.cc index b7778cbf9..ede6c403c 100644 --- a/samples/framework/application.cc +++ b/samples/framework/application.cc @@ -98,6 +98,8 @@ Application::Application() time_(0.f), last_idle_time_(0.), show_help_(false), + vertical_sync_(true), + swap_interval_(1), show_grid_(true), show_axes_(true), capture_video_(false), @@ -209,7 +211,7 @@ int Application::Run(int _argc, const char** _argv, const char* _version, #endif // EMSCRIPTEN // Setup the window and installs callbacks. - glfwSwapInterval(1); // Enables vertical sync by default. + glfwSwapInterval(vertical_sync_ ? swap_interval_ : 0); glfwSetWindowSizeCallback(&ResizeCbk); glfwSetWindowCloseCallback(&CloseCbk); @@ -611,10 +613,14 @@ bool Application::FrameworkGui() { GL(Disable(GL_MULTISAMPLE)); } } - // Vertical sync - static bool vertical_sync_ = true; // On by default. - if (im_gui->DoCheckBox("Vertical sync", &vertical_sync_, true)) { - glfwSwapInterval(vertical_sync_ ? 1 : 0); + // Vertical sync & swap interval + bool changed = im_gui->DoCheckBox("Vertical sync", &vertical_sync_); + char szLabel[64]; + std::sprintf(szLabel, "Swap interval: %d", swap_interval_); + changed |= + im_gui->DoSlider(szLabel, 1, 4, &swap_interval_, 1.f, vertical_sync_); + if (changed) { + glfwSwapInterval(vertical_sync_ ? swap_interval_ : 0); } im_gui->DoCheckBox("Show grid", &show_grid_, true); diff --git a/samples/framework/application.h b/samples/framework/application.h index fb004cdc0..c91ecfeb5 100644 --- a/samples/framework/application.h +++ b/samples/framework/application.h @@ -216,6 +216,9 @@ class Application { // Set to true to display help. bool show_help_; + bool vertical_sync_; // On by default. + int swap_interval_; + // Grid display settings. bool show_grid_; bool show_axes_; From e414a8ab0b62817dc695e5ecbf7c83c1839d24d3 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Tue, 28 Jun 2022 17:51:02 +0200 Subject: [PATCH 04/20] Exposes loading a raw animation file. --- samples/framework/utils.cc | 25 +++++++++++++++++++++++ samples/framework/utils.h | 8 ++++++++ samples/optimize/sample_optimize.cc | 31 +---------------------------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/samples/framework/utils.cc b/samples/framework/utils.cc index 9ab353e32..85fca3983 100644 --- a/samples/framework/utils.cc +++ b/samples/framework/utils.cc @@ -32,6 +32,7 @@ #include "framework/imgui.h" #include "framework/mesh.h" +#include "ozz/animation/offline/raw_animation.h" #include "ozz/animation/offline/raw_skeleton.h" #include "ozz/animation/runtime/animation.h" #include "ozz/animation/runtime/local_to_model_job.h" @@ -326,6 +327,30 @@ bool LoadAnimation(const char* _filename, return true; } +bool LoadRawAnimation(const char* _filename, + ozz::animation::offline::RawAnimation* _animation) { + assert(_filename && _animation); + ozz::log::Out() << "Loading raw animation archive: " << _filename << "." + << std::endl; + ozz::io::File file(_filename, "rb"); + if (!file.opened()) { + ozz::log::Err() << "Failed to open raw animation file " << _filename << "." + << std::endl; + return false; + } + ozz::io::IArchive archive(&file); + if (!archive.TestTag()) { + ozz::log::Err() << "Failed to load raw animation instance from file " + << _filename << "." << std::endl; + return false; + } + + // Once the tag is validated, reading cannot fail. + archive >> *_animation; + + return true; +} + namespace { template bool LoadTrackImpl(const char* _filename, _Track* _track) { diff --git a/samples/framework/utils.h b/samples/framework/utils.h index a665139c0..85a6c9a1a 100644 --- a/samples/framework/utils.h +++ b/samples/framework/utils.h @@ -167,6 +167,14 @@ bool LoadSkeleton(const char* _filename, ozz::animation::Skeleton* _skeleton); bool LoadAnimation(const char* _filename, ozz::animation::Animation* _animation); +// Loads a raw animation from an ozz archive file named _filename. +// This function will fail and return false if the file cannot be opened or if +// it is not a valid ozz animation archive. A valid animation archive can be +// produced with ozz tools (fbx2ozz) or using ozz animation serialization API. +// _filename and _animation must be non-nullptr. +bool LoadRawAnimation(const char* _filename, + ozz::animation::offline::RawAnimation* _animation); + // Loads a float track from an ozz archive file named _filename. // This function will fail and return false if the file cannot be opened or if // it is not a valid ozz float track archive. A valid float track archive can be diff --git a/samples/optimize/sample_optimize.cc b/samples/optimize/sample_optimize.cc index 2bbd9b625..8e3822451 100644 --- a/samples/optimize/sample_optimize.cc +++ b/samples/optimize/sample_optimize.cc @@ -57,35 +57,6 @@ OZZ_OPTIONS_DECLARE_STRING(skeleton, "Path to the runtime skeleton file.", OZZ_OPTIONS_DECLARE_STRING(animation, "Path to the raw animation file.", "media/animation_raw.ozz", false) -namespace { - -// Loads a raw animation from a file. -bool LoadAnimation(const char* _filename, - ozz::animation::offline::RawAnimation* _animation) { - assert(_filename && _animation); - ozz::log::Out() << "Loading raw animation archive: " << _filename << "." - << std::endl; - ozz::io::File file(_filename, "rb"); - if (!file.opened()) { - ozz::log::Err() << "Failed to open animation file " << _filename << "." - << std::endl; - return false; - } - ozz::io::IArchive archive(&file); - if (!archive.TestTag()) { - ozz::log::Err() << "Failed to load raw animation instance from file " - << _filename << "." << std::endl; - return false; - } - - // Once the tag is validated, reading cannot fail. - archive >> *_animation; - - // Ensure animation is valid. - return _animation->Validate(); -} -} // namespace - class OptimizeSampleApplication : public ozz::sample::Application { public: OptimizeSampleApplication() @@ -285,7 +256,7 @@ class OptimizeSampleApplication : public ozz::sample::Application { // Imports offline animation from a binary file. // Invalid animations are rejected by the load function. - if (!LoadAnimation(OPTIONS_animation, &raw_animation_)) { + if (!ozz::sample::LoadRawAnimation(OPTIONS_animation, &raw_animation_)) { return false; } From e94f5378cdb81341ef4414ce999432cdaea7a95d Mon Sep 17 00:00:00 2001 From: guillaumeblanc Date: Wed, 29 Jun 2022 10:42:28 +0200 Subject: [PATCH 05/20] Exposes ozz cmake configuration variables to PARENT_SCOPE, so it can be used by an external project. --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 292cad11a..1dff4c0e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ cmake_minimum_required (VERSION 3.3) # Defines the project's name project(ozz) +# Check if project is top level or a sub project +get_directory_property(is_sub_project PARENT_DIRECTORY) + # Current version set(OZZ_VERSION_MAJOR 0) set(OZZ_VERSION_MINOR 14) @@ -27,6 +30,9 @@ 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).") set(ozz_build_msvc_rt_dll ON) endif() +if(is_sub_project) + set(ozz_build_msvc_rt_dll ${ozz_build_msvc_rt_dll} PARENT_SCOPE) +endif() # Include ozz cmake parameters and scripts include(CheckCXXCompilerFlag) @@ -63,12 +69,18 @@ else() # Disables fbx if tools are disabled set(ozz_build_fbx OFF) endif() +if(is_sub_project) + set(ozz_build_fbx ${ozz_build_fbx} PARENT_SCOPE) +endif() # gltf if(ozz_build_tools AND ozz_build_gltf) else() set(ozz_build_gltf OFF) endif() +if(is_sub_project) + set(ozz_build_gltf ${ozz_build_gltf} PARENT_SCOPE) +endif() # Enables unit tests. if(ozz_build_tests) @@ -115,7 +127,6 @@ if(ozz_build_tests AND NOT EMSCRIPTEN) add_subdirectory(test) endif() - install(FILES ${PROJECT_SOURCE_DIR}/CHANGES.md ${PROJECT_SOURCE_DIR}/LICENSE.md From e685a01e50367de4d381a09afc6d60414be6ecae Mon Sep 17 00:00:00 2001 From: Christophe Meyer Date: Wed, 17 Aug 2022 13:53:01 +0200 Subject: [PATCH 06/20] Fixes deprecated implicit copy warning. (#153) --- AUTHORS.md | 1 + include/ozz/base/span.h | 3 +++ test/base/containers/intrusive_list_tests.cc | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index cc59ee5da..f294ccfd9 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -14,3 +14,4 @@ The following authors have all licensed their contributions to ozz-animation und - Kota Iguchi - Mikołaj Siedlarek - Paul Gruenbacher +- Christophe Meyer diff --git a/include/ozz/base/span.h b/include/ozz/base/span.h index 24a545b2e..e5722ed89 100644 --- a/include/ozz/base/span.h +++ b/include/ozz/base/span.h @@ -61,6 +61,9 @@ struct span { // elements. span(_Ty* _begin, size_t _size) : data_(_begin), size_(_size) {} + // Copy constructor. + span(const span& _other) = default; + // Copy operator. void operator=(const span& _other) { data_ = _other.data_; diff --git a/test/base/containers/intrusive_list_tests.cc b/test/base/containers/intrusive_list_tests.cc index 6c47090d4..164c236b7 100644 --- a/test/base/containers/intrusive_list_tests.cc +++ b/test/base/containers/intrusive_list_tests.cc @@ -645,10 +645,9 @@ class is_to_be_removed { public: explicit is_to_be_removed(int _which) : which_(_which) {} bool operator()(typename _List::const_reference) { return which_-- == 0; } + void operator=(const is_to_be_removed&) = delete; private: - void operator=(const is_to_be_removed&); - int which_; }; From ebf92dc0b7c8a6e4332b623efb51b3a131964a65 Mon Sep 17 00:00:00 2001 From: guillaumeblanc Date: Wed, 21 Sep 2022 13:20:47 +0200 Subject: [PATCH 07/20] Updates to version 0.14.1 --- CHANGES.md | 14 ++++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index fcf2243b1..0e3fff3c1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,17 @@ +Release version 0.14.1 +---------------------- + +* Samples + - Allows reusing sample framework outside of sample directory. + - #154 Exposes swap interval + +* Library + - #153 Fixes deprecated implicit copy warning. + - #141 Removes non-ASCII characters in source codes. + +* Build pipeline + - Exposes ozz cmake configuration variables to PARENT_SCOPE, so it can be used/changed by an external project. + Release version 0.14.0 ---------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dff4c0e1..07d5bbd6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ get_directory_property(is_sub_project PARENT_DIRECTORY) # Current version set(OZZ_VERSION_MAJOR 0) set(OZZ_VERSION_MINOR 14) -set(OZZ_VERSION_PATCH 0) +set(OZZ_VERSION_PATCH 1) set(OZZ_VERSION ${OZZ_VERSION_MAJOR}.${OZZ_VERSION_MINOR}.${OZZ_VERSION_PATCH}) # Add project build options From 0f91829b6d48f21c8a3a33f5e5336102a2a6c259 Mon Sep 17 00:00:00 2001 From: guillaumeblanc Date: Thu, 29 Sep 2022 13:02:14 +0200 Subject: [PATCH 08/20] Removes unneeded file. --- samples/demo.zip | Bin 4884 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 samples/demo.zip diff --git a/samples/demo.zip b/samples/demo.zip deleted file mode 100644 index c5a37bd50135cca2e00f2b0d626e32b667d395df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4884 zcmZ{o1yodB*T;vHE=OmiTM6l*q?;KAhVBmO?nWs^KuVAt=|+(5MnW8V009B%5~M>v zAD`FndwkaWox9Hc-?P>}zkTmLYwfl69|6O{1_J&XoYs9RzaIW`!}+OJ)=n6xDV69^3;pxHU>FYVA3v-#1B5P+lq*D;M#dt^K1YD;C z%p77jvog{a*N^eJU4I_tJp;Gx3pv=ojQB7d#;Wb1WbrYO|Jw&kpKILm6r?&H;}buX zAfhyEax-Q!1WB5^z!`qzg#p37`YxdqbupqlC%mF7rt#~{f(_HS_uN>OX(ivXy+fto zonwu%iKZfn3%!`y@zJzE zu`SUFvCk%B{*W_*^z~{ILEVMeHc_1_sI-U}@vsAzVs^M*HkbeDnQE}aS!pWn>UU5N zO<{=oRdL-AXS6q-+;SIPGemQ^AYO|`JWtbOGQ$9WQar_(g2njq4 zjYVFm)>Ci|c^s|Y&0l%(YzQGm%TzzbgtyE7Hjofgol~b8MetRrPlnw! zek_IlO^usap@tTd$5CG!)rsWC$)<{%O$Ww%QV-gO93Gh78V4Kt*ec002F^f1LX_@d zfgM4Q<6h{m9O$ulVm*}mJfn5f^$y~?uJqc{;5LFdt5BPxuYyD6~b!LOnKDk2ldz ztcD;3x4zjISUK6&7WR2SMyUSc z$GpKc#-CMUU|OUvjR*jE%n1Pel)nqfU)6-m(z4B9$9Y8o_`PGiy(bxJsDxjueHCTI zEQ2O~7>1|RuxD>gd`ebWEj~%RF>b%qwlUIYX-S`-@zB7j(_{V7*)UPL- zeZwGOJ5lcW)qyPKw`eGrMYm=Ru*3@EO(JK3k=NWF6<6wP>sm~4P|_h!zJBjIL+p*W zolBh3YACi?3VzPx=;S^OShNwJyGU9B!~t_+`{!Z$)81{~Wg(dIcJR~d zuM20A2|hYP?vXPrL)MmOb)tsfG_RJI`9S+Or$HCr;ow1r<0eV|tEeoI4UW^40k1obg_OkyKEAH&;Loa{YV z9pAMBNIrg7Jn2BTgR_PiS0rtY4v(jdVpVM&=9^p3B?o>UfTBVVU?_S`jHbqA-{UFt za2p6Mi9OL%+UJPcA=6tUw@Dpm!QuGu`tT0nXSnmglN*Xj-W0MJ>edble0J?>hn|RR0dogAG9P%+*28xvbx^++!~^4zrYq)2^qZV+O-H2XOiOGinHlRIy4-oxls+i z_hK|7|Hu4PzGPP7VJ{;IS5@Rw2~J{#w&jxxv*WnTuG29vbQWL_Hv8EBeuk0cQnR;p zSIr;vwK_l$Ok&dkS~=V^6O^HK2~$or^1A;{`oJHZ^|EYdaLRY?mfI*shyb`P3()f2 zIz+$$BfwYTvZMPJU)v^0l!Jj!m2}m!#8#p9%OE~qA6_QV>arglZT5*YdVlt9yh=)Q zo4JqcEc3>~@P14C90V6w20?7NcXVv75)hywLfU4{#4vHfhHVAI;^C+ezG3o3(!v|o zEmd4i0d47>LGXFln%e<*naq4r*LR46Wdq~cWuW-p2Fjsb;=m`W(~QXGFQ`Xr>Y73Zga($Y~%PEaWU_MXpyhU0;0Jmyod5S zdm5w~V^k1oG83vG#%JCM?Cpz;K&^eV4~z+7^>)#5Xx4na5_`uVI<|N5W6^C&&hwr) z&WBE|j)lwQDnau)(n!xHFJ5!u%W5l*E`=zXD>P~~L({jkxx$V6&9ja#Xq4@XhwR3@ zIo!fMTM?a170x>+WruVjzN;MN9GVBMOH?xOuZ8^O1zuF_A7-k&nO*h>uFYE-7G$=~ z=8bTVSyN(l_VDwgaWb1-aq%{#2`LN9%_m!SWnv)GH+)daw~y`ajpYJ!-jsHsb2;RO zVYbogXGCk`hO`5nfQFzrDz^~%hmzsTuQO#Wyp07D;%E^;Vy0fArQfSnicp*E`V^g8u84&8l04{UW(n zw4Z23ZAWmDnzTSzs{*{%_H-S`(Hra)9bmIU;e#}ny(f|}r}ogeq89RPv00&KHF43o z&hc)t(+5r@=eQkPmh|VbcTVQhR*B1r`Y08x4dug;+?woyjNI>;MP)A~rePwYyzre+ z-}(@Jx8rt!Z$Y?hAuHh9oXq*zM;)*4D`Uf!Xx2Pk7CVzHnIdN}8Hrer_8JnpAa=<^ z?$wg_D;jt* z#+gX=oxD4}Lt>MPzMz)Mh^7ySGd;$g{(*|@P(PxJ9LMqkHrnH$k3}V7(~+W6-P{+% z#jJIh&8_Cxt$y!Fk~l&wbukB~KAIWS>S1ZNSS9f{5)x!~MX${;3rFC{ZSIiJtglb* zI7S$`=*)@2r80!Z$=V`d#n^r*5+N}6e`%pJf6YpLO!2lRO@*^*J;8P{3R zXFBCRH`Z(kEo9gwlL(5lsnmNUL$=kIBZ1Ed(zIzG?$`7LY2|9rL@n+%8|>?!jk+p1 z#j}Z`6%ve&m+g6H!rtMAKJZ+$D7!ga9#Du**Wa7xIe~zl8-j z-k_;vbVl=tpOvtB|@cN9?q9*JU#en%<8I25T(9)@Gjxi8J4fntjJQ&1KjfjizQ% zi^WZ;d0BPeBp;1ruTcueRs#XwjdY_C@GHEqtv&86p?YF_Q+H91X)N0LqO449+E=c+ zQ(MPL*tsX?X_HcRV(SZsowSx%UE}9eO@+)QdlCcFcMMVYpZ-|hH{Elttv`_2FCh}8 zdH){am$#h{_15X>B~eskmY+d1mAm@fyBKt?YDH6X>B-*A*YZ_Y47~V6W_fqaaWQ!f z_hVtKO(gB7Of`cT@vLmiAE1vj+Xk;r`4>#xzh~nLMF2;s)`MS-yz6_yQka3h%_QRH zb^3MEIURK#NdvlkuZ4Q;q*ip|PVPYMWCc4}rp=U#O?V#V8bIA$B^;}i9t_VVZ;@Q| zzCR}G&+@@p`FK#wSUsnL>Z$GYbE^;sbY=5sz&B50u(kxD_>AL&-U@bP^5n6T7W}?q zb$$213PzW7*M>_6gu#VhK^|mu*4@!OOm0kN`5B;$=@FDP=`U~;+&@sKQO#-k97ETn zSp8f0*u1@4sR@l%QRJg8tXBHYs;a(K5am4r36aO^SY;X4fEsr7_n}hq9OVa?W9BE= z>JSUcN30LdgXAu9t;o8V8d;VTZY_}kU5Kto?fboyQxzpm8b;nw%-a8 z=v(Q27~`+avgz3`HA5K2L>{~ljm3~8bbGiQR~(yH9R_-G&I}5^QP3UXttalN^~;aDjfC$)T$C5DMiNf^6nIO8l{zRsys(^^@pj7xV| zUCLwpY_S6~s3UyJN99yYo4V%>f7tSy_BZ`>WM>stvL74zunU#Xqh}1k>eW2jI#d2Z zNRv)%av*C?9bcdfNyn0h+#^@_#;X-lmezR10JeAtRZ31bX(;+0LE2r&Ey>Vvk3bVd zV`8LuBSyp$h4C|Bnm(9GXJViGttrbj$@7w%?X{u1!n#*R;&uu5zVG6GSASv})LoKR zTor#@USqY)u6Oyw4I<*X`^OZQE(0v?lxRBM_Nm4?FTDlKrs9C&Xs#3b|1nF2|TE~i;( zX)RK2YnzpDiYPUv?iPat8(2@>G_mYr`stF;}${5-L?e; zM!k?ou*Q>EgWwnvZ~ZbWjc=j}Ck*G5i(hI<%_(~PZV)gGOi951=fW`mO#as(`&<5Q zr3e7@zm^yPFyImk($RE1f$>|RI{d%Z|A+l=&dqP^UmT{N^Ox20r;qc`B-@_^enIEz z{?vab`Lpr+XA))XKij~6(tp4DzxChrKM&=fbVBm~(Es;{{u}@ISNv843 Date: Tue, 22 Nov 2022 22:35:19 +0100 Subject: [PATCH 09/20] Moves documentation files to a specific folder. --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 292cad11a..a77a89638 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,9 +115,8 @@ if(ozz_build_tests AND NOT EMSCRIPTEN) add_subdirectory(test) endif() - install(FILES ${PROJECT_SOURCE_DIR}/CHANGES.md ${PROJECT_SOURCE_DIR}/LICENSE.md ${PROJECT_SOURCE_DIR}/README.md - DESTINATION ./) + DESTINATION "share/doc/ozz-animation/") From 418a9510dd78d9b6cfa9bc7ff329dc6f6c4a3e56 Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Thu, 4 May 2023 09:50:34 +0200 Subject: [PATCH 10/20] Include the C++ standard library in the requirements. (#166) The README menitoned only the C runtime. However, in Unix systems, you can link C++ binaries to libc without linking a C++ standard library, but this does not work for ozz. So, this commit makes it more clear that a standard C++ library is required, too. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98ef549d5..8d0a8a468 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Documentation and samples are available from [ozz-animation website](http://guil 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. From 67fc7ee25878bdfb01f1d16439a8a58bcaf57b18 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 09:13:21 +0200 Subject: [PATCH 11/20] Transitions away from sprintf to the more secure snprintf. --- CHANGES.md | 6 ++ extern/jsoncpp/dist/jsoncpp.cpp | 2 +- samples/additive/sample_additive.cc | 6 +- samples/attach/sample_attach.cc | 10 +-- samples/blend/sample_blend.cc | 6 +- samples/foot_ik/sample_foot_ik.cc | 30 ++++---- samples/framework/application.cc | 46 ++++++------ samples/framework/application.h | 2 +- samples/framework/internal/imgui_impl.cc | 2 +- samples/framework/internal/shooter.cc | 10 +-- samples/framework/utils.cc | 43 ++++++------ samples/look_at/sample_look_at.cc | 44 ++++++------ samples/millipede/sample_millipede.cc | 20 +++--- samples/multithread/sample_multithread.cc | 8 +-- samples/optimize/sample_optimize.cc | 52 +++++++------- samples/partial_blend/sample_partial_blend.cc | 14 ++-- samples/skinning/sample_skinning.cc | 8 +-- samples/two_bone_ik/sample_two_bone_ik.cc | 70 +++++++++---------- 18 files changed, 192 insertions(+), 187 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0e3fff3c1..52ac1e328 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +Release version next +-------------------- + +* Library + - Transitions away from sprintf to the more secure snprintf. + Release version 0.14.1 ---------------------- diff --git a/extern/jsoncpp/dist/jsoncpp.cpp b/extern/jsoncpp/dist/jsoncpp.cpp index d72096753..bb85e0f78 100644 --- a/extern/jsoncpp/dist/jsoncpp.cpp +++ b/extern/jsoncpp/dist/jsoncpp.cpp @@ -3887,7 +3887,7 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec int len = -1; char formatString[6]; - sprintf(formatString, "%%.%dg", precision); + snprintf(formatString, sizeof(formatString), "%%.%dg", precision); // Print into the buffer. We need not request the alternative representation // that always has a decimal point because JSON doesn't distingish the diff --git a/samples/additive/sample_additive.cc b/samples/additive/sample_additive.cc index 2a646e1e3..d033bbc1c 100644 --- a/samples/additive/sample_additive.cc +++ b/samples/additive/sample_additive.cc @@ -250,7 +250,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application { ozz::sample::ImGui::OpenClose oc(_im_gui, "Blending parameters", &open); if (open) { _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->DoLabel("Additive layer:"); @@ -259,8 +259,8 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application { std::memcpy(weights.data(), additive_weigths_, sizeof(additive_weigths_)); - std::sprintf(label, "Weights\nCurl: %.2f\nSplay: %.2f", - additive_weigths_[kCurl], additive_weigths_[kSplay]); + std::snprintf(label, sizeof(label), "Weights\nCurl: %.2f\nSplay: %.2f", + additive_weigths_[kCurl], additive_weigths_[kSplay]); if (_im_gui->DoSlider2D(label, {{0.f, 0.f}}, {{1.f, 1.f}}, &weights)) { auto_animate_weights_ = false; // User interacted. std::memcpy(additive_weigths_, weights.data(), diff --git a/samples/attach/sample_attach.cc b/samples/attach/sample_attach.cc index 7cba010aa..d425f6273 100644 --- a/samples/attach/sample_attach.cc +++ b/samples/attach/sample_attach.cc @@ -161,16 +161,16 @@ class AttachSampleApplication : public ozz::sample::Application { if (open && skeleton_.num_joints() != 0) { _im_gui->DoLabel("Select joint:"); char label[64]; - std::sprintf(label, "%s (%d)", skeleton_.joint_names()[attachment_], - attachment_); + std::snprintf(label, sizeof(label), "%s (%d)", + skeleton_.joint_names()[attachment_], attachment_); _im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &attachment_); _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); - 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); - 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); } } diff --git a/samples/blend/sample_blend.cc b/samples/blend/sample_blend.cc index 0bda29604..e76be99de 100644 --- a/samples/blend/sample_blend.cc +++ b/samples/blend/sample_blend.cc @@ -242,16 +242,16 @@ class BlendSampleApplication : public ozz::sample::Application { } 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_); for (int i = 0; i < kNumLayers; ++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_); } - std::sprintf(label, "Threshold: %.2f", threshold_); + std::snprintf(label, sizeof(label), "Threshold: %.2f", threshold_); _im_gui->DoSlider(label, .01f, 1.f, &threshold_); } } diff --git a/samples/foot_ik/sample_foot_ik.cc b/samples/foot_ik/sample_foot_ik.cc index d0b0278d4..ddfdf39a5 100644 --- a/samples/foot_ik/sample_foot_ik.cc +++ b/samples/foot_ik/sample_foot_ik.cc @@ -608,7 +608,7 @@ class FootIKSampleApplication : public ozz::sample::Application { virtual void OnDestroy() {} virtual bool OnGui(ozz::sample::ImGui* _im_gui) { - char txt[32]; + char label[32]; // Main options { @@ -636,12 +636,12 @@ class FootIKSampleApplication : public ozz::sample::Application { static bool opened = true; ozz::sample::ImGui::OpenClose oc(_im_gui, "IK settings", &opened); if (opened) { - sprintf(txt, "Foot height %.2g", foot_heigh_); - _im_gui->DoSlider(txt, 0.f, .3f, &foot_heigh_); - sprintf(txt, "Weight %.2g", weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &weight_); - sprintf(txt, "Soften %.2g", soften_); - _im_gui->DoSlider(txt, 0.f, 1.f, &soften_, 1.f, two_bone_ik_); + snprintf(label, sizeof(label), "Foot height %.2g", foot_heigh_); + _im_gui->DoSlider(label, 0.f, .3f, &foot_heigh_); + snprintf(label, sizeof(label), "Weight %.2g", weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &weight_); + snprintf(label, sizeof(label), "Soften %.2g", soften_); + _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; // Translation _im_gui->DoLabel("Translation"); - sprintf(txt, "x %.2g", root_translation_.x); - moved |= _im_gui->DoSlider(txt, -10.f, 10.f, &root_translation_.x); - sprintf(txt, "y %.2g", root_translation_.y); - moved |= _im_gui->DoSlider(txt, 0.f, 5.f, &root_translation_.y, 1.f, + snprintf(label, sizeof(label), "x %.2g", root_translation_.x); + moved |= _im_gui->DoSlider(label, -10.f, 10.f, &root_translation_.x); + snprintf(label, sizeof(label), "y %.2g", root_translation_.y); + moved |= _im_gui->DoSlider(label, 0.f, 5.f, &root_translation_.y, 1.f, !auto_character_height_); - sprintf(txt, "z %.2g", root_translation_.z); - moved |= _im_gui->DoSlider(txt, -10.f, 10.f, &root_translation_.z); + snprintf(label, sizeof(label), "z %.2g", root_translation_.z); + moved |= _im_gui->DoSlider(label, -10.f, 10.f, &root_translation_.z); // Rotation (in euler form) _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 |= - _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 // case, because UI is updated after "game" update, we need to recompute diff --git a/samples/framework/application.cc b/samples/framework/application.cc index ede6c403c..a5c155a0d 100644 --- a/samples/framework/application.cc +++ b/samples/framework/application.cc @@ -528,31 +528,32 @@ bool Application::Gui() { } bool Application::FrameworkGui() { + char label[64]; // Downcast to public imgui. ImGui* im_gui = im_gui_.get(); { // Render statistics static bool open = true; ImGui::OpenClose stat_oc(im_gui, "Statistics", &open); if (open) { - char szLabel[64]; { // FPS Record::Statistics statistics = fps_->GetStatistics(); - std::sprintf(szLabel, "FPS: %.0f", - statistics.mean == 0.f ? 0.f : 1000.f / statistics.mean); + std::snprintf(label, sizeof(label), "FPS: %.0f", + statistics.mean == 0.f ? 0.f : 1000.f / statistics.mean); static bool fps_open = false; - ImGui::OpenClose stats(im_gui, szLabel, &fps_open); + ImGui::OpenClose stats(im_gui, label, &fps_open); if (fps_open) { - std::sprintf(szLabel, "Frame: %.2f ms", statistics.mean); - im_gui->DoGraph(szLabel, 0.f, statistics.max, statistics.latest, + std::snprintf(label, sizeof(label), "Frame: %.2f ms", + statistics.mean); + im_gui->DoGraph(label, 0.f, statistics.max, statistics.latest, fps_->cursor(), fps_->record_begin(), fps_->record_end()); } } { // Update time 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. - ImGui::OpenClose stats(im_gui, szLabel, &update_open); + ImGui::OpenClose stats(im_gui, label, &update_open); if (update_open) { im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest, update_time_->cursor(), update_time_->record_begin(), @@ -561,9 +562,9 @@ bool Application::FrameworkGui() { } { // Render time 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; - ImGui::OpenClose stats(im_gui, szLabel, &render_open); + ImGui::OpenClose stats(im_gui, label, &render_open); if (render_open) { im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest, render_time_->cursor(), render_time_->record_begin(), @@ -580,18 +581,15 @@ bool Application::FrameworkGui() { im_gui->DoButton("Freeze", true, &freeze_); im_gui->DoCheckBox("Fix update rate", &fix_update_rate, true); if (!fix_update_rate) { - char sz_factor[64]; - std::sprintf(sz_factor, "Time factor: %.2f", time_factor_); - im_gui->DoSlider(sz_factor, -5.f, 5.f, &time_factor_); + std::snprintf(label, sizeof(label), "Time factor: %.2f", time_factor_); + im_gui->DoSlider(label, -5.f, 5.f, &time_factor_); if (im_gui->DoButton("Reset time factor", time_factor_ != 1.f)) { time_factor_ = 1.f; } } else { - char sz_fixed_update_rate[64]; - std::sprintf(sz_fixed_update_rate, "Update rate: %.0f fps", - fixed_update_rate); - im_gui->DoSlider(sz_fixed_update_rate, 1.f, 200.f, &fixed_update_rate, - .5f, true); + std::snprintf(label, sizeof(label), "Update rate: %.0f fps", + fixed_update_rate); + im_gui->DoSlider(label, 1.f, 200.f, &fixed_update_rate, .5f, true); if (im_gui->DoButton("Reset update rate", fixed_update_rate != 60.f)) { fixed_update_rate = 60.f; } @@ -615,10 +613,9 @@ bool Application::FrameworkGui() { } // Vertical sync & swap interval bool changed = im_gui->DoCheckBox("Vertical sync", &vertical_sync_); - char szLabel[64]; - std::sprintf(szLabel, "Swap interval: %d", swap_interval_); + std::snprintf(label, sizeof(label), "Swap interval: %d", swap_interval_); 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) { glfwSwapInterval(vertical_sync_ ? swap_interval_ : 0); } @@ -640,10 +637,9 @@ bool Application::FrameworkGui() { } } - char szResolution[64]; - std::sprintf(szResolution, "Resolution: %dx%d", resolution_.width, - resolution_.height); - if (im_gui->DoSlider(szResolution, 0, kNumPresets - 1, &preset_lookup)) { + std::snprintf(label, sizeof(label), "Resolution: %dx%d", resolution_.width, + resolution_.height); + if (im_gui->DoSlider(label, 0, kNumPresets - 1, &preset_lookup)) { // Resolution changed. resolution_ = resolution_presets[preset_lookup]; glfwSetWindowSize(resolution_.width, resolution_.height); diff --git a/samples/framework/application.h b/samples/framework/application.h index c91ecfeb5..7a17519bf 100644 --- a/samples/framework/application.h +++ b/samples/framework/application.h @@ -149,7 +149,7 @@ class Application { enum LoopStatus { kContinue, // Can continue with next loop. 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); diff --git a/samples/framework/internal/imgui_impl.cc b/samples/framework/internal/imgui_impl.cc index e47e6d075..bb5e236ad 100644 --- a/samples/framework/internal/imgui_impl.cc +++ b/samples/framework/internal/imgui_impl.cc @@ -100,7 +100,7 @@ bool FormatFloat(float _value, char* _string, const char* _string_end) { if (!_string || _string_end - _string < 8 + precision + 1) { return false; } - std::sprintf(_string, "%.2g\n", _value); + std::snprintf(_string, _string_end - _string, "%.2g\n", _value); // Removes unnecessary '0' digits in the exponent. char* exponent = strchr(_string, 'e'); diff --git a/samples/framework/internal/shooter.cc b/samples/framework/internal/shooter.cc index 80492aaa7..d441f961e 100644 --- a/samples/framework/internal/shooter.cc +++ b/samples/framework/internal/shooter.cc @@ -160,12 +160,12 @@ bool Shooter::Process() { GL(BindBuffer(GL_PIXEL_PACK_BUFFER, shot.pbo)); const void* pixels = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); if (pixels) { - char name[16]; - sprintf(name, "%06d.tga", shot_number_++); + char filename[16]; + std::snprintf(filename, sizeof(filename), "%06d.tga", shot_number_++); - ozz::sample::image::WriteTGA(name, shot.width, shot.height, image_format_, - reinterpret_cast(pixels), - false); + ozz::sample::image::WriteTGA( + filename, shot.width, shot.height, image_format_, + reinterpret_cast(pixels), false); GL(UnmapBuffer(GL_PIXEL_PACK_BUFFER)); } GL(BindBuffer(GL_PIXEL_PACK_BUFFER, 0)); diff --git a/samples/framework/utils.cc b/samples/framework/utils.cc index 85fca3983..f72740191 100644 --- a/samples/framework/utils.cc +++ b/samples/framework/utils.cc @@ -110,21 +110,22 @@ bool PlaybackController::OnGui(const animation::Animation& _animation, _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 // changes. Otherwise previous time would be incorrect. float ratio = time_ratio(); - std::sprintf(szLabel, "Animation time: %.2f", ratio * _animation.duration()); - if (_im_gui->DoSlider(szLabel, 0.f, 1.f, &ratio, 1.f, + std::snprintf(label, sizeof(label), "Animation time: %.2f", + ratio * _animation.duration()); + if (_im_gui->DoSlider(label, 0.f, 1.f, &ratio, 1.f, _enabled && _allow_set_time)) { set_time_ratio(ratio); // Pause the time if slider as moved. play_ = false; time_changed = true; } - std::sprintf(szLabel, "Playback speed: %.2f", playback_speed_); - _im_gui->DoSlider(szLabel, -5.f, 5.f, &playback_speed_, 1.f, _enabled); + std::snprintf(label, sizeof(label), "Playback speed: %.2f", playback_speed_); + _im_gui->DoSlider(label, -5.f, 5.f, &playback_speed_, 1.f, _enabled); // Allow to reset speed if it is not the default value. if (_im_gui->DoButton("Reset playback speed", @@ -139,7 +140,7 @@ bool OnRawSkeletonJointGui( ozz::sample::ImGui* _im_gui, ozz::animation::offline::RawSkeleton::Joint::Children* _children, ozz::vector::iterator* _oc_state) { - char txt[255]; + char label[255]; bool modified = false; for (size_t i = 0; i < _children->size(); ++i) { @@ -152,23 +153,23 @@ bool OnRawSkeletonJointGui( // Translation ozz::math::Float3& translation = joint.transform.translation; _im_gui->DoLabel("Translation"); - sprintf(txt, "x %.2g", translation.x); - modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.x); - sprintf(txt, "y %.2g", translation.y); - modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.y); - sprintf(txt, "z %.2g", translation.z); - modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.z); + snprintf(label, sizeof(label), "x %.2g", translation.x); + modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.x); + snprintf(label, sizeof(label), "y %.2g", translation.y); + modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.y); + snprintf(label, sizeof(label), "z %.2g", translation.z); + modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.z); // Rotation (in euler form) ozz::math::Quaternion& rotation = joint.transform.rotation; _im_gui->DoLabel("Rotation"); ozz::math::Float3 euler = ToEuler(rotation) * ozz::math::kRadianToDegree; - sprintf(txt, "x %.3g", euler.x); - bool euler_modified = _im_gui->DoSlider(txt, -180.f, 180.f, &euler.x); - sprintf(txt, "y %.3g", euler.y); - euler_modified |= _im_gui->DoSlider(txt, -180.f, 180.f, &euler.y); - sprintf(txt, "z %.3g", euler.z); - euler_modified |= _im_gui->DoSlider(txt, -180.f, 180.f, &euler.z); + snprintf(label, sizeof(label), "x %.3g", euler.x); + bool euler_modified = _im_gui->DoSlider(label, -180.f, 180.f, &euler.x); + snprintf(label, sizeof(label), "y %.3g", euler.y); + euler_modified |= _im_gui->DoSlider(label, -180.f, 180.f, &euler.y); + snprintf(label, sizeof(label), "z %.3g", euler.z); + euler_modified |= _im_gui->DoSlider(label, -180.f, 180.f, &euler.z); if (euler_modified) { modified = true; ozz::math::Float3 euler_rad = euler * ozz::math::kDegreeToRadian; @@ -179,8 +180,8 @@ bool OnRawSkeletonJointGui( // Scale (must be uniform and not 0) _im_gui->DoLabel("Scale"); ozz::math::Float3& scale = joint.transform.scale; - sprintf(txt, "%.2g", scale.x); - if (_im_gui->DoSlider(txt, -1.f, 1.f, &scale.x)) { + snprintf(label, sizeof(label), "%.2g", scale.x); + if (_im_gui->DoSlider(label, -1.f, 1.f, &scale.x)) { modified = true; 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, - ozz::animation::offline::RawAnimation* _animation) { + ozz::animation::offline::RawAnimation* _animation) { assert(_filename && _animation); ozz::log::Out() << "Loading raw animation archive: " << _filename << "." << std::endl; diff --git a/samples/look_at/sample_look_at.cc b/samples/look_at/sample_look_at.cc index 486753407..f1d2ab7e7 100644 --- a/samples/look_at/sample_look_at.cc +++ b/samples/look_at/sample_look_at.cc @@ -387,15 +387,15 @@ class LookAtSampleApplication : public ozz::sample::Application { virtual void OnDestroy() {} virtual bool OnGui(ozz::sample::ImGui* _im_gui) { - char txt[64]; + char label[64]; _im_gui->DoCheckBox("Enable ik", &enable_ik_); - sprintf(txt, "IK chain length: %d", chain_length_); - _im_gui->DoSlider(txt, 0, kMaxChainLength, &chain_length_); - sprintf(txt, "Joint weight %.2g", joint_weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &joint_weight_); - sprintf(txt, "Chain weight %.2g", chain_weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &chain_weight_); + snprintf(label, sizeof(label), "IK chain length: %d", chain_length_); + _im_gui->DoSlider(label, 0, kMaxChainLength, &chain_length_); + snprintf(label, sizeof(label), "Joint weight %.2g", joint_weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &joint_weight_); + snprintf(label, sizeof(label), "Chain weight %.2g", chain_weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &chain_weight_); // Exposes animation runtime playback controls. { @@ -413,15 +413,15 @@ class LookAtSampleApplication : public ozz::sample::Application { const float kTargetRange = 3.f; _im_gui->DoLabel("Animated extent"); - sprintf(txt, "%.2g", target_extent_); - _im_gui->DoSlider(txt, 0.f, kTargetRange, &target_extent_); - - sprintf(txt, "x %.2g", target_offset_.x); - _im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.x); - sprintf(txt, "y %.2g", target_offset_.y); - _im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.y); - sprintf(txt, "z %.2g", target_offset_.z); - _im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.z); + snprintf(label, sizeof(label), "%.2g", target_extent_); + _im_gui->DoSlider(label, 0.f, kTargetRange, &target_extent_); + + snprintf(label, sizeof(label), "x %.2g", target_offset_.x); + _im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.x); + snprintf(label, sizeof(label), "y %.2g", target_offset_.y); + _im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.y); + snprintf(label, sizeof(label), "z %.2g", 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); if (opened) { const float kOffsetRange = .5f; - sprintf(txt, "x %.2g", eyes_offset_.x); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.x); - sprintf(txt, "y %.2g", eyes_offset_.y); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.y); - sprintf(txt, "z %.2g", eyes_offset_.z); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.z); + snprintf(label, sizeof(label), "x %.2g", eyes_offset_.x); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.x); + snprintf(label, sizeof(label), "y %.2g", eyes_offset_.y); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.y); + snprintf(label, sizeof(label), "z %.2g", eyes_offset_.z); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.z); } } diff --git a/samples/millipede/sample_millipede.cc b/samples/millipede/sample_millipede.cc index d1f612329..7a23d542d 100644 --- a/samples/millipede/sample_millipede.cc +++ b/samples/millipede/sample_millipede.cc @@ -152,7 +152,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { // Rebuilds all if the number of joints has changed. int joints = skeleton_->num_joints(); 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 // the lowest values. @@ -219,17 +219,17 @@ class MillipedeSampleApplication : public ozz::sample::Application { root->transform.rotation = Quaternion::identity(); root->transform.scale = Float3::one(); - char buf[16]; + char number[16]; for (int i = 0; i < slice_count_; ++i) { // Format joint number. - std::sprintf(buf, "%d", i); + std::snprintf(number, sizeof(number), "%d", i); root->children.resize(3); // Left leg. RawSkeleton::Joint& lu = root->children[0]; lu.name = "lu"; - lu.name += buf; + lu.name += number; lu.transform.translation = kTransUp; lu.transform.rotation = kRotLeftUp; lu.transform.scale = Float3::one(); @@ -237,7 +237,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { lu.children.resize(1); RawSkeleton::Joint& ld = lu.children[0]; ld.name = "ld"; - ld.name += buf; + ld.name += number; ld.transform.translation = kTransDown; ld.transform.rotation = kRotLeftDown; ld.transform.scale = Float3::one(); @@ -245,7 +245,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { ld.children.resize(1); RawSkeleton::Joint& lf = ld.children[0]; lf.name = "lf"; - lf.name += buf; + lf.name += number; lf.transform.translation = Float3::x_axis(); lf.transform.rotation = Quaternion::identity(); lf.transform.scale = Float3::one(); @@ -253,7 +253,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { // Right leg. RawSkeleton::Joint& ru = root->children[1]; ru.name = "ru"; - ru.name += buf; + ru.name += number; ru.transform.translation = kTransUp; ru.transform.rotation = kRotRightUp; ru.transform.scale = Float3::one(); @@ -261,7 +261,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { ru.children.resize(1); RawSkeleton::Joint& rd = ru.children[0]; rd.name = "rd"; - rd.name += buf; + rd.name += number; rd.transform.translation = kTransDown; rd.transform.rotation = kRotRightDown; rd.transform.scale = Float3::one(); @@ -269,7 +269,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { rd.children.resize(1); RawSkeleton::Joint& rf = rd.children[0]; rf.name = "rf"; - rf.name += buf; + rf.name += number; rf.transform.translation = Float3::x_axis(); rf.transform.rotation = Quaternion::identity(); rf.transform.scale = Float3::one(); @@ -277,7 +277,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { // Spine. RawSkeleton::Joint& sp = root->children[2]; sp.name = "sp"; - sp.name += buf; + sp.name += number; sp.transform.translation = Float3(0.f, 0.f, kSpinLength); sp.transform.rotation = Quaternion::identity(); sp.transform.scale = Float3::one(); diff --git a/samples/multithread/sample_multithread.cc b/samples/multithread/sample_multithread.cc index d59d17408..ec765625f 100644 --- a/samples/multithread/sample_multithread.cc +++ b/samples/multithread/sample_multithread.cc @@ -287,10 +287,10 @@ class MultithreadSampleApplication : public ozz::sample::Application { ozz::sample::ImGui::OpenClose oc(_im_gui, "Sample control", &oc_open); if (oc_open) { 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); 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); } } @@ -303,11 +303,11 @@ class MultithreadSampleApplication : public ozz::sample::Application { has_threading_support_); if (enable_theading_) { 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_, .2f); 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()); _im_gui->DoLabel(label); } diff --git a/samples/optimize/sample_optimize.cc b/samples/optimize/sample_optimize.cc index 8e3822451..7402e0e27 100644 --- a/samples/optimize/sample_optimize.cc +++ b/samples/optimize/sample_optimize.cc @@ -312,29 +312,32 @@ class OptimizeSampleApplication : public ozz::sample::Application { 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, 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, optimize_); rebuild |= _im_gui->DoCheckBox("Enable joint setting", &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 |= _im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &joint_, 1.f, joint_setting_enable_ && optimize_); - std::sprintf(label, "Tolerance: %0.2f mm", - joint_setting_.tolerance * 1000); + std::snprintf(label, sizeof(label), "Tolerance: %0.2f mm", + joint_setting_.tolerance * 1000); rebuild |= _im_gui->DoSlider(label, 0.f, .1f, &joint_setting_.tolerance, .5f, joint_setting_enable_ && optimize_); - std::sprintf(label, "Distance: %0.2f mm", - joint_setting_.distance * 1000); + std::snprintf(label, sizeof(label), "Distance: %0.2f mm", + joint_setting_.distance * 1000); rebuild |= _im_gui->DoSlider(label, 0.f, 1.f, &joint_setting_.distance, .5f, joint_setting_enable_ && optimize_); @@ -356,18 +359,18 @@ class OptimizeSampleApplication : public ozz::sample::Application { static bool open = true; ozz::sample::ImGui::OpenClose ocb(_im_gui, "Memory size", &open); if (open) { - std::sprintf(label, "Original: %dKB", - static_cast(raw_animation_.size() >> 10)); + std::snprintf(label, sizeof(label), "Original: %dKB", + static_cast(raw_animation_.size() >> 10)); _im_gui->DoLabel(label); - std::sprintf(label, "Optimized: %dKB (%.1f:1)", - static_cast(raw_optimized_animation_.size() >> 10), - static_cast(raw_animation_.size()) / - raw_optimized_animation_.size()); + std::snprintf(label, sizeof(label), "Optimized: %dKB (%.1f:1)", + static_cast(raw_optimized_animation_.size() >> 10), + static_cast(raw_animation_.size()) / + raw_optimized_animation_.size()); _im_gui->DoLabel(label); - std::sprintf( - label, "Compressed: %dKB (%.1f:1)", + std::snprintf( + label, sizeof(label), "Compressed: %dKB (%.1f:1)", static_cast(animation_rt_->size() >> 10), static_cast(raw_animation_.size()) / animation_rt_->size()); _im_gui->DoLabel(label); @@ -388,37 +391,36 @@ class OptimizeSampleApplication : public ozz::sample::Application { // Show absolute error. { - char szLabel[64]; static bool error_open = true; ozz::sample::ImGui::OpenClose oc_stats(_im_gui, "Absolute error", &error_open); if (error_open) { { - std::sprintf(szLabel, "Median error: %.2fmm", - *error_record_med_.cursor()); + std::snprintf(label, sizeof(label), "Median error: %.2fmm", + *error_record_med_.cursor()); const ozz::sample::Record::Statistics error_stats = 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_.record_begin(), error_record_med_.record_end()); } { - std::sprintf(szLabel, "Maximum error: %.2fmm", - *error_record_max_.cursor()); + std::snprintf(label, sizeof(label), "Maximum error: %.2fmm", + *error_record_max_.cursor()); const ozz::sample::Record::Statistics error_stats = 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_.record_begin(), error_record_max_.record_end()); } { - std::sprintf(szLabel, "Joint %d error: %.2fmm", joint_, - *joint_error_record_.cursor()); + std::snprintf(label, sizeof(label), "Joint %d error: %.2fmm", joint_, + *joint_error_record_.cursor()); const ozz::sample::Record::Statistics error_stats = 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_.record_begin(), joint_error_record_.record_end()); diff --git a/samples/partial_blend/sample_partial_blend.cc b/samples/partial_blend/sample_partial_blend.cc index 03adbe254..abda62d78 100644 --- a/samples/partial_blend/sample_partial_blend.cc +++ b/samples/partial_blend/sample_partial_blend.cc @@ -251,7 +251,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application { _im_gui->DoCheckBox("Use automatic blending settings", &automatic); 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); Sampler& lower_body_sampler = samplers_[kLowerBody]; @@ -267,27 +267,27 @@ class PartialBlendSampleApplication : public ozz::sample::Application { _im_gui->DoLabel("Manual settings:"); _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); _im_gui->DoSlider(label, 0.f, 1.f, &lower_body_sampler.weight_setting, 1.f, !automatic); - std::sprintf(label, "Joints weight: %.2f", + std::snprintf(label, sizeof(label), "Joints weight: %.2f", lower_body_sampler.joint_weight_setting); _im_gui->DoSlider(label, 0.f, 1.f, &lower_body_sampler.joint_weight_setting, 1.f, !automatic); _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); _im_gui->DoSlider(label, 0.f, 1.f, &upper_body_sampler.weight_setting, 1.f, !automatic); - std::sprintf(label, "Joints weight: %.2f", + std::snprintf(label, sizeof(label), "Joints weight: %.2f", upper_body_sampler.joint_weight_setting); _im_gui->DoSlider(label, 0.f, 1.f, &upper_body_sampler.joint_weight_setting, 1.f, !automatic); _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_); SetupPerJointWeights(); @@ -301,7 +301,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application { _im_gui->DoLabel("Root of the upper body hierarchy:", ozz::sample::ImGui::kLeft, false); char label[64]; - std::sprintf(label, "%s (%d)", + std::snprintf(label, sizeof(label), "%s (%d)", skeleton_.joint_names()[upper_body_root_], upper_body_root_); if (_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, diff --git a/samples/skinning/sample_skinning.cc b/samples/skinning/sample_skinning.cc index 355c13c38..831d85b59 100644 --- a/samples/skinning/sample_skinning.cc +++ b/samples/skinning/sample_skinning.cc @@ -186,28 +186,28 @@ class SkinningSampleApplication : public ozz::sample::Application { ozz::sample::ImGui::OpenClose oc(_im_gui, "Model statisitics", &open); if (open) { 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); int influences = 0; for (const auto& mesh : meshes_) { 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); int vertices = 0; for (const auto& mesh : meshes_) { 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); int indices = 0; for (const auto& mesh : meshes_) { 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); } } diff --git a/samples/two_bone_ik/sample_two_bone_ik.cc b/samples/two_bone_ik/sample_two_bone_ik.cc index f52a9d783..97596a20c 100644 --- a/samples/two_bone_ik/sample_two_bone_ik.cc +++ b/samples/two_bone_ik/sample_two_bone_ik.cc @@ -264,7 +264,7 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application { virtual void OnDestroy() {} virtual bool OnGui(ozz::sample::ImGui* _im_gui) { - char txt[32]; + char label[32]; // IK parameters _im_gui->DoCheckBox("Fix initial transform", &fix_initial_transform_); @@ -273,25 +273,25 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application { static bool opened = true; ozz::sample::ImGui::OpenClose oc(_im_gui, "IK parameters", &opened); if (opened) { - sprintf(txt, "Soften: %.2g", soften_); - _im_gui->DoSlider(txt, 0.f, 1.f, &soften_, 2.f); - sprintf(txt, "Twist angle: %.0f", + snprintf(label, sizeof(label), "Soften: %.2g", soften_); + _im_gui->DoSlider(label, 0.f, 1.f, &soften_, 2.f); + snprintf(label, sizeof(label), "Twist angle: %.0f", twist_angle_ * ozz::math::kRadianToDegree); - _im_gui->DoSlider(txt, -ozz::math::kPi, ozz::math::kPi, &twist_angle_); - sprintf(txt, "Weight: %.2g", weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &weight_); + _im_gui->DoSlider(label, -ozz::math::kPi, ozz::math::kPi, &twist_angle_); + snprintf(label, sizeof(label), "Weight: %.2g", weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &weight_); { // Pole vector static bool pole_opened = true; ozz::sample::ImGui::OpenClose oc_pole(_im_gui, "Pole vector", &pole_opened); if (pole_opened) { - sprintf(txt, "x %.2g", pole_vector.x); - _im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.x); - sprintf(txt, "y %.2g", pole_vector.y); - _im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.y); - sprintf(txt, "z %.2g", pole_vector.z); - _im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.z); + snprintf(label, sizeof(label), "x %.2g", pole_vector.x); + _im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.x); + snprintf(label, sizeof(label), "y %.2g", pole_vector.y); + _im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.y); + snprintf(label, sizeof(label), "z %.2g", 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); if (opened) { _im_gui->DoLabel("Target animation extent"); - sprintf(txt, "%.2g", target_extent_); - _im_gui->DoSlider(txt, 0.f, 1.f, &target_extent_); + snprintf(label, sizeof(label), "%.2g", target_extent_); + _im_gui->DoSlider(label, 0.f, 1.f, &target_extent_); _im_gui->DoLabel("Target Offset"); const float kOffsetRange = 1.f; - sprintf(txt, "x %.2g", target_offset_.x); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.x); - sprintf(txt, "y %.2g", target_offset_.y); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.y); - sprintf(txt, "z %.2g", target_offset_.z); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.z); + snprintf(label, sizeof(label), "x %.2g", target_offset_.x); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.x); + snprintf(label, sizeof(label), "y %.2g", target_offset_.y); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.y); + snprintf(label, sizeof(label), "z %.2g", target_offset_.z); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.z); } } { // Root @@ -320,28 +320,28 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application { if (opened) { // Translation _im_gui->DoLabel("Translation"); - sprintf(txt, "x %.2g", root_translation_.x); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.x); - sprintf(txt, "y %.2g", root_translation_.y); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.y); - sprintf(txt, "z %.2g", root_translation_.z); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.z); + snprintf(label, sizeof(label), "x %.2g", root_translation_.x); + _im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.x); + snprintf(label, sizeof(label), "y %.2g", root_translation_.y); + _im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.y); + snprintf(label, sizeof(label), "z %.2g", root_translation_.z); + _im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.z); // Rotation (in euler form) _im_gui->DoLabel("Rotation"); ozz::math::Float3 euler = root_euler_ * ozz::math::kRadianToDegree; - sprintf(txt, "yaw %.3g", euler.x); - _im_gui->DoSlider(txt, -180.f, 180.f, &euler.x); - sprintf(txt, "pitch %.3g", euler.y); - _im_gui->DoSlider(txt, -180.f, 180.f, &euler.y); - sprintf(txt, "roll %.3g", euler.z); - _im_gui->DoSlider(txt, -180.f, 180.f, &euler.z); + snprintf(label, sizeof(label), "yaw %.3g", euler.x); + _im_gui->DoSlider(label, -180.f, 180.f, &euler.x); + snprintf(label, sizeof(label), "pitch %.3g", euler.y); + _im_gui->DoSlider(label, -180.f, 180.f, &euler.y); + snprintf(label, sizeof(label), "roll %.3g", euler.z); + _im_gui->DoSlider(label, -180.f, 180.f, &euler.z); root_euler_ = euler * ozz::math::kDegreeToRadian; // Scale (must be uniform and not 0) _im_gui->DoLabel("Scale"); - sprintf(txt, "%.2g", root_scale_); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_scale_); + snprintf(label, sizeof(label), "%.2g", root_scale_); + _im_gui->DoSlider(label, -1.f, 1.f, &root_scale_); } } { // Display options From 72c6029df8ed48ef98a0dd25e1218e5415a53fef Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 09:13:21 +0200 Subject: [PATCH 12/20] Transitions away from sprintf to the more secure snprintf. --- CHANGES.md | 6 ++ extern/jsoncpp/dist/jsoncpp.cpp | 2 +- samples/additive/sample_additive.cc | 6 +- samples/attach/sample_attach.cc | 10 +-- samples/blend/sample_blend.cc | 6 +- samples/foot_ik/sample_foot_ik.cc | 30 ++++---- samples/framework/application.cc | 46 ++++++------ samples/framework/application.h | 2 +- samples/framework/internal/imgui_impl.cc | 2 +- samples/framework/internal/shooter.cc | 10 +-- samples/framework/utils.cc | 43 ++++++------ samples/look_at/sample_look_at.cc | 44 ++++++------ samples/millipede/sample_millipede.cc | 20 +++--- samples/multithread/sample_multithread.cc | 8 +-- samples/optimize/sample_optimize.cc | 52 +++++++------- samples/partial_blend/sample_partial_blend.cc | 14 ++-- samples/skinning/sample_skinning.cc | 8 +-- samples/two_bone_ik/sample_two_bone_ik.cc | 70 +++++++++---------- 18 files changed, 192 insertions(+), 187 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0e3fff3c1..52ac1e328 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +Release version next +-------------------- + +* Library + - Transitions away from sprintf to the more secure snprintf. + Release version 0.14.1 ---------------------- diff --git a/extern/jsoncpp/dist/jsoncpp.cpp b/extern/jsoncpp/dist/jsoncpp.cpp index d72096753..bb85e0f78 100644 --- a/extern/jsoncpp/dist/jsoncpp.cpp +++ b/extern/jsoncpp/dist/jsoncpp.cpp @@ -3887,7 +3887,7 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec int len = -1; char formatString[6]; - sprintf(formatString, "%%.%dg", precision); + snprintf(formatString, sizeof(formatString), "%%.%dg", precision); // Print into the buffer. We need not request the alternative representation // that always has a decimal point because JSON doesn't distingish the diff --git a/samples/additive/sample_additive.cc b/samples/additive/sample_additive.cc index 2a646e1e3..d033bbc1c 100644 --- a/samples/additive/sample_additive.cc +++ b/samples/additive/sample_additive.cc @@ -250,7 +250,7 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application { ozz::sample::ImGui::OpenClose oc(_im_gui, "Blending parameters", &open); if (open) { _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->DoLabel("Additive layer:"); @@ -259,8 +259,8 @@ class AdditiveBlendSampleApplication : public ozz::sample::Application { std::memcpy(weights.data(), additive_weigths_, sizeof(additive_weigths_)); - std::sprintf(label, "Weights\nCurl: %.2f\nSplay: %.2f", - additive_weigths_[kCurl], additive_weigths_[kSplay]); + std::snprintf(label, sizeof(label), "Weights\nCurl: %.2f\nSplay: %.2f", + additive_weigths_[kCurl], additive_weigths_[kSplay]); if (_im_gui->DoSlider2D(label, {{0.f, 0.f}}, {{1.f, 1.f}}, &weights)) { auto_animate_weights_ = false; // User interacted. std::memcpy(additive_weigths_, weights.data(), diff --git a/samples/attach/sample_attach.cc b/samples/attach/sample_attach.cc index 7cba010aa..d425f6273 100644 --- a/samples/attach/sample_attach.cc +++ b/samples/attach/sample_attach.cc @@ -161,16 +161,16 @@ class AttachSampleApplication : public ozz::sample::Application { if (open && skeleton_.num_joints() != 0) { _im_gui->DoLabel("Select joint:"); char label[64]; - std::sprintf(label, "%s (%d)", skeleton_.joint_names()[attachment_], - attachment_); + std::snprintf(label, sizeof(label), "%s (%d)", + skeleton_.joint_names()[attachment_], attachment_); _im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &attachment_); _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); - 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); - 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); } } diff --git a/samples/blend/sample_blend.cc b/samples/blend/sample_blend.cc index 0bda29604..e76be99de 100644 --- a/samples/blend/sample_blend.cc +++ b/samples/blend/sample_blend.cc @@ -242,16 +242,16 @@ class BlendSampleApplication : public ozz::sample::Application { } 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_); for (int i = 0; i < kNumLayers; ++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_); } - std::sprintf(label, "Threshold: %.2f", threshold_); + std::snprintf(label, sizeof(label), "Threshold: %.2f", threshold_); _im_gui->DoSlider(label, .01f, 1.f, &threshold_); } } diff --git a/samples/foot_ik/sample_foot_ik.cc b/samples/foot_ik/sample_foot_ik.cc index d0b0278d4..ddfdf39a5 100644 --- a/samples/foot_ik/sample_foot_ik.cc +++ b/samples/foot_ik/sample_foot_ik.cc @@ -608,7 +608,7 @@ class FootIKSampleApplication : public ozz::sample::Application { virtual void OnDestroy() {} virtual bool OnGui(ozz::sample::ImGui* _im_gui) { - char txt[32]; + char label[32]; // Main options { @@ -636,12 +636,12 @@ class FootIKSampleApplication : public ozz::sample::Application { static bool opened = true; ozz::sample::ImGui::OpenClose oc(_im_gui, "IK settings", &opened); if (opened) { - sprintf(txt, "Foot height %.2g", foot_heigh_); - _im_gui->DoSlider(txt, 0.f, .3f, &foot_heigh_); - sprintf(txt, "Weight %.2g", weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &weight_); - sprintf(txt, "Soften %.2g", soften_); - _im_gui->DoSlider(txt, 0.f, 1.f, &soften_, 1.f, two_bone_ik_); + snprintf(label, sizeof(label), "Foot height %.2g", foot_heigh_); + _im_gui->DoSlider(label, 0.f, .3f, &foot_heigh_); + snprintf(label, sizeof(label), "Weight %.2g", weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &weight_); + snprintf(label, sizeof(label), "Soften %.2g", soften_); + _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; // Translation _im_gui->DoLabel("Translation"); - sprintf(txt, "x %.2g", root_translation_.x); - moved |= _im_gui->DoSlider(txt, -10.f, 10.f, &root_translation_.x); - sprintf(txt, "y %.2g", root_translation_.y); - moved |= _im_gui->DoSlider(txt, 0.f, 5.f, &root_translation_.y, 1.f, + snprintf(label, sizeof(label), "x %.2g", root_translation_.x); + moved |= _im_gui->DoSlider(label, -10.f, 10.f, &root_translation_.x); + snprintf(label, sizeof(label), "y %.2g", root_translation_.y); + moved |= _im_gui->DoSlider(label, 0.f, 5.f, &root_translation_.y, 1.f, !auto_character_height_); - sprintf(txt, "z %.2g", root_translation_.z); - moved |= _im_gui->DoSlider(txt, -10.f, 10.f, &root_translation_.z); + snprintf(label, sizeof(label), "z %.2g", root_translation_.z); + moved |= _im_gui->DoSlider(label, -10.f, 10.f, &root_translation_.z); // Rotation (in euler form) _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 |= - _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 // case, because UI is updated after "game" update, we need to recompute diff --git a/samples/framework/application.cc b/samples/framework/application.cc index ede6c403c..a5c155a0d 100644 --- a/samples/framework/application.cc +++ b/samples/framework/application.cc @@ -528,31 +528,32 @@ bool Application::Gui() { } bool Application::FrameworkGui() { + char label[64]; // Downcast to public imgui. ImGui* im_gui = im_gui_.get(); { // Render statistics static bool open = true; ImGui::OpenClose stat_oc(im_gui, "Statistics", &open); if (open) { - char szLabel[64]; { // FPS Record::Statistics statistics = fps_->GetStatistics(); - std::sprintf(szLabel, "FPS: %.0f", - statistics.mean == 0.f ? 0.f : 1000.f / statistics.mean); + std::snprintf(label, sizeof(label), "FPS: %.0f", + statistics.mean == 0.f ? 0.f : 1000.f / statistics.mean); static bool fps_open = false; - ImGui::OpenClose stats(im_gui, szLabel, &fps_open); + ImGui::OpenClose stats(im_gui, label, &fps_open); if (fps_open) { - std::sprintf(szLabel, "Frame: %.2f ms", statistics.mean); - im_gui->DoGraph(szLabel, 0.f, statistics.max, statistics.latest, + std::snprintf(label, sizeof(label), "Frame: %.2f ms", + statistics.mean); + im_gui->DoGraph(label, 0.f, statistics.max, statistics.latest, fps_->cursor(), fps_->record_begin(), fps_->record_end()); } } { // Update time 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. - ImGui::OpenClose stats(im_gui, szLabel, &update_open); + ImGui::OpenClose stats(im_gui, label, &update_open); if (update_open) { im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest, update_time_->cursor(), update_time_->record_begin(), @@ -561,9 +562,9 @@ bool Application::FrameworkGui() { } { // Render time 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; - ImGui::OpenClose stats(im_gui, szLabel, &render_open); + ImGui::OpenClose stats(im_gui, label, &render_open); if (render_open) { im_gui->DoGraph(nullptr, 0.f, statistics.max, statistics.latest, render_time_->cursor(), render_time_->record_begin(), @@ -580,18 +581,15 @@ bool Application::FrameworkGui() { im_gui->DoButton("Freeze", true, &freeze_); im_gui->DoCheckBox("Fix update rate", &fix_update_rate, true); if (!fix_update_rate) { - char sz_factor[64]; - std::sprintf(sz_factor, "Time factor: %.2f", time_factor_); - im_gui->DoSlider(sz_factor, -5.f, 5.f, &time_factor_); + std::snprintf(label, sizeof(label), "Time factor: %.2f", time_factor_); + im_gui->DoSlider(label, -5.f, 5.f, &time_factor_); if (im_gui->DoButton("Reset time factor", time_factor_ != 1.f)) { time_factor_ = 1.f; } } else { - char sz_fixed_update_rate[64]; - std::sprintf(sz_fixed_update_rate, "Update rate: %.0f fps", - fixed_update_rate); - im_gui->DoSlider(sz_fixed_update_rate, 1.f, 200.f, &fixed_update_rate, - .5f, true); + std::snprintf(label, sizeof(label), "Update rate: %.0f fps", + fixed_update_rate); + im_gui->DoSlider(label, 1.f, 200.f, &fixed_update_rate, .5f, true); if (im_gui->DoButton("Reset update rate", fixed_update_rate != 60.f)) { fixed_update_rate = 60.f; } @@ -615,10 +613,9 @@ bool Application::FrameworkGui() { } // Vertical sync & swap interval bool changed = im_gui->DoCheckBox("Vertical sync", &vertical_sync_); - char szLabel[64]; - std::sprintf(szLabel, "Swap interval: %d", swap_interval_); + std::snprintf(label, sizeof(label), "Swap interval: %d", swap_interval_); 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) { glfwSwapInterval(vertical_sync_ ? swap_interval_ : 0); } @@ -640,10 +637,9 @@ bool Application::FrameworkGui() { } } - char szResolution[64]; - std::sprintf(szResolution, "Resolution: %dx%d", resolution_.width, - resolution_.height); - if (im_gui->DoSlider(szResolution, 0, kNumPresets - 1, &preset_lookup)) { + std::snprintf(label, sizeof(label), "Resolution: %dx%d", resolution_.width, + resolution_.height); + if (im_gui->DoSlider(label, 0, kNumPresets - 1, &preset_lookup)) { // Resolution changed. resolution_ = resolution_presets[preset_lookup]; glfwSetWindowSize(resolution_.width, resolution_.height); diff --git a/samples/framework/application.h b/samples/framework/application.h index c91ecfeb5..7a17519bf 100644 --- a/samples/framework/application.h +++ b/samples/framework/application.h @@ -149,7 +149,7 @@ class Application { enum LoopStatus { kContinue, // Can continue with next loop. 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); diff --git a/samples/framework/internal/imgui_impl.cc b/samples/framework/internal/imgui_impl.cc index e47e6d075..bb5e236ad 100644 --- a/samples/framework/internal/imgui_impl.cc +++ b/samples/framework/internal/imgui_impl.cc @@ -100,7 +100,7 @@ bool FormatFloat(float _value, char* _string, const char* _string_end) { if (!_string || _string_end - _string < 8 + precision + 1) { return false; } - std::sprintf(_string, "%.2g\n", _value); + std::snprintf(_string, _string_end - _string, "%.2g\n", _value); // Removes unnecessary '0' digits in the exponent. char* exponent = strchr(_string, 'e'); diff --git a/samples/framework/internal/shooter.cc b/samples/framework/internal/shooter.cc index 80492aaa7..d441f961e 100644 --- a/samples/framework/internal/shooter.cc +++ b/samples/framework/internal/shooter.cc @@ -160,12 +160,12 @@ bool Shooter::Process() { GL(BindBuffer(GL_PIXEL_PACK_BUFFER, shot.pbo)); const void* pixels = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); if (pixels) { - char name[16]; - sprintf(name, "%06d.tga", shot_number_++); + char filename[16]; + std::snprintf(filename, sizeof(filename), "%06d.tga", shot_number_++); - ozz::sample::image::WriteTGA(name, shot.width, shot.height, image_format_, - reinterpret_cast(pixels), - false); + ozz::sample::image::WriteTGA( + filename, shot.width, shot.height, image_format_, + reinterpret_cast(pixels), false); GL(UnmapBuffer(GL_PIXEL_PACK_BUFFER)); } GL(BindBuffer(GL_PIXEL_PACK_BUFFER, 0)); diff --git a/samples/framework/utils.cc b/samples/framework/utils.cc index 85fca3983..f72740191 100644 --- a/samples/framework/utils.cc +++ b/samples/framework/utils.cc @@ -110,21 +110,22 @@ bool PlaybackController::OnGui(const animation::Animation& _animation, _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 // changes. Otherwise previous time would be incorrect. float ratio = time_ratio(); - std::sprintf(szLabel, "Animation time: %.2f", ratio * _animation.duration()); - if (_im_gui->DoSlider(szLabel, 0.f, 1.f, &ratio, 1.f, + std::snprintf(label, sizeof(label), "Animation time: %.2f", + ratio * _animation.duration()); + if (_im_gui->DoSlider(label, 0.f, 1.f, &ratio, 1.f, _enabled && _allow_set_time)) { set_time_ratio(ratio); // Pause the time if slider as moved. play_ = false; time_changed = true; } - std::sprintf(szLabel, "Playback speed: %.2f", playback_speed_); - _im_gui->DoSlider(szLabel, -5.f, 5.f, &playback_speed_, 1.f, _enabled); + std::snprintf(label, sizeof(label), "Playback speed: %.2f", playback_speed_); + _im_gui->DoSlider(label, -5.f, 5.f, &playback_speed_, 1.f, _enabled); // Allow to reset speed if it is not the default value. if (_im_gui->DoButton("Reset playback speed", @@ -139,7 +140,7 @@ bool OnRawSkeletonJointGui( ozz::sample::ImGui* _im_gui, ozz::animation::offline::RawSkeleton::Joint::Children* _children, ozz::vector::iterator* _oc_state) { - char txt[255]; + char label[255]; bool modified = false; for (size_t i = 0; i < _children->size(); ++i) { @@ -152,23 +153,23 @@ bool OnRawSkeletonJointGui( // Translation ozz::math::Float3& translation = joint.transform.translation; _im_gui->DoLabel("Translation"); - sprintf(txt, "x %.2g", translation.x); - modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.x); - sprintf(txt, "y %.2g", translation.y); - modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.y); - sprintf(txt, "z %.2g", translation.z); - modified |= _im_gui->DoSlider(txt, -1.f, 1.f, &translation.z); + snprintf(label, sizeof(label), "x %.2g", translation.x); + modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.x); + snprintf(label, sizeof(label), "y %.2g", translation.y); + modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.y); + snprintf(label, sizeof(label), "z %.2g", translation.z); + modified |= _im_gui->DoSlider(label, -1.f, 1.f, &translation.z); // Rotation (in euler form) ozz::math::Quaternion& rotation = joint.transform.rotation; _im_gui->DoLabel("Rotation"); ozz::math::Float3 euler = ToEuler(rotation) * ozz::math::kRadianToDegree; - sprintf(txt, "x %.3g", euler.x); - bool euler_modified = _im_gui->DoSlider(txt, -180.f, 180.f, &euler.x); - sprintf(txt, "y %.3g", euler.y); - euler_modified |= _im_gui->DoSlider(txt, -180.f, 180.f, &euler.y); - sprintf(txt, "z %.3g", euler.z); - euler_modified |= _im_gui->DoSlider(txt, -180.f, 180.f, &euler.z); + snprintf(label, sizeof(label), "x %.3g", euler.x); + bool euler_modified = _im_gui->DoSlider(label, -180.f, 180.f, &euler.x); + snprintf(label, sizeof(label), "y %.3g", euler.y); + euler_modified |= _im_gui->DoSlider(label, -180.f, 180.f, &euler.y); + snprintf(label, sizeof(label), "z %.3g", euler.z); + euler_modified |= _im_gui->DoSlider(label, -180.f, 180.f, &euler.z); if (euler_modified) { modified = true; ozz::math::Float3 euler_rad = euler * ozz::math::kDegreeToRadian; @@ -179,8 +180,8 @@ bool OnRawSkeletonJointGui( // Scale (must be uniform and not 0) _im_gui->DoLabel("Scale"); ozz::math::Float3& scale = joint.transform.scale; - sprintf(txt, "%.2g", scale.x); - if (_im_gui->DoSlider(txt, -1.f, 1.f, &scale.x)) { + snprintf(label, sizeof(label), "%.2g", scale.x); + if (_im_gui->DoSlider(label, -1.f, 1.f, &scale.x)) { modified = true; 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, - ozz::animation::offline::RawAnimation* _animation) { + ozz::animation::offline::RawAnimation* _animation) { assert(_filename && _animation); ozz::log::Out() << "Loading raw animation archive: " << _filename << "." << std::endl; diff --git a/samples/look_at/sample_look_at.cc b/samples/look_at/sample_look_at.cc index 486753407..f1d2ab7e7 100644 --- a/samples/look_at/sample_look_at.cc +++ b/samples/look_at/sample_look_at.cc @@ -387,15 +387,15 @@ class LookAtSampleApplication : public ozz::sample::Application { virtual void OnDestroy() {} virtual bool OnGui(ozz::sample::ImGui* _im_gui) { - char txt[64]; + char label[64]; _im_gui->DoCheckBox("Enable ik", &enable_ik_); - sprintf(txt, "IK chain length: %d", chain_length_); - _im_gui->DoSlider(txt, 0, kMaxChainLength, &chain_length_); - sprintf(txt, "Joint weight %.2g", joint_weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &joint_weight_); - sprintf(txt, "Chain weight %.2g", chain_weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &chain_weight_); + snprintf(label, sizeof(label), "IK chain length: %d", chain_length_); + _im_gui->DoSlider(label, 0, kMaxChainLength, &chain_length_); + snprintf(label, sizeof(label), "Joint weight %.2g", joint_weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &joint_weight_); + snprintf(label, sizeof(label), "Chain weight %.2g", chain_weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &chain_weight_); // Exposes animation runtime playback controls. { @@ -413,15 +413,15 @@ class LookAtSampleApplication : public ozz::sample::Application { const float kTargetRange = 3.f; _im_gui->DoLabel("Animated extent"); - sprintf(txt, "%.2g", target_extent_); - _im_gui->DoSlider(txt, 0.f, kTargetRange, &target_extent_); - - sprintf(txt, "x %.2g", target_offset_.x); - _im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.x); - sprintf(txt, "y %.2g", target_offset_.y); - _im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.y); - sprintf(txt, "z %.2g", target_offset_.z); - _im_gui->DoSlider(txt, -kTargetRange, kTargetRange, &target_offset_.z); + snprintf(label, sizeof(label), "%.2g", target_extent_); + _im_gui->DoSlider(label, 0.f, kTargetRange, &target_extent_); + + snprintf(label, sizeof(label), "x %.2g", target_offset_.x); + _im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.x); + snprintf(label, sizeof(label), "y %.2g", target_offset_.y); + _im_gui->DoSlider(label, -kTargetRange, kTargetRange, &target_offset_.y); + snprintf(label, sizeof(label), "z %.2g", 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); if (opened) { const float kOffsetRange = .5f; - sprintf(txt, "x %.2g", eyes_offset_.x); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.x); - sprintf(txt, "y %.2g", eyes_offset_.y); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.y); - sprintf(txt, "z %.2g", eyes_offset_.z); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &eyes_offset_.z); + snprintf(label, sizeof(label), "x %.2g", eyes_offset_.x); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.x); + snprintf(label, sizeof(label), "y %.2g", eyes_offset_.y); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.y); + snprintf(label, sizeof(label), "z %.2g", eyes_offset_.z); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &eyes_offset_.z); } } diff --git a/samples/millipede/sample_millipede.cc b/samples/millipede/sample_millipede.cc index d1f612329..7a23d542d 100644 --- a/samples/millipede/sample_millipede.cc +++ b/samples/millipede/sample_millipede.cc @@ -152,7 +152,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { // Rebuilds all if the number of joints has changed. int joints = skeleton_->num_joints(); 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 // the lowest values. @@ -219,17 +219,17 @@ class MillipedeSampleApplication : public ozz::sample::Application { root->transform.rotation = Quaternion::identity(); root->transform.scale = Float3::one(); - char buf[16]; + char number[16]; for (int i = 0; i < slice_count_; ++i) { // Format joint number. - std::sprintf(buf, "%d", i); + std::snprintf(number, sizeof(number), "%d", i); root->children.resize(3); // Left leg. RawSkeleton::Joint& lu = root->children[0]; lu.name = "lu"; - lu.name += buf; + lu.name += number; lu.transform.translation = kTransUp; lu.transform.rotation = kRotLeftUp; lu.transform.scale = Float3::one(); @@ -237,7 +237,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { lu.children.resize(1); RawSkeleton::Joint& ld = lu.children[0]; ld.name = "ld"; - ld.name += buf; + ld.name += number; ld.transform.translation = kTransDown; ld.transform.rotation = kRotLeftDown; ld.transform.scale = Float3::one(); @@ -245,7 +245,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { ld.children.resize(1); RawSkeleton::Joint& lf = ld.children[0]; lf.name = "lf"; - lf.name += buf; + lf.name += number; lf.transform.translation = Float3::x_axis(); lf.transform.rotation = Quaternion::identity(); lf.transform.scale = Float3::one(); @@ -253,7 +253,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { // Right leg. RawSkeleton::Joint& ru = root->children[1]; ru.name = "ru"; - ru.name += buf; + ru.name += number; ru.transform.translation = kTransUp; ru.transform.rotation = kRotRightUp; ru.transform.scale = Float3::one(); @@ -261,7 +261,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { ru.children.resize(1); RawSkeleton::Joint& rd = ru.children[0]; rd.name = "rd"; - rd.name += buf; + rd.name += number; rd.transform.translation = kTransDown; rd.transform.rotation = kRotRightDown; rd.transform.scale = Float3::one(); @@ -269,7 +269,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { rd.children.resize(1); RawSkeleton::Joint& rf = rd.children[0]; rf.name = "rf"; - rf.name += buf; + rf.name += number; rf.transform.translation = Float3::x_axis(); rf.transform.rotation = Quaternion::identity(); rf.transform.scale = Float3::one(); @@ -277,7 +277,7 @@ class MillipedeSampleApplication : public ozz::sample::Application { // Spine. RawSkeleton::Joint& sp = root->children[2]; sp.name = "sp"; - sp.name += buf; + sp.name += number; sp.transform.translation = Float3(0.f, 0.f, kSpinLength); sp.transform.rotation = Quaternion::identity(); sp.transform.scale = Float3::one(); diff --git a/samples/multithread/sample_multithread.cc b/samples/multithread/sample_multithread.cc index d59d17408..ec765625f 100644 --- a/samples/multithread/sample_multithread.cc +++ b/samples/multithread/sample_multithread.cc @@ -287,10 +287,10 @@ class MultithreadSampleApplication : public ozz::sample::Application { ozz::sample::ImGui::OpenClose oc(_im_gui, "Sample control", &oc_open); if (oc_open) { 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); 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); } } @@ -303,11 +303,11 @@ class MultithreadSampleApplication : public ozz::sample::Application { has_threading_support_); if (enable_theading_) { 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_, .2f); 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()); _im_gui->DoLabel(label); } diff --git a/samples/optimize/sample_optimize.cc b/samples/optimize/sample_optimize.cc index 8e3822451..7402e0e27 100644 --- a/samples/optimize/sample_optimize.cc +++ b/samples/optimize/sample_optimize.cc @@ -312,29 +312,32 @@ class OptimizeSampleApplication : public ozz::sample::Application { 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, 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, optimize_); rebuild |= _im_gui->DoCheckBox("Enable joint setting", &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 |= _im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, &joint_, 1.f, joint_setting_enable_ && optimize_); - std::sprintf(label, "Tolerance: %0.2f mm", - joint_setting_.tolerance * 1000); + std::snprintf(label, sizeof(label), "Tolerance: %0.2f mm", + joint_setting_.tolerance * 1000); rebuild |= _im_gui->DoSlider(label, 0.f, .1f, &joint_setting_.tolerance, .5f, joint_setting_enable_ && optimize_); - std::sprintf(label, "Distance: %0.2f mm", - joint_setting_.distance * 1000); + std::snprintf(label, sizeof(label), "Distance: %0.2f mm", + joint_setting_.distance * 1000); rebuild |= _im_gui->DoSlider(label, 0.f, 1.f, &joint_setting_.distance, .5f, joint_setting_enable_ && optimize_); @@ -356,18 +359,18 @@ class OptimizeSampleApplication : public ozz::sample::Application { static bool open = true; ozz::sample::ImGui::OpenClose ocb(_im_gui, "Memory size", &open); if (open) { - std::sprintf(label, "Original: %dKB", - static_cast(raw_animation_.size() >> 10)); + std::snprintf(label, sizeof(label), "Original: %dKB", + static_cast(raw_animation_.size() >> 10)); _im_gui->DoLabel(label); - std::sprintf(label, "Optimized: %dKB (%.1f:1)", - static_cast(raw_optimized_animation_.size() >> 10), - static_cast(raw_animation_.size()) / - raw_optimized_animation_.size()); + std::snprintf(label, sizeof(label), "Optimized: %dKB (%.1f:1)", + static_cast(raw_optimized_animation_.size() >> 10), + static_cast(raw_animation_.size()) / + raw_optimized_animation_.size()); _im_gui->DoLabel(label); - std::sprintf( - label, "Compressed: %dKB (%.1f:1)", + std::snprintf( + label, sizeof(label), "Compressed: %dKB (%.1f:1)", static_cast(animation_rt_->size() >> 10), static_cast(raw_animation_.size()) / animation_rt_->size()); _im_gui->DoLabel(label); @@ -388,37 +391,36 @@ class OptimizeSampleApplication : public ozz::sample::Application { // Show absolute error. { - char szLabel[64]; static bool error_open = true; ozz::sample::ImGui::OpenClose oc_stats(_im_gui, "Absolute error", &error_open); if (error_open) { { - std::sprintf(szLabel, "Median error: %.2fmm", - *error_record_med_.cursor()); + std::snprintf(label, sizeof(label), "Median error: %.2fmm", + *error_record_med_.cursor()); const ozz::sample::Record::Statistics error_stats = 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_.record_begin(), error_record_med_.record_end()); } { - std::sprintf(szLabel, "Maximum error: %.2fmm", - *error_record_max_.cursor()); + std::snprintf(label, sizeof(label), "Maximum error: %.2fmm", + *error_record_max_.cursor()); const ozz::sample::Record::Statistics error_stats = 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_.record_begin(), error_record_max_.record_end()); } { - std::sprintf(szLabel, "Joint %d error: %.2fmm", joint_, - *joint_error_record_.cursor()); + std::snprintf(label, sizeof(label), "Joint %d error: %.2fmm", joint_, + *joint_error_record_.cursor()); const ozz::sample::Record::Statistics error_stats = 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_.record_begin(), joint_error_record_.record_end()); diff --git a/samples/partial_blend/sample_partial_blend.cc b/samples/partial_blend/sample_partial_blend.cc index 03adbe254..abda62d78 100644 --- a/samples/partial_blend/sample_partial_blend.cc +++ b/samples/partial_blend/sample_partial_blend.cc @@ -251,7 +251,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application { _im_gui->DoCheckBox("Use automatic blending settings", &automatic); 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); Sampler& lower_body_sampler = samplers_[kLowerBody]; @@ -267,27 +267,27 @@ class PartialBlendSampleApplication : public ozz::sample::Application { _im_gui->DoLabel("Manual settings:"); _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); _im_gui->DoSlider(label, 0.f, 1.f, &lower_body_sampler.weight_setting, 1.f, !automatic); - std::sprintf(label, "Joints weight: %.2f", + std::snprintf(label, sizeof(label), "Joints weight: %.2f", lower_body_sampler.joint_weight_setting); _im_gui->DoSlider(label, 0.f, 1.f, &lower_body_sampler.joint_weight_setting, 1.f, !automatic); _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); _im_gui->DoSlider(label, 0.f, 1.f, &upper_body_sampler.weight_setting, 1.f, !automatic); - std::sprintf(label, "Joints weight: %.2f", + std::snprintf(label, sizeof(label), "Joints weight: %.2f", upper_body_sampler.joint_weight_setting); _im_gui->DoSlider(label, 0.f, 1.f, &upper_body_sampler.joint_weight_setting, 1.f, !automatic); _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_); SetupPerJointWeights(); @@ -301,7 +301,7 @@ class PartialBlendSampleApplication : public ozz::sample::Application { _im_gui->DoLabel("Root of the upper body hierarchy:", ozz::sample::ImGui::kLeft, false); char label[64]; - std::sprintf(label, "%s (%d)", + std::snprintf(label, sizeof(label), "%s (%d)", skeleton_.joint_names()[upper_body_root_], upper_body_root_); if (_im_gui->DoSlider(label, 0, skeleton_.num_joints() - 1, diff --git a/samples/skinning/sample_skinning.cc b/samples/skinning/sample_skinning.cc index 355c13c38..831d85b59 100644 --- a/samples/skinning/sample_skinning.cc +++ b/samples/skinning/sample_skinning.cc @@ -186,28 +186,28 @@ class SkinningSampleApplication : public ozz::sample::Application { ozz::sample::ImGui::OpenClose oc(_im_gui, "Model statisitics", &open); if (open) { 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); int influences = 0; for (const auto& mesh : meshes_) { 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); int vertices = 0; for (const auto& mesh : meshes_) { 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); int indices = 0; for (const auto& mesh : meshes_) { 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); } } diff --git a/samples/two_bone_ik/sample_two_bone_ik.cc b/samples/two_bone_ik/sample_two_bone_ik.cc index f52a9d783..97596a20c 100644 --- a/samples/two_bone_ik/sample_two_bone_ik.cc +++ b/samples/two_bone_ik/sample_two_bone_ik.cc @@ -264,7 +264,7 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application { virtual void OnDestroy() {} virtual bool OnGui(ozz::sample::ImGui* _im_gui) { - char txt[32]; + char label[32]; // IK parameters _im_gui->DoCheckBox("Fix initial transform", &fix_initial_transform_); @@ -273,25 +273,25 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application { static bool opened = true; ozz::sample::ImGui::OpenClose oc(_im_gui, "IK parameters", &opened); if (opened) { - sprintf(txt, "Soften: %.2g", soften_); - _im_gui->DoSlider(txt, 0.f, 1.f, &soften_, 2.f); - sprintf(txt, "Twist angle: %.0f", + snprintf(label, sizeof(label), "Soften: %.2g", soften_); + _im_gui->DoSlider(label, 0.f, 1.f, &soften_, 2.f); + snprintf(label, sizeof(label), "Twist angle: %.0f", twist_angle_ * ozz::math::kRadianToDegree); - _im_gui->DoSlider(txt, -ozz::math::kPi, ozz::math::kPi, &twist_angle_); - sprintf(txt, "Weight: %.2g", weight_); - _im_gui->DoSlider(txt, 0.f, 1.f, &weight_); + _im_gui->DoSlider(label, -ozz::math::kPi, ozz::math::kPi, &twist_angle_); + snprintf(label, sizeof(label), "Weight: %.2g", weight_); + _im_gui->DoSlider(label, 0.f, 1.f, &weight_); { // Pole vector static bool pole_opened = true; ozz::sample::ImGui::OpenClose oc_pole(_im_gui, "Pole vector", &pole_opened); if (pole_opened) { - sprintf(txt, "x %.2g", pole_vector.x); - _im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.x); - sprintf(txt, "y %.2g", pole_vector.y); - _im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.y); - sprintf(txt, "z %.2g", pole_vector.z); - _im_gui->DoSlider(txt, -1.f, 1.f, &pole_vector.z); + snprintf(label, sizeof(label), "x %.2g", pole_vector.x); + _im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.x); + snprintf(label, sizeof(label), "y %.2g", pole_vector.y); + _im_gui->DoSlider(label, -1.f, 1.f, &pole_vector.y); + snprintf(label, sizeof(label), "z %.2g", 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); if (opened) { _im_gui->DoLabel("Target animation extent"); - sprintf(txt, "%.2g", target_extent_); - _im_gui->DoSlider(txt, 0.f, 1.f, &target_extent_); + snprintf(label, sizeof(label), "%.2g", target_extent_); + _im_gui->DoSlider(label, 0.f, 1.f, &target_extent_); _im_gui->DoLabel("Target Offset"); const float kOffsetRange = 1.f; - sprintf(txt, "x %.2g", target_offset_.x); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.x); - sprintf(txt, "y %.2g", target_offset_.y); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.y); - sprintf(txt, "z %.2g", target_offset_.z); - _im_gui->DoSlider(txt, -kOffsetRange, kOffsetRange, &target_offset_.z); + snprintf(label, sizeof(label), "x %.2g", target_offset_.x); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.x); + snprintf(label, sizeof(label), "y %.2g", target_offset_.y); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.y); + snprintf(label, sizeof(label), "z %.2g", target_offset_.z); + _im_gui->DoSlider(label, -kOffsetRange, kOffsetRange, &target_offset_.z); } } { // Root @@ -320,28 +320,28 @@ class TwoBoneIKSampleApplication : public ozz::sample::Application { if (opened) { // Translation _im_gui->DoLabel("Translation"); - sprintf(txt, "x %.2g", root_translation_.x); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.x); - sprintf(txt, "y %.2g", root_translation_.y); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.y); - sprintf(txt, "z %.2g", root_translation_.z); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_translation_.z); + snprintf(label, sizeof(label), "x %.2g", root_translation_.x); + _im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.x); + snprintf(label, sizeof(label), "y %.2g", root_translation_.y); + _im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.y); + snprintf(label, sizeof(label), "z %.2g", root_translation_.z); + _im_gui->DoSlider(label, -1.f, 1.f, &root_translation_.z); // Rotation (in euler form) _im_gui->DoLabel("Rotation"); ozz::math::Float3 euler = root_euler_ * ozz::math::kRadianToDegree; - sprintf(txt, "yaw %.3g", euler.x); - _im_gui->DoSlider(txt, -180.f, 180.f, &euler.x); - sprintf(txt, "pitch %.3g", euler.y); - _im_gui->DoSlider(txt, -180.f, 180.f, &euler.y); - sprintf(txt, "roll %.3g", euler.z); - _im_gui->DoSlider(txt, -180.f, 180.f, &euler.z); + snprintf(label, sizeof(label), "yaw %.3g", euler.x); + _im_gui->DoSlider(label, -180.f, 180.f, &euler.x); + snprintf(label, sizeof(label), "pitch %.3g", euler.y); + _im_gui->DoSlider(label, -180.f, 180.f, &euler.y); + snprintf(label, sizeof(label), "roll %.3g", euler.z); + _im_gui->DoSlider(label, -180.f, 180.f, &euler.z); root_euler_ = euler * ozz::math::kDegreeToRadian; // Scale (must be uniform and not 0) _im_gui->DoLabel("Scale"); - sprintf(txt, "%.2g", root_scale_); - _im_gui->DoSlider(txt, -1.f, 1.f, &root_scale_); + snprintf(label, sizeof(label), "%.2g", root_scale_); + _im_gui->DoSlider(label, -1.f, 1.f, &root_scale_); } } { // Display options From fd4a1fe00a68b8ea42245cd8a1f72c0dfddad1e2 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 12:40:11 +0200 Subject: [PATCH 13/20] Prevents all jobs from being canceled when one fails. --- .github/workflows/linux.yml | 1 + .github/workflows/macos.yml | 1 + .github/workflows/windows.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e146543ef..4b3fa7937 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: build_type: [Debug] option: [default, ref, shared, no_sample, no_data, no_fbx, no_gltf, no_tests] diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2c4763951..dd4654e22 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: macos-latest strategy: + fail-fast: false matrix: build_type: [Debug] option: [default, ref, shared, no_fbx] diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b39eb8c8a..50a52d4d8 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: windows-latest strategy: + fail-fast: false matrix: build_type: [Debug] option: [default, ref, shared, no_fbx] From 0706780f34111d911a67315f4a81b4ef65266d84 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 12:50:04 +0200 Subject: [PATCH 14/20] Fixes "unused-result" warnings. --- build-utils/cmake/compiler_settings.cmake | 1 + test/base/containers/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/build-utils/cmake/compiler_settings.cmake b/build-utils/cmake/compiler_settings.cmake index daa6f6094..ad0ef16ab 100644 --- a/build-utils/cmake/compiler_settings.cmake +++ b/build-utils/cmake/compiler_settings.cmake @@ -95,6 +95,7 @@ else() # 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("-Wpragma-pack" W_PRAGMA_PACK) diff --git a/test/base/containers/CMakeLists.txt b/test/base/containers/CMakeLists.txt index 6efbbe5a5..7fb4c0bdf 100644 --- a/test/base/containers/CMakeLists.txt +++ b/test/base/containers/CMakeLists.txt @@ -3,6 +3,8 @@ target_include_directories(test_intrusive_list PUBLIC "${PROJECT_SOURCE_DIR}/include") target_link_libraries(test_intrusive_list gtest) +target_compile_options(test_intrusive_list + PRIVATE $<$:-Wno-unused-result>) target_copy_shared_libraries(test_intrusive_list) add_test(NAME test_intrusive_list COMMAND test_intrusive_list) 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 ozz_base gtest) +target_compile_options(test_std_containers + PRIVATE $<$:-Wno-unused-result>) target_copy_shared_libraries(test_std_containers) add_test(NAME test_std_containers COMMAND test_std_containers) set_target_properties(test_std_containers PROPERTIES FOLDER "ozz/tests/base") From 604c2fa1c4ea9da64b49d50a8ac28e513aa7b109 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Thu, 4 May 2023 09:44:30 +0200 Subject: [PATCH 15/20] Updates tested compilers. --- .github/workflows/linux.yml | 74 +++++++++++++++---------------------- 1 file changed, 29 insertions(+), 45 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4b3fa7937..61a665b0d 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,23 +12,6 @@ jobs: include: - build_type: Release option: default - - build_type: Debug - option: gcc7 - compiler_c: gcc-7 - compiler_cxx: g++-7 - - build_type: Debug - option: gcc7 - compiler_c: gcc-7 - compiler_cxx: g++-7 - cxx_standard: '17' - - build_type: Debug - option: gcc8 - compiler_c: gcc-8 - compiler_cxx: g++-8 - - build_type: Debug - option: gcc9 - compiler_c: gcc-9 - compiler_cxx: g++-9 - build_type: Debug option: gcc10 compiler_c: gcc-10 @@ -38,40 +21,41 @@ jobs: compiler_c: gcc-11 compiler_cxx: g++-11 - build_type: Debug - option: gcc11 - compiler_c: gcc-11 - compiler_cxx: g++-11 - cxx_standard: '20' - - build_type: Debug - option: clang7 - compiler_c: clang-7 - compiler_cxx: clang++-7 - - build_type: Debug - option: clang7 - compiler_c: clang-7 - compiler_cxx: clang++-7 - cxx_standard: '17' - - build_type: Debug - option: clang8 - compiler_c: clang-8 - compiler_cxx: clang++-8 + option: gcc12 + compiler_c: gcc-12 + compiler_cxx: g++-12 - build_type: Debug - option: clang9 - compiler_c: clang-9 - compiler_cxx: clang++-9 - - build_type: Debug - option: clang10 - compiler_c: clang-10 - compiler_cxx: clang++-10 + option: gcc13 + compiler_c: gcc-13 + compiler_cxx: g++-13 + - build_type: Release + option: gcc13 + compiler_c: gcc-13 + compiler_cxx: g++-13 - build_type: Debug option: clang11 compiler_c: clang-11 compiler_cxx: clang++-11 - build_type: Debug - option: clang11 - compiler_c: clang-11 - compiler_cxx: clang++-11 - cxx_standard: '20' + option: clang12 + compiler_c: clang-12 + compiler_cxx: clang++-12 + - build_type: Debug + option: clang13 + compiler_c: clang-13 + compiler_cxx: clang++-13 + - build_type: Debug + option: clang14 + compiler_c: clang-14 + compiler_cxx: clang++-14 + - build_type: Debug + option: clang15 + compiler_c: clang-15 + compiler_cxx: clang++-15 + - build_type: Release + option: clang15 + compiler_c: clang-15 + compiler_cxx: clang++-15 steps: - uses: actions/checkout@v2 From d92bf92b9a26352703883ad1a6157089561ea0a4 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 19:36:31 +0200 Subject: [PATCH 16/20] #147 Works around gcc 11 error stringop-overflow which emits false positives for ozz math serialisation. --- CHANGES.md | 1 + include/ozz/base/endianness.h | 42 ++++++++++++++++------------------- src/base/CMakeLists.txt | 1 + 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 52ac1e328..f07a05ad9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ Release version next * 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 serialisation. Release version 0.14.1 ---------------------- diff --git a/include/ozz/base/endianness.h b/include/ozz/base/endianness.h index 97c66d808..e8f7aa6b7 100644 --- a/include/ozz/base/endianness.h +++ b/include/ozz/base/endianness.h @@ -66,12 +66,11 @@ template struct EndianSwapper; // Internal macro used to swap two bytes. -#define OZZ_BYTE_SWAP(_a, _b) \ - do { \ - const ozz::byte temp = (_a); \ - (_a) = (_b); \ - (_b) = temp; \ - } while (0) +OZZ_INLINE void _in_place_byte_swap(byte& _a, byte& _b) { + _a = _a ^ _b; + _b = _a ^ _b; + _a = _a ^ _b; +} // EndianSwapper specialization for 1 byte types. template @@ -86,12 +85,12 @@ struct EndianSwapper<_Ty, 2> { OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) { byte* alias = reinterpret_cast(_ty); 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. byte* alias = reinterpret_cast(&_ty); - OZZ_BYTE_SWAP(alias[0], alias[1]); + _in_place_byte_swap(alias[0], alias[1]); return _ty; } }; @@ -102,14 +101,14 @@ struct EndianSwapper<_Ty, 4> { OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) { byte* alias = reinterpret_cast(_ty); for (size_t i = 0; i < _count * 4; i += 4) { - OZZ_BYTE_SWAP(alias[i + 0], alias[i + 3]); - OZZ_BYTE_SWAP(alias[i + 1], alias[i + 2]); + _in_place_byte_swap(alias[i + 0], alias[i + 3]); + _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. byte* alias = reinterpret_cast(&_ty); - OZZ_BYTE_SWAP(alias[0], alias[3]); - OZZ_BYTE_SWAP(alias[1], alias[2]); + _in_place_byte_swap(alias[0], alias[3]); + _in_place_byte_swap(alias[1], alias[2]); return _ty; } }; @@ -120,25 +119,22 @@ struct EndianSwapper<_Ty, 8> { OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) { byte* alias = reinterpret_cast(_ty); for (size_t i = 0; i < _count * 8; i += 8) { - OZZ_BYTE_SWAP(alias[i + 0], alias[i + 7]); - OZZ_BYTE_SWAP(alias[i + 1], alias[i + 6]); - OZZ_BYTE_SWAP(alias[i + 2], alias[i + 5]); - OZZ_BYTE_SWAP(alias[i + 3], alias[i + 4]); + _in_place_byte_swap(alias[i + 0], alias[i + 7]); + _in_place_byte_swap(alias[i + 1], alias[i + 6]); + _in_place_byte_swap(alias[i + 2], alias[i + 5]); + _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. byte* alias = reinterpret_cast(&_ty); - OZZ_BYTE_SWAP(alias[0], alias[7]); - OZZ_BYTE_SWAP(alias[1], alias[6]); - OZZ_BYTE_SWAP(alias[2], alias[5]); - OZZ_BYTE_SWAP(alias[3], alias[4]); + _in_place_byte_swap(alias[0], alias[7]); + _in_place_byte_swap(alias[1], alias[6]); + _in_place_byte_swap(alias[2], alias[5]); + _in_place_byte_swap(alias[3], alias[4]); 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. template OZZ_INLINE void EndianSwap(_Ty* _ty, size_t _count) { diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 97b069e28..8d4724220 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -62,6 +62,7 @@ target_compile_definitions(ozz_base PRIVATE $<$:OZZ_BUILD_BASE_LIB>) target_compile_options(ozz_base PUBLIC $<$:/wd4251>) + target_include_directories(ozz_base PUBLIC $ $/include>) From df82d712d9a3834c883f5807ee9a2d69fca8e21e Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 19:53:56 +0200 Subject: [PATCH 17/20] Updates checkout action version. --- .github/workflows/linux.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 61a665b0d..30379e681 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -58,7 +58,7 @@ jobs: compiler_cxx: clang++-15 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install OpenGL dependency run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index dd4654e22..540e569bb 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,7 +12,7 @@ jobs: - build_type: Release option: default steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install fbx sdk if: matrix.option != 'no_fbx' diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 50a52d4d8..6923411fb 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,7 +12,7 @@ jobs: - build_type: Release option: default steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install fbx sdk if: matrix.option != 'no_fbx' From 1db3df07173fc410d2215262f746e45f10577e32 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 21:18:55 +0200 Subject: [PATCH 18/20] Updates cmake version. --- CMakeLists.txt | 8 +-- build-utils/cmake/compiler_settings.cmake | 65 ++++++++++++----------- extern/glfw/CMakeLists.txt | 2 - 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5e82054b..b5adf3021 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.3) +cmake_minimum_required(VERSION 3.24) # Defines the project's name project(ozz) @@ -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).") set(ozz_build_msvc_rt_dll ON) endif() + if(is_sub_project) set(ozz_build_msvc_rt_dll ${ozz_build_msvc_rt_dll} PARENT_SCOPE) 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. if(ozz_build_tools AND ozz_build_fbx) - # Select a msvc runtime compatible with ozz_build_msvc_rt_dll set(FBX_SHARED ${BUILD_SHARED_LIBS}) set(FBX_MSVC_RT_DLL ${ozz_build_msvc_rt_dll}) @@ -69,15 +69,17 @@ else() # Disables fbx if tools are disabled set(ozz_build_fbx OFF) endif() + if(is_sub_project) set(ozz_build_fbx ${ozz_build_fbx} PARENT_SCOPE) endif() -# gltf +# gltf if(ozz_build_tools AND ozz_build_gltf) else() set(ozz_build_gltf OFF) endif() + if(is_sub_project) set(ozz_build_gltf ${ozz_build_gltf} PARENT_SCOPE) endif() diff --git a/build-utils/cmake/compiler_settings.cmake b/build-utils/cmake/compiler_settings.cmake index ad0ef16ab..439fde8a3 100644 --- a/build-utils/cmake/compiler_settings.cmake +++ b/build-utils/cmake/compiler_settings.cmake @@ -1,18 +1,18 @@ # Set compilers settings for all platforms/compilers. -#--------------------------------------------------- +# --------------------------------------------------- -#----------------- +# ----------------- # Includes modules include(CheckIncludeFiles) -#------------------------------ +# ------------------------------ # Enables IDE folders y default set_property(GLOBAL PROPERTY USE_FOLDERS ON) -#------------------------ +# ------------------------ # Available build options -#------------------------ +# ------------------------ # Lists all the cxx flags set(cxx_all_flags CMAKE_CXX_FLAGS @@ -26,13 +26,14 @@ set(cxx_all_flags CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE) -#-------------------------------------- +# -------------------------------------- # Cross compiler compilation flags # Requires C++11 if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) endif() + set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -41,15 +42,15 @@ if(ozz_build_simd_ref) add_compile_definitions(OZZ_BUILD_SIMD_REF) endif() - # Disables crt secure warnings - add_compile_definitions(_CRT_SECURE_NO_WARNINGS) - -#-------------------------------------- +# -------------------------------------- # Modify default MSVC compilation flags if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - #--------------------------- + # --------------------------- # For the common build flags + # Disables crt secure warnings + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + # Adds support for multiple processes builds add_compile_options(/MP) @@ -60,63 +61,61 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_compile_options(/WX) # 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) - string(REGEX REPLACE "/MT" "/MD" ${flag} "${${flag}}") - else() - string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") - endif() - endforeach() - -#-------------------------------------- + if(ozz_build_msvc_rt_dll) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() + +# -------------------------------------- # else consider the compiler as GCC compatible (inc clang) else() - # Set the warning level to Wall add_compile_options(-Wall) # Enable extra level of warning - #add_compile_options(-Wextra) + # add_compile_options(-Wextra) # Set warning as error add_compile_options(-Werror) # ignored-attributes reports issue when using _m128 as template argument check_cxx_compiler_flag("-Wignored-attributes" W_IGNORED_ATTRIBUTES) + if(W_IGNORED_ATTRIBUTES) add_compile_options(-Wno-ignored-attributes) endif() - + # Disables c98 retrocompatibility warnings check_cxx_compiler_flag("-Wc++98-compat-pedantic" W_98_COMPAT_PEDANTIC) + if(W_98_COMPAT_PEDANTIC) add_compile_options(-Wno-c++98-compat-pedantic) endif() - # 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("-Wpragma-pack" W_PRAGMA_PACK) - #---------------------- + # ---------------------- # Sets emscripten output if(EMSCRIPTEN) SET(CMAKE_EXECUTABLE_SUFFIX ".html") add_link_options(-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0) - #if(NOT ozz_build_simd_ref) - # set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-msse2") - #endif() + # if(NOT ozz_build_simd_ref) + # set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-msse2") + # endif() endif() - endif() -#--------------------- +# --------------------- # Prints all the flags message(STATUS "---------------------------------------------------------") message(STATUS "Default build type is: ${CMAKE_BUILD_TYPE}") message(STATUS "The following compilation flags will be used:") + foreach(flag ${cxx_all_flags}) message(${flag} " ${${flag}}") endforeach() @@ -125,6 +124,7 @@ message(STATUS "---------------------------------------------------------") get_directory_property(DirectoryCompileOptions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_OPTIONS) message(STATUS "Directory Compile Options:") + foreach(opt ${DirectoryCompileOptions}) message(STATUS ${opt}) endforeach() @@ -133,13 +133,14 @@ message(STATUS "---------------------------------------------------------") get_directory_property(DirectoryCompileDefinitions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS) message(STATUS "Directory Compile Definitions:") + foreach(def ${DirectoryCompileDefinitions}) message(STATUS ${def}) endforeach() message(STATUS "---------------------------------------------------------") -#---------------------------------------------- +# ---------------------------------------------- # Modifies output directory for all executables set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ".") @@ -147,7 +148,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ".") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ".") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ".") -#------------------------------- +# ------------------------------- # Set a postfix for output files if(ozz_build_postfix) set(CMAKE_DEBUG_POSTFIX "_d") diff --git a/extern/glfw/CMakeLists.txt b/extern/glfw/CMakeLists.txt index 6c4d5b424..f93d67162 100644 --- a/extern/glfw/CMakeLists.txt +++ b/extern/glfw/CMakeLists.txt @@ -57,8 +57,6 @@ if(UNIX AND APPLE) lib/cocoa/cocoa_joystick.m lib/cocoa/cocoa_time.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. set_source_files_properties(${specific_objc_file_list} PROPERTIES COMPILE_FLAGS From f98ca46864e12111afbfea4a1457e2fa100f1f87 Mon Sep 17 00:00:00 2001 From: LeeRiva <76054616+LeeRiva@users.noreply.github.com> Date: Fri, 11 Aug 2023 23:21:54 +0200 Subject: [PATCH 19/20] Update sample_blend.cc (#168) Corrected invalid command line parameter description Co-authored-by: MajorDefeat <76054616+MajorDefeat@users.noreply.github.com> --- samples/blend/sample_blend.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/blend/sample_blend.cc b/samples/blend/sample_blend.cc index e76be99de..0f6860aa0 100644 --- a/samples/blend/sample_blend.cc +++ b/samples/blend/sample_blend.cc @@ -58,7 +58,7 @@ OZZ_OPTIONS_DECLARE_STRING(animation2, // Third animation archive can be specified as an option. 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) class BlendSampleApplication : public ozz::sample::Application { From f55f2a21b5892db99ab13cef9db35d3445e8f7b9 Mon Sep 17 00:00:00 2001 From: Guillaume Blanc Date: Fri, 11 Aug 2023 23:27:12 +0200 Subject: [PATCH 20/20] Updates version number --- CHANGES.md | 7 +++++-- CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f07a05ad9..4c7a99e53 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,13 @@ -Release version next --------------------- +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 serialisation. +* Build pipeline + - Updates CI compiler versions. + Release version 0.14.1 ---------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index b5adf3021..086f4d617 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ get_directory_property(is_sub_project PARENT_DIRECTORY) # Current version set(OZZ_VERSION_MAJOR 0) set(OZZ_VERSION_MINOR 14) -set(OZZ_VERSION_PATCH 1) +set(OZZ_VERSION_PATCH 2) set(OZZ_VERSION ${OZZ_VERSION_MAJOR}.${OZZ_VERSION_MINOR}.${OZZ_VERSION_PATCH}) # Add project build options