Closed BlakeHancock closed 3 years ago
Can you please describe at least one use case that demonstrates why the existing layer tests in context of raycasting are insufficient? The engine does not enhance APIs without a compelling reason. If problems can be solved on application level in an adequate way, the API is usually not enhanced either.
I have my see through objects, such as a window, in a transparent layer and my non see through objects in an opaque layer. I also have an enabled layer. I would want to test against objects that are enabled but not see through.
I suppose maybe I am abusing object layers in a way it wasn't meant to be used. Even so, if the test function was overridable I would still be able to test against any number of object criteria not based on layers.
I could always pre-filter the objects I send to the RayCaster, it just seemed more efficient to just have to filter once.
I have my see through objects, such as a window, in a transparent layer and my non see through objects in an opaque layer. I also have an enabled layer. I would want to test against objects that are enabled but not see through.
Visibility and raycasting don't have to share common layers. You can put the camera in one layer, the raycaster in another one. By assigning the objects to both layers or only one of them, you can control both rendering and raycasting in an independent fashion.
I could always pre-filter the objects I send to the RayCaster, it just seemed more efficient to just have to filter once.
I don't understand how an enhanced Raycaster API allows you do to the filtering once. The tests have to be done one each raycasting procedure. I don't think there is a performance difference if you do this on application level by maintaining an array of objects that should be part of the raycasting process or by enhancing Raycaster
.
I guess in the contexts of games, I was planning on having a normal sight RayCaster, an infrared RayCaster, an X-Ray RayCaster and using layers to denote which objects are penetrable by each. For the infrared one for an example, depth is a consideration, so if it passes through too many objects, it would stop.
Again I can certainly create a wrapper class or function that handles this logic and uses the default ray tracer, it just seemed convenient to do it like my example.
I'm admittedly pretty new to 3d stuff, so I don't know the best practices very well.
I simply thought it was too bad I couldn't extend this part of the RayTracer due to it existing outside the exported object.
Okay, understood. But since your requirements are quite application specific, there is not yet a compelling reason for changing/enhancing the API. We can reconsider this issue if more user are going to ask for similar features.
Right now the only way to tell the RayCaster to include an object or not is with setting layers, and it is limited to checking any one of the RayCaster's layers is included in the objects layers.
Because this check exists outside the object in a separate function, in order to override this behavior, you need to needlessly override the RayCaster's intersectObject and intersectObjects functions, instead of just the outside intersectObject function.
Possible Solutions:
if ( object.layers.test( raycaster.layers ) ) {
part.)Example Current Override It requires a lot of duplicate code to get the desired result.
Potential Override If More Extendable