libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
257 stars 82 forks source link

Lights under body ignore the body #104

Closed svby closed 4 years ago

svby commented 7 years ago

Here's an example

As you can see, this isn't really the best-looking result.

I'm guessing this is because Box2D raycasts ignore fixtures they start in, but is there a way I can modify this behavior (perhaps turn off the light if a body touches it, besides using a sensor fixture for the light?)

(IMO it would look better if the rays just weren't displayed inside the body but still were outside instead of simply disabling the light)

rinold commented 7 years ago

This is really the Box2D behavior. And don't think this would be processed by the box2dlights ever - it would be or over-complicated solution (still used in rare cases) or would give the performance burn on each step due to additional "contains" checks... So the sensor, or your fixture containing lights center - seems the only way to check it for now.

Regarding the light being shaded inside the body, that's a tough thing also. Currently there is no way to override the built by box2dlights internal meshes for lights, and actually changing the PointLight to behave the way you described would kind of an alter of it's to ChainLight. Still it might be possible (not sure) to overlap the light with custom shade form of the body - need to check this option first.