Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set/get_light_mask_value(layer_number) methods to CanvasItem #3472

Open
kleonc opened this issue Oct 27, 2021 · 2 comments
Open

Add set/get_light_mask_value(layer_number) methods to CanvasItem #3472

kleonc opened this issue Oct 27, 2021 · 2 comments

Comments

@kleonc
Copy link
Member

kleonc commented Oct 27, 2021

Describe the project you are working on

Godot.

Describe the problem or limitation you are having in your project

Currently there's no utility methods for getting/setting value (enabled/disabled) for a specific layer of CanvasItem::light_mask. It makes dealing with light_mask's layers in code not user-friendly (as not everyone is familiar with bitwise operators; also performing layer-involved logic manually is more error prone). Here's an example of a confused user.

Such utility methods are available for other similar properties involving layers like VisualInstance::layers, CollisionObject2D/3D::collision_layer/mask and so on (see: godotengine/godot#51532).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add user-friendly methods:

  • CanvasItem::set_light_mask_value(int layer_number, bool value),
  • CanvasItem::get_light_mask_value(int layer_number)

and expose them to the scripting languages. It will help the same way as other similar methods (see godotengine/godot#51532) - there will be no need to manipulate layer bits manually.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Implementation similar as in godotengine/godot#51532.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No idea if it will be used often.

Is there a reason why this should be core and not an add-on in the asset library?

It changes in-core class.

@Calinou
Copy link
Member

Calinou commented Oct 27, 2021

Shouldn't they be named get_light_mask_bit() and set_light_mask_bit() to be consistent with the collision layer bit and collision mask bit methods?

@kleonc
Copy link
Member Author

kleonc commented Oct 27, 2021

Shouldn't they be named get_light_mask_bit() and set_light_mask_bit() to be consistent with the collision layer bit and collision mask bit methods?

These were renamed, see godotengine/godot#51532.
However, I guess they'd need to be added with different names for 3.x so they'd follow the naming convention in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants