From cb3d2d8abb98897f50755a10a49bfea80ed4ccbb Mon Sep 17 00:00:00 2001 From: monsieurgustav Date: Thu, 16 Oct 2014 20:01:13 +0200 Subject: [PATCH] 4.5 port set OSC_ENGINE_VERSION value to compile for an earlier version --- .../OSC/Private/Common/OscDataElemStruct.h | 12 ++++++++++- OSC/Source/OSC/Private/Osc.h | 4 ++++ .../OSC/Private/Receive/OscDispatcher.cpp | 4 ++++ README.md | 20 +++++++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/OSC/Source/OSC/Private/Common/OscDataElemStruct.h b/OSC/Source/OSC/Private/Common/OscDataElemStruct.h index 52a541b..e5af3b5 100644 --- a/OSC/Source/OSC/Private/Common/OscDataElemStruct.h +++ b/OSC/Source/OSC/Private/Common/OscDataElemStruct.h @@ -90,15 +90,25 @@ struct FOscDataElemStruct void SetString(FName value) { +#if OSC_ENGINE_VERSION < 40500 static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the string value."); + Data = *reinterpret_cast(&value); +#else + static_assert(sizeof(FMinimalName) <= sizeof(Data), "Too short to hold the string value."); + const auto mininal = NameToMinimalName(value); + Data = *reinterpret_cast(&mininal); +#endif Type = STRING; - Data = *reinterpret_cast(&value); assert(value == AsStringValue()); } FName AsStringValue() const { +#if OSC_ENGINE_VERSION < 40500 return *reinterpret_cast(&Data); +#else + return MinimalNameToName(*reinterpret_cast(&Data)); +#endif } bool IsString() const diff --git a/OSC/Source/OSC/Private/Osc.h b/OSC/Source/OSC/Private/Osc.h index 190f651..d82522f 100644 --- a/OSC/Source/OSC/Private/Osc.h +++ b/OSC/Source/OSC/Private/Osc.h @@ -1,6 +1,10 @@ #pragma once +// Target engine version. Used to enable compatibility code. +#define OSC_ENGINE_VERSION 40500 + + /* Public Dependencies *****************************************************************************/ diff --git a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp index 743eead..89992c3 100644 --- a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp +++ b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp @@ -150,7 +150,11 @@ void UOscDispatcher::Callback(const FArrayReaderPtr& data, const FIPv4Endpoint&) { FSimpleDelegateGraphTask::CreateAndDispatchWhenReady( FSimpleDelegateGraphTask::FDelegate::CreateUObject(this, &UOscDispatcher::CallbackMainThread), +#if OSC_ENGINE_VERSION < 40500 TEXT("OscDispatcherProcessMessages"), +#else + TStatId(), +#endif nullptr, ENamedThreads::GameThread); } diff --git a/README.md b/README.md index af01c8e..7ea8d24 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Integration =========== Put the "OSC" folder in a "Plugins" folder in the project root. + e.g. "/MyProject/Plugins/OSC" @@ -15,12 +16,27 @@ Usage ===== - Receiver: + Set the listening port in the plugin settings. -Add a OscReceiverComponent to your Blueprint class. -Bind the OnOscReceived custom event. + +Add a OscReceiverComponent to your Blueprint class and bind the OnOscReceived custom event, or + +Subclass the OscReceiverActor and bind the OnOscReceived custom event. + Use the PopFloat/Int/Bool/String functions to retrieve the OSC message parameters. + - Sender: + Set the "send to" addresses in the plugin settings. + Use the PushFloat/Int/Bool/String functions to build the OSC message parameters. + Use the SendOsc function to send the OSC message + + +Engine version +===== +Tested on UE 4.4, UE 4.5 (Windows, MacOSX) + +Set the OSC_ENGINE_VERSION value (in Source/OSC/Private/Osc.h) to compile for a specific engine version.