Skip to content

Commit 9fe8bf6

Browse files
authored
clean-code: naming convention (#201)
1 parent 4b5b962 commit 9fe8bf6

25 files changed

+1071
-967
lines changed

engine/source/editor/source/editor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ namespace Pilot
3535
EditorGlobalContextInitInfo init_info = {g_runtime_global_context.m_window_system.get(),
3636
g_runtime_global_context.m_render_system.get()};
3737
g_editor_global_context.initialize(init_info);
38-
g_editor_global_context.m_scene_manager->setEditorCamera(g_runtime_global_context.m_render_system->getRenderCamera());
38+
g_editor_global_context.m_scene_manager->setEditorCamera(
39+
g_runtime_global_context.m_render_system->getRenderCamera());
3940
g_editor_global_context.m_scene_manager->uploadAxisResource();
4041

4142
m_editor_ui = std::make_shared<EditorUI>();
42-
WindowUIInitInfo ui_init_info = {g_runtime_global_context.m_window_system, g_runtime_global_context.m_render_system};
43+
WindowUIInitInfo ui_init_info = {g_runtime_global_context.m_window_system,
44+
g_runtime_global_context.m_render_system};
4345
m_editor_ui->initialize(ui_init_info);
4446
}
4547

@@ -52,7 +54,7 @@ namespace Pilot
5254
float delta_time;
5355
while (true)
5456
{
55-
delta_time = m_engine_runtime->getDeltaTime();
57+
delta_time = m_engine_runtime->calculateDeltaTime();
5658
g_editor_global_context.m_scene_manager->tick(delta_time);
5759
g_editor_global_context.m_input_manager->tick(delta_time);
5860
if (!m_engine_runtime->tickOneFrame(delta_time))

engine/source/runtime/engine.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,30 @@ namespace Pilot
3939

4040
void PilotEngine::run()
4141
{
42+
std::shared_ptr<WindowSystem> window_system = g_runtime_global_context.m_window_system;
43+
ASSERT(window_system);
44+
4245
float delta_time;
43-
while (!g_runtime_global_context.m_window_system->shouldClose())
46+
while (!window_system->shouldClose())
4447
{
45-
delta_time = getDeltaTime();
48+
delta_time = calculateDeltaTime();
4649

4750
logicalTick(delta_time);
48-
fps(delta_time);
51+
calculateFPS(delta_time);
4952

5053
// single thread
5154
// exchange data between logic and render contexts
5255
g_runtime_global_context.m_render_system->swapLogicRenderData();
5356

5457
rendererTick();
5558

56-
g_runtime_global_context.m_window_system->pollEvents();
59+
window_system->pollEvents();
5760

58-
g_runtime_global_context.m_window_system->setTile(
59-
std::string("Pilot - " + std::to_string(getFPS()) + " FPS").c_str());
61+
window_system->setTile(std::string("Pilot - " + std::to_string(getFPS()) + " FPS").c_str());
6062
}
6163
}
6264

63-
float PilotEngine::getDeltaTime()
65+
float PilotEngine::calculateDeltaTime()
6466
{
6567
float delta_time;
6668
{
@@ -78,7 +80,7 @@ namespace Pilot
7880
bool PilotEngine::tickOneFrame(float delta_time)
7981
{
8082
logicalTick(delta_time);
81-
fps(delta_time);
83+
calculateFPS(delta_time);
8284

8385
// single thread
8486
// exchange data between logic and render contexts
@@ -88,7 +90,8 @@ namespace Pilot
8890

8991
g_runtime_global_context.m_window_system->pollEvents();
9092

91-
g_runtime_global_context.m_window_system->setTile(std::string("Pilot - " + std::to_string(getFPS()) + " FPS").c_str());
93+
g_runtime_global_context.m_window_system->setTile(
94+
std::string("Pilot - " + std::to_string(getFPS()) + " FPS").c_str());
9295

9396
const bool should_window_close = g_runtime_global_context.m_window_system->shouldClose();
9497
return !should_window_close;
@@ -107,7 +110,7 @@ namespace Pilot
107110
}
108111

109112
const float PilotEngine::k_fps_alpha = 1.f / 100;
110-
void PilotEngine::fps(float delta_time)
113+
void PilotEngine::calculateFPS(float delta_time)
111114
{
112115
m_frame_count++;
113116

engine/source/runtime/engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ namespace Pilot
3939
void logicalTick(float delta_time);
4040
bool rendererTick();
4141

42-
void fps(float delta_time);
42+
void calculateFPS(float delta_time);
4343

4444
/**
4545
* Each frame can only be called once
4646
*/
47-
float getDeltaTime();
47+
float calculateDeltaTime();
4848

4949
protected:
5050
EngineInitParams m_init_params;

engine/source/runtime/function/framework/component/camera/camera_component.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace Pilot
5050
if (!m_parent_object.lock())
5151
return;
5252

53-
std::shared_ptr<Level> current_level = g_runtime_global_context.m_world_manager->getCurrentActiveLevel().lock();
53+
std::shared_ptr<Level> current_level = g_runtime_global_context.m_world_manager->getCurrentActiveLevel().lock();
5454
std::shared_ptr<Character> current_character = current_level->getCurrentActiveCharacter().lock();
5555
if (current_character == nullptr)
5656
return;
@@ -75,7 +75,7 @@ namespace Pilot
7575

7676
void CameraComponent::tickFirstPersonCamera(float delta_time)
7777
{
78-
std::shared_ptr<Level> current_level = g_runtime_global_context.m_world_manager->getCurrentActiveLevel().lock();
78+
std::shared_ptr<Level> current_level = g_runtime_global_context.m_world_manager->getCurrentActiveLevel().lock();
7979
std::shared_ptr<Character> current_character = current_level->getCurrentActiveCharacter().lock();
8080
if (current_character == nullptr)
8181
return;
@@ -96,7 +96,7 @@ namespace Pilot
9696

9797
if (m_render_camera)
9898
{
99-
m_render_camera->setMainViewMatrix(desired_mat, PCurrentCameraType::Motor);
99+
m_render_camera->setMainViewMatrix(desired_mat, CurrentCameraType::Motor);
100100
}
101101

102102
Vector3 object_facing = m_foward - m_foward.dotProduct(Vector3::UNIT_Z) * Vector3::UNIT_Z;
@@ -108,7 +108,7 @@ namespace Pilot
108108

109109
void CameraComponent::tickThirdPersonCamera(float delta_time)
110110
{
111-
std::shared_ptr<Level> current_level = g_runtime_global_context.m_world_manager->getCurrentActiveLevel().lock();
111+
std::shared_ptr<Level> current_level = g_runtime_global_context.m_world_manager->getCurrentActiveLevel().lock();
112112
std::shared_ptr<Character> current_character = current_level->getCurrentActiveCharacter().lock();
113113
if (current_character == nullptr)
114114
return;
@@ -138,7 +138,7 @@ namespace Pilot
138138

139139
if (m_render_camera)
140140
{
141-
m_render_camera->setMainViewMatrix(desired_mat, PCurrentCameraType::Motor);
141+
m_render_camera->setMainViewMatrix(desired_mat, CurrentCameraType::Motor);
142142
}
143143
}
144144
} // namespace Pilot

engine/source/runtime/function/render/light.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Pilot
1010
{
11-
struct PPointLight
11+
struct PointLight
1212
{
1313
Vector3 m_position;
1414
// radiant flux in W
@@ -29,7 +29,7 @@ namespace Pilot
2929
}
3030
};
3131

32-
struct PAmbientLight
32+
struct AmbientLight
3333
{
3434
Vector3 m_irradiance;
3535
};
@@ -40,7 +40,7 @@ namespace Pilot
4040
Vector3 m_color;
4141
};
4242

43-
struct PLightList
43+
struct LightList
4444
{
4545
// vertex buffers seem to be aligned to 16 bytes
4646
struct PointLightVertex
@@ -54,7 +54,7 @@ namespace Pilot
5454
};
5555
};
5656

57-
class PPointLightList : public PLightList
57+
class PointLightList : public LightList
5858
{
5959
public:
6060
void init() {}
@@ -63,7 +63,7 @@ namespace Pilot
6363
// upload changes to GPU
6464
void update() {}
6565

66-
std::vector<PPointLight> m_lights;
66+
std::vector<PointLight> m_lights;
6767

6868
std::shared_ptr<BufferData> m_buffer;
6969
};

engine/source/runtime/function/render/passes/color_grading_pass.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ namespace Pilot
6969
pipeline_layout_create_info.pSetLayouts = descriptorset_layouts;
7070

7171
if (vkCreatePipelineLayout(
72-
m_vulkan_rhi->_device, &pipeline_layout_create_info, nullptr, &m_render_pipelines[0].layout) != VK_SUCCESS)
72+
m_vulkan_rhi->_device, &pipeline_layout_create_info, nullptr, &m_render_pipelines[0].layout) !=
73+
VK_SUCCESS)
7374
{
7475
throw std::runtime_error("create post process pipeline layout");
7576
}
7677

