mirror of
https://github.com/Linloir/SceneEditor.git
synced 2025-12-17 07:28:12 +08:00
Remove invalid code units
This commit is contained in:
parent
ef9580af3f
commit
849da430e9
@ -41,7 +41,7 @@ void Model::loadModel(std::string path) {
|
|||||||
_status = LOADED;
|
_status = LOADED;
|
||||||
Logger::info("Model loaded");
|
Logger::info("Model loaded");
|
||||||
// 仅检查一次即可
|
// 仅检查一次即可
|
||||||
//check_boundary();
|
//checkBoundary();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::processNode(aiNode* node, const aiScene* scene) {
|
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 i = 0; i < _meshes.size(); i++) {
|
||||||
for (int j = 0; j < _meshes[i].vertices().size();j++) {
|
for (int j = 0; j < _meshes[i].vertices().size();j++) {
|
||||||
// 0,1,2 for x,y,z
|
// 0,1,2 for x,y,z
|
||||||
|
|||||||
@ -41,12 +41,12 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// maybe we can check if boundary has not been set yet
|
// 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() {
|
inline glm::vec3 get_upper_bound() {
|
||||||
return _right_up_front;
|
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() {
|
inline glm::vec3 get_lower_bound() {
|
||||||
return _left_down_back;
|
return _left_down_back;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ private:
|
|||||||
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
|
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
|
||||||
std::vector<Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type, TextureType textureType);
|
std::vector<Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type, TextureType textureType);
|
||||||
// Since these are loacl position, this function should be called just once.
|
// Since these are loacl position, this function should be called just once.
|
||||||
void check_boundary();
|
void checkBoundary();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void render(const ShaderProgram& shader) const;
|
void render(const ShaderProgram& shader) const;
|
||||||
|
|||||||
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include "renderable.h"
|
#include "renderable.h"
|
||||||
|
|
||||||
// 极值点一定在model包围盒的顶点处取到
|
|
||||||
|
|
||||||
Renderable::Renderable(Model* model) : _model(model) {}
|
Renderable::Renderable(Model* model) : _model(model) {}
|
||||||
|
|
||||||
Renderable::Renderable(Model* model, glm::vec3 position) : _model(model), _position(position) {}
|
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
|
// check here to get global boundary
|
||||||
// must check before get boundary
|
// must check before get boundary
|
||||||
void Renderable::check_boundary() {
|
void Renderable::checkBoundary() {
|
||||||
std::vector<glm::vec3> temp = {_model->get_upper_bound(),_model->get_lower_bound()};
|
std::vector<glm::vec3> temp = {_model->get_upper_bound(),_model->get_lower_bound()};
|
||||||
|
|
||||||
_lower_bound = glm::vec3(3e36, 3e36, 3e36);
|
_lower_bound = glm::vec3(3e36, 3e36, 3e36);
|
||||||
_upper_bound = -_lower_bound;
|
_upper_bound = -_lower_bound;
|
||||||
auto model = this->modelMatrix();// 变换矩阵
|
|
||||||
// 位运算 从000到111的每一种组合
|
auto model = this->modelMatrix(); // transform matrix
|
||||||
|
|
||||||
|
// Bit calculation
|
||||||
for (int i = 0; i < 8; i++) {
|
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);
|
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++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
_lower_bound[j] = _lower_bound[j] < vex[j] ? _lower_bound[j] : vex[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];
|
_upper_bound[j] = _upper_bound[j] > vex[j] ? _upper_bound[j] : vex[j];
|
||||||
|
|||||||
@ -20,7 +20,6 @@ private:
|
|||||||
glm::vec3 _position = glm::vec3(0.0f);
|
glm::vec3 _position = glm::vec3(0.0f);
|
||||||
glm::mat4 _rotation = glm::mat4(1.0f);
|
glm::mat4 _rotation = glm::mat4(1.0f);
|
||||||
glm::vec3 _scale = glm::vec3(1.0f);
|
glm::vec3 _scale = glm::vec3(1.0f);
|
||||||
// 下面是与坐标轴平行的顶点
|
|
||||||
glm::vec3 _lower_bound;
|
glm::vec3 _lower_bound;
|
||||||
glm::vec3 _upper_bound;
|
glm::vec3 _upper_bound;
|
||||||
|
|
||||||
@ -45,14 +44,12 @@ public:
|
|||||||
public:
|
public:
|
||||||
void render(ShaderProgram shader);
|
void render(ShaderProgram shader);
|
||||||
// check here to get global boundary
|
// check here to get global boundary
|
||||||
void check_boundary();
|
void checkBoundary();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline glm::mat4 Renderable::modelMatrix() const {
|
inline glm::mat4 Renderable::modelMatrix() const {
|
||||||
glm::mat4 model = glm::mat4(1.0f);
|
glm::mat4 model = glm::mat4(1.0f);
|
||||||
model = glm::translate(model, _position);
|
model = glm::translate(model, _position);
|
||||||
// 左乘与右乘应该是不一样的,但是这里的表现相同
|
|
||||||
//model = model * _rotation;
|
|
||||||
model = _rotation * model;
|
model = _rotation * model;
|
||||||
model = glm::scale(model, _scale);
|
model = glm::scale(model, _scale);
|
||||||
return model;
|
return model;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user