<div dir="ltr"><div>Hi,</div><div>I am having a lot of problems with picking with LineSegmentIntersector in OSG 3.6.5.</div><div><br></div><div> </div><div>I have reduced the problem to a a simple cube, center 0.5,0.5,0.5 with a boundingSphere radius of 1.2142</div><div><br></div><div>I create the intersection with ( x , y are screen coordinates)</div><div><br></div><div style="background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" class="prettyprint"><code class="prettyprint"><div class="subprettyprint"><span style="color: #000;" class="styled-by-prettify">picker</span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #008;" class="styled-by-prettify">new</span><span style="color: #000;" class="styled-by-prettify"> osgUtil</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #606;" class="styled-by-prettify">LineSegmentIntersector</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> osgUtil</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #606;" class="styled-by-prettify">Intersector</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #000;" class="styled-by-prettify">WINDOW</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> x</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> y </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>osgUtil</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #606;" class="styled-by-prettify">IntersectionVisitor</span><span style="color: #000;" class="styled-by-prettify"> iv </span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> picker </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>getCamera</span><span style="color: #660;" class="styled-by-prettify">()-></span><span style="color: #000;" class="styled-by-prettify">accept </span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> iv </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br><br></span></div></code></div><div><br><br></div><div>When I am "close" to the model geometry in an isometric view ( the cube fills,say, 50% of the screen), this works perfectly. I get the exact intersections coordinates I expect.</div><div><br></div><div>When I "pull the camera back" from the geometry and the object is much smaller on the screen, the intersections fail.</div><div><br></div><div>After much debugging, the problem is that the intersector fails the test of the intersection of the line with the bounding sphere of my model geometry</div><div><br></div><div>Specifically I send up in</div><div><br></div><div> <div style="background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" class="prettyprint"><code class="prettyprint"><div class="subprettyprint"><span style="color: #008;" class="styled-by-prettify">bool</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #606;" class="styled-by-prettify">LineSegmentIntersector</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #000;" class="styled-by-prettify">intersects</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #008;" class="styled-by-prettify">const</span><span style="color: #000;" class="styled-by-prettify"> osg</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #606;" class="styled-by-prettify">BoundingSphere</span><span style="color: #660;" class="styled-by-prettify">&</span><span style="color: #000;" class="styled-by-prettify"> bs</span><span style="color: #660;" class="styled-by-prettify">)</span></div></code></div><br></div><div><br></div><div>The BoundingSphere is in "model space" , and correct, but the _start and _end points used in the calculation are incorrect to intersect the sphere in model space and so the intersection fails.<br></div><div><br></div><div><div style="background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" class="prettyprint"><code class="prettyprint"><div class="subprettyprint"><span style="color: #000;" class="styled-by-prettify">_start </span><span style="color: #660;" class="styled-by-prettify">{</span><span style="color: #000;" class="styled-by-prettify">_v</span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #066;" class="styled-by-prettify">0x000001ba7308d300</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">{</span><span style="color: #066;" class="styled-by-prettify">13.227287349450325</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">-</span><span style="color: #066;" class="styled-by-prettify">2.9785854231569449</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">-</span><span style="color: #066;" class="styled-by-prettify">5.5167534692525066</span><span style="color: #660;" class="styled-by-prettify">}</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">}</span><span style="color: #000;" class="styled-by-prettify"><br>_end </span><span style="color: #660;" class="styled-by-prettify">{</span><span style="color: #000;" class="styled-by-prettify">_v</span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #066;" class="styled-by-prettify">0x000001ba7308d318</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">{</span><span style="color: #066;" class="styled-by-prettify">11.072576448741074</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">-</span><span style="color: #066;" class="styled-by-prettify">5.1332963238661939</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">-</span><span style="color: #066;" class="styled-by-prettify">7.6714332827528793</span><span style="color: #660;" class="styled-by-prettify">}</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">}</span></div></code></div><br>Any ideas what is going on. It seems although the vector of start and end is the correct vector ( or the "closer" picking would not work), something is wrong in the transformation into model space.</div><div><br></div><div>Thx</div><div>Andrew<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:osg-users+unsubscribe@googlegroups.com">osg-users+unsubscribe@googlegroups.com</a>.<br />
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/osg-users/4fa21208-3ee7-45d7-a9cf-42a4b8a45d52%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/osg-users/4fa21208-3ee7-45d7-a9cf-42a4b8a45d52%40googlegroups.com</a>.<br />