overall design

overall design

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

overall design

Post by Tobi »

Some notes (guidelines?) about how I think the "overall design" of the engine should be (in relation to my move of some files yesterday):
  • Sim - The core, this should contain the simulation code and hence (most of) the synced code. This should ideally only depend on System. (it now depends on Map and Game and Lua too.) It should not contain rendering code (but still does for projectiles, features...)
  • Game - Connects/wraps the simulation with a GUI, links the GUI to network code, network code to Sim, etc., basically this glues everything together into a single application.
  • System - This is a bit of a mess now IMO but anything that could be stand alone library but is tied to Spring in one way or another seems to live here (e.g. creg, VFS, platform abstractions, network code). Additionally it also contains the program entry point... Apart from this last one System should not depend on other parts of the engine.
  • Map - Map loading & rendering, seems fine as it is, should only depend on System and Rendering code. (it should basically be possible to take this and integrate it into another engine...)
I think I got the most major points, I realize that to actually make current code adhere to this guidelines is bit of an utopy (at least short term), but with this guidelines I want to give some hints as to where new code should go.

Feel free to discuss :-)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: overall design

Post by Argh »

Is rendering going to be finally encapsulated into its own section now, so that that part is no longer wrapped up in sim code? That seems like a key goal that needs to be reached here. For example... interpolation between sim frames could all be done outside of sim (IIRC, it's being done within the unit drawing code, which is sim-dependent, but don't smack me too hard if that's incorrect, it's been ages since I read that source)...
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: overall design

Post by Tobi »

Yes, it would be good if rendering code for features and projectiles was moved out of Sim, but someone has to actually do this. I posted to keep new code from being added in the wrong place, but I don't know if anyone will be motivated to actually refactor this rendering code to another place anytime soon. Would be good if someone did tho...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: overall design

Post by Argh »

Is there anything in particular I could do that would be helpful, in terms of discussion of this? I'm probably not qualified to actually move that code, but I'd be more than willing to dig around and get discussion moving, if it might be helpful in terms of motivation.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: overall design

Post by Kloot »

Tobi wrote:
  • Map - Map loading & rendering, seems fine as it is, should only depend on System and Rendering code. (it should basically be possible to take this and integrate it into another engine...)
Indeed it is:
SSB.png
(528 KiB) Downloaded 93 times
SD.png
(419.32 KiB) Downloaded 82 times
(pathfinding + rendering experiment, quite unfinished ;))
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: overall design

Post by AF »

Perhaps more emphasis on decoupling GUI should be in place considering the variable nature it would have in completed games when taking into account work such as gundams new GUI and that shown in P.U.R.E and other content.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: overall design

Post by lurker »

How do you remove Sim's dependence on Lua?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: overall design

Post by Tobi »

Tobi wrote:ideally
In other words, I don't think we will :-)
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: overall design

Post by zerver »

Tobi wrote:Yes, it would be good if rendering code for features and projectiles was moved out of Sim, but someone has to actually do this. I posted to keep new code from being added in the wrong place, but I don't know if anyone will be motivated to actually refactor this rendering code to another place anytime soon. Would be good if someone did tho...
No GL calls are made from Sim anymore - I have verified that.
Do you mean the rendering should be moved to separate classes, like UnitDrawer?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: overall design

Post by Argh »

No GL calls are made from Sim anymore - I have verified that.
That's awesome :-)
Do you mean the rendering should be moved to separate classes, like UnitDrawer?
Well, my initial thought is that yes, it needs to be the way, to allow for several major things to be solved, such as TBN support and new model formats via new cases.

The way I see it... there should be a flow something like this (just brainstorming, obviously):

Sync sim behavior (what is happening from now until the next frame?) -->

1. Render world, base texture and self-shadow. Keep world mesh for deferred operations later, keep shadowmap -->

2. Unsync interpolation behavior (what are we doing with this Unit / Feature / CEG / Projectile from now until the next frame?) -->

3. Case modelType (what model / animation format am I?) -->

4. Mesh operations (what am I doing with my meshes?) -->

5. Resulting mesh (where are all my vertexes, in worldspace?) -->

6. If we need to do TBN per triangle, do it now -->

7. Render resulting mesh, using a shader defined by the Unit / Feature / CEG / Projectile, or the current code, which should be considered fallback / legacy from here on out.

We should be moving towards handling all of these things pretty much identically, they're all just meshes in the end, after all, and should be treated a such at this point in the rendering operations.

9. Once all visible meshes are available, perform any deferred operations (lighting, shadows, reflections, etc.).

10. Perform deferred operations on world. Keeping the world-mesh result, we can do per-facet lighting, etc. with decent speed.

11. Render any Units currently being called for via Lua gl.Unit callout (special effects, etc.).

12. Render any other Lua elements here.

13. Render Screen elements (mainly GUI stuff here), in strict layer order (DrawScreenEffects and DrawScreen would just become DrawScreen, but the layer would determine order of operation when it's time to draw).

At that point, everything's straightened out, ideally, I think. Spring sync would no longer control mesh operations very strictly- it would simply say, "X has happened", and it would be up to the unsynced side to interpret X and act accordingly.

That framework's already there, I'm just saying that I think it should be modularized, and treated in a cleaner way- past the point of mesh interpolation, what we have is nothing more than a collection of meshes in worldspace. They should get treated that way.

Sync operations --> model type --> interpolation and mesh creation --> shader (or old fallback, for legacy support) --> draw

Lastly, with this in play, it would be almost trivial to let Lua load arbitrary meshes during Initialize() and store the resulting display lists for use later, which would greatly help on the production side (it's way easier to design a special effect if you can build the mesh and uvmap it in a traditional modeling application than to code it by hand).
Post Reply

Return to “Engine”