From 849da430e9697c12cc789ed3d9763293ccec71b5 Mon Sep 17 00:00:00 2001 From: Linloir <3145078758@qq.com> Date: Sat, 17 Dec 2022 13:09:52 +0800 Subject: [PATCH] Remove invalid code units --- FinalProject/model.cpp | 4 ++-- FinalProject/model.h | 6 +++--- FinalProject/renderable.cpp | 14 +++++++------- FinalProject/renderable.h | 5 +---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/FinalProject/model.cpp b/FinalProject/model.cpp index f8e6296..34e40fc 100644 --- a/FinalProject/model.cpp +++ b/FinalProject/model.cpp @@ -41,7 +41,7 @@ void Model::loadModel(std::string path) { _status = LOADED; Logger::info("Model loaded"); // 仅检查一次即可 - //check_boundary(); + //checkBoundary(); } void Model::processNode(aiNode* node, const aiScene* scene) { @@ -193,7 +193,7 @@ void Model::render(const ShaderProgram& shader) const { } } -void Model::check_boundary() { +void Model::checkBoundary() { for (int i = 0; i < _meshes.size(); i++) { for (int j = 0; j < _meshes[i].vertices().size();j++) { // 0,1,2 for x,y,z diff --git a/FinalProject/model.h b/FinalProject/model.h index 57bbbff..f551301 100644 --- a/FinalProject/model.h +++ b/FinalProject/model.h @@ -41,12 +41,12 @@ public: // maybe we can check if boundary has not been set yet - // Do remember to ensure you have called check_boundary + // Do remember to ensure you have called checkBoundary inline glm::vec3 get_upper_bound() { return _right_up_front; } - // Do remember to ensure you have called check_boundary + // Do remember to ensure you have called checkBoundary inline glm::vec3 get_lower_bound() { return _left_down_back; } @@ -57,7 +57,7 @@ private: 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 check_boundary(); + void checkBoundary(); public: void render(const ShaderProgram& shader) const; diff --git a/FinalProject/renderable.cpp b/FinalProject/renderable.cpp index 8254edf..3daf3d7 100644 --- a/FinalProject/renderable.cpp +++ b/FinalProject/renderable.cpp @@ -2,8 +2,6 @@ #include "renderable.h" -// ֵһmodelΧеĶ㴦ȡ - Renderable::Renderable(Model* model) : _model(model) {} Renderable::Renderable(Model* model, glm::vec3 position) : _model(model), _position(position) {} @@ -50,16 +48,18 @@ void Renderable::render(ShaderProgram shader) { // check here to get global boundary // must check before get boundary -void Renderable::check_boundary() { +void Renderable::checkBoundary() { std::vector temp = {_model->get_upper_bound(),_model->get_lower_bound()}; + _lower_bound = glm::vec3(3e36, 3e36, 3e36); _upper_bound = -_lower_bound; - auto model = this->modelMatrix();// 任 - // λ 000111ÿһ + + auto model = this->modelMatrix(); // transform matrix + + // Bit calculation for (int i = 0; i < 8; i++) { - //ÿһ 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; // 仯֮ĵ + 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]; diff --git a/FinalProject/renderable.h b/FinalProject/renderable.h index 6409f1f..c20c2dc 100644 --- a/FinalProject/renderable.h +++ b/FinalProject/renderable.h @@ -20,7 +20,6 @@ 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; @@ -45,14 +44,12 @@ public: public: void render(ShaderProgram shader); // check here to get global boundary - void check_boundary(); + void checkBoundary(); }; inline glm::mat4 Renderable::modelMatrix() const { glm::mat4 model = glm::mat4(1.0f); model = glm::translate(model, _position); - // ҳӦDzһģıͬ - //model = model * _rotation; model = _rotation * model; model = glm::scale(model, _scale); return model;