77-
VkShaderModule vert_shader_module = PVulkanUtil::createShaderModule(m_vulkan_rhi->_device, POST_PROCESS_VERT);
78-
VkShaderModule frag_shader_module = PVulkanUtil::createShaderModule(m_vulkan_rhi->_device, COLOR_GRADING_FRAG);
78+
VkShaderModule vert_shader_module = VulkanUtil::createShaderModule(m_vulkan_rhi->_device, POST_PROCESS_VERT);
79+
VkShaderModule frag_shader_module = VulkanUtil::createShaderModule(m_vulkan_rhi->_device, COLOR_GRADING_FRAG);
7980

8081
VkPipelineShaderStageCreateInfo vert_pipeline_shader_stage_create_info {};
8182
vert_pipeline_shader_stage_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@@ -215,13 +216,13 @@ namespace Pilot
215216
{
216217
VkDescriptorImageInfo post_process_per_frame_input_attachment_info = {};
217218
post_process_per_frame_input_attachment_info.sampler =
218-
PVulkanUtil::getOrCreateNearestSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
219+
VulkanUtil::getOrCreateNearestSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
219220
post_process_per_frame_input_attachment_info.imageView = input_attachment;
220221
post_process_per_frame_input_attachment_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
221222

222223
VkDescriptorImageInfo color_grading_LUT_image_info = {};
223224
color_grading_LUT_image_info.sampler =
224-
PVulkanUtil::getOrCreateLinearSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
225+
VulkanUtil::getOrCreateLinearSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
225226
color_grading_LUT_image_info.imageView =
226227
m_global_render_resource->_color_grading_resource._color_grading_LUT_texture_image_view;
227228
color_grading_LUT_image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
@@ -271,13 +272,13 @@ namespace Pilot
271272
m_vulkan_rhi->_vkCmdSetViewport(m_vulkan_rhi->_current_command_buffer, 0, 1, &m_vulkan_rhi->_viewport);
272273
m_vulkan_rhi->_vkCmdSetScissor(m_vulkan_rhi->_current_command_buffer, 0, 1, &m_vulkan_rhi->_scissor);
273274
m_vulkan_rhi->_vkCmdBindDescriptorSets(m_vulkan_rhi->_current_command_buffer,
274-
VK_PIPELINE_BIND_POINT_GRAPHICS,
275-
m_render_pipelines[0].layout,
276-
0,
277-
1,
278-
&m_descriptor_infos[0].descriptor_set,
279-
0,
280-
NULL);
275+
VK_PIPELINE_BIND_POINT_GRAPHICS,
276+
m_render_pipelines[0].layout,
277+
0,
278+
1,
279+
&m_descriptor_infos[0].descriptor_set,
280+
0,
281+
NULL);
281282

