libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
256 stars 81 forks source link

setIgnoreAttachedBody() not working #64

Closed ghost closed 9 years ago

ghost commented 9 years ago

I have been trying to use the new setIgnoreAttachedBody() in the 1.4 snapshot and unfortunately it is not working.

light.attachToBody(ground);
light.setIgnoreAttachedBody(true);
System.out.println(light.getIgnoreAttachedBody());

This is returning false and shadows are still being cast on the ground body. I have tried putting setIgnoreAttachedBody() before attachToBody() as well. It appears it will work with a ConeLight but not a DirectionalLight.

rinold commented 9 years ago

Ohh... The Directional light is not a positional light type and thus doesn't support the attaching to the bodies. The methods you have used on DirectionalLight are marked as deprecated with comment that they are not applicable to that light type, so it's not the issue that they are not working...

I don't want to modify them to allow such behavior cause it could be a mess of the same methods doing quite different things. However, I'll think about adding the other specific for DirectionalLight method to make the setIgnoreAttachedBody() work...

Currently, you can achieve the same effect by setting the filters to ignore the ground body using the following method:

dirLight.setContactFilter(...)
ghost commented 9 years ago

Yeah I figured out that it wasn't supported, apologies. But yes would certainly like to request that something similar for them is implemented.

rinold commented 9 years ago

Should be available in next releases :)

/** To disable the body shadow **/
DirectionalLight sun = new DirectionalLight (...);
sun.setIgnoreBody(someBodyToIgnore);

/** To get the ignored body **/
Body ignored = sun.getBody();

/** To disable **/
sun.setIgnoreBody(null);
ghost commented 9 years ago

Thanks a lot!