Browse Source

Convert base render functions to snake_case naming

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 5 days ago
parent
commit
83b90a3199
5 changed files with 278 additions and 278 deletions
  1. 35 35
      render/draw_queue.h
  2. 11 11
      render/primitive_batch.cpp
  3. 40 40
      render/primitive_batch.h
  4. 115 115
      render/scene_renderer.cpp
  5. 77 77
      render/scene_renderer.h

+ 35 - 35
render/draw_queue.h

@@ -34,7 +34,7 @@ struct MeshCmd {
   QMatrix4x4 mvp;
   QVector3D color{1, 1, 1};
   float alpha = 1.0F;
-  int materialId = 0;
+  int material_id = 0;
   class Shader *shader = nullptr;
 };
 
@@ -59,37 +59,37 @@ struct FogBatchCmd {
 };
 
 struct GrassBatchCmd {
-  Buffer *instanceBuffer = nullptr;
+  Buffer *instance_buffer = nullptr;
   std::size_t instance_count = 0;
   GrassBatchParams params;
 };
 
 struct StoneBatchCmd {
-  Buffer *instanceBuffer = nullptr;
+  Buffer *instance_buffer = nullptr;
   std::size_t instance_count = 0;
   StoneBatchParams params;
 };
 
 struct PlantBatchCmd {
-  Buffer *instanceBuffer = nullptr;
+  Buffer *instance_buffer = nullptr;
   std::size_t instance_count = 0;
   PlantBatchParams params;
 };
 
 struct PineBatchCmd {
-  Buffer *instanceBuffer = nullptr;
+  Buffer *instance_buffer = nullptr;
   std::size_t instance_count = 0;
   PineBatchParams params;
 };
 
 struct OliveBatchCmd {
-  Buffer *instanceBuffer = nullptr;
+  Buffer *instance_buffer = nullptr;
   std::size_t instance_count = 0;
   OliveBatchParams params;
 };
 
 struct FireCampBatchCmd {
-  Buffer *instanceBuffer = nullptr;
+  Buffer *instance_buffer = nullptr;
   std::size_t instance_count = 0;
   FireCampBatchParams params;
 };
