Skip to main content
deleted 5 characters in body
Source Link

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.evaluated_depsgraph_get()view_layer.depsgraph,
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.evaluated_depsgraph_get(),
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.view_layer.depsgraph,
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?

deleted 3 characters in body
Source Link

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.evaluated_depsgraph_get(),
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I'veI got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.evaluated_depsgraph_get(),
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I've got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.evaluated_depsgraph_get(),
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?

Source Link

Incoherent face index result of ray_cast

I do a ray_cast from the camera along its direction to get the hit face:

def find_hit_face(camera, direction):
    _, _, _, hit_face_index, hit_object, _ = (
        scene.ray_cast(
            depsgraph=context.evaluated_depsgraph_get(),
            origin=camera.location,
            direction=direction,
            distance=camera.data.clip_end,
        )
    )
    polygons = hit_object.data.polygons()
    return polygons[hit_face_index]

But I've got the error IndexError: bpy_prop_collection[index]: index 5544 out of range, size 2224.

How can I get the hit face from the hit face index?