Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. //Clear old AABBs
  2. obj->ClearSecondaryAABBs();
  3.  
  4. glm::mat4 rotMat = obj->GetRotationMatrix();
  5. glm::vec3 scale = obj->GetScale();
  6.  
  7. //Calc min max for each mesh
  8. for (auto&& mesh : tempObj->GetMeshes())
  9. {
  10. glm::vec3 min = mesh.Vertices[0].Position * scale;
  11. glm::vec3 max = mesh.Vertices[0].Position * scale;
  12. glm::vec3 v;
  13.  
  14.  
  15. for (size_t i = 0; i < mesh.Vertices.size(); i++)
  16. {
  17. v = mesh.Vertices[i].Position * scale;
  18. v = rotMat * glm::vec4(v, 1);
  19. CalculateMinMax(v, min, max);
  20. }
  21.  
  22. // create new aabb
  23. AABB* newBox = new AABB(min, max);
  24.  
  25. newBox->min += obj->GetPosition();
  26. newBox->max += obj->GetPosition();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement