How to collide with just a single object

On my little world:

  • The terrain is an icosphere, but the icosphere node is also the parent of everything that is on that sphere.
  • I have a ray, from the camera position down to the center of the sphere.
  • I need to find out the height at the point of the terrain under the camera position.
  • I don’ t want icosphere.collideWith(ray, results) to iterate over all the children of this node. Just give me the spot where the ray hits the globe.

How could I do this?

The reason behind this is that I do this a lot every cycle and I assume iterating over a 1000 children is not good for performance.

So how to collide with just a single object?

2 Likes

Do you have a reference to that globe geometry? if so you should be able to just do

globe.collideWith(ray, results)

1 Like

I do have the Geometry object of this mesh. Does this collideWith method only check this specific geometry?

Yes, calling collideWith on a spatial tests if something (a ray in this case) collides with that spatial (and its children). Not it’s parent or siblings

2 Likes