Skip to content

Add DisplayAnchors and Scissor support to DisplayItem#18

Draft
Copilot wants to merge 1 commit into
Text&Areafrom
copilot/add-display-anchors-and-scissor-tests
Draft

Add DisplayAnchors and Scissor support to DisplayItem#18
Copilot wants to merge 1 commit into
Text&Areafrom
copilot/add-display-anchors-and-scissor-tests

Conversation

Copy link
Copy Markdown

Copilot AI commented May 26, 2026

Checklist

Links to issue(s) this pull request concerns (if applicable)

#14

Pull request description

Extends DisplayItem (3D model display objects) with GetAnchors() and scissor clipping so they integrate with DisplayArea the same way DisplaySprite and DisplayString already do.

Changes

  • GetAnchors() for DisplayItem — Projects the 3D bounding box into 2D screen space and returns 9 anchor points (corners, edge midpoints, center) in percent coordinates, matching the API of DisplaySprite/DisplayString.
  • Scissor supportDisplayItem now stores a scissor rect. ScriptDisplayItem::Draw() captures the active scissor state set by DisplayArea, and Renderer::DrawObjectIn3DSpace() applies/resets it per item.
  • Lua registrationGetAnchors bound under the existing ScriptReserved_DisplayStringGetAnchors key.

Usage

local area = TEN.View.DisplayArea(Vec2(10, 10), Vec2(50, 50))
local item = TEN.View.DisplayItem(TEN.Objects.ObjID.PISTOLS_ITEM)

area:AddItem(item)
area:Draw() -- item is now clipped to area bounds

local anchors = item:GetAnchors()
print(anchors.CENTER) -- projected center in percent

- Added GetAnchors() method to ScriptDisplayItem that projects the 3D
  bounding box into 2D screen space and returns 9 anchor points
- Added scissor rect storage to DisplayItem (HasScissor, SetScissor,
  ClearScissor, GetScissorRect)
- Updated ScriptDisplayItem::Draw() to capture active scissor state
  from DisplayArea
- Updated Renderer::DrawObjectIn3DSpace() to apply/reset scissor rect
- Updated DisplayArea AddItem docs to mention DisplayItem support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants