2021-04-28 16:17:03 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Scene/MeshSceneAdapter.h"
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
#include "DynamicMesh3.h"
|
2021-04-28 16:17:03 -04:00
|
|
|
#include "Spatial/MeshAABBTree3.h"
|
|
|
|
|
#include "Spatial/FastWinding.h"
|
|
|
|
|
#include "MeshDescriptionAdapter.h"
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
#include "MeshDescriptionToDynamicMesh.h"
|
|
|
|
|
#include "MeshTransforms.h"
|
|
|
|
|
#include "BoxTypes.h"
|
|
|
|
|
#include "FrameTypes.h"
|
|
|
|
|
#include "Selections/MeshConnectedComponents.h"
|
|
|
|
|
#include "Operations/OffsetMeshRegion.h"
|
|
|
|
|
#include "DynamicMeshEditor.h"
|
2021-06-07 15:02:12 -04:00
|
|
|
#include "CompGeom/ConvexHull2.h"
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
#include "Generators/PlanarPolygonMeshGenerator.h"
|
2021-05-20 19:35:43 -04:00
|
|
|
#include "Spatial/SparseDynamicOctree3.h"
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
#include "GameFramework/Actor.h"
|
|
|
|
|
#include "Components/StaticMeshComponent.h"
|
|
|
|
|
#include "Components/InstancedStaticMeshComponent.h"
|
|
|
|
|
#include "Engine/StaticMesh.h"
|
|
|
|
|
|
|
|
|
|
#include "Async/ParallelFor.h"
|
2021-05-20 19:35:43 -04:00
|
|
|
#include "Async/Async.h"
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
using namespace UE::Geometry;
|
|
|
|
|
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
/**
|
|
|
|
|
* Compute the bounds of the vertices of Mesh, under 3D transformation TransformFunc
|
|
|
|
|
* @return computed bounding box
|
|
|
|
|
*/
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
template<typename MeshType>
|
|
|
|
|
FAxisAlignedBox3d GetTransformedVertexBounds(const MeshType& Mesh, TFunctionRef<FVector3d(const FVector3d&)> TransformFunc)
|
|
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3d Bounds = FAxisAlignedBox3d::Empty();
|
|
|
|
|
int32 NumVertices = Mesh.VertexCount();
|
|
|
|
|
for (int32 k = 0; k < NumVertices; ++k)
|
|
|
|
|
{
|
|
|
|
|
if (Mesh.IsVertex(k))
|
|
|
|
|
{
|
|
|
|
|
Bounds.Contain(TransformFunc(Mesh.GetVertex(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Bounds;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
/**
|
|
|
|
|
* Collect a subset of vertices of the mesh as "seed points" for algorithms like marching-cubes/etc.
|
|
|
|
|
* Generally every vertex does not need to be used. This function will return at most 5000 point
|
|
|
|
|
* @param TransformFunc transformation applied to points, eg local-to-world mapping
|
|
|
|
|
* @param AccumPointsInOut points are added here
|
|
|
|
|
* @param MaxPoints at most this many vertices will be returned
|
|
|
|
|
*/
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
template<typename MeshType>
|
2021-05-20 19:35:43 -04:00
|
|
|
void CollectSeedPointsFromMeshVertices(
|
|
|
|
|
const MeshType& Mesh,
|
|
|
|
|
TFunctionRef<FVector3d(const FVector3d&)> TransformFunc, TArray<FVector3d>& AccumPointsInOut,
|
|
|
|
|
int32 MaxPoints = 500)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
|
|
|
|
int32 NumVertices = Mesh.VertexCount();
|
|
|
|
|
int32 LogNumVertices = FMath::Max(1, (int32)FMathd::Ceil(FMathd::Log(NumVertices)));
|
|
|
|
|
int32 SeedPointCount = (int)(10 * LogNumVertices);
|
2021-05-20 19:35:43 -04:00
|
|
|
SeedPointCount = FMath::Min(SeedPointCount, MaxPoints);
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
int32 Skip = FMath::Max(NumVertices / SeedPointCount, 2);
|
|
|
|
|
for (int32 k = 0; k < NumVertices; k += Skip)
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
AccumPointsInOut.Add(TransformFunc(Mesh.GetVertex(k)));
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Try to check if the subset of Triangles of Mesh represent a "thin" region, ie basically a planar patch (open or closed).
|
|
|
|
|
* The Normal of the largest-area triangle is taken as the plane normal, and then the "thickness" is measured relative to this plain
|
|
|
|
|
* @param ThinTolerance identify as Thin if the thickness extents is within this size
|
|
|
|
|
* @param ThinPlaneOut thin plane normal will be returned via this frame
|
|
|
|
|
* @return true if submesh identified as thin
|
|
|
|
|
*/
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
template<typename MeshType>
|
2021-05-20 19:35:43 -04:00
|
|
|
bool IsThinPlanarSubMesh(const MeshType& Mesh, const TArray<int32>& Triangles, double ThinTolerance, FFrame3d& ThinPlaneOut)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
int32 TriCount = Triangles.Num();
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
double MaxArea = 0;
|
|
|
|
|
FVector3d MaxAreaNormal;
|
|
|
|
|
FVector3d MaxAreaPoint;
|
2021-05-20 19:35:43 -04:00
|
|
|
for (int32 i = 0; i < TriCount; ++i)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
int32 tid = Triangles[i];
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
if (Mesh.IsTriangle(tid))
|
|
|
|
|
{
|
|
|
|
|
FVector3d A, B, C;
|
|
|
|
|
Mesh.GetTriVertices(tid, A, B, C);
|
|
|
|
|
double TriArea;
|
|
|
|
|
FVector3d TriNormal = VectorUtil::NormalArea(A, B, C, TriArea);
|
|
|
|
|
if (TriArea > MaxArea)
|
|
|
|
|
{
|
|
|
|
|
MaxArea = TriArea;
|
|
|
|
|
MaxAreaNormal = TriNormal;
|
|
|
|
|
MaxAreaPoint = A;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
ThinPlaneOut = FFrame3d(MaxAreaPoint, MaxAreaNormal);
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
FAxisAlignedBox3d PlaneExtents = FAxisAlignedBox3d::Empty();
|
|
|
|
|
int32 VertexCount = Mesh.VertexCount();
|
2021-05-20 19:35:43 -04:00
|
|
|
for (int32 i = 0; i < TriCount; ++i)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
int32 tid = Triangles[i];
|
|
|
|
|
if (Mesh.IsTriangle(tid))
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
FVector3d TriVerts[3];
|
|
|
|
|
Mesh.GetTriVertices(tid, TriVerts[0], TriVerts[1], TriVerts[2]);
|
|
|
|
|
for (int32 j = 0; j < 3; ++j)
|
|
|
|
|
{
|
|
|
|
|
TriVerts[j] = ThinPlaneOut.ToFramePoint(TriVerts[j]);
|
|
|
|
|
PlaneExtents.Contain(TriVerts[j]);
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (PlaneExtents.Depth() > ThinTolerance)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
FVector3d Center = PlaneExtents.Center();
|
2021-05-20 19:35:43 -04:00
|
|
|
ThinPlaneOut.Origin += Center.X*ThinPlaneOut.X() + Center.Y*ThinPlaneOut.Y() + Center.Z*ThinPlaneOut.Z();
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return false if any of Triangles in Mesh have open boundary edges
|
|
|
|
|
*/
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
static bool IsClosedRegion(const FDynamicMesh3& Mesh, const TArray<int32>& Triangles)
|
|
|
|
|
{
|
|
|
|
|
for (int32 tid : Triangles)
|
|
|
|
|
{
|
|
|
|
|
FIndex3i TriEdges = Mesh.GetTriEdges(tid);
|
|
|
|
|
if (Mesh.IsBoundaryEdge(TriEdges.A) ||
|
|
|
|
|
Mesh.IsBoundaryEdge(TriEdges.B) ||
|
|
|
|
|
Mesh.IsBoundaryEdge(TriEdges.C))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FDynamicMeshSpatialWrapper : public IMeshSpatialWrapper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FDynamicMesh3 Mesh;
|
2021-05-20 19:35:43 -04:00
|
|
|
|
|
|
|
|
// if true, Mesh is in world space (whatever that means)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
bool bHasBakedTransform = false;
|
2021-05-20 19:35:43 -04:00
|
|
|
// if true, use unsigned distance to determine inside/outside instead of winding number
|
|
|
|
|
bool bUseDistanceShellForWinding = false;
|
|
|
|
|
// unsigned distance isovalue that defines inside
|
|
|
|
|
double WindingShellThickness = 0.0;
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
TUniquePtr<TMeshAABBTree3<FDynamicMesh3>> AABBTree;
|
|
|
|
|
TUniquePtr<TFastWindingTree<FDynamicMesh3>> FWNTree;
|
|
|
|
|
|
|
|
|
|
virtual bool Build(const FMeshSceneAdapterBuildOptions& BuildOptions) override
|
|
|
|
|
{
|
|
|
|
|
ensure(Mesh.TriangleCount() > 0);
|
2021-05-20 19:35:43 -04:00
|
|
|
if (BuildOptions.bBuildSpatialDataStructures)
|
|
|
|
|
{
|
|
|
|
|
AABBTree = MakeUnique<TMeshAABBTree3<FDynamicMesh3>>(&Mesh, true);
|
|
|
|
|
if (bUseDistanceShellForWinding == false)
|
|
|
|
|
{
|
|
|
|
|
FWNTree = MakeUnique<TFastWindingTree<FDynamicMesh3>>(AABBTree.Get(), true);
|
|
|
|
|
}
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual int32 GetTriangleCount() override
|
|
|
|
|
{
|
|
|
|
|
return Mesh.TriangleCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual FAxisAlignedBox3d GetWorldBounds(TFunctionRef<FVector3d(const FVector3d&)> LocalToWorldFunc) override
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
FAxisAlignedBox3d Bounds = bHasBakedTransform ?
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
GetTransformedVertexBounds<FDynamicMesh3>(Mesh, [&](const FVector3d& P) {return P;}) :
|
|
|
|
|
GetTransformedVertexBounds<FDynamicMesh3>(Mesh, LocalToWorldFunc);
|
2021-05-20 19:35:43 -04:00
|
|
|
if (bUseDistanceShellForWinding)
|
|
|
|
|
{
|
|
|
|
|
Bounds.Expand(WindingShellThickness);
|
|
|
|
|
}
|
|
|
|
|
return Bounds;
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void CollectSeedPoints(TArray<FVector3d>& WorldPoints, TFunctionRef<FVector3d(const FVector3d&)> LocalToWorldFunc) override
|
|
|
|
|
{
|
|
|
|
|
return bHasBakedTransform ?
|
|
|
|
|
CollectSeedPointsFromMeshVertices<FDynamicMesh3>(Mesh, [&](const FVector3d& P) {return P;}, WorldPoints) :
|
|
|
|
|
CollectSeedPointsFromMeshVertices<FDynamicMesh3>(Mesh, LocalToWorldFunc, WorldPoints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual double FastWindingNumber(const FVector3d& P, const FTransformSequence3d& LocalToWorldTransform) override
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
if (bUseDistanceShellForWinding)
|
|
|
|
|
{
|
|
|
|
|
if (bHasBakedTransform)
|
|
|
|
|
{
|
|
|
|
|
double NearestDistSqr;
|
|
|
|
|
int32 NearTriID = AABBTree->FindNearestTriangle(P, NearestDistSqr, IMeshSpatial::FQueryOptions(WindingShellThickness));
|
|
|
|
|
if (NearTriID != IndexConstants::InvalidID)
|
|
|
|
|
{
|
|
|
|
|
// Do we even need to do this? won't we return InvalidID if we don't find point within distance?
|
|
|
|
|
// (also technically we can early-out as soon as we find any point, not the nearest point - might be worth a custom query)
|
|
|
|
|
FDistPoint3Triangle3d Query = TMeshQueries<FDynamicMesh3>::TriangleDistance(Mesh, NearTriID, P);
|
|
|
|
|
if (Query.GetSquared() < WindingShellThickness * WindingShellThickness)
|
|
|
|
|
{
|
|
|
|
|
return 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// todo
|
|
|
|
|
check(false);
|
|
|
|
|
}
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return bHasBakedTransform ?
|
|
|
|
|
FWNTree->FastWindingNumber(P) :
|
|
|
|
|
FWNTree->FastWindingNumber(LocalToWorldTransform.InverseTransformPosition(P));
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void ProcessVerticesInWorld(TFunctionRef<void(const FVector3d&)> ProcessFunc, const FTransformSequence3d& LocalToWorldTransform) override
|
|
|
|
|
{
|
|
|
|
|
if (bHasBakedTransform)
|
|
|
|
|
{
|
|
|
|
|
for (FVector3d P : Mesh.VerticesItr())
|
|
|
|
|
{
|
|
|
|
|
ProcessFunc(P);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (FVector3d P : Mesh.VerticesItr())
|
|
|
|
|
{
|
|
|
|
|
ProcessFunc(LocalToWorldTransform.TransformPosition(P));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void AppendMesh(FDynamicMesh3& AppendTo, const FTransformSequence3d& TransformSeq) override
|
|
|
|
|
{
|
|
|
|
|
FDynamicMeshEditor Editor(&AppendTo);
|
|
|
|
|
FMeshIndexMappings Mappings;
|
|
|
|
|
if (bHasBakedTransform)
|
|
|
|
|
{
|
|
|
|
|
Editor.AppendMesh(&Mesh, Mappings,
|
|
|
|
|
[&](int, const FVector3d& Pos) { return Pos; },
|
|
|
|
|
[&](int, const FVector3d& Normal) { return Normal; });
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Editor.AppendMesh(&Mesh, Mappings,
|
|
|
|
|
[&](int, const FVector3d& Pos) { return TransformSeq.TransformPosition(Pos); },
|
|
|
|
|
[&](int, const FVector3d& Normal) { return TransformSeq.TransformNormal(Normal); });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
class FStaticMeshSpatialWrapper : public IMeshSpatialWrapper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
UStaticMesh* StaticMesh = nullptr;
|
|
|
|
|
int32 LODIndex = 0;
|
|
|
|
|
|
|
|
|
|
FMeshDescription* SourceMesh = nullptr;
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
TUniquePtr<FMeshDescriptionTriangleMeshAdapter> Adapter;
|
|
|
|
|
TUniquePtr<TMeshAABBTree3<FMeshDescriptionTriangleMeshAdapter>> AABBTree;
|
|
|
|
|
TUniquePtr<TFastWindingTree<FMeshDescriptionTriangleMeshAdapter>> FWNTree;
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
virtual bool Build(const FMeshSceneAdapterBuildOptions& BuildOptions) override
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
|
|
|
|
check(StaticMesh);
|
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
SourceMesh = StaticMesh->GetMeshDescription(LODIndex);
|
|
|
|
|
#else
|
|
|
|
|
checkf(false, TEXT("Not currently supported - to build at Runtime it is necessary to read from the StaticMesh RenderBuffers"));
|
|
|
|
|
SourceMesh = nullptr;
|
|
|
|
|
#endif
|
|
|
|
|
if (SourceMesh)
|
|
|
|
|
{
|
|
|
|
|
Adapter = MakeUnique<FMeshDescriptionTriangleMeshAdapter>(SourceMesh);
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
FVector3d BuildScale;
|
2021-04-28 16:17:03 -04:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
// respect BuildScale build setting
|
|
|
|
|
const FMeshBuildSettings& LODBuildSettings = StaticMesh->GetSourceModel(LODIndex).BuildSettings;
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
BuildScale = (FVector3d)LODBuildSettings.BuildScale3D;
|
|
|
|
|
Adapter->SetBuildScale(BuildScale, false);
|
2021-04-28 16:17:03 -04:00
|
|
|
#endif
|
2021-05-20 19:35:43 -04:00
|
|
|
if (BuildOptions.bBuildSpatialDataStructures)
|
|
|
|
|
{
|
|
|
|
|
AABBTree = MakeUnique<TMeshAABBTree3<FMeshDescriptionTriangleMeshAdapter>>(Adapter.Get(), true);
|
|
|
|
|
FWNTree = MakeUnique<TFastWindingTree<FMeshDescriptionTriangleMeshAdapter>>(AABBTree.Get(), true);
|
|
|
|
|
}
|
2021-04-28 16:17:03 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SourceMesh = nullptr;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
virtual int32 GetTriangleCount() override
|
|
|
|
|
{
|
|
|
|
|
if (!SourceMesh) return 0;
|
|
|
|
|
return Adapter->TriangleCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual FAxisAlignedBox3d GetWorldBounds(TFunctionRef<FVector3d(const FVector3d&)> LocalToWorldFunc) override
|
|
|
|
|
{
|
|
|
|
|
if (!SourceMesh) return FAxisAlignedBox3d::Empty();
|
|
|
|
|
return GetTransformedVertexBounds<FMeshDescriptionTriangleMeshAdapter>(*Adapter, LocalToWorldFunc);
|
|
|
|
|
}
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
virtual void CollectSeedPoints(TArray<FVector3d>& WorldPoints, TFunctionRef<FVector3d(const FVector3d&)> LocalToWorldFunc) override
|
|
|
|
|
{
|
|
|
|
|
if (!SourceMesh) return;
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
CollectSeedPointsFromMeshVertices<FMeshDescriptionTriangleMeshAdapter>(*Adapter, LocalToWorldFunc, WorldPoints);
|
|
|
|
|
}
|
2021-04-28 16:17:03 -04:00
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
virtual double FastWindingNumber(const FVector3d& P, const FTransformSequence3d& LocalToWorldTransform) override
|
|
|
|
|
{
|
|
|
|
|
return (SourceMesh) ? FWNTree->FastWindingNumber(LocalToWorldTransform.InverseTransformPosition(P)) : 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void ProcessVerticesInWorld(TFunctionRef<void(const FVector3d&)> ProcessFunc, const FTransformSequence3d& LocalToWorldTransform) override
|
|
|
|
|
{
|
|
|
|
|
int32 NumVertices = (SourceMesh) ? Adapter->VertexCount() : 0;
|
|
|
|
|
for (int32 vi = 0; vi < NumVertices; ++vi)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
if (Adapter->IsVertex(vi))
|
|
|
|
|
{
|
|
|
|
|
ProcessFunc(LocalToWorldTransform.TransformPosition(Adapter->GetVertex(vi)));
|
|
|
|
|
}
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
virtual void AppendMesh(FDynamicMesh3& AppendTo, const FTransformSequence3d& TransformSeq) override
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
if (!SourceMesh) return;
|
|
|
|
|
FDynamicMeshEditor Editor(&AppendTo);
|
|
|
|
|
FMeshIndexMappings Mappings;
|
|
|
|
|
FMeshDescriptionMeshAdapterd AdapterWrapper(*Adapter);
|
|
|
|
|
Editor.AppendMesh(&AdapterWrapper, Mappings,
|
|
|
|
|
[&](int, const FVector3d& Pos) { return TransformSeq.TransformPosition(Pos); });
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static TUniquePtr<IMeshSpatialWrapper> SpatialWrapperFactory( const FMeshTypeContainer& MeshContainer )
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
|
|
|
|
if (MeshContainer.MeshType == ESceneMeshType::StaticMeshAsset)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
TUniquePtr<FStaticMeshSpatialWrapper> SMWrapper = MakeUnique<FStaticMeshSpatialWrapper>();
|
|
|
|
|
SMWrapper->SourceContainer = MeshContainer;
|
2021-04-28 16:17:03 -04:00
|
|
|
SMWrapper->StaticMesh = MeshContainer.GetStaticMesh();
|
|
|
|
|
if (ensure(SMWrapper->StaticMesh != nullptr))
|
|
|
|
|
{
|
|
|
|
|
return SMWrapper;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
return TUniquePtr<IMeshSpatialWrapper>();
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void CollectActorChildMeshes(AActor* Actor, UActorComponent* Component, FActorAdapter& Adapter)
|
|
|
|
|
{
|
|
|
|
|
UStaticMeshComponent* StaticMeshComponent = Cast<UStaticMeshComponent>(Component);
|
|
|
|
|
if (StaticMeshComponent != nullptr)
|
|
|
|
|
{
|
|
|
|
|
UStaticMesh* Mesh = StaticMeshComponent->GetStaticMesh();
|
|
|
|
|
if (Mesh != nullptr)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
TUniquePtr<FActorChildMesh> ChildMesh = MakeUnique<FActorChildMesh>();
|
|
|
|
|
ChildMesh->SourceComponent = Component;
|
|
|
|
|
ChildMesh->MeshContainer = FMeshTypeContainer{ Mesh, ESceneMeshType::StaticMeshAsset };
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
UInstancedStaticMeshComponent* ISMComponent = Cast<UInstancedStaticMeshComponent>(StaticMeshComponent);
|
|
|
|
|
if (ISMComponent != nullptr)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
// does anything additional need to happen here for HISMC?
|
2021-04-28 16:17:03 -04:00
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
ChildMesh->ComponentType = EActorMeshComponentType::InstancedStaticMesh;
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
int32 NumInstances = ISMComponent->GetInstanceCount();
|
|
|
|
|
for (int32 i = 0; i < NumInstances; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (ISMComponent->IsValidInstance(i))
|
|
|
|
|
{
|
|
|
|
|
FTransform InstanceTransform;
|
|
|
|
|
if (ensure(ISMComponent->GetInstanceTransform(i, InstanceTransform, true)))
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
TUniquePtr<FActorChildMesh> InstanceChild = MakeUnique<FActorChildMesh>();
|
|
|
|
|
InstanceChild->SourceComponent = ChildMesh->SourceComponent;
|
|
|
|
|
InstanceChild->MeshContainer = ChildMesh->MeshContainer;
|
|
|
|
|
InstanceChild->ComponentType = ChildMesh->ComponentType;
|
|
|
|
|
InstanceChild->ComponentIndex = i;
|
|
|
|
|
InstanceChild->WorldTransform.Append(InstanceTransform);
|
|
|
|
|
InstanceChild->bIsNonUniformScaled = InstanceChild->WorldTransform.HasNonUniformScale();
|
|
|
|
|
Adapter.ChildMeshes.Add(MoveTemp(InstanceChild));
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// base StaticMeshComponent
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
ChildMesh->ComponentType = EActorMeshComponentType::StaticMesh;
|
|
|
|
|
ChildMesh->ComponentIndex = 0;
|
|
|
|
|
ChildMesh->WorldTransform.Append(StaticMeshComponent->GetComponentTransform());
|
|
|
|
|
ChildMesh->bIsNonUniformScaled = ChildMesh->WorldTransform.HasNonUniformScale();
|
|
|
|
|
Adapter.ChildMeshes.Add(MoveTemp(ChildMesh));
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::AddActors(const TArray<AActor*>& ActorsSetIn)
|
|
|
|
|
{
|
|
|
|
|
// build an FActorAdapter for each Actor, that contains all mesh Components we know
|
|
|
|
|
// how to process, including those contained in ChildActorComponents
|
|
|
|
|
TArray<AActor*> ChildActors;
|
|
|
|
|
for (AActor* Actor : ActorsSetIn)
|
|
|
|
|
{
|
|
|
|
|
TUniquePtr<FActorAdapter> Adapter = MakeUnique<FActorAdapter>();
|
|
|
|
|
Adapter->SourceActor = Actor;
|
|
|
|
|
|
|
|
|
|
for (UActorComponent* Component : Actor->GetComponents())
|
|
|
|
|
{
|
|
|
|
|
CollectActorChildMeshes(Actor, Component, *Adapter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChildActors.Reset();
|
|
|
|
|
Actor->GetAllChildActors(ChildActors, true);
|
|
|
|
|
for (AActor* ChildActor : ChildActors)
|
|
|
|
|
{
|
|
|
|
|
for (UActorComponent* Component : ChildActor->GetComponents())
|
|
|
|
|
{
|
|
|
|
|
CollectActorChildMeshes(ChildActor, Component, *Adapter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SceneActors.Add(MoveTemp(Adapter));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find IMeshSpatialWrapper for each child mesh component. If one does not exist
|
|
|
|
|
// and we have not seen the underlying unique mesh (eg StaticMesh Asset, etc, construct a new one
|
|
|
|
|
for (TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
for (TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
void* MeshKey = ChildMesh->MeshContainer.GetMeshKey();
|
|
|
|
|
TSharedPtr<FSpatialWrapperInfo>* Found = SpatialAdapters.Find(MeshKey);
|
|
|
|
|
FSpatialWrapperInfo* MeshInfo = nullptr;
|
2021-04-28 16:17:03 -04:00
|
|
|
if (Found == nullptr)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
TSharedPtr<FSpatialWrapperInfo> NewWrapperInfo = MakeShared<FSpatialWrapperInfo>();
|
|
|
|
|
SpatialAdapters.Add(MeshKey, NewWrapperInfo);
|
|
|
|
|
|
|
|
|
|
NewWrapperInfo->SourceContainer = ChildMesh->MeshContainer;
|
|
|
|
|
NewWrapperInfo->SpatialWrapper = SpatialWrapperFactory(ChildMesh->MeshContainer);
|
|
|
|
|
MeshInfo = NewWrapperInfo.Get();
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
MeshInfo = (*Found).Get();
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
MeshInfo->ParentMeshes.Add(ChildMesh.Get());
|
|
|
|
|
if (ChildMesh->bIsNonUniformScaled)
|
|
|
|
|
{
|
|
|
|
|
MeshInfo->NonUniformScaleCount++;
|
|
|
|
|
}
|
|
|
|
|
ChildMesh->MeshSpatial = MeshInfo->SpatialWrapper.Get();
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
// TODO: compute per-actor world bounds
|
|
|
|
|
//FVector ActorOrigin, ActorExtent;
|
|
|
|
|
//Actor->GetActorBounds(false, ActorOrigin, ActorExtent, true);
|
|
|
|
|
//Adapter->WorldBounds = FAxisAlignedBox3d(
|
|
|
|
|
// (FVector3d)ActorOrigin - (FVector3d)ActorExtent, (FVector3d)ActorOrigin + (FVector3d)ActorExtent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::Build(const FMeshSceneAdapterBuildOptions& BuildOptions)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
|
|
|
|
if (BuildOptions.bThickenThinMeshes)
|
|
|
|
|
{
|
|
|
|
|
Build_FullDecompose(BuildOptions);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TArray<FSpatialWrapperInfo*> ToBuild;
|
|
|
|
|
for (TPair<void*, TSharedPtr<FSpatialWrapperInfo>> Pair : SpatialAdapters)
|
|
|
|
|
{
|
|
|
|
|
ToBuild.Add(Pair.Value.Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FCriticalSection ListsLock;
|
|
|
|
|
|
|
|
|
|
std::atomic<int32> DecomposedSourceMeshCount;
|
|
|
|
|
DecomposedSourceMeshCount = 0;
|
|
|
|
|
std::atomic<int32> DecomposedMeshesCount;
|
|
|
|
|
DecomposedMeshesCount = 0;
|
|
|
|
|
int32 AddedTrisCount = 0;
|
|
|
|
|
|
|
|
|
|
// parallel build of all the spatial data structures
|
|
|
|
|
ParallelFor(ToBuild.Num(), [&](int32 i)
|
|
|
|
|
{
|
|
|
|
|
FSpatialWrapperInfo* WrapperInfo = ToBuild[i];
|
|
|
|
|
TUniquePtr<IMeshSpatialWrapper>& Wrapper = WrapperInfo->SpatialWrapper;
|
|
|
|
|
bool bOK = Wrapper->Build(BuildOptions);
|
|
|
|
|
ensure(bOK); // assumption is that the wrapper will handle failure gracefully
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (BuildOptions.bPrintDebugMessages)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("[FMeshSceneAdapter] decomposed %d source meshes into %d unique meshes containing %d triangles"), DecomposedSourceMeshCount.load(), DecomposedMeshesCount.load(), AddedTrisCount)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update bounding boxes
|
|
|
|
|
ParallelFor(SceneActors.Num(), [&](int32 i)
|
|
|
|
|
{
|
|
|
|
|
UpdateActorBounds(*SceneActors[i]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::UpdateActorBounds(FActorAdapter& Actor)
|
|
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3d ActorBounds = FAxisAlignedBox3d::Empty();
|
|
|
|
|
for (const TUniquePtr<FActorChildMesh>& ChildMesh : Actor.ChildMeshes)
|
|
|
|
|
{
|
|
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3d ChildBounds = ChildMesh->MeshSpatial->GetWorldBounds(
|
|
|
|
|
[&](const FVector3d& P) { return ChildMesh->WorldTransform.TransformPosition(P); });
|
|
|
|
|
ActorBounds.Contain(ChildBounds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Actor.WorldBounds = ActorBounds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::Build_FullDecompose(const FMeshSceneAdapterBuildOptions& BuildOptions)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
|
|
|
|
TArray<FSpatialWrapperInfo*> ToBuild;
|
|
|
|
|
for (TPair<void*, TSharedPtr<FSpatialWrapperInfo>> Pair : SpatialAdapters)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
ToBuild.Add(Pair.Value.Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FCriticalSection ListsLock;
|
|
|
|
|
|
|
|
|
|
std::atomic<int32> DecomposedSourceMeshCount;
|
|
|
|
|
DecomposedSourceMeshCount = 0;
|
|
|
|
|
std::atomic<int32> DecomposedMeshesCount;
|
|
|
|
|
DecomposedMeshesCount = 0;
|
|
|
|
|
int32 AddedTrisCount = 0;
|
|
|
|
|
|
2021-05-27 13:58:40 -04:00
|
|
|
FCriticalSection PendingFuturesLock;
|
|
|
|
|
TArray<TFuture<void>> PendingClosedAssemblyBuilds;
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
// use this to disable build of unnecessary AABBTree/etc
|
|
|
|
|
FMeshSceneAdapterBuildOptions TempBuildOptions = BuildOptions;
|
|
|
|
|
TempBuildOptions.bBuildSpatialDataStructures = false;
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
// parallel build of all the spatial data structures
|
|
|
|
|
ParallelFor(ToBuild.Num(), [&](int32 i)
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh);
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
FSpatialWrapperInfo* WrapperInfo = ToBuild[i];
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
// convert this mesh to a dynamicmesh for processing
|
|
|
|
|
FDynamicMesh3 LocalMesh;
|
|
|
|
|
WrapperInfo->SpatialWrapper->Build(TempBuildOptions);
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_1Copy);
|
|
|
|
|
WrapperInfo->SpatialWrapper->AppendMesh(LocalMesh, FTransformSequence3d());
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
// should we try to weld here??
|
|
|
|
|
|
|
|
|
|
FMeshConnectedComponents Components(&LocalMesh);
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_2Components);
|
|
|
|
|
Components.FindConnectedTriangles();
|
|
|
|
|
}
|
|
|
|
|
int32 NumComponents = Components.Num();
|
|
|
|
|
TArray<bool> IsClosed;
|
|
|
|
|
IsClosed.Init(false, NumComponents);
|
|
|
|
|
std::atomic<int32> NumNonClosed = 0;
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_3Closed);
|
|
|
|
|
ParallelFor(NumComponents, [&](int32 ci)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
const FMeshConnectedComponents::FComponent& Component = Components[ci];
|
|
|
|
|
const TArray<int32>& Triangles = Component.Indices;
|
|
|
|
|
IsClosed[ci] = IsClosedRegion(LocalMesh, Triangles);
|
|
|
|
|
if (IsClosed[ci] == false)
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
NumNonClosed++;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we have no open meshes, we can just use the SpatialWrapper we already have, but we have to
|
|
|
|
|
// rebuild it because we did not do a full build above
|
|
|
|
|
if (NumNonClosed == 0)
|
|
|
|
|
{
|
|
|
|
|
WrapperInfo->SpatialWrapper->Build(BuildOptions);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE: because of thin-planar checks below, we might not actually decompose this mesh!!
|
|
|
|
|
DecomposedSourceMeshCount++;
|
|
|
|
|
|
|
|
|
|
// list of per-instance transforms
|
|
|
|
|
TArray<FActorChildMesh*> MeshesToDecompose = WrapperInfo->ParentMeshes;
|
|
|
|
|
TArray<FTransformSequence3d> ParentTransforms;
|
|
|
|
|
for (FActorChildMesh* MeshInstance : MeshesToDecompose)
|
|
|
|
|
{
|
|
|
|
|
ParentTransforms.Add(MeshInstance->WorldTransform);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool bMakeClosedAssembly = (NumNonClosed != NumComponents);
|
|
|
|
|
FDynamicMesh3 LocalSpaceParts;
|
|
|
|
|
FDynamicMeshEditor LocalSpaceAccumulator(&LocalSpaceParts);
|
|
|
|
|
FDynamicMesh3 WorldSpaceParts;
|
|
|
|
|
FDynamicMeshEditor WorldSpaceAccumulator(&WorldSpaceParts);
|
|
|
|
|
|
|
|
|
|
int32 LocalCount = 0, DecomposedCount = 0;
|
|
|
|
|
|
|
|
|
|
// Accumulate closed parts in a local-space mesh that can stay instanced, and open parts
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_4Accumulate);
|
|
|
|
|
for (int32 ci = 0; ci < NumComponents; ++ci)
|
|
|
|
|
{
|
|
|
|
|
const TArray<int32>& Triangles = Components[ci].Indices;
|
|
|
|
|
|
|
|
|
|
bool bKeepLocal = true;
|
|
|
|
|
FFrame3d ThinMeshPlane;
|
|
|
|
|
if (IsClosed[ci] == false)
|
|
|
|
|
{
|
|
|
|
|
bool IsThinMesh = IsThinPlanarSubMesh<FDynamicMesh3>(LocalMesh, Triangles, BuildOptions.DesiredMinThickness, ThinMeshPlane);
|
|
|
|
|
if (IsThinMesh && (Triangles.Num() < 10000 || WrapperInfo->ParentMeshes.Num() == 1))
|
|
|
|
|
{
|
|
|
|
|
bKeepLocal = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FMeshIndexMappings Mappings;
|
|
|
|
|
FDynamicMeshEditResult EditResult;
|
|
|
|
|
if (bKeepLocal)
|
|
|
|
|
{
|
|
|
|
|
LocalSpaceAccumulator.AppendTriangles(&LocalMesh, Triangles, Mappings, EditResult, false);
|
|
|
|
|
LocalCount++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DecomposedCount++;
|
|
|
|
|
for (const FTransformSequence3d& Transform : ParentTransforms)
|
|
|
|
|
{
|
|
|
|
|
DecomposedMeshesCount++;
|
|
|
|
|
Mappings.Reset();
|
|
|
|
|
EditResult.Reset();
|
|
|
|
|
WorldSpaceAccumulator.AppendTriangles(&LocalMesh, Triangles, Mappings, EditResult, false);
|
|
|
|
|
for (int32 vid : EditResult.NewVertices)
|
|
|
|
|
{
|
|
|
|
|
FVector3d LocalPos = WorldSpaceParts.GetVertex(vid);
|
|
|
|
|
WorldSpaceParts.SetVertex(vid, Transform.TransformPosition(LocalPos));
|
|
|
|
|
}
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
// make new mesh containers
|
|
|
|
|
|
|
|
|
|
// we re-use the existing wrapper for the closed meshes, if there are any, otherwise
|
|
|
|
|
// we need to disable the parent meshes that refer to it
|
|
|
|
|
if (bMakeClosedAssembly)
|
|
|
|
|
{
|
|
|
|
|
TUniquePtr<FDynamicMeshSpatialWrapper> LocalSpaceMeshWrapper = MakeUnique<FDynamicMeshSpatialWrapper>();
|
|
|
|
|
|
|
|
|
|
LocalSpaceMeshWrapper->Mesh = MoveTemp(LocalSpaceParts);
|
|
|
|
|
FDynamicMeshSpatialWrapper* BuildWrapper = LocalSpaceMeshWrapper.Get();
|
2021-05-27 13:58:40 -04:00
|
|
|
TFuture<void> PendingClosedAssemblyBuild = Async(EAsyncExecution::ThreadPool, [&BuildOptions, BuildWrapper]()
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_6SolidBuild);
|
|
|
|
|
BuildWrapper->Build(BuildOptions);
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-27 13:58:40 -04:00
|
|
|
PendingFuturesLock.Lock();
|
|
|
|
|
PendingClosedAssemblyBuilds.Add(MoveTemp(PendingClosedAssemblyBuild));
|
|
|
|
|
PendingFuturesLock.Unlock();
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
WrapperInfo->SpatialWrapper = MoveTemp(LocalSpaceMeshWrapper);
|
|
|
|
|
|
|
|
|
|
for (FActorChildMesh* MeshInstance : MeshesToDecompose)
|
|
|
|
|
{
|
|
|
|
|
MeshInstance->MeshSpatial = WrapperInfo->SpatialWrapper.Get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// have to null out spatials for the child meshes so that they are ignored during computation
|
|
|
|
|
for (FActorChildMesh* MeshInstance : MeshesToDecompose)
|
|
|
|
|
{
|
|
|
|
|
MeshInstance->MeshSpatial = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// currently happens if we fail to find open parts to expand/etc
|
|
|
|
|
if (WorldSpaceParts.TriangleCount() == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// world-space meshes are added to new fake adapter
|
|
|
|
|
TUniquePtr<FActorAdapter> Adapter = MakeUnique<FActorAdapter>();
|
|
|
|
|
Adapter->SourceActor = nullptr;
|
|
|
|
|
|
|
|
|
|
TUniquePtr<FActorChildMesh> ChildMesh = MakeUnique<FActorChildMesh>();
|
|
|
|
|
ChildMesh->SourceComponent = nullptr;
|
|
|
|
|
ChildMesh->ComponentType = EActorMeshComponentType::InternallyGeneratedComponent;
|
|
|
|
|
ChildMesh->ComponentIndex = 0;
|
|
|
|
|
ChildMesh->bIsNonUniformScaled = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TUniquePtr<FDynamicMeshSpatialWrapper> NewWorldSpaceSpatial = MakeUnique<FDynamicMeshSpatialWrapper>();
|
|
|
|
|
NewWorldSpaceSpatial->Mesh = MoveTemp(WorldSpaceParts);
|
|
|
|
|
NewWorldSpaceSpatial->bHasBakedTransform = true;
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_8WorldSpaceBuild);
|
|
|
|
|
NewWorldSpaceSpatial->Build(BuildOptions);
|
|
|
|
|
}
|
|
|
|
|
NewWorldSpaceSpatial->bUseDistanceShellForWinding = true;
|
|
|
|
|
NewWorldSpaceSpatial->WindingShellThickness = 0.5 * BuildOptions.DesiredMinThickness;
|
|
|
|
|
|
|
|
|
|
TSharedPtr<FSpatialWrapperInfo> NewWrapperInfo = MakeShared<FSpatialWrapperInfo>();
|
|
|
|
|
NewWrapperInfo->SpatialWrapper = MoveTemp(NewWorldSpaceSpatial);
|
|
|
|
|
NewWrapperInfo->ParentMeshes.Add(ChildMesh.Get());
|
|
|
|
|
ChildMesh->MeshSpatial = NewWrapperInfo->SpatialWrapper.Get();
|
|
|
|
|
|
|
|
|
|
void* UseKey = ChildMesh.Get();
|
|
|
|
|
Adapter->ChildMeshes.Add(MoveTemp(ChildMesh));
|
|
|
|
|
|
|
|
|
|
ListsLock.Lock();
|
|
|
|
|
SpatialAdapters.Add(UseKey, NewWrapperInfo);
|
|
|
|
|
SceneActors.Add(MoveTemp(Adapter));
|
|
|
|
|
AddedTrisCount += NewWrapperInfo->SpatialWrapper->GetTriangleCount();
|
|
|
|
|
ListsLock.Unlock();
|
2021-04-28 16:17:03 -04:00
|
|
|
});
|
|
|
|
|
|
2021-05-27 13:58:40 -04:00
|
|
|
// make sure these finishes
|
|
|
|
|
for (auto& PendingClosedAssemblyBuild : PendingClosedAssemblyBuilds)
|
|
|
|
|
{
|
|
|
|
|
PendingClosedAssemblyBuild.Wait();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
// currently true with the methods used above?
|
|
|
|
|
bSceneIsAllSolids = true;
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
if (BuildOptions.bPrintDebugMessages)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("[FMeshSceneAdapter] decomposed %d source meshes into %d unique meshes containing %d triangles"), DecomposedSourceMeshCount.load(), DecomposedMeshesCount.load(), AddedTrisCount)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::GetGeometryStatistics(FStatistics& StatsOut)
|
|
|
|
|
{
|
|
|
|
|
StatsOut.UniqueMeshCount = 0;
|
|
|
|
|
StatsOut.UniqueMeshTriangleCount = 0;
|
|
|
|
|
for (TPair<void*, TSharedPtr<FSpatialWrapperInfo>> Pair : SpatialAdapters)
|
|
|
|
|
{
|
|
|
|
|
StatsOut.UniqueMeshCount++;
|
|
|
|
|
StatsOut.UniqueMeshTriangleCount += Pair.Value->SpatialWrapper->GetTriangleCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatsOut.InstanceMeshCount = 0;
|
|
|
|
|
StatsOut.InstanceMeshTriangleCount = 0;
|
|
|
|
|
for (const TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
|
|
|
|
for (const TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
|
|
|
|
{
|
|
|
|
|
StatsOut.InstanceMeshCount++;
|
|
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
|
|
|
|
StatsOut.InstanceMeshTriangleCount += ChildMesh->MeshSpatial->GetTriangleCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FAxisAlignedBox3d FMeshSceneAdapter::GetBoundingBox()
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_GetBoundingBox);
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
if (bHaveSpatialEvaluationCache)
|
|
|
|
|
{
|
|
|
|
|
return CachedWorldBounds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this could be done in parallel...
|
|
|
|
|
FAxisAlignedBox3d SceneBounds = FAxisAlignedBox3d::Empty();
|
2021-04-28 16:17:03 -04:00
|
|
|
for (const TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
for (const TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
|
|
|
|
{
|
|
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3d ChildBounds = ChildMesh->MeshSpatial->GetWorldBounds(
|
|
|
|
|
[&](const FVector3d& P) { return ChildMesh->WorldTransform.TransformPosition(P); });
|
|
|
|
|
SceneBounds.Contain(ChildBounds);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
return SceneBounds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::CollectMeshSeedPoints(TArray<FVector3d>& Points)
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_CollectMeshSeedPoints);
|
|
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
for (const TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
for (const TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
ChildMesh->MeshSpatial->CollectSeedPoints(Points,
|
|
|
|
|
[&](const FVector3d& P) { return ChildMesh->WorldTransform.TransformPosition(P); } );
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
double FMeshSceneAdapter::FastWindingNumber(const FVector3d& P, bool bFastEarlyOutIfPossible)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
check(bHaveSpatialEvaluationCache); // must call BuildSpatialEvaluationCache() to build Octree
|
|
|
|
|
|
2021-05-04 19:08:26 -04:00
|
|
|
double SumWinding = 0.0;
|
2021-05-20 19:35:43 -04:00
|
|
|
|
|
|
|
|
// if all objects in scene are solids, then all winding queries will return integers so if any value
|
|
|
|
|
// is > 0, we are "inside"
|
|
|
|
|
if (bSceneIsAllSolids)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
if (bFastEarlyOutIfPossible)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
bool bFinished = Octree->ContainmentQueryCancellable(P, [&](int32 k)
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
double WindingNumber = SortedSpatials[k].Spatial->FastWindingNumber(P, SortedSpatials[k].ChildMesh->WorldTransform);
|
|
|
|
|
SumWinding += WindingNumber;
|
|
|
|
|
return (FMath::Abs(WindingNumber) < 0.99); // if we see an "inside" winding number we can just exit
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Octree->ContainmentQuery(P, [&](int32 k)
|
|
|
|
|
{
|
|
|
|
|
double WindingNumber = SortedSpatials[k].Spatial->FastWindingNumber(P, SortedSpatials[k].ChildMesh->WorldTransform);
|
|
|
|
|
SumWinding += WindingNumber;
|
|
|
|
|
});
|
2021-04-28 16:17:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (const FSpatialCacheInfo& SpatialInfo : SortedSpatials)
|
|
|
|
|
{
|
|
|
|
|
double WindingNumber = SpatialInfo.Spatial->FastWindingNumber(P, SpatialInfo.ChildMesh->WorldTransform);
|
|
|
|
|
SumWinding += WindingNumber;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-04 19:08:26 -04:00
|
|
|
return SumWinding;
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
void FMeshSceneAdapter::BuildSpatialEvaluationCache()
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_BuildSpatialEvaluationCache);
|
|
|
|
|
|
|
|
|
|
// build list of unique meshes we need to evaluate for spatial queries
|
|
|
|
|
SortedSpatials.Reset();
|
|
|
|
|
for (const TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
|
|
|
|
for (const TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
|
|
|
|
{
|
|
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
|
|
|
|
FSpatialCacheInfo Cache;
|
|
|
|
|
Cache.Actor = Actor.Get();
|
|
|
|
|
Cache.ChildMesh = ChildMesh.Get();
|
|
|
|
|
Cache.Spatial = ChildMesh->MeshSpatial;
|
|
|
|
|
Cache.Bounds = ChildMesh->MeshSpatial->GetWorldBounds(
|
|
|
|
|
[&](const FVector3d& P) { return ChildMesh->WorldTransform.TransformPosition(P); });
|
|
|
|
|
SortedSpatials.Add(Cache);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// sort the list (not really necessary but might improve cache coherency during linear queries)
|
|
|
|
|
SortedSpatials.Sort([&](const FSpatialCacheInfo& A, const FSpatialCacheInfo& B)
|
|
|
|
|
{
|
|
|
|
|
return A.Spatial < B.Spatial;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
int32 NumSpatials = SortedSpatials.Num();
|
|
|
|
|
ParallelFor(SortedSpatials.Num(), [&](int32 k)
|
|
|
|
|
{
|
|
|
|
|
SortedSpatials[k].Bounds = SortedSpatials[k].Spatial->GetWorldBounds(
|
|
|
|
|
[&](const FVector3d& P) { return SortedSpatials[k].ChildMesh->WorldTransform.TransformPosition(P); });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
CachedWorldBounds = FAxisAlignedBox3d::Empty();
|
|
|
|
|
for (const FSpatialCacheInfo& Cache : SortedSpatials )
|
|
|
|
|
{
|
|
|
|
|
CachedWorldBounds.Contain(Cache.Bounds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// build an octree of the mesh objects
|
|
|
|
|
Octree = MakeShared<FSparseDynamicOctree3>();
|
|
|
|
|
Octree->RootDimension = CachedWorldBounds.MaxDim() / 4.0;
|
|
|
|
|
Octree->SetMaxTreeDepth(5);
|
|
|
|
|
for (int32 k = 0; k < NumSpatials; ++k)
|
|
|
|
|
{
|
|
|
|
|
Octree->InsertObject(k, SortedSpatials[k].Bounds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bHaveSpatialEvaluationCache = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::GetAccumulatedMesh(FDynamicMesh3& AccumMesh)
|
|
|
|
|
{
|
|
|
|
|
for (const TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
|
|
|
|
for (const TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
|
|
|
|
{
|
|
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
|
|
|
|
ChildMesh->MeshSpatial->AppendMesh(AccumMesh, ChildMesh->WorldTransform);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::GenerateBaseClosingMesh(double BaseHeight, double ExtrudeHeight)
|
|
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3d WorldBounds = GetBoundingBox();
|
|
|
|
|
FInterval1d ZRange(WorldBounds.Min.Z, WorldBounds.Min.Z + BaseHeight);
|
|
|
|
|
|
|
|
|
|
TArray<FActorChildMesh*> AllChildMeshes;
|
|
|
|
|
for (TUniquePtr<FActorAdapter>& Actor : SceneActors)
|
|
|
|
|
{
|
|
|
|
|
for (TUniquePtr<FActorChildMesh>& ChildMesh : Actor->ChildMeshes)
|
|
|
|
|
{
|
|
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
|
|
|
|
AllChildMeshes.Add(ChildMesh.Get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FVector2d> WorldHullPoints;
|
|
|
|
|
FCriticalSection WorldHullPointsLock;
|
|
|
|
|
|
|
|
|
|
int32 NumChildren = AllChildMeshes.Num();
|
|
|
|
|
ParallelFor(NumChildren, [&](int32 ci)
|
|
|
|
|
{
|
|
|
|
|
FActorChildMesh* ChildMesh = AllChildMeshes[ci];
|
|
|
|
|
TArray<FVector2d> LocalHullPoints;
|
|
|
|
|
ChildMesh->MeshSpatial->ProcessVerticesInWorld([&](const FVector3d& WorldPos)
|
|
|
|
|
{
|
|
|
|
|
if (ZRange.Contains(WorldPos.Z))
|
|
|
|
|
{
|
|
|
|
|
LocalHullPoints.Add(FVector2d(WorldPos.X, WorldPos.Y));
|
|
|
|
|
}
|
|
|
|
|
}, ChildMesh->WorldTransform);
|
|
|
|
|
|
|
|
|
|
if (LocalHullPoints.Num() > 0)
|
|
|
|
|
{
|
|
|
|
|
FConvexHull2d HullSolver;
|
|
|
|
|
if (HullSolver.Solve(LocalHullPoints))
|
|
|
|
|
{
|
|
|
|
|
WorldHullPointsLock.Lock();
|
|
|
|
|
for (int32 idx : HullSolver.GetPolygonIndices())
|
|
|
|
|
{
|
|
|
|
|
WorldHullPoints.Add(LocalHullPoints[idx]);
|
|
|
|
|
}
|
|
|
|
|
WorldHullPointsLock.Unlock();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
FConvexHull2d FinalHullSolver;
|
2021-05-20 19:35:43 -04:00
|
|
|
bool bOK = FinalHullSolver.Solve(WorldHullPoints);
|
|
|
|
|
if (bOK == false)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("[FMeshSceneAdapter::GenerateBaseClosingMesh] failed to solve convex hull"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
FPolygon2d ConvexHullPoly;
|
|
|
|
|
for (int32 idx : FinalHullSolver.GetPolygonIndices())
|
|
|
|
|
{
|
|
|
|
|
ConvexHullPoly.AppendVertex(WorldHullPoints[idx]);
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
if (ConvexHullPoly.VertexCount() < 2)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("[FMeshSceneAdapter::GenerateBaseClosingMesh] convex hull is degenerate"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
FPlanarPolygonMeshGenerator MeshGen;
|
|
|
|
|
MeshGen.Polygon = ConvexHullPoly;
|
|
|
|
|
FDynamicMesh3 BasePolygonMesh(&MeshGen.Generate());
|
|
|
|
|
MeshTransforms::Translate(BasePolygonMesh, ZRange.Min * FVector3d::UnitZ());
|
|
|
|
|
|
|
|
|
|
if (ExtrudeHeight == 0)
|
|
|
|
|
{
|
|
|
|
|
BasePolygonMesh.ReverseOrientation(); // flip so it points down
|
2021-05-20 19:35:43 -04:00
|
|
|
bSceneIsAllSolids = false; // if scene was solids, it's not anymore
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FOffsetMeshRegion Offset(&BasePolygonMesh);
|
|
|
|
|
for (int32 tid : BasePolygonMesh.TriangleIndicesItr())
|
|
|
|
|
{
|
|
|
|
|
Offset.Triangles.Add(tid);
|
|
|
|
|
}
|
|
|
|
|
Offset.bUseFaceNormals = true;
|
|
|
|
|
Offset.DefaultOffsetDistance = ExtrudeHeight;
|
|
|
|
|
Offset.bIsPositiveOffset = (ExtrudeHeight > 0);
|
|
|
|
|
Offset.Apply();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// append a fake actor/mesh
|
|
|
|
|
//
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
TUniquePtr<FActorAdapter> ActorAdapter = MakeUnique<FActorAdapter>();
|
|
|
|
|
ActorAdapter->SourceActor = nullptr;
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
TUniquePtr<FActorChildMesh> ChildMesh = MakeUnique<FActorChildMesh>();
|
|
|
|
|
ChildMesh->SourceComponent = nullptr;
|
|
|
|
|
//InstanceChild->MeshContainer = ;
|
|
|
|
|
ChildMesh->ComponentType = EActorMeshComponentType::InternallyGeneratedComponent;
|
|
|
|
|
ChildMesh->ComponentIndex = 0;
|
|
|
|
|
//ChildMesh->WorldTransform.Append(InstanceTransform);
|
|
|
|
|
ChildMesh->bIsNonUniformScaled = false;
|
|
|
|
|
|
|
|
|
|
TSharedPtr<FSpatialWrapperInfo> NewWrapperInfo = MakeShared<FSpatialWrapperInfo>();
|
|
|
|
|
SpatialAdapters.Add(ChildMesh.Get(), NewWrapperInfo);
|
|
|
|
|
TUniquePtr<FDynamicMeshSpatialWrapper> DynamicMeshWrapper = MakeUnique<FDynamicMeshSpatialWrapper>();
|
|
|
|
|
//DynamicMeshWrapper->SourceContainer = NewWrapperInfo->SourceContainer;
|
|
|
|
|
DynamicMeshWrapper->Mesh = MoveTemp(BasePolygonMesh);
|
|
|
|
|
DynamicMeshWrapper->bHasBakedTransform = true;
|
|
|
|
|
FMeshSceneAdapterBuildOptions UseBuildOptions;
|
|
|
|
|
DynamicMeshWrapper->Build(UseBuildOptions);
|
|
|
|
|
|
|
|
|
|
//NewWrapperInfo->SourceContainer = ChildMesh->MeshContainer;
|
|
|
|
|
NewWrapperInfo->SpatialWrapper = MoveTemp(DynamicMeshWrapper);
|
|
|
|
|
NewWrapperInfo->ParentMeshes.Add(ChildMesh.Get());
|
|
|
|
|
ChildMesh->MeshSpatial = NewWrapperInfo->SpatialWrapper.Get();
|
2021-05-20 19:35:43 -04:00
|
|
|
ActorAdapter->ChildMeshes.Add(MoveTemp(ChildMesh));
|
|
|
|
|
UpdateActorBounds(*ActorAdapter);
|
|
|
|
|
SceneActors.Add(MoveTemp(ActorAdapter));
|
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|