Skip to content

Commit e42a65a

Browse files
[Editor] Reverted ImGui;
[Rendering] Fix Lighting (temporary);
1 parent e104e41 commit e42a65a

File tree

10 files changed

+31
-36
lines changed

10 files changed

+31
-36
lines changed

Engine/Core/Rendering/Animation/SkinnedMeshRenderSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ public void Submit()
281281

282282
var needsChange = assetGuid != lastMeshAsset ||
283283
material.Guid != (lastMaterial?.Guid ?? "") ||
284-
lastAnimator != animator;
284+
lastAnimator != animator ||
285+
renderer.lighting != MaterialLighting.Unlit;
285286

286287
if (needsChange)
287288
{

Engine/Core/Rendering/Mesh/MeshRenderSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ void DrawMesh(int index)
224224
{
225225
var material = pair.renderer.materials[index];
226226

227-
var needsChange = lastMaterial?.Guid.GetHashCode() != material?.Guid?.GetHashCode();
227+
var needsChange = lastMaterial?.Guid.GetHashCode() != material?.Guid?.GetHashCode() ||
228+
pair.renderer.lighting != MaterialLighting.Unlit;
228229

229230
if (needsChange)
230231
{

Engine/Editor/Editors/Nodes/NodeUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void Draw()
141141
int endAttribute = 0;
142142
bool fromSnap = false;
143143

144-
if (ImNodes.IsLinkCreated(ref startNode, ref startAttribute, ref endNode, ref endAttribute, ref fromSnap))
144+
if (ImNodes.IsLinkCreatedIntPtr(ref startNode, ref startAttribute, ref endNode, ref endAttribute, ref fromSnap))
145145
{
146146
if (nodes.TryGetValue(startNode, out var start) &&
147147
nodes.TryGetValue(endNode, out var end))

Engine/Editor/ImGuiProxy.cs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,14 @@ public bool Initialize()
8686
unsafe
8787
{
8888
byte *data = null;
89-
var fontWidth = 0;
90-
var fontHeight = 0;
89+
int fontWidth = 0;
90+
int fontHeight = 0;
9191

9292
io.Fonts.GetTexDataAsRGBA32(&data, ref fontWidth, ref fontHeight);
9393

94-
if (data == null)
95-
{
96-
Log.Error("Failed to load font");
97-
98-
return false;
99-
}
100-
101-
var fontData = new byte[fontWidth * fontHeight * 4];
94+
byte[] fontData = new byte[fontWidth * fontHeight * 4];
10295

103-
for(var i = 0; i < fontData.Length; i++)
96+
for(int i = 0; i < fontData.Length; i++)
10497
{
10598
fontData[i] = data[i];
10699
}
@@ -322,15 +315,15 @@ private void Render(ImDrawDataPtr drawData)
322315
var clipPos = drawData.DisplayPos;
323316
var clipScale = drawData.FramebufferScale;
324317

325-
for (var i = 0; i < drawData.CmdListsCount; i++)
318+
for (int i = 0; i < drawData.CmdListsCount; i++)
326319
{
327320
bgfx.TransientVertexBuffer tvb;
328321
bgfx.TransientIndexBuffer tib;
329322

330323
var cmdList = drawData.CmdLists.Data[i];
331324

332-
var numVertices = cmdList.VtxBuffer.Size;
333-
var numIndices = cmdList.IdxBuffer.Size;
325+
var numVertices = cmdList->VtxBuffer.Size;
326+
var numIndices = cmdList->IdxBuffer.Size;
334327

335328
if (RenderSystem.CheckAvailableTransientBuffers((uint)numVertices, layout.layout, (uint)numIndices) == false)
336329
{
@@ -346,15 +339,15 @@ private void Render(ImDrawDataPtr drawData)
346339

347340
var size = numVertices * sizeof(ImDrawVert);
348341

349-
Buffer.MemoryCopy(cmdList.VtxBuffer.Data, tvb.data, size, size);
342+
Buffer.MemoryCopy((void *)cmdList->VtxBuffer.Data, tvb.data, size, size);
350343

351344
size = numIndices * sizeof(ushort);
352345

353-
Buffer.MemoryCopy(cmdList.IdxBuffer.Data, tib.data, size, size);
346+
Buffer.MemoryCopy((void *)cmdList->IdxBuffer.Data, tib.data, size, size);
354347

355-
for (var j = 0; j < cmdList.CmdBuffer.Size; j++)
348+
for (var j = 0; j < cmdList->CmdBuffer.Size; j++)
356349
{
357-
var drawCmd = cmdList.CmdBuffer.Data[j];
350+
var drawCmd = cmdList->CmdBuffer.Data[j];
358351

359352
if (drawCmd.ElemCount == 0 || drawCmd.UserCallback != null)
360353
{
@@ -409,14 +402,14 @@ private void Render(ImDrawDataPtr drawData)
409402
}
410403

411404
[MethodImpl(MethodImplOptions.AggressiveInlining)]
412-
public static ImTextureID GetImGuiTexture(Texture texture)
405+
public static IntPtr GetImGuiTexture(Texture texture)
413406
{
414407
if(texture == null || texture.handle.Valid == false || texture.Disposed)
415408
{
416-
return ImTextureID.Null;
409+
return IntPtr.Zero;
417410
}
418411

419-
return new ImTextureID((ulong)texture.handle.idx);
412+
return new IntPtr(texture.handle.idx);
420413
}
421414

422415
[MethodImpl(MethodImplOptions.AggressiveInlining)]

Engine/Editor/ImGuiUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void ContentGrid(List<ContentGridItem> items, float padding, float
5151

5252
if(ImGui.IsItemHovered())
5353
{
54-
if(ImGui.GetMouseClickedCount(ImGuiMouseButton.Left) == 2)
54+
if(ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
5555
{
5656
onDoubleClick?.Invoke(i, item);
5757
}

Engine/Editor/StapleEditor+ImGuiStyle.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public static void SetupImGuiStyle()
7676
style.Colors[(int)ImGuiCol.ResizeGripActive] = new Vector4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.949999988079071f);
7777
style.Colors[(int)ImGuiCol.Tab] = new Vector4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f);
7878
style.Colors[(int)ImGuiCol.TabHovered] = new Vector4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.800000011920929f);
79-
style.Colors[(int)ImGuiCol.TabSelected] = new Vector4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f);
80-
style.Colors[(int)ImGuiCol.TabDimmed] = new Vector4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f);
81-
style.Colors[(int)ImGuiCol.TabDimmedSelected] = new Vector4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f);
79+
style.Colors[(int)ImGuiCol.TabActive] = new Vector4(0.2000000029802322f, 0.2470588237047195f, 0.2862745225429535f, 1.0f);
80+
style.Colors[(int)ImGuiCol.TabUnfocused] = new Vector4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f);
81+
style.Colors[(int)ImGuiCol.TabUnfocusedActive] = new Vector4(0.1098039224743843f, 0.1490196138620377f, 0.168627455830574f, 1.0f);
8282
style.Colors[(int)ImGuiCol.PlotLines] = new Vector4(0.6078431606292725f, 0.6078431606292725f, 0.6078431606292725f, 1.0f);
8383
style.Colors[(int)ImGuiCol.PlotLinesHovered] = new Vector4(1.0f, 0.4274509847164154f, 0.3490196168422699f, 1.0f);
8484
style.Colors[(int)ImGuiCol.PlotHistogram] = new Vector4(0.8980392217636108f, 0.6980392336845398f, 0.0f, 1.0f);
@@ -90,6 +90,7 @@ public static void SetupImGuiStyle()
9090
style.Colors[(int)ImGuiCol.TableRowBgAlt] = new Vector4(1.0f, 1.0f, 1.0f, 0.05999999865889549f);
9191
style.Colors[(int)ImGuiCol.TextSelectedBg] = new Vector4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 0.3499999940395355f);
9292
style.Colors[(int)ImGuiCol.DragDropTarget] = new Vector4(1.0f, 1.0f, 0.0f, 0.8999999761581421f);
93+
style.Colors[(int)ImGuiCol.NavHighlight] = new Vector4(0.2588235437870026f, 0.5882353186607361f, 0.9764705896377563f, 1.0f);
9394
style.Colors[(int)ImGuiCol.NavWindowingHighlight] = new Vector4(1.0f, 1.0f, 1.0f, 0.699999988079071f);
9495
style.Colors[(int)ImGuiCol.NavWindowingDimBg] = new Vector4(0.800000011920929f, 0.800000011920929f, 0.800000011920929f, 0.2000000029802322f);
9596
style.Colors[(int)ImGuiCol.ModalWindowDimBg] = new Vector4(0.800000011920929f, 0.800000011920929f, 0.800000011920929f, 0.3499999940395355f);

Engine/Editor/StapleEditor+Panels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void HandleReorder(bool before)
391391
var beforeString = before ? "BEFORE" : "AFTER";
392392

393393
ImGui.Selectable($"##{transform.entity.Name}-{transform.entity.Identifier.ID}-{beforeString}",
394-
ImGui.IsMouseDragging(ImGuiMouseButton.Left, -1) ? ImGuiSelectableFlags.None : ImGuiSelectableFlags.Disabled,
394+
ImGui.IsDragDropActive() ? ImGuiSelectableFlags.None : ImGuiSelectableFlags.Disabled,
395395
new Vector2(ImGui.GetContentRegionAvail().X, 2));
396396

397397
if (ImGui.BeginDragDropTarget())

Engine/Editor/StapleEditor+Render.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static void ExecuteBlock(object source, Action execute)
6666
var matrix = Math.TransformationMatrix(selectedTransform.Position, selectedTransform.Scale, selectedTransform.Rotation);
6767
var delta = Matrix4x4.Identity;
6868

69-
if (ImGuizmo.Manipulate((float *)&view, (float*)&projection, transformOperation, transformMode,
70-
(float*)&matrix, (float*)&delta, snap, localBound, snap))
69+
if (ImGuizmo.Manipulate(ref view, ref projection, transformOperation, transformMode, ref matrix, ref delta, snap, localBound, snap))
7170
{
7271
Matrix4x4.Invert(selectedTransform.parent?.Matrix ?? Matrix4x4.Identity, out var invParent);
7372

Engine/Editor/StapleEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public void Run()
646646

647647
ImGui.Selectable($"{lastProjects.items[i].name}##PL{i}");
648648

649-
if(ImGui.IsItemHovered() && ImGui.GetMouseClickedCount(ImGuiMouseButton.Left) == 2)
649+
if(ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
650650
{
651651
LoadProject(lastProjects.items[i].path);
652652

Engine/Editor/StapleEditor.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@
140140
</ItemGroup>
141141
<ItemGroup>
142142
<PackageReference Include="Microsoft.Build" Version="17.7.2" />
143-
<PackageReference Include="Hexa.NET.ImGui" Version="2.1.10" />
144-
<PackageReference Include="Hexa.NET.ImGuizmo" Version="2.1.10" />
145-
<PackageReference Include="Hexa.NET.ImNodes" Version="2.1.10" />
146-
<PackageReference Include="Hexa.NET.ImPlot" Version="2.1.10" />
143+
<PackageReference Include="Hexa.NET.ImGui" Version="1.0.3" />
144+
<PackageReference Include="Hexa.NET.ImGuizmo" Version="1.0.3" />
145+
<PackageReference Include="Hexa.NET.ImNodes" Version="1.0.3" />
146+
<PackageReference Include="Hexa.NET.ImPlot" Version="1.0.3" />
147147
</ItemGroup>
148148

149149
<ItemGroup>

0 commit comments

Comments
 (0)