Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Boost 1.5 COMPONENTS system REQUIRED) # for optitrack
find_package(Threads REQUIRED)
find_package(Boost 1.5 OPTIONAL_COMPONENTS system) # for optitrack
add_definitions(
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
Expand Down Expand Up @@ -87,8 +88,15 @@ if (LIBMOTIONCAPTURE_ENABLE_OPTITRACK)
)
set(my_libraries
${my_libraries}
Boost::system
Boost::boost
Threads::Threads
)
if (Boost_SYSTEM_FOUND)
set(my_libraries
${my_libraries}
Boost::system
)
endif()
endif()

if (LIBMOTIONCAPTURE_ENABLE_OPTITRACK_CLOSED_SOURCE)
Expand Down Expand Up @@ -232,6 +240,7 @@ target_link_directories(libmotioncapture PUBLIC
${my_link_directories}
)
target_link_libraries(libmotioncapture
Eigen3::Eigen
${my_libraries}
)
set_property(TARGET libmotioncapture PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand Down
17 changes: 15 additions & 2 deletions src/optitrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@

using boost::asio::ip::udp;

// Source - https://stackoverflow.com/a/3312896
// Posted by Steph, modified by community. See post 'Timeline' for change history
// Retrieved 2026-02-21, License - CC BY-SA 4.0

#ifdef __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif

#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
#endif


namespace libmotioncapture {

constexpr int MAX_PACKETSIZE = 65503; // max size of packet (actual packet size is dynamic)
Expand Down Expand Up @@ -355,10 +368,10 @@ if (!response.IsMulticast) {
const uint16_t port_cmd = 1510;

// Build a NatNet "Connect" command (message ID 0x0002)
struct NatNetCommand {
PACK(struct NatNetCommand {
uint16_t messageId;
uint16_t packetSize;
} __attribute__((packed));
});

NatNetCommand connectCmd;
connectCmd.messageId = 0x0002; // "Client Connect" message
Expand Down