Node Tools: Add mouse position node, wait for cursor option #121043
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#121043
Loading…
Reference in New Issue
No description provided.
Delete Branch "HooglyBoogly/blender:node-tools-mouse-position"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a "Mouse Position" node that outputs the location of the mouse
cursor in region space and the overall size of the region, both in pixel
units. Both outputs are integers to help reflect their pixel units.
If there the mouse position is ever accessible in sub-pixels, they can
easily be changed to floats.
Also add a "Wait for Cursor" option similar to the one for some built-in
operators that delay's the operator's execution until there is a mouse
click in the viewport. That way the operator can be called from menus
even though it is interactive. This option is placed in the node editor
header. When there are more options, it will be part of an "Options"
popover panel similar to the existing "Modes" and "types" popovers.
Combined with the viewport transform node, and other nodes like Raycast,
these features can allow making tools that create geometry where you
click in the scene.
The blend file requires the viewport transform node too.
Node Tools: Add mouse potiion node, wait for cursor optionto Node Tools: Add mouse position node, wait for cursor optionI realize better now how the scope of these additions to user-made tools (camera matrix, etc) is deeper than I thought. In this light, would you not expect to keep count of clicks explicitly? I understand these modal tools are meant to leverage the simulation zone? should the simulation zone provide a "click count" output socket when in "tool" mode? I suppose for this special case you could stall the simulation until the click count reaches 1. But I suppose this would call for a general way to expose listened keys
There is nothing modal going on yet. That's a separate project that we probably won't work on for a few months. So you only get the one click and mouse position here. I do expect this to be the basis for a lot of the modal interaction like you mention though. For that, the node group would execute in the simulation zone whenever there is an event. The event might be a mouse move or a click, and you could do whatever you want with it.
@ -171,6 +171,7 @@ class NODE_HT_header(Header):
if snode.node_tree:
layout.popover(panel="NODE_PT_geometry_node_tool_object_types", text="Types")
layout.popover(panel="NODE_PT_geometry_node_tool_mode", text="Modes")
layout.prop(snode.node_tree, "use_wait_for_cursor")
I think when we talked about this last time, we said that this option should be displayed this prominently. It's kind of unusual to have such a checkbox in a header.
Related meeting notes: https://devtalk.blender.org/t/2024-03-19-nodes-physics-module-meeting/33867
Also note that we mentioned it should be called e.g. "Wait for Click" instead of "Wait for Cursor".
I mentioned this in the description:
I could just move it to an options popover already?
I started with that here, but then I thought "Click" sounded wrong for pen or touch input. Not sure.. I'll ask in the UI module to see if others have ideas.
Actually I just renamed it to "Wait for Click". It can always be renamed in the future, and it seems more consistent with existing terminology than I thought.
@ -471,2 +472,4 @@
operator_eval_data.self_object_orig = object;
operator_eval_data.scene_orig = scene;
RNA_int_get_array(op->ptr, "mouse_position", operator_eval_data.mouse_position);
operator_eval_data.region_size = int2(region->sizex, region->sizey);
Would be good to check if this still works if the operator is run without ui (as part of a script). Obviously, we can't get a meaningful mouse position and region size in this case, but the operator should still work I think (especially if those inputs are not used in the node group).
I don't see why this wouldn't work-- it would just get the default RNA property value which would be 0,0
I'm more talking about
region->sizex
, not sure ifregion
can be null.Oh indeed, thanks! I think that's possible in scripts. I'll add a null check and output 0 in that case too.
@ -0,0 +8,4 @@
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Int>("Mouse X");
All these sockets need descriptions.
For Y it's especially important because it's not obvious if 0 is at the top or bottom.
I wouldn't say it's unrelated. For most uses (everything I've thought of anyway) you have to use both the region size and the mouse position. Exposing the two properties is still the most intuitive way to expose the data IMO. It could be separate but I don't really see any benefit
I'll change the name of the output sockets to
Region Size X/Y
.How about
Region Width
andRegion Height
?Oh, good idea!
@ -0,0 +12,4 @@
"The region-space mouse X location, in pixels, increasing from 0 at the left");
b.add_output<decl::Int>("Mouse Y").description(
"The region-space mouse Y location, in pixels, increasing from 0 at the bottom");
b.add_output<decl::Int>("Region Width").description("The total X size of the region in pixels");
Not sure if it's better, but maybe the descriptions should use "width" and "height" too.
It does sound a bit better that way, but I think it feels a little better to follow the typical advice of "don't repeat the name in the description"