sigma update
This commit is contained in:
@@ -239,11 +239,14 @@ namespace MeshDecimator.Algorithms
|
||||
|
||||
private ResizableArray<Vector3> vertNormals = null;
|
||||
private ResizableArray<Vector4> vertTangents = null;
|
||||
private ResizableArray<Vector4> vertTangents2 = null;
|
||||
private UVChannels<Vector2> vertUV2D = null;
|
||||
private UVChannels<Vector3> vertUV3D = null;
|
||||
private UVChannels<Vector4> vertUV4D = null;
|
||||
private ResizableArray<Vector4> vertColors = null;
|
||||
private ResizableArray<BoneWeight> vertBoneWeights = null;
|
||||
private ResizableArray<float> vertPositionWs = null;
|
||||
private ResizableArray<float> vertNormalWs = null;
|
||||
|
||||
private int remainingVertices = 0;
|
||||
|
||||
@@ -508,10 +511,22 @@ namespace MeshDecimator.Algorithms
|
||||
{
|
||||
vertNormals[i0] = vertNormals[i1];
|
||||
}
|
||||
if (vertPositionWs != null)
|
||||
{
|
||||
vertPositionWs[i0] = vertPositionWs[i1];
|
||||
}
|
||||
if (vertNormalWs != null)
|
||||
{
|
||||
vertNormalWs[i0] = vertNormalWs[i1];
|
||||
}
|
||||
if (vertTangents != null)
|
||||
{
|
||||
vertTangents[i0] = vertTangents[i1];
|
||||
}
|
||||
if (vertTangents2 != null)
|
||||
{
|
||||
vertTangents2[i0] = vertTangents2[i1];
|
||||
}
|
||||
if (vertUV2D != null)
|
||||
{
|
||||
for (int i = 0; i < Mesh.UVChannelCount; i++)
|
||||
@@ -561,10 +576,22 @@ namespace MeshDecimator.Algorithms
|
||||
{
|
||||
vertNormals[i0] = (vertNormals[i0] + vertNormals[i1]) * 0.5f;
|
||||
}
|
||||
if (vertPositionWs != null)
|
||||
{
|
||||
vertPositionWs[i0] = (vertPositionWs[i0] + vertPositionWs[i1]) * 0.5f;
|
||||
}
|
||||
if (vertNormalWs != null)
|
||||
{
|
||||
vertNormalWs[i0] = (vertNormalWs[i0] + vertNormalWs[i1]) * 0.5f;
|
||||
}
|
||||
if (vertTangents != null)
|
||||
{
|
||||
vertTangents[i0] = (vertTangents[i0] + vertTangents[i1]) * 0.5f;
|
||||
}
|
||||
if (vertTangents2 != null)
|
||||
{
|
||||
vertTangents2[i0] = (vertTangents2[i0] + vertTangents2[i1]) * 0.5f;
|
||||
}
|
||||
if (vertUV2D != null)
|
||||
{
|
||||
for (int i = 0; i < Mesh.UVChannelCount; i++)
|
||||
@@ -1080,11 +1107,14 @@ namespace MeshDecimator.Algorithms
|
||||
|
||||
var vertNormals = (this.vertNormals != null ? this.vertNormals.Data : null);
|
||||
var vertTangents = (this.vertTangents != null ? this.vertTangents.Data : null);
|
||||
var vertTangents2 = (this.vertTangents2 != null ? this.vertTangents2.Data : null);
|
||||
var vertUV2D = (this.vertUV2D != null ? this.vertUV2D.Data : null);
|
||||
var vertUV3D = (this.vertUV3D != null ? this.vertUV3D.Data : null);
|
||||
var vertUV4D = (this.vertUV4D != null ? this.vertUV4D.Data : null);
|
||||
var vertColors = (this.vertColors != null ? this.vertColors.Data : null);
|
||||
var vertBoneWeights = (this.vertBoneWeights != null ? this.vertBoneWeights.Data : null);
|
||||
var vertPositionWs = (this.vertPositionWs != null ? this.vertPositionWs.Data : null);
|
||||
var vertNormalWs = (this.vertNormalWs != null ? this.vertNormalWs.Data : null);
|
||||
|
||||
var triangles = this.triangles.Data;
|
||||
int triangleCount = this.triangles.Length;
|
||||
@@ -1102,6 +1132,14 @@ namespace MeshDecimator.Algorithms
|
||||
{
|
||||
vertBoneWeights[iDest] = vertBoneWeights[iSrc];
|
||||
}
|
||||
if (vertPositionWs != null)
|
||||
{
|
||||
vertPositionWs[iDest] = vertPositionWs[iSrc];
|
||||
}
|
||||
if (vertNormalWs != null)
|
||||
{
|
||||
vertNormalWs[iDest] = vertNormalWs[iSrc];
|
||||
}
|
||||
triangle.v0 = triangle.va0;
|
||||
}
|
||||
if (triangle.va1 != triangle.v1)
|
||||
@@ -1113,6 +1151,14 @@ namespace MeshDecimator.Algorithms
|
||||
{
|
||||
vertBoneWeights[iDest] = vertBoneWeights[iSrc];
|
||||
}
|
||||
if (vertPositionWs != null)
|
||||
{
|
||||
vertPositionWs[iDest] = vertPositionWs[iSrc];
|
||||
}
|
||||
if (vertNormalWs != null)
|
||||
{
|
||||
vertNormalWs[iDest] = vertNormalWs[iSrc];
|
||||
}
|
||||
triangle.v1 = triangle.va1;
|
||||
}
|
||||
if (triangle.va2 != triangle.v2)
|
||||
@@ -1124,6 +1170,14 @@ namespace MeshDecimator.Algorithms
|
||||
{
|
||||
vertBoneWeights[iDest] = vertBoneWeights[iSrc];
|
||||
}
|
||||
if (vertPositionWs != null)
|
||||
{
|
||||
vertPositionWs[iDest] = vertPositionWs[iSrc];
|
||||
}
|
||||
if (vertNormalWs != null)
|
||||
{
|
||||
vertNormalWs[iDest] = vertNormalWs[iSrc];
|
||||
}
|
||||
triangle.v2 = triangle.va2;
|
||||
}
|
||||
|
||||
@@ -1153,6 +1207,7 @@ namespace MeshDecimator.Algorithms
|
||||
vertices[dst].p = vert.p;
|
||||
if (vertNormals != null) vertNormals[dst] = vertNormals[i];
|
||||
if (vertTangents != null) vertTangents[dst] = vertTangents[i];
|
||||
if (vertTangents2 != null) vertTangents2[dst] = vertTangents2[i];
|
||||
if (vertUV2D != null)
|
||||
{
|
||||
for (int j = 0; j < Mesh.UVChannelCount; j++)
|
||||
@@ -1188,6 +1243,8 @@ namespace MeshDecimator.Algorithms
|
||||
}
|
||||
if (vertColors != null) vertColors[dst] = vertColors[i];
|
||||
if (vertBoneWeights != null) vertBoneWeights[dst] = vertBoneWeights[i];
|
||||
if (vertPositionWs != null) vertPositionWs[dst] = vertPositionWs[i];
|
||||
if (vertNormalWs != null) vertNormalWs[dst] = vertNormalWs[i];
|
||||
}
|
||||
++dst;
|
||||
}
|
||||
@@ -1206,11 +1263,14 @@ namespace MeshDecimator.Algorithms
|
||||
this.vertices.Resize(vertexCount);
|
||||
if (vertNormals != null) this.vertNormals.Resize(vertexCount, true);
|
||||
if (vertTangents != null) this.vertTangents.Resize(vertexCount, true);
|
||||
if (vertTangents2 != null) this.vertTangents2.Resize(vertexCount, true);
|
||||
if (vertUV2D != null) this.vertUV2D.Resize(vertexCount, true);
|
||||
if (vertUV3D != null) this.vertUV3D.Resize(vertexCount, true);
|
||||
if (vertUV4D != null) this.vertUV4D.Resize(vertexCount, true);
|
||||
if (vertColors != null) this.vertColors.Resize(vertexCount, true);
|
||||
if (vertBoneWeights != null) this.vertBoneWeights.Resize(vertexCount, true);
|
||||
if (vertPositionWs != null) this.vertPositionWs.Resize(vertexCount, true);
|
||||
if (vertNormalWs != null) this.vertNormalWs.Resize(vertexCount, true);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
@@ -1230,7 +1290,10 @@ namespace MeshDecimator.Algorithms
|
||||
int meshTriangleCount = mesh.TriangleCount;
|
||||
var meshVertices = mesh.Vertices;
|
||||
var meshNormals = mesh.Normals;
|
||||
var meshPositionWs = mesh.PositionWs;
|
||||
var meshNormalWs = mesh.NormalWs;
|
||||
var meshTangents = mesh.Tangents;
|
||||
var meshTangents2 = mesh.Tangents2;
|
||||
var meshColors = mesh.Colors;
|
||||
var meshBoneWeights = mesh.BoneWeights;
|
||||
subMeshCount = meshSubMeshCount;
|
||||
@@ -1260,7 +1323,10 @@ namespace MeshDecimator.Algorithms
|
||||
}
|
||||
|
||||
vertNormals = InitializeVertexAttribute(meshNormals, "normals");
|
||||
vertPositionWs = InitializeVertexAttribute(meshPositionWs, "positionWs");
|
||||
vertNormalWs = InitializeVertexAttribute(meshNormalWs, "normalWs");
|
||||
vertTangents = InitializeVertexAttribute(meshTangents, "tangents");
|
||||
vertTangents2 = InitializeVertexAttribute(meshTangents2, "tangents2");
|
||||
vertColors = InitializeVertexAttribute(meshColors, "colors");
|
||||
vertBoneWeights = InitializeVertexAttribute(meshBoneWeights, "boneWeights");
|
||||
|
||||
@@ -1492,10 +1558,22 @@ namespace MeshDecimator.Algorithms
|
||||
{
|
||||
newMesh.Normals = vertNormals.Data;
|
||||
}
|
||||
if (vertPositionWs != null)
|
||||
{
|
||||
newMesh.PositionWs = vertPositionWs.Data;
|
||||
}
|
||||
if (vertNormalWs != null)
|
||||
{
|
||||
newMesh.NormalWs = vertNormalWs.Data;
|
||||
}
|
||||
if (vertTangents != null)
|
||||
{
|
||||
newMesh.Tangents = vertTangents.Data;
|
||||
}
|
||||
if (vertTangents2 != null)
|
||||
{
|
||||
newMesh.Tangents2 = vertTangents2.Data;
|
||||
}
|
||||
if (vertColors != null)
|
||||
{
|
||||
newMesh.Colors = vertColors.Data;
|
||||
|
||||
Reference in New Issue
Block a user