mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-20 07:34:25 +01:00
Merge remote-tracking branch 'ackwell/mdl-io-triage-6'
This commit is contained in:
commit
97166379a7
2 changed files with 25 additions and 5 deletions
|
|
@ -138,7 +138,27 @@ public class VertexAttribute
|
||||||
|
|
||||||
return new VertexAttribute(
|
return new VertexAttribute(
|
||||||
element,
|
element,
|
||||||
index => BuildNByte4(values[index])
|
index => {
|
||||||
|
// Blend weights are _very_ sensitive to float imprecision - a vertex sum being off
|
||||||
|
// by one, such as 256, is enough to cause a visible defect. To avoid this, we tweak
|
||||||
|
// the converted values to have the expected sum, preferencing values with minimal differences.
|
||||||
|
var originalValues = values[index];
|
||||||
|
var byteValues = BuildNByte4(originalValues);
|
||||||
|
|
||||||
|
var adjustment = 255 - byteValues.Select(value => (int)value).Sum();
|
||||||
|
while (adjustment != 0)
|
||||||
|
{
|
||||||
|
var convertedValues = byteValues.Select(value => value * (1f / 255f)).ToArray();
|
||||||
|
var closestIndex = Enumerable.Range(0, 4)
|
||||||
|
.Select(index => (index, delta: Math.Abs(originalValues[index] - convertedValues[index])))
|
||||||
|
.MinBy(x => x.delta)
|
||||||
|
.index;
|
||||||
|
byteValues[closestIndex] = (byte)(byteValues[closestIndex] + Math.CopySign(1, adjustment));
|
||||||
|
adjustment = 255 - byteValues.Select(value => (int)value).Sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
return byteValues;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -401,13 +401,13 @@ public partial class ModEditWindow
|
||||||
|
|
||||||
private void DrawInvalidMaterialMarker()
|
private void DrawInvalidMaterialMarker()
|
||||||
{
|
{
|
||||||
using var colorHandle = ImRaii.PushColor(ImGuiCol.TextDisabled, 0xFF0000FF, true);
|
using (var font = ImRaii.PushFont(UiBuilder.IconFont))
|
||||||
|
ImGuiUtil.TextColored(0xFF0000FF, FontAwesomeIcon.TimesCircle.ToIconString());
|
||||||
|
|
||||||
ImGuiComponents.HelpMarker(
|
ImGuiUtil.HoverTooltip(
|
||||||
"Materials must be either relative (e.g. \"/filename.mtrl\")\n"
|
"Materials must be either relative (e.g. \"/filename.mtrl\")\n"
|
||||||
+ "or absolute (e.g. \"bg/full/path/to/filename.mtrl\"),\n"
|
+ "or absolute (e.g. \"bg/full/path/to/filename.mtrl\"),\n"
|
||||||
+ "and must end in \".mtrl\".",
|
+ "and must end in \".mtrl\".");
|
||||||
FontAwesomeIcon.TimesCircle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool DrawModelLodDetails(MdlTab tab, int lodIndex, bool disabled)
|
private bool DrawModelLodDetails(MdlTab tab, int lodIndex, bool disabled)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue