How to cast rays through an object

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

How to cast rays through an object

Post by yanbo2u » Sat Feb 29, 2020 5:43 am

i need to shoot a ray from a point to the ground( a box ). but sometimes there could be some unexpected objects getting in the way of the ray. I need to let the ray cast as if the unexpected objects never exist.

is it possible? please advise.

yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

Re: How to cast rays through an object

Post by yanbo2u » Sat Feb 29, 2020 1:19 pm

Found a solution from a earlier post.


viewtopic.php?f=4&t=2319

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

Re: How to cast rays through an object

Post by Norbo » Sat Feb 29, 2020 8:02 pm

That post is about getting the entity hit by a ray cast in v1, but it doesn't cover filtering considered bodies, which sounds like what you actually want.

In v1, Space.RayCast takes a delegate that can be used to filter out unwanted candidates.

In v2, the IRayHitHandler you pass to the Simulation.RayCast function has AllowTest callbacks you can use to reject objects before testing.

yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

Re: How to cast rays through an object

Post by yanbo2u » Sun Mar 01, 2020 2:01 am

Norbo wrote:
Sat Feb 29, 2020 8:02 pm
That post is about getting the entity hit by a ray cast in v1, but it doesn't cover filtering considered bodies, which sounds like what you actually want.

In v1, Space.RayCast takes a delegate that can be used to filter out unwanted candidates.

In v2, the IRayHitHandler you pass to the Simulation.RayCast function has AllowTest callbacks you can use to reject objects before testing.
Thanks. It works.

Post Reply