You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
Static bodies used inside a GridMap have very limited usage. Since GridMap doesn't inherits from CollisionObject3D, many of the properties present in StaticBody3D nodes aren't found in GridMaps. In its current state, a complete solution would require to use GridMap just for rendering geometry, and independent StaticBody3D nodes to correctly manage physics. What I'm proposing here is just one of many enhancements that can be done in the physics side of GridMaps: implement input_event, mouse_entered and mouse_exited signals.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
First of all, there should be an input_ray_pickable property to control if the GridMap should respond to mouse input. In the current implementation all static bodies in a GridMap have a 'hidden' input_ray_pickable value that is always true. This means that other CollisionObject3Ds that expect to receive mouse input, can be blocked by a GridMap with static bodies without a way to prevent this.
Later, the viewport code most be modified to consider the case where the collision object that the mouse pointer is intercating with, is owned by a GridMap.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The signals should work in the same way as the ones in CollisionObject3D. One useful addition could be to include the cell where the collided shape resides in. In this way the signals would have the following signature:
mouse_exited(cell: Vector3i)
Note that shape_idx in the input_event signal is mostly useless since it's the index among all the shapes within an octant. Instead of giving the real shape index, it can be passed the shape index within the cell, as specified by the MeshLibrary.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Mouse interaction can be detected by manually casting a ray, but then it's difficult to get the cell or exact shape that the mouse is interacting with (see godotengine/godot#46561). Since GridMap contains StaticBodies, one would expect to have the same capabilities
Is there a reason why this should be core and not an add-on in the asset library?
As an enhancement to the GridMap node, this belongs to core.
The text was updated successfully, but these errors were encountered:
This issue is not specific to GridMap. Any node (often custom) that doesn't inherit CollisionObject3D, or doesn't use nodes internally rather using PhysicsServer3D directly, has no way to implement the input picking feature.
It is possible to associate any object to a collider with PhysicsServer3D.body_attach_object_instance_id, so doing raycasts can find the corresponding node/object, yet Godot's input system always assumes CollisionObject3D.
This came up in my plugin Zylann/godot_heightmap_plugin#418 (comment)
And might eventually come up in my voxel terrain plugin (which can be similar to GridMap, only with many more cells and multiple colliders).
Describe the project you are working on
Imrpovements to the GridMap node
Describe the problem or limitation you are having in your project
Static bodies used inside a GridMap have very limited usage. Since GridMap doesn't inherits from CollisionObject3D, many of the properties present in StaticBody3D nodes aren't found in GridMaps. In its current state, a complete solution would require to use GridMap just for rendering geometry, and independent StaticBody3D nodes to correctly manage physics. What I'm proposing here is just one of many enhancements that can be done in the physics side of GridMaps: implement
input_event
,mouse_entered
andmouse_exited
signals.Describe the feature / enhancement and how it helps to overcome the problem or limitation
First of all, there should be an
input_ray_pickable
property to control if the GridMap should respond to mouse input. In the current implementation all static bodies in a GridMap have a 'hidden' input_ray_pickable value that is always true. This means that other CollisionObject3Ds that expect to receive mouse input, can be blocked by a GridMap with static bodies without a way to prevent this.Later, the viewport code most be modified to consider the case where the collision object that the mouse pointer is intercating with, is owned by a GridMap.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The signals should work in the same way as the ones in CollisionObject3D. One useful addition could be to include the cell where the collided shape resides in. In this way the signals would have the following signature:
input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int, cell: Vector3i)
mouse_entered(cell: Vector3i)
mouse_exited(cell: Vector3i)
Note that
shape_idx
in theinput_event
signal is mostly useless since it's the index among all the shapes within an octant. Instead of giving the real shape index, it can be passed the shape index within the cell, as specified by the MeshLibrary.If this enhancement will not be used often, can it be worked around with a few lines of script?
Mouse interaction can be detected by manually casting a ray, but then it's difficult to get the cell or exact shape that the mouse is interacting with (see godotengine/godot#46561). Since GridMap contains StaticBodies, one would expect to have the same capabilities
Is there a reason why this should be core and not an add-on in the asset library?
As an enhancement to the GridMap node, this belongs to core.
The text was updated successfully, but these errors were encountered: