Skip to content

Commit

Permalink
[add] cleanup and fix builds
Browse files Browse the repository at this point in the history
  • Loading branch information
begla committed Jul 30, 2023
1 parent a6de615 commit 9c8f628
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 193 deletions.
15 changes: 15 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Checks: 'clang-analzyer-*,modernize-*,readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-return-braced-init-list'
Checks: '-*,readability-identifier-naming,modernize-loop-convert,modernize-concat-nested-namespaces,modernize-use-nodiscard,modernize-use-auto,modernize-use-trailing-return-type,modernize-use-using,modernize-use-default-member-init'
HeaderFilterRegex: '.*Iolite.*'

CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: lower_case }
- { key: readability-identifier-naming.ClassSuffix, value: _t }
- { key: readability-identifier-naming.ClassMethodCase, value: lower_case }
- { key: readability-identifier-naming.StructCase, value: lower_case }
- { key: readability-identifier-naming.StructSuffix, value: _t }
- { key: readability-identifier-naming.FunctionCase, value: lower_case }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.GlobalVariableCase, value: lower_case }
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build_lua_plugin
name: build_plugins
on: [push]
jobs:
build:
Expand All @@ -13,12 +13,12 @@ jobs:
submodules: true
- name : "Build plugins"
run: |
cd iolite_lua_plugin
cd iolite_plugins
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
- name : "Archive plugins"
uses: actions/upload-artifact@v3
with:
name: lua_plugin
name: plugins
path: |
iolite_lua_plugin/IoliteLuaPlugin.*
iolite_plugins/Iolite*Plugin.*
48 changes: 24 additions & 24 deletions iolite_c_api/sample_plugins/sample_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static void on_build_plugin_menu()
// Add a new menu item to the menu
if (ImGui::MenuItem("Spawn Voxel Cubes"))
{
constexpr io_uint32_t numNodes = 500u;
constexpr io_uint32_t num_nodes = 500u;

// Create a new palette and set a single blueish color
const io_ref_t palette = io_resource_palette->base.create("my_palette");
Expand All @@ -167,7 +167,7 @@ static void on_build_plugin_menu()
io_resource_palette->base.commit_changes(palette);

// Spawn voxel cubes
for (uint32_t i = 0u; i < numNodes; ++i)
for (uint32_t i = 0u; i < num_nodes; ++i)
{
// Create a new node (and entity)
const io_ref_t node = io_component_node->create("cube");
Expand Down Expand Up @@ -195,10 +195,10 @@ static void on_build_plugin_menu()
// Add a new menu item to the menu
if (ImGui::MenuItem("Spawn Boids"))
{
constexpr io_uint32_t numBoids = 2000u;
constexpr io_uint32_t num_boids = 2000u;

// Spawn boids
for (uint32_t i = 0u; i < numBoids; ++i)
for (uint32_t i = 0u; i < num_boids; ++i)
{
// Create a new node (and entity)
const io_ref_t node = io_component_node->create("boid");
Expand All @@ -222,31 +222,31 @@ static void on_build_plugin_menu()
}

//----------------------------------------------------------------------------//
static bool draw_ui_sample_main_menu_button(const char* text,
io_float32_t& offset)
static auto draw_ui_sample_main_menu_button(const char* text,
io_float32_t& offset) -> bool
{
constexpr float buttonHeight = 50.0f;
constexpr float button_height = 50.0f;
constexpr float spacing = 10.0f;

bool clicked = false;

io_ui->push_transform({0.0f, 0.0f}, {1.0f, 0.0f}, {0.0f, offset},
{0.0f, offset + buttonHeight}, 0.0f);
{0.0f, offset + button_height}, 0.0f);
{
// Draw button background
{
constexpr io_vec4_t colorDefault = {0.1f, 0.1f, 0.1f, 0.5f};
constexpr io_vec4_t colorHovered = {0.25f, 0.25f, 0.25f, 0.5f};
constexpr io_vec4_t colorPressed = {0.5f, 0.5f, 0.5f, 0.5f};
constexpr io_vec4_t color_default = {0.1f, 0.1f, 0.1f, 0.5f};
constexpr io_vec4_t color_hovered = {0.25f, 0.25f, 0.25f, 0.5f};
constexpr io_vec4_t color_pressed = {0.5f, 0.5f, 0.5f, 0.5f};

io_vec4_t color = colorDefault;
io_vec4_t color = color_default;

if (io_ui->intersects(io_input_system->get_mouse_pos()))
{
color = colorHovered;
color = color_hovered;
if (io_input_system->get_key_state(io_input_key_mouse_left, 0) ==
io_input_key_state_pressed)
color = colorPressed;
color = color_pressed;
else if (io_input_system->get_key_state(io_input_key_mouse_left, 0) ==
io_input_key_state_clicked)
clicked = true;
Expand All @@ -272,7 +272,7 @@ static bool draw_ui_sample_main_menu_button(const char* text,
}
io_ui->pop_transform();

offset += spacing + buttonHeight;
offset += spacing + button_height;

return clicked;
}
Expand All @@ -294,17 +294,17 @@ static void draw_ui_sample_main_menu(io_float32_t delta_t)
io_ui->push_transform({0.0f, 0.0f}, {1.0f, 0.0f}, {0.0f, 0.0f},
{0.0f, 100.0f}, 0.0f);
{
io_vec2_t splashSize = io_ui->get_image_size("splash");
const float aspect = splashSize.y / splashSize.x;
splashSize.x = 200.0f;
splashSize.y = splashSize.x * aspect;
io_vec2_t splash_size = io_ui->get_image_size("splash");
const float aspect = splash_size.y / splash_size.x;
splash_size.x = 200.0f;
splash_size.y = splash_size.x * aspect;

// Draw logo
io_ui->push_transform_preset(io_ui_anchor_preset_center,
{-splashSize.x * 0.5f, splashSize.x * 0.5f,
-splashSize.y * 0.5f,
splashSize.y * 0.5f},
0.0f);
io_ui->push_transform_preset(
io_ui_anchor_preset_center,
{-splash_size.x * 0.5f, splash_size.x * 0.5f, -splash_size.y * 0.5f,
splash_size.y * 0.5f},
0.0f);
{
io_ui->draw_image("splash", {1.0f, 1.0f, 1.0f, 1.0f});
}
Expand Down
4 changes: 2 additions & 2 deletions iolite_plugins/lua_plugin/forward_decls.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ static const io_component_particle_i* io_component_particle;

// Custom data types
//----------------------------------------------------------------------------//
struct lua_physics_contact_event
struct lua_physics_contact_event_t
{
const char* type;
struct event_data
struct event_data_t
{
io_ref_t entity0, entity1;
io_vec3_t pos, impulse;
Expand Down
14 changes: 7 additions & 7 deletions iolite_plugins/lua_plugin/lua_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void script_update(sol::state& state, io_float32_t delta_t, io_ref_t entity,
static void on_init_script(const char* script_name, io_ref_t entity,
io_uint32_t update_interval, void** user_data)
{
sol::state** state = (sol::state**)user_data;
auto** state = (sol::state**)user_data;

void* mem = io_base->mem_allocate(sizeof(sol::state));
*state = new (mem) sol::state();
Expand All @@ -261,7 +261,7 @@ static void on_init_script(const char* script_name, io_ref_t entity,
//----------------------------------------------------------------------------//
static void on_destroy_script(io_ref_t entity, void** user_data)
{
sol::state** s = (sol::state**)user_data;
auto** s = (sol::state**)user_data;

internal::script_deactivate(**s, entity);

Expand All @@ -281,7 +281,7 @@ static void on_activate_scripts(const io_user_script_batch* scripts,

for (uint32_t i = 0u; i < scripts_length; ++i)
{
sol::state* state = (sol::state*)scripts->user_datas[i];
auto* state = (sol::state*)scripts->user_datas[i];
internal::script_activate(*state, scripts->entities[i],
scripts->update_intervals[i]);
}
Expand All @@ -295,7 +295,7 @@ static void on_deactivate_scripts(const io_user_script_batch* scripts,
{
for (uint32_t i = 0u; i < scripts_length; ++i)
{
sol::state* state = (sol::state*)scripts->user_datas[i];
auto* state = (sol::state*)scripts->user_datas[i];
internal::script_deactivate(*state, scripts->entities[i]);
}

Expand All @@ -310,7 +310,7 @@ static void on_tick_scripts(io_float32_t delta_t,
{
for (uint32_t i = 0u; i < scripts_length; ++i)
{
sol::state* state = (sol::state*)scripts->user_datas[i];
auto* state = (sol::state*)scripts->user_datas[i];
internal::script_tick(*state, delta_t, scripts->entities[i]);
// TODO
internal::script_tick_async(*state, delta_t, scripts->entities[i]);
Expand Down Expand Up @@ -345,7 +345,7 @@ static void on_physics_events(const io_events_header* begin,
if (!internal::scripts_active)
return;

std::vector<lua_physics_contact_event> lua_events;
std::vector<lua_physics_contact_event_t> lua_events;
lua_events.reserve(64u);

const io_events_header* event = begin;
Expand All @@ -356,7 +356,7 @@ static void on_physics_events(const io_events_header* begin,
{
if (event->type.hash == contact_event_type.hash)
{
io_events_data_physics_contact* contact =
auto* contact =
(io_events_data_physics_contact*)io_events_get_data(event);

lua_events.push_back({"physics_contact",
Expand Down
Loading

0 comments on commit 9c8f628

Please sign in to comment.