Ray/Sphere cast using visual transform.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Ray/Sphere cast using visual transform.

Postby Crashy » Tue Jan 31, 2023 10:25 am

Hi,

I would like to know if there is an out-of-the-box solution to perform a raycast and/or sphere cast on my scene using the interpolated visual transform instead of the ones from the current physic step.

I have fast moving objects and my game also has time compression so It's not unusual to have a strong mismatch between the physic object and the rendered object.

The goal is to implement proper picking and camera collision detection.
I know I could do it by hand myself, going through all my rigid bodies and testing against their collision, but I'm not sure it'll be super optimal.

I'm working with Newton 3.0, not the latest one but I could merge code if necessary

Thanks.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Ray/Sphere cast using visual transform.

Postby Julio Jerez » Tue Jan 31, 2023 2:00 pm

those function exist in 3.14 but because of the C interfase, they are not exposed.

If you are willing to migrate to 4.xx, teh funtion are in filr

...\newton-dynamics\newton-4.00\sdk\dCore\ndIntersections.h

ndFloat32 ndRayCastSphere (const ndVector& p0, const ndVector& p1, const ndVector& origin, ndFloat32 radius);
bool ndRayCastSphere(const ndMatrix& origin, ndFloat32 radius, const ndVector& p0, const ndVector& p1, ndFloat32& t0, ndFloat32& t1);

there is also the ndContactSolver which is what I think you are looking for.

4.xx exposes everything as a CPP, you will save yourself lot of aggravation if you spend the time migrating to it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Ray/Sphere cast using visual transform.

Postby Crashy » Wed Feb 01, 2023 3:53 pm

Thanks, I'll have a look.

I'm afraid I can't migrate right now, I'm too close to the end of the project, maybe If I can find some free time :)
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Ray/Sphere cast using visual transform.

Postby Julio Jerez » Wed Feb 01, 2023 4:21 pm

You can just copy the file and modify it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 11 guests

cron