Skip to content

Commit

Permalink
Alpha 3.2 update - hotfix
Browse files Browse the repository at this point in the history
The plug-in is linked with Houdini 18.0.532 / HAPI3.3.11.

New features:

- Attributes values used for splitting instancers into multiple components (via the "unreal_split_attr" attribute)
  are now read as strings instead of ints. This allow splitting instancers using either int, float or string attributes,
  and not just int attributes.
- Added support for forcing the creation of Hierarchical Instanced Static Mesh Components when instancing.
  To do so, simply add the "unreal_hierarchical_instancer" (value 1) to the instancer.  
- Session sync: First pass at adding viewport sync (still a work in progress)
  This allows synchronizing the unreal and Houdini viewport when using Session Sync.

Bug Fixes:

- Added back missing sub asset selection dialog when instantiating multi/versioned HDAs.
- Fixed regression that caused Houdini/HARS to crash upon updating a world input...
- Fixed regression that caused crashes when using Brushes in a world input.
  (potentially, when using anything that used the default material in a world input)
- Fixed crash when converting attribute values due to bad logging/string handling.
- When importing landscape layers to Houdini, their values are now converted 
  from [0 255] (uint8) top [0 1] (floats), instead of being normalized 
  [min max] (uint8) to [0 1] floats. 
  This also fixes Nan when importing flat layers.
- Fixed "output templated geos" displaying all nested templated geos, including those in nested HDAs.
  We now only display templated geos that are children of the main HDA node, the output OBJ node or the output display SOP.
- Curve Input: Fixed "Ghost/Broken" curve components appearing when spamming the add button.
  We now check if the HDA is being cooked when click Add button.
- Fixed bad initialization warning (CachedSurfaceHash) when building the game
  • Loading branch information
dpernuit committed Aug 12, 2020
1 parent 3fb511b commit 907a701
Show file tree
Hide file tree
Showing 17 changed files with 516 additions and 190 deletions.
4 changes: 2 additions & 2 deletions Source/HoudiniEngine/Private/HoudiniEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ FHoudiniEngine::SessionSyncConnect(

// Update the default viewport sync settings
bSyncViewport = HoudiniRuntimeSettings->bSyncViewport;
//bSyncHoudiniViewport = HoudiniRuntimeSettings->bSyncHoudiniViewport;
//bSyncUnrealViewport = HoudiniRuntimeSettings->bSyncUnrealViewport;
bSyncHoudiniViewport = HoudiniRuntimeSettings->bSyncHoudiniViewport;
bSyncUnrealViewport = HoudiniRuntimeSettings->bSyncUnrealViewport;

return true;
}
Expand Down
51 changes: 31 additions & 20 deletions Source/HoudiniEngine/Private/HoudiniEngineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ FHoudiniEngineManager::Tick()
{
// See if the session sync settings have changed on the houdini side, update ours if they did
FHoudiniEngine::Get().UpdateSessionSyncInfoFromHoudini();
/*
#if WITH_EDITOR
// Update the Houdini viewport from unreal if needed
if (FHoudiniEngine::Get().IsSyncViewportEnabled())
Expand All @@ -237,7 +236,6 @@ FHoudiniEngineManager::Tick()
}
}
#endif
*/
}
}

Expand Down Expand Up @@ -1131,7 +1129,7 @@ FHoudiniEngineManager::BuildStaticMeshesForAllHoudiniStaticMeshes(UHoudiniAssetC
/* Unreal's viewport representation rules:
Viewport location is the actual camera location;
Lookat position is always 1024cm right in front of the camera, which means the camera is looking at;
The rotator rotates the base vector to a direction & orientation, and this dir and orientation is the camera's;
The rotator rotates the forward vector to a direction & orientation, and this dir and orientation is the camera's;
The identity direction and orientation of the camera is facing positive X-axis.
*/

Expand Down Expand Up @@ -1172,38 +1170,51 @@ FHoudiniEngineManager::SyncHoudiniViewportToUnreal()
return false;
}

// Orbit pivot is by default zero
FVector OrbitPivot = FVector::ZeroVector;
/* Calculate Hapi Quaternion */
// Initialize Hapi Quat with Unreal Quat.
// Note that rotations are in general non-commutative ***
FQuat HapiQuat = UnrealViewportRotation.Quaternion();

// // We're in orbit mode, override the default pivot position
// We're in orbit mode, forward vector is Y-axis
if (ViewportClient->bUsingOrbitCamera)
ViewportClient->GetPivotForOrbit(OrbitPivot);
{
// The forward vector is Y-negative direction when on orbiting mode
HapiQuat = HapiQuat * FQuat::MakeFromEuler(FVector(0.f, 0.f, 180.f));

// rotations around X and Y axis are reversed
float TempX = HapiQuat.X;
HapiQuat.X = HapiQuat.Y;
HapiQuat.Y = TempX;
HapiQuat.W = -HapiQuat.W;

/* Calculate Hapi Quaternion */
// Rotate the Quat arount Z-axis by 90 degree.
// Note that rotations are in general non-commutative ***
FQuat HapiQuat = UnrealViewportRotation.Quaternion() * FQuat::MakeFromEuler(FVector(0.f, 0.f, 90.f));
}
// We're not in orbiting mode, forward vector is X-axis
else
{
// Rotate the Quat arount Z-axis by 90 degree.
HapiQuat = HapiQuat * FQuat::MakeFromEuler(FVector(0.f, 0.f, 90.f));
}

// Get Hapi offset
float HapiOffset = (UnrealViewportPosition - OrbitPivot).Size() / HAPI_UNREAL_SCALE_FACTOR_TRANSLATION;

/* Update Hapi H_View */
// Note: There are infinte number of H_View representation for current viewport
// Each choice of pivot point determines an equivalent representation.
// If it is not in orbit mode in UE, we set the pivot point to be the origin
// We just find an equivalent when the pivot position is the UnrealViewportLookat position

HAPI_Viewport H_View;
H_View.position[0] = OrbitPivot.X;
H_View.position[1] = OrbitPivot.Z;
H_View.position[2] = OrbitPivot.Y;
H_View.position[0] = UnrealViewportLookatPosition.X / HAPI_UNREAL_SCALE_FACTOR_TRANSLATION;
H_View.position[1] = UnrealViewportLookatPosition.Z / HAPI_UNREAL_SCALE_FACTOR_TRANSLATION;
H_View.position[2] = UnrealViewportLookatPosition.Y / HAPI_UNREAL_SCALE_FACTOR_TRANSLATION;

H_View.offset = HapiOffset;
// Get HAPI_Offset
// In Unreal, Lookat position is always 1024 cm right in front of the view position.
// Since we choose the pivot point to be the view position, the Offset is always 1024 cm
H_View.offset = 1024.f / HAPI_UNREAL_SCALE_FACTOR_TRANSLATION;

H_View.rotationQuaternion[0] = -HapiQuat.X;
H_View.rotationQuaternion[1] = -HapiQuat.Z;
H_View.rotationQuaternion[2] = -HapiQuat.Y;
H_View.rotationQuaternion[3] = HapiQuat.W;
H_View.rotationQuaternion[3] = HapiQuat.W;

FHoudiniApi::SetViewport(FHoudiniEngine::Get().GetSession(), &H_View);

Expand Down Expand Up @@ -1284,7 +1295,7 @@ FHoudiniEngineManager::SyncUnrealViewportToHoudini()
FQuat UnrealQuat = FQuat(H_View.rotationQuaternion[0], H_View.rotationQuaternion[2], H_View.rotationQuaternion[1], -H_View.rotationQuaternion[3]);
UnrealQuat = UnrealQuat * FQuat::MakeFromEuler(FVector(0.f, 0.f, -90.f));

FVector UnrealBaseVector(1.f, 0.f, 0.f); // Base vector in Unreal viewport
FVector UnrealBaseVector(1.f, 0.f, 0.f); // Forward vector in Unreal viewport

/* Get UE viewport location*/
FVector UnrealViewPosition = - UnrealQuat.RotateVector(UnrealBaseVector) * UnrealOffset + UnrealViewportPivotPosition;
Expand Down
1 change: 1 addition & 0 deletions Source/HoudiniEngine/Private/HoudiniEnginePrivatePCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
#define HAPI_UNREAL_ATTRIB_INSTANCE_POSITION HAPI_ATTRIB_POSITION
#define HAPI_UNREAL_ATTRIB_INSTANCE_COLOR "unreal_instance_color"
#define HAPI_UNREAL_ATTRIB_SPLIT_ATTR "unreal_split_attr"
#define HAPI_UNREAL_ATTRIB_HIERARCHICAL_INSTANCED_SM "unreal_hierarchical_instancer"


#define HAPI_UNREAL_ATTRIB_LANDSCAPE_TILE_NAME HAPI_ATTRIB_NAME
Expand Down
35 changes: 23 additions & 12 deletions Source/HoudiniEngine/Private/HoudiniEngineUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
#include "HoudiniParameter.h"
#include "HoudiniEngineRuntimeUtils.h"

#if WITH_EDITOR
#include "SAssetSelectionWidget.h"
#endif

#include "HAPI/HAPI_Version.h"

#include "Misc/Paths.h"
Expand All @@ -73,13 +77,19 @@
//#include "Kismet/BlueprintEditor.h"
#include "Engine/WorldComposition.h"

#if WITH_EDITOR
#include "Interfaces/IMainFrameModule.h"
#endif

#include <vector>

#include "AssetRegistryModule.h"
#include "FileHelpers.h"
#include "Factories/WorldFactory.h"
#include "HAL/FileManager.h"

#define LOCTEXT_NAMESPACE HOUDINI_LOCTEXT_NAMESPACE

// HAPI_Result strings
const FString kResultStringSuccess(TEXT("Success"));
const FString kResultStringFailure(TEXT("Generic Failure"));
Expand Down Expand Up @@ -1128,7 +1138,7 @@ FHoudiniEngineUtils::OpenSubassetSelectionWindow(TArray<HAPI_StringHandle>& Asse

// Default to the first asset
OutPickedAssetName = AssetNames[0];
/*

#if WITH_EDITOR
// Present the user with a dialog for choosing which asset to instantiate.
TSharedPtr<SWindow> ParentWindow;
Expand Down Expand Up @@ -1174,7 +1184,6 @@ FHoudiniEngineUtils::OpenSubassetSelectionWindow(TArray<HAPI_StringHandle>& Asse
return false;
}
#endif
*/

return true;
}
Expand Down Expand Up @@ -2401,7 +2410,7 @@ FHoudiniEngineUtils::HapiGetAttributeDataAsFloat(
OutData[Idx] = (float)IntData[Idx];
}

HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a float attribute, its value had to be converted from integer."), *InAttribName);
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a float attribute, its value had to be converted from integer."), *FString(InAttribName));
return true;
}
}
Expand All @@ -2424,13 +2433,13 @@ FHoudiniEngineUtils::HapiGetAttributeDataAsFloat(

if (!bConversionError)
{
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a float attribute, its value had to be converted from string."), *InAttribName);
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a float attribute, its value had to be converted from string."), *FString(InAttribName));
return true;
}
}
}

HOUDINI_LOG_WARNING(TEXT("Found attribute %s, but it was expected to be a float attribute and is of an invalid type."), *InAttribName);
HOUDINI_LOG_WARNING(TEXT("Found attribute %s, but it was expected to be a float attribute and is of an invalid type."), *FString(InAttribName));
return false;
}

Expand Down Expand Up @@ -2516,7 +2525,7 @@ FHoudiniEngineUtils::HapiGetAttributeDataAsInteger(
OutData[Idx] = (int32)FloatData[Idx];
}

HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be an integer attribute, its value had to be converted from float."), *InAttribName);
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be an integer attribute, its value had to be converted from float."), *FString(InAttribName));

return true;
}
Expand All @@ -2539,13 +2548,13 @@ FHoudiniEngineUtils::HapiGetAttributeDataAsInteger(

if (!bConversionError)
{
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be an integer attribute, its value had to be converted from string."), *InAttribName);
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be an integer attribute, its value had to be converted from string."), *FString(InAttribName));
return true;
}
}
}

HOUDINI_LOG_WARNING(TEXT("Found attribute %s, but it was expected to be an integer attribute and is of an invalid type."), *InAttribName);
HOUDINI_LOG_WARNING(TEXT("Found attribute %s, but it was expected to be an integer attribute and is of an invalid type."), *FString(InAttribName));
return false;
}

Expand Down Expand Up @@ -2623,7 +2632,7 @@ FHoudiniEngineUtils::HapiGetAttributeDataAsString(
OutData[Idx] = FString::SanitizeFloat(FloatData[Idx]);
}

HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a string attribute, its value had to be converted from float."), *InAttribName);
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a string attribute, its value had to be converted from float."), *FString(InAttribName));
return true;
}
}
Expand All @@ -2647,12 +2656,12 @@ FHoudiniEngineUtils::HapiGetAttributeDataAsString(
OutData[Idx] = FString::FromInt(IntData[Idx]);
}

HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a string attribute, its value had to be converted from integer."), *InAttribName);
HOUDINI_LOG_MESSAGE(TEXT("Attribute %s was expected to be a string attribute, its value had to be converted from integer."), *FString(InAttribName));
return true;
}
}

HOUDINI_LOG_WARNING(TEXT("Found attribute %s, but it was expected to be a string attribute and is of an invalid type."), *InAttribName);
HOUDINI_LOG_WARNING(TEXT("Found attribute %s, but it was expected to be a string attribute and is of an invalid type."), *FString(InAttribName));
return false;
}

Expand Down Expand Up @@ -4374,4 +4383,6 @@ FHoudiniEngineUtils::HapiCookNode(const HAPI_NodeId& InNodeId, HAPI_CookOptions*
// We want to yield a bit.
FPlatformProcess::Sleep(0.1f);
}
}
}

#undef LOCTEXT_NAMESPACE
11 changes: 2 additions & 9 deletions Source/HoudiniEngine/Private/HoudiniInputTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,16 +884,9 @@ FHoudiniInputTranslator::UploadInputData(UHoudiniInput* InInput)
}
else
{
// Upload the current input object to Houdin
if (UploadHoudiniInputObject(InInput, CurrentInputObject, CreatedNodeIds))
{
if (CreatedNodeIds.Num() > 0)
CurrentInputObject->InputNodeId = CreatedNodeIds.Last();
}
else
{
// Upload the current input object to Houdini
if (!UploadHoudiniInputObject(InInput, CurrentInputObject, CreatedNodeIds))
bSuccess = false;
}
}
}

Expand Down
Loading

0 comments on commit 907a701

Please sign in to comment.