Bug in RenderWorld

BlitzMax Modules Forums/MiniB3D/Bug in RenderWorld

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

no bug within minib3d I think, it is more a bug or failure in th Garbage Collector of BMax.
It seems if you remove an Entity this way sometimes the Delete() Method isn't called properly and the reference to other brushes seems to be deleted. As a workaround don't use FreeEntity within the delete() method. Try this instead:
SuperStrict

Import sidesign.minib3d

Type TCube
	Field X:Int
	Field Y:Int
	Field Z:Int
	Field Entity:TEntity
	
	Function create:TCube(x:Int,y:Int,z:Int)
		Local Cube:TCube = New TCube
		Cube.X = X
		Cube.Y = Y
		Cube.Z = Z
		
		Cube.Entity = CreateCube()
		Cube.Entity.Brush = CreateBrush()
		PositionEntity Cube.Entity,X,Y,Z
		Return Cube
	End Function
	
End Type
	
Graphics3D 800,600,32,1

Local Camera:TCamera = CreateCamera()
PositionEntity Camera,0,0,-20
Local Light:TLight = CreateLight()
RotateEntity Light,45,45,0

Local CubeList:TList = CreateList()

For Local x:Int = 1 To 10
	Local Cube:TCube = TCube.Create(Rand(-10,10),Rand(-10,10),Rand(0,10))
	CubeList.AddLast(Cube)
Next

While Not KeyHit(KEY_ESCAPE)
	Cls
	RenderWorld
	Flip
	
	If KeyHit(KEY_SPACE)
		For Local Cube:TCube = EachIn CubeList
			If Rand(1,4) = 1
				FreeEntity(Cube.Entity)
				CubeList.Remove(Cube)
				Local Cube2:TCube = TCube.Create(Rand(-10,10),Rand(-10,10),Rand(0,10))
				CubeList.AddLast(Cube2)
			End If
		Next
	End If
Wend