Mudlet icon indicating copy to clipboard operation
Mudlet copied to clipboard

3d2: exit colors overlapping?

Open Kebap opened this issue 3 months ago • 3 comments

Brief summary of issue:

Exit lines are grey. Only from current room, they are red. Until they are not?

Steps to reproduce the issue:

  1. This room has 8 exits in all directions. Those rooms have exits back to it as well.
  2. I would expect 8 red lines into each direction. Half the way, they will turn grey.
  3. Instead, depending on rotation and tilt, the red parts seem grey or a mixture!

Error output

Image

Extra information, such as the Mudlet version, operating system and ideas for how to solve:

This is in new experimental 3d mapper (number 2 so to say: 3d2) and in current compiled on Win11.

There are more exit lines overlapping here. They are probably overlapping the red lines in grey color.

Rooms are actually arranged in such a pattern:

1 2 3
4 5 6
7 8 9

Room 5 has exits to/from all the others, but also 1 to 9, etc. That line then probably overlaps lines 1 to 5 and 5 to 9 both.

Possibly all other exit lines need to be drawn before the red lines from current room are finally drawn. Much like current room is painted last so it is not overlapped (or at least in 2d map that is the case)

Kebap avatar Oct 01 '25 12:10 Kebap

This is a very sticky wicket. The rooms to the northwest [1] and southeast [9] are also directly connected to each other right? The interaction here is that the exit line drawn from 1 <-> 9 overlaps the red highlighted exit from 5 -> 1 and 5 -> 9, so you get this clipping with the red and grey exit boxes. The drawing order shouldn't matter as we have depth testing enabled.

The quickest solution I can think of is to make the red exit boxes slightly larger than the grey boxes, but if you zoom out enough you will still encounter clipping in these specific scenarios (where exit lines are on identical vector lines)

Harrison-Teeg avatar Oct 01 '25 18:10 Harrison-Teeg

The rooms to the northwest [1] and southeast [9] are also directly connected to each other right?

That is correct.

Kebap avatar Oct 01 '25 19:10 Kebap

Mudlet script to reproduce the issue -

-- Test script for issue #8296: 3D mapper exit line overlapping
-- Creates a 3x3 grid with overlapping connections to test red/grey rendering

-- Configuration
local TEST_AREA_NAME = "Exit Overlap Test"
local TEST_AREA_ID = 999  -- Use a high ID to avoid conflicts

-- Clean up any existing test area
if getRoomAreaName(TEST_AREA_ID) then
    deleteArea(TEST_AREA_ID)
end

-- Create the test area
addAreaName(TEST_AREA_ID, TEST_AREA_NAME)
echo("\n")
cecho("<green>Creating test map for issue #8296...\n")

-- Create 9 rooms in a 3x3 grid
local rooms = {}
local roomID = 1
for y = 1, 3 do
    for x = 1, 3 do
        rooms[roomID] = {
            id = roomID,
            x = x,
            y = y,
            z = 0
        }
        
        -- Create the room
        addRoom(roomID)
        setRoomArea(roomID, TEST_AREA_ID)
        setRoomCoordinates(roomID, x, y, 0)
        setRoomName(roomID, "Room " .. roomID)
        setRoomChar(roomID, tostring(roomID))
        
        -- Color rooms for visibility
        if roomID == 5 then
            -- Center room - make it stand out
            setRoomEnv(roomID, 266) -- Bright environment
        else
            setRoomEnv(roomID, 1) -- Default environment
        end
        
        roomID = roomID + 1
    end
end

cecho("<green>Created 9 rooms in a 3x3 grid\n")

-- Room layout:
-- 1  2  3
-- 4  5  6
-- 7  8  9

-- Create bidirectional connections from center room (5) to all surrounding rooms
local connections = {
    {5, 2, "n"},   -- North
    {5, 4, "w"},   -- West
    {5, 6, "e"},   -- East
    {5, 8, "s"},   -- South
    {5, 1, "nw"},  -- Northwest
    {5, 3, "ne"},  -- Northeast
    {5, 7, "sw"},  -- Southwest
    {5, 9, "se"},  -- Southeast
}

-- Create bidirectional exits
local directionPairs = {
    n = "s", s = "n", e = "w", w = "e",
    ne = "sw", sw = "ne", nw = "se", se = "nw"
}

for _, conn in ipairs(connections) do
    local from, to, dir = conn[1], conn[2], conn[3]
    local reverseDir = directionPairs[dir]
    
    -- Create exit from center to outer room
    setExit(from, to, dir)
    -- Create return exit
    setExit(to, from, reverseDir)
end

cecho("<green>Created bidirectional connections from room 5 to all surrounding rooms\n")

-- Add some diagonal connections between corners to create more overlapping
-- These will create overlapping paths that trigger the visual bug
local diagonalConnections = {
    {1, 9, "se"},  -- Top-left to bottom-right
    {3, 7, "sw"},  -- Top-right to bottom-left
    {2, 8, "s"},   -- Additional vertical connections
    {4, 6, "e"},   -- Additional horizontal connections
}

for _, conn in ipairs(diagonalConnections) do
    local from, to, dir = conn[1], conn[2], conn[3]
    local reverseDir = directionPairs[dir]
    
    setExit(from, to, dir)
    setExit(to, from, reverseDir)
end

cecho("<green>Created additional diagonal and cardinal connections for overlap testing\n")

-- Set the player's current location to the center room (where exits should be red)
mmp.gotoRoom(5)
centerview(5)

-- Print instructions
echo("\n")
cecho("<yellow>═══════════════════════════════════════════════════════════════\n")
cecho("<white>Test Map Created for Issue #8296\n")
cecho("<yellow>═══════════════════════════════════════════════════════════════\n")
cecho("<white>Room Layout:\n")
cecho("  <cyan>1  2  3\n")
cecho("  <cyan>4  5  6\n")
cecho("  <cyan>7  8  9\n\n")
cecho("<white>Current location: <green>Room 5 (center)\n\n")
cecho("<white>Testing Instructions:\n")
cecho("  <yellow>1.<white> Open the 3D mapper view\n")
cecho("  <yellow>2.<white> All exit lines from room 5 should appear <red>RED\n")
cecho("  <yellow>3.<white> Rotate the view with different angles\n")
cecho("  <yellow>4.<white> Red lines should <green>ALWAYS<white> appear on top of grey lines\n")
cecho("  <yellow>5.<white> Move to another room: <cyan>mmp.gotoRoom(1)<white> or <cyan>mmp.gotoRoom(9)\n")
cecho("  <yellow>6.<white> Exit lines from that room should be <red>RED\n")
cecho("  <yellow>7.<white> Exit lines from room 5 should now be <grey>GREY<white> and underneath\n\n")
cecho("<white>Commands:\n")
cecho("  <cyan>mmp.gotoRoom(N)<white>  - Move to room N (1-9)\n")
cecho("  <cyan>centerview(N)<white>    - Center map on room N\n")
cecho("  <cyan>deleteArea(" .. TEST_AREA_ID .. ")<white> - Remove test map\n")
cecho("<yellow>═══════════════════════════════════════════════════════════════\n")

-- Optional: Create a test command to cycle through rooms
if not testMapCycleRooms then
    testMapCycleRooms = function()
        local currentRoom = mmp.currentRoom or 5
        local nextRoom = (currentRoom % 9) + 1
        mmp.gotoRoom(nextRoom)
        centerview(nextRoom)
        cecho(f"<green>Moved to Room {nextRoom}\n")
    end
end

cecho("<white>Bonus: Type <cyan>testMapCycleRooms()<white> to cycle through rooms\n\n")

vadi2 avatar Oct 21 '25 14:10 vadi2