Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Clear old AABBs
- obj->ClearSecondaryAABBs();
- glm::mat4 rotMat = obj->GetRotationMatrix();
- glm::vec3 scale = obj->GetScale();
- //Calc min max for each mesh
- for (auto&& mesh : tempObj->GetMeshes())
- {
- glm::vec3 min = mesh.Vertices[0].Position * scale;
- glm::vec3 max = mesh.Vertices[0].Position * scale;
- glm::vec3 v;
- for (size_t i = 0; i < mesh.Vertices.size(); i++)
- {
- v = mesh.Vertices[i].Position * scale;
- v = rotMat * glm::vec4(v, 1);
- CalculateMinMax(v, min, max);
- }
- // create new aabb
- AABB* newBox = new AABB(min, max);
- newBox->min += obj->GetPosition();
- newBox->max += obj->GetPosition();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement