I don't know if this would be considered a bug or not, but it's definitely something that needs documentation as least. I've spent hours scratching my head trying to figure out why this code didn't work ...
dynRaycastSetMaxDistance(fltDistToLight-1);
dbSetVector3(VECTOR3_1,fltX,fltY,fltZ);
dbSetVector3(VECTOR3_2,fltDistToLightX,fltDistToLightY,fltDistToLightZ);
if (dynRaycastAnyShape(VECTOR3_1,VECTOR3_2,NX_STATIC_SHAPES,-1)){
}
I was casting a ray from a position in space to a light source to determine if the light was blocked or not. Collision was always false even though I knew the ray was casting through my geometry. Eventually I started hardcoding in values and collision remained false.
Eventually I set my VECTOR3_2 (direction vector) to 0,-1,0 to make sure it hit the ground. Suddenly it worked. I then added a tiny x component: 0.01,-1,0, and it stopped hitting anything. I also tried -0.5,-0.5,0 to make sure the vector was less than 1, and it still didn't work. Eventually I added some normalization thus:
dynRaycastSetMaxDistance(fltDistToLight-1);
dbSetVector3(VECTOR3_1,fltX,fltY,fltZ);
dbSetVector3(VECTOR3_2,fltDistToLightX,fltDistToLightY,fltDistToLightZ);
dbNormalizeVector3(VECTOR3_2,VECTOR3_2);
if (dynRaycastAnyShape(VECTOR3_1,VECTOR3_2,NX_STATIC_SHAPES,-1)){
}
Now it works perfectly. Not sure why you can't use a vector that hasn't been normalized, but we either need a doc change or code change.
Also there are quite a few documentation entries which have:
bool dynRaycastAnyShape (int origVec3ID, int dirVec3ID, int flag, int groups)
Returns:
Number of hits
Which is also confusing. Obviously the code returns a bool, but I'm not sure if this bool means "hit/miss" or means "success/error", since the documentation is incorrect.