Skip to content

Commit

Permalink
Minor fixes (#386)
Browse files Browse the repository at this point in the history
* Minor updates

* NUD fixes
  • Loading branch information
Dr-HyperCake authored Aug 31, 2024
1 parent 35f403b commit 91d1a8f
Show file tree
Hide file tree
Showing 6 changed files with 486 additions and 101 deletions.
74 changes: 0 additions & 74 deletions Smash Forge/Filetypes/Application/MaterialXmlBatchExport.cs

This file was deleted.

1 change: 0 additions & 1 deletion Smash Forge/Filetypes/Models/Nuds/NUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,6 @@ private static void SingleBindMesh(Mesh m, int singleBindBone)
foreach (Polygon p in m.Nodes)
{
p.boneType = 0;
p.polflag = 0;
}
}

Expand Down
7 changes: 3 additions & 4 deletions Smash Forge/Filetypes/Models/Nuds/Polygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ private List<DisplayVertex> CreateDisplayVertices()

public void CalculateTangentBitangent()
{
// Don't generate tangents and bitangents if the vertex format doesn't support them.
int vertType = vertSize & 0xF;
if (!(vertType == 3 || vertType == 7))
// Don't generate tangents and bitangents if the vertex format doesn't support them.
if (!(normalType == (int)VertexTypes.NormalsTanBiTanFloat || normalType == (int)VertexTypes.NormalsTanBiTanHalfFloat))
return;

List<int> vertexIndices = GetRenderingVertexIndices();
Expand Down Expand Up @@ -246,7 +245,7 @@ public void SmoothNormals()
normals[f[i + 1]] += nrm;
normals[f[i + 2]] += nrm;
}

for (int i = 0; i < normals.Length; i++)
vertices[i].nrm = normals[i].Normalized();

Expand Down
16 changes: 6 additions & 10 deletions Smash Forge/GUI/Editors/MeshList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,7 @@ private void singleBindToBoneToolStripMenuItem_Click(object sender, EventArgs e)
mesh.singlebind = brs.boneIndex;
foreach (Nud.Polygon poly in mesh.Nodes)
{
poly.polflag = 0;
poly.vertSize = poly.vertSize & 0x0F;
poly.boneType = (int)Nud.Polygon.BoneTypes.NoBones;
foreach (Nud.Vertex vi in poly.vertices)
{
vi.boneIds.Clear();
Expand Down Expand Up @@ -1034,15 +1033,12 @@ private void generateTanBitanToolStripMenuItem2_Click(object sender, EventArgs e

private static void GenerateTanBitanAndFixVertType(Nud.Polygon poly)
{
int vertType = poly.vertSize & 0xF;
if (!(vertType == 3 || vertType == 7))
{
// Change the vert type to normals, tan, bitan (float)
poly.vertSize = (poly.vertSize & 0xF0);
poly.vertSize |= 7;
}
if (poly.normalType == (int)Nud.Polygon.VertexTypes.NormalsFloat)
poly.normalType = (int)Nud.Polygon.VertexTypes.NormalsTanBiTanFloat;
else if (poly.normalType == (int)Nud.Polygon.VertexTypes.NormalsHalfFloat)
poly.normalType = (int)Nud.Polygon.VertexTypes.NormalsTanBiTanHalfFloat;

// This already checks for the appropriate vertex type.
// This does nothing if the vertex type doesn't support it.
poly.CalculateTangentBitangent();
}

Expand Down
19 changes: 7 additions & 12 deletions Smash Forge/GUI/Menus/DAEImportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public DAEImportSettings()

transUvVerticalCB.Checked = true;
}

public void Populate()
{
vertTypeComboBox.BeginUpdate();
Expand Down Expand Up @@ -90,22 +90,17 @@ public void Apply(Nud nud)

foreach (Nud.Polygon poly in mesh.Nodes)
{
if (BoneTypes[(string)boneTypeComboBox.SelectedItem] == BoneTypes["None"])
poly.polflag = 0;

if (smoothNrmCB.Checked)
poly.SmoothNormals();

// Set the vertex size before tangent/bitangent calculations.
if (poly.vertSize == (int)Nud.Polygon.VertexTypes.NormalsHalfFloat) // what is this supposed to mean?
poly.vertSize = 0;
else
poly.vertSize = BoneTypes[(string)boneTypeComboBox.SelectedItem] | VertexTypes[(string)vertTypeComboBox.SelectedItem];
poly.normalType = VertexTypes[(string)vertTypeComboBox.SelectedItem];
poly.boneType = BoneTypes[(string)boneTypeComboBox.SelectedItem];

poly.CalculateTangentBitangent();
poly.CalculateTangentBitangent();

int vertSizeShadowWarning = (int)Nud.Polygon.BoneTypes.HalfFloat | (int)Nud.Polygon.VertexTypes.NormalsTanBiTanHalfFloat;
if (!hasShownShadowWarning && poly.vertSize == vertSizeShadowWarning)
if (!hasShownShadowWarning &&
poly.boneType == (int)Nud.Polygon.BoneTypes.HalfFloat &&
poly.normalType == (int)Nud.Polygon.VertexTypes.NormalsTanBiTanHalfFloat)
{
MessageBox.Show("Using \"" + (string)boneTypeComboBox.SelectedItem + "\" and \"" + (string)vertTypeComboBox.SelectedItem + "\" can make shadows not appear in-game.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand Down
Loading

0 comments on commit 91d1a8f

Please sign in to comment.