Skip to content

Bugfix/pbld 226 hidden face selection fix #615

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

varinotmUnity
Copy link

@varinotmUnity varinotmUnity commented Jul 15, 2025

Purpose of this PR

This PR resolves a bug where single-click face picking on ProBuilder meshes failed if they were obscured by another GameObject, even when "Select Hidden" was enabled. The previous FaceRaycast implementation's internal next variable and looping logic caused it to often only consider the very first GameObject returned by the scene picker for a standard single click. This was problematic because if that initial GameObject was not a ProBuilder mesh, the ProBuilder picking routine would prematurely exit, preventing selection of the obscured ProBuilder face. The corrected approach now first collects all intersecting ProBuilder meshes and their hit faces under the mouse cursor. These ProBuilder hits are then internally sorted by distance, and the deep-click cycling logic is correctly applied exclusively to this filtered list of ProBuilder elements, ensuring reliable selection and improved interaction with obscured geometry.

Links

Jira:

Comments to Reviewers

Added unit tests

@varinotmUnity varinotmUnity self-assigned this Jul 15, 2025
@unity-cla-assistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov-github-com
Copy link

codecov-github-com bot commented Jul 15, 2025

Codecov Report

Attention: Patch coverage is 96.72131% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Editor/EditorCore/EditorSceneViewPicker.cs 96.72% 2 Missing ⚠️
@@            Coverage Diff             @@
##           master     #615      +/-   ##
==========================================
+ Coverage   32.61%   33.05%   +0.43%     
==========================================
  Files         277      277              
  Lines       34707    34736      +29     
==========================================
+ Hits        11321    11483     +162     
+ Misses      23386    23253     -133     
Flag Coverage Δ
mac_trunk 32.86% <96.72%> (+0.43%) ⬆️
win_trunk 32.79% <96.72%> (+0.43%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Editor/EditorCore/EditorSceneViewPicker.cs 25.62% <96.72%> (+25.62%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@TimAidleyAtUnity TimAidleyAtUnity left a comment

Choose a reason for hiding this comment

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

I really like this PR. Very clear, and the comments are useful.

I made a couple of minor points about switching some code to asserts, and I suspect we should clear s_pbHits after use, but other than that, great job!

if (next != 0)
break;
// Update the newHash for the element actually picked after cycling/filtering
int newHash = selectedHit.hash;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: Couldn't you just combine this line with line 516?

{
Vector3 centerLocal = Vector3.zero;
if (face.indexesInternal == null || face.indexesInternal.Length == 0)
return Vector3.zero; // Should not happen for valid ProBuilder faces
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this should never happen, is it worth making it into an assert instead?

Copy link
Author

Choose a reason for hiding this comment

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

I will use Assume instead, as this is not what we want to test

else
{
Debug.LogError($"Invalid vertex index {index} found in face indexes.");
return Vector3.zero; // Or handle error appropriately
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here - make it in to an assert?

}
else
{
return Mathf.Infinity; // Nothing at all hit
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should probably clear s_PbHits at this point, shouldn't we? Otherwise references to meshes and faces may hang around longer that we want them to.

@varinotmUnity varinotmUnity added the bug Something isn't working label Jul 17, 2025
Copy link
Collaborator

@zatzuri-unity zatzuri-unity left a comment

Choose a reason for hiding this comment

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

  • Tested repro steps
  • Tested on multiple PB objects/faces with hidden and non hidden faces
  • Tested with different angles
    Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants