mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 07:04:36 +00:00
Some cleanup
This commit is contained in:
parent
211b530c45
commit
940994604a
9 changed files with 95 additions and 148 deletions
|
@ -87,8 +87,7 @@ namespace LayoutBXLYT
|
|||
};
|
||||
}
|
||||
|
||||
if (!Runtime.DEVELOPER_DEBUG_MODE)
|
||||
DrawRectangle(pane, gameWindow, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha, isSelected);
|
||||
DrawRectangle(pane, gameWindow, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha, isSelected);
|
||||
|
||||
ShaderLoader.CafeShader.Disable();
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ namespace LayoutBXLYT
|
|||
shader.SetInt("textures1", 0);
|
||||
shader.SetInt("textures2", 0);
|
||||
|
||||
if (Runtime.DEVELOPER_DEBUG_MODE)
|
||||
return;
|
||||
|
||||
BindTextureUniforms(shader, material);
|
||||
|
||||
if (material.TextureMaps.Length > 0 || Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.UVTestPattern)
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace FirstPlugin
|
|||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
|
||||
public void CenterCamera(GL_ControlModern control)
|
||||
public void CenterCamera(GL_ControlBase control)
|
||||
{
|
||||
if (!Runtime.FrameCamera)
|
||||
return;
|
||||
|
|
|
@ -141,9 +141,9 @@ namespace FirstPlugin.Forms
|
|||
if (!Runtime.UseOpenGL || !DisplayViewport)
|
||||
return;
|
||||
|
||||
if (viewport.GL_ControlModern != null)
|
||||
if (viewport.GL_Control != null)
|
||||
{
|
||||
Renderer.CenterCamera(viewport.GL_ControlModern);
|
||||
Renderer.CenterCamera(viewport.GL_Control);
|
||||
viewport.UpdateViewport();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ using OpenTK;
|
|||
namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
{
|
||||
public class Matrix2DHelper
|
||||
{
|
||||
{
|
||||
public static Vector3 RotatePoint(Vector3 translate, float X, float Y, float Z, Vector3 rotate)
|
||||
{
|
||||
Matrix4 rotationX = Matrix4.CreateRotationX(rotate.X);
|
||||
|
|
|
@ -464,10 +464,10 @@ namespace FirstPlugin.Forms
|
|||
|
||||
for (int frame = 0; frame < PathTime; frame++)
|
||||
{
|
||||
if (viewport.GL_ControlModern != null)
|
||||
if (viewport.GL_Control != null)
|
||||
{
|
||||
// viewport.GL_ControlModern.CameraEye = pathLookAtPoint.Translate;
|
||||
viewport.GL_ControlModern.CameraTarget = pathMovePoint.Translate;
|
||||
viewport.GL_Control.CameraTarget = pathMovePoint.Translate;
|
||||
|
||||
viewport.UpdateViewport();
|
||||
}
|
||||
|
|
|
@ -277,37 +277,19 @@ namespace Toolbox.Library
|
|||
if (viewport == null)
|
||||
return;
|
||||
|
||||
if (viewport.GL_ControlLegacy != null &&
|
||||
!viewport.GL_ControlLegacy.IsDisposed)
|
||||
if (viewport.GL_Control == null || viewport.GL_Control.IsDisposed || viewport.GL_Control.Disposing)
|
||||
return;
|
||||
|
||||
if (viewport.GL_Control.InvokeRequired)
|
||||
{
|
||||
if (viewport.GL_ControlLegacy.InvokeRequired)
|
||||
{
|
||||
viewport.GL_ControlLegacy.Invoke((MethodInvoker)delegate {
|
||||
// Running on the UI thread
|
||||
viewport.GL_ControlLegacy.Invalidate();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
viewport.GL_ControlLegacy.Invalidate();
|
||||
}
|
||||
viewport.GL_Control.Invoke((MethodInvoker)delegate {
|
||||
// Running on the UI thread
|
||||
viewport.GL_Control.Invalidate();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (viewport.GL_ControlModern == null || viewport.GL_ControlModern.IsDisposed || viewport.GL_ControlModern.Disposing)
|
||||
return;
|
||||
|
||||
if (viewport.GL_ControlModern.InvokeRequired)
|
||||
{
|
||||
viewport.GL_ControlModern.Invoke((MethodInvoker)delegate {
|
||||
// Running on the UI thread
|
||||
viewport.GL_ControlModern.Invalidate();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
viewport.GL_ControlModern.Invalidate();
|
||||
}
|
||||
viewport.GL_Control.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +325,7 @@ namespace Toolbox.Library
|
|||
|
||||
private void SetAnimationsToFrame(float frameNum)
|
||||
{
|
||||
if (currentAnimation == null)
|
||||
if (currentAnimation == null && stCurrentAnimation == null)
|
||||
return;
|
||||
|
||||
var viewport = LibraryGUI.GetActiveViewport();
|
||||
|
@ -352,6 +334,8 @@ namespace Toolbox.Library
|
|||
|
||||
if (stCurrentAnimation != null)
|
||||
{
|
||||
Console.WriteLine("SetAnimationsToFrame");
|
||||
|
||||
if (frameNum > stCurrentAnimation.FrameCount)
|
||||
return;
|
||||
|
||||
|
@ -449,10 +433,8 @@ namespace Toolbox.Library
|
|||
Viewport viewport = LibraryGUI.GetActiveViewport();
|
||||
if (viewport != null)
|
||||
{
|
||||
if (viewport.GL_ControlLegacy != null)
|
||||
viewport.GL_ControlLegacy.VSync = Runtime.enableVSync;
|
||||
else
|
||||
viewport.GL_ControlModern.VSync = Runtime.enableVSync;
|
||||
if (viewport.GL_Control != null)
|
||||
viewport.GL_Control.VSync = Runtime.enableVSync;
|
||||
}
|
||||
|
||||
renderThread = new Thread(new ThreadStart(RenderAndAnimationLoop));
|
||||
|
@ -524,6 +506,8 @@ namespace Toolbox.Library
|
|||
isOpen = false;
|
||||
Dispose();
|
||||
|
||||
Console.WriteLine("Disposeing ANIM PANEL!!");
|
||||
|
||||
}
|
||||
|
||||
private void panel1_Paint(object sender, PaintEventArgs e)
|
||||
|
|
|
@ -52,10 +52,7 @@ namespace Toolbox.Library
|
|||
if (viewport == null)
|
||||
return null;
|
||||
|
||||
if (viewport.GL_ControlModern != null)
|
||||
return viewport.GL_ControlModern;
|
||||
else
|
||||
return viewport.GL_ControlLegacy;
|
||||
return viewport.GL_Control;
|
||||
}
|
||||
|
||||
public void SetViewport(OpenTK.GLControl control)
|
||||
|
|
|
@ -35,8 +35,7 @@ namespace Toolbox.Library
|
|||
public List<DrawableContainer> DrawableContainers;
|
||||
|
||||
public EditorScene scene = new EditorScene();
|
||||
public GL_ControlLegacy GL_ControlLegacy;
|
||||
public GL_ControlModern GL_ControlModern;
|
||||
public GL_ControlBase GL_Control;
|
||||
|
||||
Runtime.ViewportEditor editor;
|
||||
|
||||
|
@ -173,12 +172,6 @@ namespace Toolbox.Library
|
|||
|
||||
public Bitmap CaptureScreenshot(int width, int height, bool enableAlpha)
|
||||
{
|
||||
GLControl control = null;
|
||||
if (GL_ControlModern != null)
|
||||
control = GL_ControlModern;
|
||||
else
|
||||
control = GL_ControlLegacy;
|
||||
|
||||
Bitmap bitmap = new Bitmap(width, height);
|
||||
return bitmap;
|
||||
}
|
||||
|
@ -196,20 +189,14 @@ namespace Toolbox.Library
|
|||
private void LoadViewport()
|
||||
{
|
||||
if (Runtime.UseLegacyGL)
|
||||
{
|
||||
GL_ControlLegacy = new GL_ControlLegacy();
|
||||
GL_ControlLegacy.Dock = DockStyle.Fill;
|
||||
|
||||
panelViewport.Controls.Add(GL_ControlLegacy);
|
||||
}
|
||||
GL_Control = new GL_ControlLegacy();
|
||||
else
|
||||
{
|
||||
GL_ControlModern = new GL_ControlModern();
|
||||
GL_ControlModern.Dock = DockStyle.Fill;
|
||||
GL_ControlModern.VSync = true;
|
||||
GL_Control = new GL_ControlModern();
|
||||
|
||||
panelViewport.Controls.Add(GL_ControlModern);
|
||||
}
|
||||
|
||||
GL_Control.Dock = DockStyle.Fill;
|
||||
GL_Control.VSync = true;
|
||||
panelViewport.Controls.Add(GL_Control);
|
||||
}
|
||||
|
||||
public void UpdateGrid()
|
||||
|
@ -277,26 +264,21 @@ namespace Toolbox.Library
|
|||
UpdateScene();
|
||||
}
|
||||
|
||||
private void UpdateScene()
|
||||
{
|
||||
if (GL_ControlModern != null)
|
||||
GL_ControlModern.MainDrawable = scene;
|
||||
if (GL_ControlLegacy != null)
|
||||
GL_ControlLegacy.MainDrawable = scene;
|
||||
private void UpdateScene() {
|
||||
if (GL_Control != null)
|
||||
GL_Control.MainDrawable = scene;
|
||||
}
|
||||
|
||||
public void UpdateViewport()
|
||||
{
|
||||
if (SuppressUpdating) return;
|
||||
|
||||
if (GL_ControlModern != null)
|
||||
GL_ControlModern.Refresh();
|
||||
if (GL_ControlLegacy != null)
|
||||
GL_ControlLegacy.Refresh();
|
||||
if (GL_Control != null)
|
||||
GL_Control.Refresh();
|
||||
}
|
||||
public void RenderToTexture()
|
||||
{
|
||||
if (GL_ControlModern == null)
|
||||
if (GL_Control == null)
|
||||
return;
|
||||
|
||||
int Framebuffer = 0;
|
||||
|
@ -325,55 +307,31 @@ namespace Toolbox.Library
|
|||
}
|
||||
public void LoadViewportRuntimeValues()
|
||||
{
|
||||
if (GL_ControlLegacy != null)
|
||||
if (GL_Control != null)
|
||||
{
|
||||
switch (Runtime.cameraMovement)
|
||||
{
|
||||
case Runtime.CameraMovement.Inspect:
|
||||
GL_ControlLegacy.ActiveCamera = new InspectCamera(Runtime.MaxCameraSpeed);
|
||||
GL_Control.ActiveCamera = new InspectCamera(Runtime.MaxCameraSpeed);
|
||||
break;
|
||||
case Runtime.CameraMovement.Walk:
|
||||
GL_ControlLegacy.ActiveCamera = new WalkaroundCamera(Runtime.MaxCameraSpeed);
|
||||
GL_Control.ActiveCamera = new WalkaroundCamera(Runtime.MaxCameraSpeed);
|
||||
break;
|
||||
}
|
||||
GL_ControlLegacy.Stereoscopy = Runtime.stereoscopy;
|
||||
GL_ControlLegacy.ZNear = Runtime.CameraNear;
|
||||
GL_ControlLegacy.ZFar = Runtime.CameraFar;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Runtime.cameraMovement)
|
||||
{
|
||||
case Runtime.CameraMovement.Inspect:
|
||||
GL_ControlModern.ActiveCamera = new InspectCamera(Runtime.MaxCameraSpeed);
|
||||
break;
|
||||
case Runtime.CameraMovement.Walk:
|
||||
GL_ControlModern.ActiveCamera = new WalkaroundCamera(Runtime.MaxCameraSpeed);
|
||||
break;
|
||||
}
|
||||
GL_ControlModern.Stereoscopy = Runtime.stereoscopy;
|
||||
GL_ControlModern.ZNear = Runtime.CameraNear;
|
||||
GL_ControlModern.ZFar = Runtime.CameraFar;
|
||||
|
||||
GL_Control.Stereoscopy = Runtime.stereoscopy;
|
||||
GL_Control.ZNear = Runtime.CameraNear;
|
||||
GL_Control.ZFar = Runtime.CameraFar;
|
||||
}
|
||||
}
|
||||
public void SetupViewportRuntimeValues()
|
||||
{
|
||||
if (GL_ControlLegacy != null)
|
||||
if (GL_Control != null)
|
||||
{
|
||||
if (GL_ControlLegacy.ActiveCamera is InspectCamera)
|
||||
if (GL_Control.ActiveCamera is InspectCamera)
|
||||
Runtime.cameraMovement = Runtime.CameraMovement.Inspect;
|
||||
if (GL_ControlLegacy.ActiveCamera is WalkaroundCamera)
|
||||
if (GL_Control.ActiveCamera is WalkaroundCamera)
|
||||
Runtime.cameraMovement = Runtime.CameraMovement.Walk;
|
||||
Runtime.stereoscopy = GL_ControlLegacy.Stereoscopy;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GL_ControlModern.ActiveCamera is InspectCamera)
|
||||
Runtime.cameraMovement = Runtime.CameraMovement.Inspect;
|
||||
if (GL_ControlModern.ActiveCamera is WalkaroundCamera)
|
||||
Runtime.cameraMovement = Runtime.CameraMovement.Walk;
|
||||
Runtime.stereoscopy = GL_ControlModern.Stereoscopy;
|
||||
Runtime.stereoscopy = GL_Control.Stereoscopy;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,8 +355,8 @@ namespace Toolbox.Library
|
|||
|
||||
private void reloadShadersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GL_ControlModern != null)
|
||||
GL_ControlModern.ReloadShaders();
|
||||
if (GL_Control != null && GL_Control is GL_ControlModern)
|
||||
((GL_ControlModern)GL_Control).ReloadShaders();
|
||||
}
|
||||
|
||||
private void resetPoseToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -407,7 +365,8 @@ namespace Toolbox.Library
|
|||
|
||||
if (animationPanel1 != null)
|
||||
{
|
||||
if (animationPanel1.CurrentAnimation != null)
|
||||
if (animationPanel1.CurrentAnimation != null ||
|
||||
animationPanel1.CurrentSTAnimation != null)
|
||||
animationPanel1.ResetModels();
|
||||
|
||||
UpdateViewport();
|
||||
|
@ -498,39 +457,25 @@ namespace Toolbox.Library
|
|||
{
|
||||
int pickingBuffer = (int)CameraPick;
|
||||
|
||||
if (GL_ControlModern != null)
|
||||
GL_ControlModern.ApplyCameraOrientation(pickingBuffer);
|
||||
else
|
||||
GL_ControlModern.ApplyCameraOrientation(pickingBuffer);
|
||||
if (GL_Control != null)
|
||||
GL_Control.ApplyCameraOrientation(pickingBuffer);
|
||||
|
||||
UpdateViewport();
|
||||
}
|
||||
|
||||
private void toOriginToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GL_ControlLegacy != null)
|
||||
{
|
||||
GL_ControlLegacy.ResetCamera(false);
|
||||
GL_ControlLegacy.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_ControlModern.ResetCamera(false);
|
||||
GL_ControlModern.Refresh();
|
||||
if (GL_Control != null) {
|
||||
GL_Control.ResetCamera(false);
|
||||
GL_Control.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void toActiveModelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GL_ControlLegacy != null)
|
||||
{
|
||||
GL_ControlLegacy.ResetCamera(true);
|
||||
GL_ControlLegacy.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_ControlModern.ResetCamera(true);
|
||||
GL_ControlModern.Refresh();
|
||||
if (GL_Control != null) {
|
||||
GL_Control.ResetCamera(true);
|
||||
GL_Control.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,6 +495,9 @@ namespace Toolbox.Library
|
|||
|
||||
for (int i = 0; i < DrawableContainers.Count; i++)
|
||||
{
|
||||
if (i == index)
|
||||
CenterCamera(GL_Control, new List<DrawableContainer>() { DrawableContainers[i] });
|
||||
|
||||
for (int a = 0; a < DrawableContainers[i].Drawables.Count; a++)
|
||||
{
|
||||
if (i == index)
|
||||
|
@ -596,6 +544,32 @@ namespace Toolbox.Library
|
|||
}
|
||||
}
|
||||
|
||||
public void CenterCamera(GL_ControlBase control, List<DrawableContainer> Drawables)
|
||||
{
|
||||
if (!Runtime.FrameCamera)
|
||||
return;
|
||||
|
||||
var spheres = new List<Vector4>();
|
||||
for (int i = 0; i < Drawables.Count; i++)
|
||||
{
|
||||
foreach (var drawable in Drawables[i].Drawables)
|
||||
{
|
||||
if (drawable is IMeshContainer)
|
||||
{
|
||||
for (int m = 0; m < ((IMeshContainer)drawable).Meshes.Count; m++)
|
||||
{
|
||||
var mesh = ((IMeshContainer)drawable).Meshes[m];
|
||||
var vertexPositions = mesh.vertices.Select(x => x.pos).Distinct();
|
||||
spheres.Add(control.GenerateBoundingSphere(vertexPositions));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (spheres.Count > 0)
|
||||
control.FrameSelect(spheres);
|
||||
}
|
||||
|
||||
private void uVViewerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Runtime.UseOpenGL)
|
||||
|
@ -609,23 +583,15 @@ namespace Toolbox.Library
|
|||
uvEditor1.Show(this);
|
||||
}
|
||||
|
||||
public GLControl GetActiveControl()
|
||||
{
|
||||
if (GL_ControlModern != null)
|
||||
return GL_ControlModern;
|
||||
else
|
||||
return GL_ControlLegacy;
|
||||
}
|
||||
|
||||
public void SaveScreenshot()
|
||||
{
|
||||
var control = GetActiveControl();
|
||||
if (GL_Control == null) return;
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = BitmapExtension.FileFilter;
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
CreateScreenshot(control.Width, control.Height, false).Save(sfd.FileName);
|
||||
CreateScreenshot(GL_Control.Width, GL_Control.Height, false).Save(sfd.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,10 +625,8 @@ namespace Toolbox.Library
|
|||
Runtime.cameraMovement = Runtime.CameraMovement.Inspect;
|
||||
}
|
||||
|
||||
if (GL_ControlModern != null)
|
||||
GL_ControlModern.ResetCamera(Runtime.FrameCamera);
|
||||
else
|
||||
GL_ControlModern.ResetCamera(Runtime.FrameCamera);
|
||||
if (GL_Control != null)
|
||||
GL_Control.ResetCamera(Runtime.FrameCamera);
|
||||
|
||||
LoadViewportRuntimeValues();
|
||||
UpdateViewport();
|
||||
|
|
Loading…
Reference in a new issue