Skip to content

Commit da7802b

Browse files
committed
bug fixes
1 parent 8961347 commit da7802b

12 files changed

Lines changed: 51 additions & 56 deletions

File tree

Editor/EditorWindow.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ public EditorWindow(double fps, int width, int height, IFileProvider fileProvide
6464
};
6565
}
6666

67-
protected override void OnLoad()
68-
{
69-
base.OnLoad();
70-
71-
OnFramebufferResize(new FramebufferResizeEventArgs(ClientSize)); // we initialize a bunch of stuff to 1x1 by default until we know the true size of the framebuffer
72-
}
73-
7467
private void DoLoad()
7568
{
7669
GL.Enable(EnableCap.DepthTest);
@@ -91,6 +84,8 @@ private void DoLoad()
9184

9285
CenterWindow();
9386
IsVisible = true;
87+
88+
OnFramebufferResize(new FramebufferResizeEventArgs(ClientSize)); // we initialize a bunch of stuff to 1x1 by default until we know the true size of the framebuffer
9489
}
9590

9691
private readonly ConcurrentQueue<Action> _commands = new();

Editor/Managers/ImGuiController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ public void Update(GameWindow wnd, float delta)
9696
io.AddInputCharacter(c);
9797
}
9898

99-
io.KeyShift = kState.IsKeyDown(Keys.LeftShift) || kState.IsKeyDown(Keys.RightShift);
100-
io.KeyCtrl = kState.IsKeyDown(Keys.LeftControl) || kState.IsKeyDown(Keys.RightControl);
101-
io.KeyAlt = kState.IsKeyDown(Keys.LeftAlt) || kState.IsKeyDown(Keys.RightAlt);
102-
io.KeySuper = kState.IsKeyDown(Keys.LeftSuper) || kState.IsKeyDown(Keys.RightSuper);
99+
io.AddKeyEvent(ImGuiKey.ModShift, kState.IsKeyDown(Keys.LeftShift) || kState.IsKeyDown(Keys.RightShift));
100+
io.AddKeyEvent(ImGuiKey.ModCtrl, kState.IsKeyDown(Keys.LeftControl) || kState.IsKeyDown(Keys.RightControl));
101+
io.AddKeyEvent(ImGuiKey.ModAlt, kState.IsKeyDown(Keys.LeftAlt) || kState.IsKeyDown(Keys.RightAlt));
102+
io.AddKeyEvent(ImGuiKey.ModSuper, kState.IsKeyDown(Keys.LeftSuper) || kState.IsKeyDown(Keys.RightSuper));
103103

104104
_frameBegun = true;
105105
ImGui.NewFrame();

Editor/Managers/ImGuiManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected ImGuiManager(GameWindow wnd, IFileProvider fileProvider) : base(wnd, f
5353
var scale = Math.Min(xScale, yScale);
5454

5555
var io = ImGui.GetIO();
56+
io.DisplaySize = new Vector2(Settings.DefaultWidthHeight);
5657

5758
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
5859
var assemblyName = assembly.GetName().Name;

Editor/Widgets/JsonViewerWidget.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,46 +58,9 @@ public void DrawAll()
5858

5959
private void DrawTextArea(string text, int id)
6060
{
61-
var style = ImGui.GetStyle();
6261
var avail = ImGui.GetContentRegionAvail();
63-
var btnSize = new Vector2(ImGui.GetFrameHeight());
64-
var origin = ImGui.GetCursorScreenPos();
65-
6662
ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0.08f, 0.08f, 0.08f, 1f));
6763
ImGui.InputTextMultiline($"##json{id}", ref text, (uint)text.Length, new Vector2(avail.X, avail.Y), ImGuiInputTextFlags.ReadOnly);
6864
ImGui.PopStyleColor();
69-
70-
var btnMin = new Vector2(origin.X + avail.X - style.ScrollbarSize - btnSize.X - style.FramePadding.X, origin.Y + style.FramePadding.Y);
71-
var btnMax = btnMin + btnSize;
72-
73-
var mousePos = ImGui.GetIO().MousePos;
74-
var hovered = mousePos.X >= btnMin.X && mousePos.X <= btnMax.X && mousePos.Y >= btnMin.Y && mousePos.Y <= btnMax.Y;
75-
var clicked = hovered && ImGui.IsMouseClicked(ImGuiMouseButton.Left);
76-
77-
if (clicked)
78-
ImGui.SetClipboardText(text);
79-
80-
var dl = ImGui.GetForegroundDrawList();
81-
if (hovered)
82-
{
83-
dl.AddRectFilled(btnMin, btnMax,
84-
ImGui.IsMouseDown(ImGuiMouseButton.Left)
85-
? ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 0.15f))
86-
: ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 0.08f)),
87-
4f);
88-
}
89-
90-
const string icon = "\uf0c5";
91-
var iconSize = ImGui.CalcTextSize(icon);
92-
var iconPos = new Vector2(
93-
btnMin.X + (btnSize.X - iconSize.X) * 0.5f,
94-
btnMin.Y + (btnSize.Y - iconSize.Y) * 0.5f);
95-
96-
dl.AddText(iconPos, ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, hovered ? 1f : 0.4f)), icon);
97-
98-
if (hovered)
99-
{
100-
ImGui.SetTooltip("Copy JSON");
101-
}
10265
}
10366
}

Snooper/Core/Containers/Resources/GeometryPool.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public GeometryHandle Add(PrimitiveDescriptor<TVertex> descriptor, Vector2 drawD
105105
maxLod++;
106106
}
107107

108-
return (o.LOD_FirstIndex[0], o.LOD_BaseVertex[0], o.LOD_BaseColor[0], Math.Min(maxLod, Settings.MaxNumberOfLods) - 1, o);
108+
var lodCount = Math.Min(maxLod, Settings.MaxNumberOfLods);
109+
return (o.LOD_FirstIndex[0], o.LOD_BaseVertex[0], o.LOD_BaseColor[0], lodCount > 0 ? lodCount - 1 : 0, o);
109110
}
110111
}
111112

Snooper/Rendering/Components/Camera/CameraComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public class CameraComponent : SpatialComponent, IViewProjectionProvider, IResiz
3131
public float AspectRatio { get; private set; } = 1.777778f;
3232

3333
public float OrthoWidth { get; } = 15.0f;
34-
public float OrthoNearClipPlane { get; private set; } = 0.1f;
34+
public float OrthoNearClipPlane { get; private set; } = 0.01f;
3535
public float OrthoFarClipPlane { get; private set; } = 20000.0f;
3636

37-
public float PerspectiveNearClipPlane { get; private set; } = 0.1f;
37+
public float PerspectiveNearClipPlane { get; private set; } = 0.01f;
3838
public float PerspectiveFarClipPlane { get; private set; } = 20000.0f;
3939

4040
public CameraMode ProjectionMode { get; } = CameraMode.Perspective;

Snooper/Rendering/Components/Descriptors/LodDescriptor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class LodDescriptor<TVertex> : IControllable where TVertex : unmanaged
2020
public SectionDescriptor[] Sections { get; }
2121

2222
private TPrimitiveData<TVertex>? _primitive;
23-
private readonly Func<TPrimitiveData<TVertex>>? _factory;
23+
private Func<TPrimitiveData<TVertex>>? _factory;
2424

2525
public LodDescriptor(TPrimitiveData<TVertex> primitive, bool castShadow = false)
2626
{
@@ -107,6 +107,7 @@ internal TPrimitiveData<TVertex> CreatePrimitive()
107107
throw new InvalidOperationException("Cannot create primitive: no factory available.");
108108

109109
_primitive = _factory();
110+
_factory = null;
110111
return _primitive;
111112
}
112113

Snooper/Rendering/FragmentColorMode.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public static class FragmentColorMode
1212
public const uint BoneWeightPainting = 7;
1313
public const uint LODLevel = 8;
1414
public const uint MorphDisplacement = 9;
15+
public const uint Uv = 10;
1516

1617
public static readonly string[] Labels =
1718
[
@@ -25,5 +26,6 @@ public static class FragmentColorMode
2526
"Weight Painting",
2627
"LOD Level",
2728
"Morph Displacement",
29+
"UV",
2830
];
2931
}

Snooper/Rendering/Systems/ClusteredLightSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ private abstract class LightBindings : Bindings
9292

9393
private int _numClusters;
9494
private int _numWorkGroups;
95-
private int _screenWidth = 1;
96-
private int _screenHeight = 1;
95+
private int _screenWidth = Settings.DefaultWidthHeight;
96+
private int _screenHeight = Settings.DefaultWidthHeight;
9797

9898
private bool _clustersDirty = true;
9999
private Matrix4x4 _lastClusterProjection;

Snooper/Rendering/Systems/IndirectRenderSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected virtual void OnResourcesAdded(TComponent component, ResourcesMetadata
9191
material.OnMaterialDataContainerSet += section =>
9292
{
9393
TextureCache.Add(section);
94-
// component.IsOpaque &= !section.IsTranslucent;
94+
component.IsOpaque &= !section.IsTranslucent;
9595
};
9696
}
9797
}

0 commit comments

Comments
 (0)