Archived
1
Fork 0

Fix some clang-tidy warnings

This commit is contained in:
redstrate 2021-04-19 12:35:52 -04:00
parent 3827bede6d
commit 4b9754fa03
2 changed files with 33 additions and 30 deletions

View file

@ -54,10 +54,10 @@ namespace prism {
/// Command line arguments, can be empty. /// Command line arguments, can be empty.
std::vector<std::string_view> command_line_arguments; std::vector<std::string_view> command_line_arguments;
/** Sets the app object. /** Sets the p_app object.
@param app The app object to set. Must not be null. @param p_app The p_app object to set. Must not be null.
*/ */
void set_app(app* app); void set_app(app* p_app);
/** Gets the current app object /** Gets the current app object
@return The current app object. Can be null. @return The current app object. Can be null.
@ -102,9 +102,9 @@ namespace prism {
[[nodiscard]] bool is_quitting() const; [[nodiscard]] bool is_quitting() const;
/** Set the GFX api to use. /** Set the GFX api to use.
@param gfx The GFX object to use. Must not be null. @param p_gfx The GFX object to use. Must not be null.
*/ */
void set_gfx(GFX* gfx); void set_gfx(GFX* p_gfx);
/** Get the current GFX api. /** Get the current GFX api.
@return The current GFX api. Can be null. @return The current GFX api. Can be null.
@ -134,7 +134,7 @@ namespace prism {
@param path The scene file path. @param path The scene file path.
@return Returns a instance of the scene is successful, and nullptr on failure. @return Returns a instance of the scene is successful, and nullptr on failure.
*/ */
Scene* load_scene(file::Path path); Scene* load_scene(const file::Path& path);
/** Save the current scene to disk. /** Save the current scene to disk.
@param path The absolute file path. @param path The absolute file path.
@ -145,7 +145,7 @@ namespace prism {
@param path The screen file path. @param path The screen file path.
@return Returns a instance of the screen if successful, and nullptr on failure. @return Returns a instance of the screen if successful, and nullptr on failure.
*/ */
ui::Screen* load_screen(file::Path path); ui::Screen* load_screen(const file::Path& path);
/** Set the current screen. /** Set the current screen.
@param screen The screen object to set as current. Can be null. @param screen The screen object to set as current. Can be null.
@ -162,7 +162,7 @@ namespace prism {
@param path The prefab file path. @param path The prefab file path.
@param override_name If not empty, the root object's new name. Defaulted to a empty string. @param override_name If not empty, the root object's new name. Defaulted to a empty string.
*/ */
Object add_prefab(Scene& scene, file::Path path, std::string_view override_name = ""); Object add_prefab(Scene& scene, const file::Path& path, std::string_view override_name = "");
/** Save a tree of objects as a prefab to disk. /** Save a tree of objects as a prefab to disk.
@param root The parent object to save as a prefab. @param root The parent object to save as a prefab.
@ -180,12 +180,12 @@ namespace prism {
@param path The animation file path. @param path The animation file path.
@return An animation. @return An animation.
*/ */
Animation load_animation(file::Path path); Animation load_animation(const file::Path& path);
/** Load a cutscene from disk. This changes the current cutscene. /** Load a cutscene from disk. This changes the current cutscene.
@param path The cutscene file path. @param path The cutscene file path.
*/ */
void load_cutscene(file::Path path); void load_cutscene(const file::Path& path);
/** Saves the current cutscene to disk. /** Saves the current cutscene to disk.
@param path The absolute file path. @param path The absolute file path.
@ -254,7 +254,7 @@ namespace prism {
@return A localized string if the key is found, or an empty string if not found. @return A localized string if the key is found, or an empty string if not found.
@note Having no localization loaded will always return a empty string. @note Having no localization loaded will always return a empty string.
*/ */
std::string localize(std::string id); std::string localize(const std::string& id);
/** Adds a timer to the list of timers. /** Adds a timer to the list of timers.
@param timer The timer to add. @param timer The timer to add.
@ -362,7 +362,7 @@ namespace prism {
void calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, const Bone* parent_bone = nullptr); void calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, const Bone* parent_bone = nullptr);
void calculate_object(Scene& scene, Object object, Object parent_object = NullObject); void calculate_object(Scene& scene, Object object, Object parent_object = NullObject);
Shot* get_shot(float time); Shot* get_shot(float time) const;
void update_animation(const Animation& anim, float time); void update_animation(const Animation& anim, float time);
void update_cutscene(float time); void update_cutscene(float time);

View file

@ -1,6 +1,7 @@
#include "engine.hpp" #include "engine.hpp"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <utility>
#include <imgui.h> #include <imgui.h>
#include "scene.hpp" #include "scene.hpp"
@ -28,7 +29,7 @@ using prism::engine;
engine::engine(const int argc, char* argv[]) { engine::engine(const int argc, char* argv[]) {
console::info(System::Core, "Prism Engine loading..."); console::info(System::Core, "Prism Engine loading...");
console::register_command("test_cmd", console::ArgumentFormat(0), [](const console::Arguments) { console::register_command("test_cmd", console::ArgumentFormat(0), [](const console::Arguments&) {
console::info(System::Core, "Test cmd!"); console::info(System::Core, "Test cmd!");
}); });
@ -39,7 +40,7 @@ engine::engine(const int argc, char* argv[]) {
}); });
for(int i = 0; i < argc; i++) for(int i = 0; i < argc; i++)
command_line_arguments.push_back(argv[i]); command_line_arguments.emplace_back(argv[i]);
input = std::make_unique<Input>(); input = std::make_unique<Input>();
physics = std::make_unique<Physics>(); physics = std::make_unique<Physics>();
@ -47,12 +48,12 @@ engine::engine(const int argc, char* argv[]) {
assetm = std::make_unique<AssetManager>(); assetm = std::make_unique<AssetManager>();
} }
engine::~engine() {} engine::~engine() = default;
void engine::set_app(prism::app* app) { void engine::set_app(prism::app* p_app) {
Expects(app != nullptr); Expects(p_app != nullptr);
this->app = app; this->app = p_app;
} }
prism::app* engine::get_app() const { prism::app* engine::get_app() const {
@ -97,8 +98,10 @@ void engine::prepare_quit() {
app->prepare_quit(); app->prepare_quit();
} }
void engine::set_gfx(GFX* gfx) { void engine::set_gfx(GFX* p_gfx) {
this->gfx = gfx; Expects(p_gfx != nullptr);
this->gfx = p_gfx;
} }
GFX* engine::get_gfx() { GFX* engine::get_gfx() {
@ -126,7 +129,7 @@ void engine::create_empty_scene() {
current_scene = scenes.back().get(); current_scene = scenes.back().get();
} }
Scene* engine::load_scene(const file::Path path) { Scene* engine::load_scene(const file::Path& path) {
Expects(!path.empty()); Expects(!path.empty());
auto file = file::open(path); auto file = file::open(path);
@ -153,7 +156,7 @@ Scene* engine::load_scene(const file::Path path) {
transform.rotation = obj["rotation"]; transform.rotation = obj["rotation"];
transform.scale = obj["scale"]; transform.scale = obj["scale"];
} else { } else {
auto o = load_object(*scene.get(), obj); auto o = load_object(*scene, obj);
if(obj.contains("parent")) if(obj.contains("parent"))
parentQueue[o] = obj["parent"]; parentQueue[o] = obj["parent"];
@ -186,7 +189,7 @@ void engine::save_scene(const std::string_view path) {
out << j; out << j;
} }
ui::Screen* engine::load_screen(const file::Path path) { ui::Screen* engine::load_screen(const file::Path& path) {
Expects(!path.empty()); Expects(!path.empty());
return new ui::Screen(path); return new ui::Screen(path);
@ -219,7 +222,7 @@ AnimationChannel engine::load_animation(nlohmann::json a) {
return animation; return animation;
} }
Animation engine::load_animation(const file::Path path) { Animation engine::load_animation(const file::Path& path) {
Expects(!path.empty()); Expects(!path.empty());
auto file = file::open(path, true); auto file = file::open(path, true);
@ -277,7 +280,7 @@ Animation engine::load_animation(const file::Path path) {
return anim; return anim;
} }
void engine::load_cutscene(const file::Path path) { void engine::load_cutscene(const file::Path& path) {
Expects(!path.empty()); Expects(!path.empty());
cutscene = std::make_unique<Cutscene>(); cutscene = std::make_unique<Cutscene>();
@ -354,7 +357,7 @@ void engine::save_cutscene(const std::string_view path) {
out << j; out << j;
} }
Object engine::add_prefab(Scene& scene, const file::Path path, const std::string_view override_name) { Object engine::add_prefab(Scene& scene, const file::Path& path, const std::string_view override_name) {
Expects(!path.empty()); Expects(!path.empty());
auto file = file::open(path); auto file = file::open(path);
@ -416,7 +419,7 @@ void engine::add_window(void* native_handle, const int identifier, const prism::
gfx->initialize_view(native_handle, identifier, drawable_extent.width, drawable_extent.height); gfx->initialize_view(native_handle, identifier, drawable_extent.width, drawable_extent.height);
Window* window = new Window(); auto* window = new Window();
windows.push_back(window); windows.push_back(window);
window->identifier = identifier; window->identifier = identifier;
@ -489,7 +492,7 @@ bool engine::has_localization(const std::string_view id) const {
return strings.count(id.data()); return strings.count(id.data());
} }
std::string engine::localize(const std::string id) { std::string engine::localize(const std::string& id) {
Expects(!id.empty()); Expects(!id.empty());
return strings[id]; return strings[id];
@ -561,7 +564,7 @@ void engine::calculate_object(Scene& scene, Object object, const Object parent_o
calculate_object(scene, child, object); calculate_object(scene, child, object);
} }
Shot* engine::get_shot(const float time) { Shot* engine::get_shot(const float time) const {
for(auto& shot : cutscene->shots) { for(auto& shot : cutscene->shots) {
if(time >= shot.begin && time <= (shot.begin + shot.length)) if(time >= shot.begin && time <= (shot.begin + shot.length))
return &shot; return &shot;
@ -816,7 +819,7 @@ void engine::play_animation(Animation animation, Object object, bool looping) {
return; return;
AnimationTarget target; AnimationTarget target;
target.animation = animation; target.animation = std::move(animation);
target.target = object; target.target = object;
target.looping = looping; target.looping = looping;