commit b34fd4f29e4024a842ce444d8dfbefd8caea3033
parent 7fb9331fd484ccdcfa72e02abb48091b3d3b43a8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 11 Jan 2021 13:06:49 +0100
Use the morton <de|en>coding routines of RSys 0.12
Diffstat:
4 files changed, 3 insertions(+), 45 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -25,7 +25,7 @@ option(NO_TEST "Do not build tests" OFF)
# Check dependencies
################################################################################
find_package(RCMake 0.3 REQUIRED)
-find_package(RSys 0.6 REQUIRED)
+find_package(RSys 0.12 REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR})
include(rcmake)
diff --git a/src/svx_c.h b/src/svx_c.h
@@ -20,32 +20,6 @@
#include "svx.h"
#include <rsys/rsys.h>
-static INLINE uint64_t
-morton3D_encode_u21(const uint32_t u21)
-{
- uint64_t u64 = u21 & ((1<<21) - 1);
- ASSERT(u21 <= ((1 << 21) - 1));
- u64 = (u64 | (u64 << 32)) & 0xFFFF00000000FFFF;
- u64 = (u64 | (u64 << 16)) & 0x00FF0000FF0000FF;
- u64 = (u64 | (u64 << 8)) & 0xF00F00F00F00F00F;
- u64 = (u64 | (u64 << 4)) & 0x30C30C30C30C30C3;
- u64 = (u64 | (u64 << 2)) & 0x9249249249249249;
- return u64;
-}
-
-static INLINE uint32_t
-morton3D_decode_u21(const uint64_t u64)
-{
- uint64_t tmp = (u64 & 0x9249249249249249);
- tmp = (tmp | (tmp >> 2)) & 0x30C30C30C30C30C3;
- tmp = (tmp | (tmp >> 4)) & 0xF00F00F00F00F00F;
- tmp = (tmp | (tmp >> 8)) & 0x00FF0000FF0000FF;
- tmp = (tmp | (tmp >> 16)) & 0xFFFF00000000FFFF;
- tmp = (tmp | (tmp >> 32)) & 0x00000000FFFFFFFF;
- ASSERT(tmp <= ((1<<21)-1));
- return (uint32_t)tmp;
-}
-
/* Count the number of bits set to 1 */
static FINLINE int
popcount(const uint8_t x)
@@ -56,23 +30,6 @@ popcount(const uint8_t x)
return (n * 0x0101) >> 8;
}
-static INLINE uint64_t
-morton_xyz_encode_u21(const uint32_t xyz[3])
-{
- return (morton3D_encode_u21(xyz[0]) << 2)
- | (morton3D_encode_u21(xyz[1]) << 1)
- | (morton3D_encode_u21(xyz[2]) << 0);
-}
-
-static INLINE void
-morton_xyz_decode_u21(const uint64_t code, uint32_t xyz[3])
-{
- ASSERT(xyz && code < ((1ull << 63)-1));
- xyz[0] = (uint32_t)morton3D_decode_u21(code >> 2);
- xyz[1] = (uint32_t)morton3D_decode_u21(code >> 1);
- xyz[2] = (uint32_t)morton3D_decode_u21(code >> 0);
-}
-
static INLINE int
check_svx_voxel_desc(const struct svx_voxel_desc* desc)
{
diff --git a/src/svx_tree_builder.h b/src/svx_tree_builder.h
@@ -21,6 +21,7 @@
#include "svx_buffer.h"
#include <rsys/double3.h>
+#include <rsys/morton.h>
#define TREE_DEPTH_MAX 16 /* Maximum depth of a tree */
diff --git a/src/test_svx_octree.c b/src/test_svx_octree.c
@@ -15,10 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "svx.h"
-#include "svx_c.h" /* For morton_xyz_encode_u21 */
#include "test_svx_utils.h"
#include <rsys/double3.h>
+#include <rsys/morton.h>
#include <string.h>