Skip to content

Commit e4e5e39

Browse files
committed
Add option to draw orient lines on selected object
1 parent 52017b9 commit e4e5e39

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/App/BuildConfig.bf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Nanoforge.App
2020
AssetsBasePath.Set(@".\assets\");
2121
#endif
2222
ShadersPath.Set(scope $@"{AssetsBasePath}shaders\");
23-
Version.Set("v1.1.0");
23+
Version.Set("v1.3.0");
2424
}
2525
}
2626
}

src/Gui/Documents/MapEditorDocument.bf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ namespace Nanoforge.Gui.Documents
8383
public String MapExportPath = new .() ~delete _;
8484
public bool HighlightSelectedObject = true;
8585
public bool RotateBoundingBoxes = false;
86+
public bool DrawOrientationLines = true;
8687
}
8788

8889
[BonTarget, ReflectAll]
@@ -565,6 +566,22 @@ namespace Nanoforge.Gui.Documents
565566
}
566567
}
567568

569+
//Draw lines indicating object orientation (red = right, green = up, blue = forward) on selected object
570+
if (SelectedObject == obj && CVar_MapEditorSettings.Value.DrawOrientationLines && obj.Orient.Enabled)
571+
{
572+
Vec3 right = obj.Orient.Value.Vectors[0];
573+
Vec3 up = obj.Orient.Value.Vectors[1];
574+
Vec3 forward = obj.Orient.Value.Vectors[2];
575+
Vec3 size = obj.BBox.Max - obj.BBox.Min;
576+
f32 orientLineScale = 2.0f; //How many times larger than the object orient lines should be
577+
f32 lineLength = orientLineScale * Math.Max(Math.Max(size.x, size.y), size.z); //Make lines equal length, as long as the widest side of the bbox
578+
579+
Mat3 orient = obj.Orient.Value;
580+
Vec3 center = obj.Position;
581+
Scene.DrawLine(center, center + (obj.Orient.Value.Vectors[0] * lineLength), Vec4(1.0f, 0.0f, 0.0f, 1.0f), 10.0f); //Right
582+
Scene.DrawLine(center, center + (obj.Orient.Value.Vectors[1] * lineLength), Vec4(0.0f, 1.0f, 0.0f, 1.0f), 10.0f); //Up
583+
Scene.DrawLine(center, center + (obj.Orient.Value.Vectors[2] * lineLength), Vec4(0.0f, 0.0f, 1.0f, 1.0f), 10.0f); //Forward
584+
}
568585
}
569586
}
570587

@@ -655,6 +672,12 @@ namespace Nanoforge.Gui.Documents
655672
}
656673
ImGui.TooltipOnPrevious("Rotate bounding boxes when drawing them. They get rotated to whatever the 'Orient' value gets set to. Requires the object to have the orient field enabled. Useful for objects that don't have a mesh.");
657674

675+
if (ImGui.MenuItem("Draw orientation lines", null, &CVar_MapEditorSettings.Value.DrawOrientationLines))
676+
{
677+
678+
}
679+
ImGui.TooltipOnPrevious("Draw lines indicating which direction an object is rotated in");
680+
658681
ImGui.EndMenu();
659682
}
660683

0 commit comments

Comments
 (0)