| 755 | } |
| 756 | |
| 757 | void ForwardRenderQueue::SortForPerspective(const AbstractViewer* viewer) |
| 758 | { |
| 759 | Planef nearPlane = viewer->GetFrustum().GetPlane(FrustumPlane_Near); |
| 760 | Vector3f viewerPos = viewer->GetEyePosition(); |
| 761 | |
| 762 | for (auto& pair : layers) |
| 763 | { |
| 764 | Layer& layer = pair.second; |
| 765 | |
| 766 | std::sort(layer.depthSortedMeshes.begin(), layer.depthSortedMeshes.end(), [&layer, &viewerPos] (std::size_t index1, std::size_t index2) |
| 767 | { |
| 768 | const Spheref& sphere1 = layer.depthSortedMeshData[index1].obbSphere; |
| 769 | const Spheref& sphere2 = layer.depthSortedMeshData[index2].obbSphere; |
| 770 | |
| 771 | return viewerPos.SquaredDistance(sphere1.GetPosition()) > viewerPos.SquaredDistance(sphere2.GetPosition()); |
| 772 | }); |
| 773 | |
| 774 | std::sort(layer.depthSortedSprites.begin(), layer.depthSortedSprites.end(), [&layer, &viewerPos] (std::size_t index1, std::size_t index2) |
| 775 | { |
| 776 | const Vector3f& pos1 = layer.depthSortedSpriteData[index1].vertices[0].position; |
| 777 | const Vector3f& pos2 = layer.depthSortedSpriteData[index2].vertices[0].position; |
| 778 | |
| 779 | return viewerPos.SquaredDistance(pos1) > viewerPos.SquaredDistance(pos2); |
| 780 | }); |
| 781 | |
| 782 | SortBillboards(layer, nearPlane); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | /*! |
| 787 | * \brief Handle the invalidation of an index buffer |
nothing calls this directly
no test coverage detected