Question about

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Question about

Post by parapoohda » Thu Feb 06, 2020 6:59 am

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

Norbo
Site Admin
Posts: 4852
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post by Norbo » Thu Feb 06, 2020 5:59 pm

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.

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post by parapoohda » Fri Feb 07, 2020 2:37 am

Thanks.You are very helpful.

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post by parapoohda » Fri Feb 07, 2020 4:00 am

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?

Norbo
Site Admin
Posts: 4852
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post by Norbo » Fri Feb 07, 2020 4:09 pm

But another question it walk able even no ground
Sorry, not sure what the context is here.

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post by parapoohda » Wed Feb 12, 2020 4:14 am

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

Norbo
Site Admin
Posts: 4852
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post by Norbo » Wed Feb 12, 2020 5:51 pm

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.

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post by parapoohda » Thu Feb 13, 2020 1:52 am

So I can use T(t) to find it farther or nearer isn't it.
Thank you.

Norbo
Site Admin
Posts: 4852
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post by Norbo » Thu Feb 13, 2020 7:52 pm

Yup!

Post Reply