Flint Particle System Forum - Run all actions multiple times between draw operations 2011-12-12T19:58:06+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Run all actions multiple times between draw operations http://flintparticles.org/forum/comments.php?DiscussionID=401&Focus=1374#Comment_1374 2010-09-21T16:36:35+01:00 2011-12-12T19:58:06+00:00 Colin http://flintparticles.org/forum/account.php?u=390 Hi, I'm writing a custom action to implement the Lennard-Jones potential to simulate atoms interacting with one another. Unfortunately, this potential has very strong repulsion at short ...
I'm writing a custom action to implement the Lennard-Jones potential to simulate atoms interacting with one another. Unfortunately, this potential has very strong repulsion at short inter-particle separations, which always leads to the system blowing up. I've already tried using the epsilon approach used in MutualGravity, et. al and that kind of worked but it's still not great. Even using this approach, the particles gain energy constantly and the whole system speeds up over time. I'd prefer not to use SpeedLimit if possible.

My next thought is to try to run the simulation using a very short frame duration. However, this makes the system move very slowly. I could be wrong, but it seems to me that drawing the system is more computationally expensive than actually running the actions. So, I was thinking about trying to implement in Flint something I had done a couple of years ago in Java: using a very short time step for the calculations and only drawing the system every 10+ time steps. My naive first stab at this was to add a bunch of the same type of action to the emitter. However, they seem to get sorted by type. I had LennardJones, Move, and BoundingBox in that order multiple times. However, instead of executing in that order, the emitter ran LennardJones multiple times and then Move multiple times, etc. This made the system blow up super fast. Even if there is some method by which I could get this approach to work, it seems like there should be a more elegant approach.

I know you can use runAhead() to run your emitter's actions a bunch of times before you draw it for the first time. Is it possible to do this type of thing repeatedly? If so, how? Is this approach even worth pursuing?

Any input that people can offer would be much appreciated. Thanks!]]>
Run all actions multiple times between draw operations http://flintparticles.org/forum/comments.php?DiscussionID=401&Focus=1375#Comment_1375 2010-09-21T17:03:46+01:00 2011-12-12T19:58:06+00:00 Colin http://flintparticles.org/forum/account.php?u=390 I realized that the grouping issue I had with actions of the same type was due to their priorities. I guess I could add 10 of each type of action I want to execute to the emitter and then give them ... Run all actions multiple times between draw operations http://flintparticles.org/forum/comments.php?DiscussionID=401&Focus=1379#Comment_1379 2010-09-23T17:47:11+01:00 2010-09-23T17:48:08+01:00 Richard http://flintparticles.org/forum/account.php?u=1 There's probably lots of ways you could do this. The two that come to mind are... 1. Override the Emitter class class MyEmitter2D extends Emitter2D { override pubic function update( ...
1. Override the Emitter class

class MyEmitter2D extends Emitter2D
{
override pubic function update( time:Number ) : void
{
var microtime:Number = time * 0.1;
for( var i:int = 0; i < 10; i++ )
{
super.update( microtime );
}
}
}


2. Take control of the update yourself

emitter.useInternalTick = false;
FrameUpdater.instance.addEventListener( UpdateEvent.UPDATE, updateParticles, false, 0, true );

private function updateParticles( event:UpdateEvent ):void
{
var microtime:Number = event.time * 0.1;
for( var i:int = 0; i < 10; i++ )
{
emitter.update( microtime );
}
}


P.S. I haven't tested this code so I apologise if it contains errors.]]>