don't let BLENDER PHYSICS bully you

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to another default cube cg matter tutorial and this whole not starting in the chair bit it's pretty stupid okay so what do I want to talk about today I think it's actually a pretty interesting topic well it's hop into blender today I want to talk about this very seemingly simple physics problem where we have two rings and I'm trying to you know have one ring collide with the other in to say that makes sense the inspiration for this is Josh contacted me a bit ago because he needed this kind of scenario for one of the models he was making and when he asked me what the issue with the physics were I was thinking to myself what in it now I'm kidding I'm kidding there's some issues with this scenario that don't make it obvious how to set this up and after like looking into it myself I thought you know what why not make this into a tutorial in full-screen because I always forget okay so let's talk about this scenario which is whatever and you can also use this to make chains let's just get into it so I'm gonna start off with a new blender scene and let's set up the situation so we're looking for two objects that have holes in them so we're not trying to collide two cubes two prisms to whatever two objects with genus 1 I think that's correct for the topology folks out there so torus is one way to do that you could also do a coffee mug you know because the handle has anything with a hole we're gonna take this we're gonna duplicate it along the x axis and rotate it by 90 degrees so that one you know could fall on to the other and normally the way we'd set this up if we want them to interact as we take our first object go to rigidbody no we go to physics make it a rigidbody which will make this fall but not interact with anything cuz the other ones not a rigidbody so to fix that what do we do select the other one make it a rigidbody and at this point the if those of you paying attention might notice might realize that they'd both fall at the same speed but there's actually an additional issue if we click play they explode away from each other which might be what you want but not what we want and this is the issue Josh was running into okay so before before what am I even saying let me explain what the issue with this is so the reason this is happening you might be thinking oh are the objects too close together some thing like this no blenders physics isn't great but it's not that bad the issue is that when these these collisions are calculated it's not actually seeing a torus and a torus because if it were we wouldn't have this issue what it's actually seeing is bounding boxes or maybe convex hulls so for example with this object you're gonna notice that the collision shape is set to convex hull meaning that it's not actually seeing it's torus it's generating a new mesh which it's using for the collision some more obvious ones are boxes so here would simulate two boxes colliding if we said both of these two box which would still make them explode but in a somewhat more organized way you could also set these to something like cylinders which would pretty closely approximate the mesh you have some other options the point is there's nothing great for an object with a hole right so the trick is you need to set this to mesh meaning it's gonna actually use the mesh itself all these vertices faces edges to calculate the physics and you might think okay where we set both of these two mesh why wouldn't blender have that is the default option the reason is it's very very slow to calculate at least compared to the others a box is like the fastest thing you could do convex hull isn't the fastest but it's a pretty good approach and it and it approximates the geometry of the object very well a convex hull is just the shape without any indenting without any concave areas it's convex right okay so we said both of these two mesh and you might think okay that works but of course they're gonna fall at the same speed right so really what we want is this object this torus to be stationary but still reacting to physics and collisions and whatever with this object right so we don't want this to be able to fall there's a couple ways to do that you could either set it to animated which will keep it still why because we haven't animated it so it's as if we in some sense have a keyframe to say stay there unless you know we had multiple keyframes in animate it which we could do we could add a keyframe 30 frames down move it keyframe and it would look like this right and the physics still interact correctly but that's what animated means let me just get rid of those not queen' those keyframes but this is the heart the worst part about blender is you can't just grab those windows do eat keyframes not animated your second option is just to set it to pass it which means it does exactly what you want it's not active in the sense that gravity is affecting of affecting it but it's passive in that it still works with collisions but it doesn't move itself so we set it to passive and boom there you go if we did the opposite if we did the opposite where this one was passive what do you think would happen think about it this would happen okay so that kind of solves the original issue but you're gonna notice with both of these cases swords whichever one we set to passive there's actually an issue that's much more sinister it's a darker it's lurking underneath and if we click play you can see that the physics kind of react how you'd think but the objects hovering why is it hovering we I thought we set it to mesh I thought that meant that it's using the actual mesh geometry shouldn't have this like bounding box around it that's slightly bigger so this is the issue and this was another thing that a Josh ran into that at the time I didn't even really know how to solve so that's the that's the goal here so again notice that with this case our torus is still floating what's happening here is called margin or margining or marginalizing probably not that one it means that it gives it a bit of buffer room a margin and we can make that margin smaller so that there's less of a hover but of course if you set your margin to zero you're gonna get some bad physics some stuff is gonna start tearing apart so with our object in rigidbody you go to sensitivity and you see the margin is right now set to 0.04 so there's gonna be that much spacing twice because we have two objects with the sense it's a be 0.04 so let's just play this and see we have about an average distance of this a bit of a gap let's try setting it to 0.01 so 1/4 did I just type that wrong oh god it just undid all my work this is this is rough ok it's easy to set it up again so make sure to set both of these to mesh this tutorial is a disaster we're gonna set this one to 0.01 and we're gonna set this also 2.01 so now we expect the physics to be behaving pretty much in the same Bowl with less of a gap so let's see it yes indeed it is coming much much closer to the geometry and that's because we took the margin down in both cases now you're gonna see that there's some weird behavior and that's just because blenders physics is there's no saving this one honestly but um maybe one day they'll change engines but you can see that that's the compromise you have the reason the margin exists is to add stability to the simulation however now objects aren't touching so you can either try to keep bringing down the margin until you're fine with the mini mini mini miniscule gap another thing you can do by the way is if you go to the scene properties in rigid-body world which is the settings for our physics how many times is a calculating per frame what are those calculations gonna be like we have all these settings here so we could like bring up how many like steps there are per second meaning that it's gonna be slower but it's gonna be more accurate these are things you can play with but generally I feel like I've accomplished it keeps that's the thing with rigid bodies it keeps on doing my thing but uh that's the thing I wanted to go over I wanted to go over the collision shape like that what bounding box are choosing and to make it mesh and I wanted to talk about margins and this is what's gonna let you make those chain link fence know those chains just like metal chains or anything that intersects itself I can't think of any other examples right now but yeah there you go I hope you found this tutorial helpful enjoyable and if you want to support this wait I mean how am I gonna be persuasive hold up if you want to support my channel and feel like there's value in it and wanna maybe even get benefits for yourself patreon is the best way to do that you can think of it as a donation or you can think of it as ways to get discord access behind-the-scenes and now video courses if you're at a high enough tier that I do also publish on Gumroad so check that out it's the hole in the hand flush thing that I've been releasing it's a super cool thing you could either get that on Gumroad or on patreon directly but yeah whatever if you want to do patreon you'll do it if you're that kind of person you would have already done it thank you for watching this free tutorial I hope you enjoyed it I'm sorry there was so much rambling and undo messes but um happens you know
Info
Channel: Default Cube
Views: 164,035
Rating: 4.9475608 out of 5
Keywords: blender, tutorial, physics, collision, 3d, vfx, cg, cgi
Id: 18PDK5ekEWc
Channel Id: undefined
Length: 9min 5sec (545 seconds)
Published: Wed May 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.