mirror of
https://github.com/4sval/FModel.git
synced 2026-04-05 00:26:17 -05:00
no more useless data in buffer
This commit is contained in:
parent
40500d925f
commit
cd73bdd70f
|
|
@ -192,7 +192,7 @@ public class Model : IDisposable
|
|||
_morphVbo = new BufferObject<float>(_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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user