282283
vkCmdDraw(m_vulkan_rhi->_current_command_buffer, 3, 1, 0, 0);
283284

engine/source/runtime/function/render/passes/combine_ui_pass.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ namespace Pilot
7070
pipeline_layout_create_info.pSetLayouts = descriptorset_layouts;
7171

7272
if (vkCreatePipelineLayout(
73-
m_vulkan_rhi->_device, &pipeline_layout_create_info, nullptr, &m_render_pipelines[0].layout) != VK_SUCCESS)
73+
m_vulkan_rhi->_device, &pipeline_layout_create_info, nullptr, &m_render_pipelines[0].layout) !=
74+
VK_SUCCESS)
7475
{
7576
throw std::runtime_error("create combine ui pipeline layout");
7677
}
7778

78-
VkShaderModule vert_shader_module = PVulkanUtil::createShaderModule(m_vulkan_rhi->_device, POST_PROCESS_VERT);
79-
VkShaderModule frag_shader_module = PVulkanUtil::createShaderModule(m_vulkan_rhi->_device, COMBINE_UI_FRAG);
79+
VkShaderModule vert_shader_module = VulkanUtil::createShaderModule(m_vulkan_rhi->_device, POST_PROCESS_VERT);
80+
VkShaderModule frag_shader_module = VulkanUtil::createShaderModule(m_vulkan_rhi->_device, COMBINE_UI_FRAG);
8081

8182
VkPipelineShaderStageCreateInfo vert_pipeline_shader_stage_create_info {};
8283
vert_pipeline_shader_stage_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@@ -217,13 +218,13 @@ namespace Pilot
217218
{
218219
VkDescriptorImageInfo per_frame_scene_input_attachment_info = {};
219220
per_frame_scene_input_attachment_info.sampler =
220-
PVulkanUtil::getOrCreateNearestSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
221+
VulkanUtil::getOrCreateNearestSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
221222
per_frame_scene_input_attachment_info.imageView = scene_input_attachment;
222223
per_frame_scene_input_attachment_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
223224

224225
VkDescriptorImageInfo per_frame_ui_input_attachment_info = {};
225226
per_frame_ui_input_attachment_info.sampler =
226-
PVulkanUtil::getOrCreateNearestSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
227+
VulkanUtil::getOrCreateNearestSampler(m_vulkan_rhi->_physical_device, m_vulkan_rhi->_device);
227228
per_frame_ui_input_attachment_info.imageView = ui_input_attachment;
228229
per_frame_ui_input_attachment_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
229230

@@ -279,13 +280,13 @@ namespace Pilot
279280
m_vulkan_rhi->_vkCmdSetViewport(m_vulkan_rhi->_current_command_buffer, 0, 1, &viewport);
280281
m_vulkan_rhi->_vkCmdSetScissor(m_vulkan_rhi->_current_command_buffer, 0, 1, &scissor);
281282
m_vulkan_rhi->_vkCmdBindDescriptorSets(m_vulkan_rhi->_current_command_buffer,
282-
VK_PIPELINE_BIND_POINT_GRAPHICS,
283-
m_render_pipelines[0].layout,
284-
0,
285-
1,
286-
&m_descriptor_infos[0].descriptor_set,
287-
0,
288-
NULL);
283+
VK_PIPELINE_BIND_POINT_GRAPHICS,
284+
m_render_pipelines[0].layout,
285+
0,
286+
1,
287+
&m_descriptor_infos[0].descriptor_set,
288+
0,
289+
NULL);
289290

290291
vkCmdDraw(m_vulkan_rhi->_current_command_buffer, 3, 1, 0, 0);
291292

0 commit comments

Comments
 (0)