2021-04-28 16:17:03 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "Scene/MeshSceneAdapter.h"
2021-06-13 00:36:02 -04:00
# include "DynamicMesh/DynamicMesh3.h"
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
# include "DynamicMesh/ColliderMesh.h"
2021-04-28 16:17:03 -04:00
# include "Spatial/MeshAABBTree3.h"
# include "Spatial/FastWinding.h"
# include "MeshDescriptionAdapter.h"
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
# include "StaticMeshLODResourcesAdapter.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:36:02 -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:39 -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"
2022-12-15 16:01:51 -05:00
# include "MaterialDomain.h"
2021-06-21 16:33:20 -04:00
# include "Materials/Material.h"
2021-04-28 16:17:03 -04:00
# include "Async/ParallelFor.h"
2022-11-03 14:18:47 -04:00
# include "UObject/Package.h"
2021-04-28 16:17:03 -04:00
using namespace UE : : Geometry ;
2021-07-22 18:56:41 -04:00
static TAutoConsoleVariable < int32 > CVarMeshSceneAdapterDisableMultiThreading (
TEXT ( " geometry.MeshSceneAdapter.SingleThreaded " ) ,
0 ,
TEXT ( " Determines whether or not to use multi-threading in MeshSceneAdapter. \n " ) ) ;
2021-08-26 09:31:28 -04:00
namespace UE
{
namespace Geometry
{
2021-05-20 19:35:43 -04:00
/**
* Compute the bounds of the vertices of Mesh , under 3 D 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:39 -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:39 -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:39 -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:39 -04:00
for ( int32 k = 0 ; k < VertexCount ; + + k )
2021-06-08 02:55:00 -04:00
{
2021-06-15 02:47:39 -04:00
if ( Mesh . IsVertex ( k ) )
2021-06-08 02:55:00 -04:00
{
2021-06-15 02:47:39 -04:00
PlaneExtents . Contain ( Plane . ToFramePoint ( Mesh . GetVertex ( k ) ) ) ;
2021-06-08 02:55:00 -04:00
}
}
2021-06-15 02:47:39 -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:39 -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:39 -04:00
FVector3d Scale = Transform . GetAccumulatedScale ( ) ;
2021-05-20 19:35:43 -04:00
int32 TriCount = Triangles . Num ( ) ;
2021-06-15 02:47:39 -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:39 -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:39 -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 ( ) ;
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:39 -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:39 -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 ;
}
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
/**
* Base type for various spatial wrappers , to provide common config variables
*/
class FBaseMeshSpatialWrapper : public IMeshSpatialWrapper
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
{
public :
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 ;
2021-07-22 18:56:41 -04:00
// if true, do winding query before testing shell thickness. This is necessary in cases where the
// shell thickness is very small (eg slightly thickening a relatively thick object). Then the thickness
// query would only create a shell instead of a full solid
bool bRequiresWindingQueryFallback = false ;
2021-05-20 19:35:43 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
} ;
/**
* IMeshSpatialWrapper for a FDynamicMesh3 , with optional AABBTree and FWNTree .
*
*/
class FDynamicMeshSpatialWrapper : public FBaseMeshSpatialWrapper
{
public :
FDynamicMesh3 Mesh ;
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 ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
FDynamicMeshSpatialWrapper ( )
{
}
FDynamicMeshSpatialWrapper ( FDynamicMesh3 & & SourceMesh )
{
Mesh = MoveTemp ( SourceMesh ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
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-07-22 18:56:41 -04:00
if ( bUseDistanceShellForWinding = = false | | bRequiresWindingQueryFallback )
2021-05-20 19:35:43 -04:00
{
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 ;
}
2021-11-02 13:58:07 -04:00
virtual int32 GetTriangleCount ( ) const override
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 Mesh . TriangleCount ( ) ;
}
2021-09-13 17:51:19 -04:00
virtual bool IsTriangle ( int32 TriId ) const override
{
return Mesh . IsTriangle ( TriId ) ;
}
virtual FIndex3i GetTriangle ( int32 TriId ) const override
{
return Mesh . GetTriangle ( TriId ) ;
}
virtual bool HasNormals ( ) const override
{
return Mesh . HasAttributes ( ) & & Mesh . Attributes ( ) - > PrimaryNormals ( ) ;
}
virtual bool HasUVs ( const int UVLayer = 0 ) const override
{
return Mesh . HasAttributes ( ) & & Mesh . Attributes ( ) - > GetUVLayer ( UVLayer ) ;
}
virtual FVector3d TriBaryInterpolatePoint ( int32 TriId , const FVector3d & BaryCoords ) const override
{
return Mesh . GetTriBaryPoint ( TriId , BaryCoords . X , BaryCoords . Y , BaryCoords . Z ) ;
}
virtual bool TriBaryInterpolateNormal ( int32 TriId , const FVector3d & BaryCoords , FVector3f & NormalOut ) const override
{
if ( Mesh . HasAttributes ( ) )
{
const FDynamicMeshNormalOverlay * NormalOverlay = Mesh . Attributes ( ) - > PrimaryNormals ( ) ;
if ( NormalOverlay )
{
FVector3d Normal ;
NormalOverlay - > GetTriBaryInterpolate ( TriId , & BaryCoords . X , & Normal . X ) ;
NormalOut = FVector3f ( Normal ) ;
return true ;
}
}
return false ;
}
virtual bool TriBaryInterpolateUV ( const int32 TriId , const FVector3d & BaryCoords , const int UVLayer , FVector2f & UVOut ) const override
{
if ( Mesh . HasAttributes ( ) )
{
const FDynamicMeshUVOverlay * UVOverlay = Mesh . Attributes ( ) - > GetUVLayer ( UVLayer ) ;
if ( UVOverlay )
{
FVector2d UV ;
UVOverlay - > GetTriBaryInterpolate ( TriId , & BaryCoords . X , & UV . X ) ;
UVOut = FVector2f ( UV ) ;
return true ;
}
}
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 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:39 -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-07-22 18:56:41 -04:00
if ( bRequiresWindingQueryFallback )
{
double WindingNumber = bHasBakedTransform ?
FWNTree - > FastWindingNumber ( P ) :
FWNTree - > FastWindingNumber ( LocalToWorldTransform . InverseTransformPosition ( P ) ) ;
if ( WindingNumber > 0.99 )
{
return 1.0 ;
}
}
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
}
2021-08-03 19:56:54 -04:00
virtual bool RayIntersection ( const FRay3d & WorldRay , const FTransformSequence3d & LocalToWorldTransform , FMeshSceneRayHit & WorldHitResultOut ) override
{
FRay3d UseRay = WorldRay ;
if ( bHasBakedTransform = = false )
{
FVector3d LocalOrigin = LocalToWorldTransform . InverseTransformPosition ( WorldRay . Origin ) ;
FVector3d LocalDir = Normalized ( LocalToWorldTransform . InverseTransformPosition ( WorldRay . PointAt ( 1.0 ) ) - LocalOrigin ) ;
UseRay = FRay3d ( LocalOrigin , LocalDir ) ;
}
2021-09-13 17:51:19 -04:00
double RayHitT ; int32 HitTID ; FVector3d HitBaryCoords ;
if ( AABBTree - > FindNearestHitTriangle ( UseRay , RayHitT , HitTID , HitBaryCoords ) )
2021-08-03 19:56:54 -04:00
{
WorldHitResultOut . HitMeshTriIndex = HitTID ;
WorldHitResultOut . HitMeshSpatialWrapper = this ;
if ( bHasBakedTransform )
{
WorldHitResultOut . RayDistance = RayHitT ;
}
else
{
FVector3d WorldPos = LocalToWorldTransform . TransformPosition ( UseRay . PointAt ( RayHitT ) ) ;
2021-11-17 21:06:46 -05:00
WorldHitResultOut . RayDistance = WorldRay . GetParameter ( WorldPos ) ;
2021-08-03 19:56:54 -04:00
}
2021-09-13 17:51:19 -04:00
WorldHitResultOut . HitMeshBaryCoords = HitBaryCoords ;
2021-08-03 19:56:54 -04:00
return true ;
}
return false ;
}
2021-08-31 23:26:49 -04:00
virtual bool ProcessVerticesInWorld ( TFunctionRef < bool ( const FVector3d & ) > ProcessFunc , const FTransformSequence3d & LocalToWorldTransform ) override
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-08-31 23:26:49 -04:00
bool bContinue = 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 ( bHasBakedTransform )
{
for ( FVector3d P : Mesh . VerticesItr ( ) )
{
2021-08-31 23:26:49 -04:00
bContinue = ProcessFunc ( P ) ;
if ( ! bContinue )
{
break ;
}
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
{
for ( FVector3d P : Mesh . VerticesItr ( ) )
{
2021-08-31 23:26:49 -04:00
bContinue = ProcessFunc ( LocalToWorldTransform . TransformPosition ( P ) ) ;
if ( ! bContinue )
{
break ;
}
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-08-31 23:26:49 -04:00
return bContinue ;
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
{
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-07-22 18:56:41 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
/**
* IMeshSpatialWrapper that stores a minimal ( " compressed " ) version of an input mesh ,
* basically just a vertex array and indexed triangle list . This reduces the memory
* footprint of large MeshDescription / FDynamicMeshes by dropping expensive attribute
* overlays and connectivity storage . In addition , for very small meshes , FDynamicMesh3
* is not an efficient representation because each internal buffer has a minimum size ,
* so using this format can significantly reduce the overhead of all those tiny meshes .
*
* Generally supports the same options and behavior as FDynamicMeshSpatialWrapper .
* It might be useful to try and combine the various queries in a template base class ?
*
* Note that this wrapper currently does not support the barycentric - interpolation queries
* of IMeshSpatialWrapper , and cannot be used if they are requested in the build options .
*/
class FCompressedMeshSpatialWrapper : public FBaseMeshSpatialWrapper
{
public :
FDynamicMesh3 BuildInputMesh ; // source mesh data - only used in build, then discarded
// compressed representation
FColliderMesh ColliderMesh ;
TUniquePtr < TFastWindingTree < FColliderMesh > > FWNTree ;
FCompressedMeshSpatialWrapper ( )
{
}
FCompressedMeshSpatialWrapper ( FDynamicMesh3 & & SourceMesh )
{
BuildInputMesh = MoveTemp ( SourceMesh ) ;
}
virtual bool Build ( const FMeshSceneAdapterBuildOptions & BuildOptions ) override
{
ensure ( BuildOptions . bEnableUVQueries = = false & & BuildOptions . bEnableNormalsQueries = = false ) ;
ensure ( BuildInputMesh . TriangleCount ( ) > 0 ) ;
FColliderMesh : : FBuildOptions ColliderBuildOptions ;
ColliderBuildOptions . bBuildAABBTree = BuildOptions . bBuildSpatialDataStructures ;
ColliderMesh . Initialize ( BuildInputMesh ) ;
BuildInputMesh = FDynamicMesh3 ( ) ; // discard input mesh data
if ( BuildOptions . bBuildSpatialDataStructures )
{
if ( bUseDistanceShellForWinding = = false | | bRequiresWindingQueryFallback )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( MeshScene_WrapperBuild_DMesh_FWNTree ) ;
2022-06-24 14:08:36 -04:00
check ( ColliderMesh . GetRawAABBTreeUnsafe ( ) ! = nullptr ) ;
FWNTree = MakeUnique < TFastWindingTree < FColliderMesh > > ( ColliderMesh . GetRawAABBTreeUnsafe ( ) , true ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
}
}
return true ;
}
virtual int32 GetTriangleCount ( ) const override
{
return ColliderMesh . TriangleCount ( ) ;
}
virtual bool IsTriangle ( int32 TriId ) const override
{
return ColliderMesh . IsTriangle ( TriId ) ;
}
virtual FIndex3i GetTriangle ( int32 TriId ) const override
{
return ColliderMesh . GetTriangle ( TriId ) ;
}
virtual bool HasNormals ( ) const override
{
check ( false ) ;
return false ;
}
virtual bool HasUVs ( const int UVLayer = 0 ) const override
{
check ( false ) ;
return false ;
}
virtual FVector3d TriBaryInterpolatePoint ( int32 TriId , const FVector3d & BaryCoords ) const override
{
check ( false ) ;
return FVector3d : : Zero ( ) ;
}
virtual bool TriBaryInterpolateNormal ( int32 TriId , const FVector3d & BaryCoords , FVector3f & NormalOut ) const override
{
check ( false ) ;
return false ;
}
virtual bool TriBaryInterpolateUV ( const int32 TriId , const FVector3d & BaryCoords , const int UVLayer , FVector2f & UVOut ) const override
{
check ( false ) ;
return false ;
}
virtual FAxisAlignedBox3d GetWorldBounds ( TFunctionRef < FVector3d ( const FVector3d & ) > LocalToWorldFunc ) override
{
FAxisAlignedBox3d Bounds = bHasBakedTransform ?
GetTransformedVertexBounds < FColliderMesh > ( ColliderMesh , [ ] ( const FVector3d & P ) { return P ; } ) :
GetTransformedVertexBounds < FColliderMesh > ( ColliderMesh , LocalToWorldFunc ) ;
if ( bUseDistanceShellForWinding )
{
Bounds . Expand ( WindingShellThickness ) ;
}
return Bounds ;
}
virtual void CollectSeedPoints ( TArray < FVector3d > & WorldPoints , TFunctionRef < FVector3d ( const FVector3d & ) > LocalToWorldFunc ) override
{
return bHasBakedTransform ?
CollectSeedPointsFromMeshVertices < FColliderMesh > ( ColliderMesh , [ ] ( const FVector3d & P ) { return P ; } , WorldPoints ) :
CollectSeedPointsFromMeshVertices < FColliderMesh > ( ColliderMesh , LocalToWorldFunc , WorldPoints ) ;
}
virtual double FastWindingNumber ( const FVector3d & P , const FTransformSequence3d & LocalToWorldTransform ) override
{
if ( bUseDistanceShellForWinding )
{
if ( bRequiresWindingQueryFallback )
{
double WindingNumber = bHasBakedTransform ?
FWNTree - > FastWindingNumber ( P ) :
FWNTree - > FastWindingNumber ( LocalToWorldTransform . InverseTransformPosition ( P ) ) ;
if ( WindingNumber > 0.99 )
{
return 1.0 ;
}
}
if ( bHasBakedTransform | | bHasBakedScale )
{
FVector3d UseP = ( bHasBakedTransform ) ? P : LocalToWorldTransform . InverseTransformPosition ( P ) ;
double NearestDistSqr ;
2022-06-24 14:08:36 -04:00
int32 NearTriID = ColliderMesh . FindNearestTriangle ( UseP , NearestDistSqr , IMeshSpatial : : FQueryOptions ( WindingShellThickness ) ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05: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)
FDistPoint3Triangle3d Query = TMeshQueries < FColliderMesh > : : TriangleDistance ( ColliderMesh , NearTriID , UseP ) ;
if ( Query . GetSquared ( ) < WindingShellThickness * WindingShellThickness )
{
return 1.0 ;
}
}
}
else
{
ensure ( false ) ; // not supported yet
}
return 0.0 ;
}
else
{
return bHasBakedTransform ?
FWNTree - > FastWindingNumber ( P ) :
FWNTree - > FastWindingNumber ( LocalToWorldTransform . InverseTransformPosition ( P ) ) ;
}
}
virtual bool RayIntersection ( const FRay3d & WorldRay , const FTransformSequence3d & LocalToWorldTransform , FMeshSceneRayHit & WorldHitResultOut ) override
{
FRay3d UseRay = WorldRay ;
if ( bHasBakedTransform = = false )
{
FVector3d LocalOrigin = LocalToWorldTransform . InverseTransformPosition ( WorldRay . Origin ) ;
FVector3d LocalDir = Normalized ( LocalToWorldTransform . InverseTransformPosition ( WorldRay . PointAt ( 1.0 ) ) - LocalOrigin ) ;
UseRay = FRay3d ( LocalOrigin , LocalDir ) ;
}
double RayHitT ; int32 HitTID ; FVector3d HitBaryCoords ;
2022-06-24 14:08:36 -04:00
if ( ColliderMesh . FindNearestHitTriangle ( UseRay , RayHitT , HitTID , HitBaryCoords ) )
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
{
WorldHitResultOut . HitMeshTriIndex = HitTID ;
WorldHitResultOut . HitMeshSpatialWrapper = this ;
if ( bHasBakedTransform )
{
WorldHitResultOut . RayDistance = RayHitT ;
}
else
{
FVector3d WorldPos = LocalToWorldTransform . TransformPosition ( UseRay . PointAt ( RayHitT ) ) ;
WorldHitResultOut . RayDistance = WorldRay . GetParameter ( WorldPos ) ;
}
WorldHitResultOut . HitMeshBaryCoords = HitBaryCoords ;
return true ;
}
return false ;
}
virtual bool ProcessVerticesInWorld ( TFunctionRef < bool ( const FVector3d & ) > ProcessFunc , const FTransformSequence3d & LocalToWorldTransform ) override
{
bool bContinue = true ;
if ( bHasBakedTransform )
{
for ( int32 k = 0 ; k < ColliderMesh . VertexCount ( ) ; + + k )
{
bContinue = ProcessFunc ( ColliderMesh . GetVertex ( k ) ) ;
if ( ! bContinue )
{
break ;
}
}
}
else
{
for ( int32 k = 0 ; k < ColliderMesh . VertexCount ( ) ; + + k )
{
bContinue = ProcessFunc ( LocalToWorldTransform . TransformPosition ( ColliderMesh . GetVertex ( k ) ) ) ;
if ( ! bContinue )
{
break ;
}
}
}
return bContinue ;
}
virtual void AppendMesh ( FDynamicMesh3 & AppendTo , const FTransformSequence3d & TransformSeq ) override
{
// this is necessary because the Editor.AppendMesh function is not a template and explicitly takes a FTriangleMeshAdapterd
TMeshWrapperAdapterd < FColliderMesh > AdapterWrapper ( & ColliderMesh ) ;
FDynamicMeshEditor Editor ( & AppendTo ) ;
FMeshIndexMappings Mappings ;
if ( bHasBakedTransform )
{
Editor . AppendMesh ( & AdapterWrapper , Mappings ,
[ ] ( int , const FVector3d & Pos ) { return Pos ; } ) ;
}
else
{
Editor . AppendMesh ( & AdapterWrapper , Mappings ,
[ & ] ( int , const FVector3d & Pos ) { return TransformSeq . TransformPosition ( Pos ) ; } ) ;
}
}
} ;
2021-07-22 18:56:41 -04:00
/**
* Utility function for handling static mesh material queries
*/
static int32 GetStaticMeshMaterialIndexFromSlotName ( UStaticMesh * StaticMesh , FName MaterialSlotName , bool bFallbackToSlot0OnFailure )
{
const TArray < FStaticMaterial > & StaticMaterials = StaticMesh - > GetStaticMaterials ( ) ;
int32 NumMaterials = StaticMaterials . Num ( ) ;
// search primary slot names first
for ( int32 MaterialIndex = 0 ; MaterialIndex < NumMaterials ; + + MaterialIndex )
{
const FStaticMaterial & StaticMaterial = StaticMaterials [ MaterialIndex ] ;
if ( StaticMaterial . MaterialSlotName = = MaterialSlotName )
{
return MaterialIndex ;
}
}
// sometimes we are given the ImportedSlotName
for ( int32 MaterialIndex = 0 ; MaterialIndex < NumMaterials ; + + MaterialIndex )
{
const FStaticMaterial & StaticMaterial = StaticMaterials [ MaterialIndex ] ;
if ( StaticMaterial . ImportedMaterialSlotName = = MaterialSlotName )
{
return MaterialIndex ;
}
}
return ( bFallbackToSlot0OnFailure & & NumMaterials > 0 ) ? 0 : INDEX_NONE ;
}
static UMaterialInterface * GetStaticMeshMaterialFromSlotName ( UStaticMesh * StaticMesh , FName MaterialSlotName , bool bFallbackToSlot0OnFailure )
{
int32 MaterialIndex = GetStaticMeshMaterialIndexFromSlotName ( StaticMesh , MaterialSlotName , bFallbackToSlot0OnFailure ) ;
if ( MaterialIndex > INDEX_NONE )
{
UMaterialInterface * MaterialInterface = StaticMesh - > GetMaterial ( MaterialIndex ) ;
return ( MaterialInterface ! = nullptr ) ? MaterialInterface : UMaterial : : GetDefaultMaterial ( MD_Surface ) ;
}
else
{
return UMaterial : : GetDefaultMaterial ( MD_Surface ) ;
}
}
2021-06-21 16:33:20 -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 :
2021-08-30 14:32:11 -04:00
FMeshDescriptionTriangleMeshSurfaceAdapter ( const FMeshDescription * MeshIn , UStaticMesh * StaticMeshIn , bool bOnlySurfaceMaterials )
2021-06-21 16:33:20 -04:00
: 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-08-30 14:32:11 -04:00
if ( bOnlySurfaceMaterials )
2021-06-21 16:33:20 -04:00
{
2021-08-30 14:32:11 -04:00
for ( FPolygonGroupID PolygonGroupID : MeshIn - > PolygonGroups ( ) . GetElementIDs ( ) )
2021-06-21 16:33:20 -04:00
{
2021-08-30 14:32:11 -04:00
// Try to find correct material index for the slot name in the MeshDescription.
// Sometimes this data is wrong, in that case fall back to slot 0
FName MaterialSlotName = MaterialSlotNames [ PolygonGroupID ] ;
int32 MaterialIndex = GetStaticMeshMaterialIndexFromSlotName ( StaticMeshIn , MaterialSlotName , true ) ;
UMaterialInterface * MaterialInterface = GetStaticMeshMaterialFromSlotName ( StaticMeshIn , MaterialSlotName , true ) ;
const UMaterial * Material = MaterialInterface ! = nullptr ? MaterialInterface - > GetMaterial_Concurrent ( ) : nullptr ;
bool bValidPolyGroup = Material ! = nullptr & & Material - > MaterialDomain = = EMaterialDomain : : MD_Surface ;
if ( bValidPolyGroup )
{
ValidPolyGroups . Add ( PolygonGroupID ) ;
NumValidTriangles + = MeshIn - > GetNumPolygonGroupTriangles ( PolygonGroupID ) ;
}
else
{
bHasInvalidPolyGroup = true ;
}
2021-06-21 16:33:20 -04:00
}
}
}
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 ;
} ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
/**
* Extension of Mesh adapter for StaticMesh LODResources ( ie LOD0 rendering mesh ) to filter out all mesh sections that
* are using materials for which the material domain isn ' t " Surface " . This excludes decals for example .
*/
struct FStaticMeshLODResourcesMeshSurfaceAdapter : public FStaticMeshLODResourcesMeshAdapter
2021-06-21 16:33:20 -04:00
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
FStaticMeshLODResourcesMeshSurfaceAdapter ( const FStaticMeshLODResources * MeshIn , UStaticMesh * StaticMeshIn , bool bOnlySurfaceMaterials )
2021-06-21 16:33:20 -04:00
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
this - > Mesh = MeshIn ;
this - > NumTriangles = 0 ;
TriangleOffsetArray . Reserve ( MeshIn - > Sections . Num ( ) + 1 ) ;
ValidSections . Reserve ( MeshIn - > Sections . Num ( ) ) ;
for ( const FStaticMeshSection & Section : MeshIn - > Sections )
{
auto IsValidMaterial = [ StaticMeshIn , Section ] ( )
{
UMaterialInterface * MaterialInterface = StaticMeshIn - > GetMaterial ( Section . MaterialIndex ) ;
const UMaterial * Material = MaterialInterface ! = nullptr ? MaterialInterface - > GetMaterial_Concurrent ( ) : nullptr ;
return Material ! = nullptr & & Material - > MaterialDomain = = EMaterialDomain : : MD_Surface ;
} ;
bool bIsValidMaterial = bOnlySurfaceMaterials ? IsValidMaterial ( ) : true ;
if ( bIsValidMaterial )
{
2022-05-17 10:15:02 -04:00
TriangleOffsetArray . Add ( NumTriangles ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
NumTriangles + = Section . NumTriangles ;
ValidSections . Add ( & Section ) ;
}
}
2022-05-17 10:15:02 -04:00
TriangleOffsetArray . Add ( NumTriangles ) ;
2021-06-21 16:33:20 -04:00
}
} ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
/**
* TStaticMeshSpatialWrapperBase is an IMeshSpatialWrapper implementation that can be used
* with various different mesh adapter types , depending on whether the " source " mesh or built / render
* mesh should be used . This is an abstract base class , calling code should use FStaticMeshSourceDataSpatialWrapper
* or FStaticMeshRenderDataSpatialWrapper as needed
*/
template < class MeshAdapterType >
class TStaticMeshSpatialWrapperBase : public IMeshSpatialWrapper
2021-04-28 16:17:03 -04:00
{
public :
UStaticMesh * StaticMesh = nullptr ;
int32 LODIndex = 0 ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
TUniquePtr < MeshAdapterType > 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
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
TUniquePtr < TMeshAABBTree3 < MeshAdapterType > > AABBTree ;
TUniquePtr < TFastWindingTree < MeshAdapterType > > FWNTree ;
2021-06-21 16:33:20 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
/**
* Create the MeshAdapterType instance based on the build options and source mesh .
* Subclasses must implement this function .
*/
virtual TUniquePtr < MeshAdapterType > MakeMeshAdapter ( const FMeshSceneAdapterBuildOptions & BuildOptions ) = 0 ;
2022-02-07 16:33:45 -05: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:33:20 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
Adapter = MakeMeshAdapter ( BuildOptions ) ;
if ( ! Adapter )
2021-07-13 16:09:21 -04:00
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return false ;
2021-04-28 16:17:03 -04:00
}
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( BuildOptions . bBuildSpatialDataStructures )
{
{
TRACE_CPUPROFILER_EVENT_SCOPE ( MeshScene_WrapperBuild_StaticMesh_AABBTree ) ;
AABBTree = MakeUnique < TMeshAABBTree3 < MeshAdapterType > > ( Adapter . Get ( ) , true ) ;
}
{
TRACE_CPUPROFILER_EVENT_SCOPE ( MeshScene_WrapperBuild_StaticMesh_FWNTree ) ;
FWNTree = MakeUnique < TFastWindingTree < MeshAdapterType > > ( AABBTree . Get ( ) , true ) ;
}
}
return true ;
2021-04-28 16:17:03 -04:00
}
2021-11-02 13:58:07 -04:00
virtual int32 GetTriangleCount ( ) const override
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
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return Adapter ? Adapter - > TriangleCount ( ) : 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
}
2021-09-13 17:51:19 -04:00
virtual bool IsTriangle ( int32 TriId ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return Adapter ? Adapter - > IsTriangle ( TriId ) : false ;
2021-09-13 17:51:19 -04:00
}
virtual FIndex3i GetTriangle ( int32 TriId ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return Adapter ? Adapter - > GetTriangle ( TriId ) : FIndex3i : : Invalid ( ) ;
2021-09-13 17:51:19 -04:00
}
virtual bool HasNormals ( ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return Adapter ? Adapter - > HasNormals ( ) : false ;
2021-09-13 17:51:19 -04:00
}
virtual bool HasUVs ( const int UVLayer = 0 ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return Adapter ? Adapter - > HasUVs ( UVLayer ) : false ;
2021-09-13 17:51:19 -04:00
}
virtual FVector3d TriBaryInterpolatePoint ( int32 TriId , const FVector3d & BaryCoords ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( Adapter )
2021-09-13 17:51:19 -04:00
{
FVector3d P0 , P1 , P2 ;
Adapter - > GetTriVertices ( TriId , P0 , P1 , P2 ) ;
return BaryCoords [ 0 ] * P0 + BaryCoords [ 1 ] * P1 + BaryCoords [ 2 ] * P2 ;
}
return FVector3d : : Zero ( ) ;
}
virtual bool TriBaryInterpolateNormal ( int32 TriId , const FVector3d & BaryCoords , FVector3f & NormalOut ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( Adapter & & Adapter - > HasNormals ( ) )
2021-09-13 17:51:19 -04:00
{
FIndex3i VertIds = Adapter - > GetTriangle ( TriId ) ;
FVector3f N0 , N1 , N2 ;
Adapter - > GetTriNormals ( TriId , N0 , N1 , N2 ) ;
NormalOut = ( float ) BaryCoords [ 0 ] * N0 + ( float ) BaryCoords [ 1 ] * N1 + ( float ) BaryCoords [ 2 ] * N2 ;
return true ;
}
return false ;
}
virtual bool TriBaryInterpolateUV ( const int32 TriId , const FVector3d & BaryCoords , const int UVLayer , FVector2f & UVOut ) const override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( Adapter & & Adapter - > HasUVs ( UVLayer ) )
2021-09-13 17:51:19 -04:00
{
FVector2f UV0 , UV1 , UV2 ;
Adapter - > GetTriUVs ( TriId , UVLayer , UV0 , UV1 , UV2 ) ;
UVOut = ( float ) BaryCoords [ 0 ] * UV0 + ( float ) BaryCoords [ 1 ] * UV1 + ( float ) BaryCoords [ 2 ] * UV2 ;
return true ;
}
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 FAxisAlignedBox3d GetWorldBounds ( TFunctionRef < FVector3d ( const FVector3d & ) > LocalToWorldFunc ) override
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( ! Adapter ) return FAxisAlignedBox3d : : Empty ( ) ;
return GetTransformedVertexBounds < MeshAdapterType > ( * 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
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( ! Adapter ) return ;
CollectSeedPointsFromMeshVertices < MeshAdapterType > ( * 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
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return ( Adapter ) ? FWNTree - > FastWindingNumber ( LocalToWorldTransform . InverseTransformPosition ( P ) ) : 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
}
2021-08-03 19:56:54 -04:00
virtual bool RayIntersection ( const FRay3d & WorldRay , const FTransformSequence3d & LocalToWorldTransform , FMeshSceneRayHit & WorldHitResultOut ) override
{
FVector3d LocalOrigin = LocalToWorldTransform . InverseTransformPosition ( WorldRay . Origin ) ;
FVector3d LocalDir = Normalized ( LocalToWorldTransform . InverseTransformPosition ( WorldRay . PointAt ( 1.0 ) ) - LocalOrigin ) ;
FRay3d LocalRay ( LocalOrigin , LocalDir ) ;
2021-09-13 17:51:19 -04:00
double LocalHitT ; int32 HitTID ; FVector3d HitBaryCoords ;
if ( AABBTree - > FindNearestHitTriangle ( LocalRay , LocalHitT , HitTID , HitBaryCoords ) )
2021-08-03 19:56:54 -04:00
{
WorldHitResultOut . HitMeshTriIndex = HitTID ;
WorldHitResultOut . HitMeshSpatialWrapper = this ;
FVector3d WorldPos = LocalToWorldTransform . TransformPosition ( LocalRay . PointAt ( LocalHitT ) ) ;
2021-11-17 21:06:46 -05:00
WorldHitResultOut . RayDistance = WorldRay . GetParameter ( WorldPos ) ;
2021-09-13 17:51:19 -04:00
WorldHitResultOut . HitMeshBaryCoords = HitBaryCoords ;
2021-08-03 19:56:54 -04:00
return true ;
}
return false ;
}
2021-08-31 23:26:49 -04:00
virtual bool ProcessVerticesInWorld ( TFunctionRef < bool ( const FVector3d & ) > ProcessFunc , const FTransformSequence3d & LocalToWorldTransform ) override
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-08-31 23:26:49 -04:00
bool bContinue = true ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
int32 NumVertices = ( Adapter ) ? Adapter - > VertexCount ( ) : 0 ;
2021-08-31 23:26:49 -04:00
for ( int32 vi = 0 ; vi < NumVertices & & bContinue ; + + 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 ) )
{
2021-08-31 23:26:49 -04:00
bContinue = ProcessFunc ( LocalToWorldTransform . TransformPosition ( Adapter - > GetVertex ( vi ) ) ) ;
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
}
2021-08-31 23:26:49 -04:00
return bContinue ;
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
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( ! Adapter ) return ;
2021-06-08 02:55:00 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
// TODO: need to move this to FStaticMeshSourceDataSpatialWrapper?
//#if WITH_EDITOR
// // 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)
// {
// // 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
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
FDynamicMeshEditor Editor ( & AppendTo ) ;
FMeshIndexMappings Mappings ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
// this is necessary because the Editor.AppendMesh function is not a template and explicitly takes a FTriangleMeshAdapterd
TMeshWrapperAdapterd < MeshAdapterType > AdapterWrapper ( Adapter . Get ( ) ) ;
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
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
class FStaticMeshSourceDataSpatialWrapper : public TStaticMeshSpatialWrapperBase < FMeshDescriptionTriangleMeshSurfaceAdapter >
2021-04-28 16:17:03 -04:00
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
public :
FMeshDescription * CachedSourceMeshDescription = nullptr ;
2021-06-21 16:33:20 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
virtual ~ FStaticMeshSourceDataSpatialWrapper ( )
{
# if WITH_EDITOR
// Release any MeshDescriptions that were loaded. This is potentially not ideal and should probably be controlled by the build options...
if ( CachedSourceMeshDescription ! = nullptr )
2021-04-28 16:17:03 -04:00
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
CachedSourceMeshDescription = nullptr ;
StaticMesh - > ClearMeshDescriptions ( ) ;
}
# endif
}
virtual TUniquePtr < FMeshDescriptionTriangleMeshSurfaceAdapter > MakeMeshAdapter ( const FMeshSceneAdapterBuildOptions & BuildOptions ) override
{
# if WITH_EDITOR
CachedSourceMeshDescription = StaticMesh - > GetMeshDescription ( LODIndex ) ;
2022-04-28 01:59:21 -04:00
TUniquePtr < FMeshDescriptionTriangleMeshSurfaceAdapter > SurfaceAdapter = MakeUnique < FMeshDescriptionTriangleMeshSurfaceAdapter > ( CachedSourceMeshDescription , StaticMesh , BuildOptions . bOnlySurfaceMaterials ) ;
const FMeshBuildSettings & LODBuildSettings = StaticMesh - > GetSourceModel ( LODIndex ) . BuildSettings ;
SurfaceAdapter - > SetBuildScale ( LODBuildSettings . BuildScale3D , false ) ;
return SurfaceAdapter ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
# else
// cannot use this path in non-editor builds, but this should have been handled higher up by instantiating
// the runtime subclass
check ( false ) ;
return nullptr ;
# endif
}
} ;
class FStaticMeshRenderDataSpatialWrapper : public TStaticMeshSpatialWrapperBase < FStaticMeshLODResourcesMeshSurfaceAdapter >
{
public :
virtual TUniquePtr < FStaticMeshLODResourcesMeshSurfaceAdapter > MakeMeshAdapter ( const FMeshSceneAdapterBuildOptions & BuildOptions ) override
{
2023-03-24 12:15:06 -04:00
return MakeUnique < FStaticMeshLODResourcesMeshSurfaceAdapter > ( StaticMesh - > GetRenderData ( ) - > GetCurrentFirstLOD ( 0 ) , StaticMesh , BuildOptions . bOnlySurfaceMaterials ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
}
} ;
/**
* FCompressedStaticMeshSpatialWrapper mirrors the behavior of FStaticMeshSourceDataSpatialWrapper , but instead of
* using the underlying MeshDescription directly , it copies the mesh into a minimal indexed mesh ( vert list and indexed tris )
* and then releases the MeshDescription memory . This is useful to limit the total memory usage of the MeshSceneAdapter
* in cases where only certain queries are needed . In particular , the UV and Normal queries
* are not available with this MeshSpatialWrapper .
*/
class FCompressedStaticMeshSpatialWrapper : public IMeshSpatialWrapper
{
public :
UStaticMesh * StaticMesh = nullptr ;
FColliderMesh ColliderMesh ;
TUniquePtr < TMeshAABBTree3 < FColliderMesh > > AABBTree ;
TUniquePtr < TFastWindingTree < FColliderMesh > > FWNTree ;
virtual bool Build ( const FMeshSceneAdapterBuildOptions & BuildOptions ) override
{
// this is because Build() will be called twice
if ( ColliderMesh . TriangleCount ( ) = = 0 )
{
TUniquePtr < FStaticMeshSourceDataSpatialWrapper > TempWrapper = MakeUnique < FStaticMeshSourceDataSpatialWrapper > ( ) ;
TempWrapper - > SourceContainer = SourceContainer ;
TempWrapper - > StaticMesh = StaticMesh ;
FMeshSceneAdapterBuildOptions TempBuildOptions ;
TempBuildOptions . bBuildSpatialDataStructures = false ; // we are just copying from this so do not build spatials
TempWrapper - > Build ( TempBuildOptions ) ;
FDynamicMesh3 TempMesh ( EMeshComponents : : None ) ;
TempWrapper - > AppendMesh ( TempMesh , FTransformSequence3d ( ) ) ;
# if WITH_EDITOR
// dump mesh description memory
StaticMesh - > ClearMeshDescriptions ( ) ;
# endif
FColliderMesh : : FBuildOptions ColliderBuildOptions ;
ColliderBuildOptions . bBuildAABBTree = false ; // will use our own AABBTree so that we can defer build
ColliderMesh . Initialize ( TempMesh , ColliderBuildOptions ) ;
}
if ( BuildOptions . bBuildSpatialDataStructures )
{
{
TRACE_CPUPROFILER_EVENT_SCOPE ( MeshScene_WrapperBuild_StaticMeshCompressed_AABBTree ) ;
AABBTree = MakeUnique < TMeshAABBTree3 < FColliderMesh > > ( & ColliderMesh , true ) ;
}
{
TRACE_CPUPROFILER_EVENT_SCOPE ( MeshScene_WrapperBuild_StaticMeshCompressed_FWNTree ) ;
FWNTree = MakeUnique < TFastWindingTree < FColliderMesh > > ( AABBTree . Get ( ) , true ) ;
}
}
return true ;
}
virtual int32 GetTriangleCount ( ) const override
{
return ColliderMesh . TriangleCount ( ) ;
}
virtual bool IsTriangle ( int32 TriId ) const override
{
return ColliderMesh . IsTriangle ( TriId ) ;
}
virtual FIndex3i GetTriangle ( int32 TriId ) const override
{
return ColliderMesh . GetTriangle ( TriId ) ;
}
virtual bool HasNormals ( ) const override { return false ; }
virtual bool HasUVs ( const int UVLayer = 0 ) const override { return false ; }
virtual FVector3d TriBaryInterpolatePoint ( int32 TriId , const FVector3d & BaryCoords ) const override { check ( false ) ; return FVector3d : : Zero ( ) ; }
virtual bool TriBaryInterpolateNormal ( int32 TriId , const FVector3d & BaryCoords , FVector3f & NormalOut ) const override { check ( false ) ; return false ; }
virtual bool TriBaryInterpolateUV ( const int32 TriId , const FVector3d & BaryCoords , const int UVLayer , FVector2f & UVOut ) const override { check ( false ) ; return false ; }
virtual FAxisAlignedBox3d GetWorldBounds ( TFunctionRef < FVector3d ( const FVector3d & ) > LocalToWorldFunc ) override
{
return GetTransformedVertexBounds < FColliderMesh > ( ColliderMesh , LocalToWorldFunc ) ;
}
virtual void CollectSeedPoints ( TArray < FVector3d > & WorldPoints , TFunctionRef < FVector3d ( const FVector3d & ) > LocalToWorldFunc ) override
{
CollectSeedPointsFromMeshVertices < FColliderMesh > ( ColliderMesh , LocalToWorldFunc , WorldPoints ) ;
}
virtual double FastWindingNumber ( const FVector3d & P , const FTransformSequence3d & LocalToWorldTransform ) override
{
return FWNTree - > FastWindingNumber ( LocalToWorldTransform . InverseTransformPosition ( P ) ) ;
}
virtual bool RayIntersection ( const FRay3d & WorldRay , const FTransformSequence3d & LocalToWorldTransform , FMeshSceneRayHit & WorldHitResultOut ) override
{
FVector3d LocalOrigin = LocalToWorldTransform . InverseTransformPosition ( WorldRay . Origin ) ;
FVector3d LocalDir = Normalized ( LocalToWorldTransform . InverseTransformPosition ( WorldRay . PointAt ( 1.0 ) ) - LocalOrigin ) ;
FRay3d LocalRay ( LocalOrigin , LocalDir ) ;
double LocalHitT ; int32 HitTID ; FVector3d HitBaryCoords ;
if ( AABBTree - > FindNearestHitTriangle ( LocalRay , LocalHitT , HitTID , HitBaryCoords ) )
{
WorldHitResultOut . HitMeshTriIndex = HitTID ;
WorldHitResultOut . HitMeshSpatialWrapper = this ;
FVector3d WorldPos = LocalToWorldTransform . TransformPosition ( LocalRay . PointAt ( LocalHitT ) ) ;
WorldHitResultOut . RayDistance = WorldRay . GetParameter ( WorldPos ) ;
WorldHitResultOut . HitMeshBaryCoords = HitBaryCoords ;
return true ;
}
return false ;
}
virtual bool ProcessVerticesInWorld ( TFunctionRef < bool ( const FVector3d & ) > ProcessFunc , const FTransformSequence3d & LocalToWorldTransform ) override
{
bool bContinue = true ;
int32 NumVertices = ColliderMesh . VertexCount ( ) ;
for ( int32 vi = 0 ; vi < NumVertices & & bContinue ; + + vi )
{
if ( ColliderMesh . IsVertex ( vi ) )
{
bContinue = ProcessFunc ( LocalToWorldTransform . TransformPosition ( ColliderMesh . GetVertex ( vi ) ) ) ;
}
}
return bContinue ;
}
virtual void AppendMesh ( FDynamicMesh3 & AppendTo , const FTransformSequence3d & TransformSeq ) override
{
TArray < int32 > NewVertIDs ;
NewVertIDs . SetNum ( ColliderMesh . VertexCount ( ) ) ;
for ( int32 k = 0 ; k < ColliderMesh . VertexCount ( ) ; + + k )
{
NewVertIDs [ k ] = AppendTo . AppendVertex ( ColliderMesh . GetVertex ( k ) ) ;
}
for ( int32 k = 0 ; k < ColliderMesh . TriangleCount ( ) ; + + k )
{
FIndex3i Tri = ColliderMesh . GetTriangle ( k ) ;
AppendTo . AppendTriangle ( NewVertIDs [ Tri . A ] , NewVertIDs [ Tri . B ] , NewVertIDs [ Tri . C ] ) ;
2021-04-28 16:17:03 -04:00
}
}
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
} ;
static TUniquePtr < IMeshSpatialWrapper > SpatialWrapperFactory ( const FMeshTypeContainer & MeshContainer , const FMeshSceneAdapterBuildOptions & BuildOptions )
{
if ( MeshContainer . MeshType = = ESceneMeshType : : StaticMeshAsset )
{
2022-04-28 01:59:21 -04:00
UStaticMesh * StaticMesh = MeshContainer . GetStaticMesh ( ) ;
if ( ensure ( StaticMesh ! = nullptr ) )
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
# if WITH_EDITOR
2022-04-28 01:59:21 -04:00
bool bUseRenderMeshes = BuildOptions . bIgnoreStaticMeshSourceData | | StaticMesh - > GetOutermost ( ) - > bIsCookedForEditor ;
2021-06-21 16:33:20 -04:00
# else
2022-04-28 01:59:21 -04:00
bool bUseRenderMeshes = true ;
2021-06-21 16:33:20 -04:00
# endif
2021-04-28 16:17:03 -04:00
2022-04-28 01:59:21 -04:00
if ( bUseRenderMeshes )
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
{
2022-04-28 01:59:21 -04:00
TUniquePtr < FStaticMeshRenderDataSpatialWrapper > SMWrapper = MakeUnique < FStaticMeshRenderDataSpatialWrapper > ( ) ;
SMWrapper - > SourceContainer = MeshContainer ;
SMWrapper - > StaticMesh = StaticMesh ;
return SMWrapper ;
}
else if ( BuildOptions . bEnableUVQueries = = false & & BuildOptions . bEnableNormalsQueries = = false )
{
TUniquePtr < FCompressedStaticMeshSpatialWrapper > SMWrapper = MakeUnique < FCompressedStaticMeshSpatialWrapper > ( ) ;
SMWrapper - > SourceContainer = MeshContainer ;
SMWrapper - > StaticMesh = StaticMesh ;
return SMWrapper ;
}
else
{
TUniquePtr < FStaticMeshSourceDataSpatialWrapper > SMWrapper = MakeUnique < FStaticMeshSourceDataSpatialWrapper > ( ) ;
SMWrapper - > SourceContainer = MeshContainer ;
SMWrapper - > StaticMesh = StaticMesh ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
return SMWrapper ;
}
}
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
return TUniquePtr < IMeshSpatialWrapper > ( ) ;
2021-04-28 16:17:03 -04:00
}
2021-08-03 19:56:54 -04:00
static void CollectComponentChildMeshes ( UActorComponent * Component , FActorAdapter & Adapter )
2021-04-28 16:17:03 -04:00
{
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-08-26 09:31:28 -04:00
} // end namespace UE
} // end namespace Geometry
2021-06-15 02:47:39 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05: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 ;
2021-08-03 19:56:54 -04:00
TArray < FActorAdapter * > NewActorAdapters ;
2021-04-28 16:17:03 -04:00
for ( AActor * Actor : ActorsSetIn )
{
TUniquePtr < FActorAdapter > Adapter = MakeUnique < FActorAdapter > ( ) ;
Adapter - > SourceActor = Actor ;
for ( UActorComponent * Component : Actor - > GetComponents ( ) )
{
2021-08-03 19:56:54 -04:00
CollectComponentChildMeshes ( Component , * Adapter ) ;
2021-04-28 16:17:03 -04:00
}
ChildActors . Reset ( ) ;
Actor - > GetAllChildActors ( ChildActors , true ) ;
for ( AActor * ChildActor : ChildActors )
{
for ( UActorComponent * Component : ChildActor - > GetComponents ( ) )
{
2021-08-03 19:56:54 -04:00
CollectComponentChildMeshes ( Component , * Adapter ) ;
2021-04-28 16:17:03 -04:00
}
}
2021-08-03 19:56:54 -04:00
NewActorAdapters . Add ( Adapter . Get ( ) ) ;
2021-04-28 16:17:03 -04:00
SceneActors . Add ( MoveTemp ( Adapter ) ) ;
}
2021-08-03 19:56:54 -04:00
InitializeSpatialWrappers ( NewActorAdapters ) ;
}
2021-04-28 16:17:03 -04:00
2021-08-03 19:56:54 -04:00
void FMeshSceneAdapter : : AddComponents ( const TArray < UActorComponent * > & ComponentSetIn )
{
// Build an FActorAdapter for each Component. This may result in multiple FActorAdapters
// for a single AActor, this is currently not a problem
TArray < FActorAdapter * > NewActorAdapters ;
for ( UActorComponent * Component : ComponentSetIn )
{
TUniquePtr < FActorAdapter > Adapter = MakeUnique < FActorAdapter > ( ) ;
Adapter - > SourceActor = Component - > GetOwner ( ) ;
CollectComponentChildMeshes ( Component , * Adapter ) ;
if ( Adapter - > ChildMeshes . Num ( ) > 0 )
{
NewActorAdapters . Add ( Adapter . Get ( ) ) ;
SceneActors . Add ( MoveTemp ( Adapter ) ) ;
}
}
InitializeSpatialWrappers ( NewActorAdapters ) ;
}
void FMeshSceneAdapter : : InitializeSpatialWrappers ( const TArray < FActorAdapter * > & NewItemsToProcess )
{
2021-04-28 16:17:03 -04:00
// 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
2021-08-03 19:56:54 -04:00
for ( FActorAdapter * Actor : NewItemsToProcess )
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
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 ) ;
2021-10-28 19:47:45 -04:00
FSpatialWrapperInfo * MeshInfo ;
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 ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
NewWrapperInfo - > SpatialWrapper = nullptr ; // these are now initialized at beginning of Build() function
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 = 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 + + ;
}
2022-02-14 18:33:21 -05:00
ChildMesh - > MeshSpatial = nullptr ; // these are now initialized at beginning of Build() function
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 ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
// Initialize all Spatial Wrappers using the default factory
for ( TPair < void * , TSharedPtr < FSpatialWrapperInfo > > Pair : SpatialAdapters )
{
Pair . Value - > SpatialWrapper = SpatialWrapperFactory ( Pair . Value - > SourceContainer , BuildOptions ) ;
2022-02-14 18:33:21 -05:00
// populate the MeshSpatial members of the FActorChildMeshes
for ( FActorChildMesh * ParentMesh : Pair . Value - > ParentMeshes )
{
ParentMesh - > MeshSpatial = Pair . Value - > SpatialWrapper . Get ( ) ;
}
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
}
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 )
{
2021-08-30 14:32:11 -04:00
UE_LOG ( LogGeometry , Warning , TEXT ( " [FMeshSceneAdapter] decomposed %d source meshes into %d unique meshes containing %d triangles " ) , DecomposedSourceMeshCount . load ( ) , DecomposedMeshesCount . load ( ) , AddedTrisCount )
2021-05-20 19:35:43 -04:00
}
}
// 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:39 -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
2022-01-29 14:37:53 -05:00
auto CompareScales = [ ScaleComponentTolerance ] ( const FTransformSRT3d & T1 , const FTransformSRT3d & T2 )
2021-06-08 02:55:00 -04:00
{
return ( T1 . GetScale ( ) - T2 . GetScale ( ) ) . GetAbsMax ( ) < ScaleComponentTolerance ;
} ;
2021-06-15 02:47:39 -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:39 -04:00
for ( int32 j = 0 ; j < UniqueScaleTransformsOut . Num ( ) ; + + j )
2021-06-08 02:55:00 -04:00
{
2021-06-15 02:47:39 -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:39 -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:39 -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-07-22 18:56:41 -04:00
EParallelForFlags ParallelFlags = ( CVarMeshSceneAdapterDisableMultiThreading . GetValueOnAnyThread ( ) ! = 0 ) ?
EParallelForFlags : : ForceSingleThread : EParallelForFlags : : Unbalanced ;
2021-06-15 02:47:39 -04:00
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
bool bCanUseCompressedMeshes = ( BuildOptions . bEnableUVQueries = = false & & BuildOptions . bEnableNormalsQueries = = false ) ;
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:39 -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:39 -04:00
int32 NumSourceUniqueTris = 0 ;
2021-06-08 02:55:00 -04:00
std : : atomic < int32 > DecomposedSourceMeshCount = 0 ;
std : : atomic < int32 > SourceInstancesCount = 0 ;
std : : atomic < int32 > NewInstancesCount = 0 ;
2021-07-13 16:09:21 -04:00
std : : atomic < int32 > NewUniqueMeshesCount = 0 ;
2021-06-08 02:55:00 -04:00
std : : atomic < int32 > SkippedDecompositionCount = 0 ;
2021-06-15 02:47:39 -04:00
std : : atomic < int32 > SingleTriangleMeshes = 0 ;
2021-07-13 16:09:21 -04:00
std : : atomic < int32 > NumFinalUniqueTris = 0 ;
2021-06-08 02:55:00 -04:00
int32 AddedUniqueTrisCount = 0 ;
int32 InstancedTrisCount = 0 ;
2021-06-15 02:47:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -04:00
} , ParallelFlags ) ;
2021-05-20 19:35:43 -04:00
}
2021-06-15 02:47:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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:39 -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
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
int32 LocalSpacePartsTriangleCount = LocalSpaceParts . TriangleCount ( ) ;
if ( LocalSpacePartsTriangleCount > 0 )
2021-05-20 19:35:43 -04:00
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
if ( bCanUseCompressedMeshes )
{
WrapperInfo - > SpatialWrapper = MakeUnique < FCompressedMeshSpatialWrapper > ( MoveTemp ( LocalSpaceParts ) ) ;
}
else
{
WrapperInfo - > SpatialWrapper = MakeUnique < FDynamicMeshSpatialWrapper > ( MoveTemp ( LocalSpaceParts ) ) ;
}
AddBuildJob ( WrapperInfo - > SpatialWrapper . Get ( ) , LocalSpacePartsTriangleCount ) ;
2021-05-20 19:35:43 -04:00
for ( FActorChildMesh * MeshInstance : MeshesToDecompose )
{
MeshInstance - > MeshSpatial = WrapperInfo - > SpatialWrapper . Get ( ) ;
}
2021-07-13 16:09:21 -04:00
InternalListsLock . Lock ( ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
InstancedTrisCount + = LocalSpacePartsTriangleCount * ParentTransforms . Num ( ) ;
2021-07-13 16:09:21 -04:00
InternalListsLock . Unlock ( ) ;
2021-05-20 19:35:43 -04:00
}
else
{
2022-02-14 18:33:21 -05:00
// disconnect parent meshes from this spatialwrapper as it is now invalid
2021-05-20 19:35:43 -04:00
for ( FActorChildMesh * MeshInstance : MeshesToDecompose )
{
MeshInstance - > MeshSpatial = nullptr ;
}
2022-02-14 18:33:21 -05:00
WrapperInfo - > ParentMeshes . Reset ( ) ;
2021-05-20 19:35:43 -04:00
}
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-07-13 16:09:21 -04:00
NewUniqueMeshesCount + + ;
2021-06-08 02:55:00 -04:00
TUniquePtr < FActorAdapter > NewActor = MakeUnique < FActorAdapter > ( ) ;
NewActor - > SourceActor = nullptr ; // not a "real" actor
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
int32 SubmeshTriangleCount = Submesh . Mesh - > TriangleCount ( ) ;
ensure ( SubmeshTriangleCount > 0 ) ;
2021-06-08 02:55:00 -04:00
// make new spatialwrapper for this instanced mesh
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
TUniquePtr < FBaseMeshSpatialWrapper > NewSpatialWrapper ;
if ( bCanUseCompressedMeshes )
{
NewSpatialWrapper = MakeUnique < FCompressedMeshSpatialWrapper > ( MoveTemp ( * Submesh . Mesh ) ) ;
}
else
{
NewSpatialWrapper = MakeUnique < FDynamicMeshSpatialWrapper > ( MoveTemp ( * Submesh . Mesh ) ) ;
}
// configure flags
NewSpatialWrapper - > bHasBakedTransform = false ;
NewSpatialWrapper - > bHasBakedScale = true ;
2021-06-08 02:55:00 -04:00
// if mesh is too thin, configure the extra shell offset based on 'missing' thickness
if ( Submesh . ComputedThickness < BuildOptions . DesiredMinThickness )
{
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
NewSpatialWrapper - > bUseDistanceShellForWinding = true ;
NewSpatialWrapper - > WindingShellThickness = 0.5 * ( BuildOptions . DesiredMinThickness - Submesh . ComputedThickness ) ;
NewSpatialWrapper - > bRequiresWindingQueryFallback = ( NewSpatialWrapper - > WindingShellThickness < 0.6 * BuildOptions . DesiredMinThickness ) ;
2021-06-08 02:55:00 -04:00
}
TSharedPtr < FSpatialWrapperInfo > NewWrapperInfo = MakeShared < FSpatialWrapperInfo > ( ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
NewWrapperInfo - > SpatialWrapper = MoveTemp ( NewSpatialWrapper ) ;
// queue up build job
AddBuildJob ( NewWrapperInfo - > SpatialWrapper . Get ( ) , SubmeshTriangleCount ) ;
2021-06-08 02:55:00 -04:00
// add to internal lists
InternalListsLock . Lock ( ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
AddedUniqueTrisCount + = SubmeshTriangleCount ;
InstancedTrisCount + = SubmeshTriangleCount * Submesh . NewTransforms . Num ( ) ;
2021-06-08 02:55:00 -04:00
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 + + ;
}
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
ItemStats . SubmeshSizeCount . Add ( FVector2i ( SubmeshTriangleCount , Submesh . NewTransforms . Num ( ) ) ) ;
2021-06-15 02:47:39 -04:00
ItemStats . NewInstances + = Submesh . NewTransforms . Num ( ) ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
ItemStats . NewUniqueTris + = SubmeshTriangleCount ;
ItemStats . TotalNumUniqueTris + = SubmeshTriangleCount ;
2021-06-15 02:47:39 -04:00
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-07-13 16:09:21 -04:00
NumFinalUniqueTris + = ItemStats . TotalNumUniqueTris ;
2021-06-15 02:47:39 -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:39 -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-08-30 14:32:11 -04:00
UE_LOG ( LogGeometry , Warning , TEXT ( " [FMeshSceneAdapter] decomposed %d source meshes used in %d instances (of %d total source meshes with %ld unique triangles), into %d new part meshes used in %d new instances containing %ld unique triangles. Scene has %ld total unique and %ld total instanced. Skipped %d decompositions. Skipped %d tiny components (%d instances, %d total triangles). %d 1-triangle meshes. " ) ,
2021-06-15 02:47:39 -04:00
DecomposedSourceMeshCount . load ( ) , SourceInstancesCount . load ( ) , NumInitialSources , NumSourceUniqueTris ,
2021-07-13 16:09:21 -04:00
NewUniqueMeshesCount . load ( ) , NewInstancesCount . load ( ) , AddedUniqueTrisCount ,
NumFinalUniqueTris . load ( ) , InstancedTrisCount ,
2021-06-15 02:47:39 -04:00
SkippedDecompositionCount . load ( ) ,
NumTinyComponents . load ( ) , NumTinyInstances . load ( ) , TinyInstanceTotalTriangles . load ( ) ,
SingleTriangleMeshes . load ( ) )
Stats . Sort ( [ ] ( const FProcessedSourceMeshStats & A , const FProcessedSourceMeshStats & B )
{
return A . NewUniqueTris > B . NewUniqueTris ;
} ) ;
2021-07-22 18:56:41 -04:00
for ( int32 k = 0 ; k < FMath : : Min ( Stats . Num ( ) , 20 ) ; + + k )
2021-06-15 02:47:39 -04:00
{
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-10-28 19:47:45 -04:00
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 ) ;
2022-02-14 18:33:21 -05:00
// validate that internals are correctly configured
for ( TPair < void * , TSharedPtr < FSpatialWrapperInfo > > Pair : SpatialAdapters )
{
FSpatialWrapperInfo & WrapperInfo = * Pair . Value ;
IMeshSpatialWrapper * SpatialWrapper = WrapperInfo . SpatialWrapper . Get ( ) ;
for ( FActorChildMesh * MeshInstance : WrapperInfo . ParentMeshes )
{
if ( ensure ( MeshInstance - > MeshSpatial = = SpatialWrapper ) = = false )
{
UE_LOG ( LogGeometry , Warning , TEXT ( " FMeshSceneAdapter::BuildSpatialEvaluationCache: broken MeshSpatial link found! " ) ) ;
}
}
}
2021-05-20 19:35:43 -04:00
// 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
2021-08-03 19:56:54 -04:00
bool FMeshSceneAdapter : : FindNearestRayIntersection ( const FRay3d & WorldRay , FMeshSceneRayHit & HitResultOut )
{
check ( bHaveSpatialEvaluationCache ) ; // must call BuildSpatialEvaluationCache() to build Octree
int32 HitObjectID = Octree - > FindNearestHitObject ( WorldRay ,
[ & ] ( int32 idx ) { return SortedSpatials [ idx ] . Bounds ; } ,
2021-10-28 19:47:45 -04:00
[ & ] ( int idx , const FRay3d & Ray ) {
2021-08-03 19:56:54 -04:00
FMeshSceneRayHit LocalHitResult ;
FSpatialCacheInfo & CacheInfo = SortedSpatials [ idx ] ;
2021-10-28 19:47:45 -04:00
if ( CacheInfo . Spatial - > RayIntersection ( Ray , CacheInfo . ChildMesh - > WorldTransform , LocalHitResult ) )
2021-08-03 19:56:54 -04:00
{
return LocalHitResult . RayDistance ;
}
return TNumericLimits < double > : : Max ( ) ;
} ) ;
if ( HitObjectID > = 0 )
{
FSpatialCacheInfo & CacheInfo = SortedSpatials [ HitObjectID ] ;
bool bHit = CacheInfo . Spatial - > RayIntersection ( WorldRay , CacheInfo . ChildMesh - > WorldTransform , HitResultOut ) ;
if ( ensure ( bHit ) )
{
HitResultOut . HitActor = CacheInfo . Actor - > SourceActor ;
HitResultOut . HitComponent = CacheInfo . ChildMesh - > SourceComponent ;
HitResultOut . HitComponentElementIndex = CacheInfo . ChildMesh - > ComponentIndex ;
HitResultOut . Ray = WorldRay ;
HitResultOut . LocalToWorld = CacheInfo . ChildMesh - > WorldTransform ;
return true ;
}
}
return false ;
}
void FMeshSceneAdapter : : FastUpdateTransforms ( bool bRebuildSpatialCache )
{
for ( TUniquePtr < FActorAdapter > & Actor : SceneActors )
{
for ( TUniquePtr < FActorChildMesh > & ChildMesh : Actor - > ChildMeshes )
{
ChildMesh - > WorldTransform = FTransformSequence3d ( ) ;
if ( ( ChildMesh - > ComponentType = = EActorMeshComponentType : : InstancedStaticMesh ) | |
( ChildMesh - > ComponentType = = EActorMeshComponentType : : HierarchicalInstancedStaticMesh ) )
{
UInstancedStaticMeshComponent * ISMComponent = Cast < UInstancedStaticMeshComponent > ( ChildMesh - > SourceComponent ) ;
if ( ISMComponent - > IsValidInstance ( ChildMesh - > ComponentIndex ) )
{
FTransform InstanceTransform ;
ISMComponent - > GetInstanceTransform ( ChildMesh - > ComponentIndex , InstanceTransform , true ) ;
ChildMesh - > WorldTransform . Append ( InstanceTransform ) ;
ChildMesh - > bIsNonUniformScaled = ChildMesh - > WorldTransform . HasNonUniformScale ( ) ;
}
}
else if ( ChildMesh - > ComponentType = = EActorMeshComponentType : : StaticMesh )
{
UStaticMeshComponent * StaticMeshComponent = Cast < UStaticMeshComponent > ( ChildMesh - > SourceComponent ) ;
ChildMesh - > WorldTransform . Append ( StaticMeshComponent - > GetComponentTransform ( ) ) ;
ChildMesh - > bIsNonUniformScaled = ChildMesh - > WorldTransform . HasNonUniformScale ( ) ;
}
}
}
// this cache is invalid now
bHaveSpatialEvaluationCache = false ;
// update bounding boxes for actors
{
TRACE_CPUPROFILER_EVENT_SCOPE ( MeshScene_FastUpdateTransforms_ActorBounds ) ;
ParallelFor ( SceneActors . Num ( ) , [ & ] ( int32 i )
{
UpdateActorBounds ( * SceneActors [ i ] ) ;
} ) ;
}
if ( bRebuildSpatialCache )
{
BuildSpatialEvaluationCache ( ) ;
}
}
void FMeshSceneAdapter : : GetMeshBoundingBoxes ( TArray < FAxisAlignedBox3d > & Bounds )
{
if ( bHaveSpatialEvaluationCache )
{
for ( FSpatialCacheInfo & CacheInfo : SortedSpatials )
{
Bounds . Add ( CacheInfo . Bounds ) ;
}
}
else
{
for ( const TUniquePtr < FActorAdapter > & Actor : SceneActors )
{
for ( const TUniquePtr < FActorChildMesh > & ChildMesh : Actor - > ChildMeshes )
{
if ( ChildMesh - > MeshSpatial ! = nullptr )
{
FAxisAlignedBox3d ChildBounds = ChildMesh - > MeshSpatial - > GetWorldBounds (
[ & ] ( const FVector3d & P ) { return ChildMesh - > WorldTransform . TransformPosition ( P ) ; } ) ;
Bounds . Add ( ChildBounds ) ;
}
}
}
}
}
FAxisAlignedBox3d FMeshSceneAdapter : : GetMeshBoundingBox ( UActorComponent * Component , int32 ComponentIndex )
{
// implementation below depends on the spatial cache
check ( bHaveSpatialEvaluationCache ) ;
for ( FSpatialCacheInfo & CacheInfo : SortedSpatials )
{
if ( CacheInfo . ChildMesh - > SourceComponent = = Component )
{
if ( ComponentIndex = = - 1 | | ComponentIndex = = CacheInfo . ChildMesh - > ComponentIndex )
{
return CacheInfo . Bounds ;
}
}
}
return FAxisAlignedBox3d ( FVector3d : : Zero ( ) , 1.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
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 ) ) ;
}
2021-08-31 23:26:49 -04:00
return 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
} , 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 ) ;
}
2021-08-26 16:59:59 -04:00
Offset . ExtrusionVectorType = FOffsetMeshRegion : : EVertexExtrusionVectorType : : SelectionTriNormalsAngleWeightedAverage ;
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
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
}
2021-08-31 23:26:49 -04:00
void FMeshSceneAdapter : : ParallelMeshVertexEnumeration (
TFunctionRef < bool ( int32 NumMeshes ) > InitializeFunc ,
TFunctionRef < bool ( int32 MeshIndex , AActor * SourceActor , const FActorChildMesh * ChildMeshInfo , const FAxisAlignedBox3d & WorldBounds ) > MeshFilterFunc ,
TFunctionRef < bool ( int32 MeshIndex , AActor * SourceActor , const FActorChildMesh * ChildMeshInfo , const FVector3d & WorldPos ) > PerVertexFunc ,
bool bForceSingleThreaded )
{
int32 N = SortedSpatials . Num ( ) ;
if ( InitializeFunc ( N ) = = false )
{
return ;
}
bool bSingleThread = bForceSingleThreaded | | ( CVarMeshSceneAdapterDisableMultiThreading . GetValueOnAnyThread ( ) ! = 0 ) ;
ParallelFor ( N , [ & ] ( int32 Index )
{
const FSpatialCacheInfo & CacheInfo = SortedSpatials [ Index ] ;
bool bContinue = MeshFilterFunc ( Index , CacheInfo . Actor - > SourceActor , CacheInfo . ChildMesh , CacheInfo . Bounds ) ;
if ( ! bContinue )
{
return ;
}
FTransformSequence3d WorldTransform = CacheInfo . ChildMesh - > WorldTransform ;
CacheInfo . Spatial - > ProcessVerticesInWorld ( [ & ] ( const FVector3d & WorldPos )
{
2021-10-28 19:47:45 -04:00
bContinue = PerVertexFunc ( Index , CacheInfo . Actor - > SourceActor , CacheInfo . ChildMesh , WorldPos ) ;
2021-08-31 23:26:49 -04:00
return bContinue ;
} , WorldTransform ) ;
} , bSingleThread ? EParallelForFlags : : ForceSingleThread : EParallelForFlags : : Unbalanced ) ;
2021-09-13 17:51:19 -04:00
}
void FMeshSceneAdapter : : ProcessActorChildMeshes ( TFunctionRef < void ( const FActorAdapter * ActorAdapter , const FActorChildMesh * ChildMesh ) > ProcessFunc )
{
for ( const TUniquePtr < FActorAdapter > & Actor : SceneActors )
{
if ( Actor )
{
for ( const TUniquePtr < FActorChildMesh > & ChildMesh : Actor - > ChildMeshes )
{
if ( ChildMesh )
{
ProcessFunc ( Actor . Get ( ) , ChildMesh . Get ( ) ) ;
}
}
}
}
}