FreeEntity Animate Crash

Started by Kippykip, November 15, 2017, 22:16:17

Previous topic - Next topic

Kippykip

Just discovered that using FreeEntity on an Entity that has been animated will crash OpenB3D.
It points to TEntity on the FreeEntity method at "FreeEntity_(inst)"

I am using Blitzmax-NG if that helps.

Kippykip

#1
Here's an example I made up:
Import openb3d.B3dglgraphics
Graphics3D(640, 480, 32, 2, 60)
Global camera:TCamera = CreateCamera
Global sci:TEntity = LoadAnimMesh("data\models\sci.b3d")
PositionEntity(sci, 0, - 25, 50)
animate(sci)
While Not AppTerminate()

RenderWorld()
UpdateWorld()
If(KeyHit(KEY_Z))
FreeEntity(sci)
Text(0, 10, "Test passed!")
EndIf

Text(0, 0, "press Z to crash")
Flip
Delay 1000 / 60
Wend


I've attached the demo below.

EDIT 1: I found out it doesn't matter whether there's an animate parameter or not. It's just if the model contains BONES/JOINTS it will crash on FreeEntity

RonTek

Hey Kip, before anything else, I think your textures here are pointing to an absolute path..

Building crashexample
Executing:crashexample.exe
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci2_Hand1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci2_Knuckles.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/SCI3_LegBack1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/SCI3_Collar1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci3RLeg.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci3_RArm.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci3_LArm.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Hair_Side2.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Face1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Hair_Side1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Stache1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci2_Tounge.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/SCI2_Needle1.png'
Error: Can't Find Document File 'data/models/SCI2_Needle1.png'

Process complete


crashes on run. for your info

RonTek

Quote from: Kippykip on November 15, 2017, 22:34:10
EDIT 1: I found out it doesn't matter whether there's an animate parameter or not. It's just if the model contains BONES/JOINTS it will crash on FreeEntity

Looks like something to do with LoadAnimMesh only, with LoadMesh it works fine with FreeEntity.

Kippykip

#4
Quote from: RonTek on November 15, 2017, 23:11:15
Hey Kip, before anything else, I think your textures here are pointing to an absolute path..

Building crashexample
Executing:crashexample.exe
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci2_Hand1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci2_Knuckles.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/SCI3_LegBack1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/SCI3_Collar1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci3RLeg.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci3_RArm.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci3_LArm.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Hair_Side2.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Face1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Hair_Side1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Stache1.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/Sci2_Tounge.png'
Error: Can't Find Document File 'C:/Users/Kippykip/Downloads/PC Computer - Half-Life - Scientists/Scientist/SCI2_Needle1.png'
Error: Can't Find Document File 'data/models/SCI2_Needle1.png'

Process complete


crashes on run. for your info

Oh wow interesting, that's the path where I extracted some models I downloaded off the web. It should work fine though if the textures are right next to the b3d model file.
Quote from: RonTek on November 15, 2017, 23:44:12
Quote from: Kippykip on November 15, 2017, 22:34:10
EDIT 1: I found out it doesn't matter whether there's an animate parameter or not. It's just if the model contains BONES/JOINTS it will crash on FreeEntity

Looks like something to do with LoadAnimMesh only, with LoadMesh it works fine with FreeEntity.
If you use LoadAnimMesh on a model without any bones or animation it also doesn't crash, so I'm almost certain it has something to do with freeing bones.
EDIT: Wow LoadMesh doesn't do the relative path thing and just crashes right away.
EDIT 2: It also crashes LoadMesh, but doesn't on a separate model without any bones whatsoever.

Kippykip

#5
Here's a new example, both LoadMesh and LoadAnimMesh crash with FreeEntity if the model has bones in it. I just simply got rid of the textures for this example.

RonTek

#6
Quote from: Kippykip on November 16, 2017, 04:31:27
EDIT: Wow LoadMesh doesn't do the relative path thing and just crashes right away.
EDIT 2: It also crashes LoadMesh, but doesn't on a separate model without any bones whatsoever.

This I have tried: using LoadMesh and FreeEntity on Animated Bone Models works ok with OpenB3D (Latest) + NG, with MiniB3D FreeEntity works fine so it seems to be a new issue with OpenB3D.

Btw, I got an older OpenB3D version (3/2017) before the new model loader stuff/changes and FreeEntity also works ok.

Hope that helps.

Kippykip

Quote from: RonTek on November 16, 2017, 12:00:34
Quote from: Kippykip on November 16, 2017, 04:31:27
EDIT: Wow LoadMesh doesn't do the relative path thing and just crashes right away.
EDIT 2: It also crashes LoadMesh, but doesn't on a separate model without any bones whatsoever.

This I have tried: using LoadMesh and FreeEntity on Animated Bone Models works ok with OpenB3D (Latest) + NG, with MiniB3D FreeEntity works fine so it seems to be a new issue with OpenB3D.

Btw, I got an older OpenB3D version (3/2017) before the new model loader stuff/changes and FreeEntity also works ok.

Hope that helps.
Oh that's good to know, maybe I'll temporary downgrade for my project until mark takes a look at it in his free time :)

markcwm

Hi,

I've fixed the crash with freeing animated B3D, it was a fault in the library. I still have to fix the MD2 crash (also a bug in the library) but if you want to test now add to entity.cpp in function "Entity::FreeEntity(void)" code to reset "anim_update":

Code (c) Select
// remove from animate list
if(anim_update){
animate_list.remove(this);
anim_update=false;
}

Kippykip

Quote from: markcwm on November 21, 2017, 02:35:06
Hi,

I've fixed the crash with freeing animated B3D, it was a fault in the library. I still have to fix the MD2 crash (also a bug in the library) but if you want to test now add to entity.cpp in function "Entity::FreeEntity(void)" code to reset "anim_update":

Code (c) Select
// remove from animate list
if(anim_update){
animate_list.remove(this);
anim_update=false;
}

Cheers mate you are an absolute legend! ;)
I wasn't even aware that MD2 files were supported at all, that's awesome to know!

markcwm

#10
Okay,

I've fixed the MD2 animation bugs and uploaded a new commit, so all FreeEntity issues should be resolved now.

The MD2 bug is properly fixed in the library at last! 8) There wasn't enough memory allocated to md2.cpp vert_coords when resized, it just needed +1. Also in animation.cpp AnimateMesh had a divide by zero error with 'm1' and if it was the first frame 't0' had a negative value when it should be size-1.

I also changed usenative to LoadMesh(ent,par=Null,uselibrary=True) so it won't affect existing code. So if you want to use the native loaders for zipstream you need to set it to zero.

Thanks to Kip and RonTek for all the help.