2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2017-08-22 16:18:25 -04:00
# include "MeshDescription.h"
2021-11-18 14:37:34 -05:00
2019-10-04 13:11:45 -04:00
# include "Algo/Copy.h"
2021-11-18 14:37:34 -05:00
# include "MeshAttributes.h"
2019-10-04 13:11:45 -04:00
# include "Misc/SecureHash.h"
2021-10-25 20:05:28 -04:00
# include "Serialization/BulkData.h"
2021-11-18 14:37:34 -05:00
# include "Serialization/MemoryWriter.h"
2021-01-28 16:27:47 -04:00
# include "Serialization/NameAsStringProxyArchive.h"
2021-10-25 20:05:28 -04:00
# include "Serialization/VirtualizedBulkDataReader.h"
# include "Serialization/VirtualizedBulkDataWriter.h"
2019-10-04 13:11:45 -04:00
# include "UObject/EnterpriseObjectVersion.h"
2020-10-21 17:56:05 -04:00
# include "UObject/UE5CookerObjectVersion.h"
2020-09-23 12:12:34 -04:00
# include "UObject/UE5MainStreamObjectVersion.h"
2018-01-23 13:46:41 -05:00
2021-11-18 14:37:34 -05:00
# if WITH_EDITORONLY_DATA
# include "DerivedDataBuildVersion.h"
# endif
2020-10-22 10:35:43 -04:00
# if WITH_EDITOR
# include "Misc/ScopeRWLock.h"
# endif
2018-06-07 16:22:56 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
FName FMeshDescription : : VerticesName ( " Vertices " ) ;
FName FMeshDescription : : VertexInstancesName ( " VertexInstances " ) ;
FName FMeshDescription : : UVsName ( " UVs " ) ;
FName FMeshDescription : : EdgesName ( " Edges " ) ;
FName FMeshDescription : : TrianglesName ( " Triangles " ) ;
FName FMeshDescription : : PolygonsName ( " Polygons " ) ;
FName FMeshDescription : : PolygonGroupsName ( " PolygonGroups " ) ;
2018-06-07 16:22:56 -04:00
2018-06-18 08:47:01 -04:00
2019-10-01 20:41:42 -04:00
FMeshDescription : : FMeshDescription ( )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
Initialize ( ) ;
}
FMeshDescription : : FMeshDescription ( const FMeshDescription & Other )
{
Elements = Other . Elements ;
Cache ( ) ;
}
FMeshDescription & FMeshDescription : : operator = ( const FMeshDescription & Other )
{
if ( this ! = & Other )
{
Elements = Other . Elements ;
Cache ( ) ;
}
return * this ;
}
void FMeshDescription : : Initialize ( )
{
// Register the basic mesh element types
VertexElements = Elements . Emplace ( VerticesName ) . Get ( ) ;
VertexInstanceElements = Elements . Emplace ( VertexInstancesName ) . Get ( ) ;
UVElements = Elements . Emplace ( UVsName ) . Get ( ) ;
EdgeElements = Elements . Emplace ( EdgesName ) . Get ( ) ;
TriangleElements = Elements . Emplace ( TrianglesName ) . Get ( ) ;
PolygonElements = Elements . Emplace ( PolygonsName ) . Get ( ) ;
PolygonGroupElements = Elements . Emplace ( PolygonGroupsName ) . Get ( ) ;
// Now register topology-based attributes
// Register vertex reference for vertex instances
2020-07-16 08:23:15 -04:00
VertexInstanceVertices = VertexInstanceElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FVertexID > ( MeshAttribute : : VertexInstance : : VertexIndex , 1 , EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Register vertex references for edges
2020-07-16 08:23:15 -04:00
EdgeVertices = EdgeElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FVertexID [ 2 ] > ( MeshAttribute : : Edge : : VertexIndex , 1 , EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Register vertex instance and polygon references for triangles
2020-07-16 08:23:15 -04:00
TriangleVertexInstances = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FVertexInstanceID [ 3 ] > ( MeshAttribute : : Triangle : : VertexInstanceIndex , 1 , EMeshAttributeFlags : : Mandatory ) ;
TrianglePolygons = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FPolygonID > ( MeshAttribute : : Triangle : : PolygonIndex , 1 , EMeshAttributeFlags : : Mandatory ) ;
TrianglePolygonGroups = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FPolygonGroupID > ( MeshAttribute : : Triangle : : PolygonGroupIndex , 1 , EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Register UV references for triangles
2020-07-16 08:23:15 -04:00
TriangleUVs = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FUVID [ 3 ] > ( MeshAttribute : : Triangle : : UVIndex , 0 , EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Register vertex and edge references for triangles; these are transient references which are generated at load time
2020-07-16 08:23:15 -04:00
TriangleVertices = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FVertexID [ 3 ] > ( MeshAttribute : : Triangle : : VertexIndex , 1 , EMeshAttributeFlags : : Mandatory | EMeshAttributeFlags : : Transient ) ;
TriangleEdges = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FEdgeID [ 3 ] > ( MeshAttribute : : Triangle : : EdgeIndex , 1 , EMeshAttributeFlags : : Mandatory | EMeshAttributeFlags : : Transient ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Register polygon group reference for polygons
2020-07-16 08:23:15 -04:00
PolygonPolygonGroups = PolygonElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FPolygonGroupID > ( MeshAttribute : : Polygon : : PolygonGroupIndex , 1 , EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
2019-10-01 20:41:42 -04:00
// Minimal requirement is that vertices have a Position attribute
2021-05-05 15:07:25 -04:00
VertexPositions = VertexElements - > Get ( ) . GetAttributes ( ) . RegisterAttribute ( MeshAttribute : : Vertex : : Position , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Lerpable | EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Register UVCoordinates attribute for UVs
2021-11-18 14:37:34 -05:00
UVElements - > Get ( ) . GetAttributes ( ) . RegisterAttribute ( MeshAttribute : : UV : : UVCoordinate , 1 , FVector2f : : ZeroVector , EMeshAttributeFlags : : Lerpable | EMeshAttributeFlags : : Mandatory ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Associate indexers with element types and their referencing attributes
InitializeIndexers ( ) ;
}
void FMeshDescription : : InitializeIndexers ( )
{
// Vertices may typically have 6 vertex instances from the triangles which include them
VertexToVertexInstances . SetInitialNumReferences ( 6 ) ;
VertexToVertexInstances . Set ( VertexElements , VertexInstanceElements , MeshAttribute : : VertexInstance : : VertexIndex ) ;
// Vertices may typically have 6 edges from the triangles which include them
VertexToEdges . SetInitialNumReferences ( 6 ) ;
VertexToEdges . Set ( VertexElements , EdgeElements , MeshAttribute : : Edge : : VertexIndex ) ;
// @todo: VertexToTriangles?
VertexInstanceToTriangles . Set ( VertexInstanceElements , TriangleElements , MeshAttribute : : Triangle : : VertexInstanceIndex ) ;
// Assume most edges will have either 1 or 2 triangles
EdgeToTriangles . SetInitialNumReferences ( 2 ) ;
EdgeToTriangles . Set ( EdgeElements , TriangleElements , MeshAttribute : : Triangle : : EdgeIndex ) ;
// UVs may typically be used by 6 adjacent triangles
UVToTriangles . SetInitialNumReferences ( 6 ) ;
UVToTriangles . Set ( UVElements , TriangleElements , MeshAttribute : : Triangle : : UVIndex ) ;
// Assume most polygons are composed of only 1 triangle
PolygonToTriangles . SetInitialNumReferences ( 1 ) ;
PolygonToTriangles . Set ( PolygonElements , TriangleElements , MeshAttribute : : Triangle : : PolygonIndex ) ;
// Polygon group indexers are a little different; in general there will be many back references and few keys, so set not to use chunks.
PolygonGroupToTriangles . SetUnchunked ( ) ;
PolygonGroupToPolygons . SetUnchunked ( ) ;
PolygonGroupToTriangles . SetInitialNumReferences ( 256 ) ;
PolygonGroupToPolygons . SetInitialNumReferences ( 256 ) ;
PolygonGroupToTriangles . Set ( PolygonGroupElements , TriangleElements , MeshAttribute : : Triangle : : PolygonGroupIndex ) ;
PolygonGroupToPolygons . Set ( PolygonGroupElements , PolygonElements , MeshAttribute : : Polygon : : PolygonGroupIndex ) ;
}
void FMeshDescription : : Cache ( )
{
// Get pointers to element containers
VertexElements = Elements . Find ( VerticesName ) - > Get ( ) ;
VertexInstanceElements = Elements . Find ( VertexInstancesName ) - > Get ( ) ;
UVElements = Elements . Find ( UVsName ) - > Get ( ) ;
EdgeElements = Elements . Find ( EdgesName ) - > Get ( ) ;
TriangleElements = Elements . Find ( TrianglesName ) - > Get ( ) ;
PolygonElements = Elements . Find ( PolygonsName ) - > Get ( ) ;
PolygonGroupElements = Elements . Find ( PolygonGroupsName ) - > Get ( ) ;
// Register required transient attributes
2020-07-16 08:23:15 -04:00
TriangleVertices = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FVertexID [ 3 ] > ( MeshAttribute : : Triangle : : VertexIndex , 1 , EMeshAttributeFlags : : Mandatory | EMeshAttributeFlags : : Transient ) ;
TriangleEdges = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FEdgeID [ 3 ] > ( MeshAttribute : : Triangle : : EdgeIndex , 1 , EMeshAttributeFlags : : Mandatory | EMeshAttributeFlags : : Transient ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Cache fundamental attribute arrays
VertexInstanceVertices = VertexInstanceElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < FVertexID > ( MeshAttribute : : VertexInstance : : VertexIndex ) ;
EdgeVertices = EdgeElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < TArrayView < FVertexID > > ( MeshAttribute : : Edge : : VertexIndex ) ;
TriangleVertexInstances = TriangleElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < TArrayView < FVertexInstanceID > > ( MeshAttribute : : Triangle : : VertexInstanceIndex ) ;
TrianglePolygons = TriangleElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < FPolygonID > ( MeshAttribute : : Triangle : : PolygonIndex ) ;
TrianglePolygonGroups = TriangleElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < FPolygonGroupID > ( MeshAttribute : : Triangle : : PolygonGroupIndex ) ;
TriangleUVs = TriangleElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < TArrayView < FUVID > > ( MeshAttribute : : Triangle : : UVIndex ) ;
PolygonPolygonGroups = PolygonElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < FPolygonGroupID > ( MeshAttribute : : Polygon : : PolygonGroupIndex ) ;
2021-05-05 15:07:25 -04:00
VertexPositions = VertexElements - > Get ( ) . GetAttributes ( ) . GetAttributesRef < FVector3f > ( MeshAttribute : : Vertex : : Position ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Associate indexers with element types and their referencing attributes
InitializeIndexers ( ) ;
2019-10-01 20:41:42 -04:00
}
2021-01-28 16:27:47 -04:00
void FMeshDescription : : Serialize ( FArchive & BaseAr )
2019-09-10 11:35:20 -04:00
{
2021-01-28 16:27:47 -04:00
FNameAsStringProxyArchive Ar ( BaseAr ) ;
2019-09-10 11:35:20 -04:00
Ar . UsingCustomVersion ( FReleaseObjectVersion : : GUID ) ;
Ar . UsingCustomVersion ( FEditorObjectVersion : : GUID ) ;
2020-09-23 12:12:34 -04:00
Ar . UsingCustomVersion ( FUE5MainStreamObjectVersion : : GUID ) ;
2019-09-10 11:35:20 -04:00
if ( Ar . IsLoading ( ) & & Ar . CustomVer ( FReleaseObjectVersion : : GUID ) < FReleaseObjectVersion : : MeshDescriptionNewSerialization )
2018-08-07 16:07:44 -04:00
{
2019-09-10 11:35:20 -04:00
UE_LOG ( LogLoad , Warning , TEXT ( " Deprecated serialization format " ) ) ;
2018-08-07 16:07:44 -04:00
}
2020-09-23 12:12:34 -04:00
if ( Ar . IsLoading ( ) & &
Ar . CustomVer ( FReleaseObjectVersion : : GUID ) ! = FReleaseObjectVersion : : MeshDescriptionNewFormat & &
Ar . CustomVer ( FUE5MainStreamObjectVersion : : GUID ) < FUE5MainStreamObjectVersion : : MeshDescriptionNewFormat )
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
{
// Serialize the old format data and transform it into the new format mesh element map
SerializeLegacy ( Ar ) ;
}
else
{
Ar < < Elements ;
// After loading elements, we need to re-cache mesh element and attribute arrays
if ( Ar . IsLoading ( ) )
{
2021-11-29 09:40:14 -05:00
// Ensure there's a UV element container
if ( Elements . Find ( UVsName ) = = nullptr )
{
UE_LOG ( LogLoad , Warning , TEXT ( " Couldn't find UV element container in mesh - adding an empty one " ) ) ;
UVElements = Elements . Emplace ( UVsName ) . Get ( ) ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
Cache ( ) ;
for ( FTriangleID TriangleID : TriangleElements - > Get ( ) . GetElementIDs ( ) )
{
for ( int32 I = 0 ; I < 3 ; I + + )
{
FVertexInstanceID VertexInstanceID = TriangleVertexInstances [ TriangleID ] [ I ] ;
TriangleVertices [ TriangleID ] [ I ] = VertexInstanceVertices [ VertexInstanceID ] ;
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , TriangleID ) ;
}
for ( int32 I = 0 ; I < 3 ; I + + )
{
FEdgeID EdgeID = GetVertexPairEdge ( TriangleVertices [ TriangleID ] [ I ] , TriangleVertices [ TriangleID ] [ ( I + 1 ) % 3 ] ) ;
TriangleEdges [ TriangleID ] [ I ] = EdgeID ;
EdgeToTriangles . AddReferenceToKey ( EdgeID , TriangleID ) ;
}
}
RebuildIndexers ( ) ;
}
}
}
struct FMeshVertex_Legacy
{
TArray < FVertexInstanceID > VertexInstanceIDs ;
TArray < FEdgeID > ConnectedEdgeIDs ;
friend FArchive & operator < < ( FArchive & Ar , FMeshVertex_Legacy & Vertex )
{
check ( Ar . IsLoading ( ) ) ;
if ( Ar . CustomVer ( FReleaseObjectVersion : : GUID ) < FReleaseObjectVersion : : MeshDescriptionNewSerialization )
{
Ar < < Vertex . VertexInstanceIDs ;
Ar < < Vertex . ConnectedEdgeIDs ;
}
return Ar ;
}
} ;
struct FMeshVertexInstance_Legacy
{
FVertexID VertexID ;
TArray < FTriangleID > ConnectedTriangles ;
friend FArchive & operator < < ( FArchive & Ar , FMeshVertexInstance_Legacy & VertexInstance )
{
check ( Ar . IsLoading ( ) ) ;
Ar < < VertexInstance . VertexID ;
if ( Ar . CustomVer ( FReleaseObjectVersion : : GUID ) < FReleaseObjectVersion : : MeshDescriptionNewSerialization )
{
TArray < FPolygonID > ConnectedPolygons_DISCARD ;
Ar < < ConnectedPolygons_DISCARD ;
}
return Ar ;
}
} ;
struct FMeshEdge_Legacy
{
FVertexID VertexIDs [ 2 ] ;
TArray < FTriangleID > ConnectedTriangles ;
friend FArchive & operator < < ( FArchive & Ar , FMeshEdge_Legacy & Edge )
{
check ( Ar . IsLoading ( ) ) ;
Ar < < Edge . VertexIDs [ 0 ] ;
Ar < < Edge . VertexIDs [ 1 ] ;
if ( Ar . CustomVer ( FReleaseObjectVersion : : GUID ) < FReleaseObjectVersion : : MeshDescriptionNewSerialization )
{
TArray < FPolygonID > ConnectedPolygons_DISCARD ;
Ar < < ConnectedPolygons_DISCARD ;
}
return Ar ;
}
} ;
struct FMeshTriangle_Legacy
{
FVertexInstanceID VertexInstanceIDs [ 3 ] ;
FPolygonID PolygonID ;
friend FArchive & operator < < ( FArchive & Ar , FMeshTriangle_Legacy & Triangle )
{
check ( Ar . IsLoading ( ) ) ;
Ar < < Triangle . VertexInstanceIDs [ 0 ] ;
Ar < < Triangle . VertexInstanceIDs [ 1 ] ;
Ar < < Triangle . VertexInstanceIDs [ 2 ] ;
if ( Ar . CustomVer ( FEditorObjectVersion : : GUID ) > = FEditorObjectVersion : : MeshDescriptionTriangles )
{
Ar < < Triangle . PolygonID ;
}
return Ar ;
}
} ;
struct FMeshPolygon_Legacy
{
TArray < FVertexInstanceID > VertexInstanceIDs ;
TArray < FTriangleID > TriangleIDs ;
FPolygonGroupID PolygonGroupID ;
friend FArchive & operator < < ( FArchive & Ar , FMeshPolygon_Legacy & Polygon )
{
check ( Ar . IsLoading ( ) ) ;
Ar < < Polygon . VertexInstanceIDs ;
if ( Ar . CustomVer ( FEditorObjectVersion : : GUID ) < FEditorObjectVersion : : MeshDescriptionRemovedHoles )
{
TArray < TArray < FVertexInstanceID > > Empty ;
Ar < < Empty ;
}
if ( Ar . CustomVer ( FReleaseObjectVersion : : GUID ) < FReleaseObjectVersion : : MeshDescriptionNewSerialization )
{
TArray < FMeshTriangle_Legacy > Triangles_DISCARD ;
Ar < < Triangles_DISCARD ;
}
Ar < < Polygon . PolygonGroupID ;
return Ar ;
}
} ;
struct FMeshPolygonGroup_Legacy
{
TArray < FPolygonID > Polygons ;
friend FArchive & operator < < ( FArchive & Ar , FMeshPolygonGroup_Legacy & PolygonGroup )
{
check ( Ar . IsLoading ( ) ) ;
if ( Ar . CustomVer ( FReleaseObjectVersion : : GUID ) < FReleaseObjectVersion : : MeshDescriptionNewSerialization )
{
Ar < < PolygonGroup . Polygons ;
}
return Ar ;
}
} ;
2020-09-09 08:58:09 -04:00
template < typename T >
2020-11-04 08:40:25 -04:00
struct FFixAttributesSizeHelper
2020-09-09 08:58:09 -04:00
{
2020-11-04 08:40:25 -04:00
explicit FFixAttributesSizeHelper ( int32 InExpectedNum )
: ExpectedNum ( InExpectedNum ) ,
bAllDefault ( true )
{ }
template < typename U >
void operator ( ) ( const FName AttributeName , TMeshAttributesRef < T , TArrayView < U > > AttributeArrayRef )
{
// Not expecting arrays in legacy attributes
check ( false ) ;
}
template < typename U >
void operator ( ) ( const FName AttributeName , TMeshAttributesRef < T , TArrayAttribute < U > > AttributeArrayRef )
{
// Not expecting arrays in legacy attributes
check ( false ) ;
}
template < typename U >
void operator ( ) ( const FName AttributeName , TMeshAttributesRef < T , U > AttributeArrayRef )
{
if ( bAllDefault )
2020-09-09 08:58:09 -04:00
{
2020-11-04 08:40:25 -04:00
for ( int32 Channel = 0 ; Channel < AttributeArrayRef . GetNumChannels ( ) ; Channel + + )
2020-09-09 08:58:09 -04:00
{
2020-11-04 08:40:25 -04:00
for ( int32 Index = ExpectedNum ; Index < AttributeArrayRef . GetNumElements ( ) ; Index + + )
2020-09-09 08:58:09 -04:00
{
2020-11-04 08:40:25 -04:00
if ( AttributeArrayRef . Get ( T ( Index ) , Channel ) ! = AttributeArrayRef . GetDefaultValue ( ) )
2020-09-09 08:58:09 -04:00
{
2020-11-04 08:40:25 -04:00
bAllDefault = false ;
return ;
2020-09-09 08:58:09 -04:00
}
}
}
}
2020-11-04 08:40:25 -04:00
}
2020-09-09 08:58:09 -04:00
2020-11-04 08:40:25 -04:00
int32 ExpectedNum ;
bool bAllDefault ;
} ;
template < typename T >
void FixAttributesSize ( int32 ExpectedNum , TAttributesSet < T > & AttributesSet )
{
// Ensure that the attribute set is the same size as the mesh element array they describe
// If there are extra elements, and they are not set to trivial defaults, this is an error.
FFixAttributesSizeHelper < T > Helper ( ExpectedNum ) ;
AttributesSet . ForEach ( Helper ) ;
check ( Helper . bAllDefault ) ; // If this fires, something is very wrong with the legacy asset
2020-09-09 08:58:09 -04:00
AttributesSet . SetNumElements ( ExpectedNum ) ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
void FMeshDescription : : SerializeLegacy ( FArchive & Ar )
{
2020-09-09 08:58:09 -04:00
TMeshElementArray < FMeshVertex_Legacy , FVertexID > VertexArray ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TMeshElementArray < FMeshVertexInstance_Legacy , FVertexInstanceID > VertexInstanceArray ;
TMeshElementArray < FMeshEdge_Legacy , FEdgeID > EdgeArray ;
TMeshElementArray < FMeshTriangle_Legacy , FTriangleID > TriangleArray ;
TMeshElementArray < FMeshPolygon_Legacy , FPolygonID > PolygonArray ;
TMeshElementArray < FMeshPolygonGroup_Legacy , FPolygonGroupID > PolygonGroupArray ;
TAttributesSet < FVertexID > VertexAttributesSet ;
TAttributesSet < FVertexInstanceID > VertexInstanceAttributesSet ;
TAttributesSet < FEdgeID > EdgeAttributesSet ;
TAttributesSet < FTriangleID > TriangleAttributesSet ;
TAttributesSet < FPolygonID > PolygonAttributesSet ;
TAttributesSet < FPolygonGroupID > PolygonGroupAttributesSet ;
2019-09-10 11:35:20 -04:00
Ar < < VertexArray ;
Ar < < VertexInstanceArray ;
Ar < < EdgeArray ;
Ar < < PolygonArray ;
Ar < < PolygonGroupArray ;
2017-08-22 16:18:25 -04:00
2019-09-10 11:35:20 -04:00
Ar < < VertexAttributesSet ;
Ar < < VertexInstanceAttributesSet ;
Ar < < EdgeAttributesSet ;
Ar < < PolygonAttributesSet ;
Ar < < PolygonGroupAttributesSet ;
2018-05-28 14:28:16 -04:00
2020-09-09 08:58:09 -04:00
FixAttributesSize ( VertexArray . GetArraySize ( ) , VertexAttributesSet ) ;
FixAttributesSize ( VertexInstanceArray . GetArraySize ( ) , VertexInstanceAttributesSet ) ;
FixAttributesSize ( EdgeArray . GetArraySize ( ) , EdgeAttributesSet ) ;
FixAttributesSize ( PolygonArray . GetArraySize ( ) , PolygonAttributesSet ) ;
FixAttributesSize ( PolygonGroupArray . GetArraySize ( ) , PolygonGroupAttributesSet ) ;
2019-09-10 11:35:20 -04:00
// Serialize new triangle arrays since version MeshDescriptionTriangles
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( Ar . CustomVer ( FEditorObjectVersion : : GUID ) > = FEditorObjectVersion : : MeshDescriptionTriangles )
2019-09-10 11:35:20 -04:00
{
Ar < < TriangleArray ;
Ar < < TriangleAttributesSet ;
2020-09-09 08:58:09 -04:00
FixAttributesSize ( TriangleArray . GetArraySize ( ) , TriangleAttributesSet ) ;
2019-09-10 11:35:20 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Convert the old style element arrays into the new format
// Completely reinitialize the mesh elements map as it is not being directly serialized into.
Initialize ( ) ;
for ( FVertexID VertexID : VertexArray . GetElementIDs ( ) )
2018-05-28 14:28:16 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexElements - > Get ( ) . Insert ( VertexID ) ;
2018-05-28 14:28:16 -04:00
}
2018-06-07 16:22:56 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( FVertexInstanceID VertexInstanceID : VertexInstanceArray . GetElementIDs ( ) )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexInstanceElements - > Get ( ) . Insert ( VertexInstanceID ) ;
FVertexID VertexID = VertexInstanceArray [ VertexInstanceID ] . VertexID ;
VertexInstanceVertices [ VertexInstanceID ] = VertexID ;
VertexToVertexInstances . AddReferenceToKey ( VertexID , VertexInstanceID ) ;
}
for ( FEdgeID EdgeID : EdgeArray . GetElementIDs ( ) )
{
EdgeElements - > Get ( ) . Insert ( EdgeID ) ;
FVertexID VertexID0 = EdgeArray [ EdgeID ] . VertexIDs [ 0 ] ;
FVertexID VertexID1 = EdgeArray [ EdgeID ] . VertexIDs [ 1 ] ;
EdgeVertices [ EdgeID ] [ 0 ] = VertexID0 ;
EdgeVertices [ EdgeID ] [ 1 ] = VertexID1 ;
VertexToEdges . AddReferenceToKey ( VertexID0 , EdgeID ) ;
VertexToEdges . AddReferenceToKey ( VertexID1 , EdgeID ) ;
}
for ( FPolygonGroupID PolygonGroupID : PolygonGroupArray . GetElementIDs ( ) )
{
PolygonGroupElements - > Get ( ) . Insert ( PolygonGroupID ) ;
}
for ( FPolygonID PolygonID : PolygonArray . GetElementIDs ( ) )
{
PolygonElements - > Get ( ) . Insert ( PolygonID ) ;
FPolygonGroupID PolygonGroupID = PolygonArray [ PolygonID ] . PolygonGroupID ;
PolygonPolygonGroups [ PolygonID ] = PolygonGroupID ;
PolygonGroupToPolygons . AddReferenceToKey ( PolygonGroupID , PolygonID ) ;
// If the asset is pre-triangles, we generate triangles here from the polygon
2019-09-10 11:35:20 -04:00
if ( Ar . CustomVer ( FEditorObjectVersion : : GUID ) < FEditorObjectVersion : : MeshDescriptionTriangles )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
check ( PolygonArray [ PolygonID ] . VertexInstanceIDs . Num ( ) > = 3 ) ;
CreatePolygonTriangles ( PolygonID , PolygonArray [ PolygonID ] . VertexInstanceIDs ) ;
2019-09-10 11:35:20 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
}
// Only do this if there were actually triangles in the asset
if ( Ar . CustomVer ( FEditorObjectVersion : : GUID ) > = FEditorObjectVersion : : MeshDescriptionTriangles )
{
for ( FTriangleID TriangleID : TriangleArray . GetElementIDs ( ) )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TriangleElements - > Get ( ) . Insert ( TriangleID ) ;
FPolygonID PolygonID = TriangleArray [ TriangleID ] . PolygonID ;
FPolygonGroupID PolygonGroupID = PolygonArray [ PolygonID ] . PolygonGroupID ;
TrianglePolygons [ TriangleID ] = PolygonID ;
TrianglePolygonGroups [ TriangleID ] = PolygonGroupID ;
PolygonToTriangles . AddReferenceToKey ( PolygonID , TriangleID ) ;
PolygonGroupToTriangles . AddReferenceToKey ( PolygonGroupID , TriangleID ) ;
for ( int32 I = 0 ; I < 3 ; I + + )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
FVertexInstanceID VertexInstanceID = TriangleArray [ TriangleID ] . VertexInstanceIDs [ I ] ;
TriangleVertexInstances [ TriangleID ] [ I ] = VertexInstanceID ;
TriangleVertices [ TriangleID ] [ I ] = VertexInstanceVertices [ VertexInstanceID ] ;
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , TriangleID ) ;
}
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( int32 I = 0 ; I < 3 ; I + + )
{
FEdgeID EdgeID = GetVertexPairEdge ( TriangleVertices [ TriangleID ] [ I ] , TriangleVertices [ TriangleID ] [ ( I + 1 ) % 3 ] ) ;
TriangleEdges [ TriangleID ] [ I ] = EdgeID ;
EdgeToTriangles . AddReferenceToKey ( EdgeID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
}
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Unregister the position attribute from the vertex elements, as it will come from the legacy data instead.
VertexElements - > Get ( ) . GetAttributes ( ) . UnregisterAttribute ( MeshAttribute : : Vertex : : Position ) ;
// Add the legacy mesh attributes into the new containers
VertexElements - > Get ( ) . GetAttributes ( ) . AppendAttributesFrom ( VertexAttributesSet ) ;
VertexInstanceElements - > Get ( ) . GetAttributes ( ) . AppendAttributesFrom ( VertexInstanceAttributesSet ) ;
EdgeElements - > Get ( ) . GetAttributes ( ) . AppendAttributesFrom ( EdgeAttributesSet ) ;
PolygonElements - > Get ( ) . GetAttributes ( ) . AppendAttributesFrom ( PolygonAttributesSet ) ;
PolygonGroupElements - > Get ( ) . GetAttributes ( ) . AppendAttributesFrom ( PolygonGroupAttributesSet ) ;
if ( Ar . CustomVer ( FEditorObjectVersion : : GUID ) > = FEditorObjectVersion : : MeshDescriptionTriangles )
{
TriangleElements - > Get ( ) . GetAttributes ( ) . AppendAttributesFrom ( TriangleAttributesSet ) ;
}
Cache ( ) ;
BuildIndexers ( ) ;
}
void FMeshDescription : : ResetIndexers ( )
{
VertexToVertexInstances . Reset ( ) ;
VertexToEdges . Reset ( ) ;
VertexInstanceToTriangles . Reset ( ) ;
EdgeToTriangles . Reset ( ) ;
UVToTriangles . Reset ( ) ;
PolygonToTriangles . Reset ( ) ;
PolygonGroupToTriangles . Reset ( ) ;
PolygonGroupToPolygons . Reset ( ) ;
}
void FMeshDescription : : BuildIndexers ( )
{
VertexToVertexInstances . Build ( ) ;
VertexToEdges . Build ( ) ;
VertexInstanceToTriangles . Build ( ) ;
EdgeToTriangles . Build ( ) ;
UVToTriangles . Build ( ) ;
PolygonToTriangles . Build ( ) ;
PolygonGroupToTriangles . Build ( ) ;
PolygonGroupToPolygons . Build ( ) ;
}
void FMeshDescription : : RebuildIndexers ( )
{
VertexToVertexInstances . ForceRebuild ( ) ;
VertexToEdges . ForceRebuild ( ) ;
VertexInstanceToTriangles . ForceRebuild ( ) ;
EdgeToTriangles . ForceRebuild ( ) ;
UVToTriangles . ForceRebuild ( ) ;
PolygonToTriangles . ForceRebuild ( ) ;
PolygonGroupToTriangles . ForceRebuild ( ) ;
PolygonGroupToPolygons . ForceRebuild ( ) ;
2017-08-22 16:18:25 -04:00
}
2018-03-26 17:55:30 -04:00
2018-06-07 16:22:56 -04:00
void FMeshDescription : : Empty ( )
2017-12-28 17:15:00 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexElements - > Reset ( ) ;
VertexInstanceElements - > Reset ( ) ;
UVElements - > Reset ( ) ;
EdgeElements - > Reset ( ) ;
TriangleElements - > Reset ( ) ;
PolygonElements - > Reset ( ) ;
PolygonGroupElements - > Reset ( ) ;
ResetIndexers ( ) ;
2017-12-28 17:15:00 -05:00
}
Total revamp of mesh element attribute model.
Attributes now have a number of possible types (FVector, FVector4, FVector2D, float, int, bool, FName, UObject*) and are exposed as individual flat arrays, indexed by element ID. For example, vertex positions are essentially exposed as an array of FVector which can be directly accessed and modified. This has a number of advantages:
- It is completely extensible: new attributes can be created (even by a third party) and added to a mesh description without requiring a serialization version bump, or any change to the parent structures.
- This is more efficient in batch operations which deal with a number of mesh elements in one go.
- These attribute buffers can potentially be passed directly to third-party libraries without requiring any kind of transformation.
- The distinct types allow for a better representation of the attribute being specified, without invalid values being possible (cf representing a bool value in an FVector4).
Attributes also have default values, and a flags field which confers use-specific properties to them. Editable Mesh currently uses this to determine whether an attribute's value can be automatically initialized by lerping the values of its neighbours, as well as for identifying auto-generated attributes such as tangents/normals. This is desirable as it means that even unknown / third-party attributes can potentially be handled transparently by Editable Mesh, without requiring the code to be extended.
Certain higher-level operations in EditableMesh have been optimized to make full use of vertex instances where possible.
The welding/splitting of identical vertex instances has been removed from here, as the aim is to unify this with mesh utility code elsewhere.
Various bug fixes.
#rb Alexis.Matte
[CL 3794563 by Richard TalbotWatkin in Dev-Geometry branch]
2017-12-07 13:02:12 -05:00
2018-01-17 15:58:38 -05:00
2018-12-10 09:29:08 -05:00
bool FMeshDescription : : IsEmpty ( ) const
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
return VertexElements - > IsEmpty ( ) & &
VertexInstanceElements - > IsEmpty ( ) & &
UVElements - > IsEmpty ( ) & &
EdgeElements - > IsEmpty ( ) & &
TriangleElements - > IsEmpty ( ) & &
PolygonElements - > IsEmpty ( ) & &
PolygonGroupElements - > IsEmpty ( ) ;
2018-12-10 09:29:08 -05:00
}
2019-12-19 18:07:47 -05:00
void FMeshDescription : : Compact ( FElementIDRemappings & OutRemappings )
2017-08-22 16:18:25 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexElements - > Get ( ) . Compact ( OutRemappings . NewVertexIndexLookup ) ;
VertexInstanceElements - > Get ( ) . Compact ( OutRemappings . NewVertexInstanceIndexLookup ) ;
EdgeElements - > Get ( ) . Compact ( OutRemappings . NewEdgeIndexLookup ) ;
TriangleElements - > Get ( ) . Compact ( OutRemappings . NewTriangleIndexLookup ) ;
PolygonElements - > Get ( ) . Compact ( OutRemappings . NewPolygonIndexLookup ) ;
PolygonGroupElements - > Get ( ) . Compact ( OutRemappings . NewPolygonGroupIndexLookup ) ;
2017-08-22 16:18:25 -04:00
2019-12-19 18:07:47 -05:00
FixUpElementIDs ( OutRemappings ) ;
2017-08-22 16:18:25 -04:00
}
2019-12-19 18:07:47 -05:00
void FMeshDescription : : Remap ( const FElementIDRemappings & Remappings )
2017-08-22 16:18:25 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexElements - > Get ( ) . Remap ( Remappings . NewVertexIndexLookup ) ;
VertexInstanceElements - > Get ( ) . Remap ( Remappings . NewVertexInstanceIndexLookup ) ;
EdgeElements - > Get ( ) . Remap ( Remappings . NewEdgeIndexLookup ) ;
TriangleElements - > Get ( ) . Remap ( Remappings . NewTriangleIndexLookup ) ;
PolygonElements - > Get ( ) . Remap ( Remappings . NewPolygonIndexLookup ) ;
PolygonGroupElements - > Get ( ) . Remap ( Remappings . NewPolygonGroupIndexLookup ) ;
2017-08-22 16:18:25 -04:00
2019-12-19 18:07:47 -05:00
FixUpElementIDs ( Remappings ) ;
2017-08-22 16:18:25 -04:00
}
2019-12-19 18:07:47 -05:00
void FMeshDescription : : FixUpElementIDs ( const FElementIDRemappings & Remappings )
2017-08-22 16:18:25 -04:00
{
// Fix up vertex index references in vertex instance array
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( const FVertexInstanceID VertexInstanceID : VertexInstanceElements - > Get ( ) . GetElementIDs ( ) )
2017-08-22 16:18:25 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexInstanceVertices [ VertexInstanceID ] = Remappings . GetRemappedVertexID ( VertexInstanceVertices [ VertexInstanceID ] ) ;
2017-08-22 16:18:25 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( const FEdgeID EdgeID : EdgeElements - > Get ( ) . GetElementIDs ( ) )
2017-08-22 16:18:25 -04:00
{
// Fix up vertex index references in Edges array
2019-12-19 18:07:47 -05:00
for ( int32 Index = 0 ; Index < 2 ; Index + + )
2017-08-22 16:18:25 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
EdgeVertices [ EdgeID ] [ Index ] = Remappings . GetRemappedVertexID ( EdgeVertices [ EdgeID ] [ Index ] ) ;
2019-09-10 11:35:20 -04:00
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( const FTriangleID TriangleID : TriangleElements - > Get ( ) . GetElementIDs ( ) )
2019-09-10 11:35:20 -04:00
{
// Fix up vertex instance references in Triangle
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( int32 Index = 0 ; Index < 3 ; Index + + )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TriangleVertexInstances [ TriangleID ] [ Index ] = Remappings . GetRemappedVertexInstanceID ( TriangleVertexInstances [ TriangleID ] [ Index ] ) ;
TriangleEdges [ TriangleID ] [ Index ] = Remappings . GetRemappedEdgeID ( TriangleEdges [ TriangleID ] [ Index ] ) ;
TriangleVertices [ TriangleID ] [ Index ] = Remappings . GetRemappedVertexID ( TriangleVertices [ TriangleID ] [ Index ] ) ;
2019-09-10 11:35:20 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TrianglePolygons [ TriangleID ] = Remappings . GetRemappedPolygonID ( TrianglePolygons [ TriangleID ] ) ;
TrianglePolygonGroups [ TriangleID ] = Remappings . GetRemappedPolygonGroupID ( TrianglePolygonGroups [ TriangleID ] ) ;
2017-08-22 16:18:25 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( const FPolygonID PolygonID : PolygonElements - > Get ( ) . GetElementIDs ( ) )
2017-08-22 16:18:25 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
PolygonPolygonGroups [ PolygonID ] = Remappings . GetRemappedPolygonGroupID ( PolygonPolygonGroups [ PolygonID ] ) ;
2017-08-22 16:18:25 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
RebuildIndexers ( ) ;
2017-08-22 16:18:25 -04:00
}
Total revamp of mesh element attribute model.
Attributes now have a number of possible types (FVector, FVector4, FVector2D, float, int, bool, FName, UObject*) and are exposed as individual flat arrays, indexed by element ID. For example, vertex positions are essentially exposed as an array of FVector which can be directly accessed and modified. This has a number of advantages:
- It is completely extensible: new attributes can be created (even by a third party) and added to a mesh description without requiring a serialization version bump, or any change to the parent structures.
- This is more efficient in batch operations which deal with a number of mesh elements in one go.
- These attribute buffers can potentially be passed directly to third-party libraries without requiring any kind of transformation.
- The distinct types allow for a better representation of the attribute being specified, without invalid values being possible (cf representing a bool value in an FVector4).
Attributes also have default values, and a flags field which confers use-specific properties to them. Editable Mesh currently uses this to determine whether an attribute's value can be automatically initialized by lerping the values of its neighbours, as well as for identifying auto-generated attributes such as tangents/normals. This is desirable as it means that even unknown / third-party attributes can potentially be handled transparently by Editable Mesh, without requiring the code to be extended.
Certain higher-level operations in EditableMesh have been optimized to make full use of vertex instances where possible.
The welding/splitting of identical vertex instances has been removed from here, as the aim is to unify this with mesh utility code elsewhere.
Various bug fixes.
#rb Alexis.Matte
[CL 3794563 by Richard TalbotWatkin in Dev-Geometry branch]
2017-12-07 13:02:12 -05:00
2019-09-10 11:35:20 -04:00
void FMeshDescription : : CreateVertexInstance_Internal ( const FVertexInstanceID VertexInstanceID , const FVertexID VertexID )
2019-01-18 06:37:35 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexInstanceVertices [ VertexInstanceID ] = VertexID ;
VertexToVertexInstances . AddReferenceToKey ( VertexID , VertexInstanceID ) ;
2019-01-18 06:37:35 -05:00
}
2020-02-03 11:08:35 -05:00
template < template < typename . . . > class TContainer >
void FMeshDescription : : DeleteVertexInstance_Internal ( const FVertexInstanceID VertexInstanceID , TContainer < FVertexID > * InOutOrphanedVerticesPtr )
2019-01-18 06:37:35 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
checkSlow ( VertexInstanceToTriangles . Find ( VertexInstanceID ) . Num ( ) = = 0 ) ;
const FVertexID VertexID = VertexInstanceVertices [ VertexInstanceID ] ;
VertexToVertexInstances . RemoveReferenceFromKey ( VertexID , VertexInstanceID ) ;
VertexInstanceElements - > Get ( ) . Remove ( VertexInstanceID ) ;
VertexInstanceToTriangles . RemoveKey ( VertexInstanceID ) ;
// Always perform the Find() after the element has been completely deleted, so it won't be included in reindexing if the key is stale.
// Note: removing the element above will clear the attributes to default, so remember the VertexID we're interested in.
if ( InOutOrphanedVerticesPtr & &
VertexToVertexInstances . Find ( VertexID ) . Num ( ) = = 0 & &
VertexToEdges . Find ( VertexID ) . Num ( ) = = 0 )
2019-09-10 11:35:20 -04:00
{
2020-02-03 11:08:35 -05:00
AddUnique ( * InOutOrphanedVerticesPtr , VertexID ) ;
2019-09-10 11:35:20 -04:00
}
}
2020-02-03 11:08:35 -05:00
void FMeshDescription : : DeleteVertexInstance ( const FVertexInstanceID VertexInstanceID , TArray < FVertexID > * InOutOrphanedVerticesPtr )
{
DeleteVertexInstance_Internal < TArray > ( VertexInstanceID , InOutOrphanedVerticesPtr ) ;
}
2019-09-10 11:35:20 -04:00
void FMeshDescription : : CreateEdge_Internal ( const FEdgeID EdgeID , const FVertexID VertexID0 , const FVertexID VertexID1 )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
checkSlow ( GetVertexPairEdge ( VertexID0 , VertexID1 ) = = INDEX_NONE ) ;
TArrayView < FVertexID > EdgeVertexIDs = EdgeVertices [ EdgeID ] ;
EdgeVertexIDs [ 0 ] = VertexID0 ;
EdgeVertexIDs [ 1 ] = VertexID1 ;
VertexToEdges . AddReferenceToKey ( VertexID0 , EdgeID ) ;
VertexToEdges . AddReferenceToKey ( VertexID1 , EdgeID ) ;
2019-09-10 11:35:20 -04:00
}
2020-02-03 11:08:35 -05:00
template < template < typename . . . > class TContainer >
void FMeshDescription : : DeleteEdge_Internal ( const FEdgeID EdgeID , TContainer < FVertexID > * InOutOrphanedVerticesPtr )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID VertexID0 = EdgeVertices [ EdgeID ] [ 0 ] ;
const FVertexID VertexID1 = EdgeVertices [ EdgeID ] [ 1 ] ;
VertexToEdges . RemoveReferenceFromKey ( VertexID0 , EdgeID ) ;
VertexToEdges . RemoveReferenceFromKey ( VertexID1 , EdgeID ) ;
EdgeElements - > Get ( ) . Remove ( EdgeID ) ;
EdgeToTriangles . RemoveKey ( EdgeID ) ;
// Always perform the Find() after the element has been completely deleted, so it won't be included in reindexing if the key is stale.
// Note: removing the element above will clear the attributes to default, so remember the VertexID we're interested in.
if ( InOutOrphanedVerticesPtr )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( VertexToEdges . Find ( VertexID0 ) . Num ( ) = = 0 )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
check ( VertexToVertexInstances . Find ( VertexID0 ) . Num ( ) = = 0 ) ;
AddUnique ( * InOutOrphanedVerticesPtr , VertexID0 ) ;
}
if ( VertexToEdges . Find ( VertexID1 ) . Num ( ) = = 0 )
{
check ( VertexToVertexInstances . Find ( VertexID1 ) . Num ( ) = = 0 ) ;
AddUnique ( * InOutOrphanedVerticesPtr , VertexID1 ) ;
2019-09-10 11:35:20 -04:00
}
}
}
2020-02-03 11:08:35 -05:00
void FMeshDescription : : DeleteEdge ( const FEdgeID EdgeID , TArray < FVertexID > * InOutOrphanedVerticesPtr )
{
DeleteEdge_Internal < TArray > ( EdgeID , InOutOrphanedVerticesPtr ) ;
}
2019-09-10 11:35:20 -04:00
void FMeshDescription : : CreateTriangle_Internal ( const FTriangleID TriangleID , const FPolygonGroupID PolygonGroupID , TArrayView < const FVertexInstanceID > VertexInstanceIDs , TArray < FEdgeID > * OutEdgeIDs )
{
if ( OutEdgeIDs )
2019-01-18 06:37:35 -05:00
{
OutEdgeIDs - > Empty ( ) ;
}
2019-09-10 11:35:20 -04:00
// Fill out triangle vertex instances
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < FVertexInstanceID > TriVertexInstanceIDs = TriangleVertexInstances [ TriangleID ] ;
2019-09-10 11:35:20 -04:00
check ( VertexInstanceIDs . Num ( ) = = 3 ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TriVertexInstanceIDs [ 0 ] = VertexInstanceIDs [ 0 ] ;
TriVertexInstanceIDs [ 1 ] = VertexInstanceIDs [ 1 ] ;
TriVertexInstanceIDs [ 2 ] = VertexInstanceIDs [ 2 ] ;
// Fill out triangle polygon group
TrianglePolygonGroups [ TriangleID ] = PolygonGroupID ;
PolygonGroupToTriangles . AddReferenceToKey ( PolygonGroupID , TriangleID ) ;
2019-01-18 06:37:35 -05:00
2019-09-10 11:35:20 -04:00
// Make a polygon which will contain this triangle
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// @todo: make this optional; currently only exists for backwards compatibility
FPolygonID PolygonID = PolygonElements - > Get ( ) . Add ( ) ;
PolygonPolygonGroups [ PolygonID ] = PolygonGroupID ;
PolygonGroupToPolygons . AddReferenceToKey ( PolygonGroupID , PolygonID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TrianglePolygons [ TriangleID ] = PolygonID ;
PolygonToTriangles . AddReferenceToKey ( PolygonID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < FVertexID > TriVertexIDs = TriangleVertices [ TriangleID ] ;
TArrayView < FEdgeID > TriEdgeIDs = TriangleEdges [ TriangleID ] ;
2019-09-10 11:35:20 -04:00
for ( int32 Index = 0 ; Index < 3 ; + + Index )
2019-01-18 06:37:35 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexInstanceID VertexInstanceID = TriVertexInstanceIDs [ Index ] ;
const FVertexInstanceID NextVertexInstanceID = TriVertexInstanceIDs [ ( Index = = 2 ) ? 0 : Index + 1 ] ;
2019-01-18 06:37:35 -05:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID ThisVertexID = VertexInstanceVertices [ VertexInstanceID ] ;
const FVertexID NextVertexID = VertexInstanceVertices [ NextVertexInstanceID ] ;
TriVertexIDs [ Index ] = ThisVertexID ;
// VertexToTriangles.AddReferenceToKey(ThisVertexID, TriangleID); // @todo: can add this, but need to consider how degenerates would work
2019-01-18 06:37:35 -05:00
2019-09-10 11:35:20 -04:00
FEdgeID EdgeID = GetVertexPairEdge ( ThisVertexID , NextVertexID ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( EdgeID = = INDEX_NONE )
2019-01-18 06:37:35 -05:00
{
2019-09-10 11:35:20 -04:00
EdgeID = CreateEdge ( ThisVertexID , NextVertexID ) ;
if ( OutEdgeIDs )
2019-01-18 06:37:35 -05:00
{
2019-09-10 11:35:20 -04:00
OutEdgeIDs - > Add ( EdgeID ) ;
2019-01-18 06:37:35 -05:00
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TriEdgeIDs [ Index ] = EdgeID ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , TriangleID ) ;
EdgeToTriangles . AddReferenceToKey ( EdgeID , TriangleID ) ;
2019-01-18 06:37:35 -05:00
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
void FMeshDescription : : SetTriangleUVIndices ( const FTriangleID TriangleID , TArrayView < const FUVID > UVIDs , int32 UVChannel )
{
TArrayView < FUVID > TriUVs = TriangleUVs . Get ( TriangleID , UVChannel ) ;
TriUVs [ 0 ] = UVIDs [ 0 ] ;
TriUVs [ 1 ] = UVIDs [ 1 ] ;
TriUVs [ 2 ] = UVIDs [ 2 ] ;
UVToTriangles . AddReferenceToKey ( UVIDs [ 0 ] , TriangleID , UVChannel ) ;
UVToTriangles . AddReferenceToKey ( UVIDs [ 1 ] , TriangleID , UVChannel ) ;
UVToTriangles . AddReferenceToKey ( UVIDs [ 2 ] , TriangleID , UVChannel ) ;
}
2020-02-03 11:08:35 -05:00
template < template < typename . . . > class TContainer >
void FMeshDescription : : DeleteTriangle_Internal ( const FTriangleID TriangleID , TContainer < FEdgeID > * InOutOrphanedEdgesPtr , TContainer < FVertexInstanceID > * InOutOrphanedVertexInstancesPtr , TContainer < FPolygonGroupID > * InOutOrphanedPolygonGroupsPtr )
Total revamp of mesh element attribute model.
Attributes now have a number of possible types (FVector, FVector4, FVector2D, float, int, bool, FName, UObject*) and are exposed as individual flat arrays, indexed by element ID. For example, vertex positions are essentially exposed as an array of FVector which can be directly accessed and modified. This has a number of advantages:
- It is completely extensible: new attributes can be created (even by a third party) and added to a mesh description without requiring a serialization version bump, or any change to the parent structures.
- This is more efficient in batch operations which deal with a number of mesh elements in one go.
- These attribute buffers can potentially be passed directly to third-party libraries without requiring any kind of transformation.
- The distinct types allow for a better representation of the attribute being specified, without invalid values being possible (cf representing a bool value in an FVector4).
Attributes also have default values, and a flags field which confers use-specific properties to them. Editable Mesh currently uses this to determine whether an attribute's value can be automatically initialized by lerping the values of its neighbours, as well as for identifying auto-generated attributes such as tangents/normals. This is desirable as it means that even unknown / third-party attributes can potentially be handled transparently by Editable Mesh, without requiring the code to be extended.
Certain higher-level operations in EditableMesh have been optimized to make full use of vertex instances where possible.
The welding/splitting of identical vertex instances has been removed from here, as the aim is to unify this with mesh utility code elsewhere.
Various bug fixes.
#rb Alexis.Matte
[CL 3794563 by Richard TalbotWatkin in Dev-Geometry branch]
2017-12-07 13:02:12 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FPolygonGroupID PolygonGroupID = TrianglePolygonGroups [ TriangleID ] ;
PolygonGroupToTriangles . RemoveReferenceFromKey ( PolygonGroupID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FPolygonID PolygonID = TrianglePolygons [ TriangleID ] ;
PolygonToTriangles . RemoveReferenceFromKey ( PolygonID , TriangleID ) ;
2020-07-16 08:23:15 -04:00
TArrayView < FVertexInstanceID > TriVertexInstanceIDs = TriangleVertexInstances [ TriangleID ] ;
TArrayView < FEdgeID > TriEdgeIDs = TriangleEdges [ TriangleID ] ;
for ( int32 Index = 0 ; Index < 3 ; + + Index )
{
// Remove vertex instance from the triangle. Here's how we do that safely:
// 1) Take a copy of the VertexInstance ID
// 2) Remove reference from the VertexInstance to Triangles indexer
// 3) Set the triangle VertexInstance to INDEX_NONE
// 4) Ask the indexer if that VertexInstance ID has any triangle references, and if not, add it to the list.
//
// Step 3 is important because Find() below might need to reindex if the key is stale, and this would cause it to
// re-add the triangle VertexInstance reference if it were still valid, since the triangle hasn't yet been deleted.
//
// We could also wait until the triangle were deleted before querying the indexer, but this would involve taking
// copies of all the referenced element IDs first.
const FVertexInstanceID VertexInstanceID = TriVertexInstanceIDs [ Index ] ;
VertexInstanceToTriangles . RemoveReferenceFromKey ( VertexInstanceID , TriangleID ) ;
TriVertexInstanceIDs [ Index ] = INDEX_NONE ;
if ( InOutOrphanedVertexInstancesPtr & & VertexInstanceToTriangles . Find ( VertexInstanceID ) . Num ( ) = = 0 )
{
AddUnique ( * InOutOrphanedVertexInstancesPtr , VertexInstanceID ) ;
}
// Remove edge from the triangle. Same rules as above apply!
const FEdgeID EdgeID = TriEdgeIDs [ Index ] ;
EdgeToTriangles . RemoveReferenceFromKey ( EdgeID , TriangleID ) ;
TriEdgeIDs [ Index ] = INDEX_NONE ;
if ( InOutOrphanedEdgesPtr & & EdgeToTriangles . Find ( EdgeID ) . Num ( ) = = 0 )
{
AddUnique ( * InOutOrphanedEdgesPtr , EdgeID ) ;
}
// Remove UVs from the triangle if there are any
for ( int32 UVIndex = 0 ; UVIndex < TriangleUVs . GetNumChannels ( ) ; UVIndex + + )
{
TArrayView < const FUVID > TriUVs = TriangleUVs . Get ( TriangleID , UVIndex ) ;
FUVID UVID = TriUVs [ Index ] ;
UVToTriangles . RemoveReferenceFromKey ( UVID , TriangleID , UVIndex ) ;
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( PolygonToTriangles . Find ( PolygonID ) . Num ( ) = = 0 )
2019-09-10 11:35:20 -04:00
{
// If it was the only triangle in the polygon, delete the polygon too
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
check ( PolygonPolygonGroups [ PolygonID ] = = PolygonGroupID ) ;
PolygonGroupToPolygons . RemoveReferenceFromKey ( PolygonGroupID , PolygonID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
PolygonElements - > Get ( ) . Remove ( PolygonID ) ;
PolygonToTriangles . RemoveKey ( PolygonID ) ;
2019-09-10 11:35:20 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TriangleElements - > Get ( ) . Remove ( TriangleID ) ;
2020-07-16 08:23:15 -04:00
// Check orphaned polygon groups after the triangle has been removed so that reindexing won't find it again.
if ( InOutOrphanedPolygonGroupsPtr & & PolygonGroupToTriangles . Find ( PolygonGroupID ) . Num ( ) = = 0 )
{
AddUnique ( * InOutOrphanedPolygonGroupsPtr , PolygonGroupID ) ;
}
2019-09-10 11:35:20 -04:00
}
2020-02-03 11:08:35 -05:00
void FMeshDescription : : DeleteTriangle ( const FTriangleID TriangleID , TArray < FEdgeID > * InOutOrphanedEdgesPtr , TArray < FVertexInstanceID > * InOutOrphanedVertexInstancesPtr , TArray < FPolygonGroupID > * InOutOrphanedPolygonGroupsPtr )
{
DeleteTriangle_Internal < TArray > ( TriangleID , InOutOrphanedEdgesPtr , InOutOrphanedVertexInstancesPtr , InOutOrphanedPolygonGroupsPtr ) ;
}
void FMeshDescription : : DeleteTriangles ( const TArray < FTriangleID > & Triangles )
{
TSet < FEdgeID > OrphanedEdges ;
TSet < FVertexInstanceID > OrphanedVertexInstances ;
TSet < FPolygonGroupID > OrphanedPolygonGroups ;
TSet < FVertexID > OrphanedVertices ;
for ( FTriangleID TriangleID : Triangles )
{
DeleteTriangle_Internal < TSet > ( TriangleID , & OrphanedEdges , & OrphanedVertexInstances , & OrphanedPolygonGroups ) ;
}
for ( FPolygonGroupID PolygonGroupID : OrphanedPolygonGroups )
{
DeletePolygonGroup ( PolygonGroupID ) ;
}
for ( FVertexInstanceID VertexInstanceID : OrphanedVertexInstances )
{
DeleteVertexInstance_Internal < TSet > ( VertexInstanceID , & OrphanedVertices ) ;
}
for ( FEdgeID EdgeID : OrphanedEdges )
{
DeleteEdge_Internal < TSet > ( EdgeID , & OrphanedVertices ) ;
}
for ( FVertexID VertexID : OrphanedVertices )
{
DeleteVertex ( VertexID ) ;
}
}
2019-09-10 11:35:20 -04:00
void FMeshDescription : : CreatePolygon_Internal ( const FPolygonID PolygonID , const FPolygonGroupID PolygonGroupID , TArrayView < const FVertexInstanceID > VertexInstanceIDs , TArray < FEdgeID > * OutEdgeIDs )
{
if ( OutEdgeIDs )
{
OutEdgeIDs - > Empty ( ) ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
check ( PolygonGroupID ! = INDEX_NONE ) ;
PolygonPolygonGroups [ PolygonID ] = PolygonGroupID ;
PolygonGroupToPolygons . AddReferenceToKey ( PolygonGroupID , PolygonID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const int32 NumVertices = VertexInstanceIDs . Num ( ) ;
2019-09-10 11:35:20 -04:00
for ( int32 Index = 0 ; Index < NumVertices ; + + Index )
{
const FVertexInstanceID ThisVertexInstanceID = VertexInstanceIDs [ Index ] ;
const FVertexInstanceID NextVertexInstanceID = VertexInstanceIDs [ ( Index + 1 = = NumVertices ) ? 0 : Index + 1 ] ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID ThisVertexID = VertexInstanceVertices [ ThisVertexInstanceID ] ;
const FVertexID NextVertexID = VertexInstanceVertices [ NextVertexInstanceID ] ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Create any missing perimeter edges here (not internal edges; they will be created when the polygon triangles are created)
2019-09-10 11:35:20 -04:00
FEdgeID EdgeID = GetVertexPairEdge ( ThisVertexID , NextVertexID ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( EdgeID = = INDEX_NONE )
2019-09-10 11:35:20 -04:00
{
EdgeID = CreateEdge ( ThisVertexID , NextVertexID ) ;
if ( OutEdgeIDs )
{
OutEdgeIDs - > Add ( EdgeID ) ;
}
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
CreatePolygonTriangles ( PolygonID , VertexInstanceIDs ) ;
2019-09-10 11:35:20 -04:00
}
2020-02-03 11:08:35 -05:00
template < template < typename . . . > class TContainer >
void FMeshDescription : : DeletePolygon_Internal ( const FPolygonID PolygonID , TContainer < FEdgeID > * InOutOrphanedEdgesPtr , TContainer < FVertexInstanceID > * InOutOrphanedVertexInstancesPtr , TContainer < FPolygonGroupID > * InOutOrphanedPolygonGroupsPtr )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FPolygonGroupID PolygonGroupID = PolygonPolygonGroups [ PolygonID ] ;
2019-09-10 11:35:20 -04:00
// Remove constituent triangles
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < const FTriangleID > TriangleIDs = PolygonToTriangles . Find < FTriangleID > ( PolygonID ) ;
TArray < FEdgeID , TInlineAllocator < 8 > > InternalEdgesToRemove ;
InternalEdgesToRemove . Reserve ( TriangleIDs . Num ( ) - 1 ) ;
// Disconnect edges and vertex instances
for ( const FTriangleID TriangleID : TriangleIDs )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < FVertexInstanceID > TriVertexInstanceIDs = TriangleVertexInstances [ TriangleID ] ;
TArrayView < FEdgeID > TriEdgeIDs = TriangleEdges [ TriangleID ] ;
2019-09-10 11:35:20 -04:00
for ( int32 Index = 0 ; Index < 3 ; + + Index )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FEdgeID EdgeID = TriEdgeIDs [ Index ] ;
if ( IsEdgeInternal ( EdgeID ) )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Remove internal edges - but not yet.
// For now just make a note of them.
InternalEdgesToRemove . AddUnique ( EdgeID ) ;
}
else
{
EdgeToTriangles . RemoveReferenceFromKey ( EdgeID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Set the reference to INDEX_NONE here, so that it won't be picked up in the Find() below
// if it needs to rebuild the key.
TriEdgeIDs [ Index ] = INDEX_NONE ;
if ( InOutOrphanedEdgesPtr & & EdgeToTriangles . Find ( EdgeID ) . Num ( ) = = 0 )
{
AddUnique ( * InOutOrphanedEdgesPtr , EdgeID ) ;
2019-09-10 11:35:20 -04:00
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexInstanceID VertexInstanceID = TriVertexInstanceIDs [ Index ] ;
VertexInstanceToTriangles . RemoveReferenceFromKey ( VertexInstanceID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Set the reference to INDEX_NONE here, so that it won't be picked up in the Find() below
// if it needs to rebuild the key.
TriVertexInstanceIDs [ Index ] = INDEX_NONE ;
if ( InOutOrphanedVertexInstancesPtr & & VertexInstanceToTriangles . Find ( VertexInstanceID ) . Num ( ) = = 0 )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
AddUnique ( * InOutOrphanedVertexInstancesPtr , VertexInstanceID ) ;
2019-09-10 11:35:20 -04:00
}
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Remove triangles
for ( const FTriangleID TriangleID : TriangleIDs )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
check ( TrianglePolygonGroups [ TriangleID ] = = PolygonGroupID ) ;
PolygonGroupToTriangles . RemoveReferenceFromKey ( PolygonGroupID , TriangleID ) ;
TriangleElements - > Get ( ) . Remove ( TriangleID ) ;
2019-09-10 11:35:20 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Remove internal edges
for ( const FEdgeID EdgeID : InternalEdgesToRemove )
{
for ( const FVertexID EdgeVertexID : EdgeVertices [ EdgeID ] )
{
VertexToEdges . RemoveReferenceFromKey ( EdgeVertexID , EdgeID ) ;
}
EdgeElements - > Get ( ) . Remove ( EdgeID ) ;
EdgeToTriangles . RemoveKey ( EdgeID ) ;
}
PolygonGroupToPolygons . RemoveReferenceFromKey ( PolygonGroupID , PolygonID ) ;
PolygonElements - > Get ( ) . Remove ( PolygonID ) ;
PolygonToTriangles . RemoveKey ( PolygonID ) ;
if ( InOutOrphanedPolygonGroupsPtr & & PolygonGroupToPolygons . Find ( PolygonGroupID ) . Num ( ) = = 0 )
{
AddUnique ( * InOutOrphanedPolygonGroupsPtr , PolygonGroupID ) ;
}
Total revamp of mesh element attribute model.
Attributes now have a number of possible types (FVector, FVector4, FVector2D, float, int, bool, FName, UObject*) and are exposed as individual flat arrays, indexed by element ID. For example, vertex positions are essentially exposed as an array of FVector which can be directly accessed and modified. This has a number of advantages:
- It is completely extensible: new attributes can be created (even by a third party) and added to a mesh description without requiring a serialization version bump, or any change to the parent structures.
- This is more efficient in batch operations which deal with a number of mesh elements in one go.
- These attribute buffers can potentially be passed directly to third-party libraries without requiring any kind of transformation.
- The distinct types allow for a better representation of the attribute being specified, without invalid values being possible (cf representing a bool value in an FVector4).
Attributes also have default values, and a flags field which confers use-specific properties to them. Editable Mesh currently uses this to determine whether an attribute's value can be automatically initialized by lerping the values of its neighbours, as well as for identifying auto-generated attributes such as tangents/normals. This is desirable as it means that even unknown / third-party attributes can potentially be handled transparently by Editable Mesh, without requiring the code to be extended.
Certain higher-level operations in EditableMesh have been optimized to make full use of vertex instances where possible.
The welding/splitting of identical vertex instances has been removed from here, as the aim is to unify this with mesh utility code elsewhere.
Various bug fixes.
#rb Alexis.Matte
[CL 3794563 by Richard TalbotWatkin in Dev-Geometry branch]
2017-12-07 13:02:12 -05:00
}
2017-12-28 17:15:00 -05:00
2020-02-03 11:08:35 -05:00
void FMeshDescription : : DeletePolygon ( const FPolygonID PolygonID , TArray < FEdgeID > * InOutOrphanedEdgesPtr , TArray < FVertexInstanceID > * InOutOrphanedVertexInstancesPtr , TArray < FPolygonGroupID > * InOutOrphanedPolygonGroupsPtr )
{
DeletePolygon_Internal < TArray > ( PolygonID , InOutOrphanedEdgesPtr , InOutOrphanedVertexInstancesPtr , InOutOrphanedPolygonGroupsPtr ) ;
}
void FMeshDescription : : DeletePolygons ( const TArray < FPolygonID > & Polygons )
{
TSet < FEdgeID > OrphanedEdges ;
TSet < FVertexInstanceID > OrphanedVertexInstances ;
TSet < FPolygonGroupID > OrphanedPolygonGroups ;
TSet < FVertexID > OrphanedVertices ;
for ( FPolygonID PolygonID : Polygons )
{
DeletePolygon_Internal < TSet > ( PolygonID , & OrphanedEdges , & OrphanedVertexInstances , & OrphanedPolygonGroups ) ;
}
for ( FPolygonGroupID PolygonGroupID : OrphanedPolygonGroups )
{
DeletePolygonGroup ( PolygonGroupID ) ;
}
for ( FVertexInstanceID VertexInstanceID : OrphanedVertexInstances )
{
DeleteVertexInstance_Internal < TSet > ( VertexInstanceID , & OrphanedVertices ) ;
}
for ( FEdgeID EdgeID : OrphanedEdges )
{
DeleteEdge_Internal < TSet > ( EdgeID , & OrphanedVertices ) ;
}
for ( FVertexID VertexID : OrphanedVertices )
{
DeleteVertex ( VertexID ) ;
}
}
2017-12-28 17:15:00 -05:00
2019-12-19 18:07:47 -05:00
bool FMeshDescription : : IsVertexOrphaned ( const FVertexID VertexID ) const
2018-01-29 17:04:17 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < const FVertexInstanceID > VertexInstanceIDs = VertexToVertexInstances . Find < FVertexInstanceID > ( VertexID ) ;
for ( const FVertexInstanceID VertexInstanceID : VertexInstanceIDs )
2018-01-29 17:04:17 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < const FTriangleID > TriangleIDs = VertexInstanceToTriangles . Find < FTriangleID > ( VertexInstanceID ) ;
if ( TriangleIDs . Num ( ) > 0 )
2018-01-29 17:04:17 -05:00
{
return false ;
}
}
return true ;
}
2019-09-10 11:35:20 -04:00
FEdgeID FMeshDescription : : GetVertexPairEdge ( const FVertexID VertexID0 , const FVertexID VertexID1 ) const
2018-01-29 17:04:17 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < const FEdgeID > ConnectedEdgeIDs = VertexToEdges . Find < FEdgeID > ( VertexID0 ) ;
for ( const FEdgeID VertexConnectedEdgeID : ConnectedEdgeIDs )
2017-12-28 17:15:00 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID EdgeVertexID0 = EdgeVertices [ VertexConnectedEdgeID ] [ 0 ] ;
const FVertexID EdgeVertexID1 = EdgeVertices [ VertexConnectedEdgeID ] [ 1 ] ;
2019-09-10 11:35:20 -04:00
if ( ( EdgeVertexID0 = = VertexID0 & & EdgeVertexID1 = = VertexID1 ) | | ( EdgeVertexID0 = = VertexID1 & & EdgeVertexID1 = = VertexID0 ) )
{
return VertexConnectedEdgeID ;
}
2017-12-28 17:15:00 -05:00
}
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
return INDEX_NONE ;
2017-12-28 17:15:00 -05:00
}
2018-01-29 17:04:17 -05:00
2019-09-10 11:35:20 -04:00
FEdgeID FMeshDescription : : GetVertexInstancePairEdge ( const FVertexInstanceID VertexInstanceID0 , const FVertexInstanceID VertexInstanceID1 ) const
2017-12-28 17:15:00 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID VertexID0 = VertexInstanceVertices [ VertexInstanceID0 ] ;
const FVertexID VertexID1 = VertexInstanceVertices [ VertexInstanceID1 ] ;
TArrayView < const FEdgeID > ConnectedEdgeIDs = VertexToEdges . Find < FEdgeID > ( VertexID0 ) ;
for ( const FEdgeID VertexConnectedEdgeID : ConnectedEdgeIDs )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID EdgeVertexID0 = EdgeVertices [ VertexConnectedEdgeID ] [ 0 ] ;
const FVertexID EdgeVertexID1 = EdgeVertices [ VertexConnectedEdgeID ] [ 1 ] ;
2019-09-10 11:35:20 -04:00
if ( ( EdgeVertexID0 = = VertexID0 & & EdgeVertexID1 = = VertexID1 ) | | ( EdgeVertexID0 = = VertexID1 & & EdgeVertexID1 = = VertexID0 ) )
{
return VertexConnectedEdgeID ;
}
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
return INDEX_NONE ;
2017-12-28 17:15:00 -05:00
}
2018-06-07 16:22:56 -04:00
2019-09-10 11:35:20 -04:00
void FMeshDescription : : SetPolygonVertexInstance ( const FPolygonID PolygonID , const int32 PerimeterIndex , const FVertexInstanceID VertexInstanceID )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < const FTriangleID > Tris = PolygonToTriangles . Find < FTriangleID > ( PolygonID ) ;
if ( Tris . Num ( ) = = 1 )
2017-12-28 17:15:00 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
check ( PerimeterIndex < 3 ) ;
FVertexInstanceID OldVertexInstanceID = TriangleVertexInstances [ Tris [ 0 ] ] [ PerimeterIndex ] ;
check ( VertexInstanceVertices [ OldVertexInstanceID ] = = VertexInstanceVertices [ VertexInstanceID ] ) ;
VertexInstanceToTriangles . RemoveReferenceFromKey ( OldVertexInstanceID , Tris [ 0 ] ) ;
TriangleVertexInstances [ Tris [ 0 ] ] [ PerimeterIndex ] = VertexInstanceID ;
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , Tris [ 0 ] ) ;
}
else
{
TArray < FVertexInstanceID , TInlineAllocator < 8 > > PolygonVertexInstances = GetPolygonVertexInstances < TInlineAllocator < 8 > > ( PolygonID ) ;
check ( PerimeterIndex < PolygonVertexInstances . Num ( ) ) ;
FVertexInstanceID OldVertexInstanceID = PolygonVertexInstances [ PerimeterIndex ] ;
check ( VertexInstanceVertices [ OldVertexInstanceID ] = = VertexInstanceVertices [ VertexInstanceID ] ) ;
for ( const FTriangleID Tri : Tris )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( FVertexInstanceID & VertexInstance : TriangleVertexInstances [ Tri ] )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( VertexInstance = = OldVertexInstanceID )
{
VertexInstanceToTriangles . RemoveReferenceFromKey ( OldVertexInstanceID , Tri ) ;
VertexInstance = VertexInstanceID ;
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , Tri ) ;
}
2019-09-10 11:35:20 -04:00
}
}
2017-12-28 17:15:00 -05:00
}
}
2018-06-07 16:22:56 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
void FMeshDescription : : SetPolygonVertexInstances ( const FPolygonID PolygonID , TArrayView < const FVertexInstanceID > VertexInstanceIDs )
{
RemovePolygonTriangles ( PolygonID ) ;
CreatePolygonTriangles ( PolygonID , VertexInstanceIDs ) ;
}
FPlane FMeshDescription : : ComputePolygonPlane ( TArrayView < const FVertexInstanceID > PerimeterVertexInstanceIDs ) const
2017-12-28 17:15:00 -05:00
{
2019-06-07 11:22:52 -04:00
// NOTE: This polygon plane computation code is partially based on the implementation of "Newell's method" from Real-Time
2017-12-28 17:15:00 -05:00
// Collision Detection by Christer Ericson, published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc
// @todo mesheditor perf: For polygons that are just triangles, use a cross product to get the normal fast!
// @todo mesheditor perf: We could skip computing the plane distance when we only need the normal
// @todo mesheditor perf: We could cache these computed polygon normals; or just use the normal of the first three vertices' triangle if it is satisfactory in all cases
// @todo mesheditor: For non-planar polygons, the result can vary. Ideally this should use the actual polygon triangulation as opposed to the arbitrary triangulation used here.
FVector Centroid = FVector : : ZeroVector ;
FVector Normal = FVector : : ZeroVector ;
// Use 'Newell's Method' to compute a robust 'best fit' plane from the vertices of this polygon
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( int32 VertexNumberI = PerimeterVertexInstanceIDs . Num ( ) - 1 , VertexNumberJ = 0 ; VertexNumberJ < PerimeterVertexInstanceIDs . Num ( ) ; VertexNumberI = VertexNumberJ , VertexNumberJ + + )
2017-12-28 17:15:00 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID VertexIDI = PerimeterVertexInstanceIDs [ VertexNumberI ] ;
2021-05-05 15:07:25 -04:00
const FVector3f PositionI = VertexPositions [ VertexInstanceVertices [ VertexIDI ] ] ;
2017-12-28 17:15:00 -05:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexID VertexIDJ = PerimeterVertexInstanceIDs [ VertexNumberJ ] ;
2021-05-05 15:07:25 -04:00
const FVector3f PositionJ = VertexPositions [ VertexInstanceVertices [ VertexIDJ ] ] ;
2017-12-28 17:15:00 -05:00
Centroid + = PositionJ ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
Normal . X + = ( PositionJ . Y - PositionI . Y ) * ( PositionI . Z + PositionJ . Z ) ;
Normal . Y + = ( PositionJ . Z - PositionI . Z ) * ( PositionI . X + PositionJ . X ) ;
Normal . Z + = ( PositionJ . X - PositionI . X ) * ( PositionI . Y + PositionJ . Y ) ;
2017-12-28 17:15:00 -05:00
}
Normal . Normalize ( ) ;
// Construct a plane from the normal and centroid
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
return FPlane ( Normal , FVector : : DotProduct ( Centroid , Normal ) / ( float ) PerimeterVertexInstanceIDs . Num ( ) ) ;
2017-12-28 17:15:00 -05:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
FVector FMeshDescription : : ComputePolygonNormal ( TArrayView < const FVertexInstanceID > PerimeterVertexInstanceIDs ) const
2017-12-28 17:15:00 -05:00
{
// @todo mesheditor: Polygon normals are now computed and cached when changes are made to a polygon.
// In theory, we can just return that cached value, but we need to check that there is nothing which relies on the value being correct before
// the cache is updated at the end of a modification.
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FPlane PolygonPlane = ComputePolygonPlane ( PerimeterVertexInstanceIDs ) ;
const FVector PolygonNormal ( PolygonPlane . X , PolygonPlane . Y , PolygonPlane . Z ) ;
2017-12-28 17:15:00 -05:00
return PolygonNormal ;
}
2018-06-07 16:22:56 -04:00
2019-09-10 11:35:20 -04:00
/** Returns true if the triangle formed by the specified three positions has a normal that is facing the opposite direction of the reference normal */
static bool IsTriangleFlipped ( const FVector ReferenceNormal , const FVector VertexPositionA , const FVector VertexPositionB , const FVector VertexPositionC )
{
const FVector TriangleNormal = FVector : : CrossProduct (
VertexPositionC - VertexPositionA ,
VertexPositionB - VertexPositionA ) . GetSafeNormal ( ) ;
return ( FVector : : DotProduct ( ReferenceNormal , TriangleNormal ) < = 0.0f ) ;
}
/** Given three direction vectors, indicates if A and B are on the same 'side' of Vec. */
static bool VectorsOnSameSide ( const FVector & Vec , const FVector & A , const FVector & B , const float SameSideDotProductEpsilon )
{
const FVector CrossA = FVector : : CrossProduct ( Vec , A ) ;
const FVector CrossB = FVector : : CrossProduct ( Vec , B ) ;
float DotWithEpsilon = SameSideDotProductEpsilon + FVector : : DotProduct ( CrossA , CrossB ) ;
return ! FMath : : IsNegativeFloat ( DotWithEpsilon ) ;
}
/** Util to see if P lies within triangle created by A, B and C. */
static bool PointInTriangle ( const FVector & A , const FVector & B , const FVector & C , const FVector & P , const float InsideTriangleDotProductEpsilon )
{
// Cross product indicates which 'side' of the vector the point is on
// If its on the same side as the remaining vert for all edges, then its inside.
return ( VectorsOnSameSide ( B - A , P - A , C - A , InsideTriangleDotProductEpsilon ) & &
VectorsOnSameSide ( C - B , P - B , A - B , InsideTriangleDotProductEpsilon ) & &
VectorsOnSameSide ( A - C , P - C , B - C , InsideTriangleDotProductEpsilon ) ) ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
void FMeshDescription : : FindPolygonPerimeter ( const FPolygonID PolygonID , TArrayView < FEdgeID > Edges ) const
{
TArrayView < const FTriangleID > PolygonTris = PolygonToTriangles . Find < FTriangleID > ( PolygonID ) ;
check ( Edges . Num ( ) = = PolygonTris . Num ( ) + 2 ) ;
// Optimization for simple triangle
if ( PolygonTris . Num ( ) = = 1 )
{
for ( int I = 0 ; I < 3 ; I + + )
{
Edges [ I ] = TriangleEdges [ PolygonTris [ 0 ] ] [ I ] ;
}
return ;
}
// Determine perimeter for arbitrary n-gon.
// @todo: This process can undoubtedly be optimized
// Build a set of all the perimeter edges
TArray < FEdgeID , TInlineAllocator < 8 > > PerimeterEdges ;
TArray < int32 , TInlineAllocator < 8 > > TriIndices ;
for ( int32 TriIndex = 0 ; TriIndex < PolygonTris . Num ( ) ; TriIndex + + )
{
FTriangleID PolygonTri = PolygonTris [ TriIndex ] ;
TArrayView < const FEdgeID > TriEdges = TriangleEdges [ PolygonTri ] ;
for ( FEdgeID EdgeID : TriEdges )
{
int32 EdgeIndex = PerimeterEdges . Find ( EdgeID ) ;
if ( EdgeIndex ! = INDEX_NONE )
{
// If adding an edge which already exists, it must be an internal edge, so remove it again.
PerimeterEdges . RemoveAtSwap ( EdgeIndex , 1 , false ) ;
TriIndices . RemoveAtSwap ( EdgeIndex , 1 , false ) ;
}
else
{
PerimeterEdges . Add ( EdgeID ) ;
TriIndices . Add ( TriIndex ) ;
}
}
}
check ( PerimeterEdges . Num ( ) = = PolygonTris . Num ( ) + 2 ) ;
check ( PerimeterEdges . Num ( ) = = TriIndices . Num ( ) ) ;
// Reorder edges to be adjacent by ensuring there's a mutual vertex in consecutive edges
for ( int32 EdgeIndex = 0 ; EdgeIndex < PerimeterEdges . Num ( ) - 2 ; EdgeIndex + + )
{
TArrayView < const FVertexID > EdgeVertexIDs = EdgeVertices [ PerimeterEdges [ EdgeIndex ] ] ;
for ( int32 NextEdgeIndex = EdgeIndex + 1 ; NextEdgeIndex < PerimeterEdges . Num ( ) ; NextEdgeIndex + + )
{
TArrayView < const FVertexID > NextEdgeVertexIDs = EdgeVertices [ PerimeterEdges [ NextEdgeIndex ] ] ;
if ( EdgeVertexIDs [ 0 ] = = NextEdgeVertexIDs [ 0 ] | | EdgeVertexIDs [ 0 ] = = NextEdgeVertexIDs [ 1 ] | |
EdgeVertexIDs [ 1 ] = = NextEdgeVertexIDs [ 0 ] | | EdgeVertexIDs [ 1 ] = = NextEdgeVertexIDs [ 1 ] )
{
if ( NextEdgeIndex > EdgeIndex + 1 )
{
Swap ( PerimeterEdges [ EdgeIndex + 1 ] , PerimeterEdges [ NextEdgeIndex ] ) ;
Swap ( TriIndices [ EdgeIndex + 1 ] , TriIndices [ NextEdgeIndex ] ) ;
}
break ;
}
}
}
check ( EdgeVertices [ PerimeterEdges . Last ( ) ] [ 0 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 0 ] | | EdgeVertices [ PerimeterEdges . Last ( ) ] [ 0 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 1 ] | |
EdgeVertices [ PerimeterEdges . Last ( ) ] [ 1 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 0 ] | | EdgeVertices [ PerimeterEdges . Last ( ) ] [ 1 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 1 ] ) ;
// Swap the winding order if incorrect
FEdgeID FirstEdge = PerimeterEdges [ 0 ] ;
FEdgeID SecondEdge = PerimeterEdges [ 1 ] ;
// Get the triangle which the first edge lies in
FTriangleID FirstTriangle = PolygonTris [ TriIndices [ 0 ] ] ;
int32 TriEdgeIndex = TriangleEdges [ FirstTriangle ] . Find ( FirstEdge ) ;
// Get the end vertex of the edge as used in that triangle
FVertexID SecondVertex = TriangleVertices [ FirstTriangle ] [ ( TriEdgeIndex + 1 ) % 3 ] ;
// If the second edge doesn't contain that end vertex, we need to reverse the order of the edges we just constructed
if ( EdgeVertices [ SecondEdge ] [ 0 ] ! = SecondVertex & & EdgeVertices [ SecondEdge ] [ 1 ] ! = SecondVertex )
{
for ( int32 I = 0 ; I < PerimeterEdges . Num ( ) / 2 ; I + + )
{
Swap ( PerimeterEdges [ I ] , PerimeterEdges [ PerimeterEdges . Num ( ) - 1 - I ] ) ;
Swap ( TriIndices [ I ] , TriIndices [ PerimeterEdges . Num ( ) - 1 - I ] ) ;
}
}
for ( int I = 0 ; I < PerimeterEdges . Num ( ) ; I + + )
{
Edges [ I ] = PerimeterEdges [ I ] ;
}
}
void FMeshDescription : : FindPolygonPerimeter ( TArrayView < const FTriangleID > Triangles , TArrayView < TTuple < int32 , int32 > > Result ) const
{
// This constructs the perimeter indices for a polygon in the correct winding order from its constituent triangles
check ( Result . Num ( ) = = Triangles . Num ( ) + 2 ) ;
// Optimization for simple triangle
if ( Triangles . Num ( ) = = 1 )
{
// Return triangle index 0; edges 0, 1, 2
Result [ 0 ] = MakeTuple ( 0 , 0 ) ;
Result [ 1 ] = MakeTuple ( 0 , 1 ) ;
Result [ 2 ] = MakeTuple ( 0 , 2 ) ;
return ;
}
// Determine perimeter for arbitrary n-gon.
// @todo: This process can undoubtedly be optimized
// Build a set of all the perimeter edges
TArray < FEdgeID , TInlineAllocator < 8 > > PerimeterEdges ;
TArray < TTuple < int32 , int32 > , TInlineAllocator < 8 > > Indices ;
for ( int32 TriIndex = 0 ; TriIndex < Triangles . Num ( ) ; TriIndex + + )
{
FTriangleID PolygonTri = Triangles [ TriIndex ] ;
TArrayView < const FEdgeID > TriEdges = TriangleEdges [ PolygonTri ] ;
for ( int32 EdgeIndex = 0 ; EdgeIndex < 3 ; EdgeIndex + + )
{
FEdgeID EdgeID = TriEdges [ EdgeIndex ] ;
int32 PerimeterIndex = PerimeterEdges . Find ( EdgeID ) ;
if ( PerimeterIndex ! = INDEX_NONE )
{
// If adding an edge which already exists, it must be an internal edge, so remove it again.
PerimeterEdges . RemoveAtSwap ( PerimeterIndex , 1 , false ) ;
Indices . RemoveAtSwap ( PerimeterIndex , 1 , false ) ;
}
else
{
PerimeterEdges . Add ( EdgeID ) ;
Indices . Add ( MakeTuple ( TriIndex , EdgeIndex ) ) ;
}
}
}
check ( PerimeterEdges . Num ( ) = = Triangles . Num ( ) + 2 ) ;
check ( PerimeterEdges . Num ( ) = = Indices . Num ( ) ) ;
// Reorder edges to be adjacent by ensuring there's a mutual vertex in consecutive edges
for ( int32 EdgeIndex = 0 ; EdgeIndex < PerimeterEdges . Num ( ) - 2 ; EdgeIndex + + )
{
TArrayView < const FVertexID > EdgeVertexIDs = EdgeVertices [ PerimeterEdges [ EdgeIndex ] ] ;
for ( int32 NextEdgeIndex = EdgeIndex + 1 ; NextEdgeIndex < PerimeterEdges . Num ( ) ; NextEdgeIndex + + )
{
TArrayView < const FVertexID > NextEdgeVertexIDs = EdgeVertices [ PerimeterEdges [ NextEdgeIndex ] ] ;
if ( EdgeVertexIDs [ 0 ] = = NextEdgeVertexIDs [ 0 ] | | EdgeVertexIDs [ 0 ] = = NextEdgeVertexIDs [ 1 ] | |
EdgeVertexIDs [ 1 ] = = NextEdgeVertexIDs [ 0 ] | | EdgeVertexIDs [ 1 ] = = NextEdgeVertexIDs [ 1 ] )
{
if ( NextEdgeIndex > EdgeIndex + 1 )
{
Swap ( PerimeterEdges [ EdgeIndex + 1 ] , PerimeterEdges [ NextEdgeIndex ] ) ;
Swap ( Indices [ EdgeIndex + 1 ] , Indices [ NextEdgeIndex ] ) ;
}
break ;
}
}
}
check ( EdgeVertices [ PerimeterEdges . Last ( ) ] [ 0 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 0 ] | | EdgeVertices [ PerimeterEdges . Last ( ) ] [ 0 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 1 ] | |
EdgeVertices [ PerimeterEdges . Last ( ) ] [ 1 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 0 ] | | EdgeVertices [ PerimeterEdges . Last ( ) ] [ 1 ] = = EdgeVertices [ PerimeterEdges [ 0 ] ] [ 1 ] ) ;
// Swap the winding order if incorrect
FEdgeID FirstEdge = PerimeterEdges [ 0 ] ;
FEdgeID SecondEdge = PerimeterEdges [ 1 ] ;
// Get the triangle which the first edge lies in
FTriangleID FirstTriangle = Triangles [ Indices [ 0 ] . Get < 0 > ( ) ] ;
int32 TriEdgeIndex = TriangleEdges [ FirstTriangle ] . Find ( FirstEdge ) ;
// Get the end vertex of the edge as used in that triangle
FVertexID SecondVertex = TriangleVertices [ FirstTriangle ] [ ( TriEdgeIndex + 1 ) % 3 ] ;
// If the second edge doesn't contain that end vertex, we need to reverse the order of the edges we just constructed
if ( EdgeVertices [ SecondEdge ] [ 0 ] ! = SecondVertex & & EdgeVertices [ SecondEdge ] [ 1 ] ! = SecondVertex )
{
for ( int32 I = 0 ; I < Indices . Num ( ) / 2 ; I + + )
{
Swap ( Indices [ I ] , Indices [ PerimeterEdges . Num ( ) - 1 - I ] ) ;
}
}
for ( int I = 0 ; I < Indices . Num ( ) ; I + + )
{
Result [ I ] = Indices [ I ] ;
}
}
2019-09-10 11:35:20 -04:00
void FMeshDescription : : ComputePolygonTriangulation ( const FPolygonID PolygonID )
2017-12-28 17:15:00 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < const FTriangleID > TriangleIDs = PolygonToTriangles . Find < FTriangleID > ( PolygonID ) ;
2017-12-28 17:15:00 -05:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Not valid to call this on an untriangulated polygon - an untriangulated polygon is no longer valid at all.
check ( TriangleIDs . Num ( ) > 0 ) ;
2017-12-28 17:15:00 -05:00
2019-09-10 11:35:20 -04:00
// If polygon was already triangulated, and only has three vertices, no need to do anything here
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( TriangleIDs . Num ( ) = = 1 )
2019-09-10 11:35:20 -04:00
{
return ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Get the current perimeter vertex instances
TArray < FVertexInstanceID , TInlineAllocator < 8 > > PolygonVertexInstanceIDs = GetPolygonVertexInstances < TInlineAllocator < 8 > > ( PolygonID ) ;
// Remove existing triangles
RemovePolygonTriangles ( PolygonID ) ;
// Perform the triangulation
CreatePolygonTriangles ( PolygonID , PolygonVertexInstanceIDs ) ;
}
void FMeshDescription : : RemovePolygonTriangles ( const FPolygonID PolygonID )
{
TArrayView < const FTriangleID > TriangleIDs = PolygonToTriangles . Find < FTriangleID > ( PolygonID ) ;
const FPolygonGroupID PolygonGroupID = PolygonPolygonGroups [ PolygonID ] ;
2019-09-10 11:35:20 -04:00
// Remove currently configured triangles
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArray < FEdgeID > InternalEdgesToRemove ;
InternalEdgesToRemove . Reserve ( TriangleIDs . Num ( ) - 1 ) ;
for ( const FTriangleID TriangleID : TriangleIDs )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArrayView < FVertexInstanceID > TriVertexInstanceIDs = TriangleVertexInstances [ TriangleID ] ;
TArrayView < FEdgeID > TriEdgeIDs = TriangleEdges [ TriangleID ] ;
2018-06-07 18:49:50 -04:00
2019-09-10 11:35:20 -04:00
for ( int32 Index = 0 ; Index < 3 ; + + Index )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexInstanceToTriangles . RemoveReferenceFromKey ( TriVertexInstanceIDs [ Index ] , TriangleID ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FEdgeID EdgeID = TriEdgeIDs [ Index ] ;
if ( IsEdgeInternal ( EdgeID ) )
{
InternalEdgesToRemove . Add ( EdgeID ) ;
}
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
EdgeToTriangles . RemoveReferenceFromKey ( EdgeID , TriangleID ) ;
}
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
PolygonGroupToTriangles . RemoveReferenceFromKey ( PolygonGroupID , TriangleID ) ;
TriangleElements - > Get ( ) . Remove ( TriangleID ) ;
}
PolygonToTriangles . RemoveKey ( PolygonID ) ;
// Remove internal edges
for ( const FEdgeID EdgeID : InternalEdgesToRemove )
{
for ( const FVertexID EdgeVertexID : EdgeVertices [ EdgeID ] )
{
VertexToEdges . RemoveReferenceFromKey ( EdgeVertexID , EdgeID ) ;
}
EdgeElements - > Get ( ) . Remove ( EdgeID ) ;
EdgeToTriangles . RemoveKey ( EdgeID ) ;
}
}
void FMeshDescription : : CreatePolygonTriangles ( const FPolygonID PolygonID , TArrayView < const FVertexInstanceID > VertexInstanceIDs )
{
FPolygonGroupID PolygonGroupID = PolygonPolygonGroups [ PolygonID ] ;
// If perimeter only has 3 vertices, just add a single triangle and return
if ( VertexInstanceIDs . Num ( ) = = 3 )
{
const FTriangleID TriangleID = TriangleElements - > Get ( ) . Add ( ) ;
// Fill out triangle vertex instances
TArrayView < FVertexInstanceID > TriVertexInstanceIDs = TriangleVertexInstances [ TriangleID ] ;
TriVertexInstanceIDs [ 0 ] = VertexInstanceIDs [ 0 ] ;
TriVertexInstanceIDs [ 1 ] = VertexInstanceIDs [ 1 ] ;
TriVertexInstanceIDs [ 2 ] = VertexInstanceIDs [ 2 ] ;
// Fill out triangle polygon group
TrianglePolygonGroups [ TriangleID ] = PolygonGroupID ;
PolygonGroupToTriangles . AddReferenceToKey ( PolygonGroupID , TriangleID ) ;
// Fill out triangle polygon
TrianglePolygons [ TriangleID ] = PolygonID ;
PolygonToTriangles . AddReferenceToKey ( PolygonID , TriangleID ) ;
TArrayView < FVertexID > TriVertexIDs = TriangleVertices [ TriangleID ] ;
TArrayView < FEdgeID > TriEdgeIDs = TriangleEdges [ TriangleID ] ;
for ( int32 Index = 0 ; Index < 3 ; + + Index )
{
const FVertexInstanceID VertexInstanceID = TriVertexInstanceIDs [ Index ] ;
const FVertexInstanceID NextVertexInstanceID = TriVertexInstanceIDs [ ( Index = = 2 ) ? 0 : Index + 1 ] ;
const FVertexID ThisVertexID = VertexInstanceVertices [ VertexInstanceID ] ;
const FVertexID NextVertexID = VertexInstanceVertices [ NextVertexInstanceID ] ;
TriVertexIDs [ Index ] = ThisVertexID ;
FEdgeID EdgeID = GetVertexPairEdge ( ThisVertexID , NextVertexID ) ;
check ( EdgeID ! = INDEX_NONE ) ;
TriEdgeIDs [ Index ] = EdgeID ;
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , TriangleID ) ;
EdgeToTriangles . AddReferenceToKey ( EdgeID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
}
2018-06-07 18:49:50 -04:00
return ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// NOTE: This polygon triangulation code is partially based on the ear cutting algorithm described on
// page 497 of the book "Real-time Collision Detection", published in 2005.
2019-09-10 11:35:20 -04:00
// @todo mesheditor: Perhaps should always attempt to triangulate by splitting polygons along the shortest edge, for better determinism.
2017-12-28 17:15:00 -05:00
// First figure out the polygon normal. We need this to determine which triangles are convex, so that
// we can figure out which ears to clip
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVector PolygonNormal = ComputePolygonNormal ( VertexInstanceIDs ) ;
2017-12-28 17:15:00 -05:00
// Make a simple linked list array of the previous and next vertex numbers, for each vertex number
// in the polygon. This will just save us having to iterate later on.
2019-09-10 11:35:20 -04:00
TArray < int32 > PrevVertexNumbers ;
TArray < int32 > NextVertexNumbers ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArray < FVector > PolyVertexPositions ;
int32 PolygonVertexCount = VertexInstanceIDs . Num ( ) ;
2017-12-28 17:15:00 -05:00
{
PrevVertexNumbers . SetNumUninitialized ( PolygonVertexCount , false ) ;
NextVertexNumbers . SetNumUninitialized ( PolygonVertexCount , false ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
PolyVertexPositions . SetNumUninitialized ( PolygonVertexCount , false ) ;
2017-12-28 17:15:00 -05:00
for ( int32 VertexNumber = 0 ; VertexNumber < PolygonVertexCount ; + + VertexNumber )
{
PrevVertexNumbers [ VertexNumber ] = VertexNumber - 1 ;
NextVertexNumbers [ VertexNumber ] = VertexNumber + 1 ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
PolyVertexPositions [ VertexNumber ] = VertexPositions [ GetVertexInstanceVertex ( VertexInstanceIDs [ VertexNumber ] ) ] ;
2017-12-28 17:15:00 -05:00
}
PrevVertexNumbers [ 0 ] = PolygonVertexCount - 1 ;
NextVertexNumbers [ PolygonVertexCount - 1 ] = 0 ;
}
int32 EarVertexNumber = 0 ;
int32 EarTestCount = 0 ;
for ( int32 RemainingVertexCount = PolygonVertexCount ; RemainingVertexCount > = 3 ; )
{
bool bIsEar = true ;
// If we're down to only a triangle, just treat it as an ear. Also, if we've tried every possible candidate
// vertex looking for an ear, go ahead and just treat the current vertex as an ear. This can happen when
// vertices are colinear or other degenerate cases.
if ( RemainingVertexCount > 3 & & EarTestCount < RemainingVertexCount )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVector PrevVertexPosition = PolyVertexPositions [ PrevVertexNumbers [ EarVertexNumber ] ] ;
const FVector EarVertexPosition = PolyVertexPositions [ EarVertexNumber ] ;
const FVector NextVertexPosition = PolyVertexPositions [ NextVertexNumbers [ EarVertexNumber ] ] ;
2017-12-28 17:15:00 -05:00
2019-09-10 11:35:20 -04:00
// Figure out whether the potential ear triangle is facing the same direction as the polygon
// itself. If it's facing the opposite direction, then we're dealing with a concave triangle
// and we'll skip it for now.
if ( ! IsTriangleFlipped ( PolygonNormal , PrevVertexPosition , EarVertexPosition , NextVertexPosition ) )
{
int32 TestVertexNumber = NextVertexNumbers [ NextVertexNumbers [ EarVertexNumber ] ] ;
do
{
// Test every other remaining vertex to make sure that it doesn't lie inside our potential ear
// triangle. If we find a vertex that's inside the triangle, then it cannot actually be an ear.
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVector TestVertexPosition = PolyVertexPositions [ TestVertexNumber ] ;
2019-09-10 11:35:20 -04:00
if ( PointInTriangle ( PrevVertexPosition , EarVertexPosition , NextVertexPosition , TestVertexPosition , SMALL_NUMBER ) )
{
bIsEar = false ;
break ;
}
TestVertexNumber = NextVertexNumbers [ TestVertexNumber ] ;
} while ( TestVertexNumber ! = PrevVertexNumbers [ EarVertexNumber ] ) ;
}
else
{
bIsEar = false ;
}
}
if ( bIsEar )
{
// OK, we found an ear! Let's save this triangle in our output buffer.
// This will also create any missing internal edges.
{
// Add a new triangle
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FTriangleID TriangleID = TriangleElements - > Get ( ) . Add ( ) ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
// Fill out triangle vertex instances
TArrayView < FVertexInstanceID > TriVertexInstanceIDs = TriangleVertexInstances [ TriangleID ] ;
TriVertexInstanceIDs [ 0 ] = VertexInstanceIDs [ PrevVertexNumbers [ EarVertexNumber ] ] ;
TriVertexInstanceIDs [ 1 ] = VertexInstanceIDs [ EarVertexNumber ] ;
TriVertexInstanceIDs [ 2 ] = VertexInstanceIDs [ NextVertexNumbers [ EarVertexNumber ] ] ;
// Fill out triangle polygon group
TrianglePolygonGroups [ TriangleID ] = PolygonGroupID ;
PolygonGroupToTriangles . AddReferenceToKey ( PolygonGroupID , TriangleID ) ;
// Fill out triangle polygon
TrianglePolygons [ TriangleID ] = PolygonID ;
PolygonToTriangles . AddReferenceToKey ( PolygonID , TriangleID ) ;
TArrayView < FVertexID > TriVertexIDs = TriangleVertices [ TriangleID ] ;
TArrayView < FEdgeID > TriEdgeIDs = TriangleEdges [ TriangleID ] ;
2019-09-10 11:35:20 -04:00
for ( int32 Index = 0 ; Index < 3 ; + + Index )
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
const FVertexInstanceID VertexInstanceID = TriVertexInstanceIDs [ Index ] ;
const FVertexInstanceID NextVertexInstanceID = TriVertexInstanceIDs [ ( Index = = 2 ) ? 0 : Index + 1 ] ;
const FVertexID ThisVertexID = VertexInstanceVertices [ VertexInstanceID ] ;
const FVertexID NextVertexID = VertexInstanceVertices [ NextVertexInstanceID ] ;
TriVertexIDs [ Index ] = ThisVertexID ;
2019-09-10 11:35:20 -04:00
FEdgeID EdgeID = GetVertexPairEdge ( ThisVertexID , NextVertexID ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
if ( EdgeID = = INDEX_NONE )
2019-09-10 11:35:20 -04:00
{
// This must be an internal edge (as perimeter edges will already be defined)
EdgeID = CreateEdge ( ThisVertexID , NextVertexID ) ;
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TriEdgeIDs [ Index ] = EdgeID ;
2019-09-10 11:35:20 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
VertexInstanceToTriangles . AddReferenceToKey ( VertexInstanceID , TriangleID ) ;
EdgeToTriangles . AddReferenceToKey ( EdgeID , TriangleID ) ;
2019-09-10 11:35:20 -04:00
}
}
// Update our linked list. We're effectively cutting off the ear by pointing the ear vertex's neighbors to
// point at their next sequential neighbor, and reducing the remaining vertex count by one.
{
NextVertexNumbers [ PrevVertexNumbers [ EarVertexNumber ] ] = NextVertexNumbers [ EarVertexNumber ] ;
PrevVertexNumbers [ NextVertexNumbers [ EarVertexNumber ] ] = PrevVertexNumbers [ EarVertexNumber ] ;
- - RemainingVertexCount ;
}
// Move on to the previous vertex in the list, now that this vertex was cut
EarVertexNumber = PrevVertexNumbers [ EarVertexNumber ] ;
EarTestCount = 0 ;
}
else
{
// The vertex is not the ear vertex, because it formed a triangle that either had a normal which pointed in the opposite direction
// of the polygon, or at least one of the other polygon vertices was found to be inside the triangle. Move on to the next vertex.
EarVertexNumber = NextVertexNumbers [ EarVertexNumber ] ;
// Keep track of how many ear vertices we've tested, so that if we exhaust all remaining vertices, we can
// fall back to clipping the triangle and adding it to our mesh anyway. This is important for degenerate cases.
+ + EarTestCount ;
}
}
}
2019-10-01 20:41:42 -04:00
FBoxSphereBounds FMeshDescription : : GetBounds ( ) const
{
FBoxSphereBounds BoundingBoxAndSphere ;
FBox BoundingBox ;
BoundingBox . Init ( ) ;
for ( const FVertexID VertexID : Vertices ( ) . GetElementIDs ( ) )
{
if ( ! IsVertexOrphaned ( VertexID ) )
{
BoundingBox + = VertexPositions [ VertexID ] ;
}
}
BoundingBox . GetCenterAndExtents ( BoundingBoxAndSphere . Origin , BoundingBoxAndSphere . BoxExtent ) ;
// Calculate the bounding sphere, using the center of the bounding box as the origin.
BoundingBoxAndSphere . SphereRadius = 0.0f ;
for ( const FVertexID VertexID : Vertices ( ) . GetElementIDs ( ) )
{
if ( ! IsVertexOrphaned ( VertexID ) )
{
2021-05-05 15:07:25 -04:00
BoundingBoxAndSphere . SphereRadius = FMath : : Max < FVector : : FReal > ( ( VertexPositions [ VertexID ] - BoundingBoxAndSphere . Origin ) . Size ( ) , BoundingBoxAndSphere . SphereRadius ) ;
2019-10-01 20:41:42 -04:00
}
}
return BoundingBoxAndSphere ;
}
2018-06-07 16:22:56 -04:00
void FMeshDescription : : TriangulateMesh ( )
2017-12-28 17:15:00 -05:00
{
// Perform triangulation directly into mesh polygons
2018-06-07 16:22:56 -04:00
for ( const FPolygonID PolygonID : Polygons ( ) . GetElementIDs ( ) )
2017-12-28 17:15:00 -05:00
{
2019-09-10 11:35:20 -04:00
ComputePolygonTriangulation ( PolygonID ) ;
2017-12-28 17:15:00 -05:00
}
2018-01-04 15:57:54 -05:00
}
2018-06-07 16:22:56 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
void FMeshDescription : : SetNumUVChannels ( const int32 NumUVChannels )
{
UVElements - > SetNumChannels ( NumUVChannels ) ;
TriangleUVs = TriangleElements - > Get ( ) . GetAttributes ( ) . RegisterIndexAttribute < FUVID [ 3 ] > ( MeshAttribute : : Triangle : : UVIndex , NumUVChannels ) ;
// Ensure every UV element channel has a UVCoordinate attribute
for ( int32 Index = 0 ; Index < NumUVChannels ; Index + + )
{
2021-11-18 14:37:34 -05:00
UVElements - > Get ( Index ) . GetAttributes ( ) . RegisterAttribute ( MeshAttribute : : UV : : UVCoordinate , 1 , FVector2f : : ZeroVector , EMeshAttributeFlags : : Lerpable ) ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
}
}
2019-10-01 20:41:42 -04:00
namespace MeshAttribute_
{
namespace Vertex
{
const FName CornerSharpness ( " CornerSharpness " ) ;
}
namespace VertexInstance
{
const FName TextureCoordinate ( " TextureCoordinate " ) ;
const FName Normal ( " Normal " ) ;
const FName Tangent ( " Tangent " ) ;
const FName BinormalSign ( " BinormalSign " ) ;
const FName Color ( " Color " ) ;
}
namespace Edge
{
const FName IsHard ( " IsHard " ) ;
const FName IsUVSeam ( " IsUVSeam " ) ;
const FName CreaseSharpness ( " CreaseSharpness " ) ;
}
namespace Polygon
{
const FName Normal ( " Normal " ) ;
const FName Tangent ( " Tangent " ) ;
const FName Binormal ( " Binormal " ) ;
const FName Center ( " Center " ) ;
}
namespace PolygonGroup
{
const FName ImportedMaterialSlotName ( " ImportedMaterialSlotName " ) ;
const FName EnableCollision ( " EnableCollision " ) ;
const FName CastShadow ( " CastShadow " ) ;
}
}
2018-06-07 16:22:56 -04:00
float FMeshDescription : : GetPolygonCornerAngleForVertex ( const FPolygonID PolygonID , const FVertexID VertexID ) const
2018-03-22 16:02:58 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArray < FVertexInstanceID > PolygonVertexInstanceIDs = GetPolygonVertexInstances ( PolygonID ) ;
2018-03-22 16:02:58 -04:00
// Lambda function which returns the inner angle at a given index on a polygon contour
2019-12-19 18:07:47 -05:00
auto GetContourAngle = [ this ] ( const TArray < FVertexInstanceID > & VertexInstanceIDs , const int32 ContourIndex )
2018-03-22 16:02:58 -04:00
{
2019-12-19 18:07:47 -05:00
const int32 NumVertices = VertexInstanceIDs . Num ( ) ;
2018-03-22 16:02:58 -04:00
const int32 PrevIndex = ( ContourIndex + NumVertices - 1 ) % NumVertices ;
const int32 NextIndex = ( ContourIndex + 1 ) % NumVertices ;
2019-12-19 18:07:47 -05:00
const FVertexID PrevVertexID = GetVertexInstanceVertex ( VertexInstanceIDs [ PrevIndex ] ) ;
const FVertexID ThisVertexID = GetVertexInstanceVertex ( VertexInstanceIDs [ ContourIndex ] ) ;
const FVertexID NextVertexID = GetVertexInstanceVertex ( VertexInstanceIDs [ NextIndex ] ) ;
2018-03-22 16:02:58 -04:00
const FVector PrevVertexPosition = VertexPositions [ PrevVertexID ] ;
const FVector ThisVertexPosition = VertexPositions [ ThisVertexID ] ;
const FVector NextVertexPosition = VertexPositions [ NextVertexID ] ;
const FVector Direction1 = ( PrevVertexPosition - ThisVertexPosition ) . GetSafeNormal ( ) ;
const FVector Direction2 = ( NextVertexPosition - ThisVertexPosition ) . GetSafeNormal ( ) ;
return FMath : : Acos ( FVector : : DotProduct ( Direction1 , Direction2 ) ) ;
} ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
auto IsVertexInstancedFromThisVertex = [ this , VertexID ] ( const FVertexInstanceID VertexInstanceID )
2018-03-22 16:02:58 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
return this - > GetVertexInstanceVertex ( VertexInstanceID ) = = VertexID ;
2018-03-22 16:02:58 -04:00
} ;
// First look for the vertex instance in the perimeter
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
int32 ContourIndex = PolygonVertexInstanceIDs . IndexOfByPredicate ( IsVertexInstancedFromThisVertex ) ;
2018-03-22 16:02:58 -04:00
if ( ContourIndex ! = INDEX_NONE )
{
// Return the internal angle if found
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
return GetContourAngle ( PolygonVertexInstanceIDs , ContourIndex ) ;
2018-03-22 16:02:58 -04:00
}
// Found nothing; return 0
return 0.0f ;
}
2019-10-04 13:11:45 -04:00
FBox FMeshDescription : : ComputeBoundingBox ( ) const
{
FBox BoundingBox ( ForceInit ) ;
for ( const FVertexID VertexID : Vertices ( ) . GetElementIDs ( ) )
{
BoundingBox + = VertexPositions [ VertexID ] ;
}
return BoundingBox ;
}
2018-06-07 16:22:56 -04:00
2018-03-29 05:42:07 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
void FMeshDescription : : ReverseTriangleFacing ( const FTriangleID TriangleID )
{
TArrayView < FVertexInstanceID > TriVertexInstances = TriangleVertexInstances [ TriangleID ] ;
TArrayView < FVertexID > TriVertices = TriangleVertices [ TriangleID ] ;
TArrayView < FEdgeID > TriEdges = TriangleEdges [ TriangleID ] ;
Swap ( TriVertexInstances [ 0 ] , TriVertexInstances [ 1 ] ) ;
Swap ( TriVertices [ 0 ] , TriVertices [ 1 ] ) ;
Swap ( TriEdges [ 0 ] , TriEdges [ 1 ] ) ;
}
2018-06-07 16:22:56 -04:00
void FMeshDescription : : ReversePolygonFacing ( const FPolygonID PolygonID )
2018-01-04 15:57:54 -05:00
{
2019-09-10 11:35:20 -04:00
// Build a reverse perimeter
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArray < FVertexInstanceID > Contour = GetPolygonVertexInstances ( PolygonID ) ;
for ( int32 i = 0 ; i < Contour . Num ( ) / 2 ; + + i )
2018-01-04 15:57:54 -05:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
Swap ( Contour [ i ] , Contour [ Contour . Num ( ) - i - 1 ] ) ;
2018-01-04 15:57:54 -05:00
}
2019-06-07 11:22:52 -04:00
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
RemovePolygonTriangles ( PolygonID ) ;
CreatePolygonTriangles ( PolygonID , Contour ) ;
2018-01-04 15:57:54 -05:00
}
2018-06-07 16:22:56 -04:00
void FMeshDescription : : ReverseAllPolygonFacing ( )
2018-01-04 15:57:54 -05:00
{
// Perform triangulation directly into mesh polygons
for ( const FPolygonID PolygonID : Polygons ( ) . GetElementIDs ( ) )
{
ReversePolygonFacing ( PolygonID ) ;
}
2018-12-10 09:29:08 -05:00
}
2019-09-10 11:35:20 -04:00
void FMeshDescription : : RemapPolygonGroups ( const TMap < FPolygonGroupID , FPolygonGroupID > & Remap )
{
2019-10-01 20:41:42 -04:00
TPolygonGroupAttributesRef < FName > PolygonGroupNames = PolygonGroupAttributes ( ) . GetAttributesRef < FName > ( MeshAttribute_ : : PolygonGroup : : ImportedMaterialSlotName ) ;
2019-09-10 11:35:20 -04:00
struct FOldPolygonGroupData
{
FName Name ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TArray < FTriangleID > Triangles ;
2019-09-10 11:35:20 -04:00
TArray < FPolygonID > Polygons ;
} ;
TMap < FPolygonGroupID , FOldPolygonGroupData > OldData ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( const FPolygonGroupID PolygonGroupID : PolygonGroups ( ) . GetElementIDs ( ) )
2019-09-10 11:35:20 -04:00
{
if ( ! Remap . Contains ( PolygonGroupID ) | | PolygonGroupID = = Remap [ PolygonGroupID ] )
{
//No need to change this one
continue ;
}
FOldPolygonGroupData & PolygonGroupData = OldData . FindOrAdd ( PolygonGroupID ) ;
PolygonGroupData . Name = PolygonGroupNames [ PolygonGroupID ] ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
PolygonGroupData . Triangles = PolygonGroupToTriangles . Find < FTriangleID > ( PolygonGroupID ) ;
PolygonGroupData . Polygons = PolygonGroupToPolygons . Find < FPolygonID > ( PolygonGroupID ) ;
PolygonGroupElements - > Get ( ) . Remove ( PolygonGroupID ) ;
PolygonGroupToPolygons . RemoveKey ( PolygonGroupID ) ;
PolygonGroupToTriangles . RemoveKey ( PolygonGroupID ) ;
2019-09-10 11:35:20 -04:00
}
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
2019-09-10 11:35:20 -04:00
for ( auto Kvp : OldData )
{
FPolygonGroupID GroupID = Kvp . Key ;
FPolygonGroupID ToGroupID = Remap [ GroupID ] ;
if ( ! PolygonGroups ( ) . IsValid ( ToGroupID ) )
{
CreatePolygonGroupWithID ( ToGroupID ) ;
}
PolygonGroupNames [ ToGroupID ] = Kvp . Value . Name ;
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
for ( const FTriangleID TriangleID : Kvp . Value . Triangles )
2019-09-10 11:35:20 -04:00
{
First pass of MeshDescription API and format refactor.
- Removed hardcoded element type arrays (Vertices, Edges, Triangles etc.). Mesh element types can now be arbitrarily added, with any number of channels.
- Mesh element containers have a much leaner format; instead of sparse arrays, they are now represented by a simple bitarray, determining whether an index is used or not. Consequently, mesh topology is now entirely described with the attribute system, e.g. edge start and end vertices, triangle vertices, etc.
- Support added for attributes of arbitrary dimensions, e.g. float[4] or int[2].
- Support added for attributes which index into another mesh element container.
- Added FMeshElementIndexer: this is an efficient container for maintaining backward references from one element type to another; for example, edges have an attribute specifying which vertices are at each end (an attribute of type FVertexID[2]). With an indexer, it is possible to look up which edges contain a given vertex, even though this is not explicitly stored. Indexers are designed to do minimal allocations and update lazily and in batch when necessary.
- Added support for preserving UV topology in static meshes. UVs are now a first-class element type which may be indexed directly from triangles.
- Added the facility to access the underlying array in an attribute array directly.
- Triangles now directly reference their vertex, edge and UV IDs. Vertex instances are to be deprecated.
- Changed various systems to be triangle-centric rather than polygon-centric, as this is faster. Triangles are presumed to be the elementary face type in a MeshDescription, even if polygons are still supported. The concept of polygons will be somewhat shifted to mean a group of triangles which should be treated collectively for editing purposes.
- Optimised normal/tangent generation and FBX import.
- Deprecated EditableMesh, MeshEditor and StaticMeshEditorExtension plugins - these are to be removed, but they still have certain hooks in place which need removing.
#rb
[CL 13568702 by Richard TalbotWatkin in ue5-main branch]
2020-05-28 10:56:57 -04:00
TrianglePolygonGroups [ TriangleID ] = ToGroupID ;
PolygonGroupToTriangles . AddReferenceToKey ( ToGroupID , TriangleID ) ;
}
for ( const FPolygonID PolygonID : Kvp . Value . Polygons )
{
PolygonPolygonGroups [ PolygonID ] = ToGroupID ;
PolygonGroupToPolygons . AddReferenceToKey ( ToGroupID , PolygonID ) ;
2019-09-10 11:35:20 -04:00
}
}
}
2018-12-10 09:29:08 -05:00
# if WITH_EDITORONLY_DATA
2021-11-18 14:37:34 -05:00
TConstArrayView < FGuid > FMeshDescriptionBulkData : : GetMeshDescriptionCustomVersions ( )
{
static FGuid Versions [ ]
{
FEditorObjectVersion : : GUID ,
FReleaseObjectVersion : : GUID ,
FEnterpriseObjectVersion : : GUID ,
FUE5MainStreamObjectVersion : : GUID
} ;
return MakeArrayView ( Versions ) ;
}
2018-12-10 09:29:08 -05:00
void FMeshDescriptionBulkData : : Serialize ( FArchive & Ar , UObject * Owner )
{
2019-02-07 05:53:07 -05:00
Ar . UsingCustomVersion ( FEditorObjectVersion : : GUID ) ;
2020-05-28 14:09:49 -04:00
Ar . UsingCustomVersion ( FReleaseObjectVersion : : GUID ) ;
2019-10-04 13:11:45 -04:00
Ar . UsingCustomVersion ( FEnterpriseObjectVersion : : GUID ) ;
2020-10-06 06:29:40 -04:00
Ar . UsingCustomVersion ( FUE5MainStreamObjectVersion : : GUID ) ;
2019-02-07 05:53:07 -05:00
2021-02-23 15:17:22 -04:00
// Make sure to serialize only actual data
2021-02-25 12:43:28 -04:00
if ( Ar . ShouldSkipBulkData ( ) | | Ar . IsObjectReferenceCollector ( ) )
2021-02-23 15:17:22 -04:00
{
return ;
}
2021-04-20 09:46:29 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( FMeshDescriptionBulkData : : Serialize ) ;
2021-03-08 14:13:00 -04:00
if ( Ar . IsTransacting ( ) )
2019-02-02 12:38:12 -05:00
{
2019-02-07 05:53:07 -05:00
// If transacting, keep these members alive the other side of an undo, otherwise their values will get lost
CustomVersions . Serialize ( Ar ) ;
Ar < < bBulkDataUpdated ;
}
else
{
2021-03-08 14:13:00 -04:00
if ( Ar . IsSaving ( ) )
2019-02-07 05:53:07 -05:00
{
// If the bulk data hasn't been updated since this was loaded, there's a possibility that it has old versioning.
// Explicitly load and resave the FMeshDescription so that its version is in sync with the FMeshDescriptionBulkData.
if ( ! bBulkDataUpdated )
{
2021-03-20 20:01:33 -04:00
const FGuid OriginalGuid = Guid ;
2019-02-07 05:53:07 -05:00
FMeshDescription MeshDescription ;
LoadMeshDescription ( MeshDescription ) ;
SaveMeshDescription ( MeshDescription ) ;
2021-03-20 20:01:33 -04:00
2021-11-18 14:37:34 -05:00
// Maintain the original guid; this is a format change only. GetIdString will change because it adds the CustomVersions to the key.
if ( ! bGuidIsHash )
2021-03-20 20:01:33 -04:00
{
Guid = OriginalGuid ;
}
2019-02-07 05:53:07 -05:00
}
}
2019-02-02 12:38:12 -05:00
}
2020-10-21 17:56:05 -04:00
bool bSerializedOldDataTypes = false ;
FByteBulkData TempBulkData ;
2021-07-20 18:18:51 -04:00
if ( Ar . IsLoading ( ) & & Ar . CustomVer ( FUE5MainStreamObjectVersion : : GUID ) < FUE5MainStreamObjectVersion : : VirtualizedBulkDataHaveUniqueGuids )
2020-10-21 17:56:05 -04:00
{
2021-07-20 18:18:51 -04:00
if ( Ar . CustomVer ( FUE5MainStreamObjectVersion : : GUID ) < FUE5MainStreamObjectVersion : : MeshDescriptionVirtualization )
{
// Serialize the old BulkData format and mark that we require a conversion after the guid has been serialized
TempBulkData . Serialize ( Ar , Owner ) ;
bSerializedOldDataTypes = true ;
}
else
{
BulkData . Serialize ( Ar , Owner , false /* bAllowRegister */ ) ;
BulkData . CreateLegacyUniqueIdentifier ( Owner ) ;
}
2020-10-21 17:56:05 -04:00
}
else
{
2021-06-21 08:56:40 -04:00
BulkData . Serialize ( Ar , Owner ) ;
2020-10-21 17:56:05 -04:00
}
2018-12-10 19:34:09 -05:00
if ( Ar . IsLoading ( ) & & Ar . CustomVer ( FEditorObjectVersion : : GUID ) < FEditorObjectVersion : : MeshDescriptionBulkDataGuid )
{
FPlatformMisc : : CreateGuid ( Guid ) ;
}
else
{
Ar < < Guid ;
}
2019-10-04 13:11:45 -04:00
// MeshDescriptionBulkData contains a bGuidIsHash so we can benefit from DDC caching.
if ( Ar . IsLoading ( ) & & Ar . CustomVer ( FEnterpriseObjectVersion : : GUID ) < FEnterpriseObjectVersion : : MeshDescriptionBulkDataGuidIsHash )
{
bGuidIsHash = false ;
}
else
{
Ar < < bGuidIsHash ;
}
2020-10-21 17:56:05 -04:00
2021-03-08 14:13:00 -04:00
if ( ! Ar . IsTransacting ( ) & & Ar . IsLoading ( ) )
{
// If loading, take a copy of the package custom version container, so it can be applied when unpacking
// MeshDescription from the bulk data.
CustomVersions = BulkData . GetCustomVersions ( Ar ) ;
}
2020-10-21 17:56:05 -04:00
// Needs to be after the guid is serialized
if ( bSerializedOldDataTypes )
{
2021-06-24 00:51:58 -04:00
BulkData . CreateFromBulkData ( TempBulkData , Guid , Owner ) ;
2020-10-21 17:56:05 -04:00
}
2018-12-10 09:29:08 -05:00
}
void FMeshDescriptionBulkData : : SaveMeshDescription ( FMeshDescription & MeshDescription )
{
2019-10-04 13:11:45 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( FMeshDescriptionBulkData : : SaveMeshDescription ) ;
2021-02-23 15:17:22 -04:00
# if WITH_EDITOR
FRWScopeLock ScopeLock ( BulkDataLock , SLT_Write ) ;
# endif
2020-10-21 17:56:05 -04:00
BulkData . Reset ( ) ;
2018-12-10 09:29:08 -05:00
if ( ! MeshDescription . IsEmpty ( ) )
{
const bool bIsPersistent = true ;
2021-04-30 08:14:54 -04:00
UE : : Virtualization : : FVirtualizedBulkDataWriter Ar ( BulkData , bIsPersistent ) ;
2018-12-10 09:29:08 -05:00
Ar < < MeshDescription ;
2019-07-09 09:41:08 -04:00
// Preserve CustomVersions at save time so we can reuse the same ones when reloading direct from memory
CustomVersions = Ar . GetCustomVersions ( ) ;
2018-12-10 09:29:08 -05:00
}
2018-12-10 19:34:09 -05:00
2019-10-04 13:11:45 -04:00
if ( bGuidIsHash )
{
UseHashAsGuid ( ) ;
}
else
{
FPlatformMisc : : CreateGuid ( Guid ) ;
}
2019-02-07 05:53:07 -05:00
// Mark the MeshDescriptionBulkData as having been updated.
// This means we know that its version is up-to-date.
bBulkDataUpdated = true ;
2018-12-10 09:29:08 -05:00
}
2021-05-05 15:07:25 -04:00
void FMeshDescriptionBulkData : : LoadMeshDescription ( FMeshDescription & MeshDescription )
2018-12-10 09:29:08 -05:00
{
2021-04-20 09:46:29 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( FMeshDescriptionBulkData : : LoadMeshDescription ) ;
2018-12-10 09:29:08 -05:00
MeshDescription . Empty ( ) ;
2021-04-30 08:14:54 -04:00
if ( BulkData . GetPayloadSize ( ) > 0 )
{
# if WITH_EDITOR
// TODO: Remove this once VirtualizedBulkData can be shown to be thread safe
// A lock is required so we can clone the mesh description from multiple threads
FRWScopeLock ScopeLock ( BulkDataLock , SLT_Write ) ;
# endif //WITH_EDITOR
const bool bIsPersistent = true ;
UE : : Virtualization : : FVirtualizedBulkDataReader Ar ( BulkData , bIsPersistent ) ;
// Propagate the custom version information from the package to the bulk data, so that the MeshDescription
// is serialized with the same versioning.
Ar . SetCustomVersions ( CustomVersions ) ;
Ar < < MeshDescription ;
BulkData . UnloadData ( ) ;
}
2018-12-10 09:29:08 -05:00
}
void FMeshDescriptionBulkData : : Empty ( )
{
2020-10-21 17:56:05 -04:00
BulkData . Reset ( ) ;
2018-12-10 09:29:08 -05:00
}
2018-12-10 19:34:09 -05:00
FString FMeshDescriptionBulkData : : GetIdString ( ) const
{
2021-11-18 14:37:34 -05:00
// Create the IDString by combining this->Guid with the CustomVersions used for serialization,
// hashed down into a Guid to keep the string length the same as the original Guid.
UE : : DerivedData : : FBuildVersionBuilder Builder ;
Builder < < const_cast < FGuid & > ( Guid ) ;
for ( const FGuid & CustomVersionGuid : GetMeshDescriptionCustomVersions ( ) )
{
Builder < < const_cast < FGuid & > ( CustomVersionGuid ) ;
TOptional < FCustomVersion > CustomVersion = FCurrentCustomVersions : : Get ( CustomVersionGuid ) ;
check ( CustomVersion ) ;
Builder < < CustomVersion - > Version ;
}
FString GuidString = Builder . Build ( ) . ToString ( ) ;
2019-10-04 13:11:45 -04:00
if ( bGuidIsHash )
{
GuidString + = TEXT ( " X " ) ;
}
return GuidString ;
}
2021-03-20 20:01:33 -04:00
FGuid FMeshDescriptionBulkData : : GetHash ( ) const
2019-10-04 13:11:45 -04:00
{
2021-06-21 08:56:40 -04:00
if ( BulkData . GetPayloadSize ( ) > 0 )
2019-10-04 13:11:45 -04:00
{
2021-04-30 08:14:54 -04:00
return BulkData . GetPayloadId ( ) . ToGuid ( ) ;
2020-10-21 17:56:05 -04:00
}
2021-03-20 20:01:33 -04:00
return FGuid ( ) ;
}
void FMeshDescriptionBulkData : : UseHashAsGuid ( )
{
2021-06-21 08:56:40 -04:00
if ( BulkData . GetPayloadSize ( ) > 0 )
2021-03-20 20:01:33 -04:00
{
bGuidIsHash = true ;
Guid = GetHash ( ) ;
}
2020-10-21 17:56:05 -04:00
else
{
Guid . Invalidate ( ) ;
}
2018-12-10 19:34:09 -05:00
}
2018-12-10 09:29:08 -05:00
# endif // #if WITH_EDITORONLY_DATA
2021-01-28 16:27:47 -04:00