does line-of-sight work

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

does line-of-sight work

by leetelate » Mon Nov 04, 2013 23:12

i asked this before but got no answer, so i moved it here hoping for a better response - otherwise it means that nobody knows and that leaves me to have to fix my broken line-of-sight code and doing that makes me go grrrr

so, does Line Of Sight work?

where:
local p1={x=pos1.x,y=pos1.y,z=pos1.z}
local p2={x=pos2.x,y=pos2.y,z=pos2.z}
local los = minetest..line_of_sight(p1,p2,1)
so los will be true if there is a clear line of sight between p1 and p2, or false if there is not?
what about glass?
what about blocks adjacent only at the corners? like:
XX1XXX
XXX2XX
would that be false, or true?

(from the api)
minetest.line_of_sight(pos1,pos2,stepsize) ->true/false
^ checkif there is a direct line of sight between pos1 and pos2
^ pos1 First position
^ pos2 Second position
^ stepsize smaller gives more accurate results but requires more computing
time. Default is 1.

BAH! There is a tree between me and it, then I am standing on top of it, jumping up and down on it, and it always says "false"!

the cpp for it is pathfinder.cpp, but

local zpath = {}
zpath = minetest.find_path(p1,p2,10,1,1,"") --default algo
if zpath then ....

doesn't work either - says "14:41:04: ERROR[ServerThread]: invalid startposIndex: (10,10,10)Realpos: (156,32,123)"

p1 is 156,32,123 and p2 is 156.46600341797,32.5,123.71800994873 when i was standing on top of it

oh and the minetest is from 2 days ago, compiled with git clone blah blah blah

thank you...this is driving me nutso - i dun wanna fix my broke code waaaa
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Tue Nov 05, 2013 08:51

Try a smaller step size, ie: 0.2
Stepsize 1 means it goes forward a block each time, so you may miss blocks.

I have never got either of these to work.

Line of sight means there is no blocks in its way, apart from air, so glass will stop LOS.

Try rounding or flooring the positions; get rid of the decimal places in the positions.
Last edited by rubenwardy on Tue Nov 05, 2013 09:04, edited 1 time in total.
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Tue Nov 05, 2013 17:56

thanks - i just tried 0.2, 0.1, 0.01, 2 lol - no joy - pathfinder.cpp reads like slopping through deep mud, with costs and manhatan distance - i think it no worky :- ( - guess this means i have to fix my los code AGAIN - pffffft - thanks anyway - meh, my code works ok, the problem is in the adjacent corner blocks, and i just need to force it to look non-diagonally along y - niceu with the step though, just pop along x,y,z in the right direction (basically the sign of 1-2) checking each spot as if you were there - better than my do...while code anyway
Last edited by leetelate on Tue Nov 05, 2013 18:08, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Tue Nov 05, 2013 18:05

line_of_sight() seems to work to me.
It works only for air node, though, so it doesnt "see" through glass.
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Tue Nov 05, 2013 18:10

PilzAdam wrote:line_of_sight() seems to work to me.
It works only for air node, though, so it doesnt "see" through glass.


what is your call to do it (with specifics please) - did you math.floor player_pos before? - trying that now
Last edited by leetelate on Tue Nov 05, 2013 18:12, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Tue Nov 05, 2013 19:01

it's actually returning nil, not true or false - are we doing something wrong?

time to make a tester mod - brb
Last edited by leetelate on Tue Nov 05, 2013 19:29, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Tue Nov 05, 2013 19:01

leetelate wrote:
PilzAdam wrote:line_of_sight() seems to work to me.
It works only for air node, though, so it doesnt "see" through glass.


what is your call to do it (with specifics please) - did you math.floor player_pos before? - trying that now

I use it in the mobs mob in Pilztest: https://github.com/PilzAdam/pilztest/blob/master/mods/mobs/init.lua#L100 and https://github.com/PilzAdam/pilztest/blob/master/mods/mobs/init.lua#L157
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Tue Nov 05, 2013 19:06

thanks, checking

here's the test mod - drop the blocks and check the print for results
Attachments
lostest.tar.gz
(1.47 KiB) Downloaded 73 times
Last edited by leetelate on Tue Nov 05, 2013 19:07, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Tue Nov 05, 2013 19:19

ahem, pp.y = pp.y + 1 and use it as "if minetest.line_of_sight(p3, p4, 0.1) then", not in a var

told ya it was something we didn't know

works fine now. thanks

rewrote the test mod, below

thanks again,
SOLVED
Attachments
lostest.tar.gz
(1.44 KiB) Downloaded 65 times
Last edited by leetelate on Tue Nov 05, 2013 19:24, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 12 guests

cron