Distance between 2 objects

Moderators: Sascha Willems, Thomas

Distance between 2 objects

Postby Cyrus » Fri Oct 01, 2010 6:19 am

Hi,
I am using compound collision to represent each object in my world in Newton 2 with Ogre as my rendering engine
I would like to find the nearest distance between 2 objects.
Can some one provide any hiints/pointers?

Thanks in advance.
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Julio Jerez » Fri Oct 01, 2010 7:50 am

you can use the closest distance functions in newton.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Distance between 2 objects

Postby JernejL » Fri Oct 01, 2010 9:22 am

NewtonCollisionPointDistance & NewtonCollisionClosestPoint are suitable for this.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Distance between 2 objects

Postby Cyrus » Mon Oct 04, 2010 5:47 am

Thanks for the replies.

I had 1 more query. If I have compound collision to represent 1 complete object (Ogre Entity), how can I find the distance between 2 objects?

Thanks,
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Julio Jerez » Mon Oct 04, 2010 8:22 am

but was that the same question?

Code: Select all
 int NewtonCollisionClosestPoint (const NewtonWorld* newtonWorld,
                       const NewtonCollision* collisionA, const dFloat* matrixA,
                                                  const NewtonCollision* collisionB, const dFloat* matrixB,
                               dFloat* contactA, dFloat* contactB, dFloat* normalAB, int threadIndex);


calculates colsest distance, it gives you a point is shape a point on shape A and a point o shape B
who is distance is equal or shorter that any other pair points on shape A and B.

if the objects are colliding teh funtion reuturn zero.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Distance between 2 objects

Postby Cyrus » Mon Oct 04, 2010 8:53 am

Sorry for any confusion. Let me clarify my second query -
The documentation for NewtonCollisionClosestPoint mentions that - "Calculate the closest points between two disjoint convex collision primitive". I wanted to know if there is a way to find the distance between 2 compound collision

Thanks again.
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Julio Jerez » Mon Oct 04, 2010 9:39 am

you pass two compounts, compound are made of convex. it works too

bascically it comes down the the point in all sub shapes of collision A that is closer to the a point in all subshapes of collision B.
but is is more sofisticated than that since it use the hierchical organization of the compund shape make that it doe not test shapes tha cod no be any closer..
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Distance between 2 objects

Postby Cyrus » Wed Oct 06, 2010 8:49 am

Whenever we pass two disjoint compound objects, the api (NewtonCollisionClosestPoint) always returns zero!! We are using Newton 2.20
We attached the sample compound objects for which the api fails, we PMed the password for attached rar file.

Can you please check whether you are able to reproduce the problem with the models? Do you think it is a problem with the model?
Thanks.
Attachments
CompoundObjects.rar
Compound collision objects
(36.92 KiB) Downloaded 488 times
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Cyrus » Thu Oct 07, 2010 10:59 am

Please let me know if there is any way to debug this.

Thanks,
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Julio Jerez » Thu Oct 07, 2010 12:01 pm

you sent two OBJ files one look like a vowl and the other like a goble, I need or load them from using thr editor.
I do not have a way to load OBJ files to make the compound, but I will add a plugin to the file format.
But I do not have time with work. I will check this saturday.
This is not a problems it is just that I am tight at work now but I will do it this weekend
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Distance between 2 objects

Postby Cyrus » Tue Oct 12, 2010 9:50 am

Please let me know if you need more info to reproduce this issue. I can provide the Ogre mesh files if that is easier to work with.

Thanks.
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Julio Jerez » Tue Oct 12, 2010 11:28 am

Not It is Ok, I can use the OBJ file.
I am trying to add one fix before I post the SDK
I will replay tonight of Tomorrow with the solution.

It is very eassy to do this using the engine, But before I post a script for doing it I like to see why it is no working, because it certainly most.
Basically the script is a brute force that check every subshape gainst every other subshape.
for yours two mesh sample that will be fine, but for very complex mesh it will not, so I will chekc out what is wrong.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Distance between 2 objects

Postby Cyrus » Fri Oct 15, 2010 11:30 pm

Please let me know if there is any way to debug this. Thanks.
Cyrus
 
Posts: 49
Joined: Mon May 17, 2010 1:04 am

Re: Distance between 2 objects

Postby Julio Jerez » Sun Oct 17, 2010 8:20 am

I finally am a stable point, I will post 2.25 today with the fix. and also a buch of oteh bug fixes too.
Sorry for the delay.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Distance between 2 objects

Postby Julio Jerez » Sun Oct 17, 2010 10:17 pm

Upps, I finally managed to add the ability to load compound to the new file format, and I added the closest distance demo to the SDK, eventhing is nice and dandy,
but to my surprice closest distance on compound shapes does not work.
I build the engine in debug mode to see what it is, and this is the code for closest distance when using compound

Code: Select all
dgInt32 dgWorld::ClosestCompoundPoint (
   dgBody* compoundConvexA,
   dgBody* collisionB,
   dgTriplex& contactA,
   dgTriplex& contactB,
   dgTriplex& normalAB,
   dgInt32 threadIndex) const
{
_ASSERTE (0);
return 0;

/*
*/
}


I added a return at the beginning of the function a while back when I made the compund more efficient,
now I have to uncomment that and use the new algoirithm for the newer closest distance.

The function still uses the naive brute force scan which is ok for compound with small number of bodies
but very slow for compund with tousands of subshapes.
I should have this fix sometine today, but if I can not I will enable teh old brute force mode temporarily until I get the optimized version.
My bad. :oops:
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Solved bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron