March 20, 2019, 03:58:25 AM

Author Topic: FreeEntity Animate Crash  (Read 1300 times)

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
FreeEntity Animate Crash
« on: November 15, 2017, 10:16:17 PM »
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.

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FreeEntity Animate Crash
« Reply #1 on: November 15, 2017, 10:34:10 PM »
Here's an example I made up:
Code: [Select]
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

Offline RonTek

  • Sr. Member
  • ****
  • Posts: 357
Re: FreeEntity Animate Crash
« Reply #2 on: November 15, 2017, 11:11:15 PM »
Hey Kip, before anything else, I think your textures here are pointing to an absolute path..

Code: [Select]
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

Offline RonTek

  • Sr. Member
  • ****
  • Posts: 357
Re: FreeEntity Animate Crash
« Reply #3 on: November 15, 2017, 11:44:12 PM »
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.

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FreeEntity Animate Crash
« Reply #4 on: November 16, 2017, 04:31:27 AM »
Hey Kip, before anything else, I think your textures here are pointing to an absolute path..

Code: [Select]
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.
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.

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FreeEntity Animate Crash
« Reply #5 on: November 16, 2017, 04:42:38 AM »
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.

Offline RonTek

  • Sr. Member
  • ****
  • Posts: 357
Re: FreeEntity Animate Crash
« Reply #6 on: November 16, 2017, 12:00:34 PM »
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.

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FreeEntity Animate Crash
« Reply #7 on: November 16, 2017, 09:37:52 PM »
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 :)

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 351
Re: FreeEntity Animate Crash
« Reply #8 on: November 21, 2017, 02:35:06 AM »
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:  (Unknown Language)
  1.         // remove from animate list
  2.         if(anim_update){
  3.                 animate_list.remove(this);
  4.                 anim_update=false;
  5.         }

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 78
    • Kippykip Forums!
Re: FreeEntity Animate Crash
« Reply #9 on: November 21, 2017, 06:32:16 AM »
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:  (Unknown Language)
  1.         // remove from animate list
  2.         if(anim_update){
  3.                 animate_list.remove(this);
  4.                 anim_update=false;
  5.         }
Cheers mate you are an absolute legend! ;)
I wasn't even aware that MD2 files were supported at all, that's awesome to know!

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 351
Re: FreeEntity Animate Crash
« Reply #10 on: November 21, 2017, 09:06:26 AM »
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.