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 rendering layer mask to GridMap #86992

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kilojool
Copy link
Contributor

@kilojool kilojool commented Jan 9, 2024

This PR adds support for rendering layers to GridMap. It is mostly a straight-up copy of the code from VisualInstance3D. Perhaps it would be better to inherit from VisualInstance3D, but since GridMap handles collision and navigation also, I assumed that was the reason it didn't already.

Solves #40245

@kilojool kilojool requested a review from a team as a code owner January 9, 2024 11:14
@@ -1121,6 +1160,8 @@ void GridMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision_priority"), "set_collision_priority", "get_collision_priority");
ADD_GROUP("Navigation", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bake_navigation"), "set_bake_navigation", "is_baking_navigation");
ADD_GROUP("Rendering", "rendering_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rendering_layer", PROPERTY_HINT_LAYERS_3D_RENDER), "set_rendering_layer_mask", "get_rendering_layer_mask");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ADD_PROPERTY(PropertyInfo(Variant::INT, "rendering_layer", PROPERTY_HINT_LAYERS_3D_RENDER), "set_rendering_layer_mask", "get_rendering_layer_mask");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rendering_layers", PROPERTY_HINT_LAYERS_3D_RENDER), "set_rendering_layer_mask", "get_rendering_layer_mask");

To match other use, it's layers in VisualInstance3D, and it's not a singular layer

@@ -151,6 +151,7 @@ class GridMap : public Node3D {

uint32_t collision_layer = 1;
uint32_t collision_mask = 1;
uint32_t rendering_layer = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t rendering_layer = 1;
uint32_t rendering_layers = 1;

@@ -962,11 +993,14 @@ void GridMap::_update_visibility() {
for (int i = 0; i < octant->multimesh_instances.size(); i++) {
const Octant::MultimeshInstance &mi = octant->multimesh_instances[i];
RS::get_singleton()->instance_set_visible(mi.instance, is_visible_in_tree());
RS::get_singleton()->instance_set_layer_mask(mi.instance, get_rendering_layer_mask());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

modules/gridmap/doc_classes/GridMap.xml Show resolved Hide resolved
modules/gridmap/doc_classes/GridMap.xml Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants