Line of sight

sapier
Member
 
Posts: 763
Joined: Tue Aug 16, 2011 18:17

Line of sight

by sapier » Sat Jan 07, 2012 16:46

on some ocassions you need to know if between to positions is a line of sight. Doing this in lua is possible but may have huge performance impact,


Line of sight patch (fixed 3)

hopfully I'll manage to get the right one linked in here soon
Last edited by sapier on Sat Jan 07, 2012 17:41, edited 1 time in total.
DON'T mention coding style!
(c) sapier all rights reserved
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sat Jan 07, 2012 17:25

Should be merged!
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Sat Jan 07, 2012 23:50

Isn't line of sight done in the client, not the server?

Edit:

Oh, I looked at the patch, you are just looking to see if there are any nodes between two points. Don't you need to take into account transparent nodes, like glass? Also, you might need to double check that getNodeNoEx() will force load a map block if it is not already in memory. Most of the getnode functions will not do that. You get a null or CONTENT_IGNORE node.
Last edited by randomproof on Sat Jan 07, 2012 23:54, edited 1 time in total.
 

sapier
Member
 
Posts: 763
Joined: Tue Aug 16, 2011 18:17

by sapier » Sun Jan 08, 2012 04:25

no I'don't just look if there's a node i already had a discussion with celeron about what is best to look at ... my first implementation did use "sunlight_propagates" but celeron didn't like this as fences for example would be a los problem.

Using the light parameter was his suggestion and i do support it too.

I didn't know that getNodeNoEx() does have this effect but I don't think its bad too if asking for line of sight you do want to know if there's a line of sight. In regular case you won't have to load any blocks as all blocks between active entities and players will be already loaded.

Of course you may always ask "do i have a line of sight to something not within active area". I don't see any usecase for this atm ... if there really is none you might be right and we should avoid creating an additional error case. But of course this will have the effect that we do give wrong information in some cases telling there is no line of sight while there is one.

EDIT1: probably there is a line of sight check in client but only for player actions. There can't be a check if the acting object is a server active object e.g. a mob that need's to decide if it can se a player and therefor start an attack ... not like current dm's attacking player even if they can't see them
Last edited by sapier on Sun Jan 08, 2012 04:31, edited 1 time in total.
DON'T mention coding style!
(c) sapier all rights reserved
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Mon Jan 09, 2012 15:50

Ok, that makes sense. I didn't know how you were using this function. Everything seems right.
 

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » Tue Jan 10, 2012 14:49


v3f has a normalize method. I think you could do something like (pos2-pos1).normalize() instead of implementing the normalization yourself.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 2 guests

cron