Fixed building of editor app, though crashes everywhere.

RefactorUnifiedBlendTreeStateMachineHandling
Martin Felis 2024-04-24 21:58:47 +02:00
parent c267276be3
commit 3fb2995b02
2 changed files with 125 additions and 85 deletions

View File

@ -61,10 +61,10 @@ void RemoveBlendTreeConnectionsForSocket(
BlendTreeResource& blend_tree_resource, BlendTreeResource& blend_tree_resource,
AnimNodeResource* node_resource, AnimNodeResource* node_resource,
Socket& socket) { Socket& socket) {
std::vector<BlendTreeConnectionResource>::iterator iter = std::vector<BlendTreeConnectionResource>::const_iterator iter =
blend_tree_resource.m_connections.begin(); blend_tree_resource.GetConnections().begin();
while (iter != blend_tree_resource.m_connections.end()) { while (iter != blend_tree_resource.GetConnections().end()) {
// TODO adjust for refactor // TODO adjust for refactor
assert(false); assert(false);
@ -299,11 +299,11 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
#if 1 #if 1
for (size_t node_id = 0, for (size_t node_id = 0,
n = sGraphGresource.m_blend_tree_resource.m_nodes.size(); n = sGraphGresource.m_blend_tree_resource.GetNumNodes();
node_id < n; node_id < n;
node_id++) { node_id++) {
AnimNodeResource* node_resource = AnimNodeResource* node_resource =
sGraphGresource.m_blend_tree_resource.m_nodes[node_id]; sGraphGresource.m_blend_tree_resource.GetNode(node_id);
if (node_id == 0 || node_id == 1) { if (node_id == 0 || node_id == 1) {
// continue; // continue;
@ -346,31 +346,31 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
int link_id = 0; int link_id = 0;
for (size_t connection_id = 0, for (size_t connection_id = 0,
n = sGraphGresource.m_blend_tree_resource.m_connections.size(); n = sGraphGresource.m_blend_tree_resource.GetNumConnections();
connection_id < n; connection_id < n;
connection_id++) { connection_id++) {
const BlendTreeConnectionResource& connection_resource = const BlendTreeConnectionResource* connection_resource =
sGraphGresource.m_blend_tree_resource.m_connections[connection_id]; sGraphGresource.m_blend_tree_resource.GetConnection(connection_id);
const AnimNodeResource* source_node_resource = const AnimNodeResource* source_node_resource =
sGraphGresource.m_blend_tree_resource sGraphGresource.m_blend_tree_resource.GetNode(
.m_nodes[connection_resource.source_node_index]; connection_resource->source_node_index);
int source_socket_index = int source_socket_index =
source_node_resource->m_socket_accessor->GetOutputIndex( source_node_resource->m_socket_accessor->GetOutputIndex(
connection_resource.source_socket_name.c_str()); connection_resource->source_socket_name.c_str());
const AnimNodeResource* target_node_resource = const AnimNodeResource* target_node_resource =
sGraphGresource.m_blend_tree_resource sGraphGresource.m_blend_tree_resource.GetNode(
.m_nodes[connection_resource.target_node_index]; connection_resource->target_node_index);
int target_socket_index = int target_socket_index =
target_node_resource->m_socket_accessor->GetInputIndex( target_node_resource->m_socket_accessor->GetInputIndex(
connection_resource.target_socket_name.c_str()); connection_resource->target_socket_name.c_str());
int source_socket_id = GetNodeOutputSocketId( int source_socket_id = GetNodeOutputSocketId(
static_cast<int>(connection_resource.source_node_index), static_cast<int>(connection_resource->source_node_index),
source_socket_index); source_socket_index);
int target_socket_id = GetNodeInputSocketId( int target_socket_id = GetNodeInputSocketId(
static_cast<int>(connection_resource.target_node_index), static_cast<int>(connection_resource->target_node_index),
target_socket_index); target_socket_index);
ax::NodeEditor::Link(link_id++, source_socket_id, target_socket_id); ax::NodeEditor::Link(link_id++, source_socket_id, target_socket_id);
@ -407,11 +407,11 @@ void LegacyAnimGraphEditorUpdate() {
if (ImGui::Button("Load")) { if (ImGui::Button("Load")) {
sGraphGresource.LoadFromFile("editor_graph.json"); sGraphGresource.LoadFromFile("editor_graph.json");
for (size_t i = 0, n = sGraphGresource.m_blend_tree_resource.m_nodes.size(); for (size_t i = 0, n = sGraphGresource.m_blend_tree_resource.GetNumNodes();
i < n; i < n;
i++) { i++) {
const AnimNodeResource* node_resource = const AnimNodeResource* node_resource =
sGraphGresource.m_blend_tree_resource.m_nodes[i]; sGraphGresource.m_blend_tree_resource.GetNode(i);
ImNodes::SetNodeGridSpacePos( ImNodes::SetNodeGridSpacePos(
i, i,
ImVec2(node_resource->m_position[0], node_resource->m_position[1])); ImVec2(node_resource->m_position[0], node_resource->m_position[1]));
@ -485,9 +485,9 @@ void LegacyAnimGraphEditorUpdate() {
if (node_type_name != "") { if (node_type_name != "") {
AnimNodeResource* node_resource = AnimNodeResource* node_resource =
AnimNodeResourceFactory(node_type_name); AnimNodeResourceFactory(node_type_name);
size_t node_id = sGraphGresource.m_blend_tree_resource.m_nodes.size(); size_t node_id = sGraphGresource.m_blend_tree_resource.GetNumNodes();
ImNodes::SetNodeScreenSpacePos(node_id, ImGui::GetMousePos()); ImNodes::SetNodeScreenSpacePos(node_id, ImGui::GetMousePos());
sGraphGresource.m_blend_tree_resource.m_nodes.push_back(node_resource); sGraphGresource.m_blend_tree_resource.AddNode(node_resource);
} }
ImGui::EndPopup(); ImGui::EndPopup();
@ -496,11 +496,11 @@ void LegacyAnimGraphEditorUpdate() {
ImGui::PopStyleVar(ImGuiStyleVar_WindowPadding); ImGui::PopStyleVar(ImGuiStyleVar_WindowPadding);
} }
for (size_t i = 0, n = sGraphGresource.m_blend_tree_resource.m_nodes.size(); for (size_t i = 0, n = sGraphGresource.m_blend_tree_resource.GetNumNodes();
i < n; i < n;
i++) { i++) {
AnimNodeResource* node_resource = AnimNodeResource* node_resource =
sGraphGresource.m_blend_tree_resource.m_nodes[i]; sGraphGresource.m_blend_tree_resource.GetNode(i);
ImNodes::BeginNode(i); ImNodes::BeginNode(i);
ImGui::PushItemWidth(110.0f); ImGui::PushItemWidth(110.0f);
@ -624,30 +624,30 @@ void LegacyAnimGraphEditorUpdate() {
} }
for (size_t i = 0, for (size_t i = 0,
n = sGraphGresource.m_blend_tree_resource.m_connections.size(); n = sGraphGresource.m_blend_tree_resource.GetNumConnections();
i < n; i < n;
i++) { i++) {
const BlendTreeConnectionResource& connection = const BlendTreeConnectionResource* connection =
sGraphGresource.m_blend_tree_resource.m_connections[i]; sGraphGresource.m_blend_tree_resource.GetConnection(i);
int start_attr, end_attr; int start_attr, end_attr;
const AnimNodeResource* source_node = const AnimNodeResource* source_node =
sGraphGresource.m_blend_tree_resource sGraphGresource.m_blend_tree_resource.GetNode(
.m_nodes[connection.source_node_index]; connection->source_node_index);
int source_socket_index = source_node->m_socket_accessor->GetOutputIndex( int source_socket_index = source_node->m_socket_accessor->GetOutputIndex(
connection.source_socket_name.c_str()); connection->source_socket_name.c_str());
const AnimNodeResource* target_node = const AnimNodeResource* target_node =
sGraphGresource.m_blend_tree_resource sGraphGresource.m_blend_tree_resource.GetNode(
.m_nodes[connection.target_node_index]; connection->target_node_index);
int target_socket_index = target_node->m_socket_accessor->GetInputIndex( int target_socket_index = target_node->m_socket_accessor->GetInputIndex(
connection.target_socket_name.c_str()); connection->target_socket_name.c_str());
start_attr = GenerateOutputAttributeId( start_attr = GenerateOutputAttributeId(
connection.source_node_index, connection->source_node_index,
source_socket_index); source_socket_index);
end_attr = GenerateInputAttributeId( end_attr = GenerateInputAttributeId(
connection.target_node_index, connection->target_node_index,
target_socket_index); target_socket_index);
ImNodes::Link(i, start_attr, end_attr); ImNodes::Link(i, start_attr, end_attr);
@ -672,18 +672,22 @@ void LegacyAnimGraphEditorUpdate() {
BlendTreeConnectionResource connection; BlendTreeConnectionResource connection;
connection.source_node_index = node_start_id; connection.source_node_index = node_start_id;
const AnimNodeResource* source_node = const AnimNodeResource* source_node =
sGraphGresource.m_blend_tree_resource.m_nodes[node_start_id]; sGraphGresource.m_blend_tree_resource.GetNode(node_start_id);
connection.source_socket_name = connection.source_socket_name =
source_node->m_socket_accessor->m_outputs[node_start_output_index] source_node->m_socket_accessor->m_outputs[node_start_output_index]
.m_name; .m_name;
connection.target_node_index = node_end_id; connection.target_node_index = node_end_id;
const AnimNodeResource* target_node = const AnimNodeResource* target_node =
sGraphGresource.m_blend_tree_resource.m_nodes[node_end_id]; sGraphGresource.m_blend_tree_resource.GetNode(node_end_id);
connection.target_socket_name = connection.target_socket_name =
target_node->m_socket_accessor->m_inputs[node_end_input_index].m_name; target_node->m_socket_accessor->m_inputs[node_end_input_index].m_name;
sGraphGresource.m_blend_tree_resource.m_connections.push_back(connection); sGraphGresource.m_blend_tree_resource.ConnectSockets(
source_node,
connection.source_socket_name,
target_node,
connection.target_socket_name);
} }
if (ImGui::IsKeyPressed(ImGuiKey_Delete, false)) { if (ImGui::IsKeyPressed(ImGuiKey_Delete, false)) {
@ -693,8 +697,19 @@ void LegacyAnimGraphEditorUpdate() {
// Handle link detachements. // Handle link detachements.
int link_id = 0; int link_id = 0;
if (ImNodes::IsLinkDestroyed(&link_id)) { if (ImNodes::IsLinkDestroyed(&link_id)) {
sGraphGresource.m_blend_tree_resource.m_connections.erase( BlendTreeConnectionResource* connection =
sGraphGresource.m_blend_tree_resource.m_connections.begin() + link_id); sGraphGresource.m_blend_tree_resource.GetConnection(link_id);
AnimNodeResource* source_node =
sGraphGresource.m_blend_tree_resource.GetNode(
connection->source_node_index);
AnimNodeResource* target_node =
sGraphGresource.m_blend_tree_resource.GetNode(
connection->target_node_index);
sGraphGresource.m_blend_tree_resource.DisconnectSockets(
source_node,
connection->source_socket_name,
target_node,
connection->target_socket_name);
} }
int selected_nodes[ImNodes::NumSelectedNodes()]; int selected_nodes[ImNodes::NumSelectedNodes()];
@ -707,9 +722,9 @@ void LegacyAnimGraphEditorUpdate() {
if (ImNodes::NumSelectedNodes() == 1) { if (ImNodes::NumSelectedNodes() == 1) {
if (selected_nodes[0] if (selected_nodes[0]
< sGraphGresource.m_blend_tree_resource.m_nodes.size()) { < sGraphGresource.m_blend_tree_resource.GetNumNodes()) {
AnimNodeResource* selected_node = AnimNodeResource* selected_node =
sGraphGresource.m_blend_tree_resource.m_nodes[selected_nodes[0]]; sGraphGresource.m_blend_tree_resource.GetNode(selected_nodes[0]);
AnimGraphEditorRenderSidebar( AnimGraphEditorRenderSidebar(
sGraphGresource.m_blend_tree_resource, sGraphGresource.m_blend_tree_resource,
selected_node); selected_node);

View File

@ -16,13 +16,16 @@
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <iostream> #include <iostream>
#include "3rdparty/imgui-node-editor/imgui_node_editor.h"
#include "3rdparty/json/json.hpp" #include "3rdparty/json/json.hpp"
#include "AnimGraph/AnimGraphBlendTree.h"
#include "AnimGraph/AnimGraphData.h"
#include "Camera.h" #include "Camera.h"
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
#include "SkinnedMesh.h" #include "SkinnedMesh.h"
#include "SkinnedMeshRenderer.h"
#include "SkinnedMeshResource.h" #include "SkinnedMeshResource.h"
#include "src/AnimGraph/AnimGraphEditor.h" #include "src/AnimGraph/AnimGraphEditor.h"
#include "3rdparty/imgui-node-editor/imgui_node_editor.h"
const int Width = 1024; const int Width = 1024;
const int Height = 768; const int Height = 768;
@ -49,7 +52,6 @@ static void draw_imgui(ImDrawData*);
#include <cmath> // fmodf #include <cmath> // fmodf
#include <fstream> #include <fstream>
#include "SkinnedMeshRenderer.h"
#include "ozz/animation/runtime/animation.h" #include "ozz/animation/runtime/animation.h"
#include "ozz/animation/runtime/sampling_job.h" #include "ozz/animation/runtime/sampling_job.h"
#include "ozz/animation/runtime/skeleton.h" #include "ozz/animation/runtime/skeleton.h"
@ -156,14 +158,10 @@ struct Viewport {
this->pass = sg_make_pass(&offscreen_pass_desc); this->pass = sg_make_pass(&offscreen_pass_desc);
sg_pipeline_desc gl_pipeline_desc = { sg_pipeline_desc gl_pipeline_desc = {
.depth = { .depth = {.compare = SG_COMPAREFUNC_LESS_EQUAL, .write_enabled = true},
.compare = SG_COMPAREFUNC_LESS_EQUAL,
.write_enabled = true
},
.cull_mode = SG_CULLMODE_BACK, .cull_mode = SG_CULLMODE_BACK,
.sample_count = cMSAASampleCount .sample_count = cMSAASampleCount};
}; // this->pip = sg_make_pipeline(gl_pipeline_desc);
// this->pip = sg_make_pipeline(gl_pipeline_desc);
} }
}; };
@ -186,7 +184,7 @@ struct ApplicationConfig {
ax::NodeEditor::EditorContext* context = nullptr; ax::NodeEditor::EditorContext* context = nullptr;
}; };
GraphEditor graph_editor; GraphEditor graph_editor;
struct SkinnedMeshWidget { struct SkinnedMeshWidget {
bool visible = false; bool visible = false;
int position[2] = {20, 20}; int position[2] = {20, 20};
@ -224,8 +222,10 @@ void to_json(nlohmann::json& j, const ApplicationConfig& config) {
j["main_window"]["size"][1] = config.window_size[1]; j["main_window"]["size"][1] = config.window_size[1];
j["legacy_graph_editor"]["visible"] = config.legacy_graph_editor.visible; j["legacy_graph_editor"]["visible"] = config.legacy_graph_editor.visible;
j["legacy_graph_editor"]["position"][0] = config.legacy_graph_editor.position[0]; j["legacy_graph_editor"]["position"][0] =
j["legacy_graph_editor"]["position"][1] = config.legacy_graph_editor.position[1]; config.legacy_graph_editor.position[0];
j["legacy_graph_editor"]["position"][1] =
config.legacy_graph_editor.position[1];
j["legacy_graph_editor"]["size"][0] = config.legacy_graph_editor.size[0]; j["legacy_graph_editor"]["size"][0] = config.legacy_graph_editor.size[0];
j["legacy_graph_editor"]["size"][1] = config.legacy_graph_editor.size[1]; j["legacy_graph_editor"]["size"][1] = config.legacy_graph_editor.size[1];
@ -234,7 +234,7 @@ void to_json(nlohmann::json& j, const ApplicationConfig& config) {
j["graph_editor"]["position"][1] = config.graph_editor.position[1]; j["graph_editor"]["position"][1] = config.graph_editor.position[1];
j["graph_editor"]["size"][0] = config.graph_editor.size[0]; j["graph_editor"]["size"][0] = config.graph_editor.size[0];
j["graph_editor"]["size"][1] = config.graph_editor.size[1]; j["graph_editor"]["size"][1] = config.graph_editor.size[1];
j["skinned_mesh_widget"]["visible"] = config.skinned_mesh_widget.visible; j["skinned_mesh_widget"]["visible"] = config.skinned_mesh_widget.visible;
j["skinned_mesh_widget"]["position"][0] = j["skinned_mesh_widget"]["position"][0] =
config.skinned_mesh_widget.position[0]; config.skinned_mesh_widget.position[0];
@ -287,14 +287,18 @@ void from_json(const nlohmann::json& j, ApplicationConfig& config) {
if (j["legacy_graph_editor"].contains("position") if (j["legacy_graph_editor"].contains("position")
and j["legacy_graph_editor"]["position"].size() == 2) { and j["legacy_graph_editor"]["position"].size() == 2) {
config.legacy_graph_editor.position[0] = j["legacy_graph_editor"]["position"].at(0); config.legacy_graph_editor.position[0] =
config.legacy_graph_editor.position[1] = j["legacy_graph_editor"]["position"].at(1); j["legacy_graph_editor"]["position"].at(0);
config.legacy_graph_editor.position[1] =
j["legacy_graph_editor"]["position"].at(1);
} }
if (j["legacy_graph_editor"].contains("size") if (j["legacy_graph_editor"].contains("size")
and j["legacy_graph_editor"]["size"].size() == 2) { and j["legacy_graph_editor"]["size"].size() == 2) {
config.legacy_graph_editor.size[0] = j["legacy_graph_editor"]["size"].at(0); config.legacy_graph_editor.size[0] =
config.legacy_graph_editor.size[1] = j["legacy_graph_editor"]["size"].at(1); j["legacy_graph_editor"]["size"].at(0);
config.legacy_graph_editor.size[1] =
j["legacy_graph_editor"]["size"].at(1);
} }
} }
@ -302,7 +306,7 @@ void from_json(const nlohmann::json& j, ApplicationConfig& config) {
if (j["graph_editor"].contains("visible")) { if (j["graph_editor"].contains("visible")) {
config.graph_editor.visible = j["graph_editor"]["visible"]; config.graph_editor.visible = j["graph_editor"]["visible"];
} }
if (j["graph_editor"].contains("position") if (j["graph_editor"].contains("position")
and j["graph_editor"]["position"].size() == 2) { and j["graph_editor"]["position"].size() == 2) {
config.graph_editor.position[0] = j["graph_editor"]["position"].at(0); config.graph_editor.position[0] = j["graph_editor"]["position"].at(0);
@ -315,7 +319,7 @@ void from_json(const nlohmann::json& j, ApplicationConfig& config) {
config.graph_editor.size[1] = j["graph_editor"]["size"].at(1); config.graph_editor.size[1] = j["graph_editor"]["size"].at(1);
} }
} }
if (j.contains("skinned_mesh_widget")) { if (j.contains("skinned_mesh_widget")) {
if (j["skinned_mesh_widget"].contains("visible")) { if (j["skinned_mesh_widget"].contains("visible")) {
config.skinned_mesh_widget.visible = j["skinned_mesh_widget"]["visible"]; config.skinned_mesh_widget.visible = j["skinned_mesh_widget"]["visible"];
@ -529,7 +533,9 @@ int main() {
// setup sokol_gfx and sokol_time // setup sokol_gfx and sokol_time
stm_setup(); stm_setup();
sg_desc desc = {.logger = {.func = slog_func}, .context {.sample_count = cMSAASampleCount}}; sg_desc desc = {
.logger = {.func = slog_func},
.context{.sample_count = cMSAASampleCount}};
sg_setup(&desc); sg_setup(&desc);
assert(sg_isvalid()); assert(sg_isvalid());
@ -550,7 +556,7 @@ int main() {
skinned_mesh_resource.createInstance(skinned_mesh); skinned_mesh_resource.createInstance(skinned_mesh);
skinned_mesh.SetCurrentAnimation(0); skinned_mesh.SetCurrentAnimation(0);
AnimGraph anim_graph; AnimGraphBlendTree anim_graph;
AnimGraphContext anim_graph_context; AnimGraphContext anim_graph_context;
AnimData anim_graph_output; AnimData anim_graph_output;
anim_graph_output.m_local_matrices.resize( anim_graph_output.m_local_matrices.resize(
@ -673,7 +679,8 @@ int main() {
// Graph Editor // Graph Editor
gApplicationConfig.graph_editor.config.SettingsFile = "graph_editor.json"; gApplicationConfig.graph_editor.config.SettingsFile = "graph_editor.json";
gApplicationConfig.graph_editor.config.NavigateButtonIndex = 2; gApplicationConfig.graph_editor.config.NavigateButtonIndex = 2;
gApplicationConfig.graph_editor.context = ax::NodeEditor::CreateEditor(&gApplicationConfig.graph_editor.config); gApplicationConfig.graph_editor.context =
ax::NodeEditor::CreateEditor(&gApplicationConfig.graph_editor.config);
// draw loop // draw loop
while (!glfwWindowShouldClose(w)) { while (!glfwWindowShouldClose(w)) {
@ -811,12 +818,12 @@ int main() {
AnimGraphEditorGetRuntimeGraph(anim_graph); AnimGraphEditorGetRuntimeGraph(anim_graph);
anim_graph_context.m_skeleton = &skinned_mesh.m_skeleton; anim_graph_context.m_skeleton = &skinned_mesh.m_skeleton;
anim_graph.init(anim_graph_context); anim_graph.Init(anim_graph_context);
// For simplicity use first animation data output // For simplicity use first animation data output
const std::vector<Socket>& graph_output_sockets = const std::vector<Socket>& graph_output_sockets =
anim_graph.getGraphOutputs(); anim_graph.GetGraphOutputs();
for (const auto & output : graph_output_sockets) { for (const auto& output : graph_output_sockets) {
if (output.m_type == SocketType::SocketTypeAnimation) { if (output.m_type == SocketType::SocketTypeAnimation) {
anim_graph.SetOutput(output.m_name.c_str(), &anim_graph_output); anim_graph.SetOutput(output.m_name.c_str(), &anim_graph_output);
} }
@ -845,7 +852,8 @@ int main() {
ImGui::Begin("Viewport", &gApplicationConfig.viewport_widget.visible); ImGui::Begin("Viewport", &gApplicationConfig.viewport_widget.visible);
if (ImGui::IsWindowHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Right)) { if (ImGui::IsWindowHovered()
&& ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
if (gControlMode == ControlMode::ControlModeNone) { if (gControlMode == ControlMode::ControlModeNone) {
gControlMode = ControlMode::ControlModeFPS; gControlMode = ControlMode::ControlModeFPS;
Camera_CalcFromMatrix(&state.camera, &state.camera.mtxView[0]); Camera_CalcFromMatrix(&state.camera, &state.camera.mtxView[0]);
@ -854,8 +862,10 @@ int main() {
} }
ImVec2 viewport_widget_size = ImGui::GetWindowSize(); ImVec2 viewport_widget_size = ImGui::GetWindowSize();
gApplicationConfig.viewport_widget.size[0] = static_cast<int>(viewport_widget_size.x); gApplicationConfig.viewport_widget.size[0] =
gApplicationConfig.viewport_widget.size[1] = static_cast<int>(viewport_widget_size.y); static_cast<int>(viewport_widget_size.x);
gApplicationConfig.viewport_widget.size[1] =
static_cast<int>(viewport_widget_size.y);
ImGui::Text( ImGui::Text(
"Viewport size: %d, %d", "Viewport size: %d, %d",
@ -869,12 +879,16 @@ int main() {
if (static_cast<float>(current_size[0]) != content_size[0] if (static_cast<float>(current_size[0]) != content_size[0]
|| static_cast<float>(current_size[1]) != content_size[1] || static_cast<float>(current_size[1]) != content_size[1]
|| offscreen_viewport.pass.id == 0) { || offscreen_viewport.pass.id == 0) {
offscreen_viewport.Resize(static_cast<int>(content_size[0]), static_cast<int>(content_size[1])); offscreen_viewport.Resize(
static_cast<int>(content_size[0]),
static_cast<int>(content_size[1]));
} }
ImGui::Image( ImGui::Image(
(ImTextureID)(uintptr_t)offscreen_viewport.color_image.id, (ImTextureID)(uintptr_t)offscreen_viewport.color_image.id,
ImVec2(static_cast<float>(offscreen_viewport.size[0]), static_cast<float>(offscreen_viewport.size[1])), ImVec2(
static_cast<float>(offscreen_viewport.size[0]),
static_cast<float>(offscreen_viewport.size[1])),
ImVec2(0.0f, 1.0f), ImVec2(0.0f, 1.0f),
ImVec2(1.0f, 0.0f)); ImVec2(1.0f, 0.0f));
@ -897,13 +911,17 @@ int main() {
if (gApplicationConfig.skinned_mesh_widget.visible) { if (gApplicationConfig.skinned_mesh_widget.visible) {
ImGui::SetNextWindowPos( ImGui::SetNextWindowPos(
ImVec2( ImVec2(
static_cast<float>(gApplicationConfig.skinned_mesh_widget.position[0]), static_cast<float>(
static_cast<float>(gApplicationConfig.skinned_mesh_widget.position[1])), gApplicationConfig.skinned_mesh_widget.position[0]),
static_cast<float>(
gApplicationConfig.skinned_mesh_widget.position[1])),
ImGuiCond_FirstUseEver); ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize( ImGui::SetNextWindowSize(
ImVec2( ImVec2(
static_cast<float>(gApplicationConfig.skinned_mesh_widget.size[0]), static_cast<float>(
static_cast<float>(gApplicationConfig.skinned_mesh_widget.size[1])), gApplicationConfig.skinned_mesh_widget.size[0]),
static_cast<float>(
gApplicationConfig.skinned_mesh_widget.size[1])),
ImGuiCond_FirstUseEver); ImGuiCond_FirstUseEver);
ImGui::Begin( ImGui::Begin(
@ -930,13 +948,17 @@ int main() {
if (gApplicationConfig.animation_player_widget.visible) { if (gApplicationConfig.animation_player_widget.visible) {
ImGui::SetNextWindowPos( ImGui::SetNextWindowPos(
ImVec2( ImVec2(
static_cast<float>(gApplicationConfig.animation_player_widget.position[0]), static_cast<float>(
static_cast<float>(gApplicationConfig.animation_player_widget.position[1])), gApplicationConfig.animation_player_widget.position[0]),
static_cast<float>(
gApplicationConfig.animation_player_widget.position[1])),
ImGuiCond_FirstUseEver); ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize( ImGui::SetNextWindowSize(
ImVec2( ImVec2(
static_cast<float>(gApplicationConfig.animation_player_widget.size[0]), static_cast<float>(
static_cast<float>(gApplicationConfig.animation_player_widget.size[1])), gApplicationConfig.animation_player_widget.size[0]),
static_cast<float>(
gApplicationConfig.animation_player_widget.size[1])),
ImGuiCond_FirstUseEver); ImGuiCond_FirstUseEver);
ImGui::Begin( ImGui::Begin(
@ -1015,8 +1037,8 @@ int main() {
if (state.ozz.animation != nullptr) { if (state.ozz.animation != nullptr) {
state.ozz.sampling_job.animation = state.ozz.animation; state.ozz.sampling_job.animation = state.ozz.animation;
state.ozz.sampling_job.ratio = state.ozz.sampling_job.ratio = static_cast<float>(state.time.absolute)
static_cast<float>(state.time.absolute) / state.ozz.animation->duration(); / state.ozz.animation->duration();
state.ozz.sampling_job.context = &skinned_mesh.m_sampling_context; state.ozz.sampling_job.context = &skinned_mesh.m_sampling_context;
state.ozz.sampling_job.output = state.ozz.sampling_job.output =
ozz::make_span(skinned_mesh.m_local_matrices); ozz::make_span(skinned_mesh.m_local_matrices);
@ -1031,9 +1053,10 @@ int main() {
if (state.time.use_graph && !anim_graph.m_nodes.empty() if (state.time.use_graph && !anim_graph.m_nodes.empty()
&& state.time.anim_update_time > 0.) { && state.time.anim_update_time > 0.) {
anim_graph.markActiveNodes(); // TODO: update for new API after embedding refactor
anim_graph.updateTime(state.time.anim_update_time); // anim_graph.MarkActiveNodes();
anim_graph.evaluate(anim_graph_context); // anim_graph.UpdateTime()pdateTime(state.time.anim_update_time);
// anim_graph.evaluate(anim_graph_context);
skinned_mesh.m_local_matrices = anim_graph_output.m_local_matrices; skinned_mesh.m_local_matrices = anim_graph_output.m_local_matrices;
skinned_mesh.CalcModelMatrices(); skinned_mesh.CalcModelMatrices();
@ -1099,8 +1122,10 @@ int main() {
ImGuiWindowFlags_MenuBar); ImGuiWindowFlags_MenuBar);
ImVec2 graph_editor_position = ImGui::GetWindowPos(); ImVec2 graph_editor_position = ImGui::GetWindowPos();
gApplicationConfig.legacy_graph_editor.position[0] = graph_editor_position.x; gApplicationConfig.legacy_graph_editor.position[0] =
gApplicationConfig.legacy_graph_editor.position[1] = graph_editor_position.y; graph_editor_position.x;
gApplicationConfig.legacy_graph_editor.position[1] =
graph_editor_position.y;
ImVec2 graph_editor_size = ImGui::GetWindowSize(); ImVec2 graph_editor_size = ImGui::GetWindowSize();
gApplicationConfig.legacy_graph_editor.size[0] = graph_editor_size.x; gApplicationConfig.legacy_graph_editor.size[0] = graph_editor_size.x;