You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Add UE::ToolTarget::CommitMaterialSetUpdate() and ::CommitDynamicMeshUpdate(). ::GetDynamicMeshCopy() can now return tangents if requested. - Add IMeshDescriptionProvider::CalculateAutoGeneratedAttributes(). Default implementation does nothing, UStaticMeshComponentToolTarget implementation initializes auto-generated MeshDescription attributes. Used in ::GetDynamicMeshCopy() to get tangents (but requires a MeshDescription copy). - Clean up handling of Tangents in Simple/OctreeDynamicMeshComponent. Add local MakeTangentsFunc() to generate the Tangents lambda, handle different cases and no-tangents fallbacks consistently. - UDynamicMesh: add optional info arguments to EditMesh() and ChangeInfo struct. Add support for deferring change events from Edit funcs. - Remove UBaseDynamicMeshComponent::InitializeMesh(), ::Bake() APIs, and add ::SetMesh(). Implement in Simple/Octree implementations, update all Tools that used those APIs. - Add USimpleDynamicMeshComponent::ProcessMesh(), EditMesh(). These are now the preferred ways to read/write mesh. - Update USimpleDynamicMeshComponent tangents handling. Externally-computed tangents are now taken directly from the FDynamicMesh3 attribute set. Autogenerated tangents are still computed and stored in an internal FMeshTangentsf, but this is no longer exposed for external updates. - Remove UPreviewMesh pass-through functions for Tangents access, InitializeMesh() and Bake(). Add ProcessMesh() - Update all affected Tools. In most cases these Tools have also been converted to use ModelingToolTargetUtil functions, instead of direct ToolTarget interface casting. #rb none #rnx #jira none #preflight 60c3e71d3e1b3c00015668af [CL 16650666 by Ryan Schmidt in ue5-main branch]
89 lines
2.2 KiB
C++
89 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "DynamicMeshBrushTool.h"
|
|
#include "InteractiveToolManager.h"
|
|
#include "ToolBuilderUtil.h"
|
|
#include "ModelingToolTargetUtil.h"
|
|
|
|
#include "ExplicitUseGeometryMathTypes.h" // using UE::Geometry::(math types)
|
|
using namespace UE::Geometry;
|
|
|
|
// localization namespace
|
|
#define LOCTEXT_NAMESPACE "UDynamicMeshBrushTool"
|
|
|
|
/*
|
|
* Tool
|
|
*/
|
|
|
|
UDynamicMeshBrushTool::UDynamicMeshBrushTool()
|
|
{
|
|
}
|
|
|
|
|
|
void UDynamicMeshBrushTool::Setup()
|
|
{
|
|
PreviewMesh = NewObject<UPreviewMesh>(this);
|
|
PreviewMesh->bBuildSpatialDataStructure = true;
|
|
PreviewMesh->CreateInWorld(UE::ToolTarget::GetTargetActor(Target)->GetWorld(), FTransform::Identity);
|
|
FTransform3d LocalToWorldTransform = UE::ToolTarget::GetLocalToWorldTransform(Target);
|
|
PreviewMesh->SetTransform((FTransform)LocalToWorldTransform);
|
|
|
|
FComponentMaterialSet MaterialSet = UE::ToolTarget::GetMaterialSet(Target);
|
|
PreviewMesh->SetMaterials(MaterialSet.Materials);
|
|
|
|
PreviewMesh->ReplaceMesh(UE::ToolTarget::GetDynamicMeshCopy(Target));
|
|
|
|
OnBaseMeshComponentChangedHandle = PreviewMesh->GetOnMeshChanged().Add(
|
|
FSimpleMulticastDelegate::FDelegate::CreateUObject(this, &UDynamicMeshBrushTool::OnBaseMeshComponentChanged));
|
|
|
|
// call this here so that base tool can estimate target dimension
|
|
InputMeshBoundsLocal = PreviewMesh->GetPreviewDynamicMesh()->GetBounds();
|
|
double ScaledDim = LocalToWorldTransform.TransformVector(FVector::OneVector).Size();
|
|
this->WorldToLocalScale = FMathd::Sqrt3 / FMathd::Max(FMathf::ZeroTolerance, ScaledDim);
|
|
UBaseBrushTool::Setup();
|
|
|
|
UE::ToolTarget::HideSourceObject(Target);
|
|
}
|
|
|
|
|
|
|
|
double UDynamicMeshBrushTool::EstimateMaximumTargetDimension()
|
|
{
|
|
return InputMeshBoundsLocal.MaxDim();
|
|
}
|
|
|
|
|
|
void UDynamicMeshBrushTool::Shutdown(EToolShutdownType ShutdownType)
|
|
{
|
|
UBaseBrushTool::Shutdown(ShutdownType);
|
|
|
|
UE::ToolTarget::ShowSourceObject(Target);
|
|
|
|
if (PreviewMesh != nullptr)
|
|
{
|
|
PreviewMesh->GetOnMeshChanged().Remove(OnBaseMeshComponentChangedHandle);
|
|
|
|
OnShutdown(ShutdownType);
|
|
|
|
PreviewMesh->SetVisible(false);
|
|
PreviewMesh->Disconnect();
|
|
PreviewMesh = nullptr;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UDynamicMeshBrushTool::HitTest(const FRay& Ray, FHitResult& OutHit)
|
|
{
|
|
return PreviewMesh->FindRayIntersection(FRay3d(Ray), OutHit);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|