(Separate post as it may include the answer–pending confirmation that this is the right way to do this. As such, a separate post might make it easier for people to find said answer–whether to use it themselves or to refute it.)
Okay, I think that I may have found the solution!
It seems that one isn’t expected to just make a memoryview and then keep it.
Instead, one makes a new memoryview each update!
Thus, the approach ends up looking something like this:
During initialisation:
- Create a GeomVertexFormat and a GeomVertexData
- Set the number of rows in the latter to reflect the number of vertices
- Create the primitive (in this case a GeomTriangles)
- Set up a GeomNode and NodePath using that primitive
Then, during updates:
- Create an array, with format “f”, initialised with an empty list
- i.e. Like so:
array.array("f", [])
- i.e. Like so:
- Iterate over the data that defines the vertices
- For each data-point:
- Perform various calculations
- Add to the array via “fromlist”
- For each data-point:
- At the end, update the memoryview like so:
self.memoryviewObject[:len(dataList)] = dataList
Does that seem right…?
[edit]
Just to check: Should I be cleaning up my memoryviews in some way…?