[Solved] Disposing/Freeing Shadows Inside Types

BlitzMax Forums/MiniB3D Module/[Solved] Disposing/Freeing Shadows Inside Types

RustyKristi(Posted 2016) [#1]
I have a typed entity, so looks like referencing a shadow inside it won't work

Type Player
  mesh:TMesh
  shadow:TShadowObject
End Type


Unable to convert from TShadowObject(TMesh,Int) to TShadowObject

I would like to dispose/free shadows properly, I'm seeing remnants when I free my entity types above most of the time. when I do a freeshadow player.mesh I also get errors.

[Edit] I think putting the shadows in array list first solved my issues, still checking if it will be stable enough for a lot of objects.


markcw(Posted 2016) [#2]
Not really sure what that error means but you should define everything in a type as either field or global.

Also I found a memory leak in FreeShadow to do with nulling ShadowMesh. I haven't uploaded it yet but the fix is:
	Method FreeShadow()
	
		If exists
			ListRemove( shadow_list,Self ) ; shadow_list_id:-1
			ListRemove( TEntity.entity_list,ShadowMesh ) ; TEntity.entity_list_id:-1
			
			TMesh.FreeObject( TMesh.GetInstance(ShadowMesh) ) ; ShadowMesh=Null  ' no FreeEntity
			TSurface.FreeObject( TSurface.GetInstance(ShadowVolume) ) ; ShadowVolume=Null
			
			FreeShadow_( GetInstance(Self) )
			FreeObject( GetInstance(Self) )
			exists=0
		EndIf
		
	End Method



RustyKristi(Posted 2016) [#3]
Thanks, munch. I could try the field thing again but so far I'm happy to get it working and it looks stable enough.

That's great, looking forward to your next updates :-)