diff --git a/Source/DasherVR/Private/SDasherWidget.cpp b/Source/DasherVR/Private/SDasherWidget.cpp index 4cb2b611cefa424fb8ede6bbe97bcd66afa5f513..4da819d5901ec6461c61acd52c49a90be4159705 100644 --- a/Source/DasherVR/Private/SDasherWidget.cpp +++ b/Source/DasherVR/Private/SDasherWidget.cpp @@ -51,13 +51,11 @@ FReply SDasherWidget::HandleMouseMoveEvent(const FGeometry& Geometry, const FPoi { FDisplayClusterClusterEventBinary ClusterEvent; ClusterEvent.EventId = DasherEventID; - ClusterEvent.EventData.Reserve(sizeof(CursorPosition.X) + sizeof(CursorPosition.Y) + 1); + ClusterEvent.EventData.SetNumUninitialized(sizeof(CursorPosition.X) + sizeof(CursorPosition.Y) + 1); ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseMove); FMemory::Memcpy(&ClusterEvent.EventData[1], &CursorPosition.X, sizeof(CursorPosition.X)); FMemory::Memcpy(&ClusterEvent.EventData[1] + sizeof(CursorPosition.X), &CursorPosition.Y, sizeof(CursorPosition.Y)); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); - - return FReply::Handled().ReleaseMouseLock(); } } return FReply::Handled(); @@ -71,11 +69,11 @@ FReply SDasherWidget::HandleMouseDownEvent(const FGeometry& Geometry, const FPoi { FDisplayClusterClusterEventBinary ClusterEvent; ClusterEvent.EventId = DasherEventID; - ClusterEvent.EventData.Reserve(1); + ClusterEvent.EventData.SetNumUninitialized(1); ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseDown); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); - return FReply::Handled().ReleaseMouseLock(); + return FReply::Handled().LockMouseToWidget(AsShared()); } if (CurrentlyUsingVectorInput) @@ -95,7 +93,7 @@ FReply SDasherWidget::HandleMouseUpEvent(const FGeometry& Geometry, const FPoint { FDisplayClusterClusterEventBinary ClusterEvent; ClusterEvent.EventId = DasherEventID; - ClusterEvent.EventData.Reserve(1); + ClusterEvent.EventData.SetNumUninitialized(1); ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseUp); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); return FReply::Handled().ReleaseMouseLock(); @@ -121,10 +119,10 @@ FReply SDasherWidget::HandleMouseDoubleClickEvent(const FGeometry& Geometry, con { FDisplayClusterClusterEventBinary ClusterEvent; ClusterEvent.EventId = DasherEventID; - ClusterEvent.EventData.Reserve(1); + ClusterEvent.EventData.SetNumUninitialized(1); ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseDown); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); - return FReply::Handled().ReleaseMouseLock(); + return FReply::Handled(); } if (CurrentlyUsingVectorInput) @@ -260,10 +258,9 @@ void SDasherWidget::SetParameter(FString& ParameterName, FString Value) { } //paints our stuff, then lets compoundwidget (super::) draw its stuff -//This draws from bottom to top rectangles->lines->labels, this is enough for our use, but for more complex scenarios a proper layering system might have to be implemented int32 SDasherWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const { - //this doesn't draw anything red, we just need a brush. Could probably find a better "empty" brush + ////this doesn't draw anything red, we just need a brush. Could probably find a better "empty" brush auto MyBrush = FSlateColorBrush(FColor::Red); FFilledRect* RectObject; @@ -299,12 +296,12 @@ int32 SDasherWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe } //The tick function, we tick dasher in it and update the screen size for dasher -void SDasherWidget::Tick(const FGeometry& AllotedGeometry, const double InCurrentTime, const float InDeltaTime) { +void SDasherWidget::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) { + SCompoundWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime); + //don't tick in the editor if (IsEditor || InputPaused) return; - SCompoundWidget::Tick(AllotedGeometry, InCurrentTime, InDeltaTime); - if(!URWTHVRUtilities::IsRoomMountedMode()){ DasherMainInterface->Tick(static_cast<unsigned long>(InCurrentTime * 1000.0)); //we need to provide ticks in milliseconds } @@ -313,7 +310,7 @@ void SDasherWidget::Tick(const FGeometry& AllotedGeometry, const double InCurren { FDisplayClusterClusterEventBinary ClusterEvent; ClusterEvent.EventId = DasherEventID; - ClusterEvent.EventData.Reserve(sizeof(InCurrentTime) + 1); + ClusterEvent.EventData.SetNumUninitialized(sizeof(InCurrentTime) + 1); ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Tick); FMemory::Memcpy(&ClusterEvent.EventData[1], &InCurrentTime, sizeof(InCurrentTime)); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); diff --git a/Source/DasherVR/Public/SDasherWidget.h b/Source/DasherVR/Public/SDasherWidget.h index a806432abbf1ef78e4ce528c311b0f3c065b309a..f1d52165acc1bd1db405079e0ddb6929212f2b7b 100644 --- a/Source/DasherVR/Public/SDasherWidget.h +++ b/Source/DasherVR/Public/SDasherWidget.h @@ -117,7 +117,7 @@ public: void StartTraining(FString PathToTextFile); //Tick function inherited from SCompoundWidget - virtual void Tick(const FGeometry& AllotedGeometry, const double InCurrentTime, const float InDeltaTime) override; + virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override; //Function to set if the widget is in editor or not void SetEditor(bool EditorState);