Skip to content

Commit

Permalink
Added rsm mesh bounding box calculation bug (thanks Tokei)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borf committed Nov 25, 2023
1 parent 64b618c commit 336b5ea
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions browedit/components/Rsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,19 +771,16 @@ void Rsm::Mesh::setBoundingBox2(glm::mat4& mat, glm::vec3& bbmin_, glm::vec3& bb
{
glm::mat4 mat1 = mat * matrix1;
glm::mat4 mat2 = mat * matrix1 * matrix2;
for (unsigned int i = 0; i < faces.size(); i++)
for (unsigned int i = 0; i < vertices.size(); i++)
{
for (int ii = 0; ii < 3; ii++)
{
glm::vec4 v = mat2 * glm::vec4(vertices[faces[i].vertexIds[ii]], 1);
bbmin_.x = glm::min(bbmin_.x, v.x);
bbmin_.y = glm::min(bbmin_.y, v.y);
bbmin_.z = glm::min(bbmin_.z, v.z);

bbmax_.x = glm::max(bbmax_.x, v.x);
bbmax_.y = glm::max(bbmax_.y, v.y);
bbmax_.z = glm::max(bbmax_.z, v.z);
}
glm::vec4 v = mat2 * glm::vec4(vertices[i], 1);
bbmin_.x = glm::min(bbmin_.x, v.x);
bbmin_.y = glm::min(bbmin_.y, v.y);
bbmin_.z = glm::min(bbmin_.z, v.z);

bbmax_.x = glm::max(bbmax_.x, v.x);
bbmax_.y = glm::max(bbmax_.y, v.y);
bbmax_.z = glm::max(bbmax_.z, v.z);
}

for (unsigned int i = 0; i < children.size(); i++)
Expand Down

0 comments on commit 336b5ea

Please sign in to comment.