浏览代码

Update related files to use snake_case render methods

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 1 周之前
父节点
当前提交
0ed41d83d1

+ 4 - 4
app/core/game_engine.cpp

@@ -737,15 +737,15 @@ void GameEngine::render(int pixelWidth, int pixelHeight) {
   if (pixelWidth > 0 && pixelHeight > 0) {
     m_viewport.width = pixelWidth;
     m_viewport.height = pixelHeight;
-    m_renderer->setViewport(pixelWidth, pixelHeight);
+    m_renderer->set_viewport(pixelWidth, pixelHeight);
   }
   if (auto *selection_system =
           m_world->getSystem<Game::Systems::SelectionSystem>()) {
     const auto &sel = selection_system->getSelectedUnits();
     std::vector<unsigned int> const ids(sel.begin(), sel.end());
-    m_renderer->setSelectedEntities(ids);
+    m_renderer->set_selected_entities(ids);
   }
-  m_renderer->beginFrame();
+  m_renderer->begin_frame();
   if (auto *res = m_renderer->resources()) {
     for (auto *pass : m_passes) {
       if (pass != nullptr) {
@@ -774,7 +774,7 @@ void GameEngine::render(int pixelWidth, int pixelHeight) {
     Render::GL::renderPatrolFlags(m_renderer.get(), res, *m_world,
                                   preview_waypoint);
   }
-  m_renderer->endFrame();
+  m_renderer->end_frame();
 
   qreal const current_x = globalCursorX();
   qreal const current_y = globalCursorY();

+ 17 - 17
render/gl/backend.cpp

@@ -1143,11 +1143,11 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
         }
       }
 
-      DepthMaskScope const depth_mask(terrain.depthWrite);
+      DepthMaskScope const depth_mask(terrain.depth_write);
       std::unique_ptr<PolygonOffsetScope> poly_scope;
-      if (terrain.depthBias != 0.0F) {
-        poly_scope = std::make_unique<PolygonOffsetScope>(terrain.depthBias,
-                                                          terrain.depthBias);
+      if (terrain.depth_bias != 0.0F) {
+        poly_scope = std::make_unique<PolygonOffsetScope>(terrain.depth_bias,
+                                                          terrain.depth_bias);
       }
 
       terrain.mesh->draw();
@@ -1292,7 +1292,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       active_shader->setUniform(uniforms->useTexture, it.texture != nullptr);
       active_shader->setUniform(uniforms->color, it.color);
       active_shader->setUniform(uniforms->alpha, it.alpha);
-      active_shader->setUniform(uniforms->materialId, it.materialId);
+      active_shader->setUniform(uniforms->materialId, it.material_id);
       it.mesh->draw();
       break;
     }
@@ -1316,7 +1316,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       m_effectsPipeline->m_gridShader->setUniform(
           m_effectsPipeline->m_gridUniforms.lineColor, k_grid_line_color);
       m_effectsPipeline->m_gridShader->setUniform(
-          m_effectsPipeline->m_gridUniforms.cellSize, gc.cellSize);
+          m_effectsPipeline->m_gridUniforms.cellSize, gc.cell_size);
       m_effectsPipeline->m_gridShader->setUniform(
           m_effectsPipeline->m_gridUniforms.thickness, gc.thickness);
 
@@ -1358,7 +1358,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
         m_effectsPipeline->m_basicShader->setUniform(
             m_effectsPipeline->m_basicUniforms.model, m);
         m_effectsPipeline->m_basicShader->setUniform(
-            m_effectsPipeline->m_basicUniforms.alpha, sc.alphaOuter);
+            m_effectsPipeline->m_basicUniforms.alpha, sc.alpha_outer);
         ring->draw();
       }
 
@@ -1369,7 +1369,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
         m_effectsPipeline->m_basicShader->setUniform(
             m_effectsPipeline->m_basicUniforms.model, sc.model);
         m_effectsPipeline->m_basicShader->setUniform(
-            m_effectsPipeline->m_basicUniforms.alpha, sc.alphaInner);
+            m_effectsPipeline->m_basicUniforms.alpha, sc.alpha_inner);
         ring->draw();
       }
       break;
