2011-10-10 09:38:02 +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
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-10-30 13:43:22 +01:00
|
|
|
/* Allow using deprecated functionality for .blend file I/O. */
|
|
|
|
|
#define DNA_DEPRECATED_ALLOW
|
|
|
|
|
|
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 <math.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdlib.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 <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2020-10-08 18:07:20 +02:00
|
|
|
#include "DNA_defaults.h"
|
|
|
|
|
|
2020-11-06 15:58:27 +01:00
|
|
|
#include "DNA_cloth_types.h"
|
2018-08-29 15:32:50 +02:00
|
|
|
#include "DNA_collection_types.h"
|
2009-10-29 19:26:13 +00:00
|
|
|
#include "DNA_curve_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_dynamicpaint_types.h"
|
|
|
|
|
#include "DNA_fluid_types.h"
|
2009-10-29 19:26:13 +00:00
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
#include "DNA_material_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_mesh_types.h"
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2020-12-15 10:47:58 +11:00
|
|
|
#include "DNA_object_force_types.h"
|
2009-10-29 19:26:13 +00:00
|
|
|
#include "DNA_particle_types.h"
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_scene_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
|
|
|
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2018-05-15 13:26:40 +02:00
|
|
|
#include "BLI_kdopbvh.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_kdtree.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_linklist.h"
|
|
|
|
|
#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_rand.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"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.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
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-03-20 18:42:09 +00:00
|
|
|
|
2020-10-30 13:43:22 +01:00
|
|
|
#include "BKE_anim_data.h"
|
2020-04-03 11:35:04 +02:00
|
|
|
#include "BKE_anim_path.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "BKE_boids.h"
|
2009-09-16 17:43:09 +00:00
|
|
|
#include "BKE_cloth.h"
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
#include "BKE_collection.h"
|
2015-01-09 14:24:19 +01:00
|
|
|
#include "BKE_colortools.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_deform.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_displist.h"
|
2020-05-15 18:22:36 +02:00
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_idtype.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_key.h"
|
2020-05-15 18:22:36 +02:00
|
|
|
#include "BKE_lattice.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2020-05-15 18:22:36 +02:00
|
|
|
#include "BKE_lib_query.h"
|
|
|
|
|
#include "BKE_main.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_material.h"
|
2007-12-11 20:02:21 +00:00
|
|
|
#include "BKE_mesh.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_modifier.h"
|
2020-12-28 11:17:49 -06:00
|
|
|
#include "BKE_object.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_particle.h"
|
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
|
|
|
#include "BKE_pointcache.h"
|
2011-11-06 06:08:18 +00:00
|
|
|
#include "BKE_scene.h"
|
2020-05-15 18:22:36 +02:00
|
|
|
#include "BKE_texture.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-04-06 16:11:50 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
#include "DEG_depsgraph_build.h"
|
2018-04-08 09:28:52 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
2017-04-06 16:11:50 +02:00
|
|
|
|
2020-11-09 15:42:38 +01:00
|
|
|
#include "RE_texture.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
|
|
|
|
2020-10-30 13:43:22 +01:00
|
|
|
#include "BLO_read_write.h"
|
|
|
|
|
|
2018-02-14 11:52:58 +01:00
|
|
|
#include "particle_private.h"
|
|
|
|
|
|
2020-03-09 12:48:32 +01:00
|
|
|
static void fluid_free_settings(SPHFluidSettings *fluid);
|
|
|
|
|
|
2020-10-08 18:07:20 +02:00
|
|
|
static void particle_settings_init(ID *id)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *particle_settings = (ParticleSettings *)id;
|
|
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(particle_settings, id));
|
|
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(particle_settings, DNA_struct_default_get(ParticleSettings), id);
|
|
|
|
|
|
|
|
|
|
particle_settings->effector_weights = BKE_effector_add_weights(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-09 12:48:32 +01:00
|
|
|
static void particle_settings_copy_data(Main *UNUSED(bmain),
|
|
|
|
|
ID *id_dst,
|
|
|
|
|
const ID *id_src,
|
|
|
|
|
const int UNUSED(flag))
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *particle_settings_dst = (ParticleSettings *)id_dst;
|
|
|
|
|
const ParticleSettings *partticle_settings_src = (const ParticleSettings *)id_src;
|
|
|
|
|
|
|
|
|
|
particle_settings_dst->pd = BKE_partdeflect_copy(partticle_settings_src->pd);
|
|
|
|
|
particle_settings_dst->pd2 = BKE_partdeflect_copy(partticle_settings_src->pd2);
|
|
|
|
|
particle_settings_dst->effector_weights = MEM_dupallocN(
|
|
|
|
|
partticle_settings_src->effector_weights);
|
|
|
|
|
particle_settings_dst->fluid = MEM_dupallocN(partticle_settings_src->fluid);
|
|
|
|
|
|
|
|
|
|
if (partticle_settings_src->clumpcurve) {
|
|
|
|
|
particle_settings_dst->clumpcurve = BKE_curvemapping_copy(partticle_settings_src->clumpcurve);
|
|
|
|
|
}
|
|
|
|
|
if (partticle_settings_src->roughcurve) {
|
|
|
|
|
particle_settings_dst->roughcurve = BKE_curvemapping_copy(partticle_settings_src->roughcurve);
|
|
|
|
|
}
|
|
|
|
|
if (partticle_settings_src->twistcurve) {
|
|
|
|
|
particle_settings_dst->twistcurve = BKE_curvemapping_copy(partticle_settings_src->twistcurve);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
particle_settings_dst->boids = boid_copy_settings(partticle_settings_src->boids);
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
if (partticle_settings_src->mtex[a]) {
|
|
|
|
|
particle_settings_dst->mtex[a] = MEM_dupallocN(partticle_settings_src->mtex[a]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_duplicatelist(&particle_settings_dst->instance_weights,
|
|
|
|
|
&partticle_settings_src->instance_weights);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void particle_settings_free_data(ID *id)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *particle_settings = (ParticleSettings *)id;
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
MEM_SAFE_FREE(particle_settings->mtex[a]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (particle_settings->clumpcurve) {
|
|
|
|
|
BKE_curvemapping_free(particle_settings->clumpcurve);
|
|
|
|
|
}
|
|
|
|
|
if (particle_settings->roughcurve) {
|
|
|
|
|
BKE_curvemapping_free(particle_settings->roughcurve);
|
|
|
|
|
}
|
|
|
|
|
if (particle_settings->twistcurve) {
|
|
|
|
|
BKE_curvemapping_free(particle_settings->twistcurve);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_partdeflect_free(particle_settings->pd);
|
|
|
|
|
BKE_partdeflect_free(particle_settings->pd2);
|
|
|
|
|
|
|
|
|
|
MEM_SAFE_FREE(particle_settings->effector_weights);
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&particle_settings->instance_weights);
|
|
|
|
|
|
|
|
|
|
boid_free_settings(particle_settings->boids);
|
|
|
|
|
fluid_free_settings(particle_settings->fluid);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 18:22:36 +02:00
|
|
|
static void particle_settings_foreach_id(ID *id, LibraryForeachIDData *data)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *psett = (ParticleSettings *)id;
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->instance_collection, IDWALK_CB_USER);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->instance_object, IDWALK_CB_NOP);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->bb_ob, IDWALK_CB_NOP);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->collision_group, IDWALK_CB_NOP);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_MTEX; i++) {
|
|
|
|
|
if (psett->mtex[i]) {
|
|
|
|
|
BKE_texture_mtex_foreach_id(data, psett->mtex[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psett->effector_weights) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->effector_weights->group, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psett->pd) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->pd->tex, IDWALK_CB_USER);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->pd->f_source, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
if (psett->pd2) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->pd2->tex, IDWALK_CB_USER);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, psett->pd2->f_source, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psett->boids) {
|
|
|
|
|
LISTBASE_FOREACH (BoidState *, state, &psett->boids->states) {
|
|
|
|
|
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
|
|
|
|
|
if (rule->type == eBoidRuleType_Avoid) {
|
|
|
|
|
BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, gabr->ob, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
else if (rule->type == eBoidRuleType_FollowLeader) {
|
|
|
|
|
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, flbr->ob, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &psett->instance_weights) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, dw->ob, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 13:43:22 +01:00
|
|
|
static void write_boid_state(BlendWriter *writer, BoidState *state)
|
|
|
|
|
{
|
|
|
|
|
BLO_write_struct(writer, BoidState, state);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
|
|
|
|
|
switch (rule->type) {
|
|
|
|
|
case eBoidRuleType_Goal:
|
|
|
|
|
case eBoidRuleType_Avoid:
|
|
|
|
|
BLO_write_struct(writer, BoidRuleGoalAvoid, rule);
|
|
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_AvoidCollision:
|
|
|
|
|
BLO_write_struct(writer, BoidRuleAvoidCollision, rule);
|
|
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_FollowLeader:
|
|
|
|
|
BLO_write_struct(writer, BoidRuleFollowLeader, rule);
|
|
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_AverageSpeed:
|
|
|
|
|
BLO_write_struct(writer, BoidRuleAverageSpeed, rule);
|
|
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_Fight:
|
|
|
|
|
BLO_write_struct(writer, BoidRuleFight, rule);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
BLO_write_struct(writer, BoidRule, rule);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#if 0
|
|
|
|
|
BoidCondition *cond = state->conditions.first;
|
|
|
|
|
for (; cond; cond = cond->next) {
|
|
|
|
|
BLO_write_struct(writer, BoidCondition, cond);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void particle_settings_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *part = (ParticleSettings *)id;
|
|
|
|
|
if (part->id.us > 0 || BLO_write_is_undo(writer)) {
|
|
|
|
|
/* write LibData */
|
|
|
|
|
BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
|
|
|
|
|
BKE_id_blend_write(writer, &part->id);
|
|
|
|
|
|
|
|
|
|
if (part->adt) {
|
|
|
|
|
BKE_animdata_blend_write(writer, part->adt);
|
|
|
|
|
}
|
|
|
|
|
BLO_write_struct(writer, PartDeflect, part->pd);
|
|
|
|
|
BLO_write_struct(writer, PartDeflect, part->pd2);
|
|
|
|
|
BLO_write_struct(writer, EffectorWeights, part->effector_weights);
|
|
|
|
|
|
|
|
|
|
if (part->clumpcurve) {
|
|
|
|
|
BKE_curvemapping_blend_write(writer, part->clumpcurve);
|
|
|
|
|
}
|
|
|
|
|
if (part->roughcurve) {
|
|
|
|
|
BKE_curvemapping_blend_write(writer, part->roughcurve);
|
|
|
|
|
}
|
|
|
|
|
if (part->twistcurve) {
|
|
|
|
|
BKE_curvemapping_blend_write(writer, part->twistcurve);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
|
|
|
|
|
/* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
|
|
|
|
|
if (dw->ob != NULL) {
|
|
|
|
|
dw->index = 0;
|
|
|
|
|
if (part->instance_collection) { /* can be NULL if lining fails or set to None */
|
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
|
|
|
|
|
if (object == dw->ob) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
dw->index++;
|
|
|
|
|
}
|
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BLO_write_struct(writer, ParticleDupliWeight, dw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->boids && part->phystype == PART_PHYS_BOIDS) {
|
|
|
|
|
BLO_write_struct(writer, BoidSettings, part->boids);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
|
|
|
|
|
write_boid_state(writer, state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (part->fluid && part->phystype == PART_PHYS_FLUID) {
|
|
|
|
|
BLO_write_struct(writer, SPHFluidSettings, part->fluid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
if (part->mtex[a]) {
|
|
|
|
|
BLO_write_struct(writer, MTex, part->mtex[a]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_particle_partdeflect_blend_read_data(BlendDataReader *UNUSED(reader), PartDeflect *pd)
|
|
|
|
|
{
|
|
|
|
|
if (pd) {
|
|
|
|
|
pd->rng = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void particle_settings_blend_read_data(BlendDataReader *reader, ID *id)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *part = (ParticleSettings *)id;
|
|
|
|
|
BLO_read_data_address(reader, &part->adt);
|
|
|
|
|
BLO_read_data_address(reader, &part->pd);
|
|
|
|
|
BLO_read_data_address(reader, &part->pd2);
|
|
|
|
|
|
|
|
|
|
BKE_animdata_blend_read_data(reader, part->adt);
|
|
|
|
|
BKE_particle_partdeflect_blend_read_data(reader, part->pd);
|
|
|
|
|
BKE_particle_partdeflect_blend_read_data(reader, part->pd2);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &part->clumpcurve);
|
|
|
|
|
if (part->clumpcurve) {
|
|
|
|
|
BKE_curvemapping_blend_read(reader, part->clumpcurve);
|
|
|
|
|
}
|
|
|
|
|
BLO_read_data_address(reader, &part->roughcurve);
|
|
|
|
|
if (part->roughcurve) {
|
|
|
|
|
BKE_curvemapping_blend_read(reader, part->roughcurve);
|
|
|
|
|
}
|
|
|
|
|
BLO_read_data_address(reader, &part->twistcurve);
|
|
|
|
|
if (part->twistcurve) {
|
|
|
|
|
BKE_curvemapping_blend_read(reader, part->twistcurve);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &part->effector_weights);
|
|
|
|
|
if (!part->effector_weights) {
|
|
|
|
|
part->effector_weights = BKE_effector_add_weights(part->force_group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, &part->instance_weights);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &part->boids);
|
|
|
|
|
BLO_read_data_address(reader, &part->fluid);
|
|
|
|
|
|
|
|
|
|
if (part->boids) {
|
|
|
|
|
BLO_read_list(reader, &part->boids->states);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
|
|
|
|
|
BLO_read_list(reader, &state->rules);
|
|
|
|
|
BLO_read_list(reader, &state->conditions);
|
|
|
|
|
BLO_read_list(reader, &state->actions);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
BLO_read_data_address(reader, &part->mtex[a]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Protect against integer overflow vulnerability. */
|
|
|
|
|
CLAMP(part->trail_count, 1, 100000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_particle_partdeflect_blend_read_lib(BlendLibReader *reader, ID *id, PartDeflect *pd)
|
|
|
|
|
{
|
|
|
|
|
if (pd && pd->tex) {
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &pd->tex);
|
|
|
|
|
}
|
|
|
|
|
if (pd && pd->f_source) {
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &pd->f_source);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void particle_settings_blend_read_lib(BlendLibReader *reader, ID *id)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *part = (ParticleSettings *)id;
|
|
|
|
|
BLO_read_id_address(
|
|
|
|
|
reader, part->id.lib, &part->ipo); /* XXX deprecated - old animation system */
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &part->instance_object);
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &part->instance_collection);
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &part->force_group);
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &part->bb_ob);
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &part->collision_group);
|
|
|
|
|
|
|
|
|
|
BKE_particle_partdeflect_blend_read_lib(reader, &part->id, part->pd);
|
|
|
|
|
BKE_particle_partdeflect_blend_read_lib(reader, &part->id, part->pd2);
|
|
|
|
|
|
|
|
|
|
if (part->effector_weights) {
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &part->effector_weights->group);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
part->effector_weights = BKE_effector_add_weights(part->force_group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->instance_weights.first && part->instance_collection) {
|
|
|
|
|
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &dw->ob);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_listbase_clear(&part->instance_weights);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->boids) {
|
|
|
|
|
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
|
|
|
|
|
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
|
|
|
|
|
switch (rule->type) {
|
|
|
|
|
case eBoidRuleType_Goal:
|
|
|
|
|
case eBoidRuleType_Avoid: {
|
|
|
|
|
BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &brga->ob);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case eBoidRuleType_FollowLeader: {
|
|
|
|
|
BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &brfl->ob);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
MTex *mtex = part->mtex[a];
|
|
|
|
|
if (mtex) {
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &mtex->tex);
|
|
|
|
|
BLO_read_id_address(reader, part->id.lib, &mtex->object);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void particle_settings_blend_read_expand(BlendExpander *expander, ID *id)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *part = (ParticleSettings *)id;
|
|
|
|
|
BLO_expand(expander, part->instance_object);
|
|
|
|
|
BLO_expand(expander, part->instance_collection);
|
|
|
|
|
BLO_expand(expander, part->force_group);
|
|
|
|
|
BLO_expand(expander, part->bb_ob);
|
|
|
|
|
BLO_expand(expander, part->collision_group);
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
if (part->mtex[a]) {
|
|
|
|
|
BLO_expand(expander, part->mtex[a]->tex);
|
|
|
|
|
BLO_expand(expander, part->mtex[a]->object);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->effector_weights) {
|
|
|
|
|
BLO_expand(expander, part->effector_weights->group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->pd) {
|
|
|
|
|
BLO_expand(expander, part->pd->tex);
|
|
|
|
|
BLO_expand(expander, part->pd->f_source);
|
|
|
|
|
}
|
|
|
|
|
if (part->pd2) {
|
|
|
|
|
BLO_expand(expander, part->pd2->tex);
|
|
|
|
|
BLO_expand(expander, part->pd2->f_source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->boids) {
|
|
|
|
|
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
|
|
|
|
|
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
|
|
|
|
|
if (rule->type == eBoidRuleType_Avoid) {
|
|
|
|
|
BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
|
|
|
|
|
BLO_expand(expander, gabr->ob);
|
|
|
|
|
}
|
|
|
|
|
else if (rule->type == eBoidRuleType_FollowLeader) {
|
|
|
|
|
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
|
|
|
|
|
BLO_expand(expander, flbr->ob);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
|
|
|
|
|
BLO_expand(expander, dw->ob);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-09 12:48:32 +01:00
|
|
|
IDTypeInfo IDType_ID_PA = {
|
|
|
|
|
.id_code = ID_PA,
|
|
|
|
|
.id_filter = FILTER_ID_PA,
|
|
|
|
|
.main_listbase_index = INDEX_ID_PA,
|
|
|
|
|
.struct_size = sizeof(ParticleSettings),
|
|
|
|
|
.name = "ParticleSettings",
|
|
|
|
|
.name_plural = "particles",
|
|
|
|
|
.translation_context = BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
|
|
|
|
|
.flags = 0,
|
|
|
|
|
|
2020-10-08 18:07:20 +02:00
|
|
|
.init_data = particle_settings_init,
|
2020-03-09 12:48:32 +01:00
|
|
|
.copy_data = particle_settings_copy_data,
|
|
|
|
|
.free_data = particle_settings_free_data,
|
|
|
|
|
.make_local = NULL,
|
2020-05-15 18:22:36 +02:00
|
|
|
.foreach_id = particle_settings_foreach_id,
|
2020-08-28 13:05:48 +02:00
|
|
|
.foreach_cache = NULL,
|
|
|
|
|
|
2020-10-30 13:43:22 +01:00
|
|
|
.blend_write = particle_settings_blend_write,
|
|
|
|
|
.blend_read_data = particle_settings_blend_read_data,
|
|
|
|
|
.blend_read_lib = particle_settings_blend_read_lib,
|
|
|
|
|
.blend_read_expand = particle_settings_blend_read_expand,
|
2020-11-03 11:39:36 +01:00
|
|
|
|
|
|
|
|
.blend_read_undo_preserve = NULL,
|
2020-03-09 12:48:32 +01:00
|
|
|
};
|
|
|
|
|
|
2014-03-07 13:18:15 +01:00
|
|
|
unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
|
|
|
|
|
unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
|
|
|
|
|
float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
|
|
|
|
|
|
2020-11-06 16:43:09 +11:00
|
|
|
void BKE_particle_init_rng(void)
|
2014-03-07 10:25:56 +01:00
|
|
|
{
|
2018-06-12 15:23:38 +02:00
|
|
|
RNG *rng = BLI_rng_new_srandom(5831); /* arbitrary */
|
2019-09-08 00:12:26 +10:00
|
|
|
for (int i = 0; i < PSYS_FRAND_COUNT; i++) {
|
2018-06-12 15:23:38 +02:00
|
|
|
PSYS_FRAND_BASE[i] = BLI_rng_get_float(rng);
|
|
|
|
|
PSYS_FRAND_SEED_OFFSET[i] = (unsigned int)BLI_rng_get_int(rng);
|
|
|
|
|
PSYS_FRAND_SEED_MULTIPLIER[i] = (unsigned int)BLI_rng_get_int(rng);
|
2014-03-07 10:25:56 +01:00
|
|
|
}
|
2018-06-12 15:23:38 +02:00
|
|
|
BLI_rng_free(rng);
|
2014-03-07 10:25:56 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-04 03:50:12 +00:00
|
|
|
static void get_child_modifier_parameters(ParticleSettings *part,
|
|
|
|
|
ParticleThreadContext *ctx,
|
2012-05-06 15:15:33 +00:00
|
|
|
ChildParticle *cpa,
|
|
|
|
|
short cpa_from,
|
|
|
|
|
int cpa_num,
|
|
|
|
|
float *cpa_fuv,
|
|
|
|
|
float *orco,
|
|
|
|
|
ParticleTexture *ptex);
|
2018-05-15 13:26:40 +02:00
|
|
|
static void get_cpa_texture(Mesh *mesh,
|
|
|
|
|
ParticleSystem *psys,
|
|
|
|
|
ParticleSettings *part,
|
|
|
|
|
ParticleData *par,
|
2018-06-12 14:43:40 +02:00
|
|
|
int child_index,
|
|
|
|
|
int face_index,
|
|
|
|
|
const float fw[4],
|
|
|
|
|
float *orco,
|
|
|
|
|
ParticleTexture *ptex,
|
|
|
|
|
int event,
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/* few helpers for countall etc. */
|
2011-12-30 07:55:15 +00:00
|
|
|
int count_particles(ParticleSystem *psys)
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2009-09-16 17:43:09 +00:00
|
|
|
PARTICLE_P;
|
2012-05-06 15:15:33 +00:00
|
|
|
int tot = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
LOOP_SHOWN_PARTICLES
|
|
|
|
|
{
|
2012-10-07 09:48:59 +00:00
|
|
|
if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) {
|
|
|
|
|
}
|
|
|
|
|
else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) {
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
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
|
|
|
tot++;
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
|
|
|
|
return tot;
|
|
|
|
|
}
|
2011-12-30 07:55:15 +00:00
|
|
|
int count_particles_mod(ParticleSystem *psys, int totgr, int cur)
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2009-09-16 17:43:09 +00:00
|
|
|
PARTICLE_P;
|
2012-05-06 15:15:33 +00:00
|
|
|
int tot = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
LOOP_SHOWN_PARTICLES
|
|
|
|
|
{
|
2012-10-07 09:48:59 +00:00
|
|
|
if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) {
|
|
|
|
|
}
|
|
|
|
|
else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) {
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (p % totgr == cur) {
|
2012-05-06 15:15:33 +00:00
|
|
|
tot++;
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
|
|
|
|
return tot;
|
|
|
|
|
}
|
2020-07-10 16:04:09 +10:00
|
|
|
/* We allocate path cache memory in chunks instead of a big contiguous
|
|
|
|
|
* chunk, windows' memory allocator fails to find big blocks of memory often. */
|
2008-05-07 19:25:43 +00:00
|
|
|
|
|
|
|
|
#define PATH_CACHE_BUF_SIZE 1024
|
|
|
|
|
|
2016-06-03 15:11:56 +10:00
|
|
|
static ParticleCacheKey *pcache_key_segment_endpoint_safe(ParticleCacheKey *key)
|
|
|
|
|
{
|
|
|
|
|
return (key->segments > 0) ? (key + (key->segments - 1)) : key;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, int totkeys)
|
2008-05-07 19:25:43 +00:00
|
|
|
{
|
|
|
|
|
LinkData *buf;
|
|
|
|
|
ParticleCacheKey **cache;
|
|
|
|
|
int i, totkey, totbufkey;
|
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
tot = MAX2(tot, 1);
|
2008-05-07 19:25:43 +00:00
|
|
|
totkey = 0;
|
2012-05-06 15:15:33 +00:00
|
|
|
cache = MEM_callocN(tot * sizeof(void *), "PathCacheArray");
|
2008-05-07 19:25:43 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
while (totkey < tot) {
|
2012-05-06 15:15:33 +00:00
|
|
|
totbufkey = MIN2(tot - totkey, PATH_CACHE_BUF_SIZE);
|
|
|
|
|
buf = MEM_callocN(sizeof(LinkData), "PathCacheLinkData");
|
2015-01-13 17:24:20 +01:00
|
|
|
buf->data = MEM_callocN(sizeof(ParticleCacheKey) * totbufkey * totkeys, "ParticleCacheKey");
|
2008-05-07 19:25:43 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (i = 0; i < totbufkey; i++) {
|
2015-01-13 17:24:20 +01:00
|
|
|
cache[totkey + i] = ((ParticleCacheKey *)buf->data) + i * totkeys;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-05-07 19:25:43 +00:00
|
|
|
|
|
|
|
|
totkey += totbufkey;
|
|
|
|
|
BLI_addtail(bufs, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *bufs)
|
|
|
|
|
{
|
|
|
|
|
LinkData *buf;
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cache) {
|
2008-05-07 19:25:43 +00:00
|
|
|
MEM_freeN(cache);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-05-07 19:25:43 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (buf = bufs->first; buf; buf = buf->next) {
|
2008-05-07 19:25:43 +00:00
|
|
|
MEM_freeN(buf->data);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-05-07 19:25:43 +00:00
|
|
|
BLI_freelistN(bufs);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/************************************************/
|
|
|
|
|
/* Getting stuff */
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* get object's active particle system safely */
|
|
|
|
|
ParticleSystem *psys_get_current(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
ParticleSystem *psys;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ob == NULL) {
|
2012-05-06 15:15:33 +00:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10: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-05-06 15:15:33 +00:00
|
|
|
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->flag & PSYS_CURRENT) {
|
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 psys;
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
short psys_get_current_num(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
ParticleSystem *psys;
|
|
|
|
|
short i;
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ob == NULL) {
|
2012-05-06 15:15:33 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10: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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) {
|
|
|
|
|
if (psys->flag & PSYS_CURRENT) {
|
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 i;
|
2019-04-22 09:39:35 +10: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
|
|
|
return i;
|
|
|
|
|
}
|
2009-06-27 15:41:47 +00:00
|
|
|
void psys_set_current_num(Object *ob, int index)
|
|
|
|
|
{
|
|
|
|
|
ParticleSystem *psys;
|
|
|
|
|
short i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ob == NULL) {
|
2012-05-06 15:15:33 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (i == index) {
|
2009-06-27 15:41:47 +00:00
|
|
|
psys->flag |= PSYS_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-06-27 15:41:47 +00:00
|
|
|
psys->flag &= ~PSYS_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-06-27 15:41:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-04-23 07:32:13 +00:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
struct LatticeDeformData *psys_create_lattice_deform_data(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
|
|
|
{
|
2013-08-19 10:11:48 +00:00
|
|
|
struct LatticeDeformData *lattice_deform_data = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
if (psys_in_edit_mode(sim->depsgraph, sim->psys) == 0) {
|
2013-08-19 10:11:48 +00:00
|
|
|
Object *lattice = NULL;
|
2012-05-06 15:15:33 +00:00
|
|
|
ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
|
2018-06-21 16:30:34 +02:00
|
|
|
bool for_render = DEG_get_mode(sim->depsgraph) == DAG_EVAL_RENDER;
|
|
|
|
|
int mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (; md; md = md->next) {
|
|
|
|
|
if (md->type == eModifierType_Lattice) {
|
2017-07-03 18:00:13 +02:00
|
|
|
if (md->mode & mode) {
|
|
|
|
|
LatticeModifierData *lmd = (LatticeModifierData *)md;
|
|
|
|
|
lattice = lmd->object;
|
|
|
|
|
sim->psys->lattice_strength = lmd->strength;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
if (lattice) {
|
2020-06-13 15:41:34 +10:00
|
|
|
lattice_deform_data = BKE_lattice_deform_data_create(lattice, NULL);
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
return lattice_deform_data;
|
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
|
|
|
}
|
|
|
|
|
void psys_disable_all(Object *ob)
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSystem *psys = ob->particlesystem.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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (; psys; psys = psys->next) {
|
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->flag |= PSYS_DISABLED;
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
|
|
|
|
void psys_enable_all(Object *ob)
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSystem *psys = ob->particlesystem.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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (; psys; psys = psys->next) {
|
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->flag &= ~PSYS_DISABLED;
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
2017-11-09 13:11:20 -02:00
|
|
|
|
2018-05-15 14:50:24 +02:00
|
|
|
ParticleSystem *psys_orig_get(ParticleSystem *psys)
|
2018-05-15 13:08:06 +02:00
|
|
|
{
|
|
|
|
|
if (psys->orig_psys == NULL) {
|
|
|
|
|
return psys;
|
|
|
|
|
}
|
|
|
|
|
return psys->orig_psys;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-04 14:28:47 +01:00
|
|
|
struct ParticleSystem *psys_eval_get(Depsgraph *depsgraph, Object *object, ParticleSystem *psys)
|
|
|
|
|
{
|
|
|
|
|
Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
|
|
|
|
|
if (object_eval == object) {
|
|
|
|
|
return psys;
|
|
|
|
|
}
|
|
|
|
|
ParticleSystem *psys_eval = object_eval->particlesystem.first;
|
|
|
|
|
while (psys_eval != NULL) {
|
|
|
|
|
if (psys_eval->orig_psys == psys) {
|
|
|
|
|
return psys_eval;
|
|
|
|
|
}
|
|
|
|
|
psys_eval = psys_eval->next;
|
|
|
|
|
}
|
|
|
|
|
return psys_eval;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 14:50:24 +02:00
|
|
|
static PTCacheEdit *psys_orig_edit_get(ParticleSystem *psys)
|
2018-05-15 14:38:02 +02:00
|
|
|
{
|
|
|
|
|
if (psys->orig_psys == NULL) {
|
|
|
|
|
return psys->edit;
|
|
|
|
|
}
|
|
|
|
|
return psys->orig_psys->edit;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-08 10:43:34 +11:00
|
|
|
bool psys_in_edit_mode(Depsgraph *depsgraph, const 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
|
|
|
{
|
2018-05-15 12:34:18 +02:00
|
|
|
const ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
|
|
|
|
|
if (view_layer->basact == NULL) {
|
|
|
|
|
/* TODO(sergey): Needs double-check with multi-object edit. */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-04-08 09:28:52 +02:00
|
|
|
const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
|
2018-05-15 12:34:18 +02:00
|
|
|
const Object *object = view_layer->basact->object;
|
|
|
|
|
if (object->mode != OB_MODE_PARTICLE_EDIT) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-10-08 10:43:34 +11:00
|
|
|
const ParticleSystem *psys_orig = psys_orig_get((ParticleSystem *)psys);
|
2018-05-15 12:34:18 +02:00
|
|
|
return (psys_orig->edit || psys->pointcache->edit) && (use_render_params == false);
|
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
|
|
|
|
2016-06-23 07:53:49 +10:00
|
|
|
bool psys_check_enabled(Object *ob, ParticleSystem *psys, const bool use_render_params)
|
2007-12-18 16:55:09 +00:00
|
|
|
{
|
|
|
|
|
ParticleSystemModifierData *psmd;
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part) {
|
2007-12-18 16:55:09 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2007-12-18 16:55:09 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
psmd = psys_get_modifier(ob, psys);
|
2019-12-16 15:50:14 +01:00
|
|
|
|
|
|
|
|
if (!psmd) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-08 09:28:52 +02:00
|
|
|
if (use_render_params) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(psmd->modifier.mode & eModifierMode_Render)) {
|
2007-12-18 16:55:09 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2007-12-18 16:55:09 +00:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (!(psmd->modifier.mode & eModifierMode_Realtime)) {
|
2007-12-18 16:55:09 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2007-12-18 16:55:09 +00:00
|
|
|
return 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
|
|
|
|
2015-02-20 19:54:28 +11:00
|
|
|
bool psys_check_edited(ParticleSystem *psys)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->part && psys->part->type == PART_HAIR) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return (psys->pointcache->edit && psys->pointcache->edit->edited);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
void psys_find_group_weights(ParticleSettings *part)
|
|
|
|
|
{
|
|
|
|
|
/* Find object pointers based on index. If the collection is linked from
|
|
|
|
|
* another library linking may not have the object pointers available on
|
|
|
|
|
* file load, so we have to retrieve them later. See T49273. */
|
2019-05-21 17:47:04 +02:00
|
|
|
ListBase instance_collection_objects = {NULL, NULL};
|
|
|
|
|
|
|
|
|
|
if (part->instance_collection) {
|
|
|
|
|
instance_collection_objects = BKE_collection_object_cache_get(part->instance_collection);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
|
2018-06-28 14:29:54 +02:00
|
|
|
if (dw->ob == NULL) {
|
2019-02-17 19:00:54 +11:00
|
|
|
Base *base = BLI_findlink(&instance_collection_objects, dw->index);
|
2018-06-28 14:29:54 +02:00
|
|
|
if (base != NULL) {
|
|
|
|
|
dw->ob = base->object;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
void psys_check_group_weights(ParticleSettings *part)
|
|
|
|
|
{
|
|
|
|
|
ParticleDupliWeight *dw, *tdw;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-17 19:00:54 +11:00
|
|
|
if (part->ren_as != PART_DRAW_GR || !part->instance_collection) {
|
|
|
|
|
BLI_freelistN(&part->instance_weights);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
/* Find object pointers. */
|
|
|
|
|
psys_find_group_weights(part);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
/* Remove NULL objects, that were removed from the collection. */
|
2019-02-17 19:00:54 +11:00
|
|
|
dw = part->instance_weights.first;
|
2018-06-28 14:29:54 +02:00
|
|
|
while (dw) {
|
2019-02-17 19:00:54 +11:00
|
|
|
if (dw->ob == NULL ||
|
|
|
|
|
!BKE_collection_has_object_recursive(part->instance_collection, dw->ob)) {
|
2018-06-28 14:29:54 +02:00
|
|
|
tdw = dw->next;
|
2019-02-17 19:00:54 +11:00
|
|
|
BLI_freelinkN(&part->instance_weights, dw);
|
2018-06-28 14:29:54 +02:00
|
|
|
dw = tdw;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
dw = dw->next;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
/* Add new objects in the collection. */
|
|
|
|
|
int index = 0;
|
2019-02-17 19:00:54 +11:00
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
|
|
|
|
|
dw = part->instance_weights.first;
|
2018-06-28 14:29:54 +02:00
|
|
|
while (dw && dw->ob != object) {
|
|
|
|
|
dw = dw->next;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
if (!dw) {
|
|
|
|
|
dw = MEM_callocN(sizeof(ParticleDupliWeight), "ParticleDupliWeight");
|
|
|
|
|
dw->ob = object;
|
|
|
|
|
dw->count = 1;
|
2019-02-17 19:00:54 +11:00
|
|
|
BLI_addtail(&part->instance_weights, dw);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
dw->index = index++;
|
|
|
|
|
}
|
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
/* Ensure there is an element marked as current. */
|
|
|
|
|
int current = 0;
|
2019-02-17 19:00:54 +11:00
|
|
|
for (dw = part->instance_weights.first; dw; dw = dw->next) {
|
2018-06-28 14:29:54 +02:00
|
|
|
if (dw->flag & PART_DUPLIW_CURRENT) {
|
|
|
|
|
current = 1;
|
|
|
|
|
break;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-28 14:29:54 +02:00
|
|
|
if (!current) {
|
2019-02-17 19:00:54 +11:00
|
|
|
dw = part->instance_weights.first;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (dw) {
|
2018-06-28 14:29:54 +02:00
|
|
|
dw->flag |= PART_DUPLIW_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-06-28 14:29:54 +02:00
|
|
|
|
2009-12-30 15:58:59 +00:00
|
|
|
int psys_uses_gravity(ParticleSimulationData *sim)
|
|
|
|
|
{
|
|
|
|
|
return sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY && sim->psys->part &&
|
|
|
|
|
sim->psys->part->effector_weights->global_gravity != 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
|
|
|
/************************************************/
|
|
|
|
|
/* Freeing stuff */
|
|
|
|
|
/************************************************/
|
2011-02-13 10:52:18 +00:00
|
|
|
static void fluid_free_settings(SPHFluidSettings *fluid)
|
2010-04-04 12:29:06 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fluid) {
|
2018-06-17 17:05:51 +02:00
|
|
|
MEM_freeN(fluid);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-04-04 12:29:06 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-12 16:24:53 +01:00
|
|
|
void free_hair(Object *object, ParticleSystem *psys, int dynamics)
|
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-16 17:43:09 +00:00
|
|
|
PARTICLE_P;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
LOOP_PARTICLES
|
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (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
|
|
|
MEM_freeN(pa->hair);
|
2019-04-22 09:39:35 +10: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
|
|
|
pa->hair = NULL;
|
2009-09-16 17:43:09 +00:00
|
|
|
pa->totkey = 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
|
|
|
}
|
2019-04-17 06:17:24 +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_HAIR_DONE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->clmd) {
|
|
|
|
|
if (dynamics) {
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_free((ModifierData *)psys->clmd);
|
2018-12-07 09:49:28 +01:00
|
|
|
psys->clmd = NULL;
|
2018-11-12 16:24:53 +01:00
|
|
|
PTCacheID pid;
|
|
|
|
|
BKE_ptcache_id_from_particles(&pid, object, psys);
|
|
|
|
|
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-10-16 14:32:17 +00:00
|
|
|
cloth_free_modifier(psys->clmd);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2008-02-24 21:29:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->hair_in_mesh) {
|
2018-05-15 13:26:40 +02:00
|
|
|
BKE_id_free(NULL, psys->hair_in_mesh);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-05-15 13:26:40 +02:00
|
|
|
psys->hair_in_mesh = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->hair_out_mesh) {
|
2018-05-15 13:26:40 +02:00
|
|
|
BKE_id_free(NULL, psys->hair_out_mesh);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-05-15 13:26:40 +02:00
|
|
|
psys->hair_out_mesh = 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
|
|
|
}
|
|
|
|
|
void free_keyed_keys(ParticleSystem *psys)
|
|
|
|
|
{
|
2009-09-16 17:43:09 +00:00
|
|
|
PARTICLE_P;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->part->type == PART_HAIR) {
|
2009-09-16 17:43:09 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles && psys->particles->keys) {
|
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->particles->keys);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
LOOP_PARTICLES
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa->keys) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pa->keys = NULL;
|
|
|
|
|
pa->totkey = 0;
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
2009-06-05 23:59:33 +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
|
|
|
}
|
2010-07-17 17:07:50 +00:00
|
|
|
static void free_child_path_cache(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-05-07 19:25:43 +00:00
|
|
|
psys_free_path_cache_buffers(psys->childcache, &psys->childcachebufs);
|
|
|
|
|
psys->childcache = NULL;
|
|
|
|
|
psys->totchildcache = 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-09-16 17:43:09 +00:00
|
|
|
void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *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
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (edit) {
|
2009-09-16 17:43:09 +00:00
|
|
|
psys_free_path_cache_buffers(edit->pathcache, &edit->pathcachebufs);
|
2012-05-06 15:15:33 +00:00
|
|
|
edit->pathcache = NULL;
|
|
|
|
|
edit->totcached = 0;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys) {
|
2009-09-16 17:43:09 +00:00
|
|
|
psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs);
|
2012-05-06 15:15:33 +00:00
|
|
|
psys->pathcache = NULL;
|
|
|
|
|
psys->totcached = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-17 17:07:50 +00:00
|
|
|
free_child_path_cache(psys);
|
2009-09-16 17:43:09 +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-01-21 14:18:24 +00:00
|
|
|
void psys_free_children(ParticleSystem *psys)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->child) {
|
2008-01-21 14:18:24 +00:00
|
|
|
MEM_freeN(psys->child);
|
2012-05-06 15:15:33 +00:00
|
|
|
psys->child = NULL;
|
|
|
|
|
psys->totchild = 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
|
|
|
}
|
2008-01-21 14:18:24 +00:00
|
|
|
|
2010-07-17 17:07:50 +00:00
|
|
|
free_child_path_cache(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-16 17:43:09 +00:00
|
|
|
void psys_free_particles(ParticleSystem *psys)
|
|
|
|
|
{
|
|
|
|
|
PARTICLE_P;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles) {
|
2019-04-27 12:07:07 +10:00
|
|
|
/* Even though psys->part should never be NULL,
|
|
|
|
|
* this can happen as an exception during deletion.
|
2016-09-15 11:50:56 +02:00
|
|
|
* See ID_REMAP_SKIP/FORCE/FLAG_NEVER_NULL_USAGE in BKE_library_remap. */
|
|
|
|
|
if (psys->part && psys->part->type == PART_HAIR) {
|
2009-09-16 17:43:09 +00:00
|
|
|
LOOP_PARTICLES
|
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pa->hair) {
|
2009-09-16 17:43:09 +00:00
|
|
|
MEM_freeN(pa->hair);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->particles->keys) {
|
2009-09-16 17:43:09 +00:00
|
|
|
MEM_freeN(psys->particles->keys);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->particles->boid) {
|
2009-09-16 17:43:09 +00:00
|
|
|
MEM_freeN(psys->particles->boid);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
MEM_freeN(psys->particles);
|
2012-05-06 15:15:33 +00:00
|
|
|
psys->particles = NULL;
|
|
|
|
|
psys->totpart = 0;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
void psys_free_pdd(ParticleSystem *psys)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->pdd) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->pdd->cdata) {
|
2009-10-22 23:22:05 +00:00
|
|
|
MEM_freeN(psys->pdd->cdata);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
psys->pdd->cdata = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->pdd->vdata) {
|
2009-10-22 23:22:05 +00:00
|
|
|
MEM_freeN(psys->pdd->vdata);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
psys->pdd->vdata = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->pdd->ndata) {
|
2009-10-22 23:22:05 +00:00
|
|
|
MEM_freeN(psys->pdd->ndata);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
psys->pdd->ndata = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->pdd->vedata) {
|
2009-10-22 23:22:05 +00:00
|
|
|
MEM_freeN(psys->pdd->vedata);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
psys->pdd->vedata = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
psys->pdd->totpoint = 0;
|
2018-01-15 06:57:26 +01:00
|
|
|
psys->pdd->totpart = 0;
|
|
|
|
|
psys->pdd->partsize = 0;
|
2009-10-22 23:22:05 +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
|
|
|
/* free everything */
|
2012-05-06 15:15:33 +00:00
|
|
|
void psys_free(Object *ob, ParticleSystem *psys)
|
2018-06-17 17:05:51 +02:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys) {
|
2008-08-26 01:07:18 +00:00
|
|
|
int nr = 0;
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSystem *tpsys;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
psys_free_path_cache(psys, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-12 16:24:53 +01:00
|
|
|
/* NOTE: We pass dynamics=0 to free_hair() to prevent it from doing an
|
|
|
|
|
* unneeded clear of the cache. But for historical reason that code path
|
|
|
|
|
* was only clearing cloth part of modifier data.
|
|
|
|
|
*
|
|
|
|
|
* Part of the story there is that particle evaluation is trying to not
|
|
|
|
|
* re-allocate thew ModifierData itself, and limits all allocations to
|
|
|
|
|
* the cloth part of it.
|
|
|
|
|
*
|
|
|
|
|
* Why evaluation is relying on hair_free() and in some specific code
|
|
|
|
|
* paths there is beyond me.
|
|
|
|
|
*/
|
|
|
|
|
free_hair(ob, psys, 0);
|
|
|
|
|
if (psys->clmd != NULL) {
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_free((ModifierData *)psys->clmd);
|
2018-11-12 16:24:53 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
psys_free_particles(psys);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->edit && psys->free_edit) {
|
2009-09-16 17:43:09 +00:00
|
|
|
psys->free_edit(psys->edit);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* check if we are last non-visible particle system */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) {
|
2012-03-06 18:40:15 +00:00
|
|
|
if (tpsys->part) {
|
2012-04-29 15:47:02 +00:00
|
|
|
if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
|
2008-08-26 01:07:18 +00:00
|
|
|
nr++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-07 22:51:57 +00:00
|
|
|
/* clear do-not-draw-flag */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!nr) {
|
2008-08-26 01:07:18 +00:00
|
|
|
ob->transflag &= ~OB_DUPLIPARTS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
psys->part = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-12 16:24:53 +01:00
|
|
|
if ((psys->flag & PSYS_SHARED_CACHES) == 0) {
|
|
|
|
|
BKE_ptcache_free_list(&psys->ptcaches);
|
|
|
|
|
}
|
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->pointcache = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
BLI_freelistN(&psys->targets);
|
2019-04-17 06:17:24 +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);
|
2019-03-20 00:46:33 +11:00
|
|
|
BLI_kdtree_3d_free(psys->tree);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->fluid_springs) {
|
2011-01-09 19:09:41 +00:00
|
|
|
MEM_freeN(psys->fluid_springs);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-21 19:45:39 +02:00
|
|
|
BKE_effectors_free(psys->effectors);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->pdd) {
|
2009-10-22 23:22:05 +00:00
|
|
|
psys_free_pdd(psys);
|
|
|
|
|
MEM_freeN(psys->pdd);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 16:33:38 +02:00
|
|
|
BKE_particle_batch_cache_free(psys);
|
2019-04-17 06:17:24 +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
|
|
|
MEM_freeN(psys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 11:40:09 +02:00
|
|
|
void psys_copy_particles(ParticleSystem *psys_dst, ParticleSystem *psys_src)
|
|
|
|
|
{
|
|
|
|
|
/* Free existing particles. */
|
|
|
|
|
if (psys_dst->particles != psys_src->particles) {
|
|
|
|
|
psys_free_particles(psys_dst);
|
|
|
|
|
}
|
|
|
|
|
if (psys_dst->child != psys_src->child) {
|
|
|
|
|
psys_free_children(psys_dst);
|
|
|
|
|
}
|
|
|
|
|
/* Restore counters. */
|
|
|
|
|
psys_dst->totpart = psys_src->totpart;
|
|
|
|
|
psys_dst->totchild = psys_src->totchild;
|
|
|
|
|
/* Copy particles and children. */
|
|
|
|
|
psys_dst->particles = MEM_dupallocN(psys_src->particles);
|
|
|
|
|
psys_dst->child = MEM_dupallocN(psys_src->child);
|
|
|
|
|
if (psys_dst->part->type == PART_HAIR) {
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
int p;
|
|
|
|
|
for (p = 0, pa = psys_dst->particles; p < psys_dst->totpart; p++, pa++) {
|
|
|
|
|
pa->hair = MEM_dupallocN(pa->hair);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (psys_dst->particles && (psys_dst->particles->keys || psys_dst->particles->boid)) {
|
|
|
|
|
ParticleKey *key = psys_dst->particles->keys;
|
|
|
|
|
BoidParticle *boid = psys_dst->particles->boid;
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
int p;
|
|
|
|
|
if (key != NULL) {
|
|
|
|
|
key = MEM_dupallocN(key);
|
|
|
|
|
}
|
|
|
|
|
if (boid != NULL) {
|
|
|
|
|
boid = MEM_dupallocN(boid);
|
|
|
|
|
}
|
|
|
|
|
for (p = 0, pa = psys_dst->particles; p < psys_dst->totpart; p++, pa++) {
|
|
|
|
|
if (boid != NULL) {
|
|
|
|
|
pa->boid = boid++;
|
|
|
|
|
}
|
|
|
|
|
if (key != NULL) {
|
|
|
|
|
pa->keys = key;
|
|
|
|
|
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
|
|
|
/************************************************/
|
2009-07-12 23:38:47 +00:00
|
|
|
/* Interpolation */
|
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 14:00:55 +00:00
|
|
|
static float interpolate_particle_value(
|
|
|
|
|
float v1, float v2, float v3, float v4, const float w[4], int four)
|
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 value;
|
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
value = w[0] * v1 + w[1] * v2 + w[2] * v3;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (four) {
|
2012-05-06 15:15:33 +00:00
|
|
|
value += w[3] * v4;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-01-26 13:02:47 +00:00
|
|
|
|
2020-11-06 11:25:27 +11:00
|
|
|
CLAMP(value, 0.0f, 1.0f);
|
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
|
|
|
return value;
|
|
|
|
|
}
|
2010-01-12 18:33:21 +00:00
|
|
|
|
2014-10-29 14:59:29 +01:00
|
|
|
void psys_interpolate_particle(
|
|
|
|
|
short type, ParticleKey keys[4], float dt, ParticleKey *result, bool velocity)
|
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 t[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (type < 0) {
|
2012-04-29 17:11:40 +00:00
|
|
|
interp_cubic_v3(result->co, result->vel, keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt);
|
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 {
|
2009-09-16 17:43:09 +00:00
|
|
|
key_curve_position_weights(dt, t, type);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-12 18:33:21 +00:00
|
|
|
interp_v3_v3v3v3v3(result->co, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (velocity) {
|
2008-01-24 10:44:21 +00:00
|
|
|
float temp[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (dt > 0.999f) {
|
|
|
|
|
key_curve_position_weights(dt - 0.001f, t, type);
|
2010-01-12 18:33:21 +00:00
|
|
|
interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
|
2011-11-06 14:00:55 +00:00
|
|
|
sub_v3_v3v3(result->vel, result->co, temp);
|
2008-01-24 10:44:21 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
key_curve_position_weights(dt + 0.001f, t, type);
|
2010-01-12 18:33:21 +00:00
|
|
|
interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
|
2011-11-06 14:00:55 +00:00
|
|
|
sub_v3_v3v3(result->vel, temp, result->co);
|
2008-01-24 10:44:21 +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-12 23:38:47 +00:00
|
|
|
typedef struct ParticleInterpolationData {
|
|
|
|
|
HairKey *hkey[2];
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
Mesh *mesh;
|
2009-09-16 17:43:09 +00:00
|
|
|
MVert *mvert[2];
|
|
|
|
|
|
|
|
|
|
int keyed;
|
|
|
|
|
ParticleKey *kkey[2];
|
|
|
|
|
|
|
|
|
|
PointCache *cache;
|
2010-05-30 14:53:26 +00:00
|
|
|
PTCacheMem *pm;
|
2009-09-16 17:43:09 +00:00
|
|
|
|
|
|
|
|
PTCacheEditPoint *epoint;
|
|
|
|
|
PTCacheEditKey *ekey[2];
|
|
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
float birthtime, dietime;
|
2009-09-16 17:43:09 +00:00
|
|
|
int bspline;
|
2009-07-12 23:38:47 +00:00
|
|
|
} ParticleInterpolationData;
|
2019-04-27 12:07:07 +10:00
|
|
|
/**
|
|
|
|
|
* Assumes pointcache->mem_cache exists, so for disk cached particles
|
|
|
|
|
* call #psys_make_temp_pointcache() before use.
|
|
|
|
|
* It uses #ParticleInterpolationData.pm to store the current memory cache frame
|
|
|
|
|
* so it's thread safe.
|
|
|
|
|
*/
|
2010-10-16 14:32:17 +00:00
|
|
|
static void get_pointcache_keys_for_time(Object *UNUSED(ob),
|
|
|
|
|
PointCache *cache,
|
|
|
|
|
PTCacheMem **cur,
|
|
|
|
|
int index,
|
|
|
|
|
float t,
|
|
|
|
|
ParticleKey *key1,
|
|
|
|
|
ParticleKey *key2)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
2010-05-30 14:53:26 +00:00
|
|
|
static PTCacheMem *pm = NULL;
|
2011-01-09 07:41:51 +00:00
|
|
|
int index1, index2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (index < 0) { /* initialize */
|
2010-05-30 14:53:26 +00:00
|
|
|
*cur = cache->mem_cache.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (*cur) {
|
2010-05-30 14:53:26 +00:00
|
|
|
*cur = (*cur)->next;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (*cur) {
|
2019-04-22 09:39:35 +10:00
|
|
|
while (*cur && (*cur)->next && (float)(*cur)->frame < t) {
|
2010-05-30 14:53:26 +00:00
|
|
|
*cur = (*cur)->next;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-30 14:53:26 +00:00
|
|
|
pm = *cur;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-09 07:41:51 +00:00
|
|
|
index2 = BKE_ptcache_mem_index_find(pm, index);
|
|
|
|
|
index1 = BKE_ptcache_mem_index_find(pm->prev, index);
|
2016-09-08 10:24:56 +02:00
|
|
|
if (index2 < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-09 07:41:51 +00:00
|
|
|
BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (index1 < 0) {
|
2010-05-30 14:53:26 +00:00
|
|
|
copy_particle_key(key1, key2, 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2011-01-09 07:41:51 +00:00
|
|
|
BKE_ptcache_make_particle_key(key1, index1, pm->prev->data, (float)pm->prev->frame);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (cache->mem_cache.first) {
|
2010-05-30 14:53:26 +00:00
|
|
|
pm = cache->mem_cache.first;
|
2011-01-09 07:41:51 +00:00
|
|
|
index2 = BKE_ptcache_mem_index_find(pm, index);
|
2016-09-08 10:24:56 +02:00
|
|
|
if (index2 < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-01-09 07:41:51 +00:00
|
|
|
BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
|
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
|
|
|
copy_particle_key(key1, key2, 1);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:53:26 +00:00
|
|
|
static int get_pointcache_times_for_particle(PointCache *cache,
|
|
|
|
|
int index,
|
|
|
|
|
float *start,
|
|
|
|
|
float *end)
|
|
|
|
|
{
|
|
|
|
|
PTCacheMem *pm;
|
|
|
|
|
int ret = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pm = cache->mem_cache.first; pm; pm = pm->next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
|
2010-05-30 14:53:26 +00:00
|
|
|
*start = pm->frame;
|
|
|
|
|
ret++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pm = cache->mem_cache.last; pm; pm = pm->prev) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
|
2010-05-30 14:53:26 +00:00
|
|
|
*end = pm->frame;
|
|
|
|
|
ret++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-30 14:53:26 +00:00
|
|
|
return ret == 2;
|
|
|
|
|
}
|
2010-09-07 05:47:34 +00:00
|
|
|
|
2011-12-30 07:55:15 +00:00
|
|
|
float psys_get_dietime_from_cache(PointCache *cache, int index)
|
|
|
|
|
{
|
2010-09-07 05:47:34 +00:00
|
|
|
PTCacheMem *pm;
|
|
|
|
|
int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */
|
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pm = cache->mem_cache.last; pm; pm = pm->prev) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
|
2010-09-07 05:47:34 +00:00
|
|
|
return (float)pm->frame;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-09-07 05:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (float)dietime;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
static void init_particle_interpolation(Object *ob,
|
|
|
|
|
ParticleSystem *psys,
|
|
|
|
|
ParticleData *pa,
|
|
|
|
|
ParticleInterpolationData *pind)
|
|
|
|
|
{
|
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pind->epoint) {
|
2009-09-16 17:43:09 +00:00
|
|
|
PTCacheEditPoint *point = pind->epoint;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->ekey[0] = point->keys;
|
|
|
|
|
pind->ekey[1] = point->totkey > 1 ? point->keys + 1 : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->birthtime = *(point->keys->time);
|
|
|
|
|
pind->dietime = *((point->keys + point->totkey - 1)->time);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pind->keyed) {
|
2009-09-16 17:43:09 +00:00
|
|
|
ParticleKey *key = pa->keys;
|
|
|
|
|
pind->kkey[0] = key;
|
|
|
|
|
pind->kkey[1] = pa->totkey > 1 ? key + 1 : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->birthtime = key->time;
|
|
|
|
|
pind->dietime = (key + pa->totkey - 1)->time;
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pind->cache) {
|
2012-05-06 15:15:33 +00:00
|
|
|
float start = 0.0f, end = 0.0f;
|
2010-05-30 14:53:26 +00:00
|
|
|
get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL);
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->birthtime = pa ? pa->time : pind->cache->startframe;
|
|
|
|
|
pind->dietime = pa ? pa->dietime : pind->cache->endframe;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) {
|
2010-05-30 14:53:26 +00:00
|
|
|
pind->birthtime = MAX2(pind->birthtime, start);
|
|
|
|
|
pind->dietime = MIN2(pind->dietime, end);
|
|
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
else {
|
|
|
|
|
HairKey *key = pa->hair;
|
|
|
|
|
pind->hkey[0] = key;
|
|
|
|
|
pind->hkey[1] = key + 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->birthtime = key->time;
|
|
|
|
|
pind->dietime = (key + pa->totkey - 1)->time;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (pind->mesh) {
|
|
|
|
|
pind->mvert[0] = &pind->mesh->mvert[pa->hair_index];
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->mvert[1] = pind->mvert[0] + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void edit_to_particle(ParticleKey *key, PTCacheEditKey *ekey)
|
|
|
|
|
{
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(key->co, ekey->co);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ekey->vel) {
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(key->vel, ekey->vel);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
key->time = *(ekey->time);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
static void hair_to_particle(ParticleKey *key, HairKey *hkey)
|
|
|
|
|
{
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(key->co, hkey->co);
|
2009-07-12 23:38:47 +00:00
|
|
|
key->time = hkey->time;
|
|
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
|
|
|
|
|
static void mvert_to_particle(ParticleKey *key, MVert *mvert, HairKey *hkey)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(key->co, mvert->co);
|
2009-07-12 23:38:47 +00:00
|
|
|
key->time = hkey->time;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 15:50:00 +00:00
|
|
|
static void do_particle_interpolation(ParticleSystem *psys,
|
|
|
|
|
int p,
|
|
|
|
|
ParticleData *pa,
|
|
|
|
|
float t,
|
|
|
|
|
ParticleInterpolationData *pind,
|
|
|
|
|
ParticleKey *result)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
2009-09-16 17:43:09 +00:00
|
|
|
PTCacheEditPoint *point = pind->epoint;
|
2009-07-12 23:38:47 +00:00
|
|
|
ParticleKey keys[4];
|
2009-09-16 17:43:09 +00:00
|
|
|
int point_vel = (point && point->keys->vel);
|
2020-11-06 11:25:27 +11:00
|
|
|
float real_t, dfra, keytime, invdt = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-04 21:10:26 +00:00
|
|
|
/* billboards wont fill in all of these, so start cleared */
|
|
|
|
|
memset(keys, 0, sizeof(keys));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
/* interpret timing and find keys */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (point) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result->time < 0.0f) {
|
2009-09-16 17:43:09 +00:00
|
|
|
real_t = -result->time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
real_t = *(pind->ekey[0]->time) +
|
|
|
|
|
t * (*(pind->ekey[0][point->totkey - 1].time) - *(pind->ekey[0]->time));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
while (*(pind->ekey[1]->time) < real_t) {
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->ekey[1]++;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->ekey[0] = pind->ekey[1] - 1;
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pind->keyed) {
|
2009-07-12 23:38:47 +00:00
|
|
|
/* we have only one key, so let's use that */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (pind->kkey[1] == NULL) {
|
2009-07-12 23:38:47 +00:00
|
|
|
copy_particle_key(result, pind->kkey[0], 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result->time < 0.0f) {
|
2009-07-12 23:38:47 +00:00
|
|
|
real_t = -result->time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
real_t = pind->kkey[0]->time +
|
|
|
|
|
t * (pind->kkey[0][pa->totkey - 1].time - pind->kkey[0]->time);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (psys->part->phystype == PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) {
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt = psys->targets.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
pt = pt->next;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
while (pt && pa->time + pt->time < real_t) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pt = pt->next;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pt) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pt = pt->prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pa->time + pt->time + pt->duration > real_t) {
|
2009-07-20 23:52:53 +00:00
|
|
|
real_t = pa->time + pt->time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
real_t = pa->time + ((ParticleTarget *)psys->targets.last)->time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
CLAMP(real_t, pa->time, pa->dietime);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
while (pind->kkey[1]->time < real_t) {
|
2009-07-12 23:38:47 +00:00
|
|
|
pind->kkey[1]++;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
pind->kkey[0] = pind->kkey[1] - 1;
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pind->cache) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result->time < 0.0f) { /* flag for time in frames */
|
2009-07-12 23:38:47 +00:00
|
|
|
real_t = -result->time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-07-12 23:38:47 +00:00
|
|
|
real_t = pa->time + t * (pa->dietime - pa->time);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result->time < 0.0f) {
|
2009-07-12 23:38:47 +00:00
|
|
|
real_t = -result->time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
real_t = pind->hkey[0]->time +
|
|
|
|
|
t * (pind->hkey[0][pa->totkey - 1].time - pind->hkey[0]->time);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
while (pind->hkey[1]->time < real_t) {
|
2009-07-12 23:38:47 +00:00
|
|
|
pind->hkey[1]++;
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->mvert[1]++;
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
pind->hkey[0] = pind->hkey[1] - 1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
/* set actual interpolation keys */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (point) {
|
2009-09-16 17:43:09 +00:00
|
|
|
edit_to_particle(keys + 1, pind->ekey[0]);
|
|
|
|
|
edit_to_particle(keys + 2, pind->ekey[1]);
|
|
|
|
|
}
|
2018-05-15 13:26:40 +02:00
|
|
|
else if (pind->mesh) {
|
2009-09-16 17:43:09 +00:00
|
|
|
pind->mvert[0] = pind->mvert[1] - 1;
|
|
|
|
|
mvert_to_particle(keys + 1, pind->mvert[0], pind->hkey[0]);
|
|
|
|
|
mvert_to_particle(keys + 2, pind->mvert[1], pind->hkey[1]);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pind->keyed) {
|
2009-07-12 23:38:47 +00:00
|
|
|
memcpy(keys + 1, pind->kkey[0], sizeof(ParticleKey));
|
|
|
|
|
memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey));
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (pind->cache) {
|
2012-05-06 15:15:33 +00:00
|
|
|
get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys + 1, keys + 2);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
hair_to_particle(keys + 1, pind->hkey[0]);
|
|
|
|
|
hair_to_particle(keys + 2, pind->hkey[1]);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
/* set secondary interpolation keys for hair */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!pind->keyed && !pind->cache && !point_vel) {
|
|
|
|
|
if (point) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->ekey[0] != point->keys) {
|
2009-09-16 17:43:09 +00:00
|
|
|
edit_to_particle(keys, pind->ekey[0] - 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-09-16 17:43:09 +00:00
|
|
|
edit_to_particle(keys, pind->ekey[0]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2018-05-15 13:26:40 +02:00
|
|
|
else if (pind->mesh) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->hkey[0] != pa->hair) {
|
2009-09-16 17:43:09 +00:00
|
|
|
mvert_to_particle(keys, pind->mvert[0] - 1, pind->hkey[0] - 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-09-16 17:43:09 +00:00
|
|
|
mvert_to_particle(keys, pind->mvert[0], pind->hkey[0]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->hkey[0] != pa->hair) {
|
2009-07-12 23:38:47 +00:00
|
|
|
hair_to_particle(keys, pind->hkey[0] - 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-07-12 23:38:47 +00:00
|
|
|
hair_to_particle(keys, pind->hkey[0]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (point) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->ekey[1] != point->keys + point->totkey - 1) {
|
2009-09-16 17:43:09 +00:00
|
|
|
edit_to_particle(keys + 3, pind->ekey[1] + 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-09-16 17:43:09 +00:00
|
|
|
edit_to_particle(keys + 3, pind->ekey[1]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2018-05-15 13:26:40 +02:00
|
|
|
else if (pind->mesh) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->hkey[1] != pa->hair + pa->totkey - 1) {
|
2009-09-16 17:43:09 +00:00
|
|
|
mvert_to_particle(keys + 3, pind->mvert[1] + 1, pind->hkey[1] + 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-09-16 17:43:09 +00:00
|
|
|
mvert_to_particle(keys + 3, pind->mvert[1], pind->hkey[1]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->hkey[1] != pa->hair + pa->totkey - 1) {
|
2009-07-12 23:38:47 +00:00
|
|
|
hair_to_particle(keys + 3, pind->hkey[1] + 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-07-12 23:38:47 +00:00
|
|
|
hair_to_particle(keys + 3, pind->hkey[1]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
dfra = keys[2].time - keys[1].time;
|
|
|
|
|
keytime = (real_t - keys[1].time) / dfra;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-10 16:04:09 +10:00
|
|
|
/* Convert velocity to time-step size. */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pind->keyed || pind->cache || point_vel) {
|
2020-11-06 11:25:27 +11:00
|
|
|
invdt = dfra * 0.04f * (psys ? psys->part->timetweak : 1.0f);
|
2011-02-06 15:50:00 +00:00
|
|
|
mul_v3_fl(keys[1].vel, invdt);
|
|
|
|
|
mul_v3_fl(keys[2].vel, invdt);
|
2012-04-29 15:47:02 +00:00
|
|
|
interp_qt_qtqt(result->rot, keys[1].rot, keys[2].rot, keytime);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-10 16:04:09 +10:00
|
|
|
/* Now we should have in chronological order k1<=k2<=t<=k3<=k4 with key-time between
|
|
|
|
|
* [0, 1]->[k2, k3] (k1 & k4 used for cardinal & b-spline interpolation). */
|
2009-09-16 17:43:09 +00:00
|
|
|
psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ?
|
|
|
|
|
-1 /* signal for cubic interpolation */
|
2012-05-06 15:15:33 +00:00
|
|
|
:
|
|
|
|
|
(pind->bspline ? KEY_BSPLINE : KEY_CARDINAL),
|
|
|
|
|
keys,
|
|
|
|
|
keytime,
|
|
|
|
|
result,
|
|
|
|
|
1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
/* the velocity needs to be converted back from cubic interpolation */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pind->keyed || pind->cache || point_vel) {
|
2020-11-06 11:25:27 +11:00
|
|
|
mul_v3_fl(result->vel, 1.0f / invdt);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2012-02-12 00:25:52 +00:00
|
|
|
|
|
|
|
|
static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCacheKey *result)
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
int i = 0;
|
2012-02-12 00:25:52 +00:00
|
|
|
ParticleCacheKey *cur = first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* scale the requested time to fit the entire path even if the path is cut early */
|
2015-01-13 17:24:20 +01:00
|
|
|
t *= (first + first->segments)->time;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
while (i < first->segments && cur->time < t) {
|
2012-02-12 00:25:52 +00:00
|
|
|
cur++;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cur->time == t) {
|
2012-02-12 00:25:52 +00:00
|
|
|
*result = *cur;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-02-12 00:25:52 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
float dt = (t - (cur - 1)->time) / (cur->time - (cur - 1)->time);
|
|
|
|
|
interp_v3_v3v3(result->co, (cur - 1)->co, cur->co, dt);
|
|
|
|
|
interp_v3_v3v3(result->vel, (cur - 1)->vel, cur->vel, dt);
|
|
|
|
|
interp_qt_qtqt(result->rot, (cur - 1)->rot, cur->rot, dt);
|
2012-02-12 00:25:52 +00:00
|
|
|
result->time = t;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* first is actual base rotation, others are incremental from first */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cur == first || cur - 1 == first) {
|
2012-02-12 00:25:52 +00:00
|
|
|
copy_qt_qt(result->rot, first->rot);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-02-12 00:25:52 +00:00
|
|
|
mul_qt_qtqt(result->rot, first->rot, result->rot);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-02-12 00:25:52 +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
|
|
|
/************************************************/
|
|
|
|
|
/* Particles on a dm */
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* interpolate a location on a face based on face coordinates */
|
2011-12-30 07:55:15 +00:00
|
|
|
void psys_interpolate_face(MVert *mvert,
|
|
|
|
|
MFace *mface,
|
|
|
|
|
MTFace *tface,
|
|
|
|
|
float (*orcodata)[3],
|
2012-10-20 08:02:18 +00:00
|
|
|
float w[4],
|
|
|
|
|
float vec[3],
|
|
|
|
|
float nor[3],
|
|
|
|
|
float utan[3],
|
|
|
|
|
float vtan[3],
|
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
|
|
|
float orco[3])
|
2011-12-30 07:55:15 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
float *v1 = 0, *v2 = 0, *v3 = 0, *v4 = 0;
|
2012-04-29 15:47:02 +00:00
|
|
|
float e1[3], e2[3], s1, s2, t1, t2;
|
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 *uv1, *uv2, *uv3, *uv4;
|
|
|
|
|
float n1[3], n2[3], n3[3], n4[3];
|
|
|
|
|
float tuv[4][2];
|
2007-12-05 12:40:54 +00:00
|
|
|
float *o1, *o2, *o3, *o4;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
v1 = mvert[mface->v1].co;
|
|
|
|
|
v2 = mvert[mface->v2].co;
|
|
|
|
|
v3 = mvert[mface->v3].co;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-14 10:58:03 +00:00
|
|
|
normal_short_to_float_v3(n1, mvert[mface->v1].no);
|
|
|
|
|
normal_short_to_float_v3(n2, mvert[mface->v2].no);
|
|
|
|
|
normal_short_to_float_v3(n3, mvert[mface->v3].no);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (mface->v4) {
|
2012-05-06 15:15:33 +00:00
|
|
|
v4 = mvert[mface->v4].co;
|
2010-01-14 10:58:03 +00:00
|
|
|
normal_short_to_float_v3(n4, mvert[mface->v4].no);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-14 10:58:03 +00:00
|
|
|
interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (nor) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (mface->flag & ME_SMOOTH) {
|
2010-01-14 10:58:03 +00:00
|
|
|
interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-04-29 15:47:02 +00:00
|
|
|
normal_quad_v3(nor, v1, v2, v3, v4);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
}
|
|
|
|
|
else {
|
2010-01-14 10:58:03 +00:00
|
|
|
interp_v3_v3v3v3(vec, v1, v2, v3, w);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (nor) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (mface->flag & ME_SMOOTH) {
|
2010-01-14 10:58:03 +00:00
|
|
|
interp_v3_v3v3v3(nor, n1, n2, n3, w);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-04-29 15:47:02 +00:00
|
|
|
normal_tri_v3(nor, v1, v2, v3);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
/* calculate tangent vectors */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (utan && vtan) {
|
|
|
|
|
if (tface) {
|
2012-05-06 15:15:33 +00:00
|
|
|
uv1 = tface->uv[0];
|
|
|
|
|
uv2 = tface->uv[1];
|
|
|
|
|
uv3 = tface->uv[2];
|
|
|
|
|
uv4 = tface->uv[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-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
uv1 = tuv[0];
|
|
|
|
|
uv2 = tuv[1];
|
|
|
|
|
uv3 = tuv[2];
|
|
|
|
|
uv4 = tuv[3];
|
|
|
|
|
map_to_sphere(uv1, uv1 + 1, v1[0], v1[1], v1[2]);
|
|
|
|
|
map_to_sphere(uv2, uv2 + 1, v2[0], v2[1], v2[2]);
|
|
|
|
|
map_to_sphere(uv3, uv3 + 1, v3[0], v3[1], v3[2]);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (v4) {
|
2012-05-06 15:15:33 +00:00
|
|
|
map_to_sphere(uv4, uv4 + 1, v4[0], v4[1], v4[2]);
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (v4) {
|
2012-05-06 15:15:33 +00:00
|
|
|
s1 = uv3[0] - uv1[0];
|
|
|
|
|
s2 = uv4[0] - uv1[0];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
t1 = uv3[1] - uv1[1];
|
|
|
|
|
t2 = uv4[1] - uv1[1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(e1, v3, v1);
|
|
|
|
|
sub_v3_v3v3(e2, v4, v1);
|
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-06 15:15:33 +00:00
|
|
|
s1 = uv2[0] - uv1[0];
|
|
|
|
|
s2 = uv3[0] - uv1[0];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
t1 = uv2[1] - uv1[1];
|
|
|
|
|
t2 = uv3[1] - uv1[1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(e1, v2, v1);
|
|
|
|
|
sub_v3_v3v3(e2, v3, v1);
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
vtan[0] = (s1 * e2[0] - s2 * e1[0]);
|
|
|
|
|
vtan[1] = (s1 * e2[1] - s2 * e1[1]);
|
|
|
|
|
vtan[2] = (s1 * e2[2] - s2 * e1[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
utan[0] = (t1 * e2[0] - t2 * e1[0]);
|
|
|
|
|
utan[1] = (t1 * e2[1] - t2 * e1[1]);
|
|
|
|
|
utan[2] = (t1 * e2[2] - t2 * e1[2]);
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (orco) {
|
|
|
|
|
if (orcodata) {
|
2012-05-06 15:15:33 +00:00
|
|
|
o1 = orcodata[mface->v1];
|
|
|
|
|
o2 = orcodata[mface->v2];
|
|
|
|
|
o3 = orcodata[mface->v3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (mface->v4) {
|
2012-05-06 15:15:33 +00:00
|
|
|
o4 = orcodata[mface->v4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-14 10:58:03 +00:00
|
|
|
interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w);
|
2007-12-05 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-01-14 10:58:03 +00:00
|
|
|
interp_v3_v3v3v3(orco, o1, o2, o3, w);
|
2007-12-05 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(orco, vec);
|
2007-12-05 12:40: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
|
|
|
}
|
2011-11-06 14:00:55 +00:00
|
|
|
void psys_interpolate_uvs(const MTFace *tface, int quad, const float w[4], float uvco[2])
|
2008-02-17 22:42:03 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
float v10 = tface->uv[0][0];
|
|
|
|
|
float v11 = tface->uv[0][1];
|
|
|
|
|
float v20 = tface->uv[1][0];
|
|
|
|
|
float v21 = tface->uv[1][1];
|
|
|
|
|
float v30 = tface->uv[2][0];
|
|
|
|
|
float v31 = tface->uv[2][1];
|
2012-04-29 15:47:02 +00:00
|
|
|
float v40, v41;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (quad) {
|
2012-05-06 15:15:33 +00:00
|
|
|
v40 = tface->uv[3][0];
|
|
|
|
|
v41 = tface->uv[3][1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
uvco[0] = w[0] * v10 + w[1] * v20 + w[2] * v30 + w[3] * v40;
|
|
|
|
|
uvco[1] = w[0] * v11 + w[1] * v21 + w[2] * v31 + w[3] * v41;
|
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 {
|
2012-05-06 15:15:33 +00:00
|
|
|
uvco[0] = w[0] * v10 + w[1] * v20 + w[2] * v30;
|
|
|
|
|
uvco[1] = w[0] * v11 + w[1] * v21 + w[2] * v31;
|
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-17 22:42:03 +00:00
|
|
|
|
2011-11-06 14:00:55 +00:00
|
|
|
void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *mc)
|
2008-02-17 22:42:03 +00:00
|
|
|
{
|
2015-01-01 23:26:03 +11:00
|
|
|
const char *cp1, *cp2, *cp3, *cp4;
|
|
|
|
|
char *cp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
cp = (char *)mc;
|
2015-01-01 23:26:03 +11:00
|
|
|
cp1 = (const char *)&mcol[0];
|
|
|
|
|
cp2 = (const char *)&mcol[1];
|
|
|
|
|
cp3 = (const char *)&mcol[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (quad) {
|
2012-05-06 15:15:33 +00:00
|
|
|
cp4 = (char *)&mcol[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
cp[0] = (int)(w[0] * cp1[0] + w[1] * cp2[0] + w[2] * cp3[0] + w[3] * cp4[0]);
|
|
|
|
|
cp[1] = (int)(w[0] * cp1[1] + w[1] * cp2[1] + w[2] * cp3[1] + w[3] * cp4[1]);
|
|
|
|
|
cp[2] = (int)(w[0] * cp1[2] + w[1] * cp2[2] + w[2] * cp3[2] + w[3] * cp4[2]);
|
|
|
|
|
cp[3] = (int)(w[0] * cp1[3] + w[1] * cp2[3] + w[2] * cp3[3] + w[3] * cp4[3]);
|
2008-02-17 22:42:03 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
cp[0] = (int)(w[0] * cp1[0] + w[1] * cp2[0] + w[2] * cp3[0]);
|
|
|
|
|
cp[1] = (int)(w[0] * cp1[1] + w[1] * cp2[1] + w[2] * cp3[1]);
|
|
|
|
|
cp[2] = (int)(w[0] * cp1[2] + w[1] * cp2[2] + w[2] * cp3[2]);
|
|
|
|
|
cp[3] = (int)(w[0] * cp1[3] + w[1] * cp2[3] + w[2] * cp3[3]);
|
2008-02-17 22:42:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
static float psys_interpolate_value_from_verts(
|
|
|
|
|
Mesh *mesh, short from, int index, const float fw[4], const float *values)
|
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
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (values == 0 || index == -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
|
|
|
return 0.0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (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
|
|
|
case PART_FROM_VERT:
|
|
|
|
|
return values[index];
|
|
|
|
|
case PART_FROM_FACE:
|
|
|
|
|
case PART_FROM_VOLUME: {
|
2018-05-15 13:26:40 +02:00
|
|
|
MFace *mf = &mesh->mface[index];
|
2012-04-29 15:47:02 +00:00
|
|
|
return interpolate_particle_value(
|
|
|
|
|
values[mf->v1], values[mf->v2], values[mf->v3], values[mf->v4], fw, mf->v4);
|
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 14:00:55 +00:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* conversion of pa->fw to origspace layer coordinates */
|
2011-11-06 14:00:55 +00:00
|
|
|
static void psys_w_to_origspace(const float w[4], float uv[2])
|
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-06 15:15:33 +00:00
|
|
|
uv[0] = w[1] + w[2];
|
|
|
|
|
uv[1] = w[2] + w[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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* conversion of pa->fw to weights in face from origspace */
|
2011-11-06 14:00:55 +00:00
|
|
|
static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4], float neww[4])
|
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 v[4][3], co[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
v[0][0] = osface->uv[0][0];
|
|
|
|
|
v[0][1] = osface->uv[0][1];
|
|
|
|
|
v[0][2] = 0.0f;
|
|
|
|
|
v[1][0] = osface->uv[1][0];
|
|
|
|
|
v[1][1] = osface->uv[1][1];
|
|
|
|
|
v[1][2] = 0.0f;
|
|
|
|
|
v[2][0] = osface->uv[2][0];
|
|
|
|
|
v[2][1] = osface->uv[2][1];
|
|
|
|
|
v[2][2] = 0.0f;
|
2019-04-17 06:17:24 +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_w_to_origspace(w, co);
|
2012-05-06 15:15:33 +00:00
|
|
|
co[2] = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (quad) {
|
2012-05-06 15:15:33 +00:00
|
|
|
v[3][0] = osface->uv[3][0];
|
|
|
|
|
v[3][1] = osface->uv[3][1];
|
|
|
|
|
v[3][2] = 0.0f;
|
2011-11-06 14:00:55 +00:00
|
|
|
interp_weights_poly_v3(neww, v, 4, 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
|
|
|
}
|
|
|
|
|
else {
|
2011-11-06 14:00:55 +00:00
|
|
|
interp_weights_poly_v3(neww, v, 3, co);
|
2012-05-06 15:15:33 +00:00
|
|
|
neww[3] = 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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* Find the final derived mesh tessface for a particle, from its original tessface index.
|
|
|
|
|
* This is slow and can be optimized but only for many lookups.
|
|
|
|
|
*
|
2018-12-12 12:17:42 +11:00
|
|
|
* \param mesh_final: Final mesh, it may not have the same topology as original mesh.
|
|
|
|
|
* \param mesh_original: Original mesh, use for accessing #MPoly to #MFace mapping.
|
|
|
|
|
* \param findex_orig: The input tessface index.
|
|
|
|
|
* \param fw: Face weights (position of the particle inside the \a findex_orig tessface).
|
|
|
|
|
* \param poly_nodes: May be NULL, otherwise an array of linked list,
|
|
|
|
|
* one for each final \a mesh_final polygon, containing all its tessfaces indices.
|
|
|
|
|
* \return The \a mesh_final tessface index.
|
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
|
|
|
*/
|
|
|
|
|
int psys_particle_dm_face_lookup(Mesh *mesh_final,
|
2018-05-25 21:44:33 +02:00
|
|
|
Mesh *mesh_original,
|
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
|
|
|
int findex_orig,
|
|
|
|
|
const float fw[4],
|
|
|
|
|
struct LinkNode **poly_nodes)
|
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
|
|
|
MFace *mtessface_final;
|
|
|
|
|
OrigSpaceFace *osface_final;
|
|
|
|
|
int pindex_orig;
|
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 uv[2], (*faceuv)[2];
|
2019-04-17 06:17:24 +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
|
|
|
const int *index_mf_to_mpoly_deformed = NULL;
|
|
|
|
|
const int *index_mf_to_mpoly = NULL;
|
|
|
|
|
const int *index_mp_to_orig = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
const int totface_final = mesh_final->totface;
|
2018-05-25 21:44:33 +02:00
|
|
|
const int totface_deformed = mesh_original ? mesh_original->totface : totface_final;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-04-08 16:26:42 +02:00
|
|
|
if (ELEM(0, totface_final, totface_deformed)) {
|
|
|
|
|
return DMCACHE_NOTFOUND;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
index_mf_to_mpoly = CustomData_get_layer(&mesh_final->fdata, CD_ORIGINDEX);
|
|
|
|
|
index_mp_to_orig = CustomData_get_layer(&mesh_final->pdata, CD_ORIGINDEX);
|
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
|
|
|
BLI_assert(index_mf_to_mpoly);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-25 21:44:33 +02:00
|
|
|
if (mesh_original) {
|
|
|
|
|
index_mf_to_mpoly_deformed = CustomData_get_layer(&mesh_original->fdata, CD_ORIGINDEX);
|
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
|
|
|
}
|
|
|
|
|
else {
|
2018-05-15 13:26:40 +02:00
|
|
|
BLI_assert(mesh_final->runtime.deformed_only);
|
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
|
|
|
index_mf_to_mpoly_deformed = index_mf_to_mpoly;
|
|
|
|
|
}
|
|
|
|
|
BLI_assert(index_mf_to_mpoly_deformed);
|
2019-04-17 06:17:24 +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
|
|
|
pindex_orig = index_mf_to_mpoly_deformed[findex_orig];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-25 21:44:33 +02:00
|
|
|
if (mesh_original == NULL) {
|
|
|
|
|
mesh_original = mesh_final;
|
2012-10-30 19:20:17 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
index_mf_to_mpoly_deformed = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
mtessface_final = mesh_final->mface;
|
|
|
|
|
osface_final = CustomData_get_layer(&mesh_final->fdata, CD_ORIGSPACE);
|
2019-04-17 06:17:24 +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
|
|
|
if (osface_final == NULL) {
|
|
|
|
|
/* Assume we don't need osface_final data, and we get a direct 1-1 mapping... */
|
|
|
|
|
if (findex_orig < totface_final) {
|
2019-05-01 11:09:22 +10:00
|
|
|
// printf("\tNO CD_ORIGSPACE, assuming not needed\n");
|
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
|
|
|
return findex_orig;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
printf("\tNO CD_ORIGSPACE, error out of range\n");
|
|
|
|
|
return DMCACHE_NOTFOUND;
|
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
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
if (findex_orig >= mesh_original->totface) {
|
2012-05-06 15:15:33 +00:00
|
|
|
return DMCACHE_NOTFOUND; /* index not in the original mesh */
|
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
|
|
|
}
|
2019-04-17 06:17:24 +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_w_to_origspace(fw, uv);
|
2019-04-17 06:17:24 +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
|
|
|
if (poly_nodes) {
|
|
|
|
|
/* we can have a restricted linked list of faces to check, faster! */
|
|
|
|
|
LinkNode *tessface_node = poly_nodes[pindex_orig];
|
2019-04-17 06:17:24 +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
|
|
|
for (; tessface_node; tessface_node = tessface_node->next) {
|
2018-09-19 12:05:58 +10:00
|
|
|
int findex_dst = POINTER_AS_INT(tessface_node->link);
|
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
|
|
|
faceuv = osface_final[findex_dst].uv;
|
2019-04-17 06:17:24 +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
|
|
|
/* check that this intersects - Its possible this misses :/ -
|
|
|
|
|
* could also check its not between */
|
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
|
|
|
if (mtessface_final[findex_dst].v4) {
|
|
|
|
|
if (isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) {
|
|
|
|
|
return findex_dst;
|
2019-04-17 06:17:24 +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
|
|
|
}
|
|
|
|
|
else if (isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2])) {
|
|
|
|
|
return findex_dst;
|
2019-04-17 06:17:24 +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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { /* if we have no node, try every face */
|
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
|
|
|
for (int findex_dst = 0; findex_dst < totface_final; findex_dst++) {
|
2019-04-27 12:07:07 +10:00
|
|
|
/* If current tessface from 'final' DM and orig tessface (given by index)
|
|
|
|
|
* map to the same orig poly. */
|
2018-05-15 13:26:40 +02:00
|
|
|
if (BKE_mesh_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, findex_dst) ==
|
|
|
|
|
pindex_orig) {
|
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
|
|
|
faceuv = osface_final[findex_dst].uv;
|
2019-04-17 06:17:24 +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
|
|
|
/* check that this intersects - Its possible this misses :/ -
|
|
|
|
|
* could also check its not between */
|
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
|
|
|
if (mtessface_final[findex_dst].v4) {
|
|
|
|
|
if (isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) {
|
|
|
|
|
return findex_dst;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2])) {
|
|
|
|
|
return findex_dst;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
return DMCACHE_NOTFOUND;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
static int psys_map_index_on_dm(Mesh *mesh,
|
|
|
|
|
int from,
|
|
|
|
|
int index,
|
|
|
|
|
int index_dmcache,
|
|
|
|
|
const float fw[4],
|
|
|
|
|
float UNUSED(foffset),
|
|
|
|
|
int *mapindex,
|
|
|
|
|
float mapfw[4])
|
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
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (index < 0) {
|
2008-09-30 06:12:47 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (mesh->runtime.deformed_only || index_dmcache == DMCACHE_ISCHILD) {
|
2013-10-04 17:49:26 +00:00
|
|
|
/* for meshes that are either only deformed or for child particles, the
|
2008-09-30 06:12:47 +00:00
|
|
|
* index and fw do not require any mapping, so we can directly use it */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (from == PART_FROM_VERT) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (index >= mesh->totvert) {
|
2008-09-30 06:12:47 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
*mapindex = index;
|
|
|
|
|
}
|
2012-04-21 12:51:47 +00:00
|
|
|
else { /* FROM_FACE/FROM_VOLUME */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (index >= mesh->totface) {
|
2008-09-30 06:12:47 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
*mapindex = index;
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v4_v4(mapfw, fw);
|
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 {
|
2008-09-30 06:12:47 +00:00
|
|
|
/* for other meshes that have been modified, we try to map the particle
|
|
|
|
|
* to their new location, which means a different index, and for faces
|
|
|
|
|
* also a new face interpolation weights */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (from == PART_FROM_VERT) {
|
2019-07-15 14:09:57 +02:00
|
|
|
if (index_dmcache == DMCACHE_NOTFOUND || index_dmcache >= mesh->totvert) {
|
2008-09-30 06:12:47 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
*mapindex = index_dmcache;
|
|
|
|
|
}
|
2012-04-21 12:51:47 +00:00
|
|
|
else { /* FROM_FACE/FROM_VOLUME */
|
2012-05-06 15:15:33 +00:00
|
|
|
/* find a face on the derived mesh that uses this 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
|
|
|
MFace *mface;
|
|
|
|
|
OrigSpaceFace *osface;
|
2008-09-30 06:12:47 +00:00
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
i = index_dmcache;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (i == DMCACHE_NOTFOUND || i >= mesh->totface) {
|
2008-09-30 06:12:47 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
*mapindex = i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
/* modify the original weights to become
|
|
|
|
|
* weights for the derived mesh face */
|
2018-05-15 13:26:40 +02:00
|
|
|
osface = CustomData_get_layer(&mesh->fdata, CD_ORIGSPACE);
|
|
|
|
|
mface = &mesh->mface[i];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (osface == NULL) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mapfw[0] = mapfw[1] = mapfw[2] = mapfw[3] = 0.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2008-09-30 06:12:47 +00:00
|
|
|
psys_origspace_to_w(&osface[i], mface->v4, fw, mapfw);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-09-30 06:12:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
return 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
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
/* interprets particle data to get a point on a mesh in object space */
|
2018-05-15 13:26:40 +02:00
|
|
|
void psys_particle_on_dm(Mesh *mesh_final,
|
|
|
|
|
int from,
|
|
|
|
|
int index,
|
|
|
|
|
int index_dmcache,
|
2012-10-20 08:02:18 +00:00
|
|
|
const float fw[4],
|
|
|
|
|
float foffset,
|
|
|
|
|
float vec[3],
|
|
|
|
|
float nor[3],
|
|
|
|
|
float utan[3],
|
|
|
|
|
float vtan[3],
|
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
|
|
|
float orco[3])
|
2008-09-30 06:12:47 +00:00
|
|
|
{
|
|
|
|
|
float tmpnor[3], mapfw[4];
|
|
|
|
|
float(*orcodata)[3];
|
|
|
|
|
int mapindex;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (!psys_map_index_on_dm(
|
|
|
|
|
mesh_final, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (vec) {
|
|
|
|
|
vec[0] = vec[1] = vec[2] = 0.0;
|
|
|
|
|
}
|
|
|
|
|
if (nor) {
|
|
|
|
|
nor[0] = nor[1] = 0.0;
|
|
|
|
|
nor[2] = 1.0;
|
|
|
|
|
}
|
|
|
|
|
if (orco) {
|
|
|
|
|
orco[0] = orco[1] = orco[2] = 0.0;
|
|
|
|
|
}
|
|
|
|
|
if (utan) {
|
|
|
|
|
utan[0] = utan[1] = utan[2] = 0.0;
|
|
|
|
|
}
|
|
|
|
|
if (vtan) {
|
|
|
|
|
vtan[0] = vtan[1] = vtan[2] = 0.0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2008-09-30 06:12:47 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
orcodata = CustomData_get_layer(&mesh_final->vdata, CD_ORCO);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (from == PART_FROM_VERT) {
|
2018-05-15 13:26:40 +02:00
|
|
|
copy_v3_v3(vec, mesh_final->mvert[mapindex].co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (nor) {
|
2018-05-15 13:26:40 +02:00
|
|
|
normal_short_to_float_v3(nor, mesh_final->mvert[mapindex].no);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-03-28 15:37:08 +02:00
|
|
|
if (orco) {
|
|
|
|
|
if (orcodata) {
|
|
|
|
|
copy_v3_v3(orco, orcodata[mapindex]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(orco, vec);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (utan && vtan) {
|
2012-05-06 15:15:33 +00:00
|
|
|
utan[0] = utan[1] = utan[2] = 0.0f;
|
|
|
|
|
vtan[0] = vtan[1] = vtan[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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2008-09-30 06:12:47 +00:00
|
|
|
else { /* PART_FROM_FACE / PART_FROM_VOLUME */
|
|
|
|
|
MFace *mface;
|
|
|
|
|
MTFace *mtface;
|
|
|
|
|
MVert *mvert;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
mface = &mesh_final->mface[mapindex];
|
|
|
|
|
mvert = mesh_final->mvert;
|
|
|
|
|
mtface = mesh_final->mtface;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (mtface) {
|
2008-09-30 06:12:47 +00:00
|
|
|
mtface += mapindex;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (from == PART_FROM_VOLUME) {
|
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_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (nor) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(nor, tmpnor);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-14 23:29:46 +10:00
|
|
|
/* XXX Why not normalize tmpnor before copying it into nor??? -- mont29 */
|
|
|
|
|
normalize_v3(tmpnor);
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(tmpnor, -foffset);
|
2011-11-06 14:00:55 +00:00
|
|
|
add_v3_v3(vec, tmpnor);
|
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
|
|
|
}
|
2019-04-22 09:39:35 +10: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_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, nor, utan, vtan, orco);
|
2019-04-22 09:39:35 +10: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-09-30 06:12:47 +00:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
float psys_particle_value_from_verts(Mesh *mesh, short from, ParticleData *pa, float *values)
|
2008-09-30 06:12:47 +00:00
|
|
|
{
|
|
|
|
|
float mapfw[4];
|
|
|
|
|
int mapindex;
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (!psys_map_index_on_dm(
|
2019-04-22 09:39:35 +10:00
|
|
|
mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw)) {
|
2008-09-30 06:12:47 +00:00
|
|
|
return 0.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
return psys_interpolate_value_from_verts(mesh, from, mapindex, mapfw, values);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys)
|
|
|
|
|
{
|
|
|
|
|
ModifierData *md;
|
|
|
|
|
ParticleSystemModifierData *psmd;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (md = ob->modifiers.first; md; md = md->next) {
|
|
|
|
|
if (md->type == eModifierType_ParticleSystem) {
|
|
|
|
|
psmd = (ParticleSystemModifierData *)md;
|
|
|
|
|
if (psmd->psys == 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
|
|
|
return psmd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* Particles on a shape */
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* ready for future use */
|
2012-10-20 08:02:18 +00:00
|
|
|
static void psys_particle_on_shape(int UNUSED(distr),
|
|
|
|
|
int UNUSED(index),
|
|
|
|
|
float *UNUSED(fuv),
|
|
|
|
|
float vec[3],
|
|
|
|
|
float nor[3],
|
|
|
|
|
float utan[3],
|
|
|
|
|
float vtan[3],
|
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
|
|
|
float orco[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
|
|
|
{
|
|
|
|
|
/* TODO */
|
2020-08-07 22:36:11 +10:00
|
|
|
const float zerovec[3] = {0.0f, 0.0f, 0.0f};
|
2012-03-24 06:18:31 +00:00
|
|
|
if (vec) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(vec, zerovec);
|
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 (nor) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(nor, zerovec);
|
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 (utan) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(utan, zerovec);
|
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 (vtan) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(vtan, zerovec);
|
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 (orco) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(orco, zerovec);
|
2007-12-05 12:40: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
|
|
|
}
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* Particles on emitter */
|
|
|
|
|
/************************************************/
|
2015-01-15 18:15:52 +01:00
|
|
|
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
void psys_emitter_customdata_mask(ParticleSystem *psys, CustomData_MeshMasks *r_cddata_masks)
|
2015-01-15 18:15:52 +01:00
|
|
|
{
|
|
|
|
|
MTex *mtex;
|
|
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!psys->part) {
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-15 18:15:52 +01:00
|
|
|
for (i = 0; i < MAX_MTEX; i++) {
|
|
|
|
|
mtex = psys->part->mtex[i];
|
2019-04-22 09:39:35 +10:00
|
|
|
if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV)) {
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
r_cddata_masks->fmask |= CD_MASK_MTFACE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-15 18:15:52 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->part->tanfac != 0.0f) {
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
r_cddata_masks->fmask |= CD_MASK_MTFACE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-15 18:15:52 +01:00
|
|
|
/* ask for vertexgroups if we need them */
|
|
|
|
|
for (i = 0; i < PSYS_TOT_VG; i++) {
|
|
|
|
|
if (psys->vgroup[i]) {
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
|
2015-01-15 18:15:52 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-15 18:15:52 +01:00
|
|
|
/* particles only need this if they are after a non deform modifier, and
|
|
|
|
|
* the modifier stack will only create them in that case. */
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
r_cddata_masks->lmask |= CD_MASK_ORIGSPACE_MLOOP;
|
|
|
|
|
/* XXX Check we do need all those? */
|
|
|
|
|
r_cddata_masks->vmask |= CD_MASK_ORIGINDEX;
|
|
|
|
|
r_cddata_masks->emask |= CD_MASK_ORIGINDEX;
|
|
|
|
|
r_cddata_masks->pmask |= CD_MASK_ORIGINDEX;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
r_cddata_masks->vmask |= CD_MASK_ORCO;
|
2015-01-15 18:15:52 +01:00
|
|
|
}
|
|
|
|
|
|
2012-10-20 08:02:18 +00:00
|
|
|
void psys_particle_on_emitter(ParticleSystemModifierData *psmd,
|
|
|
|
|
int from,
|
|
|
|
|
int index,
|
|
|
|
|
int index_dmcache,
|
|
|
|
|
float fuv[4],
|
|
|
|
|
float foffset,
|
|
|
|
|
float vec[3],
|
|
|
|
|
float nor[3],
|
|
|
|
|
float utan[3],
|
|
|
|
|
float vtan[3],
|
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
|
|
|
float orco[3])
|
2011-12-30 07:55:15 +00:00
|
|
|
{
|
2019-06-21 11:49:43 +02:00
|
|
|
if (psmd && psmd->mesh_final) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (vec) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(vec, fuv);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (orco) {
|
2011-02-18 00:17:46 +00:00
|
|
|
copy_v3_v3(orco, fuv);
|
2019-04-22 09:39:35 +10: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
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* we cant use the num_dmcache */
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_particle_on_dm(
|
2019-06-21 11:49:43 +02:00
|
|
|
psmd->mesh_final, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco);
|
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
|
|
|
}
|
2019-04-22 09:39:35 +10: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_shape(from, index, fuv, vec, nor, utan, vtan, orco);
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* Path Cache */
|
|
|
|
|
/************************************************/
|
2009-01-10 19:34:23 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
|
|
|
|
|
{
|
|
|
|
|
EffectedPoint point;
|
|
|
|
|
ParticleKey state;
|
|
|
|
|
EffectorData efd;
|
|
|
|
|
EffectorCache *eff;
|
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
|
EffectorWeights *weights = sim->psys->part->effector_weights;
|
|
|
|
|
GuideEffectorData *data;
|
|
|
|
|
PARTICLE_P;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!effectors) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
LOOP_PARTICLES
|
|
|
|
|
{
|
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,
|
|
|
|
|
sim->psys->part->from,
|
|
|
|
|
pa->num,
|
|
|
|
|
pa->num_dmcache,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
pa->foffset,
|
|
|
|
|
state.co,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
mul_m4_v3(sim->ob->obmat, state.co);
|
|
|
|
|
mul_mat3_m4_v3(sim->ob->obmat, state.vel);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
pd_point_from_particle(sim, pa, &state, &point);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (eff = effectors->first; eff; eff = eff->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (eff->pd->forcefield != PFIELD_GUIDE) {
|
2009-10-22 23:22:05 +00:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!eff->guide_data) {
|
2012-05-06 15:15:33 +00:00
|
|
|
eff->guide_data = MEM_callocN(sizeof(GuideEffectorData) * psys->totpart,
|
|
|
|
|
"GuideEffectorData");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
data = eff->guide_data + p;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-06 14:00:55 +00:00
|
|
|
sub_v3_v3v3(efd.vec_to_point, state.co, eff->guide_loc);
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(efd.nor, eff->guide_dir);
|
2009-11-10 20:43:45 +00:00
|
|
|
efd.distance = len_v3(efd.vec_to_point);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(data->vec_to_point, efd.vec_to_point);
|
2009-10-22 23:22:05 +00:00
|
|
|
data->strength = effector_falloff(eff, &efd, &point, weights);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-09 11:44:05 +01:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
int do_guides(Depsgraph *depsgraph,
|
|
|
|
|
ParticleSettings *part,
|
|
|
|
|
ListBase *effectors,
|
|
|
|
|
ParticleKey *state,
|
|
|
|
|
int index,
|
|
|
|
|
float 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
|
|
|
{
|
2015-01-19 13:32:53 +01:00
|
|
|
CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve :
|
|
|
|
|
NULL;
|
|
|
|
|
CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve :
|
2019-04-17 06:17:24 +02:00
|
|
|
NULL;
|
2009-10-22 23:22:05 +00:00
|
|
|
EffectorCache *eff;
|
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
|
|
|
PartDeflect *pd;
|
|
|
|
|
Curve *cu;
|
2009-10-22 23:22:05 +00:00
|
|
|
GuideEffectorData *data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
float effect[3] = {0.0f, 0.0f, 0.0f}, veffect[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
float guidevec[4], guidedir[3], rot2[4], temp[3];
|
2010-04-21 11:59:47 +00:00
|
|
|
float guidetime, radius, weight, angle, totstrength = 0.0f;
|
2009-10-22 23:22:05 +00:00
|
|
|
float vec_to_point[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (effectors) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (eff = effectors->first; eff; eff = eff->next) {
|
2015-01-12 20:24:50 +01:00
|
|
|
pd = eff->pd;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pd->forcefield != PFIELD_GUIDE) {
|
2015-01-12 20:24:50 +01:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
data = eff->guide_data + index;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (data->strength <= 0.0f) {
|
2015-01-12 20:24:50 +01:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
guidetime = time / (1.0f - pd->free_end);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (guidetime > 1.0f) {
|
2015-01-12 20:24:50 +01:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
cu = (Curve *)eff->ob->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
if (pd->flag & PFIELD_GUIDE_PATH_ADD) {
|
|
|
|
|
if (where_on_path(
|
|
|
|
|
eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight) ==
|
2019-04-22 09:39:35 +10:00
|
|
|
0) {
|
2015-01-12 20:24:50 +01:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-12 20:24:50 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0) {
|
2015-01-12 20:24:50 +01:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-12 20:24:50 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
mul_m4_v3(eff->ob->obmat, guidevec);
|
|
|
|
|
mul_mat3_m4_v3(eff->ob->obmat, guidedir);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
normalize_v3(guidedir);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
copy_v3_v3(vec_to_point, data->vec_to_point);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
if (guidetime != 0.0f) {
|
|
|
|
|
/* curve direction */
|
|
|
|
|
cross_v3_v3v3(temp, eff->guide_dir, guidedir);
|
|
|
|
|
angle = dot_v3v3(eff->guide_dir, guidedir) / (len_v3(eff->guide_dir));
|
|
|
|
|
angle = saacos(angle);
|
|
|
|
|
axis_angle_to_quat(rot2, temp, angle);
|
|
|
|
|
mul_qt_v3(rot2, vec_to_point);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
/* curve tilt */
|
|
|
|
|
axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]);
|
|
|
|
|
mul_qt_v3(rot2, vec_to_point);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
/* curve taper */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cu->taperobj) {
|
2018-04-06 12:07:27 +02:00
|
|
|
mul_v3_fl(vec_to_point,
|
|
|
|
|
BKE_displist_calc_taper(depsgraph,
|
|
|
|
|
eff->scene,
|
|
|
|
|
cu->taperobj,
|
|
|
|
|
(int)(data->strength * guidetime * 100.0f),
|
|
|
|
|
100));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-12 20:24:50 +01:00
|
|
|
else { /* curve size*/
|
|
|
|
|
if (cu->flag & CU_PATH_RADIUS) {
|
|
|
|
|
mul_v3_fl(vec_to_point, radius);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2015-01-12 16:03:12 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (clumpcurve) {
|
2019-08-07 03:21:55 +10:00
|
|
|
BKE_curvemapping_changed_all(clumpcurve);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (roughcurve) {
|
2019-08-07 03:21:55 +10:00
|
|
|
BKE_curvemapping_changed_all(roughcurve);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
{
|
2015-01-13 20:58:28 +01:00
|
|
|
ParticleKey key;
|
2020-08-07 22:36:11 +10:00
|
|
|
const float par_co[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
const float par_vel[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
const float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
const float orco_offset[3] = {0.0f, 0.0f, 0.0f};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
copy_v3_v3(key.co, vec_to_point);
|
2015-01-13 20:58:28 +01:00
|
|
|
do_kink(&key,
|
|
|
|
|
par_co,
|
|
|
|
|
par_vel,
|
|
|
|
|
par_rot,
|
|
|
|
|
guidetime,
|
|
|
|
|
pd->kink_freq,
|
|
|
|
|
pd->kink_shape,
|
|
|
|
|
pd->kink_amp,
|
2020-11-06 11:25:27 +11:00
|
|
|
0.0f,
|
2015-01-13 20:58:28 +01:00
|
|
|
pd->kink,
|
|
|
|
|
pd->kink_axis,
|
|
|
|
|
0,
|
|
|
|
|
0);
|
|
|
|
|
do_clump(&key,
|
|
|
|
|
par_co,
|
|
|
|
|
guidetime,
|
|
|
|
|
orco_offset,
|
|
|
|
|
pd->clump_fac,
|
|
|
|
|
pd->clump_pow,
|
|
|
|
|
1.0f,
|
2015-01-19 13:32:53 +01:00
|
|
|
part->child_flag & PART_CHILD_USE_CLUMP_NOISE,
|
|
|
|
|
part->clump_noise_size,
|
|
|
|
|
clumpcurve);
|
2015-01-12 20:24:50 +01:00
|
|
|
copy_v3_v3(vec_to_point, key.co);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 20:24:50 +01:00
|
|
|
add_v3_v3(vec_to_point, guidevec);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-01 11:09:22 +10:00
|
|
|
// sub_v3_v3v3(pa_loc, pa_loc, pa_zero);
|
2015-01-12 20:24:50 +01:00
|
|
|
madd_v3_v3fl(effect, vec_to_point, data->strength);
|
|
|
|
|
madd_v3_v3fl(veffect, guidedir, data->strength);
|
|
|
|
|
totstrength += data->strength;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT) {
|
2015-01-12 20:24:50 +01:00
|
|
|
totstrength *= weight;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-12 20:24:50 +01:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (totstrength != 0.0f) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (totstrength > 1.0f) {
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(effect, 1.0f / totstrength);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-03-28 11:21:39 +00:00
|
|
|
CLAMP(totstrength, 0.0f, 1.0f);
|
2019-05-01 11:09:22 +10:00
|
|
|
// add_v3_v3(effect, pa_zero);
|
2009-11-10 20:43:45 +00:00
|
|
|
interp_v3_v3v3(state->co, state->co, effect, totstrength);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(veffect);
|
|
|
|
|
mul_v3_fl(veffect, len_v3(state->vel));
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(state->vel, veffect);
|
2009-10-22 23:22:05 +00:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-17 06:38:56 +00:00
|
|
|
static void do_path_effectors(ParticleSimulationData *sim,
|
|
|
|
|
int i,
|
|
|
|
|
ParticleCacheKey *ca,
|
|
|
|
|
int k,
|
|
|
|
|
int steps,
|
|
|
|
|
float *UNUSED(rootco),
|
|
|
|
|
float effector,
|
|
|
|
|
float UNUSED(dfra),
|
|
|
|
|
float UNUSED(cfra),
|
|
|
|
|
float *length,
|
|
|
|
|
float *vec)
|
2008-02-15 12:54:43 +00:00
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
float force[3] = {0.0f, 0.0f, 0.0f};
|
2008-02-15 12:54:43 +00:00
|
|
|
ParticleKey eff_key;
|
2009-10-22 23:22:05 +00:00
|
|
|
EffectedPoint epoint;
|
|
|
|
|
|
|
|
|
|
/* Don't apply effectors for dynamic hair, otherwise the effectors don't get applied twice. */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (sim->psys->flag & PSYS_HAIR_DYNAMICS) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-02-15 12:54:43 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_v3_v3(eff_key.co, (ca - 1)->co);
|
|
|
|
|
copy_v3_v3(eff_key.vel, (ca - 1)->vel);
|
|
|
|
|
copy_qt_qt(eff_key.rot, (ca - 1)->rot);
|
2008-02-15 12:54:43 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
pd_point_from_particle(sim, sim->psys->particles + i, &eff_key, &epoint);
|
2018-06-21 19:45:39 +02:00
|
|
|
BKE_effectors_apply(sim->psys->effectors,
|
|
|
|
|
sim->colliders,
|
|
|
|
|
sim->psys->part->effector_weights,
|
|
|
|
|
&epoint,
|
|
|
|
|
force,
|
2020-06-12 21:33:38 +03:00
|
|
|
NULL,
|
2018-06-21 19:45:39 +02:00
|
|
|
NULL);
|
2008-02-15 12:54:43 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_v3_fl(force,
|
|
|
|
|
effector * powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) /
|
|
|
|
|
(float)steps);
|
2008-02-15 12:54:43 +00:00
|
|
|
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(force, vec);
|
2008-02-15 12:54:43 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(force);
|
2008-02-15 12:54:43 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k < steps) {
|
2012-05-06 15:15:33 +00:00
|
|
|
sub_v3_v3v3(vec, (ca + 1)->co, ca->co);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-02-07 10:54:55 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
madd_v3_v3v3fl(ca->co, (ca - 1)->co, force, *length);
|
2011-02-07 10:54:55 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k < steps) {
|
2009-11-10 20:43:45 +00:00
|
|
|
*length = len_v3(vec);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-02-15 12:54:43 +00:00
|
|
|
}
|
2011-01-07 11:24:34 +00:00
|
|
|
static void offset_child(ChildParticle *cpa,
|
|
|
|
|
ParticleKey *par,
|
|
|
|
|
float *par_rot,
|
|
|
|
|
ParticleKey *child,
|
|
|
|
|
float flat,
|
|
|
|
|
float 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-01-07 11:24:34 +00:00
|
|
|
copy_v3_v3(child->co, cpa->fuv);
|
|
|
|
|
mul_v3_fl(child->co, 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
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
child->co[0] *= flat;
|
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:24:34 +00:00
|
|
|
copy_v3_v3(child->vel, par->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
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (par_rot) {
|
2011-01-07 11:24:34 +00:00
|
|
|
mul_qt_v3(par_rot, child->co);
|
|
|
|
|
copy_qt_qt(child->rot, par_rot);
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2011-01-07 11:24:34 +00:00
|
|
|
unit_qt(child->rot);
|
2019-04-22 09:39:35 +10: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-01-07 11:24:34 +00:00
|
|
|
add_v3_v3(child->co, par->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
|
|
|
}
|
2018-05-15 13:26:40 +02:00
|
|
|
float *psys_cache_vgroup(Mesh *mesh, ParticleSystem *psys, int vgroup)
|
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-06 15:15:33 +00:00
|
|
|
float *vg = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (vgroup < 0) {
|
2009-09-16 17:43:09 +00:00
|
|
|
/* hair dynamics pinning vgroup */
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (psys->vgroup[vgroup]) {
|
2018-05-15 13:26:40 +02:00
|
|
|
MDeformVert *dvert = mesh->dvert;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dvert) {
|
2018-05-15 13:26:40 +02:00
|
|
|
int totvert = mesh->totvert, i;
|
2012-05-06 15:15:33 +00:00
|
|
|
vg = MEM_callocN(sizeof(float) * totvert, "vg_cache");
|
|
|
|
|
if (psys->vg_neg & (1 << vgroup)) {
|
2019-04-22 09:39:35 +10:00
|
|
|
for (i = 0; i < totvert; i++) {
|
2020-03-06 12:50:56 +11:00
|
|
|
vg[i] = 1.0f - BKE_defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1);
|
2019-04-22 09:39:35 +10: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-24 06:18:31 +00:00
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
for (i = 0; i < totvert; i++) {
|
2020-03-06 12:50:56 +11:00
|
|
|
vg[i] = BKE_defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1);
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return vg;
|
|
|
|
|
}
|
2016-06-23 07:53:49 +10:00
|
|
|
void psys_find_parents(ParticleSimulationData *sim, 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
|
|
|
{
|
2015-03-25 18:34:52 +01:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSettings *part = sim->psys->part;
|
2019-03-20 00:46:33 +11:00
|
|
|
KDTree_3d *tree;
|
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
|
|
|
ChildParticle *cpa;
|
2015-03-25 18:34:52 +01:00
|
|
|
ParticleTexture ptex;
|
2012-05-06 15:15:33 +00:00
|
|
|
int p, totparent, totchild = sim->psys->totchild;
|
2007-12-05 12:40:54 +00:00
|
|
|
float co[3], orco[3];
|
2012-05-06 15:15:33 +00:00
|
|
|
int from = PART_FROM_FACE;
|
|
|
|
|
totparent = (int)(totchild * part->parents * 0.3f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (use_render_params && part->child_nbr && part->ren_child_nbr) {
|
2012-05-06 15:15:33 +00:00
|
|
|
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-11 23:04:59 +11:00
|
|
|
/* hard limit, workaround for it being ignored above */
|
|
|
|
|
if (sim->psys->totpart < totparent) {
|
|
|
|
|
totparent = sim->psys->totpart;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-20 00:46:33 +11:00
|
|
|
tree = BLI_kdtree_3d_new(totparent);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) {
|
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, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* Check if particle doesn't exist because of texture influence.
|
|
|
|
|
* Insert only existing particles into kdtree. */
|
2019-06-21 11:49:43 +02:00
|
|
|
get_cpa_texture(sim->psmd->mesh_final,
|
2018-05-15 13:26:40 +02:00
|
|
|
psys,
|
|
|
|
|
part,
|
|
|
|
|
psys->particles + cpa->pa[0],
|
|
|
|
|
p,
|
|
|
|
|
cpa->num,
|
|
|
|
|
cpa->fuv,
|
|
|
|
|
orco,
|
|
|
|
|
&ptex,
|
|
|
|
|
PAMAP_DENS | PAMAP_CHILD,
|
|
|
|
|
psys->cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-25 18:34:52 +01:00
|
|
|
if (ptex.exist >= psys_frand(psys, p + 24)) {
|
2019-03-20 00:46:33 +11:00
|
|
|
BLI_kdtree_3d_insert(tree, p, orco);
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-20 00:46:33 +11:00
|
|
|
BLI_kdtree_3d_balance(tree);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (; p < totchild; p++, cpa++) {
|
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, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
|
2019-03-20 00:46:33 +11:00
|
|
|
cpa->parent = BLI_kdtree_3d_find_nearest(tree, orco, 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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-20 00:46:33 +11:00
|
|
|
BLI_kdtree_3d_free(tree);
|
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
|
|
|
|
2016-06-23 07:53:49 +10:00
|
|
|
static bool psys_thread_context_init_path(ParticleThreadContext *ctx,
|
|
|
|
|
ParticleSimulationData *sim,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
float cfra,
|
|
|
|
|
const bool editupdate,
|
|
|
|
|
const bool use_render_params)
|
2007-12-04 13:57:28 +00:00
|
|
|
{
|
2014-10-06 18:58:41 +02:00
|
|
|
ParticleSystem *psys = sim->psys;
|
2007-12-04 13:57:28 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2012-05-06 15:15:33 +00:00
|
|
|
int totparent = 0, between = 0;
|
2015-01-13 17:24:20 +01:00
|
|
|
int segments = 1 << part->draw_step;
|
2007-12-04 13:57:28 +00:00
|
|
|
int totchild = psys->totchild;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
psys_thread_context_init(ctx, sim);
|
2019-04-17 06:17:24 +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
|
|
|
/*---start figuring out what is actually wanted---*/
|
2018-04-06 12:07:27 +02:00
|
|
|
if (psys_in_edit_mode(sim->depsgraph, psys)) {
|
2009-11-01 00:06:53 +00:00
|
|
|
ParticleEditSettings *pset = &scene->toolsettings->particle;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 14:50:24 +02:00
|
|
|
if ((use_render_params == 0) &&
|
2019-04-22 09:39:35 +10:00
|
|
|
(psys_orig_edit_get(psys) == NULL || pset->flag & PE_DRAW_PART) == 0) {
|
2012-05-06 15:15:33 +00:00
|
|
|
totchild = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
segments = 1 << pset->draw_step;
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (totchild && part->childtype == PART_CHILD_FACES) {
|
|
|
|
|
totparent = (int)(totchild * part->parents * 0.3f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (use_render_params && part->child_nbr && part->ren_child_nbr) {
|
2012-05-06 15:15:33 +00:00
|
|
|
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
/* part->parents could still be 0 so we can't test with totparent */
|
2012-05-06 15:15:33 +00:00
|
|
|
between = 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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (use_render_params) {
|
2015-01-13 17:24:20 +01:00
|
|
|
segments = 1 << part->ren_step;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
totchild = (int)((float)totchild * (float)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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-14 03:42:09 +02:00
|
|
|
totparent = MIN2(totparent, totchild);
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (totchild == 0) {
|
2014-10-06 18:58:41 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
/* fill context values */
|
2012-05-06 15:15:33 +00:00
|
|
|
ctx->between = between;
|
2015-01-13 17:24:20 +01:00
|
|
|
ctx->segments = segments;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(part->kink, PART_KINK_SPIRAL)) {
|
2015-01-13 17:24:20 +01:00
|
|
|
ctx->extra_segments = max_ii(part->kink_extra_steps, 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2015-01-13 17:24:20 +01:00
|
|
|
ctx->extra_segments = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
ctx->totchild = totchild;
|
|
|
|
|
ctx->totparent = totparent;
|
|
|
|
|
ctx->parent_pass = 0;
|
|
|
|
|
ctx->cfra = cfra;
|
|
|
|
|
ctx->editupdate = editupdate;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data = psys_create_lattice_deform_data(&ctx->sim);
|
2019-04-17 06:17:24 +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 all relevant vertex groups if they exist */
|
2018-05-15 13:26:40 +02:00
|
|
|
ctx->vg_length = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_LENGTH);
|
|
|
|
|
ctx->vg_clump = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_CLUMP);
|
|
|
|
|
ctx->vg_kink = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_KINK);
|
|
|
|
|
ctx->vg_rough1 = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_ROUGH1);
|
|
|
|
|
ctx->vg_rough2 = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_ROUGH2);
|
|
|
|
|
ctx->vg_roughe = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_ROUGHE);
|
|
|
|
|
ctx->vg_twist = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_TWIST);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->part->flag & PART_CHILD_EFFECT) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ctx->vg_effector = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_EFFECTOR);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-09 14:24:19 +01:00
|
|
|
/* prepare curvemapping tables */
|
2016-02-02 15:01:58 +01:00
|
|
|
if ((part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && part->clumpcurve) {
|
2019-08-07 03:21:55 +10:00
|
|
|
ctx->clumpcurve = BKE_curvemapping_copy(part->clumpcurve);
|
|
|
|
|
BKE_curvemapping_changed_all(ctx->clumpcurve);
|
2016-02-02 15:01:58 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ctx->clumpcurve = NULL;
|
|
|
|
|
}
|
|
|
|
|
if ((part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && part->roughcurve) {
|
2019-08-07 03:21:55 +10:00
|
|
|
ctx->roughcurve = BKE_curvemapping_copy(part->roughcurve);
|
|
|
|
|
BKE_curvemapping_changed_all(ctx->roughcurve);
|
2016-02-02 15:01:58 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ctx->roughcurve = NULL;
|
|
|
|
|
}
|
2018-02-14 14:33:53 +01:00
|
|
|
if ((part->child_flag & PART_CHILD_USE_TWIST_CURVE) && part->twistcurve) {
|
2019-08-07 03:21:55 +10:00
|
|
|
ctx->twistcurve = BKE_curvemapping_copy(part->twistcurve);
|
|
|
|
|
BKE_curvemapping_changed_all(ctx->twistcurve);
|
2018-02-14 14:33:53 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ctx->twistcurve = NULL;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
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-10-06 18:58:41 +02:00
|
|
|
static void psys_task_init_path(ParticleTask *task, ParticleSimulationData *sim)
|
|
|
|
|
{
|
|
|
|
|
/* init random number generator */
|
|
|
|
|
int seed = 31415926 + sim->psys->seed;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
task->rng_path = BLI_rng_new(seed);
|
2007-12-04 13:57: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
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
/* note: this function must be thread safe, except for branching! */
|
2014-10-06 18:58:41 +02:00
|
|
|
static void psys_thread_create_path(ParticleTask *task,
|
|
|
|
|
struct ChildParticle *cpa,
|
|
|
|
|
ParticleCacheKey *child_keys,
|
|
|
|
|
int i)
|
2007-12-04 13:57:28 +00:00
|
|
|
{
|
2014-10-06 18:58:41 +02:00
|
|
|
ParticleThreadContext *ctx = task->ctx;
|
2012-05-06 15:15:33 +00:00
|
|
|
Object *ob = ctx->sim.ob;
|
2009-10-22 23:22:05 +00:00
|
|
|
ParticleSystem *psys = ctx->sim.psys;
|
2007-12-04 13:57:28 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleCacheKey **cache = psys->childcache;
|
2018-05-15 14:50:24 +02:00
|
|
|
PTCacheEdit *edit = psys_orig_edit_get(psys);
|
2018-05-15 14:38:02 +02:00
|
|
|
ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.depsgraph, psys) && edit ?
|
|
|
|
|
edit->pathcache :
|
|
|
|
|
psys->pathcache;
|
2015-01-12 16:03:12 +01:00
|
|
|
ParticleCacheKey *child, *key[4];
|
2007-12-04 13:57:28 +00:00
|
|
|
ParticleTexture ptex;
|
2012-05-06 15:15:33 +00:00
|
|
|
float *cpa_fuv = 0, *par_rot = 0, rot[4];
|
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
|
|
|
float orco[3], hairmat[4][4], dvec[3], off1[4][3], off2[4][3];
|
2011-01-07 11:24:34 +00:00
|
|
|
float eff_length, eff_vec[3], weight[4];
|
2009-07-09 15:40:04 +00:00
|
|
|
int k, cpa_num;
|
2007-12-04 13:57:28 +00:00
|
|
|
short cpa_from;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!pcache) {
|
2009-11-01 00:06:53 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->between) {
|
2011-01-07 11:24:34 +00:00
|
|
|
ParticleData *pa = psys->particles + cpa->pa[0];
|
2007-12-04 13:57:28 +00:00
|
|
|
int w, needupdate;
|
2020-11-06 11:25:27 +11:00
|
|
|
float foffset, wsum = 0.0f;
|
2011-01-07 11:24:34 +00:00
|
|
|
float co[3];
|
|
|
|
|
float p_min = part->parting_min;
|
|
|
|
|
float p_max = part->parting_max;
|
|
|
|
|
/* Virtual parents don't work nicely with parting. */
|
2020-11-06 11:25:27 +11:00
|
|
|
float p_fac = part->parents > 0.0f ? 0.0f : part->parting_fac;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->editupdate) {
|
2012-05-06 15:15:33 +00:00
|
|
|
needupdate = 0;
|
|
|
|
|
w = 0;
|
|
|
|
|
while (w < 4 && cpa->pa[w] >= 0) {
|
2018-05-15 14:38:02 +02:00
|
|
|
if (edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) {
|
2012-05-06 15:15:33 +00:00
|
|
|
needupdate = 1;
|
2007-12-04 13:57:28 +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
|
|
|
w++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!needupdate) {
|
2007-12-04 13:57:28 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
/* get parent paths */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (w = 0; w < 4; w++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cpa->pa[w] >= 0) {
|
2011-01-07 11:24:34 +00:00
|
|
|
key[w] = pcache[cpa->pa[w]];
|
|
|
|
|
weight[w] = cpa->w[w];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
key[w] = pcache[0];
|
2020-11-06 11:25:27 +11:00
|
|
|
weight[w] = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-01-07 11:24:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
/* modify weights to create parting */
|
2020-11-06 11:25:27 +11:00
|
|
|
if (p_fac > 0.0f) {
|
2016-06-03 15:11:56 +10:00
|
|
|
const ParticleCacheKey *key_0_last = pcache_key_segment_endpoint_safe(key[0]);
|
2012-05-06 15:15:33 +00:00
|
|
|
for (w = 0; w < 4; w++) {
|
2020-11-06 11:25:27 +11:00
|
|
|
if (w && (weight[w] > 0.0f)) {
|
2016-06-03 15:11:56 +10:00
|
|
|
const ParticleCacheKey *key_w_last = pcache_key_segment_endpoint_safe(key[w]);
|
2011-01-07 11:24:34 +00:00
|
|
|
float d;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->flag & PART_CHILD_LONG_HAIR) {
|
2019-04-27 12:07:07 +10:00
|
|
|
/* For long hair use tip distance/root distance as parting
|
|
|
|
|
* factor instead of root to tip angle. */
|
2011-01-07 11:24:34 +00:00
|
|
|
float d1 = len_v3v3(key[0]->co, key[w]->co);
|
2016-06-03 15:11:56 +10:00
|
|
|
float d2 = len_v3v3(key_0_last->co, key_w_last->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 11:25:27 +11:00
|
|
|
d = d1 > 0.0f ? d2 / d1 - 1.0f : 10000.0f;
|
2011-01-07 11:24:34 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float v1[3], v2[3];
|
2016-06-03 15:11:56 +10:00
|
|
|
sub_v3_v3v3(v1, key_0_last->co, key[0]->co);
|
|
|
|
|
sub_v3_v3v3(v2, key_w_last->co, key[w]->co);
|
2011-01-07 11:24:34 +00:00
|
|
|
normalize_v3(v1);
|
|
|
|
|
normalize_v3(v2);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-17 09:43:51 +00:00
|
|
|
d = RAD2DEGF(saacos(dot_v3v3(v1, v2)));
|
2011-01-07 11:24:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (p_max > p_min) {
|
2012-05-06 15:15:33 +00:00
|
|
|
d = (d - p_min) / (p_max - p_min);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2020-11-06 11:25:27 +11:00
|
|
|
d = (d - p_min) <= 0.0f ? 0.0f : 1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 11:25:27 +11:00
|
|
|
CLAMP(d, 0.0f, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 11:25:27 +11:00
|
|
|
if (d > 0.0f) {
|
|
|
|
|
weight[w] *= (1.0f - d);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-01-07 11:24:34 +00:00
|
|
|
wsum += weight[w];
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
for (w = 0; w < 4; w++) {
|
2011-01-07 11:24:34 +00:00
|
|
|
weight[w] /= wsum;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
interp_v4_v4v4(weight, cpa->w, weight, p_fac);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
/* get the original coordinates (orco) for texture usage */
|
|
|
|
|
cpa_num = cpa->num;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
foffset = cpa->foffset;
|
2007-12-04 13:57:28 +00:00
|
|
|
cpa_fuv = cpa->fuv;
|
|
|
|
|
cpa_from = PART_FROM_FACE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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(
|
|
|
|
|
ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
mul_m4_v3(ob->obmat, co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (w = 0; w < 4; w++) {
|
2018-05-15 15:56:40 +02:00
|
|
|
sub_v3_v3v3(off1[w], co, key[w]->co);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(ob, ctx->sim.psmd->mesh_final, psys->part->from, pa, hairmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2018-05-15 15:56:40 +02:00
|
|
|
ParticleData *pa = psys->particles + cpa->parent;
|
|
|
|
|
float co[3];
|
|
|
|
|
if (ctx->editupdate) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 15:56:40 +02:00
|
|
|
memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
/* get the parent path */
|
|
|
|
|
key[0] = pcache[cpa->parent];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
/* get the original coordinates (orco) for texture usage */
|
2018-05-15 13:26:40 +02:00
|
|
|
cpa_from = part->from;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/*
|
2018-05-15 13:26:40 +02:00
|
|
|
* NOTE: Should in theory be the same as:
|
|
|
|
|
* cpa_num = psys_particle_dm_face_lookup(
|
|
|
|
|
* ctx->sim.psmd->dm_final,
|
2015-01-13 17:24:20 +01:00
|
|
|
* ctx->sim.psmd->dm_deformed,
|
2018-05-15 13:26:40 +02:00
|
|
|
* pa->num, pa->fuv,
|
2015-01-13 17:24:20 +01:00
|
|
|
* NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
*/
|
2015-01-13 17:24:20 +01:00
|
|
|
cpa_num = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num :
|
2011-01-07 11:24:34 +00:00
|
|
|
pa->num_dmcache;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-30 20:09:02 +10:00
|
|
|
/* XXX hack to avoid messed up particle num and subsequent crash (T40733) */
|
2019-06-21 11:49:43 +02:00
|
|
|
if (cpa_num > ctx->sim.psmd->mesh_final->totface) {
|
2014-06-29 15:51:58 +02:00
|
|
|
cpa_num = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-09-02 18:28:27 +10:00
|
|
|
cpa_fuv = pa->fuv;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-02 18:28:27 +10:00
|
|
|
psys_particle_on_emitter(ctx->sim.psmd,
|
|
|
|
|
cpa_from,
|
2018-02-15 10:27:39 +01:00
|
|
|
cpa_num,
|
|
|
|
|
DMCACHE_ISCHILD,
|
2019-04-17 06:17:24 +02:00
|
|
|
cpa_fuv,
|
2018-02-15 10:27:39 +01:00
|
|
|
pa->foffset,
|
2019-04-17 06:17:24 +02:00
|
|
|
co,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
2018-02-15 10:27:39 +01:00
|
|
|
orco);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(ob, ctx->sim.psmd->mesh_final, psys->part->from, pa, hairmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-15 15:56:40 +02:00
|
|
|
child_keys->segments = ctx->segments;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 15:56:40 +02:00
|
|
|
/* get different child parameters from textures & vgroups */
|
|
|
|
|
get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (ptex.exist < psys_frand(psys, i + 24)) {
|
2015-01-13 17:24:20 +01:00
|
|
|
child_keys->segments = -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
/* create the child path */
|
2015-01-13 17:24:20 +01:00
|
|
|
for (k = 0, child = child_keys; k <= ctx->segments; k++, child++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ctx->between) {
|
2007-12-04 13:57:28 +00:00
|
|
|
int w = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
zero_v3(child->co);
|
2011-01-07 11:24:34 +00:00
|
|
|
zero_v3(child->vel);
|
|
|
|
|
unit_qt(child->rot);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
for (w = 0; w < 4; w++) {
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_v3_v3(off2[w], off1[w]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
if (part->flag & PART_CHILD_LONG_HAIR) {
|
|
|
|
|
/* Use parent rotation (in addition to emission location) to determine child offset. */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k) {
|
2009-07-04 03:50:12 +00:00
|
|
|
mul_qt_v3((key[w] + k)->rot, off2[w]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-04 13:57:28 +00:00
|
|
|
/* Fade the effect of rotation for even lengths in the end */
|
2015-01-13 17:24:20 +01:00
|
|
|
project_v3_v3v3(dvec, off2[w], (key[w] + k)->vel);
|
|
|
|
|
madd_v3_v3fl(off2[w], dvec, -(float)k / (float)ctx->segments);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
add_v3_v3(off2[w], (key[w] + k)->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
/* child position is the weighted sum of parent positions */
|
2012-05-06 15:15:33 +00:00
|
|
|
interp_v3_v3v3v3v3(child->co, off2[0], off2[1], off2[2], off2[3], weight);
|
|
|
|
|
interp_v3_v3v3v3v3(child->vel,
|
|
|
|
|
(key[0] + k)->vel,
|
|
|
|
|
(key[1] + k)->vel,
|
|
|
|
|
(key[2] + k)->vel,
|
|
|
|
|
(key[3] + k)->vel,
|
2019-04-17 06:17:24 +02:00
|
|
|
weight);
|
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_qt_qt(child->rot, (key[0] + k)->rot);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (k) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_qt_qtqt(rot, (key[0] + k)->rot, key[0]->rot);
|
2011-01-07 11:24:34 +00:00
|
|
|
par_rot = rot;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-01-07 11:24:34 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
par_rot = key[0]->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
|
|
|
}
|
2011-01-07 11:24:34 +00:00
|
|
|
/* offset the child from the parent position */
|
|
|
|
|
offset_child(cpa,
|
2012-05-06 15:15:33 +00:00
|
|
|
(ParticleKey *)(key[0] + k),
|
|
|
|
|
par_rot,
|
|
|
|
|
(ParticleKey *)child,
|
|
|
|
|
part->childflat,
|
|
|
|
|
part->childrad);
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
child->time = (float)k / (float)ctx->segments;
|
2008-02-15 12:54:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-02-15 12:54:43 +00:00
|
|
|
/* apply effectors */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->flag & PART_CHILD_EFFECT) {
|
2015-01-13 17:24:20 +01:00
|
|
|
for (k = 0, child = child_keys; k <= ctx->segments; k++, child++) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (k) {
|
2015-01-13 17:24:20 +01:00
|
|
|
do_path_effectors(&ctx->sim,
|
|
|
|
|
cpa->pa[0],
|
|
|
|
|
child,
|
|
|
|
|
k,
|
|
|
|
|
ctx->segments,
|
|
|
|
|
child_keys->co,
|
|
|
|
|
ptex.effector,
|
|
|
|
|
0.0f,
|
|
|
|
|
ctx->cfra,
|
|
|
|
|
&eff_length,
|
|
|
|
|
eff_vec);
|
2008-02-15 12:54:43 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
sub_v3_v3v3(eff_vec, (child + 1)->co, child->co);
|
2011-01-07 11:24:34 +00:00
|
|
|
eff_length = len_v3(eff_vec);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2008-02-15 12:54:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-09 11:31:00 +01:00
|
|
|
{
|
2015-01-12 16:03:12 +01:00
|
|
|
ParticleData *pa = NULL;
|
|
|
|
|
ParticleCacheKey *par = NULL;
|
|
|
|
|
float par_co[3];
|
|
|
|
|
float par_orco[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-12 16:03:12 +01:00
|
|
|
if (ctx->totparent) {
|
|
|
|
|
if (i >= ctx->totparent) {
|
|
|
|
|
pa = &psys->particles[cpa->parent];
|
|
|
|
|
/* this is now threadsafe, virtual parents are calculated before rest of children */
|
2015-04-07 13:50:11 +05:00
|
|
|
BLI_assert(cpa->parent < psys->totchildcache);
|
2015-01-12 16:03:12 +01:00
|
|
|
par = cache[cpa->parent];
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2015-01-12 16:03:12 +01:00
|
|
|
}
|
|
|
|
|
else if (cpa->parent >= 0) {
|
|
|
|
|
pa = &psys->particles[cpa->parent];
|
|
|
|
|
par = pcache[cpa->parent];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-28 01:55:43 +10:00
|
|
|
/* If particle is non-existing, try to pick a viable parent from particles
|
2019-04-27 12:07:07 +10:00
|
|
|
* used for interpolation. */
|
2015-03-25 18:34:52 +01:00
|
|
|
for (k = 0; k < 4 && pa && (pa->flag & PARS_UNEXIST); k++) {
|
|
|
|
|
if (cpa->pa[k] >= 0) {
|
|
|
|
|
pa = &psys->particles[cpa->pa[k]];
|
|
|
|
|
par = pcache[cpa->pa[k]];
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pa->flag & PARS_UNEXIST) {
|
2015-03-25 18:34:52 +01:00
|
|
|
pa = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-12 16:03:12 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-20 11:42:33 +01:00
|
|
|
if (pa) {
|
2015-01-12 16:03:12 +01:00
|
|
|
ListBase modifiers;
|
|
|
|
|
BLI_listbase_clear(&modifiers);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-20 11:42:33 +01:00
|
|
|
psys_particle_on_emitter(ctx->sim.psmd,
|
|
|
|
|
part->from,
|
|
|
|
|
pa->num,
|
|
|
|
|
pa->num_dmcache,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
pa->foffset,
|
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
|
|
|
par_co,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
par_orco);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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_apply_child_modifiers(
|
|
|
|
|
ctx, &modifiers, cpa, &ptex, orco, hairmat, child_keys, par, par_orco);
|
2015-01-12 16:03:12 +01:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2015-01-20 11:42:33 +01:00
|
|
|
zero_v3(par_orco);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-01-09 11:31:00 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
/* Hide virtual parents */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (i < ctx->totparent) {
|
2015-01-13 17:24:20 +01:00
|
|
|
child_keys->segments = -1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 07:59:23 +02:00
|
|
|
static void exec_child_path_cache(TaskPool *__restrict UNUSED(pool), void *taskdata)
|
2007-12-04 13:57:28 +00:00
|
|
|
{
|
2014-10-06 18:58:41 +02:00
|
|
|
ParticleTask *task = taskdata;
|
|
|
|
|
ParticleThreadContext *ctx = task->ctx;
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSystem *psys = ctx->sim.psys;
|
|
|
|
|
ParticleCacheKey **cache = psys->childcache;
|
2007-12-04 13:57:28 +00:00
|
|
|
ChildParticle *cpa;
|
2014-10-06 18:58:41 +02:00
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
cpa = psys->child + task->begin;
|
2019-09-08 00:12:26 +10:00
|
|
|
for (i = task->begin; i < task->end; i++, cpa++) {
|
2015-04-07 13:50:11 +05:00
|
|
|
BLI_assert(i < psys->totchildcache);
|
2014-10-06 18:58:41 +02:00
|
|
|
psys_thread_create_path(task, cpa, cache[i], i);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-23 07:53:49 +10:00
|
|
|
void psys_cache_child_paths(ParticleSimulationData *sim,
|
|
|
|
|
float cfra,
|
|
|
|
|
const bool editupdate,
|
|
|
|
|
const bool use_render_params)
|
2007-12-04 13:57:28 +00:00
|
|
|
{
|
2014-10-06 18:58:41 +02:00
|
|
|
TaskPool *task_pool;
|
|
|
|
|
ParticleThreadContext ctx;
|
|
|
|
|
ParticleTask *tasks_parent, *tasks_child;
|
|
|
|
|
int numtasks_parent, numtasks_child;
|
|
|
|
|
int i, totchild, totparent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (sim->psys->flag & PSYS_GLOBAL_HAIR) {
|
2009-09-16 17:43:09 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
/* create a task pool for child path tasks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!psys_thread_context_init_path(&ctx, sim, sim->scene, cfra, editupdate, use_render_params)) {
|
2007-12-04 13:57:28 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-30 07:59:23 +02:00
|
|
|
task_pool = BLI_task_pool_create(&ctx, TASK_PRIORITY_LOW);
|
2014-10-06 18:58:41 +02:00
|
|
|
totchild = ctx.totchild;
|
|
|
|
|
totparent = ctx.totparent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) {
|
2019-04-02 17:54:04 +11:00
|
|
|
/* just overwrite the existing cache */
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* clear out old and create new empty path cache */
|
2010-07-17 17:07:50 +00:00
|
|
|
free_child_path_cache(sim->psys);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
sim->psys->childcache = psys_alloc_path_cache_buffers(
|
|
|
|
|
&sim->psys->childcachebufs, totchild, ctx.segments + ctx.extra_segments + 1);
|
2009-10-22 23:22:05 +00:00
|
|
|
sim->psys->totchildcache = totchild;
|
2007-12-04 13:57:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
/* cache parent paths */
|
|
|
|
|
ctx.parent_pass = 1;
|
2015-03-25 18:34:52 +01:00
|
|
|
psys_tasks_create(&ctx, 0, totparent, &tasks_parent, &numtasks_parent);
|
2019-09-08 00:12:26 +10:00
|
|
|
for (i = 0; i < numtasks_parent; i++) {
|
2014-10-06 18:58:41 +02:00
|
|
|
ParticleTask *task = &tasks_parent[i];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
psys_task_init_path(task, sim);
|
2020-04-09 15:51:44 +02:00
|
|
|
BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, 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-10-06 18:58:41 +02:00
|
|
|
BLI_task_pool_work_and_wait(task_pool);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
/* cache child paths */
|
|
|
|
|
ctx.parent_pass = 0;
|
2015-03-25 18:34:52 +01:00
|
|
|
psys_tasks_create(&ctx, totparent, totchild, &tasks_child, &numtasks_child);
|
2019-09-08 00:12:26 +10:00
|
|
|
for (i = 0; i < numtasks_child; i++) {
|
2014-10-06 18:58:41 +02:00
|
|
|
ParticleTask *task = &tasks_child[i];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
psys_task_init_path(task, sim);
|
2020-04-09 15:51:44 +02:00
|
|
|
BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, NULL);
|
2014-10-06 18:58:41 +02:00
|
|
|
}
|
|
|
|
|
BLI_task_pool_work_and_wait(task_pool);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
BLI_task_pool_free(task_pool);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-06 18:58:41 +02:00
|
|
|
psys_tasks_free(tasks_parent, numtasks_parent);
|
|
|
|
|
psys_tasks_free(tasks_child, numtasks_child);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-08 12:40:27 +01:00
|
|
|
psys_thread_context_free(&ctx);
|
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-10-06 18:58:41 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
/* figure out incremental rotations along path starting from unit quat */
|
|
|
|
|
static void cache_key_incremental_rotation(ParticleCacheKey *key0,
|
|
|
|
|
ParticleCacheKey *key1,
|
|
|
|
|
ParticleCacheKey *key2,
|
|
|
|
|
float *prev_tangent,
|
|
|
|
|
int i)
|
|
|
|
|
{
|
|
|
|
|
float cosangle, angle, tangent[3], normal[3], q[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (i) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case 0:
|
|
|
|
|
/* start from second key */
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
/* calculate initial tangent for incremental rotations */
|
|
|
|
|
sub_v3_v3v3(prev_tangent, key0->co, key1->co);
|
|
|
|
|
normalize_v3(prev_tangent);
|
|
|
|
|
unit_qt(key1->rot);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sub_v3_v3v3(tangent, key0->co, key1->co);
|
|
|
|
|
normalize_v3(tangent);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
cosangle = dot_v3v3(tangent, prev_tangent);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
/* note we do the comparison on cosangle instead of
|
|
|
|
|
* angle, since floating point accuracy makes it give
|
|
|
|
|
* different results across platforms */
|
|
|
|
|
if (cosangle > 0.999999f) {
|
|
|
|
|
copy_v4_v4(key1->rot, key2->rot);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
angle = saacos(cosangle);
|
|
|
|
|
cross_v3_v3v3(normal, prev_tangent, tangent);
|
|
|
|
|
axis_angle_to_quat(q, normal, angle);
|
|
|
|
|
mul_qt_qtqt(key1->rot, q, key2->rot);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_v3_v3(prev_tangent, tangent);
|
2011-01-07 11:24:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-01 12:20:18 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Calculates paths ready for drawing/rendering
|
|
|
|
|
* - Useful for making use of opengl vertex arrays for super fast strand drawing.
|
|
|
|
|
* - Makes child strands possible and creates them too into the cache.
|
|
|
|
|
* - Cached path data is also used to determine cut position for the editmode tool. */
|
2016-06-23 07:53:49 +10:00
|
|
|
void psys_cache_paths(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-10-22 23:22:05 +00:00
|
|
|
PARTICLE_PSMD;
|
|
|
|
|
ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
|
|
|
|
|
ParticleSystem *psys = sim->psys;
|
2008-09-17 19:29:44 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
2011-01-12 03:41:12 +00:00
|
|
|
ParticleCacheKey *ca, **cache;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
Mesh *hair_mesh = (psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ?
|
|
|
|
|
psys->hair_out_mesh :
|
|
|
|
|
NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-25 22:20:26 +00:00
|
|
|
ParticleKey result;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-11-27 14:12:56 +00:00
|
|
|
Material *ma;
|
2009-07-12 23:38:47 +00:00
|
|
|
ParticleInterpolationData pind;
|
2011-02-12 14:38:34 +00:00
|
|
|
ParticleTexture ptex;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
PARTICLE_P;
|
2019-04-17 06:17:24 +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
|
|
|
float birthtime = 0.0, dietime = 0.0;
|
2011-02-07 01:45:52 +00:00
|
|
|
float t, time = 0.0, dfra = 1.0 /* , frs_sec = sim->scene->r.frs_sec*/ /*UNUSED*/;
|
2009-07-04 03:50:12 +00:00
|
|
|
float col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
|
2010-12-29 12:27:03 +00:00
|
|
|
float prev_tangent[3] = {0.0f, 0.0f, 0.0f}, hairmat[4][4];
|
2009-07-12 23:38:47 +00:00
|
|
|
float rotmat[3][3];
|
2009-10-22 23:22:05 +00:00
|
|
|
int k;
|
2018-04-08 09:28:52 +02:00
|
|
|
int segments = (int)pow(2.0, (double)((use_render_params) ? part->ren_step : part->draw_step));
|
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
|
|
|
int totpart = psys->totpart;
|
2008-01-17 00:28:14 +00:00
|
|
|
float length, vec[3];
|
2012-05-06 15:15:33 +00:00
|
|
|
float *vg_effector = NULL;
|
|
|
|
|
float *vg_length = NULL, pa_length = 1.0f;
|
2009-07-04 03:50:12 +00:00
|
|
|
int keyed, baked;
|
2019-04-17 06:17:24 +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
|
|
|
/* we don't have anything valid to create paths from so let's quit here */
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 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
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys_in_edit_mode(sim->depsgraph, psys)) {
|
|
|
|
|
if ((psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) {
|
2009-09-16 17:43:09 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-04 03:50:12 +00:00
|
|
|
keyed = psys->flag & PSYS_KEYED;
|
2010-12-13 09:39:14 +00:00
|
|
|
baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
/* clear out old and create new empty path cache */
|
|
|
|
|
psys_free_path_cache(psys, psys->edit);
|
2015-01-13 17:24:20 +01:00
|
|
|
cache = psys->pathcache = psys_alloc_path_cache_buffers(
|
|
|
|
|
&psys->pathcachebufs, totpart, segments + 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
|
2020-02-05 11:23:58 +01:00
|
|
|
ma = BKE_object_material_get(sim->ob, psys->part->omat);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT)) {
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(col, &ma->r);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if ((psys->flag & PSYS_GLOBAL_HAIR) == 0) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((psys->part->flag & PART_CHILD_EFFECT) == 0) {
|
2019-06-21 11:49:43 +02:00
|
|
|
vg_effector = psys_cache_vgroup(psmd->mesh_final, psys, PSYS_VG_EFFECTOR);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!psys->totchild) {
|
2019-06-21 11:49:43 +02:00
|
|
|
vg_length = psys_cache_vgroup(psmd->mesh_final, psys, PSYS_VG_LENGTH);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-02-15 12:54:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-19 17:44:36 +00:00
|
|
|
/* ensure we have tessfaces to be used for mapping */
|
|
|
|
|
if (part->from != PART_FROM_VERT) {
|
2019-06-21 11:49:43 +02:00
|
|
|
BKE_mesh_tessface_ensure(psmd->mesh_final);
|
2012-02-19 17:44:36 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
/*---first main loop: create all actual particles' paths---*/
|
2015-01-07 16:15:03 +01:00
|
|
|
LOOP_PARTICLES
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!psys->totchild) {
|
2020-11-06 11:25:27 +11:00
|
|
|
psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.0f);
|
2014-03-07 10:25:56 +01:00
|
|
|
pa_length = ptex.length * (1.0f - part->randlength * psys_frand(psys, psys->seed + p));
|
2019-04-22 09:39:35 +10:00
|
|
|
if (vg_length) {
|
2019-06-21 11:49:43 +02:00
|
|
|
pa_length *= psys_particle_value_from_verts(psmd->mesh_final, part->from, pa, vg_length);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-09-17 19:29:44 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pind.keyed = keyed;
|
|
|
|
|
pind.cache = baked ? psys->pointcache : NULL;
|
|
|
|
|
pind.epoint = NULL;
|
|
|
|
|
pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE);
|
2018-05-15 13:26:40 +02:00
|
|
|
pind.mesh = hair_mesh;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
memset(cache[p], 0, sizeof(*cache[p]) * (segments + 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
cache[p]->segments = segments;
|
2019-04-17 06:17:24 +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
|
|
|
/*--get the first data points--*/
|
2009-10-22 23:22:05 +00:00
|
|
|
init_particle_interpolation(sim->ob, sim->psys, pa, &pind);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-25 00:55:11 +11:00
|
|
|
/* 'hairmat' is needed for non-hair particle too so we get proper rotations. */
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(sim->ob, psmd->mesh_final, psys->part->from, pa, hairmat);
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(rotmat[0], hairmat[2]);
|
|
|
|
|
copy_v3_v3(rotmat[1], hairmat[1]);
|
|
|
|
|
copy_v3_v3(rotmat[2], hairmat[0]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->draw & PART_ABS_PATH_TIME) {
|
2009-09-16 17:43:09 +00:00
|
|
|
birthtime = MAX2(pind.birthtime, part->path_start);
|
|
|
|
|
dietime = MIN2(pind.dietime, part->path_end);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float tb = pind.birthtime;
|
|
|
|
|
birthtime = tb + part->path_start * (pind.dietime - tb);
|
|
|
|
|
dietime = tb + part->path_end * (pind.dietime - tb);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (birthtime >= dietime) {
|
2015-01-13 17:24:20 +01:00
|
|
|
cache[p]->segments = -1;
|
2009-09-16 17:43:09 +00:00
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
dietime = birthtime + pa_length * (dietime - birthtime);
|
2019-04-17 06:17:24 +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
|
|
|
/*--interpolate actual path from data points--*/
|
2015-01-13 17:24:20 +01:00
|
|
|
for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
|
|
|
|
|
time = (float)k / (float)segments;
|
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
|
|
|
t = birthtime + time * (dietime - birthtime);
|
2009-07-12 23:38:47 +00:00
|
|
|
result.time = -t;
|
2011-02-06 15:50:00 +00:00
|
|
|
do_particle_interpolation(psys, p, pa, t, &pind, &result);
|
2011-01-07 11:24:34 +00:00
|
|
|
copy_v3_v3(ca->co, result.co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
/* dynamic hair is in object space */
|
2010-01-14 10:58:03 +00:00
|
|
|
/* keyed and baked are already in global space */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (hair_mesh) {
|
2011-01-07 11:24:34 +00:00
|
|
|
mul_m4_v3(sim->ob->obmat, ca->co);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else if (!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) {
|
2011-01-07 11:24:34 +00:00
|
|
|
mul_m4_v3(hairmat, ca->co);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-07 11:24:34 +00:00
|
|
|
copy_v3_v3(ca->col, col);
|
2008-01-17 00:28:14 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-03 16:46:08 +02:00
|
|
|
if (part->type == PART_HAIR) {
|
|
|
|
|
HairKey *hkey;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-08 00:12:26 +10:00
|
|
|
for (k = 0, hkey = pa->hair; k < pa->totkey; k++, hkey++) {
|
2014-10-03 16:46:08 +02:00
|
|
|
mul_v3_m4v3(hkey->world_co, hairmat, hkey->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2014-10-03 16:46:08 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
/*--modify paths and calculate rotation & velocity--*/
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
|
2010-07-25 13:18:15 +00:00
|
|
|
/* apply effectors */
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((psys->part->flag & PART_CHILD_EFFECT) == 0) {
|
2012-05-06 15:15:33 +00:00
|
|
|
float effector = 1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (vg_effector) {
|
2018-05-15 13:26:40 +02:00
|
|
|
effector *= psys_particle_value_from_verts(
|
2019-06-21 11:49:43 +02:00
|
|
|
psmd->mesh_final, psys->part->from, pa, vg_effector);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
sub_v3_v3v3(vec, (cache[p] + 1)->co, cache[p]->co);
|
2010-07-25 13:18:15 +00:00
|
|
|
length = len_v3(vec);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++) {
|
2015-01-13 17:24:20 +01:00
|
|
|
do_path_effectors(
|
|
|
|
|
sim, p, ca, k, segments, cache[p]->co, effector, dfra, cfra, &length, vec);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-07-25 13:18:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-25 13:18:15 +00:00
|
|
|
/* apply guide curves to path data */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) {
|
2019-04-22 09:39:35 +10:00
|
|
|
for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
|
2009-09-16 17:43:09 +00:00
|
|
|
/* ca is safe to cast, since only co and vel are used */
|
2018-04-06 12:07:27 +02:00
|
|
|
do_guides(sim->depsgraph,
|
|
|
|
|
sim->psys->part,
|
|
|
|
|
sim->psys->effectors,
|
|
|
|
|
(ParticleKey *)ca,
|
|
|
|
|
p,
|
|
|
|
|
(float)k / (float)segments);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-07-25 13:18:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-25 13:18:15 +00:00
|
|
|
/* lattices have to be calculated separately to avoid mixups between effector calculations */
|
2013-08-19 10:11:48 +00:00
|
|
|
if (psys->lattice_deform_data) {
|
2019-04-22 09:39:35 +10:00
|
|
|
for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
|
2020-06-13 15:41:34 +10:00
|
|
|
BKE_lattice_deform_data_eval_co(
|
|
|
|
|
psys->lattice_deform_data, ca->co, psys->lattice_strength);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-07-25 13:18:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-25 13:18:15 +00:00
|
|
|
/* finally do rotation & velocity */
|
2015-01-13 17:24:20 +01:00
|
|
|
for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++) {
|
2011-01-07 11:24:34 +00:00
|
|
|
cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k == segments) {
|
2011-01-07 11:24:34 +00:00
|
|
|
copy_qt_qt(ca->rot, (ca - 1)->rot);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-25 13:18:15 +00:00
|
|
|
/* set velocity */
|
2012-05-06 15:15:33 +00:00
|
|
|
sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k == 1) {
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_v3_v3((ca - 1)->vel, ca->vel);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
ca->time = (float)k / (float)segments;
|
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:24:34 +00:00
|
|
|
/* First rotation is based on emitting face orientation.
|
|
|
|
|
* This is way better than having flipping rotations resulting
|
|
|
|
|
* from using a global axis as a rotation pole (vec_to_quat()).
|
|
|
|
|
* It's not an ideal solution though since it disregards the
|
|
|
|
|
* initial tangent, but taking that in to account will allow
|
|
|
|
|
* the possibility of flipping again. -jahka
|
|
|
|
|
*/
|
|
|
|
|
mat3_to_quat_is_ok(cache[p]->rot, rotmat);
|
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
|
|
|
}
|
2019-04-17 06:17:24 +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->totcached = totpart;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
if (psys->lattice_deform_data) {
|
2020-06-13 15:41:34 +10:00
|
|
|
BKE_lattice_deform_data_destroy(psys->lattice_deform_data);
|
2013-08-19 10:11:48 +00:00
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (vg_effector) {
|
2008-01-24 14:16:52 +00:00
|
|
|
MEM_freeN(vg_effector);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (vg_length) {
|
2008-09-17 19:29:44 +00:00
|
|
|
MEM_freeN(vg_length);
|
2019-04-22 09:39:35 +10: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-09-16 17:43:09 +00:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
typedef struct CacheEditrPathsIterData {
|
|
|
|
|
Object *object;
|
|
|
|
|
PTCacheEdit *edit;
|
|
|
|
|
ParticleSystemModifierData *psmd;
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
int segments;
|
|
|
|
|
bool use_weight;
|
|
|
|
|
} CacheEditrPathsIterData;
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
static void psys_cache_edit_paths_iter(void *__restrict iter_data_v,
|
|
|
|
|
const int iter,
|
2019-07-30 14:56:47 +02:00
|
|
|
const TaskParallelTLS *__restrict UNUSED(tls))
|
2018-06-15 10:22:44 +02:00
|
|
|
{
|
|
|
|
|
CacheEditrPathsIterData *iter_data = (CacheEditrPathsIterData *)iter_data_v;
|
|
|
|
|
PTCacheEdit *edit = iter_data->edit;
|
|
|
|
|
PTCacheEditPoint *point = &edit->points[iter];
|
|
|
|
|
if (edit->totcached && !(point->flag & PEP_EDIT_RECALC)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (point->totkey == 0) {
|
|
|
|
|
return;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2018-06-15 10:22:44 +02:00
|
|
|
Object *ob = iter_data->object;
|
|
|
|
|
ParticleSystem *psys = edit->psys;
|
|
|
|
|
ParticleCacheKey **cache = edit->pathcache;
|
|
|
|
|
ParticleSystemModifierData *psmd = iter_data->psmd;
|
|
|
|
|
ParticleData *pa = iter_data->pa ? iter_data->pa + iter : NULL;
|
|
|
|
|
PTCacheEditKey *ekey = point->keys;
|
|
|
|
|
const int segments = iter_data->segments;
|
|
|
|
|
const bool use_weight = iter_data->use_weight;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
float birthtime = 0.0f, dietime = 0.0f;
|
|
|
|
|
float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
ParticleInterpolationData pind;
|
|
|
|
|
pind.keyed = 0;
|
|
|
|
|
pind.cache = NULL;
|
|
|
|
|
pind.epoint = point;
|
|
|
|
|
pind.bspline = psys ? (psys->part->flag & PART_HAIR_BSPLINE) : 0;
|
|
|
|
|
pind.mesh = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
/* should init_particle_interpolation set this ? */
|
2018-01-19 12:25:09 +11:00
|
|
|
if (use_weight) {
|
2018-06-15 10:22:44 +02:00
|
|
|
pind.hkey[0] = NULL;
|
|
|
|
|
/* pa != NULL since the weight brush is only available for hair */
|
|
|
|
|
pind.hkey[0] = pa->hair;
|
|
|
|
|
pind.hkey[1] = pa->hair + 1;
|
2010-01-14 08:53:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
memset(cache[iter], 0, sizeof(*cache[iter]) * (segments + 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
cache[iter]->segments = segments;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
/*--get the first data points--*/
|
|
|
|
|
init_particle_interpolation(ob, psys, pa, &pind);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
if (psys) {
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, pa, hairmat);
|
2018-06-15 10:22:44 +02:00
|
|
|
copy_v3_v3(rotmat[0], hairmat[2]);
|
|
|
|
|
copy_v3_v3(rotmat[1], hairmat[1]);
|
|
|
|
|
copy_v3_v3(rotmat[2], hairmat[0]);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
birthtime = pind.birthtime;
|
|
|
|
|
dietime = pind.dietime;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
if (birthtime >= dietime) {
|
|
|
|
|
cache[iter]->segments = -1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
/*--interpolate actual path from data points--*/
|
|
|
|
|
ParticleCacheKey *ca;
|
|
|
|
|
int k;
|
|
|
|
|
float t, time = 0.0f, keytime = 0.0f;
|
|
|
|
|
for (k = 0, ca = cache[iter]; k <= segments; k++, ca++) {
|
|
|
|
|
time = (float)k / (float)segments;
|
|
|
|
|
t = birthtime + time * (dietime - birthtime);
|
|
|
|
|
ParticleKey result;
|
|
|
|
|
result.time = -t;
|
|
|
|
|
do_particle_interpolation(psys, iter, pa, t, &pind, &result);
|
|
|
|
|
copy_v3_v3(ca->co, result.co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
/* non-hair points are already in global space */
|
|
|
|
|
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
|
|
|
|
|
mul_m4_v3(hairmat, ca->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
if (k) {
|
|
|
|
|
cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k == segments) {
|
2018-06-15 10:22:44 +02:00
|
|
|
copy_qt_qt(ca->rot, (ca - 1)->rot);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
/* set velocity */
|
|
|
|
|
sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (k == 1) {
|
2018-06-15 10:22:44 +02:00
|
|
|
copy_v3_v3((ca - 1)->vel, ca->vel);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-15 10:22:44 +02:00
|
|
|
}
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2018-06-15 10:22:44 +02:00
|
|
|
else {
|
|
|
|
|
ca->vel[0] = ca->vel[1] = 0.0f;
|
|
|
|
|
ca->vel[2] = 1.0f;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
/* selection coloring in edit mode */
|
|
|
|
|
if (use_weight) {
|
|
|
|
|
if (k == 0) {
|
2018-06-29 14:56:38 +02:00
|
|
|
BKE_defvert_weight_to_rgb(ca->col, pind.hkey[1]->weight);
|
2011-01-07 11:24:34 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2018-06-15 10:22:44 +02:00
|
|
|
/* warning: copied from 'do_particle_interpolation' (without 'mvert' array stepping) */
|
|
|
|
|
float real_t;
|
|
|
|
|
if (result.time < 0.0f) {
|
|
|
|
|
real_t = -result.time;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2018-06-15 10:22:44 +02:00
|
|
|
real_t = pind.hkey[0]->time +
|
|
|
|
|
t * (pind.hkey[0][pa->totkey - 1].time - pind.hkey[0]->time);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
while (pind.hkey[1]->time < real_t) {
|
|
|
|
|
pind.hkey[1]++;
|
|
|
|
|
}
|
|
|
|
|
pind.hkey[0] = pind.hkey[1] - 1;
|
|
|
|
|
/* end copy */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
float w1[3], w2[3];
|
|
|
|
|
keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-29 14:56:38 +02:00
|
|
|
BKE_defvert_weight_to_rgb(w1, pind.hkey[0]->weight);
|
|
|
|
|
BKE_defvert_weight_to_rgb(w2, pind.hkey[1]->weight);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
interp_v3_v3v3(ca->col, w1, w2, keytime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-01-28 18:28:10 +01:00
|
|
|
/* HACK(fclem): Instead of setting the color we pass the select state in the red channel.
|
|
|
|
|
* This is then picked up in DRW and the gpu shader will do the color interpolation. */
|
2018-06-15 10:22:44 +02:00
|
|
|
if ((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT) {
|
|
|
|
|
if ((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) {
|
2020-01-28 18:28:10 +01:00
|
|
|
ca->col[0] = 1.0f;
|
2018-06-15 10:22:44 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
|
2020-01-28 18:28:10 +01:00
|
|
|
ca->col[0] = 1.0f - keytime;
|
2010-05-04 12:31:24 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2010-01-14 08:53:10 +00:00
|
|
|
else {
|
2018-06-15 10:22:44 +02:00
|
|
|
if ((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) {
|
|
|
|
|
keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
|
2020-01-28 18:28:10 +01:00
|
|
|
ca->col[0] = keytime;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2020-01-28 18:28:10 +01:00
|
|
|
ca->col[0] = 0.0f;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
ca->time = t;
|
|
|
|
|
}
|
|
|
|
|
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
|
|
|
|
|
/* First rotation is based on emitting face orientation.
|
|
|
|
|
* This is way better than having flipping rotations resulting
|
|
|
|
|
* from using a global axis as a rotation pole (vec_to_quat()).
|
|
|
|
|
* It's not an ideal solution though since it disregards the
|
|
|
|
|
* initial tangent, but taking that in to account will allow
|
|
|
|
|
* the possibility of flipping again. -jahka
|
|
|
|
|
*/
|
|
|
|
|
mat3_to_quat_is_ok(cache[iter]->rot, rotmat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void psys_cache_edit_paths(Depsgraph *depsgraph,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
Object *ob,
|
|
|
|
|
PTCacheEdit *edit,
|
|
|
|
|
float cfra,
|
|
|
|
|
const bool use_render_params)
|
|
|
|
|
{
|
|
|
|
|
ParticleCacheKey **cache = edit->pathcache;
|
|
|
|
|
ParticleEditSettings *pset = &scene->toolsettings->particle;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
ParticleSystem *psys = edit->psys;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
ParticleData *pa = psys ? psys->particles : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
int segments = 1 << pset->draw_step;
|
|
|
|
|
int totpart = edit->totpoint, recalc_set = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-07-04 10:42:35 +02:00
|
|
|
if (edit->psmd_eval == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
segments = MAX2(segments, 4);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
if (!cache || edit->totpoint != edit->totcached) {
|
|
|
|
|
/* Clear out old and create new empty path cache. */
|
|
|
|
|
psys_free_path_cache(edit->psys, edit);
|
|
|
|
|
cache = edit->pathcache = psys_alloc_path_cache_buffers(
|
|
|
|
|
&edit->pathcachebufs, totpart, segments + 1);
|
|
|
|
|
/* Set flag for update (child particles check this too). */
|
|
|
|
|
int i;
|
|
|
|
|
PTCacheEditPoint *point;
|
|
|
|
|
for (i = 0, point = edit->points; i < totpart; i++, point++) {
|
|
|
|
|
point->flag |= PEP_EDIT_RECALC;
|
2011-01-07 11:24:34 +00:00
|
|
|
}
|
2018-06-15 10:22:44 +02:00
|
|
|
recalc_set = 1;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
const bool use_weight = (pset->brushtype == PE_BRUSH_WEIGHT) && (psys != NULL) &&
|
|
|
|
|
(psys->particles != NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-15 10:22:44 +02:00
|
|
|
CacheEditrPathsIterData iter_data;
|
|
|
|
|
iter_data.object = ob;
|
|
|
|
|
iter_data.edit = edit;
|
2018-06-19 15:25:48 +02:00
|
|
|
iter_data.psmd = edit->psmd_eval;
|
2018-06-15 10:22:44 +02:00
|
|
|
iter_data.pa = pa;
|
|
|
|
|
iter_data.segments = segments;
|
|
|
|
|
iter_data.use_weight = use_weight;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-07-30 14:56:47 +02:00
|
|
|
TaskParallelSettings settings;
|
2018-06-15 10:22:44 +02:00
|
|
|
BLI_parallel_range_settings_defaults(&settings);
|
|
|
|
|
BLI_task_parallel_range(0, edit->totpoint, &iter_data, psys_cache_edit_paths_iter, &settings);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
edit->totcached = totpart;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSimulationData sim = {0};
|
2018-04-06 12:07:27 +02:00
|
|
|
sim.depsgraph = depsgraph;
|
2012-05-06 15:15:33 +00:00
|
|
|
sim.scene = scene;
|
2018-06-06 15:48:30 +02:00
|
|
|
sim.ob = ob;
|
|
|
|
|
sim.psys = psys;
|
2018-06-19 15:25:48 +02:00
|
|
|
sim.psmd = edit->psmd_eval;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-06-23 07:53:49 +10:00
|
|
|
psys_cache_child_paths(&sim, cfra, true, use_render_params);
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-03-22 19:38:40 +00:00
|
|
|
/* clear recalc flag if set here */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (recalc_set) {
|
2018-06-15 10:22:44 +02:00
|
|
|
PTCacheEditPoint *point;
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0, point = edit->points; i < totpart; i++, point++) {
|
2010-03-22 19:38:40 +00:00
|
|
|
point->flag &= ~PEP_EDIT_RECALC;
|
2018-06-15 10:22:44 +02:00
|
|
|
}
|
2010-03-22 19:38:40 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +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
|
|
|
/************************************************/
|
|
|
|
|
/* Particle Key handling */
|
|
|
|
|
/************************************************/
|
2011-12-30 07:55:15 +00:00
|
|
|
void copy_particle_key(ParticleKey *to, ParticleKey *from, int time)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (time) {
|
2012-04-29 15:47:02 +00:00
|
|
|
memcpy(to, from, sizeof(ParticleKey));
|
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-06 15:15:33 +00:00
|
|
|
float to_time = to->time;
|
2012-04-29 15:47:02 +00:00
|
|
|
memcpy(to, from, sizeof(ParticleKey));
|
2012-05-06 15:15:33 +00:00
|
|
|
to->time = to_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
|
|
|
}
|
|
|
|
|
}
|
2012-10-20 08:02:18 +00:00
|
|
|
void psys_get_from_key(ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
|
2011-12-30 07:55:15 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (loc) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(loc, key->co);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (vel) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(vel, key->vel);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (rot) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_qt_qt(rot, key->rot);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (time) {
|
2012-05-06 15:15:33 +00:00
|
|
|
*time = key->time;
|
2019-04-22 09:39:35 +10: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-12-11 14:29:01 +00:00
|
|
|
static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat[4][4])
|
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 det, w1, w2, d1[2], d2[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-08 13:29:21 +10:00
|
|
|
memset(mat, 0, sizeof(float[4][4]));
|
2012-05-06 15:15:33 +00:00
|
|
|
mat[3][3] = 1.0f;
|
2019-04-17 06:17:24 +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
|
|
|
/* first axis is the normal */
|
2012-04-29 15:47:02 +00:00
|
|
|
normal_tri_v3(mat[2], v1, v2, v3);
|
2019-04-17 06:17:24 +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
|
|
|
/* second axis along (1, 0) in uv space */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (uv) {
|
2012-05-06 15:15:33 +00:00
|
|
|
d1[0] = uv[1][0] - uv[0][0];
|
|
|
|
|
d1[1] = uv[1][1] - uv[0][1];
|
|
|
|
|
d2[0] = uv[2][0] - uv[0][0];
|
|
|
|
|
d2[1] = uv[2][1] - uv[0][1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
det = d2[0] * d1[1] - d2[1] * d1[0];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (det != 0.0f) {
|
2012-05-06 15:15:33 +00:00
|
|
|
det = 1.0f / det;
|
|
|
|
|
w1 = -d2[1] * det;
|
|
|
|
|
w2 = d1[1] * det;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
mat[1][0] = w1 * (v2[0] - v1[0]) + w2 * (v3[0] - v1[0]);
|
|
|
|
|
mat[1][1] = w1 * (v2[1] - v1[1]) + w2 * (v3[1] - v1[1]);
|
|
|
|
|
mat[1][2] = w1 * (v2[2] - v1[2]) + w2 * (v3[2] - v1[2]);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(mat[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
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
mat[1][0] = mat[1][1] = mat[1][2] = 0.0f;
|
2019-04-22 09:39:35 +10: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
|
|
|
}
|
|
|
|
|
else {
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(mat[1], v2, v1);
|
|
|
|
|
normalize_v3(mat[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
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
/* third as a cross product */
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(mat[0], mat[1], mat[2]);
|
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-15 13:26:40 +02:00
|
|
|
static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4][4], int orco)
|
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-11 20:02:21 +00:00
|
|
|
float v[3][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
|
|
|
MFace *mface;
|
|
|
|
|
OrigSpaceFace *osface;
|
2007-12-06 17:43:47 +00:00
|
|
|
float(*orcodata)[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-07-10 05:46:45 +00:00
|
|
|
int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
|
2018-05-15 13:26:40 +02:00
|
|
|
if (i == -1 || i >= mesh->totface) {
|
|
|
|
|
unit_m4(mat);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
mface = &mesh->mface[i];
|
|
|
|
|
osface = CustomData_get(&mesh->fdata, i, CD_ORIGSPACE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (orco && (orcodata = CustomData_get_layer(&mesh->vdata, CD_ORCO))) {
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(v[0], orcodata[mface->v1]);
|
|
|
|
|
copy_v3_v3(v[1], orcodata[mface->v2]);
|
|
|
|
|
copy_v3_v3(v[2], orcodata[mface->v3]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-12-11 20:02:21 +00:00
|
|
|
/* ugly hack to use non-transformed orcos, since only those
|
|
|
|
|
* give symmetric results for mirroring in particle mode */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)) {
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_orco_verts_transform(ob->data, v, 3, 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2007-12-06 17:43:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2018-05-15 13:26:40 +02:00
|
|
|
copy_v3_v3(v[0], mesh->mvert[mface->v1].co);
|
|
|
|
|
copy_v3_v3(v[1], mesh->mvert[mface->v2].co);
|
|
|
|
|
copy_v3_v3(v[2], mesh->mvert[mface->v3].co);
|
2007-12-06 17:43:47 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
triatomat(v[0], v[1], v[2], (osface) ? osface->uv : NULL, mat);
|
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-06 17:43:47 +00:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
void psys_mat_hair_to_object(
|
|
|
|
|
Object *UNUSED(ob), Mesh *mesh, short from, ParticleData *pa, float hairmat[4][4])
|
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 vec[3];
|
|
|
|
|
|
2012-07-11 16:08:04 +00:00
|
|
|
/* can happen when called from a different object's modifier */
|
2018-05-15 13:26:40 +02:00
|
|
|
if (!mesh) {
|
2012-07-11 16:08:04 +00:00
|
|
|
unit_m4(hairmat);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_face_mat(0, mesh, pa, hairmat, 0);
|
|
|
|
|
psys_particle_on_dm(mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0);
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(hairmat[3], vec);
|
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-15 13:26:40 +02:00
|
|
|
void psys_mat_hair_to_orco(
|
|
|
|
|
Object *ob, Mesh *mesh, short from, ParticleData *pa, float hairmat[4][4])
|
2007-12-06 17:43:47 +00:00
|
|
|
{
|
|
|
|
|
float vec[3], orco[3];
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_face_mat(ob, mesh, pa, hairmat, 1);
|
|
|
|
|
psys_particle_on_dm(
|
|
|
|
|
mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco);
|
2007-12-11 20:02:21 +00:00
|
|
|
|
|
|
|
|
/* see psys_face_mat for why this function is called */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)) {
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_orco_verts_transform(ob->data, &orco, 1, 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(hairmat[3], orco);
|
2007-12-06 17:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
void psys_vec_rot_to_face(Mesh *mesh, ParticleData *pa, 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
|
|
|
{
|
|
|
|
|
float mat[4][4];
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_face_mat(0, mesh, pa, mat, 0);
|
2009-11-10 20:43:45 +00:00
|
|
|
transpose_m4(mat); /* cheap inverse for rotation matrix */
|
|
|
|
|
mul_mat3_m4_v3(mat, vec);
|
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-15 13:26:40 +02:00
|
|
|
void psys_mat_hair_to_global(
|
|
|
|
|
Object *ob, Mesh *mesh, short from, ParticleData *pa, float hairmat[4][4])
|
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 facemat[4][4];
|
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
psys_mat_hair_to_object(ob, mesh, from, pa, facemat);
|
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-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(hairmat, ob->obmat, facemat);
|
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 handling */
|
|
|
|
|
/************************************************/
|
2020-07-09 11:44:11 +02:00
|
|
|
static ModifierData *object_add_or_copy_particle_system(
|
|
|
|
|
Main *bmain, Scene *scene, Object *ob, const char *name, const ParticleSystem *psys_orig)
|
2009-06-27 15:41:47 +00:00
|
|
|
{
|
|
|
|
|
ParticleSystem *psys;
|
|
|
|
|
ModifierData *md;
|
|
|
|
|
ParticleSystemModifierData *psmd;
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!ob || ob->type != OB_MESH) {
|
2009-11-28 13:33:56 +00:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2019-03-05 15:24:54 +01:00
|
|
|
if (name == NULL) {
|
2020-07-09 11:44:11 +02:00
|
|
|
name = (psys_orig != NULL) ? psys_orig->name : DATA_("ParticleSettings");
|
2019-03-05 15:24:54 +01:00
|
|
|
}
|
|
|
|
|
|
2009-06-27 15:41:47 +00:00
|
|
|
psys = ob->particlesystem.first;
|
2019-04-22 09:39:35 +10:00
|
|
|
for (; psys; psys = psys->next) {
|
2009-06-27 15:41:47 +00:00
|
|
|
psys->flag &= ~PSYS_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
|
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->pointcache = BKE_ptcache_add(&psys->ptcaches);
|
2009-06-27 15:41:47 +00:00
|
|
|
BLI_addtail(&ob->particlesystem, psys);
|
2019-03-05 15:24:54 +01:00
|
|
|
psys_unique_name(ob, psys, name);
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2020-07-09 11:44:11 +02:00
|
|
|
if (psys_orig != NULL) {
|
|
|
|
|
psys->part = psys_orig->part;
|
|
|
|
|
id_us_plus(&psys->part->id);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
psys->part = BKE_particlesettings_add(bmain, psys->name);
|
|
|
|
|
}
|
2020-05-08 10:14:02 +02:00
|
|
|
md = BKE_modifier_new(eModifierType_ParticleSystem);
|
2019-03-05 15:24:54 +01:00
|
|
|
BLI_strncpy(md->name, psys->name, sizeof(md->name));
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_unique_name(&ob->modifiers, md);
|
2009-11-28 13:33:56 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
psmd = (ParticleSystemModifierData *)md;
|
|
|
|
|
psmd->psys = psys;
|
2009-06-27 15:41:47 +00:00
|
|
|
BLI_addtail(&ob->modifiers, md);
|
2020-12-28 11:17:49 -06:00
|
|
|
BKE_object_modifier_set_active(ob, md);
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
psys->totpart = 0;
|
2013-12-10 12:59:04 +11:00
|
|
|
psys->flag = PSYS_CURRENT;
|
2020-01-21 19:57:57 +01:00
|
|
|
if (scene != NULL) {
|
|
|
|
|
psys->cfra = BKE_scene_frame_to_ctime(scene, CFRA + 1);
|
|
|
|
|
}
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2018-06-13 11:02:48 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2009-11-28 13:33:56 +00:00
|
|
|
|
|
|
|
|
return md;
|
2009-06-27 15:41:47 +00:00
|
|
|
}
|
2020-07-09 11:44:11 +02:00
|
|
|
|
|
|
|
|
ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob, const char *name)
|
|
|
|
|
{
|
|
|
|
|
return object_add_or_copy_particle_system(bmain, scene, ob, name, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModifierData *object_copy_particle_system(Main *bmain,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
Object *ob,
|
|
|
|
|
const ParticleSystem *psys_orig)
|
|
|
|
|
{
|
|
|
|
|
return object_add_or_copy_particle_system(bmain, scene, ob, NULL, psys_orig);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-13 10:57:10 +02:00
|
|
|
void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob)
|
2009-06-27 15:41:47 +00:00
|
|
|
{
|
|
|
|
|
ParticleSystem *psys = psys_get_current(ob);
|
|
|
|
|
ParticleSystemModifierData *psmd;
|
2009-10-29 19:26:13 +00:00
|
|
|
ModifierData *md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!psys) {
|
2009-06-27 15:41:47 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-31 11:35:47 +01:00
|
|
|
/* Clear particle system in fluid modifier. */
|
2020-05-08 10:14:02 +02:00
|
|
|
if ((md = BKE_modifiers_findby_type(ob, eModifierType_Fluid))) {
|
2020-07-03 11:51:15 +02:00
|
|
|
FluidModifierData *fmd = (FluidModifierData *)md;
|
2020-01-31 11:35:47 +01:00
|
|
|
|
|
|
|
|
/* Clear particle system pointer in flow settings. */
|
2020-07-03 11:51:15 +02:00
|
|
|
if ((fmd->type == MOD_FLUID_TYPE_FLOW) && fmd->flow && fmd->flow->psys) {
|
|
|
|
|
if (fmd->flow->psys == psys) {
|
|
|
|
|
fmd->flow->psys = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2020-01-31 11:35:47 +01:00
|
|
|
/* Clear particle flag in domain settings when removing particle system manually. */
|
2020-07-03 11:51:15 +02:00
|
|
|
if (fmd->type == MOD_FLUID_TYPE_DOMAIN) {
|
2020-01-31 11:35:47 +01:00
|
|
|
if (psys->part->type == PART_FLUID_FLIP) {
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP;
|
2020-01-31 11:35:47 +01:00
|
|
|
}
|
2020-11-06 12:51:49 +11:00
|
|
|
if (ELEM(psys->part->type,
|
|
|
|
|
PART_FLUID_SPRAY,
|
|
|
|
|
PART_FLUID_SPRAYFOAM,
|
|
|
|
|
PART_FLUID_SPRAYBUBBLE,
|
|
|
|
|
PART_FLUID_SPRAYFOAMBUBBLE)) {
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY;
|
2020-01-31 11:35:47 +01:00
|
|
|
}
|
2020-11-06 12:51:49 +11:00
|
|
|
if (ELEM(psys->part->type,
|
|
|
|
|
PART_FLUID_FOAM,
|
|
|
|
|
PART_FLUID_SPRAYFOAM,
|
|
|
|
|
PART_FLUID_FOAMBUBBLE,
|
|
|
|
|
PART_FLUID_SPRAYFOAMBUBBLE)) {
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM;
|
2020-01-31 11:35:47 +01:00
|
|
|
}
|
2020-11-06 12:51:49 +11:00
|
|
|
if (ELEM(psys->part->type,
|
|
|
|
|
PART_FLUID_BUBBLE,
|
|
|
|
|
PART_FLUID_FOAMBUBBLE,
|
|
|
|
|
PART_FLUID_SPRAYBUBBLE,
|
|
|
|
|
PART_FLUID_SPRAYFOAMBUBBLE)) {
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE;
|
2020-01-31 11:35:47 +01:00
|
|
|
}
|
|
|
|
|
if (psys->part->type == PART_FLUID_TRACER) {
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_TRACER;
|
2020-01-31 11:35:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Disable combined export if combined particle system was deleted. */
|
2020-11-06 12:51:49 +11:00
|
|
|
if (ELEM(psys->part->type,
|
|
|
|
|
PART_FLUID_SPRAYFOAM,
|
|
|
|
|
PART_FLUID_SPRAYBUBBLE,
|
|
|
|
|
PART_FLUID_FOAMBUBBLE,
|
|
|
|
|
PART_FLUID_SPRAYFOAMBUBBLE)) {
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF;
|
2020-01-31 11:35:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-29 19:26:13 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
if ((md = BKE_modifiers_findby_type(ob, eModifierType_DynamicPaint))) {
|
2011-05-24 07:08:58 +00:00
|
|
|
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pmd->brush && pmd->brush->psys) {
|
|
|
|
|
if (pmd->brush->psys == psys) {
|
2011-06-16 10:41:00 +00:00
|
|
|
pmd->brush->psys = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-06 15:56:02 +01:00
|
|
|
/* Clear modifier, skip empty ones. */
|
2012-05-06 15:15:33 +00:00
|
|
|
psmd = psys_get_modifier(ob, psys);
|
2020-02-06 15:56:02 +01:00
|
|
|
if (psmd) {
|
2020-12-02 13:35:07 +01:00
|
|
|
BKE_modifier_remove_from_list(ob, (ModifierData *)psmd);
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_free((ModifierData *)psmd);
|
2020-02-06 15:56:02 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-06 15:56:02 +01:00
|
|
|
/* Clear particle system. */
|
2009-06-27 15:41:47 +00:00
|
|
|
BLI_remlink(&ob->particlesystem, psys);
|
2016-08-26 20:29:40 +02:00
|
|
|
if (psys->part) {
|
|
|
|
|
id_us_min(&psys->part->id);
|
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
psys_free(ob, psys);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ob->particlesystem.first) {
|
2009-06-27 15:41:47 +00:00
|
|
|
((ParticleSystem *)ob->particlesystem.first)->flag |= PSYS_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2018-04-05 18:20:27 +02:00
|
|
|
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-13 11:02:48 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-05 12:19:14 +02:00
|
|
|
/* Flush object mode. */
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
|
2009-06-27 15:41:47 +00:00
|
|
|
}
|
2015-01-15 11:51:30 +01:00
|
|
|
|
2018-06-13 10:57:10 +02:00
|
|
|
ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name)
|
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;
|
|
|
|
|
|
2020-10-08 12:50:04 +02:00
|
|
|
part = BKE_id_new(bmain, ID_PA, name);
|
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
|
|
|
return part;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-09 14:24:19 +01:00
|
|
|
void BKE_particlesettings_clump_curve_init(ParticleSettings *part)
|
|
|
|
|
{
|
2019-08-07 03:21:55 +10:00
|
|
|
CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-01-09 14:24:19 +01:00
|
|
|
cumap->cm[0].curve[0].x = 0.0f;
|
|
|
|
|
cumap->cm[0].curve[0].y = 1.0f;
|
|
|
|
|
cumap->cm[0].curve[1].x = 1.0f;
|
|
|
|
|
cumap->cm[0].curve[1].y = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-08-01 13:02:21 +10:00
|
|
|
BKE_curvemapping_init(cumap);
|
2018-11-25 14:21:02 +01:00
|
|
|
|
2015-01-09 14:24:19 +01:00
|
|
|
part->clumpcurve = cumap;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-09 15:58:18 +01:00
|
|
|
void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
|
|
|
|
|
{
|
2019-08-07 03:21:55 +10:00
|
|
|
CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-01-09 15:58:18 +01:00
|
|
|
cumap->cm[0].curve[0].x = 0.0f;
|
|
|
|
|
cumap->cm[0].curve[0].y = 1.0f;
|
|
|
|
|
cumap->cm[0].curve[1].x = 1.0f;
|
|
|
|
|
cumap->cm[0].curve[1].y = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-08-01 13:02:21 +10:00
|
|
|
BKE_curvemapping_init(cumap);
|
2018-11-25 14:21:02 +01:00
|
|
|
|
2015-01-09 15:58:18 +01:00
|
|
|
part->roughcurve = cumap;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-14 14:33:53 +01:00
|
|
|
void BKE_particlesettings_twist_curve_init(ParticleSettings *part)
|
|
|
|
|
{
|
2019-08-07 03:21:55 +10:00
|
|
|
CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
2018-02-14 14:33:53 +01:00
|
|
|
|
|
|
|
|
cumap->cm[0].curve[0].x = 0.0f;
|
|
|
|
|
cumap->cm[0].curve[0].y = 1.0f;
|
|
|
|
|
cumap->cm[0].curve[1].x = 1.0f;
|
|
|
|
|
cumap->cm[0].curve[1].y = 1.0f;
|
|
|
|
|
|
2020-08-01 13:02:21 +10:00
|
|
|
BKE_curvemapping_init(cumap);
|
2018-11-25 14:21:02 +01:00
|
|
|
|
2018-02-14 14:33:53 +01:00
|
|
|
part->twistcurve = cumap;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/************************************************/
|
|
|
|
|
/* Textures */
|
|
|
|
|
/************************************************/
|
2008-09-29 23:33:27 +00:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
static int get_particle_uv(Mesh *mesh,
|
|
|
|
|
ParticleData *pa,
|
|
|
|
|
int index,
|
|
|
|
|
const float fuv[4],
|
2017-07-05 12:23:42 +02:00
|
|
|
char *name,
|
|
|
|
|
float *texco,
|
|
|
|
|
bool from_vert)
|
2008-09-29 23:33:27 +00:00
|
|
|
{
|
|
|
|
|
MFace *mf;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
tf = CustomData_get_layer_named(&mesh->fdata, CD_MTFACE, name);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (tf == NULL) {
|
2018-05-15 13:26:40 +02:00
|
|
|
tf = mesh->mtface;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (tf == NULL) {
|
2008-09-29 23:33:27 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa) {
|
2014-03-26 18:34:07 +01:00
|
|
|
i = ELEM(pa->num_dmcache, DMCACHE_NOTFOUND, DMCACHE_ISCHILD) ? pa->num : pa->num_dmcache;
|
2018-05-15 13:26:40 +02:00
|
|
|
if ((!from_vert && i >= mesh->totface) || (from_vert && i >= mesh->totvert)) {
|
2008-09-29 23:33:27 +00:00
|
|
|
i = -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-07-05 12:23:42 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
i = index;
|
2008-09-29 23:33:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (i == -1) {
|
|
|
|
|
texco[0] = 0.0f;
|
|
|
|
|
texco[1] = 0.0f;
|
|
|
|
|
texco[2] = 0.0f;
|
2008-09-29 23:33:27 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2017-07-05 12:23:42 +02:00
|
|
|
if (from_vert) {
|
2018-05-15 13:26:40 +02:00
|
|
|
mf = mesh->mface;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-07-05 16:16:57 +02:00
|
|
|
/* This finds the first face to contain the emitting vertex,
|
|
|
|
|
* this is not ideal, but is mostly fine as UV seams generally
|
|
|
|
|
* map to equal-colored parts of a texture */
|
2018-05-15 13:26:40 +02:00
|
|
|
for (int j = 0; j < mesh->totface; j++, mf++) {
|
2017-07-05 12:23:42 +02:00
|
|
|
if (ELEM(i, mf->v1, mf->v2, mf->v3, mf->v4)) {
|
|
|
|
|
i = j;
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-07-05 12:23:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-05-15 13:26:40 +02:00
|
|
|
mf = &mesh->mface[i];
|
2017-07-05 12:23:42 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-29 23:33:27 +00:00
|
|
|
psys_interpolate_uvs(&tf[i], mf->v4, fuv, texco);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
texco[0] = texco[0] * 2.0f - 1.0f;
|
|
|
|
|
texco[1] = texco[1] * 2.0f - 1.0f;
|
|
|
|
|
texco[2] = 0.0f;
|
2008-09-29 23:33:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-29 23:33:27 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-18 02:41:55 +00:00
|
|
|
#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \
|
|
|
|
|
if ((event & mtex->mapto) & type) { \
|
|
|
|
|
pvalue = texture_value_blend(def, pvalue, value, texfac, blend); \
|
|
|
|
|
} \
|
|
|
|
|
(void)0
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-18 02:41:55 +00:00
|
|
|
#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \
|
2016-01-11 17:01:09 +01:00
|
|
|
if (event & type) { \
|
|
|
|
|
CLAMP(pvalue, 0.0f, 1.0f); \
|
|
|
|
|
} \
|
|
|
|
|
(void)0
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-11 17:01:09 +01:00
|
|
|
#define CLAMP_WARP_PARTICLE_TEXTURE_POS(type, pvalue) \
|
2012-11-18 02:41:55 +00:00
|
|
|
if (event & type) { \
|
2020-09-19 16:01:32 +10:00
|
|
|
if (pvalue < 0.0f) { \
|
2012-11-18 02:41:55 +00:00
|
|
|
pvalue = 1.0f + pvalue; \
|
2020-09-19 16:01:32 +10:00
|
|
|
} \
|
2012-11-18 02:41:55 +00:00
|
|
|
CLAMP(pvalue, 0.0f, 1.0f); \
|
|
|
|
|
} \
|
|
|
|
|
(void)0
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-18 02:41:55 +00:00
|
|
|
#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) \
|
|
|
|
|
if (event & type) { \
|
|
|
|
|
CLAMP(pvalue, -1.0f, 1.0f); \
|
|
|
|
|
} \
|
|
|
|
|
(void)0
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
static void get_cpa_texture(Mesh *mesh,
|
|
|
|
|
ParticleSystem *psys,
|
|
|
|
|
ParticleSettings *part,
|
|
|
|
|
ParticleData *par,
|
|
|
|
|
int child_index,
|
|
|
|
|
int face_index,
|
|
|
|
|
const float fw[4],
|
|
|
|
|
float *orco,
|
|
|
|
|
ParticleTexture *ptex,
|
|
|
|
|
int event,
|
|
|
|
|
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
|
|
|
{
|
2011-02-12 14:38:34 +00:00
|
|
|
MTex *mtex, **mtexp = part->mtex;
|
2011-02-13 02:55:23 +00:00
|
|
|
int m;
|
2011-02-12 14:38:34 +00:00
|
|
|
float value, rgba[4], texvec[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = ptex->gravity = ptex->field =
|
2015-01-14 12:29:19 +01:00
|
|
|
ptex->time = ptex->clump = ptex->kink_freq = ptex->kink_amp = ptex->effector = ptex->rough1 =
|
2012-11-18 02:41:55 +00:00
|
|
|
ptex->rough2 = ptex->roughe = 1.0f;
|
2018-02-14 16:46:29 +01:00
|
|
|
ptex->twist = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
ptex->length = 1.0f - part->randlength * psys_frand(psys, child_index + 26);
|
|
|
|
|
ptex->length *= part->clength_thres < psys_frand(psys, child_index + 27) ? part->clength : 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (m = 0; m < MAX_MTEX; m++, mtexp++) {
|
2011-02-12 14:38:34 +00:00
|
|
|
mtex = *mtexp;
|
2013-08-08 18:12:07 +00:00
|
|
|
if (mtex && mtex->tex && mtex->mapto) {
|
2012-05-06 15:15:33 +00:00
|
|
|
float def = mtex->def_var;
|
|
|
|
|
short blend = mtex->blendtype;
|
2011-02-12 14:38:34 +00:00
|
|
|
short texco = mtex->texco;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) &&
|
|
|
|
|
(ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 ||
|
2019-04-22 09:39:35 +10:00
|
|
|
part->distr == PART_DISTR_GRID)) {
|
2011-02-12 14:38:34 +00:00
|
|
|
texco = TEXCO_GLOB;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (texco) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case TEXCO_GLOB:
|
|
|
|
|
copy_v3_v3(texvec, par->state.co);
|
2011-02-12 14:38:34 +00:00
|
|
|
break;
|
2012-05-06 15:15:33 +00:00
|
|
|
case TEXCO_OBJECT:
|
|
|
|
|
copy_v3_v3(texvec, par->state.co);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (mtex->object) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_m4_v3(mtex->object->imat, texvec);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
|
|
|
|
case TEXCO_UV:
|
2018-05-15 13:26:40 +02:00
|
|
|
if (fw && get_particle_uv(mesh,
|
|
|
|
|
NULL,
|
|
|
|
|
face_index,
|
|
|
|
|
fw,
|
|
|
|
|
mtex->uvname,
|
2017-07-05 12:23:42 +02:00
|
|
|
texvec,
|
|
|
|
|
(part->from == PART_FROM_VERT))) {
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
2017-07-05 12:23:42 +02:00
|
|
|
}
|
2017-05-20 14:01:03 +10:00
|
|
|
/* no break, failed to get uv's, so let's try orco's */
|
|
|
|
|
ATTR_FALLTHROUGH;
|
2012-05-06 15:15:33 +00:00
|
|
|
case TEXCO_ORCO:
|
|
|
|
|
copy_v3_v3(texvec, orco);
|
|
|
|
|
break;
|
|
|
|
|
case TEXCO_PARTICLE:
|
|
|
|
|
/* texture coordinates in range [-1, 1] */
|
2020-11-06 11:25:27 +11:00
|
|
|
texvec[0] = 2.0f * (cfra - par->time) / (par->dietime - par->time) - 1.0f;
|
|
|
|
|
texvec[1] = 0.0f;
|
|
|
|
|
texvec[2] = 0.0f;
|
2012-05-06 15:15:33 +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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-01 14:03:12 +10:00
|
|
|
RE_texture_evaluate(mtex, texvec, 0, NULL, false, false, &value, rgba);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((event & mtex->mapto) & PAMAP_ROUGH) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend(
|
|
|
|
|
def, ptex->rough1, value, mtex->roughfac, blend);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac);
|
2015-01-14 12:29:19 +01:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_KINK_AMP, ptex->kink_amp, mtex->kinkampfac);
|
2015-01-14 12:03:55 +01:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_KINK_FREQ, ptex->kink_freq, mtex->kinkfac);
|
2011-02-12 14:38:34 +00:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
|
2018-02-15 11:22:44 +01:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_TWIST, ptex->twist, mtex->twistfac);
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length);
|
2016-01-11 17:01:09 +01:00
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_CLUMP, ptex->clump);
|
|
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_KINK_AMP, ptex->kink_amp);
|
|
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_KINK_FREQ, ptex->kink_freq);
|
|
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_ROUGH, ptex->rough1);
|
|
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist);
|
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-02-14 16:40:57 +01:00
|
|
|
void psys_get_texture(
|
|
|
|
|
ParticleSimulationData *sim, ParticleData *pa, ParticleTexture *ptex, int event, 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
|
|
|
{
|
2014-07-08 13:44:58 +02:00
|
|
|
Object *ob = sim->ob;
|
|
|
|
|
Mesh *me = (Mesh *)ob->data;
|
2011-02-12 14:38:34 +00:00
|
|
|
ParticleSettings *part = sim->psys->part;
|
|
|
|
|
MTex **mtexp = part->mtex;
|
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
|
|
|
MTex *mtex;
|
|
|
|
|
int m;
|
2011-02-12 14:38:34 +00:00
|
|
|
float value, rgba[4], co[3], texvec[3];
|
2012-05-06 15:15:33 +00:00
|
|
|
int setvars = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
/* initialize ptex */
|
|
|
|
|
ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = ptex->gravity = ptex->field =
|
2015-01-14 12:29:19 +01:00
|
|
|
ptex->length = ptex->clump = ptex->kink_freq = ptex->kink_amp = ptex->effector =
|
2012-05-06 15:15:33 +00:00
|
|
|
ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f;
|
2018-02-14 16:46:29 +01:00
|
|
|
ptex->twist = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ptex->time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (m = 0; m < MAX_MTEX; m++, mtexp++) {
|
2011-02-12 14:38:34 +00:00
|
|
|
mtex = *mtexp;
|
2013-08-08 18:12:07 +00:00
|
|
|
if (mtex && mtex->tex && mtex->mapto) {
|
2012-05-06 15:15:33 +00:00
|
|
|
float def = mtex->def_var;
|
|
|
|
|
short blend = mtex->blendtype;
|
2011-02-12 14:38:34 +00:00
|
|
|
short texco = mtex->texco;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 ||
|
2019-04-22 09:39:35 +10:00
|
|
|
part->distr == PART_DISTR_GRID)) {
|
2011-02-12 14:38:34 +00:00
|
|
|
texco = TEXCO_GLOB;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (texco) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case TEXCO_GLOB:
|
|
|
|
|
copy_v3_v3(texvec, pa->state.co);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2012-05-06 15:15:33 +00:00
|
|
|
case TEXCO_OBJECT:
|
|
|
|
|
copy_v3_v3(texvec, pa->state.co);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (mtex->object) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_m4_v3(mtex->object->imat, texvec);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-02-12 14:38:34 +00:00
|
|
|
break;
|
2019-06-21 11:49:43 +02:00
|
|
|
case TEXCO_UV:
|
|
|
|
|
if (get_particle_uv(sim->psmd->mesh_final,
|
2018-05-15 13:26:40 +02:00
|
|
|
pa,
|
|
|
|
|
0,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
mtex->uvname,
|
2017-07-05 12:23:42 +02:00
|
|
|
texvec,
|
|
|
|
|
(part->from == PART_FROM_VERT))) {
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
2017-07-05 12:23:42 +02:00
|
|
|
}
|
2017-05-20 14:01:03 +10:00
|
|
|
/* no break, failed to get uv's, so let's try orco's */
|
|
|
|
|
ATTR_FALLTHROUGH;
|
2012-05-06 15:15:33 +00:00
|
|
|
case TEXCO_ORCO:
|
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,
|
|
|
|
|
sim->psys->part->from,
|
|
|
|
|
pa->num,
|
|
|
|
|
pa->num_dmcache,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
pa->foffset,
|
|
|
|
|
co,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
texvec);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-23 15:31:11 +02:00
|
|
|
BKE_mesh_texspace_ensure(me);
|
2014-07-08 13:44:58 +02:00
|
|
|
sub_v3_v3(texvec, me->loc);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (me->size[0] != 0.0f) {
|
2014-07-08 13:44:58 +02:00
|
|
|
texvec[0] /= me->size[0];
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (me->size[1] != 0.0f) {
|
2014-07-08 13:44:58 +02:00
|
|
|
texvec[1] /= me->size[1];
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (me->size[2] != 0.0f) {
|
2014-07-08 13:44:58 +02:00
|
|
|
texvec[2] /= me->size[2];
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
break;
|
|
|
|
|
case TEXCO_PARTICLE:
|
|
|
|
|
/* texture coordinates in range [-1, 1] */
|
2020-11-06 11:25:27 +11:00
|
|
|
texvec[0] = 2.0f * (cfra - pa->time) / (pa->dietime - pa->time) - 1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (sim->psys->totpart > 0) {
|
2020-11-06 11:25:27 +11:00
|
|
|
texvec[1] = 2.0f * (float)(pa - sim->psys->particles) / (float)sim->psys->totpart -
|
|
|
|
|
1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-08-07 10:54:50 +00:00
|
|
|
texvec[1] = 0.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-11-06 11:25:27 +11:00
|
|
|
texvec[2] = 0.0f;
|
2012-05-06 15:15:33 +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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-01 14:03:12 +10:00
|
|
|
RE_texture_evaluate(mtex, texvec, 0, NULL, false, false, &value, rgba);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((event & mtex->mapto) & PAMAP_TIME) {
|
2008-02-12 16:36:03 +00:00
|
|
|
/* the first time has to set the base value for time regardless of blend mode */
|
2012-05-06 15:15:33 +00:00
|
|
|
if ((setvars & MAP_PA_TIME) == 0) {
|
|
|
|
|
int flip = (mtex->timefac < 0.0f);
|
|
|
|
|
float timefac = fabsf(mtex->timefac);
|
2009-10-22 23:22:05 +00:00
|
|
|
ptex->time *= 1.0f - timefac;
|
2012-05-06 15:15:33 +00:00
|
|
|
ptex->time += timefac * ((flip) ? 1.0f - value : value);
|
2008-02-12 16:36:03 +00:00
|
|
|
setvars |= MAP_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
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
ptex->time = texture_value_blend(def, ptex->time, value, mtex->timefac, blend);
|
2019-04-22 09:39:35 +10: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-05-27 12:21:13 +00:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_SIZE, ptex->size, mtex->sizefac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_IVEL, ptex->ivel, mtex->ivelfac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_FIELD, ptex->field, mtex->fieldfac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_GRAVITY, ptex->gravity, mtex->gravityfac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_DAMP, ptex->damp, mtex->dampfac);
|
|
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
|
2018-02-15 11:22:44 +01:00
|
|
|
SET_PARTICLE_TEXTURE(PAMAP_TWIST, ptex->twist, mtex->twistfac);
|
2012-05-27 12:21:13 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-11 17:01:09 +01:00
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_TIME, ptex->time);
|
|
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_LIFE, ptex->life);
|
|
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist);
|
2012-05-27 12:21:13 +00:00
|
|
|
CLAMP_PARTICLE_TEXTURE_POS(PAMAP_SIZE, ptex->size);
|
|
|
|
|
CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_IVEL, ptex->ivel);
|
|
|
|
|
CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_FIELD, ptex->field);
|
|
|
|
|
CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_GRAVITY, ptex->gravity);
|
2016-01-11 17:01:09 +01:00
|
|
|
CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_DAMP, ptex->damp);
|
2012-05-27 12:21:13 +00:00
|
|
|
CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length);
|
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
|
|
|
}
|
|
|
|
|
/************************************************/
|
|
|
|
|
/* Particle State */
|
|
|
|
|
/************************************************/
|
2009-10-22 23:22:05 +00:00
|
|
|
float psys_get_timestep(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-10-22 23:22:05 +00:00
|
|
|
return 0.04f * sim->psys->part->timetweak;
|
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-04 03:50:12 +00:00
|
|
|
float psys_get_child_time(
|
|
|
|
|
ParticleSystem *psys, ChildParticle *cpa, float cfra, float *birthtime, float *dietime)
|
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-04 03:50:12 +00:00
|
|
|
float time, life;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (part->childtype == PART_CHILD_FACES) {
|
|
|
|
|
int w = 0;
|
|
|
|
|
time = 0.0;
|
|
|
|
|
while (w < 4 && cpa->pa[w] >= 0) {
|
|
|
|
|
time += cpa->w[w] * (psys->particles + cpa->pa[w])->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
|
|
|
w++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
life = part->lifetime * (1.0f - part->randlife * psys_frand(psys, cpa - psys->child + 25));
|
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 {
|
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 = psys->particles + cpa->parent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-04 03:50:12 +00:00
|
|
|
time = pa->time;
|
|
|
|
|
life = 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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (birthtime) {
|
2009-07-04 03:50:12 +00:00
|
|
|
*birthtime = time;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (dietime) {
|
2012-05-06 15:15:33 +00:00
|
|
|
*dietime = time + life;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
return (cfra - time) / life;
|
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-10-16 14:32:17 +00:00
|
|
|
float psys_get_child_size(ParticleSystem *psys,
|
|
|
|
|
ChildParticle *cpa,
|
|
|
|
|
float UNUSED(cfra),
|
|
|
|
|
float *UNUSED(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
|
|
|
{
|
|
|
|
|
ParticleSettings *part = psys->part;
|
2009-01-17 14:56:12 +00:00
|
|
|
float size; /* time XXX */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-18 10:52:27 +02:00
|
|
|
if (part->childtype == PART_CHILD_FACES) {
|
|
|
|
|
int w = 0;
|
|
|
|
|
size = 0.0;
|
|
|
|
|
while (w < 4 && cpa->pa[w] >= 0) {
|
|
|
|
|
size += cpa->w[w] * (psys->particles + cpa->pa[w])->size;
|
|
|
|
|
w++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
size = psys->particles[cpa->parent].size;
|
2018-04-18 10:52:27 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
size *= part->childsize;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (part->childrandsize != 0.0f) {
|
2014-03-07 10:25:56 +01:00
|
|
|
size *= 1.0f - part->childrandsize * psys_frand(psys, cpa - psys->child + 26);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
return size;
|
|
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
static void get_child_modifier_parameters(ParticleSettings *part,
|
|
|
|
|
ParticleThreadContext *ctx,
|
|
|
|
|
ChildParticle *cpa,
|
|
|
|
|
short cpa_from,
|
|
|
|
|
int cpa_num,
|
|
|
|
|
float *cpa_fuv,
|
|
|
|
|
float *orco,
|
|
|
|
|
ParticleTexture *ptex)
|
|
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
ParticleSystem *psys = ctx->sim.psys;
|
|
|
|
|
int i = cpa - psys->child;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
get_cpa_texture(ctx->mesh,
|
|
|
|
|
psys,
|
|
|
|
|
part,
|
|
|
|
|
psys->particles + cpa->pa[0],
|
|
|
|
|
i,
|
|
|
|
|
cpa_num,
|
|
|
|
|
cpa_fuv,
|
|
|
|
|
orco,
|
|
|
|
|
ptex,
|
|
|
|
|
PAMAP_DENS | PAMAP_CHILD,
|
|
|
|
|
psys->cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ptex->exist < psys_frand(psys, i + 24)) {
|
2009-07-04 03:50:12 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ctx->vg_length) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->length *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_length);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_clump) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->clump *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_kink) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->kink_freq *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_rough1) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->rough1 *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_rough2) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->rough2 *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_roughe) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->roughe *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_effector) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->effector *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (ctx->vg_twist) {
|
2018-05-15 13:26:40 +02:00
|
|
|
ptex->twist *= psys_interpolate_value_from_verts(
|
|
|
|
|
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_twist);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2019-08-01 13:53:25 +10:00
|
|
|
/* gets hair (or keyed) particles state at the "path time" specified in state->time */
|
2014-04-01 11:34:00 +11:00
|
|
|
void psys_get_particle_on_path(ParticleSimulationData *sim,
|
|
|
|
|
int p,
|
|
|
|
|
ParticleKey *state,
|
|
|
|
|
const bool 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
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
PARTICLE_PSMD;
|
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
|
ParticleSettings *part = sim->psys->part;
|
2020-02-05 11:23:58 +01:00
|
|
|
Material *ma = BKE_object_material_get(sim->ob, part->omat);
|
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;
|
|
|
|
|
ChildParticle *cpa;
|
|
|
|
|
ParticleTexture ptex;
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleKey *par = 0, keys[4], tstate;
|
2009-07-04 03:50:12 +00:00
|
|
|
ParticleThreadContext ctx; /* fake thread context for child modifiers */
|
2009-07-12 23:38:47 +00:00
|
|
|
ParticleInterpolationData pind;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-02-06 15:50:00 +00:00
|
|
|
float t;
|
2007-12-05 12:40:54 +00:00
|
|
|
float co[3], orco[3];
|
2008-01-17 23:38:53 +00:00
|
|
|
float hairmat[4][4];
|
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
|
|
|
int totpart = psys->totpart;
|
|
|
|
|
int totchild = psys->totchild;
|
|
|
|
|
short between = 0, edit = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
int keyed = part->phystype & PART_PHYS_KEYED && psys->flag & PSYS_KEYED;
|
2009-07-04 03:50:12 +00:00
|
|
|
int cached = !keyed && part->type != PART_HAIR;
|
2019-04-17 06:17:24 +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
|
|
|
float *cpa_fuv;
|
|
|
|
|
int cpa_num;
|
|
|
|
|
short cpa_from;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-27 12:21:14 +00:00
|
|
|
/* initialize keys to zero */
|
2020-08-08 13:29:21 +10:00
|
|
|
memset(keys, 0, sizeof(ParticleKey[4]));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
t = state->time;
|
2011-03-28 11:21:39 +00:00
|
|
|
CLAMP(t, 0.0f, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (p < totpart) {
|
2012-02-12 00:25:52 +00:00
|
|
|
/* interpolate pathcache directly if it exist */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->pathcache) {
|
2012-02-12 00:25:52 +00:00
|
|
|
ParticleCacheKey result;
|
|
|
|
|
interpolate_pathcache(psys->pathcache[p], t, &result);
|
|
|
|
|
copy_v3_v3(state->co, result.co);
|
|
|
|
|
copy_v3_v3(state->vel, result.vel);
|
|
|
|
|
copy_qt_qt(state->rot, result.rot);
|
2011-06-03 05:51:39 +00:00
|
|
|
}
|
2012-02-12 00:25:52 +00:00
|
|
|
/* otherwise interpolate with other means */
|
|
|
|
|
else {
|
|
|
|
|
pa = psys->particles + p;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
pind.keyed = keyed;
|
|
|
|
|
pind.cache = cached ? psys->pointcache : NULL;
|
|
|
|
|
pind.epoint = NULL;
|
|
|
|
|
pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE);
|
2012-03-18 07:38:51 +00:00
|
|
|
/* pind.dm disabled in editmode means we don't get effectors taken into
|
2012-02-12 00:25:52 +00:00
|
|
|
* account when subdividing for instance */
|
2018-05-15 13:26:40 +02:00
|
|
|
pind.mesh = psys_in_edit_mode(sim->depsgraph, psys) ?
|
|
|
|
|
NULL :
|
|
|
|
|
psys->hair_out_mesh; /* XXX Sybren EEK */
|
2012-02-12 00:25:52 +00:00
|
|
|
init_particle_interpolation(sim->ob, psys, pa, &pind);
|
|
|
|
|
do_particle_interpolation(psys, p, pa, t, &pind, state);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
if (pind.mesh) {
|
2012-02-12 00:25:52 +00:00
|
|
|
mul_m4_v3(sim->ob->obmat, state->co);
|
|
|
|
|
mul_mat3_m4_v3(sim->ob->obmat, state->vel);
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if ((pa->flag & PARS_REKEY) == 0) {
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(sim->ob, sim->psmd->mesh_final, part->from, pa, hairmat);
|
2012-02-12 00:25:52 +00:00
|
|
|
mul_m4_v3(hairmat, state->co);
|
|
|
|
|
mul_mat3_m4_v3(hairmat, state->vel);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) {
|
2018-04-06 12:07:27 +02:00
|
|
|
do_guides(
|
|
|
|
|
sim->depsgraph, sim->psys->part, sim->psys->effectors, state, p, state->time);
|
2012-02-12 00:25:52 +00:00
|
|
|
/* TODO: proper velocity handling */
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->lattice_deform_data && edit == 0) {
|
2020-06-13 15:41:34 +10:00
|
|
|
BKE_lattice_deform_data_eval_co(
|
|
|
|
|
psys->lattice_deform_data, state->co, psys->lattice_strength);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-12 00:25:52 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (totchild) {
|
2019-05-01 11:09:22 +10:00
|
|
|
// invert_m4_m4(imat, ob->obmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* interpolate childcache directly if it exists */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->childcache) {
|
2012-02-12 00:25:52 +00:00
|
|
|
ParticleCacheKey result;
|
2012-05-06 15:15:33 +00:00
|
|
|
interpolate_pathcache(psys->childcache[p - totpart], t, &result);
|
2012-02-12 00:25:52 +00:00
|
|
|
copy_v3_v3(state->co, result.co);
|
|
|
|
|
copy_v3_v3(state->vel, result.vel);
|
|
|
|
|
copy_qt_qt(state->rot, result.rot);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-01-12 16:03:12 +01:00
|
|
|
float par_co[3], par_orco[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
cpa = psys->child + p - totpart;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (state->time < 0.0f) {
|
2012-02-12 00:25:52 +00:00
|
|
|
t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-20 22:40:07 +05:30
|
|
|
if (part->childtype == PART_CHILD_FACES) {
|
2012-02-12 00:25:52 +00:00
|
|
|
/* part->parents could still be 0 so we can't test with totparent */
|
2012-05-06 15:15:33 +00:00
|
|
|
between = 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 (between) {
|
2012-02-12 00:25:52 +00:00
|
|
|
int w = 0;
|
|
|
|
|
float foffset;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* get parent states */
|
2012-05-06 15:15:33 +00:00
|
|
|
while (w < 4 && cpa->pa[w] >= 0) {
|
2012-02-12 00:25:52 +00:00
|
|
|
keys[w].time = state->time;
|
2012-05-06 15:15:33 +00:00
|
|
|
psys_get_particle_on_path(sim, cpa->pa[w], keys + w, 1);
|
2012-02-12 00:25:52 +00:00
|
|
|
w++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* get the original coordinates (orco) for texture usage */
|
2012-05-06 15:15:33 +00:00
|
|
|
cpa_num = cpa->num;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
foffset = cpa->foffset;
|
2012-02-12 00:25:52 +00:00
|
|
|
cpa_fuv = cpa->fuv;
|
|
|
|
|
cpa_from = PART_FROM_FACE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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(
|
|
|
|
|
psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* We need to save the actual root position of the child for
|
|
|
|
|
* positioning it accurately to the surface of the emitter. */
|
2019-05-01 11:09:22 +10:00
|
|
|
// copy_v3_v3(cpa_1st, co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-01 11:09:22 +10:00
|
|
|
// mul_m4_v3(ob->obmat, cpa_1st);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
pa = psys->particles + cpa->parent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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(psmd,
|
|
|
|
|
part->from,
|
|
|
|
|
pa->num,
|
|
|
|
|
pa->num_dmcache,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
pa->foffset,
|
|
|
|
|
par_co,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
par_orco);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (part->type == PART_HAIR) {
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-02-12 00:25:52 +00:00
|
|
|
unit_m4(hairmat);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
pa = 0;
|
2012-02-12 00:25:52 +00:00
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
else {
|
|
|
|
|
/* get the parent state */
|
|
|
|
|
keys->time = state->time;
|
|
|
|
|
psys_get_particle_on_path(sim, cpa->parent, keys, 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
/* get the original coordinates (orco) for texture usage */
|
2012-05-06 15:15:33 +00:00
|
|
|
pa = psys->particles + cpa->parent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
cpa_from = part->from;
|
|
|
|
|
cpa_num = pa->num;
|
|
|
|
|
cpa_fuv = pa->fuv;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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(psmd,
|
|
|
|
|
part->from,
|
|
|
|
|
pa->num,
|
|
|
|
|
pa->num_dmcache,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
pa->foffset,
|
|
|
|
|
par_co,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
par_orco);
|
2012-04-29 15:47:02 +00:00
|
|
|
if (part->type == PART_HAIR) {
|
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(
|
|
|
|
|
psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, 0, 0, 0, orco);
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat);
|
2012-04-29 15:47:02 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(orco, cpa->fuv);
|
|
|
|
|
unit_m4(hairmat);
|
2010-12-08 11:02:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* get different child parameters from textures & vgroups */
|
|
|
|
|
memset(&ctx, 0, sizeof(ParticleThreadContext));
|
|
|
|
|
ctx.sim = *sim;
|
2019-06-21 11:49:43 +02:00
|
|
|
ctx.mesh = psmd->mesh_final;
|
2012-02-12 00:25:52 +00:00
|
|
|
ctx.ma = ma;
|
|
|
|
|
/* TODO: assign vertex groups */
|
|
|
|
|
get_child_modifier_parameters(part, &ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (between) {
|
2012-05-06 15:15:33 +00:00
|
|
|
int w = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
state->co[0] = state->co[1] = state->co[2] = 0.0f;
|
|
|
|
|
state->vel[0] = state->vel[1] = state->vel[2] = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* child position is the weighted sum of parent positions */
|
2012-05-06 15:15:33 +00:00
|
|
|
while (w < 4 && cpa->pa[w] >= 0) {
|
2012-02-12 00:25:52 +00:00
|
|
|
state->co[0] += cpa->w[w] * keys[w].co[0];
|
|
|
|
|
state->co[1] += cpa->w[w] * keys[w].co[1];
|
|
|
|
|
state->co[2] += cpa->w[w] * keys[w].co[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
state->vel[0] += cpa->w[w] * keys[w].vel[0];
|
|
|
|
|
state->vel[1] += cpa->w[w] * keys[w].vel[1];
|
|
|
|
|
state->vel[2] += cpa->w[w] * keys[w].vel[2];
|
|
|
|
|
w++;
|
|
|
|
|
}
|
|
|
|
|
/* apply offset for correct positioning */
|
2019-05-01 11:09:22 +10:00
|
|
|
// add_v3_v3(state->co, cpa_1st);
|
2012-02-12 00:25:52 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-02-12 00:25:52 +00:00
|
|
|
/* offset the child from the parent position */
|
|
|
|
|
offset_child(cpa, keys, keys->rot, state, part->childflat, part->childrad);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
par = keys;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (vel) {
|
2012-02-12 00:25:52 +00:00
|
|
|
copy_particle_key(&tstate, state, 1);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* apply different deformations to the child path */
|
2018-02-14 12:33:34 +01:00
|
|
|
ParticleChildModifierContext modifier_ctx = {NULL};
|
|
|
|
|
modifier_ctx.thread_ctx = NULL;
|
|
|
|
|
modifier_ctx.sim = sim;
|
|
|
|
|
modifier_ctx.ptex = &ptex;
|
|
|
|
|
modifier_ctx.cpa = cpa;
|
|
|
|
|
modifier_ctx.orco = orco;
|
|
|
|
|
modifier_ctx.par_co = par->co;
|
|
|
|
|
modifier_ctx.par_vel = par->vel;
|
|
|
|
|
modifier_ctx.par_rot = par->rot;
|
|
|
|
|
modifier_ctx.par_orco = par_orco;
|
2018-02-14 14:33:53 +01:00
|
|
|
modifier_ctx.parent_keys = psys->childcache ? psys->childcache[p - totpart] : NULL;
|
2018-02-14 12:33:34 +01:00
|
|
|
do_child_modifiers(&modifier_ctx, hairmat, state, t);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
/* try to estimate correct velocity */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (vel) {
|
2015-11-23 11:27:02 +11:00
|
|
|
ParticleKey tstate_tmp;
|
2012-02-12 00:25:52 +00:00
|
|
|
float length = len_v3(state->vel);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (t >= 0.001f) {
|
2015-11-23 11:27:02 +11:00
|
|
|
tstate_tmp.time = t - 0.001f;
|
|
|
|
|
psys_get_particle_on_path(sim, p, &tstate_tmp, 0);
|
|
|
|
|
sub_v3_v3v3(state->vel, state->co, tstate_tmp.co);
|
2012-02-12 00:25:52 +00:00
|
|
|
normalize_v3(state->vel);
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2015-11-23 11:27:02 +11:00
|
|
|
tstate_tmp.time = t + 0.001f;
|
|
|
|
|
psys_get_particle_on_path(sim, p, &tstate_tmp, 0);
|
|
|
|
|
sub_v3_v3v3(state->vel, tstate_tmp.co, state->co);
|
2012-02-12 00:25:52 +00:00
|
|
|
normalize_v3(state->vel);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-12 00:25:52 +00:00
|
|
|
mul_v3_fl(state->vel, length);
|
|
|
|
|
}
|
2009-07-04 03:50: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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* gets particle's state at a time, returns 1 if particle exists and can be seen and 0 if not */
|
2011-12-30 07:55:15 +00:00
|
|
|
int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *state, int always)
|
|
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
ParticleData *pa = NULL;
|
|
|
|
|
ChildParticle *cpa = 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
|
|
|
float cfra;
|
2009-10-22 23:22:05 +00:00
|
|
|
int totpart = psys->totpart;
|
|
|
|
|
float timestep = psys_get_timestep(sim);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-09-23 12:53:00 +00:00
|
|
|
/* negative time means "use current time" */
|
2018-05-16 16:09:48 +02:00
|
|
|
cfra = state->time > 0 ? state->time : DEG_get_ctime(sim->depsgraph);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (p >= totpart) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!psys->totchild) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->childtype == PART_CHILD_FACES) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(psys->flag & PSYS_KEYED)) {
|
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 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
cpa = psys->child + p - totpart;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
state->time = psys_get_child_time(psys, cpa, cfra, NULL, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-21 15:11:03 +00:00
|
|
|
if (!always) {
|
|
|
|
|
if ((state->time < 0.0f && !(part->flag & PART_UNBORN)) ||
|
|
|
|
|
(state->time > 1.0f && !(part->flag & PART_DIED))) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
state->time = (cfra - (part->sta + (part->end - part->sta) * psys_frand(psys, p + 23))) /
|
|
|
|
|
(part->lifetime * psys_frand(psys, p + 24));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
psys_get_particle_on_path(sim, p, state, 1);
|
2009-10-22 23:22:05 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
cpa = sim->psys->child + p - totpart;
|
|
|
|
|
pa = sim->psys->particles + cpa->parent;
|
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-22 23:22:05 +00:00
|
|
|
else {
|
|
|
|
|
pa = sim->psys->particles + p;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pa) {
|
2012-04-21 15:11:03 +00:00
|
|
|
if (!always) {
|
|
|
|
|
if ((cfra < pa->time && (part->flag & PART_UNBORN) == 0) ||
|
2012-10-18 15:00:32 +00:00
|
|
|
(cfra >= pa->dietime && (part->flag & PART_DIED) == 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
|
|
|
return 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-04-21 15:11:03 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-12-15 17:05:34 +00:00
|
|
|
cfra = MIN2(cfra, pa->dietime);
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sim->psys->flag & PSYS_KEYED) {
|
2012-05-06 15:15:33 +00:00
|
|
|
state->time = -cfra;
|
2012-04-29 15:47:02 +00:00
|
|
|
psys_get_particle_on_path(sim, p, state, 1);
|
2008-01-17 00:28:14 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
if (cpa) {
|
|
|
|
|
float mat[4][4];
|
|
|
|
|
ParticleKey *key1;
|
|
|
|
|
float t = (cfra - pa->time) / pa->lifetime;
|
2020-08-07 22:36:11 +10:00
|
|
|
const float par_orco[3] = {0.0f, 0.0f, 0.0f};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
key1 = &pa->state;
|
|
|
|
|
offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
CLAMP(t, 0.0f, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
unit_m4(mat);
|
|
|
|
|
ParticleChildModifierContext modifier_ctx = {NULL};
|
|
|
|
|
modifier_ctx.thread_ctx = NULL;
|
|
|
|
|
modifier_ctx.sim = sim;
|
|
|
|
|
modifier_ctx.ptex = NULL;
|
|
|
|
|
modifier_ctx.cpa = cpa;
|
|
|
|
|
modifier_ctx.orco = cpa->fuv;
|
|
|
|
|
modifier_ctx.par_co = key1->co;
|
|
|
|
|
modifier_ctx.par_vel = key1->vel;
|
|
|
|
|
modifier_ctx.par_rot = key1->rot;
|
|
|
|
|
modifier_ctx.par_orco = par_orco;
|
|
|
|
|
modifier_ctx.parent_keys = psys->childcache ? psys->childcache[p - totpart] : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
do_child_modifiers(&modifier_ctx, mat, state, t);
|
|
|
|
|
|
|
|
|
|
if (psys->lattice_deform_data) {
|
|
|
|
|
BKE_lattice_deform_data_eval_co(
|
|
|
|
|
psys->lattice_deform_data, state->co, psys->lattice_strength);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
|
|
|
|
|
copy_particle_key(state, &pa->state, 1);
|
|
|
|
|
}
|
|
|
|
|
else if (pa->prev_state.time == cfra) {
|
|
|
|
|
copy_particle_key(state, &pa->prev_state, 1);
|
2008-02-17 18:33:20 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2020-08-07 12:30:43 +02:00
|
|
|
float dfra, frs_sec = sim->scene->r.frs_sec;
|
|
|
|
|
/* let's interpolate to try to be as accurate as possible */
|
2020-11-06 11:25:27 +11:00
|
|
|
if (pa->state.time + 2.0f >= state->time && pa->prev_state.time - 2.0f <= state->time) {
|
|
|
|
|
if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.0f) {
|
2020-08-07 12:30:43 +02:00
|
|
|
/* prev_state is wrong so let's not use it,
|
|
|
|
|
* this can happen at frames 1, 0 or particle birth. */
|
|
|
|
|
dfra = state->time - pa->state.time;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
copy_particle_key(state, &pa->state, 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ParticleKey keys[4];
|
|
|
|
|
float keytime;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
copy_particle_key(keys + 1, &pa->prev_state, 1);
|
|
|
|
|
copy_particle_key(keys + 2, &pa->state, 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
dfra = keys[2].time - keys[1].time;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
keytime = (state->time - keys[1].time) / dfra;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
/* convert velocity to timestep size */
|
|
|
|
|
mul_v3_fl(keys[1].vel, dfra * timestep);
|
|
|
|
|
mul_v3_fl(keys[2].vel, dfra * timestep);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
psys_interpolate_particle(-1, keys, keytime, state, 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
/* convert back to real velocity */
|
2020-11-06 11:25:27 +11:00
|
|
|
mul_v3_fl(state->vel, 1.0f / (dfra * timestep));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime);
|
|
|
|
|
interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime);
|
2008-09-23 12:53:00 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
}
|
2020-11-06 11:25:27 +11:00
|
|
|
else if (pa->state.time + 1.0f >= state->time && pa->state.time - 1.0f <= state->time) {
|
2020-08-07 12:30:43 +02:00
|
|
|
/* linear interpolation using only pa->state */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
dfra = state->time - pa->state.time;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
copy_particle_key(state, &pa->state, 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
|
2009-07-12 23:38:47 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
else {
|
|
|
|
|
/* Extrapolating over big ranges is not accurate
|
|
|
|
|
* so let's just give something close to reasonable back. */
|
|
|
|
|
copy_particle_key(state, &pa->state, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-02-17 18:33:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-07 12:30:43 +02:00
|
|
|
if (sim->psys->lattice_deform_data) {
|
|
|
|
|
BKE_lattice_deform_data_eval_co(
|
|
|
|
|
sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
|
|
|
|
|
}
|
2008-01-17 00:28:14 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return 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-10-20 08:02:18 +00:00
|
|
|
void psys_get_dupli_texture(ParticleSystem *psys,
|
|
|
|
|
ParticleSettings *part,
|
|
|
|
|
ParticleSystemModifierData *psmd,
|
|
|
|
|
ParticleData *pa,
|
|
|
|
|
ChildParticle *cpa,
|
|
|
|
|
float uv[2],
|
|
|
|
|
float orco[3])
|
2008-01-09 14:40:25 +00:00
|
|
|
{
|
|
|
|
|
MFace *mface;
|
|
|
|
|
float loc[3];
|
|
|
|
|
int num;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-11-02 22:59:46 +11:00
|
|
|
/* XXX: on checking '(psmd->dm != NULL)'
|
2020-06-25 23:13:02 +10:00
|
|
|
* This is incorrect but needed for meta-ball evaluation.
|
2020-06-05 14:34:00 +10:00
|
|
|
* Ideally this would be calculated via the depsgraph, however with meta-balls,
|
2015-11-02 22:59:46 +11:00
|
|
|
* the entire scenes dupli's are scanned, which also looks into uncalculated data.
|
|
|
|
|
*
|
|
|
|
|
* For now just include this workaround as an alternative to crashing,
|
2020-06-05 14:34:00 +10:00
|
|
|
* but longer term meta-balls should behave in a more manageable way, see: T46622. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-02 11:42:36 +02:00
|
|
|
uv[0] = uv[1] = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-08-07 13:48:25 +03:00
|
|
|
/* Grid distribution doesn't support UV or emit from vertex mode */
|
|
|
|
|
bool is_grid = (part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cpa) {
|
2019-06-21 11:49:43 +02:00
|
|
|
if ((part->childtype == PART_CHILD_FACES) && (psmd->mesh_final != NULL)) {
|
2020-10-02 11:42:36 +02:00
|
|
|
if (!is_grid) {
|
|
|
|
|
CustomData *mtf_data = &psmd->mesh_final->fdata;
|
|
|
|
|
const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
|
|
|
|
|
|
|
|
|
|
if (uv_idx >= 0) {
|
|
|
|
|
MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
|
|
|
|
|
if (mtface != NULL) {
|
|
|
|
|
mface = CustomData_get(&psmd->mesh_final->fdata, cpa->num, CD_MFACE);
|
|
|
|
|
mtface += cpa->num;
|
|
|
|
|
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-01-09 14:40:25 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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(psmd,
|
|
|
|
|
PART_FROM_FACE,
|
|
|
|
|
cpa->num,
|
|
|
|
|
DMCACHE_ISCHILD,
|
|
|
|
|
cpa->fuv,
|
|
|
|
|
cpa->foffset,
|
|
|
|
|
loc,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
orco);
|
2011-03-09 14:18:33 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
pa = psys->particles + cpa->pa[0];
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-21 11:49:43 +02:00
|
|
|
if ((part->from == PART_FROM_FACE) && (psmd->mesh_final != NULL) && !is_grid) {
|
2012-05-06 15:15:33 +00:00
|
|
|
num = pa->num_dmcache;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (num == DMCACHE_NOTFOUND) {
|
2012-05-06 15:15:33 +00:00
|
|
|
num = pa->num;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-21 11:49:43 +02:00
|
|
|
if (num >= psmd->mesh_final->totface) {
|
2011-03-09 14:18:33 +00:00
|
|
|
/* happens when simplify is enabled
|
2012-03-03 20:19:11 +00:00
|
|
|
* gives invalid coords but would crash otherwise */
|
2012-05-06 15:15:33 +00:00
|
|
|
num = DMCACHE_NOTFOUND;
|
2008-01-09 14:40:25 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-02 11:42:36 +02:00
|
|
|
if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
|
|
|
|
|
CustomData *mtf_data = &psmd->mesh_final->fdata;
|
|
|
|
|
const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
|
|
|
|
|
|
|
|
|
|
if (uv_idx >= 0) {
|
|
|
|
|
MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
|
|
|
|
|
mface = CustomData_get(&psmd->mesh_final->fdata, num, CD_MFACE);
|
|
|
|
|
mtface += num;
|
|
|
|
|
psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
|
|
|
|
|
}
|
2011-03-09 14:18:33 +00:00
|
|
|
}
|
2008-01-09 14:40:25 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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(
|
|
|
|
|
psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, 0, 0, 0, orco);
|
2008-01-09 14:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
void psys_get_dupli_path_transform(ParticleSimulationData *sim,
|
|
|
|
|
ParticleData *pa,
|
|
|
|
|
ChildParticle *cpa,
|
|
|
|
|
ParticleCacheKey *cache,
|
|
|
|
|
float mat[4][4],
|
|
|
|
|
float *scale)
|
2008-01-09 14:40:25 +00:00
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
Object *ob = sim->ob;
|
|
|
|
|
ParticleSystem *psys = sim->psys;
|
|
|
|
|
ParticleSystemModifierData *psmd = sim->psmd;
|
2011-07-10 17:30:31 +00:00
|
|
|
float loc[3], nor[3], vec[3], side[3], len;
|
|
|
|
|
float xvec[3] = {-1.0, 0.0, 0.0}, nmat[3][3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
sub_v3_v3v3(vec, (cache + cache->segments)->co, cache->co);
|
2012-05-06 15:15:33 +00:00
|
|
|
len = normalize_v3(vec);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pa == NULL && psys->part->childflat != PART_CHILD_FACES) {
|
2011-07-10 17:30:31 +00:00
|
|
|
pa = psys->particles + cpa->pa[0];
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pa) {
|
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(psmd,
|
|
|
|
|
sim->psys->part->from,
|
|
|
|
|
pa->num,
|
|
|
|
|
pa->num_dmcache,
|
|
|
|
|
pa->fuv,
|
|
|
|
|
pa->foffset,
|
|
|
|
|
loc,
|
|
|
|
|
nor,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0);
|
2019-04-22 09:39:35 +10: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(psmd,
|
|
|
|
|
PART_FROM_FACE,
|
|
|
|
|
cpa->num,
|
|
|
|
|
DMCACHE_ISCHILD,
|
|
|
|
|
cpa->fuv,
|
|
|
|
|
cpa->foffset,
|
|
|
|
|
loc,
|
|
|
|
|
nor,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
0);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part->rotmode == PART_ROT_VEL) {
|
2014-10-30 12:13:00 +01:00
|
|
|
transpose_m3_m4(nmat, ob->imat);
|
2011-10-16 16:14:36 +00:00
|
|
|
mul_m3_v3(nmat, nor);
|
|
|
|
|
normalize_v3(nor);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-16 16:14:36 +00:00
|
|
|
/* make sure that we get a proper side vector */
|
2015-01-31 17:23:30 +11:00
|
|
|
if (fabsf(dot_v3v3(nor, vec)) > 0.999999f) {
|
|
|
|
|
if (fabsf(dot_v3v3(nor, xvec)) > 0.999999f) {
|
2011-10-16 16:14:36 +00:00
|
|
|
nor[0] = 0.0f;
|
|
|
|
|
nor[1] = 1.0f;
|
|
|
|
|
nor[2] = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
nor[0] = 1.0f;
|
|
|
|
|
nor[1] = 0.0f;
|
|
|
|
|
nor[2] = 0.0f;
|
2011-07-10 17:30:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-10-16 16:14:36 +00:00
|
|
|
cross_v3_v3v3(side, nor, vec);
|
|
|
|
|
normalize_v3(side);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-16 16:14:36 +00:00
|
|
|
/* rotate side vector around vec */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->part->phasefac != 0) {
|
2011-10-16 16:14:36 +00:00
|
|
|
float q_phase[4];
|
|
|
|
|
float phasefac = psys->part->phasefac;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (psys->part->randphasefac != 0.0f) {
|
2015-04-13 19:16:40 +05:00
|
|
|
phasefac += psys->part->randphasefac * psys_frand(psys, (pa - psys->particles) + 20);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
axis_angle_to_quat(q_phase, vec, phasefac * (float)M_PI);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-16 16:14:36 +00:00
|
|
|
mul_qt_v3(q_phase, side);
|
2011-07-10 17:30:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-16 16:14:36 +00:00
|
|
|
cross_v3_v3v3(nor, vec, side);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-16 16:14:36 +00:00
|
|
|
unit_m4(mat);
|
2011-11-06 14:00:55 +00:00
|
|
|
copy_v3_v3(mat[0], vec);
|
|
|
|
|
copy_v3_v3(mat[1], side);
|
|
|
|
|
copy_v3_v3(mat[2], nor);
|
2011-10-16 16:14:36 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
quat_to_mat4(mat, pa->state.rot);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
*scale = len;
|
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
|
|
|
void psys_apply_hair_lattice(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
|
2011-12-30 07:55:15 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ParticleSimulationData sim = {0};
|
2018-04-06 12:07:27 +02:00
|
|
|
sim.depsgraph = depsgraph;
|
2012-05-06 15:15:33 +00:00
|
|
|
sim.scene = scene;
|
|
|
|
|
sim.ob = ob;
|
|
|
|
|
sim.psys = psys;
|
|
|
|
|
sim.psmd = psys_get_modifier(ob, psys);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
if (psys->lattice_deform_data) {
|
2010-09-07 05:47:34 +00:00
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
HairKey *hkey;
|
|
|
|
|
int p, h;
|
|
|
|
|
float hairmat[4][4], imat[4][4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (p = 0; p < psys->totpart; p++, pa++) {
|
2019-06-21 11:49:43 +02:00
|
|
|
psys_mat_hair_to_global(sim.ob, sim.psmd->mesh_final, psys->part->from, pa, hairmat);
|
2010-09-07 05:47:34 +00:00
|
|
|
invert_m4_m4(imat, hairmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
hkey = pa->hair;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (h = 0; h < pa->totkey; h++, hkey++) {
|
2010-09-07 05:47:34 +00:00
|
|
|
mul_m4_v3(hairmat, hkey->co);
|
2020-06-13 15:41:34 +10:00
|
|
|
BKE_lattice_deform_data_eval_co(
|
|
|
|
|
psys->lattice_deform_data, hkey->co, psys->lattice_strength);
|
2010-09-07 05:47:34 +00:00
|
|
|
mul_m4_v3(imat, hkey->co);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-13 15:41:34 +10:00
|
|
|
BKE_lattice_deform_data_destroy(psys->lattice_deform_data);
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
/* protect the applied shape */
|
|
|
|
|
psys->flag |= PSYS_EDITED;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-09 16:23:47 +02:00
|
|
|
|
|
|
|
|
/* Draw Engine */
|
2020-10-09 07:25:43 +02:00
|
|
|
void (*BKE_particle_batch_cache_dirty_tag_cb)(ParticleSystem *psys, int mode) = NULL;
|
2017-05-09 16:23:47 +02:00
|
|
|
void (*BKE_particle_batch_cache_free_cb)(ParticleSystem *psys) = NULL;
|
|
|
|
|
|
2020-10-09 07:25:43 +02:00
|
|
|
void BKE_particle_batch_cache_dirty_tag(ParticleSystem *psys, int mode)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
|
|
|
|
if (psys->batch_cache) {
|
2018-08-23 10:14:29 -03:00
|
|
|
BKE_particle_batch_cache_dirty_tag_cb(psys, mode);
|
2017-05-09 16:23:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void BKE_particle_batch_cache_free(ParticleSystem *psys)
|
|
|
|
|
{
|
|
|
|
|
if (psys->batch_cache) {
|
|
|
|
|
BKE_particle_batch_cache_free_cb(psys);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-06 15:58:27 +01:00
|
|
|
|
|
|
|
|
void BKE_particle_system_blend_write(BlendWriter *writer, ListBase *particles)
|
|
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
|
|
|
|
|
BLO_write_struct(writer, ParticleSystem, psys);
|
|
|
|
|
|
|
|
|
|
if (psys->particles) {
|
|
|
|
|
BLO_write_struct_array(writer, ParticleData, psys->totpart, psys->particles);
|
|
|
|
|
|
|
|
|
|
if (psys->particles->hair) {
|
|
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < psys->totpart; a++, pa++) {
|
|
|
|
|
BLO_write_struct_array(writer, HairKey, pa->totkey, pa->hair);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->particles->boid && (psys->part->phystype == PART_PHYS_BOIDS)) {
|
|
|
|
|
BLO_write_struct_array(writer, BoidParticle, psys->totpart, psys->particles->boid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->part->fluid && (psys->part->phystype == PART_PHYS_FLUID) &&
|
|
|
|
|
(psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) {
|
|
|
|
|
BLO_write_struct_array(
|
|
|
|
|
writer, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
|
|
|
|
|
BLO_write_struct(writer, ParticleTarget, pt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->child) {
|
|
|
|
|
BLO_write_struct_array(writer, ChildParticle, psys->totchild, psys->child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->clmd) {
|
|
|
|
|
BLO_write_struct(writer, ClothModifierData, psys->clmd);
|
|
|
|
|
BLO_write_struct(writer, ClothSimSettings, psys->clmd->sim_parms);
|
|
|
|
|
BLO_write_struct(writer, ClothCollSettings, psys->clmd->coll_parms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_ptcache_blend_write(writer, &psys->ptcaches);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_particle_system_blend_read_data(BlendDataReader *reader, ListBase *particles)
|
|
|
|
|
{
|
|
|
|
|
ParticleData *pa;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
|
|
|
|
|
BLO_read_data_address(reader, &psys->particles);
|
|
|
|
|
|
|
|
|
|
if (psys->particles && psys->particles->hair) {
|
|
|
|
|
for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
|
|
|
|
|
BLO_read_data_address(reader, &pa->hair);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->particles && psys->particles->keys) {
|
|
|
|
|
for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
|
|
|
|
|
pa->keys = NULL;
|
|
|
|
|
pa->totkey = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
psys->flag &= ~PSYS_KEYED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->particles && psys->particles->boid) {
|
|
|
|
|
pa = psys->particles;
|
|
|
|
|
BLO_read_data_address(reader, &pa->boid);
|
|
|
|
|
|
|
|
|
|
/* This is purely runtime data, but still can be an issue if left dangling. */
|
|
|
|
|
pa->boid->ground = NULL;
|
|
|
|
|
|
|
|
|
|
for (a = 1, pa++; a < psys->totpart; a++, pa++) {
|
|
|
|
|
pa->boid = (pa - 1)->boid + 1;
|
|
|
|
|
pa->boid->ground = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (psys->particles) {
|
|
|
|
|
for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
|
|
|
|
|
pa->boid = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &psys->fluid_springs);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &psys->child);
|
|
|
|
|
psys->effectors = NULL;
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, &psys->targets);
|
|
|
|
|
|
|
|
|
|
psys->edit = NULL;
|
|
|
|
|
psys->free_edit = NULL;
|
|
|
|
|
psys->pathcache = NULL;
|
|
|
|
|
psys->childcache = NULL;
|
|
|
|
|
BLI_listbase_clear(&psys->pathcachebufs);
|
|
|
|
|
BLI_listbase_clear(&psys->childcachebufs);
|
|
|
|
|
psys->pdd = NULL;
|
|
|
|
|
|
|
|
|
|
if (psys->clmd) {
|
|
|
|
|
BLO_read_data_address(reader, &psys->clmd);
|
|
|
|
|
psys->clmd->clothObject = NULL;
|
|
|
|
|
psys->clmd->hairdata = NULL;
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &psys->clmd->sim_parms);
|
|
|
|
|
BLO_read_data_address(reader, &psys->clmd->coll_parms);
|
|
|
|
|
|
|
|
|
|
if (psys->clmd->sim_parms) {
|
|
|
|
|
psys->clmd->sim_parms->effector_weights = NULL;
|
|
|
|
|
if (psys->clmd->sim_parms->presets > 10) {
|
|
|
|
|
psys->clmd->sim_parms->presets = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
psys->hair_in_mesh = psys->hair_out_mesh = NULL;
|
|
|
|
|
psys->clmd->solver_result = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_ptcache_blend_read_data(reader, &psys->ptcaches, &psys->pointcache, 0);
|
|
|
|
|
if (psys->clmd) {
|
|
|
|
|
psys->clmd->point_cache = psys->pointcache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
psys->tree = NULL;
|
|
|
|
|
psys->bvhtree = NULL;
|
|
|
|
|
|
|
|
|
|
psys->orig_psys = NULL;
|
|
|
|
|
psys->batch_cache = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_particle_system_blend_read_lib(BlendLibReader *reader,
|
|
|
|
|
Object *ob,
|
|
|
|
|
ID *id,
|
|
|
|
|
ListBase *particles)
|
|
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH_MUTABLE (ParticleSystem *, psys, particles) {
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &psys->part);
|
|
|
|
|
if (psys->part) {
|
|
|
|
|
LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &pt->ob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &psys->parent);
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &psys->target_ob);
|
|
|
|
|
|
|
|
|
|
if (psys->clmd) {
|
|
|
|
|
/* XXX - from reading existing code this seems correct but intended usage of
|
|
|
|
|
* pointcache /w cloth should be added in 'ParticleSystem' - campbell */
|
|
|
|
|
psys->clmd->point_cache = psys->pointcache;
|
|
|
|
|
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
|
|
|
|
|
BLO_read_id_address(reader, id->lib, &psys->clmd->coll_parms->group);
|
|
|
|
|
psys->clmd->modifier.error = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* particle modifier must be removed before particle system */
|
|
|
|
|
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
|
2020-12-02 13:35:07 +01:00
|
|
|
BKE_modifier_remove_from_list(ob, (ModifierData *)psmd);
|
2020-11-06 15:58:27 +01:00
|
|
|
BKE_modifier_free((ModifierData *)psmd);
|
|
|
|
|
|
|
|
|
|
BLI_remlink(particles, psys);
|
|
|
|
|
MEM_freeN(psys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|