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

CollisionObject3D::input_event reports incorrect normals when input_capture_on_drag is enabled #67998

Closed
noidexe opened this issue Oct 29, 2022 · 2 comments · Fixed by #68007
Closed

Comments

@noidexe
Copy link
Contributor

noidexe commented Oct 29, 2022

Godot version

v4.0.beta3.official [01ae26d]

System information

Manjaro Linux (6.0.2-2-MANJARO x86_64) Vulkan, GTX 2060 SUPER with proprietary drivers

Issue description

If a CollisionObject3D has input_capture_on_drag set to true the emitted input_event signals only report correct position and normal on mouse button click.
On mouse button release or mouse motion both position and normal are always reported as (0,0,0), even if the mouse pointer is on top of the collider.

I'm not familiar with the code but I assume the problem is here:

_collision_object_3d_input_event(co, camera_3d, ev, Vector3(), Vector3(), 0);

The Vector3(), Vector3() should be the correct values only when dragging or releasing outside the collider but no ray is being cast.

Some additional issues:

  • If capture is enabled, mouse_exited is not emitted when the mouse leaves the collider, only when the mouse button is released. If this is expected I'll open a godot documentation issue
  • The auto generated callback for input_event uses position as a parameter name which will always collide with Node3D.position

Steps to reproduce

  • Run the MRP
  • Click, drag and release inside the sphere on the right
    Expected: The text at the bottom should show valid position and normal
    Actual: (0,0,0) is reported when it shouldn't

Minimal reproduction project

image

CaptureOnDragNormalMRP.zip

@Sauermann
Copy link
Contributor

Sauermann commented Oct 29, 2022

I'm not familiar with the code but I assume the problem is here

Thanks for identifying the correct location in the source code.

If capture is enabled, mouse_exited is not emitted when the mouse leaves the collider, only when the mouse button is released. If this is expected I'll open a godot documentation issue

This sounds like the same problem as we currently have for 2D: #20881, which might get solved by #67791
I believe, that it is reasonable to keep the behavior consistent in 2D and 3D.

The auto generated callback for input_event uses position as a parameter name which will always collide with Node3D.position

I am not familiar with how to solve this.

@noidexe
Copy link
Contributor Author

noidexe commented Nov 2, 2022

The auto generated callback for input_event uses position as a parameter name which will always collide with Node3D.position

I am not familiar with how to solve this.
I think you need to change it here:

ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "position"), PropertyInfo(Variant::VECTOR3, "normal"), PropertyInfo(Variant::INT, "shape_idx")));

Instead of position which is guaranteed to collide it can be something like hit_position (and maybe hit_normal for consistency).
It's a really minor annoyance since it's just the default parameter name in the editor-generated callback so the user can just go and change it to something different or leave it as is if he doesn't intend to read/write to Node3D::position. It might confuse newbie users though.

I'll open a proposal since it's not really a bug.

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

Successfully merging a pull request may close this issue.

3 participants