Skip to content

Commit 7e8077d

Browse files
author
Tim van Wankum
committed
clang formatting
1 parent 684a6bb commit 7e8077d

3 files changed

Lines changed: 65 additions & 64 deletions

File tree

src/plugins/manus/core/manus_hand_tracking_plugin.cpp

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ bool is_openxr_extension_supported(const char* ext_name)
4242
{
4343
return false;
4444
}
45-
return std::any_of(props.begin(), props.end(), [ext_name](const XrExtensionProperties& p)
46-
{
47-
return std::string(p.extensionName) == ext_name;
48-
});
45+
return std::any_of(props.begin(), props.end(),
46+
[ext_name](const XrExtensionProperties& p) { return std::string(p.extensionName) == ext_name; });
4947
}
5048

5149
} // anonymous namespace
@@ -169,8 +167,7 @@ void ManusTracker::initialize(const std::string& app_name) noexcept(false)
169167
else
170168
{
171169
std::cout << "[Manus] " << XR_EXT_HAND_TRACKING_EXTENSION_NAME
172-
<< " is not supported by the current runtime; HandTracker will not be created."
173-
<< std::endl;
170+
<< " is not supported by the current runtime; HandTracker will not be created." << std::endl;
174171
}
175172

176173
// Get required extensions from trackers
@@ -189,8 +186,7 @@ void ManusTracker::initialize(const std::string& app_name) noexcept(false)
189186
{
190187
std::cout << "[Manus] " << XR_MNDX_XDEV_SPACE_EXTENSION_NAME
191188
<< " is not supported by the current runtime; optical hand tracking"
192-
<< " will not be available and controller fallback will be used."
193-
<< std::endl;
189+
<< " will not be available and controller fallback will be used." << std::endl;
194190
}
195191

196192
// Create session with required extensions - constructor automatically begins the session
@@ -201,8 +197,10 @@ void ManusTracker::initialize(const std::string& app_name) noexcept(false)
201197
m_time_converter.emplace(m_handles);
202198

203199
// Initialize hand injectors (one per hand)
204-
m_left_injector = std::make_unique<plugin_utils::HandInjector>(m_handles.instance, m_handles.session, XR_HAND_LEFT_EXT, m_handles.space);
205-
m_right_injector = std::make_unique<plugin_utils::HandInjector>(m_handles.instance, m_handles.session, XR_HAND_RIGHT_EXT, m_handles.space);
200+
m_left_injector = std::make_unique<plugin_utils::HandInjector>(
201+
m_handles.instance, m_handles.session, XR_HAND_LEFT_EXT, m_handles.space);
202+
m_right_injector = std::make_unique<plugin_utils::HandInjector>(
203+
m_handles.instance, m_handles.session, XR_HAND_RIGHT_EXT, m_handles.space);
206204

207205
m_deviceio_session = core::DeviceIOSession::run(trackers, m_handles);
208206

@@ -214,8 +212,7 @@ void ManusTracker::initialize(const std::string& app_name) noexcept(false)
214212
initialize_xdev_hand_trackers();
215213
}
216214

217-
std::cout << "[Manus] Initialized with wrist source: "
218-
<< (m_xdev_available ? "HandTracking" : "Controllers")
215+
std::cout << "[Manus] Initialized with wrist source: " << (m_xdev_available ? "HandTracking" : "Controllers")
219216
<< std::endl;
220217

221218
success = true;
@@ -409,32 +406,34 @@ void ManusTracker::OnLandscapeStream(const Landscape* landscape)
409406
{
410407
const GloveLandscapeData& glove = gloves.gloves[i];
411408
if (glove.side == Side::Side_Left)
409+
{
410+
tracker.left_glove_id = glove.id;
411+
left_present = true;
412+
// Fetch bone topology once on connect
413+
uint32_t nc = 0;
414+
if (CoreSdk_GetRawSkeletonNodeCount(glove.id, nc) == SDKReturnCode::SDKReturnCode_Success && nc > 0)
412415
{
413-
tracker.left_glove_id = glove.id;
414-
left_present = true;
415-
// Fetch bone topology once on connect
416-
uint32_t nc = 0;
417-
if (CoreSdk_GetRawSkeletonNodeCount(glove.id, nc) == SDKReturnCode::SDKReturnCode_Success && nc > 0)
418-
{
419-
std::lock_guard<std::mutex> sk(tracker.m_skeleton_mutex);
420-
tracker.m_left_node_info.resize(nc);
421-
if (CoreSdk_GetRawSkeletonNodeInfoArray(glove.id, tracker.m_left_node_info.data(), nc) != SDKReturnCode::SDKReturnCode_Success)
422-
tracker.m_left_node_info.clear();
423-
}
416+
std::lock_guard<std::mutex> sk(tracker.m_skeleton_mutex);
417+
tracker.m_left_node_info.resize(nc);
418+
if (CoreSdk_GetRawSkeletonNodeInfoArray(glove.id, tracker.m_left_node_info.data(), nc) !=
419+
SDKReturnCode::SDKReturnCode_Success)
420+
tracker.m_left_node_info.clear();
424421
}
425-
else if (glove.side == Side::Side_Right)
422+
}
423+
else if (glove.side == Side::Side_Right)
424+
{
425+
tracker.right_glove_id = glove.id;
426+
right_present = true;
427+
uint32_t nc = 0;
428+
if (CoreSdk_GetRawSkeletonNodeCount(glove.id, nc) == SDKReturnCode::SDKReturnCode_Success && nc > 0)
426429
{
427-
tracker.right_glove_id = glove.id;
428-
right_present = true;
429-
uint32_t nc = 0;
430-
if (CoreSdk_GetRawSkeletonNodeCount(glove.id, nc) == SDKReturnCode::SDKReturnCode_Success && nc > 0)
431-
{
432-
std::lock_guard<std::mutex> sk(tracker.m_skeleton_mutex);
433-
tracker.m_right_node_info.resize(nc);
434-
if (CoreSdk_GetRawSkeletonNodeInfoArray(glove.id, tracker.m_right_node_info.data(), nc) != SDKReturnCode::SDKReturnCode_Success)
435-
tracker.m_right_node_info.clear();
436-
}
430+
std::lock_guard<std::mutex> sk(tracker.m_skeleton_mutex);
431+
tracker.m_right_node_info.resize(nc);
432+
if (CoreSdk_GetRawSkeletonNodeInfoArray(glove.id, tracker.m_right_node_info.data(), nc) !=
433+
SDKReturnCode::SDKReturnCode_Success)
434+
tracker.m_right_node_info.clear();
437435
}
436+
}
438437
}
439438

