Notifications
Clear all

[Closed] particleflow script trouble or something? __2

Hey guys,
I come again, after DenisT fixed my particle flow test_script http://forums.cgsociety.org/showthread.php?f=98&t=1103669 (thanks DenisT again),I’ve been trying particle script tests.

    and now I find an interesting thing,supposing a script is run fast,like the one DenisT fixed,but after append another event,it will become slow or forzen,even if the event appended is very very simple.
    
    for example:my pc will loop the script that DenisT fixed 50 times quickly before append another event,but after appended will forzen.
    
    When I turn off "undo",will loop faster,but "hold" and "fetch" will still take time or maybe frozen.
    
    Does another very simple event appended take so much time? thanks for any help!

loop_number=10
rollout pf_test "pf_test" width:160 height:84
(

	spinner spn1 "" pos:[88,8] width:63 height:16 range:[1,1000,10] type:#integer scale:1
	button btn1 "creat particle flow" pos:[8,33] width:144 height:39
	label lbl1 "Loop amount " pos:[8,8] width:69 height:17
	
---------------------------------------------------------------------------	
	on spn1 changed val do
	(
	loop_number=spn1.value	
	)
--------------------------------------------------------------------------		
	on btn1 pressed do
	(
	tstart = timestamp()
	
	undo on
	for i=1 to loop_number do
	(
	
	pfSource = PF_Source()
	pfSource.SetPViewLocation 1 1
	
	ParticleFlow.BeginEdit()
	op1 = Birth()
	op2 = Position_Icon()
	op3 = Speed()
	op4 = Script_Operator()
	op4.proceed_script=
"on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useSpeed = true
)

on Init pCont do 
(

)

on Proceed pCont do 
(
count = pCont.NumParticles()
slowSpeed = 1/160.0
verySlowSpeed = 0.01/160.0
divAngle = 12.0 -- random deviation per frame
tStart = pCont.getTimeStart() as float
tEnd = pCont.getTimeEnd() as float
timeDif = tEnd - tStart
timeDif /= 160.0
dragCoef = 0.08

for i in 1 to count do
(
pCont.particleIndex = i
if length(pCont.particleSpeed) > slowSpeed then 
pCont.particleSpeed -= dragCoef*timeDif*pCont.particleSpeed
newLen = length(pCont.particleSpeed)
if newLen > verySlowSpeed then
pCont.particleSpeed = pCont.randDivergeVector(pCont.particleSpeed)(divAngle/(160*newLen))
else
pCont.particleSpeed = pCont.randDivergeVector(pCont.particleSpeed)(180.0)
if length(pCont.particleSpeed) < 1.5*slowSpeed then
(
if pCont.particleID < 50 then 
pCont.particleSpeed += [(random -0.002 -0.005)*timeDif, 0, 0]
else 
pCont.particleSpeed += [(random 0.002 0.005)*timeDif, 0, 0]
)
)
)

on Release pCont do 
(

)"
	op5 = ShapeLibrary()
	op6 = RenderParticles()
	op7 = DisplayParticles Type:6
	op7.color = pfSource.wireColor
	op8 = Age_Test()
	
	ev1 = Event()
	ev1.SetPViewLocation 1 95
	
	ev1.AppendAction op1
	ev1.AppendAction op2
	ev1.AppendAction op3
	ev1.AppendAction op4
	ev1.AppendAction op5
	ev1.AppendAction op7
	ev1.AppendAction op8
	
	pfSource.AppendAction op6
	pfSource.AppendInitialActionList ev1
	
	ParticleFlow.BeginEdit()
	op9 = DisplayParticles Type:6
	ev2 = Event()
	ev2.SetPViewLocation 1 307
	
	ev2.AppendAction op9
	op8.setNextActionList ev2 op8
	
	
	clearUndoBuffer()
	)
	
	ParticleFlow.EndEdit()
	
	tend = timestamp()
	print ("done: finished. Total time: " +  ((tend-tstart)/1000.0) as string + "s")
		
	)
)
createdialog pf_test pos:[0,85] escapeEnable:true
1 Reply

When cope and paste code into maxscript editor, at line number 63 will show :
…(divAn gle/(160newLen))
please fix into …(divAngle/(160
newLen))

I try many times ,couldn’t correct the right form ,crazy me!