markcwm / openb3d.mod

OpenB3D BlitzMax wrapper, see openb3d.docs for examples
18 stars 7 forks source link

CopyMesh Crashes OpenB3D - EXCEPTION_ACCESS_VIOLATION #18

Closed Kippykip closed 4 years ago

Kippykip commented 5 years ago

copymesh crash example.zip CopyMesh seems to flat out crash OpenB3D on loaded models, from what I understand it's this part in mesh.cpp // recursively copy contents of child list before adding parent list<Entity*>::iterator it; for(it=child_list.begin();it!=child_list.end();it++){ Entity* ent=*it; dynamic_cast<Mesh*>(ent)->CopyMesh(mesh); } Specifically the *dynamic_cast<Mesh>(ent)->CopyMesh(mesh);** part, I'm not sure if it's trying to run it's own function or something? I've attached an example, it would be very epic if this one could be fixed so I can have multiple entities with animated textures without having to LoadAnimMesh and cause stutters. I'm still going to have a play around, I was able to restore minib3d behaviour where it copies the mesh without the animation, but hopefully we can fix this fully! :crossed_fingers: :smiley:

Kippykip commented 5 years ago

Hazza! I fixed it! Also I found a reliable way to fully disable lights on FX = 1, instead of just disabling normalmaps like before which just appeared to reduce the effect but could still glow meshes depending on the light angle. https://github.com/Kippykip/openb3dmax.mod

markcwm commented 4 years ago

Thanks for the fix Kippy! I had to change CopyMesh as it wasn't making a deep copy whereas CopyEntity was, this is not like in Blitz3d so I changed it around and it worked, but if a child entity is not a mesh that may crash it (so probably check it's a mesh like this... if(dynamic_cast<Mesh*>(ent)!=0){ do CopyMesh }else{ do CopyEntity }

Kippykip commented 4 years ago

There we go! Fixed it properly now with the mesh check, so now children will copy correctly now with no crashes. 😃 https://github.com/Kippykip/openb3dmax.mod/blob/a2c02111e1302f13fddc4cded8749d1d2b8f84ea/openb3dlib.mod/openb3d/src/mesh.cpp

markcwm commented 4 years ago

Hi Kippy, this should be fixed in latest commit

markcwm commented 4 years ago

Closed.