I've been using Newton for the past couple of months and really liking it so far,
but I ran into an issue while trying to implement an AI.
The problem is that I need the AI to try to stop a ball when it is moving towards it's goal.
After trying to find a solution I found out that I can get the object the ball is going to hit with ray casting.
The problem is that I cannot get the ray cast to give me a proper position of the contact.
I tried looking for a way to get the position of ray intersection in the callback, but
using code to get it from const dFloat* const hitContact seems to return always the same position for all rays
hitting a specific object.
Is this a correct way of doing this?
Code:
- Code: Select all
RayCastData* data = reinterpret_cast<RayCastData*>(userData);
data->HitEntities.push_back(new RayCastHitEntity(body, Float3(*hitContact, *(hitContact+sizeof(dFloat)), *(hitContact+sizeof(dFloat)*2))));
// Check for end //
if(data->HitEntities.size() >= (size_t)data->MaxCount)
return 0.f;
// Continue //
return 1.f;
which seems to return sane looking points, but they are always the same when hitting the same object.
If this is not what the parameter is for, it'd be great to have a parameter in the callback specifying the position of intersection.
Would be great if somebody could enlighten me on this issue, thanks.