fixed crashes in animation system; animation editor - fixed select node ui
This commit is contained in:
parent
aa963bbb96
commit
17562c8d92
4 changed files with 30 additions and 5 deletions
|
@ -75,7 +75,7 @@ RuntimeContext* Controller::createRuntime(u32 anim_set) {
|
|||
ctx->animations[anim.slot] = anim.animation;
|
||||
}
|
||||
}
|
||||
m_root->enter(*ctx);
|
||||
if (m_root) m_root->enter(*ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ void Controller::update(RuntimeContext& ctx, LocalRigidTransform& root_motion) c
|
|||
ctx.data.reserve(mem.length());
|
||||
ctx.events.clear();
|
||||
ctx.input_runtime.set(mem.begin(), mem.length());
|
||||
m_root->update(ctx, root_motion);
|
||||
if (m_root) m_root->update(ctx, root_motion);
|
||||
processEvents(ctx);
|
||||
|
||||
m_allocator.deallocate(mem.begin());
|
||||
|
@ -148,7 +148,7 @@ void Controller::getPose(RuntimeContext& ctx, Pose& pose) {
|
|||
root_bind_pose.rot = pose.rotations[root_bone_idx];
|
||||
}
|
||||
|
||||
m_root->getPose(ctx, 1.f, pose, 0xffFFffFF);
|
||||
if (m_root) m_root->getPose(ctx, 1.f, pose, 0xffFFffFF);
|
||||
|
||||
// TODO this should be in AnimationNode
|
||||
if (root_bone_iter.isValid()) {
|
||||
|
|
|
@ -403,6 +403,18 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
|
||||
switch (node.m_parent->type()) {
|
||||
default: break;
|
||||
case Node::Type::SELECT: {
|
||||
SelectNode* select = (SelectNode*)node.m_parent;
|
||||
for (SelectNode::Child& c : select->m_children) {
|
||||
if (c.node != &node) continue;
|
||||
|
||||
const InputDecl::Input& input = m_controller.m_inputs.inputs[select->m_input_index];
|
||||
ImGuiEx::Label(StaticString<64>(input.name, " <= "));
|
||||
saveUndo(ImGui::DragFloat("##mv", &c.max_value));
|
||||
// TODO sort children by c.max_value
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Node::Type::LAYERS:
|
||||
if (!m_controller.m_bone_masks.empty()) {
|
||||
LayersNode* layers = (LayersNode*)node.m_parent;
|
||||
|
@ -1404,6 +1416,7 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
if (ImGui::Selectable("Condition")) createRoot(Node::CONDITION, m_controller.m_allocator);
|
||||
if (ImGui::Selectable("Group")) createRoot(Node::GROUP, m_controller.m_allocator);
|
||||
if (ImGui::Selectable("Layers")) createRoot(Node::LAYERS, m_controller.m_allocator);
|
||||
if (ImGui::Selectable("Select")) createRoot(Node::SELECT, m_controller.m_allocator);
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
|
|
|
@ -599,6 +599,8 @@ u32 SelectNode::getChildIndex(float input_val) const {
|
|||
}
|
||||
|
||||
void SelectNode::update(RuntimeContext& ctx, LocalRigidTransform& root_motion) const {
|
||||
if (m_children.empty()) return;
|
||||
|
||||
RuntimeData data = ctx.input_runtime.read<RuntimeData>();
|
||||
|
||||
const float input_val = getInputValue(ctx, m_input_index);
|
||||
|
@ -641,16 +643,21 @@ void SelectNode::update(RuntimeContext& ctx, LocalRigidTransform& root_motion) c
|
|||
}
|
||||
|
||||
void SelectNode::enter(RuntimeContext& ctx) const {
|
||||
if (m_children.empty()) return;
|
||||
|
||||
RuntimeData runtime_data = { 0, 0, Time(0) };
|
||||
const float input_val = getInputValue(ctx, m_input_index);
|
||||
runtime_data.from = getChildIndex(input_val);
|
||||
runtime_data.to = runtime_data.from;
|
||||
ctx.data.write(runtime_data);
|
||||
if(runtime_data.from < (u32)m_children.size())
|
||||
if (runtime_data.from < (u32)m_children.size()) {
|
||||
m_children[runtime_data.from].node->enter(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectNode::skip(RuntimeContext& ctx) const {
|
||||
if (m_children.empty()) return;
|
||||
|
||||
RuntimeData data = ctx.input_runtime.read<RuntimeData>();
|
||||
m_children[data.from].node->skip(ctx);
|
||||
if (data.from != data.to) {
|
||||
|
@ -659,6 +666,8 @@ void SelectNode::skip(RuntimeContext& ctx) const {
|
|||
}
|
||||
|
||||
void SelectNode::getPose(RuntimeContext& ctx, float weight, Pose& pose, u32 mask) const {
|
||||
if (m_children.empty()) return;
|
||||
|
||||
const RuntimeData data = ctx.input_runtime.read<RuntimeData>();
|
||||
|
||||
m_children[data.from].node->getPose(ctx, weight, pose, mask);
|
||||
|
|
|
@ -598,7 +598,10 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
auto common_popup = [&](){
|
||||
const char* base_path = fs.getBasePath();
|
||||
ImGui::Checkbox("Thumbnails", &m_show_thumbnails);
|
||||
if (ImGui::Checkbox("Subresources", &m_show_subresources)) changeDir(m_dir, false);
|
||||
if (ImGui::Checkbox("Subresources", &m_show_subresources)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
changeDir(m_dir, false);
|
||||
}
|
||||
if (ImGui::SliderFloat("Icon size", &m_thumbnail_size, 0.3f, 3.f, "%.2f", ImGuiSliderFlags_AlwaysClamp)) {
|
||||
refreshLabels();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue