2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2007 by Janne Karhu.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
2010-04-04 12:29:06 +00:00
|
|
|
* Contributor(s): Raul Fernandez Hernandez (Farsthary), Stephen Swhitehorn.
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
*
|
2011-09-25 11:51:28 +00:00
|
|
|
* Adaptive time step
|
2012-12-14 04:57:26 +00:00
|
|
|
* Classical SPH
|
|
|
|
* Copyright 2011-2012 AutoCRC
|
2011-09-25 11:51:28 +00:00
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/particle_system.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-09-15 06:43:36 +00:00
|
|
|
#include <stddef.h>
|
2009-06-22 18:19:18 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-12-26 15:59:07 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "DNA_boid_types.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "DNA_particle_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
#include "DNA_modifier_types.h"
|
2018-02-07 11:14:08 +11:00
|
|
|
#include "DNA_object_force_types.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_texture_types.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "DNA_listBase.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2013-04-22 12:00:37 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2012-02-17 21:22:18 +00:00
|
|
|
#include "BLI_edgehash.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BLI_rand.h"
|
2018-02-18 21:27:33 +11:00
|
|
|
#include "BLI_jitter_2d.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_kdtree.h"
|
2008-09-13 18:09:41 +00:00
|
|
|
#include "BLI_kdopbvh.h"
|
2013-08-19 10:40:47 +00:00
|
|
|
#include "BLI_sort.h"
|
2014-10-06 18:58:41 +02:00
|
|
|
#include "BLI_task.h"
|
2007-12-04 13:57:28 +00:00
|
|
|
#include "BLI_threads.h"
|
2011-10-22 01:53:35 +00:00
|
|
|
#include "BLI_linklist.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-12-26 15:59:07 +00:00
|
|
|
#include "BKE_animsys.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "BKE_boids.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BKE_cdderivedmesh.h"
|
2008-09-13 18:09:41 +00:00
|
|
|
#include "BKE_collision.h"
|
2016-02-02 15:01:58 +01:00
|
|
|
#include "BKE_colortools.h"
|
2008-08-18 14:41:24 +00:00
|
|
|
#include "BKE_effect.h"
|
2018-05-31 15:37:15 +02:00
|
|
|
#include "BKE_global.h"
|
2018-05-15 13:26:40 +02:00
|
|
|
#include "BKE_library.h"
|
2015-10-08 14:56:20 +02:00
|
|
|
#include "BKE_library_query.h"
|
2018-05-31 15:24:30 +02:00
|
|
|
#include "BKE_main.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BKE_particle.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2017-04-21 14:28:23 +02:00
|
|
|
#include "BKE_collection.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_material.h"
|
2009-09-10 22:32:33 +00:00
|
|
|
#include "BKE_cloth.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BKE_lattice.h"
|
|
|
|
#include "BKE_pointcache.h"
|
2007-12-05 12:40:54 +00:00
|
|
|
#include "BKE_mesh.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BKE_modifier.h"
|
2008-02-13 11:18:08 +00:00
|
|
|
#include "BKE_scene.h"
|
2009-04-20 15:06:46 +00:00
|
|
|
#include "BKE_bvhutils.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2017-11-09 13:11:20 -02:00
|
|
|
#include "DEG_depsgraph.h"
|
2018-06-21 19:45:39 +02:00
|
|
|
#include "DEG_depsgraph_physics.h"
|
2018-04-08 09:28:52 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
2017-11-09 13:11:20 -02:00
|
|
|
|
2008-09-02 20:53:07 +00:00
|
|
|
#include "PIL_time.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
|
|
|
#include "RE_shader_ext.h"
|
|
|
|
|
2008-04-02 17:48:46 +00:00
|
|
|
/* fluid sim particle import */
|
2011-10-29 23:56:07 +00:00
|
|
|
#ifdef WITH_MOD_FLUID
|
2018-02-07 11:14:08 +11:00
|
|
|
#include "DNA_object_fluidsim_types.h"
|
2008-04-02 17:48:46 +00:00
|
|
|
#include "LBM_fluidsim.h"
|
|
|
|
#include <zlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-10-29 23:56:07 +00:00
|
|
|
#endif // WITH_MOD_FLUID
|
2008-04-02 17:48:46 +00:00
|
|
|
|
2014-03-18 22:25:29 +06:00
|
|
|
static ThreadRWMutex psys_bvhtree_rwlock = BLI_RWLOCK_INITIALIZER;
|
2014-03-18 13:36:24 +01:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Reacting to system events */
|
|
|
|
/************************************************/
|
|
|
|
|
2011-12-30 07:55:15 +00:00
|
|
|
static int particles_are_dynamic(ParticleSystem *psys)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->pointcache->flag & PTCACHE_BAKED)
|
2010-09-02 06:58:54 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part->type == PART_HAIR)
|
2010-09-02 06:58:54 +00:00
|
|
|
return psys->flag & PSYS_HAIR_DYNAMICS;
|
|
|
|
else
|
2014-07-20 01:30:29 +10:00
|
|
|
return ELEM(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
|
2010-09-02 06:58:54 +00:00
|
|
|
}
|
2011-02-13 10:52:18 +00:00
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
float psys_get_current_display_percentage(ParticleSystem *psys, const bool use_render_params)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
|
|
|
ParticleSettings *part=psys->part;
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
if ((use_render_params && !particles_are_dynamic(psys)) || /* non-dynamic particles can be rendered fully */
|
2012-04-21 15:11:03 +00:00
|
|
|
(part->child_nbr && part->childtype) || /* display percentage applies to children */
|
|
|
|
(psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */
|
|
|
|
{
|
2013-06-24 22:41:40 +00:00
|
|
|
return 1.0f;
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2013-06-24 22:41:40 +00:00
|
|
|
return psys->part->disp/100.0f;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2011-01-07 11:38:28 +00:00
|
|
|
static int tot_particles(ParticleSystem *psys, PTCacheID *pid)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pid && psys->pointcache->flag & PTCACHE_EXTERNAL)
|
2011-01-07 11:38:28 +00:00
|
|
|
return pid->cache->totpoint;
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT)
|
2011-02-04 15:48:13 +00:00
|
|
|
return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res - psys->totunexist;
|
2011-01-07 11:38:28 +00:00
|
|
|
else
|
2011-02-04 15:48:13 +00:00
|
|
|
return psys->part->totpart - psys->totunexist;
|
2011-01-07 11:38:28 +00:00
|
|
|
}
|
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
void psys_reset(ParticleSystem *psys, int mode)
|
|
|
|
{
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) {
|
|
|
|
if (mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) {
|
2010-11-09 11:17:00 +00:00
|
|
|
/* don't free if not absolutely necessary */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totpart != tot_particles(psys, NULL)) {
|
2010-11-09 11:17:00 +00:00
|
|
|
psys_free_particles(psys);
|
|
|
|
psys->totpart= 0;
|
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
|
|
|
psys->totkeyed= 0;
|
|
|
|
psys->flag &= ~(PSYS_HAIR_DONE|PSYS_KEYED);
|
2008-04-11 12:29:29 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->edit && psys->free_edit) {
|
2009-08-29 15:20:36 +00:00
|
|
|
psys->free_edit(psys->edit);
|
|
|
|
psys->edit = NULL;
|
|
|
|
psys->free_edit = NULL;
|
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (mode == PSYS_RESET_CACHE_MISS) {
|
2008-09-13 21:06:22 +00:00
|
|
|
/* set all particles to be skipped */
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES
|
2008-09-18 17:42:17 +00:00
|
|
|
pa->flag |= PARS_NO_DISP;
|
2008-09-13 21:06:22 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
|
|
|
/* reset children */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->child) {
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
MEM_freeN(psys->child);
|
2011-02-13 10:52:18 +00:00
|
|
|
psys->child= NULL;
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
psys->totchild= 0;
|
|
|
|
|
|
|
|
/* reset path cache */
|
2009-09-05 20:12:08 +00:00
|
|
|
psys_free_path_cache(psys, psys->edit);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
|
|
|
/* reset point cache */
|
2010-03-21 20:36:06 +00:00
|
|
|
BKE_ptcache_invalidate(psys->pointcache);
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->fluid_springs) {
|
2011-01-09 19:09:41 +00:00
|
|
|
MEM_freeN(psys->fluid_springs);
|
|
|
|
psys->fluid_springs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
psys->tot_fluidsprings = psys->alloc_fluidsprings = 0;
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
2009-09-04 23:06:15 +00:00
|
|
|
ParticleData *newpars = NULL;
|
|
|
|
BoidParticle *newboids = NULL;
|
|
|
|
PARTICLE_P;
|
|
|
|
int totpart, totsaved = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (new_totpart<0) {
|
2012-05-20 19:49:27 +00:00
|
|
|
if ((part->distr == PART_DISTR_GRID) && (part->from != PART_FROM_VERT)) {
|
2009-09-17 22:00:49 +00:00
|
|
|
totpart= part->grid_res;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
totpart*=totpart*totpart;
|
|
|
|
}
|
|
|
|
else
|
2009-09-17 22:00:49 +00:00
|
|
|
totpart=part->totpart;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
totpart=new_totpart;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totpart != psys->totpart) {
|
|
|
|
if (psys->edit && psys->free_edit) {
|
2010-02-02 18:54:23 +00:00
|
|
|
psys->free_edit(psys->edit);
|
|
|
|
psys->edit = NULL;
|
|
|
|
psys->free_edit = NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totpart) {
|
2010-09-24 07:39:52 +00:00
|
|
|
newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles");
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newpars == NULL)
|
2011-01-27 17:29:22 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part->phystype == PART_PHYS_BOIDS) {
|
2010-09-24 07:39:52 +00:00
|
|
|
newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles");
|
2011-01-27 12:21:14 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newboids == NULL) {
|
2016-06-19 06:25:54 +10:00
|
|
|
/* allocation error! */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newpars)
|
2011-01-27 17:29:22 +00:00
|
|
|
MEM_freeN(newpars);
|
|
|
|
return;
|
|
|
|
}
|
2011-01-27 12:21:14 +00:00
|
|
|
}
|
2010-09-24 07:39:52 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles) {
|
2012-05-15 12:07:44 +00:00
|
|
|
totsaved=MIN2(psys->totpart,totpart);
|
2009-09-04 23:06:15 +00:00
|
|
|
/*save old pars*/
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totsaved) {
|
2012-05-15 12:07:44 +00:00
|
|
|
memcpy(newpars,psys->particles,totsaved*sizeof(ParticleData));
|
2009-09-04 23:06:15 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles->boid)
|
2009-09-04 23:06:15 +00:00
|
|
|
memcpy(newboids, psys->particles->boid, totsaved*sizeof(BoidParticle));
|
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles->keys)
|
2009-09-04 23:06:15 +00:00
|
|
|
MEM_freeN(psys->particles->keys);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles->boid)
|
2009-09-04 23:06:15 +00:00
|
|
|
MEM_freeN(psys->particles->boid);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (p=0, pa=newpars; p<totsaved; p++, pa++) {
|
|
|
|
if (pa->keys) {
|
2009-09-04 23:06:15 +00:00
|
|
|
pa->keys= NULL;
|
|
|
|
pa->totkey= 0;
|
|
|
|
}
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (p=totsaved, pa=psys->particles+totsaved; p<psys->totpart; p++, pa++)
|
|
|
|
if (pa->hair) MEM_freeN(pa->hair);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
MEM_freeN(psys->particles);
|
2009-09-17 22:00:49 +00:00
|
|
|
psys_free_pdd(psys);
|
2009-09-04 23:06:15 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
psys->particles=newpars;
|
2009-10-05 13:25:56 +00:00
|
|
|
psys->totpart=totpart;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newboids) {
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES
|
|
|
|
pa->boid = newboids++;
|
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->child) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
MEM_freeN(psys->child);
|
2011-02-13 10:52:18 +00:00
|
|
|
psys->child=NULL;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
psys->totchild=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
int psys_get_child_number(Scene *scene, ParticleSystem *psys, const bool use_render_params)
|
2007-12-20 16:35:27 +00:00
|
|
|
{
|
2008-02-13 11:18:08 +00:00
|
|
|
int nbr;
|
2007-12-20 16:35:27 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!psys->part->childtype)
|
2007-12-20 16:35:27 +00:00
|
|
|
return 0;
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
if (use_render_params)
|
2008-02-13 11:18:08 +00:00
|
|
|
nbr= psys->part->ren_child_nbr;
|
|
|
|
else
|
2010-01-25 11:39:56 +00:00
|
|
|
nbr= psys->part->child_nbr;
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
return get_render_child_particle_number(&scene->r, nbr, use_render_params);
|
2008-02-13 11:18:08 +00:00
|
|
|
}
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
int psys_get_tot_child(Scene *scene, ParticleSystem *psys, const bool use_render_params)
|
2008-02-13 11:18:08 +00:00
|
|
|
{
|
2018-04-08 09:28:52 +02:00
|
|
|
return psys->totpart*psys_get_child_number(scene, psys, use_render_params);
|
2007-12-20 16:35:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 14:18:33 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Distribution */
|
|
|
|
/************************************************/
|
|
|
|
|
2018-05-25 21:44:33 +02:00
|
|
|
void psys_calc_dmcache(Object *ob, Mesh *mesh_final, Mesh *mesh_original, ParticleSystem *psys)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2008-02-18 10:49:46 +00:00
|
|
|
/* use for building derived mesh mapping info:
|
2012-03-03 20:19:11 +00:00
|
|
|
*
|
2018-06-17 17:05:51 +02:00
|
|
|
* node: the allocated links - total derived mesh element count
|
2012-03-03 20:19:11 +00:00
|
|
|
* nodearray: the array of nodes aligned with the base mesh's elements, so
|
|
|
|
* each original elements can reference its derived elements
|
|
|
|
*/
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
Mesh *me= (Mesh*)ob->data;
|
2013-05-27 17:11:05 +00:00
|
|
|
bool use_modifier_stack= psys->part->use_modifier_stack;
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* CACHE LOCATIONS */
|
2018-05-15 13:26:40 +02:00
|
|
|
if (!mesh_final->runtime.deformed_only) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* Will use later to speed up subsurf/derivedmesh */
|
2008-02-18 10:49:46 +00:00
|
|
|
LinkNode *node, *nodedmelem, **nodearray;
|
2012-10-30 19:20:17 +00:00
|
|
|
int totdmelem, totelem, i, *origindex, *origindex_poly = NULL;
|
2008-02-18 10:49:46 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part->from == PART_FROM_VERT) {
|
2018-05-15 13:26:40 +02:00
|
|
|
totdmelem = mesh_final->totvert;
|
2013-05-27 17:11:05 +00:00
|
|
|
|
|
|
|
if (use_modifier_stack) {
|
|
|
|
totelem= totdmelem;
|
|
|
|
origindex= NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
totelem= me->totvert;
|
2018-05-15 13:26:40 +02:00
|
|
|
origindex = CustomData_get_layer(&mesh_final->vdata, CD_ORIGINDEX);
|
2013-05-27 17:11:05 +00:00
|
|
|
}
|
2008-02-18 10:49:46 +00:00
|
|
|
}
|
|
|
|
else { /* FROM_FACE/FROM_VOLUME */
|
2018-05-15 13:26:40 +02:00
|
|
|
totdmelem= mesh_final->totface;
|
2013-05-27 17:11:05 +00:00
|
|
|
|
|
|
|
if (use_modifier_stack) {
|
|
|
|
totelem= totdmelem;
|
|
|
|
origindex= NULL;
|
|
|
|
origindex_poly= NULL;
|
|
|
|
}
|
|
|
|
else {
|
2018-05-25 21:44:33 +02:00
|
|
|
totelem = mesh_original->totface;
|
2018-05-15 13:26:40 +02:00
|
|
|
origindex = CustomData_get_layer(&mesh_final->fdata, CD_ORIGINDEX);
|
2013-05-27 17:11:05 +00:00
|
|
|
|
|
|
|
/* for face lookups we need the poly origindex too */
|
2018-05-15 13:26:40 +02:00
|
|
|
origindex_poly = CustomData_get_layer(&mesh_final->pdata, CD_ORIGINDEX);
|
2013-05-27 17:11:05 +00:00
|
|
|
if (origindex_poly == NULL) {
|
|
|
|
origindex= NULL;
|
|
|
|
}
|
2012-10-30 19:20:17 +00:00
|
|
|
}
|
2008-02-18 10:49:46 +00:00
|
|
|
}
|
Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing.
Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index
as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time...
This patch mostly fixes particle editing mode:
- Adding/removing particles when using generative modifiers (like subsurf) should now work.
- Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work.
- X-axis-mirror-editing particles over ngons does not really work, not sure why currently.
- All this in both 'modes' (with or without using modifier stack for particles).
Tech side:
- Store a deformed-only DM in particle modifier data.
- Rename existing DM to make it clear it's a final one.
- Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches.
- Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM
when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface
from an final DM tessface index).
Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway),
it's more like some urgency bandage. Whole crap needs complete rewrite anyway,
BMesh's polygons make it really hard to work with current system (and looptri would not help much here).
Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too.
Reviewers: psy-fi
Subscribers: dfelinto, eyecandy
Maniphest Tasks: T47038
Differential Revision: https://developer.blender.org/D1685
2016-01-04 12:19:45 +01:00
|
|
|
|
2008-02-18 10:49:46 +00:00
|
|
|
nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems");
|
|
|
|
nodearray= MEM_callocN(sizeof(LinkNode *)*totelem, "psys node array");
|
Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing.
Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index
as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time...
This patch mostly fixes particle editing mode:
- Adding/removing particles when using generative modifiers (like subsurf) should now work.
- Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work.
- X-axis-mirror-editing particles over ngons does not really work, not sure why currently.
- All this in both 'modes' (with or without using modifier stack for particles).
Tech side:
- Store a deformed-only DM in particle modifier data.
- Rename existing DM to make it clear it's a final one.
- Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches.
- Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM
when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface
from an final DM tessface index).
Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway),
it's more like some urgency bandage. Whole crap needs complete rewrite anyway,
BMesh's polygons make it really hard to work with current system (and looptri would not help much here).
Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too.
Reviewers: psy-fi
Subscribers: dfelinto, eyecandy
Maniphest Tasks: T47038
Differential Revision: https://developer.blender.org/D1685
2016-01-04 12:19:45 +01:00
|
|
|
|
2012-11-07 11:37:53 +00:00
|
|
|
for (i=0, node=nodedmelem; i<totdmelem; i++, node++) {
|
2012-10-30 19:20:17 +00:00
|
|
|
int origindex_final;
|
|
|
|
node->link = SET_INT_IN_POINTER(i);
|
|
|
|
|
2012-11-07 11:37:53 +00:00
|
|
|
/* may be vertex or face origindex */
|
2013-05-27 17:11:05 +00:00
|
|
|
if (use_modifier_stack) {
|
|
|
|
origindex_final = i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
origindex_final = origindex ? origindex[i] : ORIGINDEX_NONE;
|
2008-02-18 10:49:46 +00:00
|
|
|
|
2013-05-27 17:11:05 +00:00
|
|
|
/* if we have a poly source, do an index lookup */
|
|
|
|
if (origindex_poly && origindex_final != ORIGINDEX_NONE) {
|
|
|
|
origindex_final = origindex_poly[origindex_final];
|
|
|
|
}
|
2012-10-30 19:20:17 +00:00
|
|
|
}
|
|
|
|
|
2014-07-18 11:53:35 +02:00
|
|
|
if (origindex_final != ORIGINDEX_NONE && origindex_final < totelem) {
|
2012-10-30 19:20:17 +00:00
|
|
|
if (nodearray[origindex_final]) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* prepend */
|
2012-10-30 19:20:17 +00:00
|
|
|
node->next = nodearray[origindex_final];
|
|
|
|
nodearray[origindex_final] = node;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nodearray[origindex_final] = node;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing.
Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index
as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time...
This patch mostly fixes particle editing mode:
- Adding/removing particles when using generative modifiers (like subsurf) should now work.
- Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work.
- X-axis-mirror-editing particles over ngons does not really work, not sure why currently.
- All this in both 'modes' (with or without using modifier stack for particles).
Tech side:
- Store a deformed-only DM in particle modifier data.
- Rename existing DM to make it clear it's a final one.
- Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches.
- Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM
when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface
from an final DM tessface index).
Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway),
it's more like some urgency bandage. Whole crap needs complete rewrite anyway,
BMesh's polygons make it really hard to work with current system (and looptri would not help much here).
Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too.
Reviewers: psy-fi
Subscribers: dfelinto, eyecandy
Maniphest Tasks: T47038
Differential Revision: https://developer.blender.org/D1685
2016-01-04 12:19:45 +01:00
|
|
|
|
2008-02-18 10:49:46 +00:00
|
|
|
/* cache the verts/faces! */
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->num < 0) {
|
2013-05-27 17:11:05 +00:00
|
|
|
pa->num_dmcache = DMCACHE_NOTFOUND;
|
2010-12-02 14:52:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-02 19:17:34 +00:00
|
|
|
if (use_modifier_stack) {
|
|
|
|
if (pa->num < totelem)
|
|
|
|
pa->num_dmcache = DMCACHE_ISCHILD;
|
2013-05-27 17:11:05 +00:00
|
|
|
else
|
|
|
|
pa->num_dmcache = DMCACHE_NOTFOUND;
|
2008-02-18 10:49:46 +00:00
|
|
|
}
|
2013-07-02 19:17:34 +00:00
|
|
|
else {
|
|
|
|
if (psys->part->from == PART_FROM_VERT) {
|
2013-05-27 17:11:05 +00:00
|
|
|
if (pa->num < totelem && nodearray[pa->num])
|
2013-07-02 19:17:34 +00:00
|
|
|
pa->num_dmcache= GET_INT_FROM_POINTER(nodearray[pa->num]->link);
|
2013-05-27 17:11:05 +00:00
|
|
|
else
|
|
|
|
pa->num_dmcache = DMCACHE_NOTFOUND;
|
|
|
|
}
|
2013-07-02 19:17:34 +00:00
|
|
|
else { /* FROM_FACE/FROM_VOLUME */
|
2018-05-25 21:44:33 +02:00
|
|
|
pa->num_dmcache = psys_particle_dm_face_lookup(mesh_final, mesh_original, pa->num, pa->fuv, nodearray);
|
2013-07-02 19:17:34 +00:00
|
|
|
}
|
2008-02-18 10:49:46 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 10:49:46 +00:00
|
|
|
MEM_freeN(nodearray);
|
|
|
|
MEM_freeN(nodedmelem);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* TODO PARTICLE, make the following line unnecessary, each function
|
|
|
|
* should know to use the num or num_dmcache, set the num_dmcache to
|
2012-03-09 00:41:09 +00:00
|
|
|
* an invalid value, just in case */
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing.
Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index
as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time...
This patch mostly fixes particle editing mode:
- Adding/removing particles when using generative modifiers (like subsurf) should now work.
- Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work.
- X-axis-mirror-editing particles over ngons does not really work, not sure why currently.
- All this in both 'modes' (with or without using modifier stack for particles).
Tech side:
- Store a deformed-only DM in particle modifier data.
- Rename existing DM to make it clear it's a final one.
- Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches.
- Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM
when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface
from an final DM tessface index).
Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway),
it's more like some urgency bandage. Whole crap needs complete rewrite anyway,
BMesh's polygons make it really hard to work with current system (and looptri would not help much here).
Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too.
Reviewers: psy-fi
Subscribers: dfelinto, eyecandy
Maniphest Tasks: T47038
Differential Revision: https://developer.blender.org/D1685
2016-01-04 12:19:45 +01:00
|
|
|
LOOP_PARTICLES {
|
2013-05-27 17:11:05 +00:00
|
|
|
pa->num_dmcache = DMCACHE_NOTFOUND;
|
Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing.
Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index
as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time...
This patch mostly fixes particle editing mode:
- Adding/removing particles when using generative modifiers (like subsurf) should now work.
- Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work.
- X-axis-mirror-editing particles over ngons does not really work, not sure why currently.
- All this in both 'modes' (with or without using modifier stack for particles).
Tech side:
- Store a deformed-only DM in particle modifier data.
- Rename existing DM to make it clear it's a final one.
- Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches.
- Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM
when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface
from an final DM tessface index).
Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway),
it's more like some urgency bandage. Whole crap needs complete rewrite anyway,
BMesh's polygons make it really hard to work with current system (and looptri would not help much here).
Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too.
Reviewers: psy-fi
Subscribers: dfelinto, eyecandy
Maniphest Tasks: T47038
Differential Revision: https://developer.blender.org/D1685
2016-01-04 12:19:45 +01:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
/* threaded child particle distribution and path caching */
|
2014-10-06 18:58:41 +02:00
|
|
|
void psys_thread_context_init(ParticleThreadContext *ctx, ParticleSimulationData *sim)
|
2007-12-04 13:57:28 +00:00
|
|
|
{
|
2014-10-06 18:58:41 +02:00
|
|
|
memset(ctx, 0, sizeof(ParticleThreadContext));
|
2009-09-17 22:00:49 +00:00
|
|
|
ctx->sim = *sim;
|
2018-05-15 13:26:40 +02:00
|
|
|
ctx->mesh = ctx->sim.psmd->mesh_final;
|
2014-10-06 18:58:41 +02:00
|
|
|
ctx->ma = give_current_material(sim->ob, sim->psys->part->omat);
|
|
|
|
}
|
2007-12-04 13:57:28 +00:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
#define MAX_PARTICLES_PER_TASK 256 /* XXX arbitrary - maybe use at least number of points instead for better balancing? */
|
2007-12-04 13:57:28 +00:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
BLI_INLINE int ceil_ii(int a, int b)
|
|
|
|
{
|
|
|
|
return (a + b - 1) / b;
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
|
|
|
|
2015-03-25 18:34:52 +01:00
|
|
|
void psys_tasks_create(ParticleThreadContext *ctx, int startpart, int endpart, ParticleTask **r_tasks, int *r_numtasks)
|
2007-12-04 13:57:28 +00:00
|
|
|
{
|
2014-10-06 18:58:41 +02:00
|
|
|
ParticleTask *tasks;
|
2015-03-25 18:34:52 +01:00
|
|
|
int numtasks = ceil_ii((endpart - startpart), MAX_PARTICLES_PER_TASK);
|
|
|
|
float particles_per_task = (float)(endpart - startpart) / (float)numtasks, p, pnext;
|
2014-10-06 18:58:41 +02:00
|
|
|
int i;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
tasks = MEM_callocN(sizeof(ParticleTask) * numtasks, "ParticleThread");
|
|
|
|
*r_numtasks = numtasks;
|
|
|
|
*r_tasks = tasks;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-03-25 18:34:52 +01:00
|
|
|
p = (float)startpart;
|
2014-10-06 18:58:41 +02:00
|
|
|
for (i = 0; i < numtasks; i++, p = pnext) {
|
|
|
|
pnext = p + particles_per_task;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
tasks[i].ctx = ctx;
|
|
|
|
tasks[i].begin = (int)p;
|
2015-03-25 18:34:52 +01:00
|
|
|
tasks[i].end = min_ii((int)pnext, endpart);
|
2014-10-06 18:58:41 +02:00
|
|
|
}
|
|
|
|
}
|
2007-12-04 13:57:28 +00:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
void psys_tasks_free(ParticleTask *tasks, int numtasks)
|
|
|
|
{
|
|
|
|
int i;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-01-08 12:40:27 +01:00
|
|
|
/* threads */
|
|
|
|
for (i = 0; i < numtasks; ++i) {
|
|
|
|
if (tasks[i].rng)
|
|
|
|
BLI_rng_free(tasks[i].rng);
|
|
|
|
if (tasks[i].rng_path)
|
|
|
|
BLI_rng_free(tasks[i].rng_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(tasks);
|
|
|
|
}
|
|
|
|
|
|
|
|
void psys_thread_context_free(ParticleThreadContext *ctx)
|
|
|
|
{
|
2007-12-04 13:57:28 +00:00
|
|
|
/* path caching */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->vg_length)
|
2007-12-04 13:57:28 +00:00
|
|
|
MEM_freeN(ctx->vg_length);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->vg_clump)
|
2007-12-04 13:57:28 +00:00
|
|
|
MEM_freeN(ctx->vg_clump);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->vg_kink)
|
2007-12-04 13:57:28 +00:00
|
|
|
MEM_freeN(ctx->vg_kink);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->vg_rough1)
|
2007-12-04 13:57:28 +00:00
|
|
|
MEM_freeN(ctx->vg_rough1);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->vg_rough2)
|
2008-01-02 17:57:18 +00:00
|
|
|
MEM_freeN(ctx->vg_rough2);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->vg_roughe)
|
2007-12-04 13:57:28 +00:00
|
|
|
MEM_freeN(ctx->vg_roughe);
|
2018-02-14 16:46:29 +01:00
|
|
|
if (ctx->vg_twist)
|
|
|
|
MEM_freeN(ctx->vg_twist);
|
2007-12-04 13:57:28 +00:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
if (ctx->sim.psys->lattice_deform_data) {
|
|
|
|
end_latt_deform(ctx->sim.psys->lattice_deform_data);
|
|
|
|
ctx->sim.psys->lattice_deform_data = NULL;
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* distribution */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->jit) MEM_freeN(ctx->jit);
|
|
|
|
if (ctx->jitoff) MEM_freeN(ctx->jitoff);
|
|
|
|
if (ctx->weight) MEM_freeN(ctx->weight);
|
|
|
|
if (ctx->index) MEM_freeN(ctx->index);
|
|
|
|
if (ctx->seams) MEM_freeN(ctx->seams);
|
2012-04-21 12:51:47 +00:00
|
|
|
//if (ctx->vertpart) MEM_freeN(ctx->vertpart);
|
2007-12-04 13:57:28 +00:00
|
|
|
BLI_kdtree_free(ctx->tree);
|
2016-02-02 15:01:58 +01:00
|
|
|
|
|
|
|
if (ctx->clumpcurve != NULL) {
|
|
|
|
curvemapping_free(ctx->clumpcurve);
|
|
|
|
}
|
|
|
|
if (ctx->roughcurve != NULL) {
|
|
|
|
curvemapping_free(ctx->roughcurve);
|
|
|
|
}
|
2018-02-14 14:33:53 +01:00
|
|
|
if (ctx->twistcurve != NULL) {
|
|
|
|
curvemapping_free(ctx->twistcurve);
|
|
|
|
}
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
|
|
|
|
2014-02-05 23:37:19 +06:00
|
|
|
static void initialize_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2011-02-12 14:38:34 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
ParticleTexture ptex;
|
|
|
|
|
2015-02-14 16:40:57 +01:00
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-02-14 16:40:57 +01:00
|
|
|
switch (part->type) {
|
2018-04-16 17:08:27 +02:00
|
|
|
case PART_EMITTER:
|
|
|
|
if (ptex.exist < psys_frand(psys, p + 125)) {
|
|
|
|
pa->flag |= PARS_UNEXIST;
|
|
|
|
}
|
|
|
|
pa->time = part->sta + (part->end - part->sta)*ptex.time;
|
|
|
|
break;
|
|
|
|
case PART_HAIR:
|
|
|
|
if (ptex.exist < psys_frand(psys, p + 125)) {
|
|
|
|
pa->flag |= PARS_UNEXIST;
|
|
|
|
}
|
|
|
|
pa->time = 0.f;
|
|
|
|
break;
|
|
|
|
case PART_FLUID:
|
|
|
|
break;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2014-02-05 23:37:19 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set particle parameters that don't change during particle's life */
|
2014-07-02 12:17:43 +02:00
|
|
|
void initialize_particle(ParticleSimulationData *sim, ParticleData *pa)
|
2014-02-05 23:37:19 +06:00
|
|
|
{
|
2014-07-02 12:17:43 +02:00
|
|
|
ParticleSettings *part = sim->psys->part;
|
|
|
|
float birth_time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-02-05 23:37:19 +06:00
|
|
|
pa->flag &= ~PARS_UNEXIST;
|
2014-07-02 12:17:43 +02:00
|
|
|
pa->time = part->sta + (part->end - part->sta) * birth_time;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
pa->hair_index = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */
|
|
|
|
/* usage other than straight after distribute has to handle this index by itself - jahka*/
|
2012-03-18 07:38:51 +00:00
|
|
|
//pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we don't have a derived mesh face */
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2015-07-01 09:32:12 +02:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
static void initialize_all_particles(ParticleSimulationData *sim)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2015-07-01 10:32:30 +02:00
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
/* Grid distributionsets UNEXIST flag, need to take care of
|
|
|
|
* it here because later this flag is being reset.
|
|
|
|
*
|
|
|
|
* We can't do it for any distribution, because it'll then
|
|
|
|
* conflict with texture influence, which does not free
|
|
|
|
* unexisting particles and only sets flag.
|
|
|
|
*
|
|
|
|
* It's not so bad, because only grid distribution sets
|
|
|
|
* UNEXIST flag.
|
|
|
|
*/
|
|
|
|
const bool emit_from_volume_grid = (part->distr == PART_DISTR_GRID) &&
|
|
|
|
(!ELEM(part->from, PART_FROM_VERT, PART_FROM_CHILD));
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
2015-05-03 16:01:07 +02:00
|
|
|
LOOP_PARTICLES {
|
2015-07-01 10:32:30 +02:00
|
|
|
if (!(emit_from_volume_grid && (pa->flag & PARS_UNEXIST) != 0)) {
|
|
|
|
initialize_particle(sim, pa);
|
|
|
|
}
|
2015-05-03 16:01:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_unexisting_particles(ParticleSimulationData *sim)
|
|
|
|
{
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
PARTICLE_P;
|
|
|
|
|
2011-02-04 15:48:13 +00:00
|
|
|
psys->totunexist = 0;
|
|
|
|
|
|
|
|
LOOP_PARTICLES {
|
2015-05-03 16:01:07 +02:00
|
|
|
if (pa->flag & PARS_UNEXIST) {
|
2011-02-04 15:48:13 +00:00
|
|
|
psys->totunexist++;
|
2015-05-03 16:01:07 +02:00
|
|
|
}
|
2011-02-04 15:48:13 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totpart && psys->totunexist == psys->totpart) {
|
|
|
|
if (psys->particles->boid)
|
2011-02-04 15:48:13 +00:00
|
|
|
MEM_freeN(psys->particles->boid);
|
|
|
|
|
|
|
|
MEM_freeN(psys->particles);
|
|
|
|
psys->particles = NULL;
|
|
|
|
psys->totpart = psys->totunexist = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totunexist) {
|
2011-02-04 15:48:13 +00:00
|
|
|
int newtotpart = psys->totpart - psys->totunexist;
|
|
|
|
ParticleData *npa, *newpars;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-02-04 15:48:13 +00:00
|
|
|
npa = newpars = MEM_callocN(newtotpart * sizeof(ParticleData), "particles");
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (p=0, pa=psys->particles; p<newtotpart; p++, pa++, npa++) {
|
|
|
|
while (pa->flag & PARS_UNEXIST)
|
2011-02-04 15:48:13 +00:00
|
|
|
pa++;
|
|
|
|
|
|
|
|
memcpy(npa, pa, sizeof(ParticleData));
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles->boid)
|
2011-02-04 15:48:13 +00:00
|
|
|
MEM_freeN(psys->particles->boid);
|
|
|
|
MEM_freeN(psys->particles);
|
|
|
|
psys->particles = newpars;
|
|
|
|
psys->totpart -= psys->totunexist;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles->boid) {
|
2011-02-04 15:48:13 +00:00
|
|
|
BoidParticle *newboids = MEM_callocN(psys->totpart * sizeof(BoidParticle), "boid particles");
|
|
|
|
|
2015-07-01 09:32:12 +02:00
|
|
|
LOOP_PARTICLES {
|
2011-02-04 15:48:13 +00:00
|
|
|
pa->boid = newboids++;
|
2015-07-01 09:32:12 +02:00
|
|
|
}
|
2011-02-04 15:48:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2012-03-20 01:00:28 +00:00
|
|
|
|
2012-07-12 20:10:41 +00:00
|
|
|
static void get_angular_velocity_vector(short avemode, ParticleKey *state, float vec[3])
|
2012-03-20 01:00:28 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (avemode) {
|
2012-03-20 01:00:28 +00:00
|
|
|
case PART_AVE_VELOCITY:
|
|
|
|
copy_v3_v3(vec, state->vel);
|
2012-10-21 05:46:41 +00:00
|
|
|
break;
|
2012-03-20 01:00:28 +00:00
|
|
|
case PART_AVE_HORIZONTAL:
|
|
|
|
{
|
|
|
|
float zvec[3];
|
|
|
|
zvec[0] = zvec[1] = 0;
|
|
|
|
zvec[2] = 1.f;
|
|
|
|
cross_v3_v3v3(vec, state->vel, zvec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PART_AVE_VERTICAL:
|
|
|
|
{
|
|
|
|
float zvec[3], temp[3];
|
|
|
|
zvec[0] = zvec[1] = 0;
|
|
|
|
zvec[2] = 1.f;
|
|
|
|
cross_v3_v3v3(temp, state->vel, zvec);
|
|
|
|
cross_v3_v3v3(vec, temp, state->vel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PART_AVE_GLOBAL_X:
|
|
|
|
vec[0] = 1.f;
|
|
|
|
vec[1] = vec[2] = 0;
|
|
|
|
break;
|
|
|
|
case PART_AVE_GLOBAL_Y:
|
|
|
|
vec[1] = 1.f;
|
|
|
|
vec[0] = vec[2] = 0;
|
|
|
|
break;
|
|
|
|
case PART_AVE_GLOBAL_Z:
|
|
|
|
vec[2] = 1.f;
|
|
|
|
vec[0] = vec[1] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-04 14:20:31 +11:00
|
|
|
void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
Object *ob = sim->ob;
|
|
|
|
ParticleSystem *psys = sim->psys;
|
2013-07-14 07:27:44 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
ParticleTexture ptex;
|
2012-10-22 08:15:51 +00:00
|
|
|
float fac, phasefac, nor[3] = {0,0,0},loc[3],vel[3] = {0.0,0.0,0.0},rot[4],q2[4];
|
|
|
|
float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3] = {0.0,0.0,0.0};
|
|
|
|
float x_vec[3] = {1.0,0.0,0.0}, utan[3] = {0.0,1.0,0.0}, vtan[3] = {0.0,0.0,1.0}, rot_vec[3] = {0.0,0.0,0.0};
|
2011-02-12 14:38:34 +00:00
|
|
|
float q_phase[4];
|
2013-07-14 07:27:44 +00:00
|
|
|
|
|
|
|
const bool use_boids = ((part->phystype == PART_PHYS_BOIDS) &&
|
|
|
|
(pa->boid != NULL));
|
|
|
|
const bool use_tangents = ((use_boids == false) &&
|
2013-07-14 10:57:43 +00:00
|
|
|
((part->tanfac != 0.0f) || (part->rotmode == PART_ROT_NOR_TAN)));
|
2013-07-14 07:27:44 +00:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
int p = pa - psys->particles;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
/* get birth location from object */
|
2013-07-14 07:27:44 +00:00
|
|
|
if (use_tangents)
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0);
|
2011-02-12 14:38:34 +00:00
|
|
|
else
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
/* get possible textural influence */
|
2011-06-12 11:09:39 +00:00
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
/* particles live in global space so */
|
|
|
|
/* let's convert: */
|
|
|
|
/* -location */
|
|
|
|
mul_m4_v3(ob->obmat, loc);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
/* -normal */
|
|
|
|
mul_mat3_m4_v3(ob->obmat, nor);
|
|
|
|
normalize_v3(nor);
|
|
|
|
|
|
|
|
/* -tangent */
|
2013-07-14 07:27:44 +00:00
|
|
|
if (use_tangents) {
|
2012-05-15 12:07:44 +00:00
|
|
|
//float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
|
2011-02-12 14:38:34 +00:00
|
|
|
float phase=0.0f;
|
2012-05-15 12:07:44 +00:00
|
|
|
mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase)));
|
2011-11-06 14:00:55 +00:00
|
|
|
fac= -sinf((float)M_PI*(part->tanphase+phase));
|
|
|
|
madd_v3_v3fl(vtan, utan, fac);
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2012-05-15 12:07:44 +00:00
|
|
|
mul_mat3_m4_v3(ob->obmat,vtan);
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(utan, nor);
|
2012-05-15 12:07:44 +00:00
|
|
|
mul_v3_fl(utan,dot_v3v3(vtan,nor));
|
2011-11-06 14:00:55 +00:00
|
|
|
sub_v3_v3(vtan, utan);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
normalize_v3(vtan);
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-10-15 01:42:26 +00:00
|
|
|
/* -velocity (boids need this even if there's no random velocity) */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)) {
|
2014-03-07 10:25:56 +01:00
|
|
|
r_vel[0] = 2.0f * (psys_frand(psys, p + 10) - 0.5f);
|
|
|
|
r_vel[1] = 2.0f * (psys_frand(psys, p + 11) - 0.5f);
|
|
|
|
r_vel[2] = 2.0f * (psys_frand(psys, p + 12) - 0.5f);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
mul_mat3_m4_v3(ob->obmat, r_vel);
|
|
|
|
normalize_v3(r_vel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -angular velocity */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->avemode==PART_AVE_RAND) {
|
2014-03-07 10:25:56 +01:00
|
|
|
r_ave[0] = 2.0f * (psys_frand(psys, p + 13) - 0.5f);
|
|
|
|
r_ave[1] = 2.0f * (psys_frand(psys, p + 14) - 0.5f);
|
|
|
|
r_ave[2] = 2.0f * (psys_frand(psys, p + 15) - 0.5f);
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2012-05-15 12:07:44 +00:00
|
|
|
mul_mat3_m4_v3(ob->obmat,r_ave);
|
2011-02-12 14:38:34 +00:00
|
|
|
normalize_v3(r_ave);
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
/* -rotation */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randrotfac != 0.0f) {
|
2014-03-07 10:25:56 +01:00
|
|
|
r_rot[0] = 2.0f * (psys_frand(psys, p + 16) - 0.5f);
|
|
|
|
r_rot[1] = 2.0f * (psys_frand(psys, p + 17) - 0.5f);
|
|
|
|
r_rot[2] = 2.0f * (psys_frand(psys, p + 18) - 0.5f);
|
|
|
|
r_rot[3] = 2.0f * (psys_frand(psys, p + 19) - 0.5f);
|
2011-02-12 14:38:34 +00:00
|
|
|
normalize_qt(r_rot);
|
|
|
|
|
2012-05-15 12:07:44 +00:00
|
|
|
mat4_to_quat(rot,ob->obmat);
|
|
|
|
mul_qt_qtqt(r_rot,r_rot,rot);
|
2011-02-12 14:38:34 +00:00
|
|
|
}
|
2008-09-23 12:53:00 +00:00
|
|
|
|
2013-07-14 07:27:44 +00:00
|
|
|
if (use_boids) {
|
2009-07-20 23:52:53 +00:00
|
|
|
float dvec[3], q[4], mat[3][3];
|
|
|
|
|
2012-05-15 12:07:44 +00:00
|
|
|
copy_v3_v3(state->co,loc);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* boids don't get any initial velocity */
|
2011-06-12 11:09:39 +00:00
|
|
|
zero_v3(state->vel);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* boids store direction in ave */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (fabsf(nor[2])==1.0f) {
|
2011-06-12 11:09:39 +00:00
|
|
|
sub_v3_v3v3(state->ave, loc, ob->obmat[3]);
|
|
|
|
normalize_v3(state->ave);
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(state->ave, nor);
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
2009-09-04 23:06:15 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* calculate rotation matrix */
|
2011-06-12 11:09:39 +00:00
|
|
|
project_v3_v3v3(dvec, r_vel, state->ave);
|
|
|
|
sub_v3_v3v3(mat[0], state->ave, dvec);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(mat[0]);
|
2010-02-26 09:02:52 +00:00
|
|
|
negate_v3_v3(mat[2], r_vel);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(mat[2]);
|
|
|
|
cross_v3_v3v3(mat[1], mat[2], mat[0]);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* apply rotation */
|
2012-05-15 12:07:44 +00:00
|
|
|
mat3_to_quat_is_ok( q,mat);
|
2011-06-12 11:09:39 +00:00
|
|
|
copy_qt_qt(state->rot, q);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
else {
|
|
|
|
/* conversion done so now we apply new: */
|
|
|
|
/* -velocity from: */
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *reactions */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dtime > 0.f) {
|
2011-02-12 14:38:34 +00:00
|
|
|
sub_v3_v3v3(vel, pa->state.vel, pa->prev_state.vel);
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *emitter velocity */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dtime != 0.f && part->obfac != 0.f) {
|
2011-06-12 11:09:39 +00:00
|
|
|
sub_v3_v3v3(vel, loc, state->co);
|
2011-02-12 14:38:34 +00:00
|
|
|
mul_v3_fl(vel, part->obfac/dtime);
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *emitter normal */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->normfac != 0.f)
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, nor, part->normfac);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *emitter tangent */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sim->psmd && part->tanfac != 0.f)
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, vtan, part->tanfac);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
/* *emitter object orientation */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->ob_vel[0] != 0.f) {
|
2010-08-15 15:14:08 +00:00
|
|
|
normalize_v3_v3(vec, ob->obmat[0]);
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, vec, part->ob_vel[0]);
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->ob_vel[1] != 0.f) {
|
2010-08-15 15:14:08 +00:00
|
|
|
normalize_v3_v3(vec, ob->obmat[1]);
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, vec, part->ob_vel[1]);
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->ob_vel[2] != 0.f) {
|
2010-08-15 15:14:08 +00:00
|
|
|
normalize_v3_v3(vec, ob->obmat[2]);
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, vec, part->ob_vel[2]);
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *texture */
|
|
|
|
/* TODO */
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *random */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randfac != 0.f)
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, r_vel, part->randfac);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* *particle */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->partfac != 0.f)
|
2011-02-12 14:38:34 +00:00
|
|
|
madd_v3_v3fl(vel, p_vel, part->partfac);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
mul_v3_v3fl(state->vel, vel, ptex.ivel);
|
2008-01-01 01:00:05 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* -location from emitter */
|
2012-05-15 12:07:44 +00:00
|
|
|
copy_v3_v3(state->co,loc);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* -rotation */
|
2011-06-12 11:09:39 +00:00
|
|
|
unit_qt(state->rot);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->rotmode) {
|
2013-07-12 08:41:27 +00:00
|
|
|
bool use_global_space;
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* create vector into which rotation is aligned */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (part->rotmode) {
|
2009-07-20 23:52:53 +00:00
|
|
|
case PART_ROT_NOR:
|
2013-07-14 10:57:43 +00:00
|
|
|
case PART_ROT_NOR_TAN:
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(rot_vec, nor);
|
2013-07-12 08:41:27 +00:00
|
|
|
use_global_space = false;
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case PART_ROT_VEL:
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(rot_vec, vel);
|
2013-07-12 08:41:27 +00:00
|
|
|
use_global_space = true;
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case PART_ROT_GLOB_X:
|
|
|
|
case PART_ROT_GLOB_Y:
|
|
|
|
case PART_ROT_GLOB_Z:
|
|
|
|
rot_vec[part->rotmode - PART_ROT_GLOB_X] = 1.0f;
|
2013-07-12 08:41:27 +00:00
|
|
|
use_global_space = true;
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case PART_ROT_OB_X:
|
|
|
|
case PART_ROT_OB_Y:
|
|
|
|
case PART_ROT_OB_Z:
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
|
2013-07-12 08:41:27 +00:00
|
|
|
use_global_space = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
use_global_space = true;
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* create rotation quat */
|
2013-07-14 07:27:44 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2013-07-12 08:41:27 +00:00
|
|
|
if (use_global_space) {
|
2013-07-14 07:27:44 +00:00
|
|
|
negate_v3(rot_vec);
|
2013-07-12 08:41:27 +00:00
|
|
|
vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ);
|
|
|
|
|
|
|
|
/* randomize rotation quat */
|
|
|
|
if (part->randrotfac != 0.0f) {
|
|
|
|
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy_qt_qt(rot, q2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* calculate rotation in local-space */
|
|
|
|
float q_obmat[4];
|
|
|
|
float q_imat[4];
|
|
|
|
|
|
|
|
mat4_to_quat(q_obmat, ob->obmat);
|
2015-10-24 03:51:00 +11:00
|
|
|
invert_qt_qt_normalized(q_imat, q_obmat);
|
2013-07-12 08:41:27 +00:00
|
|
|
|
2013-07-14 07:27:44 +00:00
|
|
|
|
2013-07-14 10:57:43 +00:00
|
|
|
if (part->rotmode != PART_ROT_NOR_TAN) {
|
2013-07-14 07:27:44 +00:00
|
|
|
float rot_vec_local[3];
|
|
|
|
|
|
|
|
/* rot_vec */
|
|
|
|
negate_v3(rot_vec);
|
|
|
|
copy_v3_v3(rot_vec_local, rot_vec);
|
|
|
|
mul_qt_v3(q_imat, rot_vec_local);
|
|
|
|
normalize_v3(rot_vec_local);
|
|
|
|
|
|
|
|
vec_to_quat(q2, rot_vec_local, OB_POSX, OB_POSZ);
|
|
|
|
}
|
|
|
|
else {
|
2013-07-14 10:57:43 +00:00
|
|
|
/* (part->rotmode == PART_ROT_NOR_TAN) */
|
2013-07-14 07:27:44 +00:00
|
|
|
float tmat[3][3];
|
|
|
|
|
|
|
|
/* note: utan_local is not taken from 'utan', we calculate from rot_vec/vtan */
|
|
|
|
/* note: it looks like rotation phase may be applied twice (once with vtan, again below)
|
|
|
|
* however this isn't the case - campbell */
|
|
|
|
float *rot_vec_local = tmat[0];
|
|
|
|
float *vtan_local = tmat[1];
|
|
|
|
float *utan_local = tmat[2];
|
|
|
|
|
|
|
|
/* use tangents */
|
|
|
|
BLI_assert(use_tangents == true);
|
|
|
|
|
|
|
|
/* rot_vec */
|
|
|
|
copy_v3_v3(rot_vec_local, rot_vec);
|
|
|
|
mul_qt_v3(q_imat, rot_vec_local);
|
|
|
|
|
|
|
|
/* vtan_local */
|
|
|
|
copy_v3_v3(vtan_local, vtan); /* flips, cant use */
|
|
|
|
mul_qt_v3(q_imat, vtan_local);
|
|
|
|
|
|
|
|
/* ensure orthogonal matrix (rot_vec aligned) */
|
|
|
|
cross_v3_v3v3(utan_local, vtan_local, rot_vec_local);
|
|
|
|
cross_v3_v3v3(vtan_local, utan_local, rot_vec_local);
|
|
|
|
|
|
|
|
/* note: no need to normalize */
|
|
|
|
mat3_to_quat(q2, tmat);
|
|
|
|
}
|
2013-07-12 08:41:27 +00:00
|
|
|
|
|
|
|
/* randomize rotation quat */
|
|
|
|
if (part->randrotfac != 0.0f) {
|
|
|
|
mul_qt_qtqt(r_rot, r_rot, q_imat);
|
|
|
|
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy_qt_qt(rot, q2);
|
|
|
|
}
|
|
|
|
|
|
|
|
mul_qt_qtqt(rot, q_obmat, rot);
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* rotation phase */
|
|
|
|
phasefac = part->phasefac;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randphasefac != 0.0f)
|
2015-04-13 19:16:40 +05:00
|
|
|
phasefac += part->randphasefac * psys_frand(psys, p + 20);
|
2012-05-15 12:07:44 +00:00
|
|
|
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* combine base rotation & phase */
|
2011-06-12 11:09:39 +00:00
|
|
|
mul_qt_qtqt(state->rot, rot, q_phase);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/* -angular velocity */
|
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
zero_v3(state->ave);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->avemode) {
|
|
|
|
if (part->avemode == PART_AVE_RAND)
|
2012-03-20 01:00:28 +00:00
|
|
|
copy_v3_v3(state->ave, r_ave);
|
|
|
|
else
|
|
|
|
get_angular_velocity_vector(part->avemode, state, state->ave);
|
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
normalize_v3(state->ave);
|
|
|
|
mul_v3_fl(state->ave, part->avefac);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
2011-06-12 11:09:39 +00:00
|
|
|
}
|
2014-05-02 09:55:02 +02:00
|
|
|
|
|
|
|
/* recursively evaluate emitter parent anim at cfra */
|
2018-04-06 12:07:27 +02:00
|
|
|
static void evaluate_emitter_anim(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float cfra)
|
2014-05-02 09:55:02 +02:00
|
|
|
{
|
|
|
|
if (ob->parent)
|
2018-04-06 12:07:27 +02:00
|
|
|
evaluate_emitter_anim(depsgraph, scene, ob->parent, cfra);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-05-02 09:55:02 +02:00
|
|
|
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
|
2018-05-31 12:52:13 +02:00
|
|
|
BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_object_where_is_calc_time(depsgraph, scene, ob, cfra);
|
2014-05-02 09:55:02 +02:00
|
|
|
}
|
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
/* sets particle to the emitter surface with initial velocity & rotation */
|
|
|
|
void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
|
|
|
|
{
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part;
|
|
|
|
ParticleTexture ptex;
|
|
|
|
int p = pa - psys->particles;
|
|
|
|
part=psys->part;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
/* get precise emitter matrix if particle is born */
|
2017-06-02 15:38:04 +10:00
|
|
|
if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
|
2018-04-06 12:07:27 +02:00
|
|
|
evaluate_emitter_anim(sim->depsgraph, sim->scene, sim->ob, pa->time);
|
2012-03-19 18:14:24 +00:00
|
|
|
|
|
|
|
psys->flag |= PSYS_OB_ANIM_RESTORE;
|
2011-06-12 11:09:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-04 14:20:31 +11:00
|
|
|
psys_get_birth_coords(sim, pa, &pa->state, dtime, cfra);
|
2011-06-12 11:09:39 +00:00
|
|
|
|
2014-02-05 23:37:19 +06:00
|
|
|
/* Initialize particle settings which depends on texture.
|
|
|
|
*
|
|
|
|
* We could only do it now because we'll need to know coordinate
|
|
|
|
* before sampling the texture.
|
|
|
|
*/
|
|
|
|
initialize_particle_texture(sim, pa, p);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
|
2011-06-12 11:09:39 +00:00
|
|
|
BoidParticle *bpa = pa->boid;
|
|
|
|
|
|
|
|
/* and gravity in r_ve */
|
|
|
|
bpa->gravity[0] = bpa->gravity[1] = 0.0f;
|
|
|
|
bpa->gravity[2] = -1.0f;
|
2012-04-21 15:11:03 +00:00
|
|
|
if ((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) &&
|
|
|
|
(sim->scene->physics_settings.gravity[2] != 0.0f))
|
|
|
|
{
|
2011-06-12 11:09:39 +00:00
|
|
|
bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2011-06-12 11:09:39 +00:00
|
|
|
|
|
|
|
bpa->data.health = part->boids->health;
|
|
|
|
bpa->data.mode = eBoidMode_InAir;
|
|
|
|
bpa->data.state_id = ((BoidState*)part->boids->states.first)->id;
|
|
|
|
bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->type == PART_HAIR) {
|
2010-09-03 06:12:40 +00:00
|
|
|
pa->lifetime = 100.0f;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2013-10-29 14:48:25 +00:00
|
|
|
/* initialize the lifetime, in case the texture coordinates
|
|
|
|
* are from Particles/Strands, which would cause undefined values
|
|
|
|
*/
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->lifetime = part->lifetime * (1.0f - part->randlife * psys_frand(psys, p + 21));
|
2013-10-29 14:48:25 +00:00
|
|
|
pa->dietime = pa->time + pa->lifetime;
|
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
/* get possible textural influence */
|
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra);
|
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
pa->lifetime = part->lifetime * ptex.life;
|
2010-09-03 06:12:40 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randlife != 0.0f)
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->lifetime *= 1.0f - part->randlife * psys_frand(psys, p + 21);
|
2010-09-03 06:12:40 +00:00
|
|
|
}
|
|
|
|
|
2008-01-01 01:00:05 +00:00
|
|
|
pa->dietime = pa->time + pa->lifetime;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2018-04-16 17:08:27 +02:00
|
|
|
if ((sim->psys->pointcache) &&
|
|
|
|
(sim->psys->pointcache->flag & PTCACHE_BAKED) &&
|
|
|
|
(sim->psys->pointcache->mem_cache.first))
|
|
|
|
{
|
2010-09-02 10:26:19 +00:00
|
|
|
float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p);
|
|
|
|
pa->dietime = MIN2(pa->dietime, dietime);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->time > cfra)
|
2008-01-01 01:00:05 +00:00
|
|
|
pa->alive = PARS_UNBORN;
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pa->dietime <= cfra)
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pa->alive = PARS_DEAD;
|
|
|
|
else
|
|
|
|
pa->alive = PARS_ALIVE;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2008-01-01 01:00:05 +00:00
|
|
|
pa->state.time = cfra;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2009-09-17 22:00:49 +00:00
|
|
|
static void reset_all_particles(ParticleSimulationData *sim, float dtime, float cfra, int from)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
|
|
|
ParticleData *pa;
|
2009-09-17 22:00:49 +00:00
|
|
|
int p, totpart=sim->psys->totpart;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (p=from, pa=sim->psys->particles+from; p<totpart; p++, pa++)
|
2009-09-17 22:00:49 +00:00
|
|
|
reset_particle(sim, pa, dtime, cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
/************************************************/
|
2009-07-20 23:52:53 +00:00
|
|
|
/* Particle targets */
|
|
|
|
/************************************************/
|
|
|
|
ParticleSystem *psys_get_target_system(Object *ob, ParticleTarget *pt)
|
|
|
|
{
|
|
|
|
ParticleSystem *psys = NULL;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pt->ob == NULL || pt->ob == ob)
|
2009-07-20 23:52:53 +00:00
|
|
|
psys = BLI_findlink(&ob->particlesystem, pt->psys-1);
|
|
|
|
else
|
|
|
|
psys = BLI_findlink(&pt->ob->particlesystem, pt->psys-1);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys)
|
2009-07-20 23:52:53 +00:00
|
|
|
pt->flag |= PTARGET_VALID;
|
|
|
|
else
|
|
|
|
pt->flag &= ~PTARGET_VALID;
|
|
|
|
|
|
|
|
return psys;
|
|
|
|
}
|
|
|
|
/************************************************/
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* Keyed particles */
|
|
|
|
/************************************************/
|
2009-07-12 23:38:47 +00:00
|
|
|
/* Counts valid keyed targets */
|
2009-09-17 22:00:49 +00:00
|
|
|
void psys_count_keyed_targets(ParticleSimulationData *sim)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys, *kpsys;
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt = psys->targets.first;
|
2009-07-12 23:38:47 +00:00
|
|
|
int keys_valid = 1;
|
|
|
|
psys->totkeyed = 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (; pt; pt=pt->next) {
|
2009-09-17 22:00:49 +00:00
|
|
|
kpsys = psys_get_target_system(sim->ob, pt);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (kpsys && kpsys->totpart) {
|
2009-07-20 23:52:53 +00:00
|
|
|
psys->totkeyed += keys_valid;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f)
|
2009-07-20 23:52:53 +00:00
|
|
|
psys->totkeyed += 1;
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-07-20 23:52:53 +00:00
|
|
|
keys_valid = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
psys->totkeyed *= psys->flag & PSYS_KEYED_TIMING ? 1 : psys->part->keyed_loops;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
static void set_keyed_keys(ParticleSimulationData *sim)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2010-11-05 13:37:18 +00:00
|
|
|
ParticleSimulationData ksim= {0};
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt;
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
|
|
|
ParticleKey *key;
|
|
|
|
int totpart = psys->totpart, k, totkeys = psys->totkeyed;
|
2011-06-12 11:09:39 +00:00
|
|
|
int keyed_flag = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
ksim.depsgraph = sim->depsgraph;
|
2017-07-21 11:53:13 +02:00
|
|
|
ksim.scene = sim->scene;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* no proper targets so let's clear and bail out */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totkeyed==0) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
free_keyed_keys(psys);
|
|
|
|
psys->flag &= ~PSYS_KEYED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totpart && psys->particles->totkey != totkeys) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
free_keyed_keys(psys);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
key = MEM_callocN(totpart*totkeys*sizeof(ParticleKey), "Keyed keys");
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES {
|
|
|
|
pa->keys = key;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
pa->totkey = totkeys;
|
2009-09-04 23:06:15 +00:00
|
|
|
key += totkeys;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
psys->flag &= ~PSYS_KEYED;
|
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (k=0; k<totkeys; k++) {
|
2009-09-17 22:00:49 +00:00
|
|
|
ksim.ob = pt->ob ? pt->ob : sim->ob;
|
|
|
|
ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1);
|
2011-06-12 11:09:39 +00:00
|
|
|
keyed_flag = (ksim.psys->flag & PSYS_KEYED);
|
|
|
|
ksim.psys->flag &= ~PSYS_KEYED;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES {
|
|
|
|
key = pa->keys + k;
|
|
|
|
key->time = -1.0; /* use current time */
|
2009-06-08 20:08:19 +00:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
psys_get_particle_state(&ksim, p%ksim.psys->totpart, key, 1);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->flag & PSYS_KEYED_TIMING) {
|
2009-09-04 23:06:15 +00:00
|
|
|
key->time = pa->time + pt->time;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pt->duration != 0.0f && k+1 < totkeys) {
|
2009-09-04 23:06:15 +00:00
|
|
|
copy_particle_key(key+1, key, 1);
|
|
|
|
(key+1)->time = pa->time + pt->time + pt->duration;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (totkeys > 1)
|
2009-09-04 23:06:15 +00:00
|
|
|
key->time = pa->time + (float)k / (float)(totkeys - 1) * pa->lifetime;
|
2009-07-12 23:38:47 +00:00
|
|
|
else
|
2009-09-04 23:06:15 +00:00
|
|
|
key->time = pa->time;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2017-06-02 15:38:04 +10:00
|
|
|
if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f)
|
2009-07-12 23:38:47 +00:00
|
|
|
k++;
|
|
|
|
|
2011-06-12 11:09:39 +00:00
|
|
|
ksim.psys->flag |= keyed_flag;
|
|
|
|
|
2013-03-31 03:28:46 +00:00
|
|
|
pt = (pt->next && pt->next->flag & PTARGET_VALID) ? pt->next : psys->targets.first;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
psys->flag |= PSYS_KEYED;
|
|
|
|
}
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Point Cache */
|
|
|
|
/************************************************/
|
2009-07-12 23:38:47 +00:00
|
|
|
void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
|
|
|
|
{
|
|
|
|
PointCache *cache = psys->pointcache;
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
if (cache->flag & PTCACHE_DISK_CACHE && BLI_listbase_is_empty(&cache->mem_cache)) {
|
2010-03-21 20:36:06 +00:00
|
|
|
PTCacheID pid;
|
|
|
|
BKE_ptcache_id_from_particles(&pid, ob, psys);
|
2011-01-02 06:52:47 +00:00
|
|
|
cache->flag &= ~PTCACHE_DISK_CACHE;
|
2010-03-21 20:36:06 +00:00
|
|
|
BKE_ptcache_disk_to_mem(&pid);
|
2011-01-02 06:52:47 +00:00
|
|
|
cache->flag |= PTCACHE_DISK_CACHE;
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2009-09-14 16:52:06 +00:00
|
|
|
static void psys_clear_temp_pointcache(ParticleSystem *psys)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->pointcache->flag & PTCACHE_DISK_CACHE)
|
2010-03-21 20:36:06 +00:00
|
|
|
BKE_ptcache_free_mem(&psys->pointcache->mem_cache);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2009-06-21 10:16:52 +00:00
|
|
|
void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-06-21 10:16:52 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2015-11-23 11:27:02 +11:00
|
|
|
*sfra = max_ii(1, (int)part->sta);
|
|
|
|
*efra = min_ii((int)(part->end + part->lifetime + 1.0f), max_ii(scene->r.pefra, scene->r.efra));
|
2009-06-21 10:16:52 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Effectors */
|
|
|
|
/************************************************/
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
PARTICLE_P;
|
|
|
|
int totpart = 0;
|
2014-03-18 13:36:24 +01:00
|
|
|
bool need_rebuild;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
2014-03-18 13:36:24 +01:00
|
|
|
BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_READ);
|
|
|
|
need_rebuild = !psys->bvhtree || psys->bvhtree_frame != cfra;
|
|
|
|
BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-03-18 13:36:24 +01:00
|
|
|
if (need_rebuild) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
LOOP_SHOWN_PARTICLES {
|
|
|
|
totpart++;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-03-18 13:36:24 +01:00
|
|
|
BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_WRITE);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
BLI_bvhtree_free(psys->bvhtree);
|
|
|
|
psys->bvhtree = BLI_bvhtree_new(totpart, 0.0, 4, 6);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
LOOP_SHOWN_PARTICLES {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->alive == PARS_ALIVE) {
|
|
|
|
if (pa->state.time == cfra)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
BLI_bvhtree_insert(psys->bvhtree, p, pa->prev_state.co, 1);
|
|
|
|
else
|
|
|
|
BLI_bvhtree_insert(psys->bvhtree, p, pa->state.co, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BLI_bvhtree_balance(psys->bvhtree);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
psys->bvhtree_frame = cfra;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-03-18 13:36:24 +01:00
|
|
|
BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
void psys_update_particle_tree(ParticleSystem *psys, float cfra)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys) {
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
int totpart = 0;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!psys->tree || psys->tree_frame != cfra) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
LOOP_SHOWN_PARTICLES {
|
|
|
|
totpart++;
|
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
BLI_kdtree_free(psys->tree);
|
2009-09-04 23:06:15 +00:00
|
|
|
psys->tree = BLI_kdtree_new(psys->totpart);
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
LOOP_SHOWN_PARTICLES {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->alive == PARS_ALIVE) {
|
|
|
|
if (pa->state.time == cfra)
|
2014-03-18 09:05:07 +11:00
|
|
|
BLI_kdtree_insert(psys->tree, p, pa->prev_state.co);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
else
|
2014-03-18 09:05:07 +11:00
|
|
|
BLI_kdtree_insert(psys->tree, p, pa->state.co);
|
2009-10-01 17:15:23 +00:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
BLI_kdtree_balance(psys->tree);
|
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
psys->tree_frame = cfra;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
static void psys_update_effectors(ParticleSimulationData *sim)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2018-06-21 19:45:39 +02:00
|
|
|
BKE_effectors_free(sim->psys->effectors);
|
|
|
|
sim->psys->effectors = BKE_effectors_create(sim->depsgraph,
|
2018-06-22 14:42:03 +02:00
|
|
|
sim->ob, sim->psys,
|
2018-06-21 19:45:39 +02:00
|
|
|
sim->psys->part->effector_weights);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
precalc_guides(sim, sim->psys->effectors);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-12-02 16:01:06 +00:00
|
|
|
static void integrate_particle(ParticleSettings *part, ParticleData *pa, float dtime, float *external_acceleration,
|
|
|
|
void (*force_func)(void *forcedata, ParticleKey *state, float *force, float *impulse),
|
|
|
|
void *forcedata)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
{
|
2012-12-02 16:01:06 +00:00
|
|
|
#define ZERO_F43 {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}
|
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleKey states[5];
|
2012-12-02 16:01:06 +00:00
|
|
|
float force[3], acceleration[3], impulse[3], dx[4][3] = ZERO_F43, dv[4][3] = ZERO_F43, oldpos[3];
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float pa_mass= (part->flag & PART_SIZEMASS ? part->mass * pa->size : part->mass);
|
|
|
|
int i, steps=1;
|
2011-03-28 08:08:59 +00:00
|
|
|
int integrator = part->integrator;
|
|
|
|
|
2012-12-02 16:01:06 +00:00
|
|
|
#undef ZERO_F43
|
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
copy_v3_v3(oldpos, pa->state.co);
|
2012-12-02 16:01:06 +00:00
|
|
|
|
2011-03-28 08:08:59 +00:00
|
|
|
/* Verlet integration behaves strangely with moving emitters, so do first step with euler. */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
|
2011-03-28 08:08:59 +00:00
|
|
|
integrator = PART_INT_EULER;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (integrator) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
case PART_INT_EULER:
|
|
|
|
steps=1;
|
|
|
|
break;
|
|
|
|
case PART_INT_MIDPOINT:
|
|
|
|
steps=2;
|
|
|
|
break;
|
|
|
|
case PART_INT_RK4:
|
|
|
|
steps=4;
|
|
|
|
break;
|
|
|
|
case PART_INT_VERLET:
|
|
|
|
steps=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-17 13:28:30 +00:00
|
|
|
for (i=0; i<steps; i++) {
|
|
|
|
copy_particle_key(states + i, &pa->state, 1);
|
|
|
|
}
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
|
|
|
states->time = 0.f;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0; i<steps; i++) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
zero_v3(force);
|
|
|
|
zero_v3(impulse);
|
|
|
|
|
|
|
|
force_func(forcedata, states+i, force, impulse);
|
|
|
|
|
|
|
|
/* force to acceleration*/
|
|
|
|
mul_v3_v3fl(acceleration, force, 1.0f/pa_mass);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (external_acceleration)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
add_v3_v3(acceleration, external_acceleration);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* calculate next state */
|
|
|
|
add_v3_v3(states[i].vel, impulse);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (integrator) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
case PART_INT_EULER:
|
|
|
|
madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime);
|
|
|
|
madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);
|
|
|
|
break;
|
|
|
|
case PART_INT_MIDPOINT:
|
2012-03-24 06:18:31 +00:00
|
|
|
if (i==0) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
madd_v3_v3v3fl(states[1].co, states->co, states->vel, dtime*0.5f);
|
|
|
|
madd_v3_v3v3fl(states[1].vel, states->vel, acceleration, dtime*0.5f);
|
|
|
|
states[1].time = dtime*0.5f;
|
|
|
|
/*fra=sim->psys->cfra+0.5f*dfra;*/
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
madd_v3_v3v3fl(pa->state.co, states->co, states[1].vel, dtime);
|
|
|
|
madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PART_INT_RK4:
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (i) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
case 0:
|
|
|
|
copy_v3_v3(dx[0], states->vel);
|
|
|
|
mul_v3_fl(dx[0], dtime);
|
|
|
|
copy_v3_v3(dv[0], acceleration);
|
|
|
|
mul_v3_fl(dv[0], dtime);
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(states[1].co, states->co, dx[0], 0.5f);
|
|
|
|
madd_v3_v3v3fl(states[1].vel, states->vel, dv[0], 0.5f);
|
|
|
|
states[1].time = dtime*0.5f;
|
|
|
|
/*fra=sim->psys->cfra+0.5f*dfra;*/
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
madd_v3_v3v3fl(dx[1], states->vel, dv[0], 0.5f);
|
|
|
|
mul_v3_fl(dx[1], dtime);
|
|
|
|
copy_v3_v3(dv[1], acceleration);
|
|
|
|
mul_v3_fl(dv[1], dtime);
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(states[2].co, states->co, dx[1], 0.5f);
|
|
|
|
madd_v3_v3v3fl(states[2].vel, states->vel, dv[1], 0.5f);
|
|
|
|
states[2].time = dtime*0.5f;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
madd_v3_v3v3fl(dx[2], states->vel, dv[1], 0.5f);
|
|
|
|
mul_v3_fl(dx[2], dtime);
|
|
|
|
copy_v3_v3(dv[2], acceleration);
|
|
|
|
mul_v3_fl(dv[2], dtime);
|
|
|
|
|
|
|
|
add_v3_v3v3(states[3].co, states->co, dx[2]);
|
|
|
|
add_v3_v3v3(states[3].vel, states->vel, dv[2]);
|
|
|
|
states[3].time = dtime;
|
|
|
|
/*fra=cfra;*/
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
add_v3_v3v3(dx[3], states->vel, dv[2]);
|
|
|
|
mul_v3_fl(dx[3], dtime);
|
|
|
|
copy_v3_v3(dv[3], acceleration);
|
|
|
|
mul_v3_fl(dv[3], dtime);
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(pa->state.co, states->co, dx[0], 1.0f/6.0f);
|
|
|
|
madd_v3_v3fl(pa->state.co, dx[1], 1.0f/3.0f);
|
|
|
|
madd_v3_v3fl(pa->state.co, dx[2], 1.0f/3.0f);
|
|
|
|
madd_v3_v3fl(pa->state.co, dx[3], 1.0f/6.0f);
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(pa->state.vel, states->vel, dv[0], 1.0f/6.0f);
|
|
|
|
madd_v3_v3fl(pa->state.vel, dv[1], 1.0f/3.0f);
|
|
|
|
madd_v3_v3fl(pa->state.vel, dv[2], 1.0f/3.0f);
|
|
|
|
madd_v3_v3fl(pa->state.vel, dv[3], 1.0f/6.0f);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PART_INT_VERLET: /* Verlet integration */
|
|
|
|
madd_v3_v3v3fl(pa->state.vel, pa->prev_state.vel, acceleration, dtime);
|
|
|
|
madd_v3_v3v3fl(pa->state.co, pa->prev_state.co, pa->state.vel, dtime);
|
|
|
|
|
|
|
|
sub_v3_v3v3(pa->state.vel, pa->state.co, oldpos);
|
|
|
|
mul_v3_fl(pa->state.vel, 1.0f/dtime);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
/*********************************************************************************************************
|
2018-06-01 18:19:39 +02:00
|
|
|
* SPH fluid physics
|
2012-03-03 20:19:11 +00:00
|
|
|
*
|
|
|
|
* In theory, there could be unlimited implementation of SPH simulators
|
|
|
|
*
|
|
|
|
* This code uses in some parts adapted algorithms from the pseudo code as outlined in the Research paper:
|
|
|
|
*
|
|
|
|
* Titled: Particle-based Viscoelastic Fluid Simulation.
|
|
|
|
* Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin
|
|
|
|
* Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/
|
|
|
|
*
|
|
|
|
* Presented at Siggraph, (2005)
|
|
|
|
*
|
|
|
|
* ********************************************************************************************************/
|
2011-01-09 19:09:41 +00:00
|
|
|
#define PSYS_FLUID_SPRINGS_INITIAL_SIZE 256
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
static ParticleSpring *sph_spring_add(ParticleSystem *psys, ParticleSpring *spring)
|
2011-01-09 19:09:41 +00:00
|
|
|
{
|
|
|
|
/* Are more refs required? */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->alloc_fluidsprings == 0 || psys->fluid_springs == NULL) {
|
2011-01-09 19:09:41 +00:00
|
|
|
psys->alloc_fluidsprings = PSYS_FLUID_SPRINGS_INITIAL_SIZE;
|
|
|
|
psys->fluid_springs = (ParticleSpring*)MEM_callocN(psys->alloc_fluidsprings * sizeof(ParticleSpring), "Particle Fluid Springs");
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->tot_fluidsprings == psys->alloc_fluidsprings) {
|
2011-01-09 19:09:41 +00:00
|
|
|
/* Double the number of refs allocated */
|
|
|
|
psys->alloc_fluidsprings *= 2;
|
|
|
|
psys->fluid_springs = (ParticleSpring*)MEM_reallocN(psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring));
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(psys->fluid_springs + psys->tot_fluidsprings, spring, sizeof(ParticleSpring));
|
|
|
|
psys->tot_fluidsprings++;
|
|
|
|
|
|
|
|
return psys->fluid_springs + psys->tot_fluidsprings - 1;
|
|
|
|
}
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
static void sph_spring_delete(ParticleSystem *psys, int j)
|
2011-01-09 19:09:41 +00:00
|
|
|
{
|
|
|
|
if (j != psys->tot_fluidsprings - 1)
|
|
|
|
psys->fluid_springs[j] = psys->fluid_springs[psys->tot_fluidsprings - 1];
|
|
|
|
|
|
|
|
psys->tot_fluidsprings--;
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (psys->tot_fluidsprings < psys->alloc_fluidsprings/2 && psys->alloc_fluidsprings > PSYS_FLUID_SPRINGS_INITIAL_SIZE) {
|
2011-01-09 19:09:41 +00:00
|
|
|
psys->alloc_fluidsprings /= 2;
|
|
|
|
psys->fluid_springs = (ParticleSpring*)MEM_reallocN(psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring));
|
|
|
|
}
|
|
|
|
}
|
2011-12-30 07:55:15 +00:00
|
|
|
static void sph_springs_modify(ParticleSystem *psys, float dtime)
|
|
|
|
{
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
SPHFluidSettings *fluid = psys->part->fluid;
|
|
|
|
ParticleData *pa1, *pa2;
|
|
|
|
ParticleSpring *spring = psys->fluid_springs;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float h, d, Rij[3], rij, Lij;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
float yield_ratio = fluid->yield_ratio;
|
|
|
|
float plasticity = fluid->plasticity_constant;
|
|
|
|
/* scale things according to dtime */
|
|
|
|
float timefix = 25.f * dtime;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((fluid->flag & SPH_VISCOELASTIC_SPRINGS)==0 || fluid->spring_k == 0.f)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Loop through the springs */
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0; i<psys->tot_fluidsprings; i++, spring++) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
pa1 = psys->particles + spring->particle_index[0];
|
|
|
|
pa2 = psys->particles + spring->particle_index[1];
|
|
|
|
|
|
|
|
sub_v3_v3v3(Rij, pa2->prev_state.co, pa1->prev_state.co);
|
|
|
|
rij = normalize_v3(Rij);
|
|
|
|
|
|
|
|
/* adjust rest length */
|
|
|
|
Lij = spring->rest_length;
|
|
|
|
d = yield_ratio * timefix * Lij;
|
|
|
|
|
|
|
|
if (rij > Lij + d) // Stretch
|
|
|
|
spring->rest_length += plasticity * (rij - Lij - d) * timefix;
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (rij < Lij - d) // Compress
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
spring->rest_length -= plasticity * (Lij - d - rij) * timefix;
|
|
|
|
|
|
|
|
h = 4.f*pa1->size;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (spring->rest_length > h)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
spring->delete_flag = 1;
|
|
|
|
}
|
2011-01-09 19:09:41 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* Loop through springs backwaqrds - for efficient delete function */
|
|
|
|
for (i=psys->tot_fluidsprings-1; i >= 0; i--) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->fluid_springs[i].delete_flag)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
sph_spring_delete(psys, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static EdgeHash *sph_springhash_build(ParticleSystem *psys)
|
2011-01-09 19:09:41 +00:00
|
|
|
{
|
|
|
|
EdgeHash *springhash = NULL;
|
2011-01-11 07:38:16 +00:00
|
|
|
ParticleSpring *spring;
|
2011-01-09 19:09:41 +00:00
|
|
|
int i = 0;
|
|
|
|
|
2013-08-24 13:47:57 +00:00
|
|
|
springhash = BLI_edgehash_new_ex(__func__, psys->tot_fluidsprings);
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0, spring=psys->fluid_springs; i<psys->tot_fluidsprings; i++, spring++)
|
2011-01-09 19:09:41 +00:00
|
|
|
BLI_edgehash_insert(springhash, spring->particle_index[0], spring->particle_index[1], SET_INT_IN_POINTER(i+1));
|
|
|
|
|
|
|
|
return springhash;
|
|
|
|
}
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
2012-01-02 11:46:02 +00:00
|
|
|
#define SPH_NEIGHBORS 512
|
2012-06-06 22:38:39 +00:00
|
|
|
typedef struct SPHNeighbor {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleSystem *psys;
|
|
|
|
int index;
|
|
|
|
} SPHNeighbor;
|
2012-06-06 22:38:39 +00:00
|
|
|
|
|
|
|
typedef struct SPHRangeData {
|
2012-01-02 11:46:02 +00:00
|
|
|
SPHNeighbor neighbors[SPH_NEIGHBORS];
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
int tot_neighbors;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
float* data;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleSystem *npsys;
|
|
|
|
ParticleData *pa;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
float h;
|
2013-01-08 04:28:44 +00:00
|
|
|
float mass;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float massfac;
|
|
|
|
int use_size;
|
|
|
|
} SPHRangeData;
|
2012-04-21 13:37:26 +00:00
|
|
|
|
2012-12-18 01:52:18 +00:00
|
|
|
static void sph_evaluate_func(BVHTree *tree, ParticleSystem **psys, float co[3], SPHRangeData *pfr, float interaction_radius, BVHTree_RangeQuery callback)
|
|
|
|
{
|
2012-12-14 04:57:26 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
pfr->tot_neighbors = 0;
|
|
|
|
|
|
|
|
for (i=0; i < 10 && psys[i]; i++) {
|
|
|
|
pfr->npsys = psys[i];
|
2013-01-08 04:28:44 +00:00
|
|
|
pfr->massfac = psys[i]->part->mass / pfr->mass;
|
2012-12-14 04:57:26 +00:00
|
|
|
pfr->use_size = psys[i]->part->flag & PART_SIZEMASS;
|
2012-01-02 12:10:50 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
if (tree) {
|
|
|
|
BLI_bvhtree_range_query(tree, co, interaction_radius, callback, pfr);
|
|
|
|
break;
|
2012-12-18 01:46:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-03-18 13:36:24 +01:00
|
|
|
BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_READ);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
BLI_bvhtree_range_query(psys[i]->bvhtree, co, interaction_radius, callback, pfr);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-03-18 13:36:24 +01:00
|
|
|
BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
|
2012-12-14 04:57:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 17:16:50 +11:00
|
|
|
static void sph_density_accum_cb(void *userdata, int index, const float co[3], float squared_dist)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
{
|
|
|
|
SPHRangeData *pfr = (SPHRangeData *)userdata;
|
|
|
|
ParticleData *npa = pfr->npsys->particles + index;
|
|
|
|
float q;
|
2011-09-25 11:51:28 +00:00
|
|
|
float dist;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2016-03-19 17:16:50 +11:00
|
|
|
UNUSED_VARS(co);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (npa == pfr->pa || squared_dist < FLT_EPSILON)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
return;
|
2011-02-23 10:42:27 +00:00
|
|
|
|
2012-01-02 11:46:02 +00:00
|
|
|
/* Ugh! One particle has too many neighbors! If some aren't taken into
|
|
|
|
* account, the forces will be biased by the tree search order. This
|
|
|
|
* effectively adds enery to the system, and results in a churning motion.
|
|
|
|
* But, we have to stop somewhere, and it's not the end of the world.
|
|
|
|
* - jahka and z0r
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
*/
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pfr->tot_neighbors >= SPH_NEIGHBORS)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
return;
|
2011-09-25 11:51:28 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
pfr->neighbors[pfr->tot_neighbors].index = index;
|
|
|
|
pfr->neighbors[pfr->tot_neighbors].psys = pfr->npsys;
|
|
|
|
pfr->tot_neighbors++;
|
2010-11-18 19:12:36 +00:00
|
|
|
|
2011-09-25 11:51:28 +00:00
|
|
|
dist = sqrtf(squared_dist);
|
|
|
|
q = (1.f - dist/pfr->h) * pfr->massfac;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pfr->use_size)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
q *= npa->size;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
pfr->data[0] += q*q;
|
|
|
|
pfr->data[1] += q*q*q;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
}
|
2012-02-25 16:49:59 +00:00
|
|
|
|
2012-01-02 11:46:02 +00:00
|
|
|
/*
|
|
|
|
* Find the Courant number for an SPH particle (used for adaptive time step).
|
|
|
|
*/
|
2012-02-25 16:49:59 +00:00
|
|
|
static void sph_particle_courant(SPHData *sphdata, SPHRangeData *pfr)
|
|
|
|
{
|
2012-01-02 11:46:02 +00:00
|
|
|
ParticleData *pa, *npa;
|
|
|
|
int i;
|
|
|
|
float flow[3], offset[3], dist;
|
|
|
|
|
2012-07-17 12:05:15 +00:00
|
|
|
zero_v3(flow);
|
|
|
|
|
2012-01-02 11:46:02 +00:00
|
|
|
dist = 0.0f;
|
|
|
|
if (pfr->tot_neighbors > 0) {
|
|
|
|
pa = pfr->pa;
|
|
|
|
for (i=0; i < pfr->tot_neighbors; i++) {
|
|
|
|
npa = pfr->neighbors[i].psys->particles + pfr->neighbors[i].index;
|
|
|
|
sub_v3_v3v3(offset, pa->prev_state.co, npa->prev_state.co);
|
|
|
|
dist += len_v3(offset);
|
|
|
|
add_v3_v3(flow, npa->prev_state.vel);
|
|
|
|
}
|
|
|
|
dist += sphdata->psys[0]->part->fluid->radius; // TODO: remove this? - z0r
|
|
|
|
sphdata->element_size = dist / pfr->tot_neighbors;
|
|
|
|
mul_v3_v3fl(sphdata->flow, flow, 1.0f / pfr->tot_neighbors);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-08-14 10:36:07 +10:00
|
|
|
sphdata->element_size = FLT_MAX;
|
2012-03-09 06:04:17 +00:00
|
|
|
copy_v3_v3(sphdata->flow, flow);
|
2012-01-02 11:46:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-12 14:21:04 +00:00
|
|
|
static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, float *UNUSED(impulse))
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
{
|
|
|
|
SPHData *sphdata = (SPHData *)sphdata_v;
|
|
|
|
ParticleSystem **psys = sphdata->psys;
|
|
|
|
ParticleData *pa = sphdata->pa;
|
|
|
|
SPHFluidSettings *fluid = psys[0]->part->fluid;
|
|
|
|
ParticleSpring *spring = NULL;
|
|
|
|
SPHRangeData pfr;
|
|
|
|
SPHNeighbor *pfn;
|
|
|
|
float *gravity = sphdata->gravity;
|
|
|
|
EdgeHash *springhash = sphdata->eh;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float q, u, rij, dv[3];
|
|
|
|
float pressure, near_pressure;
|
2011-02-23 10:42:27 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float visc = fluid->viscosity_omega;
|
|
|
|
float stiff_visc = fluid->viscosity_beta * (fluid->flag & SPH_FAC_VISCOSITY ? fluid->viscosity_omega : 1.f);
|
2010-11-18 19:12:36 +00:00
|
|
|
|
2013-01-08 04:28:44 +00:00
|
|
|
float inv_mass = 1.0f / sphdata->mass;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float spring_constant = fluid->spring_k;
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
/* 4.0 seems to be a pretty good value */
|
|
|
|
float interaction_radius = fluid->radius * (fluid->flag & SPH_FAC_RADIUS ? 4.0f * pa->size : 1.0f);
|
|
|
|
float h = interaction_radius * sphdata->hfac;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.f); /* 4.77 is an experimentally determined density factor */
|
|
|
|
float rest_length = fluid->rest_length * (fluid->flag & SPH_FAC_REST_LENGTH ? 2.588f * pa->size : 1.f);
|
2010-11-18 19:12:36 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float stiffness = fluid->stiffness_k;
|
|
|
|
float stiffness_near_fac = fluid->stiffness_knear * (fluid->flag & SPH_FAC_REPULSION ? fluid->stiffness_k : 1.f);
|
2010-11-18 19:12:36 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleData *npa;
|
|
|
|
float vec[3];
|
|
|
|
float vel[3];
|
|
|
|
float co[3];
|
2012-12-14 04:57:26 +00:00
|
|
|
float data[2];
|
|
|
|
float density, near_density;
|
2010-11-18 19:12:36 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
int i, spring_index, index = pa - psys[0]->particles;
|
2010-11-18 19:12:36 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
data[0] = data[1] = 0;
|
|
|
|
pfr.data = data;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
pfr.h = h;
|
|
|
|
pfr.pa = pa;
|
2013-01-08 04:28:44 +00:00
|
|
|
pfr.mass = sphdata->mass;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
sph_evaluate_func( NULL, psys, state->co, &pfr, interaction_radius, sph_density_accum_cb);
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
density = data[0];
|
|
|
|
near_density = data[1];
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
pressure = stiffness * (density - rest_density);
|
|
|
|
near_pressure = stiffness_near_fac * near_density;
|
2010-11-18 19:12:36 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
pfn = pfr.neighbors;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0; i<pfr.tot_neighbors; i++, pfn++) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
npa = pfn->psys->particles + pfn->index;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
madd_v3_v3v3fl(co, npa->prev_state.co, npa->prev_state.vel, state->time);
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
sub_v3_v3v3(vec, co, state->co);
|
|
|
|
rij = normalize_v3(vec);
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
q = (1.f - rij/h) * pfn->psys->part->mass * inv_mass;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pfn->psys->part->flag & PART_SIZEMASS)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
q *= npa->size;
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
copy_v3_v3(vel, npa->prev_state.vel);
|
2010-04-04 12:29:06 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* Double Density Relaxation */
|
|
|
|
madd_v3_v3fl(force, vec, -(pressure + near_pressure*q)*q);
|
2011-01-09 19:09:41 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* Viscosity */
|
2012-10-21 05:46:41 +00:00
|
|
|
if (visc > 0.f || stiff_visc > 0.f) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
sub_v3_v3v3(dv, vel, state->vel);
|
|
|
|
u = dot_v3v3(vec, dv);
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (u < 0.f && visc > 0.f)
|
2012-05-15 12:07:44 +00:00
|
|
|
madd_v3_v3fl(force, vec, 0.5f * q * visc * u );
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (u > 0.f && stiff_visc > 0.f)
|
2012-05-15 12:07:44 +00:00
|
|
|
madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u );
|
2011-01-09 19:09:41 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (spring_constant > 0.f) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* Viscoelastic spring force */
|
|
|
|
if (pfn->psys == psys[0] && fluid->flag & SPH_VISCOELASTIC_SPRINGS && springhash) {
|
2012-01-02 12:10:50 +00:00
|
|
|
/* BLI_edgehash_lookup appears to be thread-safe. - z0r */
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
spring_index = GET_INT_FROM_POINTER(BLI_edgehash_lookup(springhash, index, pfn->index));
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (spring_index) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
spring = psys[0]->fluid_springs + spring_index - 1;
|
2011-01-09 19:09:41 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
madd_v3_v3fl(force, vec, -10.f * spring_constant * (1.f - rij/h) * (spring->rest_length - rij));
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (fluid->spring_frames == 0 || (pa->prev_state.time-pa->time) <= fluid->spring_frames) {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleSpring temp_spring;
|
|
|
|
temp_spring.particle_index[0] = index;
|
|
|
|
temp_spring.particle_index[1] = pfn->index;
|
|
|
|
temp_spring.rest_length = (fluid->flag & SPH_CURRENT_REST_LENGTH) ? rij : rest_length;
|
|
|
|
temp_spring.delete_flag = 0;
|
2012-01-02 12:10:50 +00:00
|
|
|
|
|
|
|
/* sph_spring_add is not thread-safe. - z0r */
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
sph_spring_add(psys[0], &temp_spring);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {/* PART_SPRING_HOOKES - Hooke's spring force */
|
|
|
|
madd_v3_v3fl(force, vec, -10.f * spring_constant * (1.f - rij/h) * (rest_length - rij));
|
|
|
|
}
|
2011-01-09 19:09:41 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* Artificial buoyancy force in negative gravity direction */
|
|
|
|
if (fluid->buoyancy > 0.f && gravity)
|
2012-12-14 04:57:26 +00:00
|
|
|
madd_v3_v3fl(force, gravity, fluid->buoyancy * (density-rest_density));
|
|
|
|
|
|
|
|
if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF)
|
|
|
|
sph_particle_courant(sphdata, &pfr);
|
|
|
|
sphdata->pass++;
|
|
|
|
}
|
|
|
|
|
2016-03-19 17:16:50 +11:00
|
|
|
static void sphclassical_density_accum_cb(void *userdata, int index, const float co[3], float UNUSED(squared_dist))
|
2012-12-14 04:57:26 +00:00
|
|
|
{
|
|
|
|
SPHRangeData *pfr = (SPHRangeData *)userdata;
|
|
|
|
ParticleData *npa = pfr->npsys->particles + index;
|
|
|
|
float q;
|
2012-12-14 16:10:46 +00:00
|
|
|
float qfac = 21.0f / (256.f * (float)M_PI);
|
2012-12-14 04:57:26 +00:00
|
|
|
float rij, rij_h;
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
/* Exclude particles that are more than 2h away. Can't use squared_dist here
|
|
|
|
* because it is not accurate enough. Use current state, i.e. the output of
|
|
|
|
* basic_integrate() - z0r */
|
2016-03-19 17:16:50 +11:00
|
|
|
sub_v3_v3v3(vec, npa->state.co, co);
|
2012-12-14 04:57:26 +00:00
|
|
|
rij = len_v3(vec);
|
|
|
|
rij_h = rij / pfr->h;
|
|
|
|
if (rij_h > 2.0f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Smoothing factor. Utilise the Wendland kernel. gnuplot:
|
|
|
|
* q1(x) = (2.0 - x)**4 * ( 1.0 + 2.0 * x)
|
|
|
|
* plot [0:2] q1(x) */
|
2014-11-11 18:16:20 +01:00
|
|
|
q = qfac / pow3f(pfr->h) * pow4f(2.0f - rij_h) * ( 1.0f + 2.0f * rij_h);
|
2013-01-08 04:28:44 +00:00
|
|
|
q *= pfr->npsys->part->mass;
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
if (pfr->use_size)
|
|
|
|
q *= pfr->pa->size;
|
|
|
|
|
|
|
|
pfr->data[0] += q;
|
|
|
|
pfr->data[1] += q / npa->sphdensity;
|
|
|
|
}
|
|
|
|
|
2016-03-19 17:16:50 +11:00
|
|
|
static void sphclassical_neighbour_accum_cb(void *userdata, int index, const float co[3], float UNUSED(squared_dist))
|
2012-12-14 04:57:26 +00:00
|
|
|
{
|
|
|
|
SPHRangeData *pfr = (SPHRangeData *)userdata;
|
|
|
|
ParticleData *npa = pfr->npsys->particles + index;
|
|
|
|
float rij, rij_h;
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
if (pfr->tot_neighbors >= SPH_NEIGHBORS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Exclude particles that are more than 2h away. Can't use squared_dist here
|
|
|
|
* because it is not accurate enough. Use current state, i.e. the output of
|
|
|
|
* basic_integrate() - z0r */
|
2016-03-19 17:16:50 +11:00
|
|
|
sub_v3_v3v3(vec, npa->state.co, co);
|
2012-12-14 04:57:26 +00:00
|
|
|
rij = len_v3(vec);
|
|
|
|
rij_h = rij / pfr->h;
|
|
|
|
if (rij_h > 2.0f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pfr->neighbors[pfr->tot_neighbors].index = index;
|
|
|
|
pfr->neighbors[pfr->tot_neighbors].psys = pfr->npsys;
|
|
|
|
pfr->tot_neighbors++;
|
|
|
|
}
|
|
|
|
static void sphclassical_force_cb(void *sphdata_v, ParticleKey *state, float *force, float *UNUSED(impulse))
|
|
|
|
{
|
|
|
|
SPHData *sphdata = (SPHData *)sphdata_v;
|
|
|
|
ParticleSystem **psys = sphdata->psys;
|
|
|
|
ParticleData *pa = sphdata->pa;
|
|
|
|
SPHFluidSettings *fluid = psys[0]->part->fluid;
|
|
|
|
SPHRangeData pfr;
|
|
|
|
SPHNeighbor *pfn;
|
|
|
|
float *gravity = sphdata->gravity;
|
|
|
|
|
|
|
|
float dq, u, rij, dv[3];
|
|
|
|
float pressure, npressure;
|
|
|
|
|
|
|
|
float visc = fluid->viscosity_omega;
|
|
|
|
|
|
|
|
float interaction_radius;
|
|
|
|
float h, hinv;
|
|
|
|
/* 4.77 is an experimentally determined density factor */
|
|
|
|
float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.0f);
|
|
|
|
|
2013-01-11 03:06:10 +00:00
|
|
|
// Use speed of sound squared
|
2014-11-11 18:16:20 +01:00
|
|
|
float stiffness = pow2f(fluid->stiffness_k);
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
ParticleData *npa;
|
|
|
|
float vec[3];
|
|
|
|
float co[3];
|
|
|
|
float pressureTerm;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2012-12-14 16:10:46 +00:00
|
|
|
float qfac2 = 42.0f / (256.0f * (float)M_PI);
|
2012-12-14 04:57:26 +00:00
|
|
|
float rij_h;
|
|
|
|
|
|
|
|
/* 4.0 here is to be consistent with previous formulation/interface */
|
|
|
|
interaction_radius = fluid->radius * (fluid->flag & SPH_FAC_RADIUS ? 4.0f * pa->size : 1.0f);
|
|
|
|
h = interaction_radius * sphdata->hfac;
|
|
|
|
hinv = 1.0f / h;
|
|
|
|
|
|
|
|
pfr.h = h;
|
|
|
|
pfr.pa = pa;
|
|
|
|
|
|
|
|
sph_evaluate_func(NULL, psys, state->co, &pfr, interaction_radius, sphclassical_neighbour_accum_cb);
|
2014-11-11 18:16:20 +01:00
|
|
|
pressure = stiffness * (pow7f(pa->sphdensity / rest_density) - 1.0f);
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
/* multiply by mass so that we return a force, not accel */
|
2014-11-11 18:16:20 +01:00
|
|
|
qfac2 *= sphdata->mass / pow3f(pfr.h);
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
pfn = pfr.neighbors;
|
|
|
|
for (i = 0; i < pfr.tot_neighbors; i++, pfn++) {
|
|
|
|
npa = pfn->psys->particles + pfn->index;
|
|
|
|
if (npa == pa) {
|
|
|
|
/* we do not contribute to ourselves */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-10-31 14:10:01 +00:00
|
|
|
/* Find vector to neighbor. Exclude particles that are more than 2h
|
2012-12-14 04:57:26 +00:00
|
|
|
* away. Can't use current state here because it may have changed on
|
|
|
|
* another thread - so do own mini integration. Unlike basic_integrate,
|
2013-10-31 14:10:01 +00:00
|
|
|
* SPH integration depends on neighboring particles. - z0r */
|
2012-12-14 04:57:26 +00:00
|
|
|
madd_v3_v3v3fl(co, npa->prev_state.co, npa->prev_state.vel, state->time);
|
|
|
|
sub_v3_v3v3(vec, co, state->co);
|
|
|
|
rij = normalize_v3(vec);
|
|
|
|
rij_h = rij / pfr.h;
|
|
|
|
if (rij_h > 2.0f)
|
|
|
|
continue;
|
|
|
|
|
2014-11-11 18:16:20 +01:00
|
|
|
npressure = stiffness * (pow7f(npa->sphdensity / rest_density) - 1.0f);
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
/* First derivative of smoothing factor. Utilise the Wendland kernel.
|
|
|
|
* gnuplot:
|
|
|
|
* q2(x) = 2.0 * (2.0 - x)**4 - 4.0 * (2.0 - x)**3 * (1.0 + 2.0 * x)
|
|
|
|
* plot [0:2] q2(x)
|
|
|
|
* Particles > 2h away are excluded above. */
|
2014-11-11 18:16:20 +01:00
|
|
|
dq = qfac2 * (2.0f * pow4f(2.0f - rij_h) - 4.0f * pow3f(2.0f - rij_h) * (1.0f + 2.0f * rij_h) );
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
if (pfn->psys->part->flag & PART_SIZEMASS)
|
|
|
|
dq *= npa->size;
|
|
|
|
|
2014-11-11 18:16:20 +01:00
|
|
|
pressureTerm = pressure / pow2f(pa->sphdensity) + npressure / pow2f(npa->sphdensity);
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
/* Note that 'minus' is removed, because vec = vecBA, not vecAB.
|
|
|
|
* This applies to the viscosity calculation below, too. */
|
|
|
|
madd_v3_v3fl(force, vec, pressureTerm * dq);
|
|
|
|
|
|
|
|
/* Viscosity */
|
|
|
|
if (visc > 0.0f) {
|
|
|
|
sub_v3_v3v3(dv, npa->prev_state.vel, pa->prev_state.vel);
|
|
|
|
u = dot_v3v3(vec, dv);
|
|
|
|
/* Apply parameters */
|
|
|
|
u *= -dq * hinv * visc / (0.5f * npa->sphdensity + 0.5f * pa->sphdensity);
|
|
|
|
madd_v3_v3fl(force, vec, u);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Artificial buoyancy force in negative gravity direction */
|
|
|
|
if (fluid->buoyancy > 0.f && gravity)
|
|
|
|
madd_v3_v3fl(force, gravity, fluid->buoyancy * (pa->sphdensity - rest_density));
|
2012-01-02 11:46:02 +00:00
|
|
|
|
|
|
|
if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF)
|
|
|
|
sph_particle_courant(sphdata, &pfr);
|
|
|
|
sphdata->pass++;
|
2011-01-09 19:09:41 +00:00
|
|
|
}
|
|
|
|
|
2012-12-18 01:52:18 +00:00
|
|
|
static void sphclassical_calc_dens(ParticleData *pa, float UNUSED(dfra), SPHData *sphdata)
|
|
|
|
{
|
2012-12-14 04:57:26 +00:00
|
|
|
ParticleSystem **psys = sphdata->psys;
|
|
|
|
SPHFluidSettings *fluid = psys[0]->part->fluid;
|
|
|
|
/* 4.0 seems to be a pretty good value */
|
|
|
|
float interaction_radius = fluid->radius * (fluid->flag & SPH_FAC_RADIUS ? 4.0f * psys[0]->part->size : 1.0f);
|
|
|
|
SPHRangeData pfr;
|
|
|
|
float data[2];
|
|
|
|
|
|
|
|
data[0] = 0;
|
|
|
|
data[1] = 0;
|
|
|
|
pfr.data = data;
|
|
|
|
pfr.h = interaction_radius * sphdata->hfac;
|
|
|
|
pfr.pa = pa;
|
2013-01-08 04:28:44 +00:00
|
|
|
pfr.mass = sphdata->mass;
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
sph_evaluate_func( NULL, psys, pa->state.co, &pfr, interaction_radius, sphclassical_density_accum_cb);
|
2015-11-23 11:27:02 +11:00
|
|
|
pa->sphdensity = min_ff(max_ff(data[0], fluid->rest_density * 0.9f), fluid->rest_density * 1.1f);
|
2012-12-14 04:57:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void psys_sph_init(ParticleSimulationData *sim, SPHData *sphdata)
|
2012-02-25 16:49:59 +00:00
|
|
|
{
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleTarget *pt;
|
|
|
|
int i;
|
|
|
|
|
2012-01-02 12:10:50 +00:00
|
|
|
// Add other coupled particle systems.
|
|
|
|
sphdata->psys[0] = sim->psys;
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=1, pt=sim->psys->targets.first; i<10; i++, pt=(pt?pt->next:NULL))
|
2012-01-02 12:10:50 +00:00
|
|
|
sphdata->psys[i] = pt ? psys_get_target_system(sim->ob, pt) : NULL;
|
|
|
|
|
|
|
|
if (psys_uses_gravity(sim))
|
|
|
|
sphdata->gravity = sim->scene->physics_settings.gravity;
|
|
|
|
else
|
|
|
|
sphdata->gravity = NULL;
|
|
|
|
sphdata->eh = sph_springhash_build(sim->psys);
|
|
|
|
|
|
|
|
// These per-particle values should be overridden later, but just for
|
|
|
|
// completeness we give them default values now.
|
|
|
|
sphdata->pa = NULL;
|
|
|
|
sphdata->mass = 1.0f;
|
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
if (sim->psys->part->fluid->solver == SPH_SOLVER_DDR) {
|
|
|
|
sphdata->force_cb = sph_force_cb;
|
|
|
|
sphdata->density_cb = sph_density_accum_cb;
|
|
|
|
sphdata->hfac = 1.0f;
|
2012-12-18 01:46:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-12-14 04:57:26 +00:00
|
|
|
/* SPH_SOLVER_CLASSICAL */
|
|
|
|
sphdata->force_cb = sphclassical_force_cb;
|
|
|
|
sphdata->density_cb = sphclassical_density_accum_cb;
|
|
|
|
sphdata->hfac = 0.5f;
|
|
|
|
}
|
|
|
|
|
2012-01-02 12:10:50 +00:00
|
|
|
}
|
2012-02-25 16:49:59 +00:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
void psys_sph_finalise(SPHData *sphdata)
|
2012-02-25 16:49:59 +00:00
|
|
|
{
|
2012-01-02 12:10:50 +00:00
|
|
|
if (sphdata->eh) {
|
|
|
|
BLI_edgehash_free(sphdata->eh, NULL);
|
|
|
|
sphdata->eh = NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-12-14 04:57:26 +00:00
|
|
|
/* Sample the density field at a point in space. */
|
2012-12-18 01:52:18 +00:00
|
|
|
void psys_sph_density(BVHTree *tree, SPHData *sphdata, float co[3], float vars[2])
|
|
|
|
{
|
2012-12-14 04:57:26 +00:00
|
|
|
ParticleSystem **psys = sphdata->psys;
|
|
|
|
SPHFluidSettings *fluid = psys[0]->part->fluid;
|
|
|
|
/* 4.0 seems to be a pretty good value */
|
|
|
|
float interaction_radius = fluid->radius * (fluid->flag & SPH_FAC_RADIUS ? 4.0f * psys[0]->part->size : 1.0f);
|
|
|
|
SPHRangeData pfr;
|
|
|
|
float density[2];
|
|
|
|
|
|
|
|
density[0] = density[1] = 0.0f;
|
|
|
|
pfr.data = density;
|
2013-01-08 04:28:44 +00:00
|
|
|
pfr.h = interaction_radius * sphdata->hfac;
|
|
|
|
pfr.mass = sphdata->mass;
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
sph_evaluate_func(tree, psys, co, &pfr, interaction_radius, sphdata->density_cb);
|
|
|
|
|
|
|
|
vars[0] = pfr.data[0];
|
|
|
|
vars[1] = pfr.data[1];
|
|
|
|
}
|
2012-02-25 16:49:59 +00:00
|
|
|
|
|
|
|
static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float dfra, SPHData *sphdata)
|
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSettings *part = sim->psys->part;
|
2011-03-12 14:21:04 +00:00
|
|
|
// float timestep = psys_get_timestep(sim); // UNUSED
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float pa_mass = part->mass * (part->flag & PART_SIZEMASS ? pa->size : 1.f);
|
|
|
|
float dtime = dfra*psys_get_timestep(sim);
|
2011-03-12 14:21:04 +00:00
|
|
|
// int steps = 1; // UNUSED
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float effector_acceleration[3];
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2012-01-02 12:10:50 +00:00
|
|
|
sphdata->pa = pa;
|
|
|
|
sphdata->mass = pa_mass;
|
|
|
|
sphdata->pass = 0;
|
2011-09-25 11:51:28 +00:00
|
|
|
//sphdata.element_size and sphdata.flow are set in the callback.
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* restore previous state and treat gravity & effectors as external acceleration*/
|
|
|
|
sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel);
|
|
|
|
mul_v3_fl(effector_acceleration, 1.f/dtime);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
copy_particle_key(&pa->state, &pa->prev_state, 0);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-01-02 12:10:50 +00:00
|
|
|
integrate_particle(part, pa, dtime, effector_acceleration, sphdata->force_cb, sphdata);
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Basic physics */
|
|
|
|
/************************************************/
|
2012-06-06 22:38:39 +00:00
|
|
|
typedef struct EfData {
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
ParticleTexture ptex;
|
|
|
|
ParticleSimulationData *sim;
|
|
|
|
ParticleData *pa;
|
|
|
|
} EfData;
|
|
|
|
static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, float *impulse)
|
|
|
|
{
|
|
|
|
EfData *efdata = (EfData *)efdata_v;
|
|
|
|
ParticleSimulationData *sim = efdata->sim;
|
|
|
|
ParticleSettings *part = sim->psys->part;
|
|
|
|
ParticleData *pa = efdata->pa;
|
|
|
|
EffectedPoint epoint;
|
2018-06-12 16:36:43 +02:00
|
|
|
RNG *rng = sim->rng;
|
2011-02-12 14:38:34 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* add effectors */
|
|
|
|
pd_point_from_particle(efdata->sim, efdata->pa, state, &epoint);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)
|
2018-06-21 19:45:39 +02:00
|
|
|
BKE_effectors_apply(sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
mul_v3_fl(force, efdata->ptex.field);
|
|
|
|
mul_v3_fl(impulse, efdata->ptex.field);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* calculate air-particle interaction */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->dragfac != 0.0f)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
madd_v3_v3fl(force, state->vel, -part->dragfac * pa->size * pa->size * len_v3(state->vel));
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* brownian force */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->brownfac != 0.0f) {
|
2018-06-12 16:36:43 +02:00
|
|
|
force[0] += (BLI_rng_get_float(rng)-0.5f) * part->brownfac;
|
|
|
|
force[1] += (BLI_rng_get_float(rng)-0.5f) * part->brownfac;
|
|
|
|
force[2] += (BLI_rng_get_float(rng)-0.5f) * part->brownfac;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
}
|
2012-05-28 16:58:12 +00:00
|
|
|
|
2012-06-04 20:11:09 +00:00
|
|
|
if (part->flag & PART_ROT_DYN && epoint.ave)
|
2012-05-28 16:58:12 +00:00
|
|
|
copy_v3_v3(pa->state.ave, epoint.ave);
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
}
|
|
|
|
/* gathers all forces that effect particles and calculates a new state for the particle */
|
|
|
|
static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, float cfra)
|
|
|
|
{
|
|
|
|
ParticleSettings *part = sim->psys->part;
|
|
|
|
ParticleData *pa = sim->psys->particles + p;
|
|
|
|
ParticleKey tkey;
|
|
|
|
float dtime=dfra*psys_get_timestep(sim), time;
|
|
|
|
float *gravity = NULL, gr[3];
|
|
|
|
EfData efdata;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
psys_get_texture(sim, pa, &efdata.ptex, PAMAP_PHYSICS, cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
efdata.pa = pa;
|
|
|
|
efdata.sim = sim;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* add global acceleration (gravitation) */
|
2012-04-21 15:11:03 +00:00
|
|
|
if (psys_uses_gravity(sim) &&
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* normal gravity is too strong for hair so it's disabled by default */
|
2012-04-21 15:11:03 +00:00
|
|
|
(part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR))
|
|
|
|
{
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
zero_v3(gr);
|
|
|
|
madd_v3_v3fl(gr, sim->scene->physics_settings.gravity, part->effector_weights->global_gravity * efdata.ptex.gravity);
|
|
|
|
gravity = gr;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
/* maintain angular velocity */
|
|
|
|
copy_v3_v3(pa->state.ave, pa->prev_state.ave);
|
2009-11-25 17:46:10 +00:00
|
|
|
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
integrate_particle(part, pa, dtime, gravity, basic_force_cb, &efdata);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
|
|
|
/* damp affects final velocity */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->dampfac != 0.f)
|
2011-05-05 17:07:20 +00:00
|
|
|
mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp * 25.f * dtime);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
//copy_v3_v3(pa->state.ave, states->ave);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* finally we do guides */
|
|
|
|
time=(cfra-pa->time)/pa->lifetime;
|
2011-03-28 11:21:39 +00:00
|
|
|
CLAMP(time, 0.0f, 1.0f);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-05-15 12:07:44 +00:00
|
|
|
copy_v3_v3(tkey.co,pa->state.co);
|
|
|
|
copy_v3_v3(tkey.vel,pa->state.vel);
|
2008-09-23 12:53:00 +00:00
|
|
|
tkey.time=pa->state.time;
|
2008-03-07 22:39:54 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->type != PART_HAIR) {
|
2018-04-06 12:07:27 +02:00
|
|
|
if (do_guides(sim->depsgraph, sim->psys->part, sim->psys->effectors, &tkey, p, time)) {
|
2012-05-15 12:07:44 +00:00
|
|
|
copy_v3_v3(pa->state.co,tkey.co);
|
2008-03-07 22:39:54 +00:00
|
|
|
/* guides don't produce valid velocity */
|
2011-11-06 14:00:55 +00:00
|
|
|
sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co);
|
2012-05-15 12:07:44 +00:00
|
|
|
mul_v3_fl(pa->state.vel,1.0f/dtime);
|
2008-09-23 12:53:00 +00:00
|
|
|
pa->state.time=tkey.time;
|
2008-03-07 22:39:54 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, float timestep)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2012-10-22 08:15:51 +00:00
|
|
|
float rotfac, rot1[4], rot2[4] = {1.0,0.0,0.0,0.0}, dtime=dfra*timestep, extrotfac;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-07-17 12:05:15 +00:00
|
|
|
if ((part->flag & PART_ROTATIONS) == 0) {
|
|
|
|
unit_qt(pa->state.rot);
|
2012-03-18 21:33:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-17 13:28:30 +00:00
|
|
|
if (part->flag & PART_ROT_DYN) {
|
|
|
|
extrotfac = len_v3(pa->state.ave);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
extrotfac = 0.0f;
|
|
|
|
}
|
2012-05-28 16:58:12 +00:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if ((part->flag & PART_ROT_DYN) && ELEM(part->avemode, PART_AVE_VELOCITY, PART_AVE_HORIZONTAL, PART_AVE_VERTICAL)) {
|
2012-03-20 01:00:28 +00:00
|
|
|
float angle;
|
|
|
|
float len1 = len_v3(pa->prev_state.vel);
|
|
|
|
float len2 = len_v3(pa->state.vel);
|
|
|
|
float vec[3];
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-07-17 12:05:15 +00:00
|
|
|
if (len1 == 0.0f || len2 == 0.0f) {
|
|
|
|
zero_v3(pa->state.ave);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-03-20 01:00:28 +00:00
|
|
|
cross_v3_v3v3(pa->state.ave, pa->prev_state.vel, pa->state.vel);
|
|
|
|
normalize_v3(pa->state.ave);
|
|
|
|
angle = dot_v3v3(pa->prev_state.vel, pa->state.vel) / (len1 * len2);
|
|
|
|
mul_v3_fl(pa->state.ave, saacos(angle) / dtime);
|
2008-02-13 21:06:37 +00:00
|
|
|
}
|
2012-03-20 01:00:28 +00:00
|
|
|
|
|
|
|
get_angular_velocity_vector(part->avemode, &pa->state, vec);
|
|
|
|
axis_angle_to_quat(rot2, vec, dtime*part->avefac);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 01:00:28 +00:00
|
|
|
rotfac = len_v3(pa->state.ave);
|
2012-07-17 12:05:15 +00:00
|
|
|
if (rotfac == 0.0f || (part->flag & PART_ROT_DYN)==0 || extrotfac == 0.0f) {
|
|
|
|
unit_qt(rot1);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-05-15 12:07:44 +00:00
|
|
|
axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2012-05-15 12:07:44 +00:00
|
|
|
mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot);
|
|
|
|
mul_qt_qtqt(pa->state.rot,rot2,pa->state.rot);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
|
|
|
/* keep rotation quat in good health */
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_qt(pa->state.rot);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 02:24:52 +00:00
|
|
|
/************************************************
|
|
|
|
* Collisions
|
|
|
|
*
|
|
|
|
* The algorithm is roughly:
|
|
|
|
* 1. Use a BVH tree to search for faces that a particle may collide with.
|
|
|
|
* 2. Use Newton's method to find the exact time at which the collision occurs.
|
2016-10-25 17:32:58 +02:00
|
|
|
* https://en.wikipedia.org/wiki/Newton's_method
|
2013-02-19 02:24:52 +00:00
|
|
|
*
|
|
|
|
************************************************/
|
2011-03-18 15:31:32 +00:00
|
|
|
#define COLLISION_MIN_RADIUS 0.001f
|
|
|
|
#define COLLISION_MIN_DISTANCE 0.0001f
|
|
|
|
#define COLLISION_ZERO 0.00001f
|
2013-02-19 02:24:52 +00:00
|
|
|
#define COLLISION_INIT_STEP 0.00008f
|
2011-03-18 15:31:32 +00:00
|
|
|
typedef float (*NRDistanceFunc)(float *p, float radius, ParticleCollisionElement *pce, float *nor);
|
|
|
|
static float nr_signed_distance_to_plane(float *p, float radius, ParticleCollisionElement *pce, float *nor)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2011-03-18 15:31:32 +00:00
|
|
|
float p0[3], e1[3], e2[3], d;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
sub_v3_v3v3(e1, pce->x1, pce->x0);
|
|
|
|
sub_v3_v3v3(e2, pce->x2, pce->x0);
|
|
|
|
sub_v3_v3v3(p0, p, pce->x0);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
cross_v3_v3v3(nor, e1, e2);
|
|
|
|
normalize_v3(nor);
|
|
|
|
|
|
|
|
d = dot_v3v3(p0, nor);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->inv_nor == -1) {
|
|
|
|
if (d < 0.f)
|
2011-03-18 15:31:32 +00:00
|
|
|
pce->inv_nor = 1;
|
|
|
|
else
|
|
|
|
pce->inv_nor = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->inv_nor == 1) {
|
2011-11-16 16:38:37 +00:00
|
|
|
negate_v3(nor);
|
2011-03-18 15:31:32 +00:00
|
|
|
d = -d;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
return d - radius;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 20:57:32 +00:00
|
|
|
static float nr_distance_to_edge(float *p, float radius, ParticleCollisionElement *pce, float *UNUSED(nor))
|
2011-03-18 15:31:32 +00:00
|
|
|
{
|
|
|
|
float v0[3], v1[3], v2[3], c[3];
|
|
|
|
|
|
|
|
sub_v3_v3v3(v0, pce->x1, pce->x0);
|
|
|
|
sub_v3_v3v3(v1, p, pce->x0);
|
|
|
|
sub_v3_v3v3(v2, p, pce->x1);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
cross_v3_v3v3(c, v1, v2);
|
|
|
|
|
2011-04-02 02:08:33 +00:00
|
|
|
return fabsf(len_v3(c)/len_v3(v0)) - radius;
|
2011-03-18 15:31:32 +00:00
|
|
|
}
|
2011-03-18 20:57:32 +00:00
|
|
|
static float nr_distance_to_vert(float *p, float radius, ParticleCollisionElement *pce, float *UNUSED(nor))
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2011-03-18 15:31:32 +00:00
|
|
|
return len_v3v3(p, pce->x0) - radius;
|
|
|
|
}
|
|
|
|
static void collision_interpolate_element(ParticleCollisionElement *pce, float t, float fac, ParticleCollision *col)
|
|
|
|
{
|
|
|
|
/* t is the current time for newton rhapson */
|
|
|
|
/* fac is the starting factor for current collision iteration */
|
|
|
|
/* the col->fac's are factors for the particle subframe step start and end during collision modifier step */
|
|
|
|
float f = fac + t*(1.f-fac);
|
|
|
|
float mul = col->fac1 + f * (col->fac2-col->fac1);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->tot > 0) {
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3v3fl(pce->x0, pce->x[0], pce->v[0], mul);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->tot > 1) {
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3v3fl(pce->x1, pce->x[1], pce->v[1], mul);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->tot > 2)
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3v3fl(pce->x2, pce->x[2], pce->v[2], mul);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void collision_point_velocity(ParticleCollisionElement *pce)
|
|
|
|
{
|
|
|
|
float v[3];
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
copy_v3_v3(pce->vel, pce->v[0]);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->tot > 1) {
|
2011-03-18 15:31:32 +00:00
|
|
|
sub_v3_v3v3(v, pce->v[1], pce->v[0]);
|
|
|
|
madd_v3_v3fl(pce->vel, v, pce->uv[0]);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pce->tot > 2) {
|
2011-03-18 15:31:32 +00:00
|
|
|
sub_v3_v3v3(v, pce->v[2], pce->v[0]);
|
|
|
|
madd_v3_v3fl(pce->vel, v, pce->uv[1]);
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
}
|
|
|
|
static float collision_point_distance_with_normal(float p[3], ParticleCollisionElement *pce, float fac, ParticleCollision *col, float *nor)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (fac >= 0.f)
|
2011-03-18 15:31:32 +00:00
|
|
|
collision_interpolate_element(pce, 0.f, fac, col);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (pce->tot) {
|
2011-03-18 15:31:32 +00:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
sub_v3_v3v3(nor, p, pce->x0);
|
|
|
|
return normalize_v3(nor);
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
float u, e[3], vec[3];
|
|
|
|
sub_v3_v3v3(e, pce->x1, pce->x0);
|
|
|
|
sub_v3_v3v3(vec, p, pce->x0);
|
|
|
|
u = dot_v3v3(vec, e) / dot_v3v3(e, e);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3v3fl(nor, vec, e, -u);
|
|
|
|
return normalize_v3(nor);
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
return nr_signed_distance_to_plane(p, 0.f, pce, nor);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce, float fac, ParticleCollision *col, float *co)
|
|
|
|
{
|
|
|
|
collision_interpolate_element(pce, 0.f, fac, col);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (pce->tot) {
|
2011-03-18 15:31:32 +00:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
sub_v3_v3v3(co, p, pce->x0);
|
|
|
|
normalize_v3(co);
|
|
|
|
madd_v3_v3v3fl(co, pce->x0, co, col->radius);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
float u, e[3], vec[3], nor[3];
|
|
|
|
sub_v3_v3v3(e, pce->x1, pce->x0);
|
|
|
|
sub_v3_v3v3(vec, p, pce->x0);
|
|
|
|
u = dot_v3v3(vec, e) / dot_v3v3(e, e);
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(nor, vec, e, -u);
|
|
|
|
normalize_v3(nor);
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(co, pce->x0, e, pce->uv[0]);
|
|
|
|
madd_v3_v3fl(co, nor, col->radius);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
2017-09-27 00:17:28 +10:00
|
|
|
float p0[3], e1[3], e2[3], nor[3];
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2017-09-27 00:17:28 +10:00
|
|
|
sub_v3_v3v3(e1, pce->x1, pce->x0);
|
|
|
|
sub_v3_v3v3(e2, pce->x2, pce->x0);
|
|
|
|
sub_v3_v3v3(p0, p, pce->x0);
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2017-09-27 00:17:28 +10:00
|
|
|
cross_v3_v3v3(nor, e1, e2);
|
|
|
|
normalize_v3(nor);
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2017-09-27 00:17:28 +10:00
|
|
|
if (pce->inv_nor == 1)
|
|
|
|
negate_v3(nor);
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2017-09-27 00:17:28 +10:00
|
|
|
madd_v3_v3v3fl(co, pce->x0, nor, col->radius);
|
|
|
|
madd_v3_v3fl(co, e1, pce->uv[0]);
|
|
|
|
madd_v3_v3fl(co, e2, pce->uv[1]);
|
2011-03-18 15:31:32 +00:00
|
|
|
break;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
}
|
|
|
|
/* find first root in range [0-1] starting from 0 */
|
|
|
|
static float collision_newton_rhapson(ParticleCollision *col, float radius, ParticleCollisionElement *pce, NRDistanceFunc distance_func)
|
|
|
|
{
|
2013-02-19 02:24:52 +00:00
|
|
|
float t0, t1, dt_init, d0, d1, dd, n[3];
|
2011-03-18 15:31:32 +00:00
|
|
|
int iter;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
pce->inv_nor = -1;
|
|
|
|
|
2013-09-27 13:45:47 +00:00
|
|
|
if (col->inv_total_time > 0.0f) {
|
|
|
|
/* Initial step size should be small, but not too small or floating point
|
|
|
|
* precision errors will appear. - z0r */
|
|
|
|
dt_init = COLLISION_INIT_STEP * col->inv_total_time;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dt_init = 0.001f;
|
|
|
|
}
|
2013-02-19 02:24:52 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* start from the beginning */
|
|
|
|
t0 = 0.f;
|
|
|
|
collision_interpolate_element(pce, t0, col->f, col);
|
|
|
|
d0 = distance_func(col->co1, radius, pce, n);
|
2013-02-19 02:24:52 +00:00
|
|
|
t1 = dt_init;
|
2011-03-18 15:31:32 +00:00
|
|
|
d1 = 0.f;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (iter=0; iter<10; iter++) {//, itersum++) {
|
2011-03-18 15:31:32 +00:00
|
|
|
/* get current location */
|
|
|
|
collision_interpolate_element(pce, t1, col->f, col);
|
|
|
|
interp_v3_v3v3(pce->p, col->co1, col->co2, t1);
|
|
|
|
|
|
|
|
d1 = distance_func(pce->p, radius, pce, n);
|
|
|
|
|
|
|
|
/* particle already inside face, so report collision */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iter == 0 && d0 < 0.f && d0 > -radius) {
|
2011-03-18 15:31:32 +00:00
|
|
|
copy_v3_v3(pce->p, col->co1);
|
|
|
|
copy_v3_v3(pce->nor, n);
|
|
|
|
pce->inside = 1;
|
|
|
|
return 0.f;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2013-02-19 02:24:52 +00:00
|
|
|
|
|
|
|
/* Zero gradient (no movement relative to element). Can't step from
|
|
|
|
* here. */
|
|
|
|
if (d1 == d0) {
|
|
|
|
/* If first iteration, try from other end where the gradient may be
|
|
|
|
* greater. Note: code duplicated below. */
|
|
|
|
if (iter == 0) {
|
|
|
|
t0 = 1.f;
|
|
|
|
collision_interpolate_element(pce, t0, col->f, col);
|
|
|
|
d0 = distance_func(col->co2, radius, pce, n);
|
|
|
|
t1 = 1.0f - dt_init;
|
|
|
|
d1 = 0.f;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1.f;
|
|
|
|
}
|
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
dd = (t1-t0)/(d1-d0);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
t0 = t1;
|
|
|
|
d0 = d1;
|
|
|
|
|
|
|
|
t1 -= d1*dd;
|
|
|
|
|
2013-02-19 02:24:52 +00:00
|
|
|
/* Particle moving away from plane could also mean a strangely rotating
|
|
|
|
* face, so check from end. Note: code duplicated above. */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (iter == 0 && t1 < 0.f) {
|
2011-03-18 15:31:32 +00:00
|
|
|
t0 = 1.f;
|
|
|
|
collision_interpolate_element(pce, t0, col->f, col);
|
|
|
|
d0 = distance_func(col->co2, radius, pce, n);
|
2013-02-19 02:24:52 +00:00
|
|
|
t1 = 1.0f - dt_init;
|
2011-03-18 15:31:32 +00:00
|
|
|
d1 = 0.f;
|
|
|
|
continue;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f))
|
2011-03-18 15:31:32 +00:00
|
|
|
return -1.f;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (d1 <= COLLISION_ZERO && d1 >= -COLLISION_ZERO) {
|
|
|
|
if (t1 >= -COLLISION_ZERO && t1 <= 1.f) {
|
|
|
|
if (distance_func == nr_signed_distance_to_plane)
|
2011-03-18 15:31:32 +00:00
|
|
|
copy_v3_v3(pce->nor, n);
|
|
|
|
|
|
|
|
CLAMP(t1, 0.f, 1.f);
|
|
|
|
|
|
|
|
return t1;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
else
|
|
|
|
return -1.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1.0;
|
|
|
|
}
|
|
|
|
static int collision_sphere_to_tri(ParticleCollision *col, float radius, ParticleCollisionElement *pce, float *t)
|
|
|
|
{
|
|
|
|
ParticleCollisionElement *result = &col->pce;
|
|
|
|
float ct, u, v;
|
|
|
|
|
|
|
|
pce->inv_nor = -1;
|
|
|
|
pce->inside = 0;
|
|
|
|
|
|
|
|
ct = collision_newton_rhapson(col, radius, pce, nr_signed_distance_to_plane);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ct >= 0.f && ct < *t && (result->inside==0 || pce->inside==1) ) {
|
2011-03-18 15:31:32 +00:00
|
|
|
float e1[3], e2[3], p0[3];
|
|
|
|
float e1e1, e1e2, e1p0, e2e2, e2p0, inv;
|
|
|
|
|
|
|
|
sub_v3_v3v3(e1, pce->x1, pce->x0);
|
|
|
|
sub_v3_v3v3(e2, pce->x2, pce->x0);
|
|
|
|
/* XXX: add radius correction here? */
|
|
|
|
sub_v3_v3v3(p0, pce->p, pce->x0);
|
|
|
|
|
|
|
|
e1e1 = dot_v3v3(e1, e1);
|
|
|
|
e1e2 = dot_v3v3(e1, e2);
|
|
|
|
e1p0 = dot_v3v3(e1, p0);
|
|
|
|
e2e2 = dot_v3v3(e2, e2);
|
|
|
|
e2p0 = dot_v3v3(e2, p0);
|
|
|
|
|
|
|
|
inv = 1.f/(e1e1 * e2e2 - e1e2 * e1e2);
|
|
|
|
u = (e2e2 * e1p0 - e1e2 * e2p0) * inv;
|
|
|
|
v = (e1e1 * e2p0 - e1e2 * e1p0) * inv;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (u>=0.f && u<=1.f && v>=0.f && u+v<=1.f) {
|
2011-03-18 15:31:32 +00:00
|
|
|
*result = *pce;
|
|
|
|
|
|
|
|
/* normal already calculated in pce */
|
|
|
|
|
|
|
|
result->uv[0] = u;
|
|
|
|
result->uv[1] = v;
|
|
|
|
|
|
|
|
*t = ct;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-19 13:33:03 +00:00
|
|
|
static int collision_sphere_to_edges(ParticleCollision *col, float radius, ParticleCollisionElement *pce, float *t)
|
2011-03-18 15:31:32 +00:00
|
|
|
{
|
|
|
|
ParticleCollisionElement edge[3], *cur = NULL, *hit = NULL;
|
|
|
|
ParticleCollisionElement *result = &col->pce;
|
|
|
|
|
|
|
|
float ct;
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0; i<3; i++) {
|
2011-03-18 15:31:32 +00:00
|
|
|
cur = edge+i;
|
|
|
|
cur->x[0] = pce->x[i]; cur->x[1] = pce->x[(i+1)%3];
|
|
|
|
cur->v[0] = pce->v[i]; cur->v[1] = pce->v[(i+1)%3];
|
|
|
|
cur->tot = 2;
|
|
|
|
cur->inside = 0;
|
|
|
|
|
|
|
|
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_edge);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ct >= 0.f && ct < *t) {
|
2011-03-18 15:31:32 +00:00
|
|
|
float u, e[3], vec[3];
|
|
|
|
|
|
|
|
sub_v3_v3v3(e, cur->x1, cur->x0);
|
|
|
|
sub_v3_v3v3(vec, cur->p, cur->x0);
|
|
|
|
u = dot_v3v3(vec, e) / dot_v3v3(e, e);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (u < 0.f || u > 1.f)
|
2011-03-18 15:31:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
*result = *cur;
|
|
|
|
|
|
|
|
madd_v3_v3v3fl(result->nor, vec, e, -u);
|
|
|
|
normalize_v3(result->nor);
|
|
|
|
|
|
|
|
result->uv[0] = u;
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
hit = cur;
|
|
|
|
*t = ct;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
|
|
|
|
return hit != NULL;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
static int collision_sphere_to_verts(ParticleCollision *col, float radius, ParticleCollisionElement *pce, float *t)
|
|
|
|
{
|
|
|
|
ParticleCollisionElement vert[3], *cur = NULL, *hit = NULL;
|
|
|
|
ParticleCollisionElement *result = &col->pce;
|
|
|
|
|
|
|
|
float ct;
|
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0; i<3; i++) {
|
2011-03-18 15:31:32 +00:00
|
|
|
cur = vert+i;
|
|
|
|
cur->x[0] = pce->x[i];
|
|
|
|
cur->v[0] = pce->v[i];
|
|
|
|
cur->tot = 1;
|
|
|
|
cur->inside = 0;
|
|
|
|
|
|
|
|
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_vert);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ct >= 0.f && ct < *t) {
|
2011-03-18 15:31:32 +00:00
|
|
|
*result = *cur;
|
|
|
|
|
|
|
|
sub_v3_v3v3(result->nor, cur->p, cur->x0);
|
|
|
|
normalize_v3(result->nor);
|
|
|
|
|
|
|
|
hit = cur;
|
|
|
|
*t = ct;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
return hit != NULL;
|
|
|
|
}
|
|
|
|
/* Callback for BVHTree near test */
|
|
|
|
void BKE_psys_collision_neartest_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
|
2008-09-13 18:09:41 +00:00
|
|
|
{
|
|
|
|
ParticleCollision *col = (ParticleCollision *) userdata;
|
2011-03-18 15:31:32 +00:00
|
|
|
ParticleCollisionElement pce;
|
2015-07-31 14:00:07 +10:00
|
|
|
const MVertTri *vt = &col->md->tri[index];
|
2008-09-13 18:09:41 +00:00
|
|
|
MVert *x = col->md->x;
|
|
|
|
MVert *v = col->md->current_v;
|
2011-03-18 15:31:32 +00:00
|
|
|
float t = hit->dist/col->original_ray_length;
|
2011-03-19 13:33:03 +00:00
|
|
|
int collision = 0;
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
pce.x[0] = x[vt->tri[0]].co;
|
|
|
|
pce.x[1] = x[vt->tri[1]].co;
|
|
|
|
pce.x[2] = x[vt->tri[2]].co;
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
pce.v[0] = v[vt->tri[0]].co;
|
|
|
|
pce.v[1] = v[vt->tri[1]].co;
|
|
|
|
pce.v[2] = v[vt->tri[2]].co;
|
2011-03-18 15:31:32 +00:00
|
|
|
|
|
|
|
pce.tot = 3;
|
|
|
|
pce.inside = 0;
|
2011-03-29 10:27:31 +00:00
|
|
|
pce.index = index;
|
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
collision = collision_sphere_to_tri(col, ray->radius, &pce, &t);
|
|
|
|
if (col->pce.inside == 0) {
|
|
|
|
collision += collision_sphere_to_edges(col, ray->radius, &pce, &t);
|
|
|
|
collision += collision_sphere_to_verts(col, ray->radius, &pce, &t);
|
|
|
|
}
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
if (collision) {
|
|
|
|
hit->dist = col->original_ray_length * t;
|
|
|
|
hit->index = index;
|
2011-03-18 15:31:32 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
collision_point_velocity(&col->pce);
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
col->hit = col->current;
|
|
|
|
}
|
2008-09-13 18:09:41 +00:00
|
|
|
}
|
2011-03-18 15:31:32 +00:00
|
|
|
static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRayHit *hit, ListBase *colliders)
|
|
|
|
{
|
2015-08-21 17:46:23 +10:00
|
|
|
const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
ColliderCache *coll;
|
2011-03-18 15:31:32 +00:00
|
|
|
float ray_dir[3];
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(colliders))
|
2011-03-18 15:31:32 +00:00
|
|
|
return 0;
|
2010-09-23 09:31:13 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
sub_v3_v3v3(ray_dir, col->co2, col->co1);
|
|
|
|
hit->index = -1;
|
2015-08-21 17:05:48 +10:00
|
|
|
hit->dist = col->original_ray_length = normalize_v3(ray_dir);
|
2011-03-18 15:31:32 +00:00
|
|
|
col->pce.inside = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* even if particle is stationary we want to check for moving colliders */
|
|
|
|
/* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (hit->dist == 0.0f)
|
2011-03-18 15:31:32 +00:00
|
|
|
hit->dist = col->original_ray_length = 0.000001f;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (coll = colliders->first; coll; coll=coll->next) {
|
2016-07-22 18:55:37 +03:00
|
|
|
/* for boids: don't check with current ground object; also skip if permeated */
|
|
|
|
bool skip = false;
|
|
|
|
|
|
|
|
for (int i = 0; i < col->skip_count; i++) {
|
|
|
|
if (coll->ob == col->skip[i]) {
|
|
|
|
skip = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skip)
|
2011-03-18 15:31:32 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* particles should not collide with emitter at birth */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (coll->ob == col->emitter && pa->time < col->cfra && pa->time >= col->old_cfra)
|
2011-03-18 15:31:32 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
col->current = coll->ob;
|
|
|
|
col->md = coll->collmd;
|
|
|
|
col->fac1 = (col->old_cfra - coll->collmd->time_x) / (coll->collmd->time_xnew - coll->collmd->time_x);
|
|
|
|
col->fac2 = (col->cfra - coll->collmd->time_x) / (coll->collmd->time_xnew - coll->collmd->time_x);
|
|
|
|
|
2015-08-21 17:46:23 +10:00
|
|
|
if (col->md && col->md->bvhtree) {
|
|
|
|
BLI_bvhtree_ray_cast_ex(
|
|
|
|
col->md->bvhtree, col->co1, ray_dir, col->radius, hit,
|
|
|
|
BKE_psys_collision_neartest_cb, col, raycast_flag);
|
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
return hit->index >= 0;
|
|
|
|
}
|
2018-06-12 16:36:43 +02:00
|
|
|
static int collision_response(ParticleSimulationData *sim, ParticleData *pa, ParticleCollision *col, BVHTreeRayHit *hit, int kill, int dynamic_rotation)
|
2011-03-18 15:31:32 +00:00
|
|
|
{
|
|
|
|
ParticleCollisionElement *pce = &col->pce;
|
|
|
|
PartDeflect *pd = col->hit->pd;
|
2018-06-12 16:36:43 +02:00
|
|
|
RNG *rng = sim->rng;
|
2011-03-18 15:31:32 +00:00
|
|
|
float co[3]; /* point of collision */
|
|
|
|
float x = hit->dist/col->original_ray_length; /* location factor of collision between this iteration */
|
|
|
|
float f = col->f + x * (1.0f - col->f); /* time factor of collision between timestep */
|
|
|
|
float dt1 = (f - col->f) * col->total_time; /* time since previous collision (in seconds) */
|
|
|
|
float dt2 = (1.0f - f) * col->total_time; /* time left after collision (in seconds) */
|
2018-06-12 16:36:43 +02:00
|
|
|
int through = (BLI_rng_get_float(rng) < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */
|
2011-03-18 15:31:32 +00:00
|
|
|
|
|
|
|
/* calculate exact collision location */
|
|
|
|
interp_v3_v3v3(co, col->co1, col->co2, x);
|
|
|
|
|
|
|
|
/* particle dies in collision */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (through == 0 && (kill || pd->flag & PDEFLE_KILL_PART)) {
|
2011-03-18 15:31:32 +00:00
|
|
|
pa->alive = PARS_DYING;
|
|
|
|
pa->dietime = col->old_cfra + (col->cfra - col->old_cfra) * f;
|
|
|
|
|
|
|
|
copy_v3_v3(pa->state.co, co);
|
|
|
|
interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, f);
|
|
|
|
interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, f);
|
|
|
|
interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, f);
|
|
|
|
|
|
|
|
/* particle is dead so we don't need to calculate further */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* figure out velocity and other data after collision */
|
|
|
|
else {
|
|
|
|
float v0[3]; /* velocity directly before collision to be modified into velocity directly after collision */
|
|
|
|
float v0_nor[3];/* normal component of v0 */
|
|
|
|
float v0_tan[3];/* tangential component of v0 */
|
|
|
|
float vc_tan[3];/* tangential component of collision surface velocity */
|
|
|
|
float v0_dot, vc_dot;
|
2018-06-12 16:36:43 +02:00
|
|
|
float damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_rng_get_float(rng) - 0.5f);
|
|
|
|
float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_rng_get_float(rng) - 0.5f);
|
2011-03-18 15:31:32 +00:00
|
|
|
float distance, nor[3], dot;
|
|
|
|
|
2012-05-15 12:07:44 +00:00
|
|
|
CLAMP(damp,0.0f, 1.0f);
|
|
|
|
CLAMP(frict,0.0f, 1.0f);
|
2011-03-18 15:31:32 +00:00
|
|
|
|
|
|
|
/* get exact velocity right before collision */
|
|
|
|
madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* convert collider velocity from 1/framestep to 1/s TODO: here we assume 1 frame step for collision modifier */
|
|
|
|
mul_v3_fl(pce->vel, col->inv_timestep);
|
|
|
|
|
|
|
|
/* calculate tangential particle velocity */
|
|
|
|
v0_dot = dot_v3v3(pce->nor, v0);
|
|
|
|
madd_v3_v3v3fl(v0_tan, v0, pce->nor, -v0_dot);
|
|
|
|
|
|
|
|
/* calculate tangential collider velocity */
|
|
|
|
vc_dot = dot_v3v3(pce->nor, pce->vel);
|
|
|
|
madd_v3_v3v3fl(vc_tan, pce->vel, pce->nor, -vc_dot);
|
|
|
|
|
|
|
|
/* handle friction effects (tangential and angular velocity) */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (frict > 0.0f) {
|
2011-03-18 15:31:32 +00:00
|
|
|
/* angular <-> linear velocity */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dynamic_rotation) {
|
2011-03-18 15:31:32 +00:00
|
|
|
float vr_tan[3], v1_tan[3], ave[3];
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* linear velocity of particle surface */
|
|
|
|
cross_v3_v3v3(vr_tan, pce->nor, pa->state.ave);
|
|
|
|
mul_v3_fl(vr_tan, pa->size);
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* change to coordinates that move with the collision plane */
|
|
|
|
sub_v3_v3v3(v1_tan, v0_tan, vc_tan);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* The resulting velocity is a weighted average of particle cm & surface
|
2012-03-03 20:19:11 +00:00
|
|
|
* velocity. This weight (related to particle's moment of inertia) could
|
|
|
|
* be made a parameter for angular <-> linear conversion.
|
|
|
|
*/
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3fl(v1_tan, vr_tan, -0.4);
|
|
|
|
mul_v3_fl(v1_tan, 1.0f/1.4f); /* 1/(1+0.4) */
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* rolling friction is around 0.01 of sliding friction (could be made a parameter) */
|
|
|
|
mul_v3_fl(v1_tan, 1.0f - 0.01f * frict);
|
2010-11-02 21:16:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* surface_velocity is opposite to cm velocity */
|
2011-11-08 09:02:47 +00:00
|
|
|
negate_v3_v3(vr_tan, v1_tan);
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* get back to global coordinates */
|
|
|
|
add_v3_v3(v1_tan, vc_tan);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* convert to angular velocity*/
|
|
|
|
cross_v3_v3v3(ave, vr_tan, pce->nor);
|
2011-03-28 11:21:39 +00:00
|
|
|
mul_v3_fl(ave, 1.0f/MAX2(pa->size, 0.001f));
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* only friction will cause change in linear & angular velocity */
|
|
|
|
interp_v3_v3v3(pa->state.ave, pa->state.ave, ave, frict);
|
|
|
|
interp_v3_v3v3(v0_tan, v0_tan, v1_tan, frict);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* just basic friction (unphysical due to the friction model used in Blender) */
|
|
|
|
interp_v3_v3v3(v0_tan, v0_tan, vc_tan, frict);
|
|
|
|
}
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-07-03 17:20:21 +00:00
|
|
|
/* stickiness was possibly added before, so cancel that before calculating new normal velocity */
|
2011-03-18 15:31:32 +00:00
|
|
|
/* otherwise particles go flying out of the surface because of high reversed sticky velocity */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (v0_dot < 0.0f) {
|
2012-07-04 07:35:54 +00:00
|
|
|
v0_dot += pd->pdef_stickness;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (v0_dot > 0.0f)
|
2011-03-18 15:31:32 +00:00
|
|
|
v0_dot = 0.0f;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* damping and flipping of velocity around normal */
|
|
|
|
v0_dot *= 1.0f - damp;
|
|
|
|
vc_dot *= through ? damp : 1.0f;
|
2010-09-23 09:31:13 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* calculate normal particle velocity */
|
|
|
|
/* special case for object hitting the particle from behind */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (through==0 && ((vc_dot>0.0f && v0_dot>0.0f && vc_dot>v0_dot) || (vc_dot<0.0f && v0_dot<0.0f && vc_dot<v0_dot)))
|
2011-03-18 15:31:32 +00:00
|
|
|
mul_v3_v3fl(v0_nor, pce->nor, vc_dot);
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (v0_dot > 0.f)
|
2016-07-22 18:55:37 +03:00
|
|
|
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + v0_dot);
|
2011-03-18 15:31:32 +00:00
|
|
|
else
|
|
|
|
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + (through ? 1.0f : -1.0f) * v0_dot);
|
|
|
|
|
|
|
|
/* combine components together again */
|
|
|
|
add_v3_v3v3(v0, v0_nor, v0_tan);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (col->boid) {
|
2011-03-18 15:31:32 +00:00
|
|
|
/* keep boids above ground */
|
|
|
|
BoidParticle *bpa = pa->boid;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (bpa->data.mode == eBoidMode_OnLand || co[2] <= col->boid_z) {
|
2011-03-18 15:31:32 +00:00
|
|
|
co[2] = col->boid_z;
|
|
|
|
v0[2] = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* re-apply acceleration to final location and velocity */
|
|
|
|
madd_v3_v3v3fl(pa->state.co, co, v0, dt2);
|
|
|
|
madd_v3_v3fl(pa->state.co, col->acc, 0.5f*dt2*dt2);
|
|
|
|
madd_v3_v3v3fl(pa->state.vel, v0, col->acc, dt2);
|
|
|
|
|
|
|
|
/* make sure particle stays on the right side of the surface */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!through) {
|
2011-03-18 15:31:32 +00:00
|
|
|
distance = collision_point_distance_with_normal(co, pce, -1.f, col, nor);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (distance < col->radius + COLLISION_MIN_DISTANCE)
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3fl(co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
|
2008-09-13 18:09:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
dot = dot_v3v3(nor, v0);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dot < 0.f)
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3fl(v0, nor, -dot);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
distance = collision_point_distance_with_normal(pa->state.co, pce, 1.f, col, nor);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (distance < col->radius + COLLISION_MIN_DISTANCE)
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3fl(pa->state.co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
dot = dot_v3v3(nor, pa->state.vel);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dot < 0.f)
|
2011-03-18 15:31:32 +00:00
|
|
|
madd_v3_v3fl(pa->state.vel, nor, -dot);
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-07-03 17:20:21 +00:00
|
|
|
/* add stickiness to surface */
|
2012-07-04 07:35:54 +00:00
|
|
|
madd_v3_v3fl(pa->state.vel, pce->nor, -pd->pdef_stickness);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* set coordinates for next iteration */
|
|
|
|
copy_v3_v3(col->co1, co);
|
|
|
|
copy_v3_v3(col->co2, pa->state.co);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
copy_v3_v3(col->ve1, v0);
|
|
|
|
copy_v3_v3(col->ve2, pa->state.vel);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
col->f = f;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2016-07-22 18:55:37 +03:00
|
|
|
/* if permeability random roll succeeded, disable collider for this sim step */
|
|
|
|
if (through) {
|
|
|
|
col->skip[col->skip_count++] = col->hit;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
static void collision_fail(ParticleData *pa, ParticleCollision *col)
|
|
|
|
{
|
|
|
|
/* final chance to prevent total failure, so stick to the surface and hope for the best */
|
|
|
|
collision_point_on_surface(col->co1, &col->pce, 1.f, col, pa->state.co);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
copy_v3_v3(pa->state.vel, col->pce.vel);
|
|
|
|
mul_v3_fl(pa->state.vel, col->inv_timestep);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
|
|
|
|
2011-03-19 13:36:43 +00:00
|
|
|
/* printf("max iterations\n"); */
|
2011-03-18 15:31:32 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* Particle - Mesh collision detection and response
|
|
|
|
* Features:
|
|
|
|
* -friction and damping
|
|
|
|
* -angular momentum <-> linear momentum
|
|
|
|
* -high accuracy by re-applying particle acceleration after collision
|
|
|
|
* -handles moving, rotating and deforming meshes
|
|
|
|
* -uses Newton-Rhapson iteration to find the collisions
|
|
|
|
* -handles spherical particles and (nearly) point like particles
|
|
|
|
*/
|
2011-12-30 07:55:15 +00:00
|
|
|
static void collision_check(ParticleSimulationData *sim, int p, float dfra, float cfra)
|
|
|
|
{
|
2011-03-18 15:31:32 +00:00
|
|
|
ParticleSettings *part = sim->psys->part;
|
|
|
|
ParticleData *pa = sim->psys->particles + p;
|
|
|
|
ParticleCollision col;
|
|
|
|
BVHTreeRayHit hit;
|
|
|
|
int collision_count=0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
float timestep = psys_get_timestep(sim);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
memset(&col, 0, sizeof(ParticleCollision));
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
col.total_time = timestep * dfra;
|
2013-02-19 02:24:52 +00:00
|
|
|
col.inv_total_time = 1.0f/col.total_time;
|
2011-03-18 15:31:32 +00:00
|
|
|
col.inv_timestep = 1.0f/timestep;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
col.cfra = cfra;
|
|
|
|
col.old_cfra = sim->psys->cfra;
|
2010-09-23 09:31:13 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* get acceleration (from gravity, forcefields etc. to be re-applied in collision response) */
|
|
|
|
sub_v3_v3v3(col.acc, pa->state.vel, pa->prev_state.vel);
|
|
|
|
mul_v3_fl(col.acc, 1.f/col.total_time);
|
2010-09-23 09:31:13 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* set values for first iteration */
|
|
|
|
copy_v3_v3(col.co1, pa->prev_state.co);
|
|
|
|
copy_v3_v3(col.co2, pa->state.co);
|
|
|
|
copy_v3_v3(col.ve1, pa->prev_state.vel);
|
|
|
|
copy_v3_v3(col.ve2, pa->state.vel);
|
|
|
|
col.f = 0.0f;
|
2010-09-23 09:31:13 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
col.radius = ((part->flag & PART_SIZE_DEFL) || (part->phystype == PART_PHYS_BOIDS)) ? pa->size : COLLISION_MIN_RADIUS;
|
2010-03-10 03:41:41 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* override for boids */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->phystype == PART_PHYS_BOIDS && part->boids->options & BOID_ALLOW_LAND) {
|
2011-03-18 15:31:32 +00:00
|
|
|
col.boid = 1;
|
|
|
|
col.boid_z = pa->state.co[2];
|
2016-07-22 18:55:37 +03:00
|
|
|
col.skip[col.skip_count++] = pa->boid->ground;
|
2011-03-18 15:31:32 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
/* 10 iterations to catch multiple collisions */
|
2016-07-22 18:55:37 +03:00
|
|
|
while (collision_count < PARTICLE_COLLISION_MAX_COLLISIONS) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (collision_detect(pa, &col, &hit, sim->colliders)) {
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-03-18 15:31:32 +00:00
|
|
|
collision_count++;
|
2010-09-23 09:31:13 +00:00
|
|
|
|
2016-07-22 18:55:37 +03:00
|
|
|
if (collision_count == PARTICLE_COLLISION_MAX_COLLISIONS)
|
2011-03-18 15:31:32 +00:00
|
|
|
collision_fail(pa, &col);
|
2018-06-12 16:36:43 +02:00
|
|
|
else if (collision_response(sim, pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN)==0)
|
2011-03-18 15:31:32 +00:00
|
|
|
return;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/************************************************/
|
|
|
|
/* Hair */
|
|
|
|
/************************************************/
|
2009-09-10 22:32:33 +00:00
|
|
|
/* check if path cache or children need updating and do it if needed */
|
2016-06-23 07:53:49 +10:00
|
|
|
static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, const bool use_render_params)
|
2009-09-10 22:32:33 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
2010-07-17 17:07:50 +00:00
|
|
|
ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
|
|
|
|
int distr=0, alloc=0, skip=0;
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) || psys->recalc&PSYS_RECALC_RESET)
|
2010-07-17 17:07:50 +00:00
|
|
|
alloc=1;
|
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
if (alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
|
2010-07-17 17:07:50 +00:00
|
|
|
distr=1;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (distr) {
|
|
|
|
if (alloc)
|
2010-07-17 17:07:50 +00:00
|
|
|
realloc_particles(sim, sim->psys->totpart);
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
if (psys_get_tot_child(sim->scene, psys, use_render_params)) {
|
2010-07-17 17:07:50 +00:00
|
|
|
/* don't generate children while computing the hair keys */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
|
2010-07-17 17:07:50 +00:00
|
|
|
distribute_particles(sim, PART_FROM_CHILD);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->childtype==PART_CHILD_FACES && part->parents != 0.0f)
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_find_parents(sim, use_render_params);
|
2010-07-17 17:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
psys_free_children(psys);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1; /* only hair, keyed and baked stuff can have paths */
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (part->ren_as != PART_DRAW_PATH && !(part->type==PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)))
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1; /* particle visualization must be set as path */
|
2018-04-08 09:28:52 +02:00
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->draw_as != PART_DRAW_REND)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1; /* draw visualization */
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->pointcache->flag & PTCACHE_BAKING)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1; /* no need to cache paths while baking dynamics */
|
2018-02-10 02:40:41 -05:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
else if (psys_in_edit_mode(sim->depsgraph, psys)) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((pset->flag & PE_DRAW_PART)==0)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1;
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */
|
2018-04-12 03:32:36 -04:00
|
|
|
}
|
2010-07-17 17:07:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
|
|
|
|
/* particle instance modifier with "path" option need cached paths even if particle system doesn't */
|
2018-06-21 19:45:39 +02:00
|
|
|
if (skip) {
|
|
|
|
FOREACH_SCENE_OBJECT_BEGIN(sim->scene, ob)
|
|
|
|
{
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_ParticleInstance);
|
|
|
|
if (md) {
|
|
|
|
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
|
|
|
|
if (pimd->flag & eParticleInstanceFlag_Path && pimd->ob == sim->ob && pimd->psys == (psys - (ParticleSystem*)sim->ob->particlesystem.first)) {
|
|
|
|
skip = 0;
|
|
|
|
break;
|
|
|
|
}
|
2012-02-12 00:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-21 19:45:39 +02:00
|
|
|
FOREACH_SCENE_OBJECT_END;
|
2012-02-12 00:25:52 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!skip) {
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_cache_paths(sim, cfra, use_render_params);
|
2009-09-10 22:32:33 +00:00
|
|
|
|
|
|
|
/* for render, child particle paths are computed on the fly */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->childtype) {
|
|
|
|
if (!psys->totchild)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1;
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE)==0)
|
2010-07-17 17:07:50 +00:00
|
|
|
skip = 1;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!skip)
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_cache_child_paths(sim, cfra, 0, use_render_params);
|
2010-07-17 17:07:50 +00:00
|
|
|
}
|
2009-09-10 22:32:33 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->pathcache)
|
2009-09-10 22:32:33 +00:00
|
|
|
psys_free_path_cache(psys, NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
static bool psys_hair_use_simulation(ParticleData *pa, float max_length)
|
|
|
|
{
|
|
|
|
/* Minimum segment length relative to average length.
|
|
|
|
* Hairs with segments below this length will be excluded from the simulation,
|
|
|
|
* because otherwise the solver will become unstable.
|
|
|
|
* The hair system should always make sure the hair segments have reasonable length ratios,
|
|
|
|
* but this can happen in old files when e.g. cutting hair.
|
|
|
|
*/
|
2014-09-26 10:08:56 +02:00
|
|
|
const float min_length = 0.1f * max_length;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
HairKey *key;
|
|
|
|
int k;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
if (pa->totkey < 2)
|
|
|
|
return false;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) {
|
|
|
|
float length = len_v3v3(key->co, (key-1)->co);
|
|
|
|
if (length < min_length)
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MDeformVert *hair_set_pinning(MDeformVert *dvert, float weight)
|
|
|
|
{
|
|
|
|
if (dvert) {
|
|
|
|
if (!dvert->totweight) {
|
|
|
|
dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight");
|
|
|
|
dvert->totweight = 1;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
dvert->dw->weight = weight;
|
|
|
|
dvert++;
|
|
|
|
}
|
|
|
|
return dvert;
|
|
|
|
}
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
static void hair_create_input_mesh(ParticleSimulationData *sim, int totpoint, int totedge, Mesh **r_mesh, ClothHairData **r_hairdata)
|
2009-09-10 22:32:33 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2014-11-17 19:44:42 +01:00
|
|
|
ParticleSettings *part = psys->part;
|
2018-05-15 13:26:40 +02:00
|
|
|
Mesh *mesh;
|
2014-11-17 19:44:42 +01:00
|
|
|
ClothHairData *hairdata;
|
2015-01-19 18:39:41 +01:00
|
|
|
MVert *mvert;
|
|
|
|
MEdge *medge;
|
|
|
|
MDeformVert *dvert;
|
2009-09-10 22:32:33 +00:00
|
|
|
HairKey *key;
|
|
|
|
PARTICLE_P;
|
2015-01-19 18:39:41 +01:00
|
|
|
int k, hair_index;
|
2009-09-10 22:32:33 +00:00
|
|
|
float hairmat[4][4];
|
2014-09-16 14:36:56 +02:00
|
|
|
float max_length;
|
2014-12-16 19:40:29 +01:00
|
|
|
float hair_radius;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
mesh = *r_mesh;
|
|
|
|
if (!mesh) {
|
|
|
|
*r_mesh = mesh = BKE_mesh_new_nomain(totpoint, totedge, 0, 0, 0);
|
|
|
|
CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, mesh->totvert);
|
2018-05-29 10:36:19 +02:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, false);
|
2018-05-15 13:26:40 +02:00
|
|
|
}
|
|
|
|
mvert = mesh->mvert;
|
|
|
|
medge = mesh->medge;
|
|
|
|
dvert = mesh->dvert;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-11-17 19:44:42 +01:00
|
|
|
hairdata = *r_hairdata;
|
|
|
|
if (!hairdata) {
|
|
|
|
*r_hairdata = hairdata = MEM_mallocN(sizeof(ClothHairData) * totpoint, "hair data");
|
2015-01-19 18:39:41 +01:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-09-16 14:36:56 +02:00
|
|
|
/* calculate maximum segment length */
|
|
|
|
max_length = 0.0f;
|
|
|
|
LOOP_PARTICLES {
|
2017-07-28 15:24:48 +02:00
|
|
|
if (!(pa->flag & PARS_UNEXIST)) {
|
|
|
|
for (k=1, key=pa->hair+1; k<pa->totkey; k++,key++) {
|
|
|
|
float length = len_v3v3(key->co, (key-1)->co);
|
|
|
|
if (max_length < length)
|
|
|
|
max_length = length;
|
|
|
|
}
|
2014-09-16 14:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
psys->clmd->sim_parms->vgroup_mass = 1;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-12-16 19:40:29 +01:00
|
|
|
/* XXX placeholder for more flexible future hair settings */
|
|
|
|
hair_radius = part->size;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
/* make vgroup for pin roots etc.. */
|
2015-01-19 18:39:41 +01:00
|
|
|
hair_index = 1;
|
2009-09-10 22:32:33 +00:00
|
|
|
LOOP_PARTICLES {
|
2017-07-28 15:24:48 +02:00
|
|
|
if (!(pa->flag & PARS_UNEXIST)) {
|
|
|
|
float root_mat[4][4];
|
|
|
|
float bending_stiffness;
|
|
|
|
bool use_hair;
|
|
|
|
|
|
|
|
pa->hair_index = hair_index;
|
|
|
|
use_hair = psys_hair_use_simulation(pa, max_length);
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_mat_hair_to_object(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat);
|
2017-07-28 15:24:48 +02:00
|
|
|
mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat);
|
|
|
|
normalize_m4(root_mat);
|
|
|
|
|
|
|
|
bending_stiffness = CLAMPIS(1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f);
|
|
|
|
|
|
|
|
for (k=0, key=pa->hair; k<pa->totkey; k++,key++) {
|
|
|
|
ClothHairData *hair;
|
|
|
|
float *co, *co_next;
|
|
|
|
|
|
|
|
co = key->co;
|
|
|
|
co_next = (key+1)->co;
|
|
|
|
|
|
|
|
/* create fake root before actual root to resist bending */
|
|
|
|
if (k==0) {
|
|
|
|
hair = &psys->clmd->hairdata[pa->hair_index - 1];
|
|
|
|
copy_v3_v3(hair->loc, root_mat[3]);
|
|
|
|
copy_m3_m4(hair->rot, root_mat);
|
|
|
|
|
|
|
|
hair->radius = hair_radius;
|
|
|
|
hair->bending_stiffness = bending_stiffness;
|
|
|
|
|
|
|
|
add_v3_v3v3(mvert->co, co, co);
|
|
|
|
sub_v3_v3(mvert->co, co_next);
|
|
|
|
mul_m4_v3(hairmat, mvert->co);
|
|
|
|
|
|
|
|
medge->v1 = pa->hair_index - 1;
|
|
|
|
medge->v2 = pa->hair_index;
|
|
|
|
|
|
|
|
dvert = hair_set_pinning(dvert, 1.0f);
|
|
|
|
|
|
|
|
mvert++;
|
|
|
|
medge++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store root transform in cloth data */
|
|
|
|
hair = &psys->clmd->hairdata[pa->hair_index + k];
|
2014-11-17 19:44:42 +01:00
|
|
|
copy_v3_v3(hair->loc, root_mat[3]);
|
|
|
|
copy_m3_m4(hair->rot, root_mat);
|
2017-07-28 15:24:48 +02:00
|
|
|
|
2014-12-16 19:40:29 +01:00
|
|
|
hair->radius = hair_radius;
|
2014-11-17 19:44:42 +01:00
|
|
|
hair->bending_stiffness = bending_stiffness;
|
2017-07-28 15:24:48 +02:00
|
|
|
|
|
|
|
copy_v3_v3(mvert->co, co);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(hairmat, mvert->co);
|
2017-07-28 15:24:48 +02:00
|
|
|
|
|
|
|
if (k) {
|
|
|
|
medge->v1 = pa->hair_index + k - 1;
|
|
|
|
medge->v2 = pa->hair_index + k;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* roots and disabled hairs should be 1.0, the rest can be anything from 0.0 to 1.0 */
|
|
|
|
if (use_hair)
|
|
|
|
dvert = hair_set_pinning(dvert, key->weight);
|
|
|
|
else
|
|
|
|
dvert = hair_set_pinning(dvert, 1.0f);
|
|
|
|
|
2015-01-19 18:39:41 +01:00
|
|
|
mvert++;
|
2017-07-28 15:24:48 +02:00
|
|
|
if (k)
|
|
|
|
medge++;
|
2009-09-17 22:00:49 +00:00
|
|
|
}
|
2017-07-28 15:24:48 +02:00
|
|
|
|
|
|
|
hair_index += pa->totkey + 1;
|
2009-09-10 22:32:33 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-19 18:39:41 +01:00
|
|
|
}
|
2009-09-10 22:32:33 +00:00
|
|
|
|
2015-01-19 18:39:41 +01:00
|
|
|
static void do_hair_dynamics(ParticleSimulationData *sim)
|
|
|
|
{
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
PARTICLE_P;
|
2015-02-02 14:09:02 +01:00
|
|
|
EffectorWeights *clmd_effweights;
|
2015-01-19 18:39:41 +01:00
|
|
|
int totpoint;
|
|
|
|
int totedge;
|
|
|
|
float (*deformedVerts)[3];
|
|
|
|
bool realloc_roots;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-01-19 18:39:41 +01:00
|
|
|
if (!psys->clmd) {
|
|
|
|
psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
|
|
|
|
psys->clmd->sim_parms->goalspring = 0.0f;
|
|
|
|
psys->clmd->sim_parms->vel_damping = 1.0f;
|
|
|
|
psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
|
|
|
|
psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-01-19 18:39:41 +01:00
|
|
|
/* count simulated points */
|
|
|
|
totpoint = 0;
|
|
|
|
totedge = 0;
|
|
|
|
LOOP_PARTICLES {
|
2017-07-28 15:24:48 +02:00
|
|
|
if (!(pa->flag & PARS_UNEXIST)) {
|
|
|
|
/* "out" dm contains all hairs */
|
|
|
|
totedge += pa->totkey;
|
|
|
|
totpoint += pa->totkey + 1; /* +1 for virtual root point */
|
|
|
|
}
|
2015-01-19 18:39:41 +01:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-01-19 18:39:41 +01:00
|
|
|
realloc_roots = false; /* whether hair root info array has to be reallocated */
|
2018-05-15 13:26:40 +02:00
|
|
|
if (psys->hair_in_mesh) {
|
|
|
|
Mesh *mesh = psys->hair_in_mesh;
|
|
|
|
if (totpoint != mesh->totvert || totedge != mesh->totedge) {
|
|
|
|
BKE_id_free(NULL, mesh);
|
|
|
|
psys->hair_in_mesh = NULL;
|
2015-01-19 18:39:41 +01:00
|
|
|
realloc_roots = true;
|
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (!psys->hair_in_mesh || !psys->clmd->hairdata || realloc_roots) {
|
2014-11-17 19:44:42 +01:00
|
|
|
if (psys->clmd->hairdata) {
|
|
|
|
MEM_freeN(psys->clmd->hairdata);
|
|
|
|
psys->clmd->hairdata = NULL;
|
2015-01-19 18:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh, &psys->clmd->hairdata);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (psys->hair_out_mesh)
|
|
|
|
BKE_id_free(NULL, psys->hair_out_mesh);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
psys->clmd->point_cache = psys->pointcache;
|
2015-02-02 14:09:02 +01:00
|
|
|
/* for hair sim we replace the internal cloth effector weights temporarily
|
|
|
|
* to use the particle settings
|
|
|
|
*/
|
|
|
|
clmd_effweights = psys->clmd->sim_parms->effector_weights;
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
BKE_id_copy_ex(
|
|
|
|
NULL, &psys->hair_in_mesh->id, (ID **)&psys->hair_out_mesh,
|
|
|
|
LIB_ID_CREATE_NO_MAIN |
|
|
|
|
LIB_ID_CREATE_NO_USER_REFCOUNT |
|
|
|
|
LIB_ID_CREATE_NO_DEG_TAG |
|
|
|
|
LIB_ID_COPY_NO_PREVIEW,
|
|
|
|
false);
|
|
|
|
deformedVerts = BKE_mesh_vertexCos_get(psys->hair_out_mesh, NULL);
|
2018-05-18 17:32:22 +02:00
|
|
|
clothModifier_do(psys->clmd, sim->depsgraph, sim->scene, sim->ob, psys->hair_in_mesh, deformedVerts);
|
2018-05-15 13:26:40 +02:00
|
|
|
BKE_mesh_apply_vert_coords(psys->hair_out_mesh, deformedVerts);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-15 12:26:29 +00:00
|
|
|
MEM_freeN(deformedVerts);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-02-02 14:09:02 +01:00
|
|
|
/* restore cloth effector weights */
|
|
|
|
psys->clmd->sim_parms->effector_weights = clmd_effweights;
|
2009-09-10 22:32:33 +00:00
|
|
|
}
|
2016-06-23 07:53:49 +10:00
|
|
|
static void hair_step(ParticleSimulationData *sim, float cfra, const bool use_render_params)
|
2009-09-10 22:32:33 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2011-07-10 17:30:31 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2009-09-10 22:32:33 +00:00
|
|
|
PARTICLE_P;
|
2018-04-08 09:28:52 +02:00
|
|
|
float disp = psys_get_current_display_percentage(psys, use_render_params);
|
2009-09-10 22:32:33 +00:00
|
|
|
|
|
|
|
LOOP_PARTICLES {
|
2011-07-10 17:30:31 +00:00
|
|
|
pa->size = part->size;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randsize > 0.0f)
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
|
2011-07-10 17:30:31 +00:00
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
if (psys_frand(psys, p) > disp)
|
2009-09-10 22:32:33 +00:00
|
|
|
pa->flag |= PARS_NO_DISP;
|
|
|
|
else
|
|
|
|
pa->flag &= ~PARS_NO_DISP;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->recalc & PSYS_RECALC_RESET) {
|
2009-09-10 22:32:33 +00:00
|
|
|
/* need this for changing subsurf levels */
|
2018-05-25 21:44:33 +02:00
|
|
|
psys_calc_dmcache(sim->ob, sim->psmd->mesh_final, sim->psmd->mesh_original, psys);
|
2009-09-10 22:32:33 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->clmd)
|
2010-10-16 14:32:17 +00:00
|
|
|
cloth_free_modifier(psys->clmd);
|
2009-09-10 22:32:33 +00:00
|
|
|
}
|
|
|
|
|
2011-01-07 04:30:02 +00:00
|
|
|
/* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles)
|
2009-09-17 22:00:49 +00:00
|
|
|
do_hair_dynamics(sim);
|
2009-09-10 22:32:33 +00:00
|
|
|
|
2010-07-10 18:11:01 +00:00
|
|
|
/* following lines were removed r29079 but cause bug [#22811], see report for details */
|
|
|
|
psys_update_effectors(sim);
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_update_path_cache(sim, cfra, use_render_params);
|
2010-07-10 18:11:01 +00:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
psys->flag |= PSYS_HAIR_UPDATED;
|
|
|
|
}
|
|
|
|
|
2011-12-30 07:55:15 +00:00
|
|
|
static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
|
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
Object *ob = sim->ob;
|
|
|
|
ParticleSystem *psys = sim->psys;
|
2009-09-04 23:06:15 +00:00
|
|
|
HairKey *key, *root;
|
|
|
|
PARTICLE_P;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data= psys_create_lattice_deform_data(sim);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totpart==0) return;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* save new keys for elements if needed */
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* first time alloc */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->totkey==0 || pa->hair==NULL) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
pa->hair = MEM_callocN((psys->part->hair_step + 1) * sizeof(HairKey), "HairKeys");
|
|
|
|
pa->totkey = 0;
|
|
|
|
}
|
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
key = root = pa->hair;
|
|
|
|
key += pa->totkey;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
|
|
|
/* convert from global to geometry space */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(key->co, pa->state.co);
|
|
|
|
mul_m4_v3(ob->imat, key->co);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->totkey) {
|
2011-11-06 14:00:55 +00:00
|
|
|
sub_v3_v3(key->co, root->co);
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_vec_rot_to_face(sim->psmd->mesh_final, pa, key->co);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
key->time = pa->state.time;
|
|
|
|
|
|
|
|
key->weight = 1.0f - key->time / 100.0f;
|
|
|
|
|
|
|
|
pa->totkey++;
|
|
|
|
|
|
|
|
/* root is always in the origin of hair space so we set it to be so after the last key is saved*/
|
2012-07-17 12:05:15 +00:00
|
|
|
if (pa->totkey == psys->part->hair_step + 1) {
|
|
|
|
zero_v3(root->co);
|
|
|
|
}
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-25 11:51:28 +00:00
|
|
|
|
|
|
|
/* Code for an adaptive time step based on the Courant-Friedrichs-Lewy
|
2012-03-03 20:19:11 +00:00
|
|
|
* condition. */
|
2012-12-12 22:42:55 +00:00
|
|
|
static const float MIN_TIMESTEP = 1.0f / 101.0f;
|
2012-03-09 00:41:09 +00:00
|
|
|
/* Tolerance of 1.5 means the last subframe neither favors growing nor
|
2012-03-03 20:19:11 +00:00
|
|
|
* shrinking (e.g if it were 1.3, the last subframe would tend to be too
|
|
|
|
* small). */
|
2012-12-12 22:42:55 +00:00
|
|
|
static const float TIMESTEP_EXPANSION_FACTOR = 0.1f;
|
|
|
|
static const float TIMESTEP_EXPANSION_TOLERANCE = 1.5f;
|
2011-09-25 11:51:28 +00:00
|
|
|
|
|
|
|
/* Calculate the speed of the particle relative to the local scale of the
|
2012-03-03 20:19:11 +00:00
|
|
|
* simulation. This should be called once per particle during a simulation
|
|
|
|
* step, after the velocity has been updated. element_size defines the scale of
|
2012-09-26 20:05:38 +00:00
|
|
|
* the simulation, and is typically the distance to neighboring particles. */
|
2012-09-15 01:52:28 +00:00
|
|
|
static void update_courant_num(ParticleSimulationData *sim, ParticleData *pa,
|
2016-03-12 09:09:29 +01:00
|
|
|
float dtime, SPHData *sphdata, SpinLock *spin)
|
2011-09-25 11:51:28 +00:00
|
|
|
{
|
|
|
|
float relative_vel[3];
|
|
|
|
|
2012-01-02 12:10:50 +00:00
|
|
|
sub_v3_v3v3(relative_vel, pa->prev_state.vel, sphdata->flow);
|
2016-03-12 09:09:29 +01:00
|
|
|
|
|
|
|
const float courant_num = len_v3(relative_vel) * dtime / sphdata->element_size;
|
|
|
|
if (sim->courant_num < courant_num) {
|
|
|
|
BLI_spin_lock(spin);
|
|
|
|
if (sim->courant_num < courant_num) {
|
|
|
|
sim->courant_num = courant_num;
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(spin);
|
|
|
|
}
|
2011-09-25 11:51:28 +00:00
|
|
|
}
|
2012-12-18 01:52:18 +00:00
|
|
|
static float get_base_time_step(ParticleSettings *part)
|
|
|
|
{
|
2012-12-12 22:42:55 +00:00
|
|
|
return 1.0f / (float) (part->subframes + 1);
|
|
|
|
}
|
2011-09-25 11:51:28 +00:00
|
|
|
/* Update time step size to suit current conditions. */
|
2016-08-01 21:45:42 +03:00
|
|
|
static void update_timestep(ParticleSystem *psys, ParticleSimulationData *sim)
|
2011-09-25 11:51:28 +00:00
|
|
|
{
|
2012-12-12 22:42:55 +00:00
|
|
|
float dt_target;
|
2011-09-25 11:51:28 +00:00
|
|
|
if (sim->courant_num == 0.0f)
|
2012-12-12 22:42:55 +00:00
|
|
|
dt_target = 1.0f;
|
|
|
|
else
|
|
|
|
dt_target = psys->dt_frac * (psys->part->courant_target / sim->courant_num);
|
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
/* Make sure the time step is reasonable. For some reason, the CLAMP macro
|
|
|
|
* doesn't work here. The time step becomes too large. - z0r */
|
2012-12-12 22:42:55 +00:00
|
|
|
if (dt_target < MIN_TIMESTEP)
|
|
|
|
dt_target = MIN_TIMESTEP;
|
|
|
|
else if (dt_target > get_base_time_step(psys->part))
|
|
|
|
dt_target = get_base_time_step(psys->part);
|
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
/* Decrease time step instantly, but increase slowly. */
|
2012-12-12 22:42:55 +00:00
|
|
|
if (dt_target > psys->dt_frac)
|
|
|
|
psys->dt_frac = interpf(dt_target, psys->dt_frac, TIMESTEP_EXPANSION_FACTOR);
|
2011-09-25 11:51:28 +00:00
|
|
|
else
|
2012-12-12 22:42:55 +00:00
|
|
|
psys->dt_frac = dt_target;
|
2016-08-01 21:45:42 +03:00
|
|
|
}
|
2011-09-25 11:51:28 +00:00
|
|
|
|
2016-08-01 21:45:42 +03:00
|
|
|
static float sync_timestep(ParticleSystem *psys, float t_frac)
|
|
|
|
{
|
2011-09-25 11:51:28 +00:00
|
|
|
/* Sync with frame end if it's close. */
|
|
|
|
if (t_frac == 1.0f)
|
|
|
|
return psys->dt_frac;
|
|
|
|
else if (t_frac + (psys->dt_frac * TIMESTEP_EXPANSION_TOLERANCE) >= 1.0f)
|
|
|
|
return 1.0f - t_frac;
|
|
|
|
else
|
|
|
|
return psys->dt_frac;
|
|
|
|
}
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/************************************************/
|
|
|
|
/* System Core */
|
|
|
|
/************************************************/
|
2016-01-20 19:43:45 +01:00
|
|
|
|
|
|
|
typedef struct DynamicStepSolverTaskData {
|
|
|
|
ParticleSimulationData *sim;
|
|
|
|
|
|
|
|
float cfra;
|
|
|
|
float timestep;
|
|
|
|
float dtime;
|
|
|
|
|
2016-03-12 09:09:29 +01:00
|
|
|
SpinLock spin;
|
2016-01-20 19:43:45 +01:00
|
|
|
} DynamicStepSolverTaskData;
|
|
|
|
|
|
|
|
static void dynamics_step_sph_ddr_task_cb_ex(
|
2018-01-10 12:49:51 +01:00
|
|
|
void *__restrict userdata,
|
|
|
|
const int p,
|
|
|
|
const ParallelRangeTLS *__restrict tls)
|
2016-01-20 19:43:45 +01:00
|
|
|
{
|
|
|
|
DynamicStepSolverTaskData *data = userdata;
|
|
|
|
ParticleSimulationData *sim = data->sim;
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
2018-01-05 16:33:13 +01:00
|
|
|
SPHData *sphdata = tls->userdata_chunk;
|
2016-01-20 19:43:45 +01:00
|
|
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
|
|
|
if ((pa = psys->particles + p)->state.time <= 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do global forces & effectors */
|
|
|
|
basic_integrate(sim, p, pa->state.time, data->cfra);
|
|
|
|
|
|
|
|
/* actual fluids calculations */
|
|
|
|
sph_integrate(sim, pa, pa->state.time, sphdata);
|
|
|
|
|
|
|
|
if (sim->colliders)
|
|
|
|
collision_check(sim, p, pa->state.time, data->cfra);
|
|
|
|
|
|
|
|
/* SPH particles are not physical particles, just interpolation
|
|
|
|
* particles, thus rotation has not a direct sense for them */
|
|
|
|
basic_rotate(part, pa, pa->state.time, data->timestep);
|
|
|
|
|
|
|
|
if (part->time_flag & PART_TIME_AUTOSF) {
|
2016-03-12 09:09:29 +01:00
|
|
|
update_courant_num(sim, pa, data->dtime, sphdata, &data->spin);
|
2016-01-20 19:43:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-12 09:09:29 +01:00
|
|
|
static void dynamics_step_sph_classical_basic_integrate_task_cb_ex(
|
2018-06-17 17:05:51 +02:00
|
|
|
void *__restrict userdata,
|
2018-01-10 12:49:51 +01:00
|
|
|
const int p,
|
|
|
|
const ParallelRangeTLS *__restrict UNUSED(tls))
|
2016-01-20 19:43:45 +01:00
|
|
|
{
|
|
|
|
DynamicStepSolverTaskData *data = userdata;
|
|
|
|
ParticleSimulationData *sim = data->sim;
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
|
|
|
if ((pa = psys->particles + p)->state.time <= 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
basic_integrate(sim, p, pa->state.time, data->cfra);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dynamics_step_sph_classical_calc_density_task_cb_ex(
|
2018-01-10 12:49:51 +01:00
|
|
|
void *__restrict userdata,
|
|
|
|
const int p,
|
|
|
|
const ParallelRangeTLS *__restrict tls)
|
2016-01-20 19:43:45 +01:00
|
|
|
{
|
|
|
|
DynamicStepSolverTaskData *data = userdata;
|
|
|
|
ParticleSimulationData *sim = data->sim;
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
|
2018-01-05 16:33:13 +01:00
|
|
|
SPHData *sphdata = tls->userdata_chunk;
|
2016-01-20 19:43:45 +01:00
|
|
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
|
|
|
if ((pa = psys->particles + p)->state.time <= 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sphclassical_calc_dens(pa, pa->state.time, sphdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dynamics_step_sph_classical_integrate_task_cb_ex(
|
2018-01-10 12:49:51 +01:00
|
|
|
void *__restrict userdata,
|
|
|
|
const int p,
|
|
|
|
const ParallelRangeTLS *__restrict tls)
|
2016-01-20 19:43:45 +01:00
|
|
|
{
|
|
|
|
DynamicStepSolverTaskData *data = userdata;
|
|
|
|
ParticleSimulationData *sim = data->sim;
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
2018-01-05 16:33:13 +01:00
|
|
|
SPHData *sphdata = tls->userdata_chunk;
|
2016-01-20 19:43:45 +01:00
|
|
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
|
|
|
if ((pa = psys->particles + p)->state.time <= 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actual fluids calculations */
|
|
|
|
sph_integrate(sim, pa, pa->state.time, sphdata);
|
|
|
|
|
|
|
|
if (sim->colliders)
|
|
|
|
collision_check(sim, p, pa->state.time, data->cfra);
|
|
|
|
|
|
|
|
/* SPH particles are not physical particles, just interpolation
|
|
|
|
* particles, thus rotation has not a direct sense for them */
|
|
|
|
basic_rotate(part, pa, pa->state.time, data->timestep);
|
|
|
|
|
|
|
|
if (part->time_flag & PART_TIME_AUTOSF) {
|
2016-03-12 09:09:29 +01:00
|
|
|
update_courant_num(sim, pa, data->dtime, sphdata, &data->spin);
|
2016-01-20 19:43:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* unbaked particles are calculated dynamically */
|
2009-09-17 22:00:49 +00:00
|
|
|
static void dynamics_step(ParticleSimulationData *sim, float cfra)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
ParticleSettings *part=psys->part;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidBrainData bbd;
|
2011-02-12 14:38:34 +00:00
|
|
|
ParticleTexture ptex;
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
float timestep;
|
|
|
|
/* frame & time changes */
|
2010-11-18 19:12:36 +00:00
|
|
|
float dfra, dtime;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
float birthtime, dietime;
|
2011-09-25 11:51:28 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* where have we gone in time since last time */
|
|
|
|
dfra= cfra - psys->cfra;
|
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
timestep = psys_get_timestep(sim);
|
2010-11-18 19:12:36 +00:00
|
|
|
dtime= dfra*timestep;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dfra < 0.0f) {
|
2009-09-17 22:00:49 +00:00
|
|
|
LOOP_EXISTING_PARTICLES {
|
2011-02-12 14:38:34 +00:00
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
|
|
|
|
pa->size = part->size*ptex.size;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randsize > 0.0f)
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
reset_particle(sim, pa, dtime, cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
return;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2013-05-27 22:25:54 +00:00
|
|
|
/* for now do both, boids us 'rng' */
|
2018-06-12 16:36:43 +02:00
|
|
|
sim->rng = BLI_rng_new_srandom(31415926 + (int)cfra + psys->seed);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
psys_update_effectors(sim);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->type != PART_HAIR)
|
2018-06-22 14:42:03 +02:00
|
|
|
sim->colliders = BKE_collider_cache_create(sim->depsgraph, sim->ob, part->collision_group);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
/* initialize physics type specific stuff */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (part->phystype) {
|
2010-11-18 19:12:36 +00:00
|
|
|
case PART_PHYS_BOIDS:
|
|
|
|
{
|
|
|
|
ParticleTarget *pt = psys->targets.first;
|
|
|
|
bbd.sim = sim;
|
|
|
|
bbd.part = part;
|
|
|
|
bbd.cfra = cfra;
|
|
|
|
bbd.dfra = dfra;
|
|
|
|
bbd.timestep = timestep;
|
2018-06-12 16:36:43 +02:00
|
|
|
bbd.rng = sim->rng;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
psys_update_particle_tree(psys, cfra);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
boids_precalc_rules(part, cfra);
|
2010-03-21 20:36:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (; pt; pt=pt->next) {
|
2016-03-13 18:21:30 +01:00
|
|
|
ParticleSystem *psys_target = psys_get_target_system(sim->ob, pt);
|
|
|
|
if (psys_target && psys_target != psys) {
|
|
|
|
psys_update_particle_tree(psys_target, cfra);
|
|
|
|
}
|
2010-11-18 19:12:36 +00:00
|
|
|
}
|
|
|
|
break;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2010-11-18 19:12:36 +00:00
|
|
|
case PART_PHYS_FLUID:
|
|
|
|
{
|
|
|
|
ParticleTarget *pt = psys->targets.first;
|
2012-01-02 11:46:02 +00:00
|
|
|
psys_update_particle_bvhtree(psys, cfra);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */
|
|
|
|
if (pt->ob)
|
2012-01-02 11:46:02 +00:00
|
|
|
psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
|
2010-11-18 19:12:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-04-04 12:29:06 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-18 19:12:36 +00:00
|
|
|
/* initialize all particles for dynamics */
|
2010-03-21 20:36:06 +00:00
|
|
|
LOOP_SHOWN_PARTICLES {
|
2012-05-15 12:07:44 +00:00
|
|
|
copy_particle_key(&pa->prev_state,&pa->state,1);
|
2009-09-17 22:00:49 +00:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
|
|
|
|
|
|
|
|
pa->size = part->size*ptex.size;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randsize > 0.0f)
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
birthtime = pa->time;
|
2011-07-05 02:56:14 +00:00
|
|
|
dietime = pa->dietime;
|
2008-02-17 14:44:12 +00:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
/* store this, so we can do multiple loops over particles */
|
|
|
|
pa->state.time = dfra;
|
2009-06-21 10:16:52 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dietime <= cfra && psys->cfra < dietime) {
|
2010-03-21 20:36:06 +00:00
|
|
|
/* particle dies some time between this and last step */
|
2010-11-18 19:12:36 +00:00
|
|
|
pa->state.time = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra);
|
2010-03-21 20:36:06 +00:00
|
|
|
pa->alive = PARS_DYING;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (birthtime <= cfra && birthtime >= psys->cfra) {
|
2010-03-21 20:36:06 +00:00
|
|
|
/* particle is born some time between this and last step*/
|
2010-11-18 19:12:36 +00:00
|
|
|
reset_particle(sim, pa, dfra*timestep, cfra);
|
2010-03-21 20:36:06 +00:00
|
|
|
pa->alive = PARS_ALIVE;
|
2010-11-18 19:12:36 +00:00
|
|
|
pa->state.time = cfra - birthtime;
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (dietime < cfra) {
|
2010-03-21 20:36:06 +00:00
|
|
|
/* nothing to be done when particle is dead */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only reset unborn particles if they're shown or if the particle is born soon*/
|
2012-04-21 15:11:03 +00:00
|
|
|
if (pa->alive==PARS_UNBORN && (part->flag & PART_UNBORN || (cfra + psys->pointcache->step > pa->time))) {
|
2010-03-21 20:36:06 +00:00
|
|
|
reset_particle(sim, pa, dtime, cfra);
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
|
|
|
else if (part->phystype == PART_PHYS_NO) {
|
2010-03-21 20:36:06 +00:00
|
|
|
reset_particle(sim, pa, dtime, cfra);
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING)==0 || (pa->flag & (PARS_UNEXIST|PARS_NO_DISP)))
|
2010-11-18 19:12:36 +00:00
|
|
|
pa->state.time = -1.f;
|
|
|
|
}
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (part->phystype) {
|
2010-11-18 19:12:36 +00:00
|
|
|
case PART_PHYS_NEWTON:
|
|
|
|
{
|
|
|
|
LOOP_DYNAMIC_PARTICLES {
|
|
|
|
/* do global forces & effectors */
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
basic_integrate(sim, p, pa->state.time, cfra);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
/* deflection */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sim->colliders)
|
2011-03-18 15:31:32 +00:00
|
|
|
collision_check(sim, p, pa->state.time, cfra);
|
2010-11-18 19:12:36 +00:00
|
|
|
|
|
|
|
/* rotations */
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
basic_rotate(part, pa, pa->state.time, timestep);
|
2010-11-18 19:12:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PART_PHYS_BOIDS:
|
|
|
|
{
|
|
|
|
LOOP_DYNAMIC_PARTICLES {
|
|
|
|
bbd.goal_ob = NULL;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
boid_brain(&bbd, p, pa);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->alive != PARS_DYING) {
|
2010-11-18 19:12:36 +00:00
|
|
|
boid_body(&bbd, pa);
|
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* deflection */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sim->colliders)
|
2011-03-18 15:31:32 +00:00
|
|
|
collision_check(sim, p, pa->state.time, cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2010-11-18 19:12:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PART_PHYS_FLUID:
|
|
|
|
{
|
2012-01-02 12:10:50 +00:00
|
|
|
SPHData sphdata;
|
2012-12-14 04:57:26 +00:00
|
|
|
psys_sph_init(sim, &sphdata);
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2016-01-20 19:43:45 +01:00
|
|
|
DynamicStepSolverTaskData task_data = {
|
|
|
|
.sim = sim, .cfra = cfra, .timestep = timestep, .dtime = dtime,
|
|
|
|
};
|
|
|
|
|
2016-03-12 09:09:29 +01:00
|
|
|
BLI_spin_init(&task_data.spin);
|
2016-01-20 19:43:45 +01:00
|
|
|
|
2013-01-11 02:03:22 +00:00
|
|
|
if (part->fluid->solver == SPH_SOLVER_DDR) {
|
2012-12-14 04:57:26 +00:00
|
|
|
/* Apply SPH forces using double-density relaxation algorithm
|
|
|
|
* (Clavat et. al.) */
|
|
|
|
|
2018-01-08 11:35:48 +01:00
|
|
|
ParallelRangeSettings settings;
|
|
|
|
BLI_parallel_range_settings_defaults(&settings);
|
|
|
|
settings.use_threading = (psys->totpart > 100);
|
|
|
|
settings.userdata_chunk = &sphdata;
|
|
|
|
settings.userdata_chunk_size = sizeof(sphdata);
|
|
|
|
BLI_task_parallel_range(
|
|
|
|
0, psys->totpart,
|
|
|
|
&task_data,
|
|
|
|
dynamics_step_sph_ddr_task_cb_ex,
|
|
|
|
&settings);
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
sph_springs_modify(psys, timestep);
|
2012-12-18 01:46:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-12-14 04:57:26 +00:00
|
|
|
/* SPH_SOLVER_CLASSICAL */
|
|
|
|
/* Apply SPH forces using classical algorithm (due to Gingold
|
|
|
|
* and Monaghan). Note that, unlike double-density relaxation,
|
2013-07-05 00:13:14 +00:00
|
|
|
* this algorithm is separated into distinct loops. */
|
2012-12-14 04:57:26 +00:00
|
|
|
|
2018-01-08 11:35:48 +01:00
|
|
|
{
|
|
|
|
ParallelRangeSettings settings;
|
|
|
|
BLI_parallel_range_settings_defaults(&settings);
|
|
|
|
settings.use_threading = (psys->totpart > 100);
|
|
|
|
BLI_task_parallel_range(
|
|
|
|
0, psys->totpart,
|
|
|
|
&task_data,
|
|
|
|
dynamics_step_sph_classical_basic_integrate_task_cb_ex,
|
|
|
|
&settings);
|
|
|
|
}
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
/* calculate summation density */
|
2016-01-20 19:43:45 +01:00
|
|
|
/* Note that we could avoid copying sphdata for each thread here (it's only read here),
|
|
|
|
* but doubt this would gain us anything except confusion... */
|
2018-01-08 11:35:48 +01:00
|
|
|
{
|
2018-04-16 17:08:27 +02:00
|
|
|
ParallelRangeSettings settings;
|
|
|
|
BLI_parallel_range_settings_defaults(&settings);
|
|
|
|
settings.use_threading = (psys->totpart > 100);
|
|
|
|
settings.userdata_chunk = &sphdata;
|
|
|
|
settings.userdata_chunk_size = sizeof(sphdata);
|
2018-01-08 11:35:48 +01:00
|
|
|
BLI_task_parallel_range(
|
|
|
|
0, psys->totpart,
|
|
|
|
&task_data,
|
|
|
|
dynamics_step_sph_classical_calc_density_task_cb_ex,
|
|
|
|
&settings);
|
|
|
|
}
|
2012-12-14 04:57:26 +00:00
|
|
|
|
|
|
|
/* do global forces & effectors */
|
2018-01-08 11:35:48 +01:00
|
|
|
{
|
2018-04-16 17:08:27 +02:00
|
|
|
ParallelRangeSettings settings;
|
|
|
|
BLI_parallel_range_settings_defaults(&settings);
|
|
|
|
settings.use_threading = (psys->totpart > 100);
|
|
|
|
settings.userdata_chunk = &sphdata;
|
|
|
|
settings.userdata_chunk_size = sizeof(sphdata);
|
2018-01-08 11:35:48 +01:00
|
|
|
BLI_task_parallel_range(
|
|
|
|
0, psys->totpart,
|
|
|
|
&task_data,
|
|
|
|
dynamics_step_sph_classical_integrate_task_cb_ex,
|
|
|
|
&settings);
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2016-03-12 09:09:29 +01:00
|
|
|
BLI_spin_end(&task_data.spin);
|
2016-01-20 19:43:45 +01:00
|
|
|
|
2012-12-14 04:57:26 +00:00
|
|
|
psys_sph_finalise(&sphdata);
|
2010-11-18 19:12:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
|
2010-11-18 19:12:36 +00:00
|
|
|
/* finalize particle state and time after dynamics */
|
|
|
|
LOOP_DYNAMIC_PARTICLES {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->alive == PARS_DYING) {
|
2010-11-18 19:12:36 +00:00
|
|
|
pa->alive=PARS_DEAD;
|
|
|
|
pa->state.time=pa->dietime;
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
2010-11-18 19:12:36 +00:00
|
|
|
else
|
|
|
|
pa->state.time=cfra;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2018-06-22 14:42:03 +02:00
|
|
|
BKE_collider_cache_free(&sim->colliders);
|
2018-06-12 16:36:43 +02:00
|
|
|
BLI_rng_free(sim->rng);
|
|
|
|
sim->rng = NULL;
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
2018-06-12 16:36:43 +02:00
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
static void update_children(ParticleSimulationData *sim, const bool use_render_params)
|
2010-03-21 20:36:06 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE)==0)
|
2010-03-21 20:36:06 +00:00
|
|
|
/* don't generate children while growing hair - waste of time */
|
|
|
|
psys_free_children(sim->psys);
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (sim->psys->part->childtype) {
|
2018-04-08 09:28:52 +02:00
|
|
|
if (sim->psys->totchild != psys_get_tot_child(sim->scene, sim->psys, use_render_params))
|
2010-12-10 10:34:12 +00:00
|
|
|
distribute_particles(sim, PART_FROM_CHILD);
|
2011-10-26 21:30:08 +00:00
|
|
|
else {
|
|
|
|
/* Children are up to date, nothing to do. */
|
|
|
|
}
|
2010-12-10 10:34:12 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
else
|
|
|
|
psys_free_children(sim->psys);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
/* updates cached particles' alive & other flags etc..*/
|
2018-04-08 09:28:52 +02:00
|
|
|
static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_render_params)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
2011-02-12 14:38:34 +00:00
|
|
|
ParticleTexture ptex;
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
2011-01-08 12:43:44 +00:00
|
|
|
float disp, dietime;
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
psys_update_effectors(sim);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
disp= psys_get_current_display_percentage(psys, use_render_params);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES {
|
2011-02-12 14:38:34 +00:00
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
|
|
|
|
pa->size = part->size*ptex.size;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randsize > 0.0f)
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-12-25 23:51:29 +00:00
|
|
|
dietime = pa->dietime;
|
2008-02-17 14:44:12 +00:00
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* update alive status and push events */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->time > cfra) {
|
2009-09-17 22:00:49 +00:00
|
|
|
pa->alive = PARS_UNBORN;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->flag & PART_UNBORN && (psys->pointcache->flag & PTCACHE_EXTERNAL) == 0)
|
2009-09-17 22:00:49 +00:00
|
|
|
reset_particle(sim, pa, 0.0f, cfra);
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (dietime <= cfra)
|
2008-02-17 14:44:12 +00:00
|
|
|
pa->alive = PARS_DEAD;
|
2010-03-21 20:36:06 +00:00
|
|
|
else
|
2008-02-17 14:44:12 +00:00
|
|
|
pa->alive = PARS_ALIVE;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
if (psys->lattice_deform_data) {
|
|
|
|
end_latt_deform(psys->lattice_deform_data);
|
|
|
|
psys->lattice_deform_data = NULL;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
if (psys_frand(psys, p) > disp)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
pa->flag |= PARS_NO_DISP;
|
|
|
|
else
|
|
|
|
pa->flag &= ~PARS_NO_DISP;
|
|
|
|
}
|
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2018-06-02 11:58:01 +02:00
|
|
|
static void particles_fluid_step(
|
|
|
|
Main *bmain, ParticleSimulationData *sim, int UNUSED(cfra), const bool use_render_params)
|
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles) {
|
2008-04-02 17:48:46 +00:00
|
|
|
MEM_freeN(psys->particles);
|
|
|
|
psys->particles = 0;
|
|
|
|
psys->totpart = 0;
|
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2008-04-02 17:48:46 +00:00
|
|
|
/* fluid sim particle import handling, actual loading of particles from file */
|
2013-12-22 14:11:10 +11:00
|
|
|
#ifdef WITH_MOD_FLUID
|
2008-07-25 18:57:16 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(sim->ob, eModifierType_Fluidsim);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
if ( fluidmd && fluidmd->fss) {
|
2008-07-25 18:57:16 +00:00
|
|
|
FluidsimSettings *fss= fluidmd->fss;
|
|
|
|
ParticleSettings *part = psys->part;
|
2011-01-27 12:21:14 +00:00
|
|
|
ParticleData *pa=NULL;
|
2008-07-25 18:57:16 +00:00
|
|
|
char filename[256];
|
|
|
|
char debugStrBuffer[256];
|
2009-09-17 22:00:49 +00:00
|
|
|
int curFrame = sim->scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading
|
2011-01-11 07:38:16 +00:00
|
|
|
int p, j, totpart;
|
2008-07-25 18:57:16 +00:00
|
|
|
int readMask, activeParts = 0, fileParts = 0;
|
|
|
|
gzFile gzf;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
// XXX if (ob==G.obedit) // off...
|
2009-01-02 19:10:35 +00:00
|
|
|
// return;
|
2011-02-12 09:58:28 +00:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
// ok, start loading
|
2011-11-20 14:38:11 +00:00
|
|
|
BLI_join_dirfile(filename, sizeof(filename), fss->surfdataPath, OB_FLUIDSIM_SURF_PARTICLES_FNAME);
|
|
|
|
|
2018-05-31 15:24:30 +02:00
|
|
|
BLI_path_abs(filename, modifier_path_relbase(bmain, sim->ob));
|
2011-11-20 14:38:11 +00:00
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
|
2011-02-12 09:58:28 +00:00
|
|
|
|
2012-03-20 02:17:37 +00:00
|
|
|
gzf = BLI_gzopen(filename, "rb");
|
2008-07-25 18:57:16 +00:00
|
|
|
if (!gzf) {
|
2012-05-15 12:07:44 +00:00
|
|
|
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"readFsPartData::error - Unable to open file for reading '%s'\n", filename);
|
2009-03-17 21:44:58 +00:00
|
|
|
// XXX bad level call elbeemDebugOut(debugStrBuffer);
|
2008-07-25 18:57:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
gzread(gzf, &totpart, sizeof(totpart));
|
2016-06-23 07:53:49 +10:00
|
|
|
totpart = (use_render_params) ? totpart:(part->disp*totpart) / 100;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
part->totpart= totpart;
|
|
|
|
part->sta=part->end = 1.0f;
|
2009-09-17 22:00:49 +00:00
|
|
|
part->lifetime = sim->scene->r.efra + 1;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-12-22 09:30:13 +00:00
|
|
|
/* allocate particles */
|
2009-09-17 22:00:49 +00:00
|
|
|
realloc_particles(sim, part->totpart);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
// set up reading mask
|
|
|
|
readMask = fss->typeFlags;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (p=0, pa=psys->particles; p<totpart; p++, pa++) {
|
2008-07-25 18:57:16 +00:00
|
|
|
int ptype=0;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
|
|
|
gzread(gzf, &ptype, sizeof( ptype ));
|
2012-10-27 10:42:28 +00:00
|
|
|
if (ptype & readMask) {
|
2008-07-25 18:57:16 +00:00
|
|
|
activeParts++;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-06-17 09:58:26 +00:00
|
|
|
gzread(gzf, &(pa->size), sizeof(float));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
pa->size /= 10.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j=0; j<3; j++) {
|
2008-07-25 18:57:16 +00:00
|
|
|
float wrf;
|
2018-06-17 17:05:51 +02:00
|
|
|
gzread(gzf, &wrf, sizeof( wrf ));
|
2008-07-25 18:57:16 +00:00
|
|
|
pa->state.co[j] = wrf;
|
2012-05-15 12:07:44 +00:00
|
|
|
//fprintf(stderr,"Rj%d ",j);
|
2008-07-25 18:57:16 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j=0; j<3; j++) {
|
2008-07-25 18:57:16 +00:00
|
|
|
float wrf;
|
2018-06-17 17:05:51 +02:00
|
|
|
gzread(gzf, &wrf, sizeof( wrf ));
|
2008-07-25 18:57:16 +00:00
|
|
|
pa->state.vel[j] = wrf;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-07-17 12:05:15 +00:00
|
|
|
zero_v3(pa->state.ave);
|
|
|
|
unit_qt(pa->state.rot);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-12-22 09:30:13 +00:00
|
|
|
pa->time = 1.f;
|
|
|
|
pa->dietime = sim->scene->r.efra + 1;
|
|
|
|
pa->lifetime = sim->scene->r.efra;
|
2008-07-25 18:57:16 +00:00
|
|
|
pa->alive = PARS_ALIVE;
|
2012-05-23 22:45:39 +00:00
|
|
|
//if (a < 25) fprintf(stderr,"FSPARTICLE debug set %s, a%d = %f,%f,%f, life=%f\n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime );
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-07-25 18:57:16 +00:00
|
|
|
// skip...
|
2012-03-24 06:18:31 +00:00
|
|
|
for (j=0; j<2*3+1; j++) {
|
2018-06-17 17:05:51 +02:00
|
|
|
float wrf; gzread(gzf, &wrf, sizeof( wrf ));
|
2008-07-25 18:57:16 +00:00
|
|
|
}
|
2008-04-02 17:48:46 +00:00
|
|
|
}
|
2008-07-25 18:57:16 +00:00
|
|
|
fileParts++;
|
2008-04-02 17:48:46 +00:00
|
|
|
}
|
2012-03-11 19:09:01 +00:00
|
|
|
gzclose(gzf);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
totpart = psys->totpart = activeParts;
|
2012-05-15 12:07:44 +00:00
|
|
|
BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d\n", psys->totpart,activeParts,fileParts,readMask);
|
2009-01-24 13:45:24 +00:00
|
|
|
// bad level call
|
|
|
|
// XXX elbeemDebugOut(debugStrBuffer);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-07-25 18:57:16 +00:00
|
|
|
} // fluid sim particles done
|
|
|
|
}
|
2016-06-23 07:53:49 +10:00
|
|
|
#else
|
2018-05-31 16:36:24 +02:00
|
|
|
UNUSED_VARS(bmain, use_render_params);
|
2013-12-22 14:11:10 +11:00
|
|
|
#endif // WITH_MOD_FLUID
|
2008-04-02 17:48:46 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNUSED(cfra))
|
2010-03-21 20:36:06 +00:00
|
|
|
{
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
int oldtotpart = psys->totpart;
|
2011-01-07 11:38:28 +00:00
|
|
|
int totpart = tot_particles(psys, pid);
|
2010-03-21 20:36:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totpart != oldtotpart)
|
2010-03-21 20:36:06 +00:00
|
|
|
realloc_particles(sim, totpart);
|
|
|
|
|
|
|
|
return totpart - oldtotpart;
|
|
|
|
}
|
2011-09-25 11:51:28 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* Calculates the next state for all particles of the system
|
|
|
|
* In particles code most fra-ending are frames, time-ending are fra*timestep (seconds)
|
|
|
|
* 1. Emit particles
|
|
|
|
* 2. Check cache (if used) and return if frame is cached
|
|
|
|
* 3. Do dynamics
|
|
|
|
* 4. Save to cache */
|
2016-06-23 07:53:49 +10:00
|
|
|
static void system_step(ParticleSimulationData *sim, float cfra, const bool use_render_params)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
PointCache *cache = psys->pointcache;
|
2010-12-15 17:05:34 +00:00
|
|
|
PTCacheID ptcacheid, *pid = NULL;
|
2009-09-04 23:06:15 +00:00
|
|
|
PARTICLE_P;
|
2010-12-15 17:05:34 +00:00
|
|
|
float disp, cache_cfra = cfra; /*, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; */
|
2010-12-18 09:32:27 +00:00
|
|
|
int startframe = 0, endframe = 100, oldtotpart = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* cache shouldn't be used for hair or "continue physics" */
|
2013-01-22 20:47:03 +00:00
|
|
|
if (part->type != PART_HAIR) {
|
2010-12-15 17:05:34 +00:00
|
|
|
psys_clear_temp_pointcache(psys);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* set suitable cache range automatically */
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0)
|
2010-12-15 17:05:34 +00:00
|
|
|
psys_get_pointcache_start_end(sim->scene, psys, &cache->startframe, &cache->endframe);
|
|
|
|
|
|
|
|
pid = &ptcacheid;
|
|
|
|
BKE_ptcache_id_from_particles(pid, sim->ob, psys);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-12-15 17:05:34 +00:00
|
|
|
BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2016-03-30 17:10:54 +02:00
|
|
|
/* clear everything on start frame, or when psys needs full reset! */
|
|
|
|
if ((cfra == startframe) || (psys->recalc & PSYS_RECALC_RESET)) {
|
2010-12-15 17:05:34 +00:00
|
|
|
BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED);
|
|
|
|
BKE_ptcache_validate(cache, startframe);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
cache->flag &= ~PTCACHE_REDO_NEEDED;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-12-15 17:05:34 +00:00
|
|
|
CLAMP(cache_cfra, startframe, endframe);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 17:05:34 +00:00
|
|
|
/* 1. emit particles and redo particles if needed */
|
2010-12-18 09:32:27 +00:00
|
|
|
oldtotpart = psys->totpart;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (emit_particles(sim, pid, cfra) || psys->recalc & PSYS_RECALC_RESET) {
|
2010-03-21 20:36:06 +00:00
|
|
|
distribute_particles(sim, part->from);
|
|
|
|
initialize_all_particles(sim);
|
2010-12-18 09:32:27 +00:00
|
|
|
/* reset only just created particles (on startframe all particles are recreated) */
|
|
|
|
reset_all_particles(sim, 0.0, cfra, oldtotpart);
|
2015-05-03 16:01:07 +02:00
|
|
|
free_unexisting_particles(sim);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2011-01-09 19:09:41 +00:00
|
|
|
if (psys->fluid_springs) {
|
|
|
|
MEM_freeN(psys->fluid_springs);
|
|
|
|
psys->fluid_springs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
psys->tot_fluidsprings = psys->alloc_fluidsprings = 0;
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* flag for possible explode modifiers after this system */
|
2009-09-17 22:00:49 +00:00
|
|
|
sim->psmd->flag |= eParticleSystemFlag_Pars;
|
2010-12-15 17:05:34 +00:00
|
|
|
|
2010-12-17 13:13:32 +00:00
|
|
|
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* 2. try to read from the cache */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pid) {
|
2016-08-11 13:36:29 +03:00
|
|
|
int cache_result = BKE_ptcache_read(pid, cache_cfra, true);
|
2009-06-21 10:16:52 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) {
|
2018-04-08 09:28:52 +02:00
|
|
|
cached_step(sim, cfra, use_render_params);
|
|
|
|
update_children(sim, use_render_params);
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_update_path_cache(sim, cfra, use_render_params);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2010-12-15 17:05:34 +00:00
|
|
|
BKE_ptcache_validate(cache, (int)cache_cfra);
|
2008-05-05 21:10:32 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
|
2010-12-18 15:03:31 +00:00
|
|
|
BKE_ptcache_write(pid, (int)cache_cfra);
|
2009-06-21 10:16:52 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-01-18 09:25:37 +00:00
|
|
|
/* Cache is supposed to be baked, but no data was found so bail out */
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (cache->flag & PTCACHE_BAKED) {
|
2011-01-18 09:25:37 +00:00
|
|
|
psys_reset(psys, PSYS_RESET_CACHE_MISS);
|
|
|
|
return;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (cache_result == PTCACHE_READ_OLD) {
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
psys->cfra = (float)cache->simframe;
|
2018-04-08 09:28:52 +02:00
|
|
|
cached_step(sim, psys->cfra, use_render_params);
|
2009-06-21 10:16:52 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* if on second frame, write cache for first frame */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
|
2010-12-18 15:03:31 +00:00
|
|
|
BKE_ptcache_write(pid, startframe);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
else
|
|
|
|
BKE_ptcache_invalidate(cache);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* 3. do dynamics */
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
/* set particles to be not calculated TODO: can't work with pointcache */
|
2018-04-08 09:28:52 +02:00
|
|
|
disp= psys_get_current_display_percentage(psys, use_render_params);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
LOOP_PARTICLES {
|
2014-03-07 10:25:56 +01:00
|
|
|
if (psys_frand(psys, p) > disp)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
pa->flag |= PARS_NO_DISP;
|
|
|
|
else
|
|
|
|
pa->flag &= ~PARS_NO_DISP;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totpart) {
|
2011-09-25 11:51:28 +00:00
|
|
|
int dframe, totframesback = 0;
|
|
|
|
float t_frac, dt_frac;
|
|
|
|
|
2008-06-09 16:49:33 +00:00
|
|
|
/* handle negative frame start at the first frame by doing
|
|
|
|
* all the steps before the first frame */
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((int)cfra == startframe && part->sta < startframe)
|
2008-06-09 16:49:33 +00:00
|
|
|
totframesback = (startframe - (int)part->sta);
|
2011-09-25 11:51:28 +00:00
|
|
|
|
|
|
|
if (!(part->time_flag & PART_TIME_AUTOSF)) {
|
|
|
|
/* Constant time step */
|
2012-12-12 22:42:55 +00:00
|
|
|
psys->dt_frac = get_base_time_step(part);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else if ((int)cfra == startframe) {
|
2012-12-14 04:57:26 +00:00
|
|
|
/* Variable time step; initialise to subframes */
|
2012-12-12 22:42:55 +00:00
|
|
|
psys->dt_frac = get_base_time_step(part);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else if (psys->dt_frac < MIN_TIMESTEP) {
|
2012-12-14 04:57:26 +00:00
|
|
|
/* Variable time step; subsequent frames */
|
2011-09-25 11:51:28 +00:00
|
|
|
psys->dt_frac = MIN_TIMESTEP;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (dframe=-totframesback; dframe<=0; dframe++) {
|
2011-09-25 11:51:28 +00:00
|
|
|
/* simulate each subframe */
|
|
|
|
dt_frac = psys->dt_frac;
|
|
|
|
for (t_frac = dt_frac; t_frac <= 1.0f; t_frac += dt_frac) {
|
|
|
|
sim->courant_num = 0.0f;
|
|
|
|
dynamics_step(sim, cfra+dframe+t_frac - 1.f);
|
|
|
|
psys->cfra = cfra+dframe+t_frac - 1.f;
|
|
|
|
#if 0
|
2012-05-15 12:07:44 +00:00
|
|
|
printf("%f,%f,%f,%f\n", cfra+dframe+t_frac - 1.f, t_frac, dt_frac, sim->courant_num);
|
2011-09-25 11:51:28 +00:00
|
|
|
#endif
|
|
|
|
if (part->time_flag & PART_TIME_AUTOSF)
|
2016-08-01 21:45:42 +03:00
|
|
|
update_timestep(psys, sim);
|
|
|
|
/* Even without AUTOSF dt_frac may not add up to 1.0 due to float precision. */
|
|
|
|
dt_frac = sync_timestep(psys, t_frac);
|
2010-04-12 17:34:06 +00:00
|
|
|
}
|
2008-06-09 16:49:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* 4. only write cache starting from second frame */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pid) {
|
2010-12-15 17:05:34 +00:00
|
|
|
BKE_ptcache_validate(cache, (int)cache_cfra);
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((int)cache_cfra != startframe)
|
2010-12-18 15:03:31 +00:00
|
|
|
BKE_ptcache_write(pid, (int)cache_cfra);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
update_children(sim, use_render_params);
|
2010-07-17 17:07:50 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* cleanup */
|
2013-08-19 10:11:48 +00:00
|
|
|
if (psys->lattice_deform_data) {
|
|
|
|
end_latt_deform(psys->lattice_deform_data);
|
|
|
|
psys->lattice_deform_data = NULL;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* system type has changed so set sensible defaults and clear non applicable flags */
|
2014-02-05 13:53:34 +01:00
|
|
|
void psys_changed_type(Object *ob, ParticleSystem *psys)
|
2010-03-21 20:36:06 +00:00
|
|
|
{
|
2014-02-05 13:53:34 +01:00
|
|
|
ParticleSettings *part = psys->part;
|
2010-03-21 20:36:06 +00:00
|
|
|
PTCacheID pid;
|
|
|
|
|
2014-02-05 13:53:34 +01:00
|
|
|
BKE_ptcache_id_from_particles(&pid, ob, psys);
|
2010-03-21 20:36:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->phystype != PART_PHYS_KEYED)
|
2014-02-05 13:53:34 +01:00
|
|
|
psys->flag &= ~PSYS_KEYED;
|
2010-03-21 20:36:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->type == PART_HAIR) {
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0)
|
2010-03-21 20:36:06 +00:00
|
|
|
part->ren_as = PART_DRAW_PATH;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->distr == PART_DISTR_GRID)
|
2011-03-09 14:18:33 +00:00
|
|
|
part->distr = PART_DISTR_JIT;
|
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0)
|
2010-03-21 20:36:06 +00:00
|
|
|
part->draw_as = PART_DRAW_REND;
|
|
|
|
|
|
|
|
CLAMP(part->path_start, 0.0f, 100.0f);
|
|
|
|
CLAMP(part->path_end, 0.0f, 100.0f);
|
|
|
|
|
|
|
|
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
|
|
|
|
}
|
|
|
|
else {
|
2014-02-05 13:53:34 +01:00
|
|
|
free_hair(ob, psys, 1);
|
2010-03-21 20:36:06 +00:00
|
|
|
|
|
|
|
CLAMP(part->path_start, 0.0f, MAX2(100.0f, part->end + part->lifetime));
|
|
|
|
CLAMP(part->path_end, 0.0f, MAX2(100.0f, part->end + part->lifetime));
|
|
|
|
}
|
|
|
|
|
2014-02-05 13:53:34 +01:00
|
|
|
psys_reset(psys, PSYS_RESET_ALL);
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
|
|
|
void psys_check_boid_data(ParticleSystem *psys)
|
|
|
|
{
|
|
|
|
BoidParticle *bpa;
|
|
|
|
PARTICLE_P;
|
|
|
|
|
|
|
|
pa = psys->particles;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!pa)
|
2010-03-21 20:36:06 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part && psys->part->phystype==PART_PHYS_BOIDS) {
|
|
|
|
if (!pa->boid) {
|
2010-03-21 20:36:06 +00:00
|
|
|
bpa = MEM_callocN(psys->totpart * sizeof(BoidParticle), "Boid Data");
|
|
|
|
|
|
|
|
LOOP_PARTICLES
|
|
|
|
pa->boid = bpa++;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pa->boid) {
|
2010-03-21 20:36:06 +00:00
|
|
|
MEM_freeN(pa->boid);
|
|
|
|
LOOP_PARTICLES
|
|
|
|
pa->boid = NULL;
|
|
|
|
}
|
|
|
|
}
|
2010-04-04 12:29:06 +00:00
|
|
|
|
2018-06-04 17:55:19 +02:00
|
|
|
void BKE_particlesettings_fluid_default_settings(ParticleSettings *part)
|
2011-12-30 07:55:15 +00:00
|
|
|
{
|
2010-04-04 12:29:06 +00:00
|
|
|
SPHFluidSettings *fluid = part->fluid;
|
|
|
|
|
|
|
|
fluid->spring_k = 0.f;
|
2011-01-09 19:09:41 +00:00
|
|
|
fluid->plasticity_constant = 0.1f;
|
|
|
|
fluid->yield_ratio = 0.1f;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
fluid->rest_length = 1.f;
|
2010-04-04 12:29:06 +00:00
|
|
|
fluid->viscosity_omega = 2.f;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
fluid->viscosity_beta = 0.1f;
|
|
|
|
fluid->stiffness_k = 1.f;
|
|
|
|
fluid->stiffness_knear = 1.f;
|
|
|
|
fluid->rest_density = 1.f;
|
2010-04-04 12:29:06 +00:00
|
|
|
fluid->buoyancy = 0.f;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
fluid->radius = 1.f;
|
|
|
|
fluid->flag |= SPH_FAC_REPULSION|SPH_FAC_DENSITY|SPH_FAC_RADIUS|SPH_FAC_VISCOSITY|SPH_FAC_REST_LENGTH;
|
2010-04-04 12:29:06 +00:00
|
|
|
}
|
|
|
|
|
2010-12-05 01:48:49 +00:00
|
|
|
static void psys_prepare_physics(ParticleSimulationData *sim)
|
2010-03-21 20:36:06 +00:00
|
|
|
{
|
|
|
|
ParticleSettings *part = sim->psys->part;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
|
2010-03-21 20:36:06 +00:00
|
|
|
PTCacheID pid;
|
|
|
|
BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys);
|
|
|
|
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
free_keyed_keys(sim->psys);
|
|
|
|
sim->psys->flag &= ~PSYS_KEYED;
|
|
|
|
}
|
|
|
|
|
2018-06-04 17:55:19 +02:00
|
|
|
/* RNA Update must ensure this is true. */
|
|
|
|
if (part->phystype == PART_PHYS_BOIDS) {
|
|
|
|
BLI_assert(part->boids != NULL);
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
2018-06-04 17:55:19 +02:00
|
|
|
else if (part->phystype == PART_PHYS_FLUID) {
|
|
|
|
BLI_assert(part->fluid != NULL);
|
2010-04-04 12:29:06 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
|
|
|
|
psys_check_boid_data(sim->psys);
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
static int hair_needs_recalc(ParticleSystem *psys)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
|
2012-05-24 16:35:45 +00:00
|
|
|
((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit)))
|
|
|
|
{
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* main particle update call, checks that things are ok on the large scale and
|
|
|
|
* then advances in to actual particle calculations depending on particle type */
|
2018-04-06 12:07:27 +02:00
|
|
|
void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
{
|
2010-11-05 13:37:18 +00:00
|
|
|
ParticleSimulationData sim= {0};
|
2010-03-21 20:36:06 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2018-06-19 15:25:48 +02:00
|
|
|
ParticleSystem *psys_orig = psys_orig_get(psys);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
float cfra;
|
2018-06-19 15:25:48 +02:00
|
|
|
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2009-09-17 22:00:49 +00:00
|
|
|
/* drawdata is outdated after ANY change */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->pdd) psys->pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
|
2009-09-17 22:00:49 +00:00
|
|
|
|
2016-06-23 07:53:49 +10:00
|
|
|
if (!psys_check_enabled(ob, psys, use_render_params))
|
2007-12-18 16:55:09 +00:00
|
|
|
return;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2018-05-16 10:50:49 +02:00
|
|
|
cfra = DEG_get_ctime(depsgraph);
|
2010-11-05 13:37:18 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
sim.depsgraph = depsgraph;
|
2017-07-21 11:53:13 +02:00
|
|
|
sim.scene = scene;
|
|
|
|
sim.ob = ob;
|
|
|
|
sim.psys = psys;
|
2018-06-19 15:25:48 +02:00
|
|
|
sim.psmd = psmd;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
|
|
|
/* system was already updated from modifier stack */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sim.psmd->flag & eParticleSystemFlag_psys_updated) {
|
2009-09-17 22:00:49 +00:00
|
|
|
sim.psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* make sure it really was updated to cfra */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->cfra == cfra)
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (!sim.psmd->mesh_final)
|
2007-12-18 16:55:09 +00:00
|
|
|
return;
|
|
|
|
|
2012-02-27 09:37:59 +00:00
|
|
|
if (part->from != PART_FROM_VERT) {
|
2018-05-15 13:26:40 +02:00
|
|
|
BKE_mesh_tessface_ensure(sim.psmd->mesh_final);
|
2012-02-27 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
2010-02-14 14:18:23 +00:00
|
|
|
/* execute drivers only, as animation has already been done */
|
2018-05-31 12:52:13 +02:00
|
|
|
BKE_animsys_evaluate_animdata(depsgraph, scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
|
2010-02-14 14:18:23 +00:00
|
|
|
|
2012-03-19 18:14:24 +00:00
|
|
|
/* to verify if we need to restore object afterwards */
|
|
|
|
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->recalc & PSYS_RECALC_RESET)
|
2011-02-04 15:48:13 +00:00
|
|
|
psys->totunexist = 0;
|
|
|
|
|
2010-12-05 01:48:49 +00:00
|
|
|
/* setup necessary physics type dependent additional data if it doesn't yet exist */
|
|
|
|
psys_prepare_physics(&sim);
|
2009-06-05 23:59:33 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (part->type) {
|
2010-03-21 20:36:06 +00:00
|
|
|
case PART_HAIR:
|
|
|
|
{
|
2010-10-14 09:01:03 +00:00
|
|
|
/* nothing to do so bail out early */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->totpart == 0 && part->totpart == 0) {
|
2010-10-14 09:01:03 +00:00
|
|
|
psys_free_path_cache(psys, NULL);
|
|
|
|
free_hair(ob, psys, 0);
|
2012-02-12 00:43:57 +00:00
|
|
|
psys->flag |= PSYS_HAIR_DONE;
|
2010-10-14 09:01:03 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
/* (re-)create hair */
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (hair_needs_recalc(psys)) {
|
2010-03-21 20:36:06 +00:00
|
|
|
float hcfra=0.0f;
|
|
|
|
int i, recalc = psys->recalc;
|
|
|
|
|
|
|
|
free_hair(ob, psys, 0);
|
|
|
|
|
2018-06-19 15:25:48 +02:00
|
|
|
if (psys_orig->edit && psys_orig->free_edit) {
|
|
|
|
psys_orig->free_edit(psys_orig->edit);
|
|
|
|
psys_orig->edit = NULL;
|
|
|
|
psys_orig->free_edit = NULL;
|
2011-01-12 10:01:33 +00:00
|
|
|
}
|
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
/* first step is negative so particles get killed and reset */
|
|
|
|
psys->cfra= 1.0f;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i=0; i<=part->hair_step; i++) {
|
2010-03-21 20:36:06 +00:00
|
|
|
hcfra=100.0f*(float)i/(float)psys->part->hair_step;
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((part->flag & PART_HAIR_REGROW)==0)
|
2018-05-31 12:52:13 +02:00
|
|
|
BKE_animsys_evaluate_animdata(depsgraph, scene, &part->id, part->adt, hcfra, ADT_RECALC_ANIM);
|
2016-06-23 07:53:49 +10:00
|
|
|
system_step(&sim, hcfra, use_render_params);
|
2010-03-21 20:36:06 +00:00
|
|
|
psys->cfra = hcfra;
|
|
|
|
psys->recalc = 0;
|
|
|
|
save_hair(&sim, hcfra);
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
psys->flag |= PSYS_HAIR_DONE;
|
|
|
|
psys->recalc = recalc;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->flag & PSYS_EDITED)
|
2010-11-16 16:39:35 +00:00
|
|
|
psys->flag |= PSYS_HAIR_DONE;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->flag & PSYS_HAIR_DONE)
|
2016-06-23 07:53:49 +10:00
|
|
|
hair_step(&sim, cfra, use_render_params);
|
2010-03-21 20:36:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PART_FLUID:
|
|
|
|
{
|
2018-05-31 15:37:15 +02:00
|
|
|
particles_fluid_step(G.main /* Yuck :/ */, &sim, (int)cfra, use_render_params);
|
2010-03-21 20:36:06 +00:00
|
|
|
break;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2010-03-21 20:36:06 +00:00
|
|
|
default:
|
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (part->phystype) {
|
2010-03-21 20:36:06 +00:00
|
|
|
case PART_PHYS_NO:
|
|
|
|
case PART_PHYS_KEYED:
|
|
|
|
{
|
2010-07-25 14:40:18 +00:00
|
|
|
PARTICLE_P;
|
2018-04-08 09:28:52 +02:00
|
|
|
float disp = psys_get_current_display_percentage(psys, use_render_params);
|
2015-05-03 16:01:07 +02:00
|
|
|
bool free_unexisting = false;
|
2010-07-25 14:40:18 +00:00
|
|
|
|
2010-09-01 09:47:19 +00:00
|
|
|
/* Particles without dynamics haven't been reset yet because they don't use pointcache */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->recalc & PSYS_RECALC_RESET)
|
2010-09-01 09:47:19 +00:00
|
|
|
psys_reset(psys, PSYS_RESET_ALL);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (emit_particles(&sim, NULL, cfra) || (psys->recalc & PSYS_RECALC_RESET)) {
|
2010-03-21 20:36:06 +00:00
|
|
|
free_keyed_keys(psys);
|
|
|
|
distribute_particles(&sim, part->from);
|
|
|
|
initialize_all_particles(&sim);
|
2015-05-03 16:01:07 +02:00
|
|
|
free_unexisting = true;
|
2011-04-10 11:24:29 +00:00
|
|
|
|
|
|
|
/* flag for possible explode modifiers after this system */
|
|
|
|
sim.psmd->flag |= eParticleSystemFlag_Pars;
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
2010-07-25 14:40:18 +00:00
|
|
|
|
|
|
|
LOOP_EXISTING_PARTICLES {
|
|
|
|
pa->size = part->size;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->randsize > 0.0f)
|
2014-03-07 10:25:56 +01:00
|
|
|
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
|
2010-07-25 14:40:18 +00:00
|
|
|
|
|
|
|
reset_particle(&sim, pa, 0.0, cfra);
|
2010-11-16 16:56:21 +00:00
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
if (psys_frand(psys, p) > disp)
|
2010-11-16 16:56:21 +00:00
|
|
|
pa->flag |= PARS_NO_DISP;
|
|
|
|
else
|
|
|
|
pa->flag &= ~PARS_NO_DISP;
|
2010-07-25 14:40:18 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2015-05-03 16:01:07 +02:00
|
|
|
/* free unexisting after reseting particles */
|
|
|
|
if (free_unexisting)
|
|
|
|
free_unexisting_particles(&sim);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->phystype == PART_PHYS_KEYED) {
|
2010-03-21 20:36:06 +00:00
|
|
|
psys_count_keyed_targets(&sim);
|
|
|
|
set_keyed_keys(&sim);
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_update_path_cache(&sim, (int)cfra, use_render_params);
|
2010-03-21 20:36:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
/* the main dynamic particle system step */
|
2016-06-23 07:53:49 +10:00
|
|
|
system_step(&sim, cfra, use_render_params);
|
2010-03-21 20:36:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2007-12-04 13:57:28 +00:00
|
|
|
|
2012-03-19 18:14:24 +00:00
|
|
|
/* make sure emitter is left at correct time (particle emission can change this) */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->flag & PSYS_OB_ANIM_RESTORE) {
|
2018-04-06 12:07:27 +02:00
|
|
|
evaluate_emitter_anim(depsgraph, scene, ob, cfra);
|
2012-03-19 18:14:24 +00:00
|
|
|
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
|
2011-03-22 12:53:18 +00:00
|
|
|
}
|
|
|
|
|
2018-06-19 15:25:48 +02:00
|
|
|
if (psys_orig->edit) {
|
|
|
|
psys_orig->edit->flags |= PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL;
|
|
|
|
}
|
|
|
|
|
2018-06-20 11:05:52 +02:00
|
|
|
if (DEG_is_active(depsgraph)) {
|
|
|
|
if (psys_orig != psys) {
|
|
|
|
if (psys_orig->edit != NULL &&
|
|
|
|
psys_orig->edit->psys == psys_orig)
|
|
|
|
{
|
|
|
|
psys_orig->edit->psys_eval = psys;
|
|
|
|
psys_orig->edit->psmd_eval = psmd;
|
|
|
|
}
|
|
|
|
psys_orig->flag = psys->flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-21 20:36:06 +00:00
|
|
|
psys->cfra = cfra;
|
|
|
|
psys->recalc = 0;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2010-09-08 11:08:34 +00:00
|
|
|
/* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */
|
2018-04-08 09:28:52 +02:00
|
|
|
invert_m4_m4(psys->imat, ob->obmat);
|
2017-05-09 16:23:47 +02:00
|
|
|
|
|
|
|
BKE_particle_batch_cache_dirty(psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2015-10-08 14:56:20 +02:00
|
|
|
/* ID looper */
|
|
|
|
|
|
|
|
void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func, void *userdata)
|
|
|
|
{
|
|
|
|
ParticleTarget *pt;
|
|
|
|
|
2017-01-31 09:47:59 +01:00
|
|
|
func(psys, (ID **)&psys->part, userdata, IDWALK_CB_USER | IDWALK_CB_NEVER_NULL);
|
|
|
|
func(psys, (ID **)&psys->target_ob, userdata, IDWALK_CB_NOP);
|
|
|
|
func(psys, (ID **)&psys->parent, userdata, IDWALK_CB_NOP);
|
2015-10-08 14:56:20 +02:00
|
|
|
|
|
|
|
for (pt = psys->targets.first; pt; pt = pt->next) {
|
2017-01-31 09:47:59 +01:00
|
|
|
func(psys, (ID **)&pt->ob, userdata, IDWALK_CB_NOP);
|
2015-10-08 14:56:20 +02:00
|
|
|
}
|
|
|
|
|
2016-09-15 11:50:56 +02:00
|
|
|
/* Even though psys->part should never be NULL, this can happen as an exception during deletion.
|
|
|
|
* See ID_REMAP_SKIP/FORCE/FLAG_NEVER_NULL_USAGE in BKE_library_remap. */
|
|
|
|
if (psys->part && psys->part->phystype == PART_PHYS_BOIDS) {
|
2015-10-08 14:56:20 +02:00
|
|
|
ParticleData *pa;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) {
|
2017-01-31 09:47:59 +01:00
|
|
|
func(psys, (ID **)&pa->boid->ground, userdata, IDWALK_CB_NOP);
|
2015-10-08 14:56:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-12 13:57:11 +05:00
|
|
|
/* **** Depsgraph evaluation **** */
|
|
|
|
|
2018-05-02 11:46:56 +02:00
|
|
|
void BKE_particle_system_eval_init(struct Depsgraph *depsgraph,
|
2017-07-21 11:12:34 +02:00
|
|
|
Scene *scene,
|
|
|
|
Object *ob)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
2018-05-02 11:46:56 +02:00
|
|
|
DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob);
|
2018-03-28 17:32:51 +02:00
|
|
|
for (ParticleSystem *psys = ob->particlesystem.first;
|
|
|
|
psys != NULL;
|
|
|
|
psys = psys->next)
|
|
|
|
{
|
|
|
|
psys->recalc |= (psys->part->id.recalc & DEG_TAG_PSYS_ALL);
|
|
|
|
}
|
2015-08-28 17:16:50 +02:00
|
|
|
BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH);
|
2015-05-12 13:57:11 +05:00
|
|
|
}
|