Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / [Dark Dynamix] Raycast requires normalized vector

Author
Message
Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 21st May 2012 12:42 Edited at: 21st May 2012 12:45
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 ...



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:



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.

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 21st May 2012 15:24
Hi Fallout,

Firstly I apologise for inaccurate documentation, I have updated it to reflect that some raycasts return true or false.

I'm not sure if I knew the vectors had to be normalized, my testing of the raycasts went as far as producing the raycast example code which worked fine but obviously did not go far enough. Sorry you had to be the one to have to find this out, the documentation now says it needs to be normalized.

Let me know if you have any more problems and sorry again

Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 21st May 2012 18:06
No probs mate. Just thought I'd let you and others know. Too many commands and too many combinations for you to test them all. I've had far worse "early adopter" experiences, so overall still more than happy.

Login to post a reply

Server time is: 2024-11-24 13:24:17
Your offset time is: 2024-11-24 13:24:17