2021-04-28 16:17:03 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Scene/MeshSceneAdapter.h"
|
|
|
|
|
|
2021-06-13 00:35:22 -04:00
|
|
|
#include "DynamicMesh/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"
|
2021-06-13 00:35:22 -04:00
|
|
|
#include "DynamicMesh/MeshTransforms.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 "BoxTypes.h"
|
|
|
|
|
#include "FrameTypes.h"
|
|
|
|
|
#include "Selections/MeshConnectedComponents.h"
|
2021-06-15 02:47:13 -04:00
|
|
|
#include "DynamicMesh/Operations/MergeCoincidentMeshEdges.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 "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"
|
2021-06-21 16:32:50 -04:00
|
|
|
#include "Materials/Material.h"
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
#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-06-15 02:47:13 -04:00
|
|
|
void CollectSeedPointsFromMeshVertices(
|
|
|
|
|
const FDynamicMesh3& Mesh,
|
|
|
|
|
TFunctionRef<FVector3d(const FVector3d&)> TransformFunc, TArray<FVector3d>& AccumPointsInOut,
|
|
|
|
|
double NormalOffset = 0,
|
|
|
|
|
int32 MaxPoints = 500)
|
|
|
|
|
{
|
|
|
|
|
int32 NumVertices = Mesh.VertexCount();
|
|
|
|
|
int32 LogNumVertices = FMath::Max(1, (int32)FMathd::Ceil(FMathd::Log(NumVertices)));
|
|
|
|
|
int32 SeedPointCount = (int)(10 * LogNumVertices);
|
|
|
|
|
SeedPointCount = FMath::Min(SeedPointCount, MaxPoints);
|
|
|
|
|
int32 Skip = FMath::Max(NumVertices / SeedPointCount, 2);
|
|
|
|
|
for (int32 k = 0; k < NumVertices; k += Skip)
|
|
|
|
|
{
|
|
|
|
|
FVector3d Pos = Mesh.GetVertex(k);
|
|
|
|
|
if (NormalOffset > 0)
|
|
|
|
|
{
|
|
|
|
|
int32 tid = *Mesh.VtxTrianglesItr(k).begin();
|
|
|
|
|
FVector3d TriNormal = Mesh.GetTriNormal(tid);
|
|
|
|
|
Pos += NormalOffset * TriNormal;
|
|
|
|
|
}
|
|
|
|
|
AccumPointsInOut.Add(TransformFunc(Pos));
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
/**
|
2021-06-15 02:47:13 -04:00
|
|
|
* Try to check if a Mesh is "thin", ie basically a planar patch (open or closed), relative to a given plane
|
|
|
|
|
*
|
2021-06-08 02:55:00 -04:00
|
|
|
*/
|
|
|
|
|
template<typename MeshType>
|
2021-06-15 02:47:13 -04:00
|
|
|
double MeasureThickness(const MeshType& Mesh, const FFrame3d& Plane)
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3d PlaneExtents = FAxisAlignedBox3d::Empty();
|
|
|
|
|
int32 VertexCount = Mesh.VertexCount();
|
2021-06-15 02:47:13 -04:00
|
|
|
for (int32 k = 0; k < VertexCount; ++k)
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
if (Mesh.IsVertex(k))
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
PlaneExtents.Contain(Plane.ToFramePoint(Mesh.GetVertex(k)));
|
2021-06-08 02:55:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
return PlaneExtents.Depth();
|
2021-06-08 02:55:00 -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).
|
2021-06-08 02:55:00 -04:00
|
|
|
* The Normal of the largest-area triangle is taken as the plane normal, and then the "thickness" is measured relative to this plane
|
2021-05-20 19:35:43 -04:00
|
|
|
* @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-06-15 02:47:13 -04:00
|
|
|
bool IsThinPlanarSubMesh(
|
|
|
|
|
const MeshType& Mesh, const TArray<int32>& Triangles,
|
|
|
|
|
FTransformSequence3d& Transform,
|
|
|
|
|
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-06-15 02:47:13 -04:00
|
|
|
FVector3d Scale = Transform.GetAccumulatedScale();
|
2021-05-20 19:35:43 -04:00
|
|
|
int32 TriCount = Triangles.Num();
|
2021-06-15 02:47:13 -04:00
|
|
|
FAxisAlignedBox3d MeshBounds = FAxisAlignedBox3d::Empty();
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// Find triangle with largest area and use it's normal as the plane normal
|
|
|
|
|
// (this is not ideal and we should probably do a normals histogram
|
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);
|
2021-06-15 02:47:13 -04:00
|
|
|
A *= Scale; B *= Scale; C *= Scale;
|
|
|
|
|
MeshBounds.Contain(A);
|
|
|
|
|
MeshBounds.Contain(B);
|
|
|
|
|
MeshBounds.Contain(C);
|
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 TriArea;
|
|
|
|
|
FVector3d TriNormal = VectorUtil::NormalArea(A, B, C, TriArea);
|
|
|
|
|
if (TriArea > MaxArea)
|
|
|
|
|
{
|
|
|
|
|
MaxArea = TriArea;
|
|
|
|
|
MaxAreaNormal = TriNormal;
|
|
|
|
|
MaxAreaPoint = A;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
// if one of the AABB dimensions is below the thin tolerance, just use it
|
|
|
|
|
FVector3d BoundsDimensions = MeshBounds.Diagonal();
|
|
|
|
|
if (BoundsDimensions.GetAbsMin() < ThinTolerance)
|
|
|
|
|
{
|
|
|
|
|
int32 Index = UE::Geometry::MinAbsElementIndex(BoundsDimensions);
|
|
|
|
|
FVector3d BoxNormal = FVector3d::Zero();
|
|
|
|
|
BoxNormal[Index] = 1.0;
|
|
|
|
|
ThinPlaneOut = FFrame3d(MeshBounds.Center(), BoxNormal);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// Now compute the bounding box in the local space of this plane
|
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)
|
|
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
TriVerts[j] = ThinPlaneOut.ToFramePoint(Scale * TriVerts[j]);
|
2021-05-20 19:35:43 -04:00
|
|
|
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
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// early-out if we exceed tolerance
|
|
|
|
|
if (PlaneExtents.Depth() > ThinTolerance)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// shift plane to center
|
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 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();
|
2021-06-08 02:55:00 -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
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
|
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-06-08 02:55:00 -04:00
|
|
|
// if true, Mesh is only translated and rotated (allows some assumptions to be made)
|
|
|
|
|
bool bHasBakedScale = 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)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_WrapperBuild_DMesh_AABBTree);
|
|
|
|
|
AABBTree = MakeUnique<TMeshAABBTree3<FDynamicMesh3>>(&Mesh, true);
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
if (bUseDistanceShellForWinding == false)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_WrapperBuild_DMesh_FWNTree);
|
|
|
|
|
FWNTree = MakeUnique<TFastWindingTree<FDynamicMesh3>>(AABBTree.Get(), true);
|
|
|
|
|
}
|
2021-05-20 19:35:43 -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
|
|
|
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 ?
|
2021-06-15 02:47:13 -04:00
|
|
|
CollectSeedPointsFromMeshVertices(Mesh, [&](const FVector3d& P) {return P;}, WorldPoints, WindingShellThickness) :
|
|
|
|
|
CollectSeedPointsFromMeshVertices(Mesh, LocalToWorldFunc, WorldPoints, WindingShellThickness);
|
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
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
if (bUseDistanceShellForWinding)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
if (bHasBakedTransform || bHasBakedScale)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
FVector3d UseP = (bHasBakedTransform) ? P : LocalToWorldTransform.InverseTransformPosition(P);
|
2021-05-20 19:35:43 -04:00
|
|
|
double NearestDistSqr;
|
2021-06-08 02:55:00 -04:00
|
|
|
int32 NearTriID = AABBTree->FindNearestTriangle(UseP, NearestDistSqr, IMeshSpatial::FQueryOptions(WindingShellThickness));
|
2021-05-20 19:35:43 -04:00
|
|
|
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)
|
2021-06-08 02:55:00 -04:00
|
|
|
FDistPoint3Triangle3d Query = TMeshQueries<FDynamicMesh3>::TriangleDistance(Mesh, NearTriID, UseP);
|
2021-05-20 19:35:43 -04:00
|
|
|
if (Query.GetSquared() < WindingShellThickness * WindingShellThickness)
|
|
|
|
|
{
|
|
|
|
|
return 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
ensure(false); // not supported yet
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
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-06-21 16:32:50 -04:00
|
|
|
/**
|
|
|
|
|
* Mesh adapter to filter out all mesh sections that are using materials for which the material domain isn't "Surface"
|
|
|
|
|
* This excludes decals for example.
|
|
|
|
|
*/
|
|
|
|
|
struct FMeshDescriptionTriangleMeshSurfaceAdapter : public FMeshDescriptionTriangleMeshAdapter
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FMeshDescriptionTriangleMeshSurfaceAdapter(const FMeshDescription* MeshIn, UStaticMesh* StaticMeshIn)
|
|
|
|
|
: FMeshDescriptionTriangleMeshAdapter(MeshIn)
|
|
|
|
|
, NumValidTriangles(0)
|
|
|
|
|
, bHasInvalidPolyGroup(false)
|
|
|
|
|
{
|
|
|
|
|
FStaticMeshConstAttributes MeshDescriptionAttributes(*MeshIn);
|
|
|
|
|
TPolygonGroupAttributesConstRef<FName> MaterialSlotNames = MeshDescriptionAttributes.GetPolygonGroupMaterialSlotNames();
|
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-06-21 16:32:50 -04:00
|
|
|
for (FPolygonGroupID PolygonGroupID : MeshIn->PolygonGroups().GetElementIDs())
|
|
|
|
|
{
|
|
|
|
|
bool bValidPolyGroup = 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-06-21 16:32:50 -04:00
|
|
|
int32 MaterialIndex = StaticMeshIn->GetMaterialIndex(MaterialSlotNames[PolygonGroupID]);
|
|
|
|
|
if (MaterialIndex > INDEX_NONE)
|
|
|
|
|
{
|
|
|
|
|
UMaterialInterface* MaterialInterface = StaticMeshIn->GetMaterial(MaterialIndex);
|
|
|
|
|
if (MaterialInterface && MaterialInterface->GetMaterial())
|
|
|
|
|
{
|
|
|
|
|
bValidPolyGroup = MaterialInterface->GetMaterial()->MaterialDomain == EMaterialDomain::MD_Surface;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bValidPolyGroup)
|
|
|
|
|
{
|
|
|
|
|
ValidPolyGroups.Add(PolygonGroupID);
|
|
|
|
|
NumValidTriangles += MeshIn->GetNumPolygonGroupTriangles(PolygonGroupID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bHasInvalidPolyGroup = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IsTriangle(int32 TID) const
|
|
|
|
|
{
|
|
|
|
|
return bHasInvalidPolyGroup ? ValidPolyGroups.Contains(Mesh->GetTrianglePolygonGroup(TID)) : FMeshDescriptionTriangleMeshAdapter::IsTriangle(TID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 TriangleCount() const
|
|
|
|
|
{
|
|
|
|
|
return bHasInvalidPolyGroup ? NumValidTriangles : FMeshDescriptionTriangleMeshAdapter::TriangleCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TSet<FPolygonGroupID> ValidPolyGroups;
|
|
|
|
|
int32 NumValidTriangles;
|
|
|
|
|
bool bHasInvalidPolyGroup;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class TriangleMeshType>
|
|
|
|
|
struct TMeshDescriptionMeshAdapterd : public UE::Geometry::TTriangleMeshAdapter<double>
|
|
|
|
|
{
|
|
|
|
|
TriangleMeshType ParentAdapter;
|
|
|
|
|
|
|
|
|
|
TMeshDescriptionMeshAdapterd(TriangleMeshType ParentAdapterIn) : ParentAdapter(ParentAdapterIn)
|
|
|
|
|
{
|
|
|
|
|
IsTriangle = [&](int index) { return ParentAdapter.IsTriangle(index); };
|
|
|
|
|
IsVertex = [&](int index) { return ParentAdapter.IsVertex(index); };
|
|
|
|
|
MaxTriangleID = [&]() { return ParentAdapter.MaxTriangleID(); };
|
|
|
|
|
MaxVertexID = [&]() { return ParentAdapter.MaxVertexID(); };
|
|
|
|
|
TriangleCount = [&]() { return ParentAdapter.TriangleCount(); };
|
|
|
|
|
VertexCount = [&]() { return ParentAdapter.VertexCount(); };
|
|
|
|
|
GetShapeTimestamp = [&]() { return ParentAdapter.GetShapeTimestamp(); };
|
|
|
|
|
GetTriangle = [&](int32 TriangleID) { return ParentAdapter.GetTriangle(TriangleID); };
|
|
|
|
|
GetVertex = [&](int32 VertexID) { return ParentAdapter.GetVertex(VertexID); };
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class TriangleMeshType>
|
|
|
|
|
class TStaticMeshSpatialWrapper : public IMeshSpatialWrapper
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
UStaticMesh* StaticMesh = nullptr;
|
|
|
|
|
int32 LODIndex = 0;
|
2021-06-08 02:55:00 -04:00
|
|
|
FVector3d BuildScale = FVector3d::One();
|
2021-04-28 16:17:03 -04:00
|
|
|
|
|
|
|
|
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-06-21 16:32:50 -04:00
|
|
|
TUniquePtr<TriangleMeshType> Adapter;
|
|
|
|
|
|
|
|
|
|
TUniquePtr<TMeshAABBTree3<TriangleMeshType>> AABBTree;
|
|
|
|
|
TUniquePtr<TFastWindingTree<TriangleMeshType>> FWNTree;
|
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 bool Build(const FMeshSceneAdapterBuildOptions& BuildOptions) override
|
2021-04-28 16:17:03 -04:00
|
|
|
{
|
|
|
|
|
check(StaticMesh);
|
2021-06-21 16:32:50 -04:00
|
|
|
|
|
|
|
|
#if !WITH_EDITOR
|
2021-04-28 16:17:03 -04:00
|
|
|
SourceMesh = nullptr;
|
|
|
|
|
#endif
|
|
|
|
|
if (SourceMesh)
|
|
|
|
|
{
|
2021-06-21 16:32:50 -04:00
|
|
|
check(Adapter);
|
2021-04-28 16:17:03 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
BuildScale = FVector3d::One();
|
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)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_WrapperBuild_StaticMesh_AABBTree);
|
2021-06-21 16:32:50 -04:00
|
|
|
AABBTree = MakeUnique<TMeshAABBTree3<TriangleMeshType>>(Adapter.Get(), true);
|
2021-06-08 02:55:00 -04:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_WrapperBuild_StaticMesh_FWNTree);
|
2021-06-21 16:32:50 -04:00
|
|
|
FWNTree = MakeUnique<TFastWindingTree<TriangleMeshType>>(AABBTree.Get(), true);
|
2021-06-08 02:55:00 -04:00
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
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();
|
2021-06-21 16:32:50 -04:00
|
|
|
return GetTransformedVertexBounds<TriangleMeshType>(*Adapter, LocalToWorldFunc);
|
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
|
|
|
|
|
|
|
|
virtual void CollectSeedPoints(TArray<FVector3d>& WorldPoints, TFunctionRef<FVector3d(const FVector3d&)> LocalToWorldFunc) override
|
|
|
|
|
{
|
|
|
|
|
if (!SourceMesh) return;
|
2021-06-21 16:32:50 -04:00
|
|
|
CollectSeedPointsFromMeshVertices<TriangleMeshType>(*Adapter, LocalToWorldFunc, WorldPoints);
|
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
|
|
|
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;
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
2021-06-21 16:32:50 -04:00
|
|
|
// Fast path only works on non-filtered meshes
|
|
|
|
|
// as it relies on the mesh description directly rather than the adapter
|
|
|
|
|
bool bFilteredMesh = SourceMesh->Triangles().Num() != Adapter->TriangleCount();
|
|
|
|
|
if (!bFilteredMesh && AppendTo.TriangleCount() == 0 && TransformSeq.Num() == 0)
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
|
|
|
|
// this is somewhat faster in profiling
|
|
|
|
|
FMeshDescription* UseMeshDescription = StaticMesh->GetMeshDescription(LODIndex);
|
|
|
|
|
FMeshDescriptionToDynamicMesh Converter;
|
|
|
|
|
Converter.bEnableOutputGroups = false; Converter.bCalculateMaps = false;
|
|
|
|
|
Converter.bDisableAttributes = true;
|
|
|
|
|
Converter.Convert(UseMeshDescription, AppendTo);
|
|
|
|
|
MeshTransforms::Scale(AppendTo, BuildScale, FVector3d::Zero());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
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
|
|
|
FDynamicMeshEditor Editor(&AppendTo);
|
|
|
|
|
FMeshIndexMappings Mappings;
|
2021-06-21 16:32:50 -04:00
|
|
|
TMeshDescriptionMeshAdapterd<TriangleMeshType> AdapterWrapper(*Adapter);
|
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
|
|
|
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
|
|
|
{
|
2021-06-21 16:32:50 -04:00
|
|
|
#if WITH_EDITOR
|
2021-04-28 16:17:03 -04:00
|
|
|
if (MeshContainer.MeshType == ESceneMeshType::StaticMeshAsset)
|
|
|
|
|
{
|
2021-06-21 16:32:50 -04:00
|
|
|
TUniquePtr<TStaticMeshSpatialWrapper<FMeshDescriptionTriangleMeshSurfaceAdapter>> SMWrapper = MakeUnique<TStaticMeshSpatialWrapper<FMeshDescriptionTriangleMeshSurfaceAdapter>>();
|
|
|
|
|
|
|
|
|
|
const int32 LODIndex = 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
|
|
|
SMWrapper->SourceContainer = MeshContainer;
|
2021-04-28 16:17:03 -04:00
|
|
|
SMWrapper->StaticMesh = MeshContainer.GetStaticMesh();
|
2021-06-21 16:32:50 -04:00
|
|
|
SMWrapper->SourceMesh = SMWrapper->StaticMesh->GetMeshDescription(LODIndex);
|
|
|
|
|
SMWrapper->Adapter = MakeUnique<FMeshDescriptionTriangleMeshSurfaceAdapter>(SMWrapper->SourceMesh, SMWrapper->StaticMesh);
|
|
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
if (ensure(SMWrapper->StaticMesh != nullptr))
|
|
|
|
|
{
|
|
|
|
|
return SMWrapper;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-21 16:32:50 -04:00
|
|
|
#else
|
|
|
|
|
checkf(false, TEXT("Not currently supported - to build at Runtime it is necessary to read from the StaticMesh RenderBuffers"));
|
|
|
|
|
#endif
|
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
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
void FMeshSceneAdapter::AddActors(const TArray<AActor*>& ActorsSetIn)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_AddActors);
|
|
|
|
|
|
2021-04-28 16:17:03 -04:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::Build(const FMeshSceneAdapterBuildOptions& BuildOptions)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build);
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ActorBounds);
|
|
|
|
|
ParallelFor(SceneActors.Num(), [&](int32 i)
|
|
|
|
|
{
|
|
|
|
|
UpdateActorBounds(*SceneActors[i]);
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshSceneAdapter::UpdateActorBounds(FActorAdapter& Actor)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
int32 NumChildren = Actor.ChildMeshes.Num();
|
|
|
|
|
TArray<FAxisAlignedBox3d> ChildBounds;
|
|
|
|
|
ChildBounds.Init(FAxisAlignedBox3d::Empty(), NumChildren);
|
|
|
|
|
ParallelFor(NumChildren, [&](int32 k)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
const TUniquePtr<FActorChildMesh>& ChildMesh = Actor.ChildMeshes[k];
|
2021-05-20 19:35:43 -04:00
|
|
|
if (ChildMesh->MeshSpatial != nullptr)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
ChildBounds[k] = ChildMesh->MeshSpatial->GetWorldBounds(
|
2021-05-20 19:35:43 -04:00
|
|
|
[&](const FVector3d& P) { return ChildMesh->WorldTransform.TransformPosition(P); });
|
2021-06-08 02:55:00 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Actor.WorldBounds = FAxisAlignedBox3d::Empty();
|
|
|
|
|
for (FAxisAlignedBox3d ChildBound : ChildBounds)
|
|
|
|
|
{
|
|
|
|
|
Actor.WorldBounds.Contain(ChildBound);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function is used to group the input set of transforms into subsets
|
|
|
|
|
* that have the same scale. Each of those subsets can be represented by
|
|
|
|
|
* a single scaled mesh with different rotate/translate-only transforms.
|
|
|
|
|
* We use this to reduce the number of times a mesh has to be duplicated when
|
|
|
|
|
* breaking it up into parts that require further processing that is incompatible
|
|
|
|
|
* with (nonuniform) scaling.
|
|
|
|
|
* TODO: Currently cannot differentiate between uniform and nonuniform scaling
|
|
|
|
|
*/
|
|
|
|
|
void ConstructUniqueScalesMapping(
|
|
|
|
|
const TArray<FTransformSequence3d>& TransformSet,
|
|
|
|
|
TArray<TArray<int32>>& UniqueScaleSetsOut,
|
2021-06-15 02:47:13 -04:00
|
|
|
TArray<FTransformSequence3d>& UniqueScaleTransformsOut,
|
2021-06-08 02:55:00 -04:00
|
|
|
double ScaleComponentTolerance = 0.01)
|
|
|
|
|
{
|
|
|
|
|
// two transforms are "the same up to scaling" if this returns true
|
|
|
|
|
auto CompareScales = [ScaleComponentTolerance](const FTransform3d& T1, const FTransform3d& T2)
|
|
|
|
|
{
|
|
|
|
|
return (T1.GetScale() - T2.GetScale()).GetAbsMax() < ScaleComponentTolerance;
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
UniqueScaleTransformsOut.Reset();
|
2021-06-08 02:55:00 -04:00
|
|
|
int32 N = TransformSet.Num();
|
|
|
|
|
TArray<int32> UniqueScaleMap;
|
|
|
|
|
UniqueScaleMap.SetNum(N);
|
|
|
|
|
for (int32 k = 0; k < N; ++k)
|
|
|
|
|
{
|
|
|
|
|
FTransformSequence3d CurTransform = TransformSet[k];
|
|
|
|
|
int32 FoundIndex = -1;
|
2021-06-15 02:47:13 -04:00
|
|
|
for (int32 j = 0; j < UniqueScaleTransformsOut.Num(); ++j)
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
if (CurTransform.IsEquivalent(UniqueScaleTransformsOut[j], CompareScales))
|
2021-06-08 02:55:00 -04:00
|
|
|
{
|
|
|
|
|
FoundIndex = j;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (FoundIndex >= 0)
|
|
|
|
|
{
|
|
|
|
|
UniqueScaleMap[k] = FoundIndex;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
UniqueScaleMap[k] = UniqueScaleTransformsOut.Num();
|
|
|
|
|
UniqueScaleTransformsOut.Add(CurTransform);
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// build clusters
|
2021-06-15 02:47:13 -04:00
|
|
|
int32 NumUniqueScales = UniqueScaleTransformsOut.Num();
|
2021-06-08 02:55:00 -04:00
|
|
|
UniqueScaleSetsOut.SetNum(NumUniqueScales);
|
|
|
|
|
for (int32 k = 0; k < N; ++k)
|
|
|
|
|
{
|
|
|
|
|
UniqueScaleSetsOut[UniqueScaleMap[k]].Add(k);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
EParallelForFlags ParallelFlags = EParallelForFlags::Unbalanced;
|
|
|
|
|
//EParallelForFlags ParallelFlags = EParallelForFlags::ForceSingleThread;
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// initial list of spatial wrappers that need to be built
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// Initialize the initial set of wrappers. Must do this here so that meshes are loaded and TriangleCount() below is valid
|
2021-05-20 19:35:43 -04:00
|
|
|
FMeshSceneAdapterBuildOptions TempBuildOptions = BuildOptions;
|
|
|
|
|
TempBuildOptions.bBuildSpatialDataStructures = false;
|
2021-06-08 02:55:00 -04:00
|
|
|
ParallelFor(ToBuild.Num(), [&](int32 i)
|
|
|
|
|
{
|
|
|
|
|
FSpatialWrapperInfo* WrapperInfo = ToBuild[i];
|
|
|
|
|
WrapperInfo->SpatialWrapper->Build(TempBuildOptions);
|
2021-06-15 02:47:13 -04:00
|
|
|
}, ParallelFlags);
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// sort build list by increasing triangle count
|
|
|
|
|
ToBuild.Sort([&](const FSpatialWrapperInfo& A, const FSpatialWrapperInfo& B)
|
|
|
|
|
{
|
|
|
|
|
return const_cast<FSpatialWrapperInfo&>(A).SpatialWrapper->GetTriangleCount() < const_cast<FSpatialWrapperInfo&>(B).SpatialWrapper->GetTriangleCount();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// stats we will collect during execution
|
|
|
|
|
int32 NumInitialSources = ToBuild.Num();
|
2021-06-15 02:47:13 -04:00
|
|
|
int32 NumSourceUniqueTris = 0;
|
2021-06-08 02:55:00 -04:00
|
|
|
std::atomic<int32> DecomposedSourceMeshCount = 0;
|
|
|
|
|
std::atomic<int32> DecomposedMeshesCount = 0;
|
|
|
|
|
std::atomic<int32> SourceInstancesCount = 0;
|
|
|
|
|
std::atomic<int32> NewInstancesCount = 0;
|
|
|
|
|
std::atomic<int32> SkippedDecompositionCount = 0;
|
2021-06-15 02:47:13 -04:00
|
|
|
std::atomic<int32> SingleTriangleMeshes = 0;
|
2021-06-08 02:55:00 -04:00
|
|
|
int32 AddedUniqueTrisCount = 0;
|
|
|
|
|
int32 InstancedTrisCount = 0;
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
struct FProcessedSourceMeshStats
|
|
|
|
|
{
|
|
|
|
|
FString AssetName;
|
|
|
|
|
int32 SourceTriangles = 0;
|
|
|
|
|
int32 SourceInstances = 0;
|
|
|
|
|
int32 SourceComponents = 0;
|
|
|
|
|
int32 UniqueInstanceScales = 0;
|
|
|
|
|
int32 NumOpen = 0;
|
|
|
|
|
int32 NumThin = 0;
|
|
|
|
|
int32 InstancedSubmeshComponents = 0;
|
|
|
|
|
int32 InstancedSubmeshTris = 0; // number of source tris used directly, ie copied to a single mesh for original instances
|
|
|
|
|
TArray<FVector2i> SubmeshSizeCount;
|
|
|
|
|
int32 NewUniqueTris = 0;
|
|
|
|
|
int32 NewInstances = 0;
|
|
|
|
|
int32 TotalNumUniqueTris = 0;
|
|
|
|
|
};
|
|
|
|
|
TArray<FProcessedSourceMeshStats> Stats;
|
|
|
|
|
Stats.SetNum(NumInitialSources);
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// these locks are used below to control access
|
|
|
|
|
FCriticalSection ToBuildQueueLock;
|
|
|
|
|
FCriticalSection InternalListsLock;
|
|
|
|
|
|
|
|
|
|
// The loop below will emit new IMeshSpatialWrapper's that need to have Build() called.
|
|
|
|
|
// Since larger meshes take longer, it is a better strategy to collect up these jobs and
|
|
|
|
|
// then call Build() in decreasing-size order
|
|
|
|
|
struct FBuildJob
|
|
|
|
|
{
|
|
|
|
|
int TriangleCount;
|
|
|
|
|
IMeshSpatialWrapper* BuildWrapper;
|
|
|
|
|
};
|
|
|
|
|
TArray<FBuildJob> PendingBuildJobs;
|
|
|
|
|
FCriticalSection PendingBuildsLock;
|
|
|
|
|
// this lambda is used below to append to the PendingBuildJobs list above
|
|
|
|
|
auto AddBuildJob = [&PendingBuildJobs, &PendingBuildsLock](IMeshSpatialWrapper* ToBuild, int TriangleCount)
|
|
|
|
|
{
|
|
|
|
|
PendingBuildsLock.Lock();
|
|
|
|
|
PendingBuildJobs.Add(FBuildJob{ TriangleCount, ToBuild });
|
|
|
|
|
PendingBuildsLock.Unlock();
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
std::atomic<int32> NumTinyComponents = 0;
|
|
|
|
|
std::atomic<int32> NumTinyInstances = 0;
|
|
|
|
|
std::atomic<int32> TinyInstanceTotalTriangles = 0;
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// Parallel-process all the ToBuild spatial wrappers. If the mesh is closed and all the pieces are good,
|
|
|
|
|
// this will just emit a Build job. Otherwise it will pull the mesh apart into pieces, move all the closed non-thin
|
|
|
|
|
// pieces into a new instance to be referenced by the original FActorChildMesh, and then make new meshes/wrappers
|
|
|
|
|
// for anything that needs geometric changes (eg to bake in scale, thicken mesh, etc), and in those cases, generate
|
|
|
|
|
// new instances as FActorAdapter/FActorChildMesh's. And emit BuildJob's for those different spatial wrappers.
|
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
|
|
|
ParallelFor(ToBuild.Num(), [&](int32 i)
|
|
|
|
|
{
|
2021-05-20 19:35:43 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh);
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// ParallelFor will not respect the sorting by triangle-count we did above, so we have to treat the list as a queue and pop from the back
|
|
|
|
|
ToBuildQueueLock.Lock();
|
|
|
|
|
check(ToBuild.Num() > 0);
|
2021-06-15 02:47:13 -04:00
|
|
|
FProcessedSourceMeshStats& ItemStats = Stats[ToBuild.Num() - 1];
|
2021-06-08 02:55:00 -04:00
|
|
|
FSpatialWrapperInfo* WrapperInfo = ToBuild.Pop(false);
|
2021-06-15 02:47:13 -04:00
|
|
|
NumSourceUniqueTris += WrapperInfo->SpatialWrapper->GetTriangleCount();
|
2021-06-08 02:55:00 -04:00
|
|
|
ToBuildQueueLock.Unlock();
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// get name for debugging purposes
|
2021-06-15 02:47:13 -04:00
|
|
|
ItemStats.AssetName = WrapperInfo->SourceContainer.GetStaticMesh() ? WrapperInfo->SourceContainer.GetStaticMesh()->GetName() : TEXT("Unknown");
|
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
|
|
|
// convert this mesh to a dynamicmesh for processing
|
|
|
|
|
FDynamicMesh3 LocalMesh;
|
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());
|
|
|
|
|
}
|
2021-06-15 02:47:13 -04:00
|
|
|
ItemStats.SourceTriangles = LocalMesh.TriangleCount();
|
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-06-15 02:47:13 -04:00
|
|
|
// construct list of per-instance transforms that reference this mesh
|
|
|
|
|
TArray<FActorChildMesh*> MeshesToDecompose = WrapperInfo->ParentMeshes;
|
|
|
|
|
TArray<FTransformSequence3d> ParentTransforms;
|
|
|
|
|
for (FActorChildMesh* MeshInstance : MeshesToDecompose)
|
|
|
|
|
{
|
|
|
|
|
ParentTransforms.Add(MeshInstance->WorldTransform);
|
|
|
|
|
SourceInstancesCount++;
|
|
|
|
|
}
|
|
|
|
|
ItemStats.SourceInstances = SourceInstancesCount;
|
|
|
|
|
|
|
|
|
|
// Decompose the per-instance transforms into subsets that share the same total scaling ("unique scale").
|
|
|
|
|
// If we apply these different scales to copies of the mesh, we can generate new instances for the copies,
|
|
|
|
|
// which can avoid uniquing a lot of geometry
|
|
|
|
|
TArray<TArray<int32>> UniqueScaleTransformSets;
|
|
|
|
|
TArray<FTransformSequence3d> UniqueScaleTransforms;
|
|
|
|
|
ConstructUniqueScalesMapping(ParentTransforms, UniqueScaleTransformSets, UniqueScaleTransforms);
|
|
|
|
|
int32 NumUniqueScales = UniqueScaleTransformSets.Num();
|
|
|
|
|
ItemStats.UniqueInstanceScales = NumUniqueScales;
|
|
|
|
|
|
|
|
|
|
// if mesh is not too huge, try to weld edges
|
|
|
|
|
if (LocalMesh.TriangleCount() < 100000)
|
|
|
|
|
{
|
|
|
|
|
FMergeCoincidentMeshEdges WeldEdges(&LocalMesh);
|
|
|
|
|
WeldEdges.Apply();
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// find separate submeshes of the mesh
|
2021-05-20 19:35:43 -04:00
|
|
|
FMeshConnectedComponents Components(&LocalMesh);
|
|
|
|
|
{
|
|
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_2Components);
|
|
|
|
|
Components.FindConnectedTriangles();
|
|
|
|
|
}
|
|
|
|
|
int32 NumComponents = Components.Num();
|
2021-06-15 02:47:13 -04:00
|
|
|
ItemStats.SourceComponents = NumComponents;
|
2021-06-08 02:55:00 -04:00
|
|
|
|
|
|
|
|
// for each submesh/component, determine if it is closed, and if it is 'thin'
|
|
|
|
|
TArray<bool> IsClosed, IsThin;
|
2021-05-20 19:35:43 -04:00
|
|
|
IsClosed.Init(false, NumComponents);
|
2021-06-08 02:55:00 -04:00
|
|
|
IsThin.Init(false, NumComponents);
|
2021-06-15 02:47:13 -04:00
|
|
|
std::atomic<int32> NumNonClosed = 0;
|
|
|
|
|
TArray<TArray<FFrame3d>> BestFitPlanes;
|
|
|
|
|
BestFitPlanes.SetNum(NumComponents);
|
2021-06-08 02:55:00 -04:00
|
|
|
std::atomic<int32> NumThin = 0;
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
|
|
|
|
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++;
|
|
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
BestFitPlanes[ci].SetNum(NumUniqueScales);
|
|
|
|
|
for (int32 k = 0; k < NumUniqueScales; ++k)
|
|
|
|
|
{
|
|
|
|
|
bool bIsThinUnderTransform = IsThinPlanarSubMesh<FDynamicMesh3>(LocalMesh, Triangles, UniqueScaleTransforms[k], BuildOptions.DesiredMinThickness, BestFitPlanes[ci][k]);
|
|
|
|
|
IsThin[ci] = IsThin[ci] || bIsThinUnderTransform;
|
|
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
if (IsThin[ci])
|
|
|
|
|
{
|
|
|
|
|
NumThin++;
|
|
|
|
|
}
|
2021-06-15 02:47:13 -04:00
|
|
|
}, ParallelFlags);
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
2021-06-15 02:47:13 -04:00
|
|
|
ItemStats.NumOpen = NumNonClosed.load();
|
|
|
|
|
ItemStats.NumThin = NumThin.load();
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// if we have no open meshes and no thin 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
|
|
|
|
|
// note: possibly some other cases where we can do this, if the StaticMesh wrapper supported unsigned/offset mode
|
|
|
|
|
if (NumNonClosed == 0 && NumThin == 0)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
AddBuildJob(WrapperInfo->SpatialWrapper.Get(), LocalMesh.TriangleCount());
|
2021-05-20 19:35:43 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// Accumulate submesh/components that do *not* need further processing here, that accumulated mesh
|
|
|
|
|
// (if non-empty) can be shared among all the original FActorChildMesh instances
|
2021-05-20 19:35:43 -04:00
|
|
|
FDynamicMesh3 LocalSpaceParts;
|
|
|
|
|
FDynamicMeshEditor LocalSpaceAccumulator(&LocalSpaceParts);
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// a new copy of one of the submeshes that has been scaled/processed such that it can only be
|
|
|
|
|
// represented with some of the original instance transforms (NewTransforms).
|
|
|
|
|
struct FInstancedSubmesh
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TSharedPtr<FDynamicMesh3> Mesh;
|
|
|
|
|
TArray<FTransformSequence3d> NewTransforms;
|
|
|
|
|
double ComputedThickness = 0;
|
|
|
|
|
};
|
|
|
|
|
TArray<FInstancedSubmesh> NewSubmeshes;
|
|
|
|
|
|
|
|
|
|
// Split all the submeshes/components into the LocalSpaceParts mesh (for closed and non-thin) and
|
|
|
|
|
// a set of new FInstancedSubmesh's
|
|
|
|
|
{
|
|
|
|
|
FMeshIndexMappings Mappings; // these are re-used between calls
|
|
|
|
|
FDynamicMeshEditResult EditResult;
|
|
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_Build_ProcessMesh_4Accumulate);
|
|
|
|
|
for (int32 ci = 0; ci < NumComponents; ++ci)
|
|
|
|
|
{
|
|
|
|
|
const TArray<int32>& Triangles = Components[ci].Indices;
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
int32 NewUniqueTriangles = Triangles.Num() * NumUniqueScales;
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// We will make unscaled copies of a mesh if (1) it is "thin" and (2) it has a moderate number of triangles *or* a single usage
|
|
|
|
|
// TODO: should we always unique a mesh with a single usage? We can just make it unsigned...
|
|
|
|
|
bool bIsClosed = IsClosed[ci];
|
2021-06-15 02:47:13 -04:00
|
|
|
if (IsThin[ci] == false || (NewUniqueTriangles > 1000000) )
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
Mappings.Reset(); EditResult.Reset();
|
|
|
|
|
LocalSpaceAccumulator.AppendTriangles(&LocalMesh, Triangles, Mappings, EditResult, false);
|
2021-06-15 02:47:13 -04:00
|
|
|
ItemStats.InstancedSubmeshComponents++;
|
2021-06-08 02:55:00 -04:00
|
|
|
continue;
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// if we go this far, we need to unique this mesh once for each "unique scale", and then
|
|
|
|
|
// make a new set of instance transforms for it
|
|
|
|
|
for (int32 k = 0; k < NumUniqueScales; ++k)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
FInstancedSubmesh NewSubmesh;
|
|
|
|
|
const TArray<int32>& InstanceIndices = UniqueScaleTransformSets[k];
|
|
|
|
|
// make unique copy of submesh
|
|
|
|
|
NewSubmesh.Mesh = MakeShared<FDynamicMesh3>();
|
|
|
|
|
FDynamicMeshEditor Editor(NewSubmesh.Mesh.Get());
|
|
|
|
|
Mappings.Reset(); EditResult.Reset();
|
|
|
|
|
Editor.AppendTriangles(&LocalMesh, Triangles, Mappings, EditResult, false);
|
|
|
|
|
// bake in the scaling
|
|
|
|
|
FVector3d Scale = ParentTransforms[InstanceIndices[0]].GetAccumulatedScale();
|
2021-06-15 02:47:13 -04:00
|
|
|
FAxisAlignedBox3d ScaledBounds = FAxisAlignedBox3d::Empty();
|
2021-06-08 02:55:00 -04:00
|
|
|
for (int32 vid : EditResult.NewVertices)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
FVector3d LocalPos = NewSubmesh.Mesh->GetVertex(vid);
|
2021-06-15 02:47:13 -04:00
|
|
|
LocalPos *= Scale;
|
|
|
|
|
NewSubmesh.Mesh->SetVertex(vid, LocalPos);
|
|
|
|
|
ScaledBounds.Contain(LocalPos);
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
2021-06-08 02:55:00 -04:00
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
// if this is a tiny submesh we will skip it
|
|
|
|
|
if (BuildOptions.bFilterTinyObjects && ScaledBounds.MaxDim() < BuildOptions.TinyObjectBoxMaxDimension)
|
|
|
|
|
{
|
|
|
|
|
NumTinyComponents++;
|
|
|
|
|
NumTinyInstances += InstanceIndices.Num();
|
|
|
|
|
TinyInstanceTotalTriangles += InstanceIndices.Num() * Triangles.Num();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Recompute thickness of scaled mesh and store it. Note that after scaling we might fail to
|
|
|
|
|
// be considered "thin" anymore, in that case we will fall back to using winding number
|
2021-06-08 02:55:00 -04:00
|
|
|
// for this mesh (So, it was a waste to do this separation, but messy to turn back now)
|
|
|
|
|
if (bIsClosed == false)
|
|
|
|
|
{
|
|
|
|
|
NewSubmesh.ComputedThickness = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
double NewThickness = MeasureThickness<FDynamicMesh3>(*NewSubmesh.Mesh, BestFitPlanes[ci][k]);
|
|
|
|
|
NewSubmesh.ComputedThickness = FMathd::Min(NewThickness, BuildOptions.DesiredMinThickness);
|
2021-06-08 02:55:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// make new set of instances
|
|
|
|
|
for (int32 j : InstanceIndices)
|
|
|
|
|
{
|
|
|
|
|
FTransformSequence3d InstanceTransform = ParentTransforms[j];
|
|
|
|
|
InstanceTransform.ClearScales();
|
|
|
|
|
NewSubmesh.NewTransforms.Add(InstanceTransform);
|
|
|
|
|
}
|
|
|
|
|
NewSubmeshes.Add(MoveTemp(NewSubmesh));
|
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-06-08 02:55:00 -04:00
|
|
|
// At this point we have processed all the Submeshes/Components. Now we generate new MeshSpatialWrapper's
|
|
|
|
|
// and any necessary new FActorAdapter's/FActorChildMesh's
|
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-06-15 02:47:13 -04:00
|
|
|
ItemStats.InstancedSubmeshTris = LocalSpaceParts.TriangleCount();
|
|
|
|
|
ItemStats.TotalNumUniqueTris += ItemStats.InstancedSubmeshTris;
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// First handle the LocalSpaceParts mesh, which can still be shared between the original FActorChildMesh instances
|
|
|
|
|
if (LocalSpaceParts.TriangleCount() > 0)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
|
|
|
|
TUniquePtr<FDynamicMeshSpatialWrapper> LocalSpaceMeshWrapper = MakeUnique<FDynamicMeshSpatialWrapper>();
|
|
|
|
|
LocalSpaceMeshWrapper->Mesh = MoveTemp(LocalSpaceParts);
|
2021-06-08 02:55:00 -04:00
|
|
|
AddBuildJob(LocalSpaceMeshWrapper.Get(), LocalSpaceMeshWrapper->Mesh.TriangleCount());
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// Exit if we don't have any more work to do. This happens if we ended up skipping all the possible decompositions
|
|
|
|
|
// Note: in this case we could just re-use the existing actor and skip the LocalSpaceParts mesh entirely?
|
|
|
|
|
if (NewSubmeshes.Num() == 0)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
SkippedDecompositionCount++;
|
2021-05-20 19:35:43 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// definitely decomposing this mesh
|
|
|
|
|
DecomposedSourceMeshCount++;
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// Now we create a new FActorAdapter for each new InstancedSubmesh, and then an FActorChildMesh
|
|
|
|
|
// for each Instance (ie rotate/translate transform of that instance). This is somewhat arbitrary,
|
|
|
|
|
// eg it could all be done in a single Actor, or split up further. At evaluation time we will have
|
|
|
|
|
// pulled these back out of the Actor so it doesn't really matter.
|
|
|
|
|
for (FInstancedSubmesh& Submesh : NewSubmeshes)
|
2021-05-20 19:35:43 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TUniquePtr<FActorAdapter> NewActor = MakeUnique<FActorAdapter>();
|
|
|
|
|
NewActor->SourceActor = nullptr; // not a "real" actor
|
|
|
|
|
|
|
|
|
|
// make new spatialwrapper for this instanced mesh
|
|
|
|
|
TUniquePtr<FDynamicMeshSpatialWrapper> NewInstancedMesh = MakeUnique<FDynamicMeshSpatialWrapper>();
|
|
|
|
|
int32 TriangleCount = Submesh.Mesh->TriangleCount();
|
|
|
|
|
NewInstancedMesh->Mesh = MoveTemp(*Submesh.Mesh);
|
|
|
|
|
NewInstancedMesh->bHasBakedTransform = false;
|
|
|
|
|
NewInstancedMesh->bHasBakedScale = true;
|
|
|
|
|
// queue up build job
|
|
|
|
|
AddBuildJob(NewInstancedMesh.Get(), TriangleCount);
|
|
|
|
|
// if mesh is too thin, configure the extra shell offset based on 'missing' thickness
|
|
|
|
|
if (Submesh.ComputedThickness < BuildOptions.DesiredMinThickness)
|
|
|
|
|
{
|
|
|
|
|
NewInstancedMesh->bUseDistanceShellForWinding = true;
|
|
|
|
|
NewInstancedMesh->WindingShellThickness = 0.5 * (BuildOptions.DesiredMinThickness - Submesh.ComputedThickness);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedPtr<FSpatialWrapperInfo> NewWrapperInfo = MakeShared<FSpatialWrapperInfo>();
|
|
|
|
|
NewWrapperInfo->SpatialWrapper = MoveTemp(NewInstancedMesh);
|
|
|
|
|
|
|
|
|
|
// add to internal lists
|
|
|
|
|
InternalListsLock.Lock();
|
|
|
|
|
AddedUniqueTrisCount += TriangleCount;
|
|
|
|
|
InstancedTrisCount += TriangleCount * Submesh.NewTransforms.Num();
|
|
|
|
|
void* UseKey = (void*)NewWrapperInfo->SpatialWrapper.Get();
|
|
|
|
|
SpatialAdapters.Add(UseKey, NewWrapperInfo);
|
|
|
|
|
InternalListsLock.Unlock();
|
|
|
|
|
|
|
|
|
|
// create the new transform instances
|
|
|
|
|
for (FTransformSequence3d InstanceTransform : Submesh.NewTransforms)
|
|
|
|
|
{
|
|
|
|
|
TUniquePtr<FActorChildMesh> ChildMesh = MakeUnique<FActorChildMesh>();
|
|
|
|
|
ChildMesh->SourceComponent = nullptr;
|
|
|
|
|
ChildMesh->ComponentType = EActorMeshComponentType::InternallyGeneratedComponent;
|
|
|
|
|
ChildMesh->ComponentIndex = 0;
|
|
|
|
|
ChildMesh->WorldTransform = InstanceTransform;
|
|
|
|
|
ChildMesh->bIsNonUniformScaled = false;
|
|
|
|
|
|
|
|
|
|
NewWrapperInfo->ParentMeshes.Add(ChildMesh.Get());
|
|
|
|
|
ChildMesh->MeshSpatial = NewWrapperInfo->SpatialWrapper.Get();
|
|
|
|
|
|
|
|
|
|
NewActor->ChildMeshes.Add(MoveTemp(ChildMesh));
|
|
|
|
|
NewInstancesCount++;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-15 02:47:13 -04:00
|
|
|
ItemStats.SubmeshSizeCount.Add(FVector2i(TriangleCount, Submesh.NewTransforms.Num()));
|
|
|
|
|
ItemStats.NewInstances += Submesh.NewTransforms.Num();
|
|
|
|
|
ItemStats.NewUniqueTris += TriangleCount;
|
|
|
|
|
ItemStats.TotalNumUniqueTris += TriangleCount;
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// add actor our actor set
|
|
|
|
|
InternalListsLock.Lock();
|
|
|
|
|
SceneActors.Add(MoveTemp(NewActor));
|
|
|
|
|
InternalListsLock.Unlock();
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
2021-06-15 02:47:13 -04:00
|
|
|
}, ParallelFlags); // end outer ParallelFor over ToBuild meshes
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
check(ToBuild.Num() == 0);
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// Now all that is left is to actually Build() all the different spatial wrappers that exist at this point
|
2021-05-20 19:35:43 -04:00
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
// sort by increasing triangle size.
|
|
|
|
|
PendingBuildJobs.Sort([](const FBuildJob& A, const FBuildJob& B)
|
2021-05-27 13:58:40 -04:00
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
return A.TriangleCount < B.TriangleCount;
|
|
|
|
|
});
|
|
|
|
|
ParallelFor(PendingBuildJobs.Num(), [&](int32 i)
|
|
|
|
|
{
|
|
|
|
|
// ParallelFor will not respect our sort order if we just use the index directly (because it splits into chunks internally), so
|
|
|
|
|
// we have to treat the list like a queue to get it to be processed in our desired order
|
|
|
|
|
ToBuildQueueLock.Lock();
|
|
|
|
|
check(PendingBuildJobs.Num() > 0);
|
|
|
|
|
FBuildJob BuildJob = PendingBuildJobs.Pop(false);
|
|
|
|
|
ToBuildQueueLock.Unlock();
|
|
|
|
|
BuildJob.BuildWrapper->Build(BuildOptions);
|
2021-06-15 02:47:13 -04:00
|
|
|
if (BuildJob.BuildWrapper->GetTriangleCount() == 1)
|
|
|
|
|
{
|
|
|
|
|
SingleTriangleMeshes++;
|
|
|
|
|
}
|
|
|
|
|
}, ParallelFlags);
|
2021-06-08 02:55:00 -04:00
|
|
|
check(PendingBuildJobs.Num() == 0);
|
2021-05-27 13:58:40 -04:00
|
|
|
|
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)
|
|
|
|
|
{
|
2021-06-15 02:47:13 -04:00
|
|
|
UE_LOG(LogTemp, Warning, TEXT("[FMeshSceneAdapter] decomposed %d source meshes used in %d instances (of %d total source meshes with %ld unique triangles), into %d new instances containing %ld unique triangles (%ld total instanced). Skipped %d decompositions. Skipped %d tiny components (%d instances, %d total triangles). %d 1-triangle meshes."),
|
|
|
|
|
DecomposedSourceMeshCount.load(), SourceInstancesCount.load(), NumInitialSources, NumSourceUniqueTris,
|
|
|
|
|
NewInstancesCount.load(), AddedUniqueTrisCount, InstancedTrisCount,
|
|
|
|
|
SkippedDecompositionCount.load(),
|
|
|
|
|
NumTinyComponents.load(), NumTinyInstances.load(), TinyInstanceTotalTriangles.load(),
|
|
|
|
|
SingleTriangleMeshes.load())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stats.Sort([](const FProcessedSourceMeshStats& A, const FProcessedSourceMeshStats& B)
|
|
|
|
|
{
|
|
|
|
|
return A.NewUniqueTris > B.NewUniqueTris;
|
|
|
|
|
});
|
|
|
|
|
for (int32 k = 0; k < 20; ++k)
|
|
|
|
|
{
|
|
|
|
|
const FProcessedSourceMeshStats& Stat = Stats[k];
|
|
|
|
|
FString NewSubmeshesStats;
|
|
|
|
|
for (FVector2i V : Stat.SubmeshSizeCount)
|
|
|
|
|
{
|
|
|
|
|
NewSubmeshesStats += FString::Printf(TEXT(" (%d,%d)"), V.X, V.Y);
|
|
|
|
|
}
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT(" %s : SourceTris %d Inst %d ResultTris %d Inst %d | UniqueScales %d Components %d | KeptTris %d NewUniqueTris %d | (Tri,Inst) %s"),
|
|
|
|
|
*Stat.AssetName, Stat.SourceTriangles, Stat.SourceInstances, Stat.TotalNumUniqueTris, (Stat.NewInstances + Stat.SourceInstances),
|
|
|
|
|
Stat.UniqueInstanceScales, Stat.SourceComponents,
|
|
|
|
|
Stat.InstancedSubmeshTris, Stat.NewUniqueTris, *NewSubmeshesStats);
|
|
|
|
|
}
|
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::GetGeometryStatistics(FStatistics& StatsOut)
|
|
|
|
|
{
|
|
|
|
|
StatsOut.UniqueMeshCount = 0;
|
|
|
|
|
StatsOut.UniqueMeshTriangleCount = 0;
|
|
|
|
|
for (TPair<void*, TSharedPtr<FSpatialWrapperInfo>> Pair : SpatialAdapters)
|
|
|
|
|
{
|
|
|
|
|
StatsOut.UniqueMeshCount++;
|
2021-06-08 02:55:00 -04:00
|
|
|
StatsOut.UniqueMeshTriangleCount += (int64)Pair.Value->SpatialWrapper->GetTriangleCount();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
StatsOut.InstanceMeshTriangleCount += (int64)ChildMesh->MeshSpatial->GetTriangleCount();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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();
|
|
|
|
|
CachedWorldBounds = FAxisAlignedBox3d::Empty();
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_BuildSpatialEvaluationCache_Bounds);
|
|
|
|
|
ParallelFor(SortedSpatials.Num(), [&](int32 k)
|
|
|
|
|
{
|
|
|
|
|
SortedSpatials[k].Bounds = SortedSpatials[k].Spatial->GetWorldBounds(
|
|
|
|
|
[&](const FVector3d& P) { return SortedSpatials[k].ChildMesh->WorldTransform.TransformPosition(P); });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (const FSpatialCacheInfo& Cache : SortedSpatials)
|
|
|
|
|
{
|
|
|
|
|
CachedWorldBounds.Contain(Cache.Bounds);
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
|
2021-06-08 02:55:00 -04:00
|
|
|
|
2021-05-20 19:35:43 -04:00
|
|
|
// build an octree of the mesh objects
|
|
|
|
|
Octree = MakeShared<FSparseDynamicOctree3>();
|
|
|
|
|
Octree->RootDimension = CachedWorldBounds.MaxDim() / 4.0;
|
|
|
|
|
Octree->SetMaxTreeDepth(5);
|
|
|
|
|
{
|
2021-06-08 02:55:00 -04:00
|
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(MeshScene_BuildSpatialEvaluationCache_OctreeInserts);
|
|
|
|
|
for (int32 k = 0; k < NumSpatials; ++k)
|
|
|
|
|
{
|
|
|
|
|
Octree->InsertObject(k, SortedSpatials[k].Bounds);
|
|
|
|
|
}
|
2021-05-20 19:35:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2021-06-08 02:55:00 -04:00
|
|
|
DynamicMeshWrapper->bHasBakedTransform = DynamicMeshWrapper->bHasBakedScale = 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
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|