diff --git a/FModel/Views/Snooper/Model.cs b/FModel/Views/Snooper/Model.cs index 899eec41..2a783419 100644 --- a/FModel/Views/Snooper/Model.cs +++ b/FModel/Views/Snooper/Model.cs @@ -192,7 +192,7 @@ public class Model : IDisposable _morphVbo = new BufferObject(_gl, Morphs[morph].Vertices, BufferTargetARB.ArrayBuffer); } _vao.Bind(); - _vao.VertexAttributePointer(11, 3, VertexAttribPointerType.Float, _vertexSize, 1); // morph position + _vao.VertexAttributePointer(11, 3, VertexAttribPointerType.Float, 3, 0); // morph position _vao.Unbind(); } diff --git a/FModel/Views/Snooper/Morph.cs b/FModel/Views/Snooper/Morph.cs index 1830d020..80488c9e 100644 --- a/FModel/Views/Snooper/Morph.cs +++ b/FModel/Views/Snooper/Morph.cs @@ -10,13 +10,15 @@ public class Morph : IDisposable private uint _handle; private GL _gl; + private uint _vertexSize = 3; // Position + public readonly string Name; public readonly float[] Vertices; public Morph(float[] vertices, uint vertexSize, UMorphTarget morphTarget) { Name = morphTarget.Name; - Vertices = (float[]) vertices.Clone(); + Vertices = new float[vertices.Length / vertexSize * _vertexSize]; bool TryFindVertex(uint index, out FVector positionDelta) { @@ -32,13 +34,22 @@ public class Morph : IDisposable return false; } - for (uint i = 0; i < Vertices.Length; i += vertexSize) + for (uint i = 0; i < vertices.Length; i += vertexSize) { - if (!TryFindVertex((uint) Vertices[i + 0], out var positionDelta)) continue; - - Vertices[i + 1] += positionDelta.X * Constants.SCALE_DOWN_RATIO; - Vertices[i + 2] += positionDelta.Z * Constants.SCALE_DOWN_RATIO; - Vertices[i + 3] += positionDelta.Y * Constants.SCALE_DOWN_RATIO; + var count = 0; + var baseIndex = i / vertexSize * _vertexSize; + if (TryFindVertex((uint) vertices[i + 0], out var positionDelta)) + { + Vertices[baseIndex + count++] = vertices[i + 1] + positionDelta.X * Constants.SCALE_DOWN_RATIO; + Vertices[baseIndex + count++] = vertices[i + 2] + positionDelta.Z * Constants.SCALE_DOWN_RATIO; + Vertices[baseIndex + count++] = vertices[i + 3] + positionDelta.Y * Constants.SCALE_DOWN_RATIO; + } + else + { + Vertices[baseIndex + count++] = vertices[i + 1]; + Vertices[baseIndex + count++] = vertices[i + 2]; + Vertices[baseIndex + count++] = vertices[i + 3]; + } } } diff --git a/FModel/Views/Snooper/SnimGui.cs b/FModel/Views/Snooper/SnimGui.cs index a2f9d22a..83ec1e34 100644 --- a/FModel/Views/Snooper/SnimGui.cs +++ b/FModel/Views/Snooper/SnimGui.cs @@ -315,6 +315,7 @@ public class SnimGui : IDisposable if (model.HasMorphTargets && ImGui.BeginTabItem("Morph Targets")) { + PushStyleCompact(); if (ImGui.BeginListBox("", new Vector2(ImGui.GetContentRegionAvail().X, _propertiesSize.Y / 2))) { for (int i = 0; i < model.Morphs.Length; i++) @@ -329,8 +330,9 @@ public class SnimGui : IDisposable } ImGui.EndListBox(); ImGui.Separator(); - ImGui.DragFloat("Value", ref model.MorphTime, 0.001f, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags.AlwaysClamp); + ImGui.DragFloat("Value", ref model.MorphTime, 0.01f, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags.AlwaysClamp); } + PopStyleCompact(); ImGui.EndTabItem(); } }