Transcript for:
Physics Engines Overview

all right so uh i just finished talking a little bit about physics engines and what they are and some of the basics of the kinds of calculations they have to do so uh in this one i want to talk a little bit about how things get a bit more complicated uh just a tad so one of the difficulties um is one of the first things you have to deal with is what's called rigid body calculations which is some of what we looked at before so this is going to be blocks spheres cubes those kinds of things and how they move and how they articulate um and so a lot of what you'll see will be these things called um ragdoll um engines and so they're called ragdoll engines because ultimately they look a little bit like what you would expect a rag doll to look like so a lot of times this is very limp kind of figure and it just kind of you can just kind of toss it around and it just kind of there's these like body parts in this case i'm flexing at my wrist joint right but if i throw my arm over here then my wrist goes this way and if i throw it this way the wrist goes this way and so you kind of got these like ragdoll mechanics what happens when a body goes limp or if you drop a body to the ground or something like that and so those are the kinds of things where they usually take body parts as just blocks blocks that are kind of connected by a string almost so my wrist is acting just like a like a block that is attached to my arm and it just kind of flip-flops back and forth uh there's not a lot of like actual fine motor you know control or those kinds of things in this kind of a physics engine it's just kind of a all right it just goes this way or that way so once you have that then you have to deal with like really really hard stuff is soft body physics engines so these are making objects have squishiness so if you just treat my hands as hard blocks right so if i i push on this nothing happens it's just it's just a kind of a block but in reality right you know that with my hand let's see if i can like there's there's gif look at that uh it's not it's not a solid piece of wood or something like that it squishes a little bit or you know with my clothes right they they wrinkle uh these are soft bodies it's not just kind of like i'm a i'm a square rectangle uh hair is a big one right uh hair is not just kind of fixed to your head well it moves if there's wind or clothing or those kind those are really hard dynamics to try to figure out what's going on then you have to deal with collision dynamics so what happens when two objects hit each other right so if they are hard objects like blocks they're going to you know angle of incidence angle of reflection kind of thing they're going to bounce right but if you're talking about soft body mechanics now you've got give and like you know compression and moving around and those kinds of things how do you know if two objects do collide and what happens with them two spheres colliding is probably the easiest thing to do right and so the reason for that is that you can just calculate a collision based on where the center of the square the circle is and its radius and anytime two circles get within those radius you know they are hitting each other and they are the same shape and size and everything like that but you can imagine a circle and a square are actually a little bit different you can't just calculate the distance from the center of the square to the outside because that distance changes right depending on whether or not you're going to one of the surfaces or if you're going to a corner the distance to the corner is actually different so it's a different set of equations that are slightly more complicated so then with the sphere as well right you don't have to worry about it turning a sphere if i turn a sphere it's still the same no matter which direction i turn it right as opposed to something like a square which is going to rotate differently and then all this if you throw in three dimensions it just all goes haywire it just all goes crazy so here is a really simple demonstration of different levels you can see here level one level two level three level four of physics engine calculations uh so level one is the simplest in which case there's really no physics engine right so there's no physics engine then nothing happens there are no forces that are acting on the object in the first place so the object just kind of stays put right which is what you see here right so now the second level is uh we add in we add in gravity so let's go back here so let's look here at object number two so we add in gravity so now this object falls and it's going to fall at an increasing speed we talked about falling bodies we talked about falling objects in the last lecture and so there's a force of gravity that is acting on that object but you'll notice that with that object it just fell right through this board because there's no collision detector so that's what happens in level three we add a collision detector so now we know when this object hits another object and so once it hits this object it's going to stop and because this object the gravity is still going to act on it because it's a decline plane it's going to slide down this plane but that's not how real objects act they don't just kind of slide down in the fourth level we add rotation so this object hits it slides but now it's also rotating and you see that little bounce too which is based on the rotation right when it falls flat it causes a little bit of a bounce so these are all different levels of physics engines that are all doing like much uh they're adding levels of sophistication basically to to these calculations uh so all right so how is this all done so in a computer you have what's called a typically a gpu or a graphics processing unit and so this is a piece of equipment inside your computer that's designed its purpose is to do a lot of these equations and a lot of these solving things for you uh and so you can buy these things high-end ones uh so like the uh oh i'm blanking on it uh the the g-force rtx things these can run you thousands of dollars though that are literally thousands of dollars two to three thousand dollars for a really high-end one um most most people you can get along you can play most games just fine without a really super high-end graphics card or gpu some of the common common uh versions of gpus that all have different strengths and weaknesses are here you've probably never heard of these because for most of you don't care about it as long as the game plays you don't care how it's getting its work done but this is how it's getting its work done so i want to look at a couple of examples two two simple examples of these the first is a fairly simple rendering of a rube goldberg machine and you're going to notice a couple of different mechanics that are in play here that i just talked about in terms of those kinds of things so let me change this so um you can actually see the whole thing there we go and all right so here we got a system you can see it's very blocky in general lots of hard angles hard edges and we've got a sphere so now remember spheres are some of the simplest objects because even when they roll or rotate they're still the same so what have we got here we've got collision detection so it's rolling down a ramp and we've got gravity in play so it's rolling down the ramp look at that this i went backwards these these little things here are going to demonstrate to you ragdoll articulation so let me see if i can pause it here right time so it's going to hit this block and there you can see here's a block on the end of a string and you can see those individual units those individual units kind of articulating so again spheres very easy dropping ramping collision and we're setting off this thing here ragdoll mechanics on this this like chain here there you go those are those are the ragdoll mechanics i'm talking about that floppiness of this whole thing so you're already you're looking at a couple of the simple levels of physics engine stuff very simple collisions you're basically talking about a collision with a single object per frame or something like that you've got very simple angles uh in your you're you're using basically the simplest object most of the time the sphere is moving around and yet you're able to create in this case a fairly nice uh rube goldberg machine that sets off a tray bruschett okay so you can already see like all right there's a lot that's a lot going on here so let's look at this is a very simple thing very simple graphic very simple physics engine so let's look at a more complicated version right so i'm going to show you now this is uh an example of unreal engines uh physics engine and so they've got before let me um go back so you can see before i show this real quickly this there's some extraneous commentary that's supposed to be funny and to kind of take you through this whole thing or whatever but what i want you to focus on is thinking about think about all the physics engine decisions that have to be made and this whole video although it's supposed to be funny and enjoyable and whatever but really the purpose of the video is to show show off the physics engine and you're going to see that particularly with respect to collision detection and calculation and so in this case um you're you've got a robot that's chasing around some other robots and a city and you're shooting a lot of buildings and blowing stuff up blowing stuff up is really hard because you've got all these little pieces and you have to know where they go what kind of pieces you're generating what speed are they going what direction are they going how do they interact with everything else so you're taking what was in that first rube goldberg machine a single a single collision right the ball hits some sort of switch and now you're having an explosion which is tons and tons of pieces and tons of tons of collisions that are all happening at the same time so think about that and as you watch this um in particular so there's there's hopefully the audio comes through and i'll have to pause it if i want to actually say anything but i'll let it run for a little bit here breaking news robo-resistance leader chaos has broken into a robo-ready research secret military already you can notice right we're not looking at very simple ragdoll articulations there's a smoothness to the movements here right it's not just a simple ball and string kind of thing so they've added all kinds of extra bits and pieces in order to get the smoothness in these movements okay agent 38 it's renegade recall time and dangerous time to take these chain guns for a spin all right so again there's a story or you're after this little guy but again focus on collision detection here and what are we really showing off with this are these guys made of explosives she's making a break for it i'm compensating for your lack of skills with higher caliber weaponry right so you can already see like there's tons of explosions happening each of those individual shots is fragmenting off little pieces of concrete or signage or almost everything here is uh destructible able to be destroyed um and so every single object then has to be created with this ability for collision detections in this case the the bullets from your chain gun colliding with it so yeah what about cars what happens when a chain gun collides with a car in this video enjoy your new robo-suppression autocannon don't get too sidetracked by chaos [Music] so now what are we talking about we're talking about trajectory jumping falling all those physics that we talked about she's gone into that building time to upgrade to sticky bombs this oughta level the playing field well she's in there somewhere agent 38. she's on the move again get after her uh-oh she's gone into robo-ready headquarters hmm that is a lot of targets i know let's just recall the entire building demolition grade architectural recall systems are now online good thing it's a bank holiday this place wasn't in great shape before we arrived remember on top despite all the snarky language right the point is to show off how well this physics engine is doing all this collision detection basically header off at the pass now would be a good time to figure out what that thing actually does [Music] oh that's not good let her go agent i think we've got bigger problems on the bright side you've been approved for mandatory overtime anyway okay so you get a sense now perhaps for uh what's going on with these physics engines and what they're capable of doing and why you would make a why unreal would uh post a video like this right what are they actually trying to show by posting a video like this all right so that is kind of an introduction to physics engines and hopefully giving you a bit of a taste for what they're like as well so hope you enjoyed that and um yeah we'll move on to the next thing after this