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