From bef49b7499ddeea4d46f5afdcff166abe53a289e Mon Sep 17 00:00:00 2001 From: Linloir <3145078758@qq.com> Date: Sat, 17 Dec 2022 13:19:55 +0800 Subject: [PATCH] Change variable names --- FinalProject/model.cpp | 12 ++++++------ FinalProject/model.h | 18 ++++++------------ FinalProject/renderable.cpp | 10 +++++----- FinalProject/renderable.h | 16 ++++++++-------- 4 files changed, 25 insertions(+), 31 deletions(-) diff --git a/FinalProject/model.cpp b/FinalProject/model.cpp index 34e40fc..1dd519e 100644 --- a/FinalProject/model.cpp +++ b/FinalProject/model.cpp @@ -76,8 +76,8 @@ Mesh Model::processMesh(aiMesh* mesh, const aiScene* scene) { //使用循环避免代码重复,如果可行的话,可以在此循环中确定法向量等信息 for (int j = 0; j < 3; j++) { vertexPosition[j] = mesh->mVertices[i][j]; - _left_down_back[j] = _left_down_back[j] < vertexPosition[j] ? _left_down_back[j] : vertexPosition[j]; - _right_up_front[j] = _right_up_front[j] > vertexPosition[j] ? _right_up_front[j] : vertexPosition[j]; + _leftBackBottomVex[j] = _leftBackBottomVex[j] < vertexPosition[j] ? _leftBackBottomVex[j] : vertexPosition[j]; + _rightFrontTopVex[j] = _rightFrontTopVex[j] > vertexPosition[j] ? _rightFrontTopVex[j] : vertexPosition[j]; } //vertexPosition.x = mesh->mVertices[i].x; @@ -198,11 +198,11 @@ void Model::checkBoundary() { for (int j = 0; j < _meshes[i].vertices().size();j++) { // 0,1,2 for x,y,z for (int k = 0; k < 3; k++) { - _left_down_back[k] = _left_down_back[k] < _meshes[i].vertices()[j]._position[k] ? - _left_down_back[k] : _meshes[i].vertices()[j]._position[k]; + _leftBackBottomVex[k] = _leftBackBottomVex[k] < _meshes[i].vertices()[j]._position[k] ? + _leftBackBottomVex[k] : _meshes[i].vertices()[j]._position[k]; - _right_up_front[k] = _right_up_front[k] > _meshes[i].vertices()[j]._position[k] ? - _right_up_front[k] : _meshes[i].vertices()[j]._position[k]; + _rightFrontTopVex[k] = _rightFrontTopVex[k] > _meshes[i].vertices()[j]._position[k] ? + _rightFrontTopVex[k] : _meshes[i].vertices()[j]._position[k]; } } } diff --git a/FinalProject/model.h b/FinalProject/model.h index f551301..5f7888e 100644 --- a/FinalProject/model.h +++ b/FinalProject/model.h @@ -20,9 +20,9 @@ private: MODELSTATUS _status = LOADING; // smallest point - glm::vec3 _left_down_back = glm::vec3(3e36f, 3e36f, 3e36f); + glm::vec3 _leftBackBottomVex = glm::vec3(3e36f, 3e36f, 3e36f); // largest point - glm::vec3 _right_up_front = -_left_down_back; + glm::vec3 _rightFrontTopVex = -_leftBackBottomVex; public: Model(std::string path); @@ -42,13 +42,13 @@ public: // maybe we can check if boundary has not been set yet // Do remember to ensure you have called checkBoundary - inline glm::vec3 get_upper_bound() { - return _right_up_front; + inline glm::vec3 upperBoundVex() { + return _rightFrontTopVex; } // Do remember to ensure you have called checkBoundary - inline glm::vec3 get_lower_bound() { - return _left_down_back; + inline glm::vec3 lowerBoundVex() { + return _leftBackBottomVex; } private: @@ -56,14 +56,8 @@ private: void processNode(aiNode* node, const aiScene* scene); Mesh processMesh(aiMesh* mesh, const aiScene* scene); std::vector loadMaterialTextures(aiMaterial* mat, aiTextureType type, TextureType textureType); - // Since these are loacl position, this function should be called just once. void checkBoundary(); public: void render(const ShaderProgram& shader) const; - - - - // maybe we can encapsure a function to get both upper and lower bound? - }; \ No newline at end of file diff --git a/FinalProject/renderable.cpp b/FinalProject/renderable.cpp index 3daf3d7..e6fedfd 100644 --- a/FinalProject/renderable.cpp +++ b/FinalProject/renderable.cpp @@ -49,10 +49,10 @@ void Renderable::render(ShaderProgram shader) { // check here to get global boundary // must check before get boundary void Renderable::checkBoundary() { - std::vector temp = {_model->get_upper_bound(),_model->get_lower_bound()}; + std::vector temp = {_model->upperBoundVex(),_model->lowerBoundVex()}; - _lower_bound = glm::vec3(3e36, 3e36, 3e36); - _upper_bound = -_lower_bound; + _lowerBoundVex = glm::vec3(3e36, 3e36, 3e36); + _upperBoundVex = -_lowerBoundVex; auto model = this->modelMatrix(); // transform matrix @@ -61,8 +61,8 @@ void Renderable::checkBoundary() { glm::vec4 vx = glm::vec4(temp[(i & 4) >> 2][0], temp[(i & 2)>>1][1], temp[i & 1][2], 1.0f); auto vex = model * vx; // Transformed vertex position for (int j = 0; j < 3; j++) { - _lower_bound[j] = _lower_bound[j] < vex[j] ? _lower_bound[j] : vex[j]; - _upper_bound[j] = _upper_bound[j] > vex[j] ? _upper_bound[j] : vex[j]; + _lowerBoundVex[j] = _lowerBoundVex[j] < vex[j] ? _lowerBoundVex[j] : vex[j]; + _upperBoundVex[j] = _upperBoundVex[j] > vex[j] ? _upperBoundVex[j] : vex[j]; } } } \ No newline at end of file diff --git a/FinalProject/renderable.h b/FinalProject/renderable.h index c20c2dc..6196c0a 100644 --- a/FinalProject/renderable.h +++ b/FinalProject/renderable.h @@ -20,8 +20,8 @@ private: glm::vec3 _position = glm::vec3(0.0f); glm::mat4 _rotation = glm::mat4(1.0f); glm::vec3 _scale = glm::vec3(1.0f); - glm::vec3 _lower_bound; - glm::vec3 _upper_bound; + glm::vec3 _lowerBoundVex; + glm::vec3 _upperBoundVex; public: Renderable(Model* model); @@ -38,8 +38,8 @@ public: inline glm::mat4 modelMatrix() const; - inline glm::vec3 get_upper_boundary()const; - inline glm::vec3 get_lower_boundary()const; + inline glm::vec3 upperBoundVex()const; + inline glm::vec3 lowerBoundVex()const; public: void render(ShaderProgram shader); @@ -55,9 +55,9 @@ inline glm::mat4 Renderable::modelMatrix() const { return model; } -inline glm::vec3 Renderable::get_lower_boundary()const { - return _lower_bound; +inline glm::vec3 Renderable::lowerBoundVex() const { + return _lowerBoundVex; } -inline glm::vec3 Renderable::get_upper_boundary()const { - return _upper_bound; +inline glm::vec3 Renderable::upperBoundVex() const { + return _upperBoundVex; } \ No newline at end of file