I’m trying to port one of my Dark Basic Professional projects to Panda, and I’m running into some speed issues. I need to create quickly various geometries loaded from text format. The process I have works nicely, but is a bit too slow. Searching the forums, I’ve come across a couple of threads that seem to point toward some faster approaches for using geomVertexData to create geometry in-game.
[url][SOLVED]Help with asynchronous creation of vertex data bufrs]
[url]GeomVertexDataArray from Numpy array]
format=GeomVertexFormat.getV3n3t2() #vertex 3 normal 3 texture 2 (v3n3t2)
vdata=GeomVertexData('geometry', format, Geom.UHStatic)
tri=GeomTriangles(Geom.UHStatic)
geomVertexNumpyData = np.empty((vertListLength,8),dtype=np.float32)
#add some data to the array and tri
data = geomVertexNumpyData.tostring()
geomVertexDataArray.modifyArray(0).modifyHandle().setData(data)
geomChunk=Geom(vdata)
geomChunk.addPrimitive(tri)
There seems to be a better way to do what I need to do, then, based on these threads and a couple of other leads. Unfortunately, every indication I can find on the forums suggests that you need to acquire properly formatted array data from numpy, to do this in Python. I would prefer to avoid any numpy dependency in my code, if I can avoid it.
So I’ve been trying to get the same result using various combinations of ctypes, struct, and Python’s own array format. Most of these tests give me corrupted geometry. A couple of ctypes efforts gave me a correct geometry, but they were slower than using pure Python.
So I am asking here, is there a way to get out of plain Python data which is equivalent to what numpy would produce, to allow me to use the approach noted above? I’ve come across several undocumented tricks in Panda since I began using it, so I’m hoping this is a case where there’s a secret method. If there is, this seems to be a problem I can’t tackle on my own. Need a little help. Someone, haaaaalp!
Attaching my testing code. Move the little box around using the arrow keys. When he hits the edge of the room, a room change occurs, involving a geometry swap. That change is too slow, resulting in a noticeable pause. I would prefer to avoid writing out the geometries to egg or bam or another format, if possible.
adventure_slow.zip (12.8 KB)