Prevent viewport changing models if there are none in bfres.

This commit is contained in:
KillzXGaming 2019-06-07 20:13:34 -04:00
parent 3ecb714df1
commit 7a02a36a2d
8 changed files with 30 additions and 11 deletions

Binary file not shown.

View file

@ -314,11 +314,20 @@ namespace FirstPlugin
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
bool HasModels = false;
bool HasShapes = false;
if (bfresEditor == null)
{
BFRESRender.UpdateModelList();
HasModels = BFRESRender.models.Count > 0;
foreach (var model in BFRESRender.models)
{
if (model.shapes.Count > 0)
{
HasShapes = true;
break;
}
}
bfresEditor = new BfresEditor(HasModels);
bfresEditor.Dock = DockStyle.Fill;
@ -421,7 +430,7 @@ namespace FirstPlugin
}
if (Runtime.UseOpenGL)
bfresEditor.LoadViewport(this, DrawableContainer);
bfresEditor.LoadViewport(this, HasShapes, DrawableContainer);
bool IsSimpleEditor = PluginRuntime.UseSimpleBfresEditor;

View file

@ -790,11 +790,6 @@ namespace Bfres.Structs
}
}
if (settings.MapOriginalMaterials)
{
}
if (settings.LimitSkinCount)
{
for (int i = 0; i < assimp.objects.Count; i++)

View file

@ -858,6 +858,11 @@ namespace Bfres.Structs
MessageBox.Show("No models found!");
return;
}
byte ForceSkinInfluenceMax = VertexSkinCount;
var originalAttributes = vertexAttributes;
BfresModelImportSettings settings = new BfresModelImportSettings();
settings.SetModelAttributes(assimp.objects[0]);
if (settings.ShowDialog() == DialogResult.OK)
@ -867,9 +872,17 @@ namespace Bfres.Structs
Cursor.Current = Cursors.WaitCursor;
VertexBufferIndex = obj.VertexBufferIndex;
vertices = obj.vertices;
CreateBoneList(obj, (FMDL)Parent.Parent, false);
CreateIndexList(obj, (FMDL)Parent.Parent);
VertexSkinCount = obj.GetMaxSkinInfluenceCount();
CreateBoneList(obj, (FMDL)Parent.Parent, settings.LimitSkinCount, ForceSkinInfluenceMax);
CreateIndexList(obj, (FMDL)Parent.Parent, settings.LimitSkinCount, ForceSkinInfluenceMax);
if (settings.UseOriginalAttributeFormats)
vertexAttributes = originalAttributes;
if (settings.LimitSkinCount)
obj.VertexSkinCount = ForceSkinInfluenceMax;
else
VertexSkinCount = obj.GetMaxSkinInfluenceCount();
vertexAttributes = settings.CreateNewAttributes();
ApplyImportSettings(settings, GetMaterial());
lodMeshes = obj.lodMeshes;

View file

@ -157,7 +157,7 @@ namespace FirstPlugin.Forms
public bool IsLoaded = false;
private BFRES ActiveBfres;
public void LoadViewport(BFRES bfres, DrawableContainer ActiveDrawable, List<ToolStripMenuItem> customContextMenus = null)
public void LoadViewport(BFRES bfres, bool HasShapes, DrawableContainer ActiveDrawable, List<ToolStripMenuItem> customContextMenus = null)
{
ActiveBfres = bfres;
@ -170,11 +170,13 @@ namespace FirstPlugin.Forms
viewport.LoadCustomMenuItem(menu);
}
viewport.ReloadDrawables(ActiveDrawable);
if (ActiveDrawable.Drawables.Count > 0 && HasShapes)
viewport.ReloadDrawables(ActiveDrawable);
OnLoadedTab();
}
public override void OnControlClosing()
{
animationPanel.ClosePanel();