Help Temporarily make fluids in a container ignore other colliders/fluids - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html) +--- Thread: Help Temporarily make fluids in a container ignore other colliders/fluids (/thread-4263.html) |
Temporarily make fluids in a container ignore other colliders/fluids - Tobias - 21-06-2024 Hello, I'm new to ObiFluid and I'm currently working on a 2D bartender game where you can grab glasses with fluid, move them around and pour the fluids into other glasses (or onto the shelves). For example, I'd like this to work:
So, in short, I'd need a *grabbed glass with liquid* ignore all non-grabbed-glass colliders/liquids, and *liquid that has left a grabbed glass* to normally interact with the world. Liquids can mix, so I don't think I could do anything like "liquid from the red emitter behaves differently" - it might be glass mixed with red and blue liquid that is grabbed, while other glasses also already have red or blue liquid. I see two ways this could happen:
Do those ways sound possible? Is there any other (maybe better?) way to achieve this? RE: Temporarily make fluids in a container ignore other colliders/fluids - josemendez - 25-06-2024 (21-06-2024, 03:31 PM)Tobias Wrote: Hello, Hi! Either approach should work fine. Note however that colliders are shared among solvers, so in order for the fluid to collide with some colliders but not others you will need to change the fluid/collider collision filters. See “collision filters” here: https://obi.virtualmethodstudio.com/manual/6.3/collisions.html Also check out the bottom of this page, regarding setting collision filters at runtime: https://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html Kind regards, RE: Temporarily make fluids in a container ignore other colliders/fluids - Tobias - 26-06-2024 Oh, there are collision filters for particles. Does that mean I could also leave everything in one 2D simulation and make my scenario work by just changing the collision filters for inside-a-grabbed-glass fluid particles (and again when they leave the grabbed glass due to being poured out)? Or is collision between fluids not controlled by collision filters? RE: Temporarily make fluids in a container ignore other colliders/fluids - josemendez - 26-06-2024 (26-06-2024, 06:05 AM)Tobias Wrote: Oh, there are collision filters for particles. Does that mean I could also leave everything in one 2D simulation and make my scenario work by just changing the collision filters for inside-a-grabbed-glass fluid particles (and again when they leave the grabbed glass due to being poured out)? Or is collision between fluids not controlled by collision filters? Hi Tobias, No, fluid particles don't collide with each other (as they would behave like solids otherwise). Fluids work by calculating density at each particle's position, doing a weighted sum of the mass of neighboring particles. Then they apply a pressure force proportional to the difference between the measured density and a target density. This doesn't allow for collision filtering to take place. http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html Quote:Please note that fluid particles do not collide with each other, only granulars (gravel, pebbles) do. Fluid particles interact with each other trough density constraints, so there will be no contacts between fluid particles reported by the solver. With fluids, you can use advection or diffusion instead to get information about a particle's neighborhood. You should instead move the emitter to a different solver (you will also need to re-emit active particles and set their positions afterwards), or use a 3D simulation and move fluids in the Z axis. kind regards, RE: Temporarily make fluids in a container ignore other colliders/fluids - Tobias - 26-06-2024 (26-06-2024, 08:01 AM)josemendez Wrote: You should instead move the emitter to a different solver (you will also need to re-emit active particles and set their positions afterwards) Can I also move particles between emitters? Since mixing fluids is the point of the game, the glass can contain fluids by multiple emitters, and other particles by those same emitters will be in other glasses. RE: Temporarily make fluids in a container ignore other colliders/fluids - josemendez - 26-06-2024 (26-06-2024, 05:00 PM)Tobias Wrote: Can I also move particles between emitters? Since mixing fluids is the point of the game, the glass can contain fluids by multiple emitters, and other particles by those same emitters will be in other glasses. Hi, No, as it generally doesn't make any sense: moving a particle to another emitter would suddenly change all its properties including rest density, mass, size, pressure, etc, potentially breaking the simulation. Note you don't need to move particles between emitters in order to mix them: fluids from different emitters can interact with each other, and you can use diffusion to smoothly transfer properties between particles belonging to different emitters. kind regards RE: Temporarily make fluids in a container ignore other colliders/fluids - Tobias - 26-06-2024 (26-06-2024, 05:10 PM)josemendez Wrote: Hi, Yes, but in this case I want to be able to have diffusions from the same emitters ignore each other temporarily under certain circumstances. Take the following scenario:
RE: Temporarily make fluids in a container ignore other colliders/fluids - josemendez - 26-06-2024 (26-06-2024, 06:36 PM)Tobias Wrote: Yes, but in this case I want to be able to have diffusions from the same emitters ignore each other temporarily under certain circumstances. Take the following scenario: So it's not like each bottle contains fluid from a specific emitter that you can move to a different solver when you want it to stop interacting with other fluids, right? In that case you will need to do this in 3D and use depth to prevent fluids poured on different containers from interacting with each other. Currently there's no way to make specific fluid particles ignore other particles when calculating density. We will consider adding something similar to collision filters for density constraints in the future, however it will be considerably more expensive as the amount of neighbors for each fluid particle is high, and the check would need to take place every frame. It's more efficient to use spatial coordinates for this, as spatial binning will automatically make particles that are physically distant along the Z axis ignore each other without the need to perform any checks. kind regards, RE: Temporarily make fluids in a container ignore other colliders/fluids - Tobias - 27-06-2024 Quote:In that case you will need to do this in 3D and use depth to prevent fluids poured on different containers from interacting with each other. Gotcha. Since I still want it to mostly behave as if it was 2D - what would be the best way to achieve that? 3D colliders with a really small depth? What would be the smallest depth that could still contain particles? Or can I maybe somehow restrict the Z axis for particles until I manually their Z position? Quote:moving a particle to another emitter would suddenly change all its properties including rest density, mass, size, pressure, etc, potentially breaking the simulation. I've been thinking a bit about that - are those properties all readable and settable? Could I manually create a copy of an emitter, emit some particles, manually move over particles from the original emitter by setting those properties, and then removing the particles from the old emitter? |