- Home /
Here is the solution http://wiki.unity3d.com/index.php?title=PolyContainsPoint
Am I inside a volume? (Without ray cast and default colliders?)
Hello once again!
Here is an improved version of a question explained here
Interesting, can one tell if a point in space is inside a given mesh without any kind of colliders? It get's harder once it's not a cube, but for example a pyramid, especially if we are using the x-y-z coordinate-bound approach, comparing all 3 coordinate components of vertexes against ours. Can I use c# to actually see that my position is inside a specified volume using some function?
I cannot use ray cast since I need to do this at the same time about 200 times every frame from 200 different points on the map. :<
I was thinking if I ray cast every 10 degrees (In a sphere-pattern), so I get 36 ray casts (All done in editor before the game starts). I then detect points of intersection, plant a vertex there, and come out with a mesh. Standing inside of this object I know that I will be able to see towards that emission point.
But I need to find out if I am in between those vertexes during gameplay. Raycast is very heavy on resources.
thanks for helping!
P.S.
I was thinking, maybe it's possible to create such mesh using a lighting/shadow approach? In it I somehow would detect if a surface is lit by light and would plant a vertex of my mesh where the light hits the surface, simply by looking at change of light - Sounds a little crazy, but that's what I am essentially trying to achieve with pre-bake using ray casts.