Is it imperative to reassign the entire array for Mesh variables, when you just need to change a few vertices, uvs, etc.? I can’t get anything to work unless I do reassign the entire thing, but that seems really inefficient to me.
I guess I’ll give this a bump.
As far as I can tell, you must reassign the entire vertices, uv, or triangles array to make any changes. But it’s possible I just haven’t learned a better scheme for it. Anybody know for sure?
In my experience, that’s just the way the mesh class works…
I’m not able to access and modify just one index of the mesh arrays:
// This doesn't work:
mesh.vertices [2] = new Vector3 (1, 1, 1);
That has been my experience too, but as I said, it doesn’t seem efficient. Is this something we could request UT to change, or is this a problem having to do with GPUs?
You do actually need to reassign the whole array, because the vertices, triangles arrays, etc, are actually properties rather than variables. That is to say, they behave like variables, but they are implemented in a way that activates some code whenever they are read or assigned. To get the maximum efficiency from this, I would recommend maintaining your own array with the vertex values (or whatever), making changes to this as necessary and then assigning this array to the vertices property of the mesh object.
Yep, that’s my method.
Do you know if there is any way UT could improve upon the way these functions are handled? (I’ll send them a feature request if so.)
I’m pretty sure the issue is with passing the data between main memory and GPU, so I doubt this could be improved, unfortunately.
That makes sense, and your signature is amazing.