wiremod / wire-extras

Community Contributed Wire Extras Repository (formerly UWSVN). These are addons which may be of use to wiremodders but do not undergo the same level of critique that the official repos do.
Apache License 2.0
83 stars 67 forks source link

Fixed: Ray-sphere intersection #122

Closed dvdvideo1234 closed 11 months ago

dvdvideo1234 commented 11 months ago

Fixes #121

dvdvideo1234 commented 11 months ago

Also in the future add "Fixes #PR" to your PRs so it auto-closes and you don't need to ping for us to close an issue. I've edited it for you

Yeah... I've added this Fixes Issue #.. But is dos not link them or display any activity if that ever happens. I must not have rights or something...

Vurv78 commented 11 months ago

Also in the future add "Fixes #PR" to your PRs so it auto-closes and you don't need to ping for us to close an issue. I've edited it for you

Yeah... I've added this Fixes Issue #.. But is dos not link them or display any activity if that ever happens. I must not have rights or something...

Permissions don't matter, it just needs to be a specific string that github scans for. Most common is Fixes #PR but theres also Closes #PR and some others afaik

dvdvideo1234 commented 11 months ago

My only concern for it returning two roots and picking the additive one is that it rather must return the root having positive dot product and is closer to the sphere ( The small magenta position being the ray side root and the black one is the other side root. The ray is drawn with blue ). This equation will work in any dimension as long as dot product and length are defined. When origin is outside of the sphere: image When origin is inside the sphere: image In my 2D complex numbers engine I use this check to swap return values:

  if(cO:isInCircle(cC, nR)) then return xP, xM end
  return xM, xP -- Outside the circle
dvdvideo1234 commented 11 months ago

Do you agree with this resolution to return the correct circle side @thegrb93 ?

thegrb93 commented 11 months ago

I don't know. Feel free to open a new PR though if more changes are needed.