Skip to content

Commit

Permalink
Made max vertex calculation easier to read.
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo1211 committed Aug 31, 2018
1 parent 8f4d684 commit b043da0
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ void AABox::buildAABB(const Mesh &mesh){
for(int i = 0; i < mesh.numVertices; ++i){
//Checking the current vertex for all axes
for(int ax = 0; ax < 3; ++ax){
//Thanks @Erkaman!
//Setting max values
if(mesh.vertices[i].data[ax] > maxVals.data[ax]){
maxVals.data[ax] = mesh.vertices[i].data[ax];
}
maxVals.data[ax] = std::max(mesh.vertices[i].data[ax], maxVals.data[ax]);
//Setting min values
if(mesh.vertices[i].data[ax] < minVals.data[ax]){
minVals.data[ax] = mesh.vertices[i].data[ax];
}
minVals.data[ax] = std::min(mesh.vertices[i].data[ax], minVals.data[ax]);
}
}
minPoints = minVals;
Expand Down Expand Up @@ -54,14 +51,11 @@ void AABox::update(const Matrix4 &modelMatrix){
for(int i = 0; i < 8; ++i){
//Checking the current vertex for all axes
for(int ax = 0; ax < 3; ++ax){
//Thanks @Erkaman!
//Setting max values
if(vertices[i].data[ax] > maxVals.data[ax]){
maxVals.data[ax] = vertices[i].data[ax];
}
maxVals.data[ax] = std::max(vertices[i].data[ax], maxVals.data[ax]);
//Setting min values
if(vertices[i].data[ax] < minVals.data[ax]){
minVals.data[ax] = vertices[i].data[ax];
}
minVals.data[ax] = std::min(vertices[i].data[ax], minVals.data[ax]);
}
}

Expand Down

0 comments on commit b043da0

Please sign in to comment.