@@ -1396,7 +1396,7 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
       BlendScope const blend(true);
       for (int i = 0; i < 7; ++i) {
         float const scale = 1.35F + 0.12F * i;
-        float const a = sm.baseAlpha * (1.0F - 0.09F * i);
+        float const a = sm.base_alpha * (1.0F - 0.09F * i);
         QMatrix4x4 m = sm.model;
         m.translate(0.0F, 0.02F, 0.0F);
         m.scale(scale, 1.0F, scale);
@@ -1413,29 +1413,29 @@ void Backend::execute(const DrawQueue &queue, const Camera &cam) {
     }
     case PrimitiveBatchCmdIndex: {
       const auto &batch = std::get<PrimitiveBatchCmdIndex>(cmd);
-      if (batch.instanceCount() == 0 || m_primitiveBatchPipeline == nullptr ||
+      if (batch.instance_count() == 0 || m_primitiveBatchPipeline == nullptr ||
           !m_primitiveBatchPipeline->isInitialized()) {
         break;
       }
 
-      const auto *data = batch.instanceData();
+      const auto *data = batch.instance_data();
 
       switch (batch.type) {
       case PrimitiveType::Sphere:
         m_primitiveBatchPipeline->uploadSphereInstances(data,
-                                                        batch.instanceCount());
-        m_primitiveBatchPipeline->drawSpheres(batch.instanceCount(), view_proj);
+                                                        batch.instance_count());
+        m_primitiveBatchPipeline->drawSpheres(batch.instance_count(), view_proj);
         break;
       case PrimitiveType::Cylinder:
         m_primitiveBatchPipeline->uploadCylinderInstances(
-            data, batch.instanceCount());
-        m_primitiveBatchPipeline->drawCylinders(batch.instanceCount(),
+            data, batch.instance_count());
+        m_primitiveBatchPipeline->drawCylinders(batch.instance_count(),
                                                 view_proj);
         break;
       case PrimitiveType::Cone:
         m_primitiveBatchPipeline->uploadConeInstances(data,
-                                                      batch.instanceCount());
-        m_primitiveBatchPipeline->drawCones(batch.instanceCount(), view_proj);
+                                                      batch.instance_count());
+        m_primitiveBatchPipeline->drawCones(batch.instance_count(), view_proj);
         break;
       }
 

+ 16 - 16
render/gl/backend/primitive_batch_pipeline.cpp

@@ -46,9 +46,9 @@ void PrimitiveBatchPipeline::shutdown() {
 
 void PrimitiveBatchPipeline::cacheUniforms() {
   if (m_shader != nullptr) {
-    m_uniforms.viewProj = m_shader->uniformHandle("u_viewProj");
-    m_uniforms.lightDir = m_shader->uniformHandle("u_lightDir");
-    m_uniforms.ambientStrength = m_shader->uniformHandle("u_ambientStrength");
+    m_uniforms.view_proj = m_shader->uniformHandle("u_viewProj");
+    m_uniforms.light_dir = m_shader->uniformHandle("u_lightDir");
+    m_uniforms.ambient_strength = m_shader->uniformHandle("u_ambientStrength");
   }
 }
 
@@ -64,25 +64,25 @@ void PrimitiveBatchPipeline::setupInstanceAttributes(GLuint vao,
   glEnableVertexAttribArray(3);
   glVertexAttribPointer(
       3, Vec4, GL_FLOAT, GL_FALSE, stride,
-      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, modelCol0)));
+      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, model_col0)));
   glVertexAttribDivisor(3, 1);
 
   glEnableVertexAttribArray(4);
   glVertexAttribPointer(
       4, Vec4, GL_FLOAT, GL_FALSE, stride,
-      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, modelCol1)));
+      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, model_col1)));
   glVertexAttribDivisor(4, 1);
 
   glEnableVertexAttribArray(5);
   glVertexAttribPointer(
       5, Vec4, GL_FLOAT, GL_FALSE, stride,
-      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, modelCol2)));
+      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, model_col2)));
   glVertexAttribDivisor(5, 1);
 
   glEnableVertexAttribArray(6);
   glVertexAttribPointer(
       6, Vec4, GL_FLOAT, GL_FALSE, stride,
-      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, colorAlpha)));
+      reinterpret_cast<void *>(offsetof(GL::PrimitiveInstanceGpu, color_alpha)));
   glVertexAttribDivisor(6, 1);
 
   glBindVertexArray(0);
