Fixed some clang-tidy warnings.
parent
8b7de58131
commit
dc958dcabd
68
src/main.cc
68
src/main.cc
|
@ -42,18 +42,15 @@ typedef struct {
|
||||||
|
|
||||||
static void draw_imgui(ImDrawData*);
|
static void draw_imgui(ImDrawData*);
|
||||||
|
|
||||||
#define HANDMADE_MATH_IMPLEMENTATION
|
|
||||||
#define HANDMADE_MATH_NO_SSE
|
#define HANDMADE_MATH_NO_SSE
|
||||||
#include "HandmadeMath.h"
|
#include "HandmadeMath.h"
|
||||||
|
|
||||||
// ozz-animation headers
|
// ozz-animation headers
|
||||||
#include <cmath> // fmodf
|
#include <cmath> // fmodf
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory> // std::unique_ptr, std::make_unique
|
|
||||||
|
|
||||||
#include "SkinnedMeshRenderer.h"
|
#include "SkinnedMeshRenderer.h"
|
||||||
#include "ozz/animation/runtime/animation.h"
|
#include "ozz/animation/runtime/animation.h"
|
||||||
#include "ozz/animation/runtime/local_to_model_job.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"
|
||||||
#include "ozz/base/containers/vector.h"
|
#include "ozz/base/containers/vector.h"
|
||||||
|
@ -61,7 +58,6 @@ static void draw_imgui(ImDrawData*);
|
||||||
#include "ozz/base/io/stream.h"
|
#include "ozz/base/io/stream.h"
|
||||||
#include "ozz/base/log.h"
|
#include "ozz/base/log.h"
|
||||||
#include "ozz/base/maths/soa_transform.h"
|
#include "ozz/base/maths/soa_transform.h"
|
||||||
#include "ozz/base/maths/vec_float.h"
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct {
|
struct {
|
||||||
|
@ -69,7 +65,7 @@ static struct {
|
||||||
ozz::animation::SamplingJob sampling_job;
|
ozz::animation::SamplingJob sampling_job;
|
||||||
ozz::vector<ozz::math::SoaTransform> local_matrices;
|
ozz::vector<ozz::math::SoaTransform> local_matrices;
|
||||||
} ozz;
|
} ozz;
|
||||||
sg_pass_action pass_action;
|
sg_pass_action pass_action = {};
|
||||||
Camera camera;
|
Camera camera;
|
||||||
struct {
|
struct {
|
||||||
bool skeleton;
|
bool skeleton;
|
||||||
|
@ -87,7 +83,7 @@ static struct {
|
||||||
bool paused;
|
bool paused;
|
||||||
bool use_graph = false;
|
bool use_graph = false;
|
||||||
} time;
|
} time;
|
||||||
} state;
|
} state = {};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t mousedX;
|
int32_t mousedX;
|
||||||
|
@ -768,8 +764,8 @@ int main() {
|
||||||
cur_width,
|
cur_width,
|
||||||
cur_height,
|
cur_height,
|
||||||
static_cast<float>(state.time.frame),
|
static_cast<float>(state.time.frame),
|
||||||
gGuiInputState.mousedX,
|
static_cast<float>(gGuiInputState.mousedX),
|
||||||
gGuiInputState.mousedY,
|
static_cast<float>(gGuiInputState.mousedY),
|
||||||
camera_accel);
|
camera_accel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,8 +818,7 @@ int main() {
|
||||||
// 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 (int i = 0; i < graph_output_sockets.size(); i++) {
|
for (const auto & output : graph_output_sockets) {
|
||||||
const Socket& output = graph_output_sockets[i];
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -853,8 +848,8 @@ int main() {
|
||||||
ImGui::Begin("Viewport", &gApplicationConfig.viewport_widget.visible);
|
ImGui::Begin("Viewport", &gApplicationConfig.viewport_widget.visible);
|
||||||
|
|
||||||
ImVec2 viewport_widget_size = ImGui::GetWindowSize();
|
ImVec2 viewport_widget_size = ImGui::GetWindowSize();
|
||||||
gApplicationConfig.viewport_widget.size[0] = viewport_widget_size.x;
|
gApplicationConfig.viewport_widget.size[0] = static_cast<int>(viewport_widget_size.x);
|
||||||
gApplicationConfig.viewport_widget.size[1] = viewport_widget_size.y;
|
gApplicationConfig.viewport_widget.size[1] = static_cast<int>(viewport_widget_size.y);
|
||||||
|
|
||||||
ImGui::Text(
|
ImGui::Text(
|
||||||
"Viewport size: %d, %d",
|
"Viewport size: %d, %d",
|
||||||
|
@ -865,15 +860,15 @@ int main() {
|
||||||
|
|
||||||
int* current_size = offscreen_viewport.size;
|
int* current_size = offscreen_viewport.size;
|
||||||
|
|
||||||
if (current_size[0] != content_size[0]
|
if (static_cast<float>(current_size[0]) != content_size[0]
|
||||||
|| 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(content_size[0], 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(offscreen_viewport.size[0], 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));
|
||||||
|
|
||||||
|
@ -896,13 +891,13 @@ int main() {
|
||||||
if (gApplicationConfig.skinned_mesh_widget.visible) {
|
if (gApplicationConfig.skinned_mesh_widget.visible) {
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(
|
||||||
ImVec2(
|
ImVec2(
|
||||||
gApplicationConfig.skinned_mesh_widget.position[0],
|
static_cast<float>(gApplicationConfig.skinned_mesh_widget.position[0]),
|
||||||
gApplicationConfig.skinned_mesh_widget.position[1]),
|
static_cast<float>(gApplicationConfig.skinned_mesh_widget.position[1])),
|
||||||
ImGuiCond_FirstUseEver);
|
ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSize(
|
ImGui::SetNextWindowSize(
|
||||||
ImVec2(
|
ImVec2(
|
||||||
gApplicationConfig.skinned_mesh_widget.size[0],
|
static_cast<float>(gApplicationConfig.skinned_mesh_widget.size[0]),
|
||||||
gApplicationConfig.skinned_mesh_widget.size[1]),
|
static_cast<float>(gApplicationConfig.skinned_mesh_widget.size[1])),
|
||||||
ImGuiCond_FirstUseEver);
|
ImGuiCond_FirstUseEver);
|
||||||
|
|
||||||
ImGui::Begin(
|
ImGui::Begin(
|
||||||
|
@ -911,15 +906,15 @@ int main() {
|
||||||
|
|
||||||
ImVec2 skinned_mesh_widget_position = ImGui::GetWindowPos();
|
ImVec2 skinned_mesh_widget_position = ImGui::GetWindowPos();
|
||||||
gApplicationConfig.skinned_mesh_widget.position[0] =
|
gApplicationConfig.skinned_mesh_widget.position[0] =
|
||||||
skinned_mesh_widget_position.x;
|
static_cast<int>(skinned_mesh_widget_position.x);
|
||||||
gApplicationConfig.skinned_mesh_widget.position[1] =
|
gApplicationConfig.skinned_mesh_widget.position[1] =
|
||||||
skinned_mesh_widget_position.y;
|
static_cast<int>(skinned_mesh_widget_position.y);
|
||||||
|
|
||||||
ImVec2 skinned_mesh_widget_size = ImGui::GetWindowSize();
|
ImVec2 skinned_mesh_widget_size = ImGui::GetWindowSize();
|
||||||
gApplicationConfig.skinned_mesh_widget.size[0] =
|
gApplicationConfig.skinned_mesh_widget.size[0] =
|
||||||
skinned_mesh_widget_size.x;
|
static_cast<int>(skinned_mesh_widget_size.x);
|
||||||
gApplicationConfig.skinned_mesh_widget.size[1] =
|
gApplicationConfig.skinned_mesh_widget.size[1] =
|
||||||
skinned_mesh_widget_size.y;
|
static_cast<int>(skinned_mesh_widget_size.y);
|
||||||
|
|
||||||
SkinnedMeshWidget(&skinned_mesh);
|
SkinnedMeshWidget(&skinned_mesh);
|
||||||
|
|
||||||
|
@ -929,13 +924,13 @@ int main() {
|
||||||
if (gApplicationConfig.animation_player_widget.visible) {
|
if (gApplicationConfig.animation_player_widget.visible) {
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(
|
||||||
ImVec2(
|
ImVec2(
|
||||||
gApplicationConfig.animation_player_widget.position[0],
|
static_cast<float>(gApplicationConfig.animation_player_widget.position[0]),
|
||||||
gApplicationConfig.animation_player_widget.position[1]),
|
static_cast<float>(gApplicationConfig.animation_player_widget.position[1])),
|
||||||
ImGuiCond_FirstUseEver);
|
ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSize(
|
ImGui::SetNextWindowSize(
|
||||||
ImVec2(
|
ImVec2(
|
||||||
gApplicationConfig.animation_player_widget.size[0],
|
static_cast<float>(gApplicationConfig.animation_player_widget.size[0]),
|
||||||
gApplicationConfig.animation_player_widget.size[1]),
|
static_cast<float>(gApplicationConfig.animation_player_widget.size[1])),
|
||||||
ImGuiCond_FirstUseEver);
|
ImGuiCond_FirstUseEver);
|
||||||
|
|
||||||
ImGui::Begin(
|
ImGui::Begin(
|
||||||
|
@ -944,15 +939,15 @@ int main() {
|
||||||
|
|
||||||
ImVec2 animation_player_widget_position = ImGui::GetWindowPos();
|
ImVec2 animation_player_widget_position = ImGui::GetWindowPos();
|
||||||
gApplicationConfig.animation_player_widget.position[0] =
|
gApplicationConfig.animation_player_widget.position[0] =
|
||||||
animation_player_widget_position.x;
|
static_cast<int>(animation_player_widget_position.x);
|
||||||
gApplicationConfig.animation_player_widget.position[1] =
|
gApplicationConfig.animation_player_widget.position[1] =
|
||||||
animation_player_widget_position.y;
|
static_cast<int>(animation_player_widget_position.y);
|
||||||
|
|
||||||
ImVec2 animation_player_widget_size = ImGui::GetWindowSize();
|
ImVec2 animation_player_widget_size = ImGui::GetWindowSize();
|
||||||
gApplicationConfig.animation_player_widget.size[0] =
|
gApplicationConfig.animation_player_widget.size[0] =
|
||||||
animation_player_widget_size.x;
|
static_cast<int>(animation_player_widget_size.x);
|
||||||
gApplicationConfig.animation_player_widget.size[1] =
|
gApplicationConfig.animation_player_widget.size[1] =
|
||||||
animation_player_widget_size.y;
|
static_cast<int>(animation_player_widget_size.y);
|
||||||
|
|
||||||
if (anim_graph.m_nodes.size() > 0) {
|
if (anim_graph.m_nodes.size() > 0) {
|
||||||
ImGui::Checkbox("Use Graph", &state.time.use_graph);
|
ImGui::Checkbox("Use Graph", &state.time.use_graph);
|
||||||
|
@ -973,7 +968,7 @@ int main() {
|
||||||
"Animation",
|
"Animation",
|
||||||
&selected,
|
&selected,
|
||||||
items,
|
items,
|
||||||
skinned_mesh.m_animations.size())) {
|
static_cast<int>(skinned_mesh.m_animations.size()))) {
|
||||||
state.ozz.animation = skinned_mesh.m_animations[selected];
|
state.ozz.animation = skinned_mesh.m_animations[selected];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1015,7 +1010,7 @@ 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 =
|
||||||
state.time.absolute / state.ozz.animation->duration();
|
static_cast<float>(state.time.absolute) / 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);
|
||||||
|
@ -1028,7 +1023,7 @@ int main() {
|
||||||
skinned_mesh.CalcModelMatrices();
|
skinned_mesh.CalcModelMatrices();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.time.use_graph && anim_graph.m_nodes.size() > 0
|
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();
|
anim_graph.markActiveNodes();
|
||||||
anim_graph.updateTime(state.time.anim_update_time);
|
anim_graph.updateTime(state.time.anim_update_time);
|
||||||
|
@ -1176,9 +1171,6 @@ int main() {
|
||||||
draw_imgui(ImGui::GetDrawData());
|
draw_imgui(ImGui::GetDrawData());
|
||||||
sg_end_pass();
|
sg_end_pass();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sg_commit();
|
sg_commit();
|
||||||
glfwSwapBuffers(w);
|
glfwSwapBuffers(w);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
Loading…
Reference in New Issue