Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes two issues:
pickable: false
) when using snap picking on DTX scene models.To reproduce, go on a snap to vertex example, get one model entity and set its
pickable
property tofalse
.-> The snap cursor is stuck somewhere around the origin of the model.
On this image, my mouse is hovering the model and the pink top element of the table is unpickable. The green circle is positioned on the
snappedCanvasPos
that is stuck:This issue was only present on VBO and only on snap to vertex picking.
It was not present in DTX because of the previous issue AND vertex are culled using
gl_Position = vec4(3, 3, 3, 1);
)What may happen:
Unpickable vertex are culled using
gl_Position = vec4(0);
here (idem for instancing and lines)Because of how the snap picking works, it may not be a good idea to cull a vertex this way.
I saw this formula here:
Vertex with a
vec4(0)
position ends into the NDC rectangle[-1, -1, -1]
to[1, 1, 1]
as its position is[0, 0, 0]
and becauseposition.w
is0
, it is not clipped/discarded as0 <= 0 <= 0
for eachx, y, z
components.Vertex snap picking uses point primitive. I assume "culling" a triangle with the same
vec4(0)
position for the three corner vertices may work because the triangle is too small to be rendered... but a point with pointSize of 1 may still be rendered.Because of that, unpickable objects vertices are always rendered as point of size 1 at the center of the snapping viewport.
Then, due to this line, the returned
snappedCanvasPos
seems to be always the origin of the model. Indeed,[0, 0, 0]
relative to origin is the origin... ?I hope it makes sense. Even if what I described here is not 100% correct, moving the vertices at
vec4(2, 0, 0, 0)
seems to fix the issue. I think any value other that0
may work du to the previous formula.