VEX Intersect returns 0

   3238   5   1
User Avatar
Member
5 posts
Joined: March 2020
Offline
Hi.

TLR

I am casting rays to spheres which return the number of the primcentroid they have been copied to. Works as expected, except for cases where the ray hits nothing. I am expecting a return of -1, instead I get a 0. However, this behaviour is also consistent.

Anyone else experienced this?

———

I am casting rays from every point in the direction of the yellow and red vectors. If i cast the rays from lets say point 28, my intersect returns 27 and 29 as result. This is correct. When I cast the rays from point 29, I get as a result 28 and 0. Likewise if I cast from 30, i get as a result 31 and 0. As these are both corner points, I expect a -1 insted of 0. I can change my point sort beforehand, and the numbers shift, but the result in case my ray hits nothing still returns as 0 with the other results being correct.

I have attached a screenshot of the scenario as well as my console output to clarify, unfortunately i can not attach a hip (because you know how it is…)

Has anyone else experienced this, is this a bug?

Confused.
Edited by Urban_Timetraveler - Sept. 1, 2020 12:01:44

Attachments:
ISEC_ReturnWeirdness01.JPG (65.9 KB)
ISEC_ReturnWeirdness02.JPG (47.0 KB)

User Avatar
Member
9377 posts
Joined: July 2007
Offline
it should indeed return -1 for no hit, but since I've used intersect() function so many times and with expected results, I'd assume there is something in your code causing the 0 rather than a bug
Edited by tamte - Sept. 1, 2020 12:22:20
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
5 posts
Joined: March 2020
Offline
Hi tamte,

thank you. I thought so too, because it is the first time i encountered that problem. Guess I will be combing through my code then and see whats wrong.

Still confused
User Avatar
Member
5100 posts
Joined: Feb. 2012
Offline
Hi,

Can you show your intersect code? Otherwise it's a bit hard to see what the issue might originate from. I never experienced this issue myself.

You can also make a simple scene if you can't attach the original.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
tbh, I don't know that much but I did a quick test for the hell of it.
results seem consistent to me.

- ray dir is X positive
- so I offset the origin a bit to the right so that the right most column there is nothing to the right of the rays…ie. returns -1 correctly everytime.

I suspect that you got -1 but then your logic of deriving the “point numbers” might be screwed up.

dunno, as said I don't know much, 1st time using this function.
Edited by vusta - Sept. 2, 2020 04:59:31

Attachments:
test.jpg (241.2 KB)
vu_intersect_test.hiplc (87.2 KB)

User Avatar
Member
5 posts
Joined: March 2020
Offline
Yeah, it was a user error Thank you

to clarify: my intersect code worked as expected, but vusta, you pointed me in the right direction. I simply ignored the fact that if i hit nothing, there is no prim i can get the number from. So because there was nothing to get, my code returned 0. It was just a matter of adding a simple if statement to solve it.

Sometimes you look stupidly at your code and dont even see the simplest things.

No more confusion
Edited by Urban_Timetraveler - Sept. 2, 2020 07:57:11

Attachments:
ISEC_noMoreReturnWeirdness.JPG (45.8 KB)

  • Quick Links