@@ -347,9 +347,9 @@ void PrimitiveBatchPipeline::drawSpheres(std::size_t count,
   }
 
   m_shader->use();
-  m_shader->setUniform(m_uniforms.viewProj, viewProj);
-  m_shader->setUniform(m_uniforms.lightDir, QVector3D(0.35F, 0.8F, 0.45F));
-  m_shader->setUniform(m_uniforms.ambientStrength, 0.3F);
+  m_shader->setUniform(m_uniforms.view_proj, viewProj);
+  m_shader->setUniform(m_uniforms.light_dir, QVector3D(0.35F, 0.8F, 0.45F));
+  m_shader->setUniform(m_uniforms.ambient_strength, 0.3F);
 
   glBindVertexArray(m_sphereVao);
   glDrawElementsInstanced(GL_TRIANGLES, m_sphereIndexCount, GL_UNSIGNED_INT,
@@ -364,9 +364,9 @@ void PrimitiveBatchPipeline::drawCylinders(std::size_t count,
   }
 
   m_shader->use();
-  m_shader->setUniform(m_uniforms.viewProj, viewProj);
-  m_shader->setUniform(m_uniforms.lightDir, QVector3D(0.35F, 0.8F, 0.45F));
-  m_shader->setUniform(m_uniforms.ambientStrength, 0.3F);
+  m_shader->setUniform(m_uniforms.view_proj, viewProj);
+  m_shader->setUniform(m_uniforms.light_dir, QVector3D(0.35F, 0.8F, 0.45F));
+  m_shader->setUniform(m_uniforms.ambient_strength, 0.3F);
 
   glBindVertexArray(m_cylinderVao);
   glDrawElementsInstanced(GL_TRIANGLES, m_cylinderIndexCount, GL_UNSIGNED_INT,
@@ -381,9 +381,9 @@ void PrimitiveBatchPipeline::drawCones(std::size_t count,
   }
 
   m_shader->use();
-  m_shader->setUniform(m_uniforms.viewProj, viewProj);
-  m_shader->setUniform(m_uniforms.lightDir, QVector3D(0.35F, 0.8F, 0.45F));
-  m_shader->setUniform(m_uniforms.ambientStrength, 0.3F);
+  m_shader->setUniform(m_uniforms.view_proj, viewProj);
+  m_shader->setUniform(m_uniforms.light_dir, QVector3D(0.35F, 0.8F, 0.45F));
+  m_shader->setUniform(m_uniforms.ambient_strength, 0.3F);
 
   glBindVertexArray(m_coneVao);
   glDrawElementsInstanced(GL_TRIANGLES, m_coneIndexCount, GL_UNSIGNED_INT,

+ 3 - 3
render/gl/backend/primitive_batch_pipeline.h

@@ -39,9 +39,9 @@ public:
   [[nodiscard]] auto shader() const -> GL::Shader * { return m_shader; }
 
   struct Uniforms {
-    GL::Shader::UniformHandle viewProj{GL::Shader::InvalidUniform};
-    GL::Shader::UniformHandle lightDir{GL::Shader::InvalidUniform};
-    GL::Shader::UniformHandle ambientStrength{GL::Shader::InvalidUniform};
+    GL::Shader::UniformHandle view_proj{GL::Shader::InvalidUniform};
+    GL::Shader::UniformHandle light_dir{GL::Shader::InvalidUniform};
+    GL::Shader::UniformHandle ambient_strength{GL::Shader::InvalidUniform};
   };
 
   Uniforms m_uniforms;

+ 1 - 1
render/gl/bootstrap.cpp

@@ -31,7 +31,7 @@ auto RenderBootstrap::initialize(Renderer &renderer, Camera &camera) -> bool {
   qInfo() << "RenderBootstrap: Renderer initialized successfully";
 
   qInfo() << "RenderBootstrap: Setting camera...";
-  renderer.setCamera(&camera);
+  renderer.set_camera(&camera);
   qInfo() << "RenderBootstrap: Camera set, initialization complete";
 
   return true;

+ 1 - 1
render/scene_renderer.cpp

@@ -124,7 +124,7 @@ void Renderer::mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
     QVector3D start;
     QVector3D end;
     float radius = 0.0F;
-    if (detail::decomposeUnitCylinder(model, start, end, radius)) {
+    if (detail::decompose_unit_cylinder(model, start, end, radius)) {
       cylinder(start, end, radius, color, alpha);
       return;
     }

+ 36 - 36
render/submitter.h

@@ -18,21 +18,21 @@ public:
   virtual ~ISubmitter() = default;
   virtual void mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
                     Texture *tex = nullptr, float alpha = 1.0F,
-                    int materialId = 0) = 0;
+                    int material_id = 0) = 0;
   virtual void cylinder(const QVector3D &start, const QVector3D &end,
                         float radius, const QVector3D &color,
                         float alpha = 1.0F) = 0;
-  virtual void selectionRing(const QMatrix4x4 &model, float alphaInner,
-                             float alphaOuter, const QVector3D &color) = 0;
+  virtual void selection_ring(const QMatrix4x4 &model, float alpha_inner,
+                              float alpha_outer, const QVector3D &color) = 0;
   virtual void grid(const QMatrix4x4 &model, const QVector3D &color,
-                    float cellSize, float thickness, float extent) = 0;
-  virtual void selectionSmoke(const QMatrix4x4 &model, const QVector3D &color,
-                              float baseAlpha = 0.15F) = 0;
+                    float cell_size, float thickness, float extent) = 0;
+  virtual void selection_smoke(const QMatrix4x4 &model, const QVector3D &color,
+                               float base_alpha = 0.15F) = 0;
 };
 
 namespace detail {
-inline auto decomposeUnitCylinder(const QMatrix4x4 &model, QVector3D &start,
-                                  QVector3D &end, float &radius) -> bool {
+inline auto decompose_unit_cylinder(const QMatrix4x4 &model, QVector3D &start,
+                                    QVector3D &end, float &radius) -> bool {
   start = model.map(QVector3D(0.0F, -0.5F, 0.0F));
   end = model.map(QVector3D(0.0F, 0.5F, 0.0F));
   QVector3D const sx = model.mapVector(QVector3D(1.0F, 0.0F, 0.0F));
@@ -46,11 +46,11 @@ class QueueSubmitter : public ISubmitter {
 public:
   explicit QueueSubmitter(DrawQueue *queue) : m_queue(queue) {}
 
-  void setShader(Shader *shader) { m_shader = shader; }
+  void set_shader(Shader *shader) { m_shader = shader; }
 
   void mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
             Texture *tex = nullptr, float alpha = 1.0F,
-            int materialId = 0) override {
+            int material_id = 0) override {
     if ((m_queue == nullptr) || (mesh == nullptr)) {
       return;
     }
@@ -60,7 +60,7 @@ public:
       QVector3D start;
       QVector3D end;
       float radius = 0.0F;
-      if (detail::decomposeUnitCylinder(model, start, end, radius)) {
+      if (detail::decompose_unit_cylinder(model, start, end, radius)) {
         CylinderCmd cyl;
         cyl.start = start;
         cyl.end = end;
@@ -77,7 +77,7 @@ public:
     cmd.model = model;
     cmd.color = color;
     cmd.alpha = alpha;
-    cmd.materialId = materialId;
+    cmd.material_id = material_id;
     cmd.shader = m_shader;
     m_queue->submit(cmd);
   }
@@ -94,19 +94,19 @@ public:
     cmd.alpha = alpha;
     m_queue->submit(cmd);
   }
-  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 {
     if (m_queue == nullptr) {
       return;
     }
     SelectionRingCmd cmd;
     cmd.model = model;
-    cmd.alphaInner = alphaInner;
-    cmd.alphaOuter = alphaOuter;
+    cmd.alpha_inner = alpha_inner;
+    cmd.alpha_outer = alpha_outer;
     cmd.color = color;
     m_queue->submit(cmd);
   }
-  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 {
     if (m_queue == nullptr) {
       return;
@@ -114,20 +114,20 @@ public:
     GridCmd cmd;
     cmd.model = model;
     cmd.color = color;
-    cmd.cellSize = cellSize;
+    cmd.cell_size = cell_size;
     cmd.thickness = thickness;
     cmd.extent = extent;
     m_queue->submit(cmd);
   }
-  void selectionSmoke(const QMatrix4x4 &model, const QVector3D &color,
-                      float baseAlpha = 0.15F) override {
+  void selection_smoke(const QMatrix4x4 &model, const QVector3D &color,
+                       float base_alpha = 0.15F) override {
     if (m_queue == nullptr) {
       return;
     }
     SelectionSmokeCmd cmd;
     cmd.model = model;
     cmd.color = color;
-    cmd.baseAlpha = baseAlpha;
+    cmd.base_alpha = base_alpha;
     m_queue->submit(cmd);
   }
 
@@ -142,30 +142,30 @@ public:
                              PrimitiveBatcher *batcher = nullptr)
       : m_fallback(fallback), m_batcher(batcher) {}
 
-  void setBatcher(PrimitiveBatcher *batcher) { m_batcher = batcher; }
-  void setEnabled(bool enabled) { m_enabled = enabled; }
+  void set_batcher(PrimitiveBatcher *batcher) { m_batcher = batcher; }
+  void set_enabled(bool enabled) { m_enabled = enabled; }
 
   void mesh(Mesh *mesh, const QMatrix4x4 &model, const QVector3D &color,
             Texture *tex = nullptr, float alpha = 1.0F,
-            int materialId = 0) override {
+            int material_id = 0) override {
 
     if (m_enabled && m_batcher != nullptr && tex == nullptr) {
       if (mesh == getUnitSphere()) {
-        m_batcher->addSphere(model, color, alpha);
+        m_batcher->add_sphere(model, color, alpha);
         return;
       }
       if (mesh == getUnitCylinder()) {
-        m_batcher->addCylinder(model, color, alpha);
+        m_batcher->add_cylinder(model, color, alpha);
         return;
       }
       if (mesh == getUnitCone()) {
-        m_batcher->addCone(model, color, alpha);
+        m_batcher->add_cone(model, color, alpha);
         return;
       }
     }
 
     if (m_fallback != nullptr) {
-      m_fallback->mesh(mesh, model, color, tex, alpha, materialId);
+      m_fallback->mesh(mesh, model, color, tex, alpha, material_id);
     }
   }
 
@@ -177,24 +177,24 @@ public:
     }
   }
 
-  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 {
     if (m_fallback != nullptr) {
-      m_fallback->selectionRing(model, alphaInner, alphaOuter, color);
+      m_fallback->selection_ring(model, alpha_inner, alpha_outer, color);
     }
   }
 
-  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 {
     if (m_fallback != nullptr) {
-      m_fallback->grid(model, color, cellSize, thickness, extent);
+      m_fallback->grid(model, color, cell_size, thickness, extent);
     }
   }
 
-  void selectionSmoke(const QMatrix4x4 &model, const QVector3D &color,
-                      float baseAlpha = 0.15F) override {
+  void selection_smoke(const QMatrix4x4 &model, const QVector3D &color,
+                       float base_alpha = 0.15F) override {
     if (m_fallback != nullptr) {
-      m_fallback->selectionSmoke(model, color, baseAlpha);
+      m_fallback->selection_smoke(model, color, base_alpha);
     }
   }