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 »

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: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post 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.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post by parapoohda »

Thanks.You are very helpful.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post by Norbo »

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 »

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: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post 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.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: Question about

Post by parapoohda »

So I can use T(t) to find it farther or nearer isn't it.
Thank you.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Question about

Post by Norbo »

Yup!
Post Reply