A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by pHySiQuE » Fri Dec 20, 2013 9:15 pm
It appears that NewtonWorldConvexCast presently does not produce any collisions with compound collisions. This is a big problem because I have a lot of physics shapes for furniture, vehicles, etc. that are made up of compound convex hull shapes.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by pHySiQuE » Fri Dec 20, 2013 10:05 pm
I updated Newton to the current build, and the problem still occurs.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Fri Dec 20, 2013 10:16 pm
yes is does.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sat Dec 21, 2013 12:47 pm
Can you elaborate on that?
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sat Dec 21, 2013 1:36 pm
the is a demo convex cast that cast over a large compound, try that out
..\newton-dynamics\applications\demosSandbox\sdkDemos\demos\ConvexCast.cpp
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sat Dec 21, 2013 2:32 pm
Are you saying that this is supposed to work and there is an error on my part?
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sat Dec 21, 2013 2:40 pm
yes, I just run the demo to make sure is not broken, and I see it working
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sat Dec 21, 2013 3:23 pm
Okay, the reason it was getting skipped is because the contact point data is wrong:
http://www.leadwerks.com/post/compound.aviThe truck and stair case both use a compound collision made up of convex hulls.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sat Dec 21, 2013 3:34 pm
what do you mean the contact point data in return by newton is wrong?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sat Dec 21, 2013 3:43 pm
It appears to be storing contact points in the NewtonWorldConvexCastInfo array that are about 0.5 higher than they should be. You can see in my example the player starts moving up and down when he steps on a compound collision.
0.5 happens to be the length of the convex cast I am performing.
If I increase the length of the raycast (use a higher starting y position), the offset gets longer to match the length I set.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sat Dec 21, 2013 4:56 pm
the interpreation fo eth ray cast is the same of the raycast
to get the hit point alone the ray you do this
- Code: Select all
dFloat hitParam;
NewtonWorldConvexCastReturnInfo info[16];
NewtonCollision* const shape = m_stupidLevel->GetCurrentShape();
int count = NewtonWorldConvexCast (world, &matrix[0][0], &p1[0], shape, &hitParam, NULL, NULL, &info[0], 4, 0);
if (count) {
matrix.m_posit += (p1 - matrix.m_posit).Scale (hitParam);
m_stupidLevel->SetCastEntityMatrix (scene, matrix);
}
the point you are getting are the point on the casting shape
to get the contact on the casted shape you do this
- Code: Select all
vector step ((p1 - matrix.m_posit).Scale (hitParam));
for (I =- 0 I < count; I ++)
conctat[I] += step
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sat Dec 21, 2013 4:59 pm
I need the position the collision occurs at to do my calculations. For all other types of collision shapes, the contactdata "m_point" member indicates the position the collision occurred at, in global space. Why would compounds act differently?
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sat Dec 21, 2013 7:53 pm
I told you already how to the collision point,
vector step ((p1 - matrix.m_posit).Scale (hitParam));
for (I =- 0 I < count; I ++)
conctat[I] += step
this is how it is and has always being for all collision shapes.
if you play the demo I mentioned you will see that the convex cast is performed on representation of all shapes: compound, simple, scene, and even user mesh
I will change demo to show the collision points.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sun Dec 22, 2013 4:08 pm
Okay, I used this code and it appears to work correctly:
- Code: Select all
Vec3 positionatcollisiontime = (Vec3(p1.x,p1.y,p1.z) - Vec3(p0.x,p0.y,p0.z)) * hitParam[n];
contactdata[n].m_point[0] += positionatcollisiontime.x;
contactdata[n].m_point[1] += positionatcollisiontime.y;
contactdata[n].m_point[2] += positionatcollisiontime.z;
It is strange that my code worked perfectly before on other types of objects. I guess the compounds are different because the colliding object may enter their AABB without colliding immediately, since they tend to have a lot of concave shapes.
Thank you for your help.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sun Dec 22, 2013 4:18 pm
but that is how it has always being fro all shapes since the convex cast was implemented.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- 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 2 guests