Subscribe to correct tracker signals

This commit is contained in:
Malcolm Nixon 2024-04-22 18:40:18 -04:00
parent 7abe0c6014
commit 00f3dd0337
2 changed files with 8 additions and 8 deletions

View File

@ -312,7 +312,7 @@ void XRBodyModifier3D::_process_modification() {
} }
} }
void XRBodyModifier3D::_tracker_changed(const StringName &p_tracker_name, const Ref<XRBodyTracker> &p_tracker) { void XRBodyModifier3D::_tracker_changed(const StringName &p_tracker_name, XRServer::TrackerType p_tracker_type) {
if (tracker_name == p_tracker_name) { if (tracker_name == p_tracker_name) {
_get_joint_data(); _get_joint_data();
} }
@ -327,18 +327,18 @@ void XRBodyModifier3D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
XRServer *xr_server = XRServer::get_singleton(); XRServer *xr_server = XRServer::get_singleton();
if (xr_server) { if (xr_server) {
xr_server->connect("body_tracker_added", callable_mp(this, &XRBodyModifier3D::_tracker_changed)); xr_server->connect("tracker_added", callable_mp(this, &XRBodyModifier3D::_tracker_changed));
xr_server->connect("body_tracker_updated", callable_mp(this, &XRBodyModifier3D::_tracker_changed)); xr_server->connect("tracker_updated", callable_mp(this, &XRBodyModifier3D::_tracker_changed));
xr_server->connect("body_tracker_removed", callable_mp(this, &XRBodyModifier3D::_tracker_changed).bind(Ref<XRBodyTracker>())); xr_server->connect("tracker_removed", callable_mp(this, &XRBodyModifier3D::_tracker_changed));
} }
_get_joint_data(); _get_joint_data();
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
XRServer *xr_server = XRServer::get_singleton(); XRServer *xr_server = XRServer::get_singleton();
if (xr_server) { if (xr_server) {
xr_server->disconnect("body_tracker_added", callable_mp(this, &XRBodyModifier3D::_tracker_changed)); xr_server->disconnect("tracker_added", callable_mp(this, &XRBodyModifier3D::_tracker_changed));
xr_server->disconnect("body_tracker_updated", callable_mp(this, &XRBodyModifier3D::_tracker_changed)); xr_server->disconnect("tracker_updated", callable_mp(this, &XRBodyModifier3D::_tracker_changed));
xr_server->disconnect("body_tracker_removed", callable_mp(this, &XRBodyModifier3D::_tracker_changed).bind(Ref<XRBodyTracker>())); xr_server->disconnect("tracker_removed", callable_mp(this, &XRBodyModifier3D::_tracker_changed));
} }
for (int i = 0; i < XRBodyTracker::JOINT_MAX; i++) { for (int i = 0; i < XRBodyTracker::JOINT_MAX; i++) {
joints[i].bone = -1; joints[i].bone = -1;

View File

@ -86,7 +86,7 @@ private:
JointData joints[XRBodyTracker::JOINT_MAX]; JointData joints[XRBodyTracker::JOINT_MAX];
void _get_joint_data(); void _get_joint_data();
void _tracker_changed(const StringName &p_tracker_name, const Ref<XRBodyTracker> &p_tracker); void _tracker_changed(const StringName &p_tracker_name, XRServer::TrackerType p_tracker_type);
}; };
VARIANT_BITFIELD_CAST(XRBodyModifier3D::BodyUpdate) VARIANT_BITFIELD_CAST(XRBodyModifier3D::BodyUpdate)