2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-10-01 20:41:42 -04:00
# include "StaticMeshAttributes.h"
namespace MeshAttribute
{
const FName VertexInstance : : TextureCoordinate ( " TextureCoordinate " ) ;
const FName VertexInstance : : Normal ( " Normal " ) ;
const FName VertexInstance : : Tangent ( " Tangent " ) ;
const FName VertexInstance : : BinormalSign ( " BinormalSign " ) ;
const FName VertexInstance : : Color ( " Color " ) ;
const FName Edge : : IsHard ( " IsHard " ) ;
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 FName Triangle : : Normal ( " Normal " ) ;
const FName Triangle : : Tangent ( " Tangent " ) ;
const FName Triangle : : Binormal ( " Binormal " ) ;
2019-10-01 20:41:42 -04:00
const FName Polygon : : Normal ( " Normal " ) ;
const FName Polygon : : Tangent ( " Tangent " ) ;
const FName Polygon : : Binormal ( " Binormal " ) ;
const FName Polygon : : Center ( " Center " ) ;
const FName PolygonGroup : : ImportedMaterialSlotName ( " ImportedMaterialSlotName " ) ;
2020-10-19 16:13:57 -04:00
PRAGMA_DISABLE_DEPRECATION_WARNINGS
// all deprected in 4.26
const FName Vertex : : CornerSharpness ( " CornerSharpness " ) ;
2019-10-01 20:41:42 -04:00
const FName PolygonGroup : : CastShadow ( " CastShadow " ) ;
2020-10-19 16:13:57 -04:00
const FName Edge : : CreaseSharpness ( " CreaseSharpness " ) ;
const FName Edge : : IsUVSeam ( " IsUVSeam " ) ;
const FName PolygonGroup : : EnableCollision ( " EnableCollision " ) ;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
2019-10-01 20:41:42 -04:00
}
void FStaticMeshAttributes : : Register ( )
{
// Add basic vertex attributes
// Add basic vertex instance attributes
2021-11-18 14:37:34 -05:00
MeshDescription . VertexInstanceAttributes ( ) . RegisterAttribute < FVector2f > ( MeshAttribute : : VertexInstance : : TextureCoordinate , 1 , FVector2f : : ZeroVector , EMeshAttributeFlags : : Lerpable | EMeshAttributeFlags : : Mandatory ) ;
MeshDescription . VertexInstanceAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : VertexInstance : : Normal , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : AutoGenerated | EMeshAttributeFlags : : Mandatory ) ;
MeshDescription . VertexInstanceAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : VertexInstance : : Tangent , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : AutoGenerated | EMeshAttributeFlags : : Mandatory ) ;
2020-07-16 08:23:15 -04:00
MeshDescription . VertexInstanceAttributes ( ) . RegisterAttribute < float > ( MeshAttribute : : VertexInstance : : BinormalSign , 1 , 0.0f , EMeshAttributeFlags : : AutoGenerated | EMeshAttributeFlags : : Mandatory ) ;
2021-09-22 10:01:48 -04:00
MeshDescription . VertexInstanceAttributes ( ) . RegisterAttribute < FVector4f > ( MeshAttribute : : VertexInstance : : Color , 1 , FVector4f ( 1.0f , 1.0f , 1.0f , 1.0f ) , EMeshAttributeFlags : : Lerpable | EMeshAttributeFlags : : Mandatory ) ;
2019-10-01 20:41:42 -04:00
// Add basic edge attributes
2020-07-16 08:23:15 -04:00
MeshDescription . EdgeAttributes ( ) . RegisterAttribute < bool > ( MeshAttribute : : Edge : : IsHard , 1 , false , EMeshAttributeFlags : : Mandatory ) ;
2019-10-01 20:41:42 -04:00
// Add basic polygon attributes
// Add basic polygon group attributes
2020-07-16 08:23:15 -04:00
MeshDescription . PolygonGroupAttributes ( ) . RegisterAttribute < FName > ( MeshAttribute : : PolygonGroup : : ImportedMaterialSlotName , 1 , NAME_None , EMeshAttributeFlags : : Mandatory ) ; //The unique key to match the mesh material slot
2019-10-01 20:41:42 -04:00
// Call super class
FMeshAttributes : : Register ( ) ;
}
2019-11-06 18:17:34 -05:00
void FStaticMeshAttributes : : RegisterPolygonNormalAndTangentAttributes ( )
{
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
PRAGMA_DISABLE_DEPRECATION_WARNINGS
2021-11-18 14:37:34 -05:00
MeshDescription . PolygonAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Polygon : : Normal , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Transient ) ;
MeshDescription . PolygonAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Polygon : : Tangent , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Transient ) ;
MeshDescription . PolygonAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Polygon : : Binormal , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Transient ) ;
MeshDescription . PolygonAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Polygon : : Center , 1 , FVector3f : : ZeroVector , 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
PRAGMA_ENABLE_DEPRECATION_WARNINGS
}
void FStaticMeshAttributes : : RegisterTriangleNormalAndTangentAttributes ( )
{
2021-11-18 14:37:34 -05:00
MeshDescription . TriangleAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Triangle : : Normal , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Transient ) ;
MeshDescription . TriangleAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Triangle : : Tangent , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Transient ) ;
MeshDescription . TriangleAttributes ( ) . RegisterAttribute < FVector3f > ( MeshAttribute : : Triangle : : Binormal , 1 , FVector3f : : ZeroVector , EMeshAttributeFlags : : Transient ) ;
2019-11-06 18:17:34 -05:00
}