2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-06-04 15:42:48 -04:00
|
|
|
|
|
|
|
|
#include "MeshDescriptionBuilder.h"
|
2019-10-01 20:41:42 -04:00
|
|
|
#include "StaticMeshAttributes.h"
|
2019-06-04 15:42:48 -04:00
|
|
|
#include "VectorTypes.h"
|
|
|
|
|
#include "BoxTypes.h"
|
|
|
|
|
|
2021-05-22 01:32:46 -04:00
|
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
|
|
|
|
#include "DynamicMesh/DynamicMeshAttributeSet.h"
|
2019-06-04 15:42:48 -04:00
|
|
|
|
2021-05-22 01:32:46 -04:00
|
|
|
#include "DynamicMesh/MeshNormals.h"
|
2019-10-01 20:41:42 -04:00
|
|
|
|
2021-03-09 19:33:56 -04:00
|
|
|
using namespace UE::Geometry;
|
|
|
|
|
|
2019-06-04 15:42:48 -04:00
|
|
|
namespace ExtendedMeshAttribute
|
|
|
|
|
{
|
|
|
|
|
const FName PolyTriGroups("PolyTriGroups");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::SetMeshDescription(FMeshDescription* Description)
|
|
|
|
|
{
|
2020-07-16 08:23:15 -04:00
|
|
|
FStaticMeshAttributes Attributes(*Description);
|
|
|
|
|
|
2020-11-25 13:02:43 -04:00
|
|
|
// make sure we have at least one UV channel
|
|
|
|
|
if (!Attributes.GetVertexInstanceUVs().IsValid())
|
|
|
|
|
{
|
2021-11-18 14:37:34 -05:00
|
|
|
Description->VertexInstanceAttributes().RegisterAttribute<FVector2f>(MeshAttribute::VertexInstance::TextureCoordinate, 1, FVector2f::ZeroVector, EMeshAttributeFlags::Lerpable | EMeshAttributeFlags::Mandatory);
|
2020-11-25 13:02:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handles to some of the standard attributes.
|
2019-06-04 15:42:48 -04:00
|
|
|
this->MeshDescription = Description;
|
2020-07-16 08:23:15 -04:00
|
|
|
this->VertexPositions = Attributes.GetVertexPositions();
|
|
|
|
|
this->InstanceUVs = Attributes.GetVertexInstanceUVs();
|
|
|
|
|
this->InstanceNormals = Attributes.GetVertexInstanceNormals();
|
2021-01-19 15:47:33 -04:00
|
|
|
this->InstanceTangents = Attributes.GetVertexInstanceTangents();
|
|
|
|
|
this->InstanceBiTangentSign = Attributes.GetVertexInstanceBinormalSigns();
|
2020-07-16 08:23:15 -04:00
|
|
|
this->InstanceColors = Attributes.GetVertexInstanceColors();
|
2021-09-15 12:52:56 -04:00
|
|
|
this->GroupMaterialSlotNames = Attributes.GetPolygonGroupMaterialSlotNames();
|
|
|
|
|
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::EnablePolyGroups()
|
|
|
|
|
{
|
|
|
|
|
PolyGroups =
|
|
|
|
|
MeshDescription->PolygonAttributes().GetAttributesRef<int>(ExtendedMeshAttribute::PolyTriGroups);
|
|
|
|
|
if (PolyGroups.IsValid() == false)
|
|
|
|
|
{
|
|
|
|
|
MeshDescription->PolygonAttributes().RegisterAttribute<int>(
|
|
|
|
|
ExtendedMeshAttribute::PolyTriGroups, 1, 0, EMeshAttributeFlags::AutoGenerated);
|
|
|
|
|
PolyGroups =
|
|
|
|
|
MeshDescription->PolygonAttributes().GetAttributesRef<int>(ExtendedMeshAttribute::PolyTriGroups);
|
|
|
|
|
check(PolyGroups.IsValid());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::ReserveNewVertices(int32 Count)
|
|
|
|
|
{
|
|
|
|
|
MeshDescription->ReserveNewVertices(Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-04 15:42:48 -04:00
|
|
|
FVertexID FMeshDescriptionBuilder::AppendVertex(const FVector& Position)
|
|
|
|
|
{
|
|
|
|
|
FVertexID VertexID = MeshDescription->CreateVertex();
|
2022-02-02 07:59:31 -05:00
|
|
|
VertexPositions.Set(VertexID, FVector3f(Position)); //LWC_TODO: Precision loss
|
2019-06-04 15:42:48 -04:00
|
|
|
return VertexID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-09-15 12:52:56 -04:00
|
|
|
FPolygonGroupID FMeshDescriptionBuilder::AppendPolygonGroup(FName MaterialSlotName)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
2021-09-15 12:52:56 -04:00
|
|
|
FPolygonGroupID NewPolygonGroupID = MeshDescription->CreatePolygonGroup();
|
|
|
|
|
GroupMaterialSlotNames.Set(NewPolygonGroupID, MaterialSlotName);
|
|
|
|
|
return NewPolygonGroupID;
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
FTriangleID FMeshDescriptionBuilder::AppendTriangle(const FVertexID& Vertex0, const FVertexID& Vertex1, const FVertexID& Vertex2, const FPolygonGroupID& PolygonGroup)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
2020-11-20 12:24:15 -04:00
|
|
|
|
|
|
|
|
FVertexInstanceID TriVertexInstances[3];
|
|
|
|
|
TriVertexInstances[0] = MeshDescription->CreateVertexInstance(Vertex0);
|
|
|
|
|
TriVertexInstances[1] = MeshDescription->CreateVertexInstance(Vertex1);
|
|
|
|
|
TriVertexInstances[2] = MeshDescription->CreateVertexInstance(Vertex2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AppendTriangle(TriVertexInstances[0], TriVertexInstances[1], TriVertexInstances[2], PolygonGroup);
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FVertexInstanceID FMeshDescriptionBuilder::AppendInstance(const FVertexID& VertexID)
|
|
|
|
|
{
|
|
|
|
|
return MeshDescription->CreateVertexInstance(VertexID);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
void FMeshDescriptionBuilder::ReserveNewUVs(int32 Count, int UVLayerIndex)
|
|
|
|
|
{
|
|
|
|
|
// the reserve new UVs can only be called after the UV channels have been created.
|
|
|
|
|
|
|
|
|
|
check(MeshDescription->GetNumUVElementChannels() > UVLayerIndex )
|
2019-06-04 15:42:48 -04:00
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
MeshDescription->ReserveNewUVs(Count, UVLayerIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FUVID FMeshDescriptionBuilder::AppendUV(const FVector2D& UVvalue, int32 UVLayerIndex)
|
|
|
|
|
{
|
2021-11-18 14:37:34 -05:00
|
|
|
TUVAttributesRef<FVector2f> UVCoordinates = UVCoordinateLayers[UVLayerIndex];
|
2020-11-20 12:24:15 -04:00
|
|
|
FUVID UVID = MeshDescription->CreateUV(UVLayerIndex);
|
2021-11-18 14:37:34 -05:00
|
|
|
UVCoordinates[UVID] = FVector2f(UVvalue);
|
2020-11-20 12:24:15 -04:00
|
|
|
return UVID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::AppendUVTriangle(const FTriangleID& TriangleID, const FUVID UVvertexID0, const FUVID UVvertexID1, const FUVID UVvertexID2, int32 UVLayerIndex)
|
|
|
|
|
{
|
|
|
|
|
// set the shared UVs
|
|
|
|
|
TempUVBuffer.SetNum(3, false);
|
|
|
|
|
TempUVBuffer[0] = UVvertexID0;
|
|
|
|
|
TempUVBuffer[1] = UVvertexID1;
|
|
|
|
|
TempUVBuffer[2] = UVvertexID2;
|
|
|
|
|
MeshDescription->SetTriangleUVIndices(TriangleID, TempUVBuffer, UVLayerIndex);
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
TUVAttributesRef<FVector2f> UVCoordinates = UVCoordinateLayers[UVLayerIndex];
|
2020-11-20 12:24:15 -04:00
|
|
|
|
|
|
|
|
// set per-instance UVs.
|
|
|
|
|
// NB: per-instance UVs should go away on MeshDescription.
|
|
|
|
|
TArrayView<const FVertexInstanceID> TriVertInstances = MeshDescription->GetTriangleVertexInstances(TriangleID);
|
|
|
|
|
for (int32 j = 0; j < 3; ++j)
|
|
|
|
|
{
|
|
|
|
|
const FVertexInstanceID CornerInstanceID = TriVertInstances[j];
|
2021-11-18 14:37:34 -05:00
|
|
|
const FVector2f& UVvalue = UVCoordinates[TempUVBuffer[j]];
|
2020-11-20 12:24:15 -04:00
|
|
|
|
2022-02-02 01:47:07 -05:00
|
|
|
SetInstanceUV(CornerInstanceID, FVector2D(UVvalue), UVLayerIndex);
|
2020-11-20 12:24:15 -04:00
|
|
|
}
|
|
|
|
|
}
|
2019-06-04 15:42:48 -04:00
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::SetPosition(const FVertexID& VertexID, const FVector& NewPosition)
|
|
|
|
|
{
|
2022-02-02 07:59:31 -05:00
|
|
|
VertexPositions.Set(VertexID, 0, FVector3f(NewPosition)); //LWC_TODO: Precision loss
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FVector FMeshDescriptionBuilder::GetPosition(const FVertexID& VertexID)
|
|
|
|
|
{
|
2022-02-02 07:59:31 -05:00
|
|
|
return FVector(VertexPositions.Get(VertexID, 0));
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FVector FMeshDescriptionBuilder::GetPosition(const FVertexInstanceID& InstanceID)
|
|
|
|
|
{
|
2022-02-02 07:59:31 -05:00
|
|
|
return FVector(VertexPositions.Get(MeshDescription->GetVertexInstanceVertex(InstanceID), 0));
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::SetInstanceNormal(const FVertexInstanceID& InstanceID, const FVector& Normal)
|
|
|
|
|
{
|
|
|
|
|
if (InstanceNormals.IsValid())
|
|
|
|
|
{
|
2022-02-02 07:59:31 -05:00
|
|
|
InstanceNormals.Set(InstanceID, FVector3f(Normal)); //LWC_TODO: Precision loss
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 15:47:33 -04:00
|
|
|
void FMeshDescriptionBuilder::SetInstanceTangentSpace(const FVertexInstanceID& InstanceID, const FVector& Normal, const FVector& Tangent, float Sign)
|
|
|
|
|
{
|
|
|
|
|
// set the normal
|
|
|
|
|
SetInstanceNormal(InstanceID, Normal);
|
|
|
|
|
|
|
|
|
|
if (InstanceTangents.IsValid())
|
|
|
|
|
{
|
2022-02-02 07:59:31 -05:00
|
|
|
InstanceTangents.Set(InstanceID, FVector3f(Tangent)); //LWC_TODO: Precision loss
|
2021-03-24 21:23:32 -04:00
|
|
|
}
|
|
|
|
|
if (InstanceBiTangentSign.IsValid())
|
|
|
|
|
{
|
|
|
|
|
InstanceBiTangentSign.Set(InstanceID, Sign);
|
2021-01-19 15:47:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 15:42:48 -04:00
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
void FMeshDescriptionBuilder::SetInstanceUV(const FVertexInstanceID& InstanceID, const FVector2D& InstanceUV, int32 UVLayerIndex)
|
|
|
|
|
{
|
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 (InstanceUVs.IsValid() && ensure(UVLayerIndex < InstanceUVs.GetNumChannels()))
|
2019-10-01 20:41:42 -04:00
|
|
|
{
|
2021-11-18 14:37:34 -05:00
|
|
|
InstanceUVs.Set(InstanceID, UVLayerIndex, FVector2f(InstanceUV));
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::SetNumUVLayers(int32 NumUVLayers)
|
|
|
|
|
{
|
2020-11-25 13:02:43 -04:00
|
|
|
bool bValidInstanceUVs = InstanceUVs.IsValid();
|
|
|
|
|
if (bValidInstanceUVs)
|
2019-10-01 20:41:42 -04:00
|
|
|
{
|
2020-11-20 12:24:15 -04:00
|
|
|
// initialize the instanced UV channels
|
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
|
|
|
InstanceUVs.SetNumChannels(NumUVLayers);
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
2020-11-20 12:24:15 -04:00
|
|
|
|
|
|
|
|
// initialize the shared UV channels
|
|
|
|
|
MeshDescription->SetNumUVChannels(NumUVLayers);
|
|
|
|
|
|
|
|
|
|
// cache reference to uv vertex buffers
|
|
|
|
|
UVCoordinateLayers.SetNum(NumUVLayers);
|
|
|
|
|
for (int i = 0; i < NumUVLayers; ++i)
|
|
|
|
|
{
|
2021-11-18 14:37:34 -05:00
|
|
|
UVCoordinateLayers[i] = MeshDescription->UVAttributes(i).GetAttributesRef<FVector2f>(MeshAttribute::UV::UVCoordinate);
|
2020-11-20 12:24:15 -04:00
|
|
|
}
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-09-22 10:01:48 -04:00
|
|
|
void FMeshDescriptionBuilder::SetInstanceColor(const FVertexInstanceID& InstanceID, const FVector4f& Color)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
|
|
|
|
if (InstanceColors.IsValid())
|
|
|
|
|
{
|
|
|
|
|
InstanceColors.Set(InstanceID, Color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
FTriangleID FMeshDescriptionBuilder::AppendTriangle(const FVertexID* Triangle, const FPolygonGroupID& PolygonGroup)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
2020-11-20 12:24:15 -04:00
|
|
|
FVertexInstanceID TriVertexInstances[3];
|
|
|
|
|
TriVertexInstances[0] = MeshDescription->CreateVertexInstance(Triangle[0]);
|
|
|
|
|
TriVertexInstances[1] = MeshDescription->CreateVertexInstance(Triangle[1]);
|
|
|
|
|
TriVertexInstances[2] = MeshDescription->CreateVertexInstance(Triangle[2]);
|
2019-06-04 15:42:48 -04:00
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
return AppendTriangle(TriVertexInstances[0], TriVertexInstances[1], TriVertexInstances[2], PolygonGroup);
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
FPolygonID FMeshDescriptionBuilder::AppendPolygon(const TArray<FVertexID>& Vertices, const FPolygonGroupID& PolygonGroup)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
|
|
|
|
int NumVertices = Vertices.Num();
|
|
|
|
|
TArray<FVertexInstanceID> Polygon;
|
|
|
|
|
Polygon.Reserve(NumVertices);
|
|
|
|
|
for (int j = 0; j < NumVertices; ++j)
|
|
|
|
|
{
|
|
|
|
|
FVertexInstanceID VertexInstance = MeshDescription->CreateVertexInstance(Vertices[j]);
|
|
|
|
|
Polygon.Add(VertexInstance);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FPolygonID NewPolygonID = MeshDescription->CreatePolygon(PolygonGroup, Polygon);
|
|
|
|
|
|
|
|
|
|
return NewPolygonID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
FTriangleID FMeshDescriptionBuilder::AppendTriangle(const FVertexInstanceID& Instance0, const FVertexInstanceID& Instance1, const FVertexInstanceID& Instance2, const FPolygonGroupID& PolygonGroup)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
2020-11-20 12:24:15 -04:00
|
|
|
TArray<FVertexInstanceID> CornerInstanceIDs;
|
|
|
|
|
CornerInstanceIDs.Add(Instance0);
|
|
|
|
|
CornerInstanceIDs.Add(Instance1);
|
|
|
|
|
CornerInstanceIDs.Add(Instance2);
|
2019-06-04 15:42:48 -04:00
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
TArray<FEdgeID> NewEdgeIDs;
|
|
|
|
|
const FTriangleID NewTriangleID = MeshDescription->CreateTriangle(PolygonGroup, CornerInstanceIDs, &NewEdgeIDs);
|
2019-06-04 15:42:48 -04:00
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
return NewTriangleID;
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-20 12:24:15 -04:00
|
|
|
void FMeshDescriptionBuilder::SetPolyGroupID(const FTriangleID& TriangleID, int GroupID)
|
2019-06-04 15:42:48 -04:00
|
|
|
{
|
2020-11-20 12:24:15 -04:00
|
|
|
FPolygonID PolygonID = MeshDescription->GetTrianglePolygon(TriangleID);
|
2019-06-04 15:42:48 -04:00
|
|
|
PolyGroups.Set(PolygonID, 0, GroupID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::Translate(const FVector& Translation)
|
|
|
|
|
{
|
|
|
|
|
for (FVertexID VertexID : MeshDescription->Vertices().GetElementIDs())
|
|
|
|
|
{
|
2022-02-02 07:59:31 -05:00
|
|
|
FVector3f Position = VertexPositions.Get(VertexID);
|
|
|
|
|
Position += FVector3f(Translation); //LWC_TODO: Precision loss
|
2019-06-04 15:42:48 -04:00
|
|
|
VertexPositions.Set(VertexID, Position);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::SetAllEdgesHardness(bool bHard)
|
|
|
|
|
{
|
|
|
|
|
TEdgeAttributesRef<bool> EdgeHardness =
|
|
|
|
|
MeshDescription->EdgeAttributes().GetAttributesRef<bool>(MeshAttribute::Edge::IsHard);
|
|
|
|
|
for (FEdgeID EdgeID : MeshDescription->Edges().GetElementIDs())
|
|
|
|
|
{
|
|
|
|
|
EdgeHardness.Set(EdgeID, 0, bHard);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FBox FMeshDescriptionBuilder::ComputeBoundingBox() const
|
|
|
|
|
{
|
|
|
|
|
FAxisAlignedBox3f bounds = FAxisAlignedBox3f::Empty();
|
|
|
|
|
for ( FVertexID VertexID : MeshDescription->Vertices().GetElementIDs() )
|
|
|
|
|
{
|
2021-03-30 21:25:22 -04:00
|
|
|
bounds.Contain((FVector3f)VertexPositions.Get(VertexID));
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|
2019-12-19 18:07:47 -05:00
|
|
|
return (FBox)bounds;
|
2020-11-20 12:24:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::SuspendMeshDescriptionIndexing()
|
|
|
|
|
{
|
|
|
|
|
MeshDescription->SuspendVertexInstanceIndexing();
|
|
|
|
|
MeshDescription->SuspendEdgeIndexing();
|
|
|
|
|
MeshDescription->SuspendPolygonIndexing();
|
|
|
|
|
MeshDescription->SuspendPolygonGroupIndexing();
|
|
|
|
|
MeshDescription->SuspendUVIndexing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FMeshDescriptionBuilder::ResumeMeshDescriptionIndexing()
|
|
|
|
|
{
|
|
|
|
|
MeshDescription->ResumeVertexInstanceIndexing();
|
|
|
|
|
MeshDescription->ResumeEdgeIndexing();
|
|
|
|
|
MeshDescription->ResumePolygonIndexing();
|
|
|
|
|
MeshDescription->ResumePolygonGroupIndexing();
|
|
|
|
|
MeshDescription->ResumeUVIndexing();
|
2019-06-04 15:42:48 -04:00
|
|
|
}
|