@@ -367,6 +367,11 @@ private void OnDestroy()
367367
368368 // Unsubscribe from state.
369369 _probeStateSubscription ? . Dispose ( ) ;
370+
371+ #if APP_UI
372+ // Remove the probe world state when the probe is destroyed
373+ PinpointApp . StoreServiceStore . Dispatch ( ProbeWorldActions . REMOVE_PROBE_WORLD_STATE , name ) ;
374+ #endif
370375 }
371376
372377 #endregion
@@ -491,6 +496,42 @@ public void ProbeMoved()
491496 _recRegionTopCoordWorldU = BrainAtlasManager . WorldT2WorldU ( endCoordWorldT , true ) ;
492497 }
493498
499+ #if APP_UI
500+ /// <summary>
501+ /// Dispatches the computed world-space probe state to the Redux store.
502+ /// This is called after probe position/orientation updates are complete.
503+ /// </summary>
504+ private void DispatchProbeWorldState ( )
505+ {
506+ // Get tip world coordinates
507+ var ( tipCoordWorldU , tipRightWorldU , tipUpWorldU , tipForwardWorldU ) =
508+ _probeController . GetTipWorldU ( ) ;
509+
510+ // Get tip position in WorldT
511+ Vector3 tipCoordWorldT = _probeController . ProbeTipT . position ;
512+
513+ // Create the world state object
514+ var worldState = new ProbeWorldState
515+ {
516+ Name = name ,
517+ TipPositionWorldU = tipCoordWorldU ,
518+ TipPositionWorldT = tipCoordWorldT ,
519+ TipRightWorldU = tipRightWorldU ,
520+ TipUpWorldU = tipUpWorldU ,
521+ TipForwardWorldU = tipForwardWorldU ,
522+ SurfaceCoordinateWorldT = _brainSurfaceWorldT ,
523+ SurfaceCoordinateWorldU = _brainSurfaceWorldU ,
524+ SurfaceCoordinateT = _brainSurfaceCoordT ,
525+ IsProbeInBrain = _probeInBrain ,
526+ RecRegionBaseCoordWorldU = _recRegionBaseCoordWorldU ,
527+ RecRegionTopCoordWorldU = _recRegionTopCoordWorldU
528+ } ;
529+
530+ // Dispatch to Redux store
531+ PinpointApp . StoreServiceStore . Dispatch ( ProbeWorldActions . UPDATE_PROBE_WORLD_STATE , worldState ) ;
532+ }
533+ #endif
534+
494535 #region Channel map
495536 public (
496537 float startPosmm ,
@@ -1002,6 +1043,11 @@ public void UpdateSurfacePosition()
10021043 BrainAtlasManager . ActiveReferenceAtlas . World2Atlas ( _brainSurfaceWorldU , true )
10031044 ) ;
10041045 }
1046+
1047+ #if APP_UI
1048+ // Dispatch world state update after surface position is calculated
1049+ DispatchProbeWorldState ( ) ;
1050+ #endif
10051051 }
10061052
10071053 // TODO: Remove useDV and always use depth.
0 commit comments