Strange memory access violation

BlitzMax Forums/BlitzMax Programming/Strange memory access violation

verfum(Posted 2007) [#1]
I cant see what I'm doing wrong here, I'm using Irrlicht and PhysX.
Global cloth_mesh:IAnimatedMesh=Null

cloth_mesh = smgr.getMesh("pol.b3d")
cloth_node = smgr.addAnimatedMeshSceneNode(cloth_mesh)

Global cloth_body = CreateClothSpecial(cloth_mesh)
pxClothAttachVertexToPos (cloth_body, 399, -10,30,10)
pxClothAttachVertexToPos (cloth_body, 440, 9,30,10)

Function CreateClothSpecial(cloth_mesh:IAnimatedMesh)
	
	Local entity:IMesh = cloth_mesh.getmesh(0)
	
	Local surf:IMeshBuffer = entity.getMeshBuffer(1)
	
Local nvert% = surf.getVertexCount()  'HERE
	Local nface% = surf.getIndexCount()/3   'HERE


It points to either of the two above where I've marked 'HERE, if I swap them around it'll point to the top one. The file path is correct.


Gabriel(Posted 2007) [#2]
If it happens on either line, it's probably the line above where you return the MeshBuffer. It's probably returning in invalid pointer and then the next line writes to memory it doesn't have access too. I don't use Irrlicht or PhysX though, so more than that, I can't say.


H&K(Posted 2007) [#3]
make sure this loaded something
cloth_mesh = smgr.getMesh("pol.b3d")
i.e.
If cloth_mesh = Null then end


verfum(Posted 2007) [#4]
Thanks, I'll have a look into it, it's just I have other code which is similar yet it works, I'm hoping it's not a physics problem. H&K Yes I did double check that.


gman(Posted 2007) [#5]
not sure if this is still up in the air but getMeshBuffer() is zero based so to get the first one use 0 instead of 1.