Updated ozz-animation to version 0.14.1.

This commit is contained in:
Martin Felis
2023-04-15 00:07:29 +02:00
parent eb70c06c57
commit 72bcf8a21b
29 changed files with 1389 additions and 1071 deletions
Binary file not shown.
@@ -36,6 +36,10 @@ target_link_libraries(sample_framework
ozz_geometry
ozz_animation_offline
ozz_options)
target_include_directories(sample_framework PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/samples>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/samples>)
if(TARGET BUILD_DATA_SAMPLE)
add_dependencies(sample_framework BUILD_DATA_SAMPLE)
+11 -5
View File
@@ -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);
@@ -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_;
+26 -1
View File
@@ -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::animation::offline::RawAnimation>()) {
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 <typename _Track>
bool LoadTrackImpl(const char* _filename, _Track* _track) {
@@ -411,7 +436,7 @@ bool LoadMeshes(const char* _filename,
}
namespace {
// MollerTrumbore 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,
+8
View File
@@ -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