Fix string entries not being relocated properly for user data (switch bfres)

This commit is contained in:
KillzXGaming 2019-06-22 18:45:43 -04:00
parent 85333e7cf1
commit 7395d78d67
9 changed files with 17 additions and 10 deletions

Binary file not shown.

View file

@ -301,7 +301,7 @@ namespace FirstPlugin
mesh.SelectedImageKey = "model"; mesh.SelectedImageKey = "model";
mesh.BoneIndex = (int)VisualGroups[i].BoneIndex; mesh.BoneIndex = (int)VisualGroups[i].BoneIndex;
mesh.Text = Skeleton.bones[(int)VisualGroups[i].BoneIndex].Text; mesh.Text = Skeleton.bones[(int)VisualGroups[i].MeshIndex].Text;
Root.Renderer.Meshes.Add(mesh); Root.Renderer.Meshes.Add(mesh);
var Buffer = VertexBuffers[i]; var Buffer = VertexBuffers[i];
@ -367,6 +367,7 @@ namespace FirstPlugin
public Vector3 BoundingBoxMin = new Vector3(0); public Vector3 BoundingBoxMin = new Vector3(0);
public uint BoneIndex { get; set; } public uint BoneIndex { get; set; }
public uint MeshIndex { get; set; }
public void Read(FileReader reader) public void Read(FileReader reader)
{ {
@ -381,25 +382,25 @@ namespace FirstPlugin
//Read the info section for position data //Read the info section for position data
reader.SeekBegin(InfoPosition - InfoOffset); reader.SeekBegin(InfoPosition - InfoOffset);
ushort HeaderLength = reader.ReadUInt16(); ushort HeaderLength = reader.ReadUInt16();
ushort UnknownPosition = 0;
ushort VisBonePosition = 0; ushort VisBonePosition = 0;
ushort VisMeshPosition = 0;
ushort Unknown2Position = 0; ushort Unknown2Position = 0;
ushort VisBoundsPosition = 0; ushort VisBoundsPosition = 0;
ushort Unknown3Position = 0; ushort Unknown3Position = 0;
if (HeaderLength == 0x0A) if (HeaderLength == 0x0A)
{ {
UnknownPosition = reader.ReadUInt16();
VisBonePosition = reader.ReadUInt16(); VisBonePosition = reader.ReadUInt16();
Unknown2Position = reader.ReadUInt16(); VisMeshPosition = reader.ReadUInt16();
VisBoundsPosition = reader.ReadUInt16(); VisBoundsPosition = reader.ReadUInt16();
Unknown2Position = reader.ReadUInt16();
} }
else if (HeaderLength == 0x0C) else if (HeaderLength == 0x0C)
{ {
UnknownPosition = reader.ReadUInt16();
VisBonePosition = reader.ReadUInt16(); VisBonePosition = reader.ReadUInt16();
Unknown2Position = reader.ReadUInt16(); VisMeshPosition = reader.ReadUInt16();
VisBoundsPosition = reader.ReadUInt16(); VisBoundsPosition = reader.ReadUInt16();
Unknown2Position = reader.ReadUInt16();
Unknown3Position = reader.ReadUInt16(); Unknown3Position = reader.ReadUInt16();
} }
else else
@ -412,6 +413,12 @@ namespace FirstPlugin
BoundingBoxMax = reader.ReadVec3(); BoundingBoxMax = reader.ReadVec3();
} }
if (VisMeshPosition != 0)
{
reader.SeekBegin(InfoPosition + VisMeshPosition);
MeshIndex = reader.ReadUInt32();
}
if (VisBonePosition != 0) if (VisBonePosition != 0)
{ {
reader.SeekBegin(InfoPosition + VisBonePosition); reader.SeekBegin(InfoPosition + VisBonePosition);

View file

@ -1119,12 +1119,12 @@ namespace FirstPlugin
LoadOpenGLTexture(); LoadOpenGLTexture();
UpdateBfresTextureMapping(); UpdateTextureMapping();
if (IsEditorActive()) if (IsEditorActive())
UpdateEditor(); UpdateEditor();
} }
private void UpdateBfresTextureMapping() private void UpdateTextureMapping()
{ {
var viewport = LibraryGUI.Instance.GetActiveViewport(); var viewport = LibraryGUI.Instance.GetActiveViewport();
if (viewport == null) if (viewport == null)
@ -1137,6 +1137,8 @@ namespace FirstPlugin
((BFRESRender)drawable).UpdateTextureMaps(); ((BFRESRender)drawable).UpdateTextureMaps();
} }
} }
viewport.UpdateViewport();
} }
public void Export(string FileName, bool ExportSurfaceLevel = false, public void Export(string FileName, bool ExportSurfaceLevel = false,

View file

@ -895,8 +895,6 @@ namespace FirstPlugin
((FTEX)tex.Value).LoadOpenGLTexture(); ((FTEX)tex.Value).LoadOpenGLTexture();
} }
} }
LibraryGUI.Instance.UpdateViewport();
} }
private static void SetRenderPass(FMAT mat) private static void SetRenderPass(FMAT mat)