Implemented node like debug gui for anim nodes.

This commit is contained in:
Martin Felis
2021-11-16 21:17:52 +01:00
parent 1cfba1c388
commit 5e6e81b60b
4 changed files with 73 additions and 91 deletions
+17 -25
View File
@@ -18,9 +18,8 @@ void AnimSamplerNode::SetAnimation(ozz::animation::Animation* animation) {
m_sampling_cache.Resize(num_joints);
}
void AnimSamplerNode::Evaluate(ozz::vector<ozz::math::SoaTransform>* local_matrices) {
void AnimSamplerNode::Evaluate(
ozz::vector<ozz::math::SoaTransform>* local_matrices) {
ozz::animation::SamplingJob sampling_job;
sampling_job.animation = m_animation;
sampling_job.cache = &m_sampling_cache;
@@ -31,29 +30,22 @@ void AnimSamplerNode::Evaluate(ozz::vector<ozz::math::SoaTransform>* local_matri
}
}
void AnimSamplerNode::DrawDebugUi() {
std::string node_name = "AnimSamplerNode: " + m_name;
if (ImGui::TreeNode(node_name.c_str())) {
const SkinnedMesh* skinned_mesh = m_animation_controller->m_skinned_mesh;
int anim_count = skinned_mesh->m_animation_names.size();
const char* items[255] = {0};
int item_current = 0;
for (int i = 0; i < anim_count; i++) {
items[i] = skinned_mesh->m_animation_names[i].c_str();
if (skinned_mesh->m_animations[i] == m_animation) {
item_current = i;
}
const SkinnedMesh* skinned_mesh = m_animation_controller->m_skinned_mesh;
int anim_count = skinned_mesh->m_animation_names.size();
const char* items[255] = {0};
int item_current = 0;
for (int i = 0; i < anim_count; i++) {
items[i] = skinned_mesh->m_animation_names[i].c_str();
if (skinned_mesh->m_animations[i] == m_animation) {
item_current = i;
}
if (ImGui::Combo("Animation", &item_current, items, anim_count)) {
m_animation = skinned_mesh->m_animations[item_current];
}
ImGui::Checkbox("Override", &m_override_ratio);
ImGui::SameLine();
ImGui::SliderFloat("Ratio", &m_anim_ratio, 0.f, 1.f);
ImGui::TreePop();
}
if (ImGui::Combo("Animation", &item_current, items, anim_count)) {
m_animation = skinned_mesh->m_animations[item_current];
}
ImGui::Checkbox("Override", &m_override_ratio);
ImGui::SameLine();
ImGui::SliderFloat("Ratio", &m_anim_ratio, 0.f, 1.f);
}
+2 -10
View File
@@ -49,14 +49,6 @@ void BlendNode::Evaluate(ozz::vector<ozz::math::SoaTransform>* local_matrices) {
}
void BlendNode::DrawDebugUi() {
std::string node_name = "BlendNode: " + m_name;
if (ImGui::TreeNode(node_name.c_str())) {
ImGui::Text("Input A:");
m_input_A->DrawDebugUi();
ImGui::Text("Input B:");
m_input_B->DrawDebugUi();
ImGui::SliderFloat("Weight", &m_weight, 0.f, 1.f);
ImGui::Checkbox("Sync Inputs", &m_sync_inputs);
ImGui::TreePop();
}
ImGui::SliderFloat("Weight", &m_weight, 0.f, 1.f);
ImGui::Checkbox("Sync Inputs", &m_sync_inputs);
}
+9 -16
View File
@@ -7,21 +7,14 @@
#include <imgui.h>
void SpeedScaleNode::DrawDebugUi() {
std::string node_name = "SpeedScaleNode: " + m_name;
if (ImGui::TreeNode(node_name.c_str())) {
bool is_negative = m_time_scale < 0.f;
if (ImGui::Checkbox("Reverse Time", &is_negative)) {
m_time_scale = m_time_scale * -1.f;
}
// ensure m_time_scale is positive
m_time_scale = m_time_scale * (is_negative ? -1.f : 1.f);
ImGui::SliderFloat("Time Scale", &m_time_scale, 0.01f, 5.f);
// and back to the original negative or positive sign
m_time_scale = m_time_scale * (is_negative ? -1.f : 1.f);
m_input_node->DrawDebugUi();
ImGui::TreePop();
bool is_negative = m_time_scale < 0.f;
if (ImGui::Checkbox("Reverse Time", &is_negative)) {
m_time_scale = m_time_scale * -1.f;
}
// ensure m_time_scale is positive
m_time_scale = m_time_scale * (is_negative ? -1.f : 1.f);
ImGui::SliderFloat("Time Scale", &m_time_scale, 0.01f, 5.f);
// and back to the original negative or positive sign
m_time_scale = m_time_scale * (is_negative ? -1.f : 1.f);
}