Poll: Passing coords in function params - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Poll: Passing coords in function params (/thread-2987.html) |
Poll: Passing coords in function params - xoft - 07-14-2017 I think we're long overdue for this discussion. Do we prefer passing coords between functions as three (or six) int params, or as a Vector3 / cCuboid / cBoundingBox? There's a problem with int-based approach, especially when specifying ranges - some of the functions take the (MinX, MaxX, MinY, MaxY, MinZ, MaxZ) ordering and some the (MinX, MinY, MinZ, MaxX, MaxY, MaxZ) ordering, creating a great opportunity for subtle bugs. On the other hand, we don't know if using the object-based approach has any performance implications on some platforms. We know that on x64 the Vector3i may actually be faster than three ints [1], but we have no idea about ARM. Can someone provide some insight / benchmarks? So, the question is, should we change all the code to use objects, or drop the objects completely, or keep doing what we're doing now (no guidance at all)? Ref.: [1]: https://github.com/cuberite/cuberite/pull/3826#discussion_r125324633 RE: Poll: Passing coords in function params - NiLSPACE - 07-15-2017 Vector3, cCuboid and cBoundingBox where specifically created for this, so I suppose it makes sense to use them. RE: Poll: Passing coords in function params - xoft - 07-18-2017 Well, not specifically for this, rather for storing coords inside objects, but still a valid usage. Seems pretty unanimous, we'll rewrite. |