Pages: 1
  Print  
Author Topic: Automatic updating for particle systems  (Read 11324 times)
Offline (Unknown gender) forthevin
Posted on: December 06, 2012, 01:35:34 pm

Contributor
Joined: Jun 2012
Posts: 167

View Profile
I have implemented a very basic version of particle systems, which can be seen in this fork: https://github.com/forthevin/enigma-dev. Recently, I have worked with implementing automatic updating of particle systems. In GameMaker, particle systems can be either updated automatically (the default setting), or updated by hand. I have determined that GameMaker updates the particle systems between the end-step events and the draw events.

The issue is now that updates and changes in GameMaker generally happens as part of instances and their events, and not outside them. This is reflected in ENIGMA's handling of events, since function calls (as far as I can tell) cannot be put directly in between events. Since particle systems are independent of instances and their events, they are an exception to the rule. Therefore, updating particle systems between the end-step event and the draw event seems non-trivial, since only events can be updated between events.

I have found two solutions to the problem. The first is to create a hacky event, that does not go through instances, but just calls a single function. It could look like this in event.res:

Code: [Select]
particlesystemsupdate: 100000
Name: Particle Systems Update
Mode: None
Default: ;
Instead: enigma::update_particlesystems();

The above code would be placed in between the end-step and draw events. This code solves the issue. The only thing of notice is that it also generates a superfluous virtual function in the object superclass. This solution is currently implemented in the fork and works.

The second solution I have found would be to extend the format of event.res, such that the format allows the above solution but without generating a superfluous virtual function in the object superclass.

My suggestion is now that the first solution is used as it is, while the second solution is postponed until further notice. Since the superfluous virtual function is never called, it shouldn't cause much (if any) overhead.
Logged
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: December 06, 2012, 01:40:00 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
If particles were the only systems requiring such an event, I'd probably go with the hack, but since they certainly are not, it's definitely better to do something else about them. Polygone already hacked up events.res to update some globals in a weird spot ages ago, and I haven't gotten around to dealing with that yet, either. So for now, go ahead and push your changes to master and the issue can stew for a while until I have time to do something about it.

I'd kind of like to reformat events.res into basic e-Yaml anyway, so LGM can read it. Otherwise we can't add new events in one spot later on. This might be a good place to talk about what that system should look like.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) polygone
Reply #2 Posted on: December 06, 2012, 02:24:03 pm

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
It was updating instance locals not globals. Also the path updates I put there (which are local as well).
« Last Edit: December 06, 2012, 02:26:24 pm by Red » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) Josh @ Dreamland
Reply #3 Posted on: December 06, 2012, 02:24:18 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
Whatever.

Point is, it needs restructuring so IDs don't need supplied. And while we're at it, we may as well make LGM use the file, too.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) polygone
Reply #4 Posted on: December 06, 2012, 02:25:53 pm

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
I suggested ages ago having LGM use the file. And having instances be able to call separate event files.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) forthevin
Reply #5 Posted on: December 06, 2012, 02:45:21 pm

Contributor
Joined: Jun 2012
Posts: 167

View Profile
Cool, I will keep the current implementation. There is one other thing that I would like to implement before pushing to master, namely including built-in sprites for the particle systems.

In regards to events and formats, I see both a localsweep event and several calls between events to [snip]enigma::update_globals();[/snip] in IDE_EDIT_events.h.
Logged
Offline (Male) Josh @ Dreamland
Reply #6 Posted on: December 06, 2012, 02:45:24 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
@polygone: And Ism ignored the suggestion, and I didn't push the issue. Now we have two update hacks in that file, and as ENIGMA grows, we're bound to have more legitimate events as well. Having instances use different files is by far more work for Ism in the UI than it is for me.

@forthevin: The built-in sprites sound to me like the kinds of things that can be generated with simple math functions, which beats the shit out of any compression format we'd use.

And yes. It inserts the global updater itself. Polygone hacked in the local updater the same way you did.

Also, forthevin: Are you sure you need that "default" code? Does it just not insert the event without it?
« Last Edit: December 06, 2012, 02:50:44 pm by Blue » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) polygone
Reply #7 Posted on: December 06, 2012, 03:03:13 pm

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
Yes it's work for Ism but I consider it as a decent benefit for ENIGMA. You see so many games that use hundreds of wall instances that do nothing, being able to just switch them to use the localess res file would be an easy way for people to be able to increase efficiency.
« Last Edit: December 06, 2012, 03:04:57 pm by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) forthevin
Reply #8 Posted on: December 06, 2012, 04:48:22 pm

Contributor
Joined: Jun 2012
Posts: 167

View Profile
I hadn't thought about generating the sprites. I have taken a look at the sprites, and I think that good approximations can be generated for each of them.

Regarding "default", it did indeed not insert the event without it.
Logged
Offline (Male) Josh @ Dreamland
Reply #9 Posted on: December 06, 2012, 07:59:18 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
All right, I'll see about adding a "mode: static" setting that just puts a piece of code or function call in the event function instead of the loop. Do we want to keep "instead" for it, or just make it "code:" or something? I'm happy with leaving it "instead: ", but I'm open to input on the matter.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) forthevin
Reply #10 Posted on: December 06, 2012, 08:13:51 pm

Contributor
Joined: Jun 2012
Posts: 167

View Profile
If there is no difference in work required, I would prefer "Code", but "Instead" is fine as well.
Logged
Pages: 1
  Print