Skip to content

Commit

Permalink
Merge pull request #32 from jdibenes/sm_test
Browse files Browse the repository at this point in the history
sm patch
  • Loading branch information
jdibenes authored Apr 1, 2023
2 parents 36a7550 + ccf968f commit 3478b84
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
11 changes: 10 additions & 1 deletion hl2ss/hl2ss/locator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,20 @@ float4x4 Locator_GetTransformTo(SpatialCoordinateSystem const& src, SpatialCoord
return location ? location.Value() : float4x4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}

// OK
SpatialCoordinateSystem Locator_GetWorldCoordinateSystemInternal(PerceptionTimestamp const& ts)
{
return (g_locatability == SpatialLocatability::PositionalTrackingActive) ? g_referenceFrame.CoordinateSystem() : g_attachedReferenceFrame.GetStationaryCoordinateSystemAtTimestamp(ts);
}

// OK
SpatialCoordinateSystem Locator_GetWorldCoordinateSystem(PerceptionTimestamp const& ts)
{
{
SRWLock srw(&g_lock, false);
return g_world_override ? g_world_override : ((g_locatability == SpatialLocatability::PositionalTrackingActive) ? g_referenceFrame.CoordinateSystem() : g_attachedReferenceFrame.GetStationaryCoordinateSystemAtTimestamp(ts));
if (g_world_override) { return g_world_override; }
}
return Locator_GetWorldCoordinateSystemInternal(ts);
}

// OK
Expand Down
1 change: 1 addition & 0 deletions hl2ss/hl2ss/locator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ winrt::Windows::Foundation::Numerics::float4x4 Locator_Locate(winrt::Windows::Pe
winrt::Windows::Foundation::Numerics::float4x4 Locator_GetTransformTo(winrt::Windows::Perception::Spatial::SpatialCoordinateSystem const& src, winrt::Windows::Perception::Spatial::SpatialCoordinateSystem const& dst);
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem Locator_GetWorldCoordinateSystem(winrt::Windows::Perception::PerceptionTimestamp const& ts);
void Locator_OverrideWorldCoordinateSystem(winrt::Windows::Perception::Spatial::SpatialCoordinateSystem const& scs);
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem Locator_GetWorldCoordinateSystemInternal(winrt::Windows::Perception::PerceptionTimestamp const& ts);
2 changes: 0 additions & 2 deletions hl2ss/hl2ss/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ struct App : winrt::implements<App, IFrameworkViewSource, IFrameworkView>
SU_Initialize();
VI_Initialize();

PrintSystemInfo();

m_init = true;
}

Expand Down
7 changes: 5 additions & 2 deletions hl2ss/hl2ss/spatial_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ struct SSM
SpatialSurfaceMesh mesh = nullptr;
};

// Notes
// GetObservedSurfaces crashes when using OpenXR coordinate system (in Windows.Mirage.dll)

//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -77,7 +80,7 @@ void SpatialMapping_SetVolumes(SpatialMapping_VolumeDescription const* vd, size_
{
std::vector<SpatialBoundingVolume> volumes;

g_world = Locator_GetWorldCoordinateSystem(QPCTimestampToPerceptionTimestamp(GetCurrentQPCTimestamp()));
g_world = Locator_GetWorldCoordinateSystemInternal(QPCTimestampToPerceptionTimestamp(GetCurrentQPCTimestamp()));

for (int i = 0; i < size; ++i)
{
Expand Down Expand Up @@ -158,7 +161,7 @@ static void SpatialMapping_ComputeMesh(SpatialMapping_MeshTask* task)
g_observed_meshes_info[task->index].vpd = vertex_positions.data();
g_observed_meshes_info[task->index].tid = triangle_indices.data();
g_observed_meshes_info[task->index].vnd = compute_normals ? vertex_normals.data() : NULL;
g_observed_meshes_info[task->index].pose = Locator_GetTransformTo(ssm.CoordinateSystem(), g_world);
g_observed_meshes_info[task->index].pose = Locator_GetTransformTo(ssm.CoordinateSystem(), g_world) * Locator_GetTransformTo(g_world, Locator_GetWorldCoordinateSystem(QPCTimestampToPerceptionTimestamp(GetCurrentQPCTimestamp())));
g_observed_meshes_info[task->index].scale = ssm.VertexPositionScale();
g_observed_meshes_info[task->index].bsz = compute_bounds ? sizeof(SpatialBoundingOrientedBox) : 0;
if (compute_bounds)
Expand Down
2 changes: 1 addition & 1 deletion unity/Hololens2SensorStreaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Hololens2SensorStreaming : MonoBehaviour

void Start()
{
if (!skipInitialization) { hl2ss.Initialize(enableRM, enablePV, enableMC, enableRC, enableSM, enableSU, enableVI); }
hl2ss.UpdateCoordinateSystem();
if (!skipInitialization) { hl2ss.Initialize(enableRM, enablePV, enableMC, enableRC, enableSM, enableSU, enableVI); }
}
}

0 comments on commit 3478b84

Please sign in to comment.