Adding ODE to tri-mesh- AssertionError

I’ve run into a problem adding physics to certain tri-mesh models.

I’m using the example code from the famous “bowl-egg” ODE demo:https://discourse.panda3d.org/viewtopic.php?t=2510, and have found those classes to be very awesome.

However I’ve noticed when I try and load certain models with ODEtrimesh() Python gets choked up with an Assertion Error:

in __init__
vtx1=vDataBegin+collFaceData.getVertex(s+i*3)
AssertionError: i >= 0 && i < _vertices_reader->get_num_rows() at line 1876 of c:\temp\mkpr\panda\src\gobj\geomPrimitive.cxx

Loading the ‘teapot’, ‘box’, and ‘bowl’ models all work fine; but when you switch out a more complex one like ‘panda’ or ‘ralph’ the problem arises.

Any ideas? Thanks!

It probably isn’t handling animated models correctly. I can imagine it would be difficult to handle such models properly.

Replace this part :

# get the start index of current primitive at geom's vertex data
s = collFaceData.getPrimitiveStart(prim)
for i in range(numface):
    # refer to the vertex data length list created earlier
    vtx1=vDataBegin+collFaceData.getVertex(s+i*3)
    vtx2=vDataBegin+collFaceData.getVertex(s+i*3+1)
    vtx3=vDataBegin+collFaceData.getVertex(s+i*3+2)
    collFaces.append((vtx1,vtx2,vtx3))

with this:

for i in range(0,numface*3,3):
    # refer to the vertex data length list created earlier
    vtx1=vDataBegin+collFaceData.getVertex(i)
    vtx2=vDataBegin+collFaceData.getVertex(i+1)
    vtx3=vDataBegin+collFaceData.getVertex(i+2)
    collFaces.append((vtx1,vtx2,vtx3))

Though I still don’t know what the return value of getPrimitiveStart() is useful for. Obviously it works well without it. It looks like a little liar to me. :laughing: