I've found another bug within Dark Physics particle emitters.
The phy delete emitter ID command simply hides the emitter but does not clear emitter data/mesh. If another emitter is created with the same ID number, even after several seconds, planes from the deleted emitter re-appear. This means that emitters can't be used more than once without manually setting their properties so the previous instance of the emitter had no displayed planes on deletion. It also implies that system resources taken up by an emitter are not being released.
Rem Demonstrates bug in delete emitter. The emitter mesh is not deleted and planes created in a previous instance of the emitter are retained.
phy enable debug
` set up the program
phy start
sync on
sync rate 0
autocam off
color backdrop 0
` make the particle emitter
phy make particle emitter 1, 512, 0.001, 0.0, 0.0, 0.0, 1.0, 0.0, 1.5, 0.0
` give it a texture
load image "fire.png", 1
texture object 1, 1
set object radius 1, -1
ghost object on 1
` now set some properties
remstart
phy set emitter life span 1, 0.001
phy set emitter size 1, 1.0
phy set emitter max size 1, 100.0
phy set emitter growth rate 1, 8.0
phy set emitter start color 1, 0, 255, 255
phy set emitter end color 1, 255, 255, 255
phy set emitter linear velocity range 1, -1, -2, 0, 2, 3, 1
phy set emitter range 1, -2, 2, -2, 2, 2, 2
remend
phy set emitter linear velocity 1, 0.0, 1.5, 0.0
` position the camera
position camera 0, 30, -40
point camera 0, 0, 0
` main program loop
do
if spacekey()
if phy get emitter exist(1) then phy delete emitter 1
delete object 1
endif
if shiftkey()
if phy get emitter exist(1)=0
phy make particle emitter 1, 512, 0.001, 0.0+rnd(5), 0.0, 0.0+rnd(5), 10.0, 0.0, 1.5, 0.0
texture object 1, 1
set object radius 1, -1
ghost object on 1
phy set emitter linear velocity 1, 0.0, 1.5, 0.0
endif
ENDIF
` update simulation and screen
phy update
sync
loop
A related and more serious issue is that data seems to be shared between emitters. Having deleted an emitter then creating a new emitter with a different ID still inherits data and shows planes from the deleted mesh. The code below demonstrates the problem.
Rem Demonstrates bug in delete emitter. The emitter mesh is not deleted and planes created in a previous instance of the emitter are retained.
phy enable debug
` set up the program
phy start
sync on
sync rate 0
autocam off
color backdrop 0
` make the particle emitter
phy make particle emitter 1, 512, 0.001, 0.0, 0.0, 0.0, 1.0, 0.0, 1.5, 0.0
emitterID=1
` give it a texture
load image "fire.png", 1
texture object 1, 1
set object radius 1, -1
ghost object on 1
` now set some properties
remstart
phy set emitter life span 1, 0.001
phy set emitter size 1, 1.0
phy set emitter max size 1, 100.0
phy set emitter growth rate 1, 8.0
phy set emitter start color 1, 0, 255, 255
phy set emitter end color 1, 255, 255, 255
phy set emitter linear velocity range 1, -1, -2, 0, 2, 3, 1
phy set emitter range 1, -2, 2, -2, 2, 2, 2
remend
phy set emitter linear velocity 1, 0.0, 1.5, 0.0
` position the camera
position camera 0, 30, -40
point camera 0, 0, 0
` main program loop
do
if spacekey()
if phy get emitter exist(emitterID) then phy delete emitter emitterID
endif
if shiftkey()
if phy get emitter exist(emitterID)=0
inc emitterID
phy make particle emitter emitterID, 512, 0.001, 0.0+rnd(5), 0.0, 0.0+rnd(5), 10.0, 0.0, 1.5, 0.0
texture object emitterID, 1
set object radius emitterID, -1
ghost object on emitterID
phy set emitter linear velocity emitterID, 0.0, 1.5, 0.0
endif
ENDIF
` update simulation and screen
phy update
sync
loop
GrumpyOne - the natural state of the programmer