65 lines
1.3 KiB
C#
65 lines
1.3 KiB
C#
|
|
using Godot;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Rokojori
|
|
{
|
|
public partial class RDContext
|
|
{
|
|
protected List<RenderingObject> _cleanUps = new List<RenderingObject>();
|
|
protected List<string> _cleanUpInfo = new List<string>();
|
|
|
|
public void Free( RenderingObject ro, string info = null )
|
|
{
|
|
if ( ro == null )
|
|
{
|
|
Warning( "ro == null, couldn't clean up: ", info );
|
|
return;
|
|
}
|
|
|
|
Verbose( "Cleaning up: ", info, ro.rid );
|
|
renderingDevice.FreeRid( ro.rid );
|
|
}
|
|
|
|
|
|
public void CleanUp()
|
|
{
|
|
var index = 0;
|
|
|
|
_cleanUps.ForEach(
|
|
c =>
|
|
{
|
|
Free( c, "_cleanUps[" + index + "]");
|
|
index ++;
|
|
}
|
|
);
|
|
|
|
_cleanUps.Clear();
|
|
}
|
|
|
|
public void AddToCleanUp( RenderingObject ro, string info = null )
|
|
{
|
|
if ( _cleanUps.Contains( ro ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
_cleanUps.Add( ro );
|
|
_cleanUpInfo.Add( info );
|
|
}
|
|
|
|
public void AddToCleanUp( List<RenderingObject> ro, string info = null )
|
|
{
|
|
var index = 0;
|
|
info = info == null ? "" : info;
|
|
|
|
ro.ForEach(
|
|
r =>
|
|
{
|
|
AddToCleanUp( r, info + "["+ index + "]" );
|
|
index ++;
|
|
}
|
|
);
|
|
}
|
|
}
|
|
} |