Page 1 of 1

Question about

Posted: Thu Feb 06, 2020 6:59 am
by parapoohda
I try to use bepu for physic and skill.
Now I try to make skill exclude behind wall.
So I try to understand ray.

Is this part that add ray?

Code: Select all

testRays = new QuickList<TestRay>(maxRayCount, BufferPool);
            var timeSampleCount = 16;
            algorithms = new IntersectionAlgorithm[2];
            algorithms[0] = new IntersectionAlgorithm("Unbatched", UnbatchedWorker, BufferPool, maxRayCount, timeSampleCount);
            algorithms[1] = new IntersectionAlgorithm("Batched", BatchedWorker, BufferPool, maxRayCount, timeSampleCount);
            
Is algorithms is code that add ray? and testRays just collection that keep data

Re: Question about

Posted: Thu Feb 06, 2020 5:59 pm
by Norbo
That snippet, and the "IntersectionAlgorithm" parts, are just the demo's way of organizing a bunch of ray casts using one of the two modes (batched, versus not batched).

You don't need to pay attention to the demo infrastructure- it boils down to one line:

Code: Select all

Simulation.RayCast(ray.Origin, ray.Direction, ray.MaximumT, ref hitHandler, i);
The hitHandler is an IRayHitHandler struct implementation that can filter the objects considered for testing by the ray, and reports all impacts.

Re: Question about

Posted: Fri Feb 07, 2020 2:37 am
by parapoohda
Thanks.You are very helpful.

Re: Question about

Posted: Fri Feb 07, 2020 4:00 am
by parapoohda
Update it seem I disable it my self.
But another question it walk able even no ground

Um don't know why I add raycast to scene, static object not show.
And raycast hithandler doesn't hit static
Is this normal?

Re: Question about

Posted: Fri Feb 07, 2020 4:09 pm
by Norbo
But another question it walk able even no ground
Sorry, not sure what the context is here.

Re: Question about

Posted: Wed Feb 12, 2020 4:14 am
by parapoohda
I have another question.
I try to make character not attack character behind wall
So i keep list of character in hithandler.
but accord to Console.Writeline it order by mobility first

How can I get hit point?
Or make it order by what is near origin before order by mobility?

Thank you

Re: Question about

Posted: Wed Feb 12, 2020 5:51 pm
by Norbo
It doesn't actually order by mobility- results are reported as they are encountered during the ray traversal. The reason it appears to order by mobility is that the 'active' tree is tested first, followed by the 'static/sleeping' tree.

The RayCast does not, by itself, do any filtering or ordering. It's all programmable through the hit handler. So, to find the first impact, you can cache the closest so-far-observed impact as you traverse, modifying the maximumT value to let the traversal early-out of other parts of the tree. You can see an example in the demos Grabber: https://github.com/bepu/bepuphysics2/bl ... ber.cs#L24

The hit point is just the ray origin + ray direction * T.

Re: Question about

Posted: Thu Feb 13, 2020 1:52 am
by parapoohda
So I can use T(t) to find it farther or nearer isn't it.
Thank you.

Re: Question about

Posted: Thu Feb 13, 2020 7:52 pm
by Norbo
Yup!