Как оптимизировать 3D AABB Rotate (Java)
Недавно я внедрял 3D AABB в свой игровой движок, для выполнения вращений я использую простой метод поворота всех 8 рассчитанных углов вокруг центра поля, используя мой метод Vector3f.rotate(). Но, как вы можете заметить ниже, это очень неэффективно. Если вы хотите отсортировать весь класс, это github ( https://github.com/EquilibriumGames/Flounder-Engine/blob/master/src/flounder/physics/AABB.java) в противном случае вот фрагмент, мне нужна помощь Я считаю, что могут быть более простые методы, но я хочу знать, что вы думаете. Спасибо!
// Creates the 8 AABB corners and rotates them.
Vector3f FLL = new Vector3f(destination.minExtents.x, destination.minExtents.y, destination.minExtents.z);
Vector3f.rotate(FLL, rotation, FLL);
Vector3f FLR = new Vector3f(destination.maxExtents.x, destination.minExtents.y, destination.minExtents.z);
Vector3f.rotate(FLR, rotation, FLR);
Vector3f FUL = new Vector3f(destination.minExtents.x, destination.maxExtents.y, destination.minExtents.z);
Vector3f.rotate(FUL, rotation, FUL);
Vector3f FUR = new Vector3f(destination.maxExtents.x, destination.maxExtents.y, destination.minExtents.z);
Vector3f.rotate(FUR, rotation, FUR);
Vector3f BUR = new Vector3f(destination.maxExtents.x, destination.maxExtents.y, destination.maxExtents.z);
Vector3f.rotate(BUR, rotation, BUR);
Vector3f BUL = new Vector3f(destination.minExtents.x, destination.maxExtents.y, destination.maxExtents.z);
Vector3f.rotate(BUL, rotation, BUL);
Vector3f BLR = new Vector3f(destination.maxExtents.x, destination.minExtents.y, destination.maxExtents.z);
Vector3f.rotate(BLR, rotation, BLR);
Vector3f BLL = new Vector3f(destination.minExtents.x, destination.minExtents.y, destination.maxExtents.z);
Vector3f.rotate(BLL, rotation, BLL);
destination.minExtents = Maths.min(FLL, Maths.min(FLR, Maths.min(FUL, Maths.min(FUR, Maths.min(BUR, Maths.min(BUL, Maths.min(BLR, BLL)))))));
destination.maxExtents = Maths.max(FLL, Maths.max(FLR, Maths.max(FUL, Maths.max(FUR, Maths.max(BUR, Maths.max(BUL, Maths.max(BLR, BLL)))))));