Item Placement and Lighting
Hey Folks! I managed to get another day of mostly coding done, which always feels good.
First up was item placement. Yesterday's issue I noticed with the items ignoring placement rules turned out to be a minor one. For some reason, the check I added to make sure items couldn't be placed illegally was just being called in the wrong place. I'm not sure if I moved it when working on another thing, or if I was testing it some weird way. But after some moving around of code, that was working normally again.
Then, I wanted to see if I could expand yesterday's line-of-sight (LoS) code to also work for lighting. The good news, it does! It didn't take too much work to figure out how to use the LoS code to calculate where a light shines vs. casts a shadow. And it even supports color and color blending (e.g. with other, overlapping lights)!
The bad news: the way the light intensity diminishes over distance looks a bit weird. I'm still trying to figure out what exactly is happening, but it appears that the light goes really far in each of the diagonal and cardinal directions. So I get these sort of star-shaped patterns in lighting blobs.
At first, I thought the LoS code was somehow doubling up on those tiles. It uses something called "octants," which basically divides a full 360 arc into 8 equal arcs, and perhaps where those octants meet, tiles were getting light added twice. So I cleverly halved light intensity along each of those directions.
That worked at first (with a red light), until I started using other light colors. The star pattern seems to come and go depending on color, which means this may be a perceptual color blending issue. It also may be a falloff issue, since I was trying to do realistic attenuation based on inverse square law.
So as of now, I have a really cool lighting system with some distance-fading bugs, on top of a really cool LoS system. I might get some really neat ship interiors if I can get this working, so more on this tomorrow.
Which reminds me, I may not get much done tomorrow. We have a doctor's appointment for the baby, as well as a vet's appointment for the cat, so it could be a wash as far as productivity. I'll do my best, though, and maybe catch up in the evening or weekend. Or say "hell with it" and call it a day off :)
Anyway, hope everyone has a good night!