fix(editor): NPC nameplates align with NPC + togglable to selected only

Three issues fixed in one pass:

1. Z-offset was 35 yards — nameplates floated way above the actual
   NPC position. Dropped to 3.5 yards (just above an average
   creature's head) so the label reads as attached.

2. Horizontal alignment was a fixed -30 px offset, which only looked
   centered for ~6-character names. Switched to ImGui::CalcTextSize
   and centering on the projected position.

3. Nameplates were always-on, which got noisy fast on populated
   zones. Added "Nameplate on selected only" checkbox in the NPC
   panel (default ON); when unchecked, all NPCs show their names.

Vertical position also slightly tightened (sy - textSz.y - 2 vs
sy - 10) so the text baseline aligns rather than floating below.
This commit is contained in:
Kelsi 2026-05-07 09:48:59 -07:00
parent 0e2b55f9fd
commit 3a6f119f7a
2 changed files with 32 additions and 3 deletions

View file

@ -62,6 +62,14 @@ public:
void setWireframe(bool enabled);
void setShowNpcMarkers(bool show) { showNpcMarkers_ = show; }
bool getShowNpcMarkers() const { return showNpcMarkers_; }
// Nameplates: when true, only show the floating name label on the
// currently-selected NPC; otherwise show on all of them. Default true
// to keep the viewport quiet — was previously always-on, which got
// noisy fast on populated zones.
void setNpcNameplatesSelectedOnly(bool sel) { npcNameplatesSelectedOnly_ = sel; }
bool getNpcNameplatesSelectedOnly() const { return npcNameplatesSelectedOnly_; }
bool isWireframe() const { return wireframe_; }
void setClearColor(float r, float g, float b) { clearR_=r; clearG_=g; clearB_=b; }
@ -143,6 +151,7 @@ private:
// NPC position markers
bool showNpcMarkers_ = true;
bool npcNameplatesSelectedOnly_ = true;
VkBuffer npcMarkerVB_ = VK_NULL_HANDLE;
VmaAllocation npcMarkerVBAlloc_ = VK_NULL_HANDLE;
uint32_t npcMarkerVertCount_ = 0;