Skip to content

EGP - egpObjectContainsPoint question #3354

Answered by Denneisk
Zylenxx asked this question in Q&A
Discussion options

You must be logged in to vote

Uh, in the code your provided, this works for me.

local Nearest = TABL1:getNearestPoly(TABL1:egpCursor(owner()))
local IsHit= TABL1:egpObjectContainsPoint(Nearest,TABL1:egpCursor(owner()))

And this simple test code will turn a poly green when you mouse over it.

@persist EGP:wirelink

EGP = entity():isWeldedTo():wirelink()
EGP:egpClear()

event tick() {
    EGP:egpPoly(1, vec2(100), vec2(100, 300), vec2(300))
    
    local Point = EGP:egpCursor(owner())
    local Hit = EGP:egpObjectContainsPoint(1, Point)
    EGP:egpColor(1, Hit ? vec(0, 255, 0) : vec(255, 0, 0))
}

Updating the triangle every tick to the cursor's position, however, does not work in this method. It's a bug that's resolved in

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
11 replies
@Zylenxx
Comment options

@Denneisk
Comment options

@Zylenxx
Comment options

@Denneisk
Comment options

Answer selected by Zylenxx
@Zylenxx
Comment options

@Zylenxx
Comment options

@Denneisk
Comment options

@Zylenxx
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants