Serial Link Commit 12: 15th March 2019

Hanging in the air…

Looks like everything is falling but it isn’t!

I am very, very happy with this session. There are two reasons to that. The first is that the feature, which I will talk about in a second is just really cool. The second is that its a solid example of the learning that I have doing about programming patterns at play. I have a SMART goal about learning about design patterns that you can see here.

The observer pattern

One of the most useful patterns that I have learned about is this observer pattern. When I first started learning Unreal and the blueprint scripting system I could not get my head around event dispatchers (or interfaces for that matter, both I am using prolifically now though I’m pleased to say). Well, it turns out that event dispatchers enabled me to use the observer pattern before I knew that was what it was called. So in short this pattern is based on one object registering with another so that upon some being evaluated or some event being triggered, that actor can let the registered actor know ‘something’ has gone on. That something could be anything, a boss has been defeated, the player is at a certain location or, and in my case, the game is in coming out of slow motion. Anyone not familiar with event dispatchers, read on and I will tell you how I am using them in the logic too.

How I have implemented it

I have implemented this feature on a few things now, although I think in this commit its only the Soldiers, but I am catching up a touch with the journal. Soldiers, weapons, the explosive mine and bullet casings. I am going to talk about and show how I did the bullet cases. The first problem is that every single time a bullet case is spawned (sorry Jamie, I will pool them I promise) it, as the bullet case actor, needs to know if it should hang in the air or just fall as normal. Here is the logic from the shell casing actor that happens as soon as the little blighter is born:

The first part of making that happen to ask the game state if slow motion is active. This is a bool that I keep updated from the Slow Motion component that I created a while back to handle all of the time dilation. If the game is in normal time, nothing happens. However, if it is in slow motion, then the first thing (and this is the observer pattern at play) is that the shell casing registers itself with an event dispatcher in the Serial Link Game State using that Bind Event To node. From there I created a custom event that would fire when the event dispatcher fires. You can see I called it Drop Shell Casings.

This is the event dispatcher set up in the game state:

The one that we are registered with is the one that will be called when the game comes out of slow motion. Each actor that has been ‘bound’ to that event will get a call from the game state at the right time to say ‘hey, that thing you were listening for? Its just happened’. So, when its fired, my custom event will fire and the shell casing will be updated. When that happens, I am unbinding from the event as that particular shell casing never needs to know about the state of the slow motion again.

What I am using it for

This is quite simple really. I am only using this set up to determine what the values for linear and angular damping should be at the time that the shell casing is created and then I am using the observer pattern so that the shell casing can be updated with the normal values for those fields if needed. Very high numbers for those two properties lead to the effect of the air feeling like tar to those actors.

What I intend to do with it

I think that one of the best ideas I have had with this but have not had the chance to try out is linking it up with the combat teleport feature for the player. I would really like a simple way to have the player just hang in the air when teleporting so that should he teleport over a group of enemies, its not gravity that brings him down but choice or running out of power for that ability. I think that being able to hover in the air like that would lead to some really cool and satisfying combat scenes in which the player could teleport up, take out some guys, teleport back to the floor and carry on. I think that I would start with playing around with the player capsule as I am not sure that the updating the damping settings on the mesh would work because the mesh is under the hand of the animation system at that point. I would also try disabling gravity for some period of time if it if confirmed that the player is in the air although that could lead to the character being affected by other forces like radial explosions…

Commit

  • Used the logic that controls whether the ‘body hitting the floor’ foley gets played to limit how many times the blood decal can draw. Its hacky but its works well enough for now
  • Updated the damping on the gore pieces so that they dont roll around so much.
  • Stumbled across something very cool. Its a work around for having physics bodies look like they are in slow motion when they are not.
  • Updated Ragdoll character event with the ability to set the linear damping and the angular damping to a very high value, this makes the air feel like tar to the skeletal mesh.
  • Bound to an event dispatcher in the slow motion component so that the ‘ragdoll character’ event can be notified when the player is out of slow motion, then, the normal values for the damping are re-instated. This makes the characters who were trapped in the tar effect, fall to the ground as normal.
  • Updated the explosive mine so that if it goes off when slow motion is being used, the victims hang in the air.
  • Updated the Inferno-mine so that if it goes of when time dilation is active, the victims hang in the air.
  • Updated the Fling ability so that if slow motion is enabled when the body hits the wall, the victim goes into ‘tar mode’ so that it hangs there until the slow motion. They are returned to normal when the time dilation goes back to normal
  • Casings for the SMG now hang in the air in slow mo!!! When time comes back to normal they all drop to the floor at the same time and it looks epic.
  • Also noticed that the bullets casings can be moved in the air with the gun, as that has physics enabled. So the player can tap the shell casings as they hang in the air!

Learning C++

This is the fine course that I have been following. More on that here

This is a very sensible post containing very sensible information about a very sensible topic. But, and this the fun bit, that sensible skill of coding in a language like C++ can be high-jacked and used to create monstrous abominations of grown up games! A bit like the one I have been banging on about on the journal for a while now…

The problem that I face at the moment is that I’m not a real live boy. I am the Pinocchio of game development, wooden, due to the fact that the only tool I know how to use in any depth is Unreal’s Blueprint visual scripting system. A fantastic and very elegant, powerful way to make complex stuff, but, ultimately too specific to the Unreal engine and therefor by definition, not transferable. There is also the other problem of Epic’s code hobbit running off down the narrow, dank and dim dungeon corridor clutching a whole host of advanced engine features in its grubby, slimy little digits. His little raspy voice can be heard echoing back toward this wooden boy and it says ‘You’ll never get these extra features, like the adventurers before you, you will perish as the hand of the Compiler!’. First off, who is this Compiler and second, I’m ready! You hear me you little slippery hermit? I’m ready!

On a more serious note, one of my SMART goals is to learn C++ and so I thought I would talk a little about how I am going about that and how I am finding it.

The Course and the teacher

This is Frank. He’s a real good teacher.

The course is laid out in a real ‘lets start at the beginning’ format. Perfect for someone like me that knows a bit, but could really do with starting again and filling in all those little things that I kinda know, but don’t really. That turned out to be a LOT of things. The course covers:

  • Introduction
  • Installation and Setup
  • Curriculum Overview
  • Getting Started
  • Structure of a C++ Program
  • Variables and Constants
  • Arrays and Vectors
  • Statements and Operators
  • Controlling Program Flow
  • Characters and Strings
  • Functions
  • Pointer and References
  • OOP – Classes and Objects
  • Operator Overloading
  • Inheritance
  • Polymorphism
  • Smart Pointers
  • Exception Handling
  • I/O and Streams
  • The Standard Template Library (STL)
  • Bonus Material and Source Code

You can see from the list above that it is structured well and covers all of the topics that I would need to learn about in order to take my learning further and make a career writing this stuff. I can also say that Frank is a very good presenter, calm, knows the material well (I know thats expected but not all Udemy courses can boast this), and above all, he is available to the students. I have reached out a couple of times now and got the help that I needed.

So where am I?

I have been following the course for a while now and I can write basic programs and use functions, classes and statics. I have been using the STL a little, and I understand vectors and the benefit of using them over arrays. I am comfortable writing slightly larger programs, that I already know are actually very small programs! I can make little games and have completed many of the challenges that the course has set. I also have a good understanding of classes and the various constructors including the copy and move variety. I do need to refresh myself of some things as I go along but for the main() (little joke there…) I am doing fine and progressing well.

What I struggle with

I have found pointers a little difficult to use. Use, not understand. I think that once you understand the whole memory allocation thing in enough detail to at least know that memory is divided into addressable cells and that you can access and otherwise use that address just like the information that is stored at a location, then you get it. But, sometimes, its just a bit painful to try to visualise exactly what you want to do with the bloody thing and getting the syntax to match that.

Are you done yet?

Short answer? Ha! Like I ever give those! No, I’m not finished. I have got to the section about operator overloading and I am really enjoying learned about that as it feels kind of ‘advanced’ and for me, it is. I like to feel that I always just a little outside my comfort zone and that I am learning something that is just a touch out of reach. Then, suddenly, it clicks and I have grabbed it! Time for something new… I think that I will have this course completed in the next 3 or 4 weeks considering the other commitments that I have at the moment.

And after this?

Well, ‘after this’ is not really the way I would say it because the answer to that is C++ in Unreal but I am already looking at that now. So I think that what will happen is that I finish this course so that I learn enough just about C++ and then the time that is allocated to that (about 7 hours per week) will then be rolled up in the time that I spend currently on the Unreal flavour of C++ (also about 7 hours a week) bringing the total to 15 hours per week. Love a good ‘off by one’ error. Little array joke there to end on.

if(PostFinished)

break;

Serial Link Commit 11: 15th March 2018

Lets talk about blood, baby, lets talk about you and me…

Trace channels

This commit was a good one. I learned a ton and I was also able to notice that I think about this stuff more clearly now. I really enjoy recognising that my skill level has moved on, its very satisfying. I talk about it because its one of the pleasures of being involved in something like game development, where the pit of available skills to learn is so deep that you could just go on forever. Sometimes, I think its very rewarding and motivating to tackle some problem that you tackled a while ago and find that your tool kit has grown in the mean time. Thats what happened to me in this development session. The main issue that I was solving was that the line traces that were being used to work out where the blood decals should go were returning hits from and ever increasing array of things that I had to declare as ‘actors to ignore’. Weapons, gore pieces, other soldiers, it was a right mess really. Then, upon coming back to this issue for the first time in a while my first thought was ‘I should set up a custom trace channel that everything blocks be default called something like ‘Valid Blood Surface’ then I could just go round the project setting what should not return anything in that trace to ignore’.

Well, thats what I did.

Yep, custom trace channel. Hardcore.
Tracing for the brand new trace channel. Can I get a ‘Hell Yeah’!?

Now, there were quite a lot of actors to go through an set that they and some of their components ignore this channel but thats only because its late to the party. From here on, when I create something new, I can set it to what ever I need. Very pleased with that.

Tracking the head location

Tracking the head…

The next issue that I had was that because I had been using the ‘head’ bone as the starting location of a 360 degree ‘what should I draw blood on’ test, if the poor fella that the test was coming from found that his head had been smashed into a wall in that frame, the return from that process was less than desirable. It looked as if all the decals had been draw at various rotation from exactly the location in the world that the head had been at the time. Then, there was a kind of ‘slicing’ effect that was happening and I needed to sort it out.

So, I decided to track the heads position every so often so that I could use it as a location delta (I hope that my terminology is right there). Then I could decide whether or not to carry out the scan from the head location or the location delta I had tracked. I decided to always use the delta (I think, I am writing the retrospectively). This worked the vast majority of the time. I was using the last know head location and the current head location to create a unit vector that could be used as the direction that the trace would go. This lead to the blood always being in about the right place. But…

… It turned out that I could have saved my self all of that work as I decided to play with doing things a different way instead and that worked out much better.

Setting up gore to work with hit events

So, having thrown all that work away (thats not quite how it happened but I like a little drama), I did this instead…

I know that Jamie’s toes just curled a little at the sight of the ‘Spawn Decal At Location’ node and he’s right. I shall refactor sir, I promise.

Well this lovely bit of logic caused this mess…

This looked much more natural and the gore seemed like it was in the right place although a touch over the top

I am tracking the gore pieces velocity when the hit event is thrown as in earlier testing they just painted the scene red, leaving decal’s at every single location that they came into contact with regardless of how brief that contact was. Tracking the velocity really helped with that. I also intend to link the size of the decal to the velocity, seeing as that value is already being tracked for the gating side of things.

There are some other things that need to change with this though. I am only using one sample of blood and I would also like to be able to turn the blood and think about some ways that I could make it fall in a more realistic pattern. Anyway, for now that takes care of the gore pieces and stops most of the slicing effect that I was getting. Onto the bodies them selves.

Soldiers causing blood on hit event

I tried to implement this approach immediately on the soldiers but had a bit of a problem. I didn’t know that hit event had to be enabled from the physics asset and so spent plenty of time trying to get ‘I’ve been hit’ printing out from the hit event on the skeletal mesh from the soldier actor, silly boy. Anyway, this was the problem…

Can you see the little checkbox…
… and this is the logic it runs on at the moment. Pretend that the ‘Bleeding Component’ isn’t there though, that came in a later commit! This is this like the time line in Pulp Fiction.

In an effort to not have a million decals in the level thanks to all the hit events and the fact that testing only for the velocity would still put blood on top of blood, I needed another way to control the ‘flow’ a little more. I can up with the idea of tracking the last location that there was blood drawn and then not allowing anymore unless the requested location of the new blood was at least x amount of units away. That worked quite well and was not too jarring, but I think there might be a better way that I will talk about when I try it out.

Commit

  • Added a custom trace channel called ValidBloodSurface. Now when the line traces go out to find places to draw blood, they are only looking for this. That has stopped most of the blood decal slicing effects we were getting. Changed multiple actors and component responses to allow this to work.
  • Have solved the blood decal slicing issue by tracking the head bone location every so often, line tracing from that to the actual head location while looking for surfaces that block the ‘valid blood surface’ channel set up earlier. Then, step back 50 units from the surface normal and start the actual blood splatter tracing event. Seems to have solved all the slicing problems.
  • Changed how the head position is tracked so that we are not polling for it. When the player uses the push attack, the current head location is passed to the victim soldiers for use in the blood events.
  • Updated the blood events so that it can still be triggered using the head bone without first having provided its snapshot location so that the line trace can run.
  • Changed all the components collision settings in the Base Mine class so that they ignore the ‘blood surfaces’ channel too.
  • Made a separate event for spawning gore and blood for the explosive mine as there was a problem with deciding whether or not to track the current head location.
  • Fixed a problem with the math for the blood gen location vector. Works properly now.
  • Added functionality so that the gore that is generated can leave its own blood impact decals. Need to balance this, as its too easy to just paint the whole level red!
  • Added functionality to allow the soldier to draw blood when he hits a surface hard enough.
  • Work is still needed in the new approach to blood and gore but I think that general approach of creating decals on hit events looks more natural.

Serial Link Commit 10: 15th March 2019

Decaltastic! COME ON GRAMMERLY, IM RIGHT HERE!

There isn’t really much to say other than the mighty Kanban board now says that its time to work on the gore again… Mwahahaha! I intend to centralise the gore into an actor or an actor component so that I can bolt it onto anything and have is bleed or produce gore. So, I would like to able to add it to say, a robot who’s version of blood would be globulous black liquid and who’s gore would be metal shards and sparking circuits. Im sure we will see how that goes in the next posts…

Commit

  • Fixed the blood decals not showing up when only in indirect lighting.
  • Enabled the features in project settings
  • Changed all the blood decals translucency settings
  • Updated the translucency settings on the bullet holes decal so that they now show up under static lighting like the blood.
  • Changed the ‘screen fade size’ when bullet decals are created to 0 so that they dont fade away when you walk away from them. It would be better to have this set to something like 20 meters, but the only value that does anything is 0 and that means that they dont fade out at all…
  • Added a fade to the bullet hole decals to clean them up after about a minute – Added a fade to the blood decals to clean them up after about a minute

Serial Link Commit 9: 14th March 2019

Is that a pistol in your pocket… ?

There is not too much to report in this commit, just some bug fixes and some balancing really. At the time development I was on the task ‘Weapon Basics’ and the last part of that running through the Kanban board was to balance the weapons and make sure that they were distinct from one another. I do like the way that the Kanban board has kept me totally focused on making sure that the weapon features are all finished (at least to a certain standard) before moving onto the next major task which is ‘Gore’. The ‘Weapon Basics’ tasks broke down into lots of sub tasks including…

  • Having weapon clatter when dropped
  • Being able to collect ammo
  • Being able to exchange your weapon with one on the floor or on a body
  • Being able to hold an extra weapon
  • Tying up the levelling component so that improvements and skill gains were shown on the screen via some messaging system
  • Implementing Gaussian randomness to the bullet spread
  • Implementing the grip change from rifle to pistol in the animation BP
  • Balance SMG
  • Balance Assault Rifle
  • Balance Pistol
  • Implement UI for all features above

This links in with the Agile methodology well as by focusing on just the weapons they are now a complete feature and it feels right to move onto something else.

Commit

  • Fixed bug where the weapons would not show the right ammo pool count because another weapon had altered it. Now shows the right count when the weapon is drawn.
  • Changed the psychic push so that it no longer works on dead people, it was getting in the way of the ammo and weapon collection stuff and felt odd.
  • Changed the direction of the shell casings from the pistol as they were working on the world direction and not the sockets.
  • Decreased the rate of fire on the Assault rifle as the weapons need to be more different –
  • Decreased the ammo in the clip for the Assault rifle to 20 as its strength is that its more accurate than the SMG
  • Set the spread range for the Assault rifle to -5 and 5 – Set the spread range for the SMG to -10 and 10
  • Created PistolProjectile for use with the pistol as it was using the SMG ammo which made it difficult to change the damage that it was doing.
  • Made the Pistol slow but causing a large amount of damage, 80 pts
  • AI now switches between the SMG, Assault rifle and the Pistol.
  • Added new fire sound for the pistol to make it stand out from the other weapons

Serial Link Commit 7 – 8: 14th March 2018

Shell casings now spin. They SPIN I TELL YOU!

This development session focused on having the bullet spread feature that was already built in, represented to the player via a pretty standard (but first for me) dynamic reticle. From there I wanted the shell casings to be a little more noticeable so I updated the orientation of the ‘ejector’ socket on each of them and added a little torque to the casing as it came out. I made sure that the player gets a much better look at the casings as the come up and out of the weapon and it worked really well.

This is how the reticle ‘heats’ and expands
This is how it ‘cools’ and shrinks again.

There is information coming from the players Levelling Component (yes you can level up in this game) so that allows the users skill with that weapon to be represented by the growing and shrinking of the reticle. Pretty cool.

Commit

  • Now have the dynamic reticle expanding with the bullet spread and it feels right.
  • The reticle shrinks properly now too.
  • Fixed the problem with the pistol animation although I am still not satisfied that the weapon feels good to use.
  • Changed the position of the main player cam so that the weapon is more prominent.
  • Changed the location of the ammo counter UI so that it can still be seen on the SMG with the new camera position
  • Changed the near plane clipping from 10 to 1 in the main project settings
  • The pistol has been changed to 1.4 in scale and looks much better
  • Added torque to the shell casings in the pistol
  • Added torque to the shell casings in the SMG and changed the location of the ejector socket on the mesh for a more dramatic feel to the shooting
  • Added torque to the shell casings in the Assault Rifle and changed the location and rotation of the socket that spawns them

Serial Link Commit 6: 13th March 2019

I know its too small but hey. You will have to take my word that its a line trace on tick looking for UI elements on things in the world.

I am pleased with how the information panel on the right of the UI works. I am trying hard to step back from things being too specific and I am trying to make things as abstract and flexible as I can. Sometimes it works and sometimes it doesn’t but this time it was a success! So the logic above it always looking actors with the interface ‘IsContextSensitiveUIElement’ and then should it find one it throws the message ‘ShowUI’ I wont give a detailed explanation of all the little things that stop it breaking, just the overview. Questions? Tough. I mean, ask.

The part I want to talk about though is that UI Info panel that appears to tell the player the options about how to interact with the thing that he is looking at.

This is the tail end of the event implemented for the interface I talked about earlier.

I like this as there is no casting and should the player character change for any reason it would still work. Also by passing in an array of UI elements, its easy to change what is displayed from different actors that implement the interface. I know that there is no multiplayer option to be built so I know that the player is going to be player zero so I think that accessing them in this way is fine considering the project. On the Controller side…

On Dex’s Controller. Dex is the main character that the player is using.
The widgets are added to the UIInfoPanel widget and we can have a quick look at that too in the designer…
That little tiny box there? Thats the vertical box that expands and shrinks as needed. Pretty cool.

Commit

  • Updated the look of the ‘collect ammo’ and the ‘out of ammo’ UI widgets.
  • Updated the ‘out of ammo’ to say ’empty’ instead
  • Found out that I cannot use an emissive in the UI without sorting some other things out. This is to do with the order that Unreal draws and applies post processing.
  • Added and UI info panel to the main HUD.
  • Making sure that the UI info panel is spawning its widgets and organising them so that I am free to add what I need in the future.
  • The info panel is now to the right of the cross hair although I would like to have it in the bottom right corner, I didn’t work out how to have the vertical boxed position change to accommodate its children.
  • Can pass an array of UI elements to the info panel now and they are removed when the player looks away from the weapon.
  • Added ammo pool and ammo clip UI widgets to the base weapon class
  • Created widget assets for those components
  • Now have ammo in clip displayed on all weapons in the calculator font. Looks cool!
  • Ammo status UI to change from ‘collect ammo’ to ’empty’ when the ammo is collected by the player is still looking at the weapon. Competed
  • Make sure that only the players currently equipped weapon shows the UI for ammo. Complete
  • Made the UI on the assault rifle a bit smaller.
  • Added the ammo pool from the weapon component to the ammo in the clip counter so that it can be shown on the weapon too. Looks really good.

Serial Link Commit 5: 13 March 2019

Holding an extra weapon. Kinda greedy really.

This development session focused on making sure that the player knew that they had picked up an extra or opportunistic weapon. I always liked the idea that you could have a full complement of weapons and just pick up another as all of yours were slung. In our case the Weapon Component that I created defines the ability to carry 3 weapons and an extra in your hands. The characters all have a primary, close quarters, weapon on the chest, then a secondary, assault rifle style, weapon on the back. Finally, they all have a side arm on the leg. The player can pick up the extra weapon but I would like to see that on the AI too. As all the characters are using the same Weapon Component, that should not really be difficult to set up.

Commit

  • Set up a ‘Holding Extra Weapon’ UI element in the main HUD – Used an event dispatcher from the Weapon Comp and bound to it in Dex Controller. Thats used to call an event on the ‘Main HUD’ variable on the Soldier. The event changes the opacity of the text on the HUD. – Player now takes the ammo thats in the Opportunistic weapon as he drops it. That takes care of the case where you pick up a gun, fill it with ammo, drop it and either lose that ammo or have to re-collect it. Works well.
  • Imported a font called Calculator from dafont.com and used it for the ‘holding extra weapon message

Serial Link Commit 1 – 4: 11TH March 2019

Really? I just cleaned this place up!

I wanted to start posting more frequently about the development work that is going into Serial Link as that is where I am putting the lessons I am learning into practice. The first of course if that of version control. I have talked already about the project copying that I thought was version control and I suppose to a certain extent it is, but its cumbersome and stinks of amateur hour (as do a lot of the things I do at the moment, but thats why Im here).

So the first thing was setting up the repository which was straight forward enough. Then it was the LFS part which I found just a little trickier as it could not be set up in the GUI Git Desktop and had to be done via the Git Bash tool. If I am wrong about that and have missed something, please do let me know. I then, nervously, made the first commit. This. Took. So. Long. I started to get a little worried that all was not well in the land of Serial Link and its visit to version control but after what seemed like an age, the commit was done. I pushed it to the repo on Git and bam, first commit to a remote server. Didn’t I feel proud.

The other reason that I would like to keep the journal up to date with Serial Link is that during one of the webinar’s the conversation turned to the question ‘when should one commit ones work’. So, I thought that posting how I do things here might open that discussion up for me/us/them whoever, and allow me to explore some of the other options regarding when to commit. I have started this process at commit 4 because it did not occur to me to take proper notes until then. I am very pleased that I am taking better notes though as it is making it easier to see just how much is going into making this game!

Commit

Commit notes…

  • Updated the weapon base blueprint so that it can choose whether to show a E: pick up ammo UI element or a red OUT OF AMMO element instead. I solved the problem of hitting the player and the players weapons by creating an array of ignorable actors.
  • I set up an event dispatcher in the weapons component that is triggered every time the weapons array is updated. This keeps that array of actors to ignore up to date for the player without having to recreate the array at each tick.

This commit was focused on the UI I have been implementing so that the player can actually interact with the game space in a more predictable way. The issue I was solving was that the line trace that is looking for things in the world that it can interact with was hitting the weapon instead. This was before I know how to implement custom channels for trace responses so that may have been a better way to do it.

Line tracing out to find things to interact with
After collecting the ammo.

Thats is for that commit. 😉

Git and its Version Control Goodness

I would rather have learned about git from the sky down but hey. Find it here

This talk was recommended to me by one of the fine chaps at the Games Academy, Al, as a way for me to get my feet wet with version control. Well I can report that my feet are indeed wet. The problem I was facing was one that I have spoken about before in that I did not use version control, aside from copying the project file of whatever game I was working on and then working from that copy. The main issue there is memory and it cost me more space than my wife’s shoe collection. No, I don’t know why she like Army boots either, shall we move on? There was also the small issue of perhaps losing a whole days worth of development should I introduce some issue that breaks the whole thing. The best I could do in that case would be to copy the project from the last time I knew it was ‘good’ and work from there. And then, of course, I learned the really hard way (I do that sometimes) and lost my game jam project. Time for some version control. To be honest I don’t know why I didn’t do it earlier as I had been introduced to the concept during a Udemy course I had been following. But I think that I got a little overwhelmed with having the learn C++, version control and Unreal all at the same time. I just dont think I was ready for all of it. Also, and I hate to point the finger but its true, we were not advised to use source control during the BA top up course. I think, now that I have a little more experience that is a mistake and it should be introduced in the first week as it have discovered that it really is an industry standard practice.

So I have a SMART goal for this that I have talked about recently so I wont go into that here and this talk is sort of outside of that really but I really like to know how things work behind the scenes and I know that I will feel more comfortable using git in particular if I understand the how and why and little bit better. The rest of this post is very much straight from the presenters mouth and I am not passing this off as my own work unless its worth a ton of marks then yeah, all me. I was just trying to keep up with her and document my own understanding of what she was talking about. It was very interesting and I have learned much about what goes on behind the scenes. Sorry about the bullet style I don’t write straight to the journal, I use WorkFlowy as reordering things is so very easy!

A Little History

  • 1978
  • The Source Code Control System SCCS
    • A delta table
      • A data structure that held deltas between changes in files
    • A set of control and tracking flags
      • Set permissions and release control on specific files
    • A set of control records
      • Keep track of insertions and deletions at the file level
  • 1982
    • Revision Control System RCS
      • This was not distributed and was only used on a single machine
  • 1990
    • Concurrent Version System CVS
      • This worked on the modern client/sever model
      • However this leads to the Merge Conflict and this happens because different developers edit the same file at the same time. This then needs to be resolved. How? CVS enforced the fact that the developer had to pull the most recent commit from the sever in order that they could commit their own work. This essentially stops merge conflicts from happening and from the sound of it, was a first come first serve approach to development changes.
  • 2005
    • Git
      • This is decentralised. You can have multiple ‘first class’ copies of a repository in different places. They also introduced a different way to resolve merge conflicts. You could work on a old version, pull the new version in and reconcile the two versions at that point.
    • Git hub is a separate software to Git

Under the Hood

  • .git directory
    • Objects
      • What is an object?
        • Its a data type that has
          • Type
          • Size
          • Content
        • Objects
          • Blobs
          • Trees
            • A tree is a reference to multiple blobs or multiple trees
          • Commit objects have
            • A reference to a particular tree
            • A Time stamp
            • A committer, the user that made the commit
            • Commit message that goes along with it so that the developer can explain the changes made
          • Annotated tag
            • ‘cut’ a release
            • create a tag
            • contains many of the same details that can be found in the commit object
      • info
      • pack
        • pack .idx
        • pack .pack
        • use command ‘file’ to get more information about them

Using git

Go girl! Got it from here
  • Clone the repository first
  • Create a branch, lets call it the Feature branch
    • Whats in the Head file?
      • The 40 character nonsense that is shows is called a hash
      • You can print out the content of the file that is associated with that hash
  • Staging
    • When you stage a file a new blob object is created that corresponds to that file. A blob is used to represent file data. You can fetch the hash associated with the blob object and print it. When you stage a file or project, you add a new blob object to the .git directory with every file that you have changed
  • Committing
    • When you make a commit the directory name is the first two characters of the hash and the file name the other 38
      • 2 reasons for this
        • Some operating systems place a limit on the number of files that you can have in a directory
        • Because of the way that some operating system search for files, its faster to split the files up over multiple directories.
    • The commit object, because of its connections to other blobs and trees, stores the state of the entire repository in one data structure.
  • Pushing
    • Git has compressed the ‘loose objects’ that were created in the repository into a pack file.
      • The Heuristic that is used to execute the compression is
        • The system goes through the directories and sorts files by type
          • Commit, blob, tree or tag
        • Then they are sorted by name
        • Then sorted by size
          • Because of the fact that files tend to grow over time with additions to the code base and refactoring, ordering by size is a good way to order by recency. You should have the most recent changes at the top of the directory so that the system can figure out the deltas on them.
        • Then the system uses a sliding window to compute the deltas between those adjacent objects. I don’t know why, but this is just really cool.
          • Linus’s Law – as time passes by the size of the file grows
          • If it detects only very small changes, instead of storing both objects, it will store one and a delta to the next
        • I think that they are compressed at this point? The presenter talked about compression and from what I can see this is the most obvious place for it to happen.
        • Then the index file is created that is used to resolve the hash to the file it represents in the compressed pack file via a pointer in the index.
  • Merging
    • Fast forward
      • If the Master branch has not changed then the Feature branch created earlier can just be merged with the Master using a fast forward command, which sets up a pointer in the Master branch to the one you want to merge it with, the Feature branch in our case. The pointer points to the most recent commit object you have.
    • Recursive Merge Strategy
      • You will end up with a merge commit at the head of the new branch
      • After merging you can query the merge commit object and find that it has 2 parents, pointer to the commits that are on the Feature branch and the Master branch it was merged with.
    • Rebase
      • Instead of creating a merge commit, the system reconciles that differences into a single linear history.
    • When you make a merge commit, you maintain the explicit branching which means that the commit has an awareness of the two branches that it came from. When you do a Rebase you favour having a linear history

In Conclusion

Git represents key information as objects stored in the file system.

Git compresses loose objects into pack files to increase space efficiency using delta compression

Rebases and merges differ in whether they give preference to maintaining a linear history or explicit branches