Raycasting problems

raycasting

#1

Hello,
I’ve been plugging away at this game I’m making and I’ve run into a snag that I can’t seem to figure out.
I start out with a complex geometry, maybe a couple hundred faces. To raycaste successfully against the geometry I perform .computeFaceNormals() and everything works out fine.
To speed things up I’ve decided to determine which specific faces need raycasting against and then create a temporary mesh that holds the details about those few faces. Before raycasting against it I also perform .computeFaceNormals(). However; in this instance time and time again, the ray will hit the more complex geometry but not the simple-r one.
I checked the face that the ray detects against the complex geometry and have analysed it’s vertices, and face normal, along with custom information attributed to the face. Cross checked it to see if infact such a face existed in the simple-r geometry and it does. So what gives? Why is the raycaste detecting the face in one instance but not the other?


#2

I think it’s best when you share your code. There are thousands of reasons why your raycast can fail.


#3

Yikes, yeah I know I figured out one part of the problem. It was on my end. I suspect it’s on my end but I just want to make sure that the only thing that needs calculating is the .computeFaceNormals(). Do I need to always do a computeBoundingSphere or updateMatrixWorld or anything like that?

Problem is I have code affecting this one function spread about many many different areas. It’s a real mess unfortunately.

[edit: ] O.k disregard, I’ve got the problem sorted now. Sorry about that, I misread my readouts. I got it to overlook any vertices whose index position was 0, my bad.

[edit: ] last thing, I need to also recalculate the bounding sphere everytime I change the mesh. Good To Go —>