Giter VIP home page Giter VIP logo

Comments (6)

sro5h avatar sro5h commented on May 4, 2024

Ok, sorry didnt see your comment under the other issue, I will test it again.

from cute_headers.

RandyGaul avatar RandyGaul commented on May 4, 2024

That's OK! Feel free to make as many of these issues as you would like. They are helpful.

Usually raycasts are not well-defined if the ray starts out inside of a shape. Rays are usually meant to try and find a time of impact, and are written to run very efficiently.

Games that use c2RaytoAABB generally make a lot of calls to c2RaytoAABB, so it is attempting do its work very quickly. Adding in additional code to place the time as 0 wouldn't really be very helpful in these cases.

My suggestion is before casting a ray, make sure there are no boxes on the ray's starting position. This can be done with a point to AABB collision check. If no boxes are in the way, then run the raycast function.

I'm ganna close this issue out, but feel free to comment here if you have other questions or comments about ray to AABB checks.

Since you have the source code feel free to adjust the function yourself if you like. Take line 1062, and add in a check to see if out->t is negative. If it is, set it to 0.

Cheers :)

from cute_headers.

sro5h avatar sro5h commented on May 4, 2024

Ok sure, but I kind of get the feeling it's more me using the library in a wrong way then actual bugs

Didn't know casting from inside a Shape wasn't well defined. Intuitively I thought it should give me the Point on the Edge that actually intersects with the ray.

But I guess to do that there would be quite some additional effort that can be avoided this way :)

from cute_headers.

RandyGaul avatar RandyGaul commented on May 4, 2024

You're right, it would be pretty intuitive to hit an edge when cast from the inside. And like you pointed out, lots of effort can be saved if we ignore such cases.

That's OK if these aren't actual bugs. The issues on github is also very useful for questions/suggestions/comments. Other people that come along and try out tinyc2 will have the same questions! They can search around the issues and find answers in these threads.

from cute_headers.

sro5h avatar sro5h commented on May 4, 2024

I just noticed that c2RaytoCircle returns false if the ray starts in the circle because there you test for t <= 0 (if ( t >= 0 && t <= A.t )). Wouldn't it be better if it was the same for c2AABB (and possibly the other shapes)?

from cute_headers.

RandyGaul avatar RandyGaul commented on May 4, 2024

It's not quite that easy, since a negative time could also mean the ray started outside the circle but was pointing away from the sphere.

But that is a good point on consistency. Rays starting inside of shapes are currently not well defined in tinyc2, but maybe there's a good way to make them at least choose something consistent.

I'll think about that, but for now the best thing I can say is to treat rays starting inside of shapes as not well defined.

from cute_headers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.