Skip to content

How to convert (N,3) numpy array into (N) warp vec3? #363

@cadop

Description

@cadop

Discussed in #359

Originally posted by cadop November 15, 2024

I am trying to convert an array of integers into a warp array of vec3i, where the second dim is captured by the warp dtype.

    faces = mesh.indices.reshape((-1, 3))
    faces = wp.array(faces, shape=(N), dtype=wp.vec3i, device=device)

The kernel signature is:

@wp.kernel
def _matrix(points: wp.array(dtype=wp.vec3),
            faces: wp.array(dtype=wp.vec3i),
            mesh: wp.uint64):
     f = wp.tid()
     face = faces[f]

This was seemingly working when I was in device='cpu' , however changing device to cuda results in:
RuntimeError: Error launching kernel '_matrix', argument 'faces' expects an array with dtype=<class 'warp.types.vec3i'> but passed array has dtype=<class 'warp.types.int32'>.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions