Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何优化3D AABB旋转(Java)_Java_Optimization_3d_Game Engine_Aabb - Fatal编程技术网

如何优化3D AABB旋转(Java)

如何优化3D AABB旋转(Java),java,optimization,3d,game-engine,aabb,Java,Optimization,3d,Game Engine,Aabb,最近,我在我的游戏引擎中实现了3D AABB,为了完成旋转,我使用了一种简单的方法,即使用Vector3f.rotate()方法围绕长方体中心旋转所有8个计算角。但正如你在下面可能注意到的,它是非常低效的。如果你想对整个类进行排序,这里是github(),否则这里是我需要帮助的snipit,我认为可能会有更简单的方法,但我想知道你的想法。谢谢大家! // Creates the 8 AABB corners and rotates them. Vector3f FLL =

最近,我在我的游戏引擎中实现了3D AABB,为了完成旋转,我使用了一种简单的方法,即使用Vector3f.rotate()方法围绕长方体中心旋转所有8个计算角。但正如你在下面可能注意到的,它是非常低效的。如果你想对整个类进行排序,这里是github(),否则这里是我需要帮助的snipit,我认为可能会有更简单的方法,但我想知道你的想法。谢谢大家!

        // 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)))))));