Skip to content

Commit

Permalink
Merge branch '3.0-rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed Jul 20, 2018
2 parents faf2557 + 3a4380a commit a3f58dc
Show file tree
Hide file tree
Showing 82 changed files with 1,180 additions and 599 deletions.
14 changes: 4 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@

#folders
Intermediate
Binaries/Win64/UE4Editor.modules
Binaries/Win64/UE4Editor-LeapMotion.dll
Binaries/Win64/UE4Editor*.modules
Binaries/Win64/UE4-*.dll
Binaries/Win64/UE4-*.lib
Binaries/Win64/UE4Editor*.dll
Binaries/Win64/UE4Editor*.dll
Binaries/Android/UE4-LeapMotion-Android-Shipping-armv7-es2.a
Binaries/Android/UE4-LeapMotion-armv7-es2.a
*.a
Binaries/Win64/UE4-LeapMotionC.lib
Binaries/Win64/UE4-BodyState.lib
Binaries/Win64/UE4-LeapMotion.lib
Binaries/Win64/UE4Editor-Win64-DebugGame.modules
Binaries/Win64/LeapWork-LeapMotion.lib
Binaries/Win64/LeapWork-BodyState.lib
Binary file modified Binaries/Win32/LeapC.dll
Binary file not shown.
Binary file modified Binaries/Win64/LeapC.dll
Binary file not shown.
Binary file modified Content/BodyState/BSLowPolyLeftAnimBP.uasset
Binary file not shown.
Binary file modified Content/BodyState/BSLowPolyRightAnimBP.uasset
Binary file not shown.
53 changes: 34 additions & 19 deletions LeapMotion.uplugin
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
{
"FileVersion" : 3,
"Version" : 1,
"VersionName" : "2.18.2",
"FriendlyName" : "Leap Motion Plugin",
"Description" : "Support for the Leap Motion input device",
"Category" : "Input Devices",
"CreatedBy" : "Getnamo",
"CreatedByURL" : "https://www.leapmotion.com/",
"DocsURL" : "https://github.com/getnamo/leap-ue4-preview",
"EnabledByDefault" : true,
"IsBetaVersion" : false,
"CanContainContent" : true,
"Modules" :
[
"FileVersion": 3,
"Version": 1,
"VersionName": "3.0.0",
"FriendlyName": "Leap Motion Plugin",
"Description": "Support for the Leap Motion input device.",
"Category": "Input Devices",
"CreatedBy": "Getnamo",
"CreatedByURL": "https://www.leapmotion.com/",
"DocsURL": "https://github.com/leapmotion/leapunreal",
"MarketplaceURL": "",
"SupportURL": "",
"EnabledByDefault": true,
"CanContainContent": true,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "LeapMotion",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [ "Win64", "Win32", "Android" ]
"WhitelistPlatforms": [
"Win64",
"Win32"
]
},
{
"Name": "LeapMotionEditor",
"Type": "Editor",
"LoadingPhase": "PreDefault",
"WhitelistPlatforms": [ "Win64", "Win32" ]
"WhitelistPlatforms": [
"Win64",
"Win32"
]
},
{
"Name" : "BodyState",
"Type" : "Runtime",
"Name": "BodyState",
"Type": "Runtime",
"LoadingPhase": "PreDefault",
"WhitelistPlatforms": [ "Win64", "Win32", "Android", "Mac", "IOS", "HTML5" ]
"WhitelistPlatforms": [
"Win64",
"Win32",
"Android",
"Mac",
"IOS",
"HTML5"
]
}
]
}
3 changes: 1 addition & 2 deletions Source/BodyState/BodyState.Build.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Some copyright should be here...
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

Expand All @@ -10,7 +10,6 @@ public BodyState(ReadOnlyTargetRules Target) : base(Target)

PublicIncludePaths.AddRange(
new string[] {
"BodyState/Public"
}
);

Expand Down
24 changes: 20 additions & 4 deletions Source/BodyState/Private/AnimNode_ModifyBodyStateMappedBones.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "AnimNode_ModifyBodyStateMappedBones.h"
#include "AnimationRuntime.h"
#include "Runtime/Engine/Public/Animation/AnimInstanceProxy.h"
#include "BoneControllers/AnimNode_SkeletalControlBase.h"



FAnimNode_ModifyBodyStateMappedBones::FAnimNode_ModifyBodyStateMappedBones()
: FAnimNode_SkeletalControlBase()
{
Expand All @@ -14,12 +14,20 @@ FAnimNode_ModifyBodyStateMappedBones::FAnimNode_ModifyBodyStateMappedBones()

void FAnimNode_ModifyBodyStateMappedBones::EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms)
{
//Tag limit by skeleton
if (!MappedBoneAnimData.SkeletonHasValidTags())
{
return;
}

//If we don't have data driving us, ignore this evaluation
const FBoneContainer& BoneContainer = Output.Pose.GetPose().GetBoneContainer();
const float BlendWeight = FMath::Clamp<float>(ActualAlpha, 0.f, 1.f);

TArray<FBoneTransform> TempTransform;



//SN: there should be an array re-ordered by hierarchy (parents -> children order)
for (auto CachedBone : MappedBoneAnimData.CachedBoneList)
{
Expand All @@ -28,9 +36,16 @@ void FAnimNode_ModifyBodyStateMappedBones::EvaluateSkeletalControl_AnyThread(FCo
UE_LOG(LogTemp, Warning, TEXT("%s has an invalid bone index: %d"), *CachedBone.MeshBone.BoneName.ToString(), CachedBone.MeshBone.BoneIndex);
continue;
}

FCompactPoseBoneIndex CompactPoseBoneToModify = CachedBone.MeshBone.GetCompactPoseIndex(BoneContainer);
FTransform NewBoneTM = Output.Pose.GetComponentSpaceTransform(CompactPoseBoneToModify);
FTransform ComponentTransform = Output.AnimInstanceProxy->GetComponentTransform();
FTransform NewBoneTM;
FTransform ComponentTransform;

{
FScopeLock ScopeLock(&MappedBoneAnimData.BodyStateSkeleton->BoneDataLock);
NewBoneTM = Output.Pose.GetComponentSpaceTransform(CompactPoseBoneToModify);
ComponentTransform = Output.AnimInstanceProxy->GetComponentTransform();
}

//Scale
//Ignored
Expand All @@ -40,6 +55,7 @@ void FAnimNode_ModifyBodyStateMappedBones::EvaluateSkeletalControl_AnyThread(FCo
//Bone Space
FAnimationRuntime::ConvertCSTransformToBoneSpace(ComponentTransform, Output.Pose, NewBoneTM, CompactPoseBoneToModify, EBoneControlSpace::BCS_ComponentSpace);
FQuat BoneQuat = CachedBone.BSBone->BoneData.Transform.GetRotation();


//Apply pre and post adjustment (Post * (Input * Pre) )
if (!MappedBoneAnimData.PreBaseRotation.ContainsNaN())
Expand Down
27 changes: 27 additions & 0 deletions Source/BodyState/Private/BodyStateAnimInstance.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateAnimInstance.h"
#include "BodyStateUtility.h"
#include "BodyStateBPLibrary.h"
Expand Down Expand Up @@ -580,6 +582,31 @@ void FMappedBoneAnimData::SyncCachedList(const USkeleton* LinkedSkeleton)
UE_LOG(LogTemp, Log, TEXT("Bone cache synced: %d"), CachedBoneList.Num());
}

bool FMappedBoneAnimData::BoneHasValidTags(const UBodyStateBone* QueryBone)
{
//Early exit optimization
if (TrackingTagLimit.Num() == 0)
{
return true;
}

FBodyStateBoneMeta UniqueMeta = ((UBodyStateBone*)QueryBone)->UniqueMeta();

for (FString& LimitTag : TrackingTagLimit)
{
if (!UniqueMeta.TrackingTags.Contains(LimitTag))
{
return false;
}
}
return true;
}

bool FMappedBoneAnimData::SkeletonHasValidTags()
{
return BodyStateSkeleton->HasValidTrackingTags(TrackingTagLimit);
}

TArray<int32> FBodyStateIndexedBoneList::FindBoneWithChildCount(int32 Count)
{
TArray<int32> ResultArray;
Expand Down
2 changes: 1 addition & 1 deletion Source/BodyState/Private/BodyStateBPLibrary.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateBPLibrary.h"
#include "FBodyState.h"
Expand Down
2 changes: 2 additions & 0 deletions Source/BodyState/Private/BodyStateBoneComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateBoneComponent.h"
#include "IBodyState.h"

Expand Down
4 changes: 2 additions & 2 deletions Source/BodyState/Private/BodyStateDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateDevice.h"
#include "BodyStateDeviceConfig.h"
#include "BodyStateSkeleton.h"
#include "Skeleton/BodyStateSkeleton.h"
2 changes: 1 addition & 1 deletion Source/BodyState/Private/BodyStateDeviceConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateDeviceConfig.h"

Expand Down
2 changes: 2 additions & 0 deletions Source/BodyState/Private/BodyStateEstimatorComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateEstimatorComponent.h"

UBodyStateEstimatorComponent::UBodyStateEstimatorComponent(const FObjectInitializer &init) : UActorComponent(init)
Expand Down
93 changes: 92 additions & 1 deletion Source/BodyState/Private/BodyStateHMDDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "BodyStateHMDDevice.h"
#include "IHeadMountedDisplay.h"
#include "Runtime/HeadMountedDisplay/Public/XRMotionControllerBase.h"
#include "IXRTrackingSystem.h"

FBodyStateHMDDevice::FBodyStateHMDDevice()
Expand All @@ -9,6 +12,11 @@ FBodyStateHMDDevice::FBodyStateHMDDevice()
//Default config
Config.DeviceName = TEXT("HMD");
Config.InputType = EBodyStateDeviceInputType::EXTERNAL_REFERENCE_INPUT_TYPE;
Config.TrackingTags.Add("Hands");
Config.TrackingTags.Add("Head");
bShouldTrackMotionControllers = true;
MotionControllerInertialConfidence = 0.1f;
MotionControllerTrackedConfidence = 0.8f; //it's not 1.0 to allow leap motion to override it if both are tracked at same time
}

FBodyStateHMDDevice::~FBodyStateHMDDevice()
Expand All @@ -26,13 +34,96 @@ void FBodyStateHMDDevice::UpdateInput(int32 DeviceID, class UBodyStateSkeleton*
UBodyStateBone* Head = Skeleton->Head();
if (!Head->IsTracked())
{
Head->SetTrackingConfidenceRecursively(1.f);
Head->Meta.Confidence = 1.f;
Head->Meta.ParentDistinctMeta = true;
Head->Meta.TrackingType = Config.DeviceName;
Head->Meta.TrackingTags = Config.TrackingTags;
}

FTransform HMDTransform = FTransform(Orientation, Position, FVector(1.f));
Head->BoneData.SetFromTransform(HMDTransform);

if (bShouldTrackMotionControllers)
{
UBodyStateBone* LeftHand = Skeleton->BoneForEnum(EBodyStateBasicBoneType::BONE_HAND_WRIST_L);
UBodyStateBone* RightHand = Skeleton->BoneForEnum(EBodyStateBasicBoneType::BONE_HAND_WRIST_R);

if (!LeftHand->IsTracked())
{
LeftHand->Meta.Confidence = 0.f;
LeftHand->Meta.ParentDistinctMeta = true;
LeftHand->Meta.TrackingType = Config.DeviceName;
LeftHand->Meta.TrackingTags = Config.TrackingTags;
}
if (!RightHand->IsTracked())
{
RightHand->Meta.Confidence = 0.f;
RightHand->Meta.ParentDistinctMeta = true;
RightHand->Meta.TrackingType = Config.DeviceName;
RightHand->Meta.TrackingTags = Config.TrackingTags;
}

//enum motion controllers
TArray<IMotionController*> MotionControllers = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());

FRotator OrientationRot;
FTransform HandTransform;
LeftHand->Meta.Confidence = 0.f;
RightHand->Meta.Confidence = 0.f;

for(IMotionController* Controller : MotionControllers)
{
//Left Hand
UBodyStateBone* Hand = LeftHand;
FName TrackingSource = FXRMotionControllerBase::LeftHandSourceId;

ETrackingStatus TrackingStatus = Controller->GetControllerTrackingStatus(0, TrackingSource);
if (TrackingStatus != ETrackingStatus::NotTracked)
{
if (TrackingStatus == ETrackingStatus::Tracked)
{
Hand->Meta.Confidence = MotionControllerTrackedConfidence;
}
else
{
Hand->Meta.Confidence = MotionControllerInertialConfidence;
}
if (Hand->Meta.ParentDistinctMeta == false)
{
Hand->Meta.ParentDistinctMeta = true;
Hand->Meta.TrackingTags = Config.TrackingTags;
}
Controller->GetControllerOrientationAndPosition(0, TrackingSource, OrientationRot, Position, 100.f);
HandTransform = FTransform(OrientationRot, Position, FVector(1.f));
Hand->BoneData.SetFromTransform(HandTransform);
}

//Right Hand
Hand = RightHand;
TrackingSource = FXRMotionControllerBase::RightHandSourceId;

TrackingStatus = Controller->GetControllerTrackingStatus(0, TrackingSource);
if (TrackingStatus != ETrackingStatus::NotTracked)
{
if (TrackingStatus == ETrackingStatus::Tracked)
{
Hand->Meta.Confidence = MotionControllerTrackedConfidence;
}
else
{
Hand->Meta.Confidence = MotionControllerInertialConfidence;
}
if (Hand->Meta.ParentDistinctMeta == false)
{
Hand->Meta.ParentDistinctMeta = true;
Hand->Meta.TrackingTags = Config.TrackingTags;
}
Controller->GetControllerOrientationAndPosition(0, TrackingSource, OrientationRot, Position, 100.f);
HandTransform = FTransform(OrientationRot, Position, FVector(1.f));
Hand->BoneData.SetFromTransform(HandTransform);
}
}
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion Source/BodyState/Private/BodyStateHMDDevice.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "BodyStatePrivatePCH.h"
#include "BodyStateInputInterface.h"
#include "BodyStateDeviceConfig.h"


Expand All @@ -10,6 +12,10 @@ class FBodyStateHMDDevice : public IBodyStateInputRawInterface
FBodyStateHMDDevice();
virtual ~FBodyStateHMDDevice();
int32 HMDDeviceIndex;
bool bShouldTrackMotionControllers;
float MotionControllerInertialConfidence;
float MotionControllerTrackedConfidence;

FBodyStateDeviceConfig Config;

virtual void UpdateInput(int32 DeviceID, class UBodyStateSkeleton* Skeleton) override;
Expand Down
2 changes: 2 additions & 0 deletions Source/BodyState/Private/BodyStateHMDSnapshot.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "BodyStateHMDSnapshot.h"
Expand Down
3 changes: 0 additions & 3 deletions Source/BodyState/Private/BodyStateInputInterface.cpp

This file was deleted.

Loading

0 comments on commit a3f58dc

Please sign in to comment.