Implemented node like debug gui for anim nodes.
parent
1cfba1c388
commit
5e6e81b60b
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -61,8 +61,6 @@ AnimationController::AnimationController(SkinnedMesh* skinned_mesh)
|
|||
m_output_node->Reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
AnimationController::~AnimationController() {
|
||||
while (m_anim_nodes.size() > 0) {
|
||||
delete m_anim_nodes[m_anim_nodes.size() - 1];
|
||||
|
@ -97,9 +95,7 @@ void AnimationController::UpdateOrderedNodes() {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationController::UpdateBlendLogic() {
|
||||
|
||||
}
|
||||
void AnimationController::UpdateBlendLogic() {}
|
||||
|
||||
void AnimationController::UpdateTime(float dt) {
|
||||
if (m_output_node == nullptr) {
|
||||
|
@ -121,8 +117,6 @@ void AnimationController::UpdateTime(float dt) {
|
|||
m_output_node->UpdateTime(dt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AnimationController::Evaluate() {
|
||||
if (m_output_node == nullptr) {
|
||||
return;
|
||||
|
@ -137,8 +131,6 @@ void AnimationController::Evaluate() {
|
|||
ltm_job.Run();
|
||||
};
|
||||
|
||||
|
||||
|
||||
void AnimationController::DrawDebugUi() {
|
||||
ImGui::SetNextWindowSize(ImVec2(500, 300), ImGuiCond_FirstUseEver);
|
||||
ImGui::Begin("AnimationController");
|
||||
|
@ -147,46 +139,59 @@ void AnimationController::DrawDebugUi() {
|
|||
ResetAnims();
|
||||
}
|
||||
|
||||
if (m_output_node && ImGui::TreeNode("Output")) {
|
||||
m_output_node->DrawDebugUi();
|
||||
ImVec2 node_size(200, 100);
|
||||
for (int i = 0; i < m_ordered_nodes.size(); i++) {
|
||||
AnimNode* node = m_ordered_nodes[i];
|
||||
|
||||
ImGui::TreePop();
|
||||
ImGui::SetNextWindowSize(node_size, ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2((m_ordered_nodes.size() - 1 - i) * node_size.x - i * 10, 300),
|
||||
ImGuiCond_FirstUseEver);
|
||||
ImGui::Begin(node->m_name.c_str());
|
||||
node->DrawDebugUi();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (m_output_node && ImGui::TreeNode("Nodes")) {
|
||||
ImGui::Columns(4, "NodeOverview"); // 4-ways, with border
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Synced"); ImGui::NextColumn();
|
||||
ImGui::Text("Duration"); ImGui::NextColumn();
|
||||
ImGui::Text("Time"); ImGui::NextColumn();
|
||||
ImGui::Columns(4, "Node States"); // 4-ways, with border
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Name");
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Synced");
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Duration");
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Time");
|
||||
ImGui::NextColumn();
|
||||
|
||||
ImGui::Separator();
|
||||
static int selected = -1;
|
||||
ImGui::Separator();
|
||||
static int selected = -1;
|
||||
|
||||
for (int i = 0; i < m_ordered_nodes.size(); i++) {
|
||||
AnimNode* node = m_ordered_nodes[i];
|
||||
if (ImGui::Selectable(node->m_name.c_str(), selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
bool hovered = ImGui::IsItemHovered();
|
||||
ImGui::NextColumn();
|
||||
for (int i = 0; i < m_ordered_nodes.size(); i++) {
|
||||
AnimNode* node = m_ordered_nodes[i];
|
||||
if (ImGui::Selectable(
|
||||
node->m_name.c_str(),
|
||||
selected == i,
|
||||
ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
bool hovered = ImGui::IsItemHovered();
|
||||
ImGui::NextColumn();
|
||||
|
||||
ImGui::Text(node->m_is_time_synced ? "X" : "-"); ImGui::NextColumn();
|
||||
ImGui::Text(node->m_is_time_synced ? "X" : "-");
|
||||
ImGui::NextColumn();
|
||||
|
||||
ImGui::PushID((void*)&node->m_anim_duration);
|
||||
ImGui::Text("%2.3f", node->m_anim_duration); ImGui::NextColumn();
|
||||
ImGui::PopID();
|
||||
ImGui::PushID((void*)&node->m_anim_duration);
|
||||
ImGui::Text("%2.3f", node->m_anim_duration);
|
||||
ImGui::NextColumn();
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::PushID((void*)&node->m_current_time);
|
||||
ImGui::Text("%2.3f", node->m_current_time); ImGui::NextColumn();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::TreePop();
|
||||
ImGui::PushID((void*)&node->m_current_time);
|
||||
ImGui::Text("%2.3f", node->m_current_time);
|
||||
ImGui::NextColumn();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::End();
|
||||
}
|
Loading…
Reference in New Issue