440439
// Clear stale state for any glove that is no longer present in this landscape
@@ -463,7 +462,8 @@ void ManusTracker::OnLandscapeStream(const Landscape* landscape)
463462
void ManusTracker::initialize_xdev_hand_trackers()
464463
{
465464
// Load XDev extension function pointers
466-
auto load_func = [this](const char* name, PFN_xrVoidFunction* ptr) -> bool {
465+
auto load_func = [this](const char* name, PFN_xrVoidFunction* ptr) -> bool
466+
{
467467
XrResult result = m_handles.xrGetInstanceProcAddr(m_handles.instance, name, ptr);
468468
return XR_SUCCEEDED(result) && *ptr != nullptr;
469469
};
@@ -553,20 +553,21 @@ void ManusTracker::initialize_xdev_hand_trackers()
553553
std::string serials_list;
554554
for (const auto& s : seen_serials)
555555
{
556-
if (!serials_list.empty()) serials_list += ", ";
556+
if (!serials_list.empty())
557+
serials_list += ", ";
557558
serials_list += '"';
558559
serials_list += s;
559560
serials_list += '"';
560561
}
561562
std::cerr << "[Manus] Could not match optical hand-tracking XDevs by serial. "
562-
<< "Expected \"Head Device (0)\" (left) and \"Head Device (1)\" (right), "
563-
<< "but found: [" << serials_list << "]. "
564-
<< "These serial strings are runtime-specific and may have changed."
563+
<< "Expected \"Head Device (0)\" (left) and \"Head Device (1)\" (right), " << "but found: ["
564+
<< serials_list << "]. " << "These serial strings are runtime-specific and may have changed."
565565
<< std::endl;
566566
}
567567

568568
// Create hand trackers from XDevs
569-
auto create_tracker = [this](XrXDevIdMNDX xdev_id, XrHandEXT hand, XrHandTrackerEXT& out_tracker) -> bool {
569+
auto create_tracker = [this](XrXDevIdMNDX xdev_id, XrHandEXT hand, XrHandTrackerEXT& out_tracker) -> bool
570+
{
570571
if (xdev_id == 0)
571572
{
572573
return false;
@@ -662,8 +663,8 @@ bool ManusTracker::update_xdev_hand(XrHandTrackerEXT tracker, XrTime time, XrPos
662663

663664
bool ManusTracker::get_controller_wrist_pose(bool is_left, XrPosef& out_wrist_pose)
664665
{
665-
const auto& tracked = is_left ? m_controller_tracker->get_left_controller(*m_deviceio_session)
666-
: m_controller_tracker->get_right_controller(*m_deviceio_session);
666+
const auto& tracked = is_left ? m_controller_tracker->get_left_controller(*m_deviceio_session) :
667+
m_controller_tracker->get_right_controller(*m_deviceio_session);
667668

668669
if (!tracked.data)
669670
{

src/plugins/manus/inc/core/manus_hand_tracking_plugin.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33

44
#pragma once
55

6-
#include <deviceio_trackers/controller_tracker.hpp>
76
#include <deviceio_session/deviceio_session.hpp>
7+
#include <deviceio_trackers/controller_tracker.hpp>
88
#include <deviceio_trackers/hand_tracker.hpp>
99
#include <openxr/openxr_platform.h>
1010
#include <oxr/oxr_session.hpp>
1111
#include <oxr_utils/oxr_time.hpp>
1212
#include <plugin_utils/hand_injector.hpp>
1313

14-
#include <XR_MNDX_xdev_space.h>
15-
1614
#include <ManusSDK.h>
15+
#include <XR_MNDX_xdev_space.h>
1716
#include <memory>
1817
#include <mutex>
1918
#include <optional>
@@ -39,8 +38,8 @@ class __attribute__((visibility("default"))) ManusTracker
3938
void update();
4039
std::vector<SkeletonNode> get_left_hand_nodes() const;
4140
std::vector<SkeletonNode> get_right_hand_nodes() const;
42-
std::vector<NodeInfo> get_left_node_info() const;
43-
std::vector<NodeInfo> get_right_node_info() const;
41+
std::vector<NodeInfo> get_left_node_info() const;
42+
std::vector<NodeInfo> get_right_node_info() const;
4443

4544
private:
4645
// Lifecycle

src/plugins/manus/tools/manus_hand_tracker_printer.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#include <core/manus_hand_tracking_plugin.hpp>
54
#include "manus_hand_visualizer.hpp"
65

6+
#include <core/manus_hand_tracking_plugin.hpp>
7+
78
#include <algorithm>
89
#include <chrono>
910
#include <iomanip>
@@ -27,18 +28,19 @@ try
2728
// continues without the window.
2829
// std::jthread automatically requests stop and joins on destruction,
2930
// preventing the thread from outliving the tracker singleton.
30-
std::jthread vis_thread([&tracker](std::stop_token st)
31-
{
32-
try
33-
{
34-
plugins::manus::HandVisualizer vis;
35-
vis.run(tracker, std::move(st));
36-
}
37-
catch (const std::exception& e)
31+
std::jthread vis_thread(
32+
[&tracker](std::stop_token st)
3833
{
39-
std::cerr << "[Vis] " << e.what() << " — running without visualizer" << std::endl;
40-
}
41-
});
34+
try
35+
{
36+
plugins::manus::HandVisualizer vis;
37+
vis.run(tracker, std::move(st));
38+
}
39+
catch (const std::exception& e)
40+
{
41+
std::cerr << "[Vis] " << e.what() << " — running without visualizer" << std::endl;
42+
}
43+
});
4244

4345
std::cout << "[Manus] Press Ctrl+C to stop. Printing joint data..." << std::endl;
4446

@@ -79,10 +81,9 @@ try
7981
const auto& pos = nodes[i].transform.position;
8082
const auto& ori = nodes[i].transform.rotation;
8183

82-
std::cout << "[Manus] Joint " << i << ": "
83-
<< "pos=[" << std::fixed << std::setprecision(3) << pos.x << ", " << pos.y << ", " << pos.z
84-
<< "] "
85-
<< "ori=[" << ori.x << ", " << ori.y << ", " << ori.z << ", " << ori.w << "]" << std::endl;
84+
std::cout << "[Manus] Joint " << i << ": " << "pos=[" << std::fixed << std::setprecision(3) << pos.x
85+
<< ", " << pos.y << ", " << pos.z << "] " << "ori=[" << ori.x << ", " << ori.y << ", "
86+
<< ori.z << ", " << ori.w << "]" << std::endl;
8687
}
8788

8889
if (nodes.size() > 5)

0 commit comments

Comments
 (0)