@@ -98,9 +98,9 @@ struct TerrainChunkCmd {
   Mesh *mesh = nullptr;
   QMatrix4x4 model;
   TerrainChunkParams params;
-  std::uint16_t sortKey = 0x8000U;
-  bool depthWrite = true;
-  float depthBias = 0.0F;
+  std::uint16_t sort_key = 0x8000U;
+  bool depth_write = true;
+  float depth_bias = 0.0F;
 };
 
 struct GridCmd {
@@ -108,7 +108,7 @@ struct GridCmd {
   QMatrix4x4 model;
   QMatrix4x4 mvp;
   QVector3D color{0.2F, 0.25F, 0.2F};
-  float cellSize = 1.0F;
+  float cell_size = 1.0F;
   float thickness = 0.06F;
   float extent = 50.0F;
 };
@@ -117,15 +117,15 @@ struct SelectionRingCmd {
   QMatrix4x4 model;
   QMatrix4x4 mvp;
   QVector3D color{0, 0, 0};
-  float alphaInner = 0.6F;
-  float alphaOuter = 0.25F;
+  float alpha_inner = 0.6F;
+  float alpha_outer = 0.25F;
 };
 
 struct SelectionSmokeCmd {
   QMatrix4x4 model;
   QMatrix4x4 mvp;
   QVector3D color{1, 1, 1};
-  float baseAlpha = 0.15F;
+  float base_alpha = 0.15F;
 };
 
 using DrawCmd =
@@ -180,7 +180,7 @@ constexpr std::size_t TerrainChunkCmdIndex =
 constexpr std::size_t PrimitiveBatchCmdIndex =
     static_cast<std::size_t>(DrawCmdType::PrimitiveBatch);
 
-inline auto drawCmdType(const DrawCmd &cmd) -> DrawCmdType {
+inline auto draw_cmd_type(const DrawCmd &cmd) -> DrawCmdType {
   return static_cast<DrawCmdType>(cmd.index());
 }
 
@@ -206,32 +206,32 @@ public:
   [[nodiscard]] auto empty() const -> bool { return m_items.empty(); }
   [[nodiscard]] auto size() const -> std::size_t { return m_items.size(); }
 
-  [[nodiscard]] auto getSorted(std::size_t i) const -> const DrawCmd & {
-    return m_items[m_sortIndices[i]];
+  [[nodiscard]] auto get_sorted(std::size_t i) const -> const DrawCmd & {
+    return m_items[m_sort_indices[i]];
   }
 
   [[nodiscard]] auto items() const -> const std::vector<DrawCmd> & {
     return m_items;
   }
 
-  void sortForBatching() {
+  void sort_for_batching() {
     const std::size_t count = m_items.size();
 
-    m_sortKeys.resize(count);
-    m_sortIndices.resize(count);
+    m_sort_keys.resize(count);
+    m_sort_indices.resize(count);
 
     for (std::size_t i = 0; i < count; ++i) {
-      m_sortIndices[i] = static_cast<uint32_t>(i);
-      m_sortKeys[i] = computeSortKey(m_items[i]);
+      m_sort_indices[i] = static_cast<uint32_t>(i);
+      m_sort_keys[i] = compute_sort_key(m_items[i]);
     }
 
     if (count >= 2) {
-      radixSortTwoPass(count);
+      radix_sort_two_pass(count);
     }
   }
 
 private:
-  void radixSortTwoPass(std::size_t count) {
+  void radix_sort_two_pass(std::size_t count) {
     constexpr int BUCKETS = 256;
 
     m_tempIndices.resize(count);
@@ -334,42 +334,42 @@ private:
     } else if (cmd.index() == GrassBatchCmdIndex) {
       const auto &grass = std::get<GrassBatchCmdIndex>(cmd);
       uint64_t const bufferPtr =
-          reinterpret_cast<uintptr_t>(grass.instanceBuffer) &
+          reinterpret_cast<uintptr_t>(grass.instance_buffer) &
           0x0000FFFFFFFFFFFF;
       key |= bufferPtr;
     } else if (cmd.index() == StoneBatchCmdIndex) {
       const auto &stone = std::get<StoneBatchCmdIndex>(cmd);
       uint64_t const bufferPtr =
-          reinterpret_cast<uintptr_t>(stone.instanceBuffer) &
+          reinterpret_cast<uintptr_t>(stone.instance_buffer) &
           0x0000FFFFFFFFFFFF;
       key |= bufferPtr;
     } else if (cmd.index() == PlantBatchCmdIndex) {
       const auto &plant = std::get<PlantBatchCmdIndex>(cmd);
       uint64_t const bufferPtr =
-          reinterpret_cast<uintptr_t>(plant.instanceBuffer) &
+          reinterpret_cast<uintptr_t>(plant.instance_buffer) &
           0x0000FFFFFFFFFFFF;
       key |= bufferPtr;
     } else if (cmd.index() == PineBatchCmdIndex) {
       const auto &pine = std::get<PineBatchCmdIndex>(cmd);
       uint64_t const bufferPtr =
-          reinterpret_cast<uintptr_t>(pine.instanceBuffer) & 0x0000FFFFFFFFFFFF;
+          reinterpret_cast<uintptr_t>(pine.instance_buffer) & 0x0000FFFFFFFFFFFF;
       key |= bufferPtr;
     } else if (cmd.index() == OliveBatchCmdIndex) {
       const auto &olive = std::get<OliveBatchCmdIndex>(cmd);
       uint64_t const bufferPtr =
-          reinterpret_cast<uintptr_t>(olive.instanceBuffer) &
+          reinterpret_cast<uintptr_t>(olive.instance_buffer) &
           0x0000FFFFFFFFFFFF;
       key |= bufferPtr;
     } else if (cmd.index() == FireCampBatchCmdIndex) {
       const auto &firecamp = std::get<FireCampBatchCmdIndex>(cmd);
       uint64_t const bufferPtr =
-          reinterpret_cast<uintptr_t>(firecamp.instanceBuffer) &
+          reinterpret_cast<uintptr_t>(firecamp.instance_buffer) &
           0x0000FFFFFFFFFFFF;
       key |= bufferPtr;
     } else if (cmd.index() == TerrainChunkCmdIndex) {
       const auto &terrain = std::get<TerrainChunkCmdIndex>(cmd);
       auto const sortByte =
-          static_cast<uint64_t>((terrain.sortKey >> 8) & 0xFFU);
+          static_cast<uint64_t>((terrain.sort_key >> 8) & 0xFFU);
       key |= sortByte << 48;
       uint64_t const meshPtr =
           reinterpret_cast<uintptr_t>(terrain.mesh) & 0x0000FFFFFFFFFFFFU;
@@ -379,16 +379,16 @@ private:
 
       key |= static_cast<uint64_t>(prim.type) << 48;
 
-      key |= static_cast<uint64_t>(prim.instanceCount() & 0xFFFFFFFF);
+      key |= static_cast<uint64_t>(prim.instance_count() & 0xFFFFFFFF);
     }
 
     return key;
   }
 
   std::vector<DrawCmd> m_items;
-  std::vector<uint32_t> m_sortIndices;
-  std::vector<uint64_t> m_sortKeys;
-  std::vector<uint32_t> m_tempIndices;
+  std::vector<uint32_t> m_sort_indices;
+  std::vector<uint64_t> m_sort_keys;
+  std::vector<uint32_t> m_temp_indices;
 };
 
 } // namespace Render::GL

+ 11 - 11
render/primitive_batch.cpp

@@ -16,28 +16,28 @@ PrimitiveBatcher::~PrimitiveBatcher() = default;
 void PrimitiveBatcher::addSphere(const QMatrix4x4 &transform,
                                  const QVector3D &color, float alpha) {
   PrimitiveInstanceGpu inst;
-  inst.setTransform(transform);
-  inst.setColor(color, alpha);
+  inst.set_transform(transform);
+  inst.set_color(color, alpha);
   m_spheres.push_back(inst);
-  ++s_batchStats.spheresSubmitted;
+  ++s_batchStats.spheres_submitted;
 }
 
 void PrimitiveBatcher::addCylinder(const QMatrix4x4 &transform,
                                    const QVector3D &color, float alpha) {
   PrimitiveInstanceGpu inst;
-  inst.setTransform(transform);
-  inst.setColor(color, alpha);
+  inst.set_transform(transform);
+  inst.set_color(color, alpha);
   m_cylinders.push_back(inst);
-  ++s_batchStats.cylindersSubmitted;
+  ++s_batchStats.cylinders_submitted;
 }
 
 void PrimitiveBatcher::addCone(const QMatrix4x4 &transform,
                                const QVector3D &color, float alpha) {
   PrimitiveInstanceGpu inst;
-  inst.setTransform(transform);
-  inst.setColor(color, alpha);
+  inst.set_transform(transform);
+  inst.set_color(color, alpha);
   m_cones.push_back(inst);
-  ++s_batchStats.conesSubmitted;
+  ++s_batchStats.cones_submitted;
 }
 
 void PrimitiveBatcher::clear() {
@@ -53,10 +53,10 @@ void PrimitiveBatcher::reserve(std::size_t spheres, std::size_t cylinders,
   m_cones.reserve(cones);
 }
 
-auto getPrimitiveBatchStats() -> const PrimitiveBatchStats & {
+auto get_primitive_batch_stats() -> const PrimitiveBatchStats & {
   return s_batchStats;
 }
 
-void resetPrimitiveBatchStats() { s_batchStats.reset(); }
+void reset_primitive_batch_stats() { s_batchStats.reset(); }
 
 } // namespace Render::GL

+ 40 - 40
render/primitive_batch.h

@@ -14,23 +14,23 @@ class Mesh;
 
 struct PrimitiveInstanceGpu {
 
-  QVector4D modelCol0{1.0F, 0.0F, 0.0F, 0.0F};
-  QVector4D modelCol1{0.0F, 1.0F, 0.0F, 0.0F};
-  QVector4D modelCol2{0.0F, 0.0F, 1.0F, 0.0F};
+  QVector4D model_col0{1.0F, 0.0F, 0.0F, 0.0F};
+  QVector4D model_col1{0.0F, 1.0F, 0.0F, 0.0F};
+  QVector4D model_col2{0.0F, 0.0F, 1.0F, 0.0F};
 
-  QVector4D colorAlpha{1.0F, 1.0F, 1.0F, 1.0F};
+  QVector4D color_alpha{1.0F, 1.0F, 1.0F, 1.0F};
 
-  void setTransform(const QMatrix4x4 &m) {
+  void set_transform(const QMatrix4x4 &m) {
 
-    modelCol0 = QVector4D(m(0, 0), m(1, 0), m(2, 0), m(0, 3));
+    model_col0 = QVector4D(m(0, 0), m(1, 0), m(2, 0), m(0, 3));
 
-    modelCol1 = QVector4D(m(0, 1), m(1, 1), m(2, 1), m(1, 3));
+    model_col1 = QVector4D(m(0, 1), m(1, 1), m(2, 1), m(1, 3));
 
-    modelCol2 = QVector4D(m(0, 2), m(1, 2), m(2, 2), m(2, 3));
+    model_col2 = QVector4D(m(0, 2), m(1, 2), m(2, 2), m(2, 3));
   }
 
-  void setColor(const QVector3D &color, float alpha = 1.0F) {
-    colorAlpha = QVector4D(color.x(), color.y(), color.z(), alpha);
+  void set_color(const QVector3D &color, float alpha = 1.0F) {
+    color_alpha = QVector4D(color.x(), color.y(), color.z(), alpha);
   }
 };
 
@@ -38,9 +38,9 @@ static_assert(sizeof(PrimitiveInstanceGpu) == 64,
               "PrimitiveInstanceGpu must be 64 bytes for GPU alignment");
 
 struct PrimitiveBatchParams {
-  QMatrix4x4 viewProj;
-  QVector3D lightDirection{0.35F, 0.8F, 0.45F};
-  float ambientStrength{0.3F};
+  QMatrix4x4 view_proj;
+  QVector3D light_direction{0.35F, 0.8F, 0.45F};
+  float ambient_strength{0.3F};
 };
 
 enum class PrimitiveType : uint8_t { Sphere = 0, Cylinder = 1, Cone = 2 };
@@ -50,10 +50,10 @@ struct PrimitiveBatchCmd {
   std::vector<PrimitiveInstanceGpu> instances;
   PrimitiveBatchParams params;
 
-  [[nodiscard]] auto instanceCount() const -> std::size_t {
+  [[nodiscard]] auto instance_count() const -> std::size_t {
     return instances.size();
   }
-  [[nodiscard]] auto instanceData() const -> const PrimitiveInstanceGpu * {
+  [[nodiscard]] auto instance_data() const -> const PrimitiveInstanceGpu * {
     return instances.empty() ? nullptr : instances.data();
   }
 };
@@ -63,34 +63,34 @@ public:
   PrimitiveBatcher();
   ~PrimitiveBatcher();
 
-  void addSphere(const QMatrix4x4 &transform, const QVector3D &color,
-                 float alpha = 1.0F);
-  void addCylinder(const QMatrix4x4 &transform, const QVector3D &color,
-                   float alpha = 1.0F);
-  void addCone(const QMatrix4x4 &transform, const QVector3D &color,
-               float alpha = 1.0F);
+  void add_sphere(const QMatrix4x4 &transform, const QVector3D &color,
+                  float alpha = 1.0F);
+  void add_cylinder(const QMatrix4x4 &transform, const QVector3D &color,
+                    float alpha = 1.0F);
+  void add_cone(const QMatrix4x4 &transform, const QVector3D &color,
+                float alpha = 1.0F);
 
-  [[nodiscard]] auto sphereCount() const -> std::size_t {
+  [[nodiscard]] auto sphere_count() const -> std::size_t {
     return m_spheres.size();
   }
-  [[nodiscard]] auto cylinderCount() const -> std::size_t {
+  [[nodiscard]] auto cylinder_count() const -> std::size_t {
     return m_cylinders.size();
   }
-  [[nodiscard]] auto coneCount() const -> std::size_t { return m_cones.size(); }
-  [[nodiscard]] auto totalCount() const -> std::size_t {
+  [[nodiscard]] auto cone_count() const -> std::size_t { return m_cones.size(); }
+  [[nodiscard]] auto total_count() const -> std::size_t {
     return m_spheres.size() + m_cylinders.size() + m_cones.size();
   }
 
   [[nodiscard]] auto
-  sphereData() const -> const std::vector<PrimitiveInstanceGpu> & {
+  sphere_data() const -> const std::vector<PrimitiveInstanceGpu> & {
     return m_spheres;
   }
   [[nodiscard]] auto
-  cylinderData() const -> const std::vector<PrimitiveInstanceGpu> & {
+  cylinder_data() const -> const std::vector<PrimitiveInstanceGpu> & {
     return m_cylinders;
   }
   [[nodiscard]] auto
-  coneData() const -> const std::vector<PrimitiveInstanceGpu> & {
+  cone_data() const -> const std::vector<PrimitiveInstanceGpu> & {
     return m_cones;
   }
 
@@ -105,22 +105,22 @@ private:
 };
 
 struct PrimitiveBatchStats {
-  uint32_t spheresSubmitted{0};
-  uint32_t cylindersSubmitted{0};
-  uint32_t conesSubmitted{0};
-  uint32_t batchesRendered{0};
-  uint32_t drawCallsSaved{0};
+  uint32_t spheres_submitted{0};
+  uint32_t cylinders_submitted{0};
+  uint32_t cones_submitted{0};
+  uint32_t batches_rendered{0};
+  uint32_t draw_calls_saved{0};
 
   void reset() {
-    spheresSubmitted = 0;
-    cylindersSubmitted = 0;
-    conesSubmitted = 0;
-    batchesRendered = 0;
-    drawCallsSaved = 0;
+    spheres_submitted = 0;
+    cylinders_submitted = 0;
+    cones_submitted = 0;
+    batches_rendered = 0;
+    draw_calls_saved = 0;
   }
 };
 
-auto getPrimitiveBatchStats() -> const PrimitiveBatchStats &;
-void resetPrimitiveBatchStats();
+auto get_primitive_batch_stats() -> const PrimitiveBatchStats &;
+void reset_primitive_batch_stats();
 
 } // namespace Render::GL

+ 115 - 115
render/scene_renderer.cpp

@@ -44,7 +44,7 @@ const QVector3D k_axis_y(0.0F, 1.0F, 0.0F);
 const QVector3D k_axis_z(0.0F, 0.0F, 1.0F);
 } // namespace
 
-Renderer::Renderer() { m_activeQueue = &m_queues[m_fillQueueIndex]; }
+Renderer::Renderer() { m_active_queue = &m_queues[m_fill_queue_index]; }
 
 Renderer::~Renderer() { shutdown(); }
 
@@ -53,23 +53,23 @@ auto Renderer::initialize() -> bool {
     m_backend = std::make_shared<Backend>();
   }
   m_backend->initialize();
-  m_entityRegistry = std::make_unique<EntityRendererRegistry>();
-  registerBuiltInEntityRenderers(*m_entityRegistry);
+  m_entity_registry = std::make_unique<EntityRendererRegistry>();
+  registerBuiltInEntityRenderers(*m_entity_registry);
   registerBuiltInEquipment();
   return true;
 }
 
 void Renderer::shutdown() { m_backend.reset(); }
 
-void Renderer::beginFrame() {
+void Renderer::begin_frame() {
 
   advancePoseCacheFrame();
 
   resetHumanoidRenderStats();
   resetHorseRenderStats();
 
-  m_activeQueue = &m_queues[m_fillQueueIndex];
-  m_activeQueue->clear();
+  m_active_queue = &m_queues[m_fill_queue_index];
+  m_active_queue->clear();
 
   if (m_camera != nullptr) {
     m_view_proj = m_camera->getProjectionMatrix() * m_camera->getViewMatrix();
@@ -80,30 +80,30 @@ void Renderer::beginFrame() {
   }
 }
 
-void Renderer::endFrame() {
+void Renderer::end_frame() {
   if (m_paused.load()) {
     return;
   }
   if (m_backend && (m_camera != nullptr)) {
-    std::swap(m_fillQueueIndex, m_render_queueIndex);
-    DrawQueue &render_queue = m_queues[m_render_queueIndex];
-    render_queue.sortForBatching();
-    m_backend->setAnimationTime(m_accumulatedTime);
+    std::swap(m_fill_queue_index, m_render_queue_index);
+    DrawQueue &render_queue = m_queues[m_render_queue_index];
+    render_queue.sort_for_batching();
+    m_backend->setAnimationTime(m_accumulated_time);
     m_backend->execute(render_queue, *m_camera);
   }
 }
 
-void Renderer::setCamera(Camera *camera) { m_camera = camera; }
+void Renderer::set_camera(Camera *camera) { m_camera = camera; }
 
-void Renderer::setClearColor(float r, float g, float b, float a) {
+void Renderer::set_clear_color(float r, float g, float b, float a) {
   if (m_backend) {
     m_backend->setClearColor(r, g, b, a);
   }
 }
 
-void Renderer::setViewport(int width, int height) {
-  m_viewportWidth = width;
-  m_viewportHeight = height;
+void Renderer::set_viewport(int width, int height) {
+  m_viewport_width = width;
+  m_viewport_height = height;
   if (m_backend) {
     m_backend->setViewport(width, height);
   }
@@ -114,13 +114,13 @@ void Renderer::setViewport(int width, int height) {
   }
 }
 void Renderer::mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
-                    Texture *texture, float alpha, int materialId) {
+                    Texture *texture, float alpha, int material_id) {
   if (mesh == nullptr) {
     return;
   }
 
   if (mesh == getUnitCylinder() && (texture == nullptr) &&
-      (m_currentShader == nullptr)) {
+      (m_current_shader == nullptr)) {
     QVector3D start;
     QVector3D end;
     float radius = 0.0F;
@@ -136,10 +136,10 @@ void Renderer::mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
   cmd.mvp = m_view_proj * model;
   cmd.color = color;
   cmd.alpha = alpha;
-  cmd.materialId = materialId;
-  cmd.shader = m_currentShader;
-  if (m_activeQueue != nullptr) {
-    m_activeQueue->submit(cmd);
+  cmd.material_id = material_id;
+  cmd.shader = m_current_shader;
+  if (m_active_queue != nullptr) {
+    m_active_queue->submit(cmd);
   }
 }
 
@@ -151,164 +151,164 @@ void Renderer::cylinder(const QVector3D &start, const QVector3D &end,
   cmd.radius = radius;
   cmd.color = color;
   cmd.alpha = alpha;
-  if (m_activeQueue != nullptr) {
-    m_activeQueue->submit(cmd);
+  if (m_active_queue != nullptr) {
+    m_active_queue->submit(cmd);
   }
 }
 
-void Renderer::fogBatch(const FogInstanceData *instances, std::size_t count) {
-  if ((instances == nullptr) || count == 0 || (m_activeQueue == nullptr)) {
+void Renderer::fog_batch(const FogInstanceData *instances, std::size_t count) {
+  if ((instances == nullptr) || count == 0 || (m_active_queue == nullptr)) {
     return;
   }
   FogBatchCmd cmd;
   cmd.instances = instances;
   cmd.count = count;
-  m_activeQueue->submit(cmd);
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::grassBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                          const GrassBatchParams &params) {
-  if ((instanceBuffer == nullptr) || instance_count == 0 ||
-      (m_activeQueue == nullptr)) {
+void Renderer::grass_batch(Buffer *instance_buffer, std::size_t instance_count,
+                           const GrassBatchParams &params) {
+  if ((instance_buffer == nullptr) || instance_count == 0 ||
+      (m_active_queue == nullptr)) {
     return;
   }
   GrassBatchCmd cmd;
-  cmd.instanceBuffer = instanceBuffer;
+  cmd.instance_buffer = instance_buffer;
   cmd.instance_count = instance_count;
   cmd.params = params;
-  cmd.params.time = m_accumulatedTime;
-  m_activeQueue->submit(cmd);
+  cmd.params.time = m_accumulated_time;
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::stoneBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                          const StoneBatchParams &params) {
-  if ((instanceBuffer == nullptr) || instance_count == 0 ||
-      (m_activeQueue == nullptr)) {
+void Renderer::stone_batch(Buffer *instance_buffer, std::size_t instance_count,
+                           const StoneBatchParams &params) {
+  if ((instance_buffer == nullptr) || instance_count == 0 ||
+      (m_active_queue == nullptr)) {
     return;
   }
   StoneBatchCmd cmd;
-  cmd.instanceBuffer = instanceBuffer;
+  cmd.instance_buffer = instance_buffer;
   cmd.instance_count = instance_count;
   cmd.params = params;
-  m_activeQueue->submit(cmd);
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::plantBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                          const PlantBatchParams &params) {
-  if ((instanceBuffer == nullptr) || instance_count == 0 ||
-      (m_activeQueue == nullptr)) {
+void Renderer::plant_batch(Buffer *instance_buffer, std::size_t instance_count,
+                           const PlantBatchParams &params) {
+  if ((instance_buffer == nullptr) || instance_count == 0 ||
+      (m_active_queue == nullptr)) {
     return;
   }
   PlantBatchCmd cmd;
-  cmd.instanceBuffer = instanceBuffer;
+  cmd.instance_buffer = instance_buffer;
   cmd.instance_count = instance_count;
   cmd.params = params;
-  cmd.params.time = m_accumulatedTime;
-  m_activeQueue->submit(cmd);
+  cmd.params.time = m_accumulated_time;
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::pineBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                         const PineBatchParams &params) {
-  if ((instanceBuffer == nullptr) || instance_count == 0 ||
-      (m_activeQueue == nullptr)) {
+void Renderer::pine_batch(Buffer *instance_buffer, std::size_t instance_count,
+                          const PineBatchParams &params) {
+  if ((instance_buffer == nullptr) || instance_count == 0 ||
+      (m_active_queue == nullptr)) {
     return;
   }
   PineBatchCmd cmd;
-  cmd.instanceBuffer = instanceBuffer;
+  cmd.instance_buffer = instance_buffer;
   cmd.instance_count = instance_count;
   cmd.params = params;
-  cmd.params.time = m_accumulatedTime;
-  m_activeQueue->submit(cmd);
+  cmd.params.time = m_accumulated_time;
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::oliveBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                          const OliveBatchParams &params) {
-  if ((instanceBuffer == nullptr) || instance_count == 0 ||
-      (m_activeQueue == nullptr)) {
+void Renderer::olive_batch(Buffer *instance_buffer, std::size_t instance_count,
+                           const OliveBatchParams &params) {
+  if ((instance_buffer == nullptr) || instance_count == 0 ||
+      (m_active_queue == nullptr)) {
     return;
   }
   OliveBatchCmd cmd;
-  cmd.instanceBuffer = instanceBuffer;
+  cmd.instance_buffer = instance_buffer;
   cmd.instance_count = instance_count;
   cmd.params = params;
-  cmd.params.time = m_accumulatedTime;
-  m_activeQueue->submit(cmd);
+  cmd.params.time = m_accumulated_time;
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::firecampBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                             const FireCampBatchParams &params) {
-  if ((instanceBuffer == nullptr) || instance_count == 0 ||
-      (m_activeQueue == nullptr)) {
+void Renderer::firecamp_batch(Buffer *instance_buffer, std::size_t instance_count,
+                              const FireCampBatchParams &params) {
+  if ((instance_buffer == nullptr) || instance_count == 0 ||
+      (m_active_queue == nullptr)) {
     return;
   }
   FireCampBatchCmd cmd;
-  cmd.instanceBuffer = instanceBuffer;
+  cmd.instance_buffer = instance_buffer;
   cmd.instance_count = instance_count;
   cmd.params = params;
-  cmd.params.time = m_accumulatedTime;
-  m_activeQueue->submit(cmd);
+  cmd.params.time = m_accumulated_time;
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::terrainChunk(Mesh *mesh, const QMatrix4x4 &model,
-                            const TerrainChunkParams &params,
-                            std::uint16_t sortKey, bool depthWrite,
-                            float depthBias) {
-  if ((mesh == nullptr) || (m_activeQueue == nullptr)) {
+void Renderer::terrain_chunk(Mesh *mesh, const QMatrix4x4 &model,
+                             const TerrainChunkParams &params,
+                             std::uint16_t sort_key, bool depth_write,
+                             float depth_bias) {
+  if ((mesh == nullptr) || (m_active_queue == nullptr)) {
     return;
   }
   TerrainChunkCmd cmd;
   cmd.mesh = mesh;
   cmd.model = model;
   cmd.params = params;
-  cmd.sortKey = sortKey;
-  cmd.depthWrite = depthWrite;
-  cmd.depthBias = depthBias;
-  m_activeQueue->submit(cmd);
+  cmd.sort_key = sort_key;
+  cmd.depth_write = depth_write;
+  cmd.depth_bias = depth_bias;
+  m_active_queue->submit(cmd);
 }
 
-void Renderer::selectionRing(const QMatrix4x4 &model, float alphaInner,
-                             float alphaOuter, const QVector3D &color) {
+void Renderer::selection_ring(const QMatrix4x4 &model, float alpha_inner,
+                              float alpha_outer, const QVector3D &color) {
   SelectionRingCmd cmd;
   cmd.model = model;
   cmd.mvp = m_view_proj * model;
-  cmd.alphaInner = alphaInner;
-  cmd.alphaOuter = alphaOuter;
+  cmd.alpha_inner = alpha_inner;
+  cmd.alpha_outer = alpha_outer;
   cmd.color = color;
-  if (m_activeQueue != nullptr) {
-    m_activeQueue->submit(cmd);
+  if (m_active_queue != nullptr) {
+    m_active_queue->submit(cmd);
   }
 }
 
 void Renderer::grid(const QMatrix4x4 &model, const QVector3D &color,
-                    float cellSize, float thickness, float extent) {
+                    float cell_size, float thickness, float extent) {
   GridCmd cmd;
   cmd.model = model;
   cmd.mvp = m_view_proj * model;
   cmd.color = color;
-  cmd.cellSize = cellSize;
+  cmd.cell_size = cell_size;
   cmd.thickness = thickness;
   cmd.extent = extent;
-  if (m_activeQueue != nullptr) {
-    m_activeQueue->submit(cmd);
+  if (m_active_queue != nullptr) {
+    m_active_queue->submit(cmd);
   }
 }
 
-void Renderer::selectionSmoke(const QMatrix4x4 &model, const QVector3D &color,
-                              float baseAlpha) {
+void Renderer::selection_smoke(const QMatrix4x4 &model, const QVector3D &color,
+                               float base_alpha) {
   SelectionSmokeCmd cmd;
   cmd.model = model;
   cmd.mvp = m_view_proj * model;
   cmd.color = color;
-  cmd.baseAlpha = baseAlpha;
-  if (m_activeQueue != nullptr) {
-    m_activeQueue->submit(cmd);
+  cmd.base_alpha = base_alpha;
+  if (m_active_queue != nullptr) {
+    m_active_queue->submit(cmd);
   }
 }
 
-void Renderer::enqueueSelectionRing(Engine::Core::Entity *,
-                                    Engine::Core::TransformComponent *transform,
-                                    Engine::Core::UnitComponent *unit_comp,
-                                    bool selected, bool hovered) {
+void Renderer::enqueue_selection_ring(Engine::Core::Entity *,
+                                      Engine::Core::TransformComponent *transform,
+                                      Engine::Core::UnitComponent *unit_comp,
+                                      bool selected, bool hovered) {
   if ((!selected && !hovered) || (transform == nullptr)) {
     return;
   }
@@ -365,13 +365,13 @@ void Renderer::enqueueSelectionRing(Engine::Core::Entity *,
   ring_model.scale(ring_size, 1.0F, ring_size);
 
   if (selected) {
-    selectionRing(ring_model, 0.6F, 0.25F, QVector3D(0.2F, 0.4F, 1.0F));
+    selection_ring(ring_model, 0.6F, 0.25F, QVector3D(0.2F, 0.4F, 1.0F));
   } else if (hovered) {
-    selectionRing(ring_model, 0.35F, 0.15F, QVector3D(0.90F, 0.90F, 0.25F));
+    selection_ring(ring_model, 0.35F, 0.15F, QVector3D(0.90F, 0.90F, 0.25F));
   }
 }
 
-void Renderer::renderWorld(Engine::Core::World *world) {
+void Renderer::render_world(Engine::Core::World *world) {
   if (m_paused.load()) {
     return;
   }
@@ -495,20 +495,20 @@ void Renderer::renderWorld(Engine::Core::World *world) {
                        transform->scale.z);
 
     bool drawn_by_registry = false;
-    if (m_entityRegistry) {
+    if (m_entity_registry) {
       std::string renderer_key;
       if (!renderable->rendererId.empty()) {
         renderer_key = renderable->rendererId;
       } else if (unit_comp != nullptr) {
         renderer_key = Game::Units::spawn_typeToString(unit_comp->spawn_type);
       }
-      auto fn = m_entityRegistry->get(renderer_key);
+      auto fn = m_entity_registry->get(renderer_key);
       if (fn) {
         DrawContext ctx{resources(), entity, world, model_matrix};
 
         ctx.selected = is_selected;
         ctx.hovered = is_hovered;
-        ctx.animationTime = m_accumulatedTime;
+        ctx.animationTime = m_accumulated_time;
         ctx.rendererId = renderer_key;
         ctx.backend = m_backend.get();
         ctx.camera = m_camera;
@@ -524,8 +524,8 @@ void Renderer::renderWorld(Engine::Core::World *world) {
           fn(ctx, *this);
         }
 
-        enqueueSelectionRing(entity, transform, unit_comp, is_selected,
-                             is_hovered);
+        enqueue_selection_ring(entity, transform, unit_comp, is_selected,
+                              is_hovered);
         drawn_by_registry = true;
       }
     }
@@ -605,37 +605,37 @@ void Renderer::renderWorld(Engine::Core::World *world) {
         mesh(contact_quad, c2, col, white, outer_alpha);
       }
     }
-    enqueueSelectionRing(entity, transform, unit_comp, is_selected, is_hovered);
+    enqueue_selection_ring(entity, transform, unit_comp, is_selected, is_hovered);
     mesh(mesh_to_draw, model_matrix, color,
          (res != nullptr) ? res->white() : nullptr, 1.0F);
   }
 
-  if ((m_activeQueue != nullptr) && batcher.totalCount() > 0) {
+  if ((m_active_queue != nullptr) && batcher.total_count() > 0) {
     PrimitiveBatchParams params;
     params.viewProj = m_view_proj;
 
-    if (batcher.sphereCount() > 0) {
+    if (batcher.sphere_count() > 0) {
       PrimitiveBatchCmd cmd;
       cmd.type = PrimitiveType::Sphere;
-      cmd.instances = batcher.sphereData();
+      cmd.instances = batcher.sphere_data();
       cmd.params = params;
-      m_activeQueue->submit(cmd);
+      m_active_queue->submit(cmd);
     }
 
-    if (batcher.cylinderCount() > 0) {
+    if (batcher.cylinder_count() > 0) {
       PrimitiveBatchCmd cmd;
       cmd.type = PrimitiveType::Cylinder;
-      cmd.instances = batcher.cylinderData();
+      cmd.instances = batcher.cylinder_data();
       cmd.params = params;
-      m_activeQueue->submit(cmd);
+      m_active_queue->submit(cmd);
     }
 
-    if (batcher.coneCount() > 0) {
+    if (batcher.cone_count() > 0) {
       PrimitiveBatchCmd cmd;
       cmd.type = PrimitiveType::Cone;
-      cmd.instances = batcher.coneData();
+      cmd.instances = batcher.cone_data();
       cmd.params = params;
-      m_activeQueue->submit(cmd);
+      m_active_queue->submit(cmd);
     }
   }
 }

+ 77 - 77
render/scene_renderer.h

@@ -42,145 +42,145 @@ public:
   auto initialize() -> bool;
   void shutdown();
 
-  void beginFrame();
-  void endFrame();
-  void setViewport(int width, int height);
+  void begin_frame();
+  void end_frame();
+  void set_viewport(int width, int height);
 
-  void setCamera(Camera *camera);
-  void setClearColor(float r, float g, float b, float a = 1.0F);
+  void set_camera(Camera *camera);
+  void set_clear_color(float r, float g, float b, float a = 1.0F);
 
-  void updateAnimationTime(float deltaTime) { m_accumulatedTime += deltaTime; }
-  auto getAnimationTime() const -> float { return m_accumulatedTime; }
+  void update_animation_time(float delta_time) { m_accumulated_time += delta_time; }
+  auto get_animation_time() const -> float { return m_accumulated_time; }
 
   auto resources() const -> ResourceManager * {
     return m_backend ? m_backend->resources() : nullptr;
   }
-  void setHoveredEntityId(unsigned int id) { m_hoveredEntityId = id; }
-  void setLocalOwnerId(int owner_id) { m_localOwnerId = owner_id; }
+  void set_hovered_entity_id(unsigned int id) { m_hovered_entity_id = id; }
+  void set_local_owner_id(int owner_id) { m_local_owner_id = owner_id; }
 
-  void setSelectedEntities(const std::vector<unsigned int> &ids) {
-    m_selectedIds.clear();
-    m_selectedIds.insert(ids.begin(), ids.end());
+  void set_selected_entities(const std::vector<unsigned int> &ids) {
+    m_selected_ids.clear();
+    m_selected_ids.insert(ids.begin(), ids.end());
   }
 
-  auto getMeshQuad() const -> Mesh * {
+  auto get_mesh_quad() const -> Mesh * {
     return m_backend && (m_backend->resources() != nullptr)
                ? m_backend->resources()->quad()
                : nullptr;
   }
-  auto getMeshPlane() const -> Mesh * {
+  auto get_mesh_plane() const -> Mesh * {
     return m_backend && (m_backend->resources() != nullptr)
                ? m_backend->resources()->ground()
                : nullptr;
   }
-  auto getMeshCube() const -> Mesh * {
+  auto get_mesh_cube() const -> Mesh * {
     return m_backend && (m_backend->resources() != nullptr)
                ? m_backend->resources()->unit()
                : nullptr;
   }
 
-  auto getWhiteTexture() const -> Texture * {
+  auto get_white_texture() const -> Texture * {
     return m_backend && (m_backend->resources() != nullptr)
                ? m_backend->resources()->white()
                : nullptr;
   }
 
-  auto getShader(const QString &name) const -> Shader * {
+  auto get_shader(const QString &name) const -> Shader * {
     return m_backend ? m_backend->shader(name) : nullptr;
   }
-  auto loadShader(const QString &name, const QString &vertPath,
-                  const QString &fragPath) -> Shader * {
-    return m_backend ? m_backend->getOrLoadShader(name, vertPath, fragPath)
+  auto load_shader(const QString &name, const QString &vert_path,
+                   const QString &frag_path) -> Shader * {
+    return m_backend ? m_backend->getOrLoadShader(name, vert_path, frag_path)
                      : nullptr;
   }
 
-  void setCurrentShader(Shader *shader) { m_currentShader = shader; }
-  auto getCurrentShader() const -> Shader * { return m_currentShader; }
+  void set_current_shader(Shader *shader) { m_current_shader = shader; }
+  auto get_current_shader() const -> Shader * { return m_current_shader; }
 
   struct GridParams {
-    float cellSize = 1.0F;
+    float cell_size = 1.0F;
     float thickness = 0.06F;
-    QVector3D gridColor{0.15F, 0.18F, 0.15F};
+    QVector3D grid_color{0.15F, 0.18F, 0.15F};
     float extent = 50.0F;
   };
-  void setGridParams(const GridParams &gp) { m_gridParams = gp; }
-  auto gridParams() const -> const GridParams & { return m_gridParams; }
+  void set_grid_params(const GridParams &gp) { m_grid_params = gp; }
+  auto grid_params() const -> const GridParams & { return m_grid_params; }
 
   void pause() { m_paused = true; }
   void resume() { m_paused = false; }
-  auto isPaused() const -> bool { return m_paused; }
+  auto is_paused() const -> bool { return m_paused; }
 
   void mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
             Texture *texture = nullptr, float alpha = 1.0F,
-            int materialId = 0) override;
+            int material_id = 0) override;
   void cylinder(const QVector3D &start, const QVector3D &end, float radius,
                 const QVector3D &color, float alpha = 1.0F) override;
-  void selectionRing(const QMatrix4x4 &model, float alphaInner,
-                     float alphaOuter, const QVector3D &color) override;
+  void selection_ring(const QMatrix4x4 &model, float alpha_inner,
+                      float alpha_outer, const QVector3D &color) override;
 
-  void grid(const QMatrix4x4 &model, const QVector3D &color, float cellSize,
+  void grid(const QMatrix4x4 &model, const QVector3D &color, float cell_size,
             float thickness, float extent) override;
 
-  void selectionSmoke(const QMatrix4x4 &model, const QVector3D &color,
-                      float baseAlpha = 0.15F) override;
-  void terrainChunk(Mesh *mesh, const QMatrix4x4 &model,
-                    const TerrainChunkParams &params,
-                    std::uint16_t sortKey = 0x8000U, bool depthWrite = true,
-                    float depthBias = 0.0F);
-
-  void renderWorld(Engine::Core::World *world);
-
-  void lockWorldForModification() { m_worldMutex.lock(); }
-  void unlockWorldForModification() { m_worldMutex.unlock(); }
-
-  void fogBatch(const FogInstanceData *instances, std::size_t count);
-  void grassBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                  const GrassBatchParams &params);
-  void stoneBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                  const StoneBatchParams &params);
-  void plantBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                  const PlantBatchParams &params);
-  void pineBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                 const PineBatchParams &params);
-  void oliveBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                  const OliveBatchParams &params);
-  void firecampBatch(Buffer *instanceBuffer, std::size_t instance_count,
-                     const FireCampBatchParams &params);
+  void selection_smoke(const QMatrix4x4 &model, const QVector3D &color,
+                       float base_alpha = 0.15F) override;
+  void terrain_chunk(Mesh *mesh, const QMatrix4x4 &model,
+                     const TerrainChunkParams &params,
+                     std::uint16_t sort_key = 0x8000U, bool depth_write = true,
+                     float depth_bias = 0.0F);
+
+  void render_world(Engine::Core::World *world);
+
+  void lock_world_for_modification() { m_world_mutex.lock(); }
+  void unlock_world_for_modification() { m_world_mutex.unlock(); }
+
+  void fog_batch(const FogInstanceData *instances, std::size_t count);
+  void grass_batch(Buffer *instance_buffer, std::size_t instance_count,
+                   const GrassBatchParams &params);
+  void stone_batch(Buffer *instance_buffer, std::size_t instance_count,
+                   const StoneBatchParams &params);
+  void plant_batch(Buffer *instance_buffer, std::size_t instance_count,
+                   const PlantBatchParams &params);
+  void pine_batch(Buffer *instance_buffer, std::size_t instance_count,
+                  const PineBatchParams &params);
+  void olive_batch(Buffer *instance_buffer, std::size_t instance_count,
+                   const OliveBatchParams &params);
+  void firecamp_batch(Buffer *instance_buffer, std::size_t instance_count,
+                      const FireCampBatchParams &params);
 
 private:
-  void enqueueSelectionRing(Engine::Core::Entity *entity,
-                            Engine::Core::TransformComponent *transform,
-                            Engine::Core::UnitComponent *unit_comp,
-                            bool selected, bool hovered);
+  void enqueue_selection_ring(Engine::Core::Entity *entity,
+                               Engine::Core::TransformComponent *transform,
+                               Engine::Core::UnitComponent *unit_comp,
+                               bool selected, bool hovered);
 
   Camera *m_camera = nullptr;
   std::shared_ptr<Backend> m_backend;
   DrawQueue m_queues[2];
-  DrawQueue *m_activeQueue = nullptr;
-  int m_fillQueueIndex = 0;
-  int m_render_queueIndex = 1;
-
-  std::unique_ptr<EntityRendererRegistry> m_entityRegistry;
-  unsigned int m_hoveredEntityId = 0;
-  std::unordered_set<unsigned int> m_selectedIds;
-
-  int m_viewportWidth = 0;
-  int m_viewportHeight = 0;
-  GridParams m_gridParams;
-  float m_accumulatedTime = 0.0F;
+  DrawQueue *m_active_queue = nullptr;
+  int m_fill_queue_index = 0;
+  int m_render_queue_index = 1;
+
+  std::unique_ptr<EntityRendererRegistry> m_entity_registry;
+  unsigned int m_hovered_entity_id = 0;
+  std::unordered_set<unsigned int> m_selected_ids;
+
+  int m_viewport_width = 0;
+  int m_viewport_height = 0;
+  GridParams m_grid_params;
+  float m_accumulated_time = 0.0F;
   std::atomic<bool> m_paused{false};
 
-  std::mutex m_worldMutex;
-  int m_localOwnerId = 1;
+  std::mutex m_world_mutex;
+  int m_local_owner_id = 1;
 
   QMatrix4x4 m_view_proj;
-  Shader *m_currentShader = nullptr;
+  Shader *m_current_shader = nullptr;
 };
 
 struct FrameScope {
   Renderer &r;
-  FrameScope(Renderer &renderer) : r(renderer) { r.beginFrame(); }
-  ~FrameScope() { r.endFrame(); }
+  FrameScope(Renderer &renderer) : r(renderer) { r.begin_frame(); }
+  ~FrameScope() { r.end_frame(); }
 };
 
 } // namespace Render::GL