Files
UnrealEngineUWP/Engine/Source/Runtime/StaticMeshDescription/Private/StaticMeshAttributes.cpp
richard talbotwatkin 95532d888d Fixed issue in which generating normals/tangents in a generated static mesh could lead to a crash.
#jira UE-83262
#rb none

#ROBOMERGE-SOURCE: CL 10062874 in //UE4/Release-4.24/...
#ROBOMERGE-BOT: RELEASE (Release-4.24 -> Main) (v566-10053404)

[CL 10062883 by richard talbotwatkin in Main branch]
2019-11-06 18:17:34 -05:00

63 lines
3.1 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "StaticMeshAttributes.h"
namespace MeshAttribute
{
const FName Vertex::CornerSharpness("CornerSharpness");
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");
const FName Edge::IsUVSeam("IsUVSeam");
const FName Edge::CreaseSharpness("CreaseSharpness");
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");
const FName PolygonGroup::EnableCollision("EnableCollision");
const FName PolygonGroup::CastShadow("CastShadow");
}
void FStaticMeshAttributes::Register()
{
// Add basic vertex attributes
MeshDescription.VertexAttributes().RegisterAttribute<float>(MeshAttribute::Vertex::CornerSharpness, 1, 0.0f, EMeshAttributeFlags::Lerpable);
// Add basic vertex instance attributes
MeshDescription.VertexInstanceAttributes().RegisterAttribute<FVector2D>(MeshAttribute::VertexInstance::TextureCoordinate, 1, FVector2D::ZeroVector, EMeshAttributeFlags::Lerpable);
MeshDescription.VertexInstanceAttributes().RegisterAttribute<FVector>(MeshAttribute::VertexInstance::Normal, 1, FVector::ZeroVector, EMeshAttributeFlags::AutoGenerated);
MeshDescription.VertexInstanceAttributes().RegisterAttribute<FVector>(MeshAttribute::VertexInstance::Tangent, 1, FVector::ZeroVector, EMeshAttributeFlags::AutoGenerated);
MeshDescription.VertexInstanceAttributes().RegisterAttribute<float>(MeshAttribute::VertexInstance::BinormalSign, 1, 0.0f, EMeshAttributeFlags::AutoGenerated);
MeshDescription.VertexInstanceAttributes().RegisterAttribute<FVector4>(MeshAttribute::VertexInstance::Color, 1, FVector4(1.0f, 1.0f, 1.0f, 1.0f), EMeshAttributeFlags::Lerpable);
// Add basic edge attributes
MeshDescription.EdgeAttributes().RegisterAttribute<bool>(MeshAttribute::Edge::IsHard, 1, false);
MeshDescription.EdgeAttributes().RegisterAttribute<float>(MeshAttribute::Edge::CreaseSharpness, 1, 0.0f, EMeshAttributeFlags::Lerpable);
// Add basic polygon attributes
// Add basic polygon group attributes
MeshDescription.PolygonGroupAttributes().RegisterAttribute<FName>(MeshAttribute::PolygonGroup::ImportedMaterialSlotName); //The unique key to match the mesh material slot
// Call super class
FMeshAttributes::Register();
}
void FStaticMeshAttributes::RegisterPolygonNormalAndTangentAttributes()
{
MeshDescription.PolygonAttributes().RegisterAttribute<FVector>(MeshAttribute::Polygon::Normal, 1, FVector::ZeroVector, EMeshAttributeFlags::Transient);
MeshDescription.PolygonAttributes().RegisterAttribute<FVector>(MeshAttribute::Polygon::Tangent, 1, FVector::ZeroVector, EMeshAttributeFlags::Transient);
MeshDescription.PolygonAttributes().RegisterAttribute<FVector>(MeshAttribute::Polygon::Binormal, 1, FVector::ZeroVector, EMeshAttributeFlags::Transient);
}