C3 Architect Request list

Discussion and feedback on Construct 2

Post » Sat Mar 07, 2015 12:12 am

jayderyu wrote:@Everade
That's in the documentation as a Prefab, it's the only Unity term used. It's also appropriate as it's the for word for "Prefabrication".


C3 Prefabs? If they added this, I would be incredibly excited! :)

This discussion is amazing, it's hard to believe I haven't noticed it until just now.
Has anyone mentioned adding in an online content browser to the IDE itself? Many engines now do that, and I feel like requesting an adjustment to the core website may be pointless. If we had a content browser where people could upload their custom made projects, prefabs (if they get added to the engine), art, plugins, behaviors, etc. Game designing would be much quicker than normal, and nobody would have to go searching for things within the forums. The could be organized and rated by the C3 users as well, allowing people to find the best of what they need on the fly, instead of going through Google to find it (which I often find myself doing now).

I didn't read the whole forum, or much information about C3, so I'm unsure of whether or not this will be included, so I'm sorry if my post is incredibly naive.
ImageImage
B
49
S
15
G
2
Posts: 270
Reputation: 6,679

Post » Sat Mar 07, 2015 5:01 pm

@jayderyu
@TiAm

Yes I understand that, but that doesn't mean that certain features should be in the ide from the start. Personally don't care how will they be implemented.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
93
S
30
G
22
Posts: 1,987
Reputation: 20,203

Post » Sun Mar 08, 2015 2:33 am

@KTML5
Well that's why I tried to create a focus on the architecture requests. So that such features as IDE connectivity to say web pages, or other online resources could be made. I would love for the Scirra store to be fully integrated into C3. Import assets into a project as needed. Also other aspects would help too. Sublime Text for example has a magnificent plugin resource tool. Where an IDE plugin installs other plugins from a repository. Just fantastic and a pleasure to use. Helps my development a lot when using Sublime Text.

Yes. I would love C3 to have prefabs, they are super awesome.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Sun Mar 08, 2015 5:27 pm

@jayderyu
I really like where this is going. If they make C3 the way that the people want it, it will be unbeatable as far as 2D engines go, that's to say if you don't think like me and believe C2 is already unbeatable. I'm excited for this.
ImageImage
B
49
S
15
G
2
Posts: 270
Reputation: 6,679

Post » Mon Mar 16, 2015 3:33 am

I'd be more than happy to advocate a prefab system if it made picking amongst modular objects with shared behaviour easier, as I've stated earlier in the topic. Prefabs and the parent/child system makes easy changes to individual objects easier in Unity.

Also, the Rewired asset for Unity is a fantastic example of a control system done right.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Fri Apr 03, 2015 3:46 pm

I wrote this as an update to the document draft. However I think this could improve game performance overall going forward.
https://docs.google.com/document/d/1pNR ... ZGe8/edit#
it's better formatted at google docs

Engine Runtime Code execution
Having spent some more time in the main game loop and ways to take advantange of memory, cache optimization for Duff’s Device(below) has led to a different suggestion. The current design of C2 main game loop for objects is

Current Loop
loop through all objects types
loop through instances of Object type
do object pre tick
do update
loop through behaviours
execute behaviour update
do object post tick

This is the actual loop. The loop is repeated twice.
for (i = 0, leni = this.types_by_index.length; i < leni; i++)
{
type = this.types_by_index[i];
if (type.is_family || (!type.behaviors.length && !type.families.length))
continue;
for (j = 0, lenj = type.instances.length; j < lenj; j++)
{
inst = type.instances[j];
for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++)
{
inst.behavior_insts[k].tick();
}
}
}
for (i = 0, leni = this.types_by_index.length; i < leni; i++)
{
type = this.types_by_index[i];
if (type.is_family || (!type.behaviors.length && !type.families.length))
continue; // type doesn't have any behaviors
for (j = 0, lenj = type.instances.length; j < lenj; j++)
{
inst = type.instances[j];
for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++)
{
binst = inst.behavior_insts[k];
if (binst.posttick)
binst.posttick();
}
}
}


In the above loop the loop is jumps into a multi embedded function. because the loop goes down, then back up the system is constantly clearing cache for a new behaviour, then going back to the behaviour for the next instance. There is little opportunity for the JIT to truly optimize cpu cache for both function variable cache, or object function cache.(as related to Duff’s device). As an analogy GPU/WebGL/GPU in general. Part of efficient rendering is to package sprites together on a texture. That way there is less swapping textures, which reduces memory transfer to the gpu cache, less draw calls and overall way better performance. Which C2 already works towards. however the CPU also benefits from caching code, and memory variable(as Duff Device below) significantly.

I propose a loop that the CPU can take advantage of code/behaviour batching which can improve JIT optimization at runtime. Less deep than above, and also offers the awesome feature of priority behaviour control. this of course still works off the basic idea of world object and everything is a behaviour.

Proposed loop


loop through different behaviours
loop through all of the same behaviour on all objects
execute behavior update

How does this work instead.
This loop does not loop through Objects.
This loop does not go through behaviors in an object
This has the behavior at the top, and then manipulates it’s world object

There is a BehaviourList. this list contains a BehaviourInstanceArray. And the array contains a reference to each and every instance of the behavior.

abstract sample below
BList[
Sprite[]
Collision[]
Platform[]
Solid[]
Pin[]
]

When an object is created, the code adds the behavior instance to the array. When the object is destroyed then the behavior is removed from the array. This also means that the CPU can cache the update function and run through them all in one go. Doing so offers the benefit of Duff below. However the system also offers another benefit.

Sort-able behavior execution. The above sample shows Sprite at the top, and Pin at the bottom. however this list can be sorted. Offering control as to what should be executed first to last.

So the loop is

for(int i = 0, int length = blist.length; i < length; i++)
{
var bInstList = blist[ i ];

var n = iterations % 8;
while (n--) {
bInstList[ n ].tick();
}

n = (iterations * 0.125) ^ 0;
while (n--) {
bInstList[ n - 0 ].tick();
bInstList[ n - 1 ].tick();
bInstList[ n - 2 ].tick();
bInstList[ n - 3 ].tick();
bInstList[ n - 4 ].tick();
bInstList[ n - 5 ].tick();
bInstList[ n - 6 ].tick();
bInstList[ n - 7 ].tick();
}
}

So here is the game loop. Takes advantage CPU caching. Far simpler in design. Allows for Behavior execution order. So instead of Object top down, It’s behavior top down. There are probably other optimization techniques that can be applied.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Sat Apr 04, 2015 5:39 am

Wow Jayderyu,
That very thorough explainations about Construct architecture... very informative and very useful, thanks d=(^___^)=b

Your new architecture for Construct is also amazing... so flexible and look like can produce much better and faster performance... i hope Ashley will implement it on Construct 3 :)
B
3
S
1
Posts: 20
Reputation: 357

Post » Sat Apr 04, 2015 5:50 am

No interface lag and correct file association with the steam version would be nice, but since I doubt this problem will be reliably eliminated in C3, an autoupdate feature for C3's non-steam version would be nice.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Apr 04, 2015 8:58 pm

this would not work. - behaviour for loops as described.
let's say you have 5 items with 5 behaviours - that's 25 iterations that have to happen. now let's say that one item is instead using 3 behavs - therefore
23 iterations.
you would have to do 4x5 and 1x3 loop. best way to do this is - foreach object - foreach behaviour in it - update behav. when there's no more behavs 2nd loop stops
and first iterates next. what you're suggesting is that you do behavs globally foreach object, by inserting object into behaviour list. you haven't done really anything else.
you have to do all 5behavs on each 5 items, just vice versa. also calling tick in one while 8-10 times- big no.

what i'd suggest is something better - way better - behviours and plugins should have event listeners for ticking. once tick happens - each object / each behaviour updates globally, therefore no for loops at all. of course this could be pretty hard to achieve because we want some way of updating our objects - we don't want the last object to update first. so i'd do a list of objects - where you call tick over objects - which fires their events for every behaviour. ofc then we have only 1 loop that goes through all the objects ONLY. (instead of 3 loops). still again - do we want all the behaviours / plugins to happen in a particular order or chaotically?


also another suggestions (which i don't know much about) - parallel loops? parallel.for? (c# has it, not sure about JS)

also i've just had an idea - when you click on a function name - it automatically takes you to function definition. (make it clickable in event sheet)
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 626
Reputation: 9,455

Post » Tue Apr 07, 2015 2:08 pm

http://en.wikipedia.org/wiki/Duff's_device
https://jsperf.com/duffs-device

The current loop is
foreach Object, then foreach behaviour.

And it's not the best way. As previously addressed the CPU optimization is similar to a GPU optmization in concept. Handling the same code in scope in chunks allows for better optimization and performance. Running through a ForEach(object) then ForEach(Behaviour) results in the object at the top. So the loop starts with object, then goes to the first behaviour, however since all following behaviours are never the same the CPU never optimizes as well as saying just handling all the same behaviours at once. As for ignoring Duff's device. I would do so in non game programming, but in game engine programming. It's all about finding optimal performance. Games are intensive and there is no reason not to take advantage of any and all coding tricks.

Unless your relying on IRQ, all listeners are still based on loop. An event happens, then the event loops through the listener firing off the event. In this case everything. Which as you point out would be chaotic. Since this would be a chaotic loop that would result in little to no optimization of runtime.

As for parallel loops, this might as well call it threading. In this case that would be done with a webworker. This is doable, but the this comes down to managing effective data transfer between the different threads with no conflict. I would love to see threading implemented in a game loop, but since memory needs to be transfered. I'm not entirely sure if the memory moving would save on time. It could do so in large memory batches.

on a note. I did forget to write that there is a post and pretick loops. Which also again would take advantage to scope cache in a DuffDevice.


I like the idea of clicking on a function. which then take you to the defintion. That's good :)
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests