A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Auradrummer » Fri Feb 05, 2010 11:55 am
Hello guys,
Raycasting is working right here, but I cannot find an way to detect if raycast is not intersecting the track anymore. My callback filter is this:
- Code: Select all
float callBackFilter (const NewtonBody * body, const dFloat * normal, int collisionID, void* userData, dFloat interset)
{
rayDir = (int)userData;
ship.colID = collisionID;
if (collisionID != 258) // the car is the collision # 258. This avoids that raycast hits the car and reacts
{
if (rayDir == 0)
{
ship.lfHeight = interset;
};
if (rayDir == 1)
{
ship.rfHeight = interset;
};
if (rayDir == 2)
{
ship.lrHeight = interset;
};
if (rayDir == 3)
{
ship.rrHeight = interset;
};
}
else
{
ship.lfHeight = 0;
ship.rfHeight = 0;
ship.lrHeight = 0;
ship.rrHeight = 0;
};
};
Last edited by
Auradrummer on Fri Feb 05, 2010 12:18 pm, edited 1 time in total.
Developing a racing game.
-
Auradrummer
-
- Posts: 132
- Joined: Sat May 17, 2008 9:17 am
by Auradrummer » Fri Feb 05, 2010 12:18 pm
Problem solved, here goes the solution:
At WIKI we have this phrase, that I passed over:
NewtonWorldRayFilterCallback filter - user defined function to be called for each body hit during the ray scan.
This means that not matters what is inside raycast filter, it will be called only when we have a hit.
So, I made an 'interset = 0' before raycasting. If callback is called (we had a hit), interset receives an value, otherwise, interset is always 0. Easy and fast!
Developing a racing game.
-
Auradrummer
-
- Posts: 132
- Joined: Sat May 17, 2008 9:17 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 381 guests