i am creating a mesh after loading a xml with the meshdata.
everything works fine.
when i try to delete my created mesh i run into problems.
private function clear_scene() : void {
if (awayView._view.scene.contains(root_scene_object)) {
root_scene_object.dispose(true);
}
if calling the function this error is shown:
Error #1009: Cannot access a property or method of a null object reference.
i had a look at the funktion and figured that “geometrie.dispose()” and “geometrie.removeSubgeometrie()”
both trying to delete the same subgeometrie in the subGeometrie-Vector.
here are the two functions:
public function dispose() : void
{
var numSubGeoms : uint = _subGeometries.length;
for (var i : uint = 0; i < numSubGeoms; ++i) {
var subGeom:SubGeometry = _subGeometries.shift();
removeSubGeometry(subGeom);
subGeom.dispose();
}
}
public function removeSubGeometry(subGeometry : SubGeometry) : void
{
_subGeometries.splice(_subGeometries.indexOf(subGeometry), 1); subGeometry.parentGeometry = null;
if (hasEventListener(GeometryEvent.SUB_GEOMETRY_REMOVED))
dispatchEvent(new GeometryEvent(GeometryEvent.SUB_GEOMETRY_REMOVED, subGeometry));
invalidateBounds(subGeometry);
}
i changed the dispose() into this:
public function dispose() : void
{
var numSubGeoms : uint = _subGeometries.length;
for (var i : uint = 0; i < numSubGeoms; ++i) {
var subGeom:SubGeometry = _subGeometries[0];
removeSubGeometry(subGeom);
subGeom.dispose();
}
}
and no error is shown when calling the function
if my mesh had materials applied i recieved this error when calling dispose() :
index -1 is out of range
i figured that the error happened in MaterialLibrary.unregisterMaterial():
arcane function unregisterMaterial(material : MaterialBase) : void
{
var id : int = material.uniqueId;
_names[id] = null;
_materials[id] = null;
material.setUniqueId(-1);
}
i changed the function to this:
arcane function unregisterMaterial(material : MaterialBase) : void
{
var id : int = material.uniqueId;
if(id!=-1){
_names[id] = null;
_materials[id] = null;}
material.setUniqueId(-1);
}
no error shown anymore.
still after loading and deleting a scene for several times, i recieve the error register overflow
so the dispose function is not clearing buffers